[next] telepathy-glib: connection-contact-list: don't crash if no Contacts
Simon McVittie
smcv at kemper.freedesktop.org
Fri May 11 07:29:13 PDT 2012
Module: telepathy-glib
Branch: next
Commit: 203515cea77126c5a1b7d6d8cfc2ae372d34ab08
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=203515cea77126c5a1b7d6d8cfc2ae372d34ab08
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Thu May 10 19:02:30 2012 +0100
connection-contact-list: don't crash if no Contacts
This situation would be stupid, but we still shouldn't crash.
Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49735
---
telepathy-glib/connection-contact-list.c | 14 ++++++++++++++
telepathy-glib/contact.c | 3 +++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/telepathy-glib/connection-contact-list.c b/telepathy-glib/connection-contact-list.c
index a0650a2..2e6d597 100644
--- a/telepathy-glib/connection-contact-list.c
+++ b/telepathy-glib/connection-contact-list.c
@@ -231,6 +231,7 @@ 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;
@@ -305,6 +306,19 @@ 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_with_id (
self, contacts_changed_cb, NULL, NULL, NULL, NULL);
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index 6f17769..6211cd2 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -4005,6 +4005,9 @@ contacts_bind_to_signals (TpConnection *connection,
return (const gchar **) g_ptr_array_free (array, FALSE);
}
+/*
+ * The connection must implement Contacts.
+ */
const gchar **
_tp_contacts_bind_to_signals (TpConnection *connection,
guint n_features,
More information about the telepathy-commits
mailing list