aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-09-09 05:15:38 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-09-09 05:15:38 +0800
commitdb75f8912dff0be20f17946b0131e88ae67ea837 (patch)
tree52c0d3b9df29bbf06d7d6488572db4941435dd3a
parentf9d0db03faef147752790fe0d0e254b954776b61 (diff)
downloadgsoc2013-evolution-db75f8912dff0be20f17946b0131e88ae67ea837.tar
gsoc2013-evolution-db75f8912dff0be20f17946b0131e88ae67ea837.tar.gz
gsoc2013-evolution-db75f8912dff0be20f17946b0131e88ae67ea837.tar.bz2
gsoc2013-evolution-db75f8912dff0be20f17946b0131e88ae67ea837.tar.lz
gsoc2013-evolution-db75f8912dff0be20f17946b0131e88ae67ea837.tar.xz
gsoc2013-evolution-db75f8912dff0be20f17946b0131e88ae67ea837.tar.zst
gsoc2013-evolution-db75f8912dff0be20f17946b0131e88ae67ea837.zip
Make EvolutionStorage support multiple listeners.
svn path=/trunk/; revision=5275
-rw-r--r--shell/ChangeLog14
-rw-r--r--shell/evolution-storage.c130
2 files changed, 116 insertions, 28 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 2a3c9d06ed..ba2f14e9d4 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,19 @@
2000-09-08 Ettore Perazzoli <ettore@helixcode.com>
+ * evolution-storage.c: New member `folder_tree' in
+ `EvolutionStoragePrivate'.
+ (init): Initialize it.
+ (destroy): Destroy it.
+ (list_through_listener): New.
+ (add_listener): Use it to list all the current folders through the
+ listener.
+ (evolution_storage_new_folder): Add the thingie to the
+ `folder_tree'.
+ (evolution_storage_removed_folder): Remove the thingie from the
+ `folder_tree'.
+
+2000-09-08 Ettore Perazzoli <ettore@helixcode.com>
+
* e-storage.c: Replaced the `path_to_folder' GHashTable with an
EFolderTree named `folder_tree'.
(init): Updated accordingly.
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index 887a9f98d5..6a28375b9f 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -31,6 +31,8 @@
#include "e-util/e-util.h"
+#include "e-folder-tree.h"
+
#include "evolution-storage.h"
@@ -40,6 +42,8 @@ static BonoboObjectClass *parent_class = NULL;
struct _EvolutionStoragePrivate {
char *name;
+ EFolderTree *folder_tree;
+
GList *corba_storage_listeners;
};
@@ -47,6 +51,38 @@ struct _EvolutionStoragePrivate {
/* Utility functions. */
static void
+list_through_listener_foreach (EFolderTree *tree,
+ const char *path,
+ void *data,
+ void *closure)
+{
+ const Evolution_Folder *corba_folder;
+ Evolution_StorageListener corba_listener;
+ CORBA_Environment ev;
+
+ corba_folder = (Evolution_Folder *) data;
+ corba_listener = (Evolution_StorageListener) closure;
+
+ CORBA_exception_init (&ev);
+ Evolution_StorageListener_new_folder (corba_listener, path, corba_folder, &ev);
+ CORBA_exception_free (&ev);
+}
+
+static void
+list_through_listener (EvolutionStorage *storage,
+ Evolution_StorageListener listener,
+ CORBA_Environment *ev)
+{
+ EvolutionStoragePrivate *priv;
+
+ priv = storage->priv;
+
+ e_folder_tree_foreach (priv->folder_tree,
+ list_through_listener_foreach,
+ listener);
+}
+
+static void
add_listener (EvolutionStorage *storage,
const Evolution_StorageListener listener)
{
@@ -69,10 +105,27 @@ add_listener (EvolutionStorage *storage,
priv->corba_storage_listeners = g_list_prepend (priv->corba_storage_listeners,
listener_copy);
+ list_through_listener (storage, listener_copy, &ev);
+
CORBA_exception_free (&ev);
}
+/* Functions for the EFolderTree in the storage. */
+
+static void
+folder_destroy_notify (EFolderTree *tree,
+ const char *path,
+ void *data,
+ void *closure)
+{
+ Evolution_Folder *corba_folder;
+
+ corba_folder = (Evolution_Folder *) data;
+ CORBA_free (data);
+}
+
+
/* CORBA interface implementation. */
static POA_Evolution_Storage__vepv Storage_vepv;
@@ -131,6 +184,9 @@ destroy (GtkObject *object)
g_free (priv->name);
+ if (priv->folder_tree != NULL)
+ e_folder_tree_destroy (priv->folder_tree);
+
CORBA_exception_init (&ev);
for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
@@ -190,6 +246,7 @@ init (EvolutionStorage *storage)
EvolutionStoragePrivate *priv;
priv = g_new (EvolutionStoragePrivate, 1);
+ priv->folder_tree = e_folder_tree_new (folder_destroy_notify, storage);
priv->name = NULL;
priv->corba_storage_listeners = NULL;
@@ -340,10 +397,9 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage,
{
EvolutionStorageResult result;
EvolutionStoragePrivate *priv;
- Evolution_Folder corba_folder;
+ Evolution_Folder *corba_folder;
CORBA_Environment ev;
GList *p;
- const char *path_basename;
g_return_val_if_fail (evolution_storage != NULL,
EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
@@ -357,34 +413,42 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage,
priv = evolution_storage->priv;
- path_basename = g_basename (path);
+ CORBA_exception_init (&ev);
- /* Yuck. */
- corba_folder.display_name = (CORBA_char *) display_name;
- corba_folder.description = (CORBA_char *) description;
- corba_folder.type = (CORBA_char *) type;
- corba_folder.physical_uri = (CORBA_char *) physical_uri;
+ corba_folder = Evolution_Folder__alloc ();
+ corba_folder->display_name = CORBA_string_dup (display_name);
+ corba_folder->description = CORBA_string_dup (description);
+ corba_folder->type = CORBA_string_dup (type);
+ corba_folder->physical_uri = CORBA_string_dup (physical_uri);
- CORBA_exception_init (&ev);
+ result = EVOLUTION_STORAGE_OK;
for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
Evolution_StorageListener listener;
listener = p->data;
- Evolution_StorageListener_new_folder (listener, path, &corba_folder, &ev);
- }
+ Evolution_StorageListener_new_folder (listener, path, corba_folder, &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_Evolution_StorageListener_Exists) == 0)
- result = EVOLUTION_STORAGE_ERROR_EXISTS;
- else
- result = EVOLUTION_STORAGE_ERROR_GENERIC;
+ if (ev._major == CORBA_NO_EXCEPTION)
+ continue;
+
+ if (ev._major != CORBA_USER_EXCEPTION)
+ result = EVOLUTION_STORAGE_ERROR_CORBA;
+ else if (strcmp (CORBA_exception_id (&ev), ex_Evolution_StorageListener_Exists) == 0)
+ result = EVOLUTION_STORAGE_ERROR_EXISTS;
+ else
+ result = EVOLUTION_STORAGE_ERROR_GENERIC;
+
+ break;
+ }
CORBA_exception_free (&ev);
+ if (result == EVOLUTION_STORAGE_OK) {
+ if (! e_folder_tree_add (priv->folder_tree, path, corba_folder))
+ result = EVOLUTION_STORAGE_ERROR_EXISTS;
+ }
+
return result;
}
@@ -411,24 +475,34 @@ evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
CORBA_exception_init (&ev);
+ result = EVOLUTION_STORAGE_OK;
+
for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
Evolution_StorageListener listener;
listener = p->data;
Evolution_StorageListener_removed_folder (listener, path, &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_Evolution_StorageListener_NotFound) == 0)
- result = EVOLUTION_STORAGE_ERROR_NOTFOUND;
- else
- result = EVOLUTION_STORAGE_ERROR_GENERIC;
+ if (ev._major != CORBA_NO_EXCEPTION)
+ continue;
+
+ if (ev._major != CORBA_USER_EXCEPTION)
+ result = EVOLUTION_STORAGE_ERROR_CORBA;
+ else if (strcmp (CORBA_exception_id (&ev), ex_Evolution_StorageListener_NotFound) == 0)
+ result = EVOLUTION_STORAGE_ERROR_NOTFOUND;
+ else
+ result = EVOLUTION_STORAGE_ERROR_GENERIC;
+
+ break;
+ }
CORBA_exception_free (&ev);
+ if (result == EVOLUTION_STORAGE_OK) {
+ if (! e_folder_tree_remove (priv->folder_tree, path))
+ result = EVOLUTION_STORAGE_ERROR_NOTFOUND;
+ }
+
return result;
}