summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorAllison Ryan Lortie <desrt@desrt.ca>2015-12-16 14:52:19 +0000
committerAllison Ryan Lortie <desrt@desrt.ca>2015-12-16 11:30:57 -0500
commita4139891fa874197e945fe409698e16a5ba35ae3 (patch)
treecbcb4ba5677e50b7d917e6c7cf5afc2875421733 /engine
parent7beac020f79da20e25966d6a19bc47f2e6542e92 (diff)
downloaddconf-a4139891fa874197e945fe409698e16a5ba35ae3.tar.gz
engine: merge _read and _read_user_value()
Delete the separate dconf_engine_read_user_value() and merge its functionality into dconf_engine_read() by adding a flags field. https://bugzilla.gnome.org/show_bug.cgi?id=759128
Diffstat (limited to 'engine')
-rw-r--r--engine/dconf-engine.c89
-rw-r--r--engine/dconf-engine.h7
2 files changed, 28 insertions, 68 deletions
diff --git a/engine/dconf-engine.c b/engine/dconf-engine.c
index 1b2770e..ebd8ede 100644
--- a/engine/dconf-engine.c
+++ b/engine/dconf-engine.c
@@ -444,9 +444,10 @@ dconf_engine_find_key_in_queue (GQueue *queue,
}
GVariant *
-dconf_engine_read (DConfEngine *engine,
- GQueue *read_through,
- const gchar *key)
+dconf_engine_read (DConfEngine *engine,
+ DConfReadFlags flags,
+ GQueue *read_through,
+ const gchar *key)
{
GVariant *value = NULL;
gint lock_level = 0;
@@ -476,6 +477,13 @@ dconf_engine_read (DConfEngine *engine,
* This statement includes read_through and queued changes. If a
* lock is found, we will ignore those.
*
+ * With respect to flags:
+ *
+ * If DCONF_READ_USER_VALUE is given then we completely ignore all
+ * locks, returning the user value all the time, even if it is not
+ * visible (because of a lock). This includes any pending value
+ * that is in the read_through or pending queues.
+ *
* With respect to read_through and queued changed:
*
* We only consider read_through and queued changes in the event
@@ -554,12 +562,13 @@ dconf_engine_read (DConfEngine *engine,
*
* Note: i > 0 (strictly). Ignore locks for source #0.
*/
- for (i = engine->n_sources - 1; i > 0; i--)
- if (engine->sources[i]->locks && gvdb_table_has_value (engine->sources[i]->locks, key))
- {
- lock_level = i;
- break;
- }
+ if (~flags & DCONF_READ_USER_VALUE)
+ for (i = engine->n_sources - 1; i > 0; i--)
+ if (engine->sources[i]->locks && gvdb_table_has_value (engine->sources[i]->locks, key))
+ {
+ lock_level = i;
+ break;
+ }
/* Only do steps 2 to 4 if we have no locks and we have a writable source. */
if (!lock_level && engine->n_sources != 0 && engine->sources[0]->writable)
@@ -600,61 +609,15 @@ dconf_engine_read (DConfEngine *engine,
}
/* Step 5. Check the remaining sources, until value != NULL. */
- for (i = lock_level; value == NULL && i < engine->n_sources; i++)
- {
- if (engine->sources[i]->values == NULL)
- continue;
-
- if ((value = gvdb_table_get_value (engine->sources[i]->values, key)))
- break;
- }
-
- dconf_engine_release_sources (engine);
-
- return value;
-}
-
-GVariant *
-dconf_engine_read_user_value (DConfEngine *engine,
- GQueue *read_through,
- const gchar *key)
-{
- gboolean found_key = FALSE;
- GVariant *value = NULL;
-
- /* This is a simplified version of the above. We get to ignore locks
- * and system-level settings.
- *
- * NB: we may find "NULL", which is why we have a separate variable.
- */
-
- /* Ignore the queues if we don't have a writable database */
- if (engine->n_sources == 0 || !engine->sources[0]->writable)
- return NULL;
-
- dconf_engine_acquire_sources (engine);
-
- /* First check read-through */
- if (read_through)
- found_key = dconf_engine_find_key_in_queue (read_through, key, &value);
-
- /* Next pending/in-flight */
- if (!found_key)
- {
- dconf_engine_lock_queues (engine);
-
- /* Check the pending queue first because those were submitted
- * more recently.
- */
- found_key = dconf_engine_find_key_in_queue (&engine->pending, key, &value) ||
- dconf_engine_find_key_in_queue (&engine->in_flight, key, &value);
-
- dconf_engine_unlock_queues (engine);
- }
+ if (~flags & DCONF_READ_USER_VALUE)
+ for (i = lock_level; value == NULL && i < engine->n_sources; i++)
+ {
+ if (engine->sources[i]->values == NULL)
+ continue;
- /* Finally, check the user database */
- if (!found_key && engine->sources[0]->values)
- value = gvdb_table_get_value (engine->sources[0]->values, key);
+ if ((value = gvdb_table_get_value (engine->sources[i]->values, key)))
+ break;
+ }
dconf_engine_release_sources (engine);
diff --git a/engine/dconf-engine.h b/engine/dconf-engine.h
index 5c34bbd..e166d53 100644
--- a/engine/dconf-engine.h
+++ b/engine/dconf-engine.h
@@ -21,6 +21,7 @@
#define __dconf_engine_h__
#include "../common/dconf-changeset.h"
+#include "../common/dconf-enums.h"
#include <gio/gio.h>
@@ -118,11 +119,7 @@ gchar ** dconf_engine_list_locks (DConfEn
G_GNUC_INTERNAL
GVariant * dconf_engine_read (DConfEngine *engine,
- GQueue *read_through,
- const gchar *key);
-
-G_GNUC_INTERNAL
-GVariant * dconf_engine_read_user_value (DConfEngine *engine,
+ DConfReadFlags flags,
GQueue *read_through,
const gchar *key);