Added exception RollbackDataNotFound Added exception LocationNotFound

2001-08-21  Bradford Hovinen  <hovinen@ximian.com>

	* idl/ConfigArchiver.idl: Added exception RollbackDataNotFound
	Added exception LocationNotFound

	* 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

	* mouse-properties-capplet.c (apply_settings): Use a CORBA
	exception structure
This commit is contained in:
Bradford Hovinen 2001-08-22 13:56:23 +00:00 committed by Bradford Hovinen (Gdict maintainer)
parent 1b30f14a62
commit b37d7f6897
13 changed files with 174 additions and 94 deletions

View file

@ -1,3 +1,53 @@
2001-08-21 Bradford Hovinen <hovinen@ximian.com>
* 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 <hestilow@ximian.com>
* Makefile.am: Add dependency on CORBA_SOURCE to archiver-client.c.

View file

@ -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 */

View file

@ -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 */

View file

@ -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);

View file

@ -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)

View file

@ -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);

View file

@ -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

View file

@ -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;
}