summaryrefslogtreecommitdiff
path: root/src/irc
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 /src/irc
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
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/core/irc-log.c26
1 files changed, 26 insertions, 0 deletions
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);
}