2007-03-21 [wwp] 2.8.1cvs30
authorTristan Chabredier <wwp@claws-mail.org>
Wed, 21 Mar 2007 15:00:46 +0000 (15:00 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Wed, 21 Mar 2007 15:00:46 +0000 (15:00 +0000)
* src/Makefile.am
* src/filtering.c
* src/filtering.h
* src/folder.c
* src/folderview.c
* src/imap.c
* src/inc.c
* src/main.c
* src/mainwindow.c
* src/mainwindow.h
* src/matcher.c
* src/messageview.c
* src/news.c
* src/pop.c
* src/prefs_common.c
* src/prefs_common.h
* src/prefs_logging.c
* src/prefs_logging.h
* src/prefs_other.c
* src/procmsg.c
* src/send_message.c
* src/summaryview.c
* src/common/log.c
* src/common/log.h
* src/common/nntp.c
* src/common/session.c
* src/common/smtp.c
* src/common/socket.c
* src/etpan/imap-thread.c
* src/gtk/logwindow.c
* src/gtk/logwindow.h
* src/plugins/bogofilter/bogofilter.c
* src/plugins/spamassassin/spamassassin.c
Added debugging of filtering/processing rules.
The debug log is here 'Tools/Filtering debug window',
the options there 'Configuration/Preferences/Other/Logging',
and the log file is ~/.claws-mail/filtering.log.
Moved protocol log prefs to 'Other/Logging' as well.
To support such debugging feature, the existing log API has
been enhanced (common/log.[ch] and gtk/logwindow.[ch]) and
this impacts many external modules (commits follow).

36 files changed:
ChangeLog
PATCHSETS
configure.ac
src/Makefile.am
src/common/log.c
src/common/log.h
src/common/nntp.c
src/common/session.c
src/common/smtp.c
src/common/socket.c
src/etpan/imap-thread.c
src/filtering.c
src/filtering.h
src/folder.c
src/folderview.c
src/gtk/logwindow.c
src/gtk/logwindow.h
src/imap.c
src/inc.c
src/main.c
src/mainwindow.c
src/mainwindow.h
src/matcher.c
src/messageview.c
src/news.c
src/plugins/bogofilter/bogofilter.c
src/plugins/spamassassin/spamassassin.c
src/pop.c
src/prefs_common.c
src/prefs_common.h
src/prefs_logging.c [new file with mode: 0644]
src/prefs_logging.h [new file with mode: 0644]
src/prefs_other.c
src/procmsg.c
src/send_message.c
src/summaryview.c

index c84d1de..6004c7d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,47 @@
+2007-03-21 [wwp]       2.8.1cvs30
+
+       * src/Makefile.am
+       * src/filtering.c
+       * src/filtering.h
+       * src/folder.c
+       * src/folderview.c
+       * src/imap.c
+       * src/inc.c
+       * src/main.c
+       * src/mainwindow.c
+       * src/mainwindow.h
+       * src/matcher.c
+       * src/messageview.c
+       * src/news.c
+       * src/pop.c
+       * src/prefs_common.c
+       * src/prefs_common.h
+       * src/prefs_logging.c
+       * src/prefs_logging.h
+       * src/prefs_other.c
+       * src/procmsg.c
+       * src/send_message.c
+       * src/summaryview.c
+       * src/common/log.c
+       * src/common/log.h
+       * src/common/nntp.c
+       * src/common/session.c
+       * src/common/smtp.c
+       * src/common/socket.c
+       * src/etpan/imap-thread.c
+       * src/gtk/logwindow.c
+       * src/gtk/logwindow.h
+       * src/plugins/bogofilter/bogofilter.c
+       * src/plugins/spamassassin/spamassassin.c
+               Added debugging of filtering/processing rules.
+               The debug log is here 'Tools/Filtering debug window',
+               the options there 'Configuration/Preferences/Other/Logging',
+               and the log file is ~/.claws-mail/filtering.log.
+               Moved protocol log prefs to 'Other/Logging' as well.
+               To support such debugging feature, the existing log API has
+               been enhanced (common/log.[ch] and gtk/logwindow.[ch]) and
+               this impacts many external modules (commits follow).
+
 2007-03-21 [paul]      2.8.1cvs29
 
        * src/etpan/Makefile.am
index 0c4da3f..f6a2fd8 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.115.2.143 -r 1.115.2.144 src/main.c;  ) > 2.8.1cvs27.patchset
 ( cvs diff -u -r 1.49.2.90 -r 1.49.2.91 src/procmime.c;  ) > 2.8.1cvs28.patchset
 ( cvs diff -u -r 1.1.4.6 -r 1.1.4.7 src/etpan/Makefile.am;  cvs diff -u -r 1.1.4.74 -r 1.1.4.75 src/etpan/imap-thread.c;  ) > 2.8.1cvs29.patchset
+( cvs diff -u -r 1.155.2.54 -r 1.155.2.55 src/Makefile.am;  cvs diff -u -r 1.60.2.29 -r 1.60.2.30 src/filtering.c;  cvs diff -u -r 1.21.2.12 -r 1.21.2.13 src/filtering.h;  cvs diff -u -r 1.213.2.136 -r 1.213.2.137 src/folder.c;  cvs diff -u -r 1.207.2.151 -r 1.207.2.152 src/folderview.c;  cvs diff -u -r 1.179.2.159 -r 1.179.2.160 src/imap.c;  cvs diff -u -r 1.149.2.67 -r 1.149.2.68 src/inc.c;  cvs diff -u -r 1.115.2.144 -r 1.115.2.145 src/main.c;  cvs diff -u -r 1.274.2.177 -r 1.274.2.178 src/mainwindow.c;  cvs diff -u -r 1.39.2.33 -r 1.39.2.34 src/mainwindow.h;  cvs diff -u -r 1.75.2.38 -r 1.75.2.39 src/matcher.c;  cvs diff -u -r 1.94.2.126 -r 1.94.2.127 src/messageview.c;  cvs diff -u -r 1.101.2.36 -r 1.101.2.37 src/news.c;  cvs diff -u -r 1.56.2.47 -r 1.56.2.48 src/pop.c;  cvs diff -u -r 1.204.2.123 -r 1.204.2.124 src/prefs_common.c;  cvs diff -u -r 1.103.2.77 -r 1.103.2.78 src/prefs_common.h;  diff -u /dev/null src/prefs_logging.c;  diff -u /dev/null src/prefs_logging.h;  cvs diff -u -r 1.1.2.21 -r 1.1.2.22 src/prefs_other.c;  cvs diff -u -r 1.150.2.93 -r 1.150.2.94 src/procmsg.c;  cvs diff -u -r 1.17.2.37 -r 1.17.2.38 src/send_message.c;  cvs diff -u -r 1.395.2.286 -r 1.395.2.287 src/summaryview.c;  cvs diff -u -r 1.6.2.9 -r 1.6.2.10 src/common/log.c;  cvs diff -u -r 1.4.2.5 -r 1.4.2.6 src/common/log.h;  cvs diff -u -r 1.6.2.12 -r 1.6.2.13 src/common/nntp.c;  cvs diff -u -r 1.23.2.13 -r 1.23.2.14 src/common/session.c;  cvs diff -u -r 1.11.2.20 -r 1.11.2.21 src/common/smtp.c;  cvs diff -u -r 1.13.2.27 -r 1.13.2.28 src/common/socket.c;  cvs diff -u -r 1.1.4.75 -r 1.1.4.76 src/etpan/imap-thread.c;  cvs diff -u -r 1.1.4.27 -r 1.1.4.28 src/gtk/logwindow.c;  cvs diff -u -r 1.1.4.12 -r 1.1.4.13 src/gtk/logwindow.h;  cvs diff -u -r 1.1.2.27 -r 1.1.2.28 src/plugins/bogofilter/bogofilter.c;  cvs diff -u -r 1.18.2.48 -r 1.18.2.49 src/plugins/spamassassin/spamassassin.c;  ) > 2.8.1cvs30.patchset
index cf75d07..fac45ee 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=8
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=29
+EXTRA_VERSION=30
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 8408112..66176cb 100644 (file)
@@ -109,6 +109,7 @@ claws_mail_SOURCES = \
        prefs_fonts.c \
        prefs_gtk.c \
        prefs_image_viewer.c \
+       prefs_logging.c \
        prefs_matcher.c \
        prefs_message.c \
        prefs_msg_colors.c \
@@ -250,6 +251,7 @@ claws_mailinclude_HEADERS = \
        prefs_fonts.h \
        prefs_gtk.h \
        prefs_image_viewer.h \
+       prefs_logging.h \
        prefs_matcher.h \
        prefs_message.h \
        prefs_msg_colors.h \
index 46ad5ae..6124e78 100644 (file)
 
 #include <stdio.h>
 #include <glib.h>
+#include <glib/gi18n.h>
 
 #include "utils.h"
 #include "log.h"
 #include "hooks.h"
 
-static FILE *log_fp = NULL;
+static FILE *log_fp[LOG_INSTANCE_MAX] = {
+       NULL,
+       NULL
+};
+
+typedef struct _LogInstanceData LogInstanceData;
+
+struct _LogInstanceData {
+       const char *hook;
+       gchar *title;
+       int *prefs_logwin_width;
+       int *prefs_logwin_height;
+};
+
+static LogInstanceData log_instances[LOG_INSTANCE_MAX] = {
+       { LOG_APPEND_TEXT_HOOKLIST, NULL, NULL, NULL },
+       { DEBUG_FILTERING_APPEND_TEXT_HOOKLIST, NULL, NULL, NULL }
+};
 
 static gboolean invoke_hook_cb (gpointer data)
 {
        LogText *logtext = (LogText *)data;
-       hooks_invoke(LOG_APPEND_TEXT_HOOKLIST, logtext);
+       hooks_invoke(get_log_hook(logtext->instance), logtext);
        g_free(logtext->text);
        g_free(logtext);
        return FALSE;
 }
 
-void set_log_file(const gchar *filename)
+void set_log_file(LogInstance instance, const gchar *filename)
 {
-       if (log_fp)
+       if (log_fp[instance])
                return;
 
        /* backup old logfile if existing */
@@ -56,20 +74,49 @@ void set_log_file(const gchar *filename)
                g_free(backupname);
        }
 
-       log_fp = g_fopen(filename, "wb");
-       if (!log_fp)
+       log_fp[instance] = g_fopen(filename, "wb");
+       if (!log_fp[instance])
                FILE_OP_ERROR(filename, "fopen");
 }
 
-void close_log_file(void)
+void close_log_file(LogInstance instance)
 {
-       if (log_fp) {
-               fclose(log_fp);
-               log_fp = NULL;
+       if (log_fp[instance]) {
+               fclose(log_fp[instance]);
+               log_fp[instance] = NULL;
        }
 }
 
-void log_print(const gchar *format, ...)
+const char *get_log_hook(LogInstance instance)
+{
+       return log_instances[instance].hook;
+}
+
+void set_log_title(LogInstance instance, gchar *title)
+{
+       log_instances[instance].title = title;
+}
+
+gchar *get_log_title(LogInstance instance)
+{
+       return log_instances[instance].title;
+}
+
+void set_log_prefs(LogInstance instance, int* logwin_width, int* logwin_height)
+{
+       log_instances[instance].prefs_logwin_width = logwin_width;
+       log_instances[instance].prefs_logwin_height = logwin_height;
+}
+
+void get_log_prefs(LogInstance instance, int** logwin_width, int** logwin_height)
+{
+       if (logwin_width)
+               *logwin_width = log_instances[instance].prefs_logwin_width;
+       if (logwin_height)
+               *logwin_height = log_instances[instance].prefs_logwin_height;
+}
+
+void log_print(LogInstance instance, const gchar *format, ...)
 {
        va_list args;
        gchar buf[BUFFSIZE + LOG_TIME_LEN];
@@ -85,18 +132,19 @@ void log_print(const gchar *format, ...)
 
        if (debug_get_mode()) fputs(buf, stdout);
 
+       logtext->instance = instance;
        logtext->text = g_strdup(buf);
        logtext->type = LOG_NORMAL;
        
        g_timeout_add(0, invoke_hook_cb, logtext);
        
-       if (log_fp) {
-               fputs(buf, log_fp);
-               fflush(log_fp);
+       if (log_fp[instance]) {
+               fputs(buf, log_fp[instance]);
+               fflush(log_fp[instance]);
        }
 }
 
-void log_message(const gchar *format, ...)
+void log_message(LogInstance instance, const gchar *format, ...)
 {
        va_list args;
        gchar buf[BUFFSIZE + LOG_TIME_LEN];
@@ -111,20 +159,22 @@ void log_message(const gchar *format, ...)
        va_end(args);
 
        if (debug_get_mode()) g_message("%s", buf + LOG_TIME_LEN);
+
+       logtext->instance = instance;
        logtext->text = g_strdup(buf + LOG_TIME_LEN);
        logtext->type = LOG_MSG;
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp) {
-               fwrite(buf, 1, LOG_TIME_LEN, log_fp);
-               fputs("* message: ", log_fp);
-               fputs(buf + LOG_TIME_LEN, log_fp);
-               fflush(log_fp);
+       if (log_fp[instance]) {
+               fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
+               fputs("* message: ", log_fp[instance]);
+               fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+               fflush(log_fp[instance]);
        }
 }
 
-void log_warning(const gchar *format, ...)
+void log_warning(LogInstance instance, const gchar *format, ...)
 {
        va_list args;
        gchar buf[BUFFSIZE + LOG_TIME_LEN];
@@ -139,20 +189,22 @@ void log_warning(const gchar *format, ...)
        va_end(args);
 
        g_warning("%s", buf);
+
+       logtext->instance = instance;
        logtext->text = g_strdup(buf + LOG_TIME_LEN);
        logtext->type = LOG_WARN;
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp) {
-               fwrite(buf, 1, LOG_TIME_LEN, log_fp);
-               fputs("** warning: ", log_fp);
-               fputs(buf + LOG_TIME_LEN, log_fp);
-               fflush(log_fp);
+       if (log_fp[instance]) {
+               fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
+               fputs("** warning: ", log_fp[instance]);
+               fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+               fflush(log_fp[instance]);
        }
 }
 
-void log_error(const gchar *format, ...)
+void log_error(LogInstance instance, const gchar *format, ...)
 {
        va_list args;
        gchar buf[BUFFSIZE + LOG_TIME_LEN];
@@ -167,15 +219,107 @@ void log_error(const gchar *format, ...)
        va_end(args);
 
        g_warning("%s", buf);
+
+       logtext->instance = instance;
        logtext->text = g_strdup(buf + LOG_TIME_LEN);
        logtext->type = LOG_ERROR;
        
        g_timeout_add(0, invoke_hook_cb, logtext);
 
-       if (log_fp) {
-               fwrite(buf, 1, LOG_TIME_LEN, log_fp);
-               fputs("*** error: ", log_fp);
-               fputs(buf + LOG_TIME_LEN, log_fp);
-               fflush(log_fp);
+       if (log_fp[instance]) {
+               fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
+               fputs("*** error: ", log_fp[instance]);
+               fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+               fflush(log_fp[instance]);
+       }
+}
+
+void log_status_ok(LogInstance instance, const gchar *format, ...)
+{
+       va_list args;
+       gchar buf[BUFFSIZE + LOG_TIME_LEN];
+       time_t t;
+       LogText *logtext = g_new0(LogText, 1);
+
+       time(&t);
+       strftime(buf, LOG_TIME_LEN + 1, "[%H:%M:%S] ", localtime(&t));
+
+       va_start(args, format);
+       g_vsnprintf(buf + LOG_TIME_LEN, BUFFSIZE, format, args);
+       va_end(args);
+
+       if (debug_get_mode()) g_message("%s", buf + LOG_TIME_LEN);
+
+       logtext->instance = instance;
+       logtext->text = g_strdup(buf + LOG_TIME_LEN);
+       logtext->type = LOG_STATUS_OK;
+       
+       g_timeout_add(0, invoke_hook_cb, logtext);
+
+       if (log_fp[instance]) {
+               fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
+               fputs("* OK: ", log_fp[instance]);
+               fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+               fflush(log_fp[instance]);
+       }
+}
+
+void log_status_nok(LogInstance instance, const gchar *format, ...)
+{
+       va_list args;
+       gchar buf[BUFFSIZE + LOG_TIME_LEN];
+       time_t t;
+       LogText *logtext = g_new0(LogText, 1);
+
+       time(&t);
+       strftime(buf, LOG_TIME_LEN + 1, "[%H:%M:%S] ", localtime(&t));
+
+       va_start(args, format);
+       g_vsnprintf(buf + LOG_TIME_LEN, BUFFSIZE, format, args);
+       va_end(args);
+
+       if (debug_get_mode()) g_message("%s", buf + LOG_TIME_LEN);
+
+       logtext->instance = instance;
+       logtext->text = g_strdup(buf + LOG_TIME_LEN);
+       logtext->type = LOG_STATUS_NOK;
+       
+       g_timeout_add(0, invoke_hook_cb, logtext);
+
+       if (log_fp[instance]) {
+               fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
+               fputs("* NOT OK: ", log_fp[instance]);
+               fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+               fflush(log_fp[instance]);
+       }
+}
+
+void log_status_skip(LogInstance instance, const gchar *format, ...)
+{
+       va_list args;
+       gchar buf[BUFFSIZE + LOG_TIME_LEN];
+       time_t t;
+       LogText *logtext = g_new0(LogText, 1);
+
+       time(&t);
+       strftime(buf, LOG_TIME_LEN + 1, "[%H:%M:%S] ", localtime(&t));
+
+       va_start(args, format);
+       g_vsnprintf(buf + LOG_TIME_LEN, BUFFSIZE, format, args);
+       va_end(args);
+
+       if (debug_get_mode()) g_message("%s", buf + LOG_TIME_LEN);
+
+       logtext->instance = instance;
+       logtext->text = g_strdup(buf + LOG_TIME_LEN);
+       logtext->type = LOG_STATUS_SKIP;
+       
+       g_timeout_add(0, invoke_hook_cb, logtext);
+
+       if (log_fp[instance]) {
+               fwrite(buf, 1, LOG_TIME_LEN, log_fp[instance]);
+               fputs("* SKIPPED: ", log_fp[instance]);
+               fputs(buf + LOG_TIME_LEN, log_fp[instance]);
+               fflush(log_fp[instance]);
        }
 }
index a1237c3..43920cb 100644 (file)
 #include <glib.h>
 
 #define LOG_APPEND_TEXT_HOOKLIST "log_append_text"
+#define DEBUG_FILTERING_APPEND_TEXT_HOOKLIST "debug_append_text"
+
 #define LOG_TIME_LEN 11
 
+typedef enum
+{
+       LOG_PROTOCOL = 0,
+       LOG_DEBUG_FILTERING,
+       /* reserved */
+       LOG_INSTANCE_MAX
+} LogInstance;
+
 typedef enum
 {
        LOG_NORMAL,
        LOG_MSG,
        LOG_WARN,
-       LOG_ERROR
+       LOG_ERROR,
+       LOG_STATUS_OK,
+       LOG_STATUS_NOK,
+       LOG_STATUS_SKIP
 } LogType;
 
 typedef struct _LogText LogText;
 
 struct _LogText
 {
+       LogInstance  instance;
        gchar           *text;
        LogType          type;  
 };
 
 /* logging */
-void set_log_file      (const gchar *filename);
-void close_log_file    (void);
-void log_verbosity_set (gboolean verbose);
-void log_print         (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
-void log_message       (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
-void log_warning       (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
-void log_error         (const gchar *format, ...) G_GNUC_PRINTF(1, 2);
+void set_log_file      (LogInstance instance, const gchar *filename);
+void close_log_file    (LogInstance instance);
+const char *get_log_hook(LogInstance instance);
+void set_log_title(LogInstance instance, gchar *title);
+gchar *get_log_title(LogInstance instance);
+void set_log_prefs(LogInstance instance, int* logwin_width, int* logwin_height);
+void get_log_prefs(LogInstance instance, int** logwin_width, int** logwin_height);
+void log_print         (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
+void log_message       (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
+void log_warning       (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
+void log_error         (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
+void log_status_ok     (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
+void log_status_nok    (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
+void log_status_skip   (LogInstance instance, const gchar *format, ...) G_GNUC_PRINTF(2, 3);
 
 #endif /* LOG_H */
index 1a13fa7..4c5cbc1 100644 (file)
@@ -70,14 +70,14 @@ Session *nntp_session_new(const gchar *server, gushort port, gchar *buf,
        SockInfo *sock;
 
        if ((sock = sock_connect(server, port)) == NULL) {
-               log_warning(_("Can't connect to NNTP server: %s:%d\n"),
+               log_warning(LOG_PROTOCOL, _("Can't connect to NNTP server: %s:%d\n"),
                            server, port);
                return NULL;
        }
 
 #if USE_OPENSSL
        if (ssl_type == SSL_TUNNEL && !ssl_init_socket(sock)) {
-               log_error(_("SSL handshake failed\n"));
+               log_error(LOG_PROTOCOL, _("SSL handshake failed\n"));
                sock_close(sock);
                return NULL;
        }
@@ -179,7 +179,7 @@ gint nntp_group(NNTPSession *session, const gchar *group,
 
        if (sscanf(buf, "%d %d %d %d", &resp, num, first, last)
            != 4) {
-               log_warning(_("protocol error: %s\n"), buf);
+               log_warning(LOG_PROTOCOL, _("protocol error: %s\n"), buf);
                return NN_PROTOCOL;
        }
 
@@ -202,7 +202,7 @@ gint nntp_get_article(NNTPSession *session, const gchar *cmd, gint num,
 
        extract_parenthesis(buf, '<', '>');
        if (buf[0] == '\0') {
-               log_warning(_("protocol error\n"));
+               log_warning(LOG_PROTOCOL, _("protocol error\n"));
                *msgid = g_strdup("0");
        } else
                *msgid = g_strdup(buf);
@@ -242,13 +242,13 @@ gint nntp_next(NNTPSession *session, gint *num, gchar **msgid)
                return ok;
 
        if (sscanf(buf, "%d %d", &resp, num) != 2) {
-               log_warning(_("protocol error: %s\n"), buf);
+               log_warning(LOG_PROTOCOL, _("protocol error: %s\n"), buf);
                return NN_PROTOCOL;
        }
 
        extract_parenthesis(buf, '<', '>');
        if (buf[0] == '\0') {
-               log_warning(_("protocol error\n"));
+               log_warning(LOG_PROTOCOL, _("protocol error\n"));
                return NN_PROTOCOL;
        }
        *msgid = g_strdup(buf);
@@ -298,7 +298,7 @@ gint nntp_post(NNTPSession *session, FILE *fp)
 
        msg = get_outgoing_rfc2822_str(fp);
        if (sock_write_all(SESSION(session)->sock, msg, strlen(msg)) < 0) {
-               log_warning(_("Error occurred while posting\n"));
+               log_warning(LOG_PROTOCOL, _("Error occurred while posting\n"));
                g_free(msg);
                return NN_SOCKET;
        }
@@ -371,14 +371,14 @@ static gint nntp_gen_send(SockInfo *sock, const gchar *format, ...)
 
        if (verbose) {
                if (!g_ascii_strncasecmp(buf, "AUTHINFO PASS", 13))
-                       log_print("NNTP> AUTHINFO PASS ********\n");
+                       log_print(LOG_PROTOCOL, "NNTP> AUTHINFO PASS ********\n");
                else
-                       log_print("NNTP> %s\n", buf);
+                       log_print(LOG_PROTOCOL, "NNTP> %s\n", buf);
        }
 
        strcat(buf, "\r\n");
        if (sock_write_all(sock, buf, strlen(buf)) < 0) {
-               log_warning(_("Error occurred while sending command\n"));
+               log_warning(LOG_PROTOCOL, _("Error occurred while sending command\n"));
                return NN_SOCKET;
        }
 
@@ -393,7 +393,7 @@ static gint nntp_gen_recv(SockInfo *sock, gchar *buf, gint size)
        strretchomp(buf);
 
        if (verbose)
-               log_print("NNTP< %s\n", buf);
+               log_print(LOG_PROTOCOL, "NNTP< %s\n", buf);
 
        return NN_SUCCESS;
 }
index 35dd6bf..2196853 100644 (file)
@@ -163,7 +163,7 @@ static gint session_connect_cb(SockInfo *sock, gpointer data)
                sock_set_nonblocking_mode(sock, FALSE);
                if (!ssl_init_socket(sock)) {
                        g_warning("can't initialize SSL.");
-                       log_error(_("SSL handshake failed\n"));
+                       log_error(LOG_PROTOCOL, _("SSL handshake failed\n"));
                        session->state = SESSION_ERROR;
                        return -1;
                }
index 952322e..64f6ed9 100644 (file)
@@ -148,7 +148,7 @@ gint smtp_from(SMTPSession *session)
 
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
                return SM_ERROR;
-       log_print("%sSMTP> %s\n", (session->is_esmtp?"E":""), buf);
+       log_print(LOG_PROTOCOL, "%sSMTP> %s\n", (session->is_esmtp?"E":""), buf);
 
        return SM_OK;
 }
@@ -173,7 +173,7 @@ static gint smtp_auth(SMTPSession *session)
                  (session->avail_auth_type & SMTPAUTH_PLAIN) != 0))
                smtp_auth_plain(session);
        else {
-               log_warning(_("SMTP AUTH not available\n"));
+               log_warning(LOG_PROTOCOL, _("SMTP AUTH not available\n"));
                return SM_AUTHFAIL;
        }
 
@@ -194,13 +194,13 @@ static gint smtp_auth_recv(SMTPSession *session, const gchar *msg)
                        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
                                         buf) < 0)
                                return SM_ERROR;
-                       log_print("ESMTP> [USERID]\n");
+                       log_print(LOG_PROTOCOL, "ESMTP> [USERID]\n");
                } else {
                        /* Server rejects AUTH */
                        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
                                         "*") < 0)
                                return SM_ERROR;
-                       log_print("ESMTP> *\n");
+                       log_print(LOG_PROTOCOL, "ESMTP> *\n");
                }
                break;
        case SMTPAUTH_CRAM_MD5:
@@ -216,7 +216,7 @@ static gint smtp_auth_recv(SMTPSession *session, const gchar *msg)
                        challenge = g_malloc(strlen(msg + 4) + 1);
                        challengelen = base64_decode(challenge, msg + 4, -1);
                        challenge[challengelen] = '\0';
-                       log_print("ESMTP< [Decoded: %s]\n", challenge);
+                       log_print(LOG_PROTOCOL, "ESMTP< [Decoded: %s]\n", challenge);
 
                        g_snprintf(buf, sizeof(buf), "%s", session->pass);
                        md5_hex_hmac(hexdigest, challenge, challengelen,
@@ -225,7 +225,7 @@ static gint smtp_auth_recv(SMTPSession *session, const gchar *msg)
 
                        response = g_strdup_printf
                                ("%s %s", session->user, hexdigest);
-                       log_print("ESMTP> [Encoded: %s]\n", response);
+                       log_print(LOG_PROTOCOL, "ESMTP> [Encoded: %s]\n", response);
 
                        response64 = g_malloc((strlen(response) + 3) * 2 + 1);
                        base64_encode(response64, response, strlen(response));
@@ -234,14 +234,14 @@ static gint smtp_auth_recv(SMTPSession *session, const gchar *msg)
                        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
                                         response64) < 0)
                                return SM_ERROR;
-                       log_print("ESMTP> %s\n", response64);
+                       log_print(LOG_PROTOCOL, "ESMTP> %s\n", response64);
                        g_free(response64);
                } else {
                        /* Server rejects AUTH */
                        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL,
                                         "*") < 0)
                                return SM_ERROR;
-                       log_print("ESMTP> *\n");
+                       log_print(LOG_PROTOCOL, "ESMTP> *\n");
                }
                break;
        case SMTPAUTH_DIGEST_MD5:
@@ -249,7 +249,7 @@ static gint smtp_auth_recv(SMTPSession *session, const gchar *msg)
                /* stop smtp_auth when no correct authtype */
                if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "*") < 0)
                        return SM_ERROR;
-               log_print("ESMTP> *\n");
+               log_print(LOG_PROTOCOL, "ESMTP> *\n");
                break;
        }
 
