diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-09-11 21:41:47 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-09-11 21:41:47 +0200 |
commit | ddd859886e629d01cfa6b3b9b652db00e7dd51a5 (patch) | |
tree | 7c420b84b184cf32ac74fbd0007c7dedb0789c1a /src/plugins | |
parent | ae50f6688e848d0f75fe54f73aaf19d70c7e7bdb (diff) | |
download | weechat-ddd859886e629d01cfa6b3b9b652db00e7dd51a5.zip |
irc: fix autojoin of channels when private buffers are opened (closes #2012)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/irc/irc-server.c | 25 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 1 |
2 files changed, 23 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index ed2dcf610..4ec8a856c 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1620,6 +1620,25 @@ irc_server_buffer_set_input_multiline (struct t_irc_server *server, } /* + * Checks if a server has channels opened. + */ + +int +irc_server_has_channels (struct t_irc_server *server) +{ + struct t_irc_channel *ptr_channel; + + for (ptr_channel = server->channels; ptr_channel; + ptr_channel = ptr_channel->next_channel) + { + if (ptr_channel->type == IRC_CHANNEL_TYPE_CHANNEL) + return 1; + } + + return 0; +} + +/* * Allocates a new server and adds it to the servers queue. * * Returns pointer to new server, NULL if error. @@ -5841,7 +5860,7 @@ irc_server_autojoin_create_buffers (struct t_irc_server *server) * buffers are opened only if auto-join was not already done * and if no channels are currently opened */ - if (server->autojoin_done || server->channels) + if (server->autojoin_done || irc_server_has_channels (server)) return; /* evaluate server option "autojoin" */ @@ -6002,7 +6021,7 @@ irc_server_autojoin_channels (struct t_irc_server *server) return; } - if (!server->autojoin_done && !server->channels) + if (!server->autojoin_done && !irc_server_has_channels (server)) { /* auto-join when connecting to server for first time */ autojoin = irc_server_eval_expression ( @@ -6016,7 +6035,7 @@ irc_server_autojoin_channels (struct t_irc_server *server) if (autojoin) free (autojoin); } - else if (server->channels) + else if (irc_server_has_channels (server)) { /* auto-join after disconnection (only rejoins opened channels) */ autojoin = irc_server_build_autojoin (server); diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index cd2637ccf..e779aee36 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -397,6 +397,7 @@ extern char *irc_server_get_default_msg (const char *default_msg, const char *target_nick); extern void irc_server_buffer_set_input_multiline (struct t_irc_server *server, int multiline); +extern int irc_server_has_channels (struct t_irc_server *server); extern struct t_irc_server *irc_server_alloc (const char *name); extern struct t_irc_server *irc_server_alloc_with_url (const char *irc_url); extern void irc_server_apply_command_line_options (struct t_irc_server *server, |