src/sync.h
author Volker Birk <vb@pep-project.org>
Wed, 11 May 2016 16:25:19 +0200
changeset 598 99a445d62317
parent 597 560c0caf14ef
child 599 d2a023827e42
permissions -rw-r--r--
nicer
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@597
    14
// messageToSend() - send a beacon message
vb@572
    15
//
vb@572
    16
//  parameters:
vb@598
    17
//      msg (in)        message struct with 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@598
    22
typedef PEP_STATUS (*messageToSend_t)(const message *msg);
vb@572
    23
vb@572
    24
vb@572
    25
typedef enum _sync_handshake_result {
vb@572
    26
    SYNC_HANDSHAKE_CANCEL = -1,
vb@572
    27
    SYNC_HANDSHAKE_ACCEPTED = 0,
vb@572
    28
    SYNC_HANDSHAKE_REJECTED = 1
vb@572
    29
} sync_handshake_result;
vb@572
    30
vb@572
    31
// showHandshake() - do a handshake and deliver the result
vb@572
    32
//
vb@572
    33
//  parameters:
vb@572
    34
//      self (in)       own identity
vb@572
    35
//      partner (in)    identity of partner
vb@572
    36
//
vb@572
    37
//  return value:
vb@572
    38
//      result of handshake
vb@572
    39
vb@572
    40
typedef sync_handshake_result (*showHandshake_t)(
vb@598
    41
        const pEp_identity *self,
vb@598
    42
        const pEp_identity *partner
vb@572
    43
    );
vb@572
    44
vb@572
    45
vb@572
    46
// register_sync_callbacks() - register adapter's callbacks
vb@572
    47
//
vb@572
    48
//  parameters:
vb@597
    49
//      messageToSend (in)             callback for sending beacon
vb@572
    50
//      showHandshake (in)          callback for doing the handshake
vb@572
    51
//
vb@572
    52
//  return value:
vb@572
    53
//      PEP_STATUS_OK or any other value on errror
vb@573
    54
//
vb@573
    55
//  caveat:
vb@573
    56
//      call that BEFORE you're using any other part of the engine
vb@572
    57
vb@572
    58
DYNAMIC_API PEP_STATUS register_sync_callbacks(
vb@597
    59
        messageToSend_t messageToSend,
vb@572
    60
        showHandshake_t showHandshake
vb@572
    61
    );
vb@572
    62
vb@572
    63
vb@572
    64
// unregister_sync_callbacks() - unregister adapter's callbacks
vb@572
    65
vb@573
    66
DYNAMIC_API void unregister_sync_callbacks();
vb@572
    67
vb@572
    68
vb@572
    69
#ifdef __cplusplus
vb@572
    70
}
vb@572
    71
#endif
vb@572
    72