# HG changeset patch # User Mark Doliner # Date 1082084020 0 # Node ID e72824b8428534b7f5bc59b8b53d4ea887ba0c7e # Parent 06dd136238ab966c590078f1ccf4de1338913b3a [gaim-migrate @ 9422] Show "IP Address: whatever" for some ICQ people in the info, and make the ICQ info creation use a g string. I need to make sure all tooltip info is also displayed in the get info windows. committer: Tailor Script diff -r 06dd136238ab -r e72824b84285 src/protocols/oscar/oscar.c --- a/src/protocols/oscar/oscar.c Fri Apr 16 01:46:02 2004 +0000 +++ b/src/protocols/oscar/oscar.c Fri Apr 16 02:53:40 2004 +0000 @@ -4092,13 +4092,25 @@ } #endif +static void oscar_string_append(GString *str, char *name, char *value) +{ + gchar *utf8; + + if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { + g_string_append_printf(str, "\n
%s: %s", name, utf8); + g_free(utf8); + } +} + static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) { GaimConnection *gc = sess->aux_data; - gchar *buf, *tmp, *utf8; + OscarData *od = (OscarData *)gc->proto_data; + GaimBuddy *buddy; + struct buddyinfo *bi; gchar who[16]; - GaimBuddy *buddy; - gchar *primary; + GString *str; + gchar *primary, *utf8; va_list ap; struct aim_icq_info *info; @@ -4109,34 +4121,41 @@ if (!info->uin) return 0; + str = g_string_sized_new(100); g_snprintf(who, sizeof(who), "%u", info->uin); - buf = g_strdup_printf("%s: %s", _("UIN"), who); - if (info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Nick"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->first && info->first[0] && (utf8 = gaim_utf8_try_convert(info->first))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("First Name"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->last && info->last[0] && (utf8 = gaim_utf8_try_convert(info->last))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Last Name"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } + buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); + if (buddy != NULL) + bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); + + g_string_append_printf(str, "%s: %s", _("UIN"), who); + oscar_string_append(str, _("Nick"), info->nick); + if ((bi != NULL) && (bi->ipaddr != 0)) { + char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", + (bi->ipaddr & 0xff000000) >> 24, + (bi->ipaddr & 0x00ff0000) >> 16, + (bi->ipaddr & 0x0000ff00) >> 8, + (bi->ipaddr & 0x000000ff)); + oscar_string_append(str, _("IP Address"), tstr); + g_free(tstr); + } + oscar_string_append(str, _("First Name"), info->first); + oscar_string_append(str, _("Last Name"), info->last); + oscar_string_append(str, _("Last Name"), info->last); if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Email Address"), ": ", utf8, "", NULL); g_free(tmp); g_free(utf8); + g_string_append_printf(str, "\n
%s: %s", _("Email Address"), utf8, utf8); + g_free(utf8); } if (info->numaddresses && info->email2) { int i; for (i = 0; i < info->numaddresses; i++) { if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Email Address"), ": ", utf8, "", NULL); g_free(tmp); g_free(utf8); + g_string_append_printf(str, "\n
%s: %s", _("Email Address"), utf8, utf8); + g_free(utf8); } } } - if (info->mobile && info->mobile[0] && (utf8 = gaim_utf8_try_convert(info->mobile))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Mobile Phone"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->gender) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Gender"), ": ", info->gender==1 ? _("Female") : _("Male"), NULL); g_free(tmp); - } + oscar_string_append(str, _("Mobile Phone"), info->mobile); + oscar_string_append(str, _("Gender"), info->gender==1 ? _("Female") : _("Male")); if (info->birthyear || info->birthmonth || info->birthday) { char date[30]; struct tm tm; @@ -4144,74 +4163,54 @@ tm.tm_mon = (int)info->birthmonth-1; tm.tm_year = (int)info->birthyear-1900; strftime(date, sizeof(date), "%x", &tm); - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Birthday"), ": ", date, NULL); g_free(tmp); + oscar_string_append(str, _("Birthday"), date); } if (info->age) { char age[5]; snprintf(age, sizeof(age), "%hhd", info->age); - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Age"), ": ", age, NULL); g_free(tmp); + oscar_string_append(str, _("Age"), age); } if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Personal Web Page"), ": ", utf8, "", NULL); g_free(tmp); g_free(utf8); + g_string_append_printf(str, "\n
%s: %s", _("Personal Web Page"), utf8, utf8); + g_free(utf8); } if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { - tmp = buf; buf = g_strconcat(tmp, "
", _("Additional Information"), ":
", utf8, NULL); g_free(tmp); g_free(utf8); - } - tmp = buf; buf = g_strconcat(tmp, "
\n", NULL); g_free(tmp); + g_string_append_printf(str, "
%s:
%s", _("Additional Information"), utf8); + g_free(utf8); + } + g_string_append_printf(str, "
\n"); if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { - tmp = buf; buf = g_strconcat(tmp, "", _("Home Address"), ":", NULL); g_free(tmp); - if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_utf8_try_convert(info->homeaddr))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Address"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->homecity && info->homecity[0] && (utf8 = gaim_utf8_try_convert(info->homecity))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("City"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->homestate && info->homestate[0] && (utf8 = gaim_utf8_try_convert(info->homestate))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("State"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->homezip && info->homezip[0] && (utf8 = gaim_utf8_try_convert(info->homezip))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Zip Code"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - tmp = buf; buf = g_strconcat(tmp, "\n
\n", NULL); g_free(tmp); + g_string_append_printf(str, "%s:", _("Home Address")); + oscar_string_append(str, _("Address"), info->homeaddr); + oscar_string_append(str, _("City"), info->homecity); + oscar_string_append(str, _("State"), info->homestate); + oscar_string_append(str, _("Zip Code"), info->homezip); + g_string_append_printf(str, "\n
\n"); } if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { - tmp = buf; buf = g_strconcat(tmp, "", _("Work Address"), ":", NULL); g_free(tmp); - if (info->workaddr && info->workaddr[0] && (utf8 = gaim_utf8_try_convert(info->workaddr))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Address"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->workcity && info->workcity[0] && (utf8 = gaim_utf8_try_convert(info->workcity))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("City"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->workstate && info->workstate[0] && (utf8 = gaim_utf8_try_convert(info->workstate))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("State"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->workzip && info->workzip[0] && (utf8 = gaim_utf8_try_convert(info->workzip))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Zip Code"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - tmp = buf; buf = g_strconcat(tmp, "\n
\n", NULL); g_free(tmp); + g_string_append_printf(str, "%s:", _("Work Address")); + oscar_string_append(str, _("Address"), info->workaddr); + oscar_string_append(str, _("City"), info->workcity); + oscar_string_append(str, _("State"), info->workstate); + oscar_string_append(str, _("Zip Code"), info->workzip); + g_string_append_printf(str, "\n
\n"); } if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { - tmp = buf; buf = g_strconcat(tmp, "", _("Work Information"), ":", NULL); g_free(tmp); - if (info->workcompany && info->workcompany[0] && (utf8 = gaim_utf8_try_convert(info->workcompany))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Company"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->workdivision && info->workdivision[0] && (utf8 = gaim_utf8_try_convert(info->workdivision))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Division"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } - if (info->workposition && info->workposition[0] && (utf8 = gaim_utf8_try_convert(info->workposition))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Position"), ": ", utf8, NULL); g_free(tmp); g_free(utf8); - } + g_string_append_printf(str, "%s:", _("Work Information")); + oscar_string_append(str, _("Company"), info->workcompany); + oscar_string_append(str, _("Division"), info->workdivision); + oscar_string_append(str, _("Position"), info->workposition); if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { - tmp = buf; buf = g_strconcat(tmp, "\n
", _("Web Page"), ": ", utf8, "", NULL); g_free(tmp); g_free(utf8); + g_string_append_printf(str, "\n
%s: %s", _("Web Page"), utf8, utf8); + g_free(utf8); } - tmp = buf; buf = g_strconcat(tmp, "\n
\n", NULL); g_free(tmp); - } - - buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); + g_string_append_printf(str, "\n
\n"); + } + primary = g_strdup_printf(_("ICQ Info for %s"), gaim_get_buddy_alias(buddy)); - gaim_notify_formatted(gc, NULL, primary, NULL, buf, NULL, NULL); + gaim_notify_formatted(gc, NULL, primary, NULL, str->str, NULL, NULL); g_free(primary); - g_free(buf); + g_string_free(str, TRUE); return 1; } @@ -5700,7 +5699,7 @@ g_free(status); } - if ((bi != NULL) && (bi->ipaddr)) { + if ((bi != NULL) && (bi->ipaddr != 0)) { char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", (bi->ipaddr & 0xff000000) >> 24, (bi->ipaddr & 0x00ff0000) >> 16,