Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 8700:ddd2bf87fe8d
[gaim-migrate @ 9453]
I'm adding some of the oscar tooltip info to the oscar
get info dialog. I don't think I'm finished yet, but
I want to try something that might not work,
and it's easier to "cvs -z3 diff -u | patch -p0 -R"
than it is to un-do it.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 18 Apr 2004 17:10:14 +0000 |
parents | 725413cc9fb9 |
children | ddcafeb14e35 |
comparison
equal
deleted
inserted
replaced
8699:775bd10da7f2 | 8700:ddd2bf87fe8d |
---|---|
406 } | 406 } |
407 break; | 407 break; |
408 } | 408 } |
409 | 409 |
410 return utf8; | 410 return utf8; |
411 } | |
412 | |
413 static void oscar_string_append(GString *str, char *name, char *value) | |
414 { | |
415 gchar *utf8; | |
416 | |
417 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | |
418 g_string_append_printf(str, "\n<br><b>%s:</b> %s", name, utf8); | |
419 g_free(utf8); | |
420 } | |
411 } | 421 } |
412 | 422 |
413 static struct direct_im *find_direct_im(OscarData *od, const char *who) { | 423 static struct direct_im *find_direct_im(OscarData *od, const char *who) { |
414 GSList *d = od->direct_ims; | 424 GSList *d = od->direct_ims; |
415 struct direct_im *m = NULL; | 425 struct direct_im *m = NULL; |
3259 return buf; | 3269 return buf; |
3260 } | 3270 } |
3261 | 3271 |
3262 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { | 3272 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
3263 GaimConnection *gc = sess->aux_data; | 3273 GaimConnection *gc = sess->aux_data; |
3264 GString *text; | 3274 OscarData *od = gc->proto_data; |
3265 gchar *info_utf8 = NULL, *away_utf8 = NULL; | 3275 GaimAccount *account = gaim_connection_get_account(gc); |
3266 const char *final = NULL; | 3276 GString *str; |
3277 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; | |
3278 struct buddyinfo *bi; | |
3279 GaimBuddy *b = NULL; | |
3280 GaimGroup *g = NULL; | |
3267 va_list ap; | 3281 va_list ap; |
3268 aim_userinfo_t *userinfo; | 3282 aim_userinfo_t *userinfo; |
3269 | 3283 |
3270 va_start(ap, fr); | 3284 va_start(ap, fr); |
3271 userinfo = va_arg(ap, aim_userinfo_t *); | 3285 userinfo = va_arg(ap, aim_userinfo_t *); |
3272 va_end(ap); | 3286 va_end(ap); |
3273 | 3287 |
3274 text = g_string_new(""); | 3288 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); |
3275 g_string_append_printf(text, _("Username: <b>%s</b><br>\n"), userinfo->sn); | 3289 |
3276 g_string_append_printf(text, _("Warning Level: <b>%d%%</b><br>\n"), (int)((userinfo->warnlevel/10.0) + 0.5)); | 3290 str = g_string_new(""); |
3291 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | |
3292 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); | |
3277 | 3293 |
3278 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | 3294 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3279 g_string_append_printf(text, _("Online Since: <b>%s</b><br>\n"), | 3295 oscar_string_append(str, _("Online Since"), |
3280 asctime(localtime((time_t *)&userinfo->onlinesince))); | 3296 asctime(localtime((time_t *)&userinfo->onlinesince))); |
3281 | 3297 |
3282 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | 3298 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) |
3283 g_string_append_printf(text, _("Member Since: <b>%s</b><br>\n"), | 3299 oscar_string_append(str, _("Member Since"), |
3284 asctime(localtime((time_t *)&userinfo->membersince))); | 3300 asctime(localtime((time_t *)&userinfo->membersince))); |
3285 | 3301 |
3286 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | 3302 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
3287 gchar *itime = gaim_str_seconds_to_string(userinfo->idletime*60); | 3303 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
3288 g_string_append_printf(text, _("Idle: <b>%s</b>"), itime); | 3304 oscar_string_append(str, _("Idle"), tmp); |
3289 g_free(itime); | 3305 g_free(tmp); |
3290 } else | 3306 } else |
3291 g_string_append_printf(text, _("Idle: <b>Active</b>")); | 3307 oscar_string_append(str, _("Idle"), _("Active")); |
3308 | |
3309 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
3310 tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
3311 (bi->ipaddr & 0xff000000) >> 24, | |
3312 (bi->ipaddr & 0x00ff0000) >> 16, | |
3313 (bi->ipaddr & 0x0000ff00) >> 8, | |
3314 (bi->ipaddr & 0x000000ff)); | |
3315 g_string_append_printf(str, "\n<b>%s:</b> %s", _("IP Address"), tmp); | |
3316 g_free(tmp); | |
3317 } | |
3318 | |
3319 if (userinfo->capabilities != 0) { | |
3320 tmp = caps_string(userinfo->capabilities); | |
3321 oscar_string_append(str, _("Capabilities"), tmp); | |
3322 } | |
3323 | |
3324 if ((g != NULL) && (g->name != NULL)) { | |
3325 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
3326 if (tmp != NULL) { | |
3327 oscar_string_append(str, _("Buddy Comment"), tmp); | |
3328 g_free(tmp); | |
3329 } | |
3330 } | |
3331 | |
3332 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
3333 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
3334 oscar_string_append(str, _("Available"), tmp); | |
3335 g_free(tmp); | |
3336 } | |
3292 | 3337 |
3293 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | 3338 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { |
3294 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); | 3339 tmp = oscar_encoding_extract(userinfo->away_encoding); |
3295 away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); | 3340 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); |
3296 g_free(charset); | 3341 g_free(tmp); |
3297 if (away_utf8 != NULL) { | 3342 if (away_utf8 != NULL) { |
3298 g_string_append_printf(text, "<hr>%s", away_utf8); | 3343 g_string_append_printf(str, "\n<hr>%s", away_utf8); |
3299 g_free(away_utf8); | 3344 g_free(away_utf8); |
3300 } | 3345 } |
3301 } | 3346 } |
3302 | 3347 |
3303 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { | 3348 if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { |
3304 gchar *charset = oscar_encoding_extract(userinfo->info_encoding); | 3349 tmp = oscar_encoding_extract(userinfo->info_encoding); |
3305 info_utf8 = oscar_encoding_to_utf8(charset, userinfo->info, userinfo->info_len); | 3350 info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); |
3306 g_free(charset); | 3351 g_free(tmp); |
3307 if (info_utf8 != NULL) { | 3352 if (info_utf8 != NULL) { |
3308 g_string_append_printf(text, "<hr>%s", info_utf8); | 3353 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
3309 g_free(info_utf8); | 3354 g_free(info_utf8); |
3310 } | 3355 } |
3311 } | 3356 } |
3312 | 3357 |
3313 final = gaim_str_sub_away_formatters(text->str, gaim_account_get_username(gaim_connection_get_account(gc))); | 3358 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(gaim_connection_get_account(gc))); |
3314 g_string_free(text, TRUE); | 3359 g_string_free(str, TRUE); |
3315 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, final, NULL, NULL); | 3360 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, tmp, NULL, NULL); |
3361 g_free(tmp); | |
3316 | 3362 |
3317 return 1; | 3363 return 1; |
3318 } | 3364 } |
3319 | 3365 |
3320 static gboolean gaim_reqinfo_timeout_cb(void *data) | 3366 static gboolean gaim_reqinfo_timeout_cb(void *data) |
4089 const struct tm *tm) | 4135 const struct tm *tm) |
4090 { | 4136 { |
4091 return strftime(s, max, fmt, tm); | 4137 return strftime(s, max, fmt, tm); |
4092 } | 4138 } |
4093 #endif | 4139 #endif |
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 | 4140 |
4105 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) | 4141 static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) |
4106 { | 4142 { |
4107 GaimConnection *gc = sess->aux_data; | 4143 GaimConnection *gc = sess->aux_data; |
4108 OscarData *od = (OscarData *)gc->proto_data; | 4144 OscarData *od = (OscarData *)gc->proto_data; |
5732 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); | 5768 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
5733 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); | 5769 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
5734 g_free(charset); | 5770 g_free(charset); |
5735 if (away_utf8 != NULL) { | 5771 if (away_utf8 != NULL) { |
5736 gchar *tmp1, *tmp2; | 5772 gchar *tmp1, *tmp2; |
5737 const gchar *tmp3; | |
5738 tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); | 5773 tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); |
5739 g_free(away_utf8); | 5774 g_free(away_utf8); |
5740 tmp2 = gaim_markup_strip_html(tmp1); | 5775 tmp2 = gaim_markup_strip_html(tmp1); |
5741 g_free(tmp1); | 5776 g_free(tmp1); |
5742 tmp1 = gaim_escape_html(tmp2); | 5777 tmp1 = gaim_escape_html(tmp2); |
5743 g_free(tmp2); | 5778 g_free(tmp2); |
5744 tmp3 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); | 5779 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
5745 g_free(tmp1); | 5780 g_free(tmp1); |
5746 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Away Message"), tmp3); | 5781 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
5782 g_free(tmp2); | |
5747 } | 5783 } |
5748 } | 5784 } |
5749 } else { | 5785 } else { |
5750 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | 5786 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); |
5751 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | 5787 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) |