From 768a3d5a467126fa461d1232701c281926e4619f Mon Sep 17 00:00:00 2001 From: Bradford Hovinen Date: Thu, 23 Aug 2001 19:08:26 +0000 Subject: [PATCH] Port to new CORBA interface 2001-08-23 Bradford Hovinen * main.c: Port to new CORBA interface --- capplets/screensaver/ChangeLog | 4 +++ capplets/screensaver/main.c | 58 ++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/capplets/screensaver/ChangeLog b/capplets/screensaver/ChangeLog index 45372a337..6a27ba8ef 100644 --- a/capplets/screensaver/ChangeLog +++ b/capplets/screensaver/ChangeLog @@ -1,3 +1,7 @@ +2001-08-23 Bradford Hovinen + + * main.c: Port to new CORBA interface + 2001-08-19 Abel Cheung * screensavers/Makefile.am: Added missing DESTDIR to install-data-local diff --git a/capplets/screensaver/main.c b/capplets/screensaver/main.c index 9942af256..3eb5a9d48 100644 --- a/capplets/screensaver/main.c +++ b/capplets/screensaver/main.c @@ -39,8 +39,8 @@ #include #ifdef HAVE_XIMIAN_ARCHIVER -# include -# include +# include +# include #endif /* HAVE_XIMIAN_ARCHIVER */ #include "preferences.h" @@ -57,26 +57,37 @@ static CappletWidget *capplet; #ifdef HAVE_XIMIAN_ARCHIVER -static Archive *archive; +static ConfigArchiver_Archive archive; static gboolean outside_location; static void store_archive_data (void) { - Location *location; + ConfigArchiver_Location location; xmlDocPtr xml_doc; + CORBA_Environment ev; + + CORBA_exception_init (&ev); if (capplet_get_location () == NULL) - location = archive_get_current_location (archive); + location = ConfigArchiver_Archive__get_currentLocation (archive, &ev); else - location = archive_get_location (archive, - capplet_get_location ()); + location = ConfigArchiver_Archive_getLocation + (archive, capplet_get_location (), &ev); + + if (BONOBO_EX (&ev) || location == CORBA_OBJECT_NIL) { + g_critical ("Could not open location %s", capplet_get_location ()); + return; + } xml_doc = preferences_write_xml (prefs); - location_store_xml (location, "screensaver-properties-capplet", - xml_doc, STORE_MASK_PREVIOUS); + location_client_store_xml (location, "screensaver-properties-capplet", + xml_doc, STORE_MASK_PREVIOUS, &ev); xmlFreeDoc (xml_doc); - archive_close (archive); + bonobo_object_release_unref (archive, NULL); + bonobo_object_release_unref (location, NULL); + + CORBA_exception_free (&ev); } #endif /* HAVE_XIMIAN_ARCHIVER */ @@ -314,6 +325,12 @@ do_restore_from_defaults (void) int main (int argc, char **argv) { +#ifdef HAVE_XIMIAN_ARCHIVER + CORBA_ORB orb; + CORBA_Environment ev; + CORBA_char *current_location_id = NULL; +#endif /* HAVE_XIMIAN_ARCHIVER */ + GnomeClient *client; GnomeClientFlags flags; gint token, res; @@ -348,6 +365,13 @@ main (int argc, char **argv) glade_gnome_init (); +#ifdef HAVE_XIMIAN_ARCHIVER + CORBA_exception_init (&ev); + orb = oaf_init (argc, argv); + if (!bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL)) + g_critical ("Could not initialize Bonobo"); +#endif /* HAVE_XIMIAN_ARCHIVER */ + client = gnome_master_client (); flags = gnome_client_get_flags (client); @@ -378,11 +402,16 @@ main (int argc, char **argv) init_resource_database (argc, argv); #ifdef HAVE_XIMIAN_ARCHIVER - archive = ARCHIVE (archive_load (FALSE)); + archive = bonobo_get_object ("archive:user-archive", "IDL:ConfigArchiver/Archive:1.0", &ev); + + if (BONOBO_EX (&ev) || archive == CORBA_OBJECT_NIL) + g_critical ("Could not resolve archive moniker"); + else + current_location_id = ConfigArchiver_Archive__get_currentLocationId (archive, &ev); if (capplet_get_location () != NULL && - strcmp (capplet_get_location (), - archive_get_current_location_id (archive))) + current_location_id != NULL && + strcmp (capplet_get_location (), current_location_id)) { outside_location = TRUE; do_set_xml (FALSE); @@ -394,6 +423,9 @@ main (int argc, char **argv) preferences_load (prefs); } + if (current_location_id != NULL) + CORBA_free (current_location_id); + if (!outside_location && token) { if (prefs->selection_mode != SM_DISABLE_SCREENSAVER) start_xscreensaver ();