aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-18 18:49:13 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-18 18:49:13 +0000
commit710e8923105dfcc38d8aefed19e6da670db9c440 (patch)
treec6e46d41beedcf3ac2b13a1e040a790db8aa794a /src/conversation
parent5dfc382a9f8467cd15b6a0c3a6e022fca9fc4a30 (diff)
downloadgnunet-710e8923105dfcc38d8aefed19e6da670db9c440.tar.gz
gnunet-710e8923105dfcc38d8aefed19e6da670db9c440.zip
partial refactoring, will cause FTBFS, to be completed ASAP
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/conversation_api.c88
1 files changed, 49 insertions, 39 deletions
diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c
index f28e71a98..a9dc1f27f 100644
--- a/src/conversation/conversation_api.c
+++ b/src/conversation/conversation_api.c
@@ -252,17 +252,15 @@ transmit_phone_audio (void *cls,
252 * We received a `struct ClientPhoneRingMessage` 252 * We received a `struct ClientPhoneRingMessage`
253 * 253 *
254 * @param cls the `struct GNUNET_CONVERSATION_Phone` 254 * @param cls the `struct GNUNET_CONVERSATION_Phone`
255 * @param msg the message 255 * @param ring the message
256 */ 256 */
257static void 257static void
258handle_phone_ring (void *cls, 258handle_phone_ring (void *cls,
259 const struct GNUNET_MessageHeader *msg) 259 const struct ClientPhoneRingMessage *ring)
260{ 260{
261 struct GNUNET_CONVERSATION_Phone *phone = cls; 261 struct GNUNET_CONVERSATION_Phone *phone = cls;
262 const struct ClientPhoneRingMessage *ring;
263 struct GNUNET_CONVERSATION_Caller *caller; 262 struct GNUNET_CONVERSATION_Caller *caller;
264 263
265 ring = (const struct ClientPhoneRingMessage *) msg;
266 switch (phone->state) 264 switch (phone->state)
267 { 265 {
268 case PS_REGISTER: 266 case PS_REGISTER:
@@ -294,13 +292,11 @@ handle_phone_ring (void *cls,
294 */ 292 */
295static void 293static void
296handle_phone_hangup (void *cls, 294handle_phone_hangup (void *cls,
297 const struct GNUNET_MessageHeader *msg) 295 const struct ClientPhoneHangupMessage *hang)
298{ 296{
299 struct GNUNET_CONVERSATION_Phone *phone = cls; 297 struct GNUNET_CONVERSATION_Phone *phone = cls;
300 const struct ClientPhoneHangupMessage *hang;
301 struct GNUNET_CONVERSATION_Caller *caller; 298 struct GNUNET_CONVERSATION_Caller *caller;
302 299
303 hang = (const struct ClientPhoneHangupMessage *) msg;
304 for (caller = phone->caller_head; NULL != caller; caller = caller->next) 300 for (caller = phone->caller_head; NULL != caller; caller = caller->next)
305 if (hang->cid == caller->cid) 301 if (hang->cid == caller->cid)
306 break; 302 break;
@@ -351,17 +347,15 @@ handle_phone_hangup (void *cls,
351 * We received a `struct ClientPhoneSuspendMessage`. 347 * We received a `struct ClientPhoneSuspendMessage`.
352 * 348 *
353 * @param cls the `struct GNUNET_CONVERSATION_Phone` 349 * @param cls the `struct GNUNET_CONVERSATION_Phone`
354 * @param msg the message 350 * @param suspend the message
355 */ 351 */
356static void 352static void
357handle_phone_suspend (void *cls, 353handle_phone_suspend (void *cls,
358 const struct GNUNET_MessageHeader *msg) 354 const struct ClientPhoneSuspendMessage *suspend)
359{ 355{
360 struct GNUNET_CONVERSATION_Phone *phone = cls; 356 struct GNUNET_CONVERSATION_Phone *phone = cls;
361 struct GNUNET_CONVERSATION_Caller *caller; 357 struct GNUNET_CONVERSATION_Caller *caller;
362 const struct ClientPhoneSuspendMessage *suspend;
363 358
364 suspend = (const struct ClientPhoneSuspendMessage *) msg;
365 for (caller = phone->caller_head; NULL != caller; caller = caller->next) 359 for (caller = phone->caller_head; NULL != caller; caller = caller->next)
366 if (suspend->cid == caller->cid) 360 if (suspend->cid == caller->cid)
367 break; 361 break;
@@ -396,17 +390,15 @@ handle_phone_suspend (void *cls,
396 * We received a `struct ClientPhoneResumeMessage`. 390 * We received a `struct ClientPhoneResumeMessage`.
397 * 391 *
398 * @param cls the `struct GNUNET_CONVERSATION_Phone` 392 * @param cls the `struct GNUNET_CONVERSATION_Phone`
399 * @param msg the message 393 * @param resume the message
400 */ 394 */
401static void 395static void
402handle_phone_resume (void *cls, 396handle_phone_resume (void *cls,
403 const struct GNUNET_MessageHeader *msg) 397 const struct ClientPhoneResumeMessage *resume)
404{ 398{
405 struct GNUNET_CONVERSATION_Phone *phone = cls; 399 struct GNUNET_CONVERSATION_Phone *phone = cls;
406 struct GNUNET_CONVERSATION_Caller *caller; 400 struct GNUNET_CONVERSATION_Caller *caller;
407 const struct ClientPhoneResumeMessage *resume;
408 401
409 resume = (const struct ClientPhoneResumeMessage *) msg;
410 for (caller = phone->caller_head; NULL != caller; caller = caller->next) 402 for (caller = phone->caller_head; NULL != caller; caller = caller->next)
411 if (resume->cid == caller->cid) 403 if (resume->cid == caller->cid)
412 break; 404 break;
@@ -440,20 +432,34 @@ handle_phone_resume (void *cls,
440 432
441 433
442/** 434/**
435 * We received a `struct ClientAudioMessage`, check it is well-formed.
436 *
437 * @param cls the `struct GNUNET_CONVERSATION_Phone`
438 * @param am the message
439 * @return #GNUNET_OK if @a am is well-formed
440 */
441static int
442check_phone_audio (void *cls,
443 const struct ClientAudioMessage *am)
444{
445 /* any variable-size payload is OK */
446 return GNUNET_OK;
447}
448
449
450/**
443 * We received a `struct ClientAudioMessage` 451 * We received a `struct ClientAudioMessage`
444 * 452 *
445 * @param cls the `struct GNUNET_CONVERSATION_Phone` 453 * @param cls the `struct GNUNET_CONVERSATION_Phone`
446 * @param msg the message 454 * @param am the message
447 */ 455 */
448static void 456static void
449handle_phone_audio_message (void *cls, 457handle_phone_audio (void *cls,
450 const struct GNUNET_MessageHeader *msg) 458 const struct ClientAudioMessage *am)
451{ 459{
452 struct GNUNET_CONVERSATION_Phone *phone = cls; 460 struct GNUNET_CONVERSATION_Phone *phone = cls;
453 const struct ClientAudioMessage *am;
454 struct GNUNET_CONVERSATION_Caller *caller; 461 struct GNUNET_CONVERSATION_Caller *caller;
455 462
456 am = (const struct ClientAudioMessage *) msg;
457 for (caller = phone->caller_head; NULL != caller; caller = caller->next) 463 for (caller = phone->caller_head; NULL != caller; caller = caller->next)
458 if (am->cid == caller->cid) 464 if (am->cid == caller->cid)
459 break; 465 break;
@@ -466,7 +472,7 @@ handle_phone_audio_message (void *cls,
466 break; 472 break;
467 case CS_ACTIVE: 473 case CS_ACTIVE:
468 caller->speaker->play (caller->speaker->cls, 474 caller->speaker->play (caller->speaker->cls,
469 ntohs (msg->size) - sizeof (struct ClientAudioMessage), 475 ntohs (am->header.size) - sizeof (struct ClientAudioMessage),
470 &am[1]); 476 &am[1]);
471 break; 477 break;
472 case CS_CALLEE_SUSPENDED: 478 case CS_CALLEE_SUSPENDED:
@@ -531,24 +537,28 @@ clean_up_callers (struct GNUNET_CONVERSATION_Phone *phone)
531static void 537static void
532reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone) 538reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone)
533{ 539{
534 static struct GNUNET_MQ_MessageHandler handlers[] = 540 GNUNET_MQ_hd_fixed_size (phone_ring,
535 { 541 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING,
536 { &handle_phone_ring, 542 struct ClientPhoneRingMessage);
537 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RING, 543 GNUNET_MQ_hd_fixed_size (phone_hangup,
538 sizeof (struct ClientPhoneRingMessage) }, 544 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP,
539 { &handle_phone_hangup, 545 struct ClientPhoneHangupMessage);
540 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, 546 GNUNET_MQ_hd_fixed_size (phone_suspend,
541 sizeof (struct ClientPhoneHangupMessage) }, 547 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND,
542 { &handle_phone_suspend, 548 struct ClientPhoneSuspendMessage);
543 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, 549 GNUNET_MQ_hd_fixed_size (phone_resume,
544 sizeof (struct ClientPhoneSuspendMessage) }, 550 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME,
545 { &handle_phone_resume, 551 struct ClientPhoneResumeMessage);
546 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, 552 GNUNET_MQ_hd_var_size (phone_audio,
547 sizeof (struct ClientPhoneResumeMessage) }, 553 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO,
548 { &handle_phone_audio_message, 554 struct ClientAudioMessage);
549 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, 555 struct GNUNET_MQ_MessageHandler handlers[] = {
550 0 }, 556 make_phone_ring_handler (phone),
551 { NULL, 0, 0 } 557 make_phone_hangup_handler (phone),
558 make_phone_suspend_handler (phone),
559 make_phone_resume_handler (phone),
560 make_phone_audio_handler (phone),
561 GNUNET_MQ_handler_end ()
552 }; 562 };
553 struct GNUNET_MQ_Envelope *e; 563 struct GNUNET_MQ_Envelope *e;
554 struct ClientPhoneRegisterMessage *reg; 564 struct ClientPhoneRegisterMessage *reg;