summaryrefslogtreecommitdiff
path: root/src/plugins/irc
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-03-25 08:18:54 +0200
committerSébastien Helleu <flashcode@flashtux.org>2018-03-25 08:18:54 +0200
commit5793181ead97ca3de0e50c502bf0f74e873f3e7d (patch)
treef54735675374034e038b0c6daa706d0fee3885b6 /src/plugins/irc
parent1dff6613566e85a3e48d5ed53e78bac390ff1864 (diff)
downloadweechat-5793181ead97ca3de0e50c502bf0f74e873f3e7d.zip
irc: factorize code to set state of modelists in a channel
Diffstat (limited to 'src/plugins/irc')
-rw-r--r--src/plugins/irc/irc-channel.c16
-rw-r--r--src/plugins/irc/irc-channel.h2
-rw-r--r--src/plugins/irc/irc-protocol.c24
3 files changed, 24 insertions, 18 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index a89b8e38b..4b6534c5e 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -1370,6 +1370,22 @@ irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
}
/*
+ * Sets state for modelists in a channel.
+ */
+
+void
+irc_channel_modelist_set_state (struct t_irc_channel *channel, int state)
+{
+ struct t_irc_modelist *ptr_modelist;
+
+ for (ptr_modelist = channel->modelists; ptr_modelist;
+ ptr_modelist = ptr_modelist->next_modelist)
+ {
+ ptr_modelist->state = state;
+ }
+}
+
+/*
* Frees a channel and remove it from channels list.
*/
diff --git a/src/plugins/irc/irc-channel.h b/src/plugins/irc/irc-channel.h
index b0505434a..d078d1d33 100644
--- a/src/plugins/irc/irc-channel.h
+++ b/src/plugins/irc/irc-channel.h
@@ -161,6 +161,8 @@ extern int irc_channel_autorejoin_cb (const void *pointer, void *data,
extern void irc_channel_display_nick_back_in_pv (struct t_irc_server *server,
struct t_irc_nick *nick,
const char *nickname);
+extern void irc_channel_modelist_set_state (struct t_irc_channel *channel,
+ int state);
extern struct t_hdata *irc_channel_hdata_channel_cb (const void *pointer,
void *data,
const char *hdata_name);
diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c
index 5920fabc5..1633de1fe 100644
--- a/src/plugins/irc/irc-protocol.c
+++ b/src/plugins/irc/irc-protocol.c
@@ -948,7 +948,6 @@ IRC_PROTOCOL_CALLBACK(kick)
int rejoin;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick, *ptr_nick_kicked;
- struct t_irc_modelist *ptr_modelist;
IRC_PROTOCOL_MIN_ARGS(4);
IRC_PROTOCOL_CHECK_HOST;
@@ -1008,11 +1007,8 @@ IRC_PROTOCOL_CALLBACK(kick)
*/
irc_nick_free_all (server, ptr_channel);
- for (ptr_modelist = ptr_channel->modelists; ptr_modelist;
- ptr_modelist = ptr_modelist->next_modelist)
- {
- ptr_modelist->state = IRC_MODELIST_STATE_MODIFIED;
- }
+ irc_channel_modelist_set_state (ptr_channel,
+ IRC_MODELIST_STATE_MODIFIED);
/* read option "autorejoin" in server */
rejoin = IRC_SERVER_OPTION_BOOLEAN(server, IRC_SERVER_OPTION_AUTOREJOIN);
@@ -1074,7 +1070,6 @@ IRC_PROTOCOL_CALLBACK(kill)
char *pos_comment;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick, *ptr_nick_killed;
- struct t_irc_modelist *ptr_modelist;
IRC_PROTOCOL_MIN_ARGS(3);
IRC_PROTOCOL_CHECK_HOST;
@@ -1129,11 +1124,8 @@ IRC_PROTOCOL_CALLBACK(kill)
*/
irc_nick_free_all (server, ptr_channel);
- for (ptr_modelist = ptr_channel->modelists; ptr_modelist;
- ptr_modelist = ptr_modelist->next_modelist)
- {
- ptr_modelist->state = IRC_MODELIST_STATE_MODIFIED;
- }
+ irc_channel_modelist_set_state (ptr_channel,
+ IRC_MODELIST_STATE_MODIFIED);
irc_bar_item_update_channel ();
}
@@ -1676,7 +1668,6 @@ IRC_PROTOCOL_CALLBACK(part)
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
struct t_irc_channel_speaking *ptr_nick_speaking;
- struct t_irc_modelist *ptr_modelist;
IRC_PROTOCOL_MIN_ARGS(3);
IRC_PROTOCOL_CHECK_HOST;
@@ -1773,11 +1764,8 @@ IRC_PROTOCOL_CALLBACK(part)
{
irc_nick_free_all (server, ptr_channel);
- for (ptr_modelist = ptr_channel->modelists; ptr_modelist;
- ptr_modelist = ptr_modelist->next_modelist)
- {
- ptr_modelist->state = IRC_MODELIST_STATE_MODIFIED;
- }
+ irc_channel_modelist_set_state (ptr_channel,
+ IRC_MODELIST_STATE_MODIFIED);
/* cycling ? => rejoin channel immediately */
if (ptr_channel->cycle)