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