[evolution-ews] Bug 741855 - Too often folder change notifications on folder refresh
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug 741855 - Too often folder change notifications on folder refresh
- Date: Thu, 12 Feb 2015 16:57:29 +0000 (UTC)
commit 80c5627a6b28c2a7f8c75675a2d91a49b80fccac
Author: Milan Crha <mcrha redhat com>
Date: Thu Feb 12 17:58:29 2015 +0100
Bug 741855 - Too often folder change notifications on folder refresh
src/camel/camel-ews-folder.c | 42 +++++++++++++++++++++++++++++++++---------
src/camel/camel-ews-utils.c | 41 +++++++++--------------------------------
src/camel/camel-ews-utils.h | 7 +++++--
3 files changed, 47 insertions(+), 43 deletions(-)
---
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index e1fa46d..f62d3b9 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -1407,6 +1407,7 @@ static void
sync_updated_items (CamelEwsFolder *ews_folder,
EEwsConnection *cnc,
GSList *updated_items,
+ CamelFolderChangeInfo *change_info,
GCancellable *cancellable,
GError **error)
{
@@ -1476,7 +1477,7 @@ sync_updated_items (CamelEwsFolder *ews_folder,
e_ews_additional_props_free (add_props);
}
- camel_ews_utils_sync_updated_items (ews_folder, items);
+ camel_ews_utils_sync_updated_items (ews_folder, items, change_info);
items = NULL;
if (local_error) {
camel_ews_store_maybe_disconnect (ews_store, local_error);
@@ -1499,7 +1500,7 @@ sync_updated_items (CamelEwsFolder *ews_folder,
e_ews_additional_props_free (add_props);
}
- camel_ews_utils_sync_updated_items (ews_folder, items);
+ camel_ews_utils_sync_updated_items (ews_folder, items, change_info);
if (local_error) {
camel_ews_store_maybe_disconnect (ews_store, local_error);
@@ -1522,6 +1523,7 @@ static void
sync_created_items (CamelEwsFolder *ews_folder,
EEwsConnection *cnc,
GSList *created_items,
+ CamelFolderChangeInfo *change_info,
GCancellable *cancellable,
GError **error)
{
@@ -1592,7 +1594,7 @@ sync_created_items (CamelEwsFolder *ews_folder,
goto exit;
}
- camel_ews_utils_sync_created_items (ews_folder, cnc, items, cancellable);
+ camel_ews_utils_sync_created_items (ews_folder, cnc, items, change_info, cancellable);
items = NULL;
@@ -1618,7 +1620,7 @@ sync_created_items (CamelEwsFolder *ews_folder,
goto exit;
}
- camel_ews_utils_sync_created_items (ews_folder, cnc, items, cancellable);
+ camel_ews_utils_sync_created_items (ews_folder, cnc, items, change_info, cancellable);
items = NULL;
if (generic_item_ids) {
@@ -1637,7 +1639,7 @@ sync_created_items (CamelEwsFolder *ews_folder,
e_ews_additional_props_free (add_props);
}
- camel_ews_utils_sync_created_items (ews_folder, cnc, items, cancellable);
+ camel_ews_utils_sync_created_items (ews_folder, cnc, items, change_info, cancellable);
if (local_error) {
camel_ews_store_maybe_disconnect (ews_store, local_error);
@@ -1705,6 +1707,7 @@ ews_refresh_info_sync (CamelFolder *folder,
GCancellable *cancellable,
GError **error)
{
+ CamelFolderChangeInfo *change_info;
CamelEwsFolder *ews_folder;
CamelEwsFolderPrivate *priv;
EEwsConnection *cnc;
@@ -1713,6 +1716,7 @@ ews_refresh_info_sync (CamelFolder *folder,
gchar *id;
gchar *sync_state;
gboolean includes_last_item = FALSE;
+ gint64 last_folder_update_time;
GError *local_error = NULL;
full_name = camel_folder_get_full_name (folder);
@@ -1739,6 +1743,8 @@ ews_refresh_info_sync (CamelFolder *folder,
camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
+ change_info = camel_folder_change_info_new ();
+ last_folder_update_time = g_get_monotonic_time ();
id = camel_ews_store_summary_get_folder_id_from_name (
ews_store->summary, full_name);
@@ -1776,10 +1782,10 @@ ews_refresh_info_sync (CamelFolder *folder,
}
if (items_deleted)
- camel_ews_utils_sync_deleted_items (ews_folder, items_deleted);
+ camel_ews_utils_sync_deleted_items (ews_folder, items_deleted, change_info);
if (items_created)
- sync_created_items (ews_folder, cnc, items_created, cancellable, &local_error);
+ sync_created_items (ews_folder, cnc, items_created, change_info, cancellable,
&local_error);
if (local_error) {
if (items_updated) {
@@ -1791,7 +1797,7 @@ ews_refresh_info_sync (CamelFolder *folder,
}
if (items_updated)
- sync_updated_items (ews_folder, cnc, items_updated, cancellable, &local_error);
+ sync_updated_items (ews_folder, cnc, items_updated, change_info, cancellable,
&local_error);
if (local_error)
break;
@@ -1807,9 +1813,27 @@ ews_refresh_info_sync (CamelFolder *folder,
((CamelEwsSummary *) folder->summary)->sync_state = sync_state;
camel_folder_summary_touch (folder->summary);
+
+ if (camel_folder_change_info_changed (change_info)) {
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ /* Notify any listeners only once per 10 seconds, as such notify can cause UI update
*/
+ if (g_get_monotonic_time () - last_folder_update_time >= 10 * G_USEC_PER_SEC) {
+ last_folder_update_time = g_get_monotonic_time ();
+ camel_folder_changed (folder, change_info);
+ camel_folder_change_info_clear (change_info);
+ }
+ }
} while (!local_error && !includes_last_item && !g_cancellable_is_cancelled (cancellable));
- camel_folder_summary_save_to_db (folder->summary, NULL);
+ if (camel_folder_change_info_changed (change_info)) {
+ camel_folder_summary_touch (folder->summary);
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ camel_folder_changed (folder, change_info);
+ } else {
+ camel_folder_summary_save_to_db (folder->summary, NULL);
+ }
+
+ camel_folder_change_info_free (change_info);
if (local_error)
g_propagate_error (error, local_error);
diff --git a/src/camel/camel-ews-utils.c b/src/camel/camel-ews-utils.c
index 8f3d7e1..ff60ee3 100644
--- a/src/camel/camel-ews-utils.c
+++ b/src/camel/camel-ews-utils.c
@@ -344,18 +344,16 @@ ews_utils_sync_folders (CamelEwsStore *ews_store,
void
camel_ews_utils_sync_deleted_items (CamelEwsFolder *ews_folder,
- GSList *items_deleted)
+ GSList *items_deleted,
+ CamelFolderChangeInfo *change_info)
{
CamelStore *store;
CamelFolder *folder;
const gchar *full_name;
- CamelFolderChangeInfo *ci;
CamelEwsStore *ews_store;
GSList *l;
GList *items_deleted_list = NULL;
- ci = camel_folder_change_info_new ();
-
folder = CAMEL_FOLDER (ews_folder);
full_name = camel_folder_get_full_name (folder);
@@ -369,7 +367,7 @@ camel_ews_utils_sync_deleted_items (CamelEwsFolder *ews_folder,
items_deleted_list, (gpointer) id);
camel_folder_summary_remove_uid (folder->summary, id);
- camel_folder_change_info_remove_uid (ci, id);
+ camel_folder_change_info_remove_uid (change_info, id);
}
items_deleted_list = g_list_reverse (items_deleted_list);
@@ -378,13 +376,6 @@ camel_ews_utils_sync_deleted_items (CamelEwsFolder *ews_folder,
full_name, items_deleted_list, NULL);
g_list_free (items_deleted_list);
- 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);
g_slist_free (items_deleted);
}
@@ -743,13 +734,12 @@ camel_ews_utils_update_read_receipt_flags (EEwsItem *item,
void
camel_ews_utils_sync_updated_items (CamelEwsFolder *ews_folder,
- GSList *items_updated)
+ GSList *items_updated,
+ CamelFolderChangeInfo *change_info)
{
CamelFolder *folder;
- CamelFolderChangeInfo *ci;
GSList *l;
- ci = camel_folder_change_info_new ();
folder = CAMEL_FOLDER (ews_folder);
for (l = items_updated; l != NULL; l = g_slist_next (l)) {
@@ -786,7 +776,7 @@ camel_ews_utils_sync_updated_items (CamelEwsFolder *ews_folder,
changed = camel_ews_utils_update_read_receipt_flags (item, (CamelMessageInfo *) mi,
server_flags, FALSE) || changed;
if (changed)
- camel_folder_change_info_change_uid (ci, mi->info.uid);
+ camel_folder_change_info_change_uid (change_info, mi->info.uid);
g_free (mi->change_key);
mi->change_key = g_strdup (id->change_key);
@@ -804,12 +794,6 @@ camel_ews_utils_sync_updated_items (CamelEwsFolder *ews_folder,
g_object_unref (item);
}
- 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 (CAMEL_FOLDER (ews_folder), ci);
- }
- camel_folder_change_info_free (ci);
g_slist_free (items_updated);
}
@@ -817,16 +801,15 @@ void
camel_ews_utils_sync_created_items (CamelEwsFolder *ews_folder,
EEwsConnection *cnc,
GSList *items_created,
+ CamelFolderChangeInfo *change_info,
GCancellable *cancellable)
{
CamelFolder *folder;
- CamelFolderChangeInfo *ci;
GSList *l;
if (!items_created)
return;
- ci = camel_folder_change_info_new ();
folder = CAMEL_FOLDER (ews_folder);
for (l = items_created; l != NULL; l = g_slist_next (l)) {
@@ -955,18 +938,12 @@ camel_ews_utils_sync_created_items (CamelEwsFolder *ews_folder,
*/
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);
+ camel_folder_change_info_add_uid (change_info, id->id);
+ camel_folder_change_info_recent_uid (change_info, id->id);
g_object_unref (item);
}
- 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 (CAMEL_FOLDER (ews_folder), ci);
- }
- camel_folder_change_info_free (ci);
g_slist_free (items_created);
}
diff --git a/src/camel/camel-ews-utils.h b/src/camel/camel-ews-utils.h
index 8b4caf0..0cf4940 100644
--- a/src/camel/camel-ews-utils.h
+++ b/src/camel/camel-ews-utils.h
@@ -62,15 +62,18 @@ CamelFolderInfo *
const gchar *fid);
void camel_ews_utils_sync_deleted_items
(CamelEwsFolder *ews_folder,
- GSList *items_deleted);
+ GSList *items_deleted,
+ CamelFolderChangeInfo *change_info);
void camel_ews_utils_sync_created_items
(CamelEwsFolder *ews_folder,
EEwsConnection *cnc,
GSList *items_created,
+ CamelFolderChangeInfo *change_info,
GCancellable *cancellable);
void camel_ews_utils_sync_updated_items
(CamelEwsFolder *ews_folder,
- GSList *items_updated);
+ GSList *items_updated,
+ CamelFolderChangeInfo *change_info);
void ews_utils_replace_server_user_flags
(ESoapMessage *msg,
CamelEwsMessageInfo *mi);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]