summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2011-05-10 12:16:20 +0200
committerRyan Lortie <desrt@desrt.ca>2011-05-10 12:16:20 +0200
commit70d1b330a7a09a555a1c66c17dc5111e08e77b8b (patch)
treea7a4742a2a661bebc8aba81707015475f228df35
parent03066011b7fe3a58d451d93a134022b0607ff1dc (diff)
downloaddconf-70d1b330a7a09a555a1c66c17dc5111e08e77b8b.tar.gz
Properly support watching in DConfClient
-rw-r--r--client/dconf-client.vala30
1 files changed, 30 insertions, 0 deletions
diff --git a/client/dconf-client.vala b/client/dconf-client.vala
index d84f0c8..940abf2 100644
--- a/client/dconf-client.vala
+++ b/client/dconf-client.vala
@@ -8,18 +8,48 @@ namespace DConf {
WatchFunc watch_func;
Engine engine;
+ void got_signal (DBusConnection connection, string sender_name, string object_path, string interface_name, string signal_name, Variant parameters) {
+ unowned string path;
+ unowned string tag;
+ string[] items;
+
+ if (signal_name == "Notify" && parameters.is_of_type ((VariantType) "(sass)")) {
+ VariantIter iter;
+
+ parameters.get ("(&sas&s)", out path, out iter, out tag);
+ items = new string[iter.n_children ()];
+ for (var i = 0; i < items.length; i++) {
+ iter.next ("s", out items[i]);
+ }
+ } else if (signal_name == "WritabilityNotify" && parameters.is_of_type ((VariantType) "(s)")) {
+ parameters.get ("(&s)", out path);
+ items = new string[0];
+ tag = "";
+ } else {
+ assert_not_reached ();
+ }
+
+ watch_func (this, path, items, tag);
+ }
+
void call_sync (EngineMessage dcem, out string tag, Cancellable? cancellable) throws Error {
DBusConnection connection;
if (dcem.bus_types[0] == 'e') {
if (session == null) {
session = Bus.get_sync (BusType.SESSION, cancellable);
+ if (watch_func != null) {
+ session.signal_subscribe (null, "ca.desrt.dconf.Writer", null, null, null, DBusSignalFlags.NO_MATCH_RULE, got_signal);
+ }
}
connection = session;
} else {
assert (dcem.bus_types[0] == 'y');
if (system == null) {
system = Bus.get_sync (BusType.SYSTEM, cancellable);
+ if (watch_func != null) {
+ system.signal_subscribe (null, "ca.desrt.dconf.Writer", null, null, null, DBusSignalFlags.NO_MATCH_RULE, got_signal);
+ }
}
connection = system;
}