gnome-control-center/archiver/bonobo-moniker-archiver.c

147 lines
3.7 KiB
C
Raw Normal View History

/*
* bonobo-moniker-archiver.c: archiver xml database moniker implementation
*
* Author:
* Dietmar Maurer (dietmar@ximian.com)
* Bradford Hovinen <hovinen@ximian.com>
*
* Copyright 2001 Ximian, Inc.
*/
Make backend_id const 2001-09-07 Bradford Hovinen <hovinen@ximian.com> * archiver-client.c (location_client_store_xml): Make backend_id const * util.c (parse_date): Set the time zone (parse_date): Initialize tm_isdst * archiver-client.c (location_client_store_xml): Call ConfigArchiver_Location_storageComplete when done (location_client_store_xml): Don't try to save the XML file if there was an error getting the storage filename * location.c (location_storage_complete): Implement (impl_ConfigArchiver_Location_storageComplete): Implement * config-log.c (config_log_get_backend_id_for_id): Make return value const 2001-09-04 Bradford Hovinen <hovinen@ximian.com> * location.c (location_get_storage_filename): Notify listeners that new rollback data is available * bonobo-config-archiver.c (new_rollback_cb): Implement (bonobo_config_archiver_new): Connect above to event source * location.c (location_store): (location_init): Construct an event source and add its interface * Makefile.am (INCLUDES): Remove -DDEFAULTS_DIR 2001-09-03 Bradford Hovinen <hovinen@ximian.com> * bonobo-config-archiver.c (bonobo_config_archiver_new): Accept complete moniker as an argument; do the parsing here * archiver-client.c (location_client_load_rollback_data): Adjust time from mktime according to time zone information * bonobo-moniker-archiver.c (is_leap_year): (mod_date_by_str): Implement (parse_name): Use correct math for computing offsets * bonobo-config-archiver.c (bonobo_config_archiver_new): Don't print an error message if the parent moniker is bad (bonobo_config_archiver_new): Remove debugging messages * archiver-client.c (location_client_load_rollback_data): Make date and backend_id const * bonobo-moniker-archiver.c (archiverdb_resolve): Determine date from moniker and pass to bonobo_config_archiver_new * bonobo-config-archiver.c (bonobo_config_archiver_new): Accept date structure as argument
2001-09-12 15:30:41 +00:00
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <bonobo.h>
#include "bonobo-config-archiver.h"
2001-08-20 15:47:57 +00:00
#include "archive.h"
#include "util.h"
2001-08-20 15:47:57 +00:00
static Archive *user_archive = NULL;
static Archive *global_archive = NULL;
static void
archive_destroy_cb (Archive *archive)
{
if (archive == global_archive)
global_archive = NULL;
else if (archive == user_archive)
user_archive = NULL;
}
static Bonobo_Unknown
2001-08-20 15:47:57 +00:00
archive_resolve (BonoboMoniker *moniker,
const Bonobo_ResolveOptions *options,
const CORBA_char *requested_interface,
CORBA_Environment *ev)
{
2001-08-20 15:47:57 +00:00
const gchar *name;
Bonobo_Unknown ret;
if (strcmp (requested_interface, "IDL:ConfigArchiver/Archive:1.0")) {
EX_SET_NOT_FOUND (ev);
return CORBA_OBJECT_NIL;
}
name = bonobo_moniker_get_name (moniker);
if (!strcmp (name, "global-archive")) {
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);
ret = CORBA_Object_duplicate (BONOBO_OBJREF (global_archive), ev);
} else {
ret = bonobo_object_dup_ref (BONOBO_OBJREF (global_archive), ev);
}
if (BONOBO_EX (ev)) {
g_critical ("Cannot duplicate object");
bonobo_object_release_unref (ret, NULL);
ret = CORBA_OBJECT_NIL;
}
}
else if (!strcmp (name, "user-archive")) {
if (user_archive == NULL) {
user_archive = ARCHIVE (archive_load (FALSE));
gtk_signal_connect (GTK_OBJECT (user_archive), "destroy", GTK_SIGNAL_FUNC (archive_destroy_cb), NULL);
ret = CORBA_Object_duplicate (BONOBO_OBJREF (user_archive), ev);
} else {
ret = bonobo_object_dup_ref (BONOBO_OBJREF (user_archive), ev);
}
if (BONOBO_EX (ev)) {
g_critical ("Cannot duplicate object");
bonobo_object_release_unref (ret, NULL);
ret = CORBA_OBJECT_NIL;
}
} else {
EX_SET_NOT_FOUND (ev);
ret = CORBA_OBJECT_NIL;
}
return ret;
}
static Bonobo_Unknown
archiverdb_resolve (BonoboMoniker *moniker,
const Bonobo_ResolveOptions *options,
const CORBA_char *requested_interface,
CORBA_Environment *ev)
{
Bonobo_Moniker parent;
Bonobo_ConfigDatabase db;
const gchar *name;
if (strcmp (requested_interface, "IDL:Bonobo/ConfigDatabase:1.0")) {
EX_SET_NOT_FOUND (ev);
return CORBA_OBJECT_NIL;
}
parent = bonobo_moniker_get_parent (moniker, ev);
if (BONOBO_EX (ev))
return CORBA_OBJECT_NIL;
2001-08-20 15:47:57 +00:00
if (parent == CORBA_OBJECT_NIL) {
EX_SET_NOT_FOUND (ev);
return CORBA_OBJECT_NIL;
}
2001-08-20 15:47:57 +00:00
name = bonobo_moniker_get_name (moniker);
Make backend_id const 2001-09-07 Bradford Hovinen <hovinen@ximian.com> * archiver-client.c (location_client_store_xml): Make backend_id const * util.c (parse_date): Set the time zone (parse_date): Initialize tm_isdst * archiver-client.c (location_client_store_xml): Call ConfigArchiver_Location_storageComplete when done (location_client_store_xml): Don't try to save the XML file if there was an error getting the storage filename * location.c (location_storage_complete): Implement (impl_ConfigArchiver_Location_storageComplete): Implement * config-log.c (config_log_get_backend_id_for_id): Make return value const 2001-09-04 Bradford Hovinen <hovinen@ximian.com> * location.c (location_get_storage_filename): Notify listeners that new rollback data is available * bonobo-config-archiver.c (new_rollback_cb): Implement (bonobo_config_archiver_new): Connect above to event source * location.c (location_store): (location_init): Construct an event source and add its interface * Makefile.am (INCLUDES): Remove -DDEFAULTS_DIR 2001-09-03 Bradford Hovinen <hovinen@ximian.com> * bonobo-config-archiver.c (bonobo_config_archiver_new): Accept complete moniker as an argument; do the parsing here * archiver-client.c (location_client_load_rollback_data): Adjust time from mktime according to time zone information * bonobo-moniker-archiver.c (is_leap_year): (mod_date_by_str): Implement (parse_name): Use correct math for computing offsets * bonobo-config-archiver.c (bonobo_config_archiver_new): Don't print an error message if the parent moniker is bad (bonobo_config_archiver_new): Remove debugging messages * archiver-client.c (location_client_load_rollback_data): Make date and backend_id const * bonobo-moniker-archiver.c (archiverdb_resolve): Determine date from moniker and pass to bonobo_config_archiver_new * bonobo-config-archiver.c (bonobo_config_archiver_new): Accept date structure as argument
2001-09-12 15:30:41 +00:00
db = bonobo_config_archiver_new (parent, options, name, ev);
2001-08-20 15:47:57 +00:00
if (db == CORBA_OBJECT_NIL || BONOBO_EX (ev))
EX_SET_NOT_FOUND (ev);
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
2001-08-22 13:56:23 +00:00
bonobo_object_release_unref (parent, NULL);
return db;
}
static BonoboObject *
bonobo_moniker_archiver_factory (BonoboGenericFactory *this,
const char *object_id,
void *closure)
{
2001-08-20 15:47:57 +00:00
if (!strcmp (object_id, "OAFIID:Bonobo_Moniker_archiverdb")) {
return BONOBO_OBJECT (bonobo_moniker_simple_new
("archiverdb:", archiverdb_resolve));
}
else if (!strcmp (object_id, "OAFIID:Bonobo_Moniker_archive")) {
return BONOBO_OBJECT (bonobo_moniker_simple_new
("archive:", archive_resolve));
} else {
g_warning ("Failing to manufacture a '%s'", object_id);
2001-08-20 15:47:57 +00:00
}
return NULL;
}
BONOBO_OAF_FACTORY_MULTI ("OAFIID:Bonobo_Moniker_archiver_Factory",
"bonobo xml archiver database moniker", "1.0",
bonobo_moniker_archiver_factory,
NULL);