Support STORE_DEFAULT (store_snapshot_cb): Use STORE_DEFAULT rather than
2001-05-03 Bradford Hovinen <hovinen@ximian.com> * location.c (location_store_xml): Support STORE_DEFAULT (store_snapshot_cb): Use STORE_DEFAULT rather than STORE_MASK_PREVIOUS * location.h (_StoreType): Add STORE_DEFAULT * config-log.c (config_log_get_rollback_id_by_steps): Return the current id if the node represents default data * main.c (do_add_location): Cast correctly, fixing compiler warning
This commit is contained in:
parent
a7fa858b61
commit
7631a53d80
6 changed files with 87 additions and 10 deletions
|
@ -1,3 +1,23 @@
|
||||||
|
2001-05-03 Bradford Hovinen <hovinen@ximian.com>
|
||||||
|
|
||||||
|
* location.c (location_store_xml): Support STORE_DEFAULT
|
||||||
|
(store_snapshot_cb): Use STORE_DEFAULT rather than STORE_MASK_PREVIOUS
|
||||||
|
|
||||||
|
* location.h (_StoreType): Add STORE_DEFAULT
|
||||||
|
|
||||||
|
* config-log.c (config_log_get_rollback_id_by_steps): Return the
|
||||||
|
current id if the node represents default data
|
||||||
|
|
||||||
|
* main.c (do_add_location): Cast correctly, fixing compiler
|
||||||
|
warning
|
||||||
|
|
||||||
|
* config-log.c (config_log_write_entry): Add parameter
|
||||||
|
is_default_data; call get_beginning_of_time rather than
|
||||||
|
get_current_date iff is_default_data is TRUE
|
||||||
|
(get_beginning_of_time): Implement
|
||||||
|
(has_nondefaults): Implement. Return TRUE iff the config log
|
||||||
|
contains regular (non-default) entries
|
||||||
|
|
||||||
2001-04-26 Arturo Espinosa <arturo@ximian.com>
|
2001-04-26 Arturo Espinosa <arturo@ximian.com>
|
||||||
|
|
||||||
* location.c: changed g_critical to g_error. If a newer
|
* location.c: changed g_critical to g_error. If a newer
|
||||||
|
|
|
@ -137,10 +137,12 @@ static void do_unload (ConfigLog *config_log,
|
||||||
gboolean write_log);
|
gboolean write_log);
|
||||||
|
|
||||||
static gint get_next_id (ConfigLog *config_log);
|
static gint get_next_id (ConfigLog *config_log);
|
||||||
|
static struct tm *get_beginning_of_time (void);
|
||||||
static struct tm *get_current_date (void);
|
static struct tm *get_current_date (void);
|
||||||
static void write_log (IOBuffer *output,
|
static void write_log (IOBuffer *output,
|
||||||
ConfigLogEntry *entry);
|
ConfigLogEntry *entry);
|
||||||
static void dump_log (ConfigLog *config_log);
|
static void dump_log (ConfigLog *config_log);
|
||||||
|
static gboolean has_nondefaults (ConfigLog *config_log);
|
||||||
|
|
||||||
static gboolean connect_socket (ConfigLog *config_log);
|
static gboolean connect_socket (ConfigLog *config_log);
|
||||||
static gboolean check_socket_filename (ConfigLog *config_log);
|
static gboolean check_socket_filename (ConfigLog *config_log);
|
||||||
|
@ -416,6 +418,9 @@ config_log_get_rollback_id_by_steps (ConfigLog *config_log,
|
||||||
node = find_config_log_entry_backend
|
node = find_config_log_entry_backend
|
||||||
(config_log, node, backend_id);
|
(config_log, node, backend_id);
|
||||||
|
|
||||||
|
if (((ConfigLogEntry *) node->data)->date->tm_year == 0)
|
||||||
|
return ((ConfigLogEntry *) node->data)->id;
|
||||||
|
|
||||||
if (steps > 0) {
|
if (steps > 0) {
|
||||||
if (node->next == NULL)
|
if (node->next == NULL)
|
||||||
node = load_log_entry
|
node = load_log_entry
|
||||||
|
@ -482,8 +487,21 @@ config_log_get_date_for_id (ConfigLog *config_log, gint id)
|
||||||
return ((ConfigLogEntry *) node->data)->date;
|
return ((ConfigLogEntry *) node->data)->date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* config_log_write_entry:
|
||||||
|
* @config_log:
|
||||||
|
* @backend_id: Backend id for the log entry to write
|
||||||
|
* @is_default_data: TRUE iff the corresponding data are to be considered
|
||||||
|
* "factory defaults" for the purpose of rollback
|
||||||
|
*
|
||||||
|
* Writes a new log entry to the config log
|
||||||
|
*
|
||||||
|
* Returns the id number of the entry on success or -1 on failure
|
||||||
|
**/
|
||||||
|
|
||||||
gint
|
gint
|
||||||
config_log_write_entry (ConfigLog *config_log, gchar *backend_id)
|
config_log_write_entry (ConfigLog *config_log, gchar *backend_id,
|
||||||
|
gboolean is_default_data)
|
||||||
{
|
{
|
||||||
ConfigLogEntry *entry;
|
ConfigLogEntry *entry;
|
||||||
|
|
||||||
|
@ -491,11 +509,18 @@ config_log_write_entry (ConfigLog *config_log, gchar *backend_id)
|
||||||
g_return_val_if_fail (IS_CONFIG_LOG (config_log), -1);
|
g_return_val_if_fail (IS_CONFIG_LOG (config_log), -1);
|
||||||
g_return_val_if_fail (backend_id != NULL, -1);
|
g_return_val_if_fail (backend_id != NULL, -1);
|
||||||
|
|
||||||
entry = g_new0 (ConfigLogEntry, 1);
|
if (is_default_data && has_nondefaults (config_log))
|
||||||
entry->id = get_next_id (config_log);
|
return -1;
|
||||||
entry->date = get_current_date ();
|
|
||||||
|
entry = g_new0 (ConfigLogEntry, 1);
|
||||||
|
entry->id = get_next_id (config_log);
|
||||||
entry->backend_id = g_strdup (backend_id);
|
entry->backend_id = g_strdup (backend_id);
|
||||||
|
|
||||||
|
if (is_default_data)
|
||||||
|
entry->date = get_beginning_of_time ();
|
||||||
|
else
|
||||||
|
entry->date = get_current_date ();
|
||||||
|
|
||||||
config_log->p->log_data =
|
config_log->p->log_data =
|
||||||
g_list_prepend (config_log->p->log_data, entry);
|
g_list_prepend (config_log->p->log_data, entry);
|
||||||
|
|
||||||
|
@ -926,6 +951,14 @@ get_next_id (ConfigLog *config_log)
|
||||||
return ((ConfigLogEntry *) config_log->p->log_data->data)->id + 1;
|
return ((ConfigLogEntry *) config_log->p->log_data->data)->id + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return a newly allocated struct tm with all zeros */
|
||||||
|
|
||||||
|
static struct tm *
|
||||||
|
get_beginning_of_time (void)
|
||||||
|
{
|
||||||
|
return g_new0 (struct tm, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return a newly allocated struct tm with the current time */
|
/* Return a newly allocated struct tm with the current time */
|
||||||
|
|
||||||
static struct tm *
|
static struct tm *
|
||||||
|
@ -1012,6 +1045,26 @@ dump_log (ConfigLog *config_log)
|
||||||
DEBUG_MSG ("Exit");
|
DEBUG_MSG ("Exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
has_nondefaults (ConfigLog *config_log)
|
||||||
|
{
|
||||||
|
ConfigLogEntry *first;
|
||||||
|
|
||||||
|
if (config_log->p->log_data == NULL)
|
||||||
|
load_log_entry (config_log, FALSE, config_log->p->file_buffer,
|
||||||
|
config_log->p->log_data);
|
||||||
|
|
||||||
|
if (config_log->p->log_data == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
first = config_log->p->log_data->data;
|
||||||
|
|
||||||
|
if (first->date->tm_year == 0)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
connect_socket (ConfigLog *config_log)
|
connect_socket (ConfigLog *config_log)
|
||||||
{
|
{
|
||||||
|
|
|
@ -71,7 +71,8 @@ struct tm *config_log_get_date_for_id (ConfigLog *config_log,
|
||||||
gint id);
|
gint id);
|
||||||
|
|
||||||
gint config_log_write_entry (ConfigLog *config_log,
|
gint config_log_write_entry (ConfigLog *config_log,
|
||||||
gchar *backend_id);
|
gchar *backend_id,
|
||||||
|
gboolean is_default_data);
|
||||||
|
|
||||||
void config_log_iterate (ConfigLog *config_log,
|
void config_log_iterate (ConfigLog *config_log,
|
||||||
ConfigLogIteratorCB callback,
|
ConfigLogIteratorCB callback,
|
||||||
|
|
|
@ -443,7 +443,8 @@ location_delete (Location *location)
|
||||||
* modification. STORE_COMPARE_PARENT means subtract the settings the parent
|
* modification. STORE_COMPARE_PARENT means subtract the settings the parent
|
||||||
* has that are different and store the result. STORE_MASK_PREVIOUS means
|
* has that are different and store the result. STORE_MASK_PREVIOUS means
|
||||||
* store only those settings that are reflected in the previous logged data;
|
* store only those settings that are reflected in the previous logged data;
|
||||||
* if there do not exist such data, act as in STORE_COMPARE_PARENT
|
* if there do not exist such data, act as in
|
||||||
|
* STORE_COMPARE_PARENT. STORE_DEFAULT means these are default data.
|
||||||
*
|
*
|
||||||
* Store configuration data from the given stream in the location under the
|
* Store configuration data from the given stream in the location under the
|
||||||
* given backend id
|
* given backend id
|
||||||
|
@ -559,7 +560,8 @@ location_store_xml (Location *location, gchar *backend_id, xmlDocPtr xml_doc,
|
||||||
xmlFreeDoc (prev_doc);
|
xmlFreeDoc (prev_doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
id = config_log_write_entry (location->p->config_log, backend_id);
|
id = config_log_write_entry (location->p->config_log, backend_id,
|
||||||
|
store_type == STORE_DEFAULT);
|
||||||
|
|
||||||
filename = g_strdup_printf ("%s/%08x.xml",
|
filename = g_strdup_printf ("%s/%08x.xml",
|
||||||
location->p->fullpath, id);
|
location->p->fullpath, id);
|
||||||
|
@ -1129,7 +1131,7 @@ store_snapshot_cb (Location *location, gchar *backend_id)
|
||||||
|
|
||||||
fd = run_backend_proc (backend_id, TRUE);
|
fd = run_backend_proc (backend_id, TRUE);
|
||||||
pipe = fdopen (fd, "r");
|
pipe = fdopen (fd, "r");
|
||||||
location_store (location, backend_id, pipe, STORE_MASK_PREVIOUS);
|
location_store (location, backend_id, pipe, STORE_DEFAULT);
|
||||||
fclose (pipe);
|
fclose (pipe);
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -61,7 +61,7 @@ enum _ContainmentType
|
||||||
|
|
||||||
enum _StoreType
|
enum _StoreType
|
||||||
{
|
{
|
||||||
STORE_FULL, STORE_COMPARE_PARENT, STORE_MASK_PREVIOUS
|
STORE_DEFAULT, STORE_FULL, STORE_COMPARE_PARENT, STORE_MASK_PREVIOUS
|
||||||
};
|
};
|
||||||
|
|
||||||
guint location_get_type (void);
|
guint location_get_type (void);
|
||||||
|
|
|
@ -259,7 +259,8 @@ do_add_location (Archive *archive)
|
||||||
|
|
||||||
if (parent_location == NULL && !strcmp (parent_str, "default"))
|
if (parent_location == NULL && !strcmp (parent_str, "default"))
|
||||||
parent_location =
|
parent_location =
|
||||||
location_new (archive, "default", NULL);
|
LOCATION
|
||||||
|
(location_new (archive, "default", NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
location = location_new (archive, location_id, parent_location);
|
location = location_new (archive, location_id, parent_location);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue