summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-03-03 23:27:07 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-03-03 23:27:07 +0000
commitc5cccfcdaa3e75c378b14086679e54a781b5b8c6 (patch)
tree3e06e98f93cd86ce555960fee312817cb0a67501 /src
parent6ae8ab57666e7969f8a10ca13edaa7933fe0cb3a (diff)
downloadirssi-c5cccfcdaa3e75c378b14086679e54a781b5b8c6.zip
fe-common/irc/flood removed. Some autoignore / ignore -time updates.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1330 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/core/ignore.c43
-rw-r--r--src/core/ignore.h4
-rw-r--r--src/fe-common/core/fe-ignore.c3
-rw-r--r--src/fe-common/irc/Makefile.am2
-rw-r--r--src/irc/flood/Makefile.am2
-rw-r--r--src/irc/flood/autoignore.c29
-rw-r--r--src/irc/flood/flood.c4
-rw-r--r--src/perl/irc/Flood.xs13
-rw-r--r--src/perl/irc/Irc.xs1
-rw-r--r--src/perl/irc/module.h1
10 files changed, 42 insertions, 60 deletions
diff --git a/src/core/ignore.c b/src/core/ignore.c
index 0432de05..aee47dab 100644
--- a/src/core/ignore.c
+++ b/src/core/ignore.c
@@ -36,8 +36,7 @@
GSList *ignores;
static NICKMATCH_REC *nickmatch;
-
-static int unignore_timeout(IGNORE_REC *rec);
+static int time_tag;
/* check if `text' contains ignored nick at the start of the line. */
static int ignore_check_replies_rec(IGNORE_REC *rec, CHANNEL_REC *channel,
@@ -265,7 +264,7 @@ static void ignore_set_config(IGNORE_REC *rec)
CONFIG_NODE *node;
char *levelstr;
- if (rec->level == 0 || rec->time > 0)
+ if (rec->level == 0 || rec->unignore_time > 0)
return;
node = iconfig_node_traverse("(ignores", TRUE);
@@ -324,32 +323,22 @@ 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);
- if (!rec->autoignore)
- signal_emit("ignore created", 1, rec);
- else
- signal_emit("autoignore new", 1, rec);
+ signal_emit("ignore created", 1, rec);
}
static void ignore_destroy(IGNORE_REC *rec, int send_signal)
{
ignores = g_slist_remove(ignores, rec);
- if (send_signal) {
- if (!rec->autoignore)
- signal_emit("ignore destroyed", 1, rec);
- else
- signal_emit("autoignore destroyed", 1, rec);
- }
+ if (send_signal)
+ signal_emit("ignore destroyed", 1, rec);
#ifdef HAVE_REGEX_H
if (rec->regexp_compiled) regfree(&rec->preg);
#endif
- if (rec->time_tag > 0) g_source_remove(rec->time_tag);
if (rec->channels != NULL) g_strfreev(rec->channels);
g_free_not_null(rec->mask);
g_free_not_null(rec->servertag);
@@ -378,11 +367,23 @@ void ignore_update_rec(IGNORE_REC *rec)
}
}
-static int unignore_timeout(IGNORE_REC *rec)
+static int unignore_timeout(void)
{
- rec->level = 0;
- ignore_update_rec(rec);
- return FALSE;
+ GSList *tmp, *next;
+ time_t now;
+
+ now = time(NULL);
+ for (tmp = ignores; tmp != NULL; tmp = next) {
+ IGNORE_REC *rec = tmp->data;
+
+ next = tmp->next;
+ if (now >= rec->unignore_time) {
+ rec->level = 0;
+ ignore_update_rec(rec);
+ }
+ }
+
+ return TRUE;
}
static void read_ignores(void)
@@ -465,6 +466,7 @@ void ignore_init(void)
{
ignores = NULL;
nickmatch = nickmatch_init(ignore_nick_cache);
+ time_tag = g_timeout_add(1000, (GSourceFunc) unignore_timeout, NULL);
read_ignores();
signal_add("setup reread", (SIGNAL_FUNC) read_ignores);
@@ -472,6 +474,7 @@ void ignore_init(void)
void ignore_deinit(void)
{
+ g_source_remove(time_tag);
while (ignores != NULL)
ignore_destroy(ignores->data, TRUE);
nickmatch_deinit(nickmatch);
diff --git a/src/core/ignore.h b/src/core/ignore.h
index 718630d8..4056062e 100644
--- a/src/core/ignore.h
+++ b/src/core/ignore.h
@@ -12,10 +12,8 @@ typedef struct {
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;
+ time_t unignore_time; /* time in sec for temp ignores */
- unsigned int autoignore:1;
unsigned int exception:1; /* *don't* ignore */
unsigned int regexp:1;
unsigned int fullword:1;
diff --git a/src/fe-common/core/fe-ignore.c b/src/fe-common/core/fe-ignore.c
index bab6b00e..7c10893f 100644
--- a/src/fe-common/core/fe-ignore.c
+++ b/src/fe-common/core/fe-ignore.c
@@ -140,7 +140,8 @@ static void cmd_ignore(const char *data)
rec->fullword = g_hash_table_lookup(optlist, "word") != NULL;
rec->replies = g_hash_table_lookup(optlist, "replies") != NULL;
timestr = g_hash_table_lookup(optlist, "time");
- rec->time = timestr == NULL ? 0 : atoi(timestr);
+ if (timestr != NULL)
+ rec->unignore_time = time(NULL)+atoi(timestr);
if (rec->level == 0) {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_UNIGNORED,
diff --git a/src/fe-common/irc/Makefile.am b/src/fe-common/irc/Makefile.am
index b69499f1..c3e5ce04 100644
--- a/src/fe-common/irc/Makefile.am
+++ b/src/fe-common/irc/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = dcc flood notifylist
+SUBDIRS = dcc notifylist
noinst_LIBRARIES = libfe_common_irc.a
diff --git a/src/irc/flood/Makefile.am b/src/irc/flood/Makefile.am
index fc80df47..1424380d 100644
--- a/src/irc/flood/Makefile.am
+++ b/src/irc/flood/Makefile.am
@@ -11,6 +11,4 @@ libirc_flood_la_SOURCES = \
flood.c
noinst_HEADERS = \
- autoignore.h \
- flood.h \
module.h
diff --git a/src/irc/flood/autoignore.c b/src/irc/flood/autoignore.c
index 470eacb4..7d409b6c 100644
--- a/src/irc/flood/autoignore.c
+++ b/src/irc/flood/autoignore.c
@@ -1,7 +1,7 @@
/*
autoignore.c : irssi
- Copyright (C) 1999-2000 Timo Sirainen
+ Copyright (C) 1999-2001 Timo Sirainen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,12 +29,10 @@
#include "irc-servers.h"
#include "ignore.h"
-#include "autoignore.h"
-
void autoignore_update(IGNORE_REC *rec, int level)
{
rec->level |= level;
- rec->time = settings_get_int("autoignore_time");
+ rec->unignore_time = time(NULL)+settings_get_int("autoignore_time");
ignore_update_rec(rec);
}
@@ -44,38 +42,35 @@ void autoignore_add(IRC_SERVER_REC *server, char *mask, int level)
IGNORE_REC *rec;
rec = g_new0(IGNORE_REC, 1);
-
- rec->mask = mask;
+
+ rec->mask = g_strdup(mask);
rec->servertag = g_strdup(server->tag);
rec->level = level;
- rec->time = settings_get_int("autoignore_time");
- rec->autoignore = 1;
-
+ rec->unignore_time = time(NULL)+settings_get_int("autoignore_time");
+
ignore_add_rec(rec);
}
static void sig_flood(IRC_SERVER_REC *server, const char *nick, const char *host, gpointer levelp)
{
- int level, check_level;
- GString *mask;
IGNORE_REC *rec;
+ char *mask;
+ int level, check_level;
g_return_if_fail(IS_IRC_SERVER(server));
level = GPOINTER_TO_INT(levelp);
check_level = level2bits(settings_get_str("autoignore_level"));
- mask = g_string_new(nick);
- mask = g_string_append_c(mask, '!');
- mask = g_string_append(mask, host);
+ mask = g_strdup_printf("%s!%s", nick, host);
if (level & check_level) {
- rec = ignore_find(server->tag, mask->str, NULL);
+ rec = ignore_find(server->tag, mask, NULL);
if (rec == NULL)
- autoignore_add(server, mask->str, level);
+ autoignore_add(server, mask, level);
else
autoignore_update(rec, level);
}
- g_string_free(mask, TRUE);
+ g_free(mask);
}
void autoignore_init(void)
diff --git a/src/irc/flood/flood.c b/src/irc/flood/flood.c
index a1d4dd91..c3c47507 100644
--- a/src/irc/flood/flood.c
+++ b/src/irc/flood/flood.c
@@ -27,9 +27,11 @@
#include "irc.h"
#include "irc-servers.h"
-#include "autoignore.h"
#include "ignore.h"
+void autoignore_init(void);
+void autoignore_deinit(void);
+
typedef struct {
char *target;
int level;
diff --git a/src/perl/irc/Flood.xs b/src/perl/irc/Flood.xs
deleted file mode 100644
index 5a92e442..00000000
--- a/src/perl/irc/Flood.xs
+++ /dev/null
@@ -1,13 +0,0 @@
-MODULE = Irssi::Irc PACKAGE = Irssi::Irc::Server
-
-void
-autoignore_add(server, nick, level)
- Irssi::Irc::Server server
- char *nick
- int level
-
-int
-autoignore_remove(server, mask, level)
- Irssi::Irc::Server server
- char *mask
- int level
diff --git a/src/perl/irc/Irc.xs b/src/perl/irc/Irc.xs
index 328e9c56..9bde4296 100644
--- a/src/perl/irc/Irc.xs
+++ b/src/perl/irc/Irc.xs
@@ -179,5 +179,4 @@ INCLUDE: Modes.xs
INCLUDE: Netsplit.xs
INCLUDE: Dcc.xs
-INCLUDE: Flood.xs
INCLUDE: Notifylist.xs
diff --git a/src/perl/irc/module.h b/src/perl/irc/module.h
index aa70eb0a..971f0021 100644
--- a/src/perl/irc/module.h
+++ b/src/perl/irc/module.h
@@ -15,7 +15,6 @@
#include "dcc/dcc-chat.h"
#include "dcc/dcc-get.h"
#include "dcc/dcc-send.h"
-#include "flood/autoignore.h"
#include "notifylist/notifylist.h"
#define dcc_bless(dcc) \