aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Leach <jleach@src.gnome.org>2001-06-22 00:03:26 +0800
committerJacob Leach <jleach@src.gnome.org>2001-06-22 00:03:26 +0800
commit09b9a3a4da1d8827a39fc2a7aad3402ff25250bf (patch)
tree8b0702aa552ef06bc35031eb7682af07e8bcb38a
parent6138aaf220f0de9222574436e10fa9c56a6e1f39 (diff)
downloadgsoc2013-evolution-09b9a3a4da1d8827a39fc2a7aad3402ff25250bf.tar
gsoc2013-evolution-09b9a3a4da1d8827a39fc2a7aad3402ff25250bf.tar.gz
gsoc2013-evolution-09b9a3a4da1d8827a39fc2a7aad3402ff25250bf.tar.bz2
gsoc2013-evolution-09b9a3a4da1d8827a39fc2a7aad3402ff25250bf.tar.lz
gsoc2013-evolution-09b9a3a4da1d8827a39fc2a7aad3402ff25250bf.tar.xz
gsoc2013-evolution-09b9a3a4da1d8827a39fc2a7aad3402ff25250bf.tar.zst
gsoc2013-evolution-09b9a3a4da1d8827a39fc2a7aad3402ff25250bf.zip
Fix bug #3409: Removing an EvolutionStorage from the shell's folder
tree. svn path=/trunk/; revision=10362
-rw-r--r--mail/ChangeLog6
-rw-r--r--mail/component-factory.c44
-rw-r--r--shell/ChangeLog6
-rw-r--r--shell/evolution-storage.c60
-rw-r--r--shell/evolution-storage.h2
5 files changed, 99 insertions, 19 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index d7d6be9407..fb9f6135f9 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,9 @@
+2001-06-21 Jason Leach <jleach@ximian.com>
+
+ * component-factory.c (mail_remove_storage): Deregister the
+ storage from the shell so it will get removed from the folder
+ tree.
+
2001-06-20 Kjartan Maraas <kmaraas@gnome.org>
* folder-browser.c: More than on accel key is a tad
diff --git a/mail/component-factory.c b/mail/component-factory.c
index b38fb10528..14a9c7d823 100644
--- a/mail/component-factory.c
+++ b/mail/component-factory.c
@@ -65,6 +65,7 @@ char *evolution_dir;
static BonoboGenericFactory *component_factory = NULL;
static GHashTable *storages_hash;
+static EvolutionShellComponent *shell_component;
enum {
ACCEPTED_DND_TYPE_MESSAGE_RFC822,
@@ -175,6 +176,9 @@ create_folder (EvolutionShellComponent *shell_component,
CORBA_exception_init (&ev);
if (!strcmp (type, "mail")) {
+ /* This makes the uri start with mbox://file://, which
+ looks silly but turns into a CamelURL that has
+ url->provider of "mbox" */
uri = g_strdup_printf ("mbox://%s", physical_uri);
mail_create_folder (uri, do_create_folder, CORBA_Object_duplicate (listener, &ev));
GNOME_Evolution_ShellComponentListener_notifyResult (listener,
@@ -212,14 +216,10 @@ remove_folder (EvolutionShellComponent *shell_component,
void *closure)
{
CORBA_Environment ev;
- char *uri;
CORBA_exception_init (&ev);
-
- g_warning ("removing folder: %s", physical_uri);
-
- uri = g_strdup_printf ("file://%s", physical_uri);
- mail_remove_folder (uri, do_remove_folder, CORBA_Object_duplicate (listener, &ev));
+
+ mail_remove_folder (physical_uri, do_remove_folder, CORBA_Object_duplicate (listener, &ev));
GNOME_Evolution_ShellComponentListener_notifyResult (listener,
GNOME_Evolution_ShellComponentListener_OK, &ev);
@@ -576,7 +576,6 @@ static BonoboObject *
component_fn (BonoboGenericFactory *factory, void *closure)
{
EvolutionShellComponentDndDestinationFolder *destination_interface;
- EvolutionShellComponent *shell_component;
MailOfflineHandler *offline_handler;
shell_component = evolution_shell_component_new (folder_types,
@@ -627,18 +626,22 @@ component_factory_init (void)
}
static int
-storage_create_folder (EvolutionStorage *storage, const char *path,
- const char *type, const char *description,
- const char *parent_physical_uri, gpointer user_data)
+storage_create_folder (EvolutionStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ const char *parent_physical_uri,
+ gpointer user_data)
{
CamelStore *store = user_data;
char *name;
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;
@@ -646,8 +649,9 @@ storage_create_folder (EvolutionStorage *storage, const char *path,
camel_exception_init (&ex);
if (*parent_physical_uri) {
url = camel_url_new (parent_physical_uri, NULL);
- if (!url)
+ if (!url) {
return EVOLUTION_STORAGE_ERROR_INVALID_URI;
+ }
fi = camel_store_create_folder (store, url->path + 1, name, &ex);
camel_url_free (url);
@@ -671,8 +675,10 @@ storage_create_folder (EvolutionStorage *storage, const char *path,
}
static int
-storage_remove_folder (EvolutionStorage *storage, const char *path,
- const char *physical_uri, gpointer user_data)
+storage_remove_folder (EvolutionStorage *storage,
+ const char *path,
+ const char *physical_uri,
+ gpointer user_data)
{
CamelStore *store = user_data;
CamelURL *url = NULL;
@@ -864,18 +870,24 @@ void
mail_remove_storage (CamelStore *store)
{
EvolutionStorage *storage;
+ EvolutionShellClient *shell_client;
+ GNOME_Evolution_Shell corba_shell;
/* Because the storages_hash holds a reference to each store
* used as a key in it, none of them will ever be gc'ed, meaning
* any call to camel_session_get_{service,store} with the same
* URL will always return the same object. So this works.
*/
-
+
storage = g_hash_table_lookup (storages_hash, store);
g_hash_table_remove (storages_hash, store);
+ shell_client = evolution_shell_component_get_owner (shell_component);
+ corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client));
+
+ evolution_storage_deregister_on_shell (storage, corba_shell);
+
camel_service_disconnect (CAMEL_SERVICE (store), TRUE, NULL);
- bonobo_object_unref (BONOBO_OBJECT (storage));
camel_object_unref (CAMEL_OBJECT (store));
}
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 445ee3f8b9..201c814670 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,9 @@
+2001-06-21 Jason Leach <jleach@ximian.com>
+
+ * evolution-storage.c (evolution_storage_deregister_on_shell): New
+ function, uses the StorageRegistry::removeStoragebyName corba call
+ to properly make the storage vanish from the shell.
+
2001-06-18 Dan Winship <danw@ximian.com>
* Makefile.am (evolution_LDADD): Remove DB3_LDADD
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index 517993fa79..ee6d446cb9 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -650,8 +650,8 @@ evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
CORBA_exception_init (&ev);
corba_storage_registry = Bonobo_Unknown_queryInterface (corba_shell,
- "IDL:GNOME/Evolution/StorageRegistry:1.0",
- &ev);
+ "IDL:GNOME/Evolution/StorageRegistry:1.0",
+ &ev);
if (corba_storage_registry == CORBA_OBJECT_NIL || ev._major != CORBA_NO_EXCEPTION) {
CORBA_exception_free (&ev);
return EVOLUTION_STORAGE_ERROR_NOREGISTRY;
@@ -668,6 +668,60 @@ evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
}
EvolutionStorageResult
+evolution_storage_deregister_on_shell (EvolutionStorage *evolution_storage,
+ GNOME_Evolution_Shell corba_shell)
+{
+ GNOME_Evolution_StorageRegistry corba_storage_registry;
+ EvolutionStorageResult result;
+ EvolutionStoragePrivate *priv;
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (evolution_storage != NULL,
+ EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+ g_return_val_if_fail (EVOLUTION_IS_STORAGE (evolution_storage),
+ EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+ g_return_val_if_fail (corba_shell != CORBA_OBJECT_NIL,
+ EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
+
+ priv = evolution_storage->priv;
+
+ CORBA_exception_init (&ev);
+
+ corba_storage_registry = Bonobo_Unknown_queryInterface (corba_shell,
+ "IDL:GNOME/Evolution/StorageRegistry:1.0",
+ &ev);
+ if (corba_storage_registry == CORBA_OBJECT_NIL || ev._major != CORBA_NO_EXCEPTION) {
+ CORBA_exception_free (&ev);
+ return EVOLUTION_STORAGE_ERROR_NOREGISTRY;
+ }
+
+ GNOME_Evolution_StorageRegistry_removeStorageByName (corba_storage_registry,
+ priv->name,
+ &ev);
+
+ if (ev._major = CORBA_NO_EXCEPTION)
+ result = EVOLUTION_STORAGE_OK;
+ else {
+ if (ev._major != CORBA_USER_EXCEPTION)
+ result = EVOLUTION_STORAGE_ERROR_CORBA;
+ else if (strcmp (CORBA_exception_id (&ev), ex_GNOME_Evolution_StorageRegistry_NotFound) == 0)
+ result = EVOLUTION_STORAGE_ERROR_EXISTS;
+ else
+ result = EVOLUTION_STORAGE_ERROR_GENERIC;
+ }
+
+ /* Now unref the EvolutionStorage */
+ bonobo_object_unref (BONOBO_OBJECT (evolution_storage));
+
+ Bonobo_Unknown_unref (corba_storage_registry, &ev);
+ CORBA_Object_release (corba_storage_registry, &ev);
+
+ CORBA_exception_free (&ev);
+
+ return result;
+}
+
+EvolutionStorageResult
evolution_storage_new_folder (EvolutionStorage *evolution_storage,
const char *path,
const char *display_name,
@@ -861,7 +915,7 @@ evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
listener = p->data;
GNOME_Evolution_StorageListener_notifyFolderRemoved (listener, path, &ev);
-
+
if (ev._major != CORBA_NO_EXCEPTION)
continue;
diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h
index 94b512ae3c..00a2e8af49 100644
--- a/shell/evolution-storage.h
+++ b/shell/evolution-storage.h
@@ -110,6 +110,8 @@ EvolutionStorageResult evolution_storage_register (EvolutionStorage
GNOME_Evolution_StorageRegistry corba_registry);
EvolutionStorageResult evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
GNOME_Evolution_Shell corba_shell);
+EvolutionStorageResult evolution_storage_deregister_on_shell (EvolutionStorage *storage,
+ GNOME_Evolution_Shell corba_shell);
EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage *evolution_storage,
const char *path,
const char *display_name,