src/sync.h
author Volker Birk <vb@pep-project.org>
Tue, 03 May 2016 15:57:12 +0200
changeset 573 28b0d3154f0f
parent 572 3077e2489dfe
child 574 3c21749a79a6
permissions -rw-r--r--
no handle needed
vb@572
     1
#pragma once
vb@572
     2
vb@572
     3
#include "message.h"
vb@572
     4
vb@572
     5
vb@572
     6
// this module is for being used WITHOUT the Transport API in transport.h
vb@572
     7
// DO NOT USE IT WHEN USING Transport API!
vb@572
     8
vb@572
     9
vb@572
    10
#ifdef __cplusplus
vb@572
    11
extern "C" {
vb@572
    12
#endif
vb@572
    13
vb@572
    14
// sendBeacon() - send a beacon message
vb@572
    15
//
vb@572
    16
//  parameters:
vb@572
    17
//      beacon (in)     message struct with beacon message to send
vb@572
    18
//
vb@572
    19
//  return value:
vb@572
    20
//      must return PEP_STATUS_OK or any other value on error
vb@572
    21
vb@572
    22
typedef PEP_STATUS (*sendBeacon_t)(message beacon);
vb@572
    23
vb@572
    24
vb@572
    25
// sendHandshakeRequest() - send a handshake request message
vb@572
    26
//
vb@572
    27
//  parameters:
vb@572
    28
//      request (in)    message struct with beacon message to send
vb@572
    29
//
vb@572
    30
//  return value:
vb@572
    31
//      must return PEP_STATUS_OK or any other value on error
vb@572
    32
vb@572
    33
typedef PEP_STATUS (*sendHandshakeRequest_t)(message request);
vb@572
    34
vb@572
    35
vb@572
    36
typedef enum _sync_handshake_result {
vb@572
    37
    SYNC_HANDSHAKE_CANCEL = -1,
vb@572
    38
    SYNC_HANDSHAKE_ACCEPTED = 0,
vb@572
    39
    SYNC_HANDSHAKE_REJECTED = 1
vb@572
    40
} sync_handshake_result;
vb@572
    41
vb@572
    42
// showHandshake() - do a handshake and deliver the result
vb@572
    43
//
vb@572
    44
//  parameters:
vb@572
    45
//      self (in)       own identity
vb@572
    46
//      partner (in)    identity of partner
vb@572
    47
//
vb@572
    48
//  return value:
vb@572
    49
//      result of handshake
vb@572
    50
vb@572
    51
typedef sync_handshake_result (*showHandshake_t)(
vb@572
    52
        pEp_identity self,
vb@572
    53
        pEp_identity partner
vb@572
    54
    );
vb@572
    55
vb@572
    56
vb@572
    57
// register_sync_callbacks() - register adapter's callbacks
vb@572
    58
//
vb@572
    59
//  parameters:
vb@572
    60
//      sendBeacon (in)             callback for sending beacon
vb@572
    61
//      sendHandshakeRequest (in)   callback for sending handshake request
vb@572
    62
//      showHandshake (in)          callback for doing the handshake
vb@572
    63
//
vb@572
    64
//  return value:
vb@572
    65
//      PEP_STATUS_OK or any other value on errror
vb@573
    66
//
vb@573
    67
//  caveat:
vb@573
    68
//      call that BEFORE you're using any other part of the engine
vb@572
    69
vb@572
    70
DYNAMIC_API PEP_STATUS register_sync_callbacks(
vb@572
    71
        sendBeacon_t sendBeacon,
vb@572
    72
        sendHandshakeRequest_t sendHandshakeRequest,
vb@572
    73
        showHandshake_t showHandshake
vb@572
    74
    );
vb@572
    75
vb@572
    76
vb@572
    77
// unregister_sync_callbacks() - unregister adapter's callbacks
vb@572
    78
vb@573
    79
DYNAMIC_API void unregister_sync_callbacks();
vb@572
    80
vb@572
    81
vb@572
    82
#ifdef __cplusplus
vb@572
    83
}
vb@572
    84
#endif
vb@572
    85