changeset 8114:7a6e30eb7aad

[gaim-migrate @ 8818] Thanks to Tim Ringenbach for this IRC chat list. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Thu, 15 Jan 2004 22:53:07 +0000
parents d60272410bd5
children 2a9e8ba61ec7
files plugins/tcl/tcl_glib.c src/protocols/irc/cmds.c src/protocols/irc/irc.c src/protocols/irc/irc.h src/protocols/irc/msgs.c src/protocols/irc/parse.c
diffstat 6 files changed, 106 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/tcl/tcl_glib.c	Thu Jan 15 22:20:29 2004 +0000
+++ b/plugins/tcl/tcl_glib.c	Thu Jan 15 22:53:07 2004 +0000
@@ -74,6 +74,7 @@
 
 ClientData Tcl_InitNotifier()
 {
+	Tcl_SetServiceMode(TCL_SERVICE_ALL);
 	return NULL;
 }
 
@@ -89,7 +90,6 @@
 	notifier.waitForEventProc = tcl_wait_for_event;
 
 	Tcl_SetNotifier(&notifier);
-	Tcl_SetServiceMode(TCL_SERVICE_ALL);
 
 	tcl_timer_pending = FALSE;
 	tcl_file_handlers = g_hash_table_new(g_direct_hash, g_direct_equal);
--- a/src/protocols/irc/cmds.c	Thu Jan 15 22:20:29 2004 +0000
+++ b/src/protocols/irc/cmds.c	Thu Jan 15 22:53:07 2004 +0000
@@ -204,6 +204,17 @@
 	return 0;
 }
 
+int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
+{
+	char *buf;
+
+	buf = irc_format(irc, "v", "LIST");
+	irc_send(irc, buf);
+	g_free(buf);
+
+	return 0;
+}
+
 int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args)
 {
 	GaimConnection *gc;
--- a/src/protocols/irc/irc.c	Thu Jan 15 22:20:29 2004 +0000
+++ b/src/protocols/irc/irc.c	Thu Jan 15 22:53:07 2004 +0000
@@ -465,6 +465,53 @@
 	g_free(ib);
 }
 
+static GaimRoomlist *irc_roomlist_get_list(GaimConnection *gc)
+{
+	struct irc_conn *irc;
+	GList *fields = NULL;
+	GaimRoomlistField *f;
+
+	irc = gc->proto_data;
+
+	if (irc->roomlist)
+		gaim_roomlist_unref(irc->roomlist);
+
+	irc->roomlist = gaim_roomlist_new(gaim_connection_get_account(gc));
+
+	f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "channel", TRUE);
+	fields = g_list_append(fields, f);
+
+	f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE);
+	fields = g_list_append(fields, f);
+
+	f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE);
+	fields = g_list_append(fields, f);
+
+	gaim_roomlist_set_fields(irc->roomlist, fields);
+
+	irc_cmd_list(irc, "LIST", NULL, NULL);
+
+	return irc->roomlist;
+}
+
+static void irc_roomlist_cancel(GaimRoomlist *list)
+{
+	GaimConnection *gc = gaim_account_get_connection(list->account);
+	struct irc_conn *irc;
+
+	if (gc == NULL)
+		return;
+
+	irc = gc->proto_data;
+
+	gaim_roomlist_set_in_progress(list, FALSE);
+
+	if (irc->roomlist == list) {
+		irc->roomlist = NULL;
+		gaim_roomlist_unref(list);
+	}
+}
+
 static GaimPluginProtocolInfo prpl_info =
 {
 	OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL,
@@ -515,9 +562,18 @@
 	NULL,
 	NULL,
 	NULL, /*irc_convo_closed,*/
+	NULL, /* normalize */
+	NULL, /* set buddy icon */
+	NULL, /* remove group */
+	NULL, /* get_cb_real_name */
+	NULL,
+	NULL,
+	irc_roomlist_get_list,
+	irc_roomlist_cancel,
 	NULL
 };
 
+
 static GaimPluginInfo info =
 {
 	2,                                                /**< api_version    */
--- a/src/protocols/irc/irc.h	Thu Jan 15 22:20:29 2004 +0000
+++ b/src/protocols/irc/irc.h	Thu Jan 15 22:53:07 2004 +0000
@@ -26,6 +26,7 @@
 #include <glib.h>
 
 #include "multi.h"
+#include "roomlist.h"
 
 #define IRC_DEFAULT_SERVER "irc.freenode.net"
 #define IRC_DEFAULT_PORT 6667
@@ -67,6 +68,7 @@
 		int idle;
 		time_t signon;
 	} whois;
+	GaimRoomlist *roomlist;
 };
 
 struct irc_buddy {
@@ -100,6 +102,7 @@
 void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args);
+void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args);
 void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args);
@@ -134,6 +137,7 @@
 int irc_cmd_invite(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_join(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_kick(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
+int irc_cmd_list(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_mode(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_names(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
 int irc_cmd_nick(struct irc_conn *irc, const char *cmd, const char *target, const char **args);
--- a/src/protocols/irc/msgs.c	Thu Jan 15 22:20:29 2004 +0000
+++ b/src/protocols/irc/msgs.c	Thu Jan 15 22:53:07 2004 +0000
@@ -223,6 +223,36 @@
 	memset(&irc->whois, 0, sizeof(irc->whois));
 }
 
+void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args)
+{
+	if (!irc->roomlist)
+		return;
+
+	if (!strcmp(name, "321")) {
+		gaim_roomlist_set_in_progress(irc->roomlist, TRUE);
+		return;
+	}
+
+	if (!strcmp(name, "323")) {
+		gaim_roomlist_set_in_progress(irc->roomlist, FALSE);
+		gaim_roomlist_unref(irc->roomlist);
+		irc->roomlist = NULL;
+	}
+
+	if (!strcmp(name, "322")) {
+		GaimRoomlistRoom *room;
+
+		if (!args[0] || !args[1] || !args[2] || !args[3])
+			return;
+
+		room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL);
+		gaim_roomlist_room_add_field(irc->roomlist, room, args[1]);
+		gaim_roomlist_room_add_field(irc->roomlist, room, GINT_TO_POINTER(strtol(args[2], NULL, 10)));
+		gaim_roomlist_room_add_field(irc->roomlist, room, args[3]);
+		gaim_roomlist_room_add(irc->roomlist, room);
+	}
+}
+
 void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args)
 {
 	char *chan, *topic, *msg, *nick;
--- a/src/protocols/irc/parse.c	Thu Jan 15 22:20:29 2004 +0000
+++ b/src/protocols/irc/parse.c	Thu Jan 15 22:53:07 2004 +0000
@@ -59,6 +59,9 @@
 	{ "318", "nt:", irc_msg_endwhois },	/* End of WHOIS			*/
 	{ "319", "nn:", irc_msg_whois },	/* Whois channels		*/
 	{ "320", "nn:", irc_msg_whois },	/* Whois (fn ident)		*/
+	{ "321", "*", irc_msg_list },		/* Start of list		*/
+	{ "322", "ncv:", irc_msg_list },	/* List.			*/
+	{ "323", ":", irc_msg_list },		/* End of list.			*/
 	{ "324", "ncv:", irc_msg_chanmode },	/* Channel modes		*/
 	{ "331", "nc:",	irc_msg_topic },	/* No channel topic		*/
 	{ "332", "nc:", irc_msg_topic },	/* Channel topic		*/
@@ -110,6 +113,7 @@
 	{ "j", "cv", irc_cmd_join },
 	{ "join", "cv", irc_cmd_join },
 	{ "kick", "n:", irc_cmd_kick },
+	{ "list", ":", irc_cmd_list },
 	{ "me", ":", irc_cmd_ctcp_action },
 	{ "mode", ":", irc_cmd_mode },
 	{ "msg", "t:", irc_cmd_privmsg },