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
This commit is contained in:
parent
7f4dbc6ff6
commit
6ab6caa498
12 changed files with 343 additions and 142 deletions
|
@ -1,3 +1,60 @@
|
||||||
|
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-08-29 Bradford Hovinen <hovinen@ximian.com>
|
2001-08-29 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
* archive.c (foreach_build_list_cb): Don't unref the location if
|
* archive.c (foreach_build_list_cb): Don't unref the location if
|
||||||
|
|
|
@ -16,7 +16,6 @@ INCLUDES = \
|
||||||
-DLOCATION_DIR=\""$(datadir)/control-center/archiver"\" \
|
-DLOCATION_DIR=\""$(datadir)/control-center/archiver"\" \
|
||||||
-DGLADE_DIR=\""$(INTERFACES_DIR)"\" \
|
-DGLADE_DIR=\""$(INTERFACES_DIR)"\" \
|
||||||
-DXST_BACKEND_LOCATION=\""$(datadir)/setup-tool-backends/scripts"\" \
|
-DXST_BACKEND_LOCATION=\""$(datadir)/setup-tool-backends/scripts"\" \
|
||||||
-DDEFAULTS_DIR=\""$(datadir)/control-center/defaults"\" \
|
|
||||||
@ARCHIVER_CFLAGS@ \
|
@ARCHIVER_CFLAGS@ \
|
||||||
@MONIKER_CFLAGS@
|
@MONIKER_CFLAGS@
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <gnome-xml/parser.h>
|
#include <gnome-xml/parser.h>
|
||||||
|
|
||||||
#include "archiver-client.h"
|
#include "archiver-client.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
static void merge_xml_docs (xmlDocPtr child_doc,
|
static void merge_xml_docs (xmlDocPtr child_doc,
|
||||||
xmlDocPtr parent_doc);
|
xmlDocPtr parent_doc);
|
||||||
|
@ -56,18 +57,22 @@ static gboolean compare_xml_nodes (xmlNodePtr node1, xmlNodePtr node2);
|
||||||
|
|
||||||
xmlDocPtr
|
xmlDocPtr
|
||||||
location_client_load_rollback_data (ConfigArchiver_Location location,
|
location_client_load_rollback_data (ConfigArchiver_Location location,
|
||||||
struct tm *date,
|
const struct tm *date,
|
||||||
guint steps,
|
guint steps,
|
||||||
gchar *backend_id,
|
const gchar *backend_id,
|
||||||
gboolean parent_chain,
|
gboolean parent_chain,
|
||||||
CORBA_Environment *opt_ev)
|
CORBA_Environment *opt_ev)
|
||||||
{
|
{
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
time_t time_g;
|
struct tm *date_c;
|
||||||
xmlDocPtr doc = NULL, parent_doc = NULL;
|
time_t time_g;
|
||||||
ConfigArchiver_ContainmentType type = ConfigArchiver_CONTAIN_FULL;
|
|
||||||
ConfigArchiver_Location parent = CORBA_OBJECT_NIL;
|
xmlDocPtr doc = NULL;
|
||||||
CORBA_Environment my_ev;
|
xmlDocPtr parent_doc = NULL;
|
||||||
|
ConfigArchiver_ContainmentType type = ConfigArchiver_CONTAIN_FULL;
|
||||||
|
ConfigArchiver_Location parent = CORBA_OBJECT_NIL;
|
||||||
|
|
||||||
|
CORBA_Environment my_ev;
|
||||||
|
|
||||||
g_return_val_if_fail (location != CORBA_OBJECT_NIL, NULL);
|
g_return_val_if_fail (location != CORBA_OBJECT_NIL, NULL);
|
||||||
|
|
||||||
|
@ -76,14 +81,21 @@ location_client_load_rollback_data (ConfigArchiver_Location location,
|
||||||
CORBA_exception_init (opt_ev);
|
CORBA_exception_init (opt_ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (date != NULL)
|
if (date != NULL) {
|
||||||
time_g = mktime (date);
|
date_c = dup_date (date);
|
||||||
else
|
time_g = mktime (date_c) + date_c->tm_gmtoff;
|
||||||
|
if (date_c->tm_isdst) time_g -= 3600;
|
||||||
|
g_free (date_c);
|
||||||
|
} else {
|
||||||
time_g = 0;
|
time_g = 0;
|
||||||
|
}
|
||||||
|
|
||||||
filename = ConfigArchiver_Location_getRollbackFilename
|
filename = ConfigArchiver_Location_getRollbackFilename
|
||||||
(location, time_g, steps, backend_id, parent_chain, opt_ev);
|
(location, time_g, steps, backend_id, parent_chain, opt_ev);
|
||||||
|
|
||||||
|
if (!BONOBO_EX (opt_ev) && filename != NULL)
|
||||||
|
DEBUG_MSG ("Loading rollback data: %s", filename);
|
||||||
|
|
||||||
if (!BONOBO_EX (opt_ev) && filename != NULL)
|
if (!BONOBO_EX (opt_ev) && filename != NULL)
|
||||||
doc = xmlParseFile (filename);
|
doc = xmlParseFile (filename);
|
||||||
else if (parent_chain)
|
else if (parent_chain)
|
||||||
|
@ -127,16 +139,17 @@ location_client_load_rollback_data (ConfigArchiver_Location location,
|
||||||
|
|
||||||
void
|
void
|
||||||
location_client_store_xml (ConfigArchiver_Location location,
|
location_client_store_xml (ConfigArchiver_Location location,
|
||||||
gchar *backend_id,
|
const gchar *backend_id,
|
||||||
xmlDocPtr xml_doc,
|
xmlDocPtr xml_doc,
|
||||||
ConfigArchiver_StoreType store_type,
|
ConfigArchiver_StoreType store_type,
|
||||||
CORBA_Environment *opt_ev)
|
CORBA_Environment *opt_ev)
|
||||||
{
|
{
|
||||||
xmlDocPtr parent_doc, prev_doc = NULL;
|
xmlDocPtr parent_doc;
|
||||||
char *filename;
|
xmlDocPtr prev_doc = NULL;
|
||||||
ConfigArchiver_ContainmentType contain_type;
|
char *filename;
|
||||||
ConfigArchiver_Location parent;
|
ConfigArchiver_ContainmentType contain_type;
|
||||||
CORBA_Environment my_ev;
|
ConfigArchiver_Location parent;
|
||||||
|
CORBA_Environment my_ev;
|
||||||
|
|
||||||
g_return_if_fail (location != CORBA_OBJECT_NIL);
|
g_return_if_fail (location != CORBA_OBJECT_NIL);
|
||||||
g_return_if_fail (xml_doc != NULL);
|
g_return_if_fail (xml_doc != NULL);
|
||||||
|
@ -191,9 +204,14 @@ location_client_store_xml (ConfigArchiver_Location location,
|
||||||
if (parent != CORBA_OBJECT_NIL)
|
if (parent != CORBA_OBJECT_NIL)
|
||||||
bonobo_object_release_unref (parent, NULL);
|
bonobo_object_release_unref (parent, NULL);
|
||||||
|
|
||||||
filename = ConfigArchiver_Location_getStorageFilename (location, backend_id, store_type == ConfigArchiver_STORE_DEFAULT, opt_ev);
|
filename = ConfigArchiver_Location_getStorageFilename
|
||||||
xmlSaveFile (filename, xml_doc);
|
(location, backend_id, store_type == ConfigArchiver_STORE_DEFAULT, opt_ev);
|
||||||
CORBA_free (filename);
|
|
||||||
|
if (!BONOBO_EX (opt_ev) && filename != NULL) {
|
||||||
|
xmlSaveFile (filename, xml_doc);
|
||||||
|
ConfigArchiver_Location_storageComplete (location, filename, opt_ev);
|
||||||
|
CORBA_free (filename);
|
||||||
|
}
|
||||||
|
|
||||||
if (opt_ev == &my_ev)
|
if (opt_ev == &my_ev)
|
||||||
CORBA_exception_free (opt_ev);
|
CORBA_exception_free (opt_ev);
|
||||||
|
|
|
@ -31,14 +31,14 @@
|
||||||
#include "ConfigArchiver.h"
|
#include "ConfigArchiver.h"
|
||||||
|
|
||||||
xmlDocPtr location_client_load_rollback_data (ConfigArchiver_Location location,
|
xmlDocPtr location_client_load_rollback_data (ConfigArchiver_Location location,
|
||||||
struct tm *date,
|
const struct tm *date,
|
||||||
guint steps,
|
guint steps,
|
||||||
gchar *backend_id,
|
const gchar *backend_id,
|
||||||
gboolean parent_chain,
|
gboolean parent_chain,
|
||||||
CORBA_Environment *opt_ev);
|
CORBA_Environment *opt_ev);
|
||||||
|
|
||||||
void location_client_store_xml (ConfigArchiver_Location location,
|
void location_client_store_xml (ConfigArchiver_Location location,
|
||||||
gchar *backend_id,
|
const gchar *backend_id,
|
||||||
xmlDocPtr xml_doc,
|
xmlDocPtr xml_doc,
|
||||||
ConfigArchiver_StoreType store_type,
|
ConfigArchiver_StoreType store_type,
|
||||||
CORBA_Environment *opt_ev);
|
CORBA_Environment *opt_ev);
|
||||||
|
|
|
@ -15,10 +15,8 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <bonobo/bonobo-arg.h>
|
#include <ctype.h>
|
||||||
#include <bonobo/bonobo-property-bag-xml.h>
|
#include <bonobo.h>
|
||||||
#include <bonobo/bonobo-moniker-util.h>
|
|
||||||
#include <bonobo/bonobo-exception.h>
|
|
||||||
#include <bonobo-conf/bonobo-config-utils.h>
|
#include <bonobo-conf/bonobo-config-utils.h>
|
||||||
#include <gnome-xml/xmlmemory.h>
|
#include <gnome-xml/xmlmemory.h>
|
||||||
#include <gtk/gtkmain.h>
|
#include <gtk/gtkmain.h>
|
||||||
|
@ -496,9 +494,9 @@ bonobo_config_archiver_destroy (GtkObject *object)
|
||||||
|
|
||||||
CORBA_exception_init (&ev);
|
CORBA_exception_init (&ev);
|
||||||
|
|
||||||
if (archiver_db->real_name != NULL) {
|
if (archiver_db->moniker != NULL) {
|
||||||
bonobo_url_unregister ("BONOBO_CONF:ARCHIVER", archiver_db->real_name, &ev);
|
bonobo_url_unregister ("BONOBO_CONF:ARCHIVER", archiver_db->moniker, &ev);
|
||||||
g_free (archiver_db->real_name);
|
g_free (archiver_db->moniker);
|
||||||
}
|
}
|
||||||
|
|
||||||
CORBA_exception_free (&ev);
|
CORBA_exception_free (&ev);
|
||||||
|
@ -624,74 +622,177 @@ fill_cache (BonoboConfigArchiver *archiver_db)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* parse_name
|
||||||
|
*
|
||||||
|
* Given a moniker with a backend id and (possibly) a location id encoded
|
||||||
|
* therein, parse out the backend id and the location id and set the pointers
|
||||||
|
* given to them.
|
||||||
|
*
|
||||||
|
* FIXME: Is this encoding really the way we want to do this? Ask Dietmar and
|
||||||
|
* Michael.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
parse_name (const gchar *name, gchar **backend_id, gchar **location, struct tm **date)
|
||||||
|
{
|
||||||
|
gchar *e, *e1, *time_str = NULL;
|
||||||
|
|
||||||
|
*date = NULL;
|
||||||
|
|
||||||
|
if (name[0] == '[') {
|
||||||
|
e = strchr (name + 1, '|');
|
||||||
|
|
||||||
|
if (e != NULL) {
|
||||||
|
*location = g_strndup (name + 1, e - (name + 1));
|
||||||
|
e1 = strchr (e + 1, ']');
|
||||||
|
|
||||||
|
if (e1 != NULL) {
|
||||||
|
time_str = g_strndup (e + 1, e1 - (e + 1));
|
||||||
|
*date = parse_date (time_str);
|
||||||
|
g_free (time_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
*backend_id = g_strdup (e1 + 1);
|
||||||
|
} else {
|
||||||
|
e = strchr (name + 1, ']');
|
||||||
|
|
||||||
|
if (e != NULL)
|
||||||
|
*location = g_strndup (name + 1, e - (name + 1));
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
*backend_id = g_strdup (e + 1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*backend_id = g_strdup (name);
|
||||||
|
*location = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*location != NULL && **location == '\0') {
|
||||||
|
g_free (*location);
|
||||||
|
*location = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
new_rollback_cb (BonoboListener *listener,
|
||||||
|
gchar *event_name,
|
||||||
|
CORBA_any *any,
|
||||||
|
CORBA_Environment *ev,
|
||||||
|
BonoboConfigArchiver *archiver_db)
|
||||||
|
{
|
||||||
|
BonoboArg *arg;
|
||||||
|
|
||||||
|
if (archiver_db->dir != NULL) {
|
||||||
|
delete_dir_data (archiver_db->dir, TRUE);
|
||||||
|
g_free (archiver_db->dir->name);
|
||||||
|
g_free (archiver_db->dir);
|
||||||
|
archiver_db->dir = g_new0 (DirData, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (archiver_db->doc != NULL)
|
||||||
|
xmlFreeDoc (archiver_db->doc);
|
||||||
|
|
||||||
|
archiver_db->doc = location_client_load_rollback_data
|
||||||
|
(archiver_db->location, NULL, 0, archiver_db->backend_id, TRUE, ev);
|
||||||
|
|
||||||
|
if (archiver_db->doc == NULL)
|
||||||
|
g_critical ("Could not load new rollback data");
|
||||||
|
else
|
||||||
|
fill_cache (archiver_db);
|
||||||
|
|
||||||
|
arg = bonobo_arg_new (BONOBO_ARG_NULL);
|
||||||
|
bonobo_event_source_notify_listeners (archiver_db->es, "Bonobo/ConfigDatabase:sync", arg, ev);
|
||||||
|
bonobo_arg_release (arg);
|
||||||
|
}
|
||||||
|
|
||||||
Bonobo_ConfigDatabase
|
Bonobo_ConfigDatabase
|
||||||
bonobo_config_archiver_new (Bonobo_Moniker parent,
|
bonobo_config_archiver_new (Bonobo_Moniker parent,
|
||||||
const Bonobo_ResolveOptions *options,
|
const Bonobo_ResolveOptions *options,
|
||||||
const char *backend_id,
|
const char *moniker,
|
||||||
const char *location_id,
|
|
||||||
CORBA_Environment *ev)
|
CORBA_Environment *ev)
|
||||||
{
|
{
|
||||||
BonoboConfigArchiver *archiver_db;
|
BonoboConfigArchiver *archiver_db;
|
||||||
Bonobo_ConfigDatabase db;
|
Bonobo_ConfigDatabase db;
|
||||||
gchar *real_name;
|
ConfigArchiver_Archive archive;
|
||||||
|
ConfigArchiver_Location location;
|
||||||
|
gchar *moniker_tmp;
|
||||||
|
gchar *backend_id;
|
||||||
|
gchar *location_id;
|
||||||
|
struct tm *date;
|
||||||
|
|
||||||
g_return_val_if_fail (backend_id != NULL, NULL);
|
g_return_val_if_fail (backend_id != NULL, NULL);
|
||||||
|
|
||||||
DEBUG_MSG ("Enter");
|
/* Check the Bonobo URL database to see if this archiver database has
|
||||||
|
* already been created, and return it if it has */
|
||||||
|
|
||||||
if (location_id == NULL)
|
moniker_tmp = g_strdup (moniker);
|
||||||
real_name = g_strdup (backend_id);
|
db = bonobo_url_lookup ("BONOBO_CONF:ARCHIVER", moniker_tmp, ev);
|
||||||
else
|
g_free (moniker_tmp);
|
||||||
real_name = g_strconcat ("[", location_id, "]", backend_id, NULL);
|
|
||||||
|
|
||||||
db = bonobo_url_lookup ("BONOBO_CONF:ARCHIVER", real_name, ev);
|
|
||||||
|
|
||||||
if (BONOBO_EX (ev)) {
|
if (BONOBO_EX (ev)) {
|
||||||
db = CORBA_OBJECT_NIL;
|
db = CORBA_OBJECT_NIL;
|
||||||
CORBA_exception_init (ev);
|
CORBA_exception_init (ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db) {
|
if (db != CORBA_OBJECT_NIL)
|
||||||
g_free (real_name);
|
|
||||||
return bonobo_object_dup_ref (db, NULL);
|
return bonobo_object_dup_ref (db, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
DEBUG_MSG ("Creating object");
|
/* Parse out the backend id, location id, and rollback date from the
|
||||||
|
* moniker given */
|
||||||
|
|
||||||
if ((archiver_db = gtk_type_new (BONOBO_CONFIG_ARCHIVER_TYPE)) == NULL) {
|
if (parse_name (moniker, &backend_id, &location_id, &date) < 0) {
|
||||||
g_free (real_name);
|
EX_SET_NOT_FOUND (ev);
|
||||||
return CORBA_OBJECT_NIL;
|
return CORBA_OBJECT_NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
archiver_db->archive = Bonobo_Moniker_resolve (parent, options, "IDL:ConfigArchiver/Archive:1.0", ev);
|
/* Resolve the parent archive and the location */
|
||||||
|
|
||||||
if (BONOBO_EX (ev) || archiver_db->archive == CORBA_OBJECT_NIL) {
|
archive = Bonobo_Moniker_resolve (parent, options, "IDL:ConfigArchiver/Archive:1.0", ev);
|
||||||
g_critical ("Could not resolve parent moniker to an archive");
|
|
||||||
bonobo_object_unref (BONOBO_OBJECT (archiver_db));
|
if (BONOBO_EX (ev) || archive == CORBA_OBJECT_NIL) {
|
||||||
|
g_free (location_id);
|
||||||
|
g_free (date);
|
||||||
return CORBA_OBJECT_NIL;
|
return CORBA_OBJECT_NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location_id == NULL || *location_id == '\0')
|
if (location_id == NULL || *location_id == '\0')
|
||||||
archiver_db->location = ConfigArchiver_Archive__get_currentLocation (archiver_db->archive, ev);
|
location = ConfigArchiver_Archive__get_currentLocation (archive, ev);
|
||||||
else
|
else
|
||||||
archiver_db->location = ConfigArchiver_Archive_getLocation (archiver_db->archive, location_id, ev);
|
location = ConfigArchiver_Archive_getLocation (archive, location_id, ev);
|
||||||
|
|
||||||
if (archiver_db->location == CORBA_OBJECT_NIL) {
|
g_free (location_id);
|
||||||
bonobo_object_release_unref (archiver_db->archive, NULL);
|
|
||||||
bonobo_object_unref (BONOBO_OBJECT (archiver_db));
|
if (location == CORBA_OBJECT_NIL) {
|
||||||
|
g_free (date);
|
||||||
|
bonobo_object_release_unref (archive, NULL);
|
||||||
return CORBA_OBJECT_NIL;
|
return CORBA_OBJECT_NIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
archiver_db->backend_id = g_strdup (backend_id);
|
/* Construct the database object proper and fill in its values */
|
||||||
archiver_db->real_name = real_name;
|
|
||||||
|
if ((archiver_db = gtk_type_new (BONOBO_CONFIG_ARCHIVER_TYPE)) == NULL) {
|
||||||
|
g_free (date);
|
||||||
|
return CORBA_OBJECT_NIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
archiver_db->backend_id = backend_id;
|
||||||
|
archiver_db->moniker = g_strdup (moniker);
|
||||||
|
archiver_db->archive = archive;
|
||||||
|
archiver_db->location = location;
|
||||||
|
|
||||||
|
/* Load the XML data, or use the defaults file if none are present */
|
||||||
|
|
||||||
archiver_db->doc = location_client_load_rollback_data
|
archiver_db->doc = location_client_load_rollback_data
|
||||||
(archiver_db->location, NULL, 0, archiver_db->backend_id, TRUE, ev);
|
(archiver_db->location, date, 0, archiver_db->backend_id, TRUE, ev);
|
||||||
|
g_free (date);
|
||||||
|
|
||||||
if (BONOBO_EX (ev) || archiver_db->doc == NULL) {
|
if (BONOBO_EX (ev) || archiver_db->doc == NULL) {
|
||||||
gchar *filename;
|
gchar *filename;
|
||||||
|
|
||||||
filename = g_strconcat (DEFAULTS_DIR, "/", archiver_db->backend_id, ".xml", NULL);
|
filename = g_strconcat (GNOMECC_DEFAULTS_DIR "/", archiver_db->backend_id, ".xml", NULL);
|
||||||
archiver_db->doc = xmlParseFile (filename);
|
archiver_db->doc = xmlParseFile (filename);
|
||||||
g_free (filename);
|
g_free (filename);
|
||||||
|
|
||||||
|
@ -705,6 +806,8 @@ bonobo_config_archiver_new (Bonobo_Moniker parent,
|
||||||
CORBA_exception_init (ev);
|
CORBA_exception_init (ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Load data from the XML file */
|
||||||
|
|
||||||
if (archiver_db->doc->root == NULL)
|
if (archiver_db->doc->root == NULL)
|
||||||
archiver_db->doc->root =
|
archiver_db->doc->root =
|
||||||
xmlNewDocNode (archiver_db->doc, NULL, "bonobo-config", NULL);
|
xmlNewDocNode (archiver_db->doc, NULL, "bonobo-config", NULL);
|
||||||
|
@ -718,6 +821,8 @@ bonobo_config_archiver_new (Bonobo_Moniker parent,
|
||||||
|
|
||||||
fill_cache (archiver_db);
|
fill_cache (archiver_db);
|
||||||
|
|
||||||
|
/* Construct the associated property bag and event source */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
archiver_db->es = bonobo_event_source_new ();
|
archiver_db->es = bonobo_event_source_new ();
|
||||||
|
|
||||||
|
@ -739,11 +844,20 @@ bonobo_config_archiver_new (Bonobo_Moniker parent,
|
||||||
"Date (time_t) of modification",
|
"Date (time_t) of modification",
|
||||||
BONOBO_PROPERTY_READABLE);
|
BONOBO_PROPERTY_READABLE);
|
||||||
|
|
||||||
|
/* Listen for events pertaining to new rollback data */
|
||||||
|
|
||||||
|
if (date == NULL && location_id == NULL)
|
||||||
|
bonobo_event_source_client_add_listener
|
||||||
|
(location, (BonoboListenerCallbackFn) new_rollback_cb,
|
||||||
|
"ConfigArchiver/Location:newRollbackData", ev, archiver_db);
|
||||||
|
|
||||||
|
/* Prepare to return the database object */
|
||||||
|
|
||||||
db = CORBA_Object_duplicate (BONOBO_OBJREF (archiver_db), NULL);
|
db = CORBA_Object_duplicate (BONOBO_OBJREF (archiver_db), NULL);
|
||||||
|
|
||||||
bonobo_url_register ("BONOBO_CONF:ARCHIVER", real_name, NULL, db, ev);
|
moniker_tmp = g_strdup (moniker);
|
||||||
|
bonobo_url_register ("BONOBO_CONF:ARCHIVER", moniker_tmp, NULL, db, ev);
|
||||||
DEBUG_MSG ("Exit: %p", db);
|
g_free (moniker_tmp);
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
|
|
||||||
BEGIN_GNOME_DECLS
|
BEGIN_GNOME_DECLS
|
||||||
|
|
||||||
|
#define EX_SET_NOT_FOUND(ev) bonobo_exception_set (ev, ex_Bonobo_Moniker_InterfaceNotFound)
|
||||||
|
|
||||||
#define BONOBO_CONFIG_ARCHIVER_TYPE (bonobo_config_archiver_get_type ())
|
#define BONOBO_CONFIG_ARCHIVER_TYPE (bonobo_config_archiver_get_type ())
|
||||||
#define BONOBO_CONFIG_ARCHIVER(o) (GTK_CHECK_CAST ((o), BONOBO_CONFIG_ARCHIVER_TYPE, BonoboConfigArchiver))
|
#define BONOBO_CONFIG_ARCHIVER(o) (GTK_CHECK_CAST ((o), BONOBO_CONFIG_ARCHIVER_TYPE, BonoboConfigArchiver))
|
||||||
#define BONOBO_CONFIG_ARCHIVER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), BONOBO_CONFIG_ARCHIVER_TYPE, BonoboConfigArchiverClass))
|
#define BONOBO_CONFIG_ARCHIVER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), BONOBO_CONFIG_ARCHIVER_TYPE, BonoboConfigArchiverClass))
|
||||||
|
@ -59,7 +61,7 @@ struct _BonoboConfigArchiver {
|
||||||
ConfigArchiver_Archive archive;
|
ConfigArchiver_Archive archive;
|
||||||
ConfigArchiver_Location location;
|
ConfigArchiver_Location location;
|
||||||
gchar *backend_id;
|
gchar *backend_id;
|
||||||
gchar *real_name;
|
gchar *moniker;
|
||||||
|
|
||||||
BonoboEventSource *es;
|
BonoboEventSource *es;
|
||||||
BonoboPropertyBag *pb;
|
BonoboPropertyBag *pb;
|
||||||
|
@ -76,8 +78,7 @@ bonobo_config_archiver_get_type (void);
|
||||||
Bonobo_ConfigDatabase
|
Bonobo_ConfigDatabase
|
||||||
bonobo_config_archiver_new (Bonobo_Moniker parent,
|
bonobo_config_archiver_new (Bonobo_Moniker parent,
|
||||||
const Bonobo_ResolveOptions *options,
|
const Bonobo_ResolveOptions *options,
|
||||||
const char *backend_id,
|
const char *moniker,
|
||||||
const char *location_id,
|
|
||||||
CORBA_Environment *ev);
|
CORBA_Environment *ev);
|
||||||
|
|
||||||
END_GNOME_DECLS
|
END_GNOME_DECLS
|
||||||
|
|
|
@ -7,56 +7,20 @@
|
||||||
*
|
*
|
||||||
* Copyright 2001 Ximian, Inc.
|
* Copyright 2001 Ximian, Inc.
|
||||||
*/
|
*/
|
||||||
#include <config.h>
|
|
||||||
#include <bonobo/bonobo-main.h>
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <bonobo/bonobo-context.h>
|
# include <config.h>
|
||||||
#include <bonobo/bonobo-moniker.h>
|
#endif
|
||||||
#include <bonobo/bonobo-moniker-util.h>
|
|
||||||
#include <bonobo/bonobo-moniker-simple.h>
|
#include <bonobo.h>
|
||||||
#include <bonobo/bonobo-shlib-factory.h>
|
|
||||||
#include <bonobo/bonobo-exception.h>
|
|
||||||
|
|
||||||
#include "bonobo-config-archiver.h"
|
#include "bonobo-config-archiver.h"
|
||||||
#include "archive.h"
|
#include "archive.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#define EX_SET_NOT_FOUND(ev) bonobo_exception_set (ev, ex_Bonobo_Moniker_InterfaceNotFound)
|
|
||||||
|
|
||||||
static Archive *user_archive = NULL;
|
static Archive *user_archive = NULL;
|
||||||
static Archive *global_archive = NULL;
|
static Archive *global_archive = NULL;
|
||||||
|
|
||||||
/* parse_name
|
|
||||||
*
|
|
||||||
* Given a moniker with a backend id and (possibly) a location id encoded
|
|
||||||
* therein, parse out the backend id and the location id and set the pointers
|
|
||||||
* given to them.
|
|
||||||
*
|
|
||||||
* FIXME: Is this encoding really the way we want to do this? Ask Dietmar and
|
|
||||||
* Michael.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
parse_name (const gchar *name, gchar **backend_id, gchar **location)
|
|
||||||
{
|
|
||||||
gchar *e;
|
|
||||||
|
|
||||||
if (name[0] == '[') {
|
|
||||||
e = strchr (name + 1, ']');
|
|
||||||
|
|
||||||
if (e != NULL)
|
|
||||||
*location = g_strndup (name + 1, e - name + 1);
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
*backend_id = g_strdup (e + 1);
|
|
||||||
} else {
|
|
||||||
*backend_id = g_strdup (name);
|
|
||||||
*location = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
archive_destroy_cb (Archive *archive)
|
archive_destroy_cb (Archive *archive)
|
||||||
{
|
{
|
||||||
|
@ -129,7 +93,6 @@ archiverdb_resolve (BonoboMoniker *moniker,
|
||||||
Bonobo_Moniker parent;
|
Bonobo_Moniker parent;
|
||||||
Bonobo_ConfigDatabase db;
|
Bonobo_ConfigDatabase db;
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
gchar *backend_id, *locid;
|
|
||||||
|
|
||||||
if (strcmp (requested_interface, "IDL:Bonobo/ConfigDatabase:1.0")) {
|
if (strcmp (requested_interface, "IDL:Bonobo/ConfigDatabase:1.0")) {
|
||||||
EX_SET_NOT_FOUND (ev);
|
EX_SET_NOT_FOUND (ev);
|
||||||
|
@ -147,21 +110,13 @@ archiverdb_resolve (BonoboMoniker *moniker,
|
||||||
|
|
||||||
name = bonobo_moniker_get_name (moniker);
|
name = bonobo_moniker_get_name (moniker);
|
||||||
|
|
||||||
if (parse_name (name, &backend_id, &locid) < 0) {
|
db = bonobo_config_archiver_new (parent, options, name, ev);
|
||||||
EX_SET_NOT_FOUND (ev);
|
|
||||||
return CORBA_OBJECT_NIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
db = bonobo_config_archiver_new (parent, options, backend_id, locid, ev);
|
|
||||||
|
|
||||||
if (db == CORBA_OBJECT_NIL || BONOBO_EX (ev))
|
if (db == CORBA_OBJECT_NIL || BONOBO_EX (ev))
|
||||||
EX_SET_NOT_FOUND (ev);
|
EX_SET_NOT_FOUND (ev);
|
||||||
|
|
||||||
bonobo_object_release_unref (parent, NULL);
|
bonobo_object_release_unref (parent, NULL);
|
||||||
|
|
||||||
g_free (backend_id);
|
|
||||||
g_free (locid);
|
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ config_log_get_rollback_id_by_steps (ConfigLog *config_log,
|
||||||
|
|
||||||
/* Return the backend that generated the data with the given id */
|
/* Return the backend that generated the data with the given id */
|
||||||
|
|
||||||
gchar *
|
const gchar *
|
||||||
config_log_get_backend_id_for_id (ConfigLog *config_log, gint id)
|
config_log_get_backend_id_for_id (ConfigLog *config_log, gint id)
|
||||||
{
|
{
|
||||||
GList *node;
|
GList *node;
|
||||||
|
|
|
@ -66,7 +66,7 @@ gint config_log_get_rollback_id_by_steps (ConfigLog *config_log,
|
||||||
guint steps,
|
guint steps,
|
||||||
const gchar *backend_id);
|
const gchar *backend_id);
|
||||||
|
|
||||||
gchar *config_log_get_backend_id_for_id (ConfigLog *config_log,
|
const gchar *config_log_get_backend_id_for_id (ConfigLog *config_log,
|
||||||
gint id);
|
gint id);
|
||||||
const struct tm *config_log_get_date_for_id (ConfigLog *config_log,
|
const struct tm *config_log_get_date_for_id (ConfigLog *config_log,
|
||||||
gint id);
|
gint id);
|
||||||
|
|
|
@ -63,18 +63,20 @@ struct _BackendNote
|
||||||
|
|
||||||
struct _LocationPrivate
|
struct _LocationPrivate
|
||||||
{
|
{
|
||||||
Archive *archive;
|
Archive *archive;
|
||||||
gchar *locid;
|
gchar *locid;
|
||||||
gchar *fullpath;
|
gchar *fullpath;
|
||||||
gchar *label;
|
gchar *label;
|
||||||
|
|
||||||
Location *parent;
|
Location *parent;
|
||||||
GList *contains_list; /* List of BackendNotes */
|
GList *contains_list; /* List of BackendNotes */
|
||||||
gboolean is_new;
|
gboolean is_new;
|
||||||
gboolean contains_list_dirty;
|
gboolean contains_list_dirty;
|
||||||
gboolean deleted;
|
gboolean deleted;
|
||||||
|
|
||||||
ConfigLog *config_log;
|
ConfigLog *config_log;
|
||||||
|
|
||||||
|
BonoboEventSource *es;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LOCATION_FROM_SERVANT(servant) (LOCATION (bonobo_object_from_servant (servant)))
|
#define LOCATION_FROM_SERVANT(servant) (LOCATION (bonobo_object_from_servant (servant)))
|
||||||
|
@ -173,6 +175,14 @@ impl_ConfigArchiver_Location_getRollbackFilename (PortableServer_Servant servan
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
impl_ConfigArchiver_Location_storageComplete (PortableServer_Servant servant,
|
||||||
|
const CORBA_char *filename,
|
||||||
|
CORBA_Environment *ev)
|
||||||
|
{
|
||||||
|
location_storage_complete (LOCATION_FROM_SERVANT (servant), filename);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
impl_ConfigArchiver_Location_rollbackBackends (PortableServer_Servant servant,
|
impl_ConfigArchiver_Location_rollbackBackends (PortableServer_Servant servant,
|
||||||
ConfigArchiver_Time timep,
|
ConfigArchiver_Time timep,
|
||||||
|
@ -348,11 +358,15 @@ BONOBO_X_TYPE_FUNC_FULL (Location, ConfigArchiver_Location, BONOBO_X_OBJECT_TYPE
|
||||||
static void
|
static void
|
||||||
location_init (Location *location)
|
location_init (Location *location)
|
||||||
{
|
{
|
||||||
location->p = g_new0 (LocationPrivate, 1);
|
location->p = g_new0 (LocationPrivate, 1);
|
||||||
location->p->archive = NULL;
|
location->p->archive = NULL;
|
||||||
location->p->locid = NULL;
|
location->p->locid = NULL;
|
||||||
location->p->is_new = FALSE;
|
location->p->is_new = FALSE;
|
||||||
location->p->contains_list_dirty = FALSE;
|
location->p->contains_list_dirty = FALSE;
|
||||||
|
|
||||||
|
location->p->es = bonobo_event_source_new ();
|
||||||
|
|
||||||
|
bonobo_object_add_interface (BONOBO_OBJECT (location), BONOBO_OBJECT (location->p->es));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -391,6 +405,7 @@ location_class_init (LocationClass *klass)
|
||||||
|
|
||||||
klass->epv.getStorageFilename = impl_ConfigArchiver_Location_getStorageFilename;
|
klass->epv.getStorageFilename = impl_ConfigArchiver_Location_getStorageFilename;
|
||||||
klass->epv.getRollbackFilename = impl_ConfigArchiver_Location_getRollbackFilename;
|
klass->epv.getRollbackFilename = impl_ConfigArchiver_Location_getRollbackFilename;
|
||||||
|
klass->epv.storageComplete = impl_ConfigArchiver_Location_storageComplete;
|
||||||
klass->epv.rollbackBackends = impl_ConfigArchiver_Location_rollbackBackends;
|
klass->epv.rollbackBackends = impl_ConfigArchiver_Location_rollbackBackends;
|
||||||
klass->epv.getModificationTime = impl_ConfigArchiver_Location_getModificationTime;
|
klass->epv.getModificationTime = impl_ConfigArchiver_Location_getModificationTime;
|
||||||
klass->epv.contains = impl_ConfigArchiver_Location_contains;
|
klass->epv.contains = impl_ConfigArchiver_Location_contains;
|
||||||
|
@ -775,7 +790,7 @@ location_get_storage_filename (Location *location,
|
||||||
const gchar *backend_id,
|
const gchar *backend_id,
|
||||||
gboolean is_default)
|
gboolean is_default)
|
||||||
{
|
{
|
||||||
guint id;
|
guint id;
|
||||||
|
|
||||||
g_return_val_if_fail (location != NULL, NULL);
|
g_return_val_if_fail (location != NULL, NULL);
|
||||||
g_return_val_if_fail (IS_LOCATION (location), NULL);
|
g_return_val_if_fail (IS_LOCATION (location), NULL);
|
||||||
|
@ -829,6 +844,40 @@ location_get_rollback_filename (Location *location,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* location_storage_complete:
|
||||||
|
* @location:
|
||||||
|
* @filename:
|
||||||
|
*
|
||||||
|
* Notify the location object that storage of the rollback data at the given
|
||||||
|
* filename is complete
|
||||||
|
**/
|
||||||
|
|
||||||
|
void
|
||||||
|
location_storage_complete (Location *location, const gchar *filename)
|
||||||
|
{
|
||||||
|
const gchar *tmp;
|
||||||
|
const gchar *backend_id;
|
||||||
|
guint id;
|
||||||
|
BonoboArg *value;
|
||||||
|
|
||||||
|
tmp = strrchr (filename, '/');
|
||||||
|
|
||||||
|
if (tmp == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sscanf (tmp + 1, "%x", &id);
|
||||||
|
|
||||||
|
backend_id = config_log_get_backend_id_for_id
|
||||||
|
(location->p->config_log, id);
|
||||||
|
|
||||||
|
value = bonobo_arg_new (BONOBO_ARG_STRING);
|
||||||
|
BONOBO_ARG_SET_STRING (value, backend_id);
|
||||||
|
bonobo_event_source_notify_listeners
|
||||||
|
(location->p->es, "ConfigArchiver/Location:newRollbackData", value, NULL);
|
||||||
|
bonobo_arg_release (value);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* location_store:
|
* location_store:
|
||||||
* @location:
|
* @location:
|
||||||
|
@ -852,10 +901,10 @@ gint
|
||||||
location_store (Location *location, gchar *backend_id, FILE *input,
|
location_store (Location *location, gchar *backend_id, FILE *input,
|
||||||
StoreType store_type)
|
StoreType store_type)
|
||||||
{
|
{
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
char buffer[2048];
|
char buffer[2048];
|
||||||
int t = 0;
|
int t = 0;
|
||||||
GString *doc_str;
|
GString *doc_str;
|
||||||
|
|
||||||
g_return_val_if_fail (location != NULL, -2);
|
g_return_val_if_fail (location != NULL, -2);
|
||||||
g_return_val_if_fail (IS_LOCATION (location), -2);
|
g_return_val_if_fail (IS_LOCATION (location), -2);
|
||||||
|
@ -886,6 +935,7 @@ location_store (Location *location, gchar *backend_id, FILE *input,
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_free (doc_str, TRUE);
|
g_string_free (doc_str, TRUE);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,9 @@ gchar *location_get_rollback_filename (Location *location
|
||||||
const gchar *backend_id,
|
const gchar *backend_id,
|
||||||
gboolean parent_chain);
|
gboolean parent_chain);
|
||||||
|
|
||||||
|
void location_storage_complete (Location *location,
|
||||||
|
const gchar *filename);
|
||||||
|
|
||||||
gint location_store (Location *location,
|
gint location_store (Location *location,
|
||||||
gchar *backend_id,
|
gchar *backend_id,
|
||||||
FILE *input,
|
FILE *input,
|
||||||
|
|
|
@ -63,6 +63,7 @@ parse_date (char *str)
|
||||||
if (!ok) return NULL;
|
if (!ok) return NULL;
|
||||||
|
|
||||||
date = g_new (struct tm, 1);
|
date = g_new (struct tm, 1);
|
||||||
|
date->tm_isdst = 0;
|
||||||
date->tm_year = value - 1900;
|
date->tm_year = value - 1900;
|
||||||
date->tm_mon = 11;
|
date->tm_mon = 11;
|
||||||
date->tm_mday = 31;
|
date->tm_mday = 31;
|
||||||
|
@ -93,6 +94,9 @@ parse_date (char *str)
|
||||||
if (extract_number (&str, &value, 2))
|
if (extract_number (&str, &value, 2))
|
||||||
date->tm_sec = value;
|
date->tm_sec = value;
|
||||||
|
|
||||||
|
date->tm_zone = "GMT";
|
||||||
|
date->tm_gmtoff = 0;
|
||||||
|
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue