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-vtrash-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-vtrash-folder.c')
-rw-r--r-- | camel/camel-vtrash-folder.c | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/camel/camel-vtrash-folder.c b/camel/camel-vtrash-folder.c index cb390eacda..5b09047abb 100644 --- a/camel/camel-vtrash-folder.c +++ b/camel/camel-vtrash-folder.c @@ -37,8 +37,7 @@ static CamelVeeFolderClass *camel_vtrash_folder_parent; static void vtrash_append_message (CamelFolder *folder, CamelMimeMessage *message, const CamelMessageInfo *info, CamelException *ex); -static void vtrash_copy_messages_to (CamelFolder *folder, GPtrArray *uids, CamelFolder *dest, CamelException *ex); -static void vtrash_move_messages_to (CamelFolder *folder, GPtrArray *uids, CamelFolder *dest, CamelException *ex); +static void vtrash_transfer_messages_to (CamelFolder *folder, GPtrArray *uids, CamelFolder *dest, gboolean delete_originals, CamelException *ex); static void camel_vtrash_folder_class_init (CamelVTrashFolderClass *klass) @@ -49,8 +48,7 @@ camel_vtrash_folder_class_init (CamelVTrashFolderClass *klass) CAMEL_VEE_FOLDER_CLASS (camel_type_get_global_classfuncs (camel_folder_get_type ())); folder_class->append_message = vtrash_append_message; - folder_class->copy_messages_to = vtrash_copy_messages_to; - folder_class->move_messages_to = vtrash_move_messages_to; + folder_class->transfer_messages_to = vtrash_transfer_messages_to; } static void @@ -109,26 +107,21 @@ vtrash_append_message (CamelFolder *folder, CamelMimeMessage *message, const Cam /* no-op */ } -static void -vtrash_copy_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex) -{ - /* don't allow the user to copy to or from the vtrash folder */ - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - _("You cannot copy messages from this trash folder.")); -} - -struct _move_data { +struct _transfer_data { CamelFolder *folder; CamelFolder *dest; GPtrArray *uids; + gboolean delete; }; static void -move_messages(CamelFolder *folder, struct _move_data *md, CamelException *ex) +transfer_messages(CamelFolder *folder, struct _transfer_data *md, CamelException *ex) { int i; - camel_folder_move_messages_to(md->folder, md->uids, md->dest, ex); + if (!camel_exception_is_set (ex)) + camel_folder_transfer_messages_to(md->folder, md->uids, md->dest, md->delete, ex); + for (i=0;i<md->uids->len;i++) g_free(md->uids->pdata[i]); g_ptr_array_free(md->uids, TRUE); @@ -137,18 +130,42 @@ move_messages(CamelFolder *folder, struct _move_data *md, CamelException *ex) } static void -vtrash_move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, CamelException *ex) +vtrash_transfer_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest, gboolean delete_originals, CamelException *ex) { CamelVeeMessageInfo *mi; int i; GHashTable *batch = NULL; const char *tuid; - struct _move_data *md; + struct _transfer_data *md; + + /* This is a special case of transfer_messages_to: Either the + * source or the destination is a vtrash folder (but not both + * since a store should never have more than one). + */ + + if (CAMEL_IS_VTRASH_FOLDER (dest)) { + /* Copy to trash is meaningless. */ + if (!delete_originals) + return; + + /* Move to trash is the same as deleting the message */ + for (i = 0; i < uids->len; i++) + camel_folder_delete_message (source, uids->pdata[i]); + return; + } + + g_return_if_fail (CAMEL_IS_VTRASH_FOLDER (source)); + + /* Moving/Copying from the trash to the original folder = undelete. + * Moving/Copying from the trash to a different folder = move/copy. + * + * Need to check this uid by uid, but we batch up the copies. + */ for (i = 0; i < uids->len; i++) { mi = (CamelVeeMessageInfo *)camel_folder_get_message_info (source, uids->pdata[i]); if (mi == NULL) { - g_warning ("Cannot find uid %s in source folder during move_to", (char *) uids->pdata[i]); + g_warning ("Cannot find uid %s in source folder during transfer", (char *) uids->pdata[i]); continue; } @@ -156,10 +173,6 @@ vtrash_move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest /* Just undelete the original message */ camel_folder_set_message_flags (source, uids->pdata[i], CAMEL_MESSAGE_DELETED, 0); } else { - /* This means that the user is trying to move the message - from the vTrash to a folder other than the original. - We batch them up as much as we can */ - if (batch == NULL) batch = g_hash_table_new(NULL, NULL); md = g_hash_table_lookup(batch, mi->folder); @@ -175,14 +188,13 @@ vtrash_move_messages_to (CamelFolder *source, GPtrArray *uids, CamelFolder *dest tuid = uids->pdata[i]; if (strlen(tuid)>8) tuid += 8; - printf("moving message uid '%s'\n", tuid); g_ptr_array_add(md->uids, g_strdup(tuid)); } camel_folder_free_message_info (source, (CamelMessageInfo *)mi); } if (batch) { - g_hash_table_foreach(batch, (GHFunc)move_messages, ex); + g_hash_table_foreach(batch, (GHFunc)transfer_messages, ex); g_hash_table_destroy(batch); } } |