pidgin/pidgin

Improve IRC whois command
release-2.x.y
2013-05-05, Andy Spencer
639ec03ba1ba
Improve IRC whois command

This adds support for displaying the users login name on Freenode and
also renames some of the other "names" to avoid confusion.

Refs #15451
--- a/libpurple/protocols/irc/irc.h Tue Jan 21 18:28:54 2014 -0600
+++ b/libpurple/protocols/irc/irc.h Sun May 05 01:12:06 2013 +0000
@@ -72,9 +72,11 @@
GString *names;
struct _whois {
char *nick;
+ char *real;
+ char *login;
+ char *ident;
+ char *host;
char *away;
- char *userhost;
- char *name;
char *server;
char *serverinfo;
GString *channels;
--- a/libpurple/protocols/irc/msgs.c Tue Jan 21 18:28:54 2014 -0600
+++ b/libpurple/protocols/irc/msgs.c Sun May 05 01:12:06 2013 +0000
@@ -382,8 +382,9 @@
if (!strcmp(name, "301")) {
irc->whois.away = g_strdup(args[2]);
} else if (!strcmp(name, "311") || !strcmp(name, "314")) {
- irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]);
- irc->whois.name = g_strdup(args[5]);
+ irc->whois.ident = g_strdup(args[2]);
+ irc->whois.host = g_strdup(args[3]);
+ irc->whois.real = g_strdup(args[5]);
} else if (!strcmp(name, "312")) {
irc->whois.server = g_strdup(args[2]);
irc->whois.serverinfo = g_strdup(args[3]);
@@ -401,6 +402,11 @@
}
} else if (!strcmp(name, "320")) {
irc->whois.identified = 1;
+ } else if (!strcmp(name, "330")) {
+ g_message("msg %s: 1=[%s] 2=[%s] 3=[%s]",
+ name, args[1], args[2], args[3]);
+ if (!strcmp(args[3], "is logged in as"))
+ irc->whois.login = g_strdup(args[2]);
}
}
@@ -437,13 +443,21 @@
purple_notify_user_info_add_pair(user_info, _("Away"), tmp);
g_free(tmp);
}
- if (irc->whois.userhost) {
- tmp = g_markup_escape_text(irc->whois.name, strlen(irc->whois.name));
- g_free(irc->whois.name);
- purple_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost);
- purple_notify_user_info_add_pair(user_info, _("Real name"), tmp);
- g_free(irc->whois.userhost);
- g_free(tmp);
+ if (irc->whois.real) {
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Real name"), irc->whois.real);
+ g_free(irc->whois.real);
+ }
+ if (irc->whois.login) {
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Login name"), irc->whois.login);
+ g_free(irc->whois.login);
+ }
+ if (irc->whois.ident) {
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Ident name"), irc->whois.ident);
+ g_free(irc->whois.ident);
+ }
+ if (irc->whois.host) {
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Host name"), irc->whois.host);
+ g_free(irc->whois.host);
}
if (irc->whois.server) {
tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo);
--- a/libpurple/protocols/irc/parse.c Tue Jan 21 18:28:54 2014 -0600
+++ b/libpurple/protocols/irc/parse.c Sun May 05 01:12:06 2013 +0000
@@ -64,6 +64,7 @@
{ "318", "nt:", irc_msg_endwhois }, /* End of WHOIS */
{ "319", "nn:", irc_msg_whois }, /* Whois channels */
{ "320", "nn:", irc_msg_whois }, /* Whois (fn ident) */
+ { "330", "nnv:", irc_msg_whois }, /* Whois (fn login) */
{ "314", "nnnvv:", irc_msg_whois }, /* Whowas user */
{ "315", "nt:", irc_msg_who }, /* end of WHO channel */
{ "369", "nt:", irc_msg_endwhois }, /* End of WHOWAS */