aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wombat/ChangeLog12
-rw-r--r--wombat/GNOME_Evolution_WombatLDAP.oaf.in21
-rw-r--r--wombat/GNOME_Evolution_WombatNOLDAP.oaf.in21
-rw-r--r--wombat/Makefile.am8
-rw-r--r--wombat/wombat-private-moniker.c171
-rw-r--r--wombat/wombat-private-moniker.h11
-rw-r--r--wombat/wombat.c24
7 files changed, 263 insertions, 5 deletions
diff --git a/wombat/ChangeLog b/wombat/ChangeLog
index 1daa19d3bc..ecedb46a35 100644
--- a/wombat/ChangeLog
+++ b/wombat/ChangeLog
@@ -1,3 +1,15 @@
+2001-10-11 Chris Toshok <toshok@ximian.com>
+
+ * Makefile.am (wombat_SOURCES): add wombat-private-moniker.[ch].
+
+ * GNOME_Evolution_WombatLDAP.oaf.in: add wombat-private
+ factory/moniker.
+
+ * GNOME_Evolution_WombatNOLDAP.oaf.in: same.
+
+ * wombat-private-moniker.[ch]: xmldb for private database -- non
+ configuration settings, basically.
+
2001-10-02 Chris Toshok <toshok@ximian.com>
* GNOME_Evolution_WombatNOLDAP.oaf.in: add
diff --git a/wombat/GNOME_Evolution_WombatLDAP.oaf.in b/wombat/GNOME_Evolution_WombatLDAP.oaf.in
index 6413a5b720..9fc4ec2602 100644
--- a/wombat/GNOME_Evolution_WombatLDAP.oaf.in
+++ b/wombat/GNOME_Evolution_WombatLDAP.oaf.in
@@ -52,4 +52,25 @@
</oaf_attribute>
</oaf_server>
+
+<oaf_server iid="OAFIID:Bonobo_Moniker_wombat_private_Factory" type="exe" location="wombat">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="name" type="string" value="Private XML Database Moniker factory"/>
+</oaf_server>
+
+<oaf_server iid="OAFIID:Bonobo_Moniker_wombat_private" type="factory"
+ location="OAFIID:Bonobo_Moniker_wombat_private_Factory">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Bonobo/Moniker:1.0"/>
+ <item value="IDL:Bonobo/Unknown:1.0"/>
+ </oaf_attribute>
+ <oaf_attribute name="name" type="string" value="wombat-private Moniker"/>
+ <oaf_attribute name="bonobo:moniker" type="stringv">
+ <item value="wombat-private:"/>
+ </oaf_attribute>
+</oaf_server>
+
</oaf_info>
diff --git a/wombat/GNOME_Evolution_WombatNOLDAP.oaf.in b/wombat/GNOME_Evolution_WombatNOLDAP.oaf.in
index 60f897a98f..88671c411e 100644
--- a/wombat/GNOME_Evolution_WombatNOLDAP.oaf.in
+++ b/wombat/GNOME_Evolution_WombatNOLDAP.oaf.in
@@ -51,4 +51,25 @@
</oaf_attribute>
</oaf_server>
+
+<oaf_server iid="OAFIID:Bonobo_Moniker_wombat_private_Factory" type="exe" location="wombat">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:GNOME/GenericFactory:1.0"/>
+ </oaf_attribute>
+
+ <oaf_attribute name="name" type="string" value="Private XML Database Moniker factory"/>
+</oaf_server>
+
+<oaf_server iid="OAFIID:Bonobo_Moniker_wombat_private" type="factory"
+ location="OAFIID:Bonobo_Moniker_wombat_private_Factory">
+ <oaf_attribute name="repo_ids" type="stringv">
+ <item value="IDL:Bonobo/Moniker:1.0"/>
+ <item value="IDL:Bonobo/Unknown:1.0"/>
+ </oaf_attribute>
+ <oaf_attribute name="name" type="string" value="wombat-private Moniker"/>
+ <oaf_attribute name="bonobo:moniker" type="stringv">
+ <item value="wombat-private:"/>
+ </oaf_attribute>
+</oaf_server>
+
</oaf_info>
diff --git a/wombat/Makefile.am b/wombat/Makefile.am
index 648d199d30..2f1dea004c 100644
--- a/wombat/Makefile.am
+++ b/wombat/Makefile.am
@@ -17,9 +17,11 @@ INCLUDES = \
bin_PROGRAMS = \
wombat
-wombat_SOURCES = \
- wombat-moniker.c \
- wombat-moniker.h \
+wombat_SOURCES = \
+ wombat-moniker.c \
+ wombat-moniker.h \
+ wombat-private-moniker.c \
+ wombat-private-moniker.h \
wombat.c
wombat_LDADD = \
diff --git a/wombat/wombat-private-moniker.c b/wombat/wombat-private-moniker.c
new file mode 100644
index 0000000000..ae790f39ed
--- /dev/null
+++ b/wombat/wombat-private-moniker.c
@@ -0,0 +1,171 @@
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <bonobo/bonobo-moniker-simple.h>
+#include <bonobo/bonobo-moniker-util.h>
+#include <bonobo/bonobo-exception.h>
+#include <bonobo/bonobo-storage.h>
+#include "wombat-private-moniker.h"
+
+#define USER_DB_URL "xmldb:~/evolution/private/config.xmldb"
+
+#define DB_URL (USER_DB_URL)
+
+static Bonobo_Storage
+wombat_private_root_storage (CORBA_Environment *ev)
+{
+ static BonoboStorage *root = NULL;
+ char *path;
+
+ if (!root) {
+ path = g_strconcat (g_get_home_dir (), "/evolution/private/config",
+ NULL);
+
+ root = bonobo_storage_open_full (BONOBO_IO_DRIVER_FS, path,
+ Bonobo_Storage_CREATE, 0664,
+ ev);
+
+ g_free (path);
+
+ if (BONOBO_EX (ev) || !root)
+ return CORBA_OBJECT_NIL;
+ }
+
+ return BONOBO_OBJREF (root);
+}
+
+static Bonobo_Storage
+wombat_private_lookup_storage (const char *name,
+ CORBA_Environment *ev)
+{
+ Bonobo_Storage root;
+
+ if ((root = wombat_private_root_storage (ev)) == CORBA_OBJECT_NIL)
+ return CORBA_OBJECT_NIL;
+
+ if (!strcmp (name, ""))
+ return bonobo_object_dup_ref (root, ev);
+
+ return Bonobo_Storage_openStorage (root, name, Bonobo_Storage_CREATE,
+ ev);
+}
+
+static Bonobo_Storage
+wombat_private_lookup_stream (const char *name,
+ CORBA_Environment *ev)
+{
+ Bonobo_Storage root;
+
+ if (!strcmp (name, "")) {
+ bonobo_exception_set (ev, ex_Bonobo_Storage_NotFound);
+ return CORBA_OBJECT_NIL;
+ }
+
+ if ((root = wombat_private_root_storage (ev)) == CORBA_OBJECT_NIL)
+ return CORBA_OBJECT_NIL;
+
+
+ return Bonobo_Storage_openStream (root, name, Bonobo_Storage_CREATE,
+ ev);
+}
+
+static CORBA_Object
+wombat_private_lookup_db (CORBA_Environment *ev)
+{
+ static CORBA_Object db = CORBA_OBJECT_NIL;
+
+ /* kinda crappy, but make sure permissions for the directory
+ are correct whenever someone new opens the db. */
+ char *private_dir_path;
+
+ private_dir_path = g_strconcat (g_get_home_dir (),
+ "/evolution/private",
+ NULL);
+ chmod (private_dir_path, 0700);
+ g_free (private_dir_path);
+
+ if (db == CORBA_OBJECT_NIL)
+ db = bonobo_get_object (DB_URL,
+ "IDL:Bonobo/ConfigDatabase:1.0", ev);
+
+ bonobo_object_dup_ref (db, ev);
+
+ return db;
+}
+
+static Bonobo_Unknown
+wombat_private_moniker_resolve (BonoboMoniker *moniker,
+ const Bonobo_ResolveOptions *options,
+ const CORBA_char *interface,
+ CORBA_Environment *ev)
+{
+ CORBA_Object db;
+ Bonobo_Moniker parent;
+ const gchar *name;
+ Bonobo_Storage storage;
+ Bonobo_Stream stream;
+
+ parent = bonobo_moniker_get_parent (moniker, ev);
+ if (BONOBO_EX (ev))
+ return CORBA_OBJECT_NIL;
+
+ name = bonobo_moniker_get_name (moniker);
+
+ if (parent != CORBA_OBJECT_NIL) {
+
+ g_warning ("wombat: parent moniker are not supproted");
+
+ bonobo_object_release_unref (parent, ev);
+
+ bonobo_exception_set (ev, ex_Bonobo_Moniker_InterfaceNotFound);
+
+ return CORBA_OBJECT_NIL;
+ }
+
+ if (!strcmp (interface, "IDL:Bonobo/Storage:1.0")) {
+
+ storage = wombat_private_lookup_storage (name, ev);
+
+ return storage;
+ }
+
+ if (!strcmp (interface, "IDL:Bonobo/Stream:1.0")) {
+
+ stream = wombat_private_lookup_stream (name, ev);
+
+ return stream;
+ }
+
+ if (!strcmp (interface, "IDL:Bonobo/ConfigDatabase:1.0")) {
+
+ if (strcmp (name, ""))
+ g_warning ("wombat: unused moniker name");
+
+ if ((db = wombat_private_lookup_db (ev)) != CORBA_OBJECT_NIL)
+ return db;
+ }
+
+ bonobo_exception_set (ev, ex_Bonobo_Moniker_InterfaceNotFound);
+ return CORBA_OBJECT_NIL;
+}
+
+BonoboObject *
+wombat_private_moniker_factory (BonoboGenericFactory *this,
+ const char *object_id,
+ void *data)
+{
+ g_return_val_if_fail (object_id != NULL, NULL);
+
+ if (!strcmp (object_id, "OAFIID:Bonobo_Moniker_wombat_private"))
+
+ return BONOBO_OBJECT (bonobo_moniker_simple_new (
+ "wombat-private:", wombat_private_moniker_resolve));
+
+ else
+ g_warning ("Failing to manufacture a '%s'", object_id);
+
+ return NULL;
+}
+
diff --git a/wombat/wombat-private-moniker.h b/wombat/wombat-private-moniker.h
new file mode 100644
index 0000000000..2c2bbbca8e
--- /dev/null
+++ b/wombat/wombat-private-moniker.h
@@ -0,0 +1,11 @@
+#ifndef _MONIKER_WOMBAT_PRIVATE_H_
+#define _MONIKER_WOMBAT_PRIVATE_H_
+
+#include <bonobo/bonobo-generic-factory.h>
+
+BonoboObject *
+wombat_private_moniker_factory (BonoboGenericFactory *this,
+ const char *object_id,
+ void *data);
+
+#endif
diff --git a/wombat/wombat.c b/wombat/wombat.c
index 3e40e2dc13..65f0b6f479 100644
--- a/wombat/wombat.c
+++ b/wombat/wombat.c
@@ -29,6 +29,7 @@
#endif
#include "wombat-moniker.h"
+#include "wombat-private-moniker.h"
#define CAL_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_CalendarFactory"
#define PAS_BOOK_FACTORY_OAF_ID "OAFIID:GNOME_Evolution_Wombat_ServerFactory"
@@ -169,6 +170,22 @@ setup_config (int argc, char **argv)
return TRUE;
}
+static gboolean
+setup_private (int argc, char **argv)
+{
+ BonoboGenericFactory *factory;
+ char *oafiid = "OAFIID:Bonobo_Moniker_wombat_private_Factory";
+
+ factory = bonobo_generic_factory_new_multi (oafiid,
+ wombat_private_moniker_factory,
+ NULL);
+
+ // bonobo_running_context_auto_exit_unref (BONOBO_OBJECT (factory));
+
+
+ return TRUE;
+}
+
static void
setup_vfs (int argc, char **argv)
{
@@ -206,7 +223,7 @@ init_bonobo (int *argc, char **argv)
int
main (int argc, char **argv)
{
- gboolean did_pas=FALSE, did_pcs=FALSE, did_config=FALSE;
+ gboolean did_pas=FALSE, did_pcs=FALSE, did_config=FALSE, did_private=FALSE;
bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR);
textdomain (PACKAGE);
@@ -222,7 +239,8 @@ main (int argc, char **argv)
if (!( (did_pas = setup_pas (argc, argv))
&& (did_pcs = setup_pcs (argc, argv))
- && (did_config = setup_config (argc, argv)))) {
+ && (did_config = setup_config (argc, argv))
+ && (did_private = setup_private (argc, argv)))) {
const gchar *failed = NULL;
@@ -232,6 +250,8 @@ main (int argc, char **argv)
failed = "PCS";
else if (!did_config)
failed = "Config";
+ else if (!did_private)
+ failed = "Private Config";
g_message ("main(): could not initialize Wombat service \"%s\"; terminating", failed);