aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-ops.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-05-24 06:43:03 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-05-24 06:43:03 +0800
commita2f50bb029eaa8b8c0804a5788302dc15105a3ed (patch)
tree3ffd58a9d131699dc756697d387319758a9f371b /mail/mail-ops.c
parent30dce44f3897757c3a1cb2ecfe215a6c628e9024 (diff)
downloadgsoc2013-evolution-a2f50bb029eaa8b8c0804a5788302dc15105a3ed.tar.gz
gsoc2013-evolution-a2f50bb029eaa8b8c0804a5788302dc15105a3ed.tar.zst
gsoc2013-evolution-a2f50bb029eaa8b8c0804a5788302dc15105a3ed.zip
New function that the shell component calls to copy/move a folder.
2001-05-23 Jeffrey Stedfast <fejj@ximian.com> * component-factory.c (xfer_folder): New function that the shell component calls to copy/move a folder. (component_fn): Set the xfer_folder_fn argument. * mail-ops.c (mail_remove_folder): New async function to remove a folder. God knows if it does what the ShellComponent needs or not yet. (mail_xfer_folder): Yet another yummy async function to move or copy a folder to a new location. * component-factory.c (storage_remove_folder): New function for removing folders. (remove_folder): New function that the shell component calls to delete a folder. (component_fn): Set the remove_folder_fn argument. svn path=/trunk/; revision=9954
Diffstat (limited to 'mail/mail-ops.c')
-rw-r--r--mail/mail-ops.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 23c0b047db..4b99bc76ac 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1463,6 +1463,116 @@ mail_remove_folder (const char *uri, void (*done) (char *uri, gboolean removed,
e_thread_put (mail_thread_new, (EMsg *)m);
}
+/* ** XFER FOLDER ******************************************************* */
+
+struct _xfer_folder_msg {
+ struct _mail_msg msg;
+
+ char *src_uri;
+ char *dest_uri;
+ gboolean remove;
+ CamelFolder *folder;
+ void (*done) (char *src_uri, char *dest_uri, gboolean remove, CamelFolder *folder, void *data);
+ void *data;
+};
+
+static char *
+xfer_folder_desc (struct _mail_msg *mm, int done)
+{
+ struct _xfer_folder_msg *m = (struct _xfer_folder_msg *)mm;
+
+ if (m->remove)
+ return g_strdup_printf (_("Moving folder %s to %s"), m->src_uri, m->dest_uri);
+ else
+ return g_strdup_printf (_("Copying folder %s to %s"), m->src_uri, m->dest_uri);
+}
+
+static void
+xfer_folder_get (struct _mail_msg *mm)
+{
+ struct _xfer_folder_msg *m = (struct _xfer_folder_msg *)mm;
+ CamelFolder *src, *dest = NULL;
+ GPtrArray *uids;
+
+ camel_operation_register (mm->cancel);
+
+ src = mail_tool_uri_to_folder (m->src_uri, &mm->ex);
+ if (camel_exception_is_set (&mm->ex))
+ goto done;
+
+ dest = mail_tool_get_folder_from_urlname (m->dest_uri, "mbox",
+ CAMEL_STORE_FOLDER_CREATE | CAMEL_STORE_FOLDER_BODY_INDEX,
+ &mm->ex);
+ if (camel_exception_is_set (&mm->ex))
+ goto done;
+
+ uids = camel_folder_get_uids (src);
+ if (m->remove)
+ camel_folder_move_messages_to (src, uids, dest, &mm->ex);
+ else
+ camel_folder_copy_messages_to (src, uids, dest, &mm->ex);
+
+ camel_folder_free_uids (src, uids);
+
+ if (camel_exception_is_set (&mm->ex))
+ goto done;
+
+ if (m->remove)
+ camel_store_delete_folder (src->parent_store, src->full_name, &mm->ex);
+
+ done:
+ if (src)
+ camel_object_unref (CAMEL_OBJECT (src));
+
+ m->folder = dest;
+
+ camel_operation_unregister (mm->cancel);
+}
+
+static void
+xfer_folder_got (struct _mail_msg *mm)
+{
+ struct _xfer_folder_msg *m = (struct _xfer_folder_msg *)mm;
+
+ if (m->done)
+ m->done (m->src_uri, m->dest_uri, m->remove, m->folder, m->data);
+}
+
+static void
+xfer_folder_free (struct _mail_msg *mm)
+{
+ struct _xfer_folder_msg *m = (struct _xfer_folder_msg *)mm;
+
+ g_free (m->src_uri);
+ g_free (m->dest_uri);
+ if (m->folder)
+ camel_object_unref (CAMEL_OBJECT (m->folder));
+}
+
+static struct _mail_msg_op xfer_folder_op = {
+ xfer_folder_desc,
+ xfer_folder_get,
+ xfer_folder_got,
+ xfer_folder_free,
+};
+
+void
+mail_xfer_folder (const char *src_uri, const char *dest_uri, gboolean remove_source,
+ void (*done) (char *src_uri, char *dest_uri, gboolean remove, CamelFolder *folder, void *data),
+ void *data)
+{
+ struct _xfer_folder_msg *m;
+
+ m = mail_msg_new (&xfer_folder_op, NULL, sizeof(*m));
+ m->src_uri = g_strdup (src_uri);
+ m->dest_uri = g_strdup (dest_uri);
+ m->remove = remove_source;
+ m->data = data;
+ m->done = done;
+
+ e_thread_put (mail_thread_new, (EMsg *)m);
+}
+
/* ** SYNC FOLDER ********************************************************* */
struct _sync_folder_msg {