aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ChangeLog27
-rw-r--r--shell/Evolution-LocalStorage.idl32
-rw-r--r--shell/Evolution-Storage.idl27
-rw-r--r--shell/e-corba-storage.c140
-rw-r--r--shell/e-shell-folder-creation-dialog.c2
-rw-r--r--shell/e-storage-set.c1
-rw-r--r--shell/evolution-storage.c127
-rw-r--r--shell/evolution-storage.h31
8 files changed, 346 insertions, 41 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index b34d376658..a7376eb691 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,30 @@
+2001-02-14 Dan Winship <danw@ximian.com>
+
+ * Evolution-Storage.idl: add asyncCreateFolder and
+ asyncRemoveFolder interfaces. (Use Bonobo::Listener rather than
+ creating a new listener interface.)
+
+ * Evolution-LocalStorage.idl: Remove the
+ Evolution::LocalStorageOpsListener interface, which wasn't being
+ used.
+
+ * evolution-storage.c (impl_Storage_async_create_folder,
+ impl_Storage_async_remove_folder): implement by emitting signals
+ on the EvolutionStorage object. Convert from
+ EvolutionStorageResult to GNOME_Evolution_Storage_Result (blah!)
+ (class_init): Set up the new "create_folder" and "remove_folder"
+ signals.
+
+ * e-corba-storage.c (async_create_folder, async_remove_folder):
+ Implement, using the new Evolution::Storage IDL. Convert from
+ GNOME_Evolution_Storage_Result to EStorageResult (blah!)
+
+ * e-storage-set.c (e_storage_set_async_create_folder): Don't allow
+ a NULL description (since it doesn't allow a NULL anythign else).
+
+ * e-shell-folder-creation-dialog.c (dialog_clicked_cb): Pass ""
+ rather than NULL for the description.
+
2001-02-12 Kjartan Maraas <kmaraas@gnome.org>
* Makefile.am: xml-i18n-tools setup.
diff --git a/shell/Evolution-LocalStorage.idl b/shell/Evolution-LocalStorage.idl
index 8ade4e9813..04d04c7150 100644
--- a/shell/Evolution-LocalStorage.idl
+++ b/shell/Evolution-LocalStorage.idl
@@ -27,37 +27,5 @@ module Evolution {
in string display_name,
in boolean highlighted);
};
-
- interface LocalStorageOpsListener : Bonobo::Unknown {
- enum Result {
- OK,
- UNSUPPORTED_OPERATION,
- UNSUPPORTED_TYPE,
- EXISTS,
- INVALID_URI,
- PERMISSION_DENIED,
- HAS_SUBFOLDERS,
- NO_SPACE
- };
-
- void notifyResult (in Result result);
- };
-
- interface LocalStorageOps : Bonobo::Unknown {
- exception Busy {};
-
- void addFolderAsync (in ShellComponentListener listener,
- in string physical_uri,
- in string type)
- raises (Busy);
-
- void removeFolderAsync (in ShellComponentListener listener,
- in string physical_uri)
- raises (Busy);
-
- void populateFolderContextMenu (in Bonobo::UIContainer uih,
- in string physical_uri,
- in string type);
- };
};
};
diff --git a/shell/Evolution-Storage.idl b/shell/Evolution-Storage.idl
index d71b7843be..879df8afb0 100644
--- a/shell/Evolution-Storage.idl
+++ b/shell/Evolution-Storage.idl
@@ -29,10 +29,33 @@ module Evolution {
attribute string name;
- void addListener (in StorageListener listener)
+ enum Result {
+ OK,
+ UNSUPPORTED_OPERATION,
+ UNSUPPORTED_TYPE,
+ INVALID_URI,
+ ALREADY_EXISTS,
+ DOES_NOT_EXIST,
+ PERMISSION_DENIED,
+ NO_SPACE,
+ NOT_EMPTY,
+ GENERIC_ERROR
+ };
+
+ void asyncCreateFolder (in string path,
+ in string type,
+ in string description,
+ in string parent_physical_uri,
+ in Bonobo::Listener listener);
+
+ void asyncRemoveFolder (in string path,
+ in string physical_uri,
+ in Bonobo::Listener listener);
+
+ void addListener (in StorageListener listener)
raises (AlreadyListening);
- void removeListener (in StorageListener listener)
+ void removeListener (in StorageListener listener)
raises (NotFound);
};
diff --git a/shell/e-corba-storage.c b/shell/e-corba-storage.c
index 0428a521b8..18e0723512 100644
--- a/shell/e-corba-storage.c
+++ b/shell/e-corba-storage.c
@@ -267,6 +267,144 @@ get_name (EStorage *storage)
return priv->name;
}
+struct async_folder_closure {
+ EStorageResultCallback callback;
+ EStorage *storage;
+ void *data;
+};
+
+static void
+async_folder_cb (BonoboListener *listener, char *event_name,
+ CORBA_any *any, CORBA_Environment *ev,
+ gpointer user_data)
+{
+ struct async_folder_closure *closure = user_data;
+ GNOME_Evolution_Storage_Result *corba_result;
+ EStorageResult result;
+
+ corba_result = any->_value;
+ switch (*corba_result) {
+ case GNOME_Evolution_Storage_OK:
+ result = E_STORAGE_OK;
+ break;
+ case GNOME_Evolution_Storage_UNSUPPORTED_OPERATION:
+ result = E_STORAGE_UNSUPPORTEDOPERATION;
+ break;
+ case GNOME_Evolution_Storage_UNSUPPORTED_TYPE:
+ result = E_STORAGE_UNSUPPORTEDTYPE;
+ break;
+ case GNOME_Evolution_Storage_ALREADY_EXISTS:
+ result = E_STORAGE_EXISTS;
+ break;
+ case GNOME_Evolution_Storage_DOES_NOT_EXIST:
+ result = E_STORAGE_NOTFOUND;
+ break;
+ case GNOME_Evolution_Storage_PERMISSION_DENIED:
+ result = E_STORAGE_PERMISSIONDENIED;
+ break;
+ case GNOME_Evolution_Storage_NO_SPACE:
+ result = E_STORAGE_NOSPACE;
+ break;
+ case GNOME_Evolution_Storage_INVALID_URI:
+ case GNOME_Evolution_Storage_NOT_EMPTY:
+ case GNOME_Evolution_Storage_GENERIC_ERROR:
+ default:
+ result = E_STORAGE_GENERICERROR;
+ break;
+ }
+
+ closure->callback (closure->storage, result, closure->data);
+ bonobo_object_unref (BONOBO_OBJECT (listener));
+ g_free (closure);
+}
+
+static void
+async_create_folder (EStorage *storage, const char *path,
+ const char *type, const char *description,
+ EStorageResultCallback callback, void *data)
+{
+ ECorbaStorage *corba_storage;
+ ECorbaStoragePrivate *priv;
+ const char *parent_uri;
+ char *p;
+ BonoboListener *listener;
+ Bonobo_Listener corba_listener;
+ CORBA_Environment ev;
+ struct async_folder_closure *closure;
+
+ corba_storage = E_CORBA_STORAGE (storage);
+ priv = corba_storage->priv;
+
+ p = strrchr (path, '/');
+ if (p && p != path) {
+ char *parent_path;
+ EFolder *parent;
+
+ parent_path = g_strndup (path, p - path);
+ parent = e_storage_get_folder (storage, parent_path);
+ parent_uri = e_folder_get_physical_uri (parent);
+ } else
+ parent_uri = "";
+
+ closure = g_new (struct async_folder_closure, 1);
+ closure->callback = callback;
+ closure->storage = storage;
+ closure->data = data;
+ listener = bonobo_listener_new (async_folder_cb, closure);
+ corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_Storage_asyncCreateFolder (priv->storage_interface,
+ path, type, description,
+ parent_uri,
+ corba_listener, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ callback (storage, E_STORAGE_GENERICERROR, data);
+ bonobo_object_unref (BONOBO_OBJECT (listener));
+ g_free (closure);
+ }
+ CORBA_exception_free (&ev);
+}
+
+static void
+async_remove_folder (EStorage *storage, const char *path,
+ EStorageResultCallback callback, void *data)
+{
+ ECorbaStorage *corba_storage;
+ ECorbaStoragePrivate *priv;
+ EFolder *folder;
+ BonoboListener *listener;
+ Bonobo_Listener corba_listener;
+ CORBA_Environment ev;
+ struct async_folder_closure *closure;
+
+ corba_storage = E_CORBA_STORAGE (storage);
+ priv = corba_storage->priv;
+
+ folder = e_storage_get_folder (storage, path);
+
+ closure = g_new (struct async_folder_closure, 1);
+ closure->callback = callback;
+ closure->storage = storage;
+ closure->data = data;
+ listener = bonobo_listener_new (async_folder_cb, closure);
+ corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
+
+ CORBA_exception_init (&ev);
+ GNOME_Evolution_Storage_asyncRemoveFolder (priv->storage_interface,
+ path, e_folder_get_physical_uri (folder),
+ corba_listener, &ev);
+
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ callback (storage, E_STORAGE_GENERICERROR, data);
+ bonobo_object_unref (BONOBO_OBJECT (listener));
+ g_free (closure);
+ }
+ CORBA_exception_free (&ev);
+}
+
+
static void
corba_class_init (void)
@@ -301,6 +439,8 @@ class_init (ECorbaStorageClass *klass)
storage_class = E_STORAGE_CLASS (klass);
storage_class->get_name = get_name;
+ storage_class->async_create_folder = async_create_folder;
+ storage_class->async_remove_folder = async_remove_folder;
corba_class_init ();
diff --git a/shell/e-shell-folder-creation-dialog.c b/shell/e-shell-folder-creation-dialog.c
index 9cdb8068fc..b9da2cf8c8 100644
--- a/shell/e-shell-folder-creation-dialog.c
+++ b/shell/e-shell-folder-creation-dialog.c
@@ -186,7 +186,7 @@ dialog_clicked_cb (GnomeDialog *dialog,
e_storage_set_async_create_folder (storage_set,
path,
folder_type,
- NULL, /* description */
+ "", /* description */
async_create_cb, dialog_data);
}
diff --git a/shell/e-storage-set.c b/shell/e-storage-set.c
index 246af39f68..9921fe192c 100644
--- a/shell/e-storage-set.c
+++ b/shell/e-storage-set.c
@@ -515,6 +515,7 @@ e_storage_set_async_create_folder (EStorageSet *storage_set,
g_return_if_fail (path != NULL);
g_return_if_fail (g_path_is_absolute (path));
g_return_if_fail (type != NULL);
+ g_return_if_fail (description != NULL);
g_return_if_fail (callback != NULL);
storage = get_storage_for_path (storage_set, path, &subpath);
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index 1424042653..dd9387715d 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -62,6 +62,15 @@ struct _EvolutionStoragePrivate {
};
+enum {
+ CREATE_FOLDER,
+ REMOVE_FOLDER,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
/* Utility functions. */
static void
@@ -240,6 +249,92 @@ impl_Storage__get_name (PortableServer_Servant servant,
return CORBA_string_dup (priv->name);
}
+static GNOME_Evolution_Storage_Result
+storage_gtk_to_corba_result (EvolutionStorageResult result)
+{
+ GNOME_Evolution_Storage_Result corba_result;
+
+ switch (result) {
+ case EVOLUTION_STORAGE_OK:
+ return GNOME_Evolution_Storage_OK;
+ case EVOLUTION_STORAGE_ERROR_UNSUPPORTED_OPERATION:
+ return GNOME_Evolution_Storage_UNSUPPORTED_OPERATION;
+ case EVOLUTION_STORAGE_ERROR_UNSUPPORTED_TYPE:
+ return GNOME_Evolution_Storage_UNSUPPORTED_TYPE;
+ case EVOLUTION_STORAGE_ERROR_INVALID_URI:
+ return GNOME_Evolution_Storage_INVALID_URI;
+ case EVOLUTION_STORAGE_ERROR_ALREADY_EXISTS:
+ return GNOME_Evolution_Storage_ALREADY_EXISTS;
+ case EVOLUTION_STORAGE_ERROR_DOES_NOT_EXIST:
+ return GNOME_Evolution_Storage_DOES_NOT_EXIST;
+ case EVOLUTION_STORAGE_ERROR_PERMISSION_DENIED:
+ return GNOME_Evolution_Storage_PERMISSION_DENIED;
+ case EVOLUTION_STORAGE_ERROR_NO_SPACE:
+ return GNOME_Evolution_Storage_NO_SPACE;
+ case EVOLUTION_STORAGE_ERROR_NOT_EMPTY:
+ return GNOME_Evolution_Storage_NOT_EMPTY;
+ default:
+ return GNOME_Evolution_Storage_GENERIC_ERROR;
+ }
+}
+
+static void
+impl_Storage_async_create_folder (PortableServer_Servant servant,
+ const CORBA_char *path,
+ const CORBA_char *type,
+ const CORBA_char *description,
+ const CORBA_char *parent_physical_uri,
+ const Bonobo_Listener listener,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionStorage *storage;
+ int int_result;
+ CORBA_any any;
+ GNOME_Evolution_Storage_Result corba_result;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ storage = EVOLUTION_STORAGE (bonobo_object);
+
+ int_result = GNOME_Evolution_Storage_UNSUPPORTED_OPERATION;
+ gtk_signal_emit (GTK_OBJECT (storage), signals[CREATE_FOLDER],
+ path, type, description, parent_physical_uri,
+ &int_result);
+
+ corba_result = storage_gtk_to_corba_result (int_result);
+ any._type = TC_GNOME_Evolution_Storage_Result;
+ any._value = &corba_result;
+
+ Bonobo_Listener_event (listener, "result", &any, ev);
+}
+
+static void
+impl_Storage_async_remove_folder (PortableServer_Servant servant,
+ const CORBA_char *path,
+ const CORBA_char *physical_uri,
+ const Bonobo_Listener listener,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionStorage *storage;
+ int int_result;
+ CORBA_any any;
+ GNOME_Evolution_Storage_Result corba_result;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ storage = EVOLUTION_STORAGE (bonobo_object);
+
+ int_result = GNOME_Evolution_Storage_UNSUPPORTED_OPERATION;
+ gtk_signal_emit (GTK_OBJECT (storage), signals[REMOVE_FOLDER],
+ path, physical_uri, &int_result);
+
+ corba_result = storage_gtk_to_corba_result (int_result);
+ any._type = TC_GNOME_Evolution_Storage_Result;
+ any._value = &corba_result;
+
+ Bonobo_Listener_event (listener, "result", &any, ev);
+}
+
static void
impl_Storage_add_listener (PortableServer_Servant servant,
const GNOME_Evolution_StorageListener listener,
@@ -352,6 +447,30 @@ class_init (EvolutionStorageClass *klass)
parent_class = gtk_type_class (bonobo_object_get_type ());
+ signals[CREATE_FOLDER] = gtk_signal_new ("create_folder",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionStorageClass,
+ create_folder),
+ e_marshal_INT__POINTER_POINTER_POINTER_POINTER,
+ GTK_TYPE_INT, 4,
+ GTK_TYPE_STRING,
+ GTK_TYPE_STRING,
+ GTK_TYPE_STRING,
+ GTK_TYPE_STRING);
+
+ signals[REMOVE_FOLDER] = gtk_signal_new ("remove_folder",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionStorageClass,
+ remove_folder),
+ e_marshal_INT__POINTER_POINTER,
+ GTK_TYPE_INT, 2,
+ GTK_TYPE_STRING,
+ GTK_TYPE_STRING);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+
corba_class_init ();
}
@@ -378,9 +497,11 @@ evolution_storage_get_epv (void)
POA_GNOME_Evolution_Storage__epv *epv;
epv = g_new0 (POA_GNOME_Evolution_Storage__epv, 1);
- epv->_get_name = impl_Storage__get_name;
- epv->addListener = impl_Storage_add_listener;
- epv->removeListener = impl_Storage_remove_listener;
+ epv->_get_name = impl_Storage__get_name;
+ epv->asyncCreateFolder = impl_Storage_async_create_folder;
+ epv->asyncRemoveFolder = impl_Storage_async_remove_folder;
+ epv->addListener = impl_Storage_add_listener;
+ epv->removeListener = impl_Storage_remove_listener;
return epv;
}
diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h
index 9283723924..39a82a019e 100644
--- a/shell/evolution-storage.h
+++ b/shell/evolution-storage.h
@@ -46,14 +46,28 @@ typedef struct _EvolutionStorageClass EvolutionStorageClass;
enum _EvolutionStorageResult {
EVOLUTION_STORAGE_OK,
+
+ /* Generic errors */
+ EVOLUTION_STORAGE_ERROR_GENERIC,
+ EVOLUTION_STORAGE_ERROR_CORBA,
+ EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER,
+
+ /* Registration errors */
EVOLUTION_STORAGE_ERROR_ALREADYREGISTERED,
EVOLUTION_STORAGE_ERROR_NOTREGISTERED,
EVOLUTION_STORAGE_ERROR_NOREGISTRY,
- EVOLUTION_STORAGE_ERROR_CORBA,
EVOLUTION_STORAGE_ERROR_EXISTS,
- EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER,
EVOLUTION_STORAGE_ERROR_NOTFOUND,
- EVOLUTION_STORAGE_ERROR_GENERIC
+
+ /* Folder creation/deletion errors */
+ EVOLUTION_STORAGE_ERROR_UNSUPPORTED_OPERATION,
+ EVOLUTION_STORAGE_ERROR_UNSUPPORTED_TYPE,
+ EVOLUTION_STORAGE_ERROR_INVALID_URI,
+ EVOLUTION_STORAGE_ERROR_ALREADY_EXISTS,
+ EVOLUTION_STORAGE_ERROR_DOES_NOT_EXIST,
+ EVOLUTION_STORAGE_ERROR_PERMISSION_DENIED,
+ EVOLUTION_STORAGE_ERROR_NO_SPACE,
+ EVOLUTION_STORAGE_ERROR_NOT_EMPTY
};
typedef enum _EvolutionStorageResult EvolutionStorageResult;
@@ -65,6 +79,17 @@ struct _EvolutionStorage {
struct _EvolutionStorageClass {
BonoboObjectClass parent_class;
+
+ /* signals */
+ int (*create_folder) (EvolutionStorage *storage,
+ const char *path,
+ const char *type,
+ const char *description,
+ const char *parent_physical_uri);
+
+ int (*remove_folder) (EvolutionStorage *storage,
+ const char *path,
+ const char *physical_uri);
};