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