aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-06-29 00:50:09 +0800
committerDan Winship <danw@src.gnome.org>2001-06-29 00:50:09 +0800
commita357fc5b44d807a81b066960e584787e263cd7d1 (patch)
tree6d4c95c0dbe5cf63d37a3ae11c0c99a69a228703
parent311491b26baf67164d5486b13cf794c29d6000cf (diff)
downloadgsoc2013-evolution-a357fc5b44d807a81b066960e584787e263cd7d1.tar
gsoc2013-evolution-a357fc5b44d807a81b066960e584787e263cd7d1.tar.gz
gsoc2013-evolution-a357fc5b44d807a81b066960e584787e263cd7d1.tar.bz2
gsoc2013-evolution-a357fc5b44d807a81b066960e584787e263cd7d1.tar.lz
gsoc2013-evolution-a357fc5b44d807a81b066960e584787e263cd7d1.tar.xz
gsoc2013-evolution-a357fc5b44d807a81b066960e584787e263cd7d1.tar.zst
gsoc2013-evolution-a357fc5b44d807a81b066960e584787e263cd7d1.zip
If the folder is frozen, don't refresh, just record that we need to do it
* providers/imap/camel-imap-folder.c (imap_refresh_info): If the folder is frozen, don't refresh, just record that we need to do it later. (imap_append_online): If the APPEND doesn't trigger an immediate EXISTS response (because the folder isn't the selected folder, or because the server doesn't do that until the next command), call imap_refresh_info on the folder. (imap_copy_online): Likewise. (Replacing the unconditional NOOP that was there before, which absolutely killed filter performance by forcing the IMAP provider to switch back and forth between folders after every copy or move.) (imap_thaw): If the folder needs a refresh, do it. * camel-folder.c (camel_folder_is_frozen): New method svn path=/trunk/; revision=10565
-rw-r--r--camel/ChangeLog17
-rw-r--r--camel/camel-folder.c22
-rw-r--r--camel/camel-folder.h6
-rw-r--r--camel/providers/imap/camel-imap-folder.c44
-rw-r--r--camel/providers/imap/camel-imap-folder.h2
5 files changed, 84 insertions, 7 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index dfafd7d909..eab69a3617 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,20 @@
+2001-06-28 Dan Winship <danw@ximian.com>
+
+ * providers/imap/camel-imap-folder.c (imap_refresh_info): If the
+ folder is frozen, don't refresh, just record that we need to do it
+ later.
+ (imap_append_online): If the APPEND doesn't trigger an immediate
+ EXISTS response (because the folder isn't the selected folder, or
+ because the server doesn't do that until the next command), call
+ imap_refresh_info on the folder.
+ (imap_copy_online): Likewise. (Replacing the unconditional NOOP
+ that was there before, which absolutely killed filter performance
+ by forcing the IMAP provider to switch back and forth between
+ folders after every copy or move.)
+ (imap_thaw): If the folder needs a refresh, do it.
+
+ * camel-folder.c (camel_folder_is_frozen): New method
+
2001-06-27 Jeffrey Stedfast <fejj@ximian.com>
* camel-transport.c (camel_transport_init): Initialize the private
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index ecf9190a36..4e679f36ae 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -109,6 +109,7 @@ static void move_messages_to (CamelFolder *source,
static void freeze (CamelFolder *folder);
static void thaw (CamelFolder *folder);
+static gboolean is_frozen (CamelFolder *folder);
static gboolean folder_changed (CamelObject *object,
gpointer event_data);
@@ -154,6 +155,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->move_messages_to = move_messages_to;
camel_folder_class->freeze = freeze;
camel_folder_class->thaw = thaw;
+ camel_folder_class->is_frozen = is_frozen;
/* virtual method overload */
camel_object_class_declare_event (camel_object_class,
@@ -1310,6 +1312,26 @@ camel_folder_thaw (CamelFolder *folder)
CF_CLASS (folder)->thaw (folder);
}
+static gboolean
+is_frozen (CamelFolder *folder)
+{
+ return folder->priv->frozen != 0;
+}
+
+/**
+ * camel_folder_is_frozen:
+ * @folder: a folder
+ *
+ * Return value: whether or not the folder is frozen.
+ **/
+gboolean
+camel_folder_is_frozen (CamelFolder *folder)
+{
+ g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
+
+ return CF_CLASS (folder)->is_frozen (folder);
+}
+
/* Event hooks that block emission when frozen */
static gboolean
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index 751f730188..cc4bf78a0f 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -151,8 +151,9 @@ typedef struct {
CamelFolder *destination,
CamelException *ex);
- void (*freeze) (CamelFolder *folder);
- void (*thaw) (CamelFolder *folder);
+ void (*freeze) (CamelFolder *folder);
+ void (*thaw) (CamelFolder *folder);
+ gboolean (*is_frozen) (CamelFolder *folder);
} CamelFolderClass;
/* Standard Camel function */
@@ -269,6 +270,7 @@ void camel_folder_move_messages_to (CamelFolder *source,
/* stop/restart getting events */
void camel_folder_freeze (CamelFolder *folder);
void camel_folder_thaw (CamelFolder *folder);
+gboolean camel_folder_is_frozen (CamelFolder *folder);
#if 0
/* lock/unlock at the thread level, NOTE: only used internally */
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index bf839a47eb..beb9ec2740 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -100,6 +100,8 @@ static void imap_move_messages_to (CamelFolder *source, GPtrArray *uids,
static GPtrArray *imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex);
static void imap_search_free (CamelFolder *folder, GPtrArray *uids);
+static void imap_thaw (CamelFolder *folder);
+
GData *parse_fetch_response (CamelImapFolder *imap_folder, char *msg_att);
static void
@@ -116,6 +118,7 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->move_messages_to = imap_move_messages_to;
camel_folder_class->search_by_expression = imap_search_by_expression;
camel_folder_class->search_free = imap_search_free;
+ camel_folder_class->thaw = imap_thaw;
camel_disco_folder_class->refresh_info_online = imap_refresh_info;
camel_disco_folder_class->sync_online = imap_sync_online;
@@ -371,6 +374,11 @@ imap_refresh_info (CamelFolder *folder, CamelException *ex)
if (camel_disco_store_status (CAMEL_DISCO_STORE (imap_store)) == CAMEL_DISCO_STORE_OFFLINE)
return;
+ if (camel_folder_is_frozen (folder)) {
+ imap_folder->need_refresh = TRUE;
+ return;
+ }
+
/* If the folder isn't selected, select it (which will force
* a rescan if one is needed.
*/
@@ -935,6 +943,8 @@ do_append (CamelFolder *folder, CamelMimeMessage *message,
g_byte_array_append (ba, "\0", 3);
response = camel_imap_command_continuation (store, ex, ba->data);
g_byte_array_free (ba, TRUE);
+ if (!response)
+ return response;
if (store->capabilities & IMAP_CAPABILITY_UIDPLUS) {
*uid = strstrcase (response->status, "[APPENDUID ");
@@ -961,7 +971,9 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message,
CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store);
CamelImapResponse *response;
char *uid;
+ int count;
+ count = camel_folder_summary_count (folder->summary);
response = do_append (folder, message, info, &uid, ex);
if (!response)
return;
@@ -979,6 +991,11 @@ imap_append_online (CamelFolder *folder, CamelMimeMessage *message,
}
camel_imap_response_free (store, response);
+
+ /* Make sure a "folder_changed" is emitted. */
+ if (store->current_folder != folder ||
+ camel_folder_summary_count (folder->summary) == count)
+ imap_refresh_info (folder, ex);
}
static void
@@ -1142,21 +1159,24 @@ imap_copy_online (CamelFolder *source, GPtrArray *uids,
CamelFolder *destination, CamelException *ex)
{
CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store);
- CamelImapResponse *response;
+ int count;
/* Sync message flags if needed. */
imap_sync_online (source, ex);
if (camel_exception_is_set (ex))
return;
+ count = camel_folder_summary_count (destination->summary);
+
/* Now copy the messages */
do_copy (source, uids, destination, ex);
if (camel_exception_is_set (ex))
return;
- /* Force the destination folder to notice its new messages. */
- response = camel_imap_command (store, destination, NULL, "NOOP");
- camel_imap_response_free (store, response);
+ /* Make the destination notice its new messages */
+ if (store->current_folder != destination ||
+ camel_folder_summary_count (destination->summary) == count)
+ camel_folder_refresh_info (destination, ex);
}
static void
@@ -1652,6 +1672,22 @@ camel_imap_folder_changed (CamelFolder *folder, int exists,
camel_folder_summary_save (folder->summary);
}
+static void
+imap_thaw (CamelFolder *folder)
+{
+ CamelImapFolder *imap_folder;
+
+ CAMEL_FOLDER_CLASS (disco_folder_class)->thaw (folder);
+ if (camel_folder_is_frozen (folder))
+ return;
+
+ imap_folder = CAMEL_IMAP_FOLDER (folder);
+ if (imap_folder->need_refresh) {
+ imap_folder->need_refresh = FALSE;
+ imap_refresh_info (folder, NULL);
+ }
+}
+
CamelStream *
camel_imap_folder_fetch_data (CamelImapFolder *imap_folder, const char *uid,
diff --git a/camel/providers/imap/camel-imap-folder.h b/camel/providers/imap/camel-imap-folder.h
index 8f358e656c..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;
+ gboolean need_rescan, need_refresh;
CamelFolderSearch *search;
CamelImapMessageCache *cache;
};