@@ -271,7 +271,7 @@ static gint smtp_auth_login_user_recv(SMTPSession *session, const gchar *msg)
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
                return SM_ERROR;
 
-       log_print("ESMTP> [PASSWORD]\n");
+       log_print(LOG_PROTOCOL, "ESMTP> [PASSWORD]\n");
 
        return SM_OK;
 }
@@ -288,7 +288,7 @@ static gint smtp_ehlo(SMTPSession *session)
                   session->hostname ? session->hostname : get_domain_name());
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
                return SM_ERROR;
-       log_print("ESMTP> %s\n", buf);
+       log_print(LOG_PROTOCOL, "ESMTP> %s\n", buf);
 
        return SM_OK;
 }
@@ -337,7 +337,7 @@ static gint smtp_starttls(SMTPSession *session)
 
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "STARTTLS") < 0)
                return SM_ERROR;
-       log_print("ESMTP> STARTTLS\n");
+       log_print(LOG_PROTOCOL, "ESMTP> STARTTLS\n");
 
        return SM_OK;
 }
@@ -350,7 +350,7 @@ static gint smtp_auth_cram_md5(SMTPSession *session)
 
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "AUTH CRAM-MD5") < 0)
                return SM_ERROR;
-       log_print("ESMTP> AUTH CRAM-MD5\n");
+       log_print(LOG_PROTOCOL, "ESMTP> AUTH CRAM-MD5\n");
 
        return SM_OK;
 }
@@ -401,7 +401,7 @@ static gint smtp_auth_plain(SMTPSession *session)
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
                return SM_ERROR;
 
-       log_print("ESMTP> [AUTH PLAIN]\n");
+       log_print(LOG_PROTOCOL, "ESMTP> [AUTH PLAIN]\n");
 
        g_free(b64buf);
 
@@ -415,7 +415,7 @@ static gint smtp_auth_login(SMTPSession *session)
 
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "AUTH LOGIN") < 0)
                return SM_ERROR;
-       log_print("ESMTP> AUTH LOGIN\n");
+       log_print(LOG_PROTOCOL, "ESMTP> AUTH LOGIN\n");
 
        return SM_OK;
 }
@@ -430,7 +430,7 @@ static gint smtp_helo(SMTPSession *session)
                   session->hostname ? session->hostname : get_domain_name());
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
                return SM_ERROR;
-       log_print("SMTP> %s\n", buf);
+       log_print(LOG_PROTOCOL, "SMTP> %s\n", buf);
 
        return SM_OK;
 }
@@ -452,7 +452,7 @@ static gint smtp_rcpt(SMTPSession *session)
                g_snprintf(buf, sizeof(buf), "RCPT TO:<%s>", to);
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf) < 0)
                return SM_ERROR;
-       log_print("SMTP> %s\n", buf);
+       log_print(LOG_PROTOCOL, "SMTP> %s\n", buf);
 
        session->cur_to = session->cur_to->next;
 
@@ -465,7 +465,7 @@ static gint smtp_data(SMTPSession *session)
 
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "DATA") < 0)
                return SM_ERROR;
-       log_print("SMTP> DATA\n");
+       log_print(LOG_PROTOCOL, "SMTP> DATA\n");
 
        return SM_OK;
 }
@@ -492,7 +492,7 @@ gint smtp_quit(SMTPSession *session)
        session->state = SMTP_QUIT;
 
        session_send_msg(SESSION(session), SESSION_MSG_NORMAL, "QUIT");
-       log_print("SMTP> QUIT\n");
+       log_print(LOG_PROTOCOL, "SMTP> QUIT\n");
 
        return SM_OK;
 }
@@ -503,7 +503,7 @@ static gint smtp_eom(SMTPSession *session)
 
        if (session_send_msg(SESSION(session), SESSION_MSG_NORMAL, ".") < 0)
                return SM_ERROR;
-       log_print("SMTP> . (EOM)\n");
+       log_print(LOG_PROTOCOL, "SMTP> . (EOM)\n");
 
        return SM_OK;
 }
@@ -515,7 +515,7 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
        gint ret = 0;
        
        if (strlen(msg) < 4) {
-               log_warning(_("bad SMTP response\n"));
+               log_warning(LOG_PROTOCOL, _("bad SMTP response\n"));
                return -1;
        }
 
@@ -527,16 +527,16 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
        case SMTP_AUTH_LOGIN_USER:
        case SMTP_AUTH_LOGIN_PASS:
        case SMTP_AUTH_CRAM_MD5:
-               log_print("ESMTP< %s\n", msg);
+               log_print(LOG_PROTOCOL, "ESMTP< %s\n", msg);
                break;
        default:
