From 03f4b3a74c678e0bad0ea92fa0931c8e356b2c46 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 22 Oct 2003 05:27:25 +0000 Subject: handle destination of "" properly. (emc_popup_copy_folder_selected): 2003-10-22 Not Zed * mail-component.c (em_copy_folders): handle destination of "" properly. (emc_popup_copy_folder_selected): handle url->path properly, strip leading /. (em_copy_folders): if we just created a new folder on a subscribable store, subscribe to it. (em_copy_folders): handle nonselectable folders specially. svn path=/trunk/; revision=22973 --- mail/ChangeLog | 10 ++++++++ mail/mail-component.c | 63 +++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 58 insertions(+), 15 deletions(-) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index ea233bacd9..85189ae5a3 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,13 @@ +2003-10-22 Not Zed + + * mail-component.c (em_copy_folders): handle destination of "" + properly. + (emc_popup_copy_folder_selected): handle url->path properly, strip + leading /. + (em_copy_folders): if we just created a new folder on a + subscribable store, subscribe to it. + (em_copy_folders): handle nonselectable folders specially. + 2003-10-21 Jeffrey Stedfast * mail-component.c (drag_text_uri_list, folder_dragged_cb) diff --git a/mail/mail-component.c b/mail/mail-component.c index 4bffcb1e9b..bb0bc876d1 100644 --- a/mail/mail-component.c +++ b/mail/mail-component.c @@ -1481,12 +1481,13 @@ emc_popup_open_new(GtkWidget *w, MailComponent *mc) } #endif +/* FIXME: This must be done in another thread */ static void em_copy_folders(CamelStore *tostore, const char *tobase, CamelStore *fromstore, const char *frombase, int delete) { GString *toname, *fromname; CamelFolderInfo *fi; - GList *pending = NULL; + GList *pending = NULL, *deleting = NULL, *l; guint32 flags = CAMEL_STORE_FOLDER_INFO_RECURSIVE; CamelException *ex = camel_exception_new(); int fromlen; @@ -1508,7 +1509,7 @@ em_copy_folders(CamelStore *tostore, const char *tobase, CamelStore *fromstore, if (tmp == NULL) fromlen = 0; else - fromlen = tmp-frombase; + fromlen = tmp-frombase+1; printf("top name is '%s'\n", fi->full_name); @@ -1522,37 +1523,66 @@ em_copy_folders(CamelStore *tostore, const char *tobase, CamelStore *fromstore, if (info->child) pending = g_list_append(pending, info->child); - g_string_printf(toname, "%s/%s", tobase, info->full_name + fromlen); + if (tobase[0]) + g_string_printf(toname, "%s/%s", tobase, info->full_name + fromlen); + else + g_string_printf(toname, "%s", info->full_name + fromlen); printf("Copying from '%s' to '%s'\n", info->full_name, toname->str); /* This makes sure we create the same tree, e.g. from a nonselectable source */ /* Not sure if this is really the 'right thing', e.g. for spool stores, but it makes the ui work */ - fromfolder = camel_store_get_folder(fromstore, info->full_name, 0, ex); - tofolder = camel_store_get_folder(tostore, toname->str, CAMEL_STORE_FOLDER_CREATE, ex); - if (tofolder == NULL) { - if (fromfolder) + if ((info->flags & CAMEL_FOLDER_NOSELECT) == 0) { + printf("this folder is selectable\n"); + fromfolder = camel_store_get_folder(fromstore, info->full_name, 0, ex); + if (fromfolder == NULL) + goto exception; + + tofolder = camel_store_get_folder(tostore, toname->str, CAMEL_STORE_FOLDER_CREATE, ex); + if (tofolder == NULL) { camel_object_unref(fromfolder); - goto exception; - } + goto exception; + } + + if (camel_store_supports_subscriptions(tostore) + && !camel_store_folder_subscribed(tostore, toname->str)) + camel_store_subscribe_folder(tostore, toname->str, NULL); - if (fromfolder) { uids = camel_folder_get_uids(fromfolder); - camel_folder_transfer_messages_to(fromfolder, uids, tofolder, NULL, FALSE, ex); + camel_folder_transfer_messages_to(fromfolder, uids, tofolder, NULL, delete, ex); camel_folder_free_uids(fromfolder, uids); camel_object_unref(fromfolder); + camel_object_unref(tofolder); } - camel_object_unref(tofolder); + if (camel_exception_is_set(ex)) goto exception; + else if (delete) + deleting = g_list_prepend(deleting, info); + info = info->sibling; } } - camel_store_free_folder_info(fromstore, fi); + /* delete the folders in reverse order from how we copyied them, if we are deleting any */ + l = deleting; + while (l) { + CamelFolderInfo *info = l->data; + + printf("deleting folder '%s'\n", info->full_name); + + if (camel_store_supports_subscriptions(fromstore)) + camel_store_unsubscribe_folder(fromstore, info->full_name, NULL); + + camel_store_delete_folder(fromstore, info->full_name, NULL); + l = l->next; + } exception: + camel_store_free_folder_info(fromstore, fi); + g_list_free(deleting); + g_string_free(toname, TRUE); g_string_free(fromname, TRUE); done: @@ -1591,8 +1621,10 @@ emc_popup_copy_folder_selected(const char *uri, void *data) url = camel_url_new(uri, NULL); if (url->fragment) tobase = url->fragment; + else if (url->path && url->path[0]) + tobase = url->path+1; else - tobase = url->path; + tobase = ""; em_copy_folders(tostore, tobase, fromstore, frombase, d->delete); @@ -1704,6 +1736,7 @@ em_delete_rec(CamelStore *store, CamelFolderInfo *fi, CamelException *ex) printf("deleting folder '%s'\n", fi->full_name); + /* shouldn't camel do this itself? */ if (camel_store_supports_subscriptions(store)) camel_store_unsubscribe_folder(store, fi->full_name, NULL); @@ -1839,7 +1872,7 @@ emc_popup_rename_folder(GtkWidget *w, MailComponent *mc) e_notice(NULL, GTK_MESSAGE_ERROR, _("A folder named \"%s\" already exists. Please use a different name."), new); } else { - CamelStore *store; + CamelStore *store; CamelException *ex = camel_exception_new(); const char *oldpath, *newpath; -- cgit v1.2.3