/pidgin/main: 639ec03ba1ba: Improve IRC whois command

Andy Spencer andy753421 at gmail.com
Tue Jan 21 23:10:05 EST 2014


Changeset: 639ec03ba1ba559018179f1f4fb0cd94fe28de26
Author:	 Andy Spencer <andy753421 at gmail.com>
Date:	 2013-05-05 01:12 +0000
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/639ec03ba1ba

Description:

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

diffstat:

 libpurple/protocols/irc/irc.h   |   6 ++++--
 libpurple/protocols/irc/msgs.c  |  32 +++++++++++++++++++++++---------
 libpurple/protocols/irc/parse.c |   1 +
 3 files changed, 28 insertions(+), 11 deletions(-)

diffs (84 lines):

diff --git a/libpurple/protocols/irc/irc.h b/libpurple/protocols/irc/irc.h
--- a/libpurple/protocols/irc/irc.h
+++ b/libpurple/protocols/irc/irc.h
@@ -72,9 +72,11 @@ struct irc_conn {
 	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;
diff --git a/libpurple/protocols/irc/msgs.c b/libpurple/protocols/irc/msgs.c
--- a/libpurple/protocols/irc/msgs.c
+++ b/libpurple/protocols/irc/msgs.c
@@ -382,8 +382,9 @@ void irc_msg_whois(struct irc_conn *irc,
 	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 @@ void irc_msg_whois(struct irc_conn *irc,
 		}
 	} 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 @@ void irc_msg_endwhois(struct irc_conn *i
 		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);
diff --git a/libpurple/protocols/irc/parse.c b/libpurple/protocols/irc/parse.c
--- a/libpurple/protocols/irc/parse.c
+++ b/libpurple/protocols/irc/parse.c
@@ -64,6 +64,7 @@ static struct _irc_msg {
 	{ "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		*/



More information about the Commits mailing list