diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-11-07 20:52:47 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-11-07 20:52:47 +0100 |
commit | 5ce1a3e867e0ea8c2fd4787aa45cc0aaeeb5b170 (patch) | |
tree | 7bb578dc28ab5cda8a1a4624fff2fb7a3fc1b86f /src/plugins | |
parent | 9b37ae8e3d3e4991c15447baace382618354e5ff (diff) | |
download | weechat-5ce1a3e867e0ea8c2fd4787aa45cc0aaeeb5b170.zip |
irc: fix groups in channel nicklist when reconnecting to a server that supports more nick prefixes than the previously connected server
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-channel.c | 50 | ||||
-rw-r--r-- | src/plugins/irc/irc-channel.h | 2 | ||||
-rw-r--r-- | src/plugins/irc/irc-nick.c | 6 |
3 files changed, 39 insertions, 19 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c index 302ca69a6..a3f9626ae 100644 --- a/src/plugins/irc/irc-channel.c +++ b/src/plugins/irc/irc-channel.c @@ -152,10 +152,9 @@ irc_channel_new (struct t_irc_server *server, int channel_type, { struct t_irc_channel *new_channel; struct t_gui_buffer *new_buffer, *ptr_buffer_for_merge; - int i, buffer_created, current_buffer_number, buffer_position, manual_join; + int buffer_created, current_buffer_number, buffer_position, manual_join; int noswitch; - char *buffer_name, str_number[32], str_group[32], *channel_name_lower; - const char *prefix_modes; + char *buffer_name, str_number[32], *channel_name_lower; /* alloc memory for new channel */ if ((new_channel = malloc (sizeof (*new_channel))) == NULL) @@ -262,22 +261,6 @@ irc_channel_new (struct t_irc_server *server, int channel_type, } } - if (channel_type == IRC_CHANNEL_TYPE_CHANNEL) - { - prefix_modes = irc_server_get_prefix_modes (server); - for (i = 0; prefix_modes[i]; i++) - { - snprintf (str_group, sizeof (str_group), "%03d|%c", - i, prefix_modes[i]); - weechat_nicklist_add_group (new_buffer, NULL, str_group, - "weechat.color.nicklist_group", 1); - } - snprintf (str_group, sizeof (str_group), "%03d|%s", - IRC_NICK_GROUP_OTHER_NUMBER, IRC_NICK_GROUP_OTHER_NAME); - weechat_nicklist_add_group (new_buffer, NULL, str_group, - "weechat.color.nicklist_group", 1); - } - /* initialize new channel */ new_channel->type = channel_type; new_channel->name = strdup (channel_name); @@ -376,6 +359,35 @@ irc_channel_new (struct t_irc_server *server, int channel_type, } /* + * Add groups in nicklist for a channel. + */ + +void +irc_channel_add_nicklist_groups (struct t_irc_server *server, + struct t_irc_channel *channel) +{ + const char *prefix_modes; + char str_group[32]; + int i; + + if (channel->type != IRC_CHANNEL_TYPE_CHANNEL) + return; + + prefix_modes = irc_server_get_prefix_modes (server); + for (i = 0; prefix_modes[i]; i++) + { + snprintf (str_group, sizeof (str_group), "%03d|%c", + i, prefix_modes[i]); + weechat_nicklist_add_group (channel->buffer, NULL, str_group, + "weechat.color.nicklist_group", 1); + } + snprintf (str_group, sizeof (str_group), "%03d|%s", + IRC_NICK_GROUP_OTHER_NUMBER, IRC_NICK_GROUP_OTHER_NAME); + weechat_nicklist_add_group (channel->buffer, NULL, str_group, + "weechat.color.nicklist_group", 1); +} + +/* * Sets topic for a channel. */ diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h index 24465be5b..2e7ff5514 100644 --- a/src/plugins/irc/irc-channel.h +++ b/src/plugins/irc/irc-channel.h @@ -83,6 +83,8 @@ extern struct t_irc_channel *irc_channel_new (struct t_irc_server *server, const char *channel_name, int switch_to_channel, int auto_switch); +extern void irc_channel_add_nicklist_groups (struct t_irc_server *server, + struct t_irc_channel *channel); extern void irc_channel_set_topic (struct t_irc_channel *channel, const char *topic); extern void irc_channel_set_modes (struct t_irc_channel *channel, diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 729f381d7..4146775a7 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -632,6 +632,9 @@ irc_nick_new (struct t_irc_server *server, struct t_irc_channel *channel, if (!nickname || !nickname[0]) return NULL; + if (!channel->nicks) + irc_channel_add_nicklist_groups (server, channel); + /* nick already exists on this channel? */ ptr_nick = irc_nick_search (server, channel, nickname); if (ptr_nick) @@ -821,6 +824,9 @@ irc_nick_free_all (struct t_irc_server *server, struct t_irc_channel *channel) irc_nick_free (server, channel, channel->nicks); } + /* remove all groups in nicklist */ + weechat_nicklist_remove_all (channel->buffer); + /* should be zero, but prevent any bug :D */ channel->nicks_count = 0; } |