summaryrefslogtreecommitdiff
path: root/src/conversation
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-18 20:07:17 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-18 20:07:17 +0000
commite35e4dbeb9c349981d0092542aa1e3813bf844c9 (patch)
treeb9a0fc319d724c42a47aeb3584a470529c74ee89 /src/conversation
parent577d21f282478d36c8665e0a7a2d2ee07bddd56d (diff)
convert conversation_api_call.c
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,
/**
- * We received a `struct ClientPhoneSuspendMessage`
+ * We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND.
*
* @param cls the `struct GNUNET_CONVERSATION_Call`
* @param msg the message
*/
static void
handle_call_suspend (void *cls,
- const struct GNUNET_MessageHeader *msg)
+ const struct ClientPhoneSuspendMessage *msg)
{
struct GNUNET_CONVERSATION_Call *call = cls;
@@ -233,14 +233,14 @@ handle_call_suspend (void *cls,
/**
- * We received a `struct ClientPhoneResumeMessage`
+ * We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME.
*
* @param cls the `struct GNUNET_CONVERSATION_Call`
* @param msg the message
*/
static void
handle_call_resume (void *cls,
- const struct GNUNET_MessageHeader *msg)
+ const struct ClientPhoneResumeMessage *msg)
{
struct GNUNET_CONVERSATION_Call *call = cls;
@@ -282,14 +282,14 @@ handle_call_resume (void *cls,
/**
- * We received a `struct ClientPhonePickedupMessage`
+ * We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP.
*
* @param cls the `struct GNUNET_CONVERSATION_Call`
* @param msg the message
*/
static void
handle_call_picked_up (void *cls,
- const struct GNUNET_MessageHeader *msg)
+ const struct ClientPhonePickedupMessage *msg)
{
struct GNUNET_CONVERSATION_Call *call = cls;
@@ -323,14 +323,14 @@ handle_call_picked_up (void *cls,
/**
- * We received a `struct ClientPhoneHangupMessage`
+ * We received a #GNUNET_MESSAGE_TYPE_CONVERSATION_CS_HANG_UP.
*
* @param cls the `struct GNUNET_CONVERSATION_Call`
* @param msg the message
*/
static void
handle_call_hangup (void *cls,
- const struct GNUNET_MessageHeader *msg)
+ const struct ClientPhoneHangupMessage *msg)
{
struct GNUNET_CONVERSATION_Call *call = cls;
GNUNET_CONVERSATION_CallEventHandler eh;
@@ -360,19 +360,33 @@ handle_call_hangup (void *cls,
/**
+ * We received a `struct ClientAudioMessage`, check it is well-formed.
+ *
+ * @param cls the `struct GNUNET_CONVERSATION_Call`
+ * @param msg the message
+ * @return #GNUNET_OK (always well-formed)
+ */
+static int
+check_call_audio (void *cls,
+ const struct ClientAudioMessage *am)
+{
+ /* any payload is OK */
+ return GNUNET_OK;
+}
+
+
+/**
* We received a `struct ClientAudioMessage`
*
* @param cls the `struct GNUNET_CONVERSATION_Call`
* @param msg the message
*/
static void
-handle_call_audio_message (void *cls,
- const struct GNUNET_MessageHeader *msg)
+handle_call_audio (void *cls,
+ const struct ClientAudioMessage *am)
{
struct GNUNET_CONVERSATION_Call *call = cls;
- const struct ClientAudioMessage *am;
- am = (const struct ClientAudioMessage *) msg;
switch (call->state)
{
case CS_LOOKUP:
@@ -394,7 +408,7 @@ handle_call_audio_message (void *cls,
break;
case CS_ACTIVE:
call->speaker->play (call->speaker->cls,
- ntohs (msg->size) - sizeof (struct ClientAudioMessage),
+ ntohs (am->header.size) - sizeof (struct ClientAudioMessage),
&am[1]);
break;
case CS_SHUTDOWN:
@@ -533,29 +547,33 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_CONVERSATION_CallEventHandler event_handler,
void *event_handler_cls)
{
- static struct GNUNET_MQ_MessageHandler handlers[] =
- {
- { &handle_call_suspend,
- GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND,
- sizeof (struct ClientPhoneSuspendMessage) },
- { &handle_call_resume,
- GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME,
- sizeof (struct ClientPhoneResumeMessage) },
- { &handle_call_picked_up,
- GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP,
- sizeof (struct ClientPhonePickedupMessage) },
- { &handle_call_hangup,
- GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP,
- sizeof (struct ClientPhoneHangupMessage) },
- { &handle_call_audio_message,
- GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO,
- 0 },
- { NULL, 0, 0 }
+ struct GNUNET_CONVERSATION_Call *call
+ = GNUNET_new (struct GNUNET_CONVERSATION_Call);
+ GNUNET_MQ_hd_fixed_size (call_suspend,
+ GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_SUSPEND,
+ struct ClientPhoneSuspendMessage);
+ GNUNET_MQ_hd_fixed_size (call_resume,
+ GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_RESUME,
+ struct ClientPhoneResumeMessage);
+ GNUNET_MQ_hd_fixed_size (call_picked_up,
+ GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_PICKED_UP,
+ struct ClientPhonePickedupMessage);
+ GNUNET_MQ_hd_fixed_size (call_hangup,
+ GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP,
+ struct ClientPhoneHangupMessage);
+ GNUNET_MQ_hd_var_size (call_audio,
+ GNUNET_MESSAGE_TYPE_CONVERSATION_CS_AUDIO,
+ struct ClientAudioMessage);
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ make_call_suspend_handler (call),
+ make_call_resume_handler (call),
+ make_call_picked_up_handler (call),
+ make_call_hangup_handler (call),
+ make_call_audio_handler (call),
+ GNUNET_MQ_handler_end ()
};
struct GNUNET_CRYPTO_EcdsaPublicKey my_zone;
- struct GNUNET_CONVERSATION_Call *call;
- call = GNUNET_new (struct GNUNET_CONVERSATION_Call);
call->client = GNUNET_CLIENT_connect ("conversation", cfg);
if (NULL == call->client)
{