Mercurial > pidgin
comparison src/protocols/jabber/buddy.c @ 14067:f3ed5f4efcae
[gaim-migrate @ 16688]
Fix for CID 110 (which also will fix some asserts that happen when you edit your Jabber User Info for the first time)
Fix for CID 251 (Null check after deref)
Fixes for CID 252, 253. (UNUSED_VALUE)
I also changed the jabber_buddy_find() call in jabber_vcard_parse not to create the JabberBuddy if it doesn't exist - there should be a specific jabber buddy attached to the JabberBuddyInfo and if isn't present any more, we shouldn't create a new one.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 10 Aug 2006 21:08:00 +0000 |
parents | 25e63008d3bb |
children | 6cb8bdc3366f |
comparison
equal
deleted
inserted
replaced
14066:29f03c8fba4a | 14067:f3ed5f4efcae |
---|---|
530 GaimConnection *gc = (GaimConnection *) action->context; | 530 GaimConnection *gc = (GaimConnection *) action->context; |
531 GaimRequestFields *fields; | 531 GaimRequestFields *fields; |
532 GaimRequestFieldGroup *group; | 532 GaimRequestFieldGroup *group; |
533 GaimRequestField *field; | 533 GaimRequestField *field; |
534 const struct vcard_template *vc_tp; | 534 const struct vcard_template *vc_tp; |
535 char *user_info; | 535 const char *user_info; |
536 char *cdata; | 536 char *cdata; |
537 xmlnode *x_vc_data = NULL; | 537 xmlnode *x_vc_data = NULL; |
538 | 538 |
539 fields = gaim_request_fields_new(); | 539 fields = gaim_request_fields_new(); |
540 group = gaim_request_field_group_new(NULL); | 540 group = gaim_request_field_group_new(NULL); |
541 gaim_request_fields_add_group(fields, group); | 541 gaim_request_fields_add_group(fields, group); |
542 | 542 |
543 /* | 543 /* |
544 * Get existing, XML-formatted, user info | 544 * Get existing, XML-formatted, user info |
545 */ | 545 */ |
546 if((user_info = g_strdup(gaim_account_get_user_info(gc->account))) != NULL) | 546 if((user_info = gaim_account_get_user_info(gc->account)) != NULL) |
547 x_vc_data = xmlnode_from_str(user_info, -1); | 547 x_vc_data = xmlnode_from_str(user_info, -1); |
548 else | |
549 user_info = g_strdup(""); | |
550 | 548 |
551 /* | 549 /* |
552 * Set up GSLists for edit with labels from "template," data from user info | 550 * Set up GSLists for edit with labels from "template," data from user info |
553 */ | 551 */ |
554 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) { | 552 for(vc_tp = vcard_template_data; vc_tp->label != NULL; ++vc_tp) { |
555 xmlnode *data_node; | 553 xmlnode *data_node; |
556 if((vc_tp->label)[0] == '\0') | 554 if((vc_tp->label)[0] == '\0') |
557 continue; | 555 continue; |
558 if(vc_tp->ptag == NULL) { | 556 |
559 data_node = xmlnode_get_child(x_vc_data, vc_tp->tag); | 557 if (x_vc_data != NULL) { |
560 } else { | 558 if(vc_tp->ptag == NULL) { |
561 gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag); | 559 data_node = xmlnode_get_child(x_vc_data, vc_tp->tag); |
562 data_node = xmlnode_get_child(x_vc_data, tag); | 560 } else { |
563 g_free(tag); | 561 gchar *tag = g_strdup_printf("%s/%s", vc_tp->ptag, vc_tp->tag); |
564 } | 562 data_node = xmlnode_get_child(x_vc_data, tag); |
565 if(data_node) | 563 g_free(tag); |
566 cdata = xmlnode_get_data(data_node); | 564 } |
567 else | 565 if(data_node) |
566 cdata = xmlnode_get_data(data_node); | |
567 else | |
568 cdata = NULL; | |
569 } else | |
568 cdata = NULL; | 570 cdata = NULL; |
569 | 571 |
570 if(strcmp(vc_tp->tag, "DESC") == 0) { | 572 if(strcmp(vc_tp->tag, "DESC") == 0) { |
571 field = gaim_request_field_string_new(vc_tp->tag, | 573 field = gaim_request_field_string_new(vc_tp->tag, |
572 _(vc_tp->label), cdata, | 574 _(vc_tp->label), cdata, |
580 gaim_request_field_group_add_field(group, field); | 582 gaim_request_field_group_add_field(group, field); |
581 } | 583 } |
582 | 584 |
583 if(x_vc_data != NULL) | 585 if(x_vc_data != NULL) |
584 xmlnode_free(x_vc_data); | 586 xmlnode_free(x_vc_data); |
585 | |
586 g_free(user_info); | |
587 | 587 |
588 gaim_request_fields(gc, _("Edit Jabber vCard"), | 588 gaim_request_fields(gc, _("Edit Jabber vCard"), |
589 _("Edit Jabber vCard"), | 589 _("Edit Jabber vCard"), |
590 _("All items below are optional. Enter only the " | 590 _("All items below are optional. Enter only the " |
591 "information with which you feel comfortable."), | 591 "information with which you feel comfortable."), |
722 } | 722 } |
723 } | 723 } |
724 | 724 |
725 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data) | 725 static void jabber_vcard_parse(JabberStream *js, xmlnode *packet, gpointer data) |
726 { | 726 { |
727 const char *type, *id, *from; | 727 const char *id, *from; |
728 JabberBuddy *jb; | |
729 GString *info_text; | 728 GString *info_text; |
730 char *bare_jid; | 729 char *bare_jid; |
731 char *text; | 730 char *text; |
732 xmlnode *vcard; | 731 xmlnode *vcard; |
733 GaimBuddy *b; | 732 GaimBuddy *b; |
734 JabberBuddyInfo *jbi = data; | 733 JabberBuddyInfo *jbi = data; |
735 | 734 |
736 from = xmlnode_get_attrib(packet, "from"); | 735 from = xmlnode_get_attrib(packet, "from"); |
737 type = xmlnode_get_attrib(packet, "type"); | |
738 id = xmlnode_get_attrib(packet, "id"); | 736 id = xmlnode_get_attrib(packet, "id"); |
739 | |
740 jabber_buddy_info_remove_id(jbi, id); | |
741 | 737 |
742 if(!jbi) | 738 if(!jbi) |
743 return; | 739 return; |
744 | 740 |
741 jabber_buddy_info_remove_id(jbi, id); | |
742 | |
745 if(!from) | 743 if(!from) |
746 return; | 744 return; |
747 | 745 |
748 if(!(jb = jabber_buddy_find(js, from, TRUE))) | 746 if(!jabber_buddy_find(js, from, FALSE)) |
749 return; | 747 return; |
750 | 748 |
751 /* XXX: handle the error case */ | 749 /* XXX: handle the error case */ |
752 | 750 |
753 bare_jid = jabber_get_bare_jid(from); | 751 bare_jid = jabber_get_bare_jid(from); |