Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 8701:ddcafeb14e35
[gaim-migrate @ 9454]
Alright. There's some code re-use with the Get Info box and the toolip
now. The Get Info box should have everything the tooltip does. Also
got rid of the double "Last Name" field for ICQ info.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 18 Apr 2004 18:40:41 +0000 |
parents | ddd2bf87fe8d |
children | f71c0a3fcb3d |
comparison
equal
deleted
inserted
replaced
8700:ddd2bf87fe8d | 8701:ddcafeb14e35 |
---|---|
408 } | 408 } |
409 | 409 |
410 return utf8; | 410 return utf8; |
411 } | 411 } |
412 | 412 |
413 static void oscar_string_append(GString *str, char *name, char *value) | 413 static char *oscar_caps_to_string(guint caps) |
414 { | |
415 static char buf[512], *tmp; | |
416 int count = 0, i = 0; | |
417 guint bit = 1; | |
418 | |
419 if (!caps) { | |
420 return NULL; | |
421 } else while (bit <= AIM_CAPS_LAST) { | |
422 if (bit & caps) { | |
423 switch (bit) { | |
424 case AIM_CAPS_BUDDYICON: | |
425 tmp = _("Buddy Icon"); | |
426 break; | |
427 case AIM_CAPS_TALK: | |
428 tmp = _("Voice"); | |
429 break; | |
430 case AIM_CAPS_DIRECTIM: | |
431 tmp = _("AIM Direct IM"); | |
432 break; | |
433 case AIM_CAPS_CHAT: | |
434 tmp = _("Chat"); | |
435 break; | |
436 case AIM_CAPS_GETFILE: | |
437 tmp = _("Get File"); | |
438 break; | |
439 case AIM_CAPS_SENDFILE: | |
440 tmp = _("Send File"); | |
441 break; | |
442 case AIM_CAPS_GAMES: | |
443 case AIM_CAPS_GAMES2: | |
444 tmp = _("Games"); | |
445 break; | |
446 case AIM_CAPS_ADDINS: | |
447 tmp = _("Add-Ins"); | |
448 break; | |
449 case AIM_CAPS_SENDBUDDYLIST: | |
450 tmp = _("Send Buddy List"); | |
451 break; | |
452 case AIM_CAPS_ICQ_DIRECT: | |
453 tmp = _("ICQ Direct Connect"); | |
454 break; | |
455 case AIM_CAPS_APINFO: | |
456 tmp = _("AP User"); | |
457 break; | |
458 case AIM_CAPS_ICQRTF: | |
459 tmp = _("ICQ RTF"); | |
460 break; | |
461 case AIM_CAPS_EMPTY: | |
462 tmp = _("Nihilist"); | |
463 break; | |
464 case AIM_CAPS_ICQSERVERRELAY: | |
465 tmp = _("ICQ Server Relay"); | |
466 break; | |
467 case AIM_CAPS_ICQUTF8OLD: | |
468 tmp = _("Old ICQ UTF8"); | |
469 break; | |
470 case AIM_CAPS_TRILLIANCRYPT: | |
471 tmp = _("Trillian Encryption"); | |
472 break; | |
473 case AIM_CAPS_ICQUTF8: | |
474 tmp = _("ICQ UTF8"); | |
475 break; | |
476 case AIM_CAPS_HIPTOP: | |
477 tmp = _("Hiptop"); | |
478 break; | |
479 case AIM_CAPS_SECUREIM: | |
480 tmp = _("Security Enabled"); | |
481 break; | |
482 case AIM_CAPS_VIDEO: | |
483 tmp = _("Video Chat"); | |
484 break; | |
485 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
486 case AIM_CAPS_ICHATAV: | |
487 tmp = _("iChat AV"); | |
488 break; | |
489 case AIM_CAPS_LIVEVIDEO: | |
490 tmp = _("Live Video"); | |
491 break; | |
492 case AIM_CAPS_CAMERA: | |
493 tmp = _("Camera"); | |
494 break; | |
495 default: | |
496 tmp = NULL; | |
497 break; | |
498 } | |
499 if (tmp) | |
500 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
501 tmp); | |
502 count++; | |
503 } | |
504 bit <<= 1; | |
505 } | |
506 return buf; | |
507 } | |
508 | |
509 static char *oscar_icqstatus(int state) { | |
510 /* Make a cute little string that shows the status of the dude or dudet */ | |
511 if (state & AIM_ICQ_STATE_CHAT) | |
512 return g_strdup_printf(_("Free For Chat")); | |
513 else if (state & AIM_ICQ_STATE_DND) | |
514 return g_strdup_printf(_("Do Not Disturb")); | |
515 else if (state & AIM_ICQ_STATE_OUT) | |
516 return g_strdup_printf(_("Not Available")); | |
517 else if (state & AIM_ICQ_STATE_BUSY) | |
518 return g_strdup_printf(_("Occupied")); | |
519 else if (state & AIM_ICQ_STATE_AWAY) | |
520 return g_strdup_printf(_("Away")); | |
521 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
522 return g_strdup_printf(_("Web Aware")); | |
523 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
524 return g_strdup_printf(_("Invisible")); | |
525 else | |
526 return g_strdup_printf(_("Online")); | |
527 } | |
528 | |
529 static void oscar_string_append(GString *str, char *newline, char *name, char *value) | |
414 { | 530 { |
415 gchar *utf8; | 531 gchar *utf8; |
416 | 532 |
417 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { | 533 if (value && value[0] && (utf8 = gaim_utf8_try_convert(value))) { |
418 g_string_append_printf(str, "\n<br><b>%s:</b> %s", name, utf8); | 534 g_string_append_printf(str, "%s<b>%s:</b> %s", newline, name, utf8); |
419 g_free(utf8); | 535 g_free(utf8); |
536 } | |
537 } | |
538 | |
539 static void oscar_string_append_info(GaimConnection *gc, GString *str, char *newline, GaimBuddy *b, aim_userinfo_t *userinfo) | |
540 { | |
541 OscarData *od = gc->proto_data; | |
542 GaimAccount *account = gaim_connection_get_account(gc); | |
543 GaimGroup *g = NULL; | |
544 struct buddyinfo *bi = NULL; | |
545 char *tmp; | |
546 | |
547 if ((str == NULL) || (str == NULL) || (newline == NULL) || ((b == NULL) && (userinfo == NULL))) | |
548 return; | |
549 | |
550 if (userinfo == NULL) | |
551 userinfo = aim_locate_finduserinfo(od->sess, b->name); | |
552 | |
553 if (b == NULL) | |
554 b = gaim_find_buddy(gc->account, userinfo->sn); | |
555 | |
556 if (b != NULL) | |
557 g = gaim_find_buddys_group(b); | |
558 | |
559 if (userinfo != NULL) | |
560 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
561 | |
562 | |
563 | |
564 | |
565 if (GAIM_BUDDY_IS_ONLINE(b)) { | |
566 if (isdigit(b->name[0])) { | |
567 tmp = oscar_icqstatus((b->uc & 0xffff0000) >> 16); | |
568 oscar_string_append(str, newline, _("Status"), tmp); | |
569 g_free(tmp); | |
570 } | |
571 } else { | |
572 char *tmp = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | |
573 if (aim_ssi_waitingforauth(od->sess->ssi.local, tmp, b->name)) | |
574 oscar_string_append(str, newline, _("Status"), _("Not Authorized")); | |
575 else | |
576 oscar_string_append(str, newline, _("Status"), _("Offline")); | |
577 } | |
578 | |
579 | |
580 | |
581 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
582 char *tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
583 (bi->ipaddr & 0xff000000) >> 24, | |
584 (bi->ipaddr & 0x00ff0000) >> 16, | |
585 (bi->ipaddr & 0x0000ff00) >> 8, | |
586 (bi->ipaddr & 0x000000ff)); | |
587 oscar_string_append(str, newline, _("IP Address"), tmp); | |
588 g_free(tmp); | |
589 } | |
590 | |
591 if ((userinfo != NULL) && (userinfo->capabilities != 0)) { | |
592 tmp = oscar_caps_to_string(userinfo->capabilities); | |
593 oscar_string_append(str, newline, _("Capabilities"), tmp); | |
594 } | |
595 | |
596 if ((b != NULL) && (b->name != NULL) && (g != NULL) && (g->name != NULL)) { | |
597 tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
598 if (tmp != NULL) { | |
599 oscar_string_append(str, newline, _("Buddy Comment"), tmp); | |
600 g_free(tmp); | |
601 } | |
602 } | |
603 | |
604 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
605 tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
606 oscar_string_append(str, newline, _("Available"), tmp); | |
607 g_free(tmp); | |
420 } | 608 } |
421 } | 609 } |
422 | 610 |
423 static struct direct_im *find_direct_im(OscarData *od, const char *who) { | 611 static struct direct_im *find_direct_im(OscarData *od, const char *who) { |
424 GSList *d = od->direct_ims; | 612 GSList *d = od->direct_ims; |
2952 g_free(buf); | 3140 g_free(buf); |
2953 | 3141 |
2954 return 1; | 3142 return 1; |
2955 } | 3143 } |
2956 | 3144 |
2957 static char *gaim_icq_status(int state) { | |
2958 /* Make a cute little string that shows the status of the dude or dudet */ | |
2959 if (state & AIM_ICQ_STATE_CHAT) | |
2960 return g_strdup_printf(_("Free For Chat")); | |
2961 else if (state & AIM_ICQ_STATE_DND) | |
2962 return g_strdup_printf(_("Do Not Disturb")); | |
2963 else if (state & AIM_ICQ_STATE_OUT) | |
2964 return g_strdup_printf(_("Not Available")); | |
2965 else if (state & AIM_ICQ_STATE_BUSY) | |
2966 return g_strdup_printf(_("Occupied")); | |
2967 else if (state & AIM_ICQ_STATE_AWAY) | |
2968 return g_strdup_printf(_("Away")); | |
2969 else if (state & AIM_ICQ_STATE_WEBAWARE) | |
2970 return g_strdup_printf(_("Web Aware")); | |
2971 else if (state & AIM_ICQ_STATE_INVISIBLE) | |
2972 return g_strdup_printf(_("Invisible")); | |
2973 else | |
2974 return g_strdup_printf(_("Online")); | |
2975 } | |
2976 | |
2977 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { | 3145 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { |
2978 GaimConnection *gc = sess->aux_data; | 3146 GaimConnection *gc = sess->aux_data; |
2979 OscarData *od = gc->proto_data; | 3147 OscarData *od = gc->proto_data; |
2980 | 3148 |
2981 /* BBB */ | 3149 /* BBB */ |
3002 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { | 3170 static int gaim_parse_clientauto_ch4(aim_session_t *sess, char *who, fu16_t reason, fu32_t state, char *msg) { |
3003 GaimConnection *gc = sess->aux_data; | 3171 GaimConnection *gc = sess->aux_data; |
3004 | 3172 |
3005 switch(reason) { | 3173 switch(reason) { |
3006 case 0x0003: { /* Reply from an ICQ status message request */ | 3174 case 0x0003: { /* Reply from an ICQ status message request */ |
3007 char *status_msg = gaim_icq_status(state); | 3175 char *status_msg = oscar_icqstatus(state); |
3008 char *dialog_msg, **splitmsg; | 3176 char *dialog_msg, **splitmsg; |
3009 | 3177 |
3010 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ | 3178 /* Split at (carriage return/newline)'s, then rejoin later with BRs between. */ |
3011 splitmsg = g_strsplit(msg, "\r\n", 0); | 3179 splitmsg = g_strsplit(msg, "\r\n", 0); |
3012 | 3180 |
3171 g_free(buf); | 3339 g_free(buf); |
3172 | 3340 |
3173 return 1; | 3341 return 1; |
3174 } | 3342 } |
3175 | 3343 |
3176 static char *caps_string(guint caps) | |
3177 { | |
3178 static char buf[512], *tmp; | |
3179 int count = 0, i = 0; | |
3180 guint bit = 1; | |
3181 | |
3182 if (!caps) { | |
3183 return NULL; | |
3184 } else while (bit <= AIM_CAPS_LAST) { | |
3185 if (bit & caps) { | |
3186 switch (bit) { | |
3187 case AIM_CAPS_BUDDYICON: | |
3188 tmp = _("Buddy Icon"); | |
3189 break; | |
3190 case AIM_CAPS_TALK: | |
3191 tmp = _("Voice"); | |
3192 break; | |
3193 case AIM_CAPS_DIRECTIM: | |
3194 tmp = _("AIM Direct IM"); | |
3195 break; | |
3196 case AIM_CAPS_CHAT: | |
3197 tmp = _("Chat"); | |
3198 break; | |
3199 case AIM_CAPS_GETFILE: | |
3200 tmp = _("Get File"); | |
3201 break; | |
3202 case AIM_CAPS_SENDFILE: | |
3203 tmp = _("Send File"); | |
3204 break; | |
3205 case AIM_CAPS_GAMES: | |
3206 case AIM_CAPS_GAMES2: | |
3207 tmp = _("Games"); | |
3208 break; | |
3209 case AIM_CAPS_ADDINS: | |
3210 tmp = _("Add-Ins"); | |
3211 break; | |
3212 case AIM_CAPS_SENDBUDDYLIST: | |
3213 tmp = _("Send Buddy List"); | |
3214 break; | |
3215 case AIM_CAPS_ICQ_DIRECT: | |
3216 tmp = _("ICQ Direct Connect"); | |
3217 break; | |
3218 case AIM_CAPS_APINFO: | |
3219 tmp = _("AP User"); | |
3220 break; | |
3221 case AIM_CAPS_ICQRTF: | |
3222 tmp = _("ICQ RTF"); | |
3223 break; | |
3224 case AIM_CAPS_EMPTY: | |
3225 tmp = _("Nihilist"); | |
3226 break; | |
3227 case AIM_CAPS_ICQSERVERRELAY: | |
3228 tmp = _("ICQ Server Relay"); | |
3229 break; | |
3230 case AIM_CAPS_ICQUTF8OLD: | |
3231 tmp = _("Old ICQ UTF8"); | |
3232 break; | |
3233 case AIM_CAPS_TRILLIANCRYPT: | |
3234 tmp = _("Trillian Encryption"); | |
3235 break; | |
3236 case AIM_CAPS_ICQUTF8: | |
3237 tmp = _("ICQ UTF8"); | |
3238 break; | |
3239 case AIM_CAPS_HIPTOP: | |
3240 tmp = _("Hiptop"); | |
3241 break; | |
3242 case AIM_CAPS_SECUREIM: | |
3243 tmp = _("Security Enabled"); | |
3244 break; | |
3245 case AIM_CAPS_VIDEO: | |
3246 tmp = _("Video Chat"); | |
3247 break; | |
3248 /* Not actually sure about this one... WinAIM doesn't show anything */ | |
3249 case AIM_CAPS_ICHATAV: | |
3250 tmp = _("iChat AV"); | |
3251 break; | |
3252 case AIM_CAPS_LIVEVIDEO: | |
3253 tmp = _("Live Video"); | |
3254 break; | |
3255 case AIM_CAPS_CAMERA: | |
3256 tmp = _("Camera"); | |
3257 break; | |
3258 default: | |
3259 tmp = NULL; | |
3260 break; | |
3261 } | |
3262 if (tmp) | |
3263 i += g_snprintf(buf + i, sizeof(buf) - i, "%s%s", (count ? ", " : ""), | |
3264 tmp); | |
3265 count++; | |
3266 } | |
3267 bit <<= 1; | |
3268 } | |
3269 return buf; | |
3270 } | |
3271 | |
3272 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { | 3344 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { |
3273 GaimConnection *gc = sess->aux_data; | 3345 GaimConnection *gc = sess->aux_data; |
3274 OscarData *od = gc->proto_data; | |
3275 GaimAccount *account = gaim_connection_get_account(gc); | 3346 GaimAccount *account = gaim_connection_get_account(gc); |
3276 GString *str; | 3347 GString *str; |
3277 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; | 3348 gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; |
3278 struct buddyinfo *bi; | |
3279 GaimBuddy *b = NULL; | |
3280 GaimGroup *g = NULL; | |
3281 va_list ap; | 3349 va_list ap; |
3282 aim_userinfo_t *userinfo; | 3350 aim_userinfo_t *userinfo; |
3283 | 3351 |
3284 va_start(ap, fr); | 3352 va_start(ap, fr); |
3285 userinfo = va_arg(ap, aim_userinfo_t *); | 3353 userinfo = va_arg(ap, aim_userinfo_t *); |
3286 va_end(ap); | 3354 va_end(ap); |
3287 | 3355 |
3288 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); | |
3289 | |
3290 str = g_string_new(""); | 3356 str = g_string_new(""); |
3291 g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); | 3357 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)); | 3358 g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); |
3293 | 3359 |
3294 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) | 3360 if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) |
3295 oscar_string_append(str, _("Online Since"), | 3361 oscar_string_append(str, "\n<br>", _("Online Since"), |
3296 asctime(localtime((time_t *)&userinfo->onlinesince))); | 3362 asctime(localtime((time_t *)&userinfo->onlinesince))); |
3297 | 3363 |
3298 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) | 3364 if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) |
3299 oscar_string_append(str, _("Member Since"), | 3365 oscar_string_append(str, "\n<br>", _("Member Since"), |
3300 asctime(localtime((time_t *)&userinfo->membersince))); | 3366 asctime(localtime((time_t *)&userinfo->membersince))); |
3301 | 3367 |
3302 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { | 3368 if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { |
3303 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); | 3369 tmp = gaim_str_seconds_to_string(userinfo->idletime*60); |
3304 oscar_string_append(str, _("Idle"), tmp); | 3370 oscar_string_append(str, "\n<br>", _("Idle"), tmp); |
3305 g_free(tmp); | 3371 g_free(tmp); |
3306 } else | 3372 } |
3307 oscar_string_append(str, _("Idle"), _("Active")); | 3373 |
3308 | 3374 oscar_string_append_info(gc, str, "\n<br>", NULL, userinfo); |
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 } | |
3337 | 3375 |
3338 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | 3376 if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { |
3339 tmp = oscar_encoding_extract(userinfo->away_encoding); | 3377 tmp = oscar_encoding_extract(userinfo->away_encoding); |
3340 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); | 3378 away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); |
3341 g_free(tmp); | 3379 g_free(tmp); |
3353 g_string_append_printf(str, "\n<hr>%s", info_utf8); | 3391 g_string_append_printf(str, "\n<hr>%s", info_utf8); |
3354 g_free(info_utf8); | 3392 g_free(info_utf8); |
3355 } | 3393 } |
3356 } | 3394 } |
3357 | 3395 |
3358 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(gaim_connection_get_account(gc))); | 3396 tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(account)); |
3359 g_string_free(str, TRUE); | 3397 g_string_free(str, TRUE); |
3360 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, tmp, NULL, NULL); | 3398 gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, tmp, NULL, NULL); |
3361 g_free(tmp); | 3399 g_free(tmp); |
3362 | 3400 |
3363 return 1; | 3401 return 1; |
4162 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); | 4200 buddy = gaim_find_buddy(gaim_connection_get_account(gc), who); |
4163 if (buddy != NULL) | 4201 if (buddy != NULL) |
4164 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); | 4202 bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(buddy->account, buddy->name)); |
4165 | 4203 |
4166 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); | 4204 g_string_append_printf(str, "<b>%s:</b> %s", _("UIN"), who); |
4167 oscar_string_append(str, _("Nick"), info->nick); | 4205 oscar_string_append(str, "\n<br>", _("Nick"), info->nick); |
4168 if ((bi != NULL) && (bi->ipaddr != 0)) { | 4206 if ((bi != NULL) && (bi->ipaddr != 0)) { |
4169 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | 4207 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", |
4170 (bi->ipaddr & 0xff000000) >> 24, | 4208 (bi->ipaddr & 0xff000000) >> 24, |
4171 (bi->ipaddr & 0x00ff0000) >> 16, | 4209 (bi->ipaddr & 0x00ff0000) >> 16, |
4172 (bi->ipaddr & 0x0000ff00) >> 8, | 4210 (bi->ipaddr & 0x0000ff00) >> 8, |
4173 (bi->ipaddr & 0x000000ff)); | 4211 (bi->ipaddr & 0x000000ff)); |
4174 oscar_string_append(str, _("IP Address"), tstr); | 4212 oscar_string_append(str, "\n<br>", _("IP Address"), tstr); |
4175 g_free(tstr); | 4213 g_free(tstr); |
4176 } | 4214 } |
4177 oscar_string_append(str, _("First Name"), info->first); | 4215 oscar_string_append(str, "\n<br>", _("First Name"), info->first); |
4178 oscar_string_append(str, _("Last Name"), info->last); | 4216 oscar_string_append(str, "\n<br>", _("Last Name"), info->last); |
4179 oscar_string_append(str, _("Last Name"), info->last); | |
4180 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { | 4217 if (info->email && info->email[0] && (utf8 = gaim_utf8_try_convert(info->email))) { |
4181 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); | 4218 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto:%s\">%s</a>", _("Email Address"), utf8, utf8); |
4182 g_free(utf8); | 4219 g_free(utf8); |
4183 } | 4220 } |
4184 if (info->numaddresses && info->email2) { | 4221 if (info->numaddresses && info->email2) { |
4188 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); | 4225 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"mailto%s\">%s</a>", _("Email Address"), utf8, utf8); |
4189 g_free(utf8); | 4226 g_free(utf8); |
4190 } | 4227 } |
4191 } | 4228 } |
4192 } | 4229 } |
4193 oscar_string_append(str, _("Mobile Phone"), info->mobile); | 4230 oscar_string_append(str, "\n<br>", _("Mobile Phone"), info->mobile); |
4194 oscar_string_append(str, _("Gender"), info->gender==1 ? _("Female") : _("Male")); | 4231 oscar_string_append(str, "\n<br>", _("Gender"), info->gender==1 ? _("Female") : _("Male")); |
4195 if (info->birthyear || info->birthmonth || info->birthday) { | 4232 if (info->birthyear || info->birthmonth || info->birthday) { |
4196 char date[30]; | 4233 char date[30]; |
4197 struct tm tm; | 4234 struct tm tm; |
4198 tm.tm_mday = (int)info->birthday; | 4235 tm.tm_mday = (int)info->birthday; |
4199 tm.tm_mon = (int)info->birthmonth-1; | 4236 tm.tm_mon = (int)info->birthmonth-1; |
4200 tm.tm_year = (int)info->birthyear-1900; | 4237 tm.tm_year = (int)info->birthyear-1900; |
4201 strftime(date, sizeof(date), "%x", &tm); | 4238 strftime(date, sizeof(date), "%x", &tm); |
4202 oscar_string_append(str, _("Birthday"), date); | 4239 oscar_string_append(str, "\n<br>", _("Birthday"), date); |
4203 } | 4240 } |
4204 if (info->age) { | 4241 if (info->age) { |
4205 char age[5]; | 4242 char age[5]; |
4206 snprintf(age, sizeof(age), "%hhd", info->age); | 4243 snprintf(age, sizeof(age), "%hhd", info->age); |
4207 oscar_string_append(str, _("Age"), age); | 4244 oscar_string_append(str, "\n<br>", _("Age"), age); |
4208 } | 4245 } |
4209 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { | 4246 if (info->personalwebpage && info->personalwebpage[0] && (utf8 = gaim_utf8_try_convert(info->personalwebpage))) { |
4210 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); | 4247 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Personal Web Page"), utf8, utf8); |
4211 g_free(utf8); | 4248 g_free(utf8); |
4212 } | 4249 } |
4215 g_free(utf8); | 4252 g_free(utf8); |
4216 } | 4253 } |
4217 g_string_append_printf(str, "<hr>\n"); | 4254 g_string_append_printf(str, "<hr>\n"); |
4218 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { | 4255 if ((info->homeaddr && (info->homeaddr[0])) || (info->homecity && info->homecity[0]) || (info->homestate && info->homestate[0]) || (info->homezip && info->homezip[0])) { |
4219 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); | 4256 g_string_append_printf(str, "<b>%s:</b>", _("Home Address")); |
4220 oscar_string_append(str, _("Address"), info->homeaddr); | 4257 oscar_string_append(str, "\n<br>", _("Address"), info->homeaddr); |
4221 oscar_string_append(str, _("City"), info->homecity); | 4258 oscar_string_append(str, "\n<br>", _("City"), info->homecity); |
4222 oscar_string_append(str, _("State"), info->homestate); | 4259 oscar_string_append(str, "\n<br>", _("State"), info->homestate); |
4223 oscar_string_append(str, _("Zip Code"), info->homezip); | 4260 oscar_string_append(str, "\n<br>", _("Zip Code"), info->homezip); |
4224 g_string_append_printf(str, "\n<hr>\n"); | 4261 g_string_append_printf(str, "\n<hr>\n"); |
4225 } | 4262 } |
4226 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { | 4263 if ((info->workaddr && info->workaddr[0]) || (info->workcity && info->workcity[0]) || (info->workstate && info->workstate[0]) || (info->workzip && info->workzip[0])) { |
4227 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); | 4264 g_string_append_printf(str, "<b>%s:</b>", _("Work Address")); |
4228 oscar_string_append(str, _("Address"), info->workaddr); | 4265 oscar_string_append(str, "\n<br>", _("Address"), info->workaddr); |
4229 oscar_string_append(str, _("City"), info->workcity); | 4266 oscar_string_append(str, "\n<br>", _("City"), info->workcity); |
4230 oscar_string_append(str, _("State"), info->workstate); | 4267 oscar_string_append(str, "\n<br>", _("State"), info->workstate); |
4231 oscar_string_append(str, _("Zip Code"), info->workzip); | 4268 oscar_string_append(str, "\n<br>", _("Zip Code"), info->workzip); |
4232 g_string_append_printf(str, "\n<hr>\n"); | 4269 g_string_append_printf(str, "\n<hr>\n"); |
4233 } | 4270 } |
4234 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { | 4271 if ((info->workcompany && info->workcompany[0]) || (info->workdivision && info->workdivision[0]) || (info->workposition && info->workposition[0]) || (info->workwebpage && info->workwebpage[0])) { |
4235 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); | 4272 g_string_append_printf(str, "<b>%s:</b>", _("Work Information")); |
4236 oscar_string_append(str, _("Company"), info->workcompany); | 4273 oscar_string_append(str, "\n<br>", _("Company"), info->workcompany); |
4237 oscar_string_append(str, _("Division"), info->workdivision); | 4274 oscar_string_append(str, "\n<br>", _("Division"), info->workdivision); |
4238 oscar_string_append(str, _("Position"), info->workposition); | 4275 oscar_string_append(str, "\n<br>", _("Position"), info->workposition); |
4239 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { | 4276 if (info->workwebpage && info->workwebpage[0] && (utf8 = gaim_utf8_try_convert(info->workwebpage))) { |
4240 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); | 4277 g_string_append_printf(str, "\n<br><b>%s:</b> <a href=\"%s\">%s</a>", _("Web Page"), utf8, utf8); |
4241 g_free(utf8); | 4278 g_free(utf8); |
4242 } | 4279 } |
4243 g_string_append_printf(str, "\n<hr>\n"); | 4280 g_string_append_printf(str, "\n<hr>\n"); |
5720 } | 5757 } |
5721 | 5758 |
5722 static char *oscar_tooltip_text(GaimBuddy *b) { | 5759 static char *oscar_tooltip_text(GaimBuddy *b) { |
5723 GaimConnection *gc = b->account->gc; | 5760 GaimConnection *gc = b->account->gc; |
5724 OscarData *od = gc->proto_data; | 5761 OscarData *od = gc->proto_data; |
5725 GaimGroup *g = gaim_find_buddys_group(b); | |
5726 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); | |
5727 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); | 5762 aim_userinfo_t *userinfo = aim_locate_finduserinfo(od->sess, b->name); |
5728 GString *ret = g_string_new(""); | 5763 GString *str = g_string_new(""); |
5729 | 5764 |
5730 if (GAIM_BUDDY_IS_ONLINE(b)) { | 5765 if (GAIM_BUDDY_IS_ONLINE(b)) { |
5731 if (isdigit(b->name[0])) { | 5766 oscar_string_append_info(gc, str, "\n", b, userinfo); |
5732 char *status; | |
5733 status = gaim_icq_status((b->uc & 0xffff0000) >> 16); | |
5734 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), status); | |
5735 g_free(status); | |
5736 } | |
5737 | |
5738 if ((bi != NULL) && (bi->ipaddr != 0)) { | |
5739 char *tstr = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", | |
5740 (bi->ipaddr & 0xff000000) >> 24, | |
5741 (bi->ipaddr & 0x00ff0000) >> 16, | |
5742 (bi->ipaddr & 0x0000ff00) >> 8, | |
5743 (bi->ipaddr & 0x000000ff)); | |
5744 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("IP Address"), tstr); | |
5745 g_free(tstr); | |
5746 } | |
5747 | |
5748 if ((userinfo != NULL) && (userinfo->capabilities)) { | |
5749 char *caps = caps_string(userinfo->capabilities); | |
5750 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Capabilities"), caps); | |
5751 } | |
5752 | |
5753 if (g && g->name) { | |
5754 char *comment = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); | |
5755 if (comment != NULL) { | |
5756 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Buddy Comment"), comment); | |
5757 free(comment); | |
5758 } | |
5759 } | |
5760 | |
5761 if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { | |
5762 gchar *escaped = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); | |
5763 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Available"), escaped); | |
5764 g_free(escaped); | |
5765 } | |
5766 | 5767 |
5767 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { | 5768 if ((userinfo != NULL) && (userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { |
5768 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); | 5769 gchar *charset = oscar_encoding_extract(userinfo->away_encoding); |
5769 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); | 5770 gchar *away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); |
5770 g_free(charset); | 5771 g_free(charset); |
5776 g_free(tmp1); | 5777 g_free(tmp1); |
5777 tmp1 = gaim_escape_html(tmp2); | 5778 tmp1 = gaim_escape_html(tmp2); |
5778 g_free(tmp2); | 5779 g_free(tmp2); |
5779 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); | 5780 tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); |
5780 g_free(tmp1); | 5781 g_free(tmp1); |
5781 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Away Message"), tmp2); | 5782 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Away Message"), tmp2); |
5782 g_free(tmp2); | 5783 g_free(tmp2); |
5783 } | 5784 } |
5784 } | 5785 } |
5785 } else { | 5786 } |
5786 char *gname = aim_ssi_itemlist_findparentname(od->sess->ssi.local, b->name); | 5787 |
5787 if (aim_ssi_waitingforauth(od->sess->ssi.local, gname, b->name)) | 5788 return g_string_free(str, FALSE); |
5788 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), _("Not Authorized")); | |
5789 else | |
5790 g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Status"), _("Offline")); | |
5791 } | |
5792 | |
5793 return g_string_free(ret, FALSE);; | |
5794 } | 5789 } |
5795 | 5790 |
5796 static char *oscar_status_text(GaimBuddy *b) { | 5791 static char *oscar_status_text(GaimBuddy *b) { |
5797 GaimConnection *gc = b->account->gc; | 5792 GaimConnection *gc = b->account->gc; |
5798 OscarData *od = gc->proto_data; | 5793 OscarData *od = gc->proto_data; |
5799 gchar *ret = NULL; | 5794 gchar *ret = NULL; |
5800 | 5795 |
5801 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { | 5796 if ((b->uc & UC_UNAVAILABLE) || (((b->uc & 0xffff0000) >> 16) & AIM_ICQ_STATE_CHAT)) { |
5802 if (isdigit(b->name[0])) | 5797 if (isdigit(b->name[0])) |
5803 ret = gaim_icq_status((b->uc & 0xffff0000) >> 16); | 5798 ret = oscar_icqstatus((b->uc & 0xffff0000) >> 16); |
5804 else | 5799 else |
5805 ret = g_strdup(_("Away")); | 5800 ret = g_strdup(_("Away")); |
5806 } else if (GAIM_BUDDY_IS_ONLINE(b)) { | 5801 } else if (GAIM_BUDDY_IS_ONLINE(b)) { |
5807 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); | 5802 struct buddyinfo *bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(b->account, b->name)); |
5808 if (bi->availmsg) | 5803 if (bi->availmsg) |