[evolution-data-server] [IMAPx] Move to real Trash keeps original message with UID COPY
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] [IMAPx] Move to real Trash keeps original message with UID COPY
- Date: Mon, 7 Sep 2015 16:22:04 +0000 (UTC)
commit 73d0803774e3557bd0dc38a825b11f873c0bd5f3
Author: Milan Crha <mcrha redhat com>
Date: Mon Sep 7 18:20:39 2015 +0200
[IMAPx] Move to real Trash keeps original message with UID COPY
Due to the \Deleted flag not being stored in the original folder,
the following EXPUNGE didn't delete the copied message from
the server, thus the next enter of the folder the message was
back.
Reported downstream as:
https://bugzilla.redhat.com/show_bug.cgi?id=1260416
camel/providers/imapx/camel-imapx-conn-manager.c | 46 ++++++++++++-
camel/providers/imapx/camel-imapx-server.c | 75 ++++++++++++----------
camel/providers/imapx/camel-imapx-server.h | 1 +
3 files changed, 84 insertions(+), 38 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-conn-manager.c
b/camel/providers/imapx/camel-imapx-conn-manager.c
index 49598d9..d708a30 100644
--- a/camel/providers/imapx/camel-imapx-conn-manager.c
+++ b/camel/providers/imapx/camel-imapx-conn-manager.c
@@ -1414,7 +1414,7 @@ imapx_conn_manager_sync_changes_run_sync (CamelIMAPXJob *job,
{
CamelIMAPXMailbox *mailbox;
GError *local_error = NULL;
- gboolean success;
+ gboolean can_influence_flags, success;
g_return_val_if_fail (job != NULL, FALSE);
g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (server), FALSE);
@@ -1422,7 +1422,9 @@ imapx_conn_manager_sync_changes_run_sync (CamelIMAPXJob *job,
mailbox = camel_imapx_job_get_mailbox (job);
g_return_val_if_fail (CAMEL_IS_IMAPX_MAILBOX (mailbox), FALSE);
- success = camel_imapx_server_sync_changes_sync (server, mailbox, cancellable, &local_error);
+ can_influence_flags = GPOINTER_TO_INT (camel_imapx_job_get_user_data (job)) == 1;
+
+ success = camel_imapx_server_sync_changes_sync (server, mailbox, can_influence_flags, cancellable,
&local_error);
camel_imapx_job_set_result (job, success, NULL, local_error, NULL);
@@ -1432,6 +1434,25 @@ imapx_conn_manager_sync_changes_run_sync (CamelIMAPXJob *job,
return success;
}
+static gboolean
+imapx_conn_manager_sync_changes_matches (CamelIMAPXJob *job,
+ CamelIMAPXJob *other_job)
+{
+ gboolean job_can_influence_flags, other_job_can_influence_flags;
+
+ g_return_val_if_fail (job != NULL, FALSE);
+ g_return_val_if_fail (other_job != NULL, FALSE);
+
+ if (camel_imapx_job_get_kind (job) != CAMEL_IMAPX_JOB_SYNC_CHANGES ||
+ camel_imapx_job_get_kind (job) != camel_imapx_job_get_kind (other_job))
+ return FALSE;
+
+ job_can_influence_flags = GPOINTER_TO_INT (camel_imapx_job_get_user_data (job)) == 1;
+ other_job_can_influence_flags = GPOINTER_TO_INT (camel_imapx_job_get_user_data (other_job)) == 1;
+
+ return job_can_influence_flags == other_job_can_influence_flags;
+}
+
gboolean
camel_imapx_conn_manager_sync_changes_sync (CamelIMAPXConnManager *conn_man,
CamelIMAPXMailbox *mailbox,
@@ -1446,7 +1467,11 @@ camel_imapx_conn_manager_sync_changes_sync (CamelIMAPXConnManager *conn_man,
g_return_val_if_fail (CAMEL_IS_IMAPX_CONN_MANAGER (conn_man), FALSE);
job = camel_imapx_job_new (CAMEL_IMAPX_JOB_SYNC_CHANGES, mailbox,
- imapx_conn_manager_sync_changes_run_sync, NULL, NULL);
+ imapx_conn_manager_sync_changes_run_sync,
+ imapx_conn_manager_sync_changes_matches, NULL);
+
+ /* Skip store of the \Deleted flag */
+ camel_imapx_job_set_user_data (job, GINT_TO_POINTER (1), NULL);
success = camel_imapx_conn_manager_run_job_sync (conn_man, job,
imapx_conn_manager_matches_sync_changes_or_refresh_info,
@@ -1475,6 +1500,19 @@ camel_imapx_conn_manager_sync_changes_sync (CamelIMAPXConnManager *conn_man,
}
if (success && expunge) {
+ job = camel_imapx_job_new (CAMEL_IMAPX_JOB_SYNC_CHANGES, mailbox,
+ imapx_conn_manager_sync_changes_run_sync,
+ imapx_conn_manager_sync_changes_matches, NULL);
+
+ /* Store also the \Deleted flag */
+ camel_imapx_job_set_user_data (job, GINT_TO_POINTER (0), NULL);
+
+ success = camel_imapx_conn_manager_run_job_sync (conn_man, job,
+ imapx_conn_manager_matches_sync_changes_or_refresh_info,
+ cancellable, error);
+
+ camel_imapx_job_unref (job);
+
success = imapx_conn_manager_expunge_sync (conn_man, mailbox, TRUE, cancellable, error);
}
@@ -1509,7 +1547,7 @@ imapx_conn_manager_expunge_run_sync (CamelIMAPXJob *job,
return success;
}
-gboolean
+static gboolean
imapx_conn_manager_expunge_sync (CamelIMAPXConnManager *conn_man,
CamelIMAPXMailbox *mailbox,
gboolean skip_sync_changes,
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index c40d8af..6f74fc0 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -5015,6 +5015,7 @@ imapx_server_info_changed_cb (CamelIMAPXSummary *summary,
gboolean
camel_imapx_server_sync_changes_sync (CamelIMAPXServer *is,
CamelIMAPXMailbox *mailbox,
+ gboolean can_influence_flags,
GCancellable *cancellable,
GError **error)
{
@@ -5023,14 +5024,13 @@ camel_imapx_server_sync_changes_sync (CamelIMAPXServer *is,
GArray *on_user = NULL, *off_user = NULL;
CamelFolder *folder;
CamelIMAPXMessageInfo *info;
- CamelIMAPXSettings *settings;
GHashTable *changed_meanwhile;
gulong changed_meanwhile_handler_id;
guint32 permanentflags;
struct _uidset_state uidset;
gint unread_change = 0;
- gboolean use_real_junk_path;
- gboolean use_real_trash_path;
+ gboolean use_real_junk_path = FALSE;
+ gboolean use_real_trash_path = FALSE;
gboolean remove_deleted_flags = FALSE;
gboolean nothing_to_do;
gboolean success;
@@ -5063,36 +5063,38 @@ camel_imapx_server_sync_changes_sync (CamelIMAPXServer *is,
changed_meanwhile_handler_id = g_signal_connect (folder->summary, "info-changed",
G_CALLBACK (imapx_server_info_changed_cb), changed_meanwhile);
- settings = camel_imapx_server_ref_settings (is);
- use_real_junk_path = camel_imapx_settings_get_use_real_junk_path (settings);
- use_real_trash_path = camel_imapx_settings_get_use_real_trash_path (settings);
- if (use_real_trash_path) {
- CamelFolder *trash_folder = NULL;
- gchar *real_trash_path;
+ if (can_influence_flags) {
+ CamelIMAPXSettings *settings;
+
+ settings = camel_imapx_server_ref_settings (is);
+ use_real_junk_path = camel_imapx_settings_get_use_real_junk_path (settings);
+ use_real_trash_path = camel_imapx_settings_get_use_real_trash_path (settings);
+ if (use_real_trash_path) {
+ CamelFolder *trash_folder = NULL;
+ gchar *real_trash_path;
- real_trash_path = camel_imapx_settings_dup_real_trash_path (settings);
- if (real_trash_path)
- trash_folder = camel_store_get_folder_sync (
- camel_folder_get_parent_store (folder),
- real_trash_path, 0, cancellable, NULL);
+ real_trash_path = camel_imapx_settings_dup_real_trash_path (settings);
+ if (real_trash_path)
+ trash_folder = camel_store_get_folder_sync (
+ camel_folder_get_parent_store (folder),
+ real_trash_path, 0, cancellable, NULL);
- /* Remove deleted flags in all but the trash folder itself */
- remove_deleted_flags = !trash_folder || trash_folder != folder;
+ /* Remove deleted flags in all but the trash folder itself */
+ remove_deleted_flags = !trash_folder || trash_folder != folder;
- use_real_trash_path = trash_folder != NULL;
+ use_real_trash_path = trash_folder != NULL;
- g_clear_object (&trash_folder);
- g_free (real_trash_path);
+ g_clear_object (&trash_folder);
+ g_free (real_trash_path);
+ }
+ g_object_unref (settings);
}
- g_object_unref (settings);
off_orset = on_orset = 0;
for (i = 0; i < changed_uids->len; i++) {
guint32 flags, sflags;
CamelFlag *uflags, *suflags;
const gchar *uid;
- gboolean move_to_real_junk;
- gboolean move_to_real_trash;
guint j = 0;
uid = g_ptr_array_index (changed_uids, i);
@@ -5111,21 +5113,26 @@ camel_imapx_server_sync_changes_sync (CamelIMAPXServer *is,
flags = info->info.flags & CAMEL_IMAPX_SERVER_FLAGS;
sflags = info->server_flags & CAMEL_IMAPX_SERVER_FLAGS;
- move_to_real_junk =
- use_real_junk_path &&
- (flags & CAMEL_MESSAGE_JUNK);
+ if (can_influence_flags) {
+ gboolean move_to_real_junk;
+ gboolean move_to_real_trash;
- move_to_real_trash =
- use_real_trash_path && remove_deleted_flags &&
- (flags & CAMEL_MESSAGE_DELETED);
+ move_to_real_junk =
+ use_real_junk_path &&
+ (flags & CAMEL_MESSAGE_JUNK);
- if (move_to_real_junk)
- camel_imapx_folder_add_move_to_real_junk (
- CAMEL_IMAPX_FOLDER (folder), uid);
+ move_to_real_trash =
+ use_real_trash_path && remove_deleted_flags &&
+ (flags & CAMEL_MESSAGE_DELETED);
- if (move_to_real_trash)
- camel_imapx_folder_add_move_to_real_trash (
- CAMEL_IMAPX_FOLDER (folder), uid);
+ if (move_to_real_junk)
+ camel_imapx_folder_add_move_to_real_junk (
+ CAMEL_IMAPX_FOLDER (folder), uid);
+
+ if (move_to_real_trash)
+ camel_imapx_folder_add_move_to_real_trash (
+ CAMEL_IMAPX_FOLDER (folder), uid);
+ }
if (flags != sflags) {
off_orset |= (flags ^ sflags) & ~flags;
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index 45823dd..e617ea2 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -188,6 +188,7 @@ gboolean camel_imapx_server_refresh_info_sync
gboolean camel_imapx_server_sync_changes_sync
(CamelIMAPXServer *is,
CamelIMAPXMailbox *mailbox,
+ gboolean can_influence_flags,
GCancellable *cancellable,
GError **error);
gboolean camel_imapx_server_expunge_sync (CamelIMAPXServer *is,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]