comparison 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
comparison
equal deleted inserted replaced
18162:2b8460b599ea 18163:703872bf33c6
383 JabberIq *iq; 383 JabberIq *iq;
384 JabberStream *js = gc->proto_data; 384 JabberStream *js = gc->proto_data;
385 xmlnode *vc_node; 385 xmlnode *vc_node;
386 struct tag_attr *tag_attr; 386 struct tag_attr *tag_attr;
387 387
388 /* if we have't grabbed the remote vcard yet, we can't
389 * assume that what we have here is correct */
390 if(!js->vcard_fetched)
391 return;
392
388 g_free(js->avatar_hash); 393 g_free(js->avatar_hash);
389 js->avatar_hash = NULL; 394 js->avatar_hash = NULL;
390 395
391 /* 396 /*
392 * Send only if there's actually any *information* to send 397 * Send only if there's actually any *information* to send
730 g_free(comp_id); 735 g_free(comp_id);
731 return; 736 return;
732 } 737 }
733 l = l->next; 738 l = l->next;
734 } 739 }
740 }
741
742 static void jabber_vcard_save_mine(JabberStream *js, xmlnode *packet, gpointer data)
743 {
744 xmlnode *vcard;
745 char *txt;
746 PurpleStoredImage *img;
747
748 if((vcard = xmlnode_get_child(packet, "vCard")) ||
749 (vcard = xmlnode_get_child_with_namespace(packet, "query", "vcard-temp")))
750 {
751 txt = xmlnode_to_str(vcard, NULL);
752 purple_account_set_user_info(purple_connection_get_account(js->gc), txt);
753
754 g_free(txt);
755 } else {
756 /* if we have no vCard, then lets not overwrite what we might have locally */
757 }
758
759 js->vcard_fetched = TRUE;
760
761 if(NULL != (img = purple_buddy_icons_find_account_icon(js->gc->account))) {
762 jabber_set_buddy_icon(js->gc, img);
763 purple_imgstore_unref(img);
764 }
765 }
766
767 void jabber_vcard_fetch_mine(JabberStream *js)
768 {
769 JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, "vcard-temp");
770
771 jabber_iq_set_callback(iq, jabber_vcard_save_mine, NULL);
772
773 jabber_iq_send(iq);
735 } 774 }
736 775
737 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data) 776 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data)
738 { 777 {
739 const char *id, *from; 778 const char *id, *from;