summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2012-05-13 15:26:09 +0200
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-05-14 12:37:56 +0200
commit6afc5819e15200f7cf0970bad982ea245dca4327 (patch)
tree2a5213385a70cb21f3c853175f266c3cf7720f05
parentb3aa3ffb6683d92ccc4eeae8f8cb9c11e8eb4575 (diff)
Fix ContactList not having avatars
This is a regression introduced by 22a4438161874e36e27282bd3d24a909f4b16f70, because ContactList does not go through the slow path.
-rw-r--r--telepathy-glib/contact.c28
-rw-r--r--tests/dbus/contacts.c6
2 files changed, 25 insertions, 9 deletions
diff --git a/telepathy-glib/contact.c b/telepathy-glib/contact.c
index 64690f8bc..54c027572 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 b35e007d3..3e6d7fd54 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);
}