comparison src/protocols/oscar/oscar.c @ 4819:815afc71c8e4

[gaim-migrate @ 5144] On the one hand, rabbits not laying eggs is a conscious decision--it's not that they can't, it's that they choose not to. But on the other hand, the first hand makes no sense. This should make reading ICQ info for people with non-ascii cruft not crash Gaim and/or output ugly pango utf8 messages. I also make the ICQ info strings internationalizationable. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 18 Mar 2003 05:52:22 +0000
parents 22a7602ebe25
children bfabc4a26fce
comparison
equal deleted inserted replaced
4818:1c371e4244d6 4819:815afc71c8e4
3752 } 3752 }
3753 3753
3754 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) 3754 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...)
3755 { 3755 {
3756 struct gaim_connection *gc = sess->aux_data; 3756 struct gaim_connection *gc = sess->aux_data;
3757 gchar *buf, *tmp; 3757 gchar *buf, *tmp, *utf8;
3758 gchar who[16]; 3758 gchar who[16];
3759 va_list ap; 3759 va_list ap;
3760 struct aim_icq_info *info; 3760 struct aim_icq_info *info;
3761 3761
3762 va_start(ap, fr); 3762 va_start(ap, fr);
3765 3765
3766 if (!info->uin) 3766 if (!info->uin)
3767 return 0; 3767 return 0;
3768 3768
3769 g_snprintf(who, sizeof(who), "%lu", info->uin); 3769 g_snprintf(who, sizeof(who), "%lu", info->uin);
3770 buf = g_strdup_printf("<b>UIN:</b> %s", who); 3770 buf = g_strdup_printf(_("<b>UIN:</b> %s"), who);
3771 if (info->nick && info->nick[0]) { 3771 if (info->nick && info->nick[0] && (utf8 = gaim_try_conv_to_utf8(info->nick))) {
3772 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Nick:</b> ", info->nick, NULL); g_free(tmp); 3772 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Nick:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3773 } 3773 }
3774 if (info->first && info->first[0]) { 3774 if (info->first && info->first[0] && (utf8 = gaim_try_conv_to_utf8(info->first))) {
3775 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>First Name:</b> ", info->first, NULL); g_free(tmp); 3775 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("First Name:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3776 } 3776 }
3777 if (info->last && info->last[0]) { 3777 if (info->last && info->last[0] && (utf8 = gaim_try_conv_to_utf8(info->last))) {
3778 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Last Name:</b> ", info->last, NULL); g_free(tmp); 3778 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Last Name:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3779 } 3779 }
3780 if (info->email && info->email[0]) { 3780 if (info->email && info->email[0] && (utf8 = gaim_try_conv_to_utf8(info->email))) {
3781 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Email Address:</b> <a href=\"mailto:", info->email, "\">", info->email, "</a>", NULL); g_free(tmp); 3781 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address:"), "</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8);
3782 } 3782 }
3783 if (info->numaddresses && info->email2) { 3783 if (info->numaddresses && info->email2) {
3784 int i; 3784 int i;
3785 for (i = 0; i < info->numaddresses; i++) { 3785 for (i = 0; i < info->numaddresses; i++) {
3786 if (info->email2[i] && info->email2[i][0]) { 3786 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_try_conv_to_utf8(info->email2[i]))) {
3787 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Email Address:</b> <a href=\"mailto:", info->email2[i], "\">", info->email2[i], "</a>", NULL); g_free(tmp); 3787 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Email Address:"), "</b> <a href=\"mailto:", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8);
3788 } 3788 }
3789 } 3789 }
3790 } 3790 }
3791 if (info->mobile && info->mobile[0]) { 3791 if (info->mobile && info->mobile[0] && (utf8 = gaim_try_conv_to_utf8(info->mobile))) {
3792 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Mobile Phone:</b> ", info->mobile, NULL); g_free(tmp); 3792 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Mobile Phone:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3793 } 3793 }
3794 if (info->gender) { 3794 if (info->gender) {
3795 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Gender:</b> ", info->gender==1 ? "Female" : "Male", NULL); g_free(tmp); 3795 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Gender:"), "</b> ", info->gender==1 ? _("Female") : _("Male"), NULL); g_free(tmp);
3796 } 3796 }
3797 if (info->birthyear || info->birthmonth || info->birthday) { 3797 if (info->birthyear || info->birthmonth || info->birthday) {
3798 char date[30]; 3798 char date[30];
3799 struct tm tm; 3799 struct tm tm;
3800 tm.tm_mday = (int)info->birthday; 3800 tm.tm_mday = (int)info->birthday;
3801 tm.tm_mon = (int)info->birthmonth-1; 3801 tm.tm_mon = (int)info->birthmonth-1;
3802 tm.tm_year = (int)info->birthyear-1900; 3802 tm.tm_year = (int)info->birthyear-1900;
3803 strftime(date, sizeof(date), "%x", &tm); 3803 strftime(date, sizeof(date), "%x", &tm);
3804 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Birthday:</b> ", date, NULL); g_free(tmp); 3804 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Birthday:"), "</b> ", date, NULL); g_free(tmp);
3805 } 3805 }
3806 if (info->age) { 3806 if (info->age) {
3807 char age[5]; 3807 char age[5];
3808 snprintf(age, sizeof(age), "%hhd", info->age); 3808 snprintf(age, sizeof(age), "%hhd", info->age);
3809 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Age:</b> ", age, NULL); g_free(tmp); 3809 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Age:"), "</b> ", age, NULL); g_free(tmp);
3810 } 3810 }
3811 if (info->personalwebpage && info->personalwebpage[0]) { 3811 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->personalwebpage))) {
3812 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Personal Web Page:</b> <a href=\"", info->personalwebpage, "\">", info->personalwebpage, "</a>", NULL); g_free(tmp); 3812 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Personal Web Page:"), "</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8);
3813 } 3813 }
3814 if (info->info && info->info[0]) { 3814 if (info->info && info->info[0] && (utf8 = gaim_try_conv_to_utf8(info->info))) {
3815 tmp = buf; buf = g_strconcat(tmp, "<hr><b>Additional Information:</b><br>", info->info, NULL); g_free(tmp); 3815 tmp = buf; buf = g_strconcat(tmp, "<hr><b>", _("Additional Information:"), "</b><br>", utf8, NULL); g_free(tmp); g_free(utf8);
3816 } 3816 }
3817 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp); 3817 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp);
3818 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { 3818 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) {
3819 tmp = buf; buf = g_strconcat(tmp, "<b>Home Address:</b>", NULL); g_free(tmp); 3819 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Home Address:"), "</b>", NULL); g_free(tmp);
3820 if (info->homeaddr && info->homeaddr[0]) { 3820 if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->homeaddr))) {
3821 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Address:</b> ", info->homeaddr, NULL); g_free(tmp); 3821 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3822 } 3822 }
3823 if (info->homecity && info->homecity[0]) { 3823 if (info->homecity && info->homecity[0] && (utf8 = gaim_try_conv_to_utf8(info->homecity))) {
3824 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>City:</b> ", info->homecity, NULL); g_free(tmp); 3824 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3825 } 3825 }
3826 if (info->homestate && info->homestate[0]) { 3826 if (info->homestate && info->homestate[0] && (utf8 = gaim_try_conv_to_utf8(info->homestate))) {
3827 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>State:</b> ", info->homestate, NULL); g_free(tmp); 3827 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3828 } 3828 }
3829 if (info->homezip && info->homezip[0]) { 3829 if (info->homezip && info->homezip[0] && (utf8 = gaim_try_conv_to_utf8(info->homezip))) {
3830 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Zip Code:</b> ", info->homezip, NULL); g_free(tmp); 3830 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3831 } 3831 }
3832 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); 3832 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp);
3833 } 3833 }
3834 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { 3834 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) {
3835 tmp = buf; buf = g_strconcat(tmp, "<b>Work Address:</b>", NULL); g_free(tmp); 3835 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Address:"), "</b>", NULL); g_free(tmp);
3836 if (info->workaddr && info->workaddr[0]) { 3836 if (info->workaddr && info->workaddr[0] && (utf8 = gaim_try_conv_to_utf8(info->workaddr))) {
3837 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Address:</b> ", info->workaddr, NULL); g_free(tmp); 3837 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3838 } 3838 }
3839 if (info->workcity && info->workcity[0]) { 3839 if (info->workcity && info->workcity[0] && (utf8 = gaim_try_conv_to_utf8(info->workcity))) {
3840 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>City:</b> ", info->workcity, NULL); g_free(tmp); 3840 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3841 } 3841 }
3842 if (info->workstate && info->workstate[0]) { 3842 if (info->workstate && info->workstate[0] && (utf8 = gaim_try_conv_to_utf8(info->workstate))) {
3843 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>State:</b> ", info->workstate, NULL); g_free(tmp); 3843 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3844 } 3844 }
3845 if (info->workzip && info->workzip[0]) { 3845 if (info->workzip && info->workzip[0] && (utf8 = gaim_try_conv_to_utf8(info->workzip))) {
3846 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Zip Code:</b> ", info->workzip, NULL); g_free(tmp); 3846 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3847 } 3847 }
3848 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); 3848 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp);
3849 } 3849 }
3850 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { 3850 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) {
3851 tmp = buf; buf = g_strconcat(tmp, "<b>Work Information:</b>", NULL); g_free(tmp); 3851 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Information:"), "</b>", NULL); g_free(tmp);
3852 if (info->workcompany && info->workcompany[0]) { 3852 if (info->workcompany && info->workcompany[0] && (utf8 = gaim_try_conv_to_utf8(info->workcompany))) {
3853 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Company:</b> ", info->workcompany, NULL); g_free(tmp); 3853 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Company:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3854 } 3854 }
3855 if (info->workdivision && info->workdivision[0]) { 3855 if (info->workdivision && info->workdivision[0] && (utf8 = gaim_try_conv_to_utf8(info->workdivision))) {
3856 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Division:</b> ", info->workdivision, NULL); g_free(tmp); 3856 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Division:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3857 } 3857 }
3858 if (info->workposition && info->workposition[0]) { 3858 if (info->workposition && info->workposition[0] && (utf8 = gaim_try_conv_to_utf8(info->workposition))) {
3859 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Position:</b> ", info->workposition, NULL); g_free(tmp); 3859 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Position:"), "</b> ", utf8, NULL); g_free(tmp); g_free(utf8);
3860 } 3860 }
3861 if (info->workwebpage && info->workwebpage[0]) { 3861 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_try_conv_to_utf8(info->workwebpage))) {
3862 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>Web Page:</b> <a href=\"", info->workwebpage, "\">", info->workwebpage, "</a>", NULL); g_free(tmp); 3862 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Web Page:"), "</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8);
3863 } 3863 }
3864 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); 3864 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp);
3865 } 3865 }
3866 3866
3867 g_show_info_text(gc, who, 2, buf, NULL); 3867 g_show_info_text(gc, who, 2, buf, NULL);