From dac50a4059b01b89aa46565370a1a9a14d957455 Mon Sep 17 00:00:00 2001 From: hiro Date: Thu, 14 Feb 2013 08:01:28 +0000 Subject: added an option: 'Do not classify message as junk if sender is in the address book' git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3222 ee746299-78ed-0310-b773-934348b2243d --- ChangeLog | 7 +++++++ libsylph/filter.c | 13 ++++++++++--- libsylph/prefs_common.c | 2 ++ libsylph/prefs_common.h | 2 ++ src/prefs_common_dialog.c | 26 +++++++++++++++++--------- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 12c3aae2..5c203d8a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-02-14 + + * libsylph/filter.c + libsylph/prefs_common.[ch] + src/prefs_common_dialog.c: added an option: "Do not classify message + as junk if sender is in the address book" (#77). + 2013-02-14 * src/notificationwindow.c: adjusted paddings again. diff --git a/libsylph/filter.c b/libsylph/filter.c index bb6a1c74..813ed329 100644 --- a/libsylph/filter.c +++ b/libsylph/filter.c @@ -1586,9 +1586,16 @@ FilterRule *filter_junk_rule_create(PrefsAccount *account, debug_print("filter_junk_rule_create: junk folder: %s\n", junk_id); + if (prefs_common.nofilter_junk_sender_in_book) { + cond = filter_cond_new(FLT_COND_HEADER, FLT_IN_ADDRESSBOOK, + FLT_NOT_MATCH, "From", NULL); + cond_list = g_slist_append(cond_list, cond); + } + cond = filter_cond_new(FLT_COND_CMD_TEST, 0, 0, NULL, prefs_common.junk_classify_cmd); - cond_list = g_slist_append(NULL, cond); + cond_list = g_slist_append(cond_list, cond); + if (prefs_common.delete_junk_on_recv && !is_manual) { action = filter_action_new(FLT_ACTION_COPY, junk_id); action_list = g_slist_append(NULL, action); @@ -1605,10 +1612,10 @@ FilterRule *filter_junk_rule_create(PrefsAccount *account, } if (is_manual) - rule = filter_rule_new(_("Junk mail filter (manual)"), FLT_OR, + rule = filter_rule_new(_("Junk mail filter (manual)"), FLT_AND, cond_list, action_list); else - rule = filter_rule_new(_("Junk mail filter"), FLT_OR, + rule = filter_rule_new(_("Junk mail filter"), FLT_AND, cond_list, action_list); g_free(junk_id); diff --git a/libsylph/prefs_common.c b/libsylph/prefs_common.c index 46806d4e..0c3de0bc 100644 --- a/libsylph/prefs_common.c +++ b/libsylph/prefs_common.c @@ -393,6 +393,8 @@ static PrefParam param[] = { P_BOOL}, {"delete_junk_on_receive", "TRUE", &prefs_common.delete_junk_on_recv, P_BOOL}, + {"nofilter_junk_sender_in_book", "TRUE", + &prefs_common.nofilter_junk_sender_in_book, P_BOOL}, {"mark_junk_as_read", "FALSE", &prefs_common.mark_junk_as_read, P_BOOL}, /* Privacy */ diff --git a/libsylph/prefs_common.h b/libsylph/prefs_common.h index 471d95c8..266ae13d 100644 --- a/libsylph/prefs_common.h +++ b/libsylph/prefs_common.h @@ -343,6 +343,8 @@ struct _PrefsCommon gint attach_toolbutton_pos; /* Message - Attachment */ gboolean enable_newmsg_notify_window; /* Receive */ + + gboolean nofilter_junk_sender_in_book; /* Junk Mail */ }; extern PrefsCommon prefs_common; diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c index d4c8d2bf..a917fa32 100644 --- a/src/prefs_common_dialog.c +++ b/src/prefs_common_dialog.c @@ -194,6 +194,7 @@ static struct JunkMail { GtkWidget *chkbtn_filter_on_recv; GtkWidget *chkbtn_filter_before; GtkWidget *chkbtn_delete_on_recv; + GtkWidget *chkbtn_nofilter_in_book; GtkWidget *chkbtn_mark_as_read; } junk; @@ -515,6 +516,8 @@ static PrefsUIData ui_data[] = { prefs_set_data_from_toggle, prefs_set_toggle}, {"delete_junk_on_receive", &junk.chkbtn_delete_on_recv, prefs_set_data_from_toggle, prefs_set_toggle}, + {"nofilter_junk_sender_in_book", &junk.chkbtn_nofilter_in_book, + prefs_set_data_from_toggle, prefs_set_toggle}, {"mark_junk_as_read", &junk.chkbtn_mark_as_read, prefs_set_data_from_toggle, prefs_set_toggle}, @@ -2246,6 +2249,7 @@ static void prefs_junk_create(void) GtkWidget *chkbtn_filter_on_recv; GtkWidget *chkbtn_filter_before; GtkWidget *chkbtn_delete_on_recv; + GtkWidget *chkbtn_nofilter_in_book; GtkWidget *chkbtn_mark_as_read; vbox1 = gtk_vbox_new (FALSE, VSPACING); @@ -2379,18 +2383,22 @@ static void prefs_junk_create(void) SET_TOGGLE_SENSITIVITY (chkbtn_filter_on_recv, chkbtn_filter_before); SET_TOGGLE_SENSITIVITY (chkbtn_filter_on_recv, chkbtn_delete_on_recv); + PACK_CHECK_BUTTON + (vbox3, chkbtn_nofilter_in_book, + _("Do not classify message as junk if sender is in the address book")); PACK_CHECK_BUTTON (vbox3, chkbtn_mark_as_read, _("Mark filtered junk mails as read")); - junk.chkbtn_enable_junk = chkbtn_enable_junk; - junk.entry_junk_learncmd = entry_junk_learncmd; - junk.entry_nojunk_learncmd = entry_nojunk_learncmd; - junk.entry_classify_cmd = entry_classify_cmd; - junk.entry_junkfolder = entry_junkfolder; - junk.chkbtn_filter_on_recv = chkbtn_filter_on_recv; - junk.chkbtn_filter_before = chkbtn_filter_before; - junk.chkbtn_delete_on_recv = chkbtn_delete_on_recv; - junk.chkbtn_mark_as_read = chkbtn_mark_as_read; + junk.chkbtn_enable_junk = chkbtn_enable_junk; + junk.entry_junk_learncmd = entry_junk_learncmd; + junk.entry_nojunk_learncmd = entry_nojunk_learncmd; + junk.entry_classify_cmd = entry_classify_cmd; + junk.entry_junkfolder = entry_junkfolder; + junk.chkbtn_filter_on_recv = chkbtn_filter_on_recv; + junk.chkbtn_filter_before = chkbtn_filter_before; + junk.chkbtn_delete_on_recv = chkbtn_delete_on_recv; + junk.chkbtn_nofilter_in_book = chkbtn_nofilter_in_book; + junk.chkbtn_mark_as_read = chkbtn_mark_as_read; } #if USE_GPGME -- cgit v1.2.3