diff options
author | Umut Tezduyar Lindskog <umut.tezduyar@axis.com> | 2015-06-08 10:00:17 +0200 |
---|---|---|
committer | Umut Tezduyar Lindskog <umuttl@axis.com> | 2015-06-09 08:14:56 +0200 |
commit | 5d941c92bd0209abdfbc171d588b84df45222706 (patch) | |
tree | b701ca7f1fcff83deb765a1d692d28a1fd860541 | |
parent | 7437e0f53a8ec85d7f0596a352503d178d890c68 (diff) |
sd-bus: add async convenience method call API
-rw-r--r-- | src/libsystemd/libsystemd.sym.m4 | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-convenience.c | 37 | ||||
-rw-r--r-- | src/systemd/sd-bus.h | 1 |
3 files changed, 39 insertions, 0 deletions
diff --git a/src/libsystemd/libsystemd.sym.m4 b/src/libsystemd/libsystemd.sym.m4 index 0b94a87dd6..3121e71282 100644 --- a/src/libsystemd/libsystemd.sym.m4 +++ b/src/libsystemd/libsystemd.sym.m4 @@ -320,6 +320,7 @@ global: sd_bus_get_name_creds; sd_bus_get_name_machine_id; sd_bus_call_method; + sd_bus_call_method_async; sd_bus_get_property; sd_bus_get_property_trivial; sd_bus_get_property_string; diff --git a/src/libsystemd/sd-bus/bus-convenience.c b/src/libsystemd/sd-bus/bus-convenience.c index 28bc8d2818..dfd82e746d 100644 --- a/src/libsystemd/sd-bus/bus-convenience.c +++ b/src/libsystemd/sd-bus/bus-convenience.c @@ -58,6 +58,43 @@ _public_ int sd_bus_emit_signal( return sd_bus_send(bus, m, NULL); } +_public_ int sd_bus_call_method_async( + sd_bus *bus, + sd_bus_slot **slot, + const char *destination, + const char *path, + const char *interface, + const char *member, + sd_bus_message_handler_t callback, + void *userdata, + const char *types, ...) { + + _cleanup_bus_message_unref_ sd_bus_message *m = NULL; + int r; + + assert_return(bus, -EINVAL); + assert_return(!bus_pid_changed(bus), -ECHILD); + + if (!BUS_IS_OPEN(bus->state)) + return -ENOTCONN; + + r = sd_bus_message_new_method_call(bus, &m, destination, path, interface, member); + if (r < 0) + return r; + + if (!isempty(types)) { + va_list ap; + + va_start(ap, types); + r = bus_message_append_ap(m, types, ap); + va_end(ap); + if (r < 0) + return r; + } + + return sd_bus_call_async(bus, slot, m, callback, userdata, 0); +} + _public_ int sd_bus_call_method( sd_bus *bus, const char *destination, diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index e6e2ecd0b7..57e46ced8e 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -299,6 +299,7 @@ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_t *machin /* Convenience calls */ int sd_bus_call_method(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, sd_bus_message **reply, const char *types, ...); +int sd_bus_call_method_async(sd_bus *bus, sd_bus_slot **slot, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message_handler_t callback, void *userdata, const char *types, ...); int sd_bus_get_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, sd_bus_message **reply, const char *type); int sd_bus_get_property_trivial(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char type, void *ret_ptr); int sd_bus_get_property_string(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, char **ret); /* free the result! */ |