diff options
author | Dan Winship <danw@src.gnome.org> | 2002-05-11 00:44:36 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2002-05-11 00:44:36 +0800 |
commit | 6952dcb7c0821d705fad562ff5b96613b7c7b248 (patch) | |
tree | 8610ea39d3c105a615318c00145897adb5dc00cf /camel/camel-folder.c | |
parent | 409f147b81748829457ee9110ccd0488ad9bfbf4 (diff) | |
download | gsoc2013-evolution-6952dcb7c0821d705fad562ff5b96613b7c7b248.tar.gz gsoc2013-evolution-6952dcb7c0821d705fad562ff5b96613b7c7b248.tar.zst gsoc2013-evolution-6952dcb7c0821d705fad562ff5b96613b7c7b248.zip |
Replace copy_messages_to and move_messages_to with a single function that
* camel-folder.c (camel_folder_transfer_messages_to): Replace
copy_messages_to and move_messages_to with a single function that
just takes a "delete_originals" flag. Also, use the vtrash
implementation if *either* folder is a vtrash.
(transfer_messages_to): Make this use camel_operation_progress
(previously move_messages_to did but copy_messages_to didn't), and
freeze/thaw the folder(s) if doing multiple messages.
* camel-vtrash-folder.c (vtrash_transfer_messages_to): Update for
move/copy merge. Move the "move messages into vtrash" code here
from mail-ops.c. Now all of the vtrash move/copy special casing is
in camel instead of half of it being here and half in mail/. (This
should also make it so that "Move to Trash" will work in filter
rules.)
* camel-vee-folder.c (vee_transfer_messages_to): Make this just
return an exception, since it will only be called when trying to
move/copy messages from one vfolder to another.
(vee_append_message): Add this too so we get a nicer error message
than the default "unimplemented" one in camel-folder.c.
* camel-digest-folder.c: Replace copy_messages_to and
move_messages_to with transfer_messages_to.
* camel-disco-folder.c: Likewise
* camel-disco-diary.c (camel_disco_diary_log,
camel_disco_diary_replay): replace MOVE/COPY with TRANSFER.
* providers/imap/camel-imap-folder.c (imap_transfer_offline,
imap_transfer_online, imap_transfer_resyncing): Update for
changes. (This ends up being a bit more complicated than it was
before for now, but later disconnected operation changes should
resimplify it.)
* camel-filter-driver.c (camel_filter_driver_filter_message,
do_copy, do_move): Use transfer_messages_to instead of copy.
svn path=/trunk/; revision=16744
Diffstat (limited to 'camel/camel-folder.c')
-rw-r--r-- | camel/camel-folder.c | 137 |
1 files changed, 39 insertions, 98 deletions
diff --git a/camel/camel-folder.c b/camel/camel-folder.c index e4edebf257..554c43a7f1 100644 --- a/camel/camel-folder.c +++ b/camel/camel-folder.c @@ -38,6 +38,7 @@ #include "camel-session.h" #include "camel-filter-driver.h" #include "camel-private.h" +#include "camel-vtrash-folder.h" #define d(x) #define w(x) @@ -96,8 +97,7 @@ static GPtrArray *search_by_expression (CamelFolder *folder, const char *e static GPtrArray *search_by_uids (CamelFolder *folder, const char *exp, GPtrArray *uids, CamelException *ex); static void search_free (CamelFolder * folder, GPtrArray *result); -static void copy_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex); -static void move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex); +static void transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, gboolean delete_originals, CamelException *ex); static void delete (CamelFolder *folder); static void folder_rename (CamelFolder *folder, const char *new); @@ -147,8 +147,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class) camel_folder_class->get_message_info = get_message_info; camel_folder_class->ref_message_info = ref_message_info; camel_folder_class->free_message_info = free_message_info; - camel_folder_class->copy_messages_to = copy_messages_to; - camel_folder_class->move_messages_to = move_messages_to; + camel_folder_class->transfer_messages_to = transfer_messages_to; camel_folder_class->delete = delete; camel_folder_class->rename = folder_rename; camel_folder_class->freeze = freeze; @@ -1138,7 +1137,7 @@ camel_folder_search_free (CamelFolder *folder, GPtrArray *result) static void -copy_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, CamelException *ex) +transfer_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, gboolean delete_original, CamelException *ex) { CamelMimeMessage *msg; CamelMessageInfo *info = NULL; @@ -1161,84 +1160,10 @@ copy_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, CamelE camel_folder_append_message (dest, msg, info, ex); camel_object_unref (CAMEL_OBJECT (msg)); - if (info) { - if (source->folder_flags & CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY) - CF_CLASS (source)->free_message_info (source, info); - else - camel_message_info_free (info); - } -} - -static void -copy_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex) -{ - int i; - - for (i = 0; i < uids->len && !camel_exception_is_set (ex); i++) - copy_message_to (source, uids->pdata[i], dest, ex); -} - -/** - * camel_folder_copy_messages_to: - * @source: source folder - * @uids: message UIDs in @source - * @dest: destination folder - * @ex: a CamelException - * - * This copies messages from one folder to another. If the @source and - * @dest folders have the same parent_store, this may be more efficient - * than a camel_folder_append_message(). - **/ -void -camel_folder_copy_messages_to (CamelFolder *source, GPtrArray *uids, - CamelFolder *dest, CamelException *ex) -{ - g_return_if_fail (CAMEL_IS_FOLDER (source)); - g_return_if_fail (CAMEL_IS_FOLDER (dest)); - g_return_if_fail (uids != NULL); - - if (source == dest || uids->len == 0) { - /* source and destination folders are the same, or no work to do, do nothing. */ - return; - } - - CAMEL_FOLDER_LOCK(source, lock); - - if (source->parent_store == dest->parent_store) - CF_CLASS (source)->copy_messages_to (source, uids, dest, ex); - else - copy_messages_to (source, uids, dest, ex); - - CAMEL_FOLDER_UNLOCK(source, lock); -} - -static void -move_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, CamelException *ex) -{ - CamelMimeMessage *msg; - CamelMessageInfo *info = NULL; - - /* Default implementation. */ - - msg = CF_CLASS (source)->get_message (source, uid, ex); - if (!msg) - return; - - if (source->folder_flags & CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY) - info = CF_CLASS (source)->get_message_info (source, uid); - else - info = camel_message_info_new_from_header (((CamelMimePart *)msg)->headers); - - /* we don't want to retain the deleted flag */ - if (info && info->flags & CAMEL_MESSAGE_DELETED) - info->flags = info->flags & ~CAMEL_MESSAGE_DELETED; - - camel_folder_append_message (dest, msg, info, ex); - camel_object_unref (CAMEL_OBJECT (msg)); - if (!camel_exception_is_set (ex)) + if (delete_original && !camel_exception_is_set (ex)) camel_folder_set_message_flags (source, uid, CAMEL_MESSAGE_DELETED|CAMEL_MESSAGE_SEEN, ~0); - + if (info) { if (source->folder_flags & CAMEL_FOLDER_HAS_SUMMARY_CAPABILITY) CF_CLASS (source)->free_message_info (source, info); @@ -1248,62 +1173,78 @@ move_message_to (CamelFolder *source, const char *uid, CamelFolder *dest, CamelE } static void -move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex) +transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, gboolean delete_originals, CamelException *ex) { - int i; CamelException local; + int i; camel_exception_init(&local); if (ex == NULL) ex = &local; - camel_operation_start(NULL, _("Moving messages")); + camel_operation_start(NULL, delete_originals ? _("Moving messages") : _("Copying messages")); + if (uids->len > 1) { + camel_folder_freeze(dest); + if (delete_originals) + camel_folder_freeze(source); + } for (i = 0; i < uids->len && !camel_exception_is_set (ex); i++) { - move_message_to (source, uids->pdata[i], dest, ex); + transfer_message_to (source, uids->pdata[i], dest, delete_originals, ex); camel_operation_progress(NULL, i * 100 / uids->len); } + if (uids->len > 1) { + camel_folder_thaw(dest); + if (delete_originals) + camel_folder_thaw(source); + } camel_operation_end(NULL); camel_exception_clear(&local); } /** - * camel_folder_move_messages_to: + * camel_folder_transfer_messages_to: * @source: source folder * @uids: message UIDs in @source * @dest: destination folder + * @delete_originals: whether or not to delete the original messages * @ex: a CamelException * - * This moves a message from one folder to another. If the @source and - * @dest folders have the same parent_store, this may be more efficient - * than a camel_folder_append_message() followed by - * camel_folder_delete_message(). + * This copies or moves messages from one folder to another. If the + * @source and @dest folders have the same parent_store, this may be + * more efficient than using camel_folder_append_message(). **/ void -camel_folder_move_messages_to (CamelFolder *source, GPtrArray *uids, - CamelFolder *dest, CamelException *ex) +camel_folder_transfer_messages_to (CamelFolder *source, GPtrArray *uids, + CamelFolder *dest, gboolean delete_originals, + CamelException *ex) { g_return_if_fail (CAMEL_IS_FOLDER (source)); g_return_if_fail (CAMEL_IS_FOLDER (dest)); g_return_if_fail (uids != NULL); if (source == dest || uids->len == 0) { - /* source and destination folders are the same, or no work to do, nothing to do. */ + /* source and destination folders are the same, or no work to do, do nothing. */ return; } CAMEL_FOLDER_LOCK(source, lock); - if (source->parent_store == dest->parent_store) - CF_CLASS (source)->move_messages_to (source, uids, dest, ex); - else - move_messages_to (source, uids, dest, ex); + if (source->parent_store == dest->parent_store) { + /* If either folder is a vtrash, we need to use the + * vtrash transfer method. + */ + if (CAMEL_IS_VTRASH_FOLDER (dest)) + CF_CLASS (dest)->transfer_messages_to (source, uids, dest, delete_originals, ex); + else + CF_CLASS (source)->transfer_messages_to (source, uids, dest, delete_originals, ex); + } else + transfer_messages_to (source, uids, dest, delete_originals, ex); CAMEL_FOLDER_UNLOCK(source, lock); } - static void delete (CamelFolder *folder) { |