Mercurial > pidgin.yaz
comparison libgaim/protocols/jabber/buddy.c @ 15144:b81e4e44b509
[gaim-migrate @ 17929]
User Info and Tooltips now use the GaimNotifyUserInfo object and methods defined in notify.h. GaimNotifyUserInfo objects encapsulate a list of GaimNotifyUserInfoEntry objects, each of which may have a label, a value, and be specified to be a section header.
This moves the burden of UI generation of user information from the various prpls to the UI. The UI can choose how to display the information rather than being fenced into a particular HTML formatting. Consistency across the prpls' information presentation is now enforced, as well. gaim_notify_user_info_get_text_with_newline() generates text in the:
<b>label</b>: value
<b>label</b>: value
format as was passed by convention from prpls in the past.
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Sun, 10 Dec 2006 02:53:09 +0000 |
parents | bc440018e208 |
children | 49afc9ce69d2 |
comparison
equal
deleted
inserted
replaced
15143:4b319b19aa24 | 15144:b81e4e44b509 |
---|---|
600 * end of that ancient crap that needs to die | 600 * end of that ancient crap that needs to die |
601 ******/ | 601 ******/ |
602 | 602 |
603 static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi) | 603 static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi) |
604 { | 604 { |
605 GString *info_text; | 605 char *resource_name, *tmp; |
606 char *resource_name; | |
607 JabberBuddyResource *jbr; | 606 JabberBuddyResource *jbr; |
608 JabberBuddyInfoResource *jbir = NULL; | 607 JabberBuddyInfoResource *jbir = NULL; |
609 GList *resources; | 608 GList *resources; |
609 GaimNotifyUserInfo *user_info; | |
610 | 610 |
611 /* not yet */ | 611 /* not yet */ |
612 if(jbi->ids) | 612 if(jbi->ids) |
613 return; | 613 return; |
614 | 614 |
615 info_text = g_string_new(""); | 615 user_info = gaim_notify_user_info_new(); |
616 resource_name = jabber_get_resource(jbi->jid); | 616 resource_name = jabber_get_resource(jbi->jid); |
617 | 617 |
618 if(resource_name) { | 618 if(resource_name) { |
619 jbr = jabber_buddy_find_resource(jbi->jb, resource_name); | 619 jbr = jabber_buddy_find_resource(jbi->jb, resource_name); |
620 jbir = g_hash_table_lookup(jbi->resources, resource_name); | 620 jbir = g_hash_table_lookup(jbi->resources, resource_name); |
621 if(jbr) { | 621 if(jbr) { |
622 char *purdy = NULL; | 622 char *purdy = NULL; |
623 if(jbr->status) | 623 if(jbr->status) |
624 purdy = gaim_strdup_withhtml(jbr->status); | 624 purdy = gaim_strdup_withhtml(jbr->status); |
625 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>", | 625 tmp = g_strdup_printf("%s%s%s", jabber_buddy_state_get_name(jbr->state), |
626 _("Status"), jabber_buddy_state_get_name(jbr->state), | 626 (purdy ? ": " : ""), |
627 purdy ? ": " : "", | 627 (purdy ? purdy : "")); |
628 purdy ? purdy : ""); | 628 gaim_notify_user_info_add_pair(user_info, _("Status"), tmp); |
629 if(purdy) | 629 g_free(tmp); |
630 g_free(purdy); | 630 g_free(purdy); |
631 } else { | 631 } else { |
632 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", | 632 gaim_notify_user_info_add_pair(user_info, _("Status"), _("Unknown")); |
633 _("Status"), _("Unknown")); | |
634 } | 633 } |
635 if(jbir) { | 634 if(jbir) { |
636 if(jbir->idle_seconds > 0) { | 635 if(jbir->idle_seconds > 0) { |
637 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", | 636 gaim_notify_user_info_add_pair(user_info, _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds)); |
638 _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds)); | |
639 } | 637 } |
640 } | 638 } |
641 if(jbr && jbr->client.name) { | 639 if(jbr && jbr->client.name) { |
642 g_string_append_printf(info_text, "<b>%s:</b> %s %s<br/>", | 640 tmp = g_strdup_printf("%s%s%s", jbr->client.name, |
643 _("Client:"), jbr->client.name, | 641 (jbr->client.version ? " " : ""), |
644 jbr->client.version ? jbr->client.version : ""); | 642 (jbr->client.version ? jbr->client.version : "")); |
643 gaim_notify_user_info_add_pair(user_info, _("Client"), tmp); | |
644 g_free(tmp); | |
645 | |
645 if(jbr->client.os) { | 646 if(jbr->client.os) { |
646 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", | 647 gaim_notify_user_info_add_pair(user_info, _("Operating System"), jbr->client.os); |
647 _("Operating System"), jbr->client.os); | |
648 } | 648 } |
649 } | 649 } |
650 } else { | 650 } else { |
651 for(resources = jbi->jb->resources; resources; resources = resources->next) { | 651 for(resources = jbi->jb->resources; resources; resources = resources->next) { |
652 char *purdy = NULL; | 652 char *purdy = NULL; |
653 jbr = resources->data; | 653 jbr = resources->data; |
654 if(jbr->status) | 654 if(jbr->status) |
655 purdy = gaim_strdup_withhtml(jbr->status); | 655 purdy = gaim_strdup_withhtml(jbr->status); |
656 if(jbr->name) | 656 if(jbr->name) |
657 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", | 657 gaim_notify_user_info_add_pair(user_info, _("Resource"), jbr->name); |
658 _("Resource"), jbr->name); | 658 tmp = g_strdup_printf("%d", jbr->priority); |
659 g_string_append_printf(info_text, "<b>%s:</b> %d<br/>", | 659 gaim_notify_user_info_add_pair(user_info, _("Priority"), tmp); |
660 _("Priority"), jbr->priority); | 660 g_free(tmp); |
661 g_string_append_printf(info_text, "<b>%s:</b> %s%s%s<br/>", | 661 |
662 _("Status"), jabber_buddy_state_get_name(jbr->state), | 662 tmp = g_strdup_printf("%s%s%s", jabber_buddy_state_get_name(jbr->state), |
663 purdy ? ": " : "", | 663 (purdy ? ": " : ""), |
664 purdy ? purdy : ""); | 664 (purdy ? purdy : "")); |
665 if(purdy) | 665 gaim_notify_user_info_add_pair(user_info, _("Status"), tmp); |
666 g_free(purdy); | 666 g_free(tmp); |
667 g_free(purdy); | |
667 | 668 |
668 if(jbr->name) | 669 if(jbr->name) |
669 jbir = g_hash_table_lookup(jbi->resources, jbr->name); | 670 jbir = g_hash_table_lookup(jbi->resources, jbr->name); |
670 | 671 |
671 if(jbir) { | 672 if(jbir) { |
672 if(jbir->idle_seconds > 0) { | 673 if(jbir->idle_seconds > 0) { |
673 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", | 674 gaim_notify_user_info_add_pair(user_info, _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds)); |
674 _("Idle"), gaim_str_seconds_to_string(jbir->idle_seconds)); | |
675 } | 675 } |
676 } | 676 } |
677 if(jbr->client.name) { | 677 if(jbr && jbr->client.name) { |
678 g_string_append_printf(info_text, "<b>%s:</b> %s %s<br/>", | 678 tmp = g_strdup_printf("%s%s%s", jbr->client.name, |
679 _("Client"), jbr->client.name, | 679 (jbr->client.version ? " " : ""), |
680 jbr->client.version ? jbr->client.version : ""); | 680 (jbr->client.version ? jbr->client.version : "")); |
681 gaim_notify_user_info_add_pair(user_info, | |
682 _("Client"), tmp); | |
683 g_free(tmp); | |
684 | |
681 if(jbr->client.os) { | 685 if(jbr->client.os) { |
682 g_string_append_printf(info_text, "<b>%s:</b> %s<br/>", | 686 gaim_notify_user_info_add_pair(user_info, _("Operating System"), jbr->client.os); |
683 _("Operating System"), jbr->client.os); | |
684 } | 687 } |
685 } | 688 } |
686 | |
687 g_string_append_printf(info_text, "<br/>"); | |
688 } | 689 } |
689 } | 690 } |
690 | 691 |
691 g_free(resource_name); | 692 g_free(resource_name); |
692 | 693 |
693 if (jbi->vcard_text != NULL) | 694 if (jbi->vcard_text != NULL) { |
694 info_text = g_string_append(info_text, jbi->vcard_text); | 695 gaim_notify_user_info_add_section_break(user_info); |
695 | 696 /* Should this have some sort of label? */ |
696 gaim_notify_userinfo(jbi->js->gc, jbi->jid, info_text->str, NULL, NULL); | 697 gaim_notify_user_info_add_pair(user_info, NULL, jbi->vcard_text); |
698 } | |
699 | |
700 gaim_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL); | |
701 gaim_notify_user_info_destroy(user_info); | |
697 | 702 |
698 while(jbi->vcard_imgids) { | 703 while(jbi->vcard_imgids) { |
699 gaim_imgstore_unref(GPOINTER_TO_INT(jbi->vcard_imgids->data)); | 704 gaim_imgstore_unref(GPOINTER_TO_INT(jbi->vcard_imgids->data)); |
700 jbi->vcard_imgids = g_slist_delete_link(jbi->vcard_imgids, jbi->vcard_imgids); | 705 jbi->vcard_imgids = g_slist_delete_link(jbi->vcard_imgids, jbi->vcard_imgids); |
701 } | 706 } |
702 | |
703 g_string_free(info_text, TRUE); | |
704 | 707 |
705 if (jbi->timeout_handle > 0) | 708 if (jbi->timeout_handle > 0) |
706 gaim_timeout_remove(jbi->timeout_handle); | 709 gaim_timeout_remove(jbi->timeout_handle); |
707 | 710 |
708 g_free(jbi->jid); | 711 g_free(jbi->jid); |