diff options
author | Timo Sirainen <cras@irssi.org> | 2000-07-02 16:19:26 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2000-07-02 16:19:26 +0000 |
commit | bb76eec0ffc836eaaccd35c2979fc092f1a9c520 (patch) | |
tree | 66b8de0e26e86b419d76729cb86ab50a2324883d /src/fe-common/irc/fe-netsplit.c | |
parent | cf7d6915f5cfff985cee06643644e1f176a0d28d (diff) | |
download | irssi-bb76eec0ffc836eaaccd35c2979fc092f1a9c520.zip |
When netsplit is over, irssi prints "Netsplit over, joins: (nicks)" and
hides all the real JOIN messages. Fixed also some netsplit bugs.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@414 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/irc/fe-netsplit.c')
-rw-r--r-- | src/fe-common/irc/fe-netsplit.c | 68 |
1 files changed, 52 insertions, 16 deletions
diff --git a/src/fe-common/irc/fe-netsplit.c b/src/fe-common/irc/fe-netsplit.c index 1992ec14..9411b2e9 100644 --- a/src/fe-common/irc/fe-netsplit.c +++ b/src/fe-common/irc/fe-netsplit.c @@ -25,6 +25,7 @@ #include "levels.h" #include "settings.h" +#include "irc.h" #include "irc-server.h" #include "ignore.h" #include "netsplit.h" @@ -57,7 +58,7 @@ typedef struct { typedef struct { IRC_SERVER_REC *server_rec; - NETSPLIT_SERVER_REC *server; + GSList *servers; /* if many servers splitted from the same one */ GSList *channels; } TEMP_SPLIT_REC; @@ -80,7 +81,7 @@ static void get_server_splits(void *key, NETSPLIT_REC *split, TEMP_SPLIT_REC *re TEMP_SPLIT_CHAN_REC *chanrec; GSList *tmp; - if (split->printed || split->server != rec->server) + if (split->printed || g_slist_find(rec->servers, split->server) == NULL) return; split->printed = TRUE; @@ -100,6 +101,7 @@ static void get_server_splits(void *key, NETSPLIT_REC *split, TEMP_SPLIT_REC *re rec->channels = g_slist_append(rec->channels, chanrec); } + split->server->prints++; chanrec->nick_count++; if (netsplit_max_nicks <= 0 || chanrec->nick_count < netsplit_max_nicks) { @@ -111,8 +113,25 @@ static void get_server_splits(void *key, NETSPLIT_REC *split, TEMP_SPLIT_REC *re static void print_splits(IRC_SERVER_REC *server, TEMP_SPLIT_REC *rec) { + GString *destservers; + char *sourceserver; GSList *tmp; + destservers = g_string_new(NULL); + for (tmp = rec->servers; tmp != NULL; tmp = tmp->next) { + NETSPLIT_SERVER_REC *rec = tmp->data; + + if (rec->prints > 0) + g_string_sprintfa(destservers, "%s, ", rec->destserver); + } + if (destservers->len == 0) { + /* no nicks to print in this server */ + g_string_free(destservers, TRUE); + return; + } + g_string_truncate(destservers, destservers->len-2); + + sourceserver = ((NETSPLIT_SERVER_REC *) (rec->servers->data))->server; for (tmp = rec->channels; tmp != NULL; tmp = tmp->next) { TEMP_SPLIT_CHAN_REC *chan = tmp->data; @@ -120,13 +139,15 @@ static void print_splits(IRC_SERVER_REC *server, TEMP_SPLIT_REC *rec) if (netsplit_max_nicks > 0 && chan->nick_count > netsplit_max_nicks) { printformat(server, chan->name, MSGLEVEL_QUITS, IRCTXT_NETSPLIT_MORE, - rec->server->server, rec->server->destserver, chan->nicks->str, + sourceserver, destservers->str, chan->nicks->str, chan->nick_count - netsplit_max_nicks); } else { printformat(server, chan->name, MSGLEVEL_QUITS, IRCTXT_NETSPLIT, - rec->server->server, rec->server->destserver, chan->nicks->str); + sourceserver, destservers->str, chan->nicks->str); } } + + g_string_free(destservers, TRUE); } static void temp_split_chan_free(TEMP_SPLIT_CHAN_REC *rec) @@ -137,26 +158,41 @@ static void temp_split_chan_free(TEMP_SPLIT_CHAN_REC *rec) static int check_server_splits(IRC_SERVER_REC *server) { - TEMP_SPLIT_REC rec; - GSList *tmp; + TEMP_SPLIT_REC temp; + GSList *tmp, *next, *servers; time_t last; last = get_last_split(server); - if (last+SPLIT_WAIT_TIME >= time(NULL)) + if (time(NULL)-last < SPLIT_WAIT_TIME) return FALSE; - for (tmp = server->split_servers; tmp != NULL; tmp = tmp->next) { - NETSPLIT_SERVER_REC *sserver = tmp->data; + servers = g_slist_copy(server->split_servers); + while (servers != NULL) { + NETSPLIT_SERVER_REC *sserver = servers->data; + + /* get all the splitted servers that have the same + source server */ + temp.servers = NULL; + for (tmp = servers; tmp != NULL; tmp = next) { + NETSPLIT_SERVER_REC *rec = tmp->data; + + next = tmp->next; + if (g_strcasecmp(rec->server, sserver->server) == 0) { + rec->prints = 0; + temp.servers = g_slist_append(temp.servers, rec); + servers = g_slist_remove(servers, rec); + } + } - rec.server_rec = server; - rec.server = sserver; - rec.channels = NULL; + temp.server_rec = server; + temp.channels = NULL; - g_hash_table_foreach(server->splits, (GHFunc) get_server_splits, &rec); - print_splits(server, &rec); + g_hash_table_foreach(server->splits, (GHFunc) get_server_splits, &temp); + print_splits(server, &temp); - g_slist_foreach(rec.channels, (GFunc) temp_split_chan_free, NULL); - g_slist_free(rec.channels); + g_slist_foreach(temp.channels, (GFunc) temp_split_chan_free, NULL); + g_slist_free(temp.servers); + g_slist_free(temp.channels); } return TRUE; |