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/core | |
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/core')
-rw-r--r-- | src/core/ignore.c | 37 | ||||
-rw-r--r-- | src/core/ignore.h | 5 |
2 files changed, 39 insertions, 3 deletions
diff --git a/src/core/ignore.c b/src/core/ignore.c index 0cee82cd..0721d826 100644 --- a/src/core/ignore.c +++ b/src/core/ignore.c @@ -37,6 +37,8 @@ GSList *ignores; static NICKMATCH_REC *nickmatch; +static int unignore_timeout(IGNORE_REC *rec); + /* check if `text' contains ignored nick at the start of the line. */ static int ignore_check_replies_rec(IGNORE_REC *rec, CHANNEL_REC *channel, const char *text) @@ -258,6 +260,21 @@ IGNORE_REC *ignore_find(const char *servertag, const char *mask, return NULL; } +char *ignore_get_key(IGNORE_REC *rec) +{ + char *chans, *ret; + + if (rec->channels == NULL) + return rec->mask != NULL ? g_strdup(rec->mask) : NULL; + + chans = g_strjoinv(",", rec->channels); + if (rec->mask == NULL) return chans; + + ret = g_strdup_printf("%s %s", rec->mask, chans); + g_free(chans); + return ret; +} + static void ignore_set_config(IGNORE_REC *rec) { CONFIG_NODE *node; @@ -322,16 +339,25 @@ void ignore_add_rec(IGNORE_REC *rec) regcomp(&rec->preg, rec->pattern, REG_EXTENDED|REG_ICASE|REG_NOSUB) == 0; #endif + if (rec->time > 0) + rec->time_tag = g_timeout_add(rec->time*1000, (GSourceFunc) unignore_timeout, rec); + ignores = g_slist_append(ignores, rec); ignore_set_config(rec); - signal_emit("ignore created", 1, rec); + if (!rec->autoignore) + signal_emit("ignore created", 1, rec); + else + signal_emit("autoignore new", 1, rec); } static void ignore_destroy(IGNORE_REC *rec) { ignores = g_slist_remove(ignores, rec); - signal_emit("ignore destroyed", 1, rec); + if (!rec->autoignore) + signal_emit("ignore destroyed", 1, rec); + else + signal_emit("autoignore destroyed", 1, rec); #ifdef HAVE_REGEX_H if (rec->regexp_compiled) regfree(&rec->preg); @@ -365,6 +391,13 @@ void ignore_update_rec(IGNORE_REC *rec) } } +static int unignore_timeout(IGNORE_REC *rec) +{ + rec->level = 0; + ignore_update_rec(rec); + return FALSE; +} + static void read_ignores(void) { IGNORE_REC *rec; diff --git a/src/core/ignore.h b/src/core/ignore.h index f4aea3aa..a8e30ada 100644 --- a/src/core/ignore.h +++ b/src/core/ignore.h @@ -8,13 +8,14 @@ typedef struct { int level; /* ignore these levels */ char *mask; /* nick mask */ - char *servertag; /* this is for autoignoring */ + char *servertag; /* this is for autoignoring */ char **channels; /* ignore only in these channels */ char *pattern; /* text body must match this pattern */ int time; /* time in sec for temp ignores */ int time_tag; + unsigned int autoignore:1; unsigned int exception:1; /* *don't* ignore */ unsigned int regexp:1; unsigned int fullword:1; @@ -32,6 +33,8 @@ int ignore_check(SERVER_REC *server, const char *nick, const char *host, IGNORE_REC *ignore_find(const char *servertag, const char *mask, char **channels); +char *ignore_get_key(IGNORE_REC *rec); + void ignore_add_rec(IGNORE_REC *rec); void ignore_update_rec(IGNORE_REC *rec); |