aboutsummaryrefslogtreecommitdiffstats
path: root/shell/evolution-storage.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-10-02 20:52:22 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-10-02 20:52:22 +0800
commitee5decd2ffb8693396d27b6c0eed24991d676934 (patch)
tree63be38a87db54da4a529e52f89eb31fe7b9943b2 /shell/evolution-storage.c
parent7936f1411f1737fb408eb2132bee8ee508a80233 (diff)
downloadgsoc2013-evolution-ee5decd2ffb8693396d27b6c0eed24991d676934.tar
gsoc2013-evolution-ee5decd2ffb8693396d27b6c0eed24991d676934.tar.gz
gsoc2013-evolution-ee5decd2ffb8693396d27b6c0eed24991d676934.tar.bz2
gsoc2013-evolution-ee5decd2ffb8693396d27b6c0eed24991d676934.tar.lz
gsoc2013-evolution-ee5decd2ffb8693396d27b6c0eed24991d676934.tar.xz
gsoc2013-evolution-ee5decd2ffb8693396d27b6c0eed24991d676934.tar.zst
gsoc2013-evolution-ee5decd2ffb8693396d27b6c0eed24991d676934.zip
Add a `::remove_listener' method to Evolution::Storage.
svn path=/trunk/; revision=5655
Diffstat (limited to 'shell/evolution-storage.c')
-rw-r--r--shell/evolution-storage.c81
1 files changed, 76 insertions, 5 deletions
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index 1561c48242..4d271cefa8 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -86,7 +86,30 @@ list_through_listener (EvolutionStorage *storage,
listener);
}
-static void
+static GList *
+find_listener_in_list (const Evolution_StorageListener listener,
+ GList *list)
+{
+ CORBA_Environment ev;
+ GList *p;
+
+ CORBA_exception_init (&ev);
+
+ for (p = list; p != NULL; p = p->next) {
+ Evolution_StorageListener listener_item;
+
+ listener_item = (Evolution_StorageListener) p->data;
+
+ if (CORBA_Object_is_equivalent (listener_item, listener, &ev) && ev._major == CORBA_NO_EXCEPTION)
+ return p;
+ }
+
+ CORBA_exception_free (&ev);
+
+ return NULL;
+}
+
+static gboolean
add_listener (EvolutionStorage *storage,
const Evolution_StorageListener listener)
{
@@ -96,6 +119,9 @@ add_listener (EvolutionStorage *storage,
priv = storage->priv;
+ if (find_listener_in_list (listener, priv->corba_storage_listeners) != NULL)
+ return FALSE;
+
CORBA_exception_init (&ev);
listener_copy = CORBA_Object_duplicate (listener, &ev);
@@ -103,7 +129,10 @@ add_listener (EvolutionStorage *storage,
/* Panic. */
g_warning ("EvolutionStorage -- Cannot duplicate listener.");
CORBA_exception_free (&ev);
- return;
+
+ /* FIXME this will cause the ::add_listener implementation to
+ incorrectly raise `AlreadyListening' */
+ return FALSE;
}
priv->corba_storage_listeners = g_list_prepend (priv->corba_storage_listeners,
@@ -112,6 +141,31 @@ add_listener (EvolutionStorage *storage,
list_through_listener (storage, listener_copy, &ev);
CORBA_exception_free (&ev);
+
+ return TRUE;
+}
+
+static gboolean
+remove_listener (EvolutionStorage *storage,
+ const Evolution_StorageListener listener)
+{
+ EvolutionStoragePrivate *priv;
+ CORBA_Environment ev;
+ GList *p;
+
+ priv = storage->priv;
+
+ p = find_listener_in_list (listener, priv->corba_storage_listeners);
+ if (p == NULL)
+ return FALSE;
+
+ CORBA_exception_init (&ev);
+ CORBA_Object_release ((CORBA_Object) p->data, &ev);
+ CORBA_exception_free (&ev);
+
+ priv->corba_storage_listeners = g_list_remove_link (priv->corba_storage_listeners, p);
+
+ return TRUE;
}
@@ -183,7 +237,23 @@ impl_Storage_add_listener (PortableServer_Servant servant,
bonobo_object = bonobo_object_from_servant (servant);
storage = EVOLUTION_STORAGE (bonobo_object);
- add_listener (storage, listener);
+ if (! add_listener (storage, listener))
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_Evolution_Storage_AlreadyListening, NULL);
+}
+
+static void
+impl_Storage_remove_listener (PortableServer_Servant servant,
+ const Evolution_StorageListener listener,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionStorage *storage;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ storage = EVOLUTION_STORAGE (bonobo_object);
+
+ if (! remove_listener (storage, listener))
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_Evolution_Storage_NotFound, NULL);
}
@@ -278,8 +348,9 @@ evolution_storage_get_epv (void)
POA_Evolution_Storage__epv *epv;
epv = g_new0 (POA_Evolution_Storage__epv, 1);
- epv->_get_name = impl_Storage__get_name;
- epv->add_listener = impl_Storage_add_listener;
+ epv->_get_name = impl_Storage__get_name;
+ epv->add_listener = impl_Storage_add_listener;
+ epv->remove_listener = impl_Storage_remove_listener;
return epv;
}