From 553de94865892fa7473f55d71a2fdf266e5359b7 Mon Sep 17 00:00:00 2001 From: Iain Holmes Date: Thu, 30 Aug 2001 23:21:56 +0000 Subject: Fix the Pine and Netscape importers. Give them a nice progress reporting GUI. Revert Jason's changes so that creating a folder works again. svn path=/trunk/; revision=12536 --- shell/e-local-storage.c | 53 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 9 deletions(-) (limited to 'shell/e-local-storage.c') diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c index 275b9be88e..0006be090d 100644 --- a/shell/e-local-storage.c +++ b/shell/e-local-storage.c @@ -55,6 +55,7 @@ #include "e-local-storage.h" +#include #define PARENT_TYPE E_TYPE_STORAGE static EStorageClass *parent_class = NULL; @@ -215,8 +216,33 @@ load_all_folders (ELocalStorage *local_storage) /* Callbacks for the async methods invoked on the `Evolution::ShellComponent's. */ +static void +notify_listener (const Bonobo_Listener listener, + EStorageResult result, + const char *physical_path) +{ + CORBA_any any; + GNOME_Evolution_Storage_FolderResult folder_result; + CORBA_Environment ev; + + folder_result.result = result; + folder_result.path = CORBA_string_dup (physical_path ? physical_path : ""); + any._type = TC_GNOME_Evolution_Storage_FolderResult; + any._value = &folder_result; + + CORBA_exception_init (&ev); + Bonobo_Listener_event (listener, "evolution-shell:folder_created", + &any, &ev); + if (BONOBO_EX (&ev)) { + g_warning ("Exception notifing listener: %s\n", + CORBA_exception_id (&ev)); + } + CORBA_exception_free (&ev); +} + struct _AsyncCreateFolderCallbackData { EStorage *storage; + Bonobo_Listener listener; char *path; char *display_name; @@ -266,6 +292,10 @@ component_async_create_folder_callback (EvolutionShellComponentClient *shell_com bonobo_object_unref (BONOBO_OBJECT (shell_component_client)); + if (callback_data->listener != CORBA_OBJECT_NIL) + notify_listener (callback_data->listener, storage_result, + callback_data->physical_path); + if (callback_data->callback != NULL) (* callback_data->callback) (callback_data->storage, storage_result, @@ -334,8 +364,9 @@ create_folder_directory (ELocalStorage *local_storage, return E_STORAGE_OK; } -static EStorageResult +static void create_folder (ELocalStorage *local_storage, + const Bonobo_Listener listener, const char *path, const char *type, const char *description, @@ -356,20 +387,24 @@ create_folder (ELocalStorage *local_storage, component_client = e_folder_type_registry_get_handler_for_type (priv->folder_type_registry, type); if (component_client == NULL) { + if (listener != CORBA_OBJECT_NIL) + notify_listener (listener, E_STORAGE_INVALIDTYPE, NULL); if (callback != NULL) (* callback) (storage, E_STORAGE_INVALIDTYPE, data); - return E_STORAGE_INVALIDTYPE; + return; } g_assert (g_path_is_absolute (path)); result = create_folder_directory (local_storage, path, type, description, &physical_path); if (result != E_STORAGE_OK) { - g_warning ("physical_path: %s", physical_path); if (callback != NULL) (* callback) (storage, result, data); + if (listener != CORBA_OBJECT_NIL) + notify_listener (listener, result, NULL); + g_free (physical_path); - return result; + return; } folder_name = g_basename (path); @@ -389,6 +424,7 @@ create_folder (ELocalStorage *local_storage, callback_data->description = g_strdup (description); callback_data->physical_uri = physical_uri; callback_data->physical_path = physical_path; + callback_data->listener = listener; callback_data->callback = callback; callback_data->callback_data = data; @@ -399,8 +435,6 @@ create_folder (ELocalStorage *local_storage, type, component_async_create_folder_callback, callback_data); - - return result; } struct _AsyncRemoveFolderCallbackData { @@ -607,7 +641,7 @@ impl_async_create_folder (EStorage *storage, local_storage = E_LOCAL_STORAGE (storage); - create_folder (local_storage, path, type, description, callback, data); + create_folder (local_storage, CORBA_OBJECT_NIL, path, type, description, callback, data); } @@ -887,8 +921,9 @@ impl_async_xfer_folder (EStorage *storage, /* Callbacks for the `Evolution::Storage' interface we are exposing to the outside world. */ -static int +static void bonobo_interface_create_folder_cb (EvolutionStorage *storage, + const Bonobo_Listener listener, const char *path, const char *type, const char *description, @@ -899,7 +934,7 @@ bonobo_interface_create_folder_cb (EvolutionStorage *storage, local_storage = E_LOCAL_STORAGE (data); - return create_folder (local_storage, path, type, description, NULL, NULL); + create_folder (local_storage, listener, path, type, description, NULL, NULL); } static int -- cgit v1.2.3