191 lines
7.4 KiB
Diff
191 lines
7.4 KiB
Diff
Index: camel/providers/groupwise/camel-groupwise-folder.c
|
|
===================================================================
|
|
RCS file: /cvs/gnome/evolution-data-server/camel/providers/groupwise/camel-groupwise-folder.c,v
|
|
retrieving revision 1.130
|
|
diff -u -p -r1.130 camel-groupwise-folder.c
|
|
--- camel/providers/groupwise/camel-groupwise-folder.c 18 Apr 2006 15:15:30 -0000 1.130
|
|
+++ camel/providers/groupwise/camel-groupwise-folder.c 24 Apr 2006 08:37:43 -0000
|
|
@@ -61,6 +61,7 @@
|
|
#define JUNK_FOLDER "Junk Mail"
|
|
#define READ_CURSOR_MAX_IDS 500
|
|
#define MAX_ATTACHMENT_SIZE 1*1024*1024 /*In bytes*/
|
|
+#define GROUPWISE_BULK_DELETE_LIMIT 100
|
|
|
|
static CamelOfflineFolderClass *parent_class = NULL;
|
|
|
|
@@ -586,7 +587,11 @@ groupwise_sync (CamelFolder *folder, gbo
|
|
EGwConnectionStatus status;
|
|
EGwConnection *cnc;
|
|
int count, i;
|
|
-
|
|
+
|
|
+ GList *deleted_items, *deleted_head=NULL;
|
|
+
|
|
+ deleted_items = NULL;
|
|
+
|
|
if (((CamelOfflineStore *) gw_store)->state == CAMEL_OFFLINE_STORE_NETWORK_UNAVAIL ||
|
|
((CamelService *)gw_store)->status == CAMEL_SERVICE_DISCONNECTED) {
|
|
groupwise_sync_summary (folder, ex);
|
|
@@ -606,7 +611,7 @@ groupwise_sync (CamelFolder *folder, gbo
|
|
|
|
count = camel_folder_summary_count (folder->summary);
|
|
CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
|
|
- for (i=0 ; i <count ; i++) {
|
|
+ for (i=0 ; i < count ; i++) {
|
|
guint32 flags = 0;
|
|
info = camel_folder_summary_index (folder->summary, i);
|
|
gw_info = (CamelGroupwiseMessageInfo *) info;
|
|
@@ -635,22 +640,57 @@ groupwise_sync (CamelFolder *folder, gbo
|
|
if (diff.changed & CAMEL_MESSAGE_SEEN)
|
|
read_items = g_list_append (read_items, (char *)uid);
|
|
if (diff.changed & CAMEL_MESSAGE_DELETED) {
|
|
- CAMEL_SERVICE_LOCK (gw_store, connect_lock);
|
|
- status = e_gw_connection_remove_item (cnc, container_id, uid);
|
|
- if (status == E_GW_CONNECTION_STATUS_OK) {
|
|
- CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
|
|
- camel_folder_summary_remove (folder->summary, info);
|
|
- camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
|
|
- CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
|
|
- i--; count--;
|
|
+ if (deleted_items)
|
|
+ deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
|
|
+ else {
|
|
+ g_list_free (deleted_head);
|
|
+ deleted_head = NULL;
|
|
+ deleted_head = deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
|
|
+ }
|
|
+
|
|
+ if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
|
|
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
|
|
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
|
|
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
|
|
+ if (status == E_GW_CONNECTION_STATUS_OK) {
|
|
+ char *uid;
|
|
+ while (deleted_items) {
|
|
+ uid = (char *)deleted_items->data;
|
|
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
|
|
+ camel_folder_summary_remove_uid (folder->summary, uid);
|
|
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
|
|
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
|
|
+ deleted_items = g_list_next (deleted_items);
|
|
+ count -= GROUPWISE_BULK_DELETE_LIMIT;
|
|
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
|
|
+ }
|
|
+ }
|
|
}
|
|
- CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
|
|
}
|
|
}
|
|
}
|
|
camel_message_info_free (info);
|
|
}
|
|
CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
|
|
+ if (deleted_items) {
|
|
+ CAMEL_SERVICE_LOCK (gw_store, connect_lock);
|
|
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
|
|
+ CAMEL_SERVICE_UNLOCK (gw_store, connect_lock);
|
|
+ if (status == E_GW_CONNECTION_STATUS_OK) {
|
|
+ char *uid;
|
|
+ while (deleted_items) {
|
|
+ uid = (char *)deleted_items->data;
|
|
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
|
|
+ camel_folder_summary_remove_uid (folder->summary, uid);
|
|
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
|
|
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
|
|
+ deleted_items = g_list_next (deleted_items);
|
|
+ count -= GROUPWISE_BULK_DELETE_LIMIT;
|
|
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
|
|
+ }
|
|
+ }
|
|
+ g_list_free (deleted_head);
|
|
+ }
|
|
|
|
if (read_items && g_list_length (read_items)) {
|
|
CAMEL_SERVICE_LOCK (gw_store, connect_lock);
|
|
@@ -1960,8 +2000,10 @@ groupwise_expunge (CamelFolder *folder,
|
|
CamelFolderChangeInfo *changes;
|
|
int i, max;
|
|
gboolean delete = FALSE;
|
|
+ GList *deleted_items, *deleted_head=NULL;
|
|
+
|
|
|
|
-
|
|
+ deleted_items = NULL;
|
|
cnc = cnc_lookup (priv);
|
|
if (!cnc)
|
|
return;
|
|
@@ -1988,26 +2030,62 @@ groupwise_expunge (CamelFolder *folder,
|
|
info = camel_folder_summary_index (folder->summary, i);
|
|
ginfo = (CamelGroupwiseMessageInfo *) info;
|
|
if (ginfo && (ginfo->info.flags & CAMEL_MESSAGE_DELETED)) {
|
|
- const char *uid = camel_message_info_uid (info);
|
|
- CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
|
|
- status = e_gw_connection_remove_item (cnc, container_id, uid);
|
|
- if (status == E_GW_CONNECTION_STATUS_OK) {
|
|
+
|
|
+ if (deleted_items)
|
|
+ deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
|
|
+ else {
|
|
+ g_list_free (deleted_head);
|
|
+ deleted_head = NULL;
|
|
+ deleted_head = deleted_items = g_list_prepend (deleted_items, (char *)camel_message_info_uid (info));
|
|
+ }
|
|
+ if (g_list_length (deleted_items) == GROUPWISE_BULK_DELETE_LIMIT ) {
|
|
+ /* Read the FIXME below */
|
|
+ CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
|
|
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
|
|
+ CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
|
|
+ if (status == E_GW_CONNECTION_STATUS_OK) {
|
|
+ char *uid;
|
|
+ while (deleted_items) {
|
|
+ uid = (char *)deleted_items->data;
|
|
+ CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
|
|
+ camel_folder_change_info_remove_uid (changes, uid);
|
|
+ camel_folder_summary_remove_uid (folder->summary, uid);
|
|
+ camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
|
|
+ CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
|
|
+ deleted_items = g_list_next (deleted_items);
|
|
+ max -= GROUPWISE_BULK_DELETE_LIMIT;
|
|
+ i -= GROUPWISE_BULK_DELETE_LIMIT;
|
|
+ }
|
|
+ }
|
|
+ delete = TRUE;
|
|
+ }
|
|
+ }
|
|
+ camel_message_info_free (info);
|
|
+ }
|
|
+
|
|
+ if (deleted_items) {
|
|
+ /* FIXME: Put these in a function and reuse it inside the above loop, here and in groupwise_sync*/
|
|
+ CAMEL_SERVICE_LOCK (groupwise_store, connect_lock);
|
|
+ status = e_gw_connection_remove_items (cnc, container_id, deleted_items);
|
|
+ CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
|
|
+ if (status == E_GW_CONNECTION_STATUS_OK) {
|
|
+ char *uid;
|
|
+ while (deleted_items) {
|
|
+ uid = (char *)deleted_items->data;
|
|
CAMEL_GROUPWISE_FOLDER_LOCK (folder, cache_lock);
|
|
- camel_folder_change_info_remove_uid (changes, (char *) uid);
|
|
- camel_folder_summary_remove (folder->summary, info);
|
|
+ camel_folder_change_info_remove_uid (changes, uid);
|
|
+ camel_folder_summary_remove_uid (folder->summary, uid);
|
|
camel_data_cache_remove(gw_folder->cache, "cache", uid, ex);
|
|
CAMEL_GROUPWISE_FOLDER_UNLOCK (folder, cache_lock);
|
|
- delete = TRUE;
|
|
- i--; max--;
|
|
+ deleted_items = g_list_next (deleted_items);
|
|
}
|
|
- CAMEL_SERVICE_UNLOCK (groupwise_store, connect_lock);
|
|
}
|
|
- camel_message_info_free (info);
|
|
+ delete = TRUE;
|
|
+ g_list_free (deleted_head);
|
|
}
|
|
|
|
if (delete)
|
|
camel_object_trigger_event (CAMEL_OBJECT (folder), "folder_changed", changes);
|
|
-
|
|
|
|
g_free (container_id);
|
|
camel_folder_change_info_free (changes);
|