comparison src/protocols/jabber/buddy.c @ 8213:8d41a4250bb7

[gaim-migrate @ 8936] fix the buddy ticker for when accounts sign off, and fix newlines in jabber profiles committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 06 Feb 2004 00:30:35 +0000
parents 3a229ad2fab0
children ba12d8b12ab0
comparison
equal deleted inserted replaced
8212:ad164c1ca79d 8213:8d41a4250bb7
530 JabberBuddyResource *jbr; 530 JabberBuddyResource *jbr;
531 GString *info_text; 531 GString *info_text;
532 char *resource_name; 532 char *resource_name;
533 char *bare_jid; 533 char *bare_jid;
534 char *title; 534 char *title;
535 char *text;
535 xmlnode *vcard; 536 xmlnode *vcard;
536 GaimBuddy *b; 537 GaimBuddy *b;
537 538
538 if(!from) 539 if(!from)
539 return; 540 return;
546 b = gaim_find_buddy(js->gc->account, bare_jid); 547 b = gaim_find_buddy(js->gc->account, bare_jid);
547 548
548 jb = jabber_buddy_find(js, from, TRUE); 549 jb = jabber_buddy_find(js, from, TRUE);
549 info_text = g_string_new(""); 550 info_text = g_string_new("");
550 551
551 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", _("Jabber ID"), 552 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", _("Jabber ID"),
552 from); 553 from);
553 554
554 if(resource_name) { 555 if(resource_name) {
555 jbr = jabber_buddy_find_resource(jb, resource_name); 556 jbr = jabber_buddy_find_resource(jb, resource_name);
556 if(jbr) { 557 if(jbr) {
557 char *purdy = NULL; 558 char *purdy = NULL;
558 if(jbr->status) 559 if(jbr->status)
559 purdy = gaim_strdup_withhtml(jbr->status); 560 purdy = gaim_strdup_withhtml(jbr->status);
560 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>\n", 561 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>",
561 _("Status"), jabber_get_state_string(jbr->state), 562 _("Status"), jabber_get_state_string(jbr->state),
562 purdy ? ": " : "", 563 purdy ? ": " : "",
563 purdy ? purdy : ""); 564 purdy ? purdy : "");
564 if(purdy) 565 if(purdy)
565 g_free(purdy); 566 g_free(purdy);
566 } else { 567 } else {
567 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", 568 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
568 _("Status"), _("Unknown")); 569 _("Status"), _("Unknown"));
569 } 570 }
570 } else { 571 } else {
571 for(resources = jb->resources; resources; resources = resources->next) { 572 for(resources = jb->resources; resources; resources = resources->next) {
572 char *purdy = NULL; 573 char *purdy = NULL;
573 jbr = resources->data; 574 jbr = resources->data;
574 if(jbr->status) 575 if(jbr->status)
575 purdy = gaim_strdup_withhtml(jbr->status); 576 purdy = gaim_strdup_withhtml(jbr->status);
576 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", 577 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
577 _("Resource"), jbr->name); 578 _("Resource"), jbr->name);
578 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/><br/>\n", 579 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/><br/>",
579 _("Status"), jabber_get_state_string(jbr->state), 580 _("Status"), jabber_get_state_string(jbr->state),
580 purdy ? ": " : "", 581 purdy ? ": " : "",
581 purdy ? purdy : ""); 582 purdy ? purdy : "");
582 if(purdy) 583 if(purdy)
583 g_free(purdy); 584 g_free(purdy);
590 if((vcard = xmlnode_get_child(packet, "vCard"))) { 591 if((vcard = xmlnode_get_child(packet, "vCard"))) {
591 xmlnode *child; 592 xmlnode *child;
592 for(child = vcard->child; child; child = child->next) 593 for(child = vcard->child; child; child = child->next)
593 { 594 {
594 xmlnode *child2; 595 xmlnode *child2;
595 char *text;
596 596
597 if(child->type != XMLNODE_TYPE_TAG) 597 if(child->type != XMLNODE_TYPE_TAG)
598 continue; 598 continue;
599 599
600 text = xmlnode_get_data(child); 600 text = xmlnode_get_data(child);
601 if(text && !strcmp(child->name, "FN")) { 601 if(text && !strcmp(child->name, "FN")) {
602 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", 602 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
603 _("Full Name"), text); 603 _("Full Name"), text);
604 } else if(!strcmp(child->name, "N")) { 604 } else if(!strcmp(child->name, "N")) {
605 for(child2 = child->child; child2; child2 = child2->next) 605 for(child2 = child->child; child2; child2 = child2->next)
606 { 606 {
607 char *text2; 607 char *text2;
610 continue; 610 continue;
611 611
612 text2 = xmlnode_get_data(child2); 612 text2 = xmlnode_get_data(child2);
613 if(text2 && !strcmp(child2->name, "FAMILY")) { 613 if(text2 && !strcmp(child2->name, "FAMILY")) {
614 g_string_append_printf(info_text, 614 g_string_append_printf(info_text,
615 "<b>%s:</b> %s<br/>\n", 615 "<b>%s:</b> %s<br/>",
616 _("Family Name"), text2); 616 _("Family Name"), text2);
617 } else if(text2 && !strcmp(child2->name, "GIVEN")) { 617 } else if(text2 && !strcmp(child2->name, "GIVEN")) {
618 g_string_append_printf(info_text, 618 g_string_append_printf(info_text,
619 "<b>%s:</b> %s<br/>\n", 619 "<b>%s:</b> %s<br/>",
620 _("Given Name"), text2); 620 _("Given Name"), text2);
621 } else if(text2 && !strcmp(child2->name, "MIDDLE")) { 621 } else if(text2 && !strcmp(child2->name, "MIDDLE")) {
622 g_string_append_printf(info_text, 622 g_string_append_printf(info_text,
623 "<b>%s:</b> %s<br/>\n", 623 "<b>%s:</b> %s<br/>",
624 _("Middle Name"), text2); 624 _("Middle Name"), text2);
625 } 625 }
626 g_free(text2); 626 g_free(text2);
627 } 627 }
628 } else if(text && !strcmp(child->name, "NICKNAME")) { 628 } else if(text && !strcmp(child->name, "NICKNAME")) {
629 serv_got_alias(js->gc, from, text); 629 serv_got_alias(js->gc, from, text);
630 if(b) { 630 if(b) {
631 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", text); 631 gaim_blist_node_set_string((GaimBlistNode*)b, "servernick", text);
632 gaim_blist_save(); 632 gaim_blist_save();
633 } 633 }
634 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", 634 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
635 _("Nickname"), text); 635 _("Nickname"), text);
636 } else if(text && !strcmp(child->name, "BDAY")) { 636 } else if(text && !strcmp(child->name, "BDAY")) {
637 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", 637 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
638 _("Birthday"), text); 638 _("Birthday"), text);
639 } else if(!strcmp(child->name, "ADR")) { 639 } else if(!strcmp(child->name, "ADR")) {
640 /* show which address it is */ 640 /* show which address it is */
641 if(child->child) 641 if(child->child)
642 g_string_append_printf(info_text, "<b>%s:</b><br/>\n", 642 g_string_append_printf(info_text, "<b>%s:</b><br/>",
643 _("Address")); 643 _("Address"));
644 for(child2 = child->child; child2; child2 = child2->next) 644 for(child2 = child->child; child2; child2 = child2->next)
645 { 645 {
646 char *text2; 646 char *text2;
647 647
649 continue; 649 continue;
650 650
651 text2 = xmlnode_get_data(child2); 651 text2 = xmlnode_get_data(child2);
652 if(text2 && !strcmp(child2->name, "POBOX")) { 652 if(text2 && !strcmp(child2->name, "POBOX")) {
653 g_string_append_printf(info_text, 653 g_string_append_printf(info_text,
654 "&nbsp;<b>%s:</b> %s<br/>\n", 654 "&nbsp;<b>%s:</b> %s<br/>",
655 _("P.O. Box"), text2); 655 _("P.O. Box"), text2);
656 } else if(text2 && !strcmp(child2->name, "EXTADR")) { 656 } else if(text2 && !strcmp(child2->name, "EXTADR")) {
657 g_string_append_printf(info_text, 657 g_string_append_printf(info_text,
658 "&nbsp;<b>%s:</b> %s<br/>\n", 658 "&nbsp;<b>%s:</b> %s<br/>",
659 _("Extended Address"), text2); 659 _("Extended Address"), text2);
660 } else if(text2 && !strcmp(child2->name, "STREET")) { 660 } else if(text2 && !strcmp(child2->name, "STREET")) {
661 g_string_append_printf(info_text, 661 g_string_append_printf(info_text,
662 "&nbsp;<b>%s:</b> %s<br/>\n", 662 "&nbsp;<b>%s:</b> %s<br/>",
663 _("Street Address"), text2); 663 _("Street Address"), text2);
664 } else if(text2 && !strcmp(child2->name, "LOCALITY")) { 664 } else if(text2 && !strcmp(child2->name, "LOCALITY")) {
665 g_string_append_printf(info_text, 665 g_string_append_printf(info_text,
666 "&nbsp;<b>%s:</b> %s<br/>\n", 666 "&nbsp;<b>%s:</b> %s<br/>",
667 _("Locality"), text2); 667 _("Locality"), text2);
668 } else if(text2 && !strcmp(child2->name, "REGION")) { 668 } else if(text2 && !strcmp(child2->name, "REGION")) {
669 g_string_append_printf(info_text, 669 g_string_append_printf(info_text,
670 "&nbsp;<b>%s:</b> %s<br/>\n", 670 "&nbsp;<b>%s:</b> %s<br/>",
671 _("Region"), text2); 671 _("Region"), text2);
672 } else if(text2 && !strcmp(child2->name, "PCODE")) { 672 } else if(text2 && !strcmp(child2->name, "PCODE")) {
673 g_string_append_printf(info_text, 673 g_string_append_printf(info_text,
674 "&nbsp;<b>%s:</b> %s<br/>\n", 674 "&nbsp;<b>%s:</b> %s<br/>",
675 _("Postal Code"), text2); 675 _("Postal Code"), text2);
676 } else if(text2 && (!strcmp(child2->name, "CTRY") 676 } else if(text2 && (!strcmp(child2->name, "CTRY")
677 || !strcmp(child2->name, "COUNTRY"))) { 677 || !strcmp(child2->name, "COUNTRY"))) {
678 g_string_append_printf(info_text, 678 g_string_append_printf(info_text,
679 "&nbsp;<b>%s:</b> %s<br/>\n", 679 "&nbsp;<b>%s:</b> %s<br/>",
680 _("Country"), text2); 680 _("Country"), text2);
681 } 681 }
682 g_free(text2); 682 g_free(text2);
683 } 683 }
684 } else if(!strcmp(child->name, "TEL")) { 684 } else if(!strcmp(child->name, "TEL")) {
686 if((child2 = xmlnode_get_child(child, "NUMBER"))) { 686 if((child2 = xmlnode_get_child(child, "NUMBER"))) {
687 /* show what kind of number it is */ 687 /* show what kind of number it is */
688 number = xmlnode_get_data(child2); 688 number = xmlnode_get_data(child2);
689 if(number) { 689 if(number) {
690 g_string_append_printf(info_text, 690 g_string_append_printf(info_text,
691 "<b>%s:</b> %s<br/>\n", _("Telephone"), number); 691 "<b>%s:</b> %s<br/>", _("Telephone"), number);
692 g_free(number); 692 g_free(number);
693 } 693 }
694 } else if((number = xmlnode_get_data(child))) { 694 } else if((number = xmlnode_get_data(child))) {
695 /* lots of clients (including gaim) do this, but it's 695 /* lots of clients (including gaim) do this, but it's
696 * out of spec */ 696 * out of spec */
697 g_string_append_printf(info_text, 697 g_string_append_printf(info_text,
698 "<b>%s:</b> %s<br/>\n", _("Telephone"), number); 698 "<b>%s:</b> %s<br/>", _("Telephone"), number);
699 g_free(number); 699 g_free(number);
700 } 700 }
701 } else if(!strcmp(child->name, "EMAIL")) { 701 } else if(!strcmp(child->name, "EMAIL")) {
702 char *userid; 702 char *userid;
703 if((child2 = xmlnode_get_child(child, "USERID"))) { 703 if((child2 = xmlnode_get_child(child, "USERID"))) {
704 /* show what kind of email it is */ 704 /* show what kind of email it is */
705 userid = xmlnode_get_data(child2); 705 userid = xmlnode_get_data(child2);
706 if(userid) { 706 if(userid) {
707 g_string_append_printf(info_text, 707 g_string_append_printf(info_text,
708 "<b>%s:</b> <a href='mailto:%s'>%s</a><br/>\n", 708 "<b>%s:</b> <a href='mailto:%s'>%s</a><br/>",
709 _("Email"), userid, userid); 709 _("Email"), userid, userid);
710 g_free(userid); 710 g_free(userid);
711 } 711 }
712 } else if((userid = xmlnode_get_data(child))) { 712 } else if((userid = xmlnode_get_data(child))) {
713 /* lots of clients (including gaim) do this, but it's 713 /* lots of clients (including gaim) do this, but it's
714 * out of spec */ 714 * out of spec */
715 g_string_append_printf(info_text, 715 g_string_append_printf(info_text,
716 "<b>%s:</b> <a href='mailto:%s'>%s</a><br/>\n", 716 "<b>%s:</b> <a href='mailto:%s'>%s</a><br/>",
717 _("Email"), userid, userid); 717 _("Email"), userid, userid);
718 g_free(userid); 718 g_free(userid);
719 } 719 }
720 } else if(!strcmp(child->name, "ORG")) { 720 } else if(!strcmp(child->name, "ORG")) {
721 for(child2 = child->child; child2; child2 = child2->next) 721 for(child2 = child->child; child2; child2 = child2->next)
726 continue; 726 continue;
727 727
728 text2 = xmlnode_get_data(child2); 728 text2 = xmlnode_get_data(child2);
729 if(text2 && !strcmp(child2->name, "ORGNAME")) { 729 if(text2 && !strcmp(child2->name, "ORGNAME")) {
730 g_string_append_printf(info_text, 730 g_string_append_printf(info_text,
731 "<b>%s:</b> %s<br/>\n", 731 "<b>%s:</b> %s<br/>",
732 _("Organization Name"), text2); 732 _("Organization Name"), text2);
733 } else if(text2 && !strcmp(child2->name, "ORGUNIT")) { 733 } else if(text2 && !strcmp(child2->name, "ORGUNIT")) {
734 g_string_append_printf(info_text, 734 g_string_append_printf(info_text,
735 "<b>%s:</b> %s<br/>\n", 735 "<b>%s:</b> %s<br/>",
736 _("Organization Unit"), text2); 736 _("Organization Unit"), text2);
737 } 737 }
738 g_free(text2); 738 g_free(text2);
739 } 739 }
740 } else if(text && !strcmp(child->name, "TITLE")) { 740 } else if(text && !strcmp(child->name, "TITLE")) {
741 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", 741 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
742 _("Title"), text); 742 _("Title"), text);
743 } else if(text && !strcmp(child->name, "ROLE")) { 743 } else if(text && !strcmp(child->name, "ROLE")) {
744 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", 744 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
745 _("Role"), text); 745 _("Role"), text);
746 } else if(text && !strcmp(child->name, "DESC")) { 746 } else if(text && !strcmp(child->name, "DESC")) {
747 char *text2 = gaim_strdup_withhtml(text); 747 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>",
748 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>\n", 748 _("Description"), text);
749 _("Description"), text2);
750 g_free(text2);
751 } else if(!strcmp(child->name, "PHOTO") || 749 } else if(!strcmp(child->name, "PHOTO") ||
752 !strcmp(child->name, "LOGO")) { 750 !strcmp(child->name, "LOGO")) {
753 if((child2 = xmlnode_get_child(child, "BINVAL"))) { 751 if((child2 = xmlnode_get_child(child, "BINVAL"))) {
754 char *data, *text2; 752 char *data, *text2;
755 int size, imgid; 753 int size, imgid;
772 } 770 }
773 } 771 }
774 772
775 title = g_strdup_printf("User info for %s", from); 773 title = g_strdup_printf("User info for %s", from);
776 774
775 text = gaim_strdup_withhtml(info_text->str);
776
777 gaim_notify_formatted(NULL, title, _("Jabber Profile"), 777 gaim_notify_formatted(NULL, title, _("Jabber Profile"),
778 NULL, info_text->str, NULL, NULL); 778 NULL, text, NULL, NULL);
779 779
780 g_free(title); 780 g_free(title);
781 g_string_free(info_text, TRUE); 781 g_string_free(info_text, TRUE);
782 g_free(text);
782 } 783 }
783 784
784 void jabber_buddy_get_info(GaimConnection *gc, const char *who) 785 void jabber_buddy_get_info(GaimConnection *gc, const char *who)
785 { 786 {
786 JabberStream *js = gc->proto_data; 787 JabberStream *js = gc->proto_data;