changeset 1673:0ded38ffc7c8

[gaim-migrate @ 1683] IRC got whois. committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sat, 31 Mar 2001 06:49:06 +0000
parents 7cb0cebd6d87
children 1127fa1b4c02
files ChangeLog plugins/irc.c
diffstat 2 files changed, 48 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Mar 31 06:10:42 2001 +0000
+++ b/ChangeLog	Sat Mar 31 06:49:06 2001 +0000
@@ -4,6 +4,7 @@
 	* Many, many bug fixes
 	* Can choose to not send away auto-response (thanks phzzzt)
 	* Uh... Oscar works? For now?
+	* IRC Plugin can do whois (right click and info)
 
 version 0.11.0-pre9 (03/26/2001):
 	* Can register Jabber accounts (load the Jabber plugin and click
--- a/plugins/irc.c	Sat Mar 31 06:10:42 2001 +0000
+++ b/plugins/irc.c	Sat Mar 31 06:49:06 2001 +0000
@@ -399,6 +399,28 @@
 		g_free(u_errormsg);
 	}
 
+	/* This should be a whois response. I only care about the first (311) one.  I might do
+	 * the other's later. They're boring.  */
+
+	if (((strstr(buf, " 311 ")) && (!strstr(buf, "PRIVMSG")) && (!strstr(buf, "NOTICE")))) {
+		char **res;
+
+		res = g_strsplit(buf, " ", 7);
+
+		if (!strcmp(res[1], "311"))
+		{
+			char buf[8192];
+
+			g_snprintf(buf, 4096, "<b>Nick:</b> %s<br>"
+					"<b>Host:</b> %s@%s<br>"
+					"<b>Name:</b> %s<br>", res[3], res[4], res[5], res[7]+1);
+
+			g_show_info_text(buf);
+		}
+
+		g_strfreev(res);
+	}
+
 	/* Parse the list of names that we receive when we first sign on to
 	 * a channel */
 
@@ -1166,6 +1188,24 @@
 	write(idata->fd, buf, strlen(buf));
 }
 
+/* Do a whois check on someone :-) */
+static void irc_get_info(struct gaim_connection *gc, char *who)
+{
+	struct irc_data *idata = (struct irc_data *)gc->proto_data;
+	char buf[BUF_LEN];
+
+	if ((who[0] == '@') || (who[0] == '+') && (strlen(who)>1))
+		g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who+1);
+	else
+		g_snprintf(buf, BUF_LEN, "WHOIS %s\n", who);
+	write(idata->fd, buf, strlen(buf));
+}
+
+static void irc_send_whois(GtkObject * w, char *who)
+{
+	struct gaim_connection *gc = (struct gaim_connection *)gtk_object_get_user_data(w);
+	irc_get_info(gc, who);
+}
 
 static void irc_buddy_menu(GtkWidget * menu, struct gaim_connection *gc, char *who)
 {
@@ -1176,6 +1216,12 @@
 	gtk_object_set_user_data(GTK_OBJECT(button), gc);
 	gtk_menu_append(GTK_MENU(menu), button);
 	gtk_widget_show(button);
+
+	button = gtk_menu_item_new_with_label("Whois");
+	gtk_signal_connect(GTK_OBJECT(button), "activate", GTK_SIGNAL_FUNC(irc_send_whois), who);
+	gtk_object_set_user_data(GTK_OBJECT(button), gc);
+	gtk_menu_append(GTK_MENU(menu), button);
+	gtk_widget_show(button);
 }
 
 
@@ -1194,6 +1240,7 @@
 	ret->join_chat = irc_join_chat;
 	ret->chat_leave = irc_chat_leave;
 	ret->chat_send = irc_chat_send;
+	ret->get_info = irc_get_info;
 
 	my_protocol = ret;
 }