diff --git a/ChangeLog b/ChangeLog index e053a81b6..7f45c8301 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ * configure.in (ALL_LINGUAS): zh_TW.Big5 -> zh_TW +2001-08-21 Bradford Hovinen + + * idl/ConfigArchiver.idl: Added exception RollbackDataNotFound + Added exception LocationNotFound + 2000-08-18 Pablo Saratxaga * configure.in (ALL_LINGUAS): Added Nynorsk (nn) and Walloon (wa) diff --git a/archiver/ChangeLog b/archiver/ChangeLog index 063d5d22d..5f438e6d8 100644 --- a/archiver/ChangeLog +++ b/archiver/ChangeLog @@ -1,3 +1,53 @@ +2001-08-21 Bradford Hovinen + + * archive.c (archive_get_current_location_id): Use + archive_create_location rather than location_new + (archive_get_current_location_id): Unref the location once we have + created it + + * archiver-client.c (location_client_load_rollback_data): Don't + try to parse the XML file if there was an exception + + * bonobo-config-archiver.c (bonobo_config_archiver_new): Make sure + to release_unref location and archive if aborting + (bonobo_config_archiver_new): Reinitialize exception structure + after we have succeeded + + * location.c (location_get_rollback_filename): Recurse on parent + location if parent_chain is set to TRUE + + * archive.c (impl_ConfigArchiver_Archive_getLocation): Set the + LocationNotFound exception if the location returned was NULL + + * location.c (impl_ConfigArchiver_Location_getRollbackFilename): Don't try + + * archive.c (impl_ConfigArchiver_Archive_getLocation): Don't try + to CORBA_Object_duplicate the result if it is NULL + (archive_get_location): Don't try to cast the result of + location_open before we know whether it is non-NULL + (impl_ConfigArchiver_Archive_createLocation): Call + bonobo_object_from_servant on parent_ref->servant + + * location.c (location_destroy): Remove debugging message; make + remaining debugging message more enlightening + + * archive.c (archive_get_child_locations): Rename from + archive_foreach_child_location; rewrite to return a GList of child + locations + (impl_ConfigArchiver_Archive_getChildLocations): Use + archive_get_child_locations + (archive_destroy): Remove debugging message + + * bonobo-moniker-archiver.c (archive_resolve): Remove debugging + messages + + * archive.c (archive_get_location): Remove debugging messages + + * config-log.c (dump_log): Remove debugging messages + + * archive.c (archive_foreach_child_location): Build a list first + and then traverse it to avoid screwing up the tree traversal + 2001-08-20 Richard Hestilow * Makefile.am: Add dependency on CORBA_SOURCE to archiver-client.c. diff --git a/archiver/archive.c b/archiver/archive.c index 04abb81c7..057f5ba80 100644 --- a/archiver/archive.c +++ b/archiver/archive.c @@ -35,16 +35,6 @@ #include "archive.h" #include "util.h" -typedef struct _foreach_t foreach_t; - -struct _foreach_t -{ - Archive *archive; - LocationCB callback; - Location *parent; - gpointer user_data; -}; - static GtkObjectClass *parent_class; enum { @@ -77,7 +67,16 @@ impl_ConfigArchiver_Archive_getLocation (PortableServer_Servant servant, const CORBA_char *locid, CORBA_Environment *ev) { - return CORBA_Object_duplicate (BONOBO_OBJREF (archive_get_location (ARCHIVE_FROM_SERVANT (servant), locid)), ev); + Location *loc; + + loc = archive_get_location (ARCHIVE_FROM_SERVANT (servant), locid); + + if (loc == NULL) { + bonobo_exception_set (ev, ex_ConfigArchiver_Archive_LocationNotFound); + return CORBA_OBJECT_NIL; + } else { + return CORBA_Object_duplicate (BONOBO_OBJREF (loc), ev); + } } static ConfigArchiver_Location @@ -90,17 +89,11 @@ impl_ConfigArchiver_Archive_createLocation (PortableServer_Servant serva Location *loc; loc = archive_create_location (ARCHIVE_FROM_SERVANT (servant), locid, label, - LOCATION (bonobo_object_from_servant (parent_ref))); + LOCATION (bonobo_object_from_servant (parent_ref->servant))); return bonobo_object_dup_ref (BONOBO_OBJREF (loc), ev); } -static void -build_list_cb (Archive *archive, Location *location, GList **list) -{ - *list = g_list_prepend (*list, bonobo_object_dup_ref (BONOBO_OBJREF (location), NULL)); -} - static ConfigArchiver_LocationSeq * impl_ConfigArchiver_Archive_getChildLocations (PortableServer_Servant servant, ConfigArchiver_Location location_ref, @@ -109,7 +102,7 @@ impl_ConfigArchiver_Archive_getChildLocations (PortableServer_Servant servant, ConfigArchiver_LocationSeq *ret; Archive *archive; Location *location; - GList *locs = NULL, *tmp; + GList *locs, *tmp; guint i = 0; archive = ARCHIVE_FROM_SERVANT (servant); @@ -119,14 +112,14 @@ impl_ConfigArchiver_Archive_getChildLocations (PortableServer_Servant servant, else location = LOCATION (bonobo_object_from_servant (location_ref->servant)); - archive_foreach_child_location (archive, (LocationCB) build_list_cb, location, &locs); + locs = archive_get_child_locations (archive, location); ret = ConfigArchiver_LocationSeq__alloc (); ret->_length = g_list_length (locs); ret->_buffer = CORBA_sequence_ConfigArchiver_Location_allocbuf (ret->_length); for (tmp = locs; tmp != NULL; tmp = tmp->next) - ret->_buffer[i++] = tmp->data; + ret->_buffer[i++] = CORBA_Object_duplicate (BONOBO_OBJREF (tmp->data), ev); g_list_free (locs); return ret; @@ -171,7 +164,7 @@ impl_ConfigArchiver_Archive__set_currentLocation (PortableServer_Servant serva location = LOCATION (bonobo_object_from_servant (location_ref->servant)); if (location == NULL) - /* bonobo_exception_set (ev, ex_ConfigArchiver_Archive_LocationNotFound) */; + bonobo_exception_set (ev, ex_ConfigArchiver_Archive_LocationNotFound); else archive_set_current_location (archive, location); } @@ -398,8 +391,6 @@ archive_destroy (GtkObject *object) bonobo_object_unref (BONOBO_OBJECT (archive->backend_list)); GTK_OBJECT_CLASS (parent_class)->destroy (GTK_OBJECT (archive)); - - DEBUG_MSG ("Exit"); } /** @@ -415,22 +406,20 @@ Location * archive_get_location (Archive *archive, const gchar *locid) { - Location *loc_obj; + BonoboObject *loc_obj; gchar *tmp; g_return_val_if_fail (archive != NULL, NULL); g_return_val_if_fail (IS_ARCHIVE (archive), NULL); g_return_val_if_fail (locid != NULL, NULL); - DEBUG_MSG ("Enter: %s", locid); - /* Stupid borken glib... */ tmp = g_strdup (locid); loc_obj = g_tree_lookup (archive->locations, tmp); g_free (tmp); if (loc_obj == NULL) { - loc_obj = LOCATION (location_open (archive, locid)); + loc_obj = location_open (archive, locid); if (loc_obj == NULL) return NULL; @@ -438,10 +427,10 @@ archive_get_location (Archive *archive, g_tree_insert (archive->locations, g_strdup (locid), loc_obj); } else { - bonobo_object_ref (BONOBO_OBJECT (loc_obj)); + bonobo_object_ref (loc_obj); } - return loc_obj; + return LOCATION (loc_obj); } /** @@ -621,17 +610,16 @@ archive_get_current_location_id (Archive *archive) archive_get_location (archive, archive->current_location_id); if (current_location == NULL) { - loc = LOCATION - (location_new (archive, - archive->current_location_id, - _("Default location"), - NULL)); + loc = archive_create_location (archive, archive->current_location_id, + _("Default location"), NULL); if (archive->is_global && location_store_full_snapshot (loc) < 0) { location_delete (loc); return NULL; } + + bonobo_object_unref (BONOBO_OBJECT (loc)); } else { bonobo_object_unref (BONOBO_OBJECT (current_location)); } @@ -695,17 +683,6 @@ archive_get_backend_list (Archive *archive) return archive->backend_list; } -static gint -foreach_cb (gchar *key, Location *value, foreach_t *data) -{ - if (location_get_parent (value) == data->parent) - data->callback (data->archive, value, data->user_data); - - bonobo_object_unref (BONOBO_OBJECT (value)); - - return 0; -} - /** * archive_foreach_child_location: * @archive: @@ -719,26 +696,46 @@ foreach_cb (gchar *key, Location *value, foreach_t *data) * NULL. Terminate the iteration if any child returns a nonzero value **/ -void -archive_foreach_child_location (Archive *archive, LocationCB callback, - Location *parent, gpointer data) +static gint +foreach_build_list_cb (gchar *key, Location *value, GList **node) { - foreach_t f_data; + *node = g_list_prepend (*node, value); + return 0; +} - g_return_if_fail (archive != NULL); - g_return_if_fail (IS_ARCHIVE (archive)); +GList * +archive_get_child_locations (Archive *archive, + Location *parent) +{ + GList *list = NULL, *node, *tmp; + Location *loc; + + g_return_val_if_fail (archive != NULL, NULL); + g_return_val_if_fail (IS_ARCHIVE (archive), NULL); load_all_locations (archive); - f_data.archive = archive; - f_data.callback = callback; - f_data.parent = parent; - f_data.user_data = data; - g_tree_traverse (archive->locations, - (GTraverseFunc) foreach_cb, + (GTraverseFunc) foreach_build_list_cb, G_IN_ORDER, - &f_data); + &list); + + node = list; + + while (node != NULL) { + loc = node->data; + tmp = node->next; + + if (location_get_parent (loc) != parent) { + list = g_list_remove_link (list, node); + g_list_free_1 (node); + bonobo_object_unref (BONOBO_OBJECT (loc)); + } + + node = tmp; + } + + return list; } /* Load and register all the locations for this archive */ diff --git a/archiver/archive.h b/archiver/archive.h index ffbc2234f..6e8335963 100644 --- a/archiver/archive.h +++ b/archiver/archive.h @@ -36,7 +36,6 @@ #define IS_ARCHIVE(obj) GTK_CHECK_TYPE (obj, archive_get_type ()) typedef struct _ArchiveClass ArchiveClass; -typedef void (*LocationCB) (Archive *, Location *, gpointer); struct _Archive { @@ -89,9 +88,7 @@ gboolean archive_is_global (Archive *ar BackendList *archive_get_backend_list (Archive *archive); -void archive_foreach_child_location (Archive *archive, - LocationCB callback, - Location *parent, - gpointer data); +GList *archive_get_child_locations (Archive *archive, + Location *parent); #endif /* __ARCHIVE */ diff --git a/archiver/archiver-client.c b/archiver/archiver-client.c index c9826aaba..553c25f1f 100644 --- a/archiver/archiver-client.c +++ b/archiver/archiver-client.c @@ -43,7 +43,7 @@ static xmlNodePtr subtract_xml_node (xmlNodePtr node1, static gboolean compare_xml_nodes (xmlNodePtr node1, xmlNodePtr node2); /** - * location_load_rollback_data + * location_client_load_rollback_data * @location: * @date: * @steps: @@ -69,7 +69,6 @@ location_client_load_rollback_data (ConfigArchiver_Location location, ConfigArchiver_Location parent = CORBA_OBJECT_NIL; CORBA_Environment my_ev; - g_return_val_if_fail (location != CORBA_OBJECT_NIL, NULL); if (opt_ev == NULL) { @@ -85,7 +84,7 @@ location_client_load_rollback_data (ConfigArchiver_Location location, filename = ConfigArchiver_Location_getRollbackFilename (location, time_g, steps, backend_id, parent_chain, opt_ev); - if (filename != NULL) + if (!BONOBO_EX (opt_ev) && filename != NULL) doc = xmlParseFile (filename); else if (parent_chain) type = ConfigArchiver_Location_contains (location, backend_id, opt_ev); diff --git a/archiver/bonobo-config-archiver.c b/archiver/bonobo-config-archiver.c index ab3b55f74..27890514f 100644 --- a/archiver/bonobo-config-archiver.c +++ b/archiver/bonobo-config-archiver.c @@ -677,6 +677,7 @@ bonobo_config_archiver_new (Bonobo_Moniker parent, archiver_db->location = ConfigArchiver_Archive_getLocation (archiver_db->archive, location_id, ev); if (archiver_db->location == CORBA_OBJECT_NIL) { + bonobo_object_release_unref (archiver_db->archive, NULL); bonobo_object_unref (BONOBO_OBJECT (archiver_db)); return CORBA_OBJECT_NIL; } @@ -687,7 +688,7 @@ bonobo_config_archiver_new (Bonobo_Moniker parent, archiver_db->doc = location_client_load_rollback_data (archiver_db->location, NULL, 0, archiver_db->backend_id, TRUE, ev); - if (archiver_db->doc == NULL) { + if (BONOBO_EX (ev) || archiver_db->doc == NULL) { gchar *filename; filename = g_strconcat (DEFAULTS_DIR, "/", archiver_db->backend_id, ".xml", NULL); @@ -695,9 +696,13 @@ bonobo_config_archiver_new (Bonobo_Moniker parent, g_free (filename); if (archiver_db->doc == NULL) { + bonobo_object_release_unref (archiver_db->location, NULL); + bonobo_object_release_unref (archiver_db->archive, NULL); bonobo_object_unref (BONOBO_OBJECT (archiver_db)); return CORBA_OBJECT_NIL; } + + CORBA_exception_init (ev); } if (archiver_db->doc->root == NULL) diff --git a/archiver/bonobo-moniker-archiver.c b/archiver/bonobo-moniker-archiver.c index a5d4fe1ba..939f00a3c 100644 --- a/archiver/bonobo-moniker-archiver.c +++ b/archiver/bonobo-moniker-archiver.c @@ -76,8 +76,6 @@ archive_resolve (BonoboMoniker *moniker, Bonobo_Unknown ret; - DEBUG_MSG ("Enter"); - if (strcmp (requested_interface, "IDL:ConfigArchiver/Archive:1.0")) { EX_SET_NOT_FOUND (ev); return CORBA_OBJECT_NIL; @@ -86,8 +84,6 @@ archive_resolve (BonoboMoniker *moniker, name = bonobo_moniker_get_name (moniker); if (!strcmp (name, "global-archive")) { - DEBUG_MSG ("Global archive requested"); - if (global_archive == NULL) { global_archive = ARCHIVE (archive_load (TRUE)); gtk_signal_connect (GTK_OBJECT (global_archive), "destroy", GTK_SIGNAL_FUNC (archive_destroy_cb), NULL); @@ -121,8 +117,6 @@ archive_resolve (BonoboMoniker *moniker, ret = CORBA_OBJECT_NIL; } - DEBUG_MSG ("Exit"); - return ret; } @@ -160,11 +154,11 @@ archiverdb_resolve (BonoboMoniker *moniker, db = bonobo_config_archiver_new (parent, options, backend_id, locid, ev); - bonobo_object_release_unref (parent, NULL); - if (db == CORBA_OBJECT_NIL || BONOBO_EX (ev)) EX_SET_NOT_FOUND (ev); + bonobo_object_release_unref (parent, NULL); + g_free (backend_id); g_free (locid); diff --git a/archiver/config-log.c b/archiver/config-log.c index a3307a89f..3acc4baad 100644 --- a/archiver/config-log.c +++ b/archiver/config-log.c @@ -970,8 +970,6 @@ dump_log (ConfigLog *config_log) GList *first; FILE *input, *output; - DEBUG_MSG ("Enter"); - g_return_if_fail (config_log != NULL); g_return_if_fail (IS_CONFIG_LOG (config_log)); g_return_if_fail (config_log->p->location != NULL); @@ -1010,8 +1008,6 @@ dump_log (ConfigLog *config_log) if (config_log->p->filename) rename (filename_out, config_log->p->filename); - - DEBUG_MSG ("Exit"); } /* Return TRUE if the config log has entries made by actual configuration diff --git a/archiver/location.c b/archiver/location.c index eb2264fc9..663db4861 100644 --- a/archiver/location.c +++ b/archiver/location.c @@ -160,8 +160,14 @@ impl_ConfigArchiver_Location_getRollbackFilename (PortableServer_Servant servan timeb_p = NULL; filename = location_get_rollback_filename (LOCATION_FROM_SERVANT (servant), timeb_p, steps, backendId, parentChain); - ret = CORBA_string_dup (filename); - g_free (filename); + + if (filename != NULL) { + ret = CORBA_string_dup (filename); + g_free (filename); + } else { + ret = NULL; + bonobo_exception_set (ev, ex_ConfigArchiver_Location_RollbackDataNotFound); + } return ret; } @@ -580,10 +586,10 @@ location_destroy (GtkObject *object) g_return_if_fail (object != NULL); g_return_if_fail (IS_LOCATION (object)); - DEBUG_MSG ("Enter"); - location = LOCATION (object); + DEBUG_MSG ("Enter: %s", location->p->locid); + save_metadata (location); if (location->p->config_log) @@ -597,8 +603,6 @@ location_destroy (GtkObject *object) bonobo_object_unref (BONOBO_OBJECT (location->p->archive)); GTK_OBJECT_CLASS (parent_class)->destroy (object); - - DEBUG_MSG ("Exit"); } static void @@ -818,6 +822,9 @@ location_get_rollback_filename (Location *location, if (id != -1) return g_strdup_printf ("%s/%08x.xml", location->p->fullpath, id); + else if (parent_chain && location->p->parent != NULL) + return location_get_rollback_filename + (location->p->parent, date, steps, backend_id, parent_chain); else return NULL; } diff --git a/capplets/mouse/ChangeLog b/capplets/mouse/ChangeLog index d461fa827..085697d1c 100644 --- a/capplets/mouse/ChangeLog +++ b/capplets/mouse/ChangeLog @@ -1,3 +1,8 @@ +2001-08-21 Bradford Hovinen + + * mouse-properties-capplet.c (apply_settings): Use a CORBA + exception structure + 2001-07-31 Chema Celorio * Makefile.am (cappletname): add DISTDIR to install-data-local diff --git a/capplets/mouse/gnome-mouse-properties.c b/capplets/mouse/gnome-mouse-properties.c index 931f36546..94613ac22 100644 --- a/capplets/mouse/gnome-mouse-properties.c +++ b/capplets/mouse/gnome-mouse-properties.c @@ -56,8 +56,11 @@ apply_settings (Bonobo_ConfigDatabase db) int nbuttons, num, max, den; ulong accel, threshold; gboolean rtol; + CORBA_Environment ev; - rtol = bonobo_config_get_ulong (db, "/main/right-to-left", NULL); + CORBA_exception_init (&ev); + + rtol = bonobo_config_get_ulong (db, "/main/right-to-left", &ev); nbuttons = XGetPointerMapping (GDK_DISPLAY (), buttons, MAX_BUTTONS); max = MIN (nbuttons, 3); @@ -66,7 +69,9 @@ apply_settings (Bonobo_ConfigDatabase db) XSetPointerMapping (GDK_DISPLAY (), buttons, nbuttons); - accel = bonobo_config_get_ulong (db, "/main/acceleration", NULL); + CORBA_exception_init (&ev); + + accel = bonobo_config_get_ulong (db, "/main/acceleration", &ev); if (accel < MAX_ACCEL) { num = 1; @@ -76,10 +81,14 @@ apply_settings (Bonobo_ConfigDatabase db) den = 1; } - threshold = MAX_THRESH - bonobo_config_get_ulong (db, "/main/threshold", NULL); + CORBA_exception_init (&ev); + + threshold = MAX_THRESH - bonobo_config_get_ulong (db, "/main/threshold", &ev); XChangePointerControl (GDK_DISPLAY (), True, True, num, den, threshold); + + CORBA_exception_free (&ev); } /* set_pixmap_file diff --git a/capplets/mouse/mouse-properties-capplet.c b/capplets/mouse/mouse-properties-capplet.c index 931f36546..94613ac22 100644 --- a/capplets/mouse/mouse-properties-capplet.c +++ b/capplets/mouse/mouse-properties-capplet.c @@ -56,8 +56,11 @@ apply_settings (Bonobo_ConfigDatabase db) int nbuttons, num, max, den; ulong accel, threshold; gboolean rtol; + CORBA_Environment ev; - rtol = bonobo_config_get_ulong (db, "/main/right-to-left", NULL); + CORBA_exception_init (&ev); + + rtol = bonobo_config_get_ulong (db, "/main/right-to-left", &ev); nbuttons = XGetPointerMapping (GDK_DISPLAY (), buttons, MAX_BUTTONS); max = MIN (nbuttons, 3); @@ -66,7 +69,9 @@ apply_settings (Bonobo_ConfigDatabase db) XSetPointerMapping (GDK_DISPLAY (), buttons, nbuttons); - accel = bonobo_config_get_ulong (db, "/main/acceleration", NULL); + CORBA_exception_init (&ev); + + accel = bonobo_config_get_ulong (db, "/main/acceleration", &ev); if (accel < MAX_ACCEL) { num = 1; @@ -76,10 +81,14 @@ apply_settings (Bonobo_ConfigDatabase db) den = 1; } - threshold = MAX_THRESH - bonobo_config_get_ulong (db, "/main/threshold", NULL); + CORBA_exception_init (&ev); + + threshold = MAX_THRESH - bonobo_config_get_ulong (db, "/main/threshold", &ev); XChangePointerControl (GDK_DISPLAY (), True, True, num, den, threshold); + + CORBA_exception_free (&ev); } /* set_pixmap_file diff --git a/idl/ConfigArchiver.idl b/idl/ConfigArchiver.idl index 6ff1d080a..950f41a59 100644 --- a/idl/ConfigArchiver.idl +++ b/idl/ConfigArchiver.idl @@ -57,6 +57,8 @@ module ConfigArchiver { }; interface Location : Bonobo::Unknown { + exception RollbackDataNotFound {}; + readonly attribute Location parent; readonly attribute string path; readonly attribute StringSeq backendList; @@ -70,7 +72,8 @@ module ConfigArchiver { string getRollbackFilename (in Time time, in long steps, in string backendId, - in boolean parentChain); + in boolean parentChain) + raises (RollbackDataNotFound); void rollbackBackends (in Time time, in long steps, @@ -95,6 +98,8 @@ module ConfigArchiver { typedef sequence LocationSeq; interface Archive : Bonobo::Unknown { + exception LocationNotFound {}; + readonly attribute string prefix; readonly attribute boolean isGlobal; readonly attribute BackendList backendList; @@ -102,7 +107,9 @@ module ConfigArchiver { attribute Location currentLocation; attribute string currentLocationId; - Location getLocation (in string locid); + Location getLocation (in string locid) + raises (LocationNotFound); + Location createLocation (in string locid, in string label, in Location parent);