diff options
-rw-r--r-- | telepathy-glib/contact.c | 28 | ||||
-rw-r--r-- | 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 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); } |