diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 1cc943eb..f4b08ae7 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -22,6 +22,7 @@ libcore_a_SOURCES = \ chat-protocols.c \ chatnets.c \ core.c \ + ignore.c \ levels.c \ line-split.c \ log.c \ @@ -62,6 +63,7 @@ noinst_HEADERS = \ chat-protocols.h \ chatnets.h \ core.h \ + ignore.h \ levels.h \ line-split.h \ log.h \ diff --git a/src/core/core.c b/src/core/core.c index 7ec453d1..a2a928db 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -33,6 +33,7 @@ #include "commands.h" #include "log.h" #include "rawlog.h" +#include "ignore.h" #include "special-vars.h" #include "channels.h" @@ -57,6 +58,7 @@ void core_init(void) chat_protocols_init(); chatnets_init(); + ignore_init(); servers_init(); log_init(); rawlog_init(); @@ -84,6 +86,7 @@ void core_deinit(void) rawlog_deinit(); log_deinit(); servers_deinit(); + ignore_deinit(); chatnets_deinit(); chat_protocols_deinit(); diff --git a/src/irc/core/ignore.c b/src/core/ignore.c similarity index 93% rename from src/irc/core/ignore.c rename to src/core/ignore.c index 7ec3122e..5c37fe45 100644 --- a/src/irc/core/ignore.c +++ b/src/core/ignore.c @@ -25,21 +25,20 @@ #include "lib-config/iconfig.h" #include "settings.h" -#include "irc.h" -#include "irc-masks.h" -#include "irc-servers.h" -#include "irc-channels.h" -#include "irc-nicklist.h" +#include "masks.h" +#include "servers.h" +#include "channels.h" +#include "nicklist.h" #include "ignore.h" GSList *ignores; /* check if `text' contains ignored nick at the start of the line. */ -static int ignore_check_replies(IGNORE_REC *rec, IRC_SERVER_REC *server, +static int ignore_check_replies(IGNORE_REC *rec, SERVER_REC *server, const char *channel, const char *text) { - IRC_CHANNEL_REC *chanrec; + CHANNEL_REC *chanrec; GSList *nicks, *tmp; g_return_val_if_fail(rec != NULL, FALSE); @@ -47,16 +46,16 @@ static int ignore_check_replies(IGNORE_REC *rec, IRC_SERVER_REC *server, g_return_val_if_fail(channel != NULL, FALSE); g_return_val_if_fail(text != NULL, FALSE); - chanrec = irc_channel_find(server, channel); + chanrec = channel_find(server, channel); if (chanrec == NULL) return FALSE; - nicks = nicklist_find_multiple(CHANNEL(chanrec), rec->mask); + nicks = nicklist_find_multiple(chanrec, rec->mask); if (nicks == NULL) return FALSE; for (tmp = nicks; tmp != NULL; tmp = tmp->next) { NICK_REC *nick = tmp->data; - if (nick_match_msg(SERVER(server), text, nick->nick)) + if (nick_match_msg(server, text, nick->nick)) return TRUE; } g_slist_free(nicks); @@ -64,7 +63,7 @@ static int ignore_check_replies(IGNORE_REC *rec, IRC_SERVER_REC *server, return FALSE; } -int ignore_check(IRC_SERVER_REC *server, const char *nick, const char *host, +int ignore_check(SERVER_REC *server, const char *nick, const char *host, const char *channel, const char *text, int level) { GSList *tmp; @@ -86,7 +85,7 @@ int ignore_check(IRC_SERVER_REC *server, const char *nick, const char *host, /* channel list */ if (rec->channels != NULL) { - if (channel == NULL || !ischannel(*channel)) + if (channel == NULL || !server->ischannel(*channel)) continue; if (strarray_find(rec->channels, channel) == -1) continue; @@ -103,7 +102,7 @@ int ignore_check(IRC_SERVER_REC *server, const char *nick, const char *host, ok = ((host == NULL || *host == '\0')) ? match_wildcards(rec->mask, nick) : - mask_match_address(SERVER(server), rec->mask, nick, host); + mask_match_address(server, rec->mask, nick, host); if (!ok) { /* nick didn't match, but maybe this is a reply to nick? */ if (!rec->replies || channel == NULL || text == NULL || @@ -114,7 +113,10 @@ int ignore_check(IRC_SERVER_REC *server, const char *nick, const char *host, /* pattern */ patt_len = 0; - if (rec->pattern != NULL && text != NULL) { + if (rec->pattern != NULL) { + if (text == NULL) + continue; + if (!mask_len && !best_mask) { patt_len = strlen(rec->pattern); if (patt_len <= best_patt) continue; diff --git a/src/irc/core/ignore.h b/src/core/ignore.h similarity index 91% rename from src/irc/core/ignore.h rename to src/core/ignore.h index bac02047..e4355f52 100644 --- a/src/irc/core/ignore.h +++ b/src/core/ignore.h @@ -20,7 +20,7 @@ typedef struct { extern GSList *ignores; -int ignore_check(IRC_SERVER_REC *server, const char *nick, const char *host, +int ignore_check(SERVER_REC *server, const char *nick, const char *host, const char *channel, const char *text, int level); IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels); diff --git a/src/irc/core/Makefile.am b/src/irc/core/Makefile.am index 99f72229..e6748792 100644 --- a/src/irc/core/Makefile.am +++ b/src/irc/core/Makefile.am @@ -11,7 +11,6 @@ libirc_core_a_SOURCES = \ channels-query.c \ channel-events.c \ channel-rejoin.c \ - ignore.c \ irc.c \ irc-core.c \ irc-channels.c \ @@ -37,7 +36,6 @@ libirc_core_a_SOURCES = \ noinst_HEADERS = \ bans.h \ ctcp.h \ - ignore.h \ irc.h \ irc-channels.h \ irc-chatnets.h \ diff --git a/src/irc/core/channels-query.c b/src/irc/core/channels-query.c index ae6c4f71..96f17f4d 100644 --- a/src/irc/core/channels-query.c +++ b/src/irc/core/channels-query.c @@ -128,7 +128,8 @@ static void sig_channel_destroyed(IRC_CHANNEL_REC *channel) { g_return_if_fail(channel != NULL); - if (channel->server != NULL && !channel->synced) + if (IS_IRC_CHANNEL(channel) && channel->server != NULL && + !channel->synced) channel_query_remove_all(channel); } diff --git a/src/irc/core/ctcp.c b/src/irc/core/ctcp.c index 8bcd4684..a1d1f2df 100644 --- a/src/irc/core/ctcp.c +++ b/src/irc/core/ctcp.c @@ -120,7 +120,7 @@ static void ctcp_msg(const char *data, IRC_SERVER_REC *server, { char *args, *str; - if (ignore_check(server, nick, addr, target, data, MSGLEVEL_CTCPS)) + if (ignore_check(SERVER(server), nick, addr, target, data, MSGLEVEL_CTCPS)) return; str = g_strconcat("ctcp msg ", data, NULL); @@ -140,7 +140,7 @@ static void ctcp_reply(const char *data, IRC_SERVER_REC *server, { char *args, *str; - if (ignore_check(server, nick, addr, target, data, MSGLEVEL_CTCPS)) + if (ignore_check(SERVER(server), nick, addr, target, data, MSGLEVEL_CTCPS)) return; str = g_strconcat("ctcp reply ", data, NULL); diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c index 104fc403..7eb70bb1 100644 --- a/src/irc/core/irc-core.c +++ b/src/irc/core/irc-core.c @@ -27,7 +27,6 @@ #include "irc-queries.h" #include "ctcp.h" -#include "ignore.h" #include "irc.h" #include "netsplit.h" @@ -71,7 +70,6 @@ void irc_core_init(void) irc_irc_init(); lag_init(); netsplit_init(); - ignore_init(); irc_rawlog_init(); irc_special_vars_init(); irc_log_init(); @@ -82,7 +80,6 @@ void irc_core_deinit(void) irc_log_deinit(); irc_special_vars_deinit(); irc_rawlog_deinit(); - ignore_deinit(); netsplit_deinit(); lag_deinit(); irc_commands_deinit(); diff --git a/src/irc/flood/flood.c b/src/irc/flood/flood.c index 456bc21f..08fe9bf0 100644 --- a/src/irc/flood/flood.c +++ b/src/irc/flood/flood.c @@ -211,7 +211,7 @@ static void flood_privmsg(const char *data, IRC_SERVER_REC *server, const char * params = event_get_params(data, 2, &target, &text); level = ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS; - if (addr != NULL && !ignore_check(server, nick, addr, target, text, level)) + if (addr != NULL && !ignore_check(SERVER(server), nick, addr, target, text, level)) flood_newmsg(server, level, nick, addr, target); g_free(params); @@ -228,7 +228,7 @@ static void flood_notice(const char *data, IRC_SERVER_REC *server, const char *n return; params = event_get_params(data, 2, &target, &text); - if (!ignore_check(server, nick, addr, target, text, MSGLEVEL_NOTICES)) + if (!ignore_check(SERVER(server), nick, addr, target, text, MSGLEVEL_NOTICES)) flood_newmsg(server, MSGLEVEL_NOTICES, nick, addr, target); g_free(params); @@ -246,7 +246,7 @@ static void flood_ctcp(const char *data, IRC_SERVER_REC *server, const char *nic level = g_strncasecmp(data, "ACTION ", 7) != 0 ? MSGLEVEL_CTCPS : (ischannel(*target) ? MSGLEVEL_PUBLIC : MSGLEVEL_MSGS); - if (!ignore_check(server, nick, addr, target, data, level)) + if (!ignore_check(SERVER(server), nick, addr, target, data, level)) flood_newmsg(server, level, nick, addr, target); }