summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2012-03-07 15:04:53 -0500
committerRyan Lortie <desrt@desrt.ca>2012-03-08 11:21:43 -0500
commitd28bd006832bd136c58d42003bf1b0f25f74128e (patch)
treec4ffab5d51b174f6bddbebb65ea56801535bb0ea
parent27c183fe8e63a3a21b58348a294056e2594f985f (diff)
downloadgconf-d28bd006832bd136c58d42003bf1b0f25f74128e.tar.gz
gsettings-data-convert: convert only user settings
We only want to migrate settings that were in writable databases (in order to avoid 'lifting' system defaults into the user's database). https://bugzilla.gnome.org/show_bug.cgi?id=671581
-rw-r--r--gsettings/Makefile.am1
-rw-r--r--gsettings/gsettings-data-convert.c65
2 files changed, 64 insertions, 2 deletions
diff --git a/gsettings/Makefile.am b/gsettings/Makefile.am
index 8bc9321e..8585b1e0 100644
--- a/gsettings/Makefile.am
+++ b/gsettings/Makefile.am
@@ -29,6 +29,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir) \
-I$(top_builddir) \
-DDATADIR=\"$(datadir)\" \
+ -DGCONF_CONFDIR=\""$(sysgconfdir)/$(MAJOR_VERSION)"\" \
$(GSETTINGS_CFLAGS)
gsettings_data_convert_SOURCES = gsettings-data-convert.c
diff --git a/gsettings/gsettings-data-convert.c b/gsettings/gsettings-data-convert.c
index 595091ee..9a3e4ba5 100644
--- a/gsettings/gsettings-data-convert.c
+++ b/gsettings/gsettings-data-convert.c
@@ -27,13 +27,74 @@
#include <glib.h>
#include <gio/gio.h>
+#define GCONF_ENABLE_INTERNALS
+#include <gconf/gconf-internals.h>
#include <gconf/gconf-client.h>
static gboolean changed = FALSE;
static gboolean verbose = FALSE;
static gboolean dry_run = FALSE;
-extern const gchar *gconf_value_type_to_string (int type);
+/* We only want to migrate settings that were in writable databases (in
+ * order to avoid 'lifting' system defaults into the user's database).
+ *
+ * We also want to perform the access to those readwrite databases
+ * readonly, since we're not making any changes.
+ *
+ * For that reason, we compile our own source list by scanning the
+ * default list. We take all :readwrite: sources, changing them to
+ * :readonly: as we do so.
+ */
+static GSList *
+get_writable_source_path (void)
+{
+ GSList *result = NULL;
+ gchar *config_file;
+ GSList *addresses;
+ GSList *node;
+
+ config_file = g_strconcat (GCONF_CONFDIR, "/path", NULL);
+ addresses = gconf_load_source_path (config_file, NULL);
+ g_free (config_file);
+
+ for (node = addresses; node; node = node->next)
+ {
+ const gchar *address = node->data;
+ const gchar *match;
+
+ match = strstr (address, ":readwrite:");
+
+ if (match)
+ {
+ gchar *copy;
+
+ copy = g_malloc (strlen (match) - 1 + 1);
+ memcpy (copy, address, match - address);
+ memcpy (copy + (match - address), ":readonly:", 10);
+ strcpy (copy + (match - address) + 10, match + 11);
+ result = g_slist_prepend (result, copy);
+ }
+ }
+
+ result = g_slist_reverse (result);
+
+ gconf_address_list_free (addresses);
+
+ return result;
+}
+
+static GConfClient *
+get_writable_client (void)
+{
+ GConfEngine *engine;
+ GSList *addresses;
+
+ addresses = get_writable_source_path ();
+ engine = gconf_engine_get_local_for_addresses (addresses, NULL);
+ gconf_address_list_free (addresses);
+
+ return gconf_client_get_for_engine (engine);
+}
static gboolean
type_uint32 (GSettings *settings,
@@ -84,7 +145,7 @@ handle_file (const gchar *filename)
return FALSE;
}
- client = gconf_client_get_default ();
+ client = get_writable_client ();
source = g_settings_schema_source_get_default ();
groups = g_key_file_get_groups (keyfile, NULL);