[Setup-tool-hackers] Patch for archiver interface



The XML archiver is now using a CORBA interface so that it can run in a
separate process and avoid the problems associated with multiple
processes concurrently accessing the archive. I have attached a patch to
src/common/xst-tool.c to initialize OAF and Bonobo and use the CORBA
interface to access the archive. I have tested it successfully, and
determined that, in the case that the archive moniker does not resolve,
it does not impair the remaining functionality of the setup tool (i.e.
the tool does not crash and it still correctly applies its settings). I
wanted to run this by you guys just to make sure it would be OK with you
to be invoking CORBA calls inside the setup tool frontends.

The alternative is to fork off a config-archiver process and pipe the
XML data to that, but I think the direct CORBA interface should be
sufficient.

Please let me know if it is ok to apply.

-- 
-Bradford Hovinen

We are most probably here for local information-gathering and
local-Universe problem-solving in support of the integrity of
eternally regenerative Universe.

   -- R. Buckminster Fuller
? xst.diff
? archiver-interface.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/ximian-setup-tools/src/common/ChangeLog,v
retrieving revision 1.136
diff -u -r1.136 ChangeLog
--- ChangeLog	2001/08/01 18:34:04	1.136
+++ ChangeLog	2001/08/20 15:48:18
@@ -1,3 +1,9 @@
+2001-08-20  Bradford Hovinen  <hovinen@ximian.com>
+
+	* xst-tool.c (xst_tool_load): 
+	(xst_tool_save): Use CORBA-based archiver interface
+	(xst_init): Initialize OAF and Bonobo
+
 2001-08-01  Bradford Hovinen  <hovinen@ximian.com>
 
 	* xst-tool.c (xst_tool_save): Reorganize logic to remove duplicate
Index: xst-tool.c
===================================================================
RCS file: /cvs/gnome/ximian-setup-tools/src/common/xst-tool.c,v
retrieving revision 1.63
diff -u -r1.63 xst-tool.c
--- xst-tool.c	2001/08/01 18:34:04	1.63
+++ xst-tool.c	2001/08/20 15:48:18
@@ -30,8 +30,8 @@
 #include "xst-ui.h"
 #include "xst-su.h"
 
-#include <config-archiver/archive.h>
-#include <config-archiver/location.h>
+#include <bonobo.h>
+#include <config-archiver/archiver-client.h>
 
 #include <gnome.h>
 #include <parser.h>
@@ -844,22 +844,40 @@
 		tool->config = xst_tool_run_get_directive
 			(tool, _("Scanning your system configuration."), "get", NULL);
 	} else {
-		Archive *archive;
-		Location *location;
+		CORBA_Environment ev;
+		ConfigArchiver_Archive archive;
+		ConfigArchiver_Location location;
 		gchar *backend_id;
 
-		archive = ARCHIVE (archive_load (TRUE));
-		location = archive_get_location (archive, location_id);
+		CORBA_exception_init (&ev);
+
+		archive = bonobo_get_object ("archive:global-archive", "IDL:ConfigArchiver/Archive:1.0", &ev);
+
+		if (BONOBO_EX (&ev) || archive == CORBA_OBJECT_NIL) {
+			g_critical ("Could not resolve the archive moniker");
+			return FALSE;
+		}
+
+		location = ConfigArchiver_Archive_getLocation (archive, location_id, &ev);
+
+		if (BONOBO_EX (&ev) || location == CORBA_OBJECT_NIL) {
+			g_critical ("Could not get the location %s", location_id);
+			return FALSE;
+		}
+
 		backend_id = strrchr (tool->script_path, '/');
 
 		if (backend_id != NULL)
 			backend_id++;
 		else
 			backend_id = tool->script_path;
+
+		tool->config = location_client_load_rollback_data (location, NULL, 0, backend_id, TRUE, &ev);
 
-		tool->config = location_load_rollback_data (location, NULL, 0, backend_id, TRUE);
+		bonobo_object_release_unref (location, NULL);
+		bonobo_object_release_unref (archive, NULL);
 
-		archive_close (archive);
+		CORBA_exception_free (&ev);
 	}
 
 	if (tool->config)
@@ -871,8 +889,9 @@
 gboolean
 xst_tool_save (XstTool *tool)
 {
-	Archive *archive;
-	Location *location;
+	CORBA_Environment ev;
+	ConfigArchiver_Archive archive;
+	ConfigArchiver_Location location;
 	gchar *backend_id;
 
 	g_return_val_if_fail (tool != NULL, FALSE);
@@ -891,24 +910,38 @@
 	}
 #endif
 
+	CORBA_exception_init (&ev);
+
 	/* Archive data with the archiver */
-	archive = ARCHIVE (archive_load (TRUE));
+	archive = bonobo_get_object ("archive:global-archive", "IDL:ConfigArchiver/Archive:1.0", &ev);
 
-	if (location_id == NULL)
-		location = archive_get_current_location (archive);
-	else
-		location = archive_get_location (archive, location_id);
+	if (BONOBO_EX (&ev) || archive == CORBA_OBJECT_NIL) {
+		g_critical ("Could not resolve the archive moniker");
+	} else {
+		if (location_id == NULL)
+			location = ConfigArchiver_Archive__get_currentLocation (archive, &ev);
+		else
+			location = ConfigArchiver_Archive_getLocation (archive, location_id, &ev);
 
-	backend_id = strrchr (tool->script_path, '/');
+		if (BONOBO_EX (&ev) || location == CORBA_OBJECT_NIL) {
+			g_critical ("Could not get location %s", location_id);
+			return FALSE;
+		}
 
-	if (backend_id != NULL)
-		backend_id++;
-	else
-		backend_id = tool->script_path;
+		backend_id = strrchr (tool->script_path, '/');
 
-	location_store_xml (location, backend_id, tool->config, STORE_MASK_PREVIOUS);
+		if (backend_id != NULL)
+			backend_id++;
+		else
+			backend_id = tool->script_path;
+
+		location_client_store_xml (location, backend_id, tool->config, ConfigArchiver_STORE_MASK_PREVIOUS, &ev);
+
+		bonobo_object_release_unref (location, &ev);
+		bonobo_object_release_unref (archive, &ev);
+	}
 
-	archive_close (archive);
+	CORBA_exception_free (&ev);
 
 	if (location_id == NULL)
 		xst_tool_run_set_directive (tool, tool->config,
@@ -1302,6 +1335,8 @@
 void
 xst_init (const gchar *app_name, int argc, char *argv [], const poptOption options)
 {
+	CORBA_ORB orb;
+
 	struct poptOption xst_options[] =
 	{
 		{ "location", '\0', POPT_ARG_STRING, &location_id, 0,
@@ -1337,6 +1372,11 @@
 	}
 
 	glade_gnome_init ();
+
+	orb = oaf_init (argc, argv);
+	if (bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE)
+		g_critical ("Cannot initialize bonobo");
+	bonobo_activate ();
 
 	if (geteuid () == 0) {
 		root_access = ROOT_ACCESS_REAL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]