-               log_print("SMTP< %s\n", msg);
+               log_print(LOG_PROTOCOL, "SMTP< %s\n", msg);
                break;
        }
 
        if (msg[0] == '5' && msg[1] == '0' &&
            (msg[2] == '4' || msg[2] == '3' || msg[2] == '1')) {
-               log_warning(_("error occurred on SMTP session\n"));
+               log_warning(LOG_PROTOCOL, _("error occurred on SMTP session\n"));
                smtp_session->state = SMTP_ERROR;
                smtp_session->error_val = SM_ERROR;
                g_free(smtp_session->error_msg);
@@ -545,7 +545,7 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
        }
 
        if (!strncmp(msg, "535", 3)) {
-               log_warning(_("error occurred on authentication\n"));
+               log_warning(LOG_PROTOCOL, _("error occurred on authentication\n"));
                smtp_session->state = SMTP_ERROR;
                smtp_session->error_val = SM_AUTHFAIL;
                g_free(smtp_session->error_msg);
@@ -554,7 +554,7 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
        }
 
        if (msg[0] != '1' && msg[0] != '2' && msg[0] != '3') {
-               log_warning(_("error occurred on SMTP session\n"));
+               log_warning(LOG_PROTOCOL, _("error occurred on SMTP session\n"));
                smtp_session->state = SMTP_ERROR;
                smtp_session->error_val = SM_ERROR;
                g_free(smtp_session->error_msg);
@@ -565,7 +565,7 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
        if (msg[3] == '-')
                cont = TRUE;
        else if (msg[3] != ' ' && msg[3] != '\0') {
-               log_warning(_("bad SMTP response\n"));
+               log_warning(LOG_PROTOCOL, _("bad SMTP response\n"));
                smtp_session->state = SMTP_ERROR;
                smtp_session->error_val = SM_UNRECOVERABLE;
                return -1;
@@ -600,7 +600,7 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
                if (smtp_session->max_message_size > 0
                && smtp_session->max_message_size < 
                   smtp_session->send_data_len) {
-                       log_warning(_("Message is too big "
+                       log_warning(LOG_PROTOCOL, _("Message is too big "
                              "(Maximum size is %s)\n"),
                              to_human_readable(
                               (off_t)(smtp_session->max_message_size)));
@@ -632,7 +632,7 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
        case SMTP_STARTTLS:
 #if USE_OPENSSL
                if (session_start_tls(session) < 0) {
-                       log_warning(_("couldn't start TLS session\n"));
+                       log_warning(LOG_PROTOCOL, _("couldn't start TLS session\n"));
                        smtp_session->state = SMTP_ERROR;
                        smtp_session->error_val = SM_ERROR;
                        return -1;
@@ -673,7 +673,7 @@ static gint smtp_session_recv_msg(Session *session, const gchar *msg)
                break;
        case SMTP_ERROR:
        default:
-               log_warning(_("error occurred on SMTP session\n"));
+               log_warning(LOG_PROTOCOL, _("error occurred on SMTP session\n"));
                smtp_session->error_val = SM_ERROR;
                return -1;
        }
index 32449cb..42e2e11 100644 (file)
@@ -679,7 +679,7 @@ SockInfo *sock_connect_cmd(const gchar *hostname, const gchar *tunnelcmd)
                perror("socketpair");
                return NULL;
        }
-       log_message("launching tunnel command \"%s\"\n", tunnelcmd);
+       log_message(LOG_PROTOCOL, "launching tunnel command \"%s\"\n", tunnelcmd);
        if (fork() == 0) {
                close(fd[0]);
                close(0);
@@ -1390,7 +1390,7 @@ gint fd_write_all(gint fd, const gchar *buf, gint len)
                         n = write(fd, buf, len);
 
                if (n <= 0) {
-                       log_error(_("write on fd%d: %s\n"), fd, strerror(errno));
+                       log_error(LOG_PROTOCOL, _("write on fd%d: %s\n"), fd, strerror(errno));
                        return -1;
                }
                len -= n;
index 9cc078e..5b7c356 100644 (file)
@@ -90,7 +90,7 @@ static void imap_logger_cmd(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 8192) {
-               log_print("IMAP4%c [CMD data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP4%c [CMD data - %zd bytes]\n", direction?'>':'<', size);
                return;
        }
        buf = malloc(size+1);
@@ -111,7 +111,7 @@ static void imap_logger_cmd(int direction, const char * str, size_t size)
        lines = g_strsplit(buf, "\n", -1);
 
        while (lines[i] && *lines[i]) {
-               log_print("IMAP4%c %s\n", direction?'>':'<', lines[i]);
+               log_print(LOG_PROTOCOL, "IMAP4%c %s\n", direction?'>':'<', lines[i]);
                i++;
        }
        g_strfreev(lines);
@@ -125,7 +125,7 @@ static void imap_logger_fetch(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 8192) {
-               log_print("IMAP4%c [FETCH data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP4%c [FETCH data - %zd bytes]\n", direction?'>':'<', size);
                return;
        }
        
@@ -147,11 +147,11 @@ static void imap_logger_fetch(int direction, const char * str, size_t size)
 
        if (direction != 0 || (buf[0] == '*' && buf[1] == ' ') || size < 32) {
                while (lines[i] && *lines[i]) {
-                       log_print("IMAP4%c %s\n", direction?'>':'<', lines[i]);
+                       log_print(LOG_PROTOCOL, "IMAP4%c %s\n", direction?'>':'<', lines[i]);
                        i++;
                }
        } else {
-               log_print("IMAP4%c [data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP4%c [data - %zd bytes]\n", direction?'>':'<', size);
        }
        g_strfreev(lines);
        free(buf);
@@ -164,7 +164,7 @@ static void imap_logger_uid(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 8192) {
-               log_print("IMAP4%c [UID data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP4%c [UID data - %zd bytes]\n", direction?'>':'<', size);
                return;
        }
        buf = malloc(size+1);
@@ -186,11 +186,11 @@ static void imap_logger_uid(int direction, const char * str, size_t size)
        while (lines[i] && *lines[i]) {
                int llen = strlen(lines[i]);
                if (llen < 64)
-                       log_print("IMAP4%c %s\n", direction?'>':'<', lines[i]);
+                       log_print(LOG_PROTOCOL, "IMAP4%c %s\n", direction?'>':'<', lines[i]);
                else {
                        gchar tmp[64];
                        strncpy2(tmp, lines[i], 63);
-                       log_print("IMAP4%c %s[... - %zd bytes more]\n", direction?'>':'<', tmp,
+                       log_print(LOG_PROTOCOL, "IMAP4%c %s[... - %zd bytes more]\n", direction?'>':'<', tmp,
                                  llen-64);
                }
                i++;
@@ -206,10 +206,10 @@ static void imap_logger_append(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 8192) {
-               log_print("IMAP4%c [APPEND data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP4%c [APPEND data - %zd bytes]\n", direction?'>':'<', size);
                return;
        } else if (direction == 0 && size > 64) {
-               log_print("IMAP4%c [APPEND data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP4%c [APPEND data - %zd bytes]\n", direction?'>':'<', size);
                return;
        } 
        buf = malloc(size+1);
@@ -230,11 +230,11 @@ static void imap_logger_append(int direction, const char * str, size_t size)
 
        if (direction == 0 || (buf[0] == '*' && buf[1] == ' ') || size < 64) {
                while (lines[i] && *lines[i]) {
-                       log_print("IMAP4%c %s\n", direction?'>':'<', lines[i]);
+                       log_print(LOG_PROTOCOL, "IMAP4%c %s\n", direction?'>':'<', lines[i]);
                        i++;
                }
        } else {
-               log_print("IMAP4%c [data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP4%c [data - %zd bytes]\n", direction?'>':'<', size);
        }
        g_strfreev(lines);
        free(buf);
@@ -376,7 +376,7 @@ static void generic_cb(int cancelled, void * result, void * callback_data)
        debug_print("generic_cb\n");
        if (op->imap && op->imap->imap_response_info &&
            op->imap->imap_response_info->rsp_alert) {
-               log_error("IMAP4< Alert: %s\n", 
+               log_error(LOG_PROTOCOL, "IMAP4< Alert: %s\n", 
                        op->imap->imap_response_info->rsp_alert);
                mainwindow_show_error();
        } 
index be445ad..c75d43d 100644 (file)
@@ -36,6 +36,7 @@
 #include "prefs_common.h"
 #include "addrbook.h"
 #include "addr_compl.h"
+#include "log.h"
 
 #define PREFSBUFSIZE           1024
 
@@ -43,6 +44,8 @@ GSList * pre_global_processing = NULL;
 GSList * post_global_processing = NULL;
 GSList * filtering_rules = NULL;
 
+gboolean debug_filtering_session = FALSE;
+
 static gboolean filtering_is_final_action(FilteringAction *filtering_action);
 
 #define STRLEN_WITH_CHECK(expr) \
@@ -500,25 +503,156 @@ gboolean filteringaction_apply_action_list(GSList *action_list, MsgInfo *info)
 
 static gboolean filtering_match_condition(FilteringProp *filtering, MsgInfo *info,
                                                        PrefsAccount *ac_prefs)
+
+/* this function returns true if a filtering rule applies regarding to its account
+   data and if it does, if the conditions list match.
+
+   per-account data of a filtering rule is either matched against current account
+   when filtering is done manually, or against the account currently used for
+   retrieving messages when it's an manual or automatic fetching of messages.
+   per-account data match doesn't apply to pre-/post-/folder-processing rules.
+
+   when filtering messages manually:
+    - either the filtering rule is not account-based and it will be processed
+       - or it's per-account and we check if we HAVE TO match it against the current
+         account (according to user-land settings, per-account rules might have to
+         be skipped, or only the rules that match the current account have to be
+         applied, or all rules will have to be applied regardless to if they are
+         account-based or not)
+
+   notes about debugging output in that function:
+   when not matching, log_status_skip() is used, otherwise log_status_ok() is used
+   no debug output is done when filtering_debug_level is low
+*/
 {
        gboolean matches = FALSE;
 
        if (ac_prefs != NULL) {
                matches = ((filtering->account_id == 0)
                                        || (filtering->account_id == ac_prefs->account_id));
+
+               /* debug output */
+               if (debug_filtering_session) {
+                       if (matches && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                               if (filtering->account_id == 0) {
+                                       log_status_ok(LOG_DEBUG_FILTERING,
+                                                       _("rule is not account-based\n"));
+                               } else {
+                                       if (prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_MED) {
+                                               log_status_ok(LOG_DEBUG_FILTERING,
+                                                               _("rule is account-based [id=%d, name='%s'], "
+                                                               "matching the account currently used to retrieve messages\n"),
+                                                               ac_prefs->account_id, ac_prefs->account_name);
+                                       }
+                               }
+                       }
+                       else
+                       if (!matches) {
+                               if (prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_MED) {
+                                       log_status_skip(LOG_DEBUG_FILTERING,
+                                                       _("rule is account-based, "
+                                                       "not matching the account currently used to retrieve messages\n"));
+                               } else {
+                                       if (prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                               PrefsAccount *account = account_find_from_id(filtering->account_id);
+
+                                               log_status_skip(LOG_DEBUG_FILTERING,
+                                                               _("rule is account-based [id=%d, name='%s'], "
+                                                               "not matching the account currently used to retrieve messages [id=%d, name='%s']\n"),
+                                                               filtering->account_id, account->account_name,
+                                                               ac_prefs->account_id, ac_prefs->account_name);
+                                       }
+                               }
+                       }
+               }
        } else {
                switch (prefs_common.apply_per_account_filtering_rules) {
                case FILTERING_ACCOUNT_RULES_FORCE:
                        /* apply filtering rules regardless to the account info */
                        matches = TRUE;
+
+                       /* debug output */
+                       if (debug_filtering_session) {
+                               if (prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                       if (filtering->account_id == 0) {
+                                               log_status_ok(LOG_DEBUG_FILTERING,
+                                                               _("rule is not account-based, "
+                                                               "all rules are applied on user request anyway\n"));
+                                       } else {
+                                               PrefsAccount *account = account_find_from_id(filtering->account_id);
+
+                                               log_status_ok(LOG_DEBUG_FILTERING,
+                                                               _("rule is account-based [id=%d, name='%s'], "
+                                                               "but all rules are applied on user request\n"),
+                                                               filtering->account_id, account->account_name);
+                                       }
+                               }
+                       }
                        break;
                case FILTERING_ACCOUNT_RULES_SKIP:
                        /* don't apply filtering rules that belong to an account */
                        matches = (filtering->account_id == 0);
+
+                       /* debug output */
+                       if (debug_filtering_session) {
+                               if (!matches) {
+                                       if (prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                               PrefsAccount *account = account_find_from_id(filtering->account_id);
+
+                                               log_status_skip(LOG_DEBUG_FILTERING,
+                                                               _("rule is account-based [id=%d, name='%s'], "
+                                                               "skipped on user request\n"),
+                                                               filtering->account_id, account->account_name);
+                                       } else {
+                                               log_status_skip(LOG_DEBUG_FILTERING,
+                                                               _("rule is account-based, "
+                                                               "skipped on user request\n"));
+                                       }
+                               } else {
+                                       if (matches && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                               log_status_ok(LOG_DEBUG_FILTERING,
+                                                               _("rule is not account-based\n"));
+                                       }
+                               }
+                       }
                        break;
                case FILTERING_ACCOUNT_RULES_USE_CURRENT:
                        matches = ((filtering->account_id == 0)
                                        || (filtering->account_id == cur_account->account_id));
+
+                       /* debug output */
+                       if (debug_filtering_session) {
+                               if (!matches) {
+                                       if (prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                               PrefsAccount *account = account_find_from_id(filtering->account_id);
+
+                                               log_status_skip(LOG_DEBUG_FILTERING,
+                                                               _("rule is account-based [id=%d, name='%s'], "
+                                                               "not matching current account [id=%d, name='%s']\n"),
+                                                               filtering->account_id, account->account_name,
+                                                               cur_account->account_id, cur_account->account_name);
+                                       } else {
+                                               log_status_skip(LOG_DEBUG_FILTERING,
+                                                               _("rule is account-based, "
+                                                               "not matching current account\n"));
+                                       }
+                               } else {
+                                       if (matches && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                               if (filtering->account_id == 0) {
+                                                       log_status_ok(LOG_DEBUG_FILTERING,
+                                                                       _("rule is not account-based\n"));
+                                               } else {
+                                                       PrefsAccount *account = account_find_from_id(filtering->account_id);
+
+                                                       log_status_ok(LOG_DEBUG_FILTERING,
+                                                                       _("rule is account-based [id=%d, name='%s'], "
+                                                                       "current account [id=%d, name='%s']\n"),
+                                                                       account->account_id, account->account_name,
+                                                                       cur_account->account_id, cur_account->account_name);
+                                               }
+                                       }
+                               }
+                       }
                        break;
                }
        }
@@ -547,12 +681,20 @@ static gboolean filtering_apply_rule(FilteringProp *filtering, MsgInfo *info,
         * final = FALSE;
         for (tmp = filtering->action_list ; tmp != NULL ; tmp = tmp->next) {
                 FilteringAction * action;
-                
+
                 action = tmp->data;
-                
+                               filteringaction_to_string(buf, sizeof buf, action);
+                               if (debug_filtering_session)
+                                       log_print(LOG_DEBUG_FILTERING, _("applying action [ %s ]\n"), buf);
+
                 if (FALSE == (result = filteringaction_apply(action, info))) {
-                        g_warning("No further processing after rule %s\n",
-                            filteringaction_to_string(buf, sizeof buf, action));
+                                       if (debug_filtering_session) {
+                                               if (action->type != MATCHACTION_STOP)
+                                                       log_warning(LOG_DEBUG_FILTERING, _("action could not apply\n"));
+                                               log_print(LOG_DEBUG_FILTERING,
+                                                               _("no further processing after action [ %s ]\n"), buf);
+                                       } else
+                                               g_warning("No further processing after rule %s\n", buf);
                 }
                 
                 if (filtering_is_final_action(action)) {
@@ -595,11 +737,43 @@ static gboolean filter_msginfo(GSList * filtering_list, MsgInfo * info, PrefsAcc
        for (l = filtering_list, final = FALSE, apply_next = FALSE; l != NULL; l = g_slist_next(l)) {
                FilteringProp * filtering = (FilteringProp *) l->data;
 
-               if (filtering->enabled && filtering_match_condition(filtering, info, ac_prefs)) {
-                       apply_next = filtering_apply_rule(filtering, info, &final);
-                        if (final)
-                                break;
-               }               
+               if (filtering->enabled) {
+                       if (debug_filtering_session) {
+                               gchar *buf = filteringprop_to_string(filtering);
+                               if (filtering->name && *filtering->name != '\0') {
+                                       log_print(LOG_DEBUG_FILTERING,
+                                               _("processing rule '%s' [ %s ]\n"),
+                                               filtering->name, buf);
+                               } else {
+                                       log_print(LOG_DEBUG_FILTERING,
+                                               _("processing rule <unnamed> [ %s ]\n"),
+                                               buf);
+                               }
+                       }
+
+                       if (filtering_match_condition(filtering, info, ac_prefs)) {
+                               apply_next = filtering_apply_rule(filtering, info, &final);
+                               if (final)
+                                       break;
+                       }
+
+               } else {
+                       if (debug_filtering_session) {
+                               gchar *buf = filteringprop_to_string(filtering);
+                               if (prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_MED) {
+                                       if (filtering->name && *filtering->name != '\0') {
+                                               log_status_skip(LOG_DEBUG_FILTERING,
+                                                               _("disabled rule '%s' [ %s ]\n"),
+                                                               filtering->name, buf);
+                                       } else {
+                                               log_status_skip(LOG_DEBUG_FILTERING,
+                                                               _("disabled rule <unnamed> [ %s ]\n"),
+                                                               buf);
+                                       }
+                               }
+                               g_free(buf);
+                       }
+               }
        }
 
        /* put in inbox if a final rule could not be applied, or
@@ -624,8 +798,61 @@ static gboolean filter_msginfo(GSList * filtering_list, MsgInfo * info, PrefsAcc
  *             processing. E.g. \ref inc.c::inc_start moves the 
  *             message to the inbox.   
  */
-gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount* ac_prefs)
+gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount* ac_prefs,
+                                                                  FilteringInvocationType context, gchar *extra_info)
 {
+       if (prefs_common.enable_filtering_debug) {
+               gchar *tmp = _("undetermined");
+
+               switch (context) {
+               case FILTERING_INCORPORATION:
+                       tmp = _("incorporation");
+                       debug_filtering_session = prefs_common.enable_filtering_debug_inc;
+                       break;
+               case FILTERING_MANUALLY:
+                       tmp = _("manually");
+                       debug_filtering_session = prefs_common.enable_filtering_debug_manual;
+                       break;
+               case FILTERING_FOLDER_PROCESSING:
+                       tmp = _("folder processing");
+                       debug_filtering_session = prefs_common.enable_filtering_debug_folder_proc;
+                       break;
+               case FILTERING_PRE_PROCESSING:
+                       tmp = _("pre-processing");
+                       debug_filtering_session = prefs_common.enable_filtering_debug_pre_proc;
+                       break;
+               case FILTERING_POST_PROCESSING:
+                       tmp = _("post-processing");
+                       debug_filtering_session = prefs_common.enable_filtering_debug_post_proc;
+                       break;
+               default:
+                       debug_filtering_session = FALSE;
+                       break;
+               }
+               if (debug_filtering_session) {
+                       gchar *file = procmsg_get_message_file_path(info);
+                       gchar *spc = g_strnfill(LOG_TIME_LEN + 1, ' ');
+
+                       /* show context info and essential info about the message */
+                       if (prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_MED) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               _("filtering message (%s%s%s)\n"
+                                               "%smessage file: %s\n%sDate: %s\n%sFrom: %s\n%sTo: %s\n%sSubject: %s\n"),
+                                               tmp, extra_info ? _(": ") : "", extra_info ? extra_info : "",
+                                               spc, file, spc, info->date, spc, info->from,
+                                               spc, info->to, spc, info->subject);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               _("filtering message (%s%s%s)\n"
+                                               "%smessage file: %s\n"),
+                                               tmp, extra_info ? _(": ") : "", extra_info ? extra_info : "",
+                                               spc, file);
+                       }
+                       g_free(file);
+                       g_free(spc);
+               }
+       } else
+               debug_filtering_session = FALSE;
        return filter_msginfo(flist, info, ac_prefs);
 }
 
index c5b6538..bed7a8b 100644 (file)
@@ -52,6 +52,20 @@ enum {
        FILTERING_ACCOUNT_RULES_USE_CURRENT = 2
 };
 
+typedef enum {
+       FILTERING_INCORPORATION,
+       FILTERING_MANUALLY,
+       FILTERING_FOLDER_PROCESSING,
+       FILTERING_PRE_PROCESSING,
+       FILTERING_POST_PROCESSING
+} FilteringInvocationType;
+
+typedef enum {
+       FILTERING_DEBUG_LEVEL_LOW,
+       FILTERING_DEBUG_LEVEL_MED,
+       FILTERING_DEBUG_LEVEL_HIGH
+} FilteringDebugLevel;
+       
 /* extern GSList * prefs_filtering; */
 
 
@@ -72,7 +86,8 @@ void filteringprop_free(FilteringProp *prop);
 FilteringProp * filteringprop_parse(gchar **str);
 
 void filter_msginfo_move_or_delete(GSList *filtering_list, MsgInfo *info);
-gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount *ac_prefs);
+gboolean filter_message_by_msginfo(GSList *flist, MsgInfo *info, PrefsAccount *ac_prefs,
+                                                                  FilteringInvocationType context, gchar *extra_info);
 
 gchar * filteringaction_to_string(gchar *dest, gint destlen, FilteringAction *action);
 void prefs_filtering_write_config(void);
index 04f6755..8536c89 100644 (file)
@@ -2848,7 +2848,7 @@ static FolderItem *folder_item_move_recursive(FolderItem *src, FolderItem *dest,
                new_item->folder = dest->folder;
 
        /* move messages */
-       log_message(copy ?_("Copying %s to %s...\n"):_("Moving %s to %s...\n"), 
+       log_message(LOG_PROTOCOL, copy ?_("Copying %s to %s...\n"):_("Moving %s to %s...\n"), 
                        src->name, new_item->path);
 
        mlist = folder_item_get_msg_list(src);
@@ -3863,14 +3863,16 @@ void folder_item_apply_processing(FolderItem *item)
                statusbar_progress_all(curmsg++,total, 10);
 
                 /* apply pre global rules */
-               filter_message_by_msginfo(pre_global_processing, msginfo, NULL);
+               filter_message_by_msginfo(pre_global_processing, msginfo, NULL,
+                               FILTERING_PRE_PROCESSING, NULL);
                
                 /* apply rules of the folder */
-               filter_message_by_msginfo(processing_list, msginfo, NULL);
+               filter_message_by_msginfo(processing_list, msginfo, NULL,
+                               FILTERING_FOLDER_PROCESSING, item->name);
 
                 /* apply post global rules */
-               filter_message_by_msginfo(post_global_processing, msginfo, NULL);
-                
+               filter_message_by_msginfo(post_global_processing, msginfo, NULL,
+                               FILTERING_POST_PROCESSING, NULL);
        }
        prefs_common.apply_per_account_filtering_rules = last_apply_per_account;
 
index 2ecc795..3df356a 100644 (file)
@@ -1169,7 +1169,7 @@ gint folderview_check_new(Folder *folder)
                                        if (folder) {
                                                summaryview_unlock(folderview->summaryview, item);
                                                if (FOLDER_TYPE(item->folder) == F_NEWS || FOLDER_IS_LOCAL(folder)) {
-                                                       log_error(_("Couldn't scan folder %s\n"),
+                                                       log_error(LOG_PROTOCOL, _("Couldn't scan folder %s\n"),
                                                                item->path ? item->path:item->name);
                                                        continue;
                                                } else if (!FOLDER_IS_LOCAL(folder)) {
index aaffed5..5f6afd6 100644 (file)
@@ -46,7 +46,8 @@ static gboolean key_pressed                   (GtkWidget      *widget,
                                                 GdkEventKey    *event,
                                                 LogWindow      *logwin);
 static void size_allocate_cb   (GtkWidget *widget,
-                                        GtkAllocation *allocation);
+                                        GtkAllocation *allocation,
+                                        gpointer data);
 static gboolean log_window_append              (gpointer        source,
                                                 gpointer        data);
 static void log_window_clip                    (LogWindow      *logwin,
@@ -61,15 +62,24 @@ static void log_window_popup_menu_extend    (GtkTextView    *textview,
  *\brief       Save Gtk object size to prefs dataset
  */
 static void size_allocate_cb(GtkWidget *widget,
-                                        GtkAllocation *allocation)
+                                        GtkAllocation *allocation,
+                                        gpointer data)
 {
+       gint *prefs_logwin_width = NULL;
+       gint *prefs_logwin_height = NULL;
+       LogInstance instance = GPOINTER_TO_INT(data);
+
        g_return_if_fail(allocation != NULL);
 
-       prefs_common.logwin_width = allocation->width;
-       prefs_common.logwin_height = allocation->height;
+       get_log_prefs(instance, &prefs_logwin_width, &prefs_logwin_height);
+       g_return_if_fail(prefs_logwin_width != NULL);
+       g_return_if_fail(prefs_logwin_height != NULL);
+
+       *prefs_logwin_width = allocation->width;
+       *prefs_logwin_height = allocation->height;
 }
 
-LogWindow *log_window_create(void)
+LogWindow *log_window_create(LogInstance instance)
 {
        LogWindow *logwin;
        GtkWidget *window;
@@ -78,13 +88,19 @@ LogWindow *log_window_create(void)
        GtkTextBuffer *buffer;
        GtkTextIter iter;
        static GdkGeometry geometry;
+       gint *prefs_logwin_width = NULL;
+       gint *prefs_logwin_height = NULL;
 
        debug_print("Creating log window...\n");
 
+       get_log_prefs(instance, &prefs_logwin_width, &prefs_logwin_height);
+       g_return_val_if_fail(prefs_logwin_width != NULL, NULL);
+       g_return_val_if_fail(prefs_logwin_height != NULL, NULL);
+
        logwin = g_new0(LogWindow, 1);
 
        window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "logwindow");
-       gtk_window_set_title(GTK_WINDOW(window), _("Protocol log"));
+       gtk_window_set_title(GTK_WINDOW(window), get_log_title(instance));
        gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
        g_signal_connect(G_OBJECT(window), "delete_event",
                         G_CALLBACK(gtk_widget_hide_on_delete), NULL);
@@ -121,7 +137,7 @@ LogWindow *log_window_create(void)
        gtk_widget_show(text);
 
        g_signal_connect(G_OBJECT(window), "size_allocate",
-                        G_CALLBACK(size_allocate_cb), NULL);
+                        G_CALLBACK(size_allocate_cb), GINT_TO_POINTER(instance));
 
        if (!geometry.min_height) {
                geometry.min_width = 520;
@@ -130,25 +146,27 @@ LogWindow *log_window_create(void)
 
        gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
                                      GDK_HINT_MIN_SIZE);
-       gtk_widget_set_size_request(window, prefs_common.logwin_width,
-                                   prefs_common.logwin_height);
+       gtk_widget_set_size_request(window, *prefs_logwin_width,
+                                   *prefs_logwin_height);
 
        logwin->window = window;
        logwin->scrolledwin = scrolledwin;
        logwin->text = text;
-       logwin->hook_id = hooks_register_hook(LOG_APPEND_TEXT_HOOKLIST, log_window_append, logwin);
+       logwin->hook_id = hooks_register_hook(get_log_hook(instance), log_window_append, logwin);
 
        gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(text), logwin->end_mark);
 
        return logwin;
 }
 
+#define LOG_COLORS 8
+
 void log_window_init(LogWindow *logwin)
 {
        GtkTextBuffer *buffer;
        GdkColormap *colormap;
-       GdkColor color[5];
-       gboolean success[5];
+       GdkColor color[LOG_COLORS];
+       gboolean success[LOG_COLORS];
        gint i;
 
        gtkut_convert_int_to_gdk_color(prefs_common.log_msg_color, &color[0]);
@@ -156,25 +174,33 @@ void log_window_init(LogWindow *logwin)
        gtkut_convert_int_to_gdk_color(prefs_common.log_error_color, &color[2]);
        gtkut_convert_int_to_gdk_color(prefs_common.log_in_color, &color[3]);
        gtkut_convert_int_to_gdk_color(prefs_common.log_out_color, &color[4]);
+       gtkut_convert_int_to_gdk_color(prefs_common.log_status_ok_color, &color[5]);
+       gtkut_convert_int_to_gdk_color(prefs_common.log_status_nok_color, &color[6]);
+       gtkut_convert_int_to_gdk_color(prefs_common.log_status_skip_color, &color[7]);
 
        logwin->msg_color = color[0];
        logwin->warn_color = color[1];
        logwin->error_color = color[2];
        logwin->in_color = color[3];
        logwin->out_color = color[4];
+       logwin->status_ok_color = color[5];
+       logwin->status_nok_color = color[6];
+       logwin->status_skip_color = color[7];
 
        colormap = gdk_drawable_get_colormap(logwin->window->window);
-       gdk_colormap_alloc_colors(colormap, color, 5, FALSE, TRUE, success);
+       gdk_colormap_alloc_colors(colormap, color, LOG_COLORS, FALSE, TRUE, success);
 
-       for (i = 0; i < 5; i++) {
+       for (i = 0; i < LOG_COLORS; i++) {
                if (success[i] == FALSE) {
                        GtkStyle *style;
 
                        g_warning("LogWindow: color allocation failed\n");
                        style = gtk_widget_get_style(logwin->window);
                        logwin->msg_color = logwin->warn_color =
-                       logwin->error_color = logwin->in_color =
-                       logwin->out_color = style->black;
+                                       logwin->error_color = logwin->in_color =
+                                       logwin->out_color = logwin->status_ok_color =
+                                       logwin->status_nok_color = logwin->status_skip_color =
+                                       style->black;
                        break;
                }
        }
@@ -195,8 +221,19 @@ void log_window_init(LogWindow *logwin)
        gtk_text_buffer_create_tag(buffer, "output",
                                   "foreground-gdk", &logwin->out_color,
                                   NULL);
+       gtk_text_buffer_create_tag(buffer, "status_ok",
+                                  "foreground-gdk", &logwin->status_ok_color,
+                                  NULL);
+       gtk_text_buffer_create_tag(buffer, "status_nok",
+                                  "foreground-gdk", &logwin->status_nok_color,
+                                  NULL);
+       gtk_text_buffer_create_tag(buffer, "status_skip",
+                                  "foreground-gdk", &logwin->status_skip_color,
+                                  NULL);
 }
 
+#undef LOG_COLORS
+
 void log_window_show(LogWindow *logwin)
 {
        GtkTextView *text = GTK_TEXT_VIEW(logwin->text);
@@ -275,24 +312,38 @@ static gboolean log_window_append(gpointer source, gpointer data)
                tag = "error";
                head = "*** ";
                break;
+       case LOG_STATUS_OK:
+               tag = "status_ok";
+               head = "> ";
+               break;
+       case LOG_STATUS_NOK:
+               tag = "status_nok";
+               head = "> ";
+               break;
+       case LOG_STATUS_SKIP:
+               tag = "status_skip";
+               head = "> skipped: ";
+               break;
        default:
                tag = NULL;
                break;
        }
-  
-       if (tag == NULL) {
-               if (strstr(logtext->text, "] POP3>")
-               ||  strstr(logtext->text, "] IMAP4>")
-               ||  strstr(logtext->text, "] SMTP>")
-               ||  strstr(logtext->text, "] ESMTP>")
-               ||  strstr(logtext->text, "] NNTP>"))
-                       tag = "output";
-               if (strstr(logtext->text, "] POP3<")
-               ||  strstr(logtext->text, "] IMAP4<")
-               ||  strstr(logtext->text, "] SMTP<")
-               ||  strstr(logtext->text, "] ESMTP<")
-               ||  strstr(logtext->text, "] NNTP<"))
-                       tag = "input";
+
+       if (logtext->instance == LOG_PROTOCOL) {
+               if (tag == NULL) {
+                       if (strstr(logtext->text, "] POP3>")
+                       ||  strstr(logtext->text, "] IMAP4>")
+                       ||  strstr(logtext->text, "] SMTP>")
+                       ||  strstr(logtext->text, "] ESMTP>")
+                       ||  strstr(logtext->text, "] NNTP>"))
+                               tag = "output";
+                       if (strstr(logtext->text, "] POP3<")
+                       ||  strstr(logtext->text, "] IMAP4<")
+                       ||  strstr(logtext->text, "] SMTP<")
+                       ||  strstr(logtext->text, "] ESMTP<")
+                       ||  strstr(logtext->text, "] NNTP<"))
+                               tag = "input";
+               }
        }
 
        if (head)
index 2997453..adc4c0b 100644 (file)
@@ -23,6 +23,8 @@
 #include <glib.h>
 #include <gtk/gtkwidget.h>
 
+#include "log.h"
+
 typedef struct _LogWindow      LogWindow;
 
 struct _LogWindow
@@ -36,6 +38,9 @@ struct _LogWindow
        GdkColor error_color;
        GdkColor in_color;
        GdkColor out_color;
+       GdkColor status_ok_color;
+       GdkColor status_nok_color;
+       GdkColor status_skip_color;
 
        gboolean clip;
        guint    clip_length;
@@ -47,7 +52,7 @@ struct _LogWindow
        gboolean never_shown;
 };
 
-LogWindow *log_window_create(void);
+LogWindow *log_window_create(LogInstance instance);
 void log_window_init(LogWindow *logwin);
 void log_window_show(LogWindow *logwin);
 void log_window_show_error(LogWindow *logwin);
index faf71ff..647b783 100644 (file)
@@ -641,7 +641,7 @@ static gint imap_auth(IMAPSession *session, const gchar *user, const gchar *pass
                                        "login refused.%s"),
                                        SESSION(session)->server, ext_info);
                        } else {
-                               log_error(_("Connection to %s failed: "
+                               log_error(LOG_PROTOCOL, _("Connection to %s failed: "
                                        "login refused.%s\n"),
                                        SESSION(session)->server, ext_info);
                        }
@@ -658,12 +658,12 @@ static IMAPSession *imap_reconnect_if_possible(Folder *folder, IMAPSession *sess
           connection, if yes we don't try to reconnect */
        debug_print("reconnecting\n");
        if (rfolder->session == NULL) {
-               log_warning(_("Connecting to %s failed"),
+               log_warning(LOG_PROTOCOL, _("Connecting to %s failed"),
                            folder->account->recv_server);
                session_destroy(SESSION(session));
                session = NULL;
        } else {
-               log_warning(_("IMAP4 connection to %s has been"
+               log_warning(LOG_PROTOCOL, _("IMAP4 connection to %s has been"
                            " disconnected. Reconnecting...\n"),
                            folder->account->recv_server);
                statusbar_print_all(_("IMAP4 connection to %s has been"
@@ -845,14 +845,14 @@ static IMAPSession *imap_session_new(Folder * folder,
 #if (LIBETPAN_VERSION_MAJOR > 0 || LIBETPAN_VERSION_MINOR > 48)
 #ifdef USE_OPENSSL
                if (r == MAILIMAP_ERROR_SSL)
-                       log_error(_("SSL handshake failed\n"));
+                       log_error(LOG_PROTOCOL, _("SSL handshake failed\n"));
 #endif
 #endif
                if(!prefs_common.no_recv_err_panel) {
                        alertpanel_error_log(_("Can't connect to IMAP4 server: %s:%d"),
                                         account->recv_server, port);
                } else {
-                       log_error(_("Can't connect to IMAP4 server: %s:%d\n"),
+                       log_error(LOG_PROTOCOL, _("Can't connect to IMAP4 server: %s:%d\n"),
                                         account->recv_server, port);
                } 
                
@@ -881,7 +881,7 @@ static IMAPSession *imap_session_new(Folder * folder,
 
                ok = imap_cmd_starttls(session);
                if (ok != IMAP_SUCCESS) {
-                       log_warning(_("Can't start TLS session.\n"));
+                       log_warning(LOG_PROTOCOL, _("Can't start TLS session.\n"));
                        session_destroy(SESSION(session));
                        return NULL;
                }
@@ -892,7 +892,7 @@ static IMAPSession *imap_session_new(Folder * folder,
                session->cmd_count = 1;
        }
 #endif
-       log_message("IMAP connection is %s-authenticated\n",
+       log_message(LOG_PROTOCOL, "IMAP connection is %s-authenticated\n",
                    (session->authenticated) ? "pre" : "un");
        
        return session;
@@ -929,7 +929,7 @@ try_again:
                        goto try_again;
                } else {
                        if (prefs_common.no_recv_err_panel) {
-                               log_error(_("Couldn't login to IMAP server %s."), account->recv_server);
+                               log_error(LOG_PROTOCOL, _("Couldn't login to IMAP server %s."), account->recv_server);
                                mainwindow_show_error();
                        } else
                                alertpanel_error_log(_("Couldn't login to IMAP server %s."), account->recv_server);
@@ -1434,13 +1434,13 @@ static gint imap_do_remove_msgs(Folder *folder, FolderItem *dest,
                (IMAP_SESSION(REMOTE_FOLDER(folder)->session),
                numlist, IMAP_FLAG_DELETED, TRUE);
        if (ok != IMAP_SUCCESS) {
-               log_warning(_("can't set deleted flags\n"));
+               log_warning(LOG_PROTOCOL, _("can't set deleted flags\n"));
                unlock_session();
                return ok;
        }
        ok = imap_cmd_expunge(session);
        if (ok != IMAP_SUCCESS) {
-               log_warning(_("can't expunge\n"));
+               log_warning(LOG_PROTOCOL, _("can't expunge\n"));
                unlock_session();
                return ok;
        }
@@ -2006,7 +2006,7 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
                argbuf = g_ptr_array_new();
                r = imap_threaded_list(folder, "", imap_path, &lep_list);
                if (r != MAILIMAP_NO_ERROR) {
-                       log_warning(_("can't create mailbox: LIST failed\n"));
+                       log_warning(LOG_PROTOCOL, _("can't create mailbox: LIST failed\n"));
                        g_free(imap_path);
                        g_free(dirpath);
                        ptr_array_free_strings(argbuf);
@@ -2022,7 +2022,7 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent,
                if (!exist) {
                        ok = imap_cmd_create(session, imap_path);
                        if (ok != IMAP_SUCCESS) {
-                               log_warning(_("can't create mailbox\n"));
+                               log_warning(LOG_PROTOCOL, _("can't create mailbox\n"));
                                g_free(imap_path);
                                g_free(dirpath);
                                unlock_session();
@@ -2140,7 +2140,7 @@ static gint imap_rename_folder(Folder *folder, FolderItem *item,
 
        ok = imap_cmd_rename(session, real_oldpath, real_newpath);
        if (ok != IMAP_SUCCESS) {
-               log_warning(_("can't rename mailbox: %s to %s\n"),
+               log_warning(LOG_PROTOCOL, _("can't rename mailbox: %s to %s\n"),
                            real_oldpath, real_newpath);
                g_free(real_oldpath);
                g_free(newpath);
@@ -2232,7 +2232,7 @@ static gint imap_remove_folder_real(Folder *folder, FolderItem *item)
        }
 
        if (ok != IMAP_SUCCESS) {
-               log_warning(_("can't delete mailbox\n"));
+               log_warning(LOG_PROTOCOL, _("can't delete mailbox\n"));
                g_free(path);
                unlock_session();
                return -1;
@@ -2478,7 +2478,7 @@ static gchar imap_refresh_path_separator(IMAPSession *session, IMAPFolder *folde
        r = imap_threaded_list((Folder *)folder, "", subfolder, &lep_list);
        
        if (r != MAILIMAP_NO_ERROR) {
-               log_warning(_("LIST failed\n"));
+               log_warning(LOG_PROTOCOL, _("LIST failed\n"));
                return '\0';
        }
 
@@ -2595,7 +2595,7 @@ static gint imap_select(IMAPSession *session, IMAPFolder *folder,
        ok = imap_cmd_select(session, real_path,
                             exists, recent, unseen, uid_validity, block);
        if (ok != IMAP_SUCCESS)
-               log_warning(_("can't select folder: %s\n"), real_path);
+               log_warning(LOG_PROTOCOL, _("can't select folder: %s\n"), real_path);
        else {
                session->mbox = g_strdup(path);
                session->folder_content_changed = FALSE;
@@ -2704,21 +2704,21 @@ static gint imap_cmd_login(IMAPSession *session,
                gint ok = IMAP_ERROR;
                if (imap_has_capability(session, "STARTTLS")) {
 #if USE_OPENSSL
-                       log_warning(_("Server requires TLS to log in.\n"));
+                       log_warning(LOG_PROTOCOL, _("Server requires TLS to log in.\n"));
                        ok = imap_cmd_starttls(session);
                        if (ok != IMAP_SUCCESS) {
-                               log_warning(_("Can't start TLS session.\n"));
+                               log_warning(LOG_PROTOCOL, _("Can't start TLS session.\n"));
                                return IMAP_ERROR;
                        } else {
                                /* refresh capas */
                                imap_free_capabilities(session);
                                if (imap_get_capabilities(session) != MAILIMAP_NO_ERROR) {
-                                       log_warning(_("Can't refresh capabilities.\n"));
+                                       log_warning(LOG_PROTOCOL, _("Can't refresh capabilities.\n"));
                                        return IMAP_ERROR;
                                }
                        }
 #else          
-                       log_error(_("Connection to %s failed: "
+                       log_error(LOG_PROTOCOL, _("Connection to %s failed: "
                                        "server requires TLS, but Claws Mail "
                                        "has been compiled without OpenSSL "
                                        "support.\n"),
@@ -2726,22 +2726,22 @@ static gint imap_cmd_login(IMAPSession *session,
                        return IMAP_ERROR;
 #endif
                } else {
-                       log_error(_("Server logins are disabled.\n"));
+                       log_error(LOG_PROTOCOL, _("Server logins are disabled.\n"));
                        return IMAP_ERROR;
                }
        }
 
-       log_print("IMAP4> Logging %s to %s using %s\n", 
+       log_print(LOG_PROTOCOL, "IMAP4> Logging %s to %s using %s\n", 
                        user,
                        SESSION(session)->server,
                        type);
        r = imap_threaded_login(session->folder, user, pass, type);
        if (r != MAILIMAP_NO_ERROR) {
-               log_print("IMAP4< Error logging in to %s\n",
+               log_print(LOG_PROTOCOL, "IMAP4< Error logging in to %s\n",
                                SESSION(session)->server);
                ok = IMAP_ERROR;
        } else {
-               log_print("IMAP4< Login to %s successful\n",
+               log_print(LOG_PROTOCOL, "IMAP4< Login to %s successful\n",
                                SESSION(session)->server);
                ok = IMAP_SUCCESS;
        }
@@ -3812,7 +3812,7 @@ static gint imap_remove_msg(Folder *folder, FolderItem *item, gint uid)
                (IMAP_SESSION(REMOTE_FOLDER(folder)->session),
                &numlist, IMAP_FLAG_DELETED, TRUE);
        if (ok != IMAP_SUCCESS) {
-               log_warning(_("can't set deleted flags: %d\n"), uid);
+               log_warning(LOG_PROTOCOL, _("can't set deleted flags: %d\n"), uid);
                unlock_session();
                return ok;
        }
@@ -3827,7 +3827,7 @@ static gint imap_remove_msg(Folder *folder, FolderItem *item, gint uid)
                g_free(uidstr);
        }
        if (ok != IMAP_SUCCESS) {
-               log_warning(_("can't expunge\n"));
+               log_warning(LOG_PROTOCOL, _("can't expunge\n"));
                unlock_session();
                return ok;
        }
index ed7f34c..c99ab6f 100644 (file)
--- a/src/inc.c
+++ b/src/inc.c
@@ -788,7 +788,7 @@ static IncState inc_pop3_session_do(IncSession *session)
 
        buf = g_strdup_printf(_("Connecting to POP3 server: %s..."), server);
        statusbar_print_all("%s", buf);
-       log_message("%s\n", buf);
+       log_message(LOG_PROTOCOL, "%s\n", buf);
 
        progress_dialog_set_label(inc_dialog->dialog, buf);
        GTK_EVENTS_FLUSH();
@@ -807,7 +807,7 @@ static IncState inc_pop3_session_do(IncSession *session)
                                         server, port);
                        manage_window_focus_out(inc_dialog->dialog->window, NULL, NULL);
                } else {
-                       log_error(_("Can't connect to POP3 server: %s:%d\n"),
+                       log_error(LOG_PROTOCOL, _("Can't connect to POP3 server: %s:%d\n"),
                            server, port);
                }
                session->inc_state = INC_CONNECT_ERROR;
@@ -1195,9 +1195,9 @@ static void inc_put_error(IncState istate, Pop3Session *session)
 
        if (log_msg) {
                if (fatal_error)
-                       log_error("%s\n", log_msg);
+                       log_error(LOG_PROTOCOL, "%s\n", log_msg);
                else
-                       log_warning("%s\n", log_msg);
+                       log_warning(LOG_PROTOCOL, "%s\n", log_msg);
        }
        if (prefs_common.no_recv_err_panel && fatal_error)
                mainwindow_show_error();
@@ -1223,7 +1223,7 @@ static void inc_cancel(IncProgressDialog *dialog)
 
        session->inc_state = INC_CANCEL;
 
-       log_message(_("Incorporation cancelled\n"));
+       log_message(LOG_PROTOCOL, _("Incorporation cancelled\n"));
 }
 
 gboolean inc_is_active(void)
index f35cabb..17d0e12 100644 (file)
@@ -71,6 +71,7 @@
 #include "prefs_summaries.h"
 #include "prefs_themes.h"
 #include "prefs_other.h"
+#include "prefs_logging.h"
 #include "prefs_send.h"
 #include "prefs_wrapping.h"
 #include "prefs_compose_writing.h"
@@ -723,7 +724,13 @@ int main(int argc, char *argv[])
                if (rename_force("claws.log", "claws.log.bak") < 0)
                        FILE_OP_ERROR("claws.log", "rename");
        }
-       set_log_file("claws.log");
+       set_log_file(LOG_PROTOCOL, "claws.log");
+
+       if (is_file_exist("filtering.log")) {
+               if (rename_force("filtering.log", "filtering.log.bak") < 0)
+                       FILE_OP_ERROR("filtering.log", "rename");
+       }
+       set_log_file(LOG_DEBUG_FILTERING, "filtering.log");
 
        CHDIR_RETURN_VAL_IF_FAIL(get_home_dir(), 1);
 
@@ -742,6 +749,7 @@ int main(int argc, char *argv[])
        prefs_summaries_init();
        prefs_message_init();
        prefs_other_init();
+       prefs_logging_init();
        prefs_receive_init();
        prefs_send_init();
 #ifdef USE_ASPELL
@@ -1038,7 +1046,8 @@ static void exit_claws(MainWindow *mainwin)
        remove_all_files(get_tmp_dir());
        remove_all_files(get_mime_tmp_dir());
 
-       close_log_file();
+       close_log_file(LOG_PROTOCOL);
+       close_log_file(LOG_DEBUG_FILTERING);
 
 #ifdef HAVE_LIBETPAN
        imap_main_done();
index db16089..853bcc3 100644 (file)
@@ -199,6 +199,9 @@ static void addressbook_open_cb     (MainWindow     *mainwin,
 static void log_window_show_cb (MainWindow     *mainwin,
                                 guint           action,
                                 GtkWidget      *widget);
+static void filtering_debug_window_show_cb     (MainWindow     *mainwin,
+                                guint           action,
+                                GtkWidget      *widget);
 
 static void inc_cancel_cb              (MainWindow     *mainwin,
                                         guint           action,
@@ -860,6 +863,7 @@ static GtkItemFactoryEntry mainwin_entries[] =
                                                NULL, ssl_manager_open_cb, 0, NULL},
 #endif
        {N_("/_Tools/---"),                     NULL, NULL, 0, "<Separator>"},
+       {N_("/_Tools/Filtering debug window"),  NULL, filtering_debug_window_show_cb, 0, NULL},
        {N_("/_Tools/_Log window"),             "<shift><control>L", log_window_show_cb, 0, NULL},
 
        {N_("/_Configuration"),                 NULL, NULL, 0, "<Branch>"},
@@ -1286,16 +1290,40 @@ MainWindow *main_window_create()
 
        gtk_widget_hide(offline_switch);
        gtk_widget_hide(warning_btn);
+
        /* create views */
        mainwin->folderview  = folderview  = folderview_create();
        mainwin->summaryview = summaryview = summary_create();
        mainwin->messageview = messageview = messageview_create(mainwin);
-       mainwin->logwin      = log_window_create();
 
+       /* init log instances data before creating log views */
+       set_log_title(LOG_PROTOCOL, _("Protocol log"));
+       set_log_prefs(LOG_PROTOCOL,
+                       &prefs_common.logwin_width,
+                       &prefs_common.logwin_height);
+       set_log_title(LOG_DEBUG_FILTERING, _("Filtering/processing debug log"));
+       set_log_prefs(LOG_DEBUG_FILTERING,
+                       &prefs_common.filtering_debugwin_width,
+                       &prefs_common.filtering_debugwin_height);
+
+       /* setup log windows */
+       mainwin->logwin = log_window_create(LOG_PROTOCOL);
        log_window_init(mainwin->logwin);
-       log_window_set_clipping(mainwin->logwin, prefs_common.cliplog,
+
+       mainwin->filtering_debugwin = log_window_create(LOG_DEBUG_FILTERING);
+       log_window_set_clipping(mainwin->logwin,
+                               prefs_common.cliplog,
                                prefs_common.loglength);
 
+       log_window_init(mainwin->filtering_debugwin);
+       log_window_set_clipping(mainwin->filtering_debugwin,
+                               prefs_common.filtering_debug_cliplog,
+                               prefs_common.filtering_debug_loglength);
+       if (prefs_common.enable_filtering_debug)
+               log_message(LOG_DEBUG_FILTERING, _("filtering debug enabled\n"));
+       else
+               log_message(LOG_DEBUG_FILTERING, _("filtering debug disabled\n"));
+
        folderview->mainwin      = mainwin;
        folderview->summaryview  = summaryview;
 
@@ -3157,6 +3185,12 @@ static void log_window_show_cb(MainWindow *mainwin, guint action,
        log_window_show(mainwin->logwin);
 }
 
+static void filtering_debug_window_show_cb(MainWindow *mainwin, guint action,
+                              GtkWidget *widget)
+{
+       log_window_show(mainwin->filtering_debugwin);
+}
+
 static void inc_cancel_cb(MainWindow *mainwin, guint action, GtkWidget *widget)
 {
        inc_cancel_all();
index 533112c..cf86280 100644 (file)
@@ -122,6 +122,7 @@ struct _MainWindow
        SummaryView     *summaryview;
        MessageView     *messageview;
        LogWindow       *logwin;
+       LogWindow       *filtering_debugwin;
 
        gint    progressindicator_hook;
        
index 18b32b9..e002a99 100644 (file)
@@ -43,6 +43,8 @@
 #include "quoted-printable.h"
 #include "claws.h"
 #include <ctype.h>
+#include "prefs_common.h"
+#include "log.h"
 
 /*!
  *\brief       Keyword lookup element
@@ -162,6 +164,8 @@ enum {
        MATCH_ONE = 2
 };
 
+extern gboolean debug_filtering_session;
+
 /*!
  *\brief       Look up table with keywords defined in \sa matchparser_tab
  */
@@ -323,22 +327,53 @@ static gboolean match_with_addresses_in_addressbook
                        for (; i < num_addr && !found; i++) {
                                gchar *addr = get_complete_address(i);
                                extract_address(addr);
-                               if (strcasecmp(addr, walk->data) == 0)
+                               if (strcasecmp(addr, walk->data) == 0) {
                                        found = TRUE;
+
+                                       /* debug output */
+                                       if (debug_filtering_session
+                                                       && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                               log_print(LOG_DEBUG_FILTERING,
+                                                               "address [ %s ] matches\n",
+                                                               (gchar *)walk->data);
+                                       }
+                               }
                                g_free(addr);
                        }
                }
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH
+                               && !found) {
+                       log_print(LOG_DEBUG_FILTERING,
+                                       "address [ %s ] doesn't match\n",
+                                       (gchar *)walk->data);
+               }
                g_free(walk->data);
 
                if (match == MATCH_ALL) {
                        /* if matching all addresses, stop if one doesn't match */
-                       if (!found)
-                       break;
+                       if (!found) {
+                               /* debug output */
+                               if (debug_filtering_session
+                                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                       log_print(LOG_DEBUG_FILTERING,
+                                                       "not all address match (matching all)\n");
+                               }
+                               break;
+                       }
                } else if (match == MATCH_ANY) {
                        /* if matching any address, stop if one does match */
-                       if (found)
+                       if (found) {
+                               /* debug output */
+                               if (debug_filtering_session
+                                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                                       log_print(LOG_DEBUG_FILTERING,
+                                                       "at least one address matches (matching any)\n");
+                               }
                                break;
-       }
+                       }
+               }
                /* MATCH_ONE: there should be only one loop iteration */
        }
 
@@ -356,10 +391,12 @@ static gboolean match_with_addresses_in_addressbook
  *\return      gboolean TRUE if str matches the condition in the 
  *             matcher structure
  */
-static gboolean matcherprop_string_match(MatcherProp *prop, const gchar *str)
+static gboolean matcherprop_string_match(MatcherProp *prop, const gchar *str,
+                                                                               const gchar *debug_context)
 {
        gchar *str1;
        gchar *str2;
+       gboolean ret = FALSE;
 
        if (str == NULL)
                return FALSE;
@@ -383,12 +420,50 @@ static gboolean matcherprop_string_match(MatcherProp *prop, const gchar *str)
                        return FALSE;
                
                if (regexec(prop->preg, str, 0, NULL, 0) == 0)
-                       return TRUE;
+                       ret = TRUE;
                else
-                       return FALSE;
+                       ret = FALSE;
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       gchar *stripped = g_strdup(str);
+
+                       strretchomp(stripped);
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "%s value [ %s ] matches regular expression [ %s ]\n",
+                                               debug_context, stripped, prop->expr);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "%s value [ %s ] doesn't matches regular expression [ %s ]\n",
+                                               debug_context, stripped, prop->expr);
+                       }
+                       g_free(stripped);
+               }
+               break;
                        
        case MATCHTYPE_MATCH:
-               return (strstr(str, prop->expr) != NULL);
+               ret = (strstr(str, prop->expr) != NULL);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       gchar *stripped = g_strdup(str);
+
+                       strretchomp(stripped);
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "%s value [ %s ] contains [ %s ] (case sensitive)\n",
+                                               debug_context, stripped, prop->expr);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "%s value [ %s ] doesn't contains [ %s ] (case sensitive)\n",
+                                               debug_context, stripped, prop->expr);
+                       }
+                       g_free(stripped);
+               }
+               break;
 
        /* FIXME: put upper in unesc_str */
        case MATCHTYPE_MATCHCASE:
@@ -398,15 +473,36 @@ static gboolean matcherprop_string_match(MatcherProp *prop, const gchar *str)
                str1 = alloca(strlen(str) + 1);
                strcpy(str1, str);
                g_strup(str1);
-               return (strstr(str1, str2) != NULL);
+               ret = (strstr(str1, str2) != NULL);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       gchar *stripped = g_strdup(str);
+
+                       strretchomp(stripped);
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "%s value [ %s ] contains [ %s ] (case insensitive)\n",
+                                               debug_context, stripped, prop->expr);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "%s [ %s ] doesn't contains [ %s ] (case insensitive)\n",
+                                               debug_context, stripped, prop->expr);
+                       }
+                       g_free(stripped);
+               }
+               break;
                
        default:
-               return FALSE;
+               break;
        }
+       return ret;
 }
 
 /* FIXME body search is a hack. */
-static gboolean matcherprop_string_decode_match(MatcherProp *prop, const gchar *str)
+static gboolean matcherprop_string_decode_match(MatcherProp *prop, const gchar *str,
+                                                                                               const gchar *debug_context)
 {
        gchar *utf = NULL;
        gchar tmp[BUFFSIZE];
@@ -421,10 +517,10 @@ static gboolean matcherprop_string_decode_match(MatcherProp *prop, const gchar *
                utf = conv_codeset_strdup
                        (tmp, conv_get_locale_charset_str_no_utf8(),
                         CS_INTERNAL);
-               res = matcherprop_string_match(prop, utf);
+               res = matcherprop_string_match(prop, utf, debug_context);
                g_free(utf);
        } else {
-               res = matcherprop_string_match(prop, tmp);
+               res = matcherprop_string_match(prop, tmp, debug_context);
        }
        
        if (res == FALSE && (strchr(prop->expr, '=') || strchr(prop->expr, '_')
@@ -436,10 +532,10 @@ static gboolean matcherprop_string_decode_match(MatcherProp *prop, const gchar *
                        utf = conv_codeset_strdup
                                (str, conv_get_locale_charset_str_no_utf8(),
                                 CS_INTERNAL);
-                       res = matcherprop_string_match(prop, utf);
+                       res = matcherprop_string_match(prop, utf, debug_context);
                        g_free(utf);
                } else {
-                       res = matcherprop_string_match(prop, str);
+                       res = matcherprop_string_match(prop, str, debug_context);
                }
        }
 
@@ -503,6 +599,14 @@ static gboolean matcherprop_match_test(const MatcherProp *prop,
                return FALSE;
 
 #if (defined USE_PTHREAD && defined __GLIBC__ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)))
+       /* debug output */
+       if (debug_filtering_session
+                       && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+               log_print(LOG_DEBUG_FILTERING,
+                               "starting threaded command [ %s ]\n",
+                               cmd);
+       }
+
        td->cmd = cmd;
        td->done = FALSE;
        if (pthread_create(&pt, PTHREAD_CREATE_JOINABLE, 
@@ -525,10 +629,26 @@ static gboolean matcherprop_match_test(const MatcherProp *prop,
        }
        g_free(td);
 #else
+       /* debug output */
+       if (debug_filtering_session
+                       && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+               log_print(LOG_DEBUG_FILTERING,
+                               "starting synchronous command [ %s ]\n",
+                               cmd);
+       }
+
        retval = system(cmd);
 #endif
        debug_print("Command exit code: %d\n", retval);
 
+       /* debug output */
+       if (debug_filtering_session
+                       && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+               log_print(LOG_DEBUG_FILTERING,
+                               "command returned [ %d ]\n",
+                               retval);
+       }
+
        g_free(cmd);
        return (retval == 0);
 }
@@ -549,7 +669,7 @@ gboolean matcherprop_match(MatcherProp *prop,
 
        switch(prop->criteria) {
        case MATCHCRITERIA_ALL:
-               return 1;
+               return TRUE;
        case MATCHCRITERIA_UNREAD:
                return MSG_IS_UNREAD(info->flags);
        case MATCHCRITERIA_NOT_UNREAD:
@@ -583,76 +703,288 @@ gboolean matcherprop_match(MatcherProp *prop,
        case MATCHCRITERIA_NOT_SPAM:
                return !MSG_IS_SPAM(info->flags);
        case MATCHCRITERIA_COLORLABEL:
-               return MSG_GET_COLORLABEL_VALUE(info->flags) == prop->value; 
+       {
+               gint color = MSG_GET_COLORLABEL_VALUE(info->flags);
+               gboolean ret = (color == prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message color value [ %d ] matches color value [ %d ]\n",
+                                               color, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message color value [ %d ] doesn't matches color value [ %d ]\n",
+                                               color, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_NOT_COLORLABEL:
-               return MSG_GET_COLORLABEL_VALUE(info->flags) != prop->value;
+       {
+               gint color = MSG_GET_COLORLABEL_VALUE(info->flags);
+               gboolean ret = (color != prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message color value [ %d ] matches color value [ %d ]\n",
+                                               color, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message color value [ %d ] doesn't matches color value [ %d ]\n",
+                                               color, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_IGNORE_THREAD:
                return MSG_IS_IGNORE_THREAD(info->flags);
        case MATCHCRITERIA_NOT_IGNORE_THREAD:
                return !MSG_IS_IGNORE_THREAD(info->flags);
        case MATCHCRITERIA_SUBJECT:
-               return matcherprop_string_match(prop, info->subject);
+               return matcherprop_string_match(prop, info->subject, _("subject"));
        case MATCHCRITERIA_NOT_SUBJECT:
-               return !matcherprop_string_match(prop, info->subject);
+               return !matcherprop_string_match(prop, info->subject, _("subject"));
        case MATCHCRITERIA_FROM:
-               return matcherprop_string_match(prop, info->from);
+               return matcherprop_string_match(prop, info->from, _("From: header"));
        case MATCHCRITERIA_NOT_FROM:
-               return !matcherprop_string_match(prop, info->from);
+               return !matcherprop_string_match(prop, info->from, _("From: header"));
        case MATCHCRITERIA_TO:
-               return matcherprop_string_match(prop, info->to);
+               return matcherprop_string_match(prop, info->to, _("To: header"));
        case MATCHCRITERIA_NOT_TO:
-               return !matcherprop_string_match(prop, info->to);
+               return !matcherprop_string_match(prop, info->to, _("To: header"));
        case MATCHCRITERIA_CC:
-               return matcherprop_string_match(prop, info->cc);
+               return matcherprop_string_match(prop, info->cc, _("Cc: header"));
        case MATCHCRITERIA_NOT_CC:
-               return !matcherprop_string_match(prop, info->cc);
+               return !matcherprop_string_match(prop, info->cc, _("Cc: header"));
        case MATCHCRITERIA_TO_OR_CC:
-               return matcherprop_string_match(prop, info->to)
-                       || matcherprop_string_match(prop, info->cc);
+               return matcherprop_string_match(prop, info->to, _("To: header"))
+                       || matcherprop_string_match(prop, info->cc, _("Cc: header"));
        case MATCHCRITERIA_NOT_TO_AND_NOT_CC:
-               return !(matcherprop_string_match(prop, info->to)
-               || matcherprop_string_match(prop, info->cc));
+               return !(matcherprop_string_match(prop, info->to, _("To:"))
+               || matcherprop_string_match(prop, info->cc, _("Cc:")));
        case MATCHCRITERIA_AGE_GREATER:
+       {
+               gboolean ret;
+               gint age;
+
                t = time(NULL);
-               return ((t - info->date_t) / (60 * 60 * 24)) > prop->value;
+               age = ((t - info->date_t) / (60 * 60 * 24));
+               ret = (age > prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message age [ %d ] is greater than [ %d ]\n",
+                                               age, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message age [ %d ] is not greater than [ %d ]\n",
+                                               age, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_AGE_LOWER:
+       {
+               gboolean ret;
+               gint age;
+
                t = time(NULL);
-               return ((t - info->date_t) / (60 * 60 * 24)) < prop->value;
+               age = ((t - info->date_t) / (60 * 60 * 24));
+               ret = (age < prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message age [ %d ] is lower than [ %d ]\n",
+                                               age, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message age [ %d ] is not lower than [ %d ]\n",
+                                               age, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_SCORE_GREATER:
-               return info->score > prop->value;
+       {
+               gboolean ret = (info->score > prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message score [ %d ] is greater than [ %d ]\n",
+                                               info->score, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message score [ %d ] is not greater than [ %d ]\n",
+                                               info->score, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_SCORE_LOWER:
-               return info->score < prop->value;
+       {
+               gboolean ret = (info->score < prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message score [ %d ] is lower than [ %d ]\n",
+                                               info->score, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message score [ %d ] is not lower than [ %d ]\n",
+                                               info->score, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_SCORE_EQUAL:
-               return info->score == prop->value;
+       {
+               gboolean ret = (info->score == prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message score [ %d ] is equal to [ %d ]\n",
+                                               info->score, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message score [ %d ] is not equal to [ %d ]\n",
+                                               info->score, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_SIZE_GREATER:
+       {
                /* FIXME: info->size is an off_t */
-               return info->size > (off_t) prop->value;
-       case MATCHCRITERIA_SIZE_EQUAL:
-               /* FIXME: info->size is an off_t */
-               return info->size == (off_t) prop->value;
+               gboolean ret = (info->size > (off_t) prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message size [ %ld ] is greater than [ %d ]\n",
+                                               info->size, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message size [ %ld ] is not greater than [ %d ]\n",
+                                               info->size, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_SIZE_SMALLER:
+       {
+               /* FIXME: info->size is an off_t */
+               gboolean ret = (info->size < (off_t) prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message size [ %ld ] is smaller than [ %d ]\n",
+                                               info->size, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message size [ %ld ] is not smaller than [ %d ]\n",
+                                               info->size, prop->value);
+                       }
+               }
+               return ret;
+       }
+       case MATCHCRITERIA_SIZE_EQUAL:
+       {
                /* FIXME: info->size is an off_t */
-               return info->size <  (off_t) prop->value;
+               gboolean ret = (info->size == (off_t) prop->value);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message size [ %ld ] is equal to [ %d ]\n",
+                                               info->size, prop->value);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message size [ %ld ] is not equal to [ %d ]\n",
+                                               info->size, prop->value);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_PARTIAL:
+       {
                /* FIXME: info->size is an off_t */
-               return (info->total_size != 0 && info->size != (off_t)info->total_size);
+               gboolean ret = (info->total_size != 0 && info->size != (off_t)info->total_size);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message is partially downloaded, size [ %ld ] is less than total size [ %d ])\n",
+                                               info->size, info->total_size);
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message is not partially downloaded\n");
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_NOT_PARTIAL:
+       {
                /* FIXME: info->size is an off_t */
-               return (info->total_size == 0 || info->size == (off_t)info->total_size);
+               gboolean ret = (info->total_size == 0 || info->size == (off_t)info->total_size);
+
+               /* debug output */
+               if (debug_filtering_session
+                               && prefs_common.filtering_debug_level >= FILTERING_DEBUG_LEVEL_HIGH) {
+                       if (ret) {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message is not partially downloaded\n");
+                       } else {
+                               log_print(LOG_DEBUG_FILTERING,
+                                               "message is partially downloaded, size [ %ld ] is less than total size [ %d ])\n",
+                                               info->size, info->total_size);
+                       }
+               }
+               return ret;
+       }
        case MATCHCRITERIA_NEWSGROUPS:
-               return matcherprop_string_match(prop, info->newsgroups);
+               return matcherprop_string_match(prop, info->newsgroups, _("Newsgroups: header"));
        case MATCHCRITERIA_NOT_NEWSGROUPS:
-               return !matcherprop_string_match(prop, info->newsgroups);
+               return !matcherprop_string_match(prop, info->newsgroups, _("Newsgroups: header"));
        case MATCHCRITERIA_INREPLYTO:
-               return matcherprop_string_match(prop, info->inreplyto);
+               return matcherprop_string_match(prop, info->inreplyto, _("InReplyTo: header"));
        case MATCHCRITERIA_NOT_INREPLYTO:
-               return !matcherprop_string_match(prop, info->inreplyto);
+               return !matcherprop_string_match(prop, info->inreplyto, _("InReplyTo: header"));
        /* FIXME: Using inreplyto, but matching the (newly implemented)
          * list of references is better */
-        case MATCHCRITERIA_REFERENCES:
-               return matcherprop_string_match(prop, info->inreplyto);
+       case MATCHCRITERIA_REFERENCES:
+               return matcherprop_string_match(prop, info->inreplyto, _("InReplyTo: header (references)"));
        case MATCHCRITERIA_NOT_REFERENCES:
-               return !matcherprop_string_match(prop, info->inreplyto);
+               return !matcherprop_string_match(prop, info->inreplyto, _("InReplyTo: header (references)"));
        case MATCHCRITERIA_TEST:
                return matcherprop_match_test(prop, info);
        case MATCHCRITERIA_NOT_TEST:
@@ -736,9 +1068,9 @@ static gboolean matcherprop_match_one_header(MatcherProp *matcher,
                if (procheader_headername_equal(header->name,
                                                matcher->header)) {
                        if (matcher->criteria == MATCHCRITERIA_HEADER)
-                               result = matcherprop_string_match(matcher, header->body);
+                               result = matcherprop_string_match(matcher, header->body, _("header"));
                        else
-                               result = !matcherprop_string_match(matcher, header->body);
+                               result = !matcherprop_string_match(matcher, header->body, _("header"));
                        procheader_header_free(header);
                        return result;
                }
@@ -747,13 +1079,13 @@ static gboolean matcherprop_match_one_header(MatcherProp *matcher,
                }
                break;
        case MATCHCRITERIA_HEADERS_PART:
-               return matcherprop_string_match(matcher, buf);
+               return matcherprop_string_match(matcher, buf, _("header line"));
+       case MATCHCRITERIA_NOT_HEADERS_PART:
+               return !matcherprop_string_match(matcher, buf, _("headers line"));
        case MATCHCRITERIA_MESSAGE:
-               return matcherprop_string_decode_match(matcher, buf);
+               return matcherprop_string_decode_match(matcher, buf, _("message line"));
        case MATCHCRITERIA_NOT_MESSAGE:
-               return !matcherprop_string_decode_match(matcher, buf);
-       case MATCHCRITERIA_NOT_HEADERS_PART:
-               return !matcherprop_string_match(matcher, buf);
+               return !matcherprop_string_decode_match(matcher, buf, _("message line"));
        case MATCHCRITERIA_FOUND_IN_ADDRESSBOOK:
        case MATCHCRITERIA_NOT_FOUND_IN_ADDRESSBOOK:
                {
@@ -971,10 +1303,10 @@ static gboolean matcherprop_match_line(MatcherProp *matcher, const gchar *line)
        switch (matcher->criteria) {
        case MATCHCRITERIA_BODY_PART:
        case MATCHCRITERIA_MESSAGE:
-               return matcherprop_string_decode_match(matcher, line);
+               return matcherprop_string_decode_match(matcher, line, _("body line"));
        case MATCHCRITERIA_NOT_BODY_PART:
        case MATCHCRITERIA_NOT_MESSAGE:
-               return !matcherprop_string_decode_match(matcher, line);
+               return !matcherprop_string_decode_match(matcher, line, _("body line"));
        }
        return FALSE;
 }
@@ -1148,6 +1480,12 @@ gboolean matcherlist_match(MatcherList *matchers, MsgInfo *info)
        for (l = matchers->matchers; l != NULL ;l = g_slist_next(l)) {
                MatcherProp *matcher = (MatcherProp *) l->data;
 
+               if (debug_filtering_session) {
+                       gchar *buf = matcherprop_to_string(matcher);
+                       log_print(LOG_DEBUG_FILTERING, _("checking if message matches [ %s ]\n"), buf);
+                       g_free(buf);
+               }
+
                switch(matcher->criteria) {
                case MATCHCRITERIA_ALL:
                case MATCHCRITERIA_UNREAD:
@@ -1200,11 +1538,15 @@ gboolean matcherlist_match(MatcherList *matchers, MsgInfo *info)
                case MATCHCRITERIA_NOT_PARTIAL:
                        if (matcherprop_match(matcher, info)) {
                                if (!matchers->bool_and) {
+                                       if (debug_filtering_session)
+                                               log_status_ok(LOG_DEBUG_FILTERING, _("message matches\n"));
                                        return TRUE;
                                }
                        }
                        else {
                                if (matchers->bool_and) {
+                                       if (debug_filtering_session)
+                                               log_status_nok(LOG_DEBUG_FILTERING, _("message does not match\n"));
                                        return FALSE;
                                }
                        }
@@ -1214,14 +1556,25 @@ gboolean matcherlist_match(MatcherList *matchers, MsgInfo *info)
        /* test the condition on the file */
 
        if (matcherlist_match_file(matchers, info, result)) {
-               if (!matchers->bool_and)
+               if (!matchers->bool_and) {
+                       if (debug_filtering_session)
+                               log_status_ok(LOG_DEBUG_FILTERING, _("message matches\n"));
                        return TRUE;
-       }
-       else {
-               if (matchers->bool_and)
+               }
+       } else {
+               if (matchers->bool_and) {
+                       if (debug_filtering_session)
+                               log_status_nok(LOG_DEBUG_FILTERING, _("message does not match\n"));
                        return FALSE;
+               }
        }
 
+       if (debug_filtering_session) {
+               if (result)
+                       log_status_ok(LOG_DEBUG_FILTERING, _("message matches\n"));
+               else
+                       log_status_nok(LOG_DEBUG_FILTERING, _("message does not match\n"));
+       }
        return result;
 }
 
index f68aab7..90b33f8 100644 (file)
@@ -1810,13 +1810,13 @@ void messageview_learn (MessageView *msgview, gboolean is_spam)
                if (procmsg_spam_learner_learn(msgview->msginfo, NULL, TRUE) == 0)
                        procmsg_msginfo_set_flags(msgview->msginfo, MSG_SPAM, 0);
                else
-                       log_error(_("An error happened while learning.\n"));
+                       log_error(LOG_PROTOCOL, _("An error happened while learning.\n"));
                
        } else {
                if (procmsg_spam_learner_learn(msgview->msginfo, NULL, FALSE) == 0)
                        procmsg_msginfo_unset_flags(msgview->msginfo, MSG_SPAM, 0);
                else
-                       log_error(_("An error happened while learning.\n"));
+                       log_error(LOG_PROTOCOL, _("An error happened while learning.\n"));
        }
        if (msgview->toolbar)
                toolbar_set_learn_button
index 021627c..8ab62f3 100644 (file)
@@ -252,7 +252,7 @@ static Session *news_session_new(const gchar *server, gushort port,
 
        g_return_val_if_fail(server != NULL, NULL);
 
-       log_message(_("creating NNTP connection to %s:%d ...\n"), server, port);
+       log_message(LOG_PROTOCOL, _("creating NNTP connection to %s:%d ...\n"), server, port);
 
 #if USE_OPENSSL
        session = nntp_session_new(server, port, buf, userid, passwd, ssl_type);
@@ -342,7 +342,7 @@ static NNTPSession *news_session_get(Folder *folder)
 
        if (nntp_mode(NNTP_SESSION(rfolder->session), FALSE)
            != NN_SUCCESS) {
-               log_warning(_("NNTP connection to %s:%d has been"
+               log_warning(LOG_PROTOCOL, _("NNTP connection to %s:%d has been"
                              " disconnected. Reconnecting...\n"),
                            folder->account->nntp_server,
                            folder->account->set_nntpport ?
@@ -472,7 +472,7 @@ GSList *news_get_group_list(Folder *folder)
                        return NULL;
                }
                if (recv_write_to_file(SESSION(session)->sock, filename) < 0) {
-                       log_warning(_("can't retrieve newsgroup list\n"));
+                       log_warning(LOG_PROTOCOL, _("can't retrieve newsgroup list\n"));
                        session_destroy(SESSION(session));
                        REMOTE_FOLDER(folder)->session = NULL;
                        g_free(filename);
@@ -585,7 +585,7 @@ static gint news_post_stream(Folder *folder, FILE *fp)
 
        ok = nntp_post(session, fp);
        if (ok != NN_SUCCESS) {
-               log_warning(_("couldn't post article.\n"));
+               log_warning(LOG_PROTOCOL, _("couldn't post article.\n"));
                if (ok == NN_SOCKET) {
                        session_destroy(SESSION(session));
                        REMOTE_FOLDER(folder)->session = NULL;
@@ -611,7 +611,7 @@ static gint news_get_article_cmd(NNTPSession *session, const gchar *cmd,
 
        ok = recv_write_to_file(SESSION(session)->sock, filename);
        if (ok < 0) {
-               log_warning(_("couldn't retrieve article %d\n"), num);
+               log_warning(LOG_PROTOCOL, _("couldn't retrieve article %d\n"), num);
                if (ok == -2)
                        return NN_SOCKET;
                else
@@ -660,7 +660,7 @@ static gint news_select_group(NNTPSession *session, const gchar *group,
        if (ok == NN_SUCCESS)
                session->group = g_strdup(group);
        else
-               log_warning(_("couldn't select group: %s\n"), group);
+               log_warning(LOG_PROTOCOL, _("couldn't select group: %s\n"), group);
 
        return ok;
 }
@@ -885,7 +885,7 @@ static gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_
 
        ok = news_select_group(session, item->path, &num, &first, &last);
        if (ok != NN_SUCCESS) {
-               log_warning(_("couldn't set group: %s\n"), item->path);
+               log_warning(LOG_PROTOCOL, _("couldn't set group: %s\n"), item->path);
                news_folder_unlock(NEWS_FOLDER(item->folder));
                return -1;
        }
@@ -894,7 +894,7 @@ static gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_
        if (num <= 0)
                remove_all_numbered_files(dir);
        else if (last < first)
-               log_warning(_("invalid article range: %d - %d\n"),
+               log_warning(LOG_PROTOCOL, _("invalid article range: %d - %d\n"),
                            first, last);
        else {
                for (i = first; i <= last; i++) {
@@ -914,7 +914,7 @@ static gint news_get_num_list(Folder *folder, FolderItem *item, GSList **msgnum_
 #define READ_TO_LISTEND(hdr) \
        while (!(buf[0] == '.' && buf[1] == '\r')) { \
                if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) { \
-                       log_warning(_("error occurred while getting %s.\n"), hdr); \
+                       log_warning(LOG_PROTOCOL, _("error occurred while getting %s.\n"), hdr); \
                        return msginfo; \
                } \
        }
@@ -952,14 +952,14 @@ static MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
        g_return_val_if_fail(item->folder != NULL, NULL);
        g_return_val_if_fail(FOLDER_CLASS(item->folder) == &news_class, NULL);
 
-       log_message(_("getting xover %d in %s...\n"),
+       log_message(LOG_PROTOCOL, _("getting xover %d in %s...\n"),
                    num, item->path);
        ok = nntp_xover(session, num, num);
        
        news_folder_lock(NEWS_FOLDER(item->folder));
        
        if (ok != NN_SUCCESS) {
-               log_warning(_("couldn't get xover\n"));
+               log_warning(LOG_PROTOCOL, _("couldn't get xover\n"));
                if (ok == NN_SOCKET) {
                        session_destroy(SESSION(session));
                        REMOTE_FOLDER(item->folder)->session = NULL;
@@ -969,14 +969,14 @@ static MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
        }
        
        if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
-               log_warning(_("error occurred while getting xover.\n"));
+               log_warning(LOG_PROTOCOL, _("error occurred while getting xover.\n"));
                news_folder_unlock(NEWS_FOLDER(item->folder));
                return NULL;
        }
        
        msginfo = news_parse_xover(buf);
        if (!msginfo) {
-               log_warning(_("invalid xover line: %s\n"), buf);
+               log_warning(LOG_PROTOCOL, _("invalid xover line: %s\n"), buf);
        }
 
        READ_TO_LISTEND("xover");
@@ -994,7 +994,7 @@ static MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
 
        ok = nntp_xhdr(session, "to", num, num);
        if (ok != NN_SUCCESS) {
-               log_warning(_("couldn't get xhdr\n"));
+               log_warning(LOG_PROTOCOL, _("couldn't get xhdr\n"));
                if (ok == NN_SOCKET) {
                        session_destroy(SESSION(session));
                        REMOTE_FOLDER(item->folder)->session = NULL;
@@ -1004,7 +1004,7 @@ static MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
        }
 
        if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
-               log_warning(_("error occurred while getting xhdr.\n"));
+               log_warning(LOG_PROTOCOL, _("error occurred while getting xhdr.\n"));
                news_folder_unlock(NEWS_FOLDER(item->folder));
                return msginfo;
        }
@@ -1015,7 +1015,7 @@ static MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
 
        ok = nntp_xhdr(session, "cc", num, num);
        if (ok != NN_SUCCESS) {
-               log_warning(_("couldn't get xhdr\n"));
+               log_warning(LOG_PROTOCOL, _("couldn't get xhdr\n"));
                if (ok == NN_SOCKET) {
                        session_destroy(SESSION(session));
                        REMOTE_FOLDER(item->folder)->session = NULL;
@@ -1025,7 +1025,7 @@ static MsgInfo *news_get_msginfo(Folder *folder, FolderItem *item, gint num)
        }
 
        if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
-               log_warning(_("error occurred while getting xhdr.\n"));
+               log_warning(LOG_PROTOCOL, _("error occurred while getting xhdr.\n"));
                news_folder_unlock(NEWS_FOLDER(item->folder));
                return msginfo;
        }
@@ -1049,11 +1049,11 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
        g_return_val_if_fail(session != NULL, NULL);
        g_return_val_if_fail(item != NULL, NULL);
 
-       log_message(_("getting xover %d - %d in %s...\n"),
+       log_message(LOG_PROTOCOL, _("getting xover %d - %d in %s...\n"),
                    begin, end, item->path);
        ok = nntp_xover(session, begin, end);
        if (ok != NN_SUCCESS) {
-               log_warning(_("couldn't get xover\n"));
+               log_warning(LOG_PROTOCOL, _("couldn't get xover\n"));
                if (ok == NN_SOCKET) {
                        session_destroy(SESSION(session));
                        REMOTE_FOLDER(item->folder)->session = NULL;
@@ -1065,7 +1065,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
        
        for (;;) {
                if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
-                       log_warning(_("error occurred while getting xover.\n"));
+                       log_warning(LOG_PROTOCOL, _("error occurred while getting xover.\n"));
                        news_folder_unlock(NEWS_FOLDER(item->folder));
                        return newlist;
                }
@@ -1079,7 +1079,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
 
                msginfo = news_parse_xover(buf);
                if (!msginfo) {
-                       log_warning(_("invalid xover line: %s\n"), buf);
+                       log_warning(LOG_PROTOCOL, _("invalid xover line: %s\n"), buf);
                        continue;
                }
 
@@ -1098,7 +1098,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
 
        ok = nntp_xhdr(session, "to", begin, end);
        if (ok != NN_SUCCESS) {
-               log_warning(_("couldn't get xhdr\n"));
+               log_warning(LOG_PROTOCOL, _("couldn't get xhdr\n"));
                if (ok == NN_SOCKET) {
                        session_destroy(SESSION(session));
                        REMOTE_FOLDER(item->folder)->session = NULL;
@@ -1111,7 +1111,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
 
        for (;;) {
                if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
-                       log_warning(_("error occurred while getting xhdr.\n"));
+                       log_warning(LOG_PROTOCOL, _("error occurred while getting xhdr.\n"));
                        news_folder_unlock(NEWS_FOLDER(item->folder));
                        return newlist;
                }
@@ -1130,7 +1130,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
 
        ok = nntp_xhdr(session, "cc", begin, end);
        if (ok != NN_SUCCESS) {
-               log_warning(_("couldn't get xhdr\n"));
+               log_warning(LOG_PROTOCOL, _("couldn't get xhdr\n"));
                if (ok == NN_SOCKET) {
                        session_destroy(SESSION(session));
                        REMOTE_FOLDER(item->folder)->session = NULL;
@@ -1143,7 +1143,7 @@ static GSList *news_get_msginfos_for_range(NNTPSession *session, FolderItem *ite
 
        for (;;) {
                if (sock_gets(SESSION(session)->sock, buf, sizeof(buf)) < 0) {
-                       log_warning(_("error occurred while getting xhdr.\n"));
+                       log_warning(LOG_PROTOCOL, _("error occurred while getting xhdr.\n"));
                        news_folder_unlock(NEWS_FOLDER(item->folder));
                        return newlist;
                }
index 3f5033d..92cf2b1 100644 (file)
@@ -573,7 +573,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
                        warned_error = TRUE;
                } else {
                        gchar *tmp = g_strdup_printf("%s\n", msg);
-                       log_error(tmp);
+                       log_error(LOG_PROTOCOL, tmp);
                        g_free(tmp);
                }
                g_free(msg);
@@ -680,7 +680,7 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                                
                        debug_print("%s\n", cmd);
                        if ((status = execute_command_line(cmd, FALSE)) != 0)
-                               log_error(_("Learning failed; `%s` returned with status %d."),
+                               log_error(LOG_PROTOCOL, _("Learning failed; `%s` returned with status %d."),
                                                cmd, status);
                        g_free(cmd);
                        g_free(file);
@@ -729,7 +729,7 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                                
                                debug_print("%s\n", cmd);
                                if ((status = execute_command_line(cmd, FALSE)) != 0)
-                                       log_error(_("Learning failed; `%s` returned with status %d."),
+                                       log_error(LOG_PROTOCOL, _("Learning failed; `%s` returned with status %d."),
                                                        cmd, status);
 
                                g_free(cmd);
@@ -785,7 +785,7 @@ int bogofilter_learn(MsgInfo *msginfo, GSList *msglist, gboolean spam)
                                        status = WEXITSTATUS(status);
                        }
                        if (!bogo_forked || status != 0) {
-                               log_error(_("Learning failed; `%s %s %s` returned with error:\n%s"),
+                               log_error(LOG_PROTOCOL, _("Learning failed; `%s %s %s` returned with error:\n%s"),
                                                bogo_args[0], bogo_args[1], bogo_args[2], 
                                                error ? error->message:_("Unknown error"));
                                if (error)
index b6b59e3..18f149f 100644 (file)
@@ -158,7 +158,7 @@ static MsgStatus msg_is_spam(FILE *fp)
        }
 
        if (transport_setup(&trans, flags) != EX_OK) {
-               log_error(_("SpamAssassin plugin couldn't connect to spamd.\n"));
+               log_error(LOG_PROTOCOL, _("SpamAssassin plugin couldn't connect to spamd.\n"));
                debug_print("failed to setup transport\n");
                return MSG_FILTERING_ERROR;
        }
@@ -174,7 +174,7 @@ static MsgStatus msg_is_spam(FILE *fp)
        }
 
        if (message_filter(&trans, config.username, flags, &m) != EX_OK) {
-               log_error(_("SpamAssassin plugin filtering failed.\n"));
+               log_error(LOG_PROTOCOL, _("SpamAssassin plugin filtering failed.\n"));
                debug_print("filtering the message failed\n");
                message_cleanup(&m);
                return MSG_FILTERING_ERROR;
@@ -200,7 +200,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
 
        /* SPAMASSASSIN_DISABLED : keep test for compatibility purpose */
        if (!config.enable || config.transport == SPAMASSASSIN_DISABLED) {
-               log_warning(_("SpamAssassin plugin is disabled by its preferences.\n"));
+               log_warning(LOG_PROTOCOL, _("SpamAssassin plugin is disabled by its preferences.\n"));
                return FALSE;
        }
        debug_print("Filtering message %d\n", msginfo->msgnum);
@@ -292,7 +292,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
                        warned_error = TRUE;
                } else {
                        gchar *tmp = g_strdup_printf("%s\n", msg);
-                       log_error(tmp);
+                       log_error(LOG_PROTOCOL, tmp);
                        g_free(tmp);
                }
        }
@@ -495,7 +495,7 @@ gint plugin_init(gchar **error)
        }
 
        if (!config.enable || config.transport == SPAMASSASSIN_DISABLED) {
-               log_warning(_("SpamAssassin plugin is loaded but disabled by its preferences.\n"));
+               log_warning(LOG_PROTOCOL, _("SpamAssassin plugin is loaded but disabled by its preferences.\n"));
        }
        else {
                if (config.transport == SPAMASSASSIN_TRANSPORT_TCP)
index aa6f39a..1333d06 100644 (file)
--- a/src/pop.c
+++ b/src/pop.c
@@ -147,14 +147,14 @@ static gint pop3_getauth_apop_send(Pop3Session *session)
        session->state = POP3_GETAUTH_APOP;
 
        if ((start = strchr(session->greeting, '<')) == NULL) {
-               log_error(_("Required APOP timestamp not found "
+               log_error(LOG_PROTOCOL, _("Required APOP timestamp not found "
                            "in greeting\n"));
                session->error_val = PS_PROTOCOL;
                return -1;
        }
 
        if ((end = strchr(start, '>')) == NULL || end == start + 1) {
-               log_error(_("Timestamp syntax error in greeting\n"));
+               log_error(LOG_PROTOCOL, _("Timestamp syntax error in greeting\n"));
                session->error_val = PS_PROTOCOL;
                return -1;
        }
@@ -180,7 +180,7 @@ static gint pop3_getrange_stat_send(Pop3Session *session)
 static gint pop3_getrange_stat_recv(Pop3Session *session, const gchar *msg)
 {
        if (sscanf(msg, "%d %d", &session->count, &session->total_bytes) != 2) {
-               log_error(_("POP3 protocol error\n"));
+               log_error(LOG_PROTOCOL, _("POP3 protocol error\n"));
                session->error_val = PS_PROTOCOL;
                return -1;
        } else {
@@ -207,7 +207,7 @@ static gint pop3_getrange_last_recv(Pop3Session *session, const gchar *msg)
        gint last;
 
        if (sscanf(msg, "%d", &last) == 0) {
-               log_warning(_("POP3 protocol error\n"));
+               log_warning(LOG_PROTOCOL, _("POP3 protocol error\n"));
                session->error_val = PS_PROTOCOL;
                return -1;
        } else {
@@ -253,7 +253,7 @@ static gint pop3_getrange_uidl_recv(Pop3Session *session, const gchar *data,
 
                if (sscanf(buf, "%d %" Xstr(IDLEN) "s", &num, id) != 2 ||
                    num <= 0 || num > session->count) {
-                       log_warning(_("invalid UIDL response: %s\n"), buf);
+                       log_warning(LOG_PROTOCOL, _("invalid UIDL response: %s\n"), buf);
                        continue;
                }
 
@@ -490,9 +490,9 @@ static void pop3_gen_send(Pop3Session *session, const gchar *format, ...)
        va_end(args);
 
        if (!g_ascii_strncasecmp(buf, "PASS ", 5))
-               log_print("POP3> PASS ********\n");
+               log_print(LOG_PROTOCOL, "POP3> PASS ********\n");
        else
-               log_print("POP3> %s\n", buf);
+               log_print(LOG_PROTOCOL, "POP3> %s\n", buf);
 
        session_send_msg(SESSION(session), SESSION_MSG_NORMAL, buf);
 }
@@ -774,9 +774,9 @@ static Pop3State pop3_lookup_next(Pop3Session *session)
                    msg->partial_recv == POP3_TOTALLY_RECEIVED &&
                    session->current_time - msg->recv_time >=
                    ac->msg_leave_time * 24 * 60 * 60) {
-                       log_message
-                               (_("POP3: Deleting expired message "
-                                  "%d\n"), session->cur_msg);
+                       log_message(LOG_PROTOCOL, 
+                                       _("POP3: Deleting expired message %d\n"),
+                                       session->cur_msg);
                        session->cur_total_bytes += size;
                        pop3_delete_send(session);
                        return POP3_DELETE;
@@ -790,9 +790,9 @@ static Pop3State pop3_lookup_next(Pop3Session *session)
                        } else if (msg->partial_recv == POP3_MUST_COMPLETE_RECV)
                                break;
 
-                       log_message
-                               (_("POP3: Skipping message %d (%d bytes)\n"),
-                                  session->cur_msg, size);
+                       log_message(LOG_PROTOCOL, 
+                                       _("POP3: Skipping message %d (%d bytes)\n"),
+                                       session->cur_msg, size);
                }
                
                if (size == 0 || msg->received || size_limit_over) {
@@ -814,7 +814,7 @@ static Pop3ErrorValue pop3_ok(Pop3Session *session, const gchar *msg)
 {
        Pop3ErrorValue ok;
 
-       log_print("POP3< %s\n", msg);
+       log_print(LOG_PROTOCOL, "POP3< %s\n", msg);
 
        if (!strncmp(msg, "+OK", 3))
                ok = PS_SUCCESS;
@@ -823,34 +823,34 @@ static Pop3ErrorValue pop3_ok(Pop3Session *session, const gchar *msg)
                    strstr(msg + 4, "Lock") ||
                    strstr(msg + 4, "LOCK") ||
                    strstr(msg + 4, "wait")) {
-                       log_error(_("mailbox is locked\n"));
+                       log_error(LOG_PROTOCOL, _("mailbox is locked\n"));
                        ok = PS_LOCKBUSY;
                } else if (strcasestr(msg + 4, "timeout")) {
-                       log_error(_("Session timeout\n"));
+                       log_error(LOG_PROTOCOL, _("Session timeout\n"));
                        ok = PS_ERROR;
                } else {
                        switch (session->state) {
 #if USE_OPENSSL
                        case POP3_STLS:
-                               log_error(_("couldn't start TLS session\n"));
+                               log_error(LOG_PROTOCOL, _("couldn't start TLS session\n"));
                                ok = PS_ERROR;
                                break;
 #endif
                        case POP3_GETAUTH_USER:
                        case POP3_GETAUTH_PASS:
                        case POP3_GETAUTH_APOP:
-                               log_error(_("error occurred on authentication\n"));
+                               log_error(LOG_PROTOCOL, _("error occurred on authentication\n"));
                                ok = PS_AUTHFAIL;
                                break;
                        case POP3_GETRANGE_LAST:
                        case POP3_GETRANGE_UIDL:
                        case POP3_TOP:
-                               log_warning(_("command not supported\n"));
+                               log_warning(LOG_PROTOCOL, _("command not supported\n"));
                                ok = PS_NOTSUPPORTED;
                                break;
                                
                        default:
-                               log_error(_("error occurred on POP3 session\n"));
+                               log_error(LOG_PROTOCOL, _("error occurred on POP3 session\n"));
                                ok = PS_ERROR;
                        }
                }
@@ -1044,7 +1044,7 @@ static gint pop3_session_recv_data_finished(Session *session, guchar *data,
                }
                break;
        case POP3_TOP:
-               log_warning(_("TOP command unsupported\n"));
+               log_warning(LOG_PROTOCOL, _("TOP command unsupported\n"));
                if (pop3_session->cur_msg == pop3_session->count)
                        pop3_logout_send(pop3_session);
                else {
index f6ba591..46e6299 100644 (file)
@@ -709,10 +709,12 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"important_score", "1", &prefs_common.important_score, P_INT,
         NULL, NULL, NULL},
-        {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
+
+    {"clip_log", "TRUE", &prefs_common.cliplog, P_BOOL,
         NULL, NULL, NULL},
        {"log_length", "500", &prefs_common.loglength, P_INT,
         NULL, NULL, NULL},
+
        {"log_msg_color", "#00af00", &prefs_common.log_msg_color, P_COLOR,
         NULL, NULL, NULL},
        {"log_warn_color", "#af0000", &prefs_common.log_warn_color, P_COLOR,
@@ -723,6 +725,31 @@ static PrefParam param[] = {
         NULL, NULL, NULL},
        {"log_out_color", "#0000ef", &prefs_common.log_out_color, P_COLOR,
         NULL, NULL, NULL},
+       {"log_status_ok_color", "#00af00", &prefs_common.log_status_ok_color, P_COLOR,
+        NULL, NULL, NULL},
+       {"log_status_nok_color", "#0000af", &prefs_common.log_status_nok_color, P_COLOR,
+        NULL, NULL, NULL},
+       {"log_status_skip_color", "#aa00aa", &prefs_common.log_status_skip_color, P_COLOR,
+        NULL, NULL, NULL},
+
+    {"enable_filtering_debug", "FALSE", &prefs_common.enable_filtering_debug, P_BOOL,
+        NULL, NULL, NULL},
+    {"filtering_debug_level", "1", &prefs_common.filtering_debug_level, P_INT,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_inc", "TRUE", &prefs_common.enable_filtering_debug_inc, P_BOOL,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_manual", "TRUE", &prefs_common.enable_filtering_debug_manual, P_BOOL,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_folder_proc", "FALSE", &prefs_common.enable_filtering_debug_folder_proc, P_BOOL,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_pre_proc", "FALSE", &prefs_common.enable_filtering_debug_pre_proc, P_BOOL,
+        NULL, NULL, NULL},
+    {"enable_filtering_debug_post_proc", "FALSE", &prefs_common.enable_filtering_debug_post_proc, P_BOOL,
+        NULL, NULL, NULL},
+    {"filtering_debug_clip_log", "TRUE", &prefs_common.filtering_debug_cliplog, P_BOOL,
+        NULL, NULL, NULL},
+       {"filtering_debug_log_length", "500", &prefs_common.filtering_debug_loglength, P_INT,
+        NULL, NULL, NULL},
 
        {"gtk_can_change_accels", "TRUE", &prefs_common.gtk_can_change_accels, P_BOOL,
         NULL, NULL, NULL},
@@ -801,6 +828,11 @@ static PrefParam param[] = {
        {"logwin_height", "-1", &prefs_common.logwin_height, P_INT,
         NULL, NULL, NULL},
 
+       {"filtering_debugwin_width", "600", &prefs_common.filtering_debugwin_width, P_INT,
+        NULL, NULL, NULL},
+       {"filtering_debugwin_height", "-1", &prefs_common.filtering_debugwin_height, P_INT,
+        NULL, NULL, NULL},
+
        {"folderselwin_width", "300", &prefs_common.folderselwin_width, P_INT,
         NULL, NULL, NULL},
        {"folderselwin_height", "-1", &prefs_common.folderselwin_height, P_INT,
index 3088f71..3e7a7e2 100644 (file)
@@ -338,11 +338,25 @@ struct _PrefsCommon
 
     gboolean cliplog;
     guint loglength;
+
        gulong log_msg_color;
        gulong log_warn_color;
        gulong log_error_color;
        gulong log_in_color;
        gulong log_out_color;
+       gulong log_status_ok_color;
+       gulong log_status_nok_color;
+       gulong log_status_skip_color;
+
+       gboolean enable_filtering_debug;
+       gint filtering_debug_level;
+       gboolean enable_filtering_debug_inc;
+       gboolean enable_filtering_debug_manual;
+       gboolean enable_filtering_debug_folder_proc;
+       gboolean enable_filtering_debug_pre_proc;
+       gboolean enable_filtering_debug_post_proc;
+    gboolean filtering_debug_cliplog;
+    guint filtering_debug_loglength;
 
     gboolean confirm_on_exit;
        gboolean clean_on_exit;
@@ -403,6 +417,8 @@ struct _PrefsCommon
        gint accountswin_height;
        gint logwin_width;
        gint logwin_height;
+       gint filtering_debugwin_width;
+       gint filtering_debugwin_height;
        gint folderselwin_width;
        gint folderselwin_height;
        gint addressaddwin_width;
diff --git a/src/prefs_logging.c b/src/prefs_logging.c
new file mode 100644 (file)
index 0000000..b6812e3
--- /dev/null
@@ -0,0 +1,392 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2005-2007 Colin Leroy <colin@colino.net> & The Claws Mail Team
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include "defs.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "prefs_common.h"
+#include "prefs_gtk.h"
+
+#include "gtk/gtkutils.h"
+#include "gtk/prefswindow.h"
+#include "gtk/menu.h"
+
+#include "manage_window.h"
+
+#include "log.h"
+
+typedef struct _LoggingPage
+{
+       PrefsPage page;
+
+       GtkWidget *window;
+
+       GtkWidget *checkbtn_cliplog;
+       GtkWidget *spinbtn_loglength;
+       GtkWidget *checkbtn_debug_cliplog;
+       GtkWidget *spinbtn_debug_loglength;
+       GtkWidget *checkbtn_filteringdebug;
+       GtkWidget *checkbtn_filteringdebug_inc;
+       GtkWidget *checkbtn_filteringdebug_manual;
+       GtkWidget *checkbtn_filteringdebug_folder_proc;
+       GtkWidget *checkbtn_filteringdebug_pre_proc;
+       GtkWidget *checkbtn_filteringdebug_post_proc;
+       GtkWidget *optmenu_filteringdebug_level;
+} LoggingPage;
+
+static void prefs_logging_create_widget(PrefsPage *_page, GtkWindow *window, 
+                                 gpointer data)
+{
+       LoggingPage *prefs_logging = (LoggingPage *) _page;
+       
+       GtkWidget *vbox1;
+
+       GtkWidget *frame_logging;
+       GtkWidget *vbox_logging;
+       GtkWidget *hbox_cliplog;
+       GtkWidget *checkbtn_cliplog;
+       GtkWidget *loglength_label;
+       GtkWidget *spinbtn_loglength;
+       GtkObject *spinbtn_loglength_adj;
+       GtkTooltips *loglength_tooltip;
+       GtkWidget *label;
+       GtkWidget *vbox_filteringdebug_log;
+       GtkWidget *hbox_debug_cliplog;
+       GtkWidget *checkbtn_debug_cliplog;
+       GtkWidget *debug_loglength_label;
+       GtkWidget *spinbtn_debug_loglength;
+       GtkObject *spinbtn_debug_loglength_adj;
+       GtkTooltips *debug_loglength_tooltip;
+       GtkWidget *hbox_filteringdebug;
+       GtkWidget *checkbtn_filteringdebug;
+       GtkWidget *frame_filteringdebug;
+       GtkWidget *vbox_filteringdebug;
+       GtkWidget *hbox_filteringdebug_inc;
+       GtkWidget *checkbtn_filteringdebug_inc;
+       GtkWidget *hbox_filteringdebug_manual;
+       GtkWidget *checkbtn_filteringdebug_manual;
+       GtkWidget *hbox_filteringdebug_folder_proc;
+       GtkWidget *checkbtn_filteringdebug_folder_proc;
+       GtkWidget *hbox_filteringdebug_pre_proc;
+       GtkWidget *checkbtn_filteringdebug_pre_proc;
+       GtkWidget *hbox_filteringdebug_post_proc;
+       GtkWidget *checkbtn_filteringdebug_post_proc;
+       GtkTooltips *filteringdebug_tooltip;
+       GtkWidget *hbox_filteringdebug_level;
+       GtkWidget *label_debug_level;
+       GtkWidget *optmenu_filteringdebug_level;
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+       GtkTooltips *filteringdebug_level_tooltip;
+
+       vbox1 = gtk_vbox_new (FALSE, VSPACING);
+       gtk_widget_show (vbox1);
+       gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
+
+       /* Protocol log */
+       vbox_logging = gtkut_get_options_frame(vbox1, &frame_logging, _("Protocol log"));
+
+       PACK_CHECK_BUTTON (vbox_logging, checkbtn_cliplog,
+                          _("Clip the log size"));
+       hbox_cliplog = gtk_hbox_new (FALSE, 8);
+       gtk_container_add (GTK_CONTAINER (vbox_logging), hbox_cliplog);
+       gtk_widget_show (hbox_cliplog);
+       
+       loglength_label = gtk_label_new (_("Log window length"));
+       gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
+                           FALSE, TRUE, 0);
+       gtk_widget_show (GTK_WIDGET (loglength_label));
+       
+       loglength_tooltip = gtk_tooltips_new();
+
+       spinbtn_loglength_adj = gtk_adjustment_new (500, 0, G_MAXINT, 1, 10, 10);
+       spinbtn_loglength = gtk_spin_button_new
+               (GTK_ADJUSTMENT (spinbtn_loglength_adj), 1, 0);
+       gtk_widget_show (spinbtn_loglength);
+       gtk_box_pack_start (GTK_BOX (hbox_cliplog), spinbtn_loglength,
+                           FALSE, FALSE, 0);
+       gtk_widget_set_size_request (GTK_WIDGET (spinbtn_loglength), 64, -1);
+       gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_loglength), TRUE);
+
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(loglength_tooltip), spinbtn_loglength,
+                            _("0 to stop logging in the log window"),
+                            NULL);
+
+       label = gtk_label_new(_("lines"));
+       gtk_widget_show (label);
+       gtk_box_pack_start(GTK_BOX(hbox_cliplog), label, FALSE, FALSE, 0);
+
+       SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_label);
+       SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, spinbtn_loglength);
+       SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, label);
+
+       /* Filtering/processing debug log */
+       vbox_filteringdebug_log = gtkut_get_options_frame(vbox1,
+                               &frame_logging, _("Filtering/processing debug log"));
+
+       PACK_CHECK_BUTTON (vbox_filteringdebug_log, checkbtn_filteringdebug,
+                          _("Enable debugging of filtering/processing rules"));
+       hbox_filteringdebug = gtk_hbox_new (FALSE, 8);
+       gtk_container_add (GTK_CONTAINER (vbox_filteringdebug_log), hbox_filteringdebug);
+       gtk_widget_show (hbox_filteringdebug);
+
+       filteringdebug_tooltip = gtk_tooltips_new();
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(filteringdebug_tooltip), checkbtn_filteringdebug,
+                            _("If checked, turns on debugging of filtering and processing rules.\n"
+                                       "Debug log is available from 'Tools/Filtering debug window'.\n"
+                                       "Caution: enabling this option will slow down the filtering/processing, "
+                                       "this might be critical when applying many rules upon thousands of messages."),
+                            NULL);
+
+       vbox_filteringdebug = gtkut_get_options_frame(vbox_filteringdebug_log, &frame_filteringdebug,
+                                                       _("Debugging of filtering/processing rules when.."));
+
+       PACK_CHECK_BUTTON (vbox_filteringdebug, checkbtn_filteringdebug_inc,
+                          _("filtering at incorporation"));
+       hbox_filteringdebug_inc = gtk_hbox_new (FALSE, 8);
+       gtk_container_add (GTK_CONTAINER (vbox_filteringdebug), hbox_filteringdebug_inc);
+       gtk_widget_show (hbox_filteringdebug_inc);
+
+       PACK_CHECK_BUTTON (vbox_filteringdebug, checkbtn_filteringdebug_manual,
+                          _("manually filtering"));
+       hbox_filteringdebug_manual = gtk_hbox_new (FALSE, 8);
+       gtk_container_add (GTK_CONTAINER (vbox_filteringdebug), hbox_filteringdebug_manual);
+       gtk_widget_show (hbox_filteringdebug_manual);
+
+       PACK_CHECK_BUTTON (vbox_filteringdebug, checkbtn_filteringdebug_folder_proc,
+                          _("processing folders"));
+       hbox_filteringdebug_folder_proc = gtk_hbox_new (FALSE, 8);
+       gtk_container_add (GTK_CONTAINER (vbox_filteringdebug), hbox_filteringdebug_folder_proc);
+       gtk_widget_show (hbox_filteringdebug_folder_proc);
+
+       PACK_CHECK_BUTTON (vbox_filteringdebug, checkbtn_filteringdebug_pre_proc,
+                          _("pre-processing folders"));
+       hbox_filteringdebug_pre_proc = gtk_hbox_new (FALSE, 8);
+       gtk_container_add (GTK_CONTAINER (vbox_filteringdebug), hbox_filteringdebug_pre_proc);
+       gtk_widget_show (hbox_filteringdebug_pre_proc);
+
+       PACK_CHECK_BUTTON (vbox_filteringdebug, checkbtn_filteringdebug_post_proc,
+                          _("post-processing folders"));
+       hbox_filteringdebug_post_proc = gtk_hbox_new (FALSE, 8);
+       gtk_container_add (GTK_CONTAINER (vbox_filteringdebug), hbox_filteringdebug_post_proc);
+       gtk_widget_show (hbox_filteringdebug_post_proc);
+
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, checkbtn_filteringdebug_inc);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, checkbtn_filteringdebug_manual);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, checkbtn_filteringdebug_folder_proc);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, checkbtn_filteringdebug_pre_proc);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, checkbtn_filteringdebug_post_proc);
+
+       hbox_filteringdebug_level = gtk_hbox_new (FALSE, 8);
+       gtk_widget_show (hbox_filteringdebug_level);
+       gtk_box_pack_start(GTK_BOX (vbox_filteringdebug_log), hbox_filteringdebug_level, FALSE, FALSE, 0);
+
+       label_debug_level = gtk_label_new (_("Debug level"));
+       gtk_widget_show (label_debug_level);
+       gtk_box_pack_start(GTK_BOX(hbox_filteringdebug_level), label_debug_level, FALSE, FALSE, 0);
+
+       optmenu_filteringdebug_level = gtk_option_menu_new ();
+       gtk_widget_show (optmenu_filteringdebug_level);
+       
+       menu = gtk_menu_new ();
+       MENUITEM_ADD (menu, menuitem, _("Low"), 0);
+       MENUITEM_ADD (menu, menuitem, _("Medium"), 1);
+       MENUITEM_ADD (menu, menuitem, _("High"), 2);
+
+       gtk_option_menu_set_menu (GTK_OPTION_MENU (optmenu_filteringdebug_level), menu);
+       gtk_box_pack_start(GTK_BOX(hbox_filteringdebug_level), optmenu_filteringdebug_level, FALSE, FALSE, 0);
+
+       filteringdebug_level_tooltip = gtk_tooltips_new();
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(filteringdebug_level_tooltip), optmenu_filteringdebug_level,
+                            _("Select the level of detail displayed if debugging is enabled.\n"
+                               "Choose low level to see when rules are applied, what conditions match or not and what actions are performed.\n"
+                               "Choose medium level to see more detail about the message that is being processed, and why rules are skipped.\n"
+                               "Choose high level to explicitely show the reason why all rules are skipped or not, and why all conditions are matching or not.\n"
+                               "Caution: the higher the level is, the more it will impact the performances."),
+                            NULL);
+
+       PACK_CHECK_BUTTON (vbox_filteringdebug_log, checkbtn_debug_cliplog,
+                          _("Clip the log size"));
+       hbox_debug_cliplog = gtk_hbox_new (FALSE, 8);
+       gtk_container_add (GTK_CONTAINER (vbox_filteringdebug_log), hbox_debug_cliplog);
+       gtk_widget_show (hbox_debug_cliplog);
+       
+       debug_loglength_label = gtk_label_new (_("Log window length"));
+       gtk_box_pack_start (GTK_BOX (hbox_debug_cliplog), debug_loglength_label,
+                           FALSE, TRUE, 0);
+       gtk_widget_show (GTK_WIDGET (debug_loglength_label));
+       
+       debug_loglength_tooltip = gtk_tooltips_new();
+
+       spinbtn_debug_loglength_adj = gtk_adjustment_new (500, 0, G_MAXINT, 1, 10, 10);
+       spinbtn_debug_loglength = gtk_spin_button_new
+               (GTK_ADJUSTMENT (spinbtn_debug_loglength_adj), 1, 0);
+       gtk_widget_show (spinbtn_debug_loglength);
+       gtk_box_pack_start (GTK_BOX (hbox_debug_cliplog), spinbtn_debug_loglength,
+                           FALSE, FALSE, 0);
+       gtk_widget_set_size_request (GTK_WIDGET (spinbtn_debug_loglength), 64, -1);
+       gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_debug_loglength), TRUE);
+
+       gtk_tooltips_set_tip(GTK_TOOLTIPS(debug_loglength_tooltip), spinbtn_debug_loglength,
+                            _("0 to stop logging in the log window"),
+                            NULL);
+
+       label = gtk_label_new(_("lines"));
+       gtk_widget_show (label);
+       gtk_box_pack_start(GTK_BOX(hbox_debug_cliplog), label, FALSE, FALSE, 0);
+
+       SET_TOGGLE_SENSITIVITY(checkbtn_debug_cliplog, debug_loglength_label);
+       SET_TOGGLE_SENSITIVITY(checkbtn_debug_cliplog, spinbtn_debug_loglength);
+       SET_TOGGLE_SENSITIVITY(checkbtn_debug_cliplog, label);
+
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, optmenu_filteringdebug_level);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, checkbtn_debug_cliplog);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, label_debug_level);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, debug_loglength_label);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, spinbtn_debug_loglength);
+       SET_TOGGLE_SENSITIVITY(checkbtn_filteringdebug, label);
+
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cliplog), 
+               prefs_common.cliplog);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_debug_cliplog), 
+               prefs_common.filtering_debug_cliplog);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_filteringdebug), 
+               prefs_common.enable_filtering_debug);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_filteringdebug_inc), 
+               prefs_common.enable_filtering_debug_inc);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_filteringdebug_manual), 
+               prefs_common.enable_filtering_debug_manual);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_filteringdebug_folder_proc), 
+               prefs_common.enable_filtering_debug_folder_proc);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_filteringdebug_pre_proc), 
+               prefs_common.enable_filtering_debug_pre_proc);
+       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_filteringdebug_post_proc), 
+               prefs_common.enable_filtering_debug_post_proc);
+
+       gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_loglength),
+               prefs_common.loglength);
+       gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_debug_loglength),
+               prefs_common.filtering_debug_loglength);
+
+       gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu_filteringdebug_level),
+                       prefs_common.filtering_debug_level);
+
+       prefs_logging->checkbtn_cliplog = checkbtn_cliplog;
+       prefs_logging->spinbtn_loglength = spinbtn_loglength;
+       prefs_logging->checkbtn_debug_cliplog = checkbtn_debug_cliplog;
+       prefs_logging->spinbtn_debug_loglength = spinbtn_debug_loglength;
+       prefs_logging->checkbtn_filteringdebug = checkbtn_filteringdebug;
+       prefs_logging->checkbtn_filteringdebug_inc = checkbtn_filteringdebug_inc;
+       prefs_logging->checkbtn_filteringdebug_manual = checkbtn_filteringdebug_manual;
+       prefs_logging->checkbtn_filteringdebug_folder_proc = checkbtn_filteringdebug_folder_proc;
+       prefs_logging->checkbtn_filteringdebug_pre_proc = checkbtn_filteringdebug_pre_proc;
+       prefs_logging->checkbtn_filteringdebug_post_proc = checkbtn_filteringdebug_post_proc;
+       prefs_logging->optmenu_filteringdebug_level = optmenu_filteringdebug_level;
+
+       prefs_logging->page.widget = vbox1;
+}
+
+static void prefs_logging_save(PrefsPage *_page)
+{
+       LoggingPage *page = (LoggingPage *) _page;
+       MainWindow *mainwindow;
+       gboolean filtering_debug_enabled;
+       GtkWidget *menu;
+       GtkWidget *menuitem;
+
+       menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(page->optmenu_filteringdebug_level));
+       menuitem = gtk_menu_get_active(GTK_MENU(menu));
+       prefs_common.filtering_debug_level = GPOINTER_TO_INT
+                       (g_object_get_data(G_OBJECT(menuitem), MENU_VAL_ID));
+
+       prefs_common.cliplog = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_cliplog));
+       prefs_common.loglength = gtk_spin_button_get_value_as_int(
+               GTK_SPIN_BUTTON(page->spinbtn_loglength));
+       prefs_common.filtering_debug_cliplog = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_debug_cliplog));
+       prefs_common.filtering_debug_loglength = gtk_spin_button_get_value_as_int(
+               GTK_SPIN_BUTTON(page->spinbtn_debug_loglength));
+       filtering_debug_enabled = prefs_common.enable_filtering_debug;
+       prefs_common.enable_filtering_debug = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_filteringdebug));
+       if (filtering_debug_enabled != prefs_common.enable_filtering_debug) {
+               if (prefs_common.enable_filtering_debug)
+                       log_message(LOG_DEBUG_FILTERING, _("filtering debug enabled\n"));
+               else
+                       log_message(LOG_DEBUG_FILTERING, _("filtering debug disabled\n"));
+       }
+       prefs_common.enable_filtering_debug_inc = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_filteringdebug_inc));
+       prefs_common.enable_filtering_debug_manual = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_filteringdebug_manual));
+       prefs_common.enable_filtering_debug_folder_proc = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_filteringdebug_folder_proc));
+       prefs_common.enable_filtering_debug_pre_proc = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_filteringdebug_pre_proc));
+       prefs_common.enable_filtering_debug_post_proc = gtk_toggle_button_get_active(
+               GTK_TOGGLE_BUTTON(page->checkbtn_filteringdebug_post_proc));
+
+       mainwindow = mainwindow_get_mainwindow();
+       log_window_set_clipping(mainwindow->logwin, prefs_common.cliplog,
+                               prefs_common.loglength);
+       log_window_set_clipping(mainwindow->filtering_debugwin, prefs_common.filtering_debug_cliplog,
+                               prefs_common.filtering_debug_loglength);
+}
+
+static void prefs_logging_destroy_widget(PrefsPage *_page)
+{
+}
+
+LoggingPage *prefs_logging;
+
+void prefs_logging_init(void)
+{
+       LoggingPage *page;
+       static gchar *path[3];
+
+       path[0] = _("Other");
+       path[1] = _("Logging");
+       path[2] = NULL;
+
+       page = g_new0(LoggingPage, 1);
+       page->page.path = path;
+       page->page.create_widget = prefs_logging_create_widget;
+       page->page.destroy_widget = prefs_logging_destroy_widget;
+       page->page.save_page = prefs_logging_save;
+       page->page.weight = 5.0;
+       prefs_gtk_register_page((PrefsPage *) page);
+       prefs_logging = page;
+}
+
+void prefs_logging_done(void)
+{
+       prefs_gtk_unregister_page((PrefsPage *) prefs_logging);
+       g_free(prefs_logging);
+}
diff --git a/src/prefs_logging.h b/src/prefs_logging.h
new file mode 100644 (file)
index 0000000..ca0ec50
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
+ * Copyright (C) 2005 Colin Leroy <colin@colino.net> & the Claws Mail team
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef PREFS_LOGGING_H
+#define PREFS_LOGGING_H
+
+void prefs_logging_init        (void);
+void prefs_loggin_done (void);
+
+#endif /* PREFS_LOGGING_H */ 
index c8502c9..2c65f4d 100644 (file)
@@ -53,8 +53,6 @@ typedef struct _OtherPage
        GtkWidget *checkbtn_cleanonexit;
        GtkWidget *checkbtn_askonclean;
        GtkWidget *checkbtn_warnqueued;
-        GtkWidget *checkbtn_cliplog;
-       GtkWidget *spinbtn_loglength;
        GtkWidget *spinbtn_iotimeout;
        GtkWidget *checkbtn_gtk_can_change_accels;
        GtkWidget *checkbtn_askonfilter;
@@ -487,16 +485,6 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        GtkWidget *vbox_addr;
        GtkWidget *checkbtn_addaddrbyclick;
        
-       GtkWidget *frame_cliplog;
-       GtkWidget *vbox_cliplog;
-       GtkWidget *hbox_cliplog;
-       GtkWidget *checkbtn_cliplog;
-       GtkWidget *loglength_label;
-       GtkWidget *spinbtn_loglength;
-       GtkObject *spinbtn_loglength_adj;
-       GtkTooltips *loglength_tooltip;
-       GtkWidget *label;
-
        GtkWidget *frame_exit;
        GtkWidget *vbox_exit;
        GtkWidget *checkbtn_confonexit;
@@ -527,43 +515,6 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
                (vbox_addr, checkbtn_addaddrbyclick,
                 _("Add address to destination when double-clicked"));
 
-       /* Clip Log */
-       vbox_cliplog = gtkut_get_options_frame(vbox1, &frame_cliplog, _("Log Size"));
-
-       PACK_CHECK_BUTTON (vbox_cliplog, checkbtn_cliplog,
-                          _("Clip the log size"));
-       hbox_cliplog = gtk_hbox_new (FALSE, 8);
-       gtk_container_add (GTK_CONTAINER (vbox_cliplog), hbox_cliplog);
-       gtk_widget_show (hbox_cliplog);
-       
-       loglength_label = gtk_label_new (_("Log window length"));
-       gtk_box_pack_start (GTK_BOX (hbox_cliplog), loglength_label,
-                           FALSE, TRUE, 0);
-       gtk_widget_show (GTK_WIDGET (loglength_label));
-       
-       loglength_tooltip = gtk_tooltips_new();
-
-       spinbtn_loglength_adj = gtk_adjustment_new (500, 0, G_MAXINT, 1, 10, 10);
-       spinbtn_loglength = gtk_spin_button_new
-               (GTK_ADJUSTMENT (spinbtn_loglength_adj), 1, 0);
-       gtk_widget_show (spinbtn_loglength);
-       gtk_box_pack_start (GTK_BOX (hbox_cliplog), spinbtn_loglength,
-                           FALSE, FALSE, 0);
-       gtk_widget_set_size_request (GTK_WIDGET (spinbtn_loglength), 64, -1);
-       gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbtn_loglength), TRUE);
-
-       gtk_tooltips_set_tip(GTK_TOOLTIPS(loglength_tooltip), spinbtn_loglength,
-                            _("0 to stop logging in the log window"),
-                            NULL);
-
-       label = gtk_label_new(_("lines"));
-       gtk_widget_show (label);
-       gtk_box_pack_start(GTK_BOX(hbox_cliplog), label, FALSE, FALSE, 0);
-
-       SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, loglength_label);
-       SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, spinbtn_loglength);
-       SET_TOGGLE_SENSITIVITY(checkbtn_cliplog, label);
-
        /* On Exit */
        vbox_exit = gtkut_get_options_frame(vbox1, &frame_exit, _("On exit"));
 
@@ -644,13 +595,9 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
                prefs_common.ask_on_clean);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_warnqueued), 
                prefs_common.warn_queued_on_exit);
-       gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_cliplog), 
-               prefs_common.cliplog);
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkbtn_gtk_can_change_accels),
                prefs_common.gtk_can_change_accels);
 
