Fix bug #3409: Removing an EvolutionStorage from the shell's folder
tree. svn path=/trunk/; revision=10362
This commit is contained in:
@ -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
|
||||
|
||||
@ -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));
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
@ -667,6 +667,60 @@ evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
|
||||
return result;
|
||||
}
|
||||
|
||||
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,
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user