aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-05-24 04:56:57 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-05-24 04:56:57 +0800
commit76f220863e83aa27c4f2d9efe214f697885072e0 (patch)
tree296850387147ef496b6b3a1054fc1e2cfa9e7ace
parentcd75a45fc98b686fc180feb3209bbfd2e1c4413b (diff)
downloadgsoc2013-evolution-76f220863e83aa27c4f2d9efe214f697885072e0.tar
gsoc2013-evolution-76f220863e83aa27c4f2d9efe214f697885072e0.tar.gz
gsoc2013-evolution-76f220863e83aa27c4f2d9efe214f697885072e0.tar.bz2
gsoc2013-evolution-76f220863e83aa27c4f2d9efe214f697885072e0.tar.lz
gsoc2013-evolution-76f220863e83aa27c4f2d9efe214f697885072e0.tar.xz
gsoc2013-evolution-76f220863e83aa27c4f2d9efe214f697885072e0.tar.zst
gsoc2013-evolution-76f220863e83aa27c4f2d9efe214f697885072e0.zip
New async function to remove a folder. God knows if it does what the
2001-05-23 Jeffrey Stedfast <fejj@ximian.com> * 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. * 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=9952
-rw-r--r--mail/ChangeLog12
-rw-r--r--mail/component-factory.c114
-rw-r--r--mail/mail-ops.c81
-rw-r--r--mail/mail-ops.h5
4 files changed, 201 insertions, 11 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index c58dbacf03..085bc9211a 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,15 @@
+2001-05-23 Jeffrey Stedfast <fejj@ximian.com>
+
+ * 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.
+
+ * 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.
+
2001-05-22 Jeffrey Stedfast <fejj@ximian.com>
* mail-config.c (mail_config_write_on_exit): Save the
diff --git a/mail/component-factory.c b/mail/component-factory.c
index 0935247e7d..6bfd489bff 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -144,7 +144,7 @@ create_folder (EvolutionShellComponent *shell_component,
{
char *uri;
CORBA_Environment ev;
-
+
CORBA_exception_init(&ev);
if (!strcmp (type, "mail")) {
uri = g_strdup_printf ("mbox://%s", physical_uri);
@@ -159,6 +159,45 @@ create_folder (EvolutionShellComponent *shell_component,
CORBA_exception_free(&ev);
}
+static void
+do_remove_folder (char *uri, gboolean removed, void *data)
+{
+ GNOME_Evolution_ShellComponentListener listener = data;
+ GNOME_Evolution_ShellComponentListener_Result result;
+ CORBA_Environment ev;
+
+ if (removed)
+ result = GNOME_Evolution_ShellComponentListener_OK;
+ else
+ result = GNOME_Evolution_ShellComponentListener_INVALID_URI;
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_ShellComponentListener_notifyResult (listener, result, &ev);
+ CORBA_Object_release (listener, &ev);
+ CORBA_exception_free (&ev);
+}
+
+static void
+remove_folder (EvolutionShellComponent *shell_component,
+ const char *physical_uri,
+ const GNOME_Evolution_ShellComponentListener listener,
+ void *closure)
+{
+ CORBA_Environment ev;
+ char *uri;
+
+ CORBA_exception_init (&ev);
+
+ /* FIXME: what if the folder is mh or maildir? */
+ /* ?? maybe we should just rm -rf the physical_uri?? */
+ uri = g_strdup_printf ("mbox://%s", physical_uri);
+ mail_remove_folder (uri, do_remove_folder, CORBA_Object_duplicate (listener, &ev));
+ GNOME_Evolution_ShellComponentListener_notifyResult (listener,
+ GNOME_Evolution_ShellComponentListener_OK, &ev);
+
+ CORBA_exception_free (&ev);
+}
+
static struct {
char *name, **uri;
CamelFolder **folder;
@@ -290,16 +329,16 @@ component_fn (BonoboGenericFactory *factory, void *closure)
{
EvolutionShellComponent *shell_component;
MailOfflineHandler *offline_handler;
-
+
shell_component = evolution_shell_component_new (folder_types,
create_view,
create_folder,
- NULL, /* remove_folder_fn */
+ remove_folder,
NULL, /* xfer_folder_fn */
NULL, /* populate_folder_context_menu_fn */
NULL, /* get_dnd_selection_fn */
NULL);
-
+
gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set",
GTK_SIGNAL_FUNC (owner_set_cb), NULL);
gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset",
@@ -308,10 +347,10 @@ component_fn (BonoboGenericFactory *factory, void *closure)
GTK_SIGNAL_FUNC (debug_cb), NULL);
gtk_signal_connect (GTK_OBJECT (shell_component), "destroy",
GTK_SIGNAL_FUNC (owner_unset_cb), NULL);
-
+
offline_handler = mail_offline_handler_new ();
bonobo_object_add_interface (BONOBO_OBJECT (shell_component), BONOBO_OBJECT (offline_handler));
-
+
return BONOBO_OBJECT (shell_component);
}
@@ -349,30 +388,30 @@ storage_create_folder (EvolutionStorage *storage, const char *path,
CamelURL *url;
CamelException ex;
CamelFolderInfo *fi;
-
+
if (strcmp (type, "mail") != 0)
return EVOLUTION_STORAGE_ERROR_UNSUPPORTED_TYPE;
name = strrchr (path, '/');
if (!name++)
return EVOLUTION_STORAGE_ERROR_INVALID_URI;
-
+
camel_exception_init (&ex);
if (*parent_physical_uri) {
url = camel_url_new (parent_physical_uri, NULL);
if (!url)
return EVOLUTION_STORAGE_ERROR_INVALID_URI;
-
+
fi = camel_store_create_folder (store, url->path + 1, name, &ex);
camel_url_free (url);
} else
fi = camel_store_create_folder (store, NULL, name, &ex);
-
+
if (camel_exception_is_set (&ex)) {
/* FIXME: do better than this */
camel_exception_clear (&ex);
return EVOLUTION_STORAGE_ERROR_INVALID_URI;
}
-
+
if (camel_store_supports_subscriptions (store))
camel_store_subscribe_folder (store, fi->full_name, NULL);
@@ -383,6 +422,56 @@ storage_create_folder (EvolutionStorage *storage, const char *path,
return EVOLUTION_STORAGE_OK;
}
+static int
+storage_remove_folder (EvolutionStorage *storage, const char *path,
+ const char *physical_uri, gpointer user_data)
+{
+ CamelStore *store = user_data;
+ CamelURL *url = NULL;
+ CamelFolderInfo *fi;
+ CamelException ex;
+
+ g_warning ("storage_remove_folder: path=\"%s\"; uri=\"%s\"", path, physical_uri);
+
+ if (*physical_uri) {
+ url = camel_url_new (physical_uri, NULL);
+ if (!url)
+ return EVOLUTION_STORAGE_ERROR_INVALID_URI;
+ } else {
+ if (!*path)
+ return EVOLUTION_STORAGE_ERROR_INVALID_URI;
+ }
+
+ camel_exception_init (&ex);
+ fi = camel_store_get_folder_info (store, url ? url->path + 1 : path + 1,
+ CAMEL_STORE_FOLDER_INFO_FAST, &ex);
+ if (url)
+ camel_url_free (url);
+ if (camel_exception_is_set (&ex))
+ goto exception;
+
+ camel_store_delete_folder (store, fi->full_name, &ex);
+ if (camel_exception_is_set (&ex))
+ goto exception;
+
+ if (camel_store_supports_subscriptions (store))
+ camel_store_unsubscribe_folder (store, fi->full_name, NULL);
+
+ folder_deleted (store, fi);
+
+ camel_store_free_folder_info (store, fi);
+
+ return EVOLUTION_STORAGE_OK;
+
+ exception:
+ /* FIXME: do better than this... */
+
+ if (fi)
+ camel_store_free_folder_info (store, fi);
+
+ return EVOLUTION_STORAGE_ERROR_INVALID_URI;
+}
+
static void
add_storage (const char *name, const char *uri, CamelService *store,
GNOME_Evolution_Shell corba_shell, CamelException *ex)
@@ -394,6 +483,9 @@ add_storage (const char *name, const char *uri, CamelService *store,
gtk_signal_connect (GTK_OBJECT (storage), "create_folder",
GTK_SIGNAL_FUNC (storage_create_folder),
store);
+ gtk_signal_connect (GTK_OBJECT (storage), "remove_folder",
+ GTK_SIGNAL_FUNC (storage_remove_folder),
+ store);
res = evolution_storage_register_on_shell (storage, corba_shell);
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 5b106636dc..23c0b047db 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1382,6 +1382,87 @@ mail_create_folder(const char *uri, void (*done) (char *uri, CamelFolder *folder
e_thread_put(mail_thread_new, (EMsg *)m);
}
+/* ** REMOVE FOLDER ******************************************************* */
+
+struct _remove_folder_msg {
+ struct _mail_msg msg;
+
+ char *uri;
+ gboolean removed;
+ void (*done) (char *uri, gboolean removed, void *data);
+ void *data;
+};
+
+static char *
+remove_folder_desc (struct _mail_msg *mm, int done)
+{
+ struct _remove_folder_msg *m = (struct _remove_folder_msg *)mm;
+
+ return g_strdup_printf (_("Removing folder %s"), m->uri);
+}
+
+static void
+remove_folder_get (struct _mail_msg *mm)
+{
+ struct _remove_folder_msg *m = (struct _remove_folder_msg *)mm;
+ CamelStore *store;
+ CamelURL *url;
+
+ m->removed = FALSE;
+
+ camel_operation_register (mm->cancel);
+
+ store = camel_session_get_store (session, m->uri, &mm->ex);
+ if (!store)
+ goto done;
+
+ url = camel_url_new (m->uri, NULL);
+ camel_store_delete_folder (store, url->path + 1, &mm->ex);
+ m->removed = !camel_exception_is_set (&mm->ex);
+ camel_object_unref (CAMEL_OBJECT (store));
+ camel_url_free (url);
+
+ done:
+ camel_operation_unregister (mm->cancel);
+}
+
+static void
+remove_folder_got (struct _mail_msg *mm)
+{
+ struct _remove_folder_msg *m = (struct _remove_folder_msg *)mm;
+
+ if (m->done)
+ m->done (m->uri, m->removed, m->data);
+}
+
+static void
+remove_folder_free (struct _mail_msg *mm)
+{
+ struct _remove_folder_msg *m = (struct _remove_folder_msg *)mm;
+
+ g_free (m->uri);
+}
+
+static struct _mail_msg_op remove_folder_op = {
+ remove_folder_desc,
+ remove_folder_get,
+ remove_folder_got,
+ remove_folder_free,
+};
+
+void
+mail_remove_folder (const char *uri, void (*done) (char *uri, gboolean removed, void *data), void *data)
+{
+ struct _remove_folder_msg *m;
+
+ m = mail_msg_new (&remove_folder_op, NULL, sizeof (*m));
+ m->uri = g_strdup (uri);
+ m->data = data;
+ m->done = done;
+
+ e_thread_put (mail_thread_new, (EMsg *)m);
+}
+
/* ** SYNC FOLDER ********************************************************* */
struct _sync_folder_msg {
diff --git a/mail/mail-ops.h b/mail/mail-ops.h
index e19051ab1b..305dae6b77 100644
--- a/mail/mail-ops.h
+++ b/mail/mail-ops.h
@@ -95,6 +95,11 @@ void mail_create_folder (const char *uri,
void (*done) (char *uri, CamelFolder *folder, void *data),
void *data);
+/* remove an existing folder */
+void mail_remove_folder (const char *uri,
+ void (*done) (char *uri, gboolean removed, void *data),
+ void *data);
+
/* save messages */
int mail_save_messages (CamelFolder *folder, GPtrArray *uids, const char *path,
void (*done) (CamelFolder *folder, GPtrArray *uids, char *path, void *data),