Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 8670:e72824b84285
[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 <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 16 Apr 2004 02:53:40 +0000 |
parents | e71eef9dc37f |
children | 725413cc9fb9 |
comparison
equal
deleted
inserted
replaced
8669:06dd136238ab | 8670:e72824b84285 |
---|---|
4090 { | 4090 { |
4091 return strftime(s, max, fmt, tm); | 4091 return strftime(s, max, fmt, tm); |
4092 } | 4092 } |
4093 #endif | 4093 #endif |
4094 | 4094 |
4095 static void oscar_string_append(GString *str, char *name, char *value) | |
4096 { | |
4097 gchar *utf8; | |
4098 | |
4099 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
4100 g_string_append_printf(str, "\n<br><b>%s:</b> %s", name, utf8); | |
4101 g_free(utf8); | |
4102 } | |
4103 } | |
4104 | |
4095 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) | 4105 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
4096 { | 4106 { |
4097 GaimConnection *gc = sess->aux_data; | 4107 GaimConnection *gc = sess->aux_data; |
4098 gchar *buf, *tmp, *utf8; | 4108 OscarData *od = (OscarData *)gc->proto_data; |
4109 GaimBuddy *buddy; | |
4110 struct buddyinfo *bi; | |
4099 gchar who[16]; | 4111 gchar who[16]; |
4100 GaimBuddy *buddy; | 4112 GString *str; |
4101 gchar *primary; | 4113 gchar *primary, *utf8; |
4102 va_list ap; | 4114 va_list ap; |
4103 struct aim_icq_info *info; | 4115 struct aim_icq_info *info; |
4104 | 4116 |
4105 va_start(ap, fr); | 4117 va_start(ap, fr); |
4106 info = va_arg(ap, struct aim_icq_info *); | 4118 info = va_arg(ap, struct aim_icq_info *); |
4107 va_end(ap); | 4119 va_end(ap); |
4108 | 4120 |
4109 if (!info->uin) | 4121 if (!info->uin) |
4110 return 0; | 4122 return 0; |
4111 | 4123 |
4124 str = g_string_sized_new(100); | |
4112 g_snprintf(who, sizeof(who), "%u", info->uin); | 4125 g_snprintf(who, sizeof(who), "%u", info->uin); |
4113 buf = g_strdup_printf("<b>%s:</b> %s", _("UIN"), who); | 4126 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
4114 if (info->nick && info->nick[0] && (utf8 = gaim_utf8_try_convert(info->nick))) { | 4127 if (buddy != NULL) |
4115 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Nick"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4128 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); |
4116 } | 4129 |
4117 if (info->first && info->first[0] && (utf8 = gaim_utf8_try_convert(info->first))) { | 4130 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); |
4118 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("First Name"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4131 oscar_string_append(str, _("Nick"), info->nick); |
4119 } | 4132 if ((bi != NULL) && (bi->ipaddr != 0)) { |
4120 if (info->last && info->last[0] && (utf8 = gaim_utf8_try_convert(info->last))) { | 4133 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
4121 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Last Name"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4134 (bi->ipaddr & 0xff000000) >> 24, |
4122 } | 4135 (bi->ipaddr & 0x00ff0000) >> 16, |
4136 (bi->ipaddr & 0x0000ff00) >> 8, | |
4137 (bi->ipaddr & 0x000000ff)); | |
4138 oscar_string_append(str, _("IP Address"), tstr); | |
4139 g_free(tstr); | |
4140 } | |
4141 oscar_string_append(str, _("First Name"), info->first); | |
4142 oscar_string_append(str, _("Last Name"), info->last); | |
4143 oscar_string_append(str, _("Last Name"), info->last); | |
4123 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { | 4144 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
4124 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); | 4145 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
4146 g_free(utf8); | |
4125 } | 4147 } |
4126 if (info->numaddresses && info->email2) { | 4148 if (info->numaddresses && info->email2) { |
4127 int i; | 4149 int i; |
4128 for (i = 0; i < info->numaddresses; i++) { | 4150 for (i = 0; i < info->numaddresses; i++) { |
4129 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { | 4151 if (info->email2[i] && info->email2[i][0] && (utf8 = gaim_utf8_try_convert(info->email2[i]))) { |
4130 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); | 4152 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
4153 g_free(utf8); | |
4131 } | 4154 } |
4132 } | 4155 } |
4133 } | 4156 } |
4134 if (info->mobile && info->mobile[0] && (utf8 = gaim_utf8_try_convert(info->mobile))) { | 4157 oscar_string_append(str, _("Mobile Phone"), info->mobile); |
4135 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Mobile Phone"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4158 oscar_string_append(str, _("Gender"), info->gender==1 ? _("Female") : _("Male")); |
4136 } | |
4137 if (info->gender) { | |
4138 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Gender"), ":</b> ", info->gender==1 ? _("Female") : _("Male"), NULL); g_free(tmp); | |
4139 } | |
4140 if (info->birthyear || info->birthmonth || info->birthday) { | 4159 if (info->birthyear || info->birthmonth || info->birthday) { |
4141 char date[30]; | 4160 char date[30]; |
4142 struct tm tm; | 4161 struct tm tm; |
4143 tm.tm_mday = (int)info->birthday; | 4162 tm.tm_mday = (int)info->birthday; |
4144 tm.tm_mon = (int)info->birthmonth-1; | 4163 tm.tm_mon = (int)info->birthmonth-1; |
4145 tm.tm_year = (int)info->birthyear-1900; | 4164 tm.tm_year = (int)info->birthyear-1900; |
4146 strftime(date, sizeof(date), "%x", &tm); | 4165 strftime(date, sizeof(date), "%x", &tm); |
4147 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Birthday"), ":</b> ", date, NULL); g_free(tmp); | 4166 oscar_string_append(str, _("Birthday"), date); |
4148 } | 4167 } |
4149 if (info->age) { | 4168 if (info->age) { |
4150 char age[5]; | 4169 char age[5]; |
4151 snprintf(age, sizeof(age), "%hhd", info->age); | 4170 snprintf(age, sizeof(age), "%hhd", info->age); |
4152 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Age"), ":</b> ", age, NULL); g_free(tmp); | 4171 oscar_string_append(str, _("Age"), age); |
4153 } | 4172 } |
4154 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { | 4173 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
4155 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); | 4174 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
4175 g_free(utf8); | |
4156 } | 4176 } |
4157 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { | 4177 if (info->info && info->info[0] && (utf8 = gaim_utf8_try_convert(info->info))) { |
4158 tmp = buf; buf = g_strconcat(tmp, "<hr><b>", _("Additional Information"), ":</b><br>", utf8, NULL); g_free(tmp); g_free(utf8); | 4178 g_string_append_printf(str, "<hr><b>%s:</b><br>%s", _("Additional Information"), utf8); |
4159 } | 4179 g_free(utf8); |
4160 tmp = buf; buf = g_strconcat(tmp, "<hr>\n", NULL); g_free(tmp); | 4180 } |
4181 g_string_append_printf(str, "<hr>\n"); | |
4161 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { | 4182 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
4162 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Home Address"), ":</b>", NULL); g_free(tmp); | 4183 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
4163 if (info->homeaddr && info->homeaddr[0] && (utf8 = gaim_utf8_try_convert(info->homeaddr))) { | 4184 oscar_string_append(str, _("Address"), info->homeaddr); |
4164 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4185 oscar_string_append(str, _("City"), info->homecity); |
4165 } | 4186 oscar_string_append(str, _("State"), info->homestate); |
4166 if (info->homecity && info->homecity[0] && (utf8 = gaim_utf8_try_convert(info->homecity))) { | 4187 oscar_string_append(str, _("Zip Code"), info->homezip); |
4167 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4188 g_string_append_printf(str, "\n<hr>\n"); |
4168 } | |
4169 if (info->homestate && info->homestate[0] && (utf8 = gaim_utf8_try_convert(info->homestate))) { | |
4170 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4171 } | |
4172 if (info->homezip && info->homezip[0] && (utf8 = gaim_utf8_try_convert(info->homezip))) { | |
4173 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4174 } | |
4175 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4176 } | 4189 } |
4177 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { | 4190 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
4178 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Address"), ":</b>", NULL); g_free(tmp); | 4191 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
4179 if (info->workaddr && info->workaddr[0] && (utf8 = gaim_utf8_try_convert(info->workaddr))) { | 4192 oscar_string_append(str, _("Address"), info->workaddr); |
4180 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Address"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4193 oscar_string_append(str, _("City"), info->workcity); |
4181 } | 4194 oscar_string_append(str, _("State"), info->workstate); |
4182 if (info->workcity && info->workcity[0] && (utf8 = gaim_utf8_try_convert(info->workcity))) { | 4195 oscar_string_append(str, _("Zip Code"), info->workzip); |
4183 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("City"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4196 g_string_append_printf(str, "\n<hr>\n"); |
4184 } | |
4185 if (info->workstate && info->workstate[0] && (utf8 = gaim_utf8_try_convert(info->workstate))) { | |
4186 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("State"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4187 } | |
4188 if (info->workzip && info->workzip[0] && (utf8 = gaim_utf8_try_convert(info->workzip))) { | |
4189 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Zip Code"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4190 } | |
4191 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | |
4192 } | 4197 } |
4193 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { | 4198 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
4194 tmp = buf; buf = g_strconcat(tmp, "<b>", _("Work Information"), ":</b>", NULL); g_free(tmp); | 4199 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
4195 if (info->workcompany && info->workcompany[0] && (utf8 = gaim_utf8_try_convert(info->workcompany))) { | 4200 oscar_string_append(str, _("Company"), info->workcompany); |
4196 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Company"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | 4201 oscar_string_append(str, _("Division"), info->workdivision); |
4197 } | 4202 oscar_string_append(str, _("Position"), info->workposition); |
4198 if (info->workdivision && info->workdivision[0] && (utf8 = gaim_utf8_try_convert(info->workdivision))) { | |
4199 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Division"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4200 } | |
4201 if (info->workposition && info->workposition[0] && (utf8 = gaim_utf8_try_convert(info->workposition))) { | |
4202 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Position"), ":</b> ", utf8, NULL); g_free(tmp); g_free(utf8); | |
4203 } | |
4204 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { | 4203 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
4205 tmp = buf; buf = g_strconcat(tmp, "\n<br><b>", _("Web Page"), ":</b> <a href=\"", utf8, "\">", utf8, "</a>", NULL); g_free(tmp); g_free(utf8); | 4204 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
4206 } | 4205 g_free(utf8); |
4207 tmp = buf; buf = g_strconcat(tmp, "\n<hr>\n", NULL); g_free(tmp); | 4206 } |
4208 } | 4207 g_string_append_printf(str, "\n<hr>\n"); |
4209 | 4208 } |
4210 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); | 4209 |
4211 primary = g_strdup_printf(_("ICQ Info for %s"), gaim_get_buddy_alias(buddy)); | 4210 primary = g_strdup_printf(_("ICQ Info for %s"), gaim_get_buddy_alias(buddy)); |
4212 gaim_notify_formatted(gc, NULL, primary, NULL, buf, NULL, NULL); | 4211 gaim_notify_formatted(gc, NULL, primary, NULL, str->str, NULL, NULL); |
4213 g_free(primary); | 4212 g_free(primary); |
4214 g_free(buf); | 4213 g_string_free(str, TRUE); |
4215 | 4214 |
4216 return 1; | 4215 return 1; |
4217 } | 4216 } |
4218 | 4217 |
4219 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) | 4218 static int gaim_icqalias(aim_session_t *sess, aim_frame_t *fr, ...) |
5698 status = gaim_icq_status((b->uc & 0xffff0000) >> 16); | 5697 status = gaim_icq_status((b->uc & 0xffff0000) >> 16); |
5699 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), status); | 5698 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), status); |
5700 g_free(status); | 5699 g_free(status); |
5701 } | 5700 } |
5702 | 5701 |
5703 if ((bi != NULL) && (bi->ipaddr)) { | 5702 if ((bi != NULL) && (bi->ipaddr != 0)) { |
5704 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | 5703 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
5705 (bi->ipaddr & 0xff000000) >> 24, | 5704 (bi->ipaddr & 0xff000000) >> 24, |
5706 (bi->ipaddr & 0x00ff0000) >> 16, | 5705 (bi->ipaddr & 0x00ff0000) >> 16, |
5707 (bi->ipaddr & 0x0000ff00) >> 8, | 5706 (bi->ipaddr & 0x0000ff00) >> 8, |
5708 (bi->ipaddr & 0x000000ff)); | 5707 (bi->ipaddr & 0x000000ff)); |