aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-corba-storage.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-02-15 05:50:48 +0800
committerDan Winship <danw@src.gnome.org>2001-02-15 05:50:48 +0800
commit3245f9dacf18e68ed5e1bc18226d0ffe65c7bf6c (patch)
tree8767588191220389f5b4d37ca62126e1627a416d /shell/e-corba-storage.c
parent3192e9ed0bbd475c22e8f74e8ce7c8ac1297abda (diff)
downloadgsoc2013-evolution-3245f9dacf18e68ed5e1bc18226d0ffe65c7bf6c.tar.gz
gsoc2013-evolution-3245f9dacf18e68ed5e1bc18226d0ffe65c7bf6c.tar.zst
gsoc2013-evolution-3245f9dacf18e68ed5e1bc18226d0ffe65c7bf6c.zip
add asyncCreateFolder and asyncRemoveFolder interfaces. (Use
* 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. svn path=/trunk/; revision=8230
Diffstat (limited to 'shell/e-corba-storage.c')
-rw-r--r--shell/e-corba-storage.c140
1 files changed, 140 insertions, 0 deletions
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 ();