summaryrefslogtreecommitdiff
path: root/archiver
diff options
context:
space:
mode:
Diffstat (limited to 'archiver')
-rw-r--r--archiver/ChangeLog57
-rw-r--r--archiver/Makefile.am1
-rw-r--r--archiver/archiver-client.c58
-rw-r--r--archiver/archiver-client.h6
-rw-r--r--archiver/bonobo-config-archiver.c198
-rw-r--r--archiver/bonobo-config-archiver.h7
-rw-r--r--archiver/bonobo-moniker-archiver.c59
-rw-r--r--archiver/config-log.c2
-rw-r--r--archiver/config-log.h2
-rw-r--r--archiver/location.c92
-rw-r--r--archiver/location.h3
-rw-r--r--archiver/util.c4
12 files changed, 345 insertions, 144 deletions
diff --git a/archiver/ChangeLog b/archiver/ChangeLog
index c2e1d6df5..cbbb10309 100644
--- a/archiver/ChangeLog
+++ b/archiver/ChangeLog
@@ -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>
* archive.c (foreach_build_list_cb): Don't unref the location if
diff --git a/archiver/Makefile.am b/archiver/Makefile.am
index 236368009..12d7c9f6a 100644
--- a/archiver/Makefile.am
+++ b/archiver/Makefile.am
@@ -16,7 +16,6 @@ INCLUDES = \
-DLOCATION_DIR=\""$(datadir)/control-center/archiver"\" \
-DGLADE_DIR=\""$(INTERFACES_DIR)"\" \
-DXST_BACKEND_LOCATION=\""$(datadir)/setup-tool-backends/scripts"\" \
- -DDEFAULTS_DIR=\""$(datadir)/control-center/defaults"\" \
@ARCHIVER_CFLAGS@ \
@MONIKER_CFLAGS@
diff --git a/archiver/archiver-client.c b/archiver/archiver-client.c
index 553c25f1f..7d649d868 100644
--- a/archiver/archiver-client.c
+++ b/archiver/archiver-client.c
@@ -29,6 +29,7 @@
#include <gnome-xml/parser.h>
#include "archiver-client.h"
+#include "util.h"
static void merge_xml_docs (xmlDocPtr child_doc,
xmlDocPtr parent_doc);
@@ -56,18 +57,22 @@ static gboolean compare_xml_nodes (xmlNodePtr node1, xmlNodePtr node2);
xmlDocPtr
location_client_load_rollback_data (ConfigArchiver_Location location,
- struct tm *date,
+ const struct tm *date,
guint steps,
- gchar *backend_id,
+ const gchar *backend_id,
gboolean parent_chain,
CORBA_Environment *opt_ev)
{
- gchar *filename;
- time_t time_g;
- xmlDocPtr doc = NULL, parent_doc = NULL;
- ConfigArchiver_ContainmentType type = ConfigArchiver_CONTAIN_FULL;
- ConfigArchiver_Location parent = CORBA_OBJECT_NIL;
- CORBA_Environment my_ev;
+ gchar *filename;
+ struct tm *date_c;
+ time_t time_g;
+
+ xmlDocPtr doc = NULL;
+ 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);
@@ -76,15 +81,22 @@ location_client_load_rollback_data (ConfigArchiver_Location location,
CORBA_exception_init (opt_ev);
}
- if (date != NULL)
- time_g = mktime (date);
- else
+ if (date != NULL) {
+ date_c = dup_date (date);
+ 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;
+ }
filename = ConfigArchiver_Location_getRollbackFilename
(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)
doc = xmlParseFile (filename);
else if (parent_chain)
type = ConfigArchiver_Location_contains (location, backend_id, opt_ev);
@@ -127,16 +139,17 @@ location_client_load_rollback_data (ConfigArchiver_Location location,
void
location_client_store_xml (ConfigArchiver_Location location,
- gchar *backend_id,
+ const gchar *backend_id,
xmlDocPtr xml_doc,
ConfigArchiver_StoreType store_type,
CORBA_Environment *opt_ev)
{
- xmlDocPtr parent_doc, prev_doc = NULL;
- char *filename;
- ConfigArchiver_ContainmentType contain_type;
- ConfigArchiver_Location parent;
- CORBA_Environment my_ev;
+ xmlDocPtr parent_doc;
+ xmlDocPtr prev_doc = NULL;
+ char *filename;
+ ConfigArchiver_ContainmentType contain_type;
+ ConfigArchiver_Location parent;
+ CORBA_Environment my_ev;
g_return_if_fail (location != CORBA_OBJECT_NIL);
g_return_if_fail (xml_doc != NULL);
@@ -191,9 +204,14 @@ location_client_store_xml (ConfigArchiver_Location location,
if (parent != CORBA_OBJECT_NIL)
bonobo_object_release_unref (parent, NULL);
- filename = ConfigArchiver_Location_getStorageFilename (location, backend_id, store_type == ConfigArchiver_STORE_DEFAULT, opt_ev);
- xmlSaveFile (filename, xml_doc);
- CORBA_free (filename);
+ filename = ConfigArchiver_Location_getStorageFilename
+ (location, backend_id, store_type == ConfigArchiver_STORE_DEFAULT, opt_ev);
+
+ 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)
CORBA_exception_free (opt_ev);
diff --git a/archiver/archiver-client.h b/archiver/archiver-client.h
index 526e59ad8..96dd287a0 100644
--- a/archiver/archiver-client.h
+++ b/archiver/archiver-client.h
@@ -31,14 +31,14 @@
#include "ConfigArchiver.h"
xmlDocPtr location_client_load_rollback_data (ConfigArchiver_Location location,
- struct tm *date,
+ const struct tm *date,
guint steps,
- gchar *backend_id,
+ const gchar *backend_id,
gboolean parent_chain,
CORBA_Environment *opt_ev);
void location_client_store_xml (ConfigArchiver_Location location,
- gchar *backend_id,
+ const gchar *backend_id,
xmlDocPtr xml_doc,
ConfigArchiver_StoreType store_type,
CORBA_Environment *opt_ev);
diff --git a/archiver/bonobo-config-archiver.c b/archiver/bonobo-config-archiver.c
index 27890514f..b2ee2d628 100644
--- a/archiver/bonobo-config-archiver.c
+++ b/archiver/bonobo-config-archiver.c
@@ -15,10 +15,8 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
-#include <bonobo/bonobo-arg.h>
-#include <bonobo/bonobo-property-bag-xml.h>
-#include <bonobo/bonobo-moniker-util.h>
-#include <bonobo/bonobo-exception.h>
+#include <ctype.h>
+#include <bonobo.h>
#include <bonobo-conf/bonobo-config-utils.h>
#include <gnome-xml/xmlmemory.h>
#include <gtk/gtkmain.h>
@@ -496,9 +494,9 @@ bonobo_config_archiver_destroy (GtkObject *object)
CORBA_exception_init (&ev);
- if (archiver_db->real_name != NULL) {
- bonobo_url_unregister ("BONOBO_CONF:ARCHIVER", archiver_db->real_name, &ev);
- g_free (archiver_db->real_name);
+ if (archiver_db->moniker != NULL) {
+ bonobo_url_unregister ("BONOBO_CONF:ARCHIVER", archiver_db->moniker, &ev);
+ g_free (archiver_db->moniker);
}
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_config_archiver_new (Bonobo_Moniker parent,
const Bonobo_ResolveOptions *options,
- const char *backend_id,
- const char *location_id,
+ const char *moniker,
CORBA_Environment *ev)
{
- BonoboConfigArchiver *archiver_db;
- Bonobo_ConfigDatabase db;
- gchar *real_name;
+ BonoboConfigArchiver *archiver_db;
+ Bonobo_ConfigDatabase db;
+ 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);
- DEBUG_MSG ("Enter");
-
- if (location_id == NULL)
- real_name = g_strdup (backend_id);
- else
- real_name = g_strconcat ("[", location_id, "]", backend_id, NULL);
+ /* Check the Bonobo URL database to see if this archiver database has
+ * already been created, and return it if it has */
- db = bonobo_url_lookup ("BONOBO_CONF:ARCHIVER", real_name, ev);
+ moniker_tmp = g_strdup (moniker);
+ db = bonobo_url_lookup ("BONOBO_CONF:ARCHIVER", moniker_tmp, ev);
+ g_free (moniker_tmp);
if (BONOBO_EX (ev)) {
db = CORBA_OBJECT_NIL;
CORBA_exception_init (ev);
}
- if (db) {
- g_free (real_name);
+ if (db != CORBA_OBJECT_NIL)
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) {
- g_free (real_name);
+ if (parse_name (moniker, &backend_id, &location_id, &date) < 0) {
+ EX_SET_NOT_FOUND (ev);
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 */
+
+ archive = Bonobo_Moniker_resolve (parent, options, "IDL:ConfigArchiver/Archive:1.0", ev);
- if (BONOBO_EX (ev) || archiver_db->archive == CORBA_OBJECT_NIL) {
- 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;
}
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
- 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) {
- bonobo_object_release_unref (archiver_db->archive, NULL);
- bonobo_object_unref (BONOBO_OBJECT (archiver_db));
+ g_free (location_id);
+
+ if (location == CORBA_OBJECT_NIL) {
+ g_free (date);
+ bonobo_object_release_unref (archive, NULL);
return CORBA_OBJECT_NIL;
}
- archiver_db->backend_id = g_strdup (backend_id);
- archiver_db->real_name = real_name;
-
+ /* Construct the database object proper and fill in its values */
+
+ 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->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) {
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);
g_free (filename);
@@ -705,6 +806,8 @@ bonobo_config_archiver_new (Bonobo_Moniker parent,
CORBA_exception_init (ev);
}
+ /* Load data from the XML file */
+
if (archiver_db->doc->root == NULL)
archiver_db->doc->root =
xmlNewDocNode (archiver_db->doc, NULL, "bonobo-config", NULL);
@@ -718,6 +821,8 @@ bonobo_config_archiver_new (Bonobo_Moniker parent,
fill_cache (archiver_db);
+ /* Construct the associated property bag and event source */
+
#if 0
archiver_db->es = bonobo_event_source_new ();
@@ -739,11 +844,20 @@ bonobo_config_archiver_new (Bonobo_Moniker parent,
"Date (time_t) of modification",
BONOBO_PROPERTY_READABLE);
- db = CORBA_Object_duplicate (BONOBO_OBJREF (archiver_db), NULL);
+ /* Listen for events pertaining to new rollback data */
- bonobo_url_register ("BONOBO_CONF:ARCHIVER", real_name, NULL, db, ev);
+ 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);
- DEBUG_MSG ("Exit: %p", db);
+ moniker_tmp = g_strdup (moniker);
+ bonobo_url_register ("BONOBO_CONF:ARCHIVER", moniker_tmp, NULL, db, ev);
+ g_free (moniker_tmp);
return db;
}
diff --git a/archiver/bonobo-config-archiver.h b/archiver/bonobo-config-archiver.h
index d02c847cc..eec1ebf61 100644
--- a/archiver/bonobo-config-archiver.h
+++ b/archiver/bonobo-config-archiver.h
@@ -22,6 +22,8 @@
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(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))
@@ -59,7 +61,7 @@ struct _BonoboConfigArchiver {
ConfigArchiver_Archive archive;
ConfigArchiver_Location location;
gchar *backend_id;
- gchar *real_name;
+ gchar *moniker;
BonoboEventSource *es;
BonoboPropertyBag *pb;
@@ -76,8 +78,7 @@ bonobo_config_archiver_get_type (void);
Bonobo_ConfigDatabase
bonobo_config_archiver_new (Bonobo_Moniker parent,
const Bonobo_ResolveOptions *options,
- const char *backend_id,
- const char *location_id,
+ const char *moniker,
CORBA_Environment *ev);
END_GNOME_DECLS
diff --git a/archiver/bonobo-moniker-archiver.c b/archiver/bonobo-moniker-archiver.c
index 939f00a3c..19c4efde5 100644
--- a/archiver/bonobo-moniker-archiver.c
+++ b/archiver/bonobo-moniker-archiver.c
@@ -7,56 +7,20 @@
*
* Copyright 2001 Ximian, Inc.
*/
-#include <config.h>
-#include <bonobo/bonobo-main.h>
-#include <bonobo/bonobo-context.h>
-#include <bonobo/bonobo-moniker.h>
-#include <bonobo/bonobo-moniker-util.h>
-#include <bonobo/bonobo-moniker-simple.h>
-#include <bonobo/bonobo-shlib-factory.h>
-#include <bonobo/bonobo-exception.h>
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <bonobo.h>
#include "bonobo-config-archiver.h"
#include "archive.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 *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
archive_destroy_cb (Archive *archive)
{
@@ -129,7 +93,6 @@ archiverdb_resolve (BonoboMoniker *moniker,
Bonobo_Moniker parent;
Bonobo_ConfigDatabase db;
const gchar *name;
- gchar *backend_id, *locid;
if (strcmp (requested_interface, "IDL:Bonobo/ConfigDatabase:1.0")) {
EX_SET_NOT_FOUND (ev);
@@ -147,21 +110,13 @@ archiverdb_resolve (BonoboMoniker *moniker,
name = bonobo_moniker_get_name (moniker);
- if (parse_name (name, &backend_id, &locid) < 0) {
- EX_SET_NOT_FOUND (ev);
- return CORBA_OBJECT_NIL;
- }
-
- db = bonobo_config_archiver_new (parent, options, backend_id, locid, ev);
+ db = bonobo_config_archiver_new (parent, options, name, ev);
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);
-
return db;
}
diff --git a/archiver/config-log.c b/archiver/config-log.c
index c2df35c24..a8e6db5ab 100644
--- a/archiver/config-log.c
+++ b/archiver/config-log.c
@@ -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 */
-gchar *
+const gchar *
config_log_get_backend_id_for_id (ConfigLog *config_log, gint id)
{
GList *node;
diff --git a/archiver/config-log.h b/archiver/config-log.h
index 28fe49db3..ef3b9632b 100644
--- a/archiver/config-log.h
+++ b/archiver/config-log.h
@@ -66,7 +66,7 @@ gint config_log_get_rollback_id_by_steps (ConfigLog *config_log,
guint steps,
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);
const struct tm *config_log_get_date_for_id (ConfigLog *config_log,
gint id);
diff --git a/archiver/location.c b/archiver/location.c
index 80f734a58..248bc560c 100644
--- a/archiver/location.c
+++ b/archiver/location.c
@@ -63,18 +63,20 @@ struct _BackendNote
struct _LocationPrivate
{
- Archive *archive;
- gchar *locid;
- gchar *fullpath;
- gchar *label;
-
- Location *parent;
- GList *contains_list; /* List of BackendNotes */
- gboolean is_new;
- gboolean contains_list_dirty;
- gboolean deleted;
-
- ConfigLog *config_log;
+ Archive *archive;
+ gchar *locid;
+ gchar *fullpath;
+ gchar *label;
+
+ Location *parent;
+ GList *contains_list; /* List of BackendNotes */
+ gboolean is_new;
+ gboolean contains_list_dirty;
+ gboolean deleted;
+
+ ConfigLog *config_log;
+
+ BonoboEventSource *es;
};
#define LOCATION_FROM_SERVANT(servant) (LOCATION (bonobo_object_from_servant (servant)))
@@ -174,6 +176,14 @@ impl_ConfigArchiver_Location_getRollbackFilename (PortableServer_Servant servan
}
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
impl_ConfigArchiver_Location_rollbackBackends (PortableServer_Servant servant,
ConfigArchiver_Time timep,
CORBA_long steps,
@@ -348,11 +358,15 @@ BONOBO_X_TYPE_FUNC_FULL (Location, ConfigArchiver_Location, BONOBO_X_OBJECT_TYPE
static void
location_init (Location *location)
{
- location->p = g_new0 (LocationPrivate, 1);
- location->p->archive = NULL;
- location->p->locid = NULL;
- location->p->is_new = FALSE;
+ location->p = g_new0 (LocationPrivate, 1);
+ location->p->archive = NULL;
+ location->p->locid = NULL;
+ location->p->is_new = 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
@@ -391,6 +405,7 @@ location_class_init (LocationClass *klass)
klass->epv.getStorageFilename = impl_ConfigArchiver_Location_getStorageFilename;
klass->epv.getRollbackFilename = impl_ConfigArchiver_Location_getRollbackFilename;
+ klass->epv.storageComplete = impl_ConfigArchiver_Location_storageComplete;
klass->epv.rollbackBackends = impl_ConfigArchiver_Location_rollbackBackends;
klass->epv.getModificationTime = impl_ConfigArchiver_Location_getModificationTime;
klass->epv.contains = impl_ConfigArchiver_Location_contains;
@@ -775,7 +790,7 @@ location_get_storage_filename (Location *location,
const gchar *backend_id,
gboolean is_default)
{
- guint id;
+ guint id;
g_return_val_if_fail (location != NULL, NULL);
g_return_val_if_fail (IS_LOCATION (location), NULL);
@@ -830,6 +845,40 @@ location_get_rollback_filename (Location *location,
}
/**
+ * 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:
* @backend_id:
@@ -852,10 +901,10 @@ gint
location_store (Location *location, gchar *backend_id, FILE *input,
StoreType store_type)
{
- xmlDocPtr doc;
- char buffer[2048];
- int t = 0;
- GString *doc_str;
+ xmlDocPtr doc;
+ char buffer[2048];
+ int t = 0;
+ GString *doc_str;
g_return_val_if_fail (location != NULL, -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);
+
return 0;
}
diff --git a/archiver/location.h b/archiver/location.h
index 7b777d7ac..c42a3b0e2 100644
--- a/archiver/location.h
+++ b/archiver/location.h
@@ -83,6 +83,9 @@ gchar *location_get_rollback_filename (Location *location
const gchar *backend_id,
gboolean parent_chain);
+void location_storage_complete (Location *location,
+ const gchar *filename);
+
gint location_store (Location *location,
gchar *backend_id,
FILE *input,
diff --git a/archiver/util.c b/archiver/util.c
index fadc6eb43..58ff00275 100644
--- a/archiver/util.c
+++ b/archiver/util.c
@@ -63,6 +63,7 @@ parse_date (char *str)
if (!ok) return NULL;
date = g_new (struct tm, 1);
+ date->tm_isdst = 0;
date->tm_year = value - 1900;
date->tm_mon = 11;
date->tm_mday = 31;
@@ -93,6 +94,9 @@ parse_date (char *str)
if (extract_number (&str, &value, 2))
date->tm_sec = value;
+ date->tm_zone = "GMT";
+ date->tm_gmtoff = 0;
+
return date;
}