From a129eafa4c349d30f6a1323f854bf31d69bb776f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 7 Oct 2013 09:28:41 +0000 Subject: -transmit termination reason also for caller hanging up --- src/conversation/conversation_api.c | 47 +++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'src/conversation/conversation_api.c') diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c index 6e1cbe3fb..50ee0a23a 100644 --- a/src/conversation/conversation_api.c +++ b/src/conversation/conversation_api.c @@ -1070,6 +1070,21 @@ GNUNET_CONVERSATION_call_start (const struct GNUNET_CONFIGURATION_Handle *cfg, } +/** + * We've sent the hang up message, now finish terminating the call. + * + * @param cls the `struct GNUNET_CONVERSATION_Call` to terminate + */ +static void +finish_stop (void *cls) +{ + struct GNUNET_CONVERSATION_Call *call = cls; + + GNUNET_assert (CS_SHUTDOWN == call->state); + GNUNET_CONVERSATION_call_stop (call, NULL); +} + + /** * Terminate a call. The call may be ringing or ready at this time. * @@ -1081,23 +1096,25 @@ void GNUNET_CONVERSATION_call_stop (struct GNUNET_CONVERSATION_Call *call, const char *reason) { + struct GNUNET_MQ_Envelope *e; + struct ClientPhoneHangupMessage *hang; + size_t slen; + + if ( (NULL != call->speaker) && + (CS_ACTIVE == call->state) ) + call->speaker->disable_speaker (call->speaker->cls); + if ( (NULL != call->mic) && + (CS_ACTIVE == call->state) ) + call->mic->disable_microphone (call->mic->cls); if (NULL != reason) { - // FIXME: transmit reason to service... (not implemented!) - GNUNET_break (0); - // return; - } - if (NULL != call->speaker) - { - if (CS_ACTIVE == call->state) - call->speaker->disable_speaker (call->speaker->cls); - call->speaker = NULL; - } - if (NULL != call->mic) - { - if (CS_ACTIVE == call->state) - call->mic->disable_microphone (call->mic->cls); - call->mic =NULL; + slen = strlen (reason) + 1; + e = GNUNET_MQ_msg_extra (hang, slen, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); + memcpy (&hang[1], reason, slen); + GNUNET_MQ_notify_sent (e, &finish_stop, call); + GNUNET_MQ_send (call->mq, e); + call->state = CS_SHUTDOWN; + return; } if (NULL != call->mq) { -- cgit v1.2.3