/*
This file is part of GNUnet
- (C) 2013 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2013 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
static void
reconnect_call (struct GNUNET_CONVERSATION_Call *call)
{
- 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_CRYPTO_EcdsaPublicKey my_zone;
-
if (CS_ACTIVE == call->state)
{
call->speaker->disable_speaker (call->speaker->cls);
call->client = NULL;
}
call->state = CS_SHUTDOWN;
- call->client = GNUNET_CLIENT_connect ("conversation", call->cfg);
- if (NULL == call->client)
- {
- call->event_handler (call->event_handler_cls,
+ call->event_handler (call->event_handler_cls,
GNUNET_CONVERSATION_EC_CALL_ERROR);
- return;
- }
-
- call->mq = GNUNET_MQ_queue_for_connection_client (call->client,
- handlers,
- &call_error_handler,
- call);
- call->state = CS_LOOKUP;
- GNUNET_IDENTITY_ego_get_public_key (call->zone_id,
- &my_zone);
- call->gns_lookup = GNUNET_GNS_lookup (call->gns,
- call->callee,
- &my_zone,
- GNUNET_GNSRECORD_TYPE_PHONE,
- GNUNET_NO,
- NULL /* FIXME: add shortening support */,
- &handle_gns_response, call);
- GNUNET_assert (NULL != call->gns_lookup);
+ GNUNET_CONVERSATION_call_stop (call);
}
* #GNUNET_CONVERSATION_EC_CALL_PICKED_UP event is generated)
* @param event_handler how to notify the owner of the phone about events
* @param event_handler_cls closure for @a event_handler
+ * @return handle for the call, NULL on hard errors
*/
struct GNUNET_CONVERSATION_Call *
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_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)
+ {
+ GNUNET_break (0);
+ GNUNET_free (call);
+ return NULL;
+ }
call->cfg = cfg;
call->caller_id = caller_id;
call->zone_id = zone_id;
call->event_handler = event_handler;
call->event_handler_cls = event_handler_cls;
call->gns = GNUNET_GNS_connect (cfg);
- reconnect_call (call);
-
- if ( (NULL == call->client) ||
- (NULL == call->gns) )
+ if (NULL == call->gns)
{
GNUNET_CONVERSATION_call_stop (call);
return NULL;
}
+ call->mq = GNUNET_MQ_queue_for_connection_client (call->client,
+ handlers,
+ &call_error_handler,
+ call);
+ call->state = CS_LOOKUP;
+ GNUNET_IDENTITY_ego_get_public_key (call->zone_id,
+ &my_zone);
+ call->gns_lookup = GNUNET_GNS_lookup (call->gns,
+ call->callee,
+ &my_zone,
+ GNUNET_GNSRECORD_TYPE_PHONE,
+ GNUNET_NO,
+ NULL /* FIXME: add shortening support */,
+ &handle_gns_response, call);
+ GNUNET_assert (NULL != call->gns_lookup);
return call;
}