diff options
author | Dan Winship <danw@src.gnome.org> | 2001-01-12 07:56:50 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2001-01-12 07:56:50 +0800 |
commit | 2805b11f123c6dbde4417804fc3d1542b9b87269 (patch) | |
tree | 33478bc9cc9661b7f63ccddbecfbdcfd22b80311 | |
parent | d5bbb1d75d22f87993472fbdd6918164b8427b20 (diff) | |
download | gsoc2013-evolution-2805b11f123c6dbde4417804fc3d1542b9b87269.tar gsoc2013-evolution-2805b11f123c6dbde4417804fc3d1542b9b87269.tar.gz gsoc2013-evolution-2805b11f123c6dbde4417804fc3d1542b9b87269.tar.bz2 gsoc2013-evolution-2805b11f123c6dbde4417804fc3d1542b9b87269.tar.lz gsoc2013-evolution-2805b11f123c6dbde4417804fc3d1542b9b87269.tar.xz gsoc2013-evolution-2805b11f123c6dbde4417804fc3d1542b9b87269.tar.zst gsoc2013-evolution-2805b11f123c6dbde4417804fc3d1542b9b87269.zip |
(imap_copy_message_to): Fix this up: sync flags to the server
before copying so that they end up correct in the remote folder.
And poke the destination folder after doing the copy so it notices
the new message right away.
(imap_move_message_to): Call imap_copy_message_to for most of the
work rather than duplicating the code (since it's much more
complicated now).
svn path=/trunk/; revision=7419
-rw-r--r-- | camel/ChangeLog | 7 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 83 |
2 files changed, 57 insertions, 33 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 3ceb41d676..d46a844e85 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -4,6 +4,13 @@ Fix a bug in previous commit: don't check for deleted messages if there are no known messages in the folder (because it would end up sending "FETCH 0 ..."). + (imap_copy_message_to): Fix this up: sync flags to the server + before copying so that they end up correct in the remote folder. + And poke the destination folder after doing the copy so it notices + the new message right away. + (imap_move_message_to): Call imap_copy_message_to for most of the + work rather than duplicating the code (since it's much more + complicated now). 2001-01-11 Dan Winship <danw@ximian.com> diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 562b989057..3d8efbf34b 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -412,10 +412,31 @@ imap_rescan (CamelFolder *folder, int exists, CamelException *ex) } static void +sync_message (CamelImapStore *store, CamelFolder *folder, + CamelMessageInfo *mi, CamelException *ex) +{ + CamelImapResponse *response; + char *flags; + + flags = imap_create_flag_list (mi->flags); + CAMEL_IMAP_STORE_LOCK (store, command_lock); + response = camel_imap_command (store, folder, ex, + "UID STORE %s FLAGS.SILENT %s", + camel_message_info_uid (mi), flags); + CAMEL_IMAP_STORE_UNLOCK (store, command_lock); + g_free (flags); + if (camel_exception_is_set (ex)) + return; + camel_imap_response_free (response); + + mi->flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED; + ((CamelImapMessageInfo *)mi)->server_flags = mi->flags; +} + +static void imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) { CamelImapStore *store = CAMEL_IMAP_STORE (folder->parent_store); - /*CamelImapFolder *imap_folder = CAMEL_IMAP_FOLDER (folder);*/ CamelImapResponse *response; int i, max; @@ -425,28 +446,12 @@ imap_sync (CamelFolder *folder, gboolean expunge, CamelException *ex) CamelMessageInfo *info; info = camel_folder_summary_index (folder->summary, i); - if (info && (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) { - char *flags; - - flags = imap_create_flag_list (info->flags); - if (flags) { - CAMEL_IMAP_STORE_LOCK(store, command_lock); - response = camel_imap_command ( - store, folder, ex, - "UID STORE %s FLAGS.SILENT %s", - camel_message_info_uid(info), flags); - CAMEL_IMAP_STORE_UNLOCK(store, command_lock); - - g_free (flags); - if (!response) { - camel_folder_summary_info_free(folder->summary, info); - return; - } - camel_imap_response_free (response); - } - info->flags &= ~CAMEL_MESSAGE_FOLDER_FLAGGED; - } + if (info && (info->flags & CAMEL_MESSAGE_FOLDER_FLAGGED)) + sync_message (store, folder, info, ex); camel_folder_summary_info_free(folder->summary, info); + + if (camel_exception_is_set (ex)) + return; } if (expunge) { @@ -549,28 +554,40 @@ imap_copy_message_to (CamelFolder *source, const char *uid, { CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store); CamelImapResponse *response; - + CamelMessageInfo *mi; + + mi = camel_folder_summary_uid (source->summary, uid); + g_return_if_fail (mi != NULL); + + /* Sync message flags if needed. */ + if (mi->flags & CAMEL_MESSAGE_FOLDER_FLAGGED) + sync_message (store, source, mi, ex); + camel_folder_summary_info_free (source->summary, mi); + + if (camel_exception_is_set (ex)) + return; + + /* Now copy it */ CAMEL_IMAP_STORE_LOCK(store, command_lock); response = camel_imap_command (store, source, ex, "UID COPY %s %S", uid, destination->full_name); CAMEL_IMAP_STORE_UNLOCK(store, command_lock); + if (camel_exception_is_set (ex)) + return; + camel_imap_response_free (response); -} + + /* Force the destination folder to notice its new messages. */ + response = camel_imap_command (store, destination, NULL, "NOOP"); + camel_imap_response_free (response); + } static void imap_move_message_to (CamelFolder *source, const char *uid, CamelFolder *destination, CamelException *ex) { - CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store); - CamelImapResponse *response; - - CAMEL_IMAP_STORE_LOCK(store, command_lock); - response = camel_imap_command (store, source, ex, "UID COPY %s %S", - uid, destination->full_name); - CAMEL_IMAP_STORE_UNLOCK(store, command_lock); - camel_imap_response_free (response); - + imap_copy_message_to (source, uid, destination, ex); if (camel_exception_is_set (ex)) return; |