[evolution-ews] Bug #656709 - Excessive updates being sent to server
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug #656709 - Excessive updates being sent to server
- Date: Thu, 19 Jul 2012 09:42:19 +0000 (UTC)
commit 2122dc8f7bfab2c3c895a306fa1ac49bff879d8f
Author: Milan Crha <mcrha redhat com>
Date: Thu Jul 19 11:41:52 2012 +0200
Bug #656709 - Excessive updates being sent to server
src/camel/camel-ews-folder.c | 21 ++++++++++++++++-----
src/camel/camel-ews-summary.c | 17 -----------------
src/camel/camel-ews-summary.h | 4 ----
src/camel/camel-ews-utils.c | 34 +++++++++++++++++++++++++++-------
4 files changed, 43 insertions(+), 33 deletions(-)
---
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index d30e12a..5733cba 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -912,8 +912,10 @@ ews_move_to_junk_folder (CamelFolder *folder,
camel_folder_summary_unlock (folder->summary, CAMEL_FOLDER_SUMMARY_SUMMARY_LOCK);
}
- if (camel_folder_change_info_changed (changes))
+ if (camel_folder_change_info_changed (changes)) {
+ camel_folder_summary_touch (folder->summary);
camel_folder_changed (folder, changes);
+ }
camel_folder_change_info_free (changes);
}
@@ -971,7 +973,8 @@ ews_synchronize_sync (CamelFolder *folder,
/* Exchange doesn't seem to have a sane representation
* for most flags â not even replied/forwarded. */
- if (flags_changed & (CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_FORWARDED | CAMEL_MESSAGE_FLAGGED)) {
+ if ((flags_set & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0 &&
+ (flags_changed & (CAMEL_MESSAGE_SEEN | CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_FORWARDED | CAMEL_MESSAGE_FLAGGED)) != 0) {
mi_list = g_slist_append (mi_list, mi);
mi_list_len++;
@@ -985,7 +988,7 @@ ews_synchronize_sync (CamelFolder *folder,
} else if (flags_set & CAMEL_MESSAGE_JUNK) {
junk_uids = g_slist_prepend (junk_uids, (gpointer) camel_pstring_strdup (uids->pdata[i]));
camel_message_info_free (mi);
- } else if (mi->info.dirty || (flags_set & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0) {
+ } else if ((flags_set & CAMEL_MESSAGE_FOLDER_FLAGGED) != 0) {
/* OK, the change must have been the labels */
mi_list = g_slist_append (mi_list, mi);
mi_list_len++;
@@ -1346,6 +1349,8 @@ ews_refresh_info_sync (CamelFolder *folder,
cnc = camel_ews_store_get_connection (ews_store);
g_return_val_if_fail (cnc != NULL, FALSE);
+ camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
+
id = camel_ews_store_summary_get_folder_id_from_name
(ews_store->summary,
full_name);
@@ -1536,7 +1541,10 @@ ews_transfer_messages_to_sync (CamelFolder *source,
camel_folder_summary_remove_uid (source->summary, uids->pdata[i]);
camel_folder_change_info_remove_uid (changes, uids->pdata[i]);
}
- camel_folder_changed (source, changes);
+ if (camel_folder_change_info_changed (changes)) {
+ camel_folder_summary_touch (source->summary);
+ camel_folder_changed (source, changes);
+ }
camel_folder_change_info_free (changes);
}
@@ -1620,7 +1628,10 @@ ews_delete_messages (CamelFolder *folder,
g_propagate_error (error, local_error);
}
- camel_folder_changed (folder, changes);
+ if (camel_folder_change_info_changed (changes)) {
+ camel_folder_summary_touch (folder->summary);
+ camel_folder_changed (folder, changes);
+ }
g_slist_foreach (deleted_head, (GFunc) camel_pstring_free, NULL);
g_slist_free (deleted_head);
diff --git a/src/camel/camel-ews-summary.c b/src/camel/camel-ews-summary.c
index f85d947..ae51f33 100644
--- a/src/camel/camel-ews-summary.c
+++ b/src/camel/camel-ews-summary.c
@@ -307,23 +307,6 @@ camel_ews_summary_add_message (CamelFolderSummary *summary,
camel_message_info_free (info);
}
-void
-camel_ews_summary_add_message_info (CamelFolderSummary *summary,
- guint32 server_flags,
- CamelMessageInfo *mi)
-{
- CamelMessageInfoBase *binfo = (CamelMessageInfoBase *) mi;
- CamelEwsMessageInfo *einfo = (CamelEwsMessageInfo *) mi;
-
- binfo->flags |= server_flags;
- einfo->server_flags = server_flags;
-
- /* TODO update user flags */
-
- binfo->flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
- camel_folder_summary_add (summary, (CamelMessageInfo *) mi);
-}
-
static gboolean
ews_update_user_flags (CamelMessageInfo *info,
CamelFlag *server_user_flags)
diff --git a/src/camel/camel-ews-summary.h b/src/camel/camel-ews-summary.h
index 57300a8..78a1407 100644
--- a/src/camel/camel-ews-summary.h
+++ b/src/camel/camel-ews-summary.h
@@ -92,10 +92,6 @@ gboolean
void camel_ews_summary_add_message (CamelFolderSummary *summary,
const gchar *uid,
CamelMimeMessage *message);
-void camel_ews_summary_add_message_info
- (CamelFolderSummary *summary,
- guint32 server_flags,
- CamelMessageInfo *info);
void ews_summary_clear (CamelFolderSummary *summary,
gboolean uncache);
diff --git a/src/camel/camel-ews-utils.c b/src/camel/camel-ews-utils.c
index 7aadd34..63dacc5 100644
--- a/src/camel/camel-ews-utils.c
+++ b/src/camel/camel-ews-utils.c
@@ -553,7 +553,11 @@ camel_ews_utils_sync_deleted_items (CamelEwsFolder *ews_folder,
camel_db_delete_uids (((CamelStore *) ews_store)->cdb_w, full_name, items_deleted_list, NULL);
g_list_free (items_deleted_list);
- camel_folder_changed ((CamelFolder *) ews_folder, ci);
+ if (camel_folder_change_info_changed (ci)) {
+ camel_folder_summary_touch (folder->summary);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ camel_folder_changed (folder, ci);
+ }
camel_folder_change_info_free (ci);
g_slist_foreach (items_deleted, (GFunc) g_free, NULL);
@@ -861,8 +865,11 @@ camel_ews_utils_sync_updated_items (CamelEwsFolder *ews_folder,
g_object_unref (item);
}
- camel_folder_summary_save_to_db (folder->summary, NULL);
- camel_folder_changed ((CamelFolder *) ews_folder, ci);
+ if (camel_folder_change_info_changed (ci)) {
+ camel_folder_summary_touch (folder->summary);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ camel_folder_changed ((CamelFolder *) ews_folder, ci);
+ }
camel_folder_change_info_free (ci);
g_slist_free (items_updated);
}
@@ -951,16 +958,29 @@ camel_ews_utils_sync_created_items (CamelEwsFolder *ews_folder,
server_flags = ews_utils_get_server_flags (item);
ews_utils_merge_server_user_flags (item, mi);
- camel_ews_summary_add_message_info (folder->summary, server_flags,
- (CamelMessageInfo *) mi);
+ mi->info.flags |= server_flags;
+ mi->server_flags = server_flags;
+
+ camel_folder_summary_add (folder->summary, (CamelMessageInfo *) mi);
+
+ /* camel_folder_summary_add() sets folder_flagged flag
+ on the message info, but this is a fresh item downloaded
+ from the server, thus unset it, to avoid resync up to the server
+ on folder leave/store
+ */
+ mi->info.flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED;
+
camel_folder_change_info_add_uid (ci, id->id);
camel_folder_change_info_recent_uid (ci, id->id);
g_object_unref (item);
}
- camel_folder_summary_save_to_db (folder->summary, NULL);
- camel_folder_changed ((CamelFolder *) ews_folder, ci);
+ if (camel_folder_change_info_changed (ci)) {
+ camel_folder_summary_touch (folder->summary);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ camel_folder_changed ((CamelFolder *) ews_folder, ci);
+ }
camel_folder_change_info_free (ci);
g_slist_free (items_created);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]