From 05b36a709563320562f0f975b77822e25d101ef2 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Tue, 29 May 2012 13:28:38 +0200 Subject: [PATCH] WIP: TpBaseConnection: use tp_handle_ensure_async() in RequestHandles https://bugs.freedesktop.org/show_bug.cgi?id=50341 --- telepathy-glib/base-connection.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c index fe268fc..3776590 100644 --- a/telepathy-glib/base-connection.c +++ b/telepathy-glib/base-connection.c @@ -2507,6 +2507,32 @@ tp_base_connection_release_handles (TpSvcConnection *iface, tp_svc_connection_return_from_release_handles (context); } +static void +ensure_handle_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + TpHandleRepoIface *repo = (TpHandleRepoIface *) source; + DBusGMethodInvocation *context = user_data; + TpHandle handle; + GArray *handles; + GError *error = NULL; + + handle = tp_handle_ensure_finish (repo, result, &error); + if (handle == 0) + { + dbus_g_method_return_error (context, error); + g_clear_error (&error); + return; + } + + handles = g_array_new (FALSE, FALSE, sizeof (guint)); + g_array_append_val (handles, handle); + + tp_svc_connection_return_from_request_handles (context, handles); + + g_array_unref (handles); +} /** * tp_base_connection_dbus_request_handles: (skip) @@ -2561,6 +2587,14 @@ tp_base_connection_dbus_request_handles (TpSvcConnection *iface, goto out; } + /* FIXME: Quick And Dirty hack */ + if (count == 1 && handle_type == TP_HANDLE_TYPE_CONTACT) + { + tp_handle_ensure_async (handle_repo, self, names[0], NULL, + ensure_handle_cb, context); + return; + } + handles = g_array_sized_new (FALSE, FALSE, sizeof (guint), count); for (i = 0; i < count; i++) -- 1.7.9.5