summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-06-02 01:15:51 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-06-02 01:15:51 +0000
commitbf61b699da3fd504769714d185943d8bda388dac (patch)
tree243e7f6304c2b87aef98cad79efefa8db82f0965
parentd2df583801ad5c6cd73673155151586293ad2189 (diff)
downloadirssi-bf61b699da3fd504769714d185943d8bda388dac.zip
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
-rw-r--r--src/fe-common/core/fe-log.c21
-rw-r--r--src/fe-common/core/module-formats.c2
-rw-r--r--src/fe-common/core/module-formats.h2
-rw-r--r--src/irc/core/irc-log.c26
4 files changed, 51 insertions, 0 deletions
diff --git a/src/fe-common/core/fe-log.c b/src/fe-common/core/fe-log.c
index 6dcf7e40..116821c3 100644
--- a/src/fe-common/core/fe-log.c
+++ b/src/fe-common/core/fe-log.c
@@ -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);
}
diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c
index abbf0f46..2371db45 100644
--- a/src/fe-common/core/module-formats.c
+++ b/src/fe-common/core/module-formats.c
@@ -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 },
diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h
index 137c718f..cc38d4ae 100644
--- a/src/fe-common/core/module-formats.h
+++ b/src/fe-common/core/module-formats.h
@@ -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,
diff --git a/src/irc/core/irc-log.c b/src/irc/core/irc-log.c
index 9773a29a..b454192a 100644
--- a/src/irc/core/irc-log.c
+++ b/src/irc/core/irc-log.c
@@ -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);
}