src/sync_actions.c
author Krista Grothoff <krista@pep-project.org>
Sat, 24 Sep 2016 18:09:18 +0200
branchENGINE-27
changeset 1185 4b01328f3cf2
parent 907 8f5cca5bfa2d
child 939 ed7dfdae3031
permissions -rw-r--r--
ENGINE-27: update_identity no longer pays attention to the input identity's fpr, but pulls one from elect_pubkey.
     1 // Actions for DeviceState state machine
     2 
     3 #include <assert.h>
     4 #include "pEp_internal.h"
     5 #include "message.h"
     6 #include "sync_fsm.h"
     7 
     8 
     9 // showHandshake() - trigger the handshake dialog of the application
    10 //
    11 //  params:
    12 //      session (in)        session handle
    13 //      state (in)          state the state machine is in
    14 //      partner (in)        partner to communicate with
    15 //
    16 //  returns:
    17 //      PEP_STATUS_OK or any other value on error
    18 
    19 PEP_STATUS showHandshake(
    20         PEP_SESSION session,
    21         DeviceState_state state,
    22         const Identity partner
    23     )
    24 {
    25     PEP_STATUS status = PEP_STATUS_OK;
    26     assert(session);
    27     assert(partner);
    28     if (!(session && partner))
    29         return PEP_ILLEGAL_VALUE;
    30     assert(session->showHandshake);
    31     if (!session->showHandshake)
    32         return PEP_SYNC_NO_TRUSTWORDS_CALLBACK;
    33 
    34     pEp_identity *me = NULL;
    35     status = get_identity(session, partner->address, PEP_OWN_USERID, &me);
    36     if (status != PEP_STATUS_OK)
    37         goto error;
    38     
    39     status = session->showHandshake(session, me, partner);
    40     if (status != PEP_STATUS_OK)
    41         goto error;
    42 
    43     free_identity(me);
    44     return status;
    45 
    46 enomem:
    47     status = PEP_OUT_OF_MEMORY;
    48 error:
    49     free_identity(me);
    50     return status;
    51 }
    52 
    53 
    54 // reject() - stores rejection of partner
    55 //
    56 //  params:
    57 //      session (in)        session handle
    58 //      state (in)          state the state machine is in
    59 //      partner (in)        partner to communicate with
    60 //
    61 //  returns:
    62 //      PEP_STATUS_OK or any other value on error
    63 
    64 PEP_STATUS reject(
    65         PEP_SESSION session,
    66         DeviceState_state state,
    67         const Identity partner
    68     )
    69 {
    70     PEP_STATUS status = PEP_STATUS_OK;
    71 
    72     assert(session);
    73     assert(partner);
    74     if (!(session && partner))
    75         return PEP_ILLEGAL_VALUE;
    76 
    77     // working code
    78 
    79 
    80     return status;
    81 
    82 enomem:
    83     status = PEP_OUT_OF_MEMORY;
    84 error:
    85     // free...
    86     return status;
    87 }
    88 
    89 
    90 // storeGroupKeys() - 
    91 //
    92 //  params:
    93 //      session (in)        session handle
    94 //      state (in)          state the state machine is in
    95 //      partner (in)        partner to communicate with
    96 //
    97 //  returns:
    98 //      PEP_STATUS_OK or any other value on error
    99 
   100 PEP_STATUS storeGroupKeys(
   101         PEP_SESSION session,
   102         DeviceState_state state,
   103         const Identity partner
   104     )
   105 {
   106     PEP_STATUS status = PEP_STATUS_OK;
   107 
   108     assert(session);
   109     assert(partner);
   110     if (!(session && partner))
   111         return PEP_ILLEGAL_VALUE;
   112 
   113     // working code
   114 
   115 
   116     return status;
   117 
   118 enomem:
   119     status = PEP_OUT_OF_MEMORY;
   120 error:
   121     // free...
   122     return status;
   123 }
   124