1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Awaylog is printed to screen when you set yourself unaway.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@275 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2000-06-02 01:15:51 +00:00 committed by cras
parent d2df583801
commit bf61b699da
4 changed files with 51 additions and 0 deletions

View File

@ -375,6 +375,25 @@ static void sig_log_create_failed(LOG_REC *log)
IRCTXT_LOG_CREATE_FAILED, log->fname, g_strerror(errno));
}
static void sig_awaylog_show(LOG_REC *log, gpointer pmsgs, gpointer pfilepos)
{
char *str;
int msgs, filepos;
msgs = GPOINTER_TO_INT(pmsgs);
filepos = GPOINTER_TO_INT(pfilepos);
if (msgs == 0)
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_LOG_NO_AWAY_MSGS, log->fname);
else {
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, IRCTXT_LOG_AWAY_MSGS, log->fname, msgs);
str = g_strdup_printf("\"%s\" %d", log->fname, filepos);
signal_emit("command cat", 1, str);
g_free(str);
}
}
static void read_settings(void)
{
int old_autolog = autolog_level;
@ -411,6 +430,7 @@ void fe_log_init(void)
signal_add("window refnum changed", (SIGNAL_FUNC) sig_window_refnum_changed);
signal_add("log locked", (SIGNAL_FUNC) sig_log_locked);
signal_add("log create failed", (SIGNAL_FUNC) sig_log_create_failed);
signal_add("awaylog show", (SIGNAL_FUNC) sig_awaylog_show);
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
}
@ -431,5 +451,6 @@ void fe_log_deinit(void)
signal_remove("window refnum changed", (SIGNAL_FUNC) sig_window_refnum_changed);
signal_remove("log locked", (SIGNAL_FUNC) sig_log_locked);
signal_remove("log create failed", (SIGNAL_FUNC) sig_log_create_failed);
signal_remove("awaylog show", (SIGNAL_FUNC) sig_awaylog_show);
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
}

View File

@ -83,6 +83,8 @@ FORMAT_REC fecommon_core_formats[] = {
{ "log_list_footer", "", 0 },
{ "windowlog_file", "Window LOGFILE set to $0", 1, { 0 } },
{ "windowlog_file_logging", "Can't change window's logfile while log is on", 0 },
{ "no_away_msgs", "No new messages in awaylog", 1, { 0 } },
{ "away_msgs", "$1 new messages in awaylog:", 2, { 0, 1 } },
/* ---- */
{ NULL, "Misc", 0 },

View File

@ -57,6 +57,8 @@ enum {
IRCTXT_LOG_LIST_FOOTER,
IRCTXT_WINDOWLOG_FILE,
IRCTXT_WINDOWLOG_FILE_LOGGING,
IRCTXT_LOG_NO_AWAY_MSGS,
IRCTXT_LOG_AWAY_MSGS,
IRCTXT_FILL_6,

View File

@ -26,6 +26,17 @@
#include "irc-server.h"
static LOG_REC *awaylog;
static int away_filepos;
static int away_msgs;
static void sig_log_written(LOG_REC *log)
{
if (log != awaylog) return;
away_msgs++;
}
static void event_away(const char *data, IRC_SERVER_REC *server)
{
const char *fname, *levelstr;
@ -49,7 +60,12 @@ static void event_away(const char *data, IRC_SERVER_REC *server)
if (!log_start_logging(log)) {
/* creating log file failed? close it. */
log_close(log);
return;
}
awaylog = log;
away_filepos = lseek(log->handle, 0, SEEK_CUR);
away_msgs = 0;
}
static void event_unaway(const char *data, IRC_SERVER_REC *server)
@ -66,20 +82,30 @@ static void event_unaway(const char *data, IRC_SERVER_REC *server)
return;
}
if (awaylog == log) awaylog = NULL;
signal_emit("awaylog show", 3, log, GINT_TO_POINTER(away_msgs),
GINT_TO_POINTER(away_filepos));
log_close(log);
}
void irc_log_init(void)
{
awaylog = NULL;
away_filepos = 0;
away_msgs = 0;
settings_add_str("log", "awaylog_file", "~/.irssi/away.log");
settings_add_str("log", "awaylog_level", "msgs hilight");
signal_add("log written", (SIGNAL_FUNC) sig_log_written);
signal_add("event 306", (SIGNAL_FUNC) event_away);
signal_add("event 305", (SIGNAL_FUNC) event_unaway);
}
void irc_log_deinit(void)
{
signal_remove("log written", (SIGNAL_FUNC) sig_log_written);
signal_remove("event 306", (SIGNAL_FUNC) event_away);
signal_remove("event 305", (SIGNAL_FUNC) event_unaway);
}