-       gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_loglength),
-               prefs_common.loglength);
        gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinbtn_iotimeout),
                prefs_common.io_timeout_secs);
 
@@ -662,8 +609,6 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
        prefs_other->checkbtn_cleanonexit = checkbtn_cleanonexit;
        prefs_other->checkbtn_askonclean = checkbtn_askonclean;
        prefs_other->checkbtn_warnqueued = checkbtn_warnqueued;
-       prefs_other->checkbtn_cliplog = checkbtn_cliplog;
-       prefs_other->spinbtn_loglength = spinbtn_loglength;
        prefs_other->spinbtn_iotimeout = spinbtn_iotimeout;
        prefs_other->checkbtn_gtk_can_change_accels = checkbtn_gtk_can_change_accels;
        prefs_other->checkbtn_askonfilter = checkbtn_askonfilter;
@@ -674,7 +619,6 @@ static void prefs_other_create_widget(PrefsPage *_page, GtkWindow *window,
 static void prefs_other_save(PrefsPage *_page)
 {
        OtherPage *page = (OtherPage *) _page;
-       MainWindow *mainwindow;
        gboolean gtk_can_change_accels;
 
        prefs_common.add_address_by_click = gtk_toggle_button_get_active(
@@ -687,10 +631,6 @@ static void prefs_other_save(PrefsPage *_page)
                GTK_TOGGLE_BUTTON(page->checkbtn_askonclean));
        prefs_common.warn_queued_on_exit = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_warnqueued)); 
