diff options
author | LemonBoy <thatlemon@gmail.com> | 2015-09-19 23:58:16 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2015-09-19 23:58:16 +0200 |
commit | 06040fb30bc0503696794ff6097cd55eff332bb5 (patch) | |
tree | ecf64cc55aa80e219f8456a0e4b14f24fc3a2770 /src/irc/core/irc-servers.c | |
parent | 24d32c28ee2d5dbd001cbe29fa5d90077c6be107 (diff) | |
parent | 9586766d87820bdfa9e7cbe805f5ed4b7b0378e5 (diff) | |
download | irssi-06040fb30bc0503696794ff6097cd55eff332bb5.zip |
Merge remote-tracking branch 'origin' into sasl
Diffstat (limited to 'src/irc/core/irc-servers.c')
-rw-r--r-- | src/irc/core/irc-servers.c | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index ad4d09cc..82584382 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -34,6 +34,8 @@ #include "irc-servers.h" #include "irc-cap.h" #include "sasl.h" + +#include "channels-setup.h" #include "channel-rejoin.h" #include "servers-idle.h" #include "servers-reconnect.h" @@ -73,13 +75,20 @@ static int isnickflag_func(SERVER_REC *server, char flag) static int ischannel_func(SERVER_REC *server, const char *data) { - if (*data == '@') { - /* @#channel, @+#channel */ + IRC_SERVER_REC *irc_server = (IRC_SERVER_REC *) server; + char *chantypes, *statusmsg; + + chantypes = g_hash_table_lookup(irc_server->isupport, "chantypes"); + if (chantypes == NULL) + chantypes = "#&!+"; /* normal, local, secure, modeless */ + statusmsg = g_hash_table_lookup(irc_server->isupport, "statusmsg"); + if (statusmsg == NULL) + statusmsg = "@+"; + + while (strchr(statusmsg, *data) != NULL) data++; - if (*data == '+' && ischannel(data[1])) - return 1; - } - return ischannel(*data); + + return strchr(chantypes, *data) != NULL; } static char **split_line(const SERVER_REC *server, const char *line, @@ -606,32 +615,59 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) GString *chans, *keys; char *ret; int use_keys; + char *rejoin_channels_mode; g_return_val_if_fail(server != NULL, FALSE); + rejoin_channels_mode = g_strdup(settings_get_str("rejoin_channels_on_reconnect")); + + if (rejoin_channels_mode == NULL || + (g_ascii_strcasecmp(rejoin_channels_mode, "on") != 0 && + g_ascii_strcasecmp(rejoin_channels_mode, "off") != 0 && + g_ascii_strcasecmp(rejoin_channels_mode, "auto") != 0)) { + g_warning("Invalid value for 'rejoin_channels_on_reconnect', valid values are 'on', 'off', 'auto', using 'on' as default value."); + g_free(rejoin_channels_mode); + rejoin_channels_mode = g_strdup("on"); + } + chans = g_string_new(NULL); keys = g_string_new(NULL); use_keys = FALSE; + /* do we want to rejoin channels in the first place? */ + if(g_ascii_strcasecmp(rejoin_channels_mode, "off") == 0) { + g_string_free(chans, TRUE); + g_string_free(keys, TRUE); + g_free(rejoin_channels_mode); + return g_strdup(""); + } + /* get currently joined channels */ for (tmp = server->channels; tmp != NULL; tmp = tmp->next) { CHANNEL_REC *channel = tmp->data; - - g_string_append_printf(chans, "%s,", channel->name); - g_string_append_printf(keys, "%s,", channel->key == NULL ? "x" : - channel->key); - if (channel->key != NULL) - use_keys = TRUE; + CHANNEL_SETUP_REC *setup = channel_setup_find(channel->name, channel->server->connrec->chatnet); + if ((setup != NULL && setup->autojoin && g_ascii_strcasecmp(rejoin_channels_mode, "auto") == 0) || + g_ascii_strcasecmp(rejoin_channels_mode, "on") == 0) { + g_string_append_printf(chans, "%s,", channel->name); + g_string_append_printf(keys, "%s,", channel->key == NULL ? "x" : channel->key); + if (channel->key != NULL) + use_keys = TRUE; + } } /* get also the channels that are in rejoin list */ for (tmp = server->rejoin_channels; tmp != NULL; tmp = tmp->next) { REJOIN_REC *rec = tmp->data; + CHANNEL_SETUP_REC *setup = channel_setup_find(rec->channel, server->tag); + + if ((setup != NULL && setup->autojoin && g_ascii_strcasecmp(rejoin_channels_mode, "auto") == 0) || + g_ascii_strcasecmp(rejoin_channels_mode, "on") == 0) { + g_string_append_printf(chans, "%s,", rec->channel); + g_string_append_printf(keys, "%s,", rec->key == NULL ? "x" : + rec->key); - g_string_append_printf(chans, "%s,", rec->channel); - g_string_append_printf(keys, "%s,", rec->key == NULL ? "x" : - rec->key); - if (rec->key != NULL) use_keys = TRUE; + if (rec->key != NULL) use_keys = TRUE; + } } if (chans->len > 0) { @@ -643,6 +679,7 @@ char *irc_server_get_channels(IRC_SERVER_REC *server) ret = chans->str; g_string_free(chans, FALSE); g_string_free(keys, TRUE); + g_free(rejoin_channels_mode); return ret; } @@ -988,6 +1025,7 @@ void irc_server_init_isupport(IRC_SERVER_REC *server) void irc_servers_init(void) { + settings_add_str("servers", "rejoin_channels_on_reconnect", "on"); settings_add_str("misc", "usermode", DEFAULT_USER_MODE); settings_add_str("misc", "split_line_start", ""); settings_add_str("misc", "split_line_end", ""); |