1
0
forked from bip/bip

[OPTION] implement backlog_reset_connection

backlog_reset_on_talk no works per query/channel.
Setting backlog_reset_connection to true falls back to the former kind
of backlog reset.
This commit is contained in:
Arnaud Cornet 2009-01-17 12:50:39 +01:00
parent 0e2f305d4e
commit 26eb9c28d7
10 changed files with 50 additions and 20 deletions

View File

@ -194,7 +194,13 @@ If true, backlogged line won't include the timestamp.
\fBbacklog_reset_on_talk\fP (default: \fBfalse\fP) \fBbacklog_reset_on_talk\fP (default: \fBfalse\fP)
When true, backlog will be reset upon client talk (channel/private message or When true, backlog will be reset upon client talk (channel/private message or
action). It means that next time you log to your bip session, the backlogging action). It means that next time you log to your bip session, the backlogging
will start at the time right after your last words on that specific network. will start at the time right after your last words on that specific channel or
query.
.TP
\fBbacklog_reset_connection\fP (default: \fBfalse\fP)
When true, backlog_reset_on_talk option above is changed in that the whole
network backlog is resetted when you talk in the network.
.TP .TP
\fBbacklog_msg_only\fP (default: \fBfalse\fP) \fBbacklog_msg_only\fP (default: \fBfalse\fP)

View File

