[evolution-ews] Bug #720260 - Moved messages need to be retrieved again
- From: Fabiano Fidêncio <ffidencio src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Bug #720260 - Moved messages need to be retrieved again
- Date: Mon, 17 Feb 2014 20:06:55 +0000 (UTC)
commit f367a18db027d39fd90b07247cf3ba9574ce84ca
Author: Fabiano Fidêncio <fidencio redhat com>
Date: Wed Feb 12 18:44:28 2014 +0100
Bug #720260 - Moved messages need to be retrieved again
src/camel/camel-ews-folder.c | 86 ++++++++++++++++++++++++++++++++++++++++-
src/camel/camel-ews-summary.c | 4 ++
src/camel/camel-ews-summary.h | 1 +
3 files changed, 89 insertions(+), 2 deletions(-)
---
diff --git a/src/camel/camel-ews-folder.c b/src/camel/camel-ews-folder.c
index 45be1f6..7ed46c1 100644
--- a/src/camel/camel-ews-folder.c
+++ b/src/camel/camel-ews-folder.c
@@ -185,6 +185,29 @@ ews_get_filename (CamelFolder *folder,
return filename;
}
+static CamelStream *
+ews_data_cache_add (CamelDataCache *cdc,
+ const gchar *path,
+ const gchar *key,
+ GError **error)
+{
+ GIOStream *base_stream;
+ CamelStream *stream = NULL;
+ GChecksum *sha = g_checksum_new (G_CHECKSUM_SHA256);
+
+ g_checksum_update (sha, (guchar *) key, strlen (key));
+ base_stream = camel_data_cache_add (
+ cdc, path, g_checksum_get_string (sha), error);
+ g_checksum_free (sha);
+
+ if (base_stream != NULL)
+ stream = camel_stream_new (base_stream);
+
+ g_object_unref (base_stream);
+
+ return stream;
+}
+
static gint
ews_data_cache_remove (CamelDataCache *cdc,
const gchar *path,
@@ -1774,7 +1797,7 @@ ews_append_message_sync (CamelFolder *folder,
e_ews_folder_id_free (fid);
g_free (folder_id);
- camel_ews_summary_add_message (folder->summary, itemid, info, message);
+ camel_ews_summary_add_message (folder->summary, itemid, changekey, info, message);
if (appended_uid)
*appended_uid = itemid;
@@ -1799,7 +1822,6 @@ ews_transfer_messages_to_sync (CamelFolder *source,
{
EEwsConnection *cnc;
CamelEwsStore *dst_ews_store;
- CamelFolderChangeInfo *changes = NULL;
const gchar *dst_full_name;
gchar *dst_id;
GError *local_error = NULL;
@@ -1848,22 +1870,82 @@ ews_transfer_messages_to_sync (CamelFolder *source,
if (mi_list != NULL && success)
success = ews_save_flags (source, mi_list, cancellable, &local_error);
+ ids = g_slist_reverse (ids);
+
if (success && e_ews_connection_move_items_sync (
cnc, EWS_PRIORITY_MEDIUM,
dst_id, !delete_originals,
ids, &ret_items,
cancellable, &local_error)) {
+ CamelFolderChangeInfo *changes;
+ GSList *l;
+
+ changes = camel_folder_change_info_new ();
+
+ for (l = ret_items, i = 0; l != NULL; l = l->next, i++) {
+ CamelMimeMessage *message;
+ CamelStream *stream;
+ CamelMessageInfo *info;
+ CamelMessageInfo *clone;
+ const EwsId *id;
+
+ if (e_ews_item_get_item_type (l->data) == E_EWS_ITEM_TYPE_ERROR)
+ continue;
+
+ id = e_ews_item_get_id (l->data);
+
+ message = ews_folder_get_message_cached (source, uids->pdata[i], cancellable);
+ if (message == NULL)
+ continue;
+
+ stream = ews_data_cache_add (
+ CAMEL_EWS_FOLDER (destination)->cache, "cur", id->id, NULL);
+ if (stream == NULL) {
+ g_object_unref (message);
+
+ continue;
+ }
+
+ camel_data_wrapper_write_to_stream_sync (
+ CAMEL_DATA_WRAPPER (message), stream, cancellable, NULL);
+
+ info = camel_folder_summary_get (source->summary, uids->pdata[i]);
+ if (info == NULL) {
+ g_object_unref (stream);
+ g_object_unref (message);
+
+ continue;
+ }
+
+ clone = camel_message_info_clone (info);
+
+ camel_ews_summary_add_message (destination->summary, id->id, id->change_key, clone,
message);
+ camel_folder_change_info_add_uid (changes, id->id);
+
+ camel_message_info_unref (clone);
+ camel_message_info_unref (info);
+ g_object_unref (stream);
+ g_object_unref (message);
+ }
+
+ if (camel_folder_change_info_changed (changes))
+ camel_folder_changed (destination, changes);
+
+ camel_folder_change_info_free (changes);
if (delete_originals) {
changes = camel_folder_change_info_new ();
+
for (i = 0; i < uids->len; i++) {
camel_folder_summary_remove_uid (source->summary, uids->pdata[i]);
camel_folder_change_info_remove_uid (changes, uids->pdata[i]);
+ ews_data_cache_remove (CAMEL_EWS_FOLDER (source)->cache, "cur",
uids->pdata[i], NULL);
}
if (camel_folder_change_info_changed (changes)) {
camel_folder_summary_touch (source->summary);
camel_folder_changed (source, changes);
}
+
camel_folder_change_info_free (changes);
}
diff --git a/src/camel/camel-ews-summary.c b/src/camel/camel-ews-summary.c
index 966a8e8..e413910 100644
--- a/src/camel/camel-ews-summary.c
+++ b/src/camel/camel-ews-summary.c
@@ -274,6 +274,7 @@ ews_info_set_flags (CamelMessageInfo *info,
void
camel_ews_summary_add_message (CamelFolderSummary *summary,
const gchar *uid,
+ const gchar *change_key,
CamelMessageInfo *info,
CamelMimeMessage *message)
{
@@ -289,6 +290,9 @@ camel_ews_summary_add_message (CamelFolderSummary *summary,
mi = (CamelEwsMessageInfo *) camel_folder_summary_info_new_from_message (summary, message, NULL);
g_return_if_fail (mi != NULL);
+ /* Set the change_key */
+ mi->change_key = g_strdup (change_key);
+
/* Copy flags 'n' tags */
mi->info.flags = camel_message_info_flags (info);
diff --git a/src/camel/camel-ews-summary.h b/src/camel/camel-ews-summary.h
index e69eed6..eb47a7a 100644
--- a/src/camel/camel-ews-summary.h
+++ b/src/camel/camel-ews-summary.h
@@ -91,6 +91,7 @@ gboolean
CamelFlag *server_user_flags);
void camel_ews_summary_add_message (CamelFolderSummary *summary,
const gchar *uid,
+ const gchar *change_key,
CamelMessageInfo *info,
CamelMimeMessage *message);
void ews_summary_clear (CamelFolderSummary *summary,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]