diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-10-31 03:02:49 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-10-31 03:02:49 +0100 |
commit | e5609878d8802e2469c433be418bcbcf55fbe63b (patch) | |
tree | d0ca90e9fb655767e220b6d12b7c61dc4614fde6 /src/libsystemd-bus | |
parent | 2f6a59070559786428d9eaf199ae3d61772b2225 (diff) |
timedatectl: assorted simplifications
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r-- | src/libsystemd-bus/bus-convenience.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libsystemd-bus/bus-convenience.c b/src/libsystemd-bus/bus-convenience.c index 95a7577b29..7c9824258b 100644 --- a/src/libsystemd-bus/bus-convenience.c +++ b/src/libsystemd-bus/bus-convenience.c @@ -23,6 +23,7 @@ #include "bus-message.h" #include "bus-signature.h" #include "bus-util.h" +#include "bus-type.h" int sd_bus_emit_signal( sd_bus *bus, @@ -269,6 +270,41 @@ int sd_bus_get_property( return 0; } +int sd_bus_get_property_trivial( + sd_bus *bus, + const char *destination, + const char *path, + const char *interface, + const char *member, + sd_bus_error *error, + char type, void *ptr) { + + _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; + int r; + + assert_return(bus, -EINVAL); + assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL); + assert_return(member_name_is_valid(member), -EINVAL); + assert_return(bus_type_is_trivial(type), -EINVAL); + assert_return(ptr, -EINVAL); + assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); + assert_return(!bus_pid_changed(bus), -ECHILD); + + r = sd_bus_call_method(bus, destination, path, "org.freedesktop.DBus.Properties", "Get", error, &reply, "ss", strempty(interface), member); + if (r < 0) + return r; + + r = sd_bus_message_enter_container(reply, 'v', CHAR_TO_STR(type)); + if (r < 0) + return r; + + r = sd_bus_message_read_basic(reply, type, ptr); + if (r < 0) + return r; + + return 0; +} + int sd_bus_set_property( sd_bus *bus, const char *destination, |