@ -148,9 +148,15 @@ user {
# ugly. # ugly.
# If blreset_on_talk talking on an irc network has the same effect of # If blreset_on_talk talking on an irc network has the same effect of
# issuing /bip blreset, meaning that stuffed logged before the command # issuing /bip blreset <current window>, meaning that stuffed logged
# won't be read back on backlog # before the command won't be read back on backlog
#backlog_reset_on_talk = false; #backlog_reset_on_talk = false;
#
# If you have backlog_reset_on_talk set to true, talking in a query
# will reset the backlog for the query. Same goes for channel. With the
# following option set to true, talking in a connection will reset the
# whole connection. The backlog for the current network is reset.
#backlog_reset_connection = true;
# If bl_msg_only is true, only channel and private messages will be # If bl_msg_only is true, only channel and private messages will be
# backlogged upon the reconnection of a client. Default is false, thus # backlogged upon the reconnection of a client. Default is false, thus

View File

@ -479,7 +479,7 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
#endif #endif
} else { } else {
l->network = NULL; l->network = NULL;
log_reinit_all(l->log); log_reset_all(l->log);
} }
while ((t = list_remove_first(data))) { while ((t = list_remove_first(data))) {
@ -682,6 +682,7 @@ static int add_user(bip_t *bip, list_t *data, struct historical_directives *hds)
u->backlog_lines = DEFAULT_BACKLOG_LINES; u->backlog_lines = DEFAULT_BACKLOG_LINES;
u->backlog_no_timestamp = DEFAULT_BACKLOG_NO_TIMESTAMP; u->backlog_no_timestamp = DEFAULT_BACKLOG_NO_TIMESTAMP;
u->blreset_on_talk = DEFAULT_BLRESET_ON_TALK; u->blreset_on_talk = DEFAULT_BLRESET_ON_TALK;
u->blreset_connection = DEFAULT_BLRESET_CONNECTION;
u->bip_use_notice = DEFAULT_BIP_USE_NOTICE; u->bip_use_notice = DEFAULT_BIP_USE_NOTICE;
} else { } else {
FREE(u->name); FREE(u->name);
@ -742,6 +743,9 @@ static int add_user(bip_t *bip, list_t *data, struct historical_directives *hds)
case LEX_BLRESET_ON_TALK: case LEX_BLRESET_ON_TALK:
u->blreset_on_talk = t->ndata; u->blreset_on_talk = t->ndata;
break; break;
case LEX_BLRESET_CONNECTION:
u->blreset_connection = t->ndata;
break;
case LEX_BIP_USE_NOTICE: case LEX_BIP_USE_NOTICE:
u->bip_use_notice = t->ndata; u->bip_use_notice = t->ndata;
break; break;
@ -1847,7 +1851,7 @@ void bip_notify(struct link_client *ic, char *fmt, ...)
void adm_blreset(struct link_client *ic) void adm_blreset(struct link_client *ic)
{ {
log_reinit_all(LINK(ic)->log); log_reset_all(LINK(ic)->log);
bip_notify(ic, "backlog resetted for this network."); bip_notify(ic, "backlog resetted for this network.");
} }
@ -2181,7 +2185,7 @@ int adm_bip(bip_t *bip, struct link_client *ic, struct line *line, int privmsg)
irc_line_elem(line, irc_line_elem(line,
privmsg + 3)); privmsg + 3));
} else { } else {
log_reinit_all(LINK(ic)->log); log_reset_all(LINK(ic)->log);
} }
} else { } else {
adm_blreset_store(ic, irc_line_elem(line, adm_blreset_store(ic, irc_line_elem(line,

View File

@ -68,7 +68,7 @@ struct tuple *tuple_l_new(int type, void *p)
%} %}
%token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_SSL_CLIENT_CERTFILE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN LEX_BIP_USE_NOTICE LEX_CSS_PEM %token LEX_IP LEX_EQ LEX_PORT LEX_CSS LEX_SEMICOLON LEX_CONNECTION LEX_NETWORK LEX_LBRA LEX_RBRA LEX_USER LEX_NAME LEX_NICK LEX_SERVER LEX_PASSWORD LEX_SRCIP LEX_HOST LEX_VHOST LEX_SOURCE_PORT LEX_NONE LEX_COMMENT LEX_BUNCH LEX_REALNAME LEX_SSL LEX_SSL_CHECK_MODE LEX_SSL_CHECK_STORE LEX_SSL_CLIENT_CERTFILE LEX_CHANNEL LEX_KEY LEX_LOG_ROOT LEX_LOG_FORMAT LEX_LOG_LEVEL LEX_BACKLOG_LINES LEX_BACKLOG_NO_TIMESTAMP LEX_BACKLOG LEX_LOG LEX_LOG_SYSTEM LEX_LOG_SYNC_INTERVAL LEX_FOLLOW_NICK LEX_ON_CONNECT_SEND LEX_AWAY_NICK LEX_PID_FILE LEX_IGN_FIRST_NICK LEX_ALWAYS_BACKLOG LEX_BLRESET_ON_TALK LEX_BLRESET_CONNECTION LEX_DEFAULT_USER LEX_DEFAULT_NICK LEX_DEFAULT_REALNAME LEX_NO_CLIENT_AWAY_MSG LEX_BL_MSG_ONLY LEX_ADMIN LEX_BIP_USE_NOTICE LEX_CSS_PEM
%union { %union {
int number; int number;
@ -168,6 +168,9 @@ usr_command:
| LEX_BLRESET_ON_TALK LEX_EQ LEX_BOOL { | LEX_BLRESET_ON_TALK LEX_EQ LEX_BOOL {
$$ = tuple_i_new(LEX_BLRESET_ON_TALK, $3); $$ = tuple_i_new(LEX_BLRESET_ON_TALK, $3);
} }
| LEX_BLRESET_CONNECTION LEX_EQ LEX_BOOL {
$$ = tuple_i_new(LEX_BLRESET_CONNECTION, $3);
}
| LEX_BL_MSG_ONLY LEX_EQ LEX_BOOL { | LEX_BL_MSG_ONLY LEX_EQ LEX_BOOL {
$$ = tuple_i_new(LEX_BL_MSG_ONLY, $3); $$ = tuple_i_new(LEX_BL_MSG_ONLY, $3);
} }

View File

@ -20,6 +20,7 @@
#define DEFAULT_BACKLOG_LINES 10 #define DEFAULT_BACKLOG_LINES 10
#define DEFAULT_BACKLOG_NO_TIMESTAMP 0 #define DEFAULT_BACKLOG_NO_TIMESTAMP 0
#define DEFAULT_BLRESET_ON_TALK 0 #define DEFAULT_BLRESET_ON_TALK 0
#define DEFAULT_BLRESET_CONNECTION 0
#define DEFAULT_LOG 1 #define DEFAULT_LOG 1
#define DEFAULT_LOG_SYSTEM 1 #define DEFAULT_LOG_SYSTEM 1
#define DEFAULT_LOG_SYNC_INTERVAL 5 #define DEFAULT_LOG_SYNC_INTERVAL 5

View File

@ -869,8 +869,12 @@ static int irc_cli_privmsg(bip_t *bip, struct link_client *ic,
log_cli_privmsg(LINK(ic)->log, LINK(ic)->l_server->nick, log_cli_privmsg(LINK(ic)->log, LINK(ic)->l_server->nick,
irc_line_elem(line, 1), irc_line_elem(line, 2)); irc_line_elem(line, 1), irc_line_elem(line, 2));
if (LINK(ic)->user->blreset_on_talk) if (LINK(ic)->user->blreset_on_talk) {
if (LINK(ic)->user->blreset_connection)
log_reset_all(LINK(ic)->log);
else
log_reset_store(LINK(ic)->log, irc_line_elem(line, 1)); log_reset_store(LINK(ic)->log, irc_line_elem(line, 1));
}
return OK_COPY_CLI; return OK_COPY_CLI;
} }
@ -880,8 +884,12 @@ static int irc_cli_notice(struct link_client *ic, struct line *line)
return OK_FORGET; return OK_FORGET;
log_cli_notice(LINK(ic)->log, LINK(ic)->l_server->nick, log_cli_notice(LINK(ic)->log, LINK(ic)->l_server->nick,
irc_line_elem(line, 1), irc_line_elem(line, 2)); irc_line_elem(line, 1), irc_line_elem(line, 2));
if (LINK(ic)->user->blreset_on_talk) if (LINK(ic)->user->blreset_on_talk) {
if (LINK(ic)->user->blreset_connection)
log_reset_all(LINK(ic)->log);
else
log_reset_store(LINK(ic)->log, irc_line_elem(line, 1)); log_reset_store(LINK(ic)->log, irc_line_elem(line, 1));
}
return OK_COPY_CLI; return OK_COPY_CLI;
} }

View File

@ -74,12 +74,13 @@ struct user {
char *default_realname; char *default_realname;
/* backlog options */ /* backlog options */
int backlog; int backlog:1;
int backlog_lines; int backlog_lines;
int always_backlog; int always_backlog:1;
int bl_msg_only; int bl_msg_only:1;
int backlog_no_timestamp; int backlog_no_timestamp:1;
int blreset_on_talk; int blreset_on_talk:1;
int blreset_connection:1;
#ifdef HAVE_LIBSSL #ifdef HAVE_LIBSSL
int ssl_check_mode; int ssl_check_mode;
@ -88,7 +89,7 @@ struct user {
#endif #endif
hash_t connections; hash_t connections;
int in_use; /* for mark and sweep on reload */ int in_use:1; /* for mark and sweep on reload */
}; };
struct network struct network

View File

@ -91,6 +91,7 @@ list_t *parse_conf(FILE *file, int *err)
"backlog_always" { return LEX_ALWAYS_BACKLOG; } "backlog_always" { return LEX_ALWAYS_BACKLOG; }
"backlog_msg_only" { return LEX_BL_MSG_ONLY; } "backlog_msg_only" { return LEX_BL_MSG_ONLY; }
"backlog_reset_on_talk" { return LEX_BLRESET_ON_TALK; } "backlog_reset_on_talk" { return LEX_BLRESET_ON_TALK; }
"backlog_reset_connection" { return LEX_BLRESET_CONNECTION; }
"blreset_on_talk" { return LEX_BLRESET_ON_TALK; } "blreset_on_talk" { return LEX_BLRESET_ON_TALK; }
"bl_msg_only" { return LEX_BL_MSG_ONLY; } "bl_msg_only" { return LEX_BL_MSG_ONLY; }
"always_backlog" { return LEX_ALWAYS_BACKLOG; } "always_backlog" { return LEX_ALWAYS_BACKLOG; }

View File

@ -678,7 +678,7 @@ static void log_drop(log_t *log, const char *storename)
log_store_free(store); log_store_free(store);
} }
void log_reinit_all(log_t *logdata) void log_reset_all(log_t *logdata)
{ {
logstore_t *store; logstore_t *store;
hash_iterator_t hi; hash_iterator_t hi;
@ -706,7 +706,7 @@ void log_client_none_connected(log_t *logdata)
if (logdata->user->always_backlog) if (logdata->user->always_backlog)
return; return;
log_reinit_all(logdata); log_reset_all(logdata);
} }
void log_client_connected(log_t *logdata) void log_client_connected(log_t *logdata)

View File

@ -97,7 +97,7 @@ int log_has_backlog(log_t *logdata, const char *destination);
void log_flush_all(void); void log_flush_all(void);
void log_client_none_connected(log_t *logdata); void log_client_none_connected(log_t *logdata);
void log_reset(logstore_t *); void log_reset(logstore_t *);
void log_reinit_all(log_t *logdata); void log_reset_all(log_t *logdata);
void log_free(log_t *log); void log_free(log_t *log);
int check_dir(char *filename, int is_fatal); int check_dir(char *filename, int is_fatal);
void log_reset_store(log_t *log, const char *storename); void log_reset_store(log_t *log, const char *storename);