aboutsummaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation')
-rw-r--r--src/conversation/conversation_api_call.c84
1 files changed, 51 insertions, 33 deletions
diff --git a/src/conversation/conversation_api_call.c b/src/conversation/conversation_api_call.c
index 0984290d3..51b07b7c8 100644
--- a/src/conversation/conversation_api_call.c
+++ b/src/conversation/conversation_api_call.c
@@ -188,14 +188,14 @@ transmit_call_audio (void *cls,
188 188
189 189
190/** 190/**
191 * We received a `struct ClientPhoneSuspendMessage` 191 * We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND.
192 * 192 *
193 * @param cls the `struct GNUNET_CONVERSATION_Call` 193 * @param cls the `struct GNUNET_CONVERSATION_Call`
194 * @param msg the message 194 * @param msg the message
195 */ 195 */
196static void 196static void
197handle_call_suspend (void *cls, 197handle_call_suspend (void *cls,
198 const struct GNUNET_MessageHeader *msg) 198 const struct ClientPhoneSuspendMessage *msg)
199{ 199{
200 struct GNUNET_CONVERSATION_Call *call = cls; 200 struct GNUNET_CONVERSATION_Call *call = cls;
201 201
@@ -233,14 +233,14 @@ handle_call_suspend (void *cls,
233 233
234 234
235/** 235/**
236 * We received a `struct ClientPhoneResumeMessage` 236 * We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME.
237 * 237 *
238 * @param cls the `struct GNUNET_CONVERSATION_Call` 238 * @param cls the `struct GNUNET_CONVERSATION_Call`
239 * @param msg the message 239 * @param msg the message
240 */ 240 */
241static void 241static void
242handle_call_resume (void *cls, 242handle_call_resume (void *cls,
243 const struct GNUNET_MessageHeader *msg) 243 const struct ClientPhoneResumeMessage *msg)
244{ 244{
245 struct GNUNET_CONVERSATION_Call *call = cls; 245 struct GNUNET_CONVERSATION_Call *call = cls;
246 246
@@ -282,14 +282,14 @@ handle_call_resume (void *cls,
282 282
283 283
284/** 284/**
285 * We received a `struct ClientPhonePickedupMessage` 285 * We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP.
286 * 286 *
287 * @param cls the `struct GNUNET_CONVERSATION_Call` 287 * @param cls the `struct GNUNET_CONVERSATION_Call`
288 * @param msg the message 288 * @param msg the message
289 */ 289 */
290static void 290static void
291handle_call_picked_up (void *cls, 291handle_call_picked_up (void *cls,
292 const struct GNUNET_MessageHeader *msg) 292 const struct ClientPhonePickedupMessage *msg)
293{ 293{
294 struct GNUNET_CONVERSATION_Call *call = cls; 294 struct GNUNET_CONVERSATION_Call *call = cls;
295 295
@@ -323,14 +323,14 @@ handle_call_picked_up (void *cls,
323 323
324 324
325/** 325/**
326 * We received a `struct ClientPhoneHangupMessage` 326 * We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_HANG_UP.
327 * 327 *
328 * @param cls the `struct GNUNET_CONVERSATION_Call` 328 * @param cls the `struct GNUNET_CONVERSATION_Call`
329 * @param msg the message 329 * @param msg the message
330 */ 330 */
331static void 331static void
332handle_call_hangup (void *cls, 332handle_call_hangup (void *cls,
333 const struct GNUNET_MessageHeader *msg) 333 const struct ClientPhoneHangupMessage *msg)
334{ 334{
335 struct GNUNET_CONVERSATION_Call *call = cls; 335 struct GNUNET_CONVERSATION_Call *call = cls;
336 GNUNET_CONVERSATION_CallEventHandler eh; 336 GNUNET_CONVERSATION_CallEventHandler eh;
@@ -360,19 +360,33 @@ handle_call_hangup (void *cls,
360 360
361 361
362/** 362/**
363 * We received a `struct ClientAudioMessage`, check it is well-formed.
364 *
365 * @param cls the `struct GNUNET_CONVERSATION_Call`
366 * @param msg the message
367 * @return #GNUNET_OK (always well-formed)
368 */
369static int
370check_call_audio (void *cls,
371 const struct ClientAudioMessage *am)
372{
373 /* any payload is OK */
374 return GNUNET_OK;
375}
376
377
378/**
363 * We received a `struct ClientAudioMessage` 379 * We received a `struct ClientAudioMessage`
364 * 380 *
365 * @param cls the `struct GNUNET_CONVERSATION_Call` 381 * @param cls the `struct GNUNET_CONVERSATION_Call`
366 * @param msg the message 382 * @param msg the message
367 */ 383 */
368static void 384static void
369handle_call_audio_message (void *cls, 385handle_call_audio (void *cls,
370 const struct GNUNET_MessageHeader *msg) 386 const struct ClientAudioMessage *am)
371{ 387{
372 struct GNUNET_CONVERSATION_Call *call = cls; 388 struct GNUNET_CONVERSATION_Call *call = cls;
373 const struct ClientAudioMessage *am;
374 389
375 am = (const struct ClientAudioMessage *) msg;
376 switch (call->state) 390 switch (call->state)
377 { 391 {
378 case CS_LOOKUP: 392 case CS_LOOKUP:
@@ -394,7 +408,7 @@ handle_call_audio_message (void *cls,
394 break; 408 break;
395 case CS_ACTIVE: 409 case CS_ACTIVE:
396 call->speaker->play (call->speaker->cls, 410 call->speaker->play (call->speaker->cls,
397 ntohs (msg->size) - sizeof (struct ClientAudioMessage), 411 ntohs (am->header.size) - sizeof (struct ClientAudioMessage),
398 &am[1]); 412 &am[1]);
399 break; 413 break;
400 case CS_SHUTDOWN: 414 case CS_SHUTDOWN:
@@ -533,29 +547,33 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
533 GNUNET_CONVERSATION_CallEventHandler event_handler, 547 GNUNET_CONVERSATION_CallEventHandler event_handler,
534 void *event_handler_cls) 548 void *event_handler_cls)
535{ 549{
536 static struct GNUNET_MQ_MessageHandler handlers[] = 550 struct GNUNET_CONVERSATION_Call *call
537 { 551 = GNUNET_new (struct GNUNET_CONVERSATION_Call);
538 { &handle_call_suspend, 552 GNUNET_MQ_hd_fixed_size (call_suspend,
539 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND, 553 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND,
540 sizeof (struct ClientPhoneSuspendMessage) }, 554 struct ClientPhoneSuspendMessage);
541 { &handle_call_resume, 555 GNUNET_MQ_hd_fixed_size (call_resume,
542 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME, 556 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME,
543 sizeof (struct ClientPhoneResumeMessage) }, 557 struct ClientPhoneResumeMessage);
544 { &handle_call_picked_up, 558 GNUNET_MQ_hd_fixed_size (call_picked_up,
545 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP, 559 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP,
546 sizeof (struct ClientPhonePickedupMessage) }, 560 struct ClientPhonePickedupMessage);
547 { &handle_call_hangup, 561 GNUNET_MQ_hd_fixed_size (call_hangup,
548 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP, 562 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP,
549 sizeof (struct ClientPhoneHangupMessage) }, 563 struct ClientPhoneHangupMessage);
550 { &handle_call_audio_message, 564 GNUNET_MQ_hd_var_size (call_audio,
551 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO, 565 GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO,
552 0 }, 566 struct ClientAudioMessage);
553 { NULL, 0, 0 } 567 struct GNUNET_MQ_MessageHandler handlers[] = {
568 make_call_suspend_handler (call),
569 make_call_resume_handler (call),
570 make_call_picked_up_handler (call),
571 make_call_hangup_handler (call),
572 make_call_audio_handler (call),
573 GNUNET_MQ_handler_end ()
554 }; 574 };
555 struct GNUNET_CRYPTO_EcdsaPublicKey my_zone; 575 struct GNUNET_CRYPTO_EcdsaPublicKey my_zone;
556 struct GNUNET_CONVERSATION_Call *call;
557 576
558 call = GNUNET_new (struct GNUNET_CONVERSATION_Call);
559 call->client = GNUNET_CLIENT_connect ("conversation", cfg); 577 call->client = GNUNET_CLIENT_connect ("conversation", cfg);
560 if (NULL == call->client) 578 if (NULL == call->client)
561 { 579 {