[Commits] [SCM] claws branch, master, updated. 3.11.1-14-gfd3e515
ticho at claws-mail.org
ticho at claws-mail.org
Thu Nov 13 15:12:28 CET 2014
The branch, master has been updated
via fd3e5155cf7652b058e677f26bf2e2ff7b1e4992 (commit)
from ae516559e73b6a06f3139f0fa88cd649643fe7b4 (commit)
Summary of changes:
src/plugins/bogofilter/bogofilter.c | 24 +++++++----
src/plugins/bogofilter/bogofilter.h | 9 ++++-
src/plugins/bogofilter/bogofilter_gtk.c | 66 +++++++++++++++++++++++++------
3 files changed, 78 insertions(+), 21 deletions(-)
- Log -----------------------------------------------------------------
commit fd3e5155cf7652b058e677f26bf2e2ff7b1e4992
Author: Andrej Kacian <ticho at claws-mail.org>
Date: Fri Nov 7 19:11:34 2014 +0100
Bogofilter: In addition to deleting or saving a spam message, allow third option, where such message is only marked as spam, but is let through for user to handle it further (perhaps via filtering rules).
diff --git a/src/plugins/bogofilter/bogofilter.c b/src/plugins/bogofilter/bogofilter.c
index d5e6076..66bd311 100644
--- a/src/plugins/bogofilter/bogofilter.c
+++ b/src/plugins/bogofilter/bogofilter.c
@@ -88,7 +88,7 @@ static BogofilterConfig config;
static PrefParam param[] = {
{"process_emails", "TRUE", &config.process_emails, P_BOOL,
NULL, NULL, NULL},
- {"receive_spam", "TRUE", &config.receive_spam, P_BOOL,
+ {"receive_spam", "1", &config.receive_spam, P_INT,
NULL, NULL, NULL},
{"save_folder", NULL, &config.save_folder, P_STRING,
NULL, NULL, NULL},
@@ -319,9 +319,16 @@ static void bogofilter_do_filter(BogoFilterData *data)
if (!whitelisted && parts && parts[0] && parts[1] && *parts[1] == 'S') {
debug_print("message %d is spam\n", msginfo->msgnum);
- /* Spam will be filtered away */
- data->mail_filtering_data->filtered = g_slist_prepend(
- data->mail_filtering_data->filtered, msginfo);
+ /* Spam will be filtered away, unless we want "mark only".
+ * In that case, we want it among unfiltered messages, so
+ * it gets processed further. */
+ if (config.receive_spam == SPAM_MARK_ONLY) {
+ data->mail_filtering_data->unfiltered = g_slist_prepend(
+ data->mail_filtering_data->unfiltered, msginfo);
+ } else {
+ data->mail_filtering_data->filtered = g_slist_prepend(
+ data->mail_filtering_data->filtered, msginfo);
+ }
data->new_spams = g_slist_prepend(data->new_spams, msginfo);
} else if (whitelisted && parts && parts[0] && parts[1] &&
@@ -584,11 +591,12 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
}
}
- /* flag spams and delete them if !config.receive_spam
- * (if config.receive_spam is set, we'll move them later) */
+ /* flag spams and delete them if config.receive_spam == 0
+ * (if config.receive_spam is set to 1, we'll move them later,
+ * mark as spam only if set to 2) */
for (cur = new_spams; cur; cur = cur->next) {
MsgInfo *msginfo = (MsgInfo *)cur->data;
- if (config.receive_spam) {
+ if (config.receive_spam != SPAM_DELETE) {
if (config.mark_as_read)
procmsg_msginfo_unset_flags(msginfo, ~0, 0);
procmsg_msginfo_set_flags(msginfo, MSG_SPAM, 0);
@@ -627,7 +635,7 @@ static gboolean mail_filtering_hook(gpointer source, gpointer data)
mail_filtering_data->filtered = NULL;
mail_filtering_data->unfiltered = NULL;
} else {
- if (config.receive_spam && new_spams) {
+ if (config.receive_spam == SPAM_MARK_AND_SAVE && new_spams) {
FolderItem *save_folder = NULL;
if ((!config.save_folder) ||
diff --git a/src/plugins/bogofilter/bogofilter.h b/src/plugins/bogofilter/bogofilter.h
index 9d92698..ce49b57 100644
--- a/src/plugins/bogofilter/bogofilter.h
+++ b/src/plugins/bogofilter/bogofilter.h
@@ -31,7 +31,7 @@ typedef void (*MessageCallback) (gchar *, gint total, gint done, gboolean thread
struct _BogofilterConfig
{
gboolean process_emails;
- gboolean receive_spam;
+ guint receive_spam;
gchar *save_folder;
guint max_size;
gchar *bogopath;
@@ -44,6 +44,13 @@ struct _BogofilterConfig
gboolean mark_as_read;
};
+/* Used for values of receive_spam preference. */
+enum {
+ SPAM_DELETE,
+ SPAM_MARK_AND_SAVE,
+ SPAM_MARK_ONLY
+};
+
BogofilterConfig *bogofilter_get_config (void);
void bogofilter_save_config (void);
void bogofilter_set_message_callback (MessageCallback callback);
diff --git a/src/plugins/bogofilter/bogofilter_gtk.c b/src/plugins/bogofilter/bogofilter_gtk.c
index 82a7fc6..6be16d2 100644
--- a/src/plugins/bogofilter/bogofilter_gtk.c
+++ b/src/plugins/bogofilter/bogofilter_gtk.c
@@ -79,6 +79,17 @@ static void foldersel_cb(GtkWidget *widget, gpointer data)
}
}
+static void spam_handle_combobox_callback(GtkWidget *widget, gpointer user_data)
+{
+ GtkWidget *hbox = GTK_WIDGET(user_data);
+
+ if (gtk_combo_box_get_active(GTK_COMBO_BOX(widget)) == 1) {
+ gtk_widget_set_sensitive(hbox, TRUE);
+ } else {
+ gtk_widget_set_sensitive(hbox, FALSE);
+ }
+}
+
#ifndef USE_NEW_ADDRBOOK
static void bogofilter_whitelist_ab_select_cb(GtkWidget *widget, gpointer data)
{
@@ -115,7 +126,8 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
GtkWidget *process_emails_checkbtn;
- GtkWidget *save_spam_checkbtn;
+ GtkWidget *spam_handle_label;
+ GtkWidget *spam_handle_combobox;
GtkWidget *save_spam_folder_entry;
GtkWidget *save_spam_folder_select;
@@ -175,22 +187,55 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
gtk_widget_show(hbox_save_spam);
gtk_box_pack_start (GTK_BOX (vbox2), hbox_save_spam, TRUE, TRUE, 0);
- save_spam_checkbtn = gtk_check_button_new_with_label(_("Save spam in"));
- gtk_widget_show(save_spam_checkbtn);
- gtk_box_pack_start(GTK_BOX(hbox_save_spam), save_spam_checkbtn, FALSE, FALSE, 0);
+#if !GTK_CHECK_VERSION(2, 24, 0)
+ spam_handle_combobox = gtk_combo_box_new_text();
+#else
+ spam_handle_combobox = gtk_combo_box_text_new();
+#endif
+
+#if !GTK_CHECK_VERSION(2, 24, 0)
+ gtk_combo_box_append_text(GTK_COMBO_BOX(spam_handle_combobox),
+#else
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(spam_handle_combobox),
+#endif
+ _("Delete spam"));
+
+#if !GTK_CHECK_VERSION(2, 24, 0)
+ gtk_combo_box_append_text(GTK_COMBO_BOX(spam_handle_combobox),
+#else
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(spam_handle_combobox),
+#endif
+ _("Save spam in..."));
+
+#if !GTK_CHECK_VERSION(2, 24, 0)
+ gtk_combo_box_append_text(GTK_COMBO_BOX(spam_handle_combobox),
+#else
+ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(spam_handle_combobox),
+#endif
+ _("Only mark as spam"));
+
+ gtk_widget_show(spam_handle_combobox);
+ gtk_box_pack_start(GTK_BOX(hbox_save_spam), spam_handle_combobox, FALSE, FALSE, 0);
+
+ GtkWidget *hbox = gtk_hbox_new(FALSE, 8);
+ gtk_widget_show(hbox);
+ gtk_box_pack_start (GTK_BOX (hbox_save_spam), hbox, TRUE, TRUE, 0);
save_spam_folder_entry = gtk_entry_new();
gtk_widget_show (save_spam_folder_entry);
- gtk_box_pack_start (GTK_BOX (hbox_save_spam), save_spam_folder_entry, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), save_spam_folder_entry, TRUE, TRUE, 0);
CLAWS_SET_TIP(save_spam_folder_entry,
_("Folder for storing identified spam. Leave empty to use the trash folder."));
save_spam_folder_select = gtkut_get_browse_directory_btn(_("_Browse"));
gtk_widget_show (save_spam_folder_select);
- gtk_box_pack_start (GTK_BOX (hbox_save_spam), save_spam_folder_select, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), save_spam_folder_select, FALSE, FALSE, 0);
CLAWS_SET_TIP(save_spam_folder_select,
_("Click this button to select a folder for storing spam"));
+ g_signal_connect(G_OBJECT(spam_handle_combobox), "changed",
+ G_CALLBACK(spam_handle_combobox_callback), (gpointer)hbox);
+
hbox_save_unsure = gtk_hbox_new(FALSE, 8);
gtk_widget_show(hbox_save_unsure);
gtk_box_pack_start (GTK_BOX (vbox2), hbox_save_unsure, TRUE, TRUE, 0);
@@ -266,8 +311,6 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
gtk_widget_show(mark_as_read_checkbtn);
gtk_box_pack_start(GTK_BOX(hbox_mark_as_read), mark_as_read_checkbtn, FALSE, FALSE, 0);
- SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, save_spam_folder_entry);
- SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, save_spam_folder_select);
SET_TOGGLE_SENSITIVITY(save_unsure_checkbtn, save_unsure_folder_entry);
SET_TOGGLE_SENSITIVITY(save_unsure_checkbtn, save_unsure_folder_select);
SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, whitelist_ab_folder_combo);
@@ -275,7 +318,6 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, whitelist_ab_select_btn);
#endif
SET_TOGGLE_SENSITIVITY(whitelist_ab_checkbtn, learn_from_whitelist_chkbtn);
- SET_TOGGLE_SENSITIVITY(save_spam_checkbtn, mark_as_read_checkbtn);
config = bogofilter_get_config();
@@ -291,7 +333,7 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
#endif
gtk_spin_button_set_value(GTK_SPIN_BUTTON(max_size_spinbtn), (float) config->max_size);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(process_emails_checkbtn), config->process_emails);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_spam_checkbtn), config->receive_spam);
+ gtk_combo_box_set_active(GTK_COMBO_BOX(spam_handle_combobox), config->receive_spam);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(save_unsure_checkbtn), config->save_unsure);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(insert_header_checkbtn), config->insert_header);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(whitelist_ab_checkbtn), config->whitelist_ab);
@@ -321,7 +363,7 @@ static void bogofilter_create_widget_func(PrefsPage * _page,
page->max_size = max_size_spinbtn;
page->process_emails = process_emails_checkbtn;
- page->receive_spam = save_spam_checkbtn;
+ page->receive_spam = spam_handle_combobox;
page->save_folder = save_spam_folder_entry;
page->save_folder_select = save_spam_folder_select;
@@ -358,7 +400,7 @@ static void bogofilter_save_func(PrefsPage *_page)
config->process_emails = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->process_emails));
/* receive_spam */
- config->receive_spam = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(page->receive_spam));
+ config->receive_spam = gtk_combo_box_get_active(GTK_COMBO_BOX(page->receive_spam));
/* save_folder */
g_free(config->save_folder);
-----------------------------------------------------------------------
hooks/post-receive
--
Claws Mail
More information about the Commits
mailing list