chiark / gitweb /
bus-util: add bool property setter
authorJan Klötzke <Jan.Kloetzke@preh.de>
Thu, 11 Jan 2018 09:42:27 +0000 (10:42 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:13 +0000 (07:50 +0200)
src/shared/bus-util.c
src/shared/bus-util.h

index f301ab185e0b9ff4f81d46fede9cf97c1e341de0..375dbfb4841962c29a49122a4dba0827723dc5ee 100644 (file)
@@ -1348,6 +1348,25 @@ int bus_property_get_bool(
         return sd_bus_message_append_basic(reply, 'b', &b);
 }
 
+int bus_property_set_bool(
+                sd_bus *bus,
+                const char *path,
+                const char *interface,
+                const char *property,
+                sd_bus_message *value,
+                void *userdata,
+                sd_bus_error *error) {
+
+        int b, r;
+
+        r = sd_bus_message_read(value, "b", &b);
+        if (r < 0)
+                return r;
+
+        *(bool *) userdata = !!b;
+        return 0;
+}
+
 #if 0 /// UNNEEDED by elogind
 int bus_property_get_id128(
                 sd_bus *bus,
index e0addd71cdae6569b20fb05c54809c0d9e9c8a6b..6083451306776909310d658a8560101c6992e168 100644 (file)
@@ -92,6 +92,7 @@ int bus_print_property(const char *name, sd_bus_message *property, bool value, b
 int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool value, bool all);
 
 int bus_property_get_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
+int bus_property_set_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *error);
 #if 0 /// UNNEEDED by elogind
 int bus_property_get_id128(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error);
 #endif // 0