changeset 32299:fa183182bc2b

Update js->initial_avatar_hash if the user tries to set the icon before we've received our self vcard. This is the other half of a fix to get rid of a race condition where the user's icon wouldn't get set correctly if they set it while connecting.
author Mark Doliner <mark@kingant.net>
date Wed, 13 Apr 2011 00:22:29 +0000
parents 515ed916e691
children fec20ae8373a
files libpurple/protocols/jabber/buddy.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c	Wed Apr 13 00:17:13 2011 +0000
+++ b/libpurple/protocols/jabber/buddy.c	Wed Apr 13 00:22:29 2011 +0000
@@ -467,8 +467,20 @@
 
 	/* if we haven't grabbed the remote vcard yet, we can't
 	 * assume that what we have here is correct */
-	if(!js->vcard_fetched)
+	if(!js->vcard_fetched) {
+		PurpleStoredImage *image;
+		g_free(js->initial_avatar_hash);
+		image = purple_buddy_icons_find_account_icon(purple_connection_get_account(gc));
+		if (image != NULL) {
+			js->initial_avatar_hash =
+					jabber_calculate_data_hash(purple_imgstore_get_data(image),
+			purple_imgstore_get_size(image), "sha1");
+			purple_imgstore_unref(image);
+		} else {
+			js->initial_avatar_hash = NULL;
+		}
 		return;
+	}
 
 	if (js->vcard_timer) {
 		purple_timeout_remove(js->vcard_timer);