diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2011-10-20 15:30:17 +0200 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2011-10-24 16:33:06 +0200 |
commit | 81c9de86431c1c6fc2968b862ab8645e2804f448 (patch) | |
tree | 75d53925b2f4f2da21e138e1b6722067f5aef797 | |
parent | f1f4e8bc7f58bb8e4c551bbc0c98674cfa0dc1c7 (diff) | |
download | telepathy-glib-81c9de86431c1c6fc2968b862ab8645e2804f448.tar.gz |
Prevent circular introspection dependency
As part of preparing a Connection the self contact will be retrieved. If
the contacts requested features include _CAPABILITIES _and_ the
connection doesn't support ContactCapabilities then the Capabilties of
the connection get use. But if we wait for this feature to be prepared
then the introspection stalls.
So instead use internal API to force getting the capabilities of the
connection regardless of the state of the various features and break the
circular dependency.
-rw-r--r-- | telepathy-glib/contact.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c index 2be525b5b..70c0100a6 100644 --- a/telepathy-glib/contact.c +++ b/telepathy-glib/contact.c @@ -2487,38 +2487,38 @@ set_conn_capabilities_on_contacts (GPtrArray *contacts, TpConnection *connection) { guint i; + TpCapabilities *conn_caps = tp_connection_get_capabilities (connection); + GPtrArray *rcc; + + /* If the connection has no capabilities then don't bother setting them on + * the contact and pretend we just don't know.. In practise this will only + * happen if there was an error in getting the connections capabilities so + * claiming ignorance seems the most sensible thing to do */ + if (conn_caps == NULL) + return; + + rcc = tp_capabilities_get_channel_classes (conn_caps); + if (rcc == NULL || rcc->len == 0) + return; for (i = 0; i < contacts->len; i++) { TpContact *contact = g_ptr_array_index (contacts, i); - contact_set_capabilities (contact, tp_connection_get_capabilities ( - connection)); + contact_set_capabilities (contact, conn_caps); } } static void -connection_capabilities_prepare_cb (GObject *object, +connection_capabilities_fetched_cb (GObject *object, GAsyncResult *res, gpointer user_data) { - GError *error = NULL; ContactsContext *c = user_data; - if (!tp_proxy_prepare_finish (object, res, &error)) - { - DEBUG ("Failed to prepare Connection capabilities feature: %s %u: %s", - g_quark_to_string (error->domain), error->code, error->message); - } - else if (!tp_proxy_is_prepared (object, TP_CONNECTION_FEATURE_CAPABILITIES)) - { - DEBUG ("Connection capabilities feature has not been actually prepared"); - } - else - { - set_conn_capabilities_on_contacts (c->contacts, c->connection); - } + DEBUG ("Connection capabilities prepared"); + set_conn_capabilities_on_contacts (c->contacts, c->connection); contacts_context_continue (c); contacts_context_unref (c); } @@ -2526,12 +2526,13 @@ connection_capabilities_prepare_cb (GObject *object, static void contacts_get_conn_capabilities (ContactsContext *c) { - GQuark features[] = { TP_CONNECTION_FEATURE_CAPABILITIES, 0 }; g_assert (c->handles->len == c->contacts->len); + DEBUG ("Getting connection capabilities"); + c->refcount++; - tp_proxy_prepare_async (c->connection, features, - connection_capabilities_prepare_cb, c); + _tp_connection_get_capabilities_async (c->connection, + connection_capabilities_fetched_cb, c); } static void |