-       prefs_common.cliplog = gtk_toggle_button_get_active(
-               GTK_TOGGLE_BUTTON(page->checkbtn_cliplog));
-       prefs_common.loglength = gtk_spin_button_get_value_as_int(
-               GTK_SPIN_BUTTON(page->spinbtn_loglength));
        prefs_common.io_timeout_secs = gtk_spin_button_get_value_as_int(
                GTK_SPIN_BUTTON(page->spinbtn_iotimeout));
        sock_set_io_timeout(prefs_common.io_timeout_secs);
@@ -701,10 +641,6 @@ static void prefs_other_save(PrefsPage *_page)
                gtk_toggle_button_get_active(
                        GTK_TOGGLE_BUTTON(page->checkbtn_askonfilter)); 
 
-       mainwindow = mainwindow_get_mainwindow();
-       log_window_set_clipping(mainwindow->logwin, prefs_common.cliplog,
-                               prefs_common.loglength);
-
        gtk_can_change_accels = gtk_toggle_button_get_active(
                GTK_TOGGLE_BUTTON(page->checkbtn_gtk_can_change_accels));
 
index a5276c8..3b370ae 100644 (file)
@@ -857,7 +857,7 @@ gint procmsg_send_queue(FolderItem *queue, gboolean save_msgs, gchar **errstr)
        
        if (send_queue_lock) {
                /* Avoid having to translate two similar strings */
-               log_warning("%s\n", _("Already trying to send."));
+               log_warning(LOG_PROTOCOL, "%s\n", _("Already trying to send."));
                if (errstr) {
                        if (*errstr) g_free(*errstr);
                        *errstr = g_strdup_printf(_("Already trying to send."));
@@ -2121,7 +2121,8 @@ static gboolean procmsg_msginfo_filter(MsgInfo *msginfo, PrefsAccount* ac_prefs)
 
        /* filter if enabled in prefs or move to inbox if not */
        if((filtering_rules != NULL) &&
-          filter_message_by_msginfo(filtering_rules, msginfo, ac_prefs)) {
+               filter_message_by_msginfo(filtering_rules, msginfo, ac_prefs,
+                               FILTERING_INCORPORATION, NULL)) {
                return TRUE;
        }
                
index a5e41e8..a652773 100644 (file)
@@ -134,7 +134,7 @@ gint send_message_local(const gchar *command, FILE *fp)
        g_return_val_if_fail(command != NULL, -1);
        g_return_val_if_fail(fp != NULL, -1);
 
-       log_message(_("Sending message using command: %s\n"), command);
+       log_message(LOG_PROTOCOL, _("Sending message using command: %s\n"), command);
 
        argv = strsplit_with_quote(command, " ", 0);
 
@@ -149,7 +149,7 @@ gint send_message_local(const gchar *command, FILE *fp)
                                     NULL) == FALSE) {
                g_snprintf(buf, sizeof(buf),
                           _("Couldn't execute command: %s"), command);
-               log_warning("%s\n", buf);
+               log_warning(LOG_PROTOCOL, "%s\n", buf);
                alertpanel_error("%s", buf);
                g_strfreev(argv);
                return -1;
@@ -185,7 +185,7 @@ gint send_message_local(const gchar *command, FILE *fp)
                g_snprintf(buf, sizeof(buf),
                           _("Error occurred while executing command: %s"),
                           command);
-               log_warning("%s\n", buf);
+               log_warning(LOG_PROTOCOL, "%s\n", buf);
                alertpanel_error("%s", buf);
                return -1;
        }
