comparison libpurple/protocols/jabber/buddy.c @ 27325:91e0cd125f3d

Style and comments
author Paul Aurich <paul@darkrain42.org>
date Sun, 05 Jul 2009 06:05:54 +0000
parents 77fc855ed8b7
children 41cc041a0733
comparison
equal deleted inserted replaced
27324:77fc855ed8b7 27325:91e0cd125f3d
659 659
660 jbir = g_hash_table_lookup(jbi->resources, resource); 660 jbir = g_hash_table_lookup(jbi->resources, resource);
661 user_info = jbi->user_info; 661 user_info = jbi->user_info;
662 662
663 if (jbr && jbr->client.name) { 663 if (jbr && jbr->client.name) {
664 char *tmp = g_strdup_printf("%s%s%s", jbr->client.name, 664 char *tmp =
665 (jbr->client.version ? " " : ""), 665 g_strdup_printf("%s%s%s", jbr->client.name,
666 (jbr->client.version ? jbr->client.version : "")); 666 (jbr->client.version ? " " : ""),
667 (jbr->client.version ? jbr->client.version : ""));
667 purple_notify_user_info_prepend_pair(user_info, _("Client"), tmp); 668 purple_notify_user_info_prepend_pair(user_info, _("Client"), tmp);
668 g_free(tmp); 669 g_free(tmp);
669 670
670 if (jbr->client.os) { 671 if (jbr->client.os)
671 purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os); 672 purple_notify_user_info_prepend_pair(user_info, _("Operating System"), jbr->client.os);
672 }
673 } 673 }
674 674
675 if (jbr && jbr->tz_off != PURPLE_NO_TZ_OFF) { 675 if (jbr && jbr->tz_off != PURPLE_NO_TZ_OFF) {
676 time_t now_t; 676 time_t now_t;
677 struct tm *now; 677 struct tm *now;
678 char *timestamp; 678 char *timestamp;
679 time(&now_t); 679 time(&now_t);
680 now_t += jbr->tz_off; 680 now_t += jbr->tz_off;
681 now = gmtime(&now_t); 681 now = gmtime(&now_t);
682 682
683 timestamp = g_strdup_printf("%s %c%02d%02d", purple_time_format(now), 683 timestamp =
684 jbr->tz_off < 0 ? '-' : '+', 684 g_strdup_printf("%s %c%02d%02d", purple_time_format(now),
685 abs(jbr->tz_off / (60*60)), 685 jbr->tz_off < 0 ? '-' : '+',
686 abs((jbr->tz_off % (60*60)) / 60)); 686 abs(jbr->tz_off / (60*60)),
687 abs((jbr->tz_off % (60*60)) / 60));
687 purple_notify_user_info_prepend_pair(user_info, _("Local Time"), timestamp); 688 purple_notify_user_info_prepend_pair(user_info, _("Local Time"), timestamp);
688 g_free(timestamp); 689 g_free(timestamp);
689 } 690 }
690 691
691 if (jbir && jbir->idle_seconds > 0) { 692 if (jbir && jbir->idle_seconds > 0) {
698 char *purdy = NULL; 699 char *purdy = NULL;
699 char *tmp; 700 char *tmp;
700 char priority[12]; 701 char priority[12];
701 const char *status_name = jabber_buddy_state_get_name(jbr->state); 702 const char *status_name = jabber_buddy_state_get_name(jbr->state);
702 703
703 if (jbr->status) 704 if (jbr->status) {
704 purdy = purple_strdup_withhtml(jbr->status); 705 purdy = purple_strdup_withhtml(jbr->status);
705 if (status_name && purdy && !strcmp(status_name, purdy)) 706
706 status_name = NULL; 707 if (purple_strequal(status_name, purdy))
708 status_name = NULL;
709 }
707 710
708 tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""), 711 tmp = g_strdup_printf("%s%s%s", (status_name ? status_name : ""),
709 ((status_name && purdy) ? ": " : ""), 712 ((status_name && purdy) ? ": " : ""),
710 (purdy ? purdy : "")); 713 (purdy ? purdy : ""));
711 purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp); 714 purple_notify_user_info_prepend_pair(user_info, _("Status"), tmp);
726 JabberBuddyResource *jbr; 729 JabberBuddyResource *jbr;
727 GList *resources; 730 GList *resources;
728 PurpleNotifyUserInfo *user_info; 731 PurpleNotifyUserInfo *user_info;
729 732
730 /* not yet */ 733 /* not yet */
731 if(jbi->ids) 734 if (jbi->ids)
732 return; 735 return;
733 736
734 user_info = jbi->user_info; 737 user_info = jbi->user_info;
735 resource_name = jabber_get_resource(jbi->jid); 738 resource_name = jabber_get_resource(jbi->jid);
736 739
737 /* If we have one or more pairs from the vcard, put a section break above it */ 740 /* If we have one or more pairs from the vcard, put a section break above it */
738 if (purple_notify_user_info_get_entries(user_info)) 741 if (purple_notify_user_info_get_entries(user_info))
739 purple_notify_user_info_prepend_section_break(user_info); 742 purple_notify_user_info_prepend_section_break(user_info);
740 743
741 /* Prepend the primary buddy info to user_info so that it goes before the vcard. */ 744 /* Add the information about the user's resource(s) */
742 if(resource_name) { 745 if (resource_name) {
743 jbr = jabber_buddy_find_resource(jbi->jb, resource_name); 746 jbr = jabber_buddy_find_resource(jbi->jb, resource_name);
744 add_jbr_info(jbi, resource_name, jbr); 747 add_jbr_info(jbi, resource_name, jbr);
745 } else { 748 } else {
746 for (resources = jbi->jb->resources; resources; resources = resources->next) { 749 for (resources = jbi->jb->resources; resources; resources = resources->next) {
747 jbr = resources->data; 750 jbr = resources->data;
748 751
749 /* put a section break between resources, this is not needed if 752 /* put a section break between resources, this is not needed if
750 we are at the first, because one was already added for the vcard 753 we are at the first, because one was already added for the vcard
751 section */ 754 section */
752 if (resources != jbi->jb->resources) { 755 if (resources != jbi->jb->resources)
753 purple_notify_user_info_prepend_section_break(user_info); 756 purple_notify_user_info_prepend_section_break(user_info);
754 }
755 757
756 add_jbr_info(jbi, jbr->name, jbr); 758 add_jbr_info(jbi, jbr->name, jbr);
757 759
758 if(jbr->name) 760 if (jbr->name)
759 purple_notify_user_info_prepend_pair(user_info, _("Resource"), jbr->name); 761 purple_notify_user_info_prepend_pair(user_info, _("Resource"), jbr->name);
760 } 762 }
761 } 763 }
762 764
763 if (!jbi->jb->resources) { 765 if (!jbi->jb->resources) {
764 /* the buddy is offline */ 766 /* the buddy is offline */
765 gchar *status = 767 gchar *status =
766 g_strdup_printf("%s%s%s", _("Offline"), 768 g_strdup_printf("%s%s%s", _("Offline"),
767 jbi->last_message ? ": " : "", 769 jbi->last_message ? ": " : "",
768 jbi->last_message ? jbi->last_message : ""); 770 jbi->last_message ? jbi->last_message : "");
769 if (jbi->last_seconds > 0) { 771 if (jbi->last_seconds > 0) {
770 char *last = purple_str_seconds_to_string(jbi->last_seconds); 772 char *last = purple_str_seconds_to_string(jbi->last_seconds);
771 gchar *message = g_strdup_printf(_("%s ago"), last); 773 gchar *message = g_strdup_printf(_("%s ago"), last);
772 purple_notify_user_info_prepend_pair(user_info, 774 purple_notify_user_info_prepend_pair(user_info,
773 _("Logged off"), message); 775 _("Logged off"), message);
780 782
781 g_free(resource_name); 783 g_free(resource_name);
782 784
783 purple_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL); 785 purple_notify_userinfo(jbi->js->gc, jbi->jid, user_info, NULL, NULL);
784 786
785 while(jbi->vcard_imgids) { 787 while (jbi->vcard_imgids) {
786 purple_imgstore_unref_by_id(GPOINTER_TO_INT(jbi->vcard_imgids->data)); 788 purple_imgstore_unref_by_id(GPOINTER_TO_INT(jbi->vcard_imgids->data));
787 jbi->vcard_imgids = g_slist_delete_link(jbi->vcard_imgids, jbi->vcard_imgids); 789 jbi->vcard_imgids = g_slist_delete_link(jbi->vcard_imgids, jbi->vcard_imgids);
788 } 790 }
789 791
790 jbi->js->pending_buddy_info_requests = g_slist_remove(jbi->js->pending_buddy_info_requests, jbi); 792 jbi->js->pending_buddy_info_requests = g_slist_remove(jbi->js->pending_buddy_info_requests, jbi);