+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
( 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
MICRO_VERSION=1
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=29
+EXTRA_VERSION=30
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=
prefs_fonts.c \
prefs_gtk.c \
prefs_image_viewer.c \
+ prefs_logging.c \
prefs_matcher.c \
prefs_message.c \
prefs_msg_colors.c \
prefs_fonts.h \
prefs_gtk.h \
prefs_image_viewer.h \
+ prefs_logging.h \
prefs_matcher.h \
prefs_message.h \
prefs_msg_colors.h \
#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 */
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];
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];
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];
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];
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]);
}
}
#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 */
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;
}
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;
}
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);
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);
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;
}
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;
}
strretchomp(buf);
if (verbose)
- log_print("NNTP< %s\n", buf);
+ log_print(LOG_PROTOCOL, "NNTP< %s\n", buf);
return NN_SUCCESS;
}
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;
}
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;
}
(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;
}
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:
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,
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));
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:
/* 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;
}
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;
}
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;
}
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;
}
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;
}
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);
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;
}
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;
}
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;
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;
}
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;
}
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;
}
gint ret = 0;
if (strlen(msg) < 4) {
- log_warning(_("bad SMTP response\n"));
+ log_warning(LOG_PROTOCOL, _("bad SMTP response\n"));
return -1;
}
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);
}
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);
}
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);
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;
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)));
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;
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;
}
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);
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;
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);
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);
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;
}
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);
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);
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++;
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);
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);
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();
}
#include "prefs_common.h"
#include "addrbook.h"
#include "addr_compl.h"
+#include "log.h"
#define PREFSBUFSIZE 1024
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) \
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;
}
}
* 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)) {
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
* 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);
}
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; */
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);
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);
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;
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)) {
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,
*\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;
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);
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;
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]);
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;
}
}
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);
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)
#include <glib.h>
#include <gtk/gtkwidget.h>
+#include "log.h"
+
typedef struct _LogWindow LogWindow;
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;
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);
"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);
}
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"
#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);
}
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;
}
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;
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);
(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;
}
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);
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();
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);
}
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;
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';
}
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;
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"),
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;
}
(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;
}
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;
}
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();
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;
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();
session->inc_state = INC_CANCEL;
- log_message(_("Incorporation cancelled\n"));
+ log_message(LOG_PROTOCOL, _("Incorporation cancelled\n"));
}
gboolean inc_is_active(void)
#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"
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);
prefs_summaries_init();
prefs_message_init();
prefs_other_init();
+ prefs_logging_init();
prefs_receive_init();
prefs_send_init();
#ifdef USE_ASPELL
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();
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,
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>"},
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;
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();
SummaryView *summaryview;
MessageView *messageview;
LogWindow *logwin;
+ LogWindow *filtering_debugwin;
gint progressindicator_hook;
#include "quoted-printable.h"
#include "claws.h"
#include <ctype.h>
+#include "prefs_common.h"
+#include "log.h"
/*!
*\brief Keyword lookup element
MATCH_ONE = 2
};
+extern gboolean debug_filtering_session;
+
/*!
*\brief Look up table with keywords defined in \sa matchparser_tab
*/
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 */
}
*\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;
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:
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];
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, '_')
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);
}
}
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,
}
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);
}
switch(prop->criteria) {
case MATCHCRITERIA_ALL:
- return 1;
+ return TRUE;
case MATCHCRITERIA_UNREAD:
return MSG_IS_UNREAD(info->flags);
case MATCHCRITERIA_NOT_UNREAD:
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:
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;
}
}
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:
{
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;
}
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:
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;
}
}
/* 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;
}
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
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);
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 ?
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);
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;
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
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;
}
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;
}
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++) {
#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; \
} \
}
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;
}
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");
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;
}
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;
}
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;
}
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;
}
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;
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;
}
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;
}
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;
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;
}
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;
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;
}
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);
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);
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);
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)
}
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;
}
}
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;
/* 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);
warned_error = TRUE;
} else {
gchar *tmp = g_strdup_printf("%s\n", msg);
- log_error(tmp);
+ log_error(LOG_PROTOCOL, tmp);
g_free(tmp);
}
}
}
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)
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;
}
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 {
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 {
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;
}
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);
}
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;
} 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) {
{
Pop3ErrorValue ok;
- log_print("POP3< %s\n", msg);
+ log_print(LOG_PROTOCOL, "POP3< %s\n", msg);
if (!strncmp(msg, "+OK", 3))
ok = PS_SUCCESS;
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;
}
}
}
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 {
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,
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},
{"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,
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;
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;
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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 */
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;
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;
(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"));
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);
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;
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(
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);
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));
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."));
/* 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;
}
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);
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;
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;
}
&& (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();
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
}
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 ||
}
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);
}
}
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;
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,
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;