@@ -325,7 +325,7 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
                    && (ac_prefs->protocol == A_APOP || ac_prefs->protocol == A_POP3)
                    && (time(NULL) - ac_prefs->last_pop_login_time) > (60 * ac_prefs->pop_before_smtp_timeout)) {
                        g_snprintf(buf, sizeof(buf), _("Doing POP before SMTP..."));
-                       log_message(buf);
+                       log_message(LOG_PROTOCOL, buf);
                        progress_dialog_set_label(dialog->dialog, buf);
                        progress_dialog_list_set_status(dialog->dialog, 0, _("POP before SMTP"));
                        GTK_EVENTS_FLUSH();
@@ -335,7 +335,7 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
                g_snprintf(buf, sizeof(buf), _("Connecting to SMTP server: %s ..."),
                           ac_prefs->smtp_server);
                progress_dialog_set_label(dialog->dialog, buf);
-               log_message("%s\n", buf);
+               log_message(LOG_PROTOCOL, "%s\n", buf);
 
                session_set_recv_message_notify(session, send_recv_message, dialog);
                session_set_send_data_progressive_notify
@@ -392,12 +392,12 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
                }
                ret = -1;
        } else if (SMTP_SESSION(session)->state == SMTP_MAIL_SENT_OK) {
-               log_message("%s\n", _("Mail sent successfully."));
+               log_message(LOG_PROTOCOL, "%s\n", _("Mail sent successfully."));
                ret = 0;
        } else if (session->state == SESSION_EOF &&
                   SMTP_SESSION(session)->state == SMTP_QUIT) {
                /* consider EOF right after QUIT successful */
-               log_warning("%s\n", _("Connection closed by the remote host."));
+               log_warning(LOG_PROTOCOL, "%s\n", _("Connection closed by the remote host."));
                ret = 0;
        } else if (session->state == SESSION_ERROR ||
                   session->state == SESSION_EOF ||
@@ -648,11 +648,11 @@ static void send_put_error(Session *session)
        }
 
        if (err_msg) {
-               log_error("%s\n", err_msg);
+               log_error(LOG_PROTOCOL, "%s\n", err_msg);
                g_free(err_msg);
        } else {
                if (log_msg)
-                       log_warning("%s\n", log_msg);
+                       log_warning(LOG_PROTOCOL, "%s\n", log_msg);
        }
 }
 
index 061e736..291466d 100644 (file)
@@ -3557,7 +3557,7 @@ void summary_mark_as_spam(SummaryView *summaryview, guint action, GtkWidget *wid
                        summary_set_row_marks(summaryview, row);
                }
        } else {
-               log_error(_("An error happened while learning.\n"));
+               log_error(LOG_PROTOCOL, _("An error happened while learning.\n"));
        }
 
        prefs_common.immediate_exec = immediate_exec;
@@ -4824,7 +4824,8 @@ static void summary_filter_func(MsgInfo *msginfo)
        if (hooks_invoke(MAIL_MANUAL_FILTERING_HOOKLIST, &mail_filtering_data))
                return;
 
-       filter_message_by_msginfo(filtering_rules, msginfo, NULL);
+       filter_message_by_msginfo(filtering_rules, msginfo, NULL,
+                       FILTERING_MANUALLY, NULL);
 }
 
 void summary_msginfo_filter_open(FolderItem * item, MsgInfo *msginfo,
@@ -5598,7 +5599,7 @@ static void summary_selected(GtkCTree *ctree, GtkCTreeNode *row,
                                if (procmsg_spam_learner_learn(msginfo, NULL, FALSE) == 0)
                                        summary_msginfo_unset_flags(msginfo, MSG_SPAM, 0);
                                else
-                                       log_error(_("An error happened while learning.\n"));
+                                       log_error(LOG_PROTOCOL, _("An error happened while learning.\n"));
                } else if (!MSG_IS_REPLIED(msginfo->flags) &&
                         !MSG_IS_FORWARDED(msginfo->flags)) {
                        marked_unread = TRUE;