[frogr] Provide API for setting the version of the settings file
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Provide API for setting the version of the settings file
- Date: Wed, 4 Apr 2012 19:14:16 +0000 (UTC)
commit 7b0d59489d0759a764637671e9fbdc474a706a44
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Wed Apr 4 21:12:49 2012 +0200
Provide API for setting the version of the settings file
src/frogr-config.c | 27 +++++++++++++++++++++++++++
src/frogr-config.h | 2 ++
2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/frogr-config.c b/src/frogr-config.c
index 5503abb..363abcc 100644
--- a/src/frogr-config.c
+++ b/src/frogr-config.c
@@ -81,6 +81,8 @@ struct _FrogrConfigPrivate
gchar *proxy_port;
gchar *proxy_username;
gchar *proxy_password;
+
+ gchar *settings_version;
};
static FrogrConfig *_instance = NULL;
@@ -289,6 +291,17 @@ _load_settings (FrogrConfig *self)
if (!xmlStrcmp (node->name, (const xmlChar*) "http-proxy"))
_load_proxy_data_xml (self, xml, node);
+
+ if (!xmlStrcmp (node->name, (const xmlChar*) "version"))
+ {
+ xmlChar *content = NULL;
+
+ content = xmlNodeGetContent (node);
+ g_free (priv->settings_version);
+ priv->settings_version = g_strdup ((gchar *) content);
+
+ xmlFree (content);
+ }
}
}
else if (node && node->name)
@@ -705,6 +718,7 @@ _save_settings (FrogrConfig *self)
_xml_add_bool_child (node, "use-gnome-proxy", priv->use_gnome_proxy);
xmlAddChild (root, node);
+ /* Settings versioning */
_xml_add_string_child (root, "version", SETTINGS_FORMAT_VERSION);
xml_path = g_build_filename (priv->config_dir, SETTINGS_FILENAME, NULL);
@@ -897,6 +911,7 @@ _finalize (GObject *object)
g_free (priv->proxy_port);
g_free (priv->proxy_username);
g_free (priv->proxy_password);
+ g_free (priv->settings_version);
/* Call superclass */
G_OBJECT_CLASS (frogr_config_parent_class)->finalize (object);
@@ -968,6 +983,7 @@ frogr_config_init (FrogrConfig *self)
priv->proxy_port = NULL;
priv->proxy_username = NULL;
priv->proxy_password = NULL;
+ priv->settings_version = NULL;
/* Ensure that we have the config directory in place. */
config_dir = g_build_filename (g_get_user_config_dir (), APP_SHORTNAME, NULL);
@@ -1591,3 +1607,14 @@ frogr_config_get_proxy_password (FrogrConfig *self)
priv = FROGR_CONFIG_GET_PRIVATE (self);
return priv->proxy_password;
}
+
+const gchar *
+frogr_config_get_settings_version (FrogrConfig *self)
+{
+ FrogrConfigPrivate * priv = NULL;
+
+ g_return_val_if_fail (FROGR_IS_CONFIG (self), FALSE);
+
+ priv = FROGR_CONFIG_GET_PRIVATE (self);
+ return priv->settings_version;
+}
diff --git a/src/frogr-config.h b/src/frogr-config.h
index 3efdfaa..38806cb 100644
--- a/src/frogr-config.h
+++ b/src/frogr-config.h
@@ -166,6 +166,8 @@ void frogr_config_set_proxy_password (FrogrConfig *self, const gchar *password);
const gchar *frogr_config_get_proxy_password (FrogrConfig *self);
+const gchar *frogr_config_get_settings_version (FrogrConfig *self);
+
G_END_DECLS
#endif /* !_FROGR_CONFIG_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]