aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-09-08 16:34:35 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-09-08 16:34:35 +0800
commitaa20072666850291f8a00dec148df5d58991ae60 (patch)
tree299882862d2b7710c62915bd78c03d5f4c9648d0
parenta38d76bc2e91964b73ffac3efcb043db54bf2189 (diff)
downloadgsoc2013-evolution-aa20072666850291f8a00dec148df5d58991ae60.tar
gsoc2013-evolution-aa20072666850291f8a00dec148df5d58991ae60.tar.gz
gsoc2013-evolution-aa20072666850291f8a00dec148df5d58991ae60.tar.bz2
gsoc2013-evolution-aa20072666850291f8a00dec148df5d58991ae60.tar.lz
gsoc2013-evolution-aa20072666850291f8a00dec148df5d58991ae60.tar.xz
gsoc2013-evolution-aa20072666850291f8a00dec148df5d58991ae60.tar.zst
gsoc2013-evolution-aa20072666850291f8a00dec148df5d58991ae60.zip
Added new interfaces to be exposed by the local storage, so that
components can get a list of all the folders and specify the display name for them. (Unfinished and untested.) svn path=/trunk/; revision=5256
-rw-r--r--shell/ChangeLog44
-rw-r--r--shell/Evolution-LocalStorage.idl26
-rw-r--r--shell/Evolution-Shell.idl12
-rw-r--r--shell/Evolution-Storage.idl6
-rw-r--r--shell/Evolution.idl3
-rw-r--r--shell/Makefile.am5
-rw-r--r--shell/e-local-storage.c40
-rw-r--r--shell/e-local-storage.h14
-rw-r--r--shell/e-shell.c43
-rw-r--r--shell/evolution-local-storage-client.c212
-rw-r--r--shell/evolution-local-storage-client.h71
-rw-r--r--shell/evolution-local-storage.c213
-rw-r--r--shell/evolution-local-storage.h78
-rw-r--r--shell/evolution-session.c2
-rw-r--r--shell/evolution-shell-component.c2
-rw-r--r--shell/evolution-shell-view.c2
-rw-r--r--shell/evolution-storage-listener.c305
-rw-r--r--shell/evolution-storage-listener.h86
-rw-r--r--shell/evolution-storage.c91
-rw-r--r--shell/evolution-storage.h39
20 files changed, 1240 insertions, 54 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 1c019cc6ee..fe823c91e6 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,47 @@
+2000-09-08 Ettore Perazzoli <ettore@helixcode.com>
+
+ * evolution-shell-view.c (destroy): Chain to the parent's
+ destroy method.
+
+ * evolution-shell-component.c (destroy): Chain to the parent's
+ destroy method.
+
+ * evolution-storage.c: `corba_storage_listener' in
+ `EvolutionStoragePrivate' replaced with a list of listeners,
+ `corba_storage_listeners'.
+ (init): Init to NULL.
+ (add_listener): New utility function.
+ (destroy): Destroy all the listeners.
+ (evolution_storage_new_folder): Notify all the listeners.
+ (evolution_storage_removed_folder): Likewise.
+
+ * e-local-storage.c: New member `bonobo_interface' in
+ `ELocalStoragePrivate'.
+ (init): Init to NULL.
+ (e_local_storage_get_corba_interface): New.
+
+ * e-shell.c: New member `local_storage' in `EShellPrivate'.
+ (init): Init to NULL.
+ (setup_local_storage): Make it point to the newly created local
+ storage.
+ (destroy): Unref if not NULL.
+ (impl_Shell_get_local_storage): New, implementation for
+ `Evolution::Shell::get_local_storage'.
+ (corba_class_init): Set it up.
+
+ * evolution-local-storage-client.c: New.
+ * evolution-local-storage-client.h: New.
+ * evolution-local-storage.c: New.
+ * evolution-local-storage.h: New.
+ * evolution-storage-listener.c: New.
+ * evolution-storage-listener.h: New.
+
+ * Evolution-Storage.idl: New method `Storage::add_listener'.
+
+ * Evolution-Shell.idl: New method `Shell::get_local_storage'.
+
+ * Evolution-LocalStorage.idl: New.
+
2000-09-02 Lauris Kaplinski <lauris@helixcode.com>
* e-shell-folder-creation-dialog.c: Use e_utf8 wrappers
diff --git a/shell/Evolution-LocalStorage.idl b/shell/Evolution-LocalStorage.idl
new file mode 100644
index 0000000000..0a31105c3e
--- /dev/null
+++ b/shell/Evolution-LocalStorage.idl
@@ -0,0 +1,26 @@
+/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Interface for the Evolution local storage.
+ *
+ * Authors:
+ * Ettore Perazzoli <ettore@helixcode.com>
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ */
+
+#include <Bonobo.idl>
+
+module Evolution {
+ interface LocalStorage : Evolution::Storage {
+ /**
+ * set_display_name:
+ * @path: Path of a folder within the storage.
+ * @display: Name to be displayed in the tree view for this folder
+ *
+ * Set the name to display for the folder at the specified
+ * @path.
+ */
+ void set_display_name (in string path,
+ in string display_name);
+ };
+};
diff --git a/shell/Evolution-Shell.idl b/shell/Evolution-Shell.idl
index bda5732537..d224cb0b27 100644
--- a/shell/Evolution-Shell.idl
+++ b/shell/Evolution-Shell.idl
@@ -51,6 +51,18 @@ module Evolution {
in string default_folder,
in FolderTypeList possible_types)
raises (Busy);
+
+ /**
+ * get_local_storage:
+ *
+ * Get the interface to the local storage.
+ *
+ * FIXME: Probably we just want to be able to request this to
+ * the StorageRegistry. This is an ugly kludge.
+ *
+ * Return value: the `Evolution::LocalStorage' interface for
+ * the local storage. */
+ LocalStorage get_local_storage ();
};
interface FolderSelectionListener {
diff --git a/shell/Evolution-Storage.idl b/shell/Evolution-Storage.idl
index 46c73e2654..0a2402a773 100644
--- a/shell/Evolution-Storage.idl
+++ b/shell/Evolution-Storage.idl
@@ -23,6 +23,10 @@ module Evolution {
interface Storage : Bonobo::Unknown {
attribute string name;
+
+ void add_listener (in StorageListener listener);
+
+ /* FIXME remove_listener? */
};
interface StorageListener {
@@ -31,6 +35,8 @@ module Evolution {
void destroyed ();
+ /* FIXME exceptions don't make much sense here... */
+
void new_folder (in string path, in Folder folder)
raises (Exists);
diff --git a/shell/Evolution.idl b/shell/Evolution.idl
index 2463d23b10..a81430848b 100644
--- a/shell/Evolution.idl
+++ b/shell/Evolution.idl
@@ -11,7 +11,8 @@
#include <Bonobo.idl>
#include <Evolution-Session.idl>
-#include <Evolution-Shell.idl>
#include <Evolution-ShellComponent.idl>
#include <Evolution-ShellView.idl>
#include <Evolution-Storage.idl>
+#include <Evolution-LocalStorage.idl>
+#include <Evolution-Shell.idl>
diff --git a/shell/Makefile.am b/shell/Makefile.am
index aa5a9156ba..b167fe3354 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -20,6 +20,7 @@ CLEANFILES = $(IDL_GENERATED)
IDLS = \
Evolution.idl \
+ Evolution-LocalStorage.idl \
Evolution-Session.idl \
Evolution-Shell.idl \
Evolution-ShellComponent.idl \
@@ -45,6 +46,8 @@ noinst_LIBRARIES = \
libeshell_a_SOURCES = \
$(IDL_GENERATED) \
+ evolution-local-storage.c \
+ evolution-local-storage.h \
evolution-session.c \
evolution-session.h \
evolution-shell-client.c \
@@ -55,6 +58,8 @@ libeshell_a_SOURCES = \
evolution-shell-component-client.h \
evolution-shell-view.c \
evolution-shell-view.h \
+ evolution-storage-listener.c \
+ evolution-storage-listener.h \
evolution-storage.c \
evolution-storage.h
diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c
index a66990f03a..5e78f05b9a 100644
--- a/shell/e-local-storage.c
+++ b/shell/e-local-storage.c
@@ -44,9 +44,13 @@
#include <gnome.h>
+#include <bonobo.h>
+
#include "e-util/e-util.h"
#include "e-local-folder.h"
+#include "evolution-local-storage.h"
+
#include "e-local-storage.h"
@@ -59,6 +63,7 @@ static EStorageClass *parent_class = NULL;
struct _ELocalStoragePrivate {
EFolderTypeRegistry *folder_type_registry;
char *base_path;
+ EvolutionLocalStorage *bonobo_interface;
};
@@ -362,17 +367,25 @@ impl_destroy (GtkObject *object)
{
ELocalStorage *local_storage;
ELocalStoragePrivate *priv;
+ CORBA_Environment ev;
local_storage = E_LOCAL_STORAGE (object);
priv = local_storage->priv;
+ CORBA_exception_init (&ev);
+
g_free (priv->base_path);
if (priv->folder_type_registry != NULL)
gtk_object_unref (GTK_OBJECT (priv->folder_type_registry));
-
+
+ if (priv->bonobo_interface != NULL)
+ bonobo_object_unref (BONOBO_OBJECT (priv->bonobo_interface));
+
g_free (priv);
+ CORBA_exception_free (&ev);
+
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -382,8 +395,7 @@ impl_destroy (GtkObject *object)
static const char *
impl_get_name (EStorage *storage)
{
- /* FIXME this sucks. */
- return "local";
+ return E_LOCAL_STORAGE_NAME;
}
static void
@@ -521,8 +533,9 @@ init (ELocalStorage *local_storage)
priv = g_new (ELocalStoragePrivate, 1);
- priv->base_path = NULL;
+ priv->base_path = NULL;
priv->folder_type_registry = NULL;
+ priv->bonobo_interface = NULL;
local_storage->priv = priv;
}
@@ -553,6 +566,9 @@ construct (ELocalStorage *local_storage,
g_assert (priv->base_path == NULL);
priv->base_path = g_strndup (base_path, base_path_len);
+ g_assert (priv->bonobo_interface == NULL);
+ priv->bonobo_interface = evolution_local_storage_new (E_LOCAL_STORAGE_NAME);
+
return load_all_folders (local_storage);
}
@@ -586,4 +602,20 @@ e_local_storage_get_base_path (ELocalStorage *local_storage)
}
+const Evolution_LocalStorage
+e_local_storage_get_corba_interface (ELocalStorage *local_storage)
+{
+ ELocalStoragePrivate *priv;
+ Evolution_LocalStorage corba_interface;
+
+ g_return_val_if_fail (local_storage != NULL, NULL);
+ g_return_val_if_fail (E_IS_LOCAL_STORAGE (local_storage), NULL);
+
+ priv = local_storage->priv;
+ corba_interface = bonobo_object_corba_objref (BONOBO_OBJECT (priv->bonobo_interface));
+
+ return corba_interface;
+}
+
+
E_MAKE_TYPE (e_local_storage, "ELocalStorage", ELocalStorage, class_init, init, PARENT_TYPE)
diff --git a/shell/e-local-storage.h b/shell/e-local-storage.h
index 14a48cbdd4..4abb72077c 100644
--- a/shell/e-local-storage.h
+++ b/shell/e-local-storage.h
@@ -57,10 +57,16 @@ struct _ELocalStorageClass {
};
-GtkType e_local_storage_get_type (void);
-EStorage *e_local_storage_open (EFolderTypeRegistry *folder_type_registry,
- const char *base_path);
-const char *e_local_storage_get_base_path (ELocalStorage *storage);
+#define E_LOCAL_STORAGE_NAME "local"
+
+
+GtkType e_local_storage_get_type (void);
+
+EStorage *e_local_storage_open (EFolderTypeRegistry *folder_type_registry,
+ const char *base_path);
+const char *e_local_storage_get_base_path (ELocalStorage *storage);
+
+const Evolution_LocalStorage e_local_storage_get_corba_interface (ELocalStorage *storage);
#ifdef __cplusplus
}
diff --git a/shell/e-shell.c b/shell/e-shell.c
index d8869a88b6..1623162dda 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -55,6 +55,8 @@ struct _EShellPrivate {
GList *views;
EStorageSet *storage_set;
+ ELocalStorage *local_storage;
+
EShortcuts *shortcuts;
EFolderTypeRegistry *folder_type_registry;
@@ -245,6 +247,28 @@ impl_Shell_user_select_folder (PortableServer_Servant servant,
gtk_widget_show (folder_selection_dialog);
}
+static Evolution_LocalStorage
+impl_Shell_get_local_storage (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ Evolution_LocalStorage local_storage_interface;
+ Evolution_LocalStorage copy_of_local_storage_interface;
+ EShell *shell;
+ EShellPrivate *priv;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ shell = E_SHELL (bonobo_object);
+ priv = shell->priv;
+
+ local_storage_interface = e_local_storage_get_corba_interface (priv->local_storage);
+
+ copy_of_local_storage_interface = CORBA_Object_duplicate (local_storage_interface, ev);
+ Bonobo_Unknown_ref (copy_of_local_storage_interface, ev);
+
+ return copy_of_local_storage_interface;
+}
+
/* Initialization of the storages. */
@@ -282,10 +306,11 @@ setup_local_storage (EShell *shell)
priv = shell->priv;
- local_storage_path = g_concat_dir_and_file (priv->local_directory,
- LOCAL_STORAGE_DIRECTORY);
- local_storage = e_local_storage_open (priv->folder_type_registry,
- local_storage_path);
+ g_assert (priv->folder_type_registry != NULL);
+ g_assert (priv->local_storage == NULL);
+
+ local_storage_path = g_concat_dir_and_file (priv->local_directory, LOCAL_STORAGE_DIRECTORY);
+ local_storage = e_local_storage_open (priv->folder_type_registry, local_storage_path);
if (local_storage == NULL) {
g_warning (_("Cannot set up local storage -- %s"), local_storage_path);
g_free (local_storage_path);
@@ -293,11 +318,8 @@ setup_local_storage (EShell *shell)
}
g_free (local_storage_path);
- g_assert (shell->priv->folder_type_registry);
-
e_storage_set_add_storage (priv->storage_set, local_storage);
-
- gtk_object_unref (GTK_OBJECT (local_storage));
+ priv->local_storage = E_LOCAL_STORAGE (local_storage);
return TRUE;
}
@@ -382,6 +404,9 @@ destroy (GtkObject *object)
if (priv->storage_set != NULL)
gtk_object_unref (GTK_OBJECT (priv->storage_set));
+ if (priv->local_storage != NULL)
+ gtk_object_unref (GTK_OBJECT (priv->local_storage));
+
if (priv->shortcuts != NULL)
gtk_object_unref (GTK_OBJECT (priv->shortcuts));
@@ -429,6 +454,7 @@ corba_class_init (void)
epv = g_new0 (POA_Evolution_Shell__epv, 1);
epv->get_component_for_type = impl_Shell_get_component_for_type;
epv->user_select_folder = impl_Shell_user_select_folder;
+ epv->get_local_storage = impl_Shell_get_local_storage;
vepv = &shell_vepv;
vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
@@ -469,6 +495,7 @@ init (EShell *shell)
priv->local_directory = NULL;
priv->storage_set = NULL;
+ priv->local_storage = NULL;
priv->shortcuts = NULL;
priv->component_registry = NULL;
priv->folder_type_registry = NULL;
diff --git a/shell/evolution-local-storage-client.c b/shell/evolution-local-storage-client.c
new file mode 100644
index 0000000000..08c0a6b96d
--- /dev/null
+++ b/shell/evolution-local-storage-client.c
@@ -0,0 +1,212 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-local-storage-client.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gnome.h>
+#include "evolution-local-storage-client.h"
+
+
+#define PARENT_TYPE gtk_object_get_type ()
+static GtkObjectClass *parent_class = NULL;
+
+struct _EvolutionLocalStorageClientPrivate {
+ Evolution_LocalStorage corba_local_storage;
+ Evolution_StorageListener corba_storage_listener;
+};
+
+enum {
+ NEW_FOLDER,
+ REMOVED_FOLDER,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+/* Listener interface. */
+
+static void
+setup_corba_storage_listener (EvolutionLocalStorageClient *client)
+{
+ EvolutionLocalStorageClientPrivate *priv;
+
+ priv = client->priv;
+
+ g_assert (priv->corba_storage_listener != NULL);
+}
+
+
+/* GtkObject methods. */
+
+static void
+impl_destroy (GtkObject *object)
+{
+ EvolutionLocalStorageClient *client;
+ EvolutionLocalStorageClientPriv *priv;
+ CORBA_Environment ev;
+
+ client = EVOLUTION_LOCAL_STORAGE_CLIENT (object);
+ priv = client->priv;
+
+ CORBA_exception_init (&ev);
+
+ if (! CORBA_Object_is_nil (priv->corba_local_storage, &ev)) {
+ Bonobo_Unknown_unref (priv->corba_local_storage, &ev);
+ CORBA_Object_release (priv->corba_local_storage, &ev);
+ }
+
+ if (! CORBA_Object_is_nil (priv->corba_storage_listener, &ev)) {
+ Bonobo_Unknown_unref (priv->corba_storage_listener, &ev);
+ CORBA_Object_release (priv->corba_storage_listener, &ev);
+ }
+
+ CORBA_exception_free (&ev);
+
+ g_free (priv);
+}
+
+
+static void
+class_init (EvolutionLocalStorageClientClass *klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ object_lass->destroy = impl_destroy;
+
+ signals[NEW_FOLDER] =
+ gtk_signal_new ("new_folder",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionLocalStorageClientClass, new_folder),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+ signals[REMOVED_FOLDER] =
+ gtk_signal_new ("removed_folder",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionLocalStorageClientClass, removed_folder),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gtk_object_class_add_signals (object_class, local_storage_client_signals, LAST_SIGNAL);
+}
+
+static void
+init (EvolutionLocalStorageClient *local_storage_client)
+{
+ EvolutionLocalStorageClientPrivate *priv;
+
+ priv = g_new (EvolutionLocalStorageClientPrivate, 1);
+ priv->corba_local_storage = CORBA_OBJECT_NIL;
+ priv->corba_storage_listener = CORBA_OBJECT_NIL;
+
+ local_storage_client->priv = priv;
+}
+
+
+/**
+ * evolution_local_storage_client_construct:
+ * @client: An EvolutionLocalStorageClient to be constructed
+ * @shell: An Evolution::Shell CORBA interface to get the local storage from
+ *
+ * Construct @client, associating it with @shell.
+ *
+ * Return value: %TRUE if successful, %FALSE otherwise.
+ **/
+gboolean
+evolution_local_storage_client_construct (EvolutionLocalStorageClient *client,
+ Evolution_Shell shell)
+{
+ EvolutionLocalStorageClientPrivate *priv;
+ Evolution_LocalStorage corba_local_storage;
+ CORBA_Environment ev;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (EVOLUTION_IS_LOCAL_STORAGE_CLIENT (client), FALSE);
+ g_return_val_if_fail (shell != CORBA_OBJECT_NIL, FALSE);
+
+ priv = client->priv;
+ g_return_val_if_fail (priv->local_storage == CORBA_OBJECT_NIL, FALSE);
+
+ CORBA_exception_init (&ev);
+
+ corba_local_storage = Evolution_Shell_get_local_storage (shell, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("EvolutionLocalStorageClient: The shell doesn't provide us with a ::LocalStorage interface.");
+ CORBA_exception_free (&ev);
+ return FALSE;
+ }
+
+ /* No dup, no ref as we assume ::get_local_storage did that. */
+ priv->corba_local_storage = corba_local_storage;
+
+ if (! setup_corba_storage_listener (client)) {
+ g_warning ("EvolutionLocalStorageClient: Cannot set up the listener interface.");
+ CORBA_exception_free (&ev);
+ return FALSE;
+ }
+
+ Evolution_Storage_add_listener (priv->corba_local_storage, priv->corba_storage_listener, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_warning ("EvolutionLocalStorageClient: Cannot add a listener.");
+ CORBA_exception_free (&ev);
+ return FALSE;
+ }
+
+ CORBA_exception_free (&ev);
+ return TRUE;
+}
+
+/**
+ * evolution_local_storage_client_new:
+ * @shell: An Evolution::Shell CORBA interface to get the local storage from
+ *
+ * Create a new local storage client object.
+ *
+ * Return value: The newly created EvolutionLocalStorageClient object.
+ **/
+EvolutionLocalStorageClient *
+evolution_local_storage_client_new (Evolution_Shell shell)
+{
+ EvolutionLocalStorageClient *client;
+
+ g_return_val_if_fail (shell != CORBA_OBJECT_NIL, NULL);
+
+ client = gtk_type_new (evolution_local_storage_client_get_type ());
+ if (! evolution_local_storage_client_construct (client, shell)) {
+ gtk_object_unref (GTK_OBJECT (client));
+ return NULL;
+ }
+
+ return client;
+}
+
+
+E_MAKE_TYPE (evolution_local_storage_client, "EvolutionLocalStorageClient", EvolutionLocalStorageClient,
+ class_init, init, PARENT_TYPE)
diff --git a/shell/evolution-local-storage-client.h b/shell/evolution-local-storage-client.h
new file mode 100644
index 0000000000..ed2883b8eb
--- /dev/null
+++ b/shell/evolution-local-storage-client.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-local-storage-client.h
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifndef __EVOLUTION_LOCAL_STORAGE_CLIENT_H__
+#define __EVOLUTION_LOCAL_STORAGE_CLIENT_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gnome.h>
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EVOLUTION_TYPE_LOCAL_STORAGE_CLIENT (evolution_local_storage_client_get_type ())
+#define EVOLUTION_LOCAL_STORAGE_CLIENT(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_LOCAL_STORAGE_CLIENT, EvolutionLocalStorageClient))
+#define EVOLUTION_LOCAL_STORAGE_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_LOCAL_STORAGE_CLIENT, EvolutionLocalStorageClientClass))
+#define EVOLUTION_IS_LOCAL_STORAGE_CLIENT(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_LOCAL_STORAGE_CLIENT))
+#define EVOLUTION_IS_LOCAL_STORAGE_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_LOCAL_STORAGE_CLIENT))
+
+
+typedef struct _EvolutionLocalStorageClient EvolutionLocalStorageClient;
+typedef struct _EvolutionLocalStorageClientPrivate EvolutionLocalStorageClientPrivate;
+typedef struct _EvolutionLocalStorageClientClass EvolutionLocalStorageClientClass;
+
+struct _EvolutionLocalStorageClient {
+ GtkObject parent;
+
+ EvolutionLocalStorageClientPrivate *priv;
+};
+
+struct _EvolutionLocalStorageClientClass {
+ GtkObjectClass parent_class;
+
+ /* Signals. */
+ void (* new_folder) (EvolutionLocalStorageClient *local_storage_client);
+ void (* removed_folder) (EvolutionLocalStorageClient *local_storage_client);
+};
+
+
+GtkType evolution_local_storage_client_get_type (void);
+EvolutionLocalStorageClient *evolution_local_storage_client_new (Evolution_Shell corba_shell);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __EVOLUTION_LOCAL_STORAGE_CLIENT_H__ */
diff --git a/shell/evolution-local-storage.c b/shell/evolution-local-storage.c
new file mode 100644
index 0000000000..2340bbfc93
--- /dev/null
+++ b/shell/evolution-local-storage.c
@@ -0,0 +1,213 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-local-storage.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gnome.h>
+
+#include "e-util/e-util.h"
+
+#include "evolution-local-storage.h"
+
+
+#define PARENT_TYPE evolution_storage_get_type ()
+static EvolutionStorageClass *parent_class = NULL;
+
+struct _EvolutionLocalStoragePrivate {
+ int dummy;
+};
+
+
+enum {
+ SET_DISPLAY_NAME,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+/* CORBA interface implementation. */
+
+static POA_Evolution_LocalStorage__vepv LocalStorage_vepv;
+
+static void
+impl_Evolution_LocalStorage_set_display_name (PortableServer_Servant servant,
+ const CORBA_char *path,
+ const CORBA_char *display_name,
+ CORBA_Environment *ev)
+{
+ BonoboObject *bonobo_object;
+ EvolutionLocalStorage *local_storage;
+
+ bonobo_object = bonobo_object_from_servant (servant);
+ local_storage = EVOLUTION_LOCAL_STORAGE (bonobo_object);
+
+ gtk_signal_emit (GTK_OBJECT (local_storage), signals[SET_DISPLAY_NAME], path, display_name);
+}
+
+static POA_Evolution_LocalStorage *
+create_servant (void)
+{
+ POA_Evolution_LocalStorage *servant;
+ CORBA_Environment ev;
+
+ servant = (POA_Evolution_LocalStorage *) g_new0 (BonoboObjectServant, 1);
+ servant->vepv = &LocalStorage_vepv;
+
+ CORBA_exception_init (&ev);
+
+ POA_Evolution_LocalStorage__init ((PortableServer_Servant) servant, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_free (servant);
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ CORBA_exception_free (&ev);
+
+ return servant;
+}
+
+
+/* GtkObject methods. */
+
+static void
+impl_destroy (GtkObject *object)
+{
+ EvolutionLocalStorage *local_storage;
+ EvolutionLocalStoragePrivate *priv;
+
+ local_storage = EVOLUTION_LOCAL_STORAGE (object);
+ priv = local_storage->priv;
+
+ g_free (priv);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
+static void
+corba_class_init (void)
+{
+ POA_Evolution_LocalStorage__vepv *vepv;
+ PortableServer_ServantBase__epv *base_epv;
+
+ base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
+ base_epv->_private = NULL;
+ base_epv->finalize = NULL;
+ base_epv->default_POA = NULL;
+
+ vepv = &LocalStorage_vepv;
+ vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
+ vepv->Evolution_Storage_epv = evolution_storage_get_epv ();
+ vepv->Evolution_LocalStorage_epv = evolution_local_storage_get_epv ();
+}
+
+static void
+class_init (EvolutionLocalStorageClass *klass)
+{
+ GtkObjectClass *object_class;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = impl_destroy;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ signals[SET_DISPLAY_NAME] = gtk_signal_new ("set_display_name",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionLocalStorageClass,
+ set_display_name),
+ gtk_marshal_NONE__POINTER_POINTER,
+ GTK_TYPE_NONE, 2,
+ GTK_TYPE_STRING,
+ GTK_TYPE_STRING);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+
+ corba_class_init ();
+}
+
+static void
+init (EvolutionLocalStorage *local_storage)
+{
+ EvolutionLocalStoragePrivate *priv;
+
+ priv = g_new (EvolutionLocalStoragePrivate, 1);
+
+ local_storage->priv = priv;
+}
+
+
+POA_Evolution_LocalStorage__epv *
+evolution_local_storage_get_epv (void)
+{
+ POA_Evolution_LocalStorage__epv *epv;
+
+ epv = g_new0 (POA_Evolution_LocalStorage__epv, 1);
+ epv->set_display_name = impl_Evolution_LocalStorage_set_display_name;
+
+ return epv;
+}
+
+void
+evolution_local_storage_construct (EvolutionLocalStorage *local_storage,
+ Evolution_LocalStorage corba_object,
+ const char *name)
+{
+ g_return_if_fail (local_storage != NULL);
+ g_return_if_fail (EVOLUTION_IS_LOCAL_STORAGE (local_storage));
+ g_return_if_fail (corba_object != CORBA_OBJECT_NIL);
+ g_return_if_fail (name != NULL);
+ g_return_if_fail (name[0] != '\0');
+
+ evolution_storage_construct (EVOLUTION_STORAGE (local_storage), corba_object, name);
+}
+
+EvolutionLocalStorage *
+evolution_local_storage_new (const char *name)
+{
+ EvolutionLocalStorage *new;
+ POA_Evolution_LocalStorage *servant;
+ Evolution_LocalStorage corba_object;
+
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (name[0] != '\0', NULL);
+
+ servant = create_servant ();
+ if (servant == NULL)
+ return NULL;
+
+ new = gtk_type_new (evolution_local_storage_get_type ());
+
+ corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (new), servant);
+ evolution_local_storage_construct (new, corba_object, name);
+
+ return new;
+}
+
+
+E_MAKE_TYPE (evolution_local_storage, "EvolutionLocalStorage", EvolutionLocalStorage,
+ class_init, init, PARENT_TYPE)
diff --git a/shell/evolution-local-storage.h b/shell/evolution-local-storage.h
new file mode 100644
index 0000000000..0034c33648
--- /dev/null
+++ b/shell/evolution-local-storage.h
@@ -0,0 +1,78 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-local-storage.h
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifndef __EVOLUTION_LOCAL_STORAGE_H__
+#define __EVOLUTION_LOCAL_STORAGE_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gnome.h>
+
+#include "evolution-storage.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EVOLUTION_TYPE_LOCAL_STORAGE (evolution_local_storage_get_type ())
+#define EVOLUTION_LOCAL_STORAGE(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_LOCAL_STORAGE, EvolutionLocalStorage))
+#define EVOLUTION_LOCAL_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_LOCAL_STORAGE, EvolutionLocalStorageClass))
+#define EVOLUTION_IS_LOCAL_STORAGE(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_LOCAL_STORAGE))
+#define EVOLUTION_IS_LOCAL_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_LOCAL_STORAGE))
+
+
+typedef struct _EvolutionLocalStorage EvolutionLocalStorage;
+typedef struct _EvolutionLocalStoragePrivate EvolutionLocalStoragePrivate;
+typedef struct _EvolutionLocalStorageClass EvolutionLocalStorageClass;
+
+struct _EvolutionLocalStorage {
+ EvolutionStorage parent;
+
+ EvolutionLocalStoragePrivate *priv;
+};
+
+struct _EvolutionLocalStorageClass {
+ EvolutionStorageClass parent_class;
+
+ void (* set_display_name) (EvolutionLocalStorage *local_storage,
+ const char *path,
+ const char *display_name);
+};
+
+
+POA_Evolution_LocalStorage__epv *evolution_local_storage_get_epv (void);
+
+GtkType evolution_local_storage_get_type (void);
+void evolution_local_storage_construct (EvolutionLocalStorage *local_storage,
+ Evolution_LocalStorage corba_object,
+ const char *name);
+EvolutionLocalStorage *evolution_local_storage_new (const char *name);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __EVOLUTION_LOCAL_STORAGE_H__ */
diff --git a/shell/evolution-session.c b/shell/evolution-session.c
index 1e0acb36b4..8d92f8fd56 100644
--- a/shell/evolution-session.c
+++ b/shell/evolution-session.c
@@ -145,6 +145,8 @@ class_init (EvolutionSessionClass *klass)
GTK_TYPE_NONE, 1,
GTK_TYPE_STRING);
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+
corba_class_init ();
}
diff --git a/shell/evolution-shell-component.c b/shell/evolution-shell-component.c
index cedcf64b98..ed83895392 100644
--- a/shell/evolution-shell-component.c
+++ b/shell/evolution-shell-component.c
@@ -327,6 +327,8 @@ destroy (GtkObject *object)
g_list_free (priv->folder_types);
g_free (priv);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
diff --git a/shell/evolution-shell-view.c b/shell/evolution-shell-view.c
index 8ace962f1b..cef3287851 100644
--- a/shell/evolution-shell-view.c
+++ b/shell/evolution-shell-view.c
@@ -108,6 +108,8 @@ destroy (GtkObject *object)
priv = shell_view->priv;
g_free (priv);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
diff --git a/shell/evolution-storage-listener.c b/shell/evolution-storage-listener.c
new file mode 100644
index 0000000000..e051c1d2ea
--- /dev/null
+++ b/shell/evolution-storage-listener.c
@@ -0,0 +1,305 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-storage-listener.c
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gnome.h>
+#include <bonobo.h>
+
+#include "e-util/e-util.h"
+
+#include "evolution-storage-listener.h"
+
+
+#define PARENT_TYPE gtk_object_get_type ()
+static GtkObjectClass *parent_class = NULL;
+
+struct _EvolutionStorageListenerPrivate {
+ Evolution_StorageListener corba_objref;
+ EvolutionStorageListenerServant *servant;
+};
+
+
+enum {
+ DESTROYED,
+ NEW_FOLDER,
+ REMOVED_FOLDER,
+ LAST_SIGNAL
+};
+static guint signals[LAST_SIGNAL] = { 0 };
+
+
+/* Evolution::StorageListener implementation. */
+
+static POA_Evolution_StorageListener__vepv my_Evolution_StorageListener_vepv;
+
+static EvolutionStorageListener *
+gtk_object_from_servant (PortableServer_Servant servant)
+{
+ EvolutionStorageListenerServant *my_servant;
+
+ my_servant = (EvolutionStorageListenerServant *) servant;
+ return my_servant->gtk_object;
+}
+
+static void
+impl_Evolution_StorageListener_destroyed (PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ EvolutionStorageListener *listener;
+ EvolutionStorageListenerPrivate *priv;
+
+ listener = gtk_object_from_servant (servant);
+ priv = listener->priv;
+
+ gtk_signal_emit (GTK_OBJECT (listener), signals[DESTROYED]);
+}
+
+static void
+impl_Evolution_StorageListener_new_folder (PortableServer_Servant servant,
+ const CORBA_char *path,
+ const Evolution_Folder *folder,
+ CORBA_Environment *ev)
+{
+ EvolutionStorageListener *listener;
+ EvolutionStorageListenerPrivate *priv;
+
+ listener = gtk_object_from_servant (servant);
+ priv = listener->priv;
+
+ gtk_signal_emit (GTK_OBJECT (listener), signals[NEW_FOLDER], path, folder);
+}
+
+static void
+impl_Evolution_StorageListener_removed_folder (PortableServer_Servant servant,
+ const CORBA_char *path,
+ CORBA_Environment *ev)
+{
+ EvolutionStorageListener *listener;
+ EvolutionStorageListenerPrivate *priv;
+
+ listener = gtk_object_from_servant (servant);
+ priv = listener->priv;
+
+ gtk_signal_emit (GTK_OBJECT (listener), signals[REMOVED_FOLDER], path);
+}
+
+static POA_Evolution_StorageListener *
+create_servant (EvolutionStorageListener *listener)
+{
+ EvolutionStorageListenerServant *servant;
+ POA_Evolution_StorageListener *corba_servant;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ servant = g_new (EvolutionStorageListenerServant, 1);
+ corba_servant = (POA_Evolution_StorageListener *) servant;
+
+ corba_servant->vepv = &my_Evolution_StorageListener_vepv;
+ POA_Evolution_StorageListener__init ((PortableServer_Servant) corba_servant, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ g_free (servant);
+ CORBA_exception_free (&ev);
+ return NULL;
+ }
+
+ servant->gtk_object = listener;
+
+ CORBA_exception_free (&ev);
+
+ return (POA_Evolution_StorageListener *) servant;
+}
+
+static Evolution_StorageListener
+activate_servant (EvolutionStorageListener *listener,
+ POA_Evolution_StorageListener *servant)
+{
+ Evolution_StorageListener corba_object;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), servant, &ev));
+
+ corba_object = PortableServer_POA_servant_to_reference (bonobo_poa(), servant, &ev);
+
+ if (ev._major == CORBA_NO_EXCEPTION && ! CORBA_Object_is_nil (corba_object, &ev)) {
+ CORBA_exception_free (&ev);
+ return corba_object;
+ }
+
+ CORBA_exception_free (&ev);
+
+ return CORBA_OBJECT_NIL;
+}
+
+
+/* GtkObject methods. */
+
+static void
+impl_destroy (GtkObject *object)
+{
+ EvolutionStorageListener *storage_listener;
+ EvolutionStorageListenerPrivate *priv;
+ CORBA_Environment ev;
+
+ storage_listener = EVOLUTION_STORAGE_LISTENER (object);
+ priv = storage_listener->priv;
+
+ CORBA_exception_init (&ev);
+
+ if (priv->corba_objref != CORBA_OBJECT_NIL)
+ CORBA_Object_release (priv->corba_objref, &ev);
+
+ if (priv->servant != NULL) {
+ PortableServer_ObjectId *object_id;
+
+ object_id = PortableServer_POA_servant_to_id (bonobo_poa(), priv->servant, &ev);
+ PortableServer_POA_deactivate_object (bonobo_poa (), object_id, &ev);
+ CORBA_free (object_id);
+
+ POA_Evolution_StorageListener__fini (priv->servant, &ev);
+ }
+
+ CORBA_exception_free (&ev);
+
+ g_free (priv);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
+}
+
+
+static void
+corba_class_init (void)
+{
+ POA_Evolution_StorageListener__vepv *vepv;
+ POA_Evolution_StorageListener__epv *epv;
+ PortableServer_ServantBase__epv *base_epv;
+
+ base_epv = g_new0 (PortableServer_ServantBase__epv, 1);
+ base_epv->_private = NULL;
+ base_epv->finalize = NULL;
+ base_epv->default_POA = NULL;
+
+ epv = g_new0 (POA_Evolution_StorageListener__epv, 1);
+ epv->destroyed = impl_Evolution_StorageListener_destroyed;
+ epv->new_folder = impl_Evolution_StorageListener_new_folder;
+ epv->removed_folder = impl_Evolution_StorageListener_removed_folder;
+
+ vepv = & my_Evolution_StorageListener_vepv;
+ vepv->_base_epv = base_epv;
+ vepv->Evolution_StorageListener_epv = epv;
+}
+
+static void
+class_init (EvolutionStorageListenerClass *klass)
+{
+ GtkObjectClass *object_class;
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = impl_destroy;
+
+ signals[DESTROYED] = gtk_signal_new ("destroyed",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionStorageListenerClass, destroyed),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ signals[NEW_FOLDER] = gtk_signal_new ("new_folder",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionStorageListenerClass, new_folder),
+ gtk_marshal_NONE__POINTER_POINTER,
+ GTK_TYPE_NONE, 2,
+ GTK_TYPE_STRING,
+ GTK_TYPE_POINTER);
+
+ signals[REMOVED_FOLDER] = gtk_signal_new ("removed_folder",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EvolutionStorageListenerClass, removed_folder),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_STRING);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
+
+ corba_class_init ();
+}
+
+static void
+init (EvolutionStorageListener *storage_listener)
+{
+ EvolutionStorageListenerPrivate *priv;
+
+ priv = g_new (EvolutionStorageListenerPrivate, 1);
+ priv->corba_objref = CORBA_OBJECT_NIL;
+
+ storage_listener->priv = priv;
+}
+
+
+void
+evolution_storage_listener_construct (EvolutionStorageListener *listener,
+ Evolution_StorageListener corba_objref)
+{
+ EvolutionStorageListenerPrivate *priv;
+
+ g_return_if_fail (listener != NULL);
+ g_return_if_fail (corba_objref != CORBA_OBJECT_NIL);
+
+ priv = listener->priv;
+
+ g_return_if_fail (priv->corba_objref == CORBA_OBJECT_NIL);
+
+ priv->corba_objref = corba_objref;
+}
+
+EvolutionStorageListener *
+evolution_storage_listener_new (void)
+{
+ EvolutionStorageListener *new;
+ EvolutionStorageListenerPrivate *priv;
+ Evolution_StorageListener corba_objref;
+ POA_Evolution_StorageListener *servant;
+
+ new = gtk_type_new (evolution_storage_listener_get_type ());
+ priv = new->priv;
+
+ priv->servant = create_servant (new);
+ corba_objref = activate_servant (new, servant);
+
+ evolution_storage_listener_construct (new, corba_objref);
+
+ return new;
+}
+
+
+E_MAKE_TYPE (evolution_storage_listener, "EvolutionStorageListener", EvolutionStorageListener,
+ class_init, init, PARENT_TYPE)
diff --git a/shell/evolution-storage-listener.h b/shell/evolution-storage-listener.h
new file mode 100644
index 0000000000..3ac48f0803
--- /dev/null
+++ b/shell/evolution-storage-listener.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* evolution-storage-listener.h
+ *
+ * Copyright (C) 2000 Helix Code, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Author: Ettore Perazzoli
+ */
+
+#ifndef __EVOLUTION_STORAGE_LISTENER_H__
+#define __EVOLUTION_STORAGE_LISTENER_H__
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gnome.h>
+
+#include "Evolution.h"
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#define EVOLUTION_TYPE_STORAGE_LISTENER (evolution_storage_listener_get_type ())
+#define EVOLUTION_STORAGE_LISTENER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_STORAGE_LISTENER, EvolutionStorageListener))
+#define EVOLUTION_STORAGE_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_STORAGE_LISTENER, EvolutionStorageListenerClass))
+#define EVOLUTION_IS_STORAGE_LISTENER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_STORAGE_LISTENER))
+#define EVOLUTION_IS_STORAGE_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_STORAGE_LISTENER))
+
+
+typedef struct _EvolutionStorageListener EvolutionStorageListener;
+typedef struct _EvolutionStorageListenerPrivate EvolutionStorageListenerPrivate;
+typedef struct _EvolutionStorageListenerClass EvolutionStorageListenerClass;
+
+struct _EvolutionStorageListener {
+ GtkObject parent;
+
+ EvolutionStorageListenerPrivate *priv;
+};
+
+struct _EvolutionStorageListenerClass {
+ GtkObjectClass parent_class;
+
+ /* Signals. */
+ void (* destroyed) (EvolutionStorageListener *storage_listener);
+ void (* new_folder) (EvolutionStorageListener *storage_listener,
+ const char *path,
+ const Evolution_Folder *folder);
+ void (* removed_folder) (EvolutionStorageListener *storage_listener,
+ const char *path);
+};
+
+
+struct _EvolutionStorageListenerServant {
+ POA_Evolution_StorageListener servant_placeholder;
+ EvolutionStorageListener *gtk_object;
+};
+typedef struct _EvolutionStorageListenerServant EvolutionStorageListenerServant;
+
+
+GtkType evolution_storage_listener_get_type (void);
+void evolution_storage_listener_construct (EvolutionStorageListener *listener,
+ Evolution_StorageListener corba_objref);
+EvolutionStorageListener *evolution_storage_listener_new (void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __EVOLUTION_STORAGE_LISTENER_H__ */
diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c
index 670765482c..8e3374158f 100644
--- a/shell/evolution-storage.c
+++ b/shell/evolution-storage.c
@@ -40,10 +40,39 @@ static BonoboObjectClass *parent_class = NULL;
struct _EvolutionStoragePrivate {
char *name;
- Evolution_StorageListener corba_storage_listener;
+ GList *corba_storage_listeners;
};
+/* Utility functions. */
+
+static void
+add_listener (EvolutionStorage *storage,
+ const Evolution_StorageListener listener)
+{
+ EvolutionStoragePrivate *priv;
+ Evolution_StorageListener listener_copy;
+ CORBA_Environment ev;
+
+ priv = storage->priv;
+
+ CORBA_exception_init (&ev);
+
+ listener_copy = CORBA_Object_duplicate (listener, &ev);
+ if (ev._major != CORBA_NO_EXCEPTION) {
+ /* Panic. */
+ g_warning ("EvolutionStorage -- Cannot duplicate listener.");
+ CORBA_exception_free (&ev);
+ return;
+ }
+
+ priv->corba_storage_listeners = g_list_prepend (priv->corba_storage_listeners,
+ listener_copy);
+
+ CORBA_exception_free (&ev);
+}
+
+
/* CORBA interface implementation. */
static POA_Evolution_Storage__vepv Storage_vepv;
@@ -95,6 +124,7 @@ destroy (GtkObject *object)
EvolutionStorage *storage;
EvolutionStoragePrivate *priv;
CORBA_Environment ev;
+ GList *p;
storage = EVOLUTION_STORAGE (object);
priv = storage->priv;
@@ -103,16 +133,24 @@ destroy (GtkObject *object)
CORBA_exception_init (&ev);
- if (priv->corba_storage_listener != CORBA_OBJECT_NIL) {
- Evolution_StorageListener_destroyed (priv->corba_storage_listener, &ev);
+ for (p = priv->corba_storage_listeners; p != NULL; p = p->next) {
+ Evolution_StorageListener listener;
+
+ listener = p->data;
+
+ Evolution_StorageListener_destroyed (listener, &ev);
/* (This is not a Bonobo object, so no unref.) */
- CORBA_Object_release (priv->corba_storage_listener, &ev);
+ CORBA_Object_release (listener, &ev);
}
+ g_list_free (priv->corba_storage_listeners);
+
CORBA_exception_free (&ev);
g_free (priv);
+
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -128,12 +166,9 @@ corba_class_init (void)
base_epv->finalize = NULL;
base_epv->default_POA = NULL;
- epv = g_new0 (POA_Evolution_Storage__epv, 1);
- epv->_get_name = impl_Storage__get_name;
-
vepv = &Storage_vepv;
vepv->Bonobo_Unknown_epv = bonobo_object_get_epv ();
- vepv->Evolution_Storage_epv = epv;
+ vepv->Evolution_Storage_epv = evolution_storage_get_epv ();
}
static void
@@ -155,13 +190,24 @@ init (EvolutionStorage *storage)
EvolutionStoragePrivate *priv;
priv = g_new (EvolutionStoragePrivate, 1);
- priv->name = NULL;
- priv->corba_storage_listener = NULL;
+ priv->name = NULL;
+ priv->corba_storage_listeners = NULL;
storage->priv = priv;
}
+POA_Evolution_Storage__epv *
+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;
+
+ return epv;
+}
+
void
evolution_storage_construct (EvolutionStorage *storage,
Evolution_Storage corba_object,
@@ -222,7 +268,7 @@ evolution_storage_register (EvolutionStorage *evolution_storage,
priv = evolution_storage->priv;
- if (priv->corba_storage_listener != CORBA_OBJECT_NIL)
+ if (priv->corba_storage_listeners != NULL)
return EVOLUTION_STORAGE_ERROR_ALREADYREGISTERED;
CORBA_exception_init (&ev);
@@ -233,7 +279,7 @@ evolution_storage_register (EvolutionStorage *evolution_storage,
priv->name, &ev);
if (ev._major == CORBA_NO_EXCEPTION) {
- priv->corba_storage_listener = corba_storage_listener;
+ add_listener (evolution_storage, corba_storage_listener);
result = EVOLUTION_STORAGE_OK;
} else {
if (ev._major != CORBA_USER_EXCEPTION)
@@ -296,6 +342,7 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage,
EvolutionStoragePrivate *priv;
Evolution_Folder corba_folder;
CORBA_Environment ev;
+ GList *p;
const char *path_basename;
g_return_val_if_fail (evolution_storage != NULL,
@@ -320,10 +367,12 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage,
CORBA_exception_init (&ev);
- Evolution_StorageListener_new_folder (priv->corba_storage_listener,
- path,
- &corba_folder,
- &ev);
+ 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);
+ }
if (ev._major == CORBA_NO_EXCEPTION)
result = EVOLUTION_STORAGE_OK;
@@ -346,6 +395,7 @@ evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
EvolutionStorageResult result;
EvolutionStoragePrivate *priv;
CORBA_Environment ev;
+ GList *p;
g_return_val_if_fail (evolution_storage != NULL,
EVOLUTION_STORAGE_ERROR_INVALIDPARAMETER);
@@ -356,12 +406,17 @@ evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
priv = evolution_storage->priv;
- if (priv->corba_storage_listener == CORBA_OBJECT_NIL)
+ if (priv->corba_storage_listeners == NULL)
return EVOLUTION_STORAGE_ERROR_NOTREGISTERED;
CORBA_exception_init (&ev);
- Evolution_StorageListener_removed_folder (priv->corba_storage_listener, path, &ev);
+ 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;
diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h
index ff36bef3c0..d32b716f86 100644
--- a/shell/evolution-storage.h
+++ b/shell/evolution-storage.h
@@ -72,25 +72,26 @@ struct _EvolutionStorageClass {
};
-GtkType evolution_storage_get_type (void);
-void evolution_storage_construct (EvolutionStorage *storage,
- Evolution_Storage corba_object,
- const char *name);
-EvolutionStorage *evolution_storage_new (const char *name);
-
-EvolutionStorageResult evolution_storage_register (EvolutionStorage *storage,
- Evolution_StorageRegistry corba_registry);
-EvolutionStorageResult evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
- Evolution_Shell corba_shell);
-
-EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage *evolution_storage,
- const char *path,
- const char *display_name,
- const char *type,
- const char *physical_uri,
- const char *description);
-EvolutionStorageResult evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
- const char *path);
+POA_Evolution_Storage__epv *evolution_storage_get_epv (void);
+
+GtkType evolution_storage_get_type (void);
+void evolution_storage_construct (EvolutionStorage *storage,
+ Evolution_Storage corba_object,
+ const char *name);
+EvolutionStorage *evolution_storage_new (const char *name);
+
+EvolutionStorageResult evolution_storage_register (EvolutionStorage *storage,
+ Evolution_StorageRegistry corba_registry);
+EvolutionStorageResult evolution_storage_register_on_shell (EvolutionStorage *evolution_storage,
+ Evolution_Shell corba_shell);
+EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage *evolution_storage,
+ const char *path,
+ const char *display_name,
+ const char *type,
+ const char *physical_uri,
+ const char *description);
+EvolutionStorageResult evolution_storage_removed_folder (EvolutionStorage *evolution_storage,
+ const char *path);
#ifdef __cplusplus
}