Mercurial > pidgin.yaz
diff libpurple/protocols/jabber/buddy.c @ 18163:703872bf33c6
server-side jabber vcards now take precedence over local vcards, so
we no longer overwrite things we shouldn't (fixes #1013)
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sun, 17 Jun 2007 15:27:35 +0000 |
parents | f88c2a41200d |
children | 6050348614ab |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c Sun Jun 17 15:09:05 2007 +0000 +++ b/libpurple/protocols/jabber/buddy.c Sun Jun 17 15:27:35 2007 +0000 @@ -385,6 +385,11 @@ xmlnode *vc_node; struct tag_attr *tag_attr; + /* if we have't grabbed the remote vcard yet, we can't + * assume that what we have here is correct */ + if(!js->vcard_fetched) + return; + g_free(js->avatar_hash); js->avatar_hash = NULL; @@ -734,6 +739,40 @@ } } +static void jabber_vcard_save_mine(JabberStream *js, xmlnode *packet, gpointer data) +{ + xmlnode *vcard; + char *txt; + PurpleStoredImage *img; + + if((vcard = xmlnode_get_child(packet, "vCard")) || + (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp"))) + { + txt = xmlnode_to_str(vcard, NULL); + purple_account_set_user_info(purple_connection_get_account(js->gc), txt); + + g_free(txt); + } else { + /* if we have no vCard, then lets not overwrite what we might have locally */ + } + + js->vcard_fetched = TRUE; + + if(NULL != (img = purple_buddy_icons_find_account_icon(js->gc->account))) { + jabber_set_buddy_icon(js->gc, img); + purple_imgstore_unref(img); + } +} + +void jabber_vcard_fetch_mine(JabberStream *js) +{ + JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, "vcard-temp"); + + jabber_iq_set_callback(iq, jabber_vcard_save_mine, NULL); + + jabber_iq_send(iq); +} + static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data) { const char *id, *from;