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