telepathy-glib: Fix ContactList not having avatars

Xavier Claessens xclaesse at kemper.freedesktop.org
Mon May 14 03:38:16 PDT 2012


Module: telepathy-glib
Branch: master
Commit: 6afc5819e15200f7cf0970bad982ea245dca4327
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=6afc5819e15200f7cf0970bad982ea245dca4327

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Sun May 13 15:26:09 2012 +0200

Fix ContactList not having avatars

This is a regression introduced by 22a4438161874e36e27282bd3d24a909f4b16f70,
because ContactList does not go through the slow path.

---

 telepathy-glib/contact.c |   28 +++++++++++++++++++---------
 tests/dbus/contacts.c    |    6 ++++++
 2 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index 64690f8..54c0275 100644
--- a/telepathy-glib/contact.c
+++ b/telepathy-glib/contact.c
@@ -2833,6 +2833,17 @@ out:
 }
 
 static void
+contact_maybe_update_avatar_data (TpContact *self)
+{
+  if ((self->priv->has_features & CONTACT_FEATURE_FLAG_AVATAR_DATA) == 0 &&
+      (self->priv->has_features & CONTACT_FEATURE_FLAG_AVATAR_TOKEN) != 0)
+    {
+      self->priv->has_features |= CONTACT_FEATURE_FLAG_AVATAR_DATA;
+      contact_update_avatar_data (self);
+    }
+}
+
+static void
 contacts_bind_to_avatar_retrieved (TpConnection *connection)
 {
   if (!connection->priv->tracking_avatar_retrieved)
@@ -2854,15 +2865,7 @@ contacts_get_avatar_data (ContactsContext *c)
   contacts_bind_to_avatar_retrieved (c->connection);
 
   for (i = 0; i < c->contacts->len; i++)
-    {
-      TpContact *contact = g_ptr_array_index (c->contacts, i);
-
-      if ((contact->priv->has_features & CONTACT_FEATURE_FLAG_AVATAR_DATA) == 0)
-        {
-          contact->priv->has_features |= CONTACT_FEATURE_FLAG_AVATAR_DATA;
-          contact_update_avatar_data (contact);
-        }
-    }
+    contact_maybe_update_avatar_data (g_ptr_array_index (c->contacts, i));
 
   contacts_context_continue (c);
 }
@@ -3681,6 +3684,13 @@ tp_contact_set_attributes (TpContact *contact,
       contact_set_avatar_token (contact, s, TRUE);
     }
 
+  if (wanted & CONTACT_FEATURE_FLAG_AVATAR_DATA)
+    {
+      /* There is no attribute for the avatar data, this will set the avatar
+       * from cache or start the avatar request if its missing from cache. */
+      contact_maybe_update_avatar_data (contact);
+    }
+
   if (wanted & CONTACT_FEATURE_FLAG_PRESENCE)
     {
       boxed = tp_asv_get_boxed (asv,
diff --git a/tests/dbus/contacts.c b/tests/dbus/contacts.c
index b35e007..3e6d7fd 100644
--- a/tests/dbus/contacts.c
+++ b/tests/dbus/contacts.c
@@ -2686,6 +2686,7 @@ test_contact_list (Fixture *f,
   factory = tp_proxy_get_factory (f->client_conn);
   tp_simple_client_factory_add_contact_features_varargs (factory,
       TP_CONTACT_FEATURE_ALIAS,
+      TP_CONTACT_FEATURE_AVATAR_DATA,
       TP_CONTACT_FEATURE_INVALID);
 
   /* Now put it online and wait for contact list state move to success */
@@ -2713,6 +2714,11 @@ test_contact_list (Fixture *f,
   /* Even if we didn't explicitely asked that feature, we should have it for free */
   g_assert (tp_contact_has_feature (contact, TP_CONTACT_FEATURE_SUBSCRIPTION_STATES));
   g_assert_cmpint (tp_contact_get_subscribe_state (contact), ==, TP_SUBSCRIPTION_STATE_ASK);
+  /* We asked for AVATAR_DATA, verify we got it. This is special because it has
+   * no contact attribute, and ContactList preparation does not go through
+   * the slow path. */
+  g_assert (tp_contact_has_feature (contact, TP_CONTACT_FEATURE_AVATAR_DATA));
+
   g_ptr_array_unref (contacts);
 }
 



More information about the telepathy-commits mailing list