[evolution-ews] Bug 786208 - Already opened message box doesn’t show new emails
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug 786208 - Already opened message box doesn’t show new emails
- Date: Mon, 2 Oct 2017 11:42:07 +0000 (UTC)
commit f662bb0a70a728d5f590ae3e16aa87c6132dc1df
Author: Milan Crha <mcrha redhat com>
Date: Mon Oct 2 13:43:04 2017 +0200
Bug 786208 - Already opened message box doesn’t show new emails
src/camel/camel-ews-folder.c | 52 ++++++++++++++++++++++++++++++++++++++++-
src/camel/camel-ews-summary.c | 19 ++++++++++++--
src/camel/camel-ews-summary.h | 3 ++
3 files changed, 70 insertions(+), 4 deletions(-)
---
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index 4c82676..054caca 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -1760,6 +1760,7 @@ static void
sync_created_items (CamelEwsFolder *ews_folder,
EEwsConnection *cnc,
GSList *created_items,
+ GHashTable *updating_summary_uids,
CamelFolderChangeInfo *change_info,
GCancellable *cancellable,
GError **error)
@@ -1789,6 +1790,20 @@ sync_created_items (CamelEwsFolder *ews_folder,
continue;
}
+ if (updating_summary_uids) {
+ const gchar *pooled_uid = camel_pstring_strdup (id->id);
+ gboolean known;
+
+ known = g_hash_table_remove (updating_summary_uids, pooled_uid);
+
+ camel_pstring_free (pooled_uid);
+
+ if (known) {
+ g_object_unref (item);
+ continue;
+ }
+ }
+
/* created_msg_ids are items other than generic item. We fetch them
* separately since the property sets vary */
/* FIXME: Do we need to handle any other item types
@@ -1950,6 +1965,7 @@ ews_refresh_info_sync (CamelFolder *folder,
CamelFolderSummary *folder_summary;
CamelEwsFolder *ews_folder;
CamelEwsFolderPrivate *priv;
+ GHashTable *updating_summary_uids = NULL;
EEwsConnection *cnc;
CamelEwsStore *ews_store;
const gchar *full_name;
@@ -1991,6 +2007,10 @@ ews_refresh_info_sync (CamelFolder *folder,
camel_operation_push_message (cancellable, _("Refreshing folder “%s”"), camel_folder_get_display_name
(folder));
+ if (camel_ews_summary_get_version (CAMEL_EWS_SUMMARY (folder_summary)) < CAMEL_EWS_SUMMARY_VERSION) {
+ updating_summary_uids = camel_folder_summary_get_hash (folder_summary);
+ }
+
/* Sync folder items does not return the fields ToRecipients,
* CCRecipients. With the item_type unknown, its not possible
* to fetch the right properties which are valid for an item type.
@@ -2017,6 +2037,10 @@ ews_refresh_info_sync (CamelFolder *folder,
g_free (sync_state);
sync_state = NULL;
ews_folder_forget_all_mails (ews_folder);
+ if (updating_summary_uids) {
+ g_hash_table_destroy (updating_summary_uids);
+ updating_summary_uids = NULL;
+ }
e_ews_connection_sync_folder_items_sync (cnc, EWS_PRIORITY_MEDIUM, NULL, id,
"IdOnly", NULL, EWS_MAX_FETCH_COUNT,
&sync_state, &includes_last_item, &items_created, &items_updated,
&items_deleted,
@@ -2032,7 +2056,7 @@ ews_refresh_info_sync (CamelFolder *folder,
camel_ews_utils_sync_deleted_items (ews_folder, items_deleted, change_info);
if (items_created)
- sync_created_items (ews_folder, cnc, items_created, change_info, cancellable,
&local_error);
+ sync_created_items (ews_folder, cnc, items_created, updating_summary_uids,
change_info, cancellable, &local_error);
if (local_error) {
if (items_updated) {
@@ -2071,6 +2095,32 @@ ews_refresh_info_sync (CamelFolder *folder,
}
} while (!local_error && !includes_last_item && !g_cancellable_is_cancelled (cancellable));
+ if (updating_summary_uids) {
+ if (!local_error && !g_cancellable_is_cancelled (cancellable) &&
+ g_hash_table_size (updating_summary_uids) > 0) {
+ GHashTableIter iter;
+ gpointer key;
+ GList *removed_uids = NULL;
+
+ g_hash_table_iter_init (&iter, updating_summary_uids);
+ while (g_hash_table_iter_next (&iter, &key, NULL)) {
+ const gchar *uid = key;
+
+ camel_folder_change_info_remove_uid (change_info, uid);
+ ews_data_cache_remove (ews_folder->cache, "cur", uid, NULL);
+
+ removed_uids = g_list_prepend (removed_uids, (gpointer) uid);
+ }
+
+ camel_folder_summary_remove_uids (folder_summary, removed_uids);
+
+ g_list_free (removed_uids);
+ }
+
+ g_hash_table_destroy (updating_summary_uids);
+ updating_summary_uids = NULL;
+ }
+
camel_operation_pop_message (cancellable);
if (camel_folder_change_info_changed (change_info)) {
diff --git a/src/camel/camel-ews-summary.c b/src/camel/camel-ews-summary.c
index b79487d..5fdb2c0 100644
--- a/src/camel/camel-ews-summary.c
+++ b/src/camel/camel-ews-summary.c
@@ -34,8 +34,6 @@
#include "camel-ews-folder.h"
#include "camel-ews-summary.h"
-#define CAMEL_EWS_SUMMARY_VERSION (1)
-
#define EXTRACT_FIRST_DIGIT(val) part ? val=strtoul (part, &part, 10) : 0;
#define EXTRACT_DIGIT(val) part++; part ? val=strtoul (part, &part, 10) : 0;
@@ -122,13 +120,18 @@ summary_header_load (CamelFolderSummary *s,
if (!CAMEL_FOLDER_SUMMARY_CLASS (camel_ews_summary_parent_class)->summary_header_load (s, mir))
return FALSE;
+ ews_summary->priv->version = 0;
+
part = mir->bdata;
if (part)
EXTRACT_FIRST_DIGIT (ews_summary->priv->version);
- if (part && part++ && strcmp (part, "(null)")) {
+ if (part && part++ && strcmp (part, "(null)") &&
+ ews_summary->priv->version >= CAMEL_EWS_SUMMARY_VERSION) {
camel_ews_summary_set_sync_state (ews_summary, part);
+ } else {
+ camel_ews_summary_set_sync_state (ews_summary, NULL);
}
return TRUE;
@@ -152,6 +155,8 @@ summary_header_save (CamelFolderSummary *s,
g_free (sync_state);
+ ews_summary->priv->version = CAMEL_EWS_SUMMARY_VERSION;
+
return fir;
}
@@ -277,6 +282,14 @@ ews_summary_clear (CamelFolderSummary *summary,
camel_folder_summary_free_array (known_uids);
}
+gint32
+camel_ews_summary_get_version (CamelEwsSummary *ews_summary)
+{
+ g_return_val_if_fail (CAMEL_IS_EWS_SUMMARY (ews_summary), -1);
+
+ return ews_summary->priv->version;
+}
+
void
camel_ews_summary_set_sync_state (CamelEwsSummary *ews_summary,
const gchar *sync_state)
diff --git a/src/camel/camel-ews-summary.h b/src/camel/camel-ews-summary.h
index 4903a2b..62b0807 100644
--- a/src/camel/camel-ews-summary.h
+++ b/src/camel/camel-ews-summary.h
@@ -26,6 +26,8 @@
#include "camel-ews-message-info.h"
+#define CAMEL_EWS_SUMMARY_VERSION (2)
+
/* Standard GObject macros */
#define CAMEL_TYPE_EWS_SUMMARY \
(camel_ews_summary_get_type ())
@@ -78,6 +80,7 @@ gboolean
CamelMimeMessage *message);
void ews_summary_clear (CamelFolderSummary *summary,
gboolean uncache);
+gint32 camel_ews_summary_get_version (CamelEwsSummary *ews_summary);
void camel_ews_summary_set_sync_state(CamelEwsSummary *ews_summary,
const gchar *sync_state);
gchar * camel_ews_summary_dup_sync_state(CamelEwsSummary *ews_summary);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]