diff options
author | Elliot Lee <sopwith@src.gnome.org> | 1999-11-19 17:38:13 +0000 |
---|---|---|
committer | Elliot Lee <sopwith@src.gnome.org> | 1999-11-19 17:38:13 +0000 |
commit | 5351638c91d603d44599e842e727fd98465d9006 (patch) | |
tree | ea32f2998524ce10df9837ea5b985748ecced818 | |
parent | 0d3b389ceffcf06976f0a4d36856ebacd5735d02 (diff) | |
download | gconf-5351638c91d603d44599e842e727fd98465d9006.tar.gz |
Make it all use OAF, and redo the initialization routine(s) to fit betterPOST_OAF_CONVERSION
* Make it all use OAF, and redo the initialization routine(s) to fit better into the
GnomeModuleInfo system.
-rw-r--r-- | ChangeLog | 4 | ||||
-rwxr-xr-x | autogen.sh | 4 | ||||
-rw-r--r-- | backends/Makefile.am | 2 | ||||
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | gconf-editor/Makefile.am | 2 | ||||
-rw-r--r-- | gconf-editor/gconf-editor.c | 9 | ||||
-rw-r--r-- | gconf/GConf.idl | 3 | ||||
-rw-r--r-- | gconf/GConfX.idl | 3 | ||||
-rw-r--r-- | gconf/Makefile.am | 18 | ||||
-rw-r--r-- | gconf/gconf-orbit.c | 263 | ||||
-rw-r--r-- | gconf/gconf-orbit.h | 16 | ||||
-rw-r--r-- | gconf/gconf.c | 267 | ||||
-rw-r--r-- | gconf/gconf.h | 19 | ||||
-rw-r--r-- | gconf/gconfd.c | 99 | ||||
-rw-r--r-- | gconf/gconftool.c | 10 | ||||
-rw-r--r-- | gconf/testgconfclient.c | 21 | ||||
-rw-r--r-- | wrappers/gtk/Makefile.am | 2 | ||||
-rw-r--r-- | wrappers/gtk/testgconfclient.c | 21 | ||||
-rw-r--r-- | wrappers/guile/Makefile.am | 2 | ||||
-rw-r--r-- | wrappers/guile/gconf-guile.c | 9 |
20 files changed, 115 insertions, 660 deletions
@@ -1,3 +1,7 @@ +1999-11-19 Elliot Lee <sopwith@redhat.com> + + * Make it all use OAF, and redo the initialization routine(s) to fit better into the GnomeModuleInfo system. + 1999-11-18 Elliot Lee <sopwith@redhat.com> * gconf.m4: AM_PATH_GCONF macro. @@ -28,7 +28,7 @@ DIE=0 DIE=1 } -(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && { +(grep "^AM_PROG_LIBTOOL" configure.in >/dev/null) && { (libtool --version) < /dev/null > /dev/null 2>&1 || { echo echo "**Error**: You must have \`libtool' installed to compile $PROJECT." @@ -38,7 +38,7 @@ DIE=0 } } -grep "^AM_GNU_GETTEXT" $srcdir/configure.in >/dev/null && { +grep "^AM_GNU_GETTEXT" configure.in >/dev/null && { grep "sed.*POTFILES" $srcdir/configure.in >/dev/null || \ (gettext --version) < /dev/null > /dev/null 2>&1 || { echo diff --git a/backends/Makefile.am b/backends/Makefile.am index ff4dd6f5..c6e1c8eb 100644 --- a/backends/Makefile.am +++ b/backends/Makefile.am @@ -1,4 +1,4 @@ -INCLUDES= -I$(top_srcdir) -I$(top_builddir)/gconf $(GLIB_CFLAGS) $(ORBIT_CFLAGS) $(XML_CFLAGS) +INCLUDES= -I$(top_srcdir) -I$(top_builddir)/gconf $(GLIB_CFLAGS) $(OAF_CFLAGS) $(ORBIT_CFLAGS) $(XML_CFLAGS) backenddir = $(libdir)/gconf diff --git a/configure.in b/configure.in index 367ed0f6..ec88a04d 100644 --- a/configure.in +++ b/configure.in @@ -54,6 +54,7 @@ else fi AM_PATH_GLIB(1.2.0,,AC_MSG_ERROR(glib not found),gmodule) +AM_PATH_OAF(0.1.0,,AC_MSG_ERROR([OAF not found])) AC_PATH_PROG(GNOME_CONFIG,gnome-config,no) if test x$GNOME_CONFIG != xno; then diff --git a/gconf-editor/Makefile.am b/gconf-editor/Makefile.am index cacdafb4..91b00199 100644 --- a/gconf-editor/Makefile.am +++ b/gconf-editor/Makefile.am @@ -1,5 +1,5 @@ INCLUDES=-I$(top_srcdir) \ - -I$(includedir) $(GNOME_CFLAGS) \ + -I$(includedir) $(GNOME_CFLAGS) $(OAF_CFLAGS) \ -DG_LOG_DOMAIN=\"GConfEd\" -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ -I../intl -I$(top_srcdir)/intl -I$(top_srcdir)/gconf diff --git a/gconf-editor/gconf-editor.c b/gconf-editor/gconf-editor.c index 6108a745..00f4d62a 100644 --- a/gconf-editor/gconf-editor.c +++ b/gconf-editor/gconf-editor.c @@ -65,14 +65,7 @@ main(int argc, char** argv) bindtextdomain(PACKAGE, GNOMELOCALEDIR); textdomain(PACKAGE); - if (gconf_init_orb(&argc, argv, &err) == CORBA_OBJECT_NIL) - { - fprintf(stderr, _("Failed to init orb: %s\n"), err->str); - gconf_error_destroy(err); - return 1; - } - - if (!gconf_init(&err)) + if (!gconf_init(argc, argv, &err)) { fprintf(stderr, _("Failed to init GConf: %s\n"), err->str); gconf_error_destroy(err); diff --git a/gconf/GConf.idl b/gconf/GConf.idl index f0aa80ef..6d015193 100644 --- a/gconf/GConf.idl +++ b/gconf/GConf.idl @@ -150,6 +150,3 @@ interface ConfigServer { void shutdown(); }; - - - diff --git a/gconf/GConfX.idl b/gconf/GConfX.idl index f0aa80ef..6d015193 100644 --- a/gconf/GConfX.idl +++ b/gconf/GConfX.idl @@ -150,6 +150,3 @@ interface ConfigServer { void shutdown(); }; - - - diff --git a/gconf/Makefile.am b/gconf/Makefile.am index a2429684..de31d01e 100644 --- a/gconf/Makefile.am +++ b/gconf/Makefile.am @@ -1,5 +1,6 @@ -INCLUDES=-I$(top_srcdir) $(GLIB_CFLAGS) $(ORBIT_CFLAGS) $(XML_CFLAGS) \ - -DGCONF_SRCDIR=\""$(absolute_top_srcdir)"\" -DGCONF_SYSCONFDIR=\""$(sysconfdir)"\" -DGCONF_BACKEND_DIR=\""$(libdir)/gconf"\" +INCLUDES=-I$(top_srcdir) $(GLIB_CFLAGS) $(ORBIT_CFLAGS) $(XML_CFLAGS) $(OAF_CFLAGS) \ + -DGCONF_SRCDIR=\""$(absolute_top_srcdir)"\" -DGCONF_SYSCONFDIR=\""$(sysconfdir)"\" \ + -DGCONF_BACKEND_DIR=\""$(libdir)/gconf"\" -DVERSION=\""$(VERSION)"\" EFENCE= @@ -32,7 +33,7 @@ gconfd_SOURCES = \ gconfd.c \ gconf-sources.c -gconfd_LDADD = $(EFENCE) $(GLIB_LIBS) $(ORBIT_LIBS) libgconf.la +gconfd_LDADD = $(EFENCE) $(OAF_LIBS) $(GLIB_LIBS) libgconf.la # gconf_testclient_SOURCES = \ # testclient.c @@ -42,7 +43,7 @@ gconfd_LDADD = $(EFENCE) $(GLIB_LIBS) $(ORBIT_LIBS) libgconf.la gconftool_SOURCES = \ gconftool.c -gconftool_LDADD = $(EFENCE) $(GLIB_LIBS) $(ORBIT_LIBS) $(POPT_LIBS) $(XML_LIBS) libgconf.la +gconftool_LDADD = $(EFENCE) $(OAF_LIBS) $(GLIB_LIBS) $(ORBIT_LIBS) $(POPT_LIBS) $(XML_LIBS) libgconf.la $(CORBA_SOURCES): $(srcdir)/GConf.idl orbit-idl $(srcdir)/GConf.idl @@ -60,10 +61,9 @@ libgconf_la_SOURCES = \ gconf.c \ $(CORBA_SOURCES) -libgconf_la_LDFLAGS = -version-info $(GCONF_CURRENT):$(GCONF_REVISION):$(GCONF_AGE) -libgconf_la_LIBADD = $(GLIB_LIBS) $(ORBIT_LIBS) - -EXTRA_DIST=GConf.idl - +libgconf_la_LDFLAGS = -version-info $(GCONF_CURRENT):$(GCONF_REVISION):$(GCONF_AGE) $(OAF_LIBS) +EXTRA_DIST=GConf.idl gconfd.oafinfo +oafinfodir=$(datadir)/oaf +oafinfo_DATA=gconfd.oafinfo diff --git a/gconf/gconf-orbit.c b/gconf/gconf-orbit.c index 3d19bf04..c812e9a2 100644 --- a/gconf/gconf-orbit.c +++ b/gconf/gconf-orbit.c @@ -36,6 +36,7 @@ #include <fcntl.h> #include <time.h> #include "gconf-internals.h" +#include <liboaf/liboaf.h> /* Quick hack so I can mark strings */ @@ -51,275 +52,19 @@ #define N_(x) x #endif -static CORBA_ORB gconf_orbit_orb = CORBA_OBJECT_NIL; -static CORBA_Principal gconf_request_cookie; - -static char * gconf_get_cookie_reliably (const char *setme, GConfError** err); -static const char *gconf_cookie_setup(const char *setme, GConfError** err); - -static gboolean -orb_handle_connection(GIOChannel *source, GIOCondition cond, - GIOPConnection *cnx) -{ - - /* The best way to know about an fd exception is if select()/poll() - * tells you about it, so we just relay that information on to ORBit - * if possible - */ - - if(cond & (G_IO_HUP|G_IO_NVAL|G_IO_ERR)) - giop_main_handle_connection_exception(cnx); - else - giop_main_handle_connection(cnx); - - return TRUE; -} - -static void -orb_add_connection(GIOPConnection *cnx) -{ - int tag; - GIOChannel *channel; - - channel = g_io_channel_unix_new(GIOP_CONNECTION_GET_FD(cnx)); - tag = g_io_add_watch_full (channel, G_PRIORITY_DEFAULT, - G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL, - (GIOFunc)orb_handle_connection, - cnx, NULL); - g_io_channel_unref (channel); - - cnx->user_data = GUINT_TO_POINTER (tag); -} - -static void -orb_remove_connection(GIOPConnection *cnx) -{ - g_source_remove(GPOINTER_TO_UINT (cnx->user_data)); - cnx->user_data = GINT_TO_POINTER (-1); -} - -static ORBit_MessageValidationResult -gconf_ORBit_request_validate(CORBA_unsigned_long request_id, - CORBA_Principal *principal, - CORBA_char *operation) -{ - if (principal->_length == gconf_request_cookie._length - && !(principal->_buffer[principal->_length - 1]) - && !strcmp(principal->_buffer, gconf_request_cookie._buffer)) - return ORBIT_MESSAGE_ALLOW_ALL; - else - return ORBIT_MESSAGE_BAD; -} - -/* - * I bet these will require porting sooner or later - */ -static gboolean -get_exclusive_lock (int fd, GConfError** err) -{ - /* flock (fd, LOCK_EX); */ - struct flock lbuf; - - lbuf.l_type = F_WRLCK; - lbuf.l_whence = SEEK_SET; - lbuf.l_start = lbuf.l_len = 0L; /* Lock the whole file. */ - if (fcntl (fd, F_SETLKW, &lbuf) < 0) - { - if (errno == EINTR) - if (fcntl(fd, F_SETLKW, &lbuf) == 0) /* try again */ - return TRUE; - - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Could not get lock to set up authentication cookie: %s"), - strerror(errno)); - return FALSE; - } - else - return TRUE; -} - -static void -release_lock (int fd) -{ - /* flock (fd, LOCK_UN); */ - struct flock lbuf; - - lbuf.l_type = F_UNLCK; - lbuf.l_whence = SEEK_SET; - lbuf.l_start = lbuf.l_len = 0L; /* Unlock the whole file. */ - fcntl (fd, F_SETLKW, &lbuf); -} - -static char * -gconf_get_cookie_reliably (const char *setme, GConfError** err) -{ - char buf[64]; - char *random_string = NULL; - char *name; - int fd = -1; - gchar* dir; - - dir = gconf_server_info_dir(); - - if (mkdir(dir, 0700) < 0) - { - if (errno != EEXIST) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Couldn't make directory `%s': %s"), - dir, strerror(errno)); - g_free(dir); - return NULL; - } - } - - name = g_strconcat (dir, "/cookie", NULL); - - g_free(dir); - - if(setme) { - - /* Just write it into the file for reference purposes */ - fd = open (name, O_CREAT|O_WRONLY, S_IRUSR | S_IWUSR); - - if (fd < 0) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Could not open cookie file `%s': %s"), - name, strerror(errno)); - goto out; - } - - if (!get_exclusive_lock(fd, err)) - goto out; /* error is set */ - - if (write(fd, setme, strlen(setme)) < 0) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Could not write cookie to file `%s': %s"), - name, strerror(errno)); - release_lock(fd); - goto out; - } - - release_lock(fd); - random_string = g_strdup(setme); - - } else { - - buf [sizeof(buf)-1] = '\0'; - - /* - * Create the file exclusively with permissions rw for the - * user. if this fails, it means the file already existed - */ - fd = open (name, O_CREAT|O_EXCL|O_WRONLY, S_IRUSR | S_IWUSR); - - if(fd >= 0) { - unsigned int i; - - if (!get_exclusive_lock (fd, err)) - goto out; /* error is set */ - - srandom (time (NULL)); - for (i = 0; i < sizeof (buf)-1; i++) - buf [i] = (random () % (126-33)) + 33; - - if(write(fd, buf, sizeof(buf)-1) < (sizeof(buf)-1)) - goto out; - - release_lock(fd); - } else if(fd < 0) { - int i; - fd = open(name, O_RDONLY); - if (fd < 0) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Failed to open cookie file `%s': %s"), - name, strerror(errno)); - goto out; - } - i = read(fd, buf, sizeof(buf)-1); - if(i < 0) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Failed to read cookie file `%s': %s"), - name, strerror(errno)); - goto out; - } - buf[i] = '\0'; - } - - random_string = g_strdup(buf); - } - - out: - if(fd >= 0) - close(fd); - g_free(name); - - return random_string; -} - -static const char * -gconf_cookie_setup(const char *setme, GConfError** err) -{ - gconf_request_cookie._buffer = gconf_get_cookie_reliably (setme, err); - - if (gconf_request_cookie._buffer == NULL || - *gconf_request_cookie._buffer == '\0') - return NULL; - - gconf_request_cookie._length = strlen(gconf_request_cookie._buffer) + 1; - - ORBit_set_request_validation_handler(&gconf_ORBit_request_validate); - ORBit_set_default_principal(&gconf_request_cookie); - - return gconf_request_cookie._buffer; -} - CORBA_ORB gconf_init_orb(int* argc, char** argv, GConfError** err) { CORBA_ORB retval; - CORBA_Environment ev; - - CORBA_exception_init(&ev); - - IIOPAddConnectionHandler = orb_add_connection; - IIOPRemoveConnectionHandler = orb_remove_connection; - gconf_orbit_orb = retval = CORBA_ORB_init(argc, argv, "orbit-local-orb", &ev); + retval = oaf_init(*argc, argv); - if (ev._major != CORBA_NO_EXCEPTION) + if (!retval) { if (err) - *err = gconf_error_new(GCONF_FAILED, _("Failure initializing ORB: %s"), - CORBA_exception_id(&ev)); - CORBA_exception_free(&ev); + *err = gconf_error_new(GCONF_FAILED, _("Failure initializing ORB")); return CORBA_OBJECT_NIL; } - if (gconf_cookie_setup(NULL, err) == NULL) - { - return CORBA_OBJECT_NIL; - } - return retval; } - -CORBA_ORB -gconf_get_orb(void) -{ - return gconf_orbit_orb; -} - -void -gconf_set_orb(CORBA_ORB orb) -{ - g_return_if_fail(gconf_orbit_orb == CORBA_OBJECT_NIL); - g_return_if_fail(orb != CORBA_OBJECT_NIL); - - gconf_orbit_orb = orb; -} - diff --git a/gconf/gconf-orbit.h b/gconf/gconf-orbit.h index 3eb256a3..84258841 100644 --- a/gconf/gconf-orbit.h +++ b/gconf/gconf-orbit.h @@ -23,20 +23,6 @@ #include <glib.h> #include <orb/orbit.h> #include "gconf-error.h" - -/* Sets up orb to work with a glib main loop, just as libgnorba does. */ -CORBA_ORB -gconf_init_orb(int* argc, char** argv, GConfError** err); - -/* Assumes orb is already set up (for example, via libgnorba) - and just tells GConf where to find it -*/ -void -gconf_set_orb(CORBA_ORB orb); - -CORBA_ORB -gconf_get_orb(void); +#include <liboaf/liboaf.h> #endif - - diff --git a/gconf/gconf.c b/gconf/gconf.c index a30fcd0a..6ad4e809 100644 --- a/gconf/gconf.c +++ b/gconf/gconf.c @@ -17,6 +17,7 @@ * Boston, MA 02111-1307, USA. */ +#include <popt.h> #include "GConf.h" #include "gconf.h" #include "gconf-internals.h" @@ -932,48 +933,32 @@ static ConfigServer server = CORBA_OBJECT_NIL; static ConfigServer try_to_contact_server(GConfError** err) { - /* This writing-IOR-to-file crap is a temporary hack. */ - gchar* ior; + CORBA_Environment ev; - g_return_val_if_fail(server == CORBA_OBJECT_NIL, server); - - ior = gconf_read_server_ior(err); + CORBA_exception_init(&ev); + + server = oaf_activate_from_id("OAFAID:[OAFIID:gconf:19991118]", 0, NULL, &ev); - if (ior == NULL) + /* So try to ping server */ + if (!CORBA_Object_is_nil(server, &ev)) { - g_return_val_if_fail(err == NULL || (*err != NULL), CORBA_OBJECT_NIL); - return CORBA_OBJECT_NIL; - } + ConfigServer_ping(server, &ev); - if (ior != NULL) + if (ev._major != CORBA_NO_EXCEPTION) + { + server = CORBA_OBJECT_NIL; + if (err) + *err = gconf_error_new(GCONF_NO_SERVER, _("Pinging the server failed, CORBA error: %s"), + CORBA_exception_id(&ev)); + } + } + else { - CORBA_Environment ev; - - CORBA_exception_init(&ev); - - /* May well fail, could be a stale IOR */ - server = CORBA_ORB_string_to_object(gconf_get_orb(), ior, &ev); - - /* So try to ping server */ - if (server != CORBA_OBJECT_NIL) - { - ConfigServer_ping(server, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - { - server = CORBA_OBJECT_NIL; - if (err) - *err = gconf_error_new(GCONF_NO_SERVER, _("Pinging the server failed, CORBA error: %s"), - CORBA_exception_id(&ev)); - CORBA_exception_free(&ev); - } - } - else - { - if (err) - *err = gconf_error_new(GCONF_NO_SERVER, _("Failed to convert server IOR to an object reference")); - } + if (err) + *err = gconf_error_new(GCONF_NO_SERVER, _("Failed to activate server")); } + + CORBA_exception_free(&ev); return server; } @@ -988,123 +973,7 @@ gconf_get_config_server(gboolean start_if_not_found, GConfError** err) server = try_to_contact_server(err); - if (start_if_not_found) - - { - /* - * We aren't interested in this error; - * only in the success or failure of the - * attempt to spawn the server ourselves. - */ - if (err && *err) - { - gconf_error_destroy(*err); - *err = NULL; - } - } - else - return server; /* return what we have, NIL or not */ - - if (server == CORBA_OBJECT_NIL) - { - pid_t pid; - int fds[2]; - int status; - - if (pipe(fds) < 0) - { - if (err) - *err = gconf_error_new(GCONF_NO_SERVER, _("Failed to create pipe to server: %s"), - strerror(errno)); - return CORBA_OBJECT_NIL; - } - - pid = fork(); - - if (pid < 0) - { - if (err) - *err = gconf_error_new(GCONF_NO_SERVER, _("gconfd fork failed: %s"), - strerror(errno)); - return CORBA_OBJECT_NIL; - } - - if (pid == 0) - { - gchar buf[20]; - - close(fds[0]); - - g_snprintf(buf, 20, "%d", fds[1]); - - /* Child. Exec... */ - if (execlp("gconfd", "gconfd", buf, NULL) < 0) - { - /* in the child, don't want to set error */ - g_warning(_("Failed to exec gconfd: %s"), strerror(errno)); - - close(fds[1]); - - _exit(1); - } - } - - /* Parent - waitpid(), gconfd instantly forks anyway */ - if (waitpid(pid, &status, 0) != pid) - { - if (err) - *err = gconf_error_new(GCONF_NO_SERVER, - _("waitpid() failed waiting for child in %s: %s"), - __FUNCTION__, strerror(errno)); - close(fds[1]); - return CORBA_OBJECT_NIL; - } - - if (WIFEXITED(status)) - { - if (WEXITSTATUS(status) != 0) - { - if (err) - *err = gconf_error_new(GCONF_NO_SERVER, - _("spawned server returned error code, giving up on contacting it.")); - close(fds[1]); - return CORBA_OBJECT_NIL; - } - } - else - { - if (err) - *err = gconf_error_new(GCONF_NO_SERVER, _("spawned gconfd child didn't exit normally, can't contact server.")); - close(fds[1]); - return CORBA_OBJECT_NIL; - } - - close(fds[1]); - - /* Wait for the child to send us a byte */ - { - char c = '\0'; - - if (read(fds[0], &c, 1) < 0) - { - /* Not a fatal error */ - g_warning("Error reading from pipe to gconfd: %s", strerror(errno)); - c = 'g'; /* suppress next error message */ - } - - if (c != 'g') /* g is the magic letter */ - { - /* not fatal either */ - g_warning("gconfd sent us the wrong byte!"); - } - - close(fds[0]); - } - - server = try_to_contact_server(err); - } - - return server; + return server; /* return what we have, NIL or not */ } static void @@ -1194,28 +1063,14 @@ gconf_get_config_listener(void) static gboolean have_initted = FALSE; -gboolean -gconf_init (GConfError** err) +void +gconf_preinit(gpointer app, gpointer mod_info) { - static CORBA_ORB orb = CORBA_OBJECT_NIL; - - if (have_initted) - { - g_warning("Attempt to init GConf a second time"); - return FALSE; - } - - orb = gconf_get_orb(); - - if (orb == CORBA_OBJECT_NIL) - { - /* warn instead of error, since it indicates an application bug - (app should have checked errors after initting the orb) - */ - g_warning("Failed to get orb (perhaps orb wasn't set/initted?)"); - return FALSE; - } +} +void +gconf_postinit(gpointer app, gpointer mod_info) +{ if (listener == CORBA_OBJECT_NIL) { CORBA_Environment ev; @@ -1226,44 +1081,24 @@ gconf_init (GConfError** err) POA_ConfigListener__init(&poa_listener_servant, &ev); if (ev._major != CORBA_NO_EXCEPTION) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Failed to init the listener servant: %s"), - CORBA_exception_id(&ev)); - return FALSE; - } + return; - poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(gconf_get_orb(), "RootPOA", &ev); + poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(oaf_orb_get(), "RootPOA", &ev); if (ev._major != CORBA_NO_EXCEPTION) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Failed to resolve the root POA: %s"), - CORBA_exception_id(&ev)); - return FALSE; - } + return; PortableServer_POAManager_activate(PortableServer_POA__get_the_POAManager(poa, &ev), &ev); if (ev._major != CORBA_NO_EXCEPTION) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Failed to activate the POA Manager: %s"), - CORBA_exception_id(&ev)); - return FALSE; - } + return; PortableServer_POA_activate_object_with_id(poa, &objid, &poa_listener_servant, &ev); if (ev._major != CORBA_NO_EXCEPTION) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Failed to activate the listener servant: %s"), - CORBA_exception_id(&ev)); - return FALSE; - } + return; listener = PortableServer_POA_servant_to_reference(poa, @@ -1271,15 +1106,38 @@ gconf_init (GConfError** err) &ev); if (listener == CORBA_OBJECT_NIL || ev._major != CORBA_NO_EXCEPTION) - { - if (err) - *err = gconf_error_new(GCONF_FAILED, _("Failed get object reference for the listener servant: %s"), - CORBA_exception_id(&ev)); - return FALSE; - } + return; } + have_initted = TRUE; +} + +const char gconf_version[] = VERSION; + +struct poptOption gconf_options[] = { + {NULL} +}; + +gboolean +gconf_init (int argc, char **argv, GConfError** err) +{ + CORBA_ORB orb = CORBA_OBJECT_NIL; + + if (have_initted) + { + g_warning("Attempt to init GConf a second time"); + return FALSE; + } + + gconf_preinit(NULL, NULL); + + orb = oaf_init(argc, argv); + + gconf_postinit(NULL, NULL); + + if(!have_initted) + return FALSE; return TRUE; } @@ -1573,7 +1431,6 @@ ctable_reinstall_everything(CnxnTable* ct, ConfigServer_Context context, ConfigServer cs, GConfError** err) { ConfigListener cl; - CORBA_Environment ev; GConfCnxn* cnxn; struct ReinstallData rd; diff --git a/gconf/gconf.h b/gconf/gconf.h index 35dff14b..13cc8a88 100644 --- a/gconf/gconf.h +++ b/gconf/gconf.h @@ -31,7 +31,6 @@ extern "C" { #include "gconf-engine.h" #include "gconf-error.h" -gboolean gconf_init (GConfError** err); gboolean gconf_is_initialized (void); typedef void (*GConfNotifyFunc)(GConfEngine* conf, guint cnxn_id, const gchar* key, GConfValue* value, gpointer user_data); @@ -167,6 +166,24 @@ gboolean gconf_set_pair (GConfEngine* conf, const gchar* key, gconstpointer address_of_cdr, GConfError** err); + +gboolean gconf_init (int argc, char **argv, GConfError** err); + +/* For use by the Gnome module system */ +void gconf_preinit(gpointer app, gpointer mod_info); +void gconf_postinit(gpointer app, gpointer mod_info); + +extern const char gconf_version[]; + +#ifdef HAVE_POPT_H +#include <popt.h> +#endif + +#ifdef POPT_AUTOHELP +/* If people are using popt, then make the table available to them */ +extern struct poptOption gconf_options[]; +#endif + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/gconf/gconfd.c b/gconf/gconfd.c index e2eebe80..f63ec800 100644 --- a/gconf/gconfd.c +++ b/gconf/gconfd.c @@ -954,43 +954,13 @@ main(int argc, char** argv) PortableServer_POA poa; CORBA_Environment ev; - char *ior; CORBA_ORB orb; gchar* logname; const gchar* username; guint len; GConfError* err = NULL; - gchar* nodaemon_var; - gboolean nodaemon = FALSE; + gboolean nodaemon = TRUE; - int launcher_fd = -1; /* FD passed from the client that spawned us */ - - nodaemon_var = g_getenv("GCONFD_NO_DAEMON"); - - if (nodaemon_var && strcmp(nodaemon_var, "1") == 0) - nodaemon = TRUE; - - if (!nodaemon) - { - /* Following all Stevens' rules for daemons, unless the - GCONFD_NO_DAEMON env variable is set to 1 */ - - switch (fork()) - { - case -1: - fprintf(stderr, _("Failed to fork gconfd")); - exit(1); - break; - case 0: - break; - default: - exit(0); - break; - } - - setsid(); - } - chdir ("/"); umask(0); @@ -1027,49 +997,15 @@ main(int argc, char** argv) CORBA_exception_init(&ev); - if (!gconf_init_orb(&argc, argv, &err)) /* must do before our own arg parsing */ + if (!oaf_init(argc, argv)) { gconf_log(GCL_ERR, _("Failed to init ORB: %s"), err->str); exit(1); } - if (argc > 2) - { - gconf_log(GCL_ERR, _("Invalid command line arguments")); - exit(1); - } - else if (argc == 2) - { - /* Verify that it's a positive integer */ - gchar* s = argv[1]; - while (*s) - { - if (!isdigit(*s)) - { - gconf_log(GCL_ERR, _("Command line arg should be a file descriptor, not `%s'"), - argv[1]); - exit(1); - } - ++s; - } - - launcher_fd = atoi(argv[1]); - - gconf_log(GCL_DEBUG, _("Will notify launcher client on fd %d"), launcher_fd); - - if (nodaemon) - gconf_log(GCL_WARNING, _("GCONFD_NO_DAEMON environment variable is set to 1, but we are being launched as if from a GConf client")); - } - init_contexts(); - orb = gconf_get_orb(); - - if (orb == CORBA_OBJECT_NIL) - { - gconf_log(GCL_ERR, _("Failed to get ORB reference")); - exit(1); - } + orb = oaf_orb_get(); POA_ConfigServer__init(&poa_server_servant, &ev); @@ -1081,38 +1017,13 @@ main(int argc, char** argv) server = PortableServer_POA_servant_to_reference(poa, &poa_server_servant, &ev); - if (server == CORBA_OBJECT_NIL) + if (CORBA_Object_is_nil(server, &ev)) { gconf_log(GCL_ERR, _("Failed to get object reference for ConfigServer")); return 1; } - ior = CORBA_ORB_object_to_string(orb, server, &ev); - - /* Write IOR to a file (temporary hack, name server will be used eventually */ - if (!gconf_server_write_info_file(ior)) - { - gconf_log(GCL_ERR, - _("Failed to write info file - maybe another gconfd is running. Exiting.")); - return 1; - } - - CORBA_free(ior); - - /* If we got a fd on the command line, write the magic byte 'g' - to it to notify our spawning client that we're ready. - */ - - if (launcher_fd >= 0) - { - if (write(launcher_fd, "g", 1) != 1) - gconf_log(GCL_ERR, _("Failed to notify spawning parent of server liveness: %s"), - strerror(errno)); - - if (close(launcher_fd) < 0) - gconf_log(GCL_ERR, _("Failed to close pipe to spawning parent: %s"), - strerror(errno)); - } + oaf_active_server_register("OAFIID:gconfd:19991118" /* matches OAFIID in gconfd.oafinfo */, server); gconf_main(); diff --git a/gconf/gconftool.c b/gconf/gconftool.c index 4462fce6..50d87a28 100644 --- a/gconf/gconftool.c +++ b/gconf/gconftool.c @@ -361,15 +361,7 @@ main (int argc, char** argv) return 1; } - if (gconf_init_orb(&argc, argv, &err) == CORBA_OBJECT_NIL) - { - fprintf(stderr, _("Failed to init orb: %s\n"), err->str); - gconf_error_destroy(err); - err = NULL; - return 1; - } - - if (!gconf_init(&err)) + if (!gconf_init(argc, argv, &err)) { fprintf(stderr, _("Failed to init GConf: %s\n"), err->str); gconf_error_destroy(err); diff --git a/gconf/testgconfclient.c b/gconf/testgconfclient.c index 87c3b385..213e3b84 100644 --- a/gconf/testgconfclient.c +++ b/gconf/testgconfclient.c @@ -42,28 +42,9 @@ main(int argc, char** argv) CORBA_exception_init(&ev); -#if 0 - orb = gnome_CORBA_init(PACKAGE, VERSION, &argc, argv, - 0, &ev); - if (orb == CORBA_OBJECT_NIL) - { - g_warning("Failed to init orb"); - return 1; - } - gconf_set_orb(orb); -#else gnome_init(PACKAGE, VERSION, argc, argv); - orb = gconf_init_orb(&argc, argv, &error); - if (orb == CORBA_OBJECT_NIL) - { - g_assert(error != NULL); - g_warning("Failed to init orb:\n %s", error->str); - return 1; - } - g_assert(error == NULL); -#endif - if (!gconf_init(&error)) + if (!gconf_init(argc, argv, &error)) { g_assert(error != NULL); g_warning("GConf init failed:\n %s", error->str); diff --git a/wrappers/gtk/Makefile.am b/wrappers/gtk/Makefile.am index 246184ee..b5624da6 100644 --- a/wrappers/gtk/Makefile.am +++ b/wrappers/gtk/Makefile.am @@ -1,4 +1,4 @@ -INCLUDES=-I$(top_srcdir) -I$(top_builddir)/gconf $(GLIB_CFLAGS) $(GMODULE_CFLAGS) $(ORBIT_CFLAGS) $(GNOME_CFLAGS)\ +INCLUDES=-I$(top_srcdir) -I$(top_builddir)/gconf $(GLIB_CFLAGS) $(OAF_CFLAGS) $(GMODULE_CFLAGS) $(ORBIT_CFLAGS) $(GNOME_CFLAGS)\ -DGCONF_SRCDIR=\""$(absolute_top_srcdir)"\" -DGCONF_SYSCONFDIR=\""$(sysconfdir)"\" -DGCONF_BACKEND_DIR=\""$(pkglibdir)"\" lib_LTLIBRARIES = libgconf-gtk.la diff --git a/wrappers/gtk/testgconfclient.c b/wrappers/gtk/testgconfclient.c index 87c3b385..213e3b84 100644 --- a/wrappers/gtk/testgconfclient.c +++ b/wrappers/gtk/testgconfclient.c @@ -42,28 +42,9 @@ main(int argc, char** argv) CORBA_exception_init(&ev); -#if 0 - orb = gnome_CORBA_init(PACKAGE, VERSION, &argc, argv, - 0, &ev); - if (orb == CORBA_OBJECT_NIL) - { - g_warning("Failed to init orb"); - return 1; - } - gconf_set_orb(orb); -#else gnome_init(PACKAGE, VERSION, argc, argv); - orb = gconf_init_orb(&argc, argv, &error); - if (orb == CORBA_OBJECT_NIL) - { - g_assert(error != NULL); - g_warning("Failed to init orb:\n %s", error->str); - return 1; - } - g_assert(error == NULL); -#endif - if (!gconf_init(&error)) + if (!gconf_init(argc, argv, &error)) { g_assert(error != NULL); g_warning("GConf init failed:\n %s", error->str); diff --git a/wrappers/guile/Makefile.am b/wrappers/guile/Makefile.am index d197aad7..3682cdf9 100644 --- a/wrappers/guile/Makefile.am +++ b/wrappers/guile/Makefile.am @@ -2,7 +2,7 @@ gconfmoduledir = $(datadir)/guile/gconf # -I$(builddir) catches the .x files -INCLUDES = -I$(top_builddir)/wrappers/guile -I$(top_srcdir)/gconf -I$(includedir) $(GUILE_CFLAGS) $(ORBIT_CFLAGS) $(GLIB_CFLAGS) \ +INCLUDES = -I$(top_builddir)/wrappers/guile -I$(top_srcdir)/gconf -I$(includedir) $(GUILE_CFLAGS) $(OAF_CFLAGS) $(ORBIT_CFLAGS) $(GLIB_CFLAGS) \ -DG_LOG_DOMAIN=\"libgconf-scm\" -DGCONF_GUILE_DIR=\""$(gconfmoduledir)"\" lib_LTLIBRARIES = libgconf-scm.la diff --git a/wrappers/guile/gconf-guile.c b/wrappers/guile/gconf-guile.c index d2f4020e..0c8802b0 100644 --- a/wrappers/guile/gconf-guile.c +++ b/wrappers/guile/gconf-guile.c @@ -44,14 +44,7 @@ real_main(void* closure, int argc, char* argv[]) { GConfError* err = NULL; - if (gconf_init_orb(&argc, argv, &err) == CORBA_OBJECT_NIL) - { - fprintf(stderr, _("Failed to init orb: %s\n"), err->str); - gconf_error_destroy(err); - exit(1); - } - - if (!gconf_init(&err)) + if (!gconf_init(argc, argv, &err)) { fprintf(stderr, _("Failed to init gconf: %s\n"), err->str); gconf_error_destroy(err); |