diff options
Diffstat (limited to 'src/conversation/conversation_api.c')
-rw-r--r-- | src/conversation/conversation_api.c | 696 |
1 files changed, 350 insertions, 346 deletions
diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c index cd777c285..4c19a7d2d 100644 --- a/src/conversation/conversation_api.c +++ b/src/conversation/conversation_api.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet | 2 | This file is part of GNUnet |
3 | Copyright (C) 2013, 2014 GNUnet e.V. | 3 | Copyright (C) 2013, 2014 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation, either version 3 of the License, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -33,8 +33,7 @@ | |||
33 | /** | 33 | /** |
34 | * Possible states of a caller. | 34 | * Possible states of a caller. |
35 | */ | 35 | */ |
36 | enum CallerState | 36 | enum CallerState { |
37 | { | ||
38 | /** | 37 | /** |
39 | * The phone is ringing (user knows about incoming call). | 38 | * The phone is ringing (user knows about incoming call). |
40 | */ | 39 | */ |
@@ -66,9 +65,7 @@ enum CallerState | |||
66 | /** | 65 | /** |
67 | * A caller is the handle we have for an incoming call. | 66 | * A caller is the handle we have for an incoming call. |
68 | */ | 67 | */ |
69 | struct GNUNET_CONVERSATION_Caller | 68 | struct GNUNET_CONVERSATION_Caller { |
70 | { | ||
71 | |||
72 | /** | 69 | /** |
73 | * We keep all callers in a DLL. | 70 | * We keep all callers in a DLL. |
74 | */ | 71 | */ |
@@ -118,15 +115,13 @@ struct GNUNET_CONVERSATION_Caller | |||
118 | * State machine for the phone. | 115 | * State machine for the phone. |
119 | */ | 116 | */ |
120 | enum CallerState state; | 117 | enum CallerState state; |
121 | |||
122 | }; | 118 | }; |
123 | 119 | ||
124 | 120 | ||
125 | /** | 121 | /** |
126 | * Possible states of a phone. | 122 | * Possible states of a phone. |
127 | */ | 123 | */ |
128 | enum PhoneState | 124 | enum PhoneState { |
129 | { | ||
130 | /** | 125 | /** |
131 | * We still need to register the phone. | 126 | * We still need to register the phone. |
132 | */ | 127 | */ |
@@ -136,7 +131,6 @@ enum PhoneState | |||
136 | * We are waiting for calls. | 131 | * We are waiting for calls. |
137 | */ | 132 | */ |
138 | PS_READY | 133 | PS_READY |
139 | |||
140 | }; | 134 | }; |
141 | 135 | ||
142 | 136 | ||
@@ -151,8 +145,7 @@ enum PhoneState | |||
151 | * something rather internal to a phone and not obvious from it). | 145 | * something rather internal to a phone and not obvious from it). |
152 | * You can only have one conversation per phone at any time. | 146 | * You can only have one conversation per phone at any time. |
153 | */ | 147 | */ |
154 | struct GNUNET_CONVERSATION_Phone | 148 | struct GNUNET_CONVERSATION_Phone { |
155 | { | ||
156 | /** | 149 | /** |
157 | * Our configuration. | 150 | * Our configuration. |
158 | */ | 151 | */ |
@@ -202,7 +195,6 @@ struct GNUNET_CONVERSATION_Phone | |||
202 | * State machine for the phone. | 195 | * State machine for the phone. |
203 | */ | 196 | */ |
204 | enum PhoneState state; | 197 | enum PhoneState state; |
205 | |||
206 | }; | 198 | }; |
207 | 199 | ||
208 | 200 | ||
@@ -212,7 +204,7 @@ struct GNUNET_CONVERSATION_Phone | |||
212 | * @param phone phone to reconnect | 204 | * @param phone phone to reconnect |
213 | */ | 205 | */ |
214 | static void | 206 | static void |
215 | reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone); | 207 | reconnect_phone(struct GNUNET_CONVERSATION_Phone *phone); |
216 | 208 | ||
217 | 209 | ||
218 | /** | 210 | /** |
@@ -223,24 +215,24 @@ reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone); | |||
223 | * @param data audio data to play | 215 | * @param data audio data to play |
224 | */ | 216 | */ |
225 | static void | 217 | static void |
226 | transmit_phone_audio (void *cls, | 218 | transmit_phone_audio(void *cls, |
227 | size_t data_size, | 219 | size_t data_size, |
228 | const void *data) | 220 | const void *data) |
229 | { | 221 | { |
230 | struct GNUNET_CONVERSATION_Caller *caller = cls; | 222 | struct GNUNET_CONVERSATION_Caller *caller = cls; |
231 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; | 223 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; |
232 | struct GNUNET_MQ_Envelope *e; | 224 | struct GNUNET_MQ_Envelope *e; |
233 | struct ClientAudioMessage *am; | 225 | struct ClientAudioMessage *am; |
234 | 226 | ||
235 | e = GNUNET_MQ_msg_extra (am, | 227 | e = GNUNET_MQ_msg_extra(am, |
236 | data_size, | 228 | data_size, |
237 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO); | 229 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO); |
238 | am->cid = caller->cid; | 230 | am->cid = caller->cid; |
239 | GNUNET_memcpy (&am[1], | 231 | GNUNET_memcpy(&am[1], |
240 | data, | 232 | data, |
241 | data_size); | 233 | data_size); |
242 | GNUNET_MQ_send (phone->mq, | 234 | GNUNET_MQ_send(phone->mq, |
243 | e); | 235 | e); |
244 | } | 236 | } |
245 | 237 | ||
246 | 238 | ||
@@ -251,32 +243,33 @@ transmit_phone_audio (void *cls, | |||
251 | * @param ring the message | 243 | * @param ring the message |
252 | */ | 244 | */ |
253 | static void | 245 | static void |
254 | handle_phone_ring (void *cls, | 246 | handle_phone_ring(void *cls, |
255 | const struct ClientPhoneRingMessage *ring) | 247 | const struct ClientPhoneRingMessage *ring) |
256 | { | 248 | { |
257 | struct GNUNET_CONVERSATION_Phone *phone = cls; | 249 | struct GNUNET_CONVERSATION_Phone *phone = cls; |
258 | struct GNUNET_CONVERSATION_Caller *caller; | 250 | struct GNUNET_CONVERSATION_Caller *caller; |
259 | 251 | ||
260 | switch (phone->state) | 252 | switch (phone->state) |
261 | { | 253 | { |
262 | case PS_REGISTER: | 254 | case PS_REGISTER: |
263 | GNUNET_assert (0); | 255 | GNUNET_assert(0); |
264 | break; | 256 | break; |
265 | case PS_READY: | 257 | |
266 | caller = GNUNET_new (struct GNUNET_CONVERSATION_Caller); | 258 | case PS_READY: |
267 | caller->phone = phone; | 259 | caller = GNUNET_new(struct GNUNET_CONVERSATION_Caller); |
268 | GNUNET_CONTAINER_DLL_insert (phone->caller_head, | 260 | caller->phone = phone; |
269 | phone->caller_tail, | 261 | GNUNET_CONTAINER_DLL_insert(phone->caller_head, |
270 | caller); | 262 | phone->caller_tail, |
271 | caller->caller_id = ring->caller_id; | 263 | caller); |
272 | caller->cid = ring->cid; | 264 | caller->caller_id = ring->caller_id; |
273 | caller->state = CS_RINGING; | 265 | caller->cid = ring->cid; |
274 | phone->event_handler (phone->event_handler_cls, | 266 | caller->state = CS_RINGING; |
275 | GNUNET_CONVERSATION_EC_PHONE_RING, | 267 | phone->event_handler(phone->event_handler_cls, |
276 | caller, | 268 | GNUNET_CONVERSATION_EC_PHONE_RING, |
277 | &caller->caller_id); | 269 | caller, |
278 | break; | 270 | &caller->caller_id); |
279 | } | 271 | break; |
272 | } | ||
280 | } | 273 | } |
281 | 274 | ||
282 | 275 | ||
@@ -288,12 +281,12 @@ handle_phone_ring (void *cls, | |||
288 | * @return NULL if @a cid was not found | 281 | * @return NULL if @a cid was not found |
289 | */ | 282 | */ |
290 | static struct GNUNET_CONVERSATION_Caller * | 283 | static struct GNUNET_CONVERSATION_Caller * |
291 | find_caller (struct GNUNET_CONVERSATION_Phone *phone, | 284 | find_caller(struct GNUNET_CONVERSATION_Phone *phone, |
292 | uint32_t cid) | 285 | uint32_t cid) |
293 | { | 286 | { |
294 | struct GNUNET_CONVERSATION_Caller *caller; | 287 | struct GNUNET_CONVERSATION_Caller *caller; |
295 | 288 | ||
296 | for (caller = phone->caller_head;NULL != caller;caller = caller->next) | 289 | for (caller = phone->caller_head; NULL != caller; caller = caller->next) |
297 | if (cid == caller->cid) | 290 | if (cid == caller->cid) |
298 | return caller; | 291 | return caller; |
299 | return NULL; | 292 | return NULL; |
@@ -307,54 +300,56 @@ find_caller (struct GNUNET_CONVERSATION_Phone *phone, | |||
307 | * @param msg the message | 300 | * @param msg the message |
308 | */ | 301 | */ |
309 | static void | 302 | static void |
310 | handle_phone_hangup (void *cls, | 303 | handle_phone_hangup(void *cls, |
311 | const struct ClientPhoneHangupMessage *hang) | 304 | const struct ClientPhoneHangupMessage *hang) |
312 | { | 305 | { |
313 | struct GNUNET_CONVERSATION_Phone *phone = cls; | 306 | struct GNUNET_CONVERSATION_Phone *phone = cls; |
314 | struct GNUNET_CONVERSATION_Caller *caller; | 307 | struct GNUNET_CONVERSATION_Caller *caller; |
315 | 308 | ||
316 | caller = find_caller (phone, | 309 | caller = find_caller(phone, |
317 | hang->cid); | 310 | hang->cid); |
318 | if (NULL == caller) | 311 | if (NULL == caller) |
319 | { | 312 | { |
320 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 313 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
321 | "Received HANG_UP message for unknown caller ID %u\n", | 314 | "Received HANG_UP message for unknown caller ID %u\n", |
322 | (unsigned int) hang->cid); | 315 | (unsigned int)hang->cid); |
323 | return; | 316 | return; |
324 | } | 317 | } |
325 | 318 | ||
326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 319 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
327 | "Received HANG_UP message, terminating call with `%s'\n", | 320 | "Received HANG_UP message, terminating call with `%s'\n", |
328 | GNUNET_GNSRECORD_pkey_to_zkey (&caller->caller_id)); | 321 | GNUNET_GNSRECORD_pkey_to_zkey(&caller->caller_id)); |
329 | switch (caller->state) | 322 | switch (caller->state) |
330 | { | 323 | { |
331 | case CS_RINGING: | 324 | case CS_RINGING: |
332 | phone->event_handler (phone->event_handler_cls, | 325 | phone->event_handler(phone->event_handler_cls, |
333 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | 326 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, |
334 | caller, | 327 | caller, |
335 | &caller->caller_id); | 328 | &caller->caller_id); |
336 | break; | 329 | break; |
337 | case CS_ACTIVE: | 330 | |
338 | caller->speaker->disable_speaker (caller->speaker->cls); | 331 | case CS_ACTIVE: |
339 | caller->mic->disable_microphone (caller->mic->cls); | 332 | caller->speaker->disable_speaker(caller->speaker->cls); |
340 | phone->event_handler (phone->event_handler_cls, | 333 | caller->mic->disable_microphone(caller->mic->cls); |
341 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | 334 | phone->event_handler(phone->event_handler_cls, |
342 | caller, | 335 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, |
343 | &caller->caller_id); | 336 | caller, |
344 | break; | 337 | &caller->caller_id); |
345 | case CS_CALLEE_SUSPENDED: | 338 | break; |
346 | case CS_CALLER_SUSPENDED: | 339 | |
347 | case CS_BOTH_SUSPENDED: | 340 | case CS_CALLEE_SUSPENDED: |
348 | phone->event_handler (phone->event_handler_cls, | 341 | case CS_CALLER_SUSPENDED: |
349 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | 342 | case CS_BOTH_SUSPENDED: |
350 | caller, | 343 | phone->event_handler(phone->event_handler_cls, |
351 | &caller->caller_id); | 344 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, |
352 | break; | 345 | caller, |
353 | } | 346 | &caller->caller_id); |
354 | GNUNET_CONTAINER_DLL_remove (phone->caller_head, | 347 | break; |
355 | phone->caller_tail, | 348 | } |
356 | caller); | 349 | GNUNET_CONTAINER_DLL_remove(phone->caller_head, |
357 | GNUNET_free (caller); | 350 | phone->caller_tail, |
351 | caller); | ||
352 | GNUNET_free(caller); | ||
358 | } | 353 | } |
359 | 354 | ||
360 | 355 | ||
@@ -365,38 +360,41 @@ handle_phone_hangup (void *cls, | |||
365 | * @param suspend the message | 360 | * @param suspend the message |
366 | */ | 361 | */ |
367 | static void | 362 | static void |
368 | handle_phone_suspend (void *cls, | 363 | handle_phone_suspend(void *cls, |
369 | const struct ClientPhoneSuspendMessage *suspend) | 364 | const struct ClientPhoneSuspendMessage *suspend) |
370 | { | 365 | { |
371 | struct GNUNET_CONVERSATION_Phone *phone = cls; | 366 | struct GNUNET_CONVERSATION_Phone *phone = cls; |
372 | struct GNUNET_CONVERSATION_Caller *caller; | 367 | struct GNUNET_CONVERSATION_Caller *caller; |
373 | 368 | ||
374 | caller = find_caller (phone, | 369 | caller = find_caller(phone, |
375 | suspend->cid); | 370 | suspend->cid); |
376 | if (NULL == caller) | 371 | if (NULL == caller) |
377 | return; | 372 | return; |
378 | switch (caller->state) | 373 | switch (caller->state) |
379 | { | 374 | { |
380 | case CS_RINGING: | 375 | case CS_RINGING: |
381 | GNUNET_break_op (0); | 376 | GNUNET_break_op(0); |
382 | break; | 377 | break; |
383 | case CS_ACTIVE: | 378 | |
384 | caller->state = CS_CALLER_SUSPENDED; | 379 | case CS_ACTIVE: |
385 | caller->speaker->disable_speaker (caller->speaker->cls); | 380 | caller->state = CS_CALLER_SUSPENDED; |
386 | caller->mic->disable_microphone (caller->mic->cls); | 381 | caller->speaker->disable_speaker(caller->speaker->cls); |
387 | caller->event_handler (caller->event_handler_cls, | 382 | caller->mic->disable_microphone(caller->mic->cls); |
388 | GNUNET_CONVERSATION_EC_CALLER_SUSPEND); | 383 | caller->event_handler(caller->event_handler_cls, |
389 | break; | 384 | GNUNET_CONVERSATION_EC_CALLER_SUSPEND); |
390 | case CS_CALLEE_SUSPENDED: | 385 | break; |
391 | caller->state = CS_BOTH_SUSPENDED; | 386 | |
392 | caller->event_handler (caller->event_handler_cls, | 387 | case CS_CALLEE_SUSPENDED: |
393 | GNUNET_CONVERSATION_EC_CALLER_SUSPEND); | 388 | caller->state = CS_BOTH_SUSPENDED; |
394 | break; | 389 | caller->event_handler(caller->event_handler_cls, |
395 | case CS_CALLER_SUSPENDED: | 390 | GNUNET_CONVERSATION_EC_CALLER_SUSPEND); |
396 | case CS_BOTH_SUSPENDED: | 391 | break; |
397 | GNUNET_break_op (0); | 392 | |
398 | break; | 393 | case CS_CALLER_SUSPENDED: |
399 | } | 394 | case CS_BOTH_SUSPENDED: |
395 | GNUNET_break_op(0); | ||
396 | break; | ||
397 | } | ||
400 | } | 398 | } |
401 | 399 | ||
402 | 400 | ||
@@ -407,40 +405,43 @@ handle_phone_suspend (void *cls, | |||
407 | * @param resume the message | 405 | * @param resume the message |
408 | */ | 406 | */ |
409 | static void | 407 | static void |
410 | handle_phone_resume (void *cls, | 408 | handle_phone_resume(void *cls, |
411 | const struct ClientPhoneResumeMessage *resume) | 409 | const struct ClientPhoneResumeMessage *resume) |
412 | { | 410 | { |
413 | struct GNUNET_CONVERSATION_Phone *phone = cls; | 411 | struct GNUNET_CONVERSATION_Phone *phone = cls; |
414 | struct GNUNET_CONVERSATION_Caller *caller; | 412 | struct GNUNET_CONVERSATION_Caller *caller; |
415 | 413 | ||
416 | caller = find_caller (phone, | 414 | caller = find_caller(phone, |
417 | resume->cid); | 415 | resume->cid); |
418 | if (NULL == caller) | 416 | if (NULL == caller) |
419 | return; | 417 | return; |
420 | switch (caller->state) | 418 | switch (caller->state) |
421 | { | 419 | { |
422 | case CS_RINGING: | 420 | case CS_RINGING: |
423 | GNUNET_break_op (0); | 421 | GNUNET_break_op(0); |
424 | break; | 422 | break; |
425 | case CS_ACTIVE: | 423 | |
426 | case CS_CALLEE_SUSPENDED: | 424 | case CS_ACTIVE: |
427 | GNUNET_break_op (0); | 425 | case CS_CALLEE_SUSPENDED: |
428 | break; | 426 | GNUNET_break_op(0); |
429 | case CS_CALLER_SUSPENDED: | 427 | break; |
430 | caller->state = CS_ACTIVE; | 428 | |
431 | caller->speaker->enable_speaker (caller->speaker->cls); | 429 | case CS_CALLER_SUSPENDED: |
432 | caller->mic->enable_microphone (caller->mic->cls, | 430 | caller->state = CS_ACTIVE; |
433 | &transmit_phone_audio, | 431 | caller->speaker->enable_speaker(caller->speaker->cls); |
434 | caller); | 432 | caller->mic->enable_microphone(caller->mic->cls, |
435 | caller->event_handler (caller->event_handler_cls, | 433 | &transmit_phone_audio, |
436 | GNUNET_CONVERSATION_EC_CALLER_RESUME); | 434 | caller); |
437 | break; | 435 | caller->event_handler(caller->event_handler_cls, |
438 | case CS_BOTH_SUSPENDED: | 436 | GNUNET_CONVERSATION_EC_CALLER_RESUME); |
439 | caller->state = CS_CALLEE_SUSPENDED; | 437 | break; |
440 | caller->event_handler (caller->event_handler_cls, | 438 | |
441 | GNUNET_CONVERSATION_EC_CALLER_RESUME); | 439 | case CS_BOTH_SUSPENDED: |
442 | break; | 440 | caller->state = CS_CALLEE_SUSPENDED; |
443 | } | 441 | caller->event_handler(caller->event_handler_cls, |
442 | GNUNET_CONVERSATION_EC_CALLER_RESUME); | ||
443 | break; | ||
444 | } | ||
444 | } | 445 | } |
445 | 446 | ||
446 | 447 | ||
@@ -452,12 +453,12 @@ handle_phone_resume (void *cls, | |||
452 | * @return #GNUNET_OK if @a am is well-formed | 453 | * @return #GNUNET_OK if @a am is well-formed |
453 | */ | 454 | */ |
454 | static int | 455 | static int |
455 | check_phone_audio (void *cls, | 456 | check_phone_audio(void *cls, |
456 | const struct ClientAudioMessage *am) | 457 | const struct ClientAudioMessage *am) |
457 | { | 458 | { |
458 | (void) cls; | 459 | (void)cls; |
459 | (void) am; | 460 | (void)am; |
460 | 461 | ||
461 | /* any variable-size payload is OK */ | 462 | /* any variable-size payload is OK */ |
462 | return GNUNET_OK; | 463 | return GNUNET_OK; |
463 | } | 464 | } |
@@ -470,31 +471,33 @@ check_phone_audio (void *cls, | |||
470 | * @param am the message | 471 | * @param am the message |
471 | */ | 472 | */ |
472 | static void | 473 | static void |
473 | handle_phone_audio (void *cls, | 474 | handle_phone_audio(void *cls, |
474 | const struct ClientAudioMessage *am) | 475 | const struct ClientAudioMessage *am) |
475 | { | 476 | { |
476 | struct GNUNET_CONVERSATION_Phone *phone = cls; | 477 | struct GNUNET_CONVERSATION_Phone *phone = cls; |
477 | struct GNUNET_CONVERSATION_Caller *caller; | 478 | struct GNUNET_CONVERSATION_Caller *caller; |
478 | 479 | ||
479 | caller = find_caller (phone, | 480 | caller = find_caller(phone, |
480 | am->cid); | 481 | am->cid); |
481 | if (NULL == caller) | 482 | if (NULL == caller) |
482 | return; | 483 | return; |
483 | switch (caller->state) | 484 | switch (caller->state) |
484 | { | 485 | { |
485 | case CS_RINGING: | 486 | case CS_RINGING: |
486 | GNUNET_break_op (0); | 487 | GNUNET_break_op(0); |
487 | break; | 488 | break; |
488 | case CS_ACTIVE: | 489 | |
489 | caller->speaker->play (caller->speaker->cls, | 490 | case CS_ACTIVE: |
490 | ntohs (am->header.size) - sizeof (struct ClientAudioMessage), | 491 | caller->speaker->play(caller->speaker->cls, |
491 | &am[1]); | 492 | ntohs(am->header.size) - sizeof(struct ClientAudioMessage), |
492 | break; | 493 | &am[1]); |
493 | case CS_CALLEE_SUSPENDED: | 494 | break; |
494 | case CS_CALLER_SUSPENDED: | 495 | |
495 | case CS_BOTH_SUSPENDED: | 496 | case CS_CALLEE_SUSPENDED: |
496 | break; | 497 | case CS_CALLER_SUSPENDED: |
497 | } | 498 | case CS_BOTH_SUSPENDED: |
499 | break; | ||
500 | } | ||
498 | } | 501 | } |
499 | 502 | ||
500 | 503 | ||
@@ -505,15 +508,15 @@ handle_phone_audio (void *cls, | |||
505 | * @param error details about the error | 508 | * @param error details about the error |
506 | */ | 509 | */ |
507 | static void | 510 | static void |
508 | phone_error_handler (void *cls, | 511 | phone_error_handler(void *cls, |
509 | enum GNUNET_MQ_Error error) | 512 | enum GNUNET_MQ_Error error) |
510 | { | 513 | { |
511 | struct GNUNET_CONVERSATION_Phone *phone = cls; | 514 | struct GNUNET_CONVERSATION_Phone *phone = cls; |
512 | 515 | ||
513 | (void) error; | 516 | (void)error; |
514 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 517 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
515 | _("Connection to conversation service lost, trying to reconnect\n")); | 518 | _("Connection to conversation service lost, trying to reconnect\n")); |
516 | reconnect_phone (phone); | 519 | reconnect_phone(phone); |
517 | } | 520 | } |
518 | 521 | ||
519 | 522 | ||
@@ -523,25 +526,25 @@ phone_error_handler (void *cls, | |||
523 | * @param phone phone to clean up callers for | 526 | * @param phone phone to clean up callers for |
524 | */ | 527 | */ |
525 | static void | 528 | static void |
526 | clean_up_callers (struct GNUNET_CONVERSATION_Phone *phone) | 529 | clean_up_callers(struct GNUNET_CONVERSATION_Phone *phone) |
527 | { | 530 | { |
528 | struct GNUNET_CONVERSATION_Caller *caller; | 531 | struct GNUNET_CONVERSATION_Caller *caller; |
529 | 532 | ||
530 | while (NULL != (caller = phone->caller_head)) | 533 | while (NULL != (caller = phone->caller_head)) |
531 | { | ||
532 | /* make sure mic/speaker are disabled *before* callback */ | ||
533 | if (CS_ACTIVE == caller->state) | ||
534 | { | 534 | { |
535 | caller->speaker->disable_speaker (caller->speaker->cls); | 535 | /* make sure mic/speaker are disabled *before* callback */ |
536 | caller->mic->disable_microphone (caller->mic->cls); | 536 | if (CS_ACTIVE == caller->state) |
537 | caller->state = CS_CALLER_SUSPENDED; | 537 | { |
538 | caller->speaker->disable_speaker(caller->speaker->cls); | ||
539 | caller->mic->disable_microphone(caller->mic->cls); | ||
540 | caller->state = CS_CALLER_SUSPENDED; | ||
541 | } | ||
542 | phone->event_handler(phone->event_handler_cls, | ||
543 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | ||
544 | caller, | ||
545 | &caller->caller_id); | ||
546 | GNUNET_CONVERSATION_caller_hang_up(caller); | ||
538 | } | 547 | } |
539 | phone->event_handler (phone->event_handler_cls, | ||
540 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | ||
541 | caller, | ||
542 | &caller->caller_id); | ||
543 | GNUNET_CONVERSATION_caller_hang_up (caller); | ||
544 | } | ||
545 | } | 548 | } |
546 | 549 | ||
547 | 550 | ||
@@ -551,53 +554,53 @@ clean_up_callers (struct GNUNET_CONVERSATION_Phone *phone) | |||
551 | * @param phone phone to reconnect | 554 | * @param phone phone to reconnect |
552 | */ | 555 | */ |
553 | static void | 556 | static void |
554 | reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone) | 557 | reconnect_phone(struct GNUNET_CONVERSATION_Phone *phone) |
555 | { | 558 | { |
556 | struct GNUNET_MQ_MessageHandler handlers[] = { | 559 | struct GNUNET_MQ_MessageHandler handlers[] = { |
557 | GNUNET_MQ_hd_fixed_size (phone_ring, | 560 | GNUNET_MQ_hd_fixed_size(phone_ring, |
558 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING, | 561 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING, |
559 | struct ClientPhoneRingMessage, | 562 | struct ClientPhoneRingMessage, |
560 | phone), | 563 | phone), |
561 | GNUNET_MQ_hd_fixed_size (phone_hangup, | 564 | GNUNET_MQ_hd_fixed_size(phone_hangup, |
562 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, | 565 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, |
563 | struct ClientPhoneHangupMessage, | 566 | struct ClientPhoneHangupMessage, |
564 | phone), | 567 | phone), |
565 | GNUNET_MQ_hd_fixed_size (phone_suspend, | 568 | GNUNET_MQ_hd_fixed_size(phone_suspend, |
566 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, | 569 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, |
567 | struct ClientPhoneSuspendMessage, | 570 | struct ClientPhoneSuspendMessage, |
568 | phone), | 571 | phone), |
569 | GNUNET_MQ_hd_fixed_size (phone_resume, | 572 | GNUNET_MQ_hd_fixed_size(phone_resume, |
570 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, | 573 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, |
571 | struct ClientPhoneResumeMessage, | 574 | struct ClientPhoneResumeMessage, |
572 | phone), | 575 | phone), |
573 | GNUNET_MQ_hd_var_size (phone_audio, | 576 | GNUNET_MQ_hd_var_size(phone_audio, |
574 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, | 577 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, |
575 | struct ClientAudioMessage, | 578 | struct ClientAudioMessage, |
576 | phone), | 579 | phone), |
577 | GNUNET_MQ_handler_end () | 580 | GNUNET_MQ_handler_end() |
578 | }; | 581 | }; |
579 | struct GNUNET_MQ_Envelope *e; | 582 | struct GNUNET_MQ_Envelope *e; |
580 | struct ClientPhoneRegisterMessage *reg; | 583 | struct ClientPhoneRegisterMessage *reg; |
581 | 584 | ||
582 | clean_up_callers (phone); | 585 | clean_up_callers(phone); |
583 | if (NULL != phone->mq) | 586 | if (NULL != phone->mq) |
584 | { | 587 | { |
585 | GNUNET_MQ_destroy (phone->mq); | 588 | GNUNET_MQ_destroy(phone->mq); |
586 | phone->mq = NULL; | 589 | phone->mq = NULL; |
587 | } | 590 | } |
588 | phone->state = PS_REGISTER; | 591 | phone->state = PS_REGISTER; |
589 | phone->mq = GNUNET_CLIENT_connect (phone->cfg, | 592 | phone->mq = GNUNET_CLIENT_connect(phone->cfg, |
590 | "conversation", | 593 | "conversation", |
591 | handlers, | 594 | handlers, |
592 | &phone_error_handler, | 595 | &phone_error_handler, |
593 | phone); | 596 | phone); |
594 | if (NULL == phone->mq) | 597 | if (NULL == phone->mq) |
595 | return; | 598 | return; |
596 | e = GNUNET_MQ_msg (reg, | 599 | e = GNUNET_MQ_msg(reg, |
597 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER); | 600 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_REGISTER); |
598 | reg->line_port = phone->my_record.line_port; | 601 | reg->line_port = phone->my_record.line_port; |
599 | GNUNET_MQ_send (phone->mq, | 602 | GNUNET_MQ_send(phone->mq, |
600 | e); | 603 | e); |
601 | phone->state = PS_READY; | 604 | phone->state = PS_READY; |
602 | } | 605 | } |
603 | 606 | ||
@@ -613,54 +616,54 @@ reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone) | |||
613 | * @return NULL on error (no valid line configured) | 616 | * @return NULL on error (no valid line configured) |
614 | */ | 617 | */ |
615 | struct GNUNET_CONVERSATION_Phone * | 618 | struct GNUNET_CONVERSATION_Phone * |
616 | GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | 619 | GNUNET_CONVERSATION_phone_create(const struct GNUNET_CONFIGURATION_Handle *cfg, |
617 | const struct GNUNET_IDENTITY_Ego *ego, | 620 | const struct GNUNET_IDENTITY_Ego *ego, |
618 | GNUNET_CONVERSATION_PhoneEventHandler event_handler, | 621 | GNUNET_CONVERSATION_PhoneEventHandler event_handler, |
619 | void *event_handler_cls) | 622 | void *event_handler_cls) |
620 | { | 623 | { |
621 | struct GNUNET_CONVERSATION_Phone *phone; | 624 | struct GNUNET_CONVERSATION_Phone *phone; |
622 | char *line; | 625 | char *line; |
623 | struct GNUNET_HashCode line_port; | 626 | struct GNUNET_HashCode line_port; |
624 | 627 | ||
625 | if (GNUNET_OK != | 628 | if (GNUNET_OK != |
626 | GNUNET_CONFIGURATION_get_value_string (cfg, | 629 | GNUNET_CONFIGURATION_get_value_string(cfg, |
627 | "CONVERSATION", | 630 | "CONVERSATION", |
628 | "LINE", | 631 | "LINE", |
629 | &line)) | 632 | &line)) |
630 | { | 633 | { |
631 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 634 | GNUNET_log_config_missing(GNUNET_ERROR_TYPE_ERROR, |
632 | "CONVERSATION", | 635 | "CONVERSATION", |
633 | "LINE"); | 636 | "LINE"); |
634 | return NULL; | 637 | return NULL; |
635 | } | 638 | } |
636 | GNUNET_CRYPTO_hash (line, | 639 | GNUNET_CRYPTO_hash(line, |
637 | strlen (line), | 640 | strlen(line), |
638 | &line_port); | 641 | &line_port); |
639 | phone = GNUNET_new (struct GNUNET_CONVERSATION_Phone); | 642 | phone = GNUNET_new(struct GNUNET_CONVERSATION_Phone); |
640 | if (GNUNET_OK != | 643 | if (GNUNET_OK != |
641 | GNUNET_CRYPTO_get_peer_identity (cfg, | 644 | GNUNET_CRYPTO_get_peer_identity(cfg, |
642 | &phone->my_record.peer)) | 645 | &phone->my_record.peer)) |
643 | { | 646 | { |
644 | GNUNET_break (0); | 647 | GNUNET_break(0); |
645 | GNUNET_free (phone); | 648 | GNUNET_free(phone); |
646 | return NULL; | 649 | return NULL; |
647 | } | 650 | } |
648 | phone->cfg = cfg; | 651 | phone->cfg = cfg; |
649 | phone->my_zone = *GNUNET_IDENTITY_ego_get_private_key (ego); | 652 | phone->my_zone = *GNUNET_IDENTITY_ego_get_private_key(ego); |
650 | phone->event_handler = event_handler; | 653 | phone->event_handler = event_handler; |
651 | phone->event_handler_cls = event_handler_cls; | 654 | phone->event_handler_cls = event_handler_cls; |
652 | phone->ns = GNUNET_NAMESTORE_connect (cfg); | 655 | phone->ns = GNUNET_NAMESTORE_connect(cfg); |
653 | phone->my_record.version = htonl (1); | 656 | phone->my_record.version = htonl(1); |
654 | phone->my_record.reserved = htonl (0); | 657 | phone->my_record.reserved = htonl(0); |
655 | phone->my_record.line_port = line_port; | 658 | phone->my_record.line_port = line_port; |
656 | reconnect_phone (phone); | 659 | reconnect_phone(phone); |
657 | if ( (NULL == phone->mq) || | 660 | if ((NULL == phone->mq) || |
658 | (NULL == phone->ns) ) | 661 | (NULL == phone->ns)) |
659 | { | 662 | { |
660 | GNUNET_break (0); | 663 | GNUNET_break(0); |
661 | GNUNET_CONVERSATION_phone_destroy (phone); | 664 | GNUNET_CONVERSATION_phone_destroy(phone); |
662 | return NULL; | 665 | return NULL; |
663 | } | 666 | } |
664 | return phone; | 667 | return phone; |
665 | } | 668 | } |
666 | 669 | ||
@@ -674,12 +677,12 @@ GNUNET_CONVERSATION_phone_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
674 | * @param rd namestore record to fill in | 677 | * @param rd namestore record to fill in |
675 | */ | 678 | */ |
676 | void | 679 | void |
677 | GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone, | 680 | GNUNET_CONVERSATION_phone_get_record(struct GNUNET_CONVERSATION_Phone *phone, |
678 | struct GNUNET_GNSRECORD_Data *rd) | 681 | struct GNUNET_GNSRECORD_Data *rd) |
679 | { | 682 | { |
680 | rd->data = &phone->my_record; | 683 | rd->data = &phone->my_record; |
681 | rd->expiration_time = 0; | 684 | rd->expiration_time = 0; |
682 | rd->data_size = sizeof (struct GNUNET_CONVERSATION_PhoneRecord); | 685 | rd->data_size = sizeof(struct GNUNET_CONVERSATION_PhoneRecord); |
683 | rd->record_type = GNUNET_GNSRECORD_TYPE_PHONE; | 686 | rd->record_type = GNUNET_GNSRECORD_TYPE_PHONE; |
684 | rd->flags = GNUNET_GNSRECORD_RF_NONE; | 687 | rd->flags = GNUNET_GNSRECORD_RF_NONE; |
685 | } | 688 | } |
@@ -696,31 +699,31 @@ GNUNET_CONVERSATION_phone_get_record (struct GNUNET_CONVERSATION_Phone *phone, | |||
696 | * @param mic microphone to use | 699 | * @param mic microphone to use |
697 | */ | 700 | */ |
698 | void | 701 | void |
699 | GNUNET_CONVERSATION_caller_pick_up (struct GNUNET_CONVERSATION_Caller *caller, | 702 | GNUNET_CONVERSATION_caller_pick_up(struct GNUNET_CONVERSATION_Caller *caller, |
700 | GNUNET_CONVERSATION_CallerEventHandler event_handler, | 703 | GNUNET_CONVERSATION_CallerEventHandler event_handler, |
701 | void *event_handler_cls, | 704 | void *event_handler_cls, |
702 | struct GNUNET_SPEAKER_Handle *speaker, | 705 | struct GNUNET_SPEAKER_Handle *speaker, |
703 | struct GNUNET_MICROPHONE_Handle *mic) | 706 | struct GNUNET_MICROPHONE_Handle *mic) |
704 | { | 707 | { |
705 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; | 708 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; |
706 | struct GNUNET_MQ_Envelope *e; | 709 | struct GNUNET_MQ_Envelope *e; |
707 | struct ClientPhonePickupMessage *pick; | 710 | struct ClientPhonePickupMessage *pick; |
708 | 711 | ||
709 | GNUNET_assert (CS_RINGING == caller->state); | 712 | GNUNET_assert(CS_RINGING == caller->state); |
710 | caller->speaker = speaker; | 713 | caller->speaker = speaker; |
711 | caller->mic = mic; | 714 | caller->mic = mic; |
712 | e = GNUNET_MQ_msg (pick, | 715 | e = GNUNET_MQ_msg(pick, |
713 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP); | 716 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICK_UP); |
714 | pick->cid = caller->cid; | 717 | pick->cid = caller->cid; |
715 | GNUNET_MQ_send (phone->mq, | 718 | GNUNET_MQ_send(phone->mq, |
716 | e); | 719 | e); |
717 | caller->state = CS_ACTIVE; | 720 | caller->state = CS_ACTIVE; |
718 | caller->event_handler = event_handler; | 721 | caller->event_handler = event_handler; |
719 | caller->event_handler_cls = event_handler_cls; | 722 | caller->event_handler_cls = event_handler_cls; |
720 | caller->speaker->enable_speaker (caller->speaker->cls); | 723 | caller->speaker->enable_speaker(caller->speaker->cls); |
721 | caller->mic->enable_microphone (caller->mic->cls, | 724 | caller->mic->enable_microphone(caller->mic->cls, |
722 | &transmit_phone_audio, | 725 | &transmit_phone_audio, |
723 | caller); | 726 | caller); |
724 | } | 727 | } |
725 | 728 | ||
726 | 729 | ||
@@ -731,30 +734,31 @@ GNUNET_CONVERSATION_caller_pick_up (struct GNUNET_CONVERSATION_Caller *caller, | |||
731 | * @param caller conversation to hang up on | 734 | * @param caller conversation to hang up on |
732 | */ | 735 | */ |
733 | void | 736 | void |
734 | GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller) | 737 | GNUNET_CONVERSATION_caller_hang_up(struct GNUNET_CONVERSATION_Caller *caller) |
735 | { | 738 | { |
736 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; | 739 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; |
737 | struct GNUNET_MQ_Envelope *e; | 740 | struct GNUNET_MQ_Envelope *e; |
738 | struct ClientPhoneHangupMessage *hang; | 741 | struct ClientPhoneHangupMessage *hang; |
739 | 742 | ||
740 | switch (caller->state) | 743 | switch (caller->state) |
741 | { | 744 | { |
742 | case CS_ACTIVE: | 745 | case CS_ACTIVE: |
743 | caller->speaker->disable_speaker (caller->speaker->cls); | 746 | caller->speaker->disable_speaker(caller->speaker->cls); |
744 | caller->mic->disable_microphone (caller->mic->cls); | 747 | caller->mic->disable_microphone(caller->mic->cls); |
745 | break; | 748 | break; |
746 | default: | 749 | |
747 | break; | 750 | default: |
748 | } | 751 | break; |
749 | GNUNET_CONTAINER_DLL_remove (phone->caller_head, | 752 | } |
750 | phone->caller_tail, | 753 | GNUNET_CONTAINER_DLL_remove(phone->caller_head, |
751 | caller); | 754 | phone->caller_tail, |
752 | e = GNUNET_MQ_msg (hang, | 755 | caller); |
753 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | 756 | e = GNUNET_MQ_msg(hang, |
757 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | ||
754 | hang->cid = caller->cid; | 758 | hang->cid = caller->cid; |
755 | GNUNET_MQ_send (phone->mq, | 759 | GNUNET_MQ_send(phone->mq, |
756 | e); | 760 | e); |
757 | GNUNET_free (caller); | 761 | GNUNET_free(caller); |
758 | } | 762 | } |
759 | 763 | ||
760 | 764 | ||
@@ -764,20 +768,20 @@ GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller) | |||
764 | * @param phone phone to destroy | 768 | * @param phone phone to destroy |
765 | */ | 769 | */ |
766 | void | 770 | void |
767 | GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone) | 771 | GNUNET_CONVERSATION_phone_destroy(struct GNUNET_CONVERSATION_Phone *phone) |
768 | { | 772 | { |
769 | clean_up_callers (phone); | 773 | clean_up_callers(phone); |
770 | if (NULL != phone->ns) | 774 | if (NULL != phone->ns) |
771 | { | 775 | { |
772 | GNUNET_NAMESTORE_disconnect (phone->ns); | 776 | GNUNET_NAMESTORE_disconnect(phone->ns); |
773 | phone->ns = NULL; | 777 | phone->ns = NULL; |
774 | } | 778 | } |
775 | if (NULL != phone->mq) | 779 | if (NULL != phone->mq) |
776 | { | 780 | { |
777 | GNUNET_MQ_destroy (phone->mq); | 781 | GNUNET_MQ_destroy(phone->mq); |
778 | phone->mq = NULL; | 782 | phone->mq = NULL; |
779 | } | 783 | } |
780 | GNUNET_free (phone); | 784 | GNUNET_free(phone); |
781 | } | 785 | } |
782 | 786 | ||
783 | 787 | ||
@@ -789,26 +793,26 @@ GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone) | |||
789 | * @param caller call to suspend | 793 | * @param caller call to suspend |
790 | */ | 794 | */ |
791 | void | 795 | void |
792 | GNUNET_CONVERSATION_caller_suspend (struct GNUNET_CONVERSATION_Caller *caller) | 796 | GNUNET_CONVERSATION_caller_suspend(struct GNUNET_CONVERSATION_Caller *caller) |
793 | { | 797 | { |
794 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; | 798 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; |
795 | struct GNUNET_MQ_Envelope *e; | 799 | struct GNUNET_MQ_Envelope *e; |
796 | struct ClientPhoneSuspendMessage *suspend; | 800 | struct ClientPhoneSuspendMessage *suspend; |
797 | 801 | ||
798 | GNUNET_assert ( (CS_ACTIVE == caller->state) || | 802 | GNUNET_assert((CS_ACTIVE == caller->state) || |
799 | (CS_CALLER_SUSPENDED == caller->state) ); | 803 | (CS_CALLER_SUSPENDED == caller->state)); |
800 | if (CS_ACTIVE == caller->state) | 804 | if (CS_ACTIVE == caller->state) |
801 | { | 805 | { |
802 | caller->speaker->disable_speaker (caller->speaker->cls); | 806 | caller->speaker->disable_speaker(caller->speaker->cls); |
803 | caller->mic->disable_microphone (caller->mic->cls); | 807 | caller->mic->disable_microphone(caller->mic->cls); |
804 | } | 808 | } |
805 | caller->speaker = NULL; | 809 | caller->speaker = NULL; |
806 | caller->mic = NULL; | 810 | caller->mic = NULL; |
807 | e = GNUNET_MQ_msg (suspend, | 811 | e = GNUNET_MQ_msg(suspend, |
808 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND); | 812 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND); |
809 | suspend->cid = caller->cid; | 813 | suspend->cid = caller->cid; |
810 | GNUNET_MQ_send (phone->mq, | 814 | GNUNET_MQ_send(phone->mq, |
811 | e); | 815 | e); |
812 | if (CS_ACTIVE == caller->state) | 816 | if (CS_ACTIVE == caller->state) |
813 | caller->state = CS_CALLEE_SUSPENDED; | 817 | caller->state = CS_CALLEE_SUSPENDED; |
814 | else | 818 | else |
@@ -824,35 +828,35 @@ GNUNET_CONVERSATION_caller_suspend (struct GNUNET_CONVERSATION_Caller *caller) | |||
824 | * @param mic microphone to use | 828 | * @param mic microphone to use |
825 | */ | 829 | */ |
826 | void | 830 | void |
827 | GNUNET_CONVERSATION_caller_resume (struct GNUNET_CONVERSATION_Caller *caller, | 831 | GNUNET_CONVERSATION_caller_resume(struct GNUNET_CONVERSATION_Caller *caller, |
828 | struct GNUNET_SPEAKER_Handle *speaker, | 832 | struct GNUNET_SPEAKER_Handle *speaker, |
829 | struct GNUNET_MICROPHONE_Handle *mic) | 833 | struct GNUNET_MICROPHONE_Handle *mic) |
830 | { | 834 | { |
831 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; | 835 | struct GNUNET_CONVERSATION_Phone *phone = caller->phone; |
832 | struct GNUNET_MQ_Envelope *e; | 836 | struct GNUNET_MQ_Envelope *e; |
833 | struct ClientPhoneResumeMessage *resume; | 837 | struct ClientPhoneResumeMessage *resume; |
834 | 838 | ||
835 | GNUNET_assert ( (CS_CALLEE_SUSPENDED == caller->state) || | 839 | GNUNET_assert((CS_CALLEE_SUSPENDED == caller->state) || |
836 | (CS_BOTH_SUSPENDED == caller->state) ); | 840 | (CS_BOTH_SUSPENDED == caller->state)); |
837 | caller->speaker = speaker; | 841 | caller->speaker = speaker; |
838 | caller->mic = mic; | 842 | caller->mic = mic; |
839 | e = GNUNET_MQ_msg (resume, | 843 | e = GNUNET_MQ_msg(resume, |
840 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME); | 844 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME); |
841 | resume->cid = caller->cid; | 845 | resume->cid = caller->cid; |
842 | GNUNET_MQ_send (phone->mq, | 846 | GNUNET_MQ_send(phone->mq, |
843 | e); | 847 | e); |
844 | if (CS_CALLEE_SUSPENDED == caller->state) | 848 | if (CS_CALLEE_SUSPENDED == caller->state) |
845 | { | 849 | { |
846 | caller->state = CS_ACTIVE; | 850 | caller->state = CS_ACTIVE; |
847 | caller->speaker->enable_speaker (caller->speaker->cls); | 851 | caller->speaker->enable_speaker(caller->speaker->cls); |
848 | caller->mic->enable_microphone (caller->mic->cls, | 852 | caller->mic->enable_microphone(caller->mic->cls, |
849 | &transmit_phone_audio, | 853 | &transmit_phone_audio, |
850 | caller); | 854 | caller); |
851 | } | 855 | } |
852 | else | 856 | else |
853 | { | 857 | { |
854 | caller->state = CS_CALLER_SUSPENDED; | 858 | caller->state = CS_CALLER_SUSPENDED; |
855 | } | 859 | } |
856 | } | 860 | } |
857 | 861 | ||
858 | /* end of conversation_api.c */ | 862 | /* end of conversation_api.c */ |