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
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@572
     6
vb@572
     7
DYNAMIC_API PEP_STATUS register_sync_callbacks(
vb@599
     8
        PEP_SESSION session,
vb@599
     9
        void *obj,
vb@597
    10
        messageToSend_t messageToSend,
vb@572
    11
        showHandshake_t showHandshake
vb@572
    12
    )
vb@572
    13
{
vb@599
    14
    session->sync_obj = obj;
vb@604
    15
    session->messageToSend = messageToSend;
vb@604
    16
    session->showHandshake = showHandshake;
vb@572
    17
vb@572
    18
    return PEP_STATUS_OK;
vb@572
    19
}
vb@572
    20
vb@572
    21
DYNAMIC_API void unregister_sync_callbacks(PEP_SESSION session) {
vb@602
    22
    session->sync_obj = NULL;
vb@604
    23
    session->messageToSend = NULL;
vb@604
    24
    session->showHandshake = NULL;
vb@572
    25
}
vb@572
    26
vb@679
    27
DYNAMIC_API PEP_STATUS deliverHandshakeResult(
vb@609
    28
        PEP_SESSION session,
vb@609
    29
        sync_handshake_result result
vb@609
    30
    )
vb@609
    31
{
vb@609
    32
    assert(session);
vb@609
    33
    if (!session)
vb@609
    34
        return PEP_ILLEGAL_VALUE;
vb@609
    35
vb@609
    36
    switch (result) {
vb@609
    37
        case SYNC_HANDSHAKE_CANCEL:
vb@690
    38
            fsm_DeviceState_inject(session, Cancel, NULL, 0);
vb@609
    39
            break;
vb@609
    40
        case SYNC_HANDSHAKE_ACCEPTED:
vb@690
    41
            fsm_DeviceState_inject(session, HandshakeAccepted, NULL, 0);
vb@609
    42
            break;
vb@609
    43
        case SYNC_HANDSHAKE_REJECTED:
vb@690
    44
            fsm_DeviceState_inject(session, HandshakeRejected, NULL, 0);
vb@609
    45
            break;
vb@609
    46
        default:
vb@609
    47
            return PEP_ILLEGAL_VALUE;
vb@609
    48
    }
vb@609
    49
vb@609
    50
    return PEP_STATUS_OK;
vb@609
    51
}
vb@609
    52