summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2012-07-02 00:49:46 -0400
committerRyan Lortie <desrt@desrt.ca>2012-07-02 00:49:46 -0400
commit4eea8cb823c5a113d8209b04102f17f08df853d6 (patch)
tree5a8bb7d0c220e00981c0f0ba6e834ac8e1f6e584 /bin
parent6a675a5bdef5949e2397b0d5ca9d0c8a36ccedfd (diff)
downloaddconf-4eea8cb823c5a113d8209b04102f17f08df853d6.tar.gz
Massively reorganise the client-side
This commit represents a rather complete rethinking of DConfEngine. - the different kinds of sources are now properly abstracted. This will make landing NFS support substantially easier. - there is now substantially more internal documentation - DConfEngineMessage is gone and replaced with ordinary function calls to be implemented by the D-Bus glue code - the GDBus glue has been factored out and is now shared between the client library and GSettings - the "outstanding" queue logic from the GSettings backend is now in the engine - all changes now go through a single API that accepts a (new) DConfChangeset object. Currently this only supports the current operations (ie: setting and resetting). In the future this object will also support the directory operations required by GSettingsList and will be the basis for the new approach to implementing the 'delayed' GSettingsBackend (which will be the method by which those two concepts can co-exist). The (internal) API of the engine changed substantially. This caused the following: - the libdconf client library has been rewritten in C. Most of the complicated aspects of it (that made it more convenience to use Vala) are now gone. - during the rewrite of libdconf, the DConfClient API changed a bit to look more like a proper GObject. It now makes GIO-style use of thread-default main contexts and uses GObject signals for notifications (instead of hand-rolled callbacks). - the GSettings backend has been substantially simplified (the "outstanding" logic is gone). No externally-visible changes. - the dbus-1 backend has taken a copy of the old engine code for now until it can be ported to the new engine and sufficiently tested. No externally-visible changes. - the dconf commandline tool and dconf-editor required minor changes to adjust to the DConfClient API changes There is a substantial amount of cleaning up and finishing of work to be done. There are many stubs remaining. There are likely still a large number of bugs.
Diffstat (limited to 'bin')
-rw-r--r--bin/dconf-dump.vala37
-rw-r--r--bin/dconf-update.vala2
-rw-r--r--bin/dconf.vala9
3 files changed, 11 insertions, 37 deletions
diff --git a/bin/dconf-dump.vala b/bin/dconf-dump.vala
index 4fb8c02..135b230 100644
--- a/bin/dconf-dump.vala
+++ b/bin/dconf-dump.vala
@@ -47,48 +47,21 @@ KeyFile keyfile_from_stdin () throws Error {
return kf;
}
-class DConfLoadState {
- public string[] keys;
- public Variant?[] vals;
- int n_keys;
- int i;
-
- public DConfLoadState (int n) {
- keys = new string[n + 1];
- vals = new Variant?[n];
- n_keys = n;
- i = 0;
- }
-
- public int add (void *key, void *value) {
- assert (i < n_keys);
-
- keys[i] = (string) key;
- vals[i] = (Variant) value;
- i++;
-
- return (int) false;
- }
-}
-
void dconf_load (string[] args) throws Error {
var dir = args[2];
DConf.verify_dir (dir);
- var tree = new Tree<string, Variant> (strcmp);
+ var changeset = new DConf.Changeset ();
var kf = keyfile_from_stdin ();
foreach (var group in kf.get_groups ()) {
foreach (var key in kf.get_keys (group)) {
- var rel = (group == "/" ? "" : group + "/") + key;
- DConf.verify_rel_key (rel);
- tree.insert (rel, Variant.parse (null, kf.get_value (group, key)));
+ var path = dir + (group == "/" ? "" : group + "/") + key;
+ DConf.verify_key (path);
+ changeset.set (path, Variant.parse (null, kf.get_value (group, key)));
}
}
- DConfLoadState list = new DConfLoadState (tree.nnodes ());
- tree.foreach (list.add);
-
var client = new DConf.Client ();
- client.write_many (dir, list.keys, list.vals);
+ client.change_sync (changeset);
}
diff --git a/bin/dconf-update.vala b/bin/dconf-update.vala
index 434b022..9fcc4ec 100644
--- a/bin/dconf-update.vala
+++ b/bin/dconf-update.vala
@@ -240,7 +240,7 @@ void update_all (string dirname) {
}
}
-void dconf_update (string[] args) {
+void dconf_update (string[] args) throws GLib.Error {
update_all ("/etc/dconf/db");
}
diff --git a/bin/dconf.vala b/bin/dconf.vala
index 4117d23..88db9e6 100644
--- a/bin/dconf.vala
+++ b/bin/dconf.vala
@@ -173,7 +173,7 @@ void dconf_write (string?[] args) throws Error {
DConf.verify_key (key);
- client.write (key, Variant.parse (null, val));
+ client.write_sync (key, Variant.parse (null, val));
}
void dconf_reset (string?[] args) throws Error {
@@ -194,7 +194,7 @@ void dconf_reset (string?[] args) throws Error {
throw new OptionError.FAILED ("-f must be given to (recursively) reset entire dirs");
}
- client.write (path, null);
+ client.write_sync (path, null);
}
void show_path (DConf.Client client, string path) {
@@ -221,12 +221,13 @@ void watch_function (DConf.Client client, string path, string[] items, string ta
}
void dconf_watch (string?[] args) throws Error {
- var client = new DConf.Client (null, watch_function);
+ var client = new DConf.Client ();
+ client.changed.connect (watch_function);
var path = args[2];
DConf.verify_path (path);
- client.watch (path);
+ client.watch_sync (path);
new MainLoop (null, false).run ();
}