[Telepathy-commits] [telepathy-haze/master] Don't include self_handle in the map returned by GetKnownAvatarTokens if the account appears to have no icon.
Will Thompson
will.thompson at collabora.co.uk
Mon Aug 11 11:12:56 PDT 2008
20080811181256-9f02e-cd9d6c0580808c00d39dc3845cb52e049e3206ab.gz
---
src/connection-avatars.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/src/connection-avatars.c b/src/connection-avatars.c
index fcaf018..0ea163d 100644
--- a/src/connection-avatars.c
+++ b/src/connection-avatars.c
@@ -205,9 +205,35 @@ haze_connection_get_known_avatar_tokens (TpSvcConnectionInterfaceAvatars *self,
for (i = 0; i < contacts->len; i++)
{
TpHandle handle = g_array_index (contacts, TpHandle, i);
- gchar *token = get_handle_token (conn, handle);
+ gchar *token = NULL;
+
+ /* Purple doesn't provide any way to distinguish between a contact with
+ * no avatar and a contact whose avatar we haven't retrieved yet,
+ * mainly because it always automatically downloads all avatars. So in
+ * general, we assume no avatar means the former, so that clients don't
+ * repeatedly call RequestAvatar hoping eventually to get the avatar.
+ *
+ * But on protocols where avatars aren't saved server-side, we should
+ * report that it's unknown, so that the UI (aka. mcd) can re-set the
+ * avatar you last used. So we special-case self_handle here.
+ */
+
+ if (handle == base_conn->self_handle)
+ {
+ GArray *avatar = get_avatar (conn, handle);
+ if (avatar != NULL)
+ {
+ token = get_token (avatar);
+ g_array_free (avatar, TRUE);
+ }
+ }
+ else
+ {
+ token = get_handle_token (conn, handle);
+ }
- g_hash_table_insert (tokens, GUINT_TO_POINTER (handle), token);
+ if (token != NULL)
+ g_hash_table_insert (tokens, GUINT_TO_POINTER (handle), token);
}
tp_svc_connection_interface_avatars_return_from_get_known_avatar_tokens (
--
1.5.6.3
More information about the Telepathy-commits
mailing list