src/sync.h
author Volker Birk <vb@pep.foundation>
Thu, 11 Aug 2016 12:39:51 +0200
branchkeysync
changeset 1003 e5eef6e5b153
parent 991 b230b6418b52
child 1043 f786ee22e281
permissions -rw-r--r--
avoiding name clash with Python
vb@572
     1
#pragma once
vb@572
     2
vb@572
     3
#include "message.h"
vb@690
     4
#include "sync_fsm.h"
vb@572
     5
vb@572
     6
vb@572
     7
// this module is for being used WITHOUT the Transport API in transport.h
vb@572
     8
// DO NOT USE IT WHEN USING Transport API!
vb@572
     9
vb@572
    10
vb@572
    11
#ifdef __cplusplus
vb@572
    12
extern "C" {
vb@572
    13
#endif
vb@572
    14
vb@597
    15
// messageToSend() - send a beacon message
vb@572
    16
//
vb@572
    17
//  parameters:
vb@599
    18
//      obj (in)        object handle (implementation defined)
vb@598
    19
//      msg (in)        message struct with message to send
vb@572
    20
//
vb@572
    21
//  return value:
vb@604
    22
//      PEP_STATUS_OK or any other value on error
vb@991
    23
//
vb@991
    24
//  caveat:
vb@991
    25
//      the ownership of msg goes to the callee
vb@572
    26
vb@991
    27
typedef PEP_STATUS (*messageToSend_t)(void *obj, message *msg);
vb@572
    28
vb@572
    29
vb@572
    30
typedef enum _sync_handshake_result {
vb@572
    31
    SYNC_HANDSHAKE_CANCEL = -1,
vb@572
    32
    SYNC_HANDSHAKE_ACCEPTED = 0,
vb@572
    33
    SYNC_HANDSHAKE_REJECTED = 1
vb@572
    34
} sync_handshake_result;
vb@572
    35
vb@609
    36
// showHandshake() - do a handshake by showing the handshake dialog
vb@572
    37
//
vb@572
    38
//  parameters:
vb@599
    39
//      obj (in)        object handle (implementation defined)
vb@1003
    40
//      me (in)         own identity
vb@572
    41
//      partner (in)    identity of partner
vb@572
    42
//
vb@572
    43
//  return value:
vb@604
    44
//      PEP_STATUS_OK or any other value on error
vb@991
    45
//
vb@991
    46
//  caveat:
vb@991
    47
//      ownership of self and partner go to the callee
vb@572
    48
vb@604
    49
typedef PEP_STATUS (*showHandshake_t)(
vb@599
    50
        void *obj,
vb@1003
    51
        pEp_identity *me,
vb@991
    52
        pEp_identity *partner
vb@609
    53
    );
vb@609
    54
vb@609
    55
vb@609
    56
// deliverHandshakeResult() - give the result of the handshake dialog
vb@609
    57
//
vb@609
    58
//  parameters:
vb@609
    59
//      session (in)    session handle
vb@609
    60
//      result (in)     handshake result
vb@609
    61
vb@679
    62
DYNAMIC_API PEP_STATUS deliverHandshakeResult(
vb@609
    63
        PEP_SESSION session,
vb@609
    64
        sync_handshake_result result
vb@572
    65
    );
vb@572
    66
vb@572
    67
vb@572
    68
// register_sync_callbacks() - register adapter's callbacks
vb@572
    69
//
vb@572
    70
//  parameters:
vb@599
    71
//      session (in)                session where to store obj handle
vb@599
    72
//      obj (in)                    object handle (implementation defined)
vb@599
    73
//      messageToSend (in)          callback for sending message
vb@572
    74
//      showHandshake (in)          callback for doing the handshake
vb@572
    75
//
vb@572
    76
//  return value:
vb@572
    77
//      PEP_STATUS_OK or any other value on errror
vb@573
    78
//
vb@573
    79
//  caveat:
vb@573
    80
//      call that BEFORE you're using any other part of the engine
vb@572
    81
vb@572
    82
DYNAMIC_API PEP_STATUS register_sync_callbacks(
vb@599
    83
        PEP_SESSION session,
vb@599
    84
        void *obj,
vb@597
    85
        messageToSend_t messageToSend,
vb@572
    86
        showHandshake_t showHandshake
vb@572
    87
    );
vb@572
    88
vb@572
    89
vb@572
    90
// unregister_sync_callbacks() - unregister adapter's callbacks
vb@602
    91
//
vb@602
    92
//  parameters:
vb@602
    93
//      session (in)                session where to store obj handle
vb@572
    94
vb@602
    95
DYNAMIC_API void unregister_sync_callbacks(PEP_SESSION session);
vb@572
    96
vb@572
    97
vb@572
    98
#ifdef __cplusplus
vb@572
    99
}
vb@572
   100
#endif
vb@572
   101