From 316bd7d14271fdd9524175ed309a0622340b127d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 15 Jul 2001 14:07:48 +0000 Subject: Moved awaylog to core. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1629 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/core/Makefile.am | 1 + src/core/core.c | 5 ++ src/core/log-away.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++ src/irc/core/Makefile.am | 1 - src/irc/core/irc-core.c | 5 -- src/irc/core/irc-log.c | 114 --------------------------------------------- src/perl/Makefile.am | 17 +++++-- 7 files changed, 138 insertions(+), 124 deletions(-) create mode 100644 src/core/log-away.c delete mode 100644 src/irc/core/irc-log.c (limited to 'src') diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 1dc2f5f9..042ca8c6 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -27,6 +27,7 @@ libcore_a_SOURCES = \ levels.c \ line-split.c \ log.c \ + log-away.c \ masks.c \ $(memdebug_src) \ misc.c \ diff --git a/src/core/core.c b/src/core/core.c index 87816316..f0a691f6 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -48,6 +48,9 @@ void chat_commands_init(void); void chat_commands_deinit(void); +void log_away_init(void); +void log_away_deinit(void); + int irssi_gui; static char *irssi_dir, *irssi_config_file; @@ -180,6 +183,7 @@ void core_init(int argc, char *argv[]) servers_init(); write_buffer_init(); log_init(); + log_away_init(); rawlog_init(); channels_init(); @@ -206,6 +210,7 @@ void core_deinit(void) channels_deinit(); rawlog_deinit(); + log_away_deinit(); log_deinit(); write_buffer_deinit(); servers_deinit(); diff --git a/src/core/log-away.c b/src/core/log-away.c new file mode 100644 index 00000000..724e4b4a --- /dev/null +++ b/src/core/log-away.c @@ -0,0 +1,119 @@ +/* + log-away.c : Awaylog handling + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +#include "module.h" +#include "signals.h" +#include "levels.h" +#include "log.h" +#include "servers.h" +#include "settings.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 awaylog_open(void) +{ + const char *fname, *levelstr; + LOG_REC *log; + int level; + + fname = settings_get_str("awaylog_file"); + levelstr = settings_get_str("awaylog_level"); + if (*fname == '\0' || *levelstr == '\0') return; + + level = level2bits(levelstr); + if (level == 0) return; + + log = log_find(fname); + if (log != NULL && log->handle != -1) + return; /* already open */ + + if (log == NULL) { + log = log_create_rec(fname, level); + log->temp = TRUE; + log_update(log); + } + + 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 awaylog_close(void) +{ + const char *fname; + LOG_REC *log; + + fname = settings_get_str("awaylog_file"); + if (*fname == '\0') return; + + log = log_find(fname); + if (log == NULL || log->handle == -1) { + /* awaylog not open */ + 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); +} + +static void sig_away_changed(SERVER_REC *server) +{ + if (server->usermode_away) + awaylog_open(); + else + awaylog_close(); +} + +void log_away_init(void) +{ + awaylog = NULL; + away_filepos = 0; + away_msgs = 0; + + settings_add_str("log", "awaylog_file", IRSSI_DIR_SHORT"/away.log"); + settings_add_str("log", "awaylog_level", "msgs hilight"); + + signal_add("log written", (SIGNAL_FUNC) sig_log_written); + signal_add("away mode changed", (SIGNAL_FUNC) sig_away_changed); +} + +void log_away_deinit(void) +{ + signal_remove("log written", (SIGNAL_FUNC) sig_log_written); + signal_remove("away mode changed", (SIGNAL_FUNC) sig_away_changed); +} diff --git a/src/irc/core/Makefile.am b/src/irc/core/Makefile.am index 296a9a91..40204183 100644 --- a/src/irc/core/Makefile.am +++ b/src/irc/core/Makefile.am @@ -18,7 +18,6 @@ libirc_core_a_SOURCES = \ irc-chatnets.c \ irc-commands.c \ irc-expandos.c \ - irc-log.c \ irc-masks.c \ irc-nicklist.c \ irc-queries.c \ diff --git a/src/irc/core/irc-core.c b/src/irc/core/irc-core.c index cce9d0d7..b036d244 100644 --- a/src/irc/core/irc-core.c +++ b/src/irc/core/irc-core.c @@ -42,9 +42,6 @@ void irc_rawlog_deinit(void); void irc_expandos_init(void); void irc_expandos_deinit(void); -void irc_log_init(void); -void irc_log_deinit(void); - void lag_init(void); void lag_deinit(void); @@ -106,14 +103,12 @@ void irc_core_init(void) netsplit_init(); irc_rawlog_init(); irc_expandos_init(); - irc_log_init(); } void irc_core_deinit(void) { signal_emit("chat protocol deinit", 1, chat_protocol_find("IRC")); - irc_log_deinit(); irc_expandos_deinit(); irc_rawlog_deinit(); netsplit_deinit(); diff --git a/src/irc/core/irc-log.c b/src/irc/core/irc-log.c deleted file mode 100644 index 717686df..00000000 --- a/src/irc/core/irc-log.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - irc-log.c : irssi - - Copyright (C) 1999-2000 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 - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -#include "module.h" -#include "signals.h" -#include "levels.h" -#include "log.h" -#include "settings.h" - -#include "irc-servers.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(IRC_SERVER_REC *server, const char *data) -{ - const char *fname, *levelstr; - LOG_REC *log; - int level; - - fname = settings_get_str("awaylog_file"); - levelstr = settings_get_str("awaylog_level"); - if (*fname == '\0' || *levelstr == '\0') return; - - level = level2bits(levelstr); - if (level == 0) return; - - log = log_find(fname); - if (log != NULL && log->handle != -1) - return; /* already open */ - - if (log == NULL) { - log = log_create_rec(fname, level); - log->temp = TRUE; - log_update(log); - } - - 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(IRC_SERVER_REC *server, const char *data) -{ - const char *fname; - LOG_REC *log; - - fname = settings_get_str("awaylog_file"); - if (*fname == '\0') return; - - log = log_find(fname); - if (log == NULL || log->handle == -1) { - /* awaylog not open */ - 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_DIR_SHORT"/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); -} diff --git a/src/perl/Makefile.am b/src/perl/Makefile.am index 70cfee0c..5926eb2a 100644 --- a/src/perl/Makefile.am +++ b/src/perl/Makefile.am @@ -84,13 +84,21 @@ UI_SOURCES = \ ui/typemap \ ui/module.h +TEXTUI_SOURCES = \ + ui/TextUI.xs \ + ui/TextUI.pm \ + ui/Makefile.PL.in \ + ui/typemap \ + ui/module.h + EXTRA_DIST = \ libperl_dynaloader.la \ libperl_orig.la \ get-signals.pl \ $(CORE_SOURCES) \ $(IRC_SOURCES) \ - $(UI_SOURCES) + $(UI_SOURCES) \ + $(TEXTUI_SOURCES) noinst_HEADERS = \ module.h \ @@ -98,19 +106,20 @@ noinst_HEADERS = \ perl-signals.h all-local: - for dir in common irc ui; do cd $$dir && if [ ! -f Makefile ]; then if [ "x$(PERL_LIB_DIR)" = "x" ]; then $(perlpath) Makefile.PL; else $(perlpath) Makefile.PL LIB=$(PERL_LIB_DIR) PREFIX=$(PERL_LIB_DIR); fi; fi && ($(MAKE) || $(MAKE)) && cd ..; done + for dir in common irc ui textui; do cd $$dir && if [ ! -f Makefile ]; then if [ "x$(PERL_LIB_DIR)" = "x" ]; then $(perlpath) Makefile.PL; else $(perlpath) Makefile.PL LIB=$(PERL_LIB_DIR) PREFIX=$(PERL_LIB_DIR); fi; fi && ($(MAKE) || $(MAKE)) && cd ..; done # FIXME: remove after .99: the libfe_perl must not be used anymore install-exec-local: -(rm -f $(moduledir)/libfe_perl.*) - for dir in common irc ui; do cd $$dir && $(MAKE) install && cd ..; done + for dir in common irc ui textui; do cd $$dir && $(MAKE) install && cd ..; done clean-generic: - rm -f common/Irssi.c irc/Irc.c ui/UI.c + rm -f common/Irssi.c irc/Irc.c ui/UI.c textui/TextUI.c distclean: distclean-am -(cd common && $(MAKE) realclean && rm -f Makefile.PL) -(cd irc && $(MAKE) realclean && rm -f Makefile.PL) -(cd ui && $(MAKE) realclean && rm -f Makefile.PL) + -(cd textui && $(MAKE) realclean && rm -f Makefile.PL) libperl_core_la_LIBADD = $(PERL_LDFLAGS) -- cgit v1.2.3