diff options
Diffstat (limited to 'src/fe-common/irc/fe-netjoin.c')
-rw-r--r-- | src/fe-common/irc/fe-netjoin.c | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/fe-common/irc/fe-netjoin.c b/src/fe-common/irc/fe-netjoin.c index f5cb081e..4eb388c0 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 *filter_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,19 @@ 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); + + /* Filter the results by channel if asked to do so */ + if (filter_channel != NULL && + strcasecmp(realchannel, filter_channel) != 0) + continue; + temp = g_hash_table_lookup(channels, realchannel); if (temp == NULL) { temp = g_new0(TEMP_PRINT_REC, 1); @@ -214,8 +222,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 +243,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 +285,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 |