Mercurial > pidgin.yaz
diff libpurple/protocols/jabber/useravatar.c @ 25817:9195955395b6
Only (re)publish XMPP avatars at login if the server's avatar differs
As part of this, no longer rely on the vcard for determining a need to
publish the XEP-0084 avatar; explicitly fetch and compare it.
Closes #7734.
References #7732. That patch needs updating to apply on top of this.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 21 Jan 2009 20:16:22 +0000 |
parents | b68ac693ae2d |
children | ba8f51cb3691 |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/useravatar.c Wed Jan 21 17:56:07 2009 +0000 +++ b/libpurple/protocols/jabber/useravatar.c Wed Jan 21 20:16:22 2009 +0000 @@ -158,6 +158,37 @@ } } +static void +do_got_own_avatar_cb(JabberStream *js, const char *from, xmlnode *items) +{ + xmlnode *item = NULL, *metadata = NULL, *info = NULL; + PurpleAccount *account = purple_connection_get_account(js->gc); + const char *current_hash = purple_account_get_string(account, "prpl-jabber_icon_checksum", ""); + const char *server_hash = NULL; + + if ((item = xmlnode_get_child(items, "item")) && + (metadata = xmlnode_get_child(item, "metadata")) && + (info = xmlnode_get_child(metadata, "info"))) { + server_hash = xmlnode_get_attrib(info, "id"); + } + + /* Publish ours if it's different than the server's */ + if ((!server_hash && current_hash[0] != '\0') || + (server_hash && strcmp(server_hash, current_hash))) { + PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); + jabber_avatar_set(js, img); + purple_imgstore_unref(img); + } +} + +void jabber_avatar_fetch_mine(JabberStream *js) +{ + char *jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); + jabber_pep_request_item(js, jid, AVATARNAMESPACEMETA, NULL, + do_got_own_avatar_cb); + g_free(jid); +} + typedef struct _JabberBuddyAvatarUpdateURLInfo { JabberStream *js; char *from;