From b80608ac3f45338f9f8146be2717ef181b36e9c0 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 1 Jun 2012 17:17:42 +0200 Subject: [PATCH] Abort preparing contact-list feature early if CONTACTS iface is missing Current code has issues: 1) It's possible it completes without returning to mainloop first 2) contact-list-state could regress from SUCCESS to FAILED https://bugs.freedesktop.org/show_bug.cgi?id=49373 --- telepathy-glib/connection-contact-list.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/telepathy-glib/connection-contact-list.c b/telepathy-glib/connection-contact-list.c index 85eddac..f3f4673 100644 --- a/telepathy-glib/connection-contact-list.c +++ b/telepathy-glib/connection-contact-list.c @@ -228,7 +228,6 @@ got_contact_list_attributes_cb (TpConnection *self, GObject *weak_object) { GSimpleAsyncResult *result = (GSimpleAsyncResult *) weak_object; - /* may be NULL if error != NULL, when calling directly */ GArray *features = user_data; GHashTableIter iter; gpointer key, value; @@ -302,19 +301,6 @@ prepare_roster (TpConnection *self, DEBUG ("CM has the roster for connection %s, fetch it now.", tp_proxy_get_object_path (self)); - /* Pre-empt _tp_contacts_bind_to_signals, which assumes that Contacts - * is present and works correctly */ - if (!tp_proxy_has_interface_by_id (self, - TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACTS)) - { - GError error = { TP_DBUS_ERRORS, TP_DBUS_ERROR_NO_INTERFACE, - "Obsolete CM does not have the Contacts interface" }; - - got_contact_list_attributes_cb (self, NULL, &error, NULL, - (GObject *) result); - return; - } - tp_cli_connection_interface_contact_list_connect_to_contacts_changed ( self, contacts_changed_cb, NULL, NULL, NULL, NULL); @@ -426,6 +412,18 @@ void _tp_connection_prepare_contact_list_async (TpProxy *proxy, TpConnection *self = (TpConnection *) proxy; GSimpleAsyncResult *result; + /* Pre-empt _tp_contacts_bind_to_signals, which assumes that Contacts + * is present and works correctly */ + if (!tp_proxy_has_interface_by_id (self, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CONTACTS)) + { + g_simple_async_report_error_in_idle ((GObject *) self, + callback, user_data, + TP_DBUS_ERRORS, TP_DBUS_ERROR_NO_INTERFACE, + "Obsolete CM does not have the Contacts interface"); + return; + } + result = g_simple_async_result_new ((GObject *) self, callback, user_data, _tp_connection_prepare_contact_list_async); -- 1.7.9.5