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