mirror of
https://github.com/irssi/irssi.git
synced 2024-09-01 04:14:16 -04:00
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
This commit is contained in:
parent
6ae8ab5766
commit
c5cccfcdaa
@ -713,7 +713,6 @@ src/fe-common/Makefile
|
||||
src/fe-common/core/Makefile
|
||||
src/fe-common/irc/Makefile
|
||||
src/fe-common/irc/dcc/Makefile
|
||||
src/fe-common/irc/flood/Makefile
|
||||
src/fe-common/irc/notifylist/Makefile
|
||||
src/fe-none/Makefile
|
||||
src/fe-text/Makefile
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -1,4 +1,4 @@
|
||||
SUBDIRS = dcc flood notifylist
|
||||
SUBDIRS = dcc notifylist
|
||||
|
||||
noinst_LIBRARIES = libfe_common_irc.a
|
||||
|
||||
|
@ -11,6 +11,4 @@ libirc_flood_la_SOURCES = \
|
||||
flood.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
autoignore.h \
|
||||
flood.h \
|
||||
module.h
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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
|
@ -179,5 +179,4 @@ INCLUDE: Modes.xs
|
||||
INCLUDE: Netsplit.xs
|
||||
|
||||
INCLUDE: Dcc.xs
|
||||
INCLUDE: Flood.xs
|
||||
INCLUDE: Notifylist.xs
|
||||
|
@ -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) \
|
||||
|
Loading…
Reference in New Issue
Block a user