diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2016-10-11 16:12:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-11 16:12:35 +0200 |
commit | 61590f31df3c93d04b056fd89c6632f9d89feb51 (patch) | |
tree | 04a8b95a8ab8ce58fe876a73e60c8a4184c42fca /src/fe-common | |
parent | 0fce47a5ad29a31400b01a80be45aa6da9d221b3 (diff) | |
parent | c0f66c95ff00bdc22155a8ac53d887a9c1bbc90f (diff) | |
download | irssi-61590f31df3c93d04b056fd89c6632f9d89feb51.zip |
Merge pull request #465 from LemonBoy/netsplit-print
Some small adjustments to the netsplit code.
Diffstat (limited to 'src/fe-common')
-rw-r--r-- | src/fe-common/irc/fe-netjoin.c | 43 | ||||
-rw-r--r-- | src/fe-common/irc/fe-netsplit.c | 31 |
2 files changed, 47 insertions, 27 deletions
diff --git a/src/fe-common/irc/fe-netjoin.c b/src/fe-common/irc/fe-netjoin.c index f5cb081e..22ca642c 100644 --- a/src/fe-common/irc/fe-netjoin.c +++ b/src/fe-common/irc/fe-netjoin.c @@ -164,11 +164,11 @@ static void print_channel_netjoins(char *channel, TEMP_PRINT_REC *rec, g_free(channel); } -static void print_netjoins(NETJOIN_SERVER_REC *server) +static void print_netjoins(NETJOIN_SERVER_REC *server, const char *channel) { TEMP_PRINT_REC *temp; GHashTable *channels; - GSList *tmp, *next, *old; + GSList *tmp, *tmp2, *next, *next2, *old; g_return_if_fail(server != NULL); @@ -181,11 +181,17 @@ static void print_netjoins(NETJOIN_SERVER_REC *server) for (tmp = server->netjoins; tmp != NULL; tmp = next) { NETJOIN_REC *rec = tmp->data; - next = tmp->next; - while (rec->now_channels != NULL) { - char *channel = rec->now_channels->data; + next = g_slist_next(tmp); + + for (tmp2 = rec->now_channels; tmp2 != NULL; tmp2 = next2) { + char *channel = tmp2->data; char *realchannel = channel + 1; + next2 = g_slist_next(tmp2); + + if (channel != NULL && strcasecmp(realchannel, channel) != 0) + continue; + temp = g_hash_table_lookup(channels, realchannel); if (temp == NULL) { temp = g_new0(TEMP_PRINT_REC, 1); @@ -214,8 +220,8 @@ static void print_netjoins(NETJOIN_SERVER_REC *server) g_free(data); } - rec->now_channels = - g_slist_remove(rec->now_channels, channel); + /* drop tmp2 from the list */ + rec->now_channels = g_slist_delete_link(rec->now_channels, tmp2); g_free(channel); } @@ -235,20 +241,25 @@ static void print_netjoins(NETJOIN_SERVER_REC *server) /* something is going to be printed to screen, print our current netsplit message before it. */ -static void sig_print_starting(void) +static void sig_print_starting(TEXT_DEST_REC *dest) { - GSList *tmp, *next; + NETJOIN_SERVER_REC *rec; if (printing_joins) return; - for (tmp = joinservers; tmp != NULL; tmp = next) { - NETJOIN_SERVER_REC *server = tmp->data; + if (!IS_IRC_SERVER(dest->server)) + return; - next = tmp->next; - if (server->netjoins != NULL) - print_netjoins(server); - } + if (dest->level != MSGLEVEL_PUBLIC) + return; + + if (!server_ischannel(dest->server, dest->target)) + return; + + rec = netjoin_find_server(IRC_SERVER(dest->server)); + if (rec != NULL && rec->netjoins != NULL) + print_netjoins(rec, dest->target); } static int sig_check_netjoins(void) @@ -272,7 +283,7 @@ static int sig_check_netjoins(void) } if (server->netjoins != NULL) - print_netjoins(server); + print_netjoins(server, NULL); } /* now remove all netjoins which haven't had any new joins diff --git a/src/fe-common/irc/fe-netsplit.c b/src/fe-common/irc/fe-netsplit.c index 3eb30796..aa05639b 100644 --- a/src/fe-common/irc/fe-netsplit.c +++ b/src/fe-common/irc/fe-netsplit.c @@ -142,7 +142,7 @@ static void get_server_splits(void *key, NETSPLIT_REC *split, } } -static void print_server_splits(IRC_SERVER_REC *server, TEMP_SPLIT_REC *rec) +static void print_server_splits(IRC_SERVER_REC *server, TEMP_SPLIT_REC *rec, const char *channel) { GString *destservers; char *sourceserver; @@ -168,6 +168,9 @@ static void print_server_splits(IRC_SERVER_REC *server, TEMP_SPLIT_REC *rec) for (tmp = rec->channels; tmp != NULL; tmp = tmp->next) { TEMP_SPLIT_CHAN_REC *chan = tmp->data; + if (channel != NULL && strcasecmp(channel, chan->name) != 0) + continue; + g_string_truncate(chan->nicks, chan->nicks->len-2); if (netsplit_max_nicks > 0 && @@ -193,7 +196,7 @@ static void temp_split_chan_free(TEMP_SPLIT_CHAN_REC *rec) g_free(rec); } -static void print_splits(IRC_SERVER_REC *server) +static void print_splits(IRC_SERVER_REC *server, const char *channel) { TEMP_SPLIT_REC temp; GSList *servers; @@ -212,7 +215,7 @@ static void print_splits(IRC_SERVER_REC *server) g_hash_table_foreach(server->splits, (GHFunc) get_server_splits, &temp); - print_server_splits(server, &temp); + print_server_splits(server, &temp, channel); g_slist_foreach(temp.channels, (GFunc) temp_split_chan_free, NULL); @@ -233,25 +236,31 @@ static int check_server_splits(IRC_SERVER_REC *server) if (time(NULL)-last < SPLIT_WAIT_TIME) return FALSE; - print_splits(server); + print_splits(server, NULL); return TRUE; } /* something is going to be printed to screen, print our current netsplit message before it. */ -static void sig_print_starting(void) +static void sig_print_starting(TEXT_DEST_REC *dest) { - GSList *tmp; + IRC_SERVER_REC *rec; if (printing_splits) return; - for (tmp = servers; tmp != NULL; tmp = tmp->next) { - IRC_SERVER_REC *rec = tmp->data; + if (IS_IRC_SERVER(dest->server) == FALSE) + return; - if (IS_IRC_SERVER(rec) && rec->split_servers != NULL) - print_splits(rec); - } + if (dest->level != MSGLEVEL_PUBLIC) + return; + + if (server_ischannel(dest->server, dest->target) == FALSE) + return; + + rec = IRC_SERVER(dest->server); + if (rec->split_servers != NULL) + print_splits(rec, dest->target); } static int sig_check_splits(void) |