im.pidgin.pidgin: 8560411a346db747adaad2941cb437284f63c8de

nosnilmot at pidgin.im nosnilmot at pidgin.im
Thu Feb 14 08:05:58 EST 2008


-----------------------------------------------------------------
Revision: 8560411a346db747adaad2941cb437284f63c8de
Ancestor: 29a6e3789a996fbd9446c3c130c83f5c808898fc
Author: nosnilmot at pidgin.im
Date: 2008-02-14T13:03:34
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/8560411a346db747adaad2941cb437284f63c8de

Modified files:
        libpurple/protocols/jabber/buddy.c

ChangeLog: 

Fix setting vCard buddy icons when we don't have any other user info set.
Fixes #3450.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/buddy.c	64b5d98022eb0426a7f0e0caaf846a42e8d9d793
+++ libpurple/protocols/jabber/buddy.c	30ccef8ae960bfa7d6e2007eaa0e15f6d2a8dbf2
@@ -392,6 +392,7 @@ void jabber_set_info(PurpleConnection *g
  */
 void jabber_set_info(PurpleConnection *gc, const char *info)
 {
+	PurpleStoredImage *img;
 	JabberIq *iq;
 	JabberStream *js = gc->proto_data;
 	xmlnode *vc_node;
@@ -410,57 +411,58 @@ void jabber_set_info(PurpleConnection *g
 	 */
 	vc_node = info ? xmlnode_from_str(info, -1) : NULL;
 
-	if(!vc_node) {
-		vc_node = xmlnode_new("vCard");
-		for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr)
-			xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
+	if (vc_node && (!vc_node->name ||
+			g_ascii_strncasecmp(vc_node->name, "vCard", 5))) {
+		xmlnode_free(vc_node);
+		vc_node = NULL;
 	}
 
-	if (vc_node->name &&
-			!g_ascii_strncasecmp(vc_node->name, "vCard", 5)) {
-		PurpleStoredImage *img;
+	if ((img = purple_buddy_icons_find_account_icon(gc->account))) {
+		gconstpointer avatar_data;
+		gsize avatar_len;
+		xmlnode *photo, *binval, *type;
+		gchar *enc;
+		int i;
+		unsigned char hashval[20];
+		char *p, hash[41];
 
-		if ((img = purple_buddy_icons_find_account_icon(gc->account))) {
-			gconstpointer avatar_data;
-			gsize avatar_len;
-			xmlnode *photo, *binval, *type;
-			gchar *enc;
-			int i;
-			unsigned char hashval[20];
-			char *p, hash[41];
+		if(!vc_node) {
+			vc_node = xmlnode_new("vCard");
+			for(tag_attr = vcard_tag_attr_list; tag_attr->attr != NULL; ++tag_attr)
+				xmlnode_set_attrib(vc_node, tag_attr->attr, tag_attr->value);
+		}
 
-			avatar_data = purple_imgstore_get_data(img);
-			avatar_len = purple_imgstore_get_size(img);
-			/* have to get rid of the old PHOTO if it exists */
-			if((photo = xmlnode_get_child(vc_node, "PHOTO"))) {
-				xmlnode_free(photo);
-			}
-			photo = xmlnode_new_child(vc_node, "PHOTO");
-			type = xmlnode_new_child(photo, "TYPE");
-			xmlnode_insert_data(type, "image/png", -1);
-			binval = xmlnode_new_child(photo, "BINVAL");
-			enc = purple_base64_encode(avatar_data, avatar_len);
+		avatar_data = purple_imgstore_get_data(img);
+		avatar_len = purple_imgstore_get_size(img);
+		/* have to get rid of the old PHOTO if it exists */
+		if((photo = xmlnode_get_child(vc_node, "PHOTO"))) {
+			xmlnode_free(photo);
+		}
+		photo = xmlnode_new_child(vc_node, "PHOTO");
+		type = xmlnode_new_child(photo, "TYPE");
+		xmlnode_insert_data(type, "image/png", -1);
+		binval = xmlnode_new_child(photo, "BINVAL");
+		enc = purple_base64_encode(avatar_data, avatar_len);
 
-			purple_cipher_digest_region("sha1", avatar_data,
-									  avatar_len, sizeof(hashval),
-									  hashval, NULL);
+		purple_cipher_digest_region("sha1", avatar_data,
+								  avatar_len, sizeof(hashval),
+								  hashval, NULL);
 
-			purple_imgstore_unref(img);
+		purple_imgstore_unref(img);
 
-			p = hash;
-			for(i=0; i<20; i++, p+=2)
-				snprintf(p, 3, "%02x", hashval[i]);
-			js->avatar_hash = g_strdup(hash);
+		p = hash;
+		for(i=0; i<20; i++, p+=2)
+			snprintf(p, 3, "%02x", hashval[i]);
+		js->avatar_hash = g_strdup(hash);
 
-			xmlnode_insert_data(binval, enc, -1);
-			g_free(enc);
-		}
+		xmlnode_insert_data(binval, enc, -1);
+		g_free(enc);
+	}
 
+	if (vc_node != NULL) {
 		iq = jabber_iq_new(js, JABBER_IQ_SET);
 		xmlnode_insert_child(iq->node, vc_node);
 		jabber_iq_send(iq);
-	} else {
-		xmlnode_free(vc_node);
 	}
 }
 


More information about the Commits mailing list