diff options
author | Timo Sirainen <cras@irssi.org> | 2001-02-22 06:09:48 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2001-02-22 06:09:48 +0000 |
commit | fc17069cec434306599582a381ea1d61d8cea4ad (patch) | |
tree | 298cc293140b36192b0add11e2171f71e03ed807 /src/fe-common | |
parent | a2a6c7e29376adff275baacc69b3834751ab0043 (diff) | |
download | irssi-fc17069cec434306599582a381ea1d61d8cea4ad.zip |
Autoignore fixes by fuchs (not tested, hope it works ;)
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1281 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common')
-rw-r--r-- | src/fe-common/core/fe-ignore.c | 89 | ||||
-rw-r--r-- | src/fe-common/irc/flood/fe-flood.c | 36 | ||||
-rw-r--r-- | src/fe-common/irc/flood/module-formats.c | 2 |
3 files changed, 57 insertions, 70 deletions
diff --git a/src/fe-common/core/fe-ignore.c b/src/fe-common/core/fe-ignore.c index fdbc60d5..2af5f655 100644 --- a/src/fe-common/core/fe-ignore.c +++ b/src/fe-common/core/fe-ignore.c @@ -29,24 +29,6 @@ #include "ignore.h" #include "printtext.h" -static void fe_unignore(IGNORE_REC *rec); - -static char *ignore_get_key(IGNORE_REC *rec) -{ - char *chans, *ret; - - if (rec->channels == NULL) - return g_strdup(rec->mask == NULL ? "*" : rec->mask); - - chans = g_strjoinv(",", rec->channels); - if (rec->mask == NULL) return chans; - - ret = g_strdup_printf("%s %s", rec->mask == NULL ? - "*" : rec->mask, chans); - g_free(chans); - return ret; -} - static void ignore_print(int index, IGNORE_REC *rec) { GString *options; @@ -71,12 +53,6 @@ static void ignore_print(int index, IGNORE_REC *rec) g_free(levels); } -static int unignore_timeout(IGNORE_REC *rec) -{ - fe_unignore(rec); - return FALSE; -} - static void cmd_ignore_show(void) { GSList *tmp; @@ -98,9 +74,9 @@ static void cmd_ignore_show(void) [-time <secs>] <channels> <levels> */ static void cmd_ignore(const char *data) { - GHashTable *optlist; + GHashTable *optlist; IGNORE_REC *rec; - char *patternarg, *chanarg, *mask, *levels, *key, *timestr; + char *patternarg, *chanarg, *mask, *levels, *timestr; char **channels; void *free_arg; int new_ignore; @@ -154,17 +130,8 @@ static void cmd_ignore(const char *data) if (rec->level == 0) { printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_UNIGNORED, rec->mask == NULL ? "*" : rec->mask); - } else { - key = ignore_get_key(rec); - levels = bits2level(rec->level); - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_IGNORED, key, levels); - g_free(key); - g_free(levels); } - if (rec->time > 0) - rec->time_tag = g_timeout_add(rec->time*1000, (GSourceFunc) unignore_timeout, rec); - if (new_ignore) ignore_add_rec(rec); else @@ -173,18 +140,6 @@ static void cmd_ignore(const char *data) cmd_params_free(free_arg); } -static void fe_unignore(IGNORE_REC *rec) -{ - char *key; - - key = ignore_get_key(rec); - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_UNIGNORED, key); - g_free(key); - - rec->level = 0; - ignore_update_rec(rec); -} - /* SYNTAX: UNIGNORE <id>|<mask> */ static void cmd_unignore(const char *data) { @@ -210,10 +165,34 @@ static void cmd_unignore(const char *data) rec = ignore_find("*", data, (char **) chans); } - if (rec == NULL) - printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_IGNORE_NOT_FOUND, data); - else - fe_unignore(rec); + if (rec != NULL) { + rec->level = 0; + ignore_update_rec(rec); + } else { + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + TXT_IGNORE_NOT_FOUND, data); + } +} + +static void sig_ignore_created(IGNORE_REC *rec) +{ + char *key, *levels; + + key = ignore_get_key(rec); + levels = bits2level(rec->level); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, + TXT_IGNORED, key, levels); + g_free(key); + g_free(levels); +} + +static void sig_ignore_destroyed(IGNORE_REC *rec) +{ + char *key; + + key = ignore_get_key(rec); + printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_UNIGNORED, key); + g_free(key); } void fe_ignore_init(void) @@ -221,6 +200,10 @@ void fe_ignore_init(void) command_bind("ignore", NULL, (SIGNAL_FUNC) cmd_ignore); command_bind("unignore", NULL, (SIGNAL_FUNC) cmd_unignore); + signal_add("ignore destroyed", (SIGNAL_FUNC) sig_ignore_destroyed); + signal_add("ignore created", (SIGNAL_FUNC) sig_ignore_created); + signal_add("ignore changed", (SIGNAL_FUNC) sig_ignore_created); + command_set_options("ignore", "regexp word except replies -time -pattern -channels"); } @@ -228,4 +211,8 @@ void fe_ignore_deinit(void) { command_unbind("ignore", (SIGNAL_FUNC) cmd_ignore); command_unbind("unignore", (SIGNAL_FUNC) cmd_unignore); + + signal_remove("ignore destroyed", (SIGNAL_FUNC) sig_ignore_destroyed); + signal_remove("ignore created", (SIGNAL_FUNC) sig_ignore_created); + signal_remove("ignore changed", (SIGNAL_FUNC) sig_ignore_created); } diff --git a/src/fe-common/irc/flood/fe-flood.c b/src/fe-common/irc/flood/fe-flood.c index 7f5a0ee5..0cd59208 100644 --- a/src/fe-common/irc/flood/fe-flood.c +++ b/src/fe-common/irc/flood/fe-flood.c @@ -24,38 +24,38 @@ #include "levels.h" #include "irc-servers.h" +#include "ignore.h" #include "irc/flood/autoignore.h" #include "themes.h" #include "printtext.h" -static void event_autoignore_new(IRC_SERVER_REC *server, AUTOIGNORE_REC *ignore) +static void event_autoignore_new(IGNORE_REC *rec) { - g_return_if_fail(ignore != NULL); + g_return_if_fail(rec != NULL); + + printformat(server_find_tag(rec->servertag), NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_AUTOIGNORE, rec->mask, rec->time); +} - printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_AUTOIGNORE, - ignore->nick, (ignore->timeleft+59)/60); -} - -static void event_autoignore_remove(IRC_SERVER_REC *server, AUTOIGNORE_REC *ignore) +static void event_autoignore_destroyed(IGNORE_REC *rec) { - g_return_if_fail(ignore != NULL); - - printformat(server, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_AUTOUNIGNORE, ignore->nick); -} - + g_return_if_fail(rec != NULL); + + printformat(server_find_tag(rec->servertag), NULL, MSGLEVEL_CLIENTNOTICE, + IRCTXT_AUTOUNIGNORE, rec->mask, rec->time); +} void fe_irc_flood_init(void) { - signal_add("autoignore new", (SIGNAL_FUNC) event_autoignore_new); - signal_add("autoignore remove", (SIGNAL_FUNC) event_autoignore_remove); + signal_add("autoignore new", (SIGNAL_FUNC) event_autoignore_new); + signal_add("autoignore destroyed", (SIGNAL_FUNC) event_autoignore_destroyed); - theme_register(fecommon_irc_flood_formats); + theme_register(fecommon_irc_flood_formats); } void fe_irc_flood_deinit(void) { - theme_unregister(); - signal_remove("autoignore new", (SIGNAL_FUNC) event_autoignore_new); - signal_remove("autoignore remove", (SIGNAL_FUNC) event_autoignore_remove); + signal_remove("autoignore destroyed", (SIGNAL_FUNC) event_autoignore_destroyed); + theme_unregister(); } diff --git a/src/fe-common/irc/flood/module-formats.c b/src/fe-common/irc/flood/module-formats.c index 29b76ace..c2ce4ae1 100644 --- a/src/fe-common/irc/flood/module-formats.c +++ b/src/fe-common/irc/flood/module-formats.c @@ -28,7 +28,7 @@ FORMAT_REC fecommon_irc_flood_formats[] = /* ---- */ { NULL, "Autoignore", 0 }, - { "autoignore", "Flood detected from {nick $0}, autoignoring for {hilight $1} minutes", 2, { 0, 1 } }, + { "autoignore", "Flood detected from {nick $0}, autoignoring for {hilight $1} seconds", 2, { 0, 1 } }, { "autounignore", "Removed autoignore from {nick $0}", 1, { 0 } }, { NULL, NULL, 0 } |