libgaim/protocols/oscar/oscar.c

changeset 15205
f642029b2f97
parent 15204
6775ac53169c
child 15210
4278244e432c
equal deleted inserted replaced
15204:6775ac53169c 15205:f642029b2f97
703 else 703 else
704 return g_strdup_printf(_("Online")); 704 return g_strdup_printf(_("Online"));
705 } 705 }
706 706
707 static void 707 static void
708 oscar_string_append(GString *str, const char *newline, 708 oscar_user_info_add_pair(GaimNotifyUserInfo *user_info, const char *name, const char *value)
709 const char *name, const char *value)
710 { 709 {
711 if (value && value[0]) { 710 if (value && value[0]) {
712 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, value); 711 gaim_notify_user_info_add_pair(user_info, name, value);
712 }
713 }
714
715 static void
716 oscar_user_info_convert_and_add_pair(GaimAccount *account, GaimNotifyUserInfo *user_info,
717 const char *name, const char *value)
718 {
719 gchar *utf8;
720
721 if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) {
722 gaim_notify_user_info_add_pair(user_info, name, utf8);
723 g_free(utf8);
713 } 724 }
714 } 725 }
715 726
716 static void 727 static void
717 oscar_string_convert_and_append(GaimAccount *account, GString *str, const char *newline, 728 oscar_string_convert_and_append(GaimAccount *account, GString *str, const char *newline,
723 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); 734 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8);
724 g_free(utf8); 735 g_free(utf8);
725 } 736 }
726 } 737 }
727 738
728 static void oscar_string_append_info(GaimConnection *gc, GString *str, const char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) 739 static void
740 oscar_user_info_convert_and_add(GaimAccount *account, GaimNotifyUserInfo *user_info,
741 const char *name, const char *value)
742 {
743 gchar *utf8;
744
745 if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, value))) {
746 gaim_notify_user_info_add_pair(user_info, name, value);
747 g_free(utf8);
748 }
749 }
750
751 static void oscar_string_append_info(GaimConnection *gc, GaimNotifyUserInfo *user_info, GaimBuddy *b, aim_userinfo_t *userinfo)
729 { 752 {
730 OscarData *od; 753 OscarData *od;
731 GaimAccount *account; 754 GaimAccount *account;
732 GaimPresence *presence = NULL; 755 GaimPresence *presence = NULL;
733 GaimStatus *status = NULL; 756 GaimStatus *status = NULL;
736 char *tmp; 759 char *tmp;
737 760
738 od = gc->proto_data; 761 od = gc->proto_data;
739 account = gaim_connection_get_account(gc); 762 account = gaim_connection_get_account(gc);
740 763
741 if ((str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) 764 if ((user_info == NULL) || ((b == NULL) && (userinfo == NULL)))
742 return; 765 return;
743 766
744 if (userinfo == NULL) 767 if (userinfo == NULL)
745 userinfo = aim_locate_finduserinfo(od, b->name); 768 userinfo = aim_locate_finduserinfo(od, b->name);
746 769
758 781
759 if (b != NULL) { 782 if (b != NULL) {
760 if (gaim_presence_is_online(presence)) { 783 if (gaim_presence_is_online(presence)) {
761 if (aim_sn_is_icq(b->name)) { 784 if (aim_sn_is_icq(b->name)) {
762 GaimStatus *status = gaim_presence_get_active_status(presence); 785 GaimStatus *status = gaim_presence_get_active_status(presence);
763 oscar_string_append(str, newline, _("Status"), 786 oscar_user_info_add_pair(user_info, _("Status"), gaim_status_get_name(status));
764 gaim_status_get_name(status));
765 } 787 }
766 } else { 788 } else {
767 tmp = aim_ssi_itemlist_findparentname(od->ssi.local, b->name); 789 tmp = aim_ssi_itemlist_findparentname(od->ssi.local, b->name);
768 if (aim_ssi_waitingforauth(od->ssi.local, tmp, b->name)) 790 if (aim_ssi_waitingforauth(od->ssi.local, tmp, b->name))
769 oscar_string_append(str, newline, _("Status"), 791 oscar_user_info_add_pair(user_info, _("Status"), _("Not Authorized"));
770 _("Not Authorized"));
771 else 792 else
772 oscar_string_append(str, newline, _("Status"), 793 oscar_user_info_add_pair(user_info, _("Status"), _("Offline"));
773 _("Offline"));
774 } 794 }
775 } 795 }
776 796
777 if ((bi != NULL) && (bi->ipaddr != 0)) { 797 if ((bi != NULL) && (bi->ipaddr != 0)) {
778 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", 798 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu",
779 (bi->ipaddr & 0xff000000) >> 24, 799 (bi->ipaddr & 0xff000000) >> 24,
780 (bi->ipaddr & 0x00ff0000) >> 16, 800 (bi->ipaddr & 0x00ff0000) >> 16,
781 (bi->ipaddr & 0x0000ff00) >> 8, 801 (bi->ipaddr & 0x0000ff00) >> 8,
782 (bi->ipaddr & 0x000000ff)); 802 (bi->ipaddr & 0x000000ff));
783 oscar_string_append(str, newline, _("IP Address"), tmp); 803 oscar_user_info_add_pair(user_info, _("IP Address"), tmp);
784 g_free(tmp); 804 g_free(tmp);
785 } 805 }
786 806
787 807
788 if ((userinfo != NULL) && (userinfo->warnlevel != 0)) { 808 if ((userinfo != NULL) && (userinfo->warnlevel != 0)) {
789 tmp = g_strdup_printf("%d", (int)(userinfo->warnlevel/10.0 + .5)); 809 tmp = g_strdup_printf("%d", (int)(userinfo->warnlevel/10.0 + .5));
790 oscar_string_append(str, newline, _("Warning Level"), tmp); 810 oscar_user_info_add_pair(user_info, _("Warning Level"), tmp);
791 g_free(tmp); 811 g_free(tmp);
792 } 812 }
793 813
794 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { 814 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) {
795 tmp = aim_ssi_getcomment(od->ssi.local, g->name, b->name); 815 tmp = aim_ssi_getcomment(od->ssi.local, g->name, b->name);
796 if (tmp != NULL) { 816 if (tmp != NULL) {
797 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp)); 817 char *tmp2 = g_markup_escape_text(tmp, strlen(tmp));
798 g_free(tmp); 818 g_free(tmp);
799 oscar_string_convert_and_append(account, str, newline, _("Buddy Comment"), tmp2); 819
820 oscar_user_info_convert_and_add_pair(account, user_info, _("Buddy Comment"), tmp2);
800 g_free(tmp2); 821 g_free(tmp2);
801 } 822 }
802 } 823 }
803 } 824 }
804 825
2579 static int gaim_parse_clientauto_ch4(OscarData *od, char *who, guint16 reason, guint32 state, char *msg) { 2600 static int gaim_parse_clientauto_ch4(OscarData *od, char *who, guint16 reason, guint32 state, char *msg) {
2580 GaimConnection *gc = od->gc; 2601 GaimConnection *gc = od->gc;
2581 2602
2582 switch(reason) { 2603 switch(reason) {
2583 case 0x0003: { /* Reply from an ICQ status message request */ 2604 case 0x0003: { /* Reply from an ICQ status message request */
2584 char *title, *statusmsg, **splitmsg, *dialogmsg; 2605 char *statusmsg, **splitmsg;
2585 2606 GaimNotifyUserInfo *user_info;
2586 title = g_strdup_printf(_("Info for %s"), who);
2587 2607
2588 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ 2608 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */
2589 statusmsg = oscar_icqstatus(state); 2609 statusmsg = oscar_icqstatus(state);
2590 splitmsg = g_strsplit(msg, "\r\n", 0); 2610 splitmsg = g_strsplit(msg, "\r\n", 0);
2591 dialogmsg = g_strdup_printf(_("<B>UIN:</B> %s<BR><B>Status:</B> %s<HR>%s"), who, statusmsg, g_strjoinv("<BR>", splitmsg)); 2611
2612 user_info = gaim_notify_user_info_new();
2613
2614 gaim_notify_user_info_add_pair(user_info, _("UIN"), who);
2615 gaim_notify_user_info_add_pair(user_info, _("Status"), statusmsg);
2616 gaim_notify_user_info_add_pair(user_info, NULL, g_strjoinv("<BR>", splitmsg));
2617
2592 g_free(statusmsg); 2618 g_free(statusmsg);
2593 g_strfreev(splitmsg); 2619 g_strfreev(splitmsg);
2594 2620
2595 gaim_notify_userinfo(gc, who, dialogmsg, NULL, NULL); 2621 gaim_notify_userinfo(gc, who, user_info, NULL, NULL);
2596 2622 gaim_notify_user_info_destroy(user_info);
2597 g_free(title); 2623
2598 g_free(dialogmsg);
2599 } break; 2624 } break;
2600 2625
2601 default: { 2626 default: {
2602 gaim_debug_warning("oscar", 2627 gaim_debug_warning("oscar",
2603 "Received an unknown client auto-response from %s. " 2628 "Received an unknown client auto-response from %s. "
2764 } 2789 }
2765 2790
2766 static int gaim_parse_userinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) { 2791 static int gaim_parse_userinfo(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) {
2767 GaimConnection *gc = od->gc; 2792 GaimConnection *gc = od->gc;
2768 GaimAccount *account = gaim_connection_get_account(gc); 2793 GaimAccount *account = gaim_connection_get_account(gc);
2769 GString *str; 2794 GaimNotifyUserInfo *user_info;
2770 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; 2795 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL;
2771 va_list ap; 2796 va_list ap;
2772 aim_userinfo_t *userinfo; 2797 aim_userinfo_t *userinfo;
2773 2798
2774 va_start(ap, fr); 2799 va_start(ap, fr);
2775 userinfo = va_arg(ap, aim_userinfo_t *); 2800 userinfo = va_arg(ap, aim_userinfo_t *);
2776 va_end(ap); 2801 va_end(ap);
2777 2802
2778 str = g_string_new(""); 2803 user_info = gaim_notify_user_info_new();
2779 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); 2804 gaim_notify_user_info_add_pair(user_info, _("Screen Name"), userinfo->sn);
2780 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); 2805
2806 tmp = g_strdup_printf("%d", (int)((userinfo->warnlevel/10.0) + 0.5));
2807 gaim_notify_user_info_add_pair(user_info, _("Warning Level"), tmp);
2808 g_free(tmp);
2781 2809
2782 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) { 2810 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) {
2783 time_t t = userinfo->onlinesince - od->timeoffset; 2811 time_t t = userinfo->onlinesince - od->timeoffset;
2784 oscar_string_append(str, "\n<br>", _("Online Since"), gaim_date_format_full(localtime(&t))); 2812 oscar_user_info_add_pair(user_info, _("Online Since"), gaim_date_format_full(localtime(&t)));
2785 } 2813 }
2786 2814
2787 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) { 2815 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) {
2788 time_t t = userinfo->membersince - od->timeoffset; 2816 time_t t = userinfo->membersince - od->timeoffset;
2789 oscar_string_append(str, "\n<br>", _("Member Since"), gaim_date_format_full(localtime(&t))); 2817 oscar_user_info_add_pair(user_info, _("Member Since"), gaim_date_format_full(localtime(&t)));
2790 } 2818 }
2791 2819
2792 if (userinfo->capabilities != 0) { 2820 if (userinfo->capabilities != 0) {
2793 tmp = oscar_caps_to_string(userinfo->capabilities); 2821 tmp = oscar_caps_to_string(userinfo->capabilities);
2794 oscar_string_append(str, "\n<br>", _("Capabilities"), tmp); 2822 oscar_user_info_add_pair(user_info, _("Capabilities"), tmp);
2795 g_free(tmp); 2823 g_free(tmp);
2796 } 2824 }
2797 2825
2798 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { 2826 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) {
2799 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); 2827 tmp = gaim_str_seconds_to_string(userinfo->idletime*60);
2800 oscar_string_append(str, "\n<br>", _("Idle"), tmp); 2828 oscar_user_info_add_pair(user_info, _("Idle"), tmp);
2801 g_free(tmp); 2829 g_free(tmp);
2802 } 2830 }
2803 2831
2804 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); 2832 oscar_string_append_info(gc, user_info, NULL, userinfo);
2805 2833
2806 /* Available message */ 2834 /* Available message */
2807 if ((userinfo->status != NULL) && !(userinfo->flags & AIM_FLAG_AWAY)) 2835 if ((userinfo->status != NULL) && !(userinfo->flags & AIM_FLAG_AWAY))
2808 { 2836 {
2809 if (userinfo->status[0] != '\0') 2837 if (userinfo->status[0] != '\0')
2810 tmp = oscar_encoding_to_utf8(userinfo->status_encoding, 2838 tmp = oscar_encoding_to_utf8(userinfo->status_encoding,
2811 userinfo->status, userinfo->status_len); 2839 userinfo->status, userinfo->status_len);
2812 oscar_string_convert_and_append(account, str, "\n<br>", _("Available Message"), tmp); 2840 oscar_user_info_add_pair(user_info, _("Available Message"), tmp);
2813 g_free(tmp); 2841 g_free(tmp);
2814 } 2842 }
2815 2843
2816 /* Away message */ 2844 /* Away message */
2817 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { 2845 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) {
2818 tmp = oscar_encoding_extract(userinfo->away_encoding); 2846 tmp = oscar_encoding_extract(userinfo->away_encoding);
2819 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); 2847 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len);
2820 g_free(tmp); 2848 g_free(tmp);
2821 if (away_utf8 != NULL) { 2849 if (away_utf8 != NULL) {
2822 g_string_append_printf(str, "\n<hr>%s", away_utf8); 2850 tmp = gaim_str_sub_away_formatters(away_utf8, gaim_account_get_username(account));
2851 oscar_user_info_add_pair(user_info, NULL, tmp);
2852 g_free(tmp);
2823 g_free(away_utf8); 2853 g_free(away_utf8);
2824 } 2854 }
2825 } 2855 }
2826 2856
2827 /* Info */ 2857 /* Info */
2828 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { 2858 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) {
2829 tmp = oscar_encoding_extract(userinfo->info_encoding); 2859 tmp = oscar_encoding_extract(userinfo->info_encoding);
2830 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); 2860 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len);
2831 g_free(tmp); 2861 g_free(tmp);
2832 if (info_utf8 != NULL) { 2862 if (info_utf8 != NULL) {
2833 g_string_append_printf(str, "\n<hr>%s", info_utf8); 2863 tmp = gaim_str_sub_away_formatters(info_utf8, gaim_account_get_username(account));
2864 oscar_user_info_add_pair(user_info, _("Profile"), tmp);
2865 g_free(tmp);
2834 g_free(info_utf8); 2866 g_free(info_utf8);
2835 } 2867 }
2836 } 2868 }
2837 2869
2838 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); 2870 gaim_notify_userinfo(gc, userinfo->sn, user_info, NULL, NULL);
2839 g_string_free(str, TRUE); 2871 gaim_notify_user_info_destroy(user_info);
2840 gaim_str_strip_char(tmp, '\r');
2841 gaim_notify_userinfo(gc, userinfo->sn, tmp, NULL, NULL);
2842 g_free(tmp);
2843 2872
2844 return 1; 2873 return 1;
2845 } 2874 }
2846 2875
2847 static int gaim_got_infoblock(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) 2876 static int gaim_got_infoblock(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
3579 GaimConnection *gc; 3608 GaimConnection *gc;
3580 GaimAccount *account; 3609 GaimAccount *account;
3581 GaimBuddy *buddy; 3610 GaimBuddy *buddy;
3582 struct buddyinfo *bi; 3611 struct buddyinfo *bi;
3583 gchar who[16]; 3612 gchar who[16];
3584 GString *str; 3613 GaimNotifyUserInfo *user_info;
3614 GString *tmp;
3585 gchar *utf8; 3615 gchar *utf8;
3616 gchar *buf;
3586 const gchar *alias; 3617 const gchar *alias;
3587 va_list ap; 3618 va_list ap;
3588 struct aim_icq_info *info; 3619 struct aim_icq_info *info;
3589 3620
3590 gc = od->gc; 3621 gc = od->gc;
3595 va_end(ap); 3626 va_end(ap);
3596 3627
3597 if (!info->uin) 3628 if (!info->uin)
3598 return 0; 3629 return 0;
3599 3630
3600 str = g_string_sized_new(100); 3631 user_info = gaim_notify_user_info_new();
3632
3601 g_snprintf(who, sizeof(who), "%u", info->uin); 3633 g_snprintf(who, sizeof(who), "%u", info->uin);
3602 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); 3634 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who);
3603 if (buddy != NULL) 3635 if (buddy != NULL)
3604 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); 3636 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name));
3605 else 3637 else
3606 bi = NULL; 3638 bi = NULL;
3607 3639
3608 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); 3640 gaim_notify_user_info_add_pair(user_info, _("UIN"), who);
3609 oscar_string_convert_and_append(account, str, "\n<br>", _("Nick"), info->nick); 3641 oscar_user_info_convert_and_add(account, user_info, _("Nick"), info->nick);
3610 if ((bi != NULL) && (bi->ipaddr != 0)) { 3642 if ((bi != NULL) && (bi->ipaddr != 0)) {
3611 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", 3643 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu",
3612 (bi->ipaddr & 0xff000000) >> 24, 3644 (bi->ipaddr & 0xff000000) >> 24,
3613 (bi->ipaddr & 0x00ff0000) >> 16, 3645 (bi->ipaddr & 0x00ff0000) >> 16,
3614 (bi->ipaddr & 0x0000ff00) >> 8, 3646 (bi->ipaddr & 0x0000ff00) >> 8,
3615 (bi->ipaddr & 0x000000ff)); 3647 (bi->ipaddr & 0x000000ff));
3616 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); 3648 gaim_notify_user_info_add_pair(user_info, _("IP Address"), tstr);
3617 g_free(tstr); 3649 g_free(tstr);
3618 } 3650 }
3619 oscar_string_convert_and_append(account, str, "\n<br>", _("First Name"), info->first); 3651 oscar_user_info_convert_and_add(account, user_info, _("First Name"), info->first);
3620 oscar_string_convert_and_append(account, str, "\n<br>", _("Last Name"), info->last); 3652 oscar_user_info_convert_and_add(account, user_info, _("Last Name"), info->last);
3621 if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) { 3653 if (info->email && info->email[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email))) {
3622 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("E-Mail Address"), utf8, utf8); 3654 buf = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", utf8, utf8);
3655 gaim_notify_user_info_add_pair(user_info, _("E-Mail Address"), buf);
3656 g_free(buf);
3623 g_free(utf8); 3657 g_free(utf8);
3624 } 3658 }
3625 if (info->numaddresses && info->email2) { 3659 if (info->numaddresses && info->email2) {
3626 int i; 3660 int i;
3627 for (i = 0; i < info->numaddresses; i++) { 3661 for (i = 0; i < info->numaddresses; i++) {
3628 if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) { 3662 if (info->email2[i] && info->email2[i][0] && (utf8 = oscar_utf8_try_convert(gc->account, info->email2[i]))) {
3629 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("E-Mail Address"), utf8, utf8); 3663 buf = g_strdup_printf("<a href=\"mailto:%s\">%s</a>", utf8, utf8);
3664 gaim_notify_user_info_add_pair(user_info, _("E-Mail Address"), buf);
3665 g_free(buf);
3630 g_free(utf8); 3666 g_free(utf8);
3631 } 3667 }
3632 } 3668 }
3633 } 3669 }
3634 oscar_string_convert_and_append(account, str, "\n<br>", _("Mobile Phone"), info->mobile); 3670 oscar_user_info_convert_and_add(account, user_info, _("Mobile Phone"), info->mobile);
3671
3635 if (info->gender != 0) 3672 if (info->gender != 0)
3636 oscar_string_append(str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); 3673 gaim_notify_user_info_add_pair(user_info, _("Gender"), (info->gender == 1 ? _("Female") : _("Male")));
3674
3637 if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) { 3675 if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) {
3638 /* Initialize the struct properly or strftime() will crash 3676 /* Initialize the struct properly or strftime() will crash
3639 * under some conditions (e.g. Debian sarge w/ LANG=en_HK). */ 3677 * under some conditions (e.g. Debian sarge w/ LANG=en_HK). */
3640 time_t t = time(NULL); 3678 time_t t = time(NULL);
3641 struct tm *tm = localtime(&t); 3679 struct tm *tm = localtime(&t);
3647 /* To be 100% sure that the fields are re-normalized. 3685 /* To be 100% sure that the fields are re-normalized.
3648 * If you're sure strftime() ALWAYS does this EVERYWHERE, 3686 * If you're sure strftime() ALWAYS does this EVERYWHERE,
3649 * feel free to remove it. --rlaager */ 3687 * feel free to remove it. --rlaager */
3650 mktime(tm); 3688 mktime(tm);
3651 3689
3652 oscar_string_append(str, "\n<br>", _("Birthday"), 3690 oscar_user_info_convert_and_add(account, user_info, _("Birthday"), gaim_date_format_short(tm));
3653 gaim_date_format_short(tm));
3654 } 3691 }
3655 if ((info->age > 0) && (info->age < 255)) { 3692 if ((info->age > 0) && (info->age < 255)) {
3656 char age[5]; 3693 char age[5];
3657 snprintf(age, sizeof(age), "%hhd", info->age); 3694 snprintf(age, sizeof(age), "%hhd", info->age);
3658 oscar_string_append(str, "\n<br>", _("Age"), age); 3695 gaim_notify_user_info_add_pair(user_info,
3696 _("Age"), age);
3659 } 3697 }
3660 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) { 3698 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->personalwebpage))) {
3661 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); 3699 buf = g_strdup_printf("<a href=\"%s\">%s</a>", utf8, utf8);
3700 gaim_notify_user_info_add_pair(user_info, _("Personal Web Page"), buf);
3701 g_free(buf);
3662 g_free(utf8); 3702 g_free(utf8);
3663 } 3703 }
3664 if (info->info && info->info[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->info))) { 3704
3665 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); 3705 oscar_user_info_convert_and_add(account, user_info, _("Additional Information"), info->info);
3666 g_free(utf8); 3706
3667 } 3707 /* g_string_append_printf(str, "<hr>"); */
3668 g_string_append_printf(str, "<hr>"); 3708
3669 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { 3709 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
3670 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); 3710 tmp = g_string_sized_new(100);
3671 oscar_string_convert_and_append(account, str, "\n<br>", _("Address"), info->homeaddr); 3711 oscar_string_convert_and_append(account, tmp, "\n<br>", _("Address"), info->homeaddr);
3672 oscar_string_convert_and_append(account, str, "\n<br>", _("City"), info->homecity); 3712 oscar_string_convert_and_append(account, tmp, "\n<br>", _("City"), info->homecity);
3673 oscar_string_convert_and_append(account, str, "\n<br>", _("State"), info->homestate); 3713 oscar_string_convert_and_append(account, tmp, "\n<br>", _("State"), info->homestate);
3674 oscar_string_convert_and_append(account, str, "\n<br>", _("Zip Code"), info->homezip); 3714 oscar_string_convert_and_append(account, tmp, "\n<br>", _("Zip Code"), info->homezip);
3675 g_string_append_printf(str, "\n<hr>"); 3715
3716 gaim_notify_user_info_add_pair(user_info, _("Home Address"), tmp->str);
3717
3718 g_string_free(tmp, TRUE);
3676 } 3719 }
3677 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { 3720 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
3678 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); 3721 tmp = g_string_sized_new(100);
3679 oscar_string_convert_and_append(account, str, "\n<br>", _("Address"), info->workaddr); 3722
3680 oscar_string_convert_and_append(account, str, "\n<br>", _("City"), info->workcity); 3723 oscar_string_convert_and_append(account, tmp, "\n<br>", _("Address"), info->workaddr);
3681 oscar_string_convert_and_append(account, str, "\n<br>", _("State"), info->workstate); 3724 oscar_string_convert_and_append(account, tmp, "\n<br>", _("City"), info->workcity);
3682 oscar_string_convert_and_append(account, str, "\n<br>", _("Zip Code"), info->workzip); 3725 oscar_string_convert_and_append(account, tmp, "\n<br>", _("State"), info->workstate);
3683 g_string_append_printf(str, "\n<hr>"); 3726 oscar_string_convert_and_append(account, tmp, "\n<br>", _("Zip Code"), info->workzip);
3727
3728 gaim_notify_user_info_add_pair(user_info, _("Work Address"), tmp->str);
3729
3730 g_string_free(tmp, TRUE);
3684 } 3731 }
3685 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { 3732 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
3686 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); 3733 tmp = g_string_sized_new(100);
3687 oscar_string_convert_and_append(account, str, "\n<br>", _("Company"), info->workcompany); 3734
3688 oscar_string_convert_and_append(account, str, "\n<br>", _("Division"), info->workdivision); 3735 oscar_string_convert_and_append(account, tmp, "\n<br>", _("Company"), info->workcompany);
3689 oscar_string_convert_and_append(account, str, "\n<br>", _("Position"), info->workposition); 3736 oscar_string_convert_and_append(account, tmp, "\n<br>", _("Division"), info->workdivision);
3737 oscar_string_convert_and_append(account, tmp, "\n<br>", _("Position"), info->workposition);
3690 if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) { 3738 if (info->workwebpage && info->workwebpage[0] && (utf8 = oscar_utf8_try_convert(gc->account, info->workwebpage))) {
3691 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); 3739 g_string_append_printf(tmp, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8);
3692 g_free(utf8); 3740 g_free(utf8);
3693 } 3741 }
3694 g_string_append_printf(str, "\n<hr>"); 3742 gaim_notify_user_info_add_pair(user_info, _("Work Information"), tmp->str);
3743 g_string_free(tmp, TRUE);
3695 } 3744 }
3696 3745
3697 if (buddy != NULL) 3746 if (buddy != NULL)
3698 alias = gaim_buddy_get_alias(buddy); 3747 alias = gaim_buddy_get_alias(buddy);
3699 else 3748 else
3700 alias = who; 3749 alias = who;
3701 gaim_notify_userinfo(gc, who, str->str, NULL, NULL); 3750 gaim_notify_userinfo(gc, who, user_info, NULL, NULL);
3702 g_string_free(str, TRUE); 3751 gaim_notify_user_info_destroy(user_info);
3703 3752
3704 return 1; 3753 return 1;
3705 } 3754 }
3706 3755
3707 static int gaim_icqalias(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...) 3756 static int gaim_icqalias(OscarData *od, FlapConnection *conn, FlapFrame *fr, ...)
5359 *sw = emblems[1]; 5408 *sw = emblems[1];
5360 *nw = emblems[2]; 5409 *nw = emblems[2];
5361 *ne = emblems[3]; 5410 *ne = emblems[3];
5362 } 5411 }
5363 5412
5364 void oscar_tooltip_text(GaimBuddy *b, GString *str, gboolean full) { 5413 void oscar_tooltip_text(GaimBuddy *b, GaimNotifyUserInfo *user_info, gboolean full) {
5365 GaimConnection *gc = b->account->gc; 5414 GaimConnection *gc = b->account->gc;
5366 OscarData *od = gc->proto_data; 5415 OscarData *od = gc->proto_data;
5367 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od, b->name); 5416 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od, b->name);
5368 5417
5369 if (GAIM_BUDDY_IS_ONLINE(b)) { 5418 if (GAIM_BUDDY_IS_ONLINE(b)) {
5370 GaimPresence *presence; 5419 GaimPresence *presence;
5371 GaimStatus *status; 5420 GaimStatus *status;
5372 const char *message; 5421 const char *message;
5373 5422
5374 if (full) 5423 if (full)
5375 oscar_string_append_info(gc, str, "\n", b, userinfo); 5424 oscar_string_append_info(gc, user_info, b, userinfo);
5376 5425
5377 presence = gaim_buddy_get_presence(b); 5426 presence = gaim_buddy_get_presence(b);
5378 status = gaim_presence_get_active_status(presence); 5427 status = gaim_presence_get_active_status(presence);
5379 message = gaim_status_get_attr_string(status, "message"); 5428 message = gaim_status_get_attr_string(status, "message");
5380 5429
5383 if (message != NULL) 5432 if (message != NULL)
5384 { 5433 {
5385 /* Available status messages are plain text */ 5434 /* Available status messages are plain text */
5386 gchar *tmp; 5435 gchar *tmp;
5387 tmp = g_markup_escape_text(message, -1); 5436 tmp = g_markup_escape_text(message, -1);
5388 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp); 5437 gaim_notify_user_info_add_pair(user_info, _("Message"), tmp);
5389 g_free(tmp); 5438 g_free(tmp);
5390 } 5439 }
5391 } 5440 }
5392 else 5441 else
5393 { 5442 {
5398 tmp2 = gaim_markup_strip_html(message); 5447 tmp2 = gaim_markup_strip_html(message);
5399 tmp1 = g_markup_escape_text(tmp2, -1); 5448 tmp1 = g_markup_escape_text(tmp2, -1);
5400 g_free(tmp2); 5449 g_free(tmp2);
5401 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); 5450 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc)));
5402 g_free(tmp1); 5451 g_free(tmp1);
5403 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), tmp2); 5452 gaim_notify_user_info_add_pair(user_info, _("Away Message"), tmp2);
5404 g_free(tmp2); 5453 g_free(tmp2);
5405 } 5454 }
5406 else 5455 else
5407 { 5456 {
5408 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Message"), _("<i>(retrieving)</i>")); 5457 gaim_notify_user_info_add_pair(user_info, _("Away Message"), _("<i>(retrieving)</i>"));
5409 } 5458 }
5410 } 5459 }
5411 } 5460 }
5412 } 5461 }
5413 5462

mercurial