src/sync.c
author Volker Birk <vb@pep-project.org>
Thu, 12 May 2016 11:21:57 +0200
changeset 609 a22a400611ca
parent 604 ba04c2bd81a1
child 679 2210805af158
permissions -rw-r--r--
sync handshake dialog async
     1 #include "pEp_internal.h"
     2 
     3 #include <memory.h>
     4 #include <assert.h>
     5 
     6 #include "sync_fsm.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 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);
    41             break;
    42         case SYNC_HANDSHAKE_ACCEPTED:
    43             fsm_DeviceState_inject(session, HandshakeAccepted);
    44             break;
    45         case SYNC_HANDSHAKE_REJECTED:
    46             fsm_DeviceState_inject(session, HandshakeRejected);
    47             break;
    48         default:
    49             return PEP_ILLEGAL_VALUE;
    50     }
    51 
    52     return PEP_STATUS_OK;
    53 }
    54