From 6952dcb7c0821d705fad562ff5b96613b7c7b248 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Fri, 10 May 2002 16:44:36 +0000 Subject: 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 --- camel/providers/imap/camel-imap-folder.c | 82 +++++++++++++++++--------------- 1 file changed, 43 insertions(+), 39 deletions(-) (limited to 'camel/providers') diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index b654919e09..9baf2560aa 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -93,14 +93,18 @@ static void imap_append_offline (CamelFolder *folder, CamelMimeMessage *message, static void imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex); -static void imap_copy_online (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex); -static void imap_copy_offline (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex); -static void imap_copy_resyncing (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex); -static void imap_move_messages_to (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex); +static void imap_transfer_online (CamelFolder *source, GPtrArray *uids, + CamelFolder *destination, + gboolean delete_originals, + CamelException *ex); +static void imap_transfer_offline (CamelFolder *source, GPtrArray *uids, + CamelFolder *destination, + gboolean delete_originals, + CamelException *ex); +static void imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids, + CamelFolder *destination, + gboolean delete_originals, + CamelException *ex); /* searching */ static GPtrArray *imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex); @@ -121,7 +125,6 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class) /* virtual method overload */ camel_folder_class->get_message = imap_get_message; - camel_folder_class->move_messages_to = imap_move_messages_to; camel_folder_class->rename = imap_rename; camel_folder_class->search_by_expression = imap_search_by_expression; camel_folder_class->search_by_uids = imap_search_by_uids; @@ -141,9 +144,9 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class) camel_disco_folder_class->append_online = imap_append_online; camel_disco_folder_class->append_offline = imap_append_offline; camel_disco_folder_class->append_resyncing = imap_append_resyncing; - camel_disco_folder_class->copy_online = imap_copy_online; - camel_disco_folder_class->copy_offline = imap_copy_offline; - camel_disco_folder_class->copy_resyncing = imap_copy_resyncing; + camel_disco_folder_class->transfer_online = imap_transfer_online; + camel_disco_folder_class->transfer_offline = imap_transfer_offline; + camel_disco_folder_class->transfer_resyncing = imap_transfer_resyncing; camel_disco_folder_class->cache_message = imap_cache_message; } @@ -1123,8 +1126,9 @@ imap_append_resyncing (CamelFolder *folder, CamelMimeMessage *message, static void -imap_copy_offline (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex) +imap_transfer_offline (CamelFolder *source, GPtrArray *uids, + CamelFolder *destination, gboolean delete_originals, + CamelException *ex) { CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store); CamelImapMessageCache *sc = CAMEL_IMAP_FOLDER (source)->cache; @@ -1164,6 +1168,9 @@ imap_copy_offline (CamelFolder *source, GPtrArray *uids, camel_folder_change_info_add_uid (changes, destuid); g_free (destuid); + + if (delete_originals) + camel_folder_delete_message (source, uid); } CAMEL_IMAP_FOLDER_UNLOCK (destination, cache_lock); @@ -1174,8 +1181,8 @@ imap_copy_offline (CamelFolder *source, GPtrArray *uids, camel_folder_change_info_free (changes); camel_disco_diary_log (CAMEL_DISCO_STORE (store)->diary, - CAMEL_DISCO_DIARY_FOLDER_COPY, - source, destination, uids); + CAMEL_DISCO_DIARY_FOLDER_TRANSFER, + source, destination, uids, delete_originals); } static void @@ -1257,11 +1264,12 @@ do_copy (CamelFolder *source, GPtrArray *uids, } static void -imap_copy_online (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex) +imap_transfer_online (CamelFolder *source, GPtrArray *uids, + CamelFolder *destination, gboolean delete_originals, + CamelException *ex) { CamelImapStore *store = CAMEL_IMAP_STORE (source->parent_store); - int count; + int count, i; /* Sync message flags if needed. */ imap_sync_online (source, ex); @@ -1279,11 +1287,17 @@ imap_copy_online (CamelFolder *source, GPtrArray *uids, if (store->current_folder != destination || camel_folder_summary_count (destination->summary) == count) camel_folder_refresh_info (destination, ex); + + if (delete_originals) { + for (i = 0; i < uids->len; i++) + camel_folder_delete_message (source, uids->pdata[i]); + } } static void -imap_copy_resyncing (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex) +imap_transfer_resyncing (CamelFolder *source, GPtrArray *uids, + CamelFolder *destination, gboolean delete_originals, + CamelException *ex) { CamelDiscoDiary *diary = CAMEL_DISCO_STORE (source->parent_store)->diary; GPtrArray *realuids; @@ -1313,6 +1327,9 @@ imap_copy_resyncing (CamelFolder *source, GPtrArray *uids, break; } g_ptr_array_add (realuids, (char *)uid); + + if (delete_originals) + camel_folder_delete_message (source, uid); } /* If we saw any real UIDs, do a COPY */ @@ -1327,17 +1344,20 @@ imap_copy_resyncing (CamelFolder *source, GPtrArray *uids, while (i < uids->len && !isdigit (*(unsigned char *)(uids->pdata[i])) && !camel_exception_is_set (ex)) { - message = camel_folder_get_message (source, uids->pdata[i], NULL); + uid = uids->pdata[i]; + message = camel_folder_get_message (source, uid, NULL); if (!message) { /* Message must have been expunged */ continue; } - info = camel_folder_get_message_info (source, uids->pdata[i]); + info = camel_folder_get_message_info (source, uid); g_return_if_fail (info != NULL); imap_append_online (destination, message, info, ex); camel_folder_free_message_info (source, info); camel_object_unref (CAMEL_OBJECT (message)); + if (delete_originals) + camel_folder_delete_message (source, uid); i++; } } @@ -1345,22 +1365,6 @@ imap_copy_resyncing (CamelFolder *source, GPtrArray *uids, g_ptr_array_free (realuids, FALSE); } -static void -imap_move_messages_to (CamelFolder *source, GPtrArray *uids, - CamelFolder *destination, CamelException *ex) -{ - int i; - - /* do it this way (as opposed to camel_folder_copy_messages_to) - * to avoid locking issues */ - CF_CLASS (source)->copy_messages_to (source, uids, destination, ex); - if (camel_exception_is_set (ex)) - return; - - for (i = 0; i < uids->len; i++) - camel_folder_delete_message (source, uids->pdata[i]); -} - static GPtrArray * imap_search_by_expression (CamelFolder *folder, const char *expression, CamelException *ex) { -- cgit