From 50cad5e06347b2fa49d6718034bcdb552d43b4d3 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Fri, 9 Jan 2009 16:15:43 +0000 Subject: Port to the new empathy_call_when_ready api Signed-off-by: Sjoerd Simons svn path=/trunk/; revision=2193 --- libempathy/empathy-dispatcher.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'libempathy') diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index bde8b6a1a..a0d5fbc3d 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -902,6 +902,22 @@ empathy_dispatcher_dup_singleton (void) return EMPATHY_DISPATCHER (g_object_new (EMPATHY_TYPE_DISPATCHER, NULL)); } +static void +dispatcher_request_failed (EmpathyDispatcher *dispatcher, + DispatcherRequestData *request_data, const GError *error) +{ + EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher); + ConnectionData *conn_data; + + conn_data = g_hash_table_lookup (priv->connections, request_data->connection); + if (request_data->cb != NULL) + request_data->cb (NULL, error, request_data->user_data); + + conn_data->outstanding_requests = + g_list_remove (conn_data->outstanding_requests, request_data); + free_dispatcher_request_data (request_data); +} + static void dispatcher_connection_new_requested_channel (EmpathyDispatcher *dispatcher, DispatcherRequestData *request_data, const gchar *object_path, @@ -918,12 +934,7 @@ dispatcher_connection_new_requested_channel (EmpathyDispatcher *dispatcher, { DEBUG ("Channel request failed: %s", error->message); - if (request_data->cb != NULL) - request_data->cb (NULL, error, request_data->user_data); - - conn_data->outstanding_requests = - g_list_remove (conn_data->outstanding_requests, request_data); - free_dispatcher_request_data (request_data); + dispatcher_request_failed (dispatcher, request_data, error); goto out; } @@ -1043,7 +1054,8 @@ empathy_dispatcher_call_with_contact ( EmpathyContact *contact, static void -dispatcher_chat_with_contact_cb (EmpathyContact *contact, gpointer user_data) +dispatcher_chat_with_contact_cb (EmpathyContact *contact, + const GError *error, gpointer user_data, GObject *object) { DispatcherRequestData *request_data = (DispatcherRequestData *) user_data; @@ -1080,7 +1092,7 @@ empathy_dispatcher_chat_with_contact (EmpathyContact *contact, empathy_contact_call_when_ready (contact, EMPATHY_CONTACT_READY_HANDLE, dispatcher_chat_with_contact_cb, - request_data); + request_data, NULL, G_OBJECT (dispatcher)); g_object_unref (dispatcher); } @@ -1184,13 +1196,20 @@ dispatcher_create_channel_cb (TpConnection *connect, static void dispatcher_create_channel_with_contact_cb (EmpathyContact *contact, - gpointer user_data) + const GError *error, gpointer user_data, GObject *object) { DispatcherRequestData *request_data = (DispatcherRequestData *) user_data; GValue *target_handle; g_assert (request_data->request); + if (error != NULL) + { + dispatcher_request_failed (request_data->dispatcher, + request_data, error); + return; + } + request_data->handle = empathy_contact_get_handle (contact); target_handle = tp_g_value_slice_new (G_TYPE_UINT); @@ -1265,7 +1284,7 @@ empathy_dispatcher_send_file_to_contact (EmpathyContact *contact, empathy_contact_call_when_ready (contact, EMPATHY_CONTACT_READY_HANDLE, dispatcher_create_channel_with_contact_cb, - request_data); + request_data, NULL, G_OBJECT (dispatcher)); g_object_unref (dispatcher); } -- cgit v1.2.3