summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-11-19 01:23:08 +0100
committerLennart Poettering <lennart@poettering.net>2013-11-20 19:37:02 +0100
commit911121a7c837040454c5d0422e2a225a8d799eef (patch)
tree7347fbd3ecd0abf1eb6fcbd7319910f98bb73210 /src
parentaea93debfa1281a7d5f1523225b043955c1c2472 (diff)
bus: add sd_bus_send_to() API call
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-bus/libsystemd-bus.sym4
-rw-r--r--src/libsystemd-bus/sd-bus.c21
-rw-r--r--src/systemd/sd-bus.h2
3 files changed, 24 insertions, 3 deletions
diff --git a/src/libsystemd-bus/libsystemd-bus.sym b/src/libsystemd-bus/libsystemd-bus.sym
index a1ffc439c1..8fa2cdec6d 100644
--- a/src/libsystemd-bus/libsystemd-bus.sym
+++ b/src/libsystemd-bus/libsystemd-bus.sym
@@ -43,9 +43,7 @@ global:
sd_bus_can_send;
sd_bus_get_server_id;
sd_bus_send;
- sd_bus_call;
- sd_bus_call_async;
- sd_bus_call_async_cancel;
+ sd_bus_send_to;
sd_bus_get_fd;
sd_bus_get_events;
sd_bus_get_timeout;
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 0be5a29f36..c8248e19aa 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1435,6 +1435,27 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial) {
return 1;
}
+_public_ int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destination, uint64_t *serial) {
+ int r;
+
+ assert_return(bus, -EINVAL);
+ assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
+ assert_return(m, -EINVAL);
+ assert_return(!bus_pid_changed(bus), -ECHILD);
+
+ if (!streq_ptr(m->destination, destination)) {
+
+ if (!destination)
+ return -EEXIST;
+
+ r = sd_bus_message_set_destination(m, destination);
+ if (r < 0)
+ return r;
+ }
+
+ return sd_bus_send(bus, m, serial);
+}
+
static usec_t calc_elapse(uint64_t usec) {
if (usec == (uint64_t) -1)
return 0;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index d56f8b3c75..072b54fa3a 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -94,6 +94,7 @@ int sd_bus_can_send(sd_bus *bus, char type);
int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *peer);
int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial);
+int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destination, uint64_t *serial);
int sd_bus_call(sd_bus *bus, sd_bus_message *m, uint64_t usec, sd_bus_error *error, sd_bus_message **reply);
int sd_bus_call_async(sd_bus *bus, sd_bus_message *m, sd_bus_message_handler_t callback, void *userdata, uint64_t usec, uint64_t *serial);
int sd_bus_call_async_cancel(sd_bus *bus, uint64_t serial);
@@ -225,6 +226,7 @@ int sd_bus_get_property_trivial(sd_bus *bus, const char *destination, const char
int sd_bus_get_property_string(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, char **ret); /* free the result! */
int sd_bus_get_property_strv(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, char ***ret); /* free the result! */
int sd_bus_set_property(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *error, const char *type, ...);
+
int sd_bus_reply_method_return(sd_bus *bus, sd_bus_message *call, const char *types, ...);
int sd_bus_reply_method_error(sd_bus *bus, sd_bus_message *call, const sd_bus_error *e);
int sd_bus_reply_method_errorf(sd_bus *bus, sd_bus_message *call, const char *name, const char *format, ...) _sd_printf_(4, 0);