# HG changeset patch # User Ethan Blanton # Date 1170020938 0 # Node ID 79f25bbe69bffcd9c9516614154369a890077e6e # Parent c68f2808f703796b42f67145d99bd5a263be7703 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. diff -r c68f2808f703 -r 79f25bbe69bf libpurple/protocols/irc/cmds.c --- 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; } diff -r c68f2808f703 -r 79f25bbe69bf libpurple/protocols/irc/irc.h --- 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; diff -r c68f2808f703 -r 79f25bbe69bf libpurple/protocols/irc/msgs.c --- 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; }