changeset 15455:79f25bbe69bf

This makes IRC /names handling generally more robust, as well as properly dealing with the case where the user runs /quote names #chan and we don't know about it. I thought things were already handled in this fashion, but obviously they were not.
author Ethan Blanton <elb@pidgin.im>
date Sun, 28 Jan 2007 21:48:58 +0000
parents c68f2808f703
children f217a2d656c8
files libpurple/protocols/irc/cmds.c libpurple/protocols/irc/irc.h libpurple/protocols/irc/msgs.c
diffstat 3 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/irc/cmds.c	Sun Jan 28 21:40:32 2007 +0000
+++ b/libpurple/protocols/irc/cmds.c	Sun Jan 28 21:48:58 2007 +0000
@@ -245,8 +245,6 @@
 	irc_send(irc, buf);
 	g_free(buf);
 
-	irc->nameconv = g_strdup(target);
-
 	return 0;
 }
 
--- a/libpurple/protocols/irc/irc.h	Sun Jan 28 21:40:32 2007 +0000
+++ b/libpurple/protocols/irc/irc.h	Sun Jan 28 21:48:58 2007 +0000
@@ -41,6 +41,8 @@
 
 #define IRC_INITIAL_BUFSIZE 1024
 
+#define IRC_NAMES_FLAG "irc-namelist"
+
 
 enum { IRC_USEROPT_SERVER, IRC_USEROPT_PORT, IRC_USEROPT_CHARSET };
 enum irc_state { IRC_STATE_NEW, IRC_STATE_ESTABLISHED };
@@ -60,7 +62,6 @@
 
 	GString *motd;
 	GString *names;
-	char *nameconv;
 	struct _whois {
 		char *nick;
 		char *away;
--- a/libpurple/protocols/irc/msgs.c	Sun Jan 28 21:40:32 2007 +0000
+++ b/libpurple/protocols/irc/msgs.c	Sun Jan 28 21:48:58 2007 +0000
@@ -442,27 +442,23 @@
 	GaimConversation *convo;
 
 	if (!strcmp(name, "366")) {
-		convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, irc->nameconv ? irc->nameconv : args[1], irc->account);
+		convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, args[1], irc->account);
 		if (!convo) {
 			gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]);
 			g_string_free(irc->names, TRUE);
 			irc->names = NULL;
-			g_free(irc->nameconv);
-			irc->nameconv = NULL;
 			return;
 		}
 
 		names = cur = g_string_free(irc->names, FALSE);
 		irc->names = NULL;
-		if (irc->nameconv) {
+		if (gaim_conversation_get_data(convo, IRC_NAMES_FLAG)) {
 			msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : "");
 			if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT)
 				gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
 			else
 				gaim_conv_im_write(GAIM_CONV_IM(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL));
 			g_free(msg);
-			g_free(irc->nameconv);
-			irc->nameconv = NULL;
 		} else {
 			GList *users = NULL;
 			GList *flags = NULL;
@@ -504,6 +500,9 @@
 				g_list_free(users);
 				g_list_free(flags);
 			}
+
+			gaim_conversation_set_data(convo, IRC_NAMES_FLAG,
+						   GINT_TO_POINTER(TRUE));
 		}
 		g_free(names);
 	} else {
@@ -723,10 +722,13 @@
 		convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
 							    args[0],
 							    irc->account);
+
 		if (convo == NULL) {
 			gaim_debug_error("irc", "tried to join %s but couldn't\n", args[0]);
 			return;
 		}
+		gaim_conversation_set_data(convo, IRC_NAMES_FLAG,
+					   GINT_TO_POINTER(FALSE));
 		gaim_conversation_present(convo);
 		return;
 	}