aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/imap
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-07-02 23:03:49 +0800
committerDan Winship <danw@src.gnome.org>2001-07-02 23:03:49 +0800
commitfaac871501ee1935cdbaf044e2f8ac4dc00eadc2 (patch)
tree14ae39437ee4f3ffc127ac83676c26c506f7c742 /camel/providers/imap
parent55938df2d4948d9581adf7ef660b01fbc6482f4e (diff)
downloadgsoc2013-evolution-faac871501ee1935cdbaf044e2f8ac4dc00eadc2.tar
gsoc2013-evolution-faac871501ee1935cdbaf044e2f8ac4dc00eadc2.tar.gz
gsoc2013-evolution-faac871501ee1935cdbaf044e2f8ac4dc00eadc2.tar.bz2
gsoc2013-evolution-faac871501ee1935cdbaf044e2f8ac4dc00eadc2.tar.lz
gsoc2013-evolution-faac871501ee1935cdbaf044e2f8ac4dc00eadc2.tar.xz
gsoc2013-evolution-faac871501ee1935cdbaf044e2f8ac4dc00eadc2.tar.zst
gsoc2013-evolution-faac871501ee1935cdbaf044e2f8ac4dc00eadc2.zip
new method to get an application-initialized filter driver.
* camel-session.c (camel_session_get_filter_driver): new method to get an application-initialized filter driver. * camel-filter-driver.c (camel_filter_driver_new): Remove the get_folder function and data args from here... (camel_filter_driver_set_folder_func): ...and add this function to set/change them. * providers/imap/camel-imap-folder.c (camel_imap_folder_new): If this folder is INBOX and we're filtering INBOX, set a flag on the folder for later. (imap_update_summary): Add another argument (GPtrArray *recents), and if it's non-NULL, add the uids of any \Recent new messages to it. (camel_imap_folder_changed): If doing filtering in this folder, create a recents array and pass it to imap_update_summary. Then get a filter driver and use it to filter the recent messages. * providers/imap/camel-imap-summary.h: * providers/imap/camel-imap-utils.c (imap_parse_flag_list): Add support for the \Recent flag. * providers/imap/camel-imap-provider.c (imap_conf_entries): enable the "filter" option. * camel-types.h: add CamelFilterDriver typedef here svn path=/trunk/; revision=10681
Diffstat (limited to 'camel/providers/imap')
-rw-r--r--camel/providers/imap/camel-imap-folder.c34
-rw-r--r--camel/providers/imap/camel-imap-folder.h2
-rw-r--r--camel/providers/imap/camel-imap-provider.c2
-rw-r--r--camel/providers/imap/camel-imap-summary.h2
-rw-r--r--camel/providers/imap/camel-imap-utils.c2
5 files changed, 37 insertions, 5 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index beb9ec2740..c04c6cbb4c 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -50,6 +50,7 @@
#include "camel-data-wrapper.h"
#include "camel-disco-diary.h"
#include "camel-exception.h"
+#include "camel-filter-driver.h"
#include "camel-mime-filter-crlf.h"
#include "camel-mime-filter-from.h"
#include "camel-mime-message.h"
@@ -219,6 +220,10 @@ camel_imap_folder_new (CamelStore *parent, const char *folder_name,
return NULL;
}
+ if ((imap_store->parameters & IMAP_PARAM_FILTER_INBOX) &&
+ !g_strcasecmp (folder_name, "INBOX"))
+ imap_folder->do_filtering = TRUE;
+
return folder;
}
@@ -1515,6 +1520,7 @@ imap_cache_message (CamelDiscoFolder *disco_folder, const char *uid,
static void
imap_update_summary (CamelFolder *folder,
CamelFolderChangeInfo *changes,
+ GPtrArray *recents,
CamelException *ex)
{
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
@@ -1623,12 +1629,14 @@ imap_update_summary (CamelFolder *folder,
}
camel_folder_summary_add (folder->summary, mi);
camel_folder_change_info_add_uid (changes, camel_message_info_uid (mi));
+ if (recents && (mi->flags & CAMEL_IMAP_MESSAGE_RECENT))
+ g_ptr_array_add (recents, (char *)camel_message_info_uid (mi));
}
g_ptr_array_free (messages, TRUE);
/* Did more mail arrive while we were doing this? */
if (exists && exists > camel_folder_summary_count (folder->summary))
- imap_update_summary (folder, changes, ex);
+ imap_update_summary (folder, changes, recents, ex);
}
/* Called with the store's command_lock locked */
@@ -1639,6 +1647,7 @@ camel_imap_folder_changed (CamelFolder *folder, int exists,
CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
CamelFolderChangeInfo *changes;
CamelMessageInfo *info;
+ GPtrArray *recents = NULL;
int len;
CAMEL_IMAP_STORE_ASSERT_LOCKED (folder->parent_store, command_lock);
@@ -1660,8 +1669,11 @@ camel_imap_folder_changed (CamelFolder *folder, int exists,
}
len = camel_folder_summary_count (folder->summary);
- if (exists > len)
- imap_update_summary (folder, changes, ex);
+ if (exists > len) {
+ if (imap_folder->do_filtering)
+ recents = g_ptr_array_new ();
+ imap_update_summary (folder, changes, recents, ex);
+ }
if (camel_folder_change_info_changed (changes)) {
camel_object_trigger_event (CAMEL_OBJECT (folder),
@@ -1669,6 +1681,22 @@ camel_imap_folder_changed (CamelFolder *folder, int exists,
}
camel_folder_change_info_free (changes);
+ if (recents) {
+ if (!camel_exception_is_set (ex) && recents->len) {
+ CamelFilterDriver *driver;
+
+ driver = camel_session_get_filter_driver (
+ CAMEL_SERVICE (folder->parent_store)->session,
+ "incoming", ex);
+ if (driver) {
+ camel_filter_driver_filter_folder (
+ driver, folder, recents, FALSE, ex);
+ camel_object_unref (CAMEL_OBJECT (driver));
+ }
+ }
+ g_ptr_array_free (recents, TRUE);
+ }
+
camel_folder_summary_save (folder->summary);
}
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index 295cfd041e..db507d52d5 100644
--- a/camel/providers/imap/camel-imap-folder.h
+++ b/camel/providers/imap/camel-imap-folder.h
@@ -48,7 +48,7 @@ struct _CamelImapFolder {
struct _CamelImapFolderPrivate *priv;
- gboolean need_rescan, need_refresh;
+ gboolean need_rescan, need_refresh, do_filtering;
CamelFolderSearch *search;
CamelImapMessageCache *cache;
};
diff --git a/camel/providers/imap/camel-imap-provider.c b/camel/providers/imap/camel-imap-provider.c
index c4b86c3bfc..35163cdf8d 100644
--- a/camel/providers/imap/camel-imap-provider.c
+++ b/camel/providers/imap/camel-imap-provider.c
@@ -53,7 +53,7 @@ CamelProviderConfEntry imap_conf_entries[] = {
{ CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace",
N_("Namespace") },
{ CAMEL_PROVIDER_CONF_SECTION_END },
- { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", "UNIMPLEMENTED",
+ { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
N_("Apply filters to new messages in INBOX on this server"), "0" },
{ CAMEL_PROVIDER_CONF_END }
};
diff --git a/camel/providers/imap/camel-imap-summary.h b/camel/providers/imap/camel-imap-summary.h
index 1b96008b1f..bd9e39cc5b 100644
--- a/camel/providers/imap/camel-imap-summary.h
+++ b/camel/providers/imap/camel-imap-summary.h
@@ -38,6 +38,8 @@
CAMEL_MESSAGE_FLAGGED | \
CAMEL_MESSAGE_SEEN)
+#define CAMEL_IMAP_MESSAGE_RECENT (1 << 8)
+
typedef struct _CamelImapSummaryClass CamelImapSummaryClass;
typedef struct _CamelImapMessageContentInfo {
diff --git a/camel/providers/imap/camel-imap-utils.c b/camel/providers/imap/camel-imap-utils.c
index 1da6bbcf20..f2909fb6a4 100644
--- a/camel/providers/imap/camel-imap-utils.c
+++ b/camel/providers/imap/camel-imap-utils.c
@@ -176,6 +176,8 @@ imap_parse_flag_list (char **flag_list_p)
flags |= CAMEL_MESSAGE_FLAGGED;
else if (!g_strncasecmp (flag_list, "\\Seen", len))
flags |= CAMEL_MESSAGE_SEEN;
+ else if (!g_strncasecmp (flag_list, "\\Recent", len))
+ flags |= CAMEL_IMAP_MESSAGE_RECENT;
flag_list += len;
if (*flag_list == ' ')