From d4184f78c5fa03dfff97a0bbb09429a1e2cd9fc2 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Thu, 22 Mar 2012 16:02:25 +0100 Subject: [PATCH] irc: do not send command "MODE #channel" on manual /names (do it only when names are received on join of channel) (bug #35930) --- ChangeLog | 4 +++- src/plugins/irc/irc-channel.c | 11 ++++++++--- src/plugins/irc/irc-channel.h | 1 + src/plugins/irc/irc-protocol.c | 24 ++++++++++++++++++++---- src/plugins/irc/irc-upgrade.c | 1 + 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5e36c2b37..4a3207fdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.3.8-dev, 2012-03-18 +v0.3.8-dev, 2012-03-21 Version 0.3.8 (under dev!) @@ -15,6 +15,8 @@ Version 0.3.8 (under dev!) (task #11316) * core: fix display of wide chars on last column of chat area (patch #7733) * api: add list "gui_buffer_last_displayed" in hdata "buffer" +* irc: do not send command "MODE #channel" on manual /names (do it only when + names are received on join of channel) (bug #35930) * irc: do not allow the creation of two servers with same name but different case (fix error when writing file irc.conf) (bug #35840) * irc: update away flag for nicks on manual /who diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index a45248885..626cd531c 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -264,6 +264,7 @@ irc_channel_new (struct t_irc_server *server, int channel_type, new_channel->modes = NULL; new_channel->limit = 0; new_channel->key = NULL; + new_channel->names_received = 0; new_channel->checking_away = 0; new_channel->away_message = NULL; new_channel->has_quit_server = 0; @@ -882,6 +883,7 @@ irc_channel_hdata_channel_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_irc_channel, modes, STRING, NULL); WEECHAT_HDATA_VAR(struct t_irc_channel, limit, INTEGER, NULL); WEECHAT_HDATA_VAR(struct t_irc_channel, key, STRING, NULL); + WEECHAT_HDATA_VAR(struct t_irc_channel, names_received, INTEGER, NULL); WEECHAT_HDATA_VAR(struct t_irc_channel, checking_away, INTEGER, NULL); WEECHAT_HDATA_VAR(struct t_irc_channel, away_message, STRING, NULL); WEECHAT_HDATA_VAR(struct t_irc_channel, has_quit_server, INTEGER, NULL); @@ -971,9 +973,7 @@ irc_channel_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_string (ptr_item, "key", channel->key)) return 0; - if (!weechat_infolist_new_var_string (ptr_item, "pv_remote_nick_color", channel->pv_remote_nick_color)) - return 0; - if (!weechat_infolist_new_var_integer (ptr_item, "nicks_count", channel->nicks_count)) + if (!weechat_infolist_new_var_integer (ptr_item, "names_received", channel->names_received)) return 0; if (!weechat_infolist_new_var_integer (ptr_item, "checking_away", channel->checking_away)) return 0; @@ -987,6 +987,10 @@ irc_channel_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_integer (ptr_item, "nick_completion_reset", channel->nick_completion_reset)) return 0; + if (!weechat_infolist_new_var_string (ptr_item, "pv_remote_nick_color", channel->pv_remote_nick_color)) + return 0; + if (!weechat_infolist_new_var_integer (ptr_item, "nicks_count", channel->nicks_count)) + return 0; for (i = 0; i < 2; i++) { if (channel->nicks_speaking[i]) @@ -1047,6 +1051,7 @@ irc_channel_print_log (struct t_irc_channel *channel) weechat_log_printf (" modes. . . . . . . . . . : '%s'", channel->modes); weechat_log_printf (" limit. . . . . . . . . . : %d", channel->limit); weechat_log_printf (" key. . . . . . . . . . . : '%s'", channel->key); + weechat_log_printf (" names_received . . . . . : %d", channel->names_received); weechat_log_printf (" checking_away. . . . . . : %d", channel->checking_away); weechat_log_printf (" away_message . . . . . . : '%s'", channel->away_message); weechat_log_printf (" has_quit_server. . . . . : %d", channel->has_quit_server); diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h index b85fcec35..99ec9aacc 100644 --- a/src/plugins/irc/irc-channel.h +++ b/src/plugins/irc/irc-channel.h @@ -47,6 +47,7 @@ struct t_irc_channel char *modes; /* channel modes */ int limit; /* user limit (0 is limit not set) */ char *key; /* channel key (NULL if no key set) */ + int names_received; /* names received (message 366) */ int checking_away; /* = 1 if checking away with WHO cmd */ char *away_message; /* to display away only once in pv */ int has_quit_server; /* =1 if nick has quit (pv only), to */ diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index 4876304b4..943415852 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -557,9 +557,19 @@ IRC_PROTOCOL_CALLBACK(join) } } - /* remove topic if joining new channel */ + /* reset some variables if joining new channel */ if (!ptr_channel->nicks) + { irc_channel_set_topic (ptr_channel, NULL); + if (ptr_channel->modes) + { + free (ptr_channel->modes); + ptr_channel->modes = NULL; + } + ptr_channel->limit = 0; + ptr_channel->names_received = 0; + ptr_channel->checking_away = 0; + } /* add nick in channel */ ptr_nick = irc_nick_new (server, ptr_channel, nick, NULL, 0); @@ -3929,9 +3939,12 @@ IRC_PROTOCOL_CALLBACK(366) NG_("normal", "normals", num_normal), IRC_COLOR_CHAT_DELIMITERS); - irc_command_mode_server (server, ptr_channel, NULL, - IRC_SERVER_SEND_OUTQ_PRIO_LOW); - irc_channel_check_away (server, ptr_channel); + if (!ptr_channel->names_received) + { + irc_command_mode_server (server, ptr_channel, NULL, + IRC_SERVER_SEND_OUTQ_PRIO_LOW); + irc_channel_check_away (server, ptr_channel); + } } else { @@ -3947,6 +3960,9 @@ IRC_PROTOCOL_CALLBACK(366) (argv[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]); } + if (ptr_channel) + ptr_channel->names_received = 1; + return WEECHAT_RC_OK; } diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index fe2ef7540..37e59915e 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -416,6 +416,7 @@ irc_upgrade_read_cb (void *data, str = weechat_infolist_string (infolist, "key"); if (str) irc_upgrade_current_channel->key = strdup (str); + irc_upgrade_current_channel->names_received = weechat_infolist_integer (infolist, "names_received"); irc_upgrade_current_channel->checking_away = weechat_infolist_integer (infolist, "checking_away"); str = weechat_infolist_string (infolist, "away_message"); if (str)