summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-10-21 11:08:49 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-10-21 11:08:49 +0000
commit06c431bcd784ec9f30e39d3ddece269bfa3da63a (patch)
tree8c8e59bf8d1a36c37ce76118452f0f353134131b /src
parente5c9dc37dc126c16cd51fcc4a43d8636164636c1 (diff)
downloadirssi-06c431bcd784ec9f30e39d3ddece269bfa3da63a.zip
Don't autojoin channels that have already been joined in some other server
connection in same chat network. This has mostly been just annoying, and this enables us to add eg. 20 channels autojoinable, then create 2 server connections and irssi will automatically join the first 10 in first connection and 10 other in the later (well, or at least if the 10 later channels get "not enough channels" message from server before the connection is finished, which well might not happen .. problem :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1875 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/core/channels.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/core/channels.c b/src/core/channels.c
index 6a0a315e..a464b1fb 100644
--- a/src/core/channels.c
+++ b/src/core/channels.c
@@ -114,17 +114,47 @@ CHANNEL_REC *channel_find(SERVER_REC *server, const char *name)
(void *) name);
}
+static CHANNEL_REC *channel_find_servers(GSList *servers, const char *name)
+{
+ return gslist_foreach_find(servers,
+ (FOREACH_FIND_FUNC) channel_find_server,
+ (void *) name);
+}
+
+static GSList *servers_find_chatnet_except(SERVER_REC *server)
+{
+ GSList *tmp, *list;
+
+ list = NULL;
+ for (tmp = servers; tmp != NULL; tmp = tmp->next) {
+ SERVER_REC *rec = tmp->data;
+
+ if (server != rec && rec->connrec->chatnet != NULL &&
+ strcmp(server->connrec->chatnet,
+ rec->connrec->chatnet) == 0) {
+ /* chatnets match */
+ list = g_slist_append(list, rec);
+ }
+ }
+
+ return list;
+}
+
/* connected to server, autojoin to channels. */
static void event_connected(SERVER_REC *server)
{
GString *chans;
- GSList *tmp;
+ GSList *tmp, *chatnet_servers;
g_return_if_fail(SERVER(server));
if (server->connrec->reconnection)
return;
+ /* get list of servers in same chat network */
+ chatnet_servers = server->connrec->chatnet == NULL ? NULL:
+ servers_find_chatnet_except(server);
+
/* join to the channels marked with autojoin in setup */
chans = g_string_new(NULL);
for (tmp = setupchannels; tmp != NULL; tmp = tmp->next) {
@@ -135,7 +165,10 @@ static void event_connected(SERVER_REC *server)
server->connrec->chatnet))
continue;
- g_string_sprintfa(chans, "%s,", rec->name);
+ /* check that we haven't already joined this channel in
+ same chat network connection.. */
+ if (channel_find_servers(servers, rec->name) == NULL)
+ g_string_sprintfa(chans, "%s,", rec->name);
}
if (chans->len > 0) {