summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorAllison Ryan Lortie <desrt@desrt.ca>2015-11-30 14:46:12 -0500
committerAllison Ryan Lortie <desrt@desrt.ca>2015-11-30 14:59:10 -0500
commit768ed4bbe040c53ee5010038c34aec7c69dba0a5 (patch)
treeba0de89dbcc757b9f3c85cf301ae2f1e2dacf197 /engine
parent014d634529f2a88ff638834dbbe827f6bb82aa16 (diff)
downloaddconf-768ed4bbe040c53ee5010038c34aec7c69dba0a5.tar.gz
engine, client: add list_locks() operation
Add an API to dconf-engine (and exposed via DConfClient) for getting a list of locks that are present in a given dconf profile. https://bugzilla.gnome.org/show_bug.cgi?id=758864
Diffstat (limited to 'engine')
-rw-r--r--engine/dconf-engine.c65
-rw-r--r--engine/dconf-engine.h5
2 files changed, 70 insertions, 0 deletions
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index 57bce96..e51ec57 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -363,6 +363,71 @@ dconf_engine_is_writable (DConfEngine *engine,
return writable;
}
+gchar **
+dconf_engine_list_locks (DConfEngine *engine,
+ const gchar *path,
+ gint *length)
+{
+ gchar **strv;
+
+ if (dconf_is_dir (path, NULL))
+ {
+ GHashTable *set;
+
+ set = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ dconf_engine_acquire_sources (engine);
+
+ if (engine->n_sources > 0 && engine->sources[0]->writable)
+ {
+ gint i, j;
+
+ for (i = 1; i < engine->n_sources; i++)
+ {
+ if (engine->sources[i]->locks)
+ {
+ strv = gvdb_table_get_names (engine->sources[i]->locks, NULL);
+
+ for (j = 0; strv[j]; j++)
+ {
+ /* It is not currently possible to lock dirs, so we
+ * don't (yet) have to check the other direction.
+ */
+ if (g_str_has_prefix (strv[j], path))
+ g_hash_table_add (set, strv[j]);
+ else
+ g_free (strv[j]);
+ }
+
+ g_free (strv);
+ }
+ }
+ }
+ else
+ g_hash_table_add (set, g_strdup (path));
+
+ dconf_engine_release_sources (engine);
+
+ strv = (gchar **) g_hash_table_get_keys_as_array (set, (guint *) length);
+ g_hash_table_steal_all (set);
+ g_hash_table_unref (set);
+ }
+ else
+ {
+ if (dconf_engine_is_writable (engine, path))
+ {
+ strv = g_new0 (gchar *, 0 + 1);
+ }
+ else
+ {
+ strv = g_new0 (gchar *, 1 + 1);
+ strv[0] = g_strdup (path);
+ }
+ }
+
+ return strv;
+}
+
static gboolean
dconf_engine_find_key_in_queue (GQueue *queue,
const gchar *key,
diff --git a/engine/dconf-engine.h b/engine/dconf-engine.h
index 9ea118c..5c34bbd 100644
--- a/engine/dconf-engine.h
+++ b/engine/dconf-engine.h
@@ -112,6 +112,11 @@ gboolean dconf_engine_is_writable (DConfEn
const gchar *key);
G_GNUC_INTERNAL
+gchar ** dconf_engine_list_locks (DConfEngine *engine,
+ const gchar *path,
+ gint *length);
+
+G_GNUC_INTERNAL
GVariant * dconf_engine_read (DConfEngine *engine,
GQueue *read_through,
const gchar *key);