aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_conversation_service.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-11-15 19:06:55 +0000
committerChristian Grothoff <christian@grothoff.org>2013-11-15 19:06:55 +0000
commitdd594a4b0a7dbc57ea49f8a797a7a412e53baa53 (patch)
tree6a651b061395ebd9370cef01f14655ff50e81a66 /src/include/gnunet_conversation_service.h
parent1c405f3fb76f509113526678dbe9a5736dfce394 (diff)
downloadgnunet-dd594a4b0a7dbc57ea49f8a797a7a412e53baa53.tar.gz
gnunet-dd594a4b0a7dbc57ea49f8a797a7a412e53baa53.zip
-towards enabling call waiting in conversation -- creates FTBFS
Diffstat (limited to 'src/include/gnunet_conversation_service.h')
-rw-r--r--src/include/gnunet_conversation_service.h244
1 files changed, 183 insertions, 61 deletions
diff --git a/src/include/gnunet_conversation_service.h b/src/include/gnunet_conversation_service.h
index 70dd013d6..b5a7fbc9a 100644
--- a/src/include/gnunet_conversation_service.h
+++ b/src/include/gnunet_conversation_service.h
@@ -37,17 +37,10 @@
37 * using a separate service; CONVERSATION is supposed to be just 37 * using a separate service; CONVERSATION is supposed to be just
38 * the "bare bones" voice service. 38 * the "bare bones" voice service.
39 * 39 *
40 * Meta data passing is supported so that advanced services
41 * can identify themselves appropriately.
42 *
43 * As this is supposed to be a "secure" service, caller ID is of 40 * As this is supposed to be a "secure" service, caller ID is of
44 * course provided as part of the basic implementation, as only the 41 * course provided as part of the basic implementation, as only the
45 * CONVERSATION service can know for sure who it is that we are 42 * CONVERSATION service can know for sure who it is that we are
46 * talking to. 43 * talking to.
47 *
48 * TODO:
49 * - call waiting
50 * - put on hold
51 */ 44 */
52#ifndef GNUNET_CONVERSATION_SERVICE_H 45#ifndef GNUNET_CONVERSATION_SERVICE_H
53#define GNUNET_CONVERSATION_SERVICE_H 46#define GNUNET_CONVERSATION_SERVICE_H
@@ -70,8 +63,18 @@ extern "C"
70/** 63/**
71 * Version of the conversation API. 64 * Version of the conversation API.
72 */ 65 */
73#define GNUNET_CONVERSATION_VERSION 0x00000002 66#define GNUNET_CONVERSATION_VERSION 0x00000003
74 67
68/**
69 * Handle to identify a particular caller. A caller is an entity that
70 * initiate a call to a phone. This struct identifies the caller to
71 * the user operating the phone. The entity that initiated the call
72 * will have a `struct GNUNET_CONVERSATION_Call`.
73 */
74struct GNUNET_CONVERSATION_Caller;
75
76
77GNUNET_NETWORK_STRUCT_BEGIN
75 78
76/** 79/**
77 * A phone record specifies which peer is hosting a given user and 80 * A phone record specifies which peer is hosting a given user and
@@ -100,67 +103,77 @@ struct GNUNET_CONVERSATION_PhoneRecord
100 103
101}; 104};
102 105
106GNUNET_NETWORK_STRUCT_END
103 107
104/** 108/**
105 * Information about the current status of a call. Each call 109 * Information about active callers to a phone.
106 * progresses from ring over ready to terminated. Steps may
107 * be skipped.
108 */ 110 */
109enum GNUNET_CONVERSATION_EventCode 111enum GNUNET_CONVERSATION_PhoneEventCode
110{ 112{
111 /** 113 /**
112 * The phone is ringing, caller ID is provided in the varargs as 114 * We are the callee and the phone is ringing.
113 * a `const char *`. The caller ID will be a GNS name. 115 * We should accept the call or hang up.
114 */ 116 */
115 GNUNET_CONVERSATION_EC_RING, 117 GNUNET_CONVERSATION_EC_PHONE_RING,
116 118
117 /** 119 /**
118 * We are the caller and are now ringing the other party. 120 * The conversation was terminated by the caller.
119 * The varargs will be empty. 121 * We must no longer use the caller's handle.
120 */ 122 */
121 GNUNET_CONVERSATION_EC_RINGING, 123 GNUNET_CONVERSATION_EC_PHONE_HUNG_UP
122 124
123 /** 125};
124 * We are ready to talk, metadata about the call may be supplied 126
125 * as a `const char *` in the varargs. 127
126 */ 128/**
127 GNUNET_CONVERSATION_EC_READY, 129 * Function called with an event emitted by a phone.
130 *
131 * @param cls closure
132 * @param code type of the event
133 * @param caller handle for the caller
134 * @param caller_id name of the caller in GNS
135 */
136typedef void (*GNUNET_CONVERSATION_PhoneEventHandler)(void *cls,
137 enum GNUNET_CONVERSATION_PhoneEventCode code,
138 struct GNUNET_CONVERSATION_Caller *caller,
139 const char *caller_id);
128 140
129 /** 141
130 * We failed to locate a phone record in GNS. After this invocation, 142/**
131 * the respective call handle will be automatically destroyed and the 143 * Information about the current status of a call. Each call
132 * client must no longer call #GNUNET_CONVERSATION_call_stop. 144 * progresses from ring over ready to terminated. Steps may
133 */ 145 * be skipped.
134 GNUNET_CONVERSATION_EC_GNS_FAIL, 146 */
147enum GNUNET_CONVERSATION_CallerEventCode
148{
135 149
136 /** 150 /**
137 * The phone is busy. Varargs will be empty. After this invocation, 151 * We are the callee and the caller suspended the call. Note that
138 * the respective call handle will be automatically destroyed and the 152 * both sides can independently suspend and resume calls; a call is
139 * client must no longer call #GNUNET_CONVERSATION_call_stop. 153 * only "working" of both sides are active.
140 */ 154 */
141 GNUNET_CONVERSATION_EC_BUSY, 155 GNUNET_CONVERSATION_EC_CALLER_SUSPEND,
142 156
143 /** 157 /**
144 * The conversation was terminated, a reason may be supplied as a 158 * We are the callee and the caller resumed the call. Note that
145 * `const char *` in the varargs. After this invocation, the 159 * both sides can independently suspend and resume calls; a call is
146 * respective call handle will be automatically destroyed and the 160 * only "working" of both sides are active.
147 * client must no longer call #GNUNET_CONVERSATION_call_stop.
148 */ 161 */
149 GNUNET_CONVERSATION_EC_TERMINATED 162 GNUNET_CONVERSATION_EC_CALLER_RESUME
150 163
151}; 164};
152 165
153 166
154/** 167/**
155 * Function called with an event emitted by a phone. 168 * Function called with an event emitted by a caller.
169 * These events are only generated after the phone is
170 * picked up.
156 * 171 *
157 * @param cls closure 172 * @param cls closure
158 * @param code type of the event on the phone 173 * @param code type of the event for this caller
159 * @param ... additional information, depends on @a code
160 */ 174 */
161typedef void (*GNUNET_CONVERSATION_EventHandler)(void *cls, 175typedef void (*GNUNET_CONVERSATION_CallerEventHandler)(void *cls,
162 enum GNUNET_CONVERSATION_EventCode code, 176 enum GNUNET_CONVERSATION_CallerEventCode code);
163 ...);
164 177
165 178
166/** 179/**
@@ -189,7 +202,7 @@ struct GNUNET_CONVERSATION_Phone;
189struct GNUNET_CONVERSATION_Phone * 202struct GNUNET_CONVERSATION_Phone *
190GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg, 203GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
191 const struct GNUNET_IDENTITY_Ego *ego, 204 const struct GNUNET_IDENTITY_Ego *ego,
192 GNUNET_CONVERSATION_EventHandler event_handler, 205 GNUNET_CONVERSATION_PhoneEventHandler event_handler,
193 void *event_handler_cls); 206 void *event_handler_cls);
194 207
195 208
@@ -207,31 +220,55 @@ GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone,
207 220
208 221
209/** 222/**
210 * Picks up a (ringing) phone. This will connect the speaker 223 * Picks up a (ringing) phone call. This will connect the speaker
211 * to the microphone of the other party, and vice versa. 224 * to the microphone of the other party, and vice versa.
212 * 225 *
213 * @param phone phone to pick up 226 * @param caller handle that identifies which caller should be answered
214 * @param metadata meta data to give to the other user about the pick up event 227 * @param event_handler how to notify about events by the caller
228 * @param event_handler_cls closure for @a event_handler
229 * @param speaker speaker to use
230 * @param mic microphone to use
231 */
232void
233GNUNET_CONVERSATION_caller_pick_up (struct GNUNET_CONVERSATION_Caller *caller,
234 GNUNET_CONVERSATION_CallerEventHandler event_handler,
235 void *event_handler_cls,
236 struct GNUNET_SPEAKER_Handle *speaker,
237 struct GNUNET_MICROPHONE_Handle *mic);
238
239
240/**
241 * Pause conversation of an active call. This will disconnect the speaker
242 * and the microphone. The call can later be resumed with
243 * #GNUNET_CONVERSATION_caller_resume.
244 *
245 * @param phone phone to pause
246 */
247void
248GNUNET_CONVERSATION_caller_suspend (struct GNUNET_CONVERSATION_Caller *caller);
249
250
251/**
252 * Resume suspended conversation of a phone.
253 *
254 * @param phone phone to resume
215 * @param speaker speaker to use 255 * @param speaker speaker to use
216 * @param mic microphone to use 256 * @param mic microphone to use
217 */ 257 */
218void 258void
219GNUNET_CONVERSATION_phone_pick_up (struct GNUNET_CONVERSATION_Phone *phone, 259GNUNET_CONVERSATION_caller_resume (struct GNUNET_CONVERSATION_Caller *caller,
220 const char *metadata,
221 struct GNUNET_SPEAKER_Handle *speaker, 260 struct GNUNET_SPEAKER_Handle *speaker,
222 struct GNUNET_MICROPHONE_Handle *mic); 261 struct GNUNET_MICROPHONE_Handle *mic);
223 262
224 263
225/** 264/**
226 * Hang up up a (possibly ringing) phone. This will notify the other 265 * Hang up up a (possibly ringing or paused) phone. This will notify
227 * party that we are no longer interested in talking with them. 266 * the caller that we are no longer interested in talking with them.
228 * 267 *
229 * @param phone phone to pick up 268 * @param caller who should we hang up on
230 * @param reason text we give to the other party about why we terminated the conversation
231 */ 269 */
232void 270void
233GNUNET_CONVERSATION_phone_hang_up (struct GNUNET_CONVERSATION_Phone *phone, 271GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller);
234 const char *reason);
235 272
236 273
237/** 274/**
@@ -243,6 +280,8 @@ void
243GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone); 280GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone);
244 281
245 282
283/* *********************** CALL API ************************ */
284
246/** 285/**
247 * Handle for an outgoing call. 286 * Handle for an outgoing call.
248 */ 287 */
@@ -250,6 +289,66 @@ struct GNUNET_CONVERSATION_Call;
250 289
251 290
252/** 291/**
292 * Information about the current status of a call.
293 */
294enum GNUNET_CONVERSATION_CallEventCode
295{
296 /**
297 * We are the caller and are now ringing the other party (GNS lookup
298 * succeeded).
299 */
300 GNUNET_CONVERSATION_EC_CALL_RINGING,
301
302 /**
303 * We are the caller and are now ready to talk as the callee picked up.
304 */
305 GNUNET_CONVERSATION_EC_CALL_PICKED_UP,
306
307 /**
308 * We are the caller and failed to locate a phone record in GNS.
309 * After this invocation, the respective call handle will be
310 * automatically destroyed and the client must no longer call
311 * #GNUNET_CONVERSATION_call_stop or any other function on the
312 * call object.
313 */
314 GNUNET_CONVERSATION_EC_CALL_GNS_FAIL,
315
316 /**
317 * We are the caller and the callee called
318 * #GNUNET_CONVERSATION_caller_hang_up. After this invocation, the
319 * respective call handle will be automatically destroyed and the
320 * client must no longer call #GNUNET_CONVERSATION_call_stop.
321 */
322 GNUNET_CONVERSATION_EC_CALL_HUNG_UP,
323
324 /**
325 * We are the caller and the callee suspended the call. Note that
326 * both sides can independently suspend and resume calls; a call is
327 * only "working" of both sides are active.
328 */
329 GNUNET_CONVERSATION_EC_CALL_SUSPENDED,
330
331 /**
332 * We are the caller and the callee suspended the call. Note that
333 * both sides can independently suspend and resume calls; a call is
334 * only "working" of both sides are active.
335 */
336 GNUNET_CONVERSATION_EC_CALL_RESUMED
337
338};
339
340
341/**
342 * Function called with an event emitted for a call.
343 *
344 * @param cls closure
345 * @param code type of the event on the call
346 */
347typedef void (*GNUNET_CONVERSATION_CallEventHandler)(void *cls,
348 enum GNUNET_CONVERSATION_CallEventCode code);
349
350
351/**
253 * Call the phone of another user. 352 * Call the phone of another user.
254 * 353 *
255 * @param cfg configuration to use, specifies our phone service 354 * @param cfg configuration to use, specifies our phone service
@@ -269,20 +368,43 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
269 const char *callee, 368 const char *callee,
270 struct GNUNET_SPEAKER_Handle *speaker, 369 struct GNUNET_SPEAKER_Handle *speaker,
271 struct GNUNET_MICROPHONE_Handle *mic, 370 struct GNUNET_MICROPHONE_Handle *mic,
272 GNUNET_CONVERSATION_EventHandler event_handler, 371 GNUNET_CONVERSATION_CallEventHandler event_handler,
273 void *event_handler_cls); 372 void *event_handler_cls);
274 373
275 374
276/** 375/**
376 * Pause a call. Temporarily suspends the use of speaker and
377 * microphone.
378 *
379 * @param call call to pause
380 */
381void
382GNUNET_CONVERSATION_call_suspend (struct GNUNET_CONVERSATION_Call *call);
383
384
385/**
386 * Resumes a call after #GNUNET_CONVERSATION_call_pause.
387 *
388 * @param call call to resume
389 * @param speaker speaker to use (will be used automatically immediately once the
390 * #GNUNET_CONVERSATION_EC_READY event is generated); we will NOT generate
391 * a ring tone on the speaker
392 * @param mic microphone to use (will be used automatically immediately once the
393 * #GNUNET_CONVERSATION_EC_READY event is generated)
394 */
395void
396GNUNET_CONVERSATION_call_resume (struct GNUNET_CONVERSATION_Call *call,
397 struct GNUNET_SPEAKER_Handle *speaker,
398 struct GNUNET_MICROPHONE_Handle *mic);
399
400
401/**
277 * Terminate a call. The call may be ringing or ready at this time. 402 * Terminate a call. The call may be ringing or ready at this time.
278 * 403 *
279 * @param call call to terminate 404 * @param call call to terminate
280 * @param reason if the call was active (ringing or ready) this will be the
281 * reason given to the other user for why we hung up
282 */ 405 */
283void 406void
284GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call, 407GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call);
285 const char *reason);
286 408
287 409
288#if 0 /* keep Emacsens' auto-indent happy */ 410#if 0 /* keep Emacsens' auto-indent happy */