changeset 16422:6447865b2d08

/whowas for IRC. Thanks, achris.
author Ethan Blanton <elb@pidgin.im>
date Wed, 25 Apr 2007 16:03:24 +0000
parents ac2c14628790
children 0fb719b5dc0e
files ChangeLog libpurple/protocols/irc/cmds.c libpurple/protocols/irc/irc.h libpurple/protocols/irc/msgs.c libpurple/protocols/irc/parse.c
diffstat 5 files changed, 31 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Apr 25 13:42:00 2007 +0000
+++ b/ChangeLog	Wed Apr 25 16:03:24 2007 +0000
@@ -172,6 +172,7 @@
 	* Added /nickserv, /memoserv, /chanserv and /operserv
 	  commands (Joao Luís Marques Pinto)
 	* Added CTCP VERSION via /version (Andrej Krivulčík)
+	* Added /whowas command (achris)
 
 	Jabber Features:
 	* Support for SRV lookups
--- a/libpurple/protocols/irc/cmds.c	Wed Apr 25 13:42:00 2007 +0000
+++ b/libpurple/protocols/irc/cmds.c	Wed Apr 25 16:03:24 2007 +0000
@@ -559,6 +559,22 @@
 	return 0;
 }
 
+int irc_cmd_whowas(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
+{
+	char *buf;
+
+	if (!args || !args[0])
+		return 0;
+
+	buf = irc_format(irc, "vn", "WHOWAS", args[0]);
+	
+	irc->whois.nick = g_strdup(args[0]);
+	irc_send(irc, buf);
+	g_free(buf);
+
+	return 0;
+}
+
 static void irc_do_mode(struct irc_conn *irc, const char *target, const char *sign, char **ops)
 {
 	char *buf, mode[5];
--- a/libpurple/protocols/irc/irc.h	Wed Apr 25 13:42:00 2007 +0000
+++ b/libpurple/protocols/irc/irc.h	Wed Apr 25 16:03:24 2007 +0000
@@ -179,6 +179,7 @@
 int irc_cmd_topic(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_wallops(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_whois(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
+int irc_cmd_whowas(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 
 PurpleXfer *irc_dccsend_new_xfer(PurpleConnection *gc, const char *who);
 void irc_dccsend_send_file(PurpleConnection *gc, const char *who, const char *file);
--- a/libpurple/protocols/irc/msgs.c	Wed Apr 25 13:42:00 2007 +0000
+++ b/libpurple/protocols/irc/msgs.c	Wed Apr 25 16:03:24 2007 +0000
@@ -236,18 +236,20 @@
 void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
 	if (!irc->whois.nick) {
-		purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected WHOIS reply for %s\n", args[1]);
+		purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected %s reply for %s\n", !strcmp(name, "314") ? "WHOWAS" : "WHOIS"
+											   , args[1]);
 		return;
 	}
 
 	if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
-		purple_debug(PURPLE_DEBUG_WARNING, "irc", "Got WHOIS reply for %s while waiting for %s\n", args[1], irc->whois.nick);
+		purple_debug(PURPLE_DEBUG_WARNING, "irc", "Got %s reply for %s while waiting for %s\n", !strcmp(name, "314") ? "WHOWAS" : "WHOIS"
+												      , args[1], irc->whois.nick);
 		return;
 	}
 
 	if (!strcmp(name, "301")) {
 		irc->whois.away = g_strdup(args[2]);
-	} else if (!strcmp(name, "311")) {
+	} 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]);
 	} else if (!strcmp(name, "312")) {
@@ -273,11 +275,13 @@
 	PurpleNotifyUserInfo *user_info;
 
 	if (!irc->whois.nick) {
-		purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected End of WHOIS for %s\n", args[1]);
+		purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected End of %s for %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS" 
+											     , args[1]);
 		return;
 	}
 	if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) {
-		purple_debug(PURPLE_DEBUG_WARNING, "irc", "Received end of WHOIS for %s, expecting %s\n", args[1], irc->whois.nick);
+		purple_debug(PURPLE_DEBUG_WARNING, "irc", "Received end of %s for %s, expecting %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS" 
+													 , args[1], irc->whois.nick);
 		return;
 	}
 
--- a/libpurple/protocols/irc/parse.c	Wed Apr 25 13:42:00 2007 +0000
+++ b/libpurple/protocols/irc/parse.c	Wed Apr 25 16:03:24 2007 +0000
@@ -64,6 +64,8 @@
 	{ "318", "nt:", irc_msg_endwhois },	/* End of WHOIS			*/
 	{ "319", "nn:", irc_msg_whois },	/* Whois channels		*/
 	{ "320", "nn:", irc_msg_whois },	/* Whois (fn ident)		*/
+	{ "314", "nnvvv:", irc_msg_whois },	/* Whowas user			*/
+	{ "369", "nt:", irc_msg_endwhois },	/* End of WHOWAS		*/
 	{ "321", "*", irc_msg_list },		/* Start of list		*/
 	{ "322", "ncv:", irc_msg_list },	/* List.			*/
 	{ "323", ":", irc_msg_list },		/* End of list.			*/
@@ -78,6 +80,7 @@
 	{ "376", "n:", irc_msg_motd },		/* End of MOTD			*/
 	{ "391", "nv:", irc_msg_time },		/* Time reply			*/
 	{ "401", "nt:", irc_msg_nonick },	/* No such nick/chan		*/
+	{ "406", "nt:", irc_msg_nonick },	/* No such nick for WHOWAS	*/
 	{ "403", "nc:", irc_msg_nochan },	/* No such channel		*/
 	{ "404", "nt:", irc_msg_nosend },	/* Cannot send to chan		*/
 	{ "421", "nv:", irc_msg_unknown },	/* Unknown command		*/
@@ -148,6 +151,7 @@
 	{ "voice", ":", irc_cmd_op, N_("voice &lt;nick1&gt; [nick2] ...:  Grant channel voice status to someone. You must be a channel operator to do this.") },
 	{ "wallops", ":", irc_cmd_wallops, N_("wallops &lt;message&gt;:  If you don't know what this is, you probably can't use it.") },
 	{ "whois", "tt", irc_cmd_whois, N_("whois [server] &lt;nick&gt;:  Get information on a user.") },
+	{ "whowas", "t", irc_cmd_whowas, N_("whowas &lt;nick&gt;: Get information on a user that has logged off.") },
 	{ NULL, NULL, NULL, NULL }
 };