aboutsummaryrefslogtreecommitdiffstats
path: root/mail/component-factory.c
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 /mail/component-factory.c
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
Diffstat (limited to 'mail/component-factory.c')
-rw-r--r--mail/component-factory.c114
1 files changed, 103 insertions, 11 deletions
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);