aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-12-22 08:44:10 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-12-22 08:44:10 +0000
commitc77c6ae995dedbe433fa36f1e4fc75ece4537039 (patch)
treee2cd5933e9824e946a1e41ac3729dde5a51a9e9b /src
parentd2327d919562327399c0799b36e71178defe9e93 (diff)
Automatically select appropriate Junk folder on filtering.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2767 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/inc.c38
-rw-r--r--src/inc.h2
-rw-r--r--src/main.c2
-rw-r--r--src/prefs_common_dialog.c1
-rw-r--r--src/summaryview.c21
-rw-r--r--src/summaryview.h3
6 files changed, 51 insertions, 16 deletions
diff --git a/src/inc.c b/src/inc.c
index b62e2676..0bed04ac 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -253,12 +253,18 @@ static gint inc_remote_account_mail(MainWindow *mainwin, PrefsAccount *account)
FolderItem *inbox = FOLDER(account->folder)->inbox;
GSList *mlist, *cur;
FilterInfo *fltinfo;
+ GSList junk_fltlist = {NULL, NULL};
+ FilterRule *junk_rule;
gint n_filtered = 0;
debug_print("inc_remote_account_mail(): filtering IMAP4 INBOX\n");
mlist = folder_item_get_uncached_msg_list(inbox);
debug_print("inc_remote_account_mail(): uncached messages: %d\n", g_slist_length(mlist));
+ junk_rule = filter_junk_rule_create(account, NULL, TRUE);
+ if (junk_rule)
+ junk_fltlist.data = junk_rule;
+
for (cur = mlist; cur != NULL; cur = cur->next) {
MsgInfo *msginfo = (MsgInfo *)cur->data;
@@ -268,10 +274,9 @@ static gint inc_remote_account_mail(MainWindow *mainwin, PrefsAccount *account)
if (prefs_common.enable_junk &&
prefs_common.filter_junk_on_recv &&
- prefs_common.filter_junk_before) {
+ prefs_common.filter_junk_before && junk_rule) {
filter_apply_msginfo
- (prefs_common.manual_junk_fltlist,
- msginfo, fltinfo);
+ (&junk_fltlist, msginfo, fltinfo);
}
if (!fltinfo->drop_done) {
@@ -282,10 +287,9 @@ static gint inc_remote_account_mail(MainWindow *mainwin, PrefsAccount *account)
if (!fltinfo->drop_done &&
prefs_common.enable_junk &&
prefs_common.filter_junk_on_recv &&
- !prefs_common.filter_junk_before) {
+ !prefs_common.filter_junk_before && junk_rule) {
filter_apply_msginfo
- (prefs_common.manual_junk_fltlist,
- msginfo, fltinfo);
+ (&junk_fltlist, msginfo, fltinfo);
}
if (msginfo->flags.perm_flags !=
@@ -323,6 +327,9 @@ static gint inc_remote_account_mail(MainWindow *mainwin, PrefsAccount *account)
filter_info_free(fltinfo);
}
+ if (junk_rule)
+ filter_rule_free(junk_rule);
+
procmsg_msg_list_free(mlist);
debug_print("inc_remote_account_mail(): INBOX: %d new, %d filtered\n",
@@ -585,6 +592,7 @@ static void inc_progress_dialog_destroy(IncProgressDialog *inc_dialog)
static IncSession *inc_session_new(PrefsAccount *account)
{
IncSession *session;
+ FilterRule *rule;
g_return_val_if_fail(account != NULL, NULL);
@@ -611,6 +619,12 @@ static IncSession *inc_session_new(PrefsAccount *account)
session->folder_table = g_hash_table_new(NULL, NULL);
session->tmp_folder_table = g_hash_table_new(NULL, NULL);
+ rule = filter_junk_rule_create(account, NULL, FALSE);
+ if (rule)
+ session->junk_fltlist = g_slist_append(NULL, rule);
+ else
+ session->junk_fltlist = NULL;
+
session->cur_total_bytes = 0;
session->new_msgs = 0;
@@ -629,6 +643,8 @@ static void inc_session_destroy(IncSession *session)
session_destroy(session->session);
g_hash_table_destroy(session->folder_table);
g_hash_table_destroy(session->tmp_folder_table);
+ if (session->junk_fltlist)
+ filter_rule_list_free(session->junk_fltlist);
g_free(session);
}
@@ -1283,8 +1299,9 @@ static gint inc_drop_message(Pop3Session *session, const gchar *file)
if (prefs_common.enable_junk &&
prefs_common.filter_junk_on_recv &&
- prefs_common.filter_junk_before) {
- filter_apply_msginfo(prefs_common.junk_fltlist, msginfo,
+ prefs_common.filter_junk_before &&
+ inc_session->junk_fltlist) {
+ filter_apply_msginfo(inc_session->junk_fltlist, msginfo,
fltinfo);
if (fltinfo->drop_done)
is_junk = TRUE;
@@ -1306,8 +1323,9 @@ static gint inc_drop_message(Pop3Session *session, const gchar *file)
if (!fltinfo->drop_done) {
if (prefs_common.enable_junk &&
prefs_common.filter_junk_on_recv &&
- !prefs_common.filter_junk_before) {
- filter_apply_msginfo(prefs_common.junk_fltlist,
+ !prefs_common.filter_junk_before &&
+ inc_session->junk_fltlist) {
+ filter_apply_msginfo(inc_session->junk_fltlist,
msginfo, fltinfo);
if (fltinfo->drop_done)
is_junk = TRUE;
diff --git a/src/inc.h b/src/inc.h
index 4481120e..5f30c076 100644
--- a/src/inc.h
+++ b/src/inc.h
@@ -73,6 +73,8 @@ struct _IncSession
GHashTable *folder_table; /* table of destination folders */
GHashTable *tmp_folder_table; /* for progressive update */
+ GSList *junk_fltlist;
+
gint64 cur_total_bytes;
gint new_msgs;
diff --git a/src/main.c b/src/main.c
index 727f084a..36a18259 100644
--- a/src/main.c
+++ b/src/main.c
@@ -349,8 +349,6 @@ int main(int argc, char *argv[])
new_account = setup_account();
}
- prefs_common_junk_filter_list_set();
-
account_set_menu();
main_window_reflect_prefs_all();
diff --git a/src/prefs_common_dialog.c b/src/prefs_common_dialog.c
index 8399dec9..6e7f432b 100644
--- a/src/prefs_common_dialog.c
+++ b/src/prefs_common_dialog.c
@@ -4382,7 +4382,6 @@ static void prefs_common_ok(void)
static void prefs_common_apply(void)
{
prefs_set_data_from_dialog(prefs_common_get_params());
- prefs_common_junk_filter_list_set();
gtkut_stock_button_set_set_reverse(!prefs_common.comply_gnome_hig);
main_window_reflect_prefs_all();
compose_reflect_prefs_all();
diff --git a/src/summaryview.c b/src/summaryview.c
index 80e8adb9..0349f55c 100644
--- a/src/summaryview.c
+++ b/src/summaryview.c
@@ -4643,8 +4643,7 @@ static gboolean summary_filter_junk_func(GtkTreeModel *model, GtkTreePath *path,
fltinfo = filter_info_new();
fltinfo->flags = msginfo->flags;
- filter_apply_msginfo(prefs_common.manual_junk_fltlist,
- msginfo, fltinfo);
+ filter_apply_msginfo(summaryview->junk_fltlist, msginfo, fltinfo);
if (fltinfo->actions[FLT_ACTION_MOVE] ||
fltinfo->actions[FLT_ACTION_COPY] ||
@@ -4761,9 +4760,25 @@ void summary_filter(SummaryView *summaryview, gboolean selected_only)
void summary_filter_junk(SummaryView *summaryview, gboolean selected_only)
{
- if (prefs_common.manual_junk_fltlist)
+ FilterRule *rule;
+ GSList junk_fltlist = {NULL, NULL};
+ FolderItem *item = summaryview->folder_item;
+ FolderItem *junk = NULL;
+
+ if (!item)
+ return;
+
+ if (item->folder)
+ junk = folder_get_junk(item->folder);
+ rule = filter_junk_rule_create(NULL, junk, TRUE);
+ if (rule) {
+ junk_fltlist.data = rule;
+ summaryview->junk_fltlist = &junk_fltlist;
summary_filter_real(summaryview, summary_filter_junk_func,
selected_only);
+ summaryview->junk_fltlist = NULL;
+ filter_rule_free(rule);
+ }
}
void summary_filter_open(SummaryView *summaryview, FilterCreateType type)
diff --git a/src/summaryview.h b/src/summaryview.h
index 6c64fe7b..723b5b73 100644
--- a/src/summaryview.h
+++ b/src/summaryview.h
@@ -159,6 +159,9 @@ private:
GSList *pos_list;
guint write_lock_count;
+
+ /* junk filter list */
+ GSList *junk_fltlist;
};
SummaryView *summary_create(void);