summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-10-11 05:22:00 +0200
committerLennart Poettering <lennart@poettering.net>2013-10-11 05:22:00 +0200
commit62b5c2aec12e6a3d305445ee1a88bc18ca0a1548 (patch)
treeba2ecb8852cb08a674e5a547046fda501fc703a1 /src/libsystemd-bus
parent90d184b234fbb72cb06636571655f30ba9858887 (diff)
bus: make PropertiesChanged emission work
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r--src/libsystemd-bus/sd-bus.c14
-rw-r--r--src/libsystemd-bus/test-bus-objects.c27
2 files changed, 30 insertions, 11 deletions
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 542b5e8c49..11194af007 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -3994,18 +3994,16 @@ static int emit_properties_changed_on_interface(
if (streq(c->interface, interface))
break;
-
- r = node_vtable_get_userdata(bus, path, c, &u);
- if (r < 0)
- return r;
- if (r > 0)
- break;
}
if (!c)
return 0;
- r = sd_bus_message_new_signal(bus, path, "org.freedesktop.DBus", "PropertiesChanged", &m);
+ r = node_vtable_get_userdata(bus, path, c, &u);
+ if (r <= 0)
+ return r;
+
+ r = sd_bus_message_new_signal(bus, path, "org.freedesktop.DBus.Properties", "PropertiesChanged", &m);
if (r < 0)
return r;
@@ -4042,7 +4040,7 @@ static int emit_properties_changed_on_interface(
if (r < 0)
return r;
- r = sd_bus_message_append(m, "s", *n);
+ r = sd_bus_message_append(m, "s", *property);
if (r < 0)
return r;
diff --git a/src/libsystemd-bus/test-bus-objects.c b/src/libsystemd-bus/test-bus-objects.c
index f3571cb3c4..b4facda04b 100644
--- a/src/libsystemd-bus/test-bus-objects.c
+++ b/src/libsystemd-bus/test-bus-objects.c
@@ -36,8 +36,6 @@
/* Test:
*
- * sd_bus_emit_properties_changed()
- *
* Add in:
*
* automatic properties
@@ -134,6 +132,16 @@ static int value_handler(sd_bus *bus, const char *path, const char *interface, c
assert_se(PTR_TO_UINT(userdata) == 30);
+ return 1;
+}
+
+static int notify_test(sd_bus *bus, sd_bus_message *m, void *userdata) {
+ int r;
+
+ assert_se(sd_bus_emit_properties_changed(bus, m->path, "org.freedesktop.systemd.ValueTest", "Value", NULL) >= 0);
+
+ r = sd_bus_reply_method_return(bus, m, NULL);
+ assert_se(r >= 0);
return 1;
}
@@ -148,7 +156,8 @@ static const sd_bus_vtable vtable[] = {
static const sd_bus_vtable vtable2[] = {
SD_BUS_VTABLE_START(0),
- SD_BUS_PROPERTY("Value", "s", value_handler, 10, 0),
+ SD_BUS_METHOD("NotifyTest", "", "", 0, notify_test),
+ SD_BUS_PROPERTY("Value", "s", value_handler, 10, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_VTABLE_END
};
@@ -347,6 +356,18 @@ static int client(struct context *c) {
sd_bus_message_unref(reply);
reply = NULL;
+ r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/value/a", "org.freedesktop.systemd.ValueTest", "NotifyTest", &error, NULL, "");
+ assert_se(r >= 0);
+
+ r = sd_bus_process(bus, &reply);
+ assert_se(r > 0);
+
+ assert_se(sd_bus_message_is_signal(reply, "org.freedesktop.DBus.Properties", "PropertiesChanged"));
+ bus_message_dump(reply);
+
+ sd_bus_message_unref(reply);
+ reply = NULL;
+
r = sd_bus_call_method(bus, "org.freedesktop.systemd.test", "/foo", "org.freedesktop.systemd.test", "Exit", &error, NULL, "");
assert_se(r >= 0);