diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2004-04-09 02:23:29 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-04-09 02:23:29 +0800 |
commit | 7fecce2d23b2b565a40bd6cf4cc99a9456ffba74 (patch) | |
tree | 6e24ab9166749be51417a9129bea72968239feda /mail/em-folder-tree.c | |
parent | 0fa18252ba6d98e5085d2edbcf85dbcff89b57a4 (diff) | |
download | gsoc2013-evolution-7fecce2d23b2b565a40bd6cf4cc99a9456ffba74.tar.gz gsoc2013-evolution-7fecce2d23b2b565a40bd6cf4cc99a9456ffba74.tar.zst gsoc2013-evolution-7fecce2d23b2b565a40bd6cf4cc99a9456ffba74.zip |
We need to recursively copy the dragged folder tree over to the drop
2004-04-08 Jeffrey Stedfast <fejj@ximian.com>
* em-folder-tree.c (emft_drop_folder): We need to recursively copy
the dragged folder tree over to the drop location, not just the
parent folder. We also need to subscribe to the newly created
folder in some cases.
svn path=/trunk/; revision=25375
Diffstat (limited to 'mail/em-folder-tree.c')
-rw-r--r-- | mail/em-folder-tree.c | 63 |
1 files changed, 54 insertions, 9 deletions
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 102c87b65d..fdf75d9d17 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -745,6 +745,51 @@ emft_drop_uid_list(struct _DragDataReceivedAsync *m, CamelFolder *dest) } static void +emft_drop_folder_rec (CamelStore *store, CamelFolderInfo *fi, const char *parent_name, CamelException *ex) +{ + CamelFolder *src, *dest; + CamelFolderInfo *nfi; + char *new_name; + + while (fi != NULL) { + if (!(src = mail_tool_uri_to_folder (fi->uri, 0, ex))) + break; + + /* handles dropping to the root properly */ + if (parent_name[0]) + new_name = g_strdup_printf ("%s/%s", parent_name, src->name); + else + new_name = g_strdup (src->name); + + if ((nfi = camel_store_create_folder (store, parent_name, src->name, ex))) { + camel_store_free_folder_info (store, nfi); + + if (camel_store_supports_subscriptions (store)) + camel_store_subscribe_folder (store, new_name, ex); + + /* copy the folder to the new location */ + if ((dest = camel_store_get_folder (store, new_name, 0, ex))) { + GPtrArray *uids; + + uids = camel_folder_get_uids (src); + camel_folder_transfer_messages_to (src, uids, dest, NULL, FALSE, ex); + camel_folder_free_uids (src, uids); + + camel_object_unref (dest); + } + } + + camel_object_unref (src); + + if (fi->child) + emft_drop_folder_rec (store, fi->child, new_name, ex); + + g_free (new_name); + fi = fi->next; + } +} + +static void emft_drop_folder(struct _DragDataReceivedAsync *m) { CamelFolder *src; @@ -766,19 +811,19 @@ emft_drop_folder(struct _DragDataReceivedAsync *m) camel_store_rename_folder(m->store, src->full_name, new_name, &m->msg.ex); m->moved = !camel_exception_is_set (&m->msg.ex); } else { - CamelFolder *dest; + CamelFolderInfo *fi, *nfi; /* FIXME: should check we're not coming from a vfolder, otherwise bad stuff could happen */ - /* copy the folder to the new location */ - if ((dest = camel_store_get_folder(m->store, new_name, CAMEL_STORE_FOLDER_CREATE_EXCL, &m->msg.ex))) { - GPtrArray *uids; - - uids = camel_folder_get_uids (src); - camel_folder_transfer_messages_to (src, uids, dest, NULL, FALSE, &m->msg.ex); - camel_folder_free_uids (src, uids); + if ((fi = camel_store_get_folder_info (src->parent_store, src->full_name, CAMEL_STORE_FOLDER_INFO_FAST | + CAMEL_STORE_FOLDER_INFO_RECURSIVE, &m->msg.ex))) { + if (!(nfi = camel_store_get_folder_info (m->store, new_name, CAMEL_STORE_FOLDER_INFO_FAST, &m->msg.ex))) { + /* Good. The folder doesn't already exist... */ + camel_exception_clear (&m->msg.ex); + emft_drop_folder_rec (m->store, fi, m->full_name, &m->msg.ex); + } - camel_object_unref (dest); + camel_store_free_folder_info (src->parent_store, fi); } } |