comparison libpurple/protocols/jabber/useravatar.c @ 25353: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
comparison
equal deleted inserted replaced
25352:b68ac693ae2d 25353:9195955395b6
156 purple_debug_error("jabber", "Cannot set PEP avatar to non-PNG data\n"); 156 purple_debug_error("jabber", "Cannot set PEP avatar to non-PNG data\n");
157 } 157 }
158 } 158 }
159 } 159 }
160 160
161 static void
162 do_got_own_avatar_cb(JabberStream *js, const char *from, xmlnode *items)
163 {
164 xmlnode *item = NULL, *metadata = NULL, *info = NULL;
165 PurpleAccount *account = purple_connection_get_account(js->gc);
166 const char *current_hash = purple_account_get_string(account, "prpl-jabber_icon_checksum", "");
167 const char *server_hash = NULL;
168
169 if ((item = xmlnode_get_child(items, "item")) &&
170 (metadata = xmlnode_get_child(item, "metadata")) &&
171 (info = xmlnode_get_child(metadata, "info"))) {
172 server_hash = xmlnode_get_attrib(info, "id");
173 }
174
175 /* Publish ours if it's different than the server's */
176 if ((!server_hash && current_hash[0] != '\0') ||
177 (server_hash && strcmp(server_hash, current_hash))) {
178 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
179 jabber_avatar_set(js, img);
180 purple_imgstore_unref(img);
181 }
182 }
183
184 void jabber_avatar_fetch_mine(JabberStream *js)
185 {
186 char *jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain);
187 jabber_pep_request_item(js, jid, AVATARNAMESPACEMETA, NULL,
188 do_got_own_avatar_cb);
189 g_free(jid);
190 }
191
161 typedef struct _JabberBuddyAvatarUpdateURLInfo { 192 typedef struct _JabberBuddyAvatarUpdateURLInfo {
162 JabberStream *js; 193 JabberStream *js;
163 char *from; 194 char *from;
164 char *id; 195 char *id;
165 } JabberBuddyAvatarUpdateURLInfo; 196 } JabberBuddyAvatarUpdateURLInfo;