1 // This file is under GNU General Public License 3.0
15 typedef enum _sync_handshake_signal {
16 SYNC_NOTIFY_UNDEFINED = 0,
18 // request show handshake dialog
19 SYNC_NOTIFY_INIT_ADD_OUR_DEVICE = 1,
20 SYNC_NOTIFY_INIT_ADD_OTHER_DEVICE = 2,
21 SYNC_NOTIFY_INIT_FORM_GROUP = 3,
22 // SYNC_NOTIFY_INIT_MOVE_OUR_DEVICE = 4,
24 // handshake process timed out
25 SYNC_NOTIFY_TIMEOUT = 5,
27 // handshake accepted by user
28 SYNC_NOTIFY_ACCEPTED_DEVICE_ADDED = 6,
29 SYNC_NOTIFY_ACCEPTED_GROUP_CREATED = 7,
30 SYNC_NOTIFY_ACCEPTED_DEVICE_ACCEPTED = 8,
32 // handshake dialog must be closed
33 // SYNC_NOTIFY_OVERTAKEN = 9,
36 // SYNC_NOTIFY_FORMING_GROUP = 10,
38 // notification of actual group status
39 SYNC_NOTIFY_SOLE = 254,
40 SYNC_NOTIFY_IN_GROUP = 255
41 } sync_handshake_signal;
44 // notifyHandshake() - notify UI about sync handshaking process
47 // obj (in) object handle (implementation defined)
48 // me (in) own identity
49 // partner (in) identity of partner
50 // signal (in) reason of the notification
53 // PEP_STATUS_OK or any other value on error
56 // ownership of self and partner go to the callee
58 typedef PEP_STATUS (*notifyHandshake_t)(
60 pEp_identity *partner,
61 sync_handshake_signal signal
64 typedef enum _sync_handshake_result {
65 SYNC_HANDSHAKE_CANCEL = -1,
66 SYNC_HANDSHAKE_ACCEPTED = 0,
67 SYNC_HANDSHAKE_REJECTED = 1
68 } sync_handshake_result;
70 // deliverHandshakeResult() - provide the result of the handshake dialog
73 // session (in) session handle
74 // result (in) handshake result
75 // identities_sharing (in) own_identities sharing data in this group
78 // identities_sharing may be NULL; in this case all identities are sharing
80 // identities_sharing may only contain own identities
82 DYNAMIC_API PEP_STATUS deliverHandshakeResult(
84 sync_handshake_result result,
85 const identity_list *identities_sharing
89 // retrieve_next_sync_event - receive next sync event
92 // management (in) application defined; usually a locked queue
93 // threshold (in) threshold in seconds for timeout
99 // an implementation of retrieve_next_sync_event must return
100 // new_sync_timeout_event() in case of timeout
102 typedef SYNC_EVENT (*retrieve_next_sync_event_t)(void *management,
106 // register_sync_callbacks() - register adapter's callbacks
109 // session (in) session where to register callbacks
110 // management (in) application defined; usually a locked queue
111 // notifyHandshake (in) callback for doing the handshake
112 // retrieve_next_sync_event (in) callback for receiving sync event
115 // PEP_STATUS_OK or any other value on errror
118 // use this function in an adapter where you're processing the sync
121 // implement start_sync() in this adapter and provide it to the
122 // application, so it can trigger startup
124 // in case of parallelization start_sync() and register_sync_callbacks()
125 // will run in parallel
127 // do not return from start_sync() before register_sync_callbacks() was
130 // when execution of the sync state machine ends a call to
131 // unregister_sync_callbacks() is recommended
133 DYNAMIC_API PEP_STATUS register_sync_callbacks(
136 notifyHandshake_t notifyHandshake,
137 retrieve_next_sync_event_t retrieve_next_sync_event
140 DYNAMIC_API void unregister_sync_callbacks(PEP_SESSION session);
143 // do_sync_protocol() - function to be run on an extra thread
146 // session pEp session to use
147 // retrieve_next_sync_msg pointer to retrieve_next_identity() callback
148 // which returns at least a valid address field in
149 // the identity struct
150 // obj application defined sync object
153 // PEP_STATUS_OK if thread has to terminate successfully or any other
156 DYNAMIC_API PEP_STATUS do_sync_protocol(
162 // do_sync_protocol_step() - function for single threaded implementations
165 // session pEp session to use
166 // retrieve_next_sync_msg pointer to retrieve_next_identity() callback
167 // which returns at least a valid address field in
168 // the identity struct
169 // obj application defined sync object
170 // event Sync event to process
172 DYNAMIC_API PEP_STATUS do_sync_protocol_step(
179 // is_sync_thread() - determine if this is sync thread's session
182 // session (in) pEp session to test
185 // true if this is sync thread's session, false otherwise
187 DYNAMIC_API bool is_sync_thread(PEP_SESSION session);
190 // new_sync_timeout_event() - create a Sync timeout event
193 // returns a new Sync timeout event, or NULL on failure
195 DYNAMIC_API SYNC_EVENT new_sync_timeout_event();
198 // enter_device_group() - enter a device group
201 // session (in) pEp session
202 // identities_sharing (in) own_identities sharing data in this group
205 // identities_sharing may be NULL; in this case all identities are sharing
207 // identities_sharing may only contain own identities
209 // this call can be repeated if sharing information changes
211 DYNAMIC_API PEP_STATUS enter_device_group(
213 const identity_list *identities_sharing
217 // disable_sync() - leave a device group and shutdown sync
220 // session pEp session
222 PEP_STATUS disable_sync(PEP_SESSION session);
225 // leave_device_group() - Issue a group key reset request and
226 // leave the device group, shutting down sync
229 // session pEp session
231 DYNAMIC_API PEP_STATUS leave_device_group(PEP_SESSION session);
234 // enable_identity_for_sync() - enable sync for this identity
236 // session pEp session
237 // ident own identity to enable
239 DYNAMIC_API PEP_STATUS enable_identity_for_sync(PEP_SESSION session,
240 pEp_identity *ident);
243 // disable_identity_for_sync() - disable sync for this identity
245 // session pEp session
246 // ident own identity to disable
248 DYNAMIC_API PEP_STATUS disable_identity_for_sync(PEP_SESSION session,
249 pEp_identity *ident);