diff options
author | 8 <NotZed@Ximian.com> | 2001-09-19 05:43:00 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2001-09-19 05:43:00 +0800 |
commit | 8347ce1403c68a408a3b9952f6486b5ac584104b (patch) | |
tree | 3df009be2f1e694e277133818acb872904d10392 /camel/providers | |
parent | 390621f624b0be7485abdba29d0fe46c905156c8 (diff) | |
download | gsoc2013-evolution-8347ce1403c68a408a3b9952f6486b5ac584104b.tar gsoc2013-evolution-8347ce1403c68a408a3b9952f6486b5ac584104b.tar.gz gsoc2013-evolution-8347ce1403c68a408a3b9952f6486b5ac584104b.tar.bz2 gsoc2013-evolution-8347ce1403c68a408a3b9952f6486b5ac584104b.tar.lz gsoc2013-evolution-8347ce1403c68a408a3b9952f6486b5ac584104b.tar.xz gsoc2013-evolution-8347ce1403c68a408a3b9952f6486b5ac584104b.tar.zst gsoc2013-evolution-8347ce1403c68a408a3b9952f6486b5ac584104b.zip |
If filter inbox is set on the store, and we're opening inbox '', then
2001-09-18 <NotZed@Ximian.com>
* providers/local/camel-maildir-folder.c
(camel_maildir_folder_new): If filter inbox is set on the store,
and we're opening inbox '', then enable filtering on new messages.
* providers/local/camel-local-folder.c
(camel_local_folder_construct): After loading the summary, check
it, and only abort if that fails. Also maintain the changes
count.
* providers/local/camel-local-summary.c
(camel_local_summary_load): Remove summary_check code from here.
(camel_local_summary_check): Sync index/summary here, if we were
successful.
* providers/local/camel-spool-folder.c
(camel_spool_folder_new): If we have filter-new-messages-on-inbox
set and we just opened inbox, turn on filtering on this folder.
(camel_spool_folder_construct): Keep track of changes for the
folder, so that filter-new-messages works right (?)
* providers/local/camel-spool-store.c (get_folder): Pass 'INBOX'
as the folder name, not the path.
* camel-folder-search.c (search_not): Modified patch from
<peterw@ximian.com> since the summary is messageinfo's, not
strings.
** Ok so the problem with the stuff below is that maildir/spool
'summary_load' throws away all events, including recents, joy eh?
* providers/local/camel-maildir-summary.c (maildir_summary_check):
Add new messages to the recent changeinfo.
* providers/local/camel-spool-summary.c: Mark 'new' message as
recent, for later processing if required (i.e. 'filter new
messages').
* camel-store.c (construct): new function, cascade up construct
method and check for 'filter' param, and set accordingly for any
one that might want it.
* providers/imap/camel-imap-store.c (construct): map the
param_filter_inbox flag to the store->flags as
CAMEL_STORE_FILTER_INBOX.
* camel-store.h (CAMEL_STORE_FILTER_INBOX): new flag to tell it to
filter inbox.
* providers/imap/camel-imap-folder.h: Removed do_filtering flag
from CamelImapFolder.
* providers/imap/camel-imap-folder.c (imap_update_summary): Remove
the 'recents' parameter, use the 'changes' parameter instead to
convey this info.
(camel_imap_folder_changed): Changed for update_summary api
change. Now always just emit the changed event if we have any
changes to report, filtering code removed, handled upstream.
(filter_proc):
(filter_free): Removed old filtering code.
(camel_imap_folder_new): Set the filter_recent flag on the folder
if we're the inbox and filtering of inbox is enabled.
* camel-folder.c (folder_changed): If we have 'recent' messages,
and are set to filter recents, then freeze the folder and launch a
thread to do the processing (or similar if threading not enabled).
(thaw): Make sure we emit the changed signal outside of owning the
lock and if things have changed. Also, no longer bother
downgrading folder_changed events to message_changed events.
* camel-folder.h (struct _CamelFolder): Added filter_recent flag
-> signifies all recent messages in folder should be filtered.
* camel-session.c: (camel_session_thread_msg_new,
camel_session_thread_msg_free, camel_session_thread_queue,
camel_session_thread_wait): code to handle async operations as
part of camel processing.
(camel_session_finalise): free thread_lock, destroy thread, active
hash, etc.
(camel_session_init): init thread, active hash, etc.
(camel_session_class_init): Init virtual functions.
(session_thread_msg_new, session_thread_msg_free,
session_thread_destroy, session_thread_received,
session_thread_queue, session_thread_wait): default implementation
of session threads stuff.
2001-09-17 <NotZed@Ximian.com>
* camel-folder.c (camel_folder_change_info_recent_uid): New
function to add a 'recent' uid to the change info.
(camel_folder_change_info_clear): Clear recent list.
(camel_folder_change_info_free): Free recent list.
(camel_folder_change_info_new): Setup recent list.
* camel-folder.h: Added a uid_recent item to the folder_changed
event data.
* providers/local/camel-maildir-store.c (scan_dir): Free new in
the right block.
* providers/local/camel-local-provider.c: Add local config entries
to filter on new messages in spool and maildir provider.
* camel-vee-folder.c (vee_folder_construct): Remove the assertion
which stops ? in names from being allowed.
svn path=/trunk/; revision=12956
Diffstat (limited to 'camel/providers')
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 93 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.h | 2 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 4 | ||||
-rw-r--r-- | camel/providers/local/camel-local-folder.c | 6 | ||||
-rw-r--r-- | camel/providers/local/camel-local-provider.c | 8 | ||||
-rw-r--r-- | camel/providers/local/camel-local-store.c | 3 | ||||
-rw-r--r-- | camel/providers/local/camel-local-summary.c | 19 | ||||
-rw-r--r-- | camel/providers/local/camel-maildir-folder.c | 5 | ||||
-rw-r--r-- | camel/providers/local/camel-maildir-store.c | 2 | ||||
-rw-r--r-- | camel/providers/local/camel-maildir-summary.c | 4 | ||||
-rw-r--r-- | camel/providers/local/camel-spool-folder.c | 9 | ||||
-rw-r--r-- | camel/providers/local/camel-spool-store.c | 10 | ||||
-rw-r--r-- | camel/providers/local/camel-spool-summary.c | 5 |
13 files changed, 60 insertions, 110 deletions
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index fc873f9e85..5d2a8ba146 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -50,7 +50,6 @@ #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" @@ -220,7 +219,7 @@ camel_imap_folder_new (CamelStore *parent, const char *folder_name, if ((imap_store->parameters & IMAP_PARAM_FILTER_INBOX) && !g_strcasecmp (folder_name, "INBOX")) - imap_folder->do_filtering = TRUE; + folder->filter_recent = TRUE; return folder; } @@ -1586,7 +1585,6 @@ add_message_from_data (CamelFolder *folder, GPtrArray *messages, static void imap_update_summary (CamelFolder *folder, int exists, CamelFolderChangeInfo *changes, - GPtrArray *recents, CamelException *ex) { CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store); @@ -1775,8 +1773,8 @@ imap_update_summary (CamelFolder *folder, int exists, 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)); + if ((mi->flags & CAMEL_IMAP_MESSAGE_RECENT)) + camel_folder_change_info_recent_uid(changes, camel_message_info_uid (mi)); } g_ptr_array_free (messages, TRUE); return; @@ -1798,44 +1796,6 @@ imap_update_summary (CamelFolder *folder, int exists, } } -struct _filter_msg { - CamelImapMsg msg; - - GPtrArray *recents; - CamelFolder *folder; - CamelFilterDriver *driver; -}; - -static void -filter_proc(CamelImapStore *store, CamelImapMsg *mm) -{ - struct _filter_msg *msg = (struct _filter_msg *)mm; - - printf("executing filtering %d messages folder %p\n", msg->recents->len, msg->folder); - - /* what about exceptions? */ - camel_filter_driver_filter_folder(msg->driver, msg->folder, NULL, msg->recents, FALSE, NULL); -} - -static void -filter_free(CamelImapStore *store, CamelImapMsg *mm) -{ - struct _filter_msg *msg = (struct _filter_msg *)mm; - int i; - - printf("freeing filtering %d messages folder %p\n", msg->recents->len, msg->folder); - - camel_object_unref((CamelObject *)msg->driver); - - camel_folder_thaw(msg->folder); - camel_object_unref((CamelObject *)msg->folder); - - for (i=0;i<msg->recents->len;i++) - g_free(msg->recents->pdata[i]); - - g_ptr_array_free(msg->recents, TRUE); -} - /* Called with the store's command_lock locked */ void camel_imap_folder_changed (CamelFolder *folder, int exists, @@ -1872,50 +1832,11 @@ camel_imap_folder_changed (CamelFolder *folder, int exists, } len = camel_folder_summary_count (folder->summary); - if (exists > len) { - if (imap_folder->do_filtering) - recents = g_ptr_array_new (); - imap_update_summary (folder, exists, changes, recents, ex); - } + if (exists > len) + imap_update_summary (folder, exists, changes, ex); - /* if we have updates to make for filtering (probably), then we freeze the - folder so we dont show them till they're complete, this may cause unacceptable - delays for users, but the alternative isn't very nice either (show them and let - them change as processed) */ - if (recents && !camel_exception_is_set (ex) && recents->len) { - CamelFilterDriver *driver; - - camel_folder_freeze (folder); - - if (camel_folder_change_info_changed (changes)) - camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes); - - driver = camel_session_get_filter_driver (CAMEL_SERVICE (folder->parent_store)->session, "incoming", ex); - if (driver) { -#ifdef ENABLE_THREADS - int i; - struct _filter_msg *msg = (struct _filter_msg *)camel_imap_msg_new(filter_proc, filter_free, sizeof(*msg)); - - msg->recents = g_ptr_array_new(); - for (i=0;i<recents->len;i++) - g_ptr_array_add(msg->recents, g_strdup(recents->pdata[i])); - - camel_object_ref((CamelObject *)folder); - msg->folder = folder; - msg->driver = driver; - printf("queueing filtering %d messages folder %p\n", msg->recents->len, folder); - camel_imap_msg_queue((CamelImapStore *)folder->parent_store, (CamelImapMsg *)msg); -#else - camel_filter_driver_filter_folder (driver, folder, NULL, recents, FALSE, ex); - camel_folder_thaw (folder); - camel_object_unref (CAMEL_OBJECT (driver)); -#endif - } else - camel_folder_thaw (folder); - } else { - if (camel_folder_change_info_changed (changes)) - camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes); - } + if (camel_folder_change_info_changed (changes)) + camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes); camel_folder_change_info_free (changes); diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h index db507d52d5..295cfd041e 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, do_filtering; + gboolean need_rescan, need_refresh; CamelFolderSearch *search; CamelImapMessageCache *cache; }; diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index d4cf4fb16c..b58b97fa83 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -285,8 +285,10 @@ construct (CamelService *service, CamelSession *session, } if (camel_url_get_param (url, "check_all")) imap_store->parameters |= IMAP_PARAM_CHECK_ALL; - if (camel_url_get_param (url, "filter")) + if (camel_url_get_param (url, "filter")) { imap_store->parameters |= IMAP_PARAM_FILTER_INBOX; + store->flags |= CAMEL_STORE_FILTER_INBOX; + } } static void diff --git a/camel/providers/local/camel-local-folder.c b/camel/providers/local/camel-local-folder.c index 811a71ecbe..927ca105ae 100644 --- a/camel/providers/local/camel-local-folder.c +++ b/camel/providers/local/camel-local-folder.c @@ -213,10 +213,14 @@ camel_local_folder_construct(CamelLocalFolder *lf, CamelStore *parent_store, con folder->summary = (CamelFolderSummary *)CLOCALF_CLASS(lf)->create_summary(lf->summary_path, lf->folder_path, lf->index); if (camel_local_summary_load((CamelLocalSummary *)folder->summary, forceindex, ex) == -1) { + camel_exception_clear(ex); + } + + if (camel_local_summary_check((CamelLocalSummary *)folder->summary, lf->changes, ex) == -1) { camel_object_unref (CAMEL_OBJECT (folder)); return NULL; } - + fi = g_new0 (CamelFolderInfo, 1); fi->full_name = g_strdup (full_name); fi->name = g_strdup (name); diff --git a/camel/providers/local/camel-local-provider.c b/camel/providers/local/camel-local-provider.c index 8a4047699f..606416fc37 100644 --- a/camel/providers/local/camel-local-provider.c +++ b/camel/providers/local/camel-local-provider.c @@ -55,6 +55,12 @@ static CamelProvider mbox_provider = { /* ... */ }; +static CamelProviderConfEntry local_conf_entries[] = { + { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL, + N_("Apply filters to new messages in INBOX"), "0" }, + { CAMEL_PROVIDER_CONF_END } +}; + static CamelProvider maildir_provider = { "maildir", N_("Qmail maildir-format mail files"), @@ -62,6 +68,7 @@ static CamelProvider maildir_provider = { "mail", CAMEL_PROVIDER_IS_SOURCE | CAMEL_PROVIDER_IS_STORAGE, CAMEL_URL_NEED_PATH | CAMEL_URL_PATH_IS_ABSOLUTE, + local_conf_entries, /* ... */ }; @@ -72,6 +79,7 @@ static CamelProvider spool_provider = { "mail", CAMEL_PROVIDER_IS_SOURCE | CAMEL_PROVIDER_IS_STORAGE, CAMEL_URL_NEED_PATH | CAMEL_URL_PATH_IS_ABSOLUTE, + local_conf_entries, /* ... */ }; diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c index fe8f09a911..43437b551a 100644 --- a/camel/providers/local/camel-local-store.c +++ b/camel/providers/local/camel-local-store.c @@ -190,6 +190,9 @@ get_folder_info (CamelStore *store, const char *top, /* FIXME: This is broken, but it corresponds to what was * there before. */ + + printf("-- LOCAL STRE -- get folder info: %s\n", top); + return NULL; } diff --git a/camel/providers/local/camel-local-summary.c b/camel/providers/local/camel-local-summary.c index c925e6e36a..3202076520 100644 --- a/camel/providers/local/camel-local-summary.c +++ b/camel/providers/local/camel-local-summary.c @@ -148,18 +148,12 @@ camel_local_summary_load(CamelLocalSummary *cls, int forceindex, CamelException if (forceindex || stat(s->summary_path, &st) == -1 || ((CamelLocalSummaryClass *)(CAMEL_OBJECT_GET_CLASS(cls)))->load(cls, forceindex, ex) == -1) { + g_warning("Could not load summary: flags may be reset"); camel_folder_summary_clear((CamelFolderSummary *)cls); + return -1; } - if (camel_local_summary_check(cls, NULL, ex) == 0) { - if (camel_folder_summary_save(s) == -1) - g_warning("Could not save summary for %s: %s", cls->folder_path, strerror(errno)); - if (cls->index && ibex_save(cls->index) == -1) - g_warning("Could not sync index for %s: %s", cls->folder_path, strerror(errno)); - - return 0; - } - return -1; + return 0; } char * @@ -261,6 +255,13 @@ camel_local_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changei ret = ((CamelLocalSummaryClass *)(CAMEL_OBJECT_GET_CLASS(cls)))->check(cls, changeinfo, ex); + if (ret != -1) { + if (camel_folder_summary_save((CamelFolderSummary *)cls) == -1) + g_warning("Could not save summary for %s: %s", cls->folder_path, strerror(errno)); + if (cls->index && ibex_save(cls->index) == -1) + g_warning("Could not sync index for %s: %s", cls->folder_path, strerror(errno)); + } + #ifdef DOSTATS if (ret != -1) { int i; diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c index 159aa84620..1bd6417e1a 100644 --- a/camel/providers/local/camel-maildir-folder.c +++ b/camel/providers/local/camel-maildir-folder.c @@ -110,6 +110,11 @@ camel_maildir_folder_new(CamelStore *parent_store, const char *full_name, guint3 d(printf("Creating maildir folder: %s\n", full_name)); folder = (CamelFolder *)camel_object_new(CAMEL_MAILDIR_FOLDER_TYPE); + + if (parent_store->flags & CAMEL_STORE_FILTER_INBOX + && strcmp(full_name, "") == 0) + folder->filter_recent = TRUE; + folder = (CamelFolder *)camel_local_folder_construct((CamelLocalFolder *)folder, parent_store, full_name, flags, ex); diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c index c200058c95..927c194089 100644 --- a/camel/providers/local/camel-maildir-store.c +++ b/camel/providers/local/camel-maildir-store.c @@ -313,8 +313,8 @@ static int scan_dir(GHashTable *visited, char *root, const char *path, guint32 f closedir(dir); return -1; } + g_free(new); } - g_free(new); } g_free(tmp); } diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c index 315e45ffd6..39726566bc 100644 --- a/camel/providers/local/camel-maildir-summary.c +++ b/camel/providers/local/camel-maildir-summary.c @@ -635,8 +635,10 @@ maildir_summary_check(CamelLocalSummary *cls, CamelFolderChangeInfo *changes, Ca if (rename(src, dest) == 0) { camel_maildir_summary_add(cls, destfilename, forceindex); - if (changes) + if (changes) { camel_folder_change_info_add_uid(changes, destname); + camel_folder_change_info_recent_uid(changes, destname); + } } else { /* else? we should probably care about failures, but wont */ g_warning("Failed to move new maildir message %s to cur %s", src, dest); diff --git a/camel/providers/local/camel-spool-folder.c b/camel/providers/local/camel-spool-folder.c index be4ca31cf2..c5e9165917 100644 --- a/camel/providers/local/camel-spool-folder.c +++ b/camel/providers/local/camel-spool-folder.c @@ -200,7 +200,7 @@ camel_spool_folder_construct(CamelSpoolFolder *lf, CamelStore *parent_store, con return NULL; } - camel_spool_summary_check((CamelSpoolSummary *)folder->summary, NULL, ex); + camel_spool_summary_check((CamelSpoolSummary *)folder->summary, lf->changes, ex); camel_spool_folder_unlock(lf); fi = g_malloc0(sizeof(*fi)); @@ -209,9 +209,8 @@ camel_spool_folder_construct(CamelSpoolFolder *lf, CamelStore *parent_store, con fi->url = g_strdup(lf->folder_path); fi->unread_message_count = camel_folder_get_unread_message_count(folder); camel_object_trigger_event(CAMEL_OBJECT(parent_store), "folder_created", fi); - camel_folder_info_free (fi); - + return lf; } @@ -223,6 +222,10 @@ camel_spool_folder_new(CamelStore *parent_store, const char *full_name, guint32 d(printf("Creating spool folder: %s in %s\n", full_name, camel_local_store_get_toplevel_dir((CamelLocalStore *)parent_store))); folder = (CamelFolder *)camel_object_new(CAMEL_SPOOL_FOLDER_TYPE); + + if (parent_store->flags & CAMEL_STORE_FILTER_INBOX + && strcmp(full_name, "INBOX") == 0) + folder->filter_recent = TRUE; folder = (CamelFolder *)camel_spool_folder_construct((CamelSpoolFolder *)folder, parent_store, full_name, flags, ex); diff --git a/camel/providers/local/camel-spool-store.c b/camel/providers/local/camel-spool-store.c index aa9d583d17..600ee8b2bc 100644 --- a/camel/providers/local/camel-spool-store.c +++ b/camel/providers/local/camel-spool-store.c @@ -148,8 +148,7 @@ static CamelFolder * get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelException * ex) { char *path = ((CamelService *)store)->url->path; - char *name; - int len; + CamelFolder *folder; printf("opening folder %s on path %s\n", folder_name, path); @@ -161,12 +160,9 @@ get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelExce return NULL; } - len = strlen(path); - name = alloca(len+1); - strcpy(name, path); - name[len-1] = 0; + folder = camel_spool_folder_new(store, folder_name, flags, ex); - return camel_spool_folder_new(store, name, flags, ex); + return folder; } static CamelFolder * diff --git a/camel/providers/local/camel-spool-summary.c b/camel/providers/local/camel-spool-summary.c index 2aa0dcb8e4..651ce7b0e9 100644 --- a/camel/providers/local/camel-spool-summary.c +++ b/camel/providers/local/camel-spool-summary.c @@ -751,6 +751,11 @@ spool_summary_sync_full(CamelSpoolSummary *cls, gboolean expunge, CamelFolderCha strerror(errno)); goto error; } + + /* mark this message as recent */ + if (info->info.flags & CAMEL_MESSAGE_FOLDER_NOXEV) + camel_folder_change_info_recent_uid(changeinfo, camel_message_info_uid(info)); + info->info.flags &= 0xffff; g_free(xevnew); xevnew = NULL; |