aboutsummaryrefslogtreecommitdiff
path: root/src/inc.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-01-17 08:35:55 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2007-01-17 08:35:55 +0000
commit4405c245a1c3608f76e48fe64bab1122cfdad64b (patch)
tree2fe300963f584cda964ac68c347d17a378ab1da2 /src/inc.c
parent4136cc09224f82a99016a9af275564372c868a4a (diff)
implemented the automatic filtering of IMAP4 INBOX folder.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1491 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src/inc.c')
-rw-r--r--src/inc.c51
1 files changed, 48 insertions, 3 deletions
diff --git a/src/inc.c b/src/inc.c
index 6eb939ce..9bed8960 100644
--- a/src/inc.c
+++ b/src/inc.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2007 Hiroyuki Yamamoto
*
* 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
@@ -241,23 +241,68 @@ static gint inc_remote_account_mail(MainWindow *mainwin, PrefsAccount *account)
{
FolderItem *item = mainwin->summaryview->folder_item;
gint new_msgs;
+ gboolean update_summary = FALSE;
g_return_val_if_fail(account->folder != NULL, 0);
+ if (account->protocol == A_IMAP4 &&
+ account->imap_filter_inbox_on_recv) {
+ FolderItem *inbox = FOLDER(account->folder)->inbox;
+ GSList *mlist, *cur;
+ FilterInfo *fltinfo;
+ 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));
+
+ for (cur = mlist; cur != NULL; cur = cur->next) {
+ MsgInfo *msginfo = (MsgInfo *)cur->data;
+
+ fltinfo = filter_info_new();
+ fltinfo->account = account;
+ fltinfo->flags = msginfo->flags;
+ filter_apply_msginfo(prefs_common.fltlist,
+ msginfo, fltinfo);
+ if (fltinfo->actions[FLT_ACTION_MOVE] &&
+ fltinfo->move_dest)
+ folder_item_move_msg
+ (fltinfo->move_dest, msginfo);
+ else if (fltinfo->actions[FLT_ACTION_DELETE])
+ folder_item_remove_msg(inbox, msginfo);
+ if (fltinfo->drop_done)
+ ++n_filtered;
+
+ filter_info_free(fltinfo);
+ }
+
+ procmsg_msg_list_free(mlist);
+
+ debug_print("inc_remote_account_mail(): %d message(s) filtered\n", n_filtered);
+
+ if (!prefs_common.scan_all_after_inc && item != NULL &&
+ inbox == item)
+ update_summary = TRUE;
+ }
+
if (account->protocol == A_IMAP4 && account->imap_check_inbox_only) {
FolderItem *inbox = FOLDER(account->folder)->inbox;
new_msgs = folderview_check_new_item(inbox);
if (!prefs_common.scan_all_after_inc && item != NULL &&
inbox == item)
- folderview_update_item(item, TRUE);
+ update_summary = TRUE;
} else {
new_msgs = folderview_check_new(FOLDER(account->folder));
if (!prefs_common.scan_all_after_inc && item != NULL &&
FOLDER(account->folder) == item->folder)
- folderview_update_item(item, TRUE);
+ update_summary = TRUE;
}
+ if (update_summary)
+ folderview_update_item(item, TRUE);
+ folderview_update_all_updated(FALSE);
+
return new_msgs;
}