[evolution-data-server/evolution-data-server-3-12] Bug 735191 - [IMAPx] Avoid storing server-disallowed message flags
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/evolution-data-server-3-12] Bug 735191 - [IMAPx] Avoid storing server-disallowed message flags
- Date: Fri, 29 Aug 2014 14:58:16 +0000 (UTC)
commit 513af2aeeae82f14ea8135bfe7b4eca8cae38b96
Author: Milan Crha <mcrha redhat com>
Date: Fri Aug 29 16:57:45 2014 +0200
Bug 735191 - [IMAPx] Avoid storing server-disallowed message flags
camel/providers/imapx/camel-imapx-server.c | 113 +++++++++++++++-------------
camel/providers/imapx/camel-imapx-utils.c | 6 +-
camel/providers/imapx/camel-imapx-utils.h | 2 +-
3 files changed, 66 insertions(+), 55 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index cfff143..41ec5ea 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -2431,7 +2431,7 @@ imapx_untagged_fetch (CamelIMAPXServer *is,
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
- imapx_set_message_info_flags_for_new_message (mi, server_flags,
server_user_flags, FALSE, NULL, folder);
+ imapx_set_message_info_flags_for_new_message (mi, server_flags,
server_user_flags, FALSE, NULL, is->priv->permanentflags);
camel_folder_summary_add (folder->summary, mi);
camel_folder_change_info_add_uid (data->changes, mi->uid);
@@ -5260,7 +5260,7 @@ imapx_command_copy_messages_step_done (CamelIMAPXServer *is,
((CamelMessageInfoBase *) source_info)->user_flags,
TRUE,
((CamelMessageInfoBase *) source_info)->user_tags,
- destination);
+ is->priv->permanentflags);
if (is_new)
camel_folder_summary_add (destination->summary, destination_info);
camel_folder_change_info_add_uid (changes, destination_info->uid);
@@ -5457,7 +5457,7 @@ imapx_command_append_message_done (CamelIMAPXServer *is,
((CamelMessageInfoBase *) data->info)->user_flags,
TRUE,
((CamelMessageInfoBase *) data->info)->user_tags,
- folder);
+ is->priv->permanentflags);
camel_folder_summary_add (folder->summary, mi);
changes = camel_folder_change_info_new ();
camel_folder_change_info_add_uid (changes, mi->uid);
@@ -7297,7 +7297,9 @@ imapx_command_sync_changes_done (CamelIMAPXServer *is,
xinfo->info.flags |= CAMEL_MESSAGE_FOLDER_FLAGGED;
}
xinfo->info.dirty = TRUE;
- camel_flag_list_copy (&xinfo->server_user_flags, &xinfo->info.user_flags);
+ if ((is->priv->permanentflags & CAMEL_MESSAGE_USER) != 0 ||
+ camel_flag_list_size (&xinfo->server_user_flags) == 0)
+ camel_flag_list_copy (&xinfo->server_user_flags, &xinfo->info.user_flags);
camel_folder_summary_touch (folder->summary);
camel_message_info_unref (xinfo);
@@ -8796,66 +8798,75 @@ imapx_server_sync_changes (CamelIMAPXServer *is,
camel_imapx_folder_add_move_to_real_trash (
CAMEL_IMAPX_FOLDER (folder), uid);
+ flags &= is->priv->permanentflags;
+ sflags &= is->priv->permanentflags;
+
if (flags != sflags) {
off_orset |= (flags ^ sflags) & ~flags;
on_orset |= (flags ^ sflags) & flags;
}
- uflags = info->info.user_flags;
- suflags = info->server_user_flags;
- while (uflags || suflags) {
- gint res;
-
- if (uflags) {
- if (suflags)
- res = strcmp (uflags->name, suflags->name);
- else if (*uflags->name)
- res = -1;
- else {
- uflags = uflags->next;
- continue;
+ if ((is->priv->permanentflags & CAMEL_MESSAGE_USER) != 0) {
+ uflags = info->info.user_flags;
+ suflags = info->server_user_flags;
+ while (uflags || suflags) {
+ gint res;
+
+ if (uflags) {
+ if (suflags)
+ res = strcmp (uflags->name, suflags->name);
+ else if (*uflags->name)
+ res = -1;
+ else {
+ uflags = uflags->next;
+ continue;
+ }
+ } else {
+ res = 1;
}
- } else {
- res = 1;
- }
- if (res == 0) {
- uflags = uflags->next;
- suflags = suflags->next;
- } else {
- GArray *user_set;
- CamelFlag *user_flag;
- struct _imapx_flag_change *change = NULL, add = { 0 };
-
- if (res < 0) {
- if (on_user == NULL)
- on_user = g_array_new (FALSE, FALSE, sizeof (struct
_imapx_flag_change));
- user_set = on_user;
- user_flag = uflags;
+ if (res == 0) {
uflags = uflags->next;
- } else {
- if (off_user == NULL)
- off_user = g_array_new (FALSE, FALSE, sizeof (struct
_imapx_flag_change));
- user_set = off_user;
- user_flag = suflags;
suflags = suflags->next;
- }
+ } else {
+ GArray *user_set;
+ CamelFlag *user_flag;
+ struct _imapx_flag_change *change = NULL, add = { 0 };
+
+ if (res < 0) {
+ if (on_user == NULL)
+ on_user = g_array_new (FALSE, FALSE, sizeof (struct
_imapx_flag_change));
+ user_set = on_user;
+ user_flag = uflags;
+ uflags = uflags->next;
+ } else {
+ if (off_user == NULL)
+ off_user = g_array_new (FALSE, FALSE, sizeof (struct
_imapx_flag_change));
+ user_set = off_user;
+ user_flag = suflags;
+ suflags = suflags->next;
+ }
- /* Could sort this and binary search */
- for (j = 0; j < user_set->len; j++) {
- change = &g_array_index (user_set, struct _imapx_flag_change, j);
- if (strcmp (change->name, user_flag->name) == 0)
- goto found;
+ /* Could sort this and binary search */
+ for (j = 0; j < user_set->len; j++) {
+ change = &g_array_index (user_set, struct _imapx_flag_change,
j);
+ if (strcmp (change->name, user_flag->name) == 0)
+ goto found;
+ }
+ add.name = g_strdup (user_flag->name);
+ add.infos = g_ptr_array_new ();
+ g_array_append_val (user_set, add);
+ change = &add;
+ found:
+ camel_message_info_ref (info);
+ g_ptr_array_add (change->infos, info);
}
- add.name = g_strdup (user_flag->name);
- add.infos = g_ptr_array_new ();
- g_array_append_val (user_set, add);
- change = &add;
- found:
- camel_message_info_ref (info);
- g_ptr_array_add (change->infos, info);
}
+ } else {
+ /* Cannot save user flags to the server => store them locally only */
+ camel_flag_list_copy (&info->server_user_flags, &info->info.user_flags);
}
+
camel_message_info_unref (info);
}
diff --git a/camel/providers/imapx/camel-imapx-utils.c b/camel/providers/imapx/camel-imapx-utils.c
index a257a3e..45bd8c9 100644
--- a/camel/providers/imapx/camel-imapx-utils.c
+++ b/camel/providers/imapx/camel-imapx-utils.c
@@ -324,7 +324,7 @@ imapx_update_message_info_flags (CamelMessageInfo *info,
changed = TRUE;
}
- if ((folder->permanent_flags & CAMEL_MESSAGE_USER) != 0 && imapx_update_user_flags (info,
server_user_flags))
+ if ((permanent_flags & CAMEL_MESSAGE_USER) != 0 && imapx_update_user_flags (info, server_user_flags))
changed = TRUE;
return changed;
@@ -336,7 +336,7 @@ imapx_set_message_info_flags_for_new_message (CamelMessageInfo *info,
CamelFlag *server_user_flags,
gboolean force_user_flags,
CamelTag *user_tags,
- CamelFolder *folder)
+ guint32 permanent_flags)
{
CamelMessageInfoBase *binfo = (CamelMessageInfoBase *) info;
CamelIMAPXMessageInfo *xinfo = (CamelIMAPXMessageInfo *) info;
@@ -346,7 +346,7 @@ imapx_set_message_info_flags_for_new_message (CamelMessageInfo *info,
xinfo->server_flags = server_flags;
- if (force_user_flags || (folder->permanent_flags & CAMEL_MESSAGE_USER) != 0)
+ if (force_user_flags || (permanent_flags & CAMEL_MESSAGE_USER) != 0)
imapx_update_user_flags (info, server_user_flags);
while (user_tags) {
diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h
index 6e42b5c..7b6bb48 100644
--- a/camel/providers/imapx/camel-imapx-utils.h
+++ b/camel/providers/imapx/camel-imapx-utils.h
@@ -153,7 +153,7 @@ void imapx_set_message_info_flags_for_new_message
CamelFlag *server_user_flags,
gboolean force_user_flags,
CamelTag *user_tags,
- CamelFolder *folder);
+ guint32 permanent_flags);
void imapx_update_store_summary (CamelFolder *folder);
gchar * camel_imapx_dup_uid_from_summary_index
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]