Mercurial > pidgin.yaz
changeset 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 | 775bd10da7f2 |
children | ddcafeb14e35 |
files | src/protocols/oscar/oscar.c src/server.c src/util.c src/util.h |
diffstat | 4 files changed, 92 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c Sun Apr 18 15:44:52 2004 +0000 +++ b/src/protocols/oscar/oscar.c Sun Apr 18 17:10:14 2004 +0000 @@ -410,6 +410,16 @@ return utf8; } +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<br><b>%s:</b> %s", name, utf8); + g_free(utf8); + } +} + static struct direct_im *find_direct_im(OscarData *od, const char *who) { GSList *d = od->direct_ims; struct direct_im *m = NULL; @@ -3261,9 +3271,13 @@ static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) { GaimConnection *gc = sess->aux_data; - GString *text; - gchar *info_utf8 = NULL, *away_utf8 = NULL; - const char *final = NULL; + OscarData *od = gc->proto_data; + GaimAccount *account = gaim_connection_get_account(gc); + GString *str; + gchar *tmp = NULL, *info_utf8 = NULL, *away_utf8 = NULL; + struct buddyinfo *bi; + GaimBuddy *b = NULL; + GaimGroup *g = NULL; va_list ap; aim_userinfo_t *userinfo; @@ -3271,48 +3285,80 @@ userinfo = va_arg(ap, aim_userinfo_t *); va_end(ap); - text = g_string_new(""); - g_string_append_printf(text, _("Username: <b>%s</b><br>\n"), userinfo->sn); - g_string_append_printf(text, _("Warning Level: <b>%d%%</b><br>\n"), (int)((userinfo->warnlevel/10.0) + 0.5)); + bi = g_hash_table_lookup(od->buddyinfo, gaim_normalize(account, userinfo->sn)); + + str = g_string_new(""); + g_string_append_printf(str, "<b>%s:</b> %s", _("Screen Name"), userinfo->sn); + g_string_append_printf(str, "\n<br><b>%s</b>: %d%%", _("Warning Level"), (int)((userinfo->warnlevel/10.0) + 0.5)); if (userinfo->present & AIM_USERINFO_PRESENT_ONLINESINCE) - g_string_append_printf(text, _("Online Since: <b>%s</b><br>\n"), - asctime(localtime((time_t *)&userinfo->onlinesince))); + oscar_string_append(str, _("Online Since"), + asctime(localtime((time_t *)&userinfo->onlinesince))); if (userinfo->present & AIM_USERINFO_PRESENT_MEMBERSINCE) - g_string_append_printf(text, _("Member Since: <b>%s</b><br>\n"), - asctime(localtime((time_t *)&userinfo->membersince))); + oscar_string_append(str, _("Member Since"), + asctime(localtime((time_t *)&userinfo->membersince))); if (userinfo->present & AIM_USERINFO_PRESENT_IDLE) { - gchar *itime = gaim_str_seconds_to_string(userinfo->idletime*60); - g_string_append_printf(text, _("Idle: <b>%s</b>"), itime); - g_free(itime); + tmp = gaim_str_seconds_to_string(userinfo->idletime*60); + oscar_string_append(str, _("Idle"), tmp); + g_free(tmp); } else - g_string_append_printf(text, _("Idle: <b>Active</b>")); + oscar_string_append(str, _("Idle"), _("Active")); + + if ((bi != NULL) && (bi->ipaddr != 0)) { + tmp = g_strdup_printf("%hhu.%hhu.%hhu.%hhu", + (bi->ipaddr & 0xff000000) >> 24, + (bi->ipaddr & 0x00ff0000) >> 16, + (bi->ipaddr & 0x0000ff00) >> 8, + (bi->ipaddr & 0x000000ff)); + g_string_append_printf(str, "\n<b>%s:</b> %s", _("IP Address"), tmp); + g_free(tmp); + } + + if (userinfo->capabilities != 0) { + tmp = caps_string(userinfo->capabilities); + oscar_string_append(str, _("Capabilities"), tmp); + } + + if ((g != NULL) && (g->name != NULL)) { + tmp = aim_ssi_getcomment(od->sess->ssi.local, g->name, b->name); + if (tmp != NULL) { + oscar_string_append(str, _("Buddy Comment"), tmp); + g_free(tmp); + } + } + + if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) { + tmp = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg)); + oscar_string_append(str, _("Available"), tmp); + g_free(tmp); + } if ((userinfo->flags & AIM_FLAG_AWAY) && (userinfo->away_len > 0) && (userinfo->away != NULL) && (userinfo->away_encoding != NULL)) { - gchar *charset = oscar_encoding_extract(userinfo->away_encoding); - away_utf8 = oscar_encoding_to_utf8(charset, userinfo->away, userinfo->away_len); - g_free(charset); + tmp = oscar_encoding_extract(userinfo->away_encoding); + away_utf8 = oscar_encoding_to_utf8(tmp, userinfo->away, userinfo->away_len); + g_free(tmp); if (away_utf8 != NULL) { - g_string_append_printf(text, "<hr>%s", away_utf8); + g_string_append_printf(str, "\n<hr>%s", away_utf8); g_free(away_utf8); } } if ((userinfo->info_len > 0) && (userinfo->info != NULL) && (userinfo->info_encoding != NULL)) { - gchar *charset = oscar_encoding_extract(userinfo->info_encoding); - info_utf8 = oscar_encoding_to_utf8(charset, userinfo->info, userinfo->info_len); - g_free(charset); + tmp = oscar_encoding_extract(userinfo->info_encoding); + info_utf8 = oscar_encoding_to_utf8(tmp, userinfo->info, userinfo->info_len); + g_free(tmp); if (info_utf8 != NULL) { - g_string_append_printf(text, "<hr>%s", info_utf8); + g_string_append_printf(str, "\n<hr>%s", info_utf8); g_free(info_utf8); } } - final = gaim_str_sub_away_formatters(text->str, gaim_account_get_username(gaim_connection_get_account(gc))); - g_string_free(text, TRUE); - gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, final, NULL, NULL); + tmp = gaim_str_sub_away_formatters(str->str, gaim_account_get_username(gaim_connection_get_account(gc))); + g_string_free(str, TRUE); + gaim_notify_formatted(gc, NULL, _("Buddy Information"), NULL, tmp, NULL, NULL); + g_free(tmp); return 1; } @@ -4092,16 +4138,6 @@ } #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<br><b>%s:</b> %s", name, utf8); - g_free(utf8); - } -} - static int gaim_icqinfo(aim_session_t *sess, aim_frame_t *fr, ...) { GaimConnection *gc = sess->aux_data; @@ -5734,16 +5770,16 @@ g_free(charset); if (away_utf8 != NULL) { gchar *tmp1, *tmp2; - const gchar *tmp3; tmp1 = gaim_strcasereplace(away_utf8, "<BR>", "\n"); g_free(away_utf8); tmp2 = gaim_markup_strip_html(tmp1); g_free(tmp1); tmp1 = gaim_escape_html(tmp2); g_free(tmp2); - tmp3 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); + tmp2 = gaim_str_sub_away_formatters(tmp1, gaim_account_get_username(gaim_connection_get_account(gc))); g_free(tmp1); - g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Away Message"), tmp3); + g_string_append_printf(ret, "\n<b>%s:</b> %s", _("Away Message"), tmp2); + g_free(tmp2); } } } else {
--- a/src/server.c Sun Apr 18 15:44:52 2004 +0000 +++ b/src/server.c Sun Apr 18 17:10:14 2004 +0000 @@ -1032,7 +1032,12 @@ /* apply default fonts and colors */ tmpmsg = stylize(gc->away, MSG_LEN); - serv_send_im(gc, name, gaim_str_sub_away_formatters(tmpmsg, alias), GAIM_CONV_IM_AUTO_RESP); + + /* Move this to oscar.c! */ + buffy = gaim_str_sub_away_formatters(tmpmsg, alias); + serv_send_im(gc, name, buffy, GAIM_CONV_IM_AUTO_RESP); + g_free(buffy); + if (!cnv && awayqueue && gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) {
--- a/src/util.c Sun Apr 18 15:44:52 2004 +0000 +++ b/src/util.c Sun Apr 18 17:10:14 2004 +0000 @@ -1771,26 +1771,26 @@ return ret; } -/* Look for %n, %d, or %t in msg, and replace with the sender's name, date, - or time */ -const char * -gaim_str_sub_away_formatters(const char *msg, const char *name) +gchar * +gaim_str_sub_away_formatters(const char *str, const char *name) { char *c; - static char cpy[BUF_LONG]; + gchar *cpy; int cnt = 0; time_t t; struct tm *tme; char tmp[20]; - g_return_val_if_fail(msg != NULL, NULL); + g_return_val_if_fail(str != NULL, NULL); g_return_val_if_fail(name != NULL, NULL); + cpy = g_malloc(BUF_LONG); + t = time(NULL); tme = localtime(&t); cpy[0] = '\0'; - c = (char *)msg; + c = (char *)str; while (*c) { switch (*c) { case '%': @@ -1827,7 +1827,8 @@ c++; } cpy[cnt] = '\0'; - return (cpy); + + return cpy; } gchar *
--- a/src/util.h Sun Apr 18 15:44:52 2004 +0000 +++ b/src/util.h Sun Apr 18 17:10:14 2004 +0000 @@ -426,15 +426,13 @@ * Looks for %n, %d, or %t in a string, and replaces them with the * specified name, date, and time, respectively. * - * The returned string is stored in a static buffer, so the result - * should be g_strdup()'d if it's intended to be used for long. - * * @param str The string that may contain the special variables. * @param name The sender name. * - * @return A new string where the special variables are expanded. + * @return A newly allocated string where the special variables are + * expanded. This should be g_free'd by the caller. */ -const char *gaim_str_sub_away_formatters(const char *str, const char *name); +gchar *gaim_str_sub_away_formatters(const char *str, const char *name); /** * Duplicates a string and replaces all newline characters from the