src/sync.c
author Volker Birk <vb@pep.foundation>
Sun, 31 Jul 2016 19:38:23 +0200
branchkeysync
changeset 951 dec407deb10e
parent 690 3ae86b68fdfe
child 976 75cbd583a894
permissions -rw-r--r--
...
     1 #include "pEp_internal.h"
     2 
     3 #include <memory.h>
     4 #include <assert.h>
     5 
     6 #include "../asn.1/DeviceGroup-Protocol.h"
     7 
     8 
     9 DYNAMIC_API PEP_STATUS register_sync_callbacks(
    10         PEP_SESSION session,
    11         void *obj,
    12         messageToSend_t messageToSend,
    13         showHandshake_t showHandshake
    14     )
    15 {
    16     session->sync_obj = obj;
    17     session->messageToSend = messageToSend;
    18     session->showHandshake = showHandshake;
    19 
    20     return PEP_STATUS_OK;
    21 }
    22 
    23 DYNAMIC_API void unregister_sync_callbacks(PEP_SESSION session) {
    24     session->sync_obj = NULL;
    25     session->messageToSend = NULL;
    26     session->showHandshake = NULL;
    27 }
    28 
    29 DYNAMIC_API PEP_STATUS deliverHandshakeResult(
    30         PEP_SESSION session,
    31         sync_handshake_result result
    32     )
    33 {
    34     assert(session);
    35     if (!session)
    36         return PEP_ILLEGAL_VALUE;
    37 
    38     switch (result) {
    39         case SYNC_HANDSHAKE_CANCEL:
    40             fsm_DeviceState_inject(session, Cancel, NULL, 0);
    41             break;
    42         case SYNC_HANDSHAKE_ACCEPTED:
    43             fsm_DeviceState_inject(session, HandshakeAccepted, NULL, 0);
    44             break;
    45         case SYNC_HANDSHAKE_REJECTED:
    46             fsm_DeviceState_inject(session, HandshakeRejected, NULL, 0);
    47             break;
    48         default:
    49             return PEP_ILLEGAL_VALUE;
    50     }
    51 
    52     return PEP_STATUS_OK;
    53 }
    54