aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camel/ChangeLog23
-rw-r--r--camel/providers/imap/camel-imap-folder.c65
-rw-r--r--camel/providers/imap/camel-imap-folder.h1
-rw-r--r--camel/providers/imap/camel-imap-store.c1
4 files changed, 66 insertions, 24 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index cd3ea21ea7..0e88cca43b 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,26 @@
+2001-05-26 Dan Winship <danw@ximian.com>
+
+ * providers/imap/camel-imap-folder.c: Add a "need_rescan" flag
+ saying if we want to rescan the entire folder for flag changes
+ next time it's selected.
+ (camel_imap_folder_init): Set need_rescan TRUE.
+ (camel_imap_folder_selected): If need_rescan is TRUE, call
+ imap_rescan.
+ (imap_refresh_info): Only do a full rescan if need_rescan is TRUE.
+ Otherwise just do a NOOP, making this a MUCH more lightweight
+ operation. Also, don't call imap_rescan directly if the folder
+ isn't selected, since that could end up causing the folder to be
+ scanned *twice* (imap_rescan -> camel_imap_command ->
+ camel_imap_folder_selected -> imap_rescan).
+ (imap_rescan): Set need_rescan FALSE.
+ (imap_sync_online): Don't NOOP if no changes were pushed: the
+ caller will call refresh_info if it wants to poll for changes.
+ Fixes evolution-mail doing lots of unnecessary extra work at
+ quit time.
+
+ * providers/imap/camel-imap-store.c (refresh_folder_info): Set
+ need_rescan on each folder before calling refresh_info.
+
2001-05-25 Jeffrey Stedfast <fejj@ximian.com>
* providers/smtp/camel-smtp-transport.c (smtp_auth): Oops. Use a
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 26410a7abf..b8e53c604a 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -136,6 +136,8 @@ camel_imap_folder_init (gpointer object, gpointer klass)
imap_folder->priv->search_lock = e_mutex_new(E_MUTEX_SIMPLE);
imap_folder->priv->cache_lock = e_mutex_new(E_MUTEX_REC);
#endif
+
+ imap_folder->need_rescan = TRUE;
}
CamelType
@@ -251,17 +253,15 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response,
imap_summary->validity = validity;
camel_folder_summary_clear (folder->summary);
camel_imap_message_cache_clear (imap_folder->cache);
+ imap_folder->need_rescan = FALSE;
camel_imap_folder_changed (folder, exists, NULL, ex);
return;
}
/* If we've lost messages, we have to rescan everything */
- if (exists < count) {
- imap_rescan (folder, exists, ex);
- return;
- }
-
- if (count != 0) {
+ if (exists < count)
+ imap_folder->need_rescan = TRUE;
+ else if (count != 0 && !imap_folder->need_rescan) {
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
/* Similarly, if the UID of the highest message we
@@ -298,14 +298,18 @@ camel_imap_folder_selected (CamelFolder *folder, CamelImapResponse *response,
info = camel_folder_summary_index (folder->summary, count - 1);
val = strtoul (camel_message_info_uid (info), NULL, 10);
camel_folder_summary_info_free (folder->summary, info);
- if (uid == 0 || uid != val) {
- imap_rescan (folder, exists, ex);
- return;
- }
+ if (uid == 0 || uid != val)
+ imap_folder->need_rescan = TRUE;
+ }
+
+ /* Now rescan if we need to */
+ if (imap_folder->need_rescan) {
+ imap_rescan (folder, exists, ex);
+ return;
}
- /* OK. So now we know that no messages have been expunged. Whew.
- * Now see if messages have been added.
+ /* If we don't need to rescan completely, but new messages
+ * have been added, find out about them.
*/
if (exists > count)
camel_imap_folder_changed (folder, exists, NULL, ex);
@@ -333,12 +337,32 @@ imap_finalize (CamelObject *object)
static void
imap_refresh_info (CamelFolder *folder, CamelException *ex)
{
- if (camel_disco_store_status (CAMEL_DISCO_STORE (folder->parent_store)) == CAMEL_DISCO_STORE_OFFLINE)
+ CamelImapStore *imap_store = CAMEL_IMAP_STORE (folder->parent_store);
+ CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);
+ CamelImapResponse *response;
+
+ if (camel_disco_store_status (CAMEL_DISCO_STORE (imap_store)) == CAMEL_DISCO_STORE_OFFLINE)
+ return;
+
+ /* If the folder isn't selected, select it (which will force
+ * a rescan if one is needed.
+ */
+ if (imap_store->current_folder != folder) {
+ response = camel_imap_command (imap_store, folder, ex, NULL);
+ camel_imap_response_free (imap_store, response);
return;
+ }
- CAMEL_IMAP_STORE_LOCK (folder->parent_store, command_lock);
- imap_rescan (folder, camel_folder_summary_count (folder->summary), ex);
- CAMEL_IMAP_STORE_UNLOCK (folder->parent_store, command_lock);
+ /* Otherwise, if we need a rescan, do it, and if not, just do
+ * a NOOP to give the server a chance to tell us about new
+ * messages.
+ */
+ if (imap_folder->need_rescan)
+ imap_rescan (folder, camel_folder_summary_count (folder->summary), ex);
+ else {
+ response = camel_imap_command (imap_store, folder, ex, "NOOP");
+ camel_imap_response_free (imap_store, response);
+ }
}
/* Called with the store's command_lock locked */
@@ -360,6 +384,7 @@ imap_rescan (CamelFolder *folder, int exists, CamelException *ex)
GData *fetch_data;
CAMEL_IMAP_STORE_ASSERT_LOCKED (store, command_lock);
+ imap_folder->need_rescan = FALSE;
camel_operation_start(NULL, _("Scanning IMAP folder"));
@@ -575,14 +600,6 @@ imap_sync_online (CamelFolder *folder, CamelException *ex)
}
}
- if (!response) {
- /* We didn't sync anything... Do a noop so the server
- * gets a chance to tell us any news it has.
- */
- response = camel_imap_command (store, folder, ex, "NOOP");
- camel_imap_response_free (store, response);
- }
-
/* Save the summary */
imap_sync_offline (folder, ex);
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index 96b33c0400..8f358e656c 100644
--- a/camel/providers/imap/camel-imap-folder.h
+++ b/camel/providers/imap/camel-imap-folder.h
@@ -48,6 +48,7 @@ struct _CamelImapFolder {
struct _CamelImapFolderPrivate *priv;
+ gboolean need_rescan;
CamelFolderSearch *search;
CamelImapMessageCache *cache;
};
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index 5138cda658..94d2436810 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -353,6 +353,7 @@ refresh_folder_info (gpointer key, gpointer value, gpointer data)
{
CamelFolder *folder = CAMEL_FOLDER (value);
+ CAMEL_IMAP_FOLDER (folder)->need_rescan = TRUE;
CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(folder))->refresh_info(folder, data);
}