comparison libpurple/protocols/jabber/buddy.c @ 32371:7422716de669

Now that there's no speed difference between purple_notify_user_info_add_pair_html and purple_notify_user_info_prepend_pair, use the former to that we don't add items in reverse order. This is hopefully a little less error prone? It also means we won't have to create separate prepend_pair_html and prepend_pair_plaintext functions
author Mark Doliner <mark@kingant.net>
date Mon, 22 Aug 2011 05:39:00 +0000
parents 6283c0f2b02f
children 16f241146576 e1b70ca6bfd7
comparison
equal deleted inserted replaced
32370:8a55048115ab 32371:7422716de669
724 PurpleNotifyUserInfo *user_info; 724 PurpleNotifyUserInfo *user_info;
725 725
726 jbir = g_hash_table_lookup(jbi->resources, resource); 726 jbir = g_hash_table_lookup(jbi->resources, resource);
727 user_info = jbi->user_info; 727 user_info = jbi->user_info;
728 728
729 if (jbr && jbr->client.name) { 729 if (jbr) {
730 char *tmp = 730 char *purdy = NULL;
731 g_strdup_printf("%s%s%s", jbr->client.name, 731 char *tmp;
732 (jbr->client.version ? " " : ""), 732 char priority[12];
733 (jbr->client.version ? jbr->client.version : "")); 733 const char *status_name = jabber_buddy_state_get_name(jbr->state);
734 purple_notify_user_info_prepend_pair(user_info, _("Client"), tmp); 734
735 g_snprintf(priority, sizeof(priority), "%d", jbr->priority);
736 purple_notify_user_info_add_pair_html(user_info, _("Priority"), priority);
737
738 if (jbr->status) {
739 tmp = purple_markup_escape_text(jbr->status, -1);
740 purdy = purple_strdup_withhtml(tmp);
741 g_free(tmp);
742
743 if (purple_strequal(status_name, purdy))
744 status_name = NULL;
745 }
746
747 tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""),
748 ((status_name && purdy) ? ": " : ""),
749 (purdy ? purdy : ""));
750 purple_notify_user_info_add_pair_html(user_info, _("Status"), tmp);
751
735 g_free(tmp); 752 g_free(tmp);
736 753 g_free(purdy);
737 if (jbr->client.os) 754 } else {
738 purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os); 755 purple_notify_user_info_add_pair_html(user_info, _("Status"), _("Unknown"));
756 }
757
758 if (jbir && jbir->idle_seconds > 0) {
759 char *idle = purple_str_seconds_to_string(jbir->idle_seconds);
760 purple_notify_user_info_add_pair_html(user_info, _("Idle"), idle);
761 g_free(idle);
739 } 762 }
740 763
741 if (jbr && jbr->tz_off != PURPLE_NO_TZ_OFF) { 764 if (jbr && jbr->tz_off != PURPLE_NO_TZ_OFF) {
742 time_t now_t; 765 time_t now_t;
743 struct tm *now; 766 struct tm *now;
749 timestamp = 772 timestamp =
750 g_strdup_printf("%s %c%02d%02d", purple_time_format(now), 773 g_strdup_printf("%s %c%02d%02d", purple_time_format(now),
751 jbr->tz_off < 0 ? '-' : '+', 774 jbr->tz_off < 0 ? '-' : '+',
752 abs(jbr->tz_off / (60*60)), 775 abs(jbr->tz_off / (60*60)),
753 abs((jbr->tz_off % (60*60)) / 60)); 776 abs((jbr->tz_off % (60*60)) / 60));
754 purple_notify_user_info_prepend_pair(user_info, _("Local Time"), timestamp); 777 purple_notify_user_info_add_pair_html(user_info, _("Local Time"), timestamp);
755 g_free(timestamp); 778 g_free(timestamp);
756 } 779 }
757 780
758 if (jbir && jbir->idle_seconds > 0) { 781 if (jbr && jbr->client.name) {
759 char *idle = purple_str_seconds_to_string(jbir->idle_seconds);
760 purple_notify_user_info_prepend_pair(user_info, _("Idle"), idle);
761 g_free(idle);
762 }
763
764 if (jbr) {
765 char *purdy = NULL;
766 char *tmp; 782 char *tmp;
767 char priority[12]; 783
768 const char *status_name = jabber_buddy_state_get_name(jbr->state); 784 if (jbr->client.os)
769 785 purple_notify_user_info_add_pair_html(user_info, _("Operating System"), jbr->client.os);
770 if (jbr->status) { 786
771 tmp = purple_markup_escape_text(jbr->status, -1); 787 tmp = g_strdup_printf("%s%s%s", jbr->client.name,
772 purdy = purple_strdup_withhtml(tmp); 788 (jbr->client.version ? " " : ""),
773 g_free(tmp); 789 (jbr->client.version ? jbr->client.version : ""));
774 790 purple_notify_user_info_add_pair_html(user_info, _("Client"), tmp);
775 if (purple_strequal(status_name, purdy))
776 status_name = NULL;
777 }
778
779 tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""),
780 ((status_name && purdy) ? ": " : ""),
781 (purdy ? purdy : ""));
782 purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp);
783
784 g_snprintf(priority, sizeof(priority), "%d", jbr->priority);
785 purple_notify_user_info_prepend_pair(user_info, _("Priority"), priority);
786
787 g_free(tmp); 791 g_free(tmp);
788 g_free(purdy);
789 } else {
790 purple_notify_user_info_prepend_pair(user_info, _("Status"), _("Unknown"));
791 } 792 }
792 } 793 }
793 794
794 static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi) 795 static void jabber_buddy_info_show_if_ready(JabberBuddyInfo *jbi)
795 { 796 {