diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-12-12 05:55:58 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-12-12 05:55:58 +0100 |
commit | 29a07cdb4a317f2e1ea160b79bfe6eb1be2e6e01 (patch) | |
tree | 4002a201b4947b46fc466af2c27ddbb01ed71210 /src/libsystemd-bus | |
parent | f8e11cda5316055c381f45bd30843c1b54cd323b (diff) |
bus: instead of exposing the dbus1 flags when acquiring a name use our own that are closer to kdbus
This turns around DO_NOT_QUEUE into QUEUE which implies a more useful
default. (And negative options are awful anyway.)
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r-- | src/libsystemd-bus/bus-control.c | 19 | ||||
-rw-r--r-- | src/libsystemd-bus/bus-kernel.c | 2 | ||||
-rw-r--r-- | src/libsystemd-bus/bus-protocol.h | 8 |
3 files changed, 22 insertions, 7 deletions
diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c index b9700068b6..2682439427 100644 --- a/src/libsystemd-bus/bus-control.c +++ b/src/libsystemd-bus/bus-control.c @@ -49,7 +49,7 @@ _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) { return 0; } -static int bus_request_name_kernel(sd_bus *bus, const char *name, unsigned flags) { +static int bus_request_name_kernel(sd_bus *bus, const char *name, uint64_t flags) { struct kdbus_cmd_name *n; size_t l; int r; @@ -77,14 +77,21 @@ static int bus_request_name_kernel(sd_bus *bus, const char *name, unsigned flags return 1; } -static int bus_request_name_dbus1(sd_bus *bus, const char *name, unsigned flags) { +static int bus_request_name_dbus1(sd_bus *bus, const char *name, uint64_t flags) { _cleanup_bus_message_unref_ sd_bus_message *reply = NULL; - uint32_t ret; + uint32_t ret, param = 0; int r; assert(bus); assert(name); + if (flags & SD_BUS_NAME_ALLOW_REPLACEMENT) + param |= BUS_NAME_ALLOW_REPLACEMENT; + if (flags & SD_BUS_NAME_REPLACE_EXISTING) + param |= BUS_NAME_REPLACE_EXISTING; + if (!(flags & SD_BUS_NAME_QUEUE)) + param |= BUS_NAME_DO_NOT_QUEUE; + r = sd_bus_call_method( bus, "org.freedesktop.DBus", @@ -95,7 +102,7 @@ static int bus_request_name_dbus1(sd_bus *bus, const char *name, unsigned flags) &reply, "su", name, - flags); + param); if (r < 0) return r; @@ -115,13 +122,13 @@ static int bus_request_name_dbus1(sd_bus *bus, const char *name, unsigned flags) return -EIO; } -_public_ int sd_bus_request_name(sd_bus *bus, const char *name, unsigned flags) { +_public_ int sd_bus_request_name(sd_bus *bus, const char *name, uint64_t flags) { assert_return(bus, -EINVAL); assert_return(name, -EINVAL); assert_return(bus->bus_client, -EINVAL); assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN); assert_return(!bus_pid_changed(bus), -ECHILD); - assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_DO_NOT_QUEUE)), -EINVAL); + assert_return(!(flags & ~(SD_BUS_NAME_ALLOW_REPLACEMENT|SD_BUS_NAME_REPLACE_EXISTING|SD_BUS_NAME_QUEUE)), -EINVAL); if (bus->is_kernel) return bus_request_name_kernel(bus, name, flags); diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c index 81dfba7476..0437c96a9e 100644 --- a/src/libsystemd-bus/bus-kernel.c +++ b/src/libsystemd-bus/bus-kernel.c @@ -1020,7 +1020,7 @@ int kdbus_translate_request_name_flags(uint64_t flags, uint64_t *kdbus_flags) { if (flags & SD_BUS_NAME_REPLACE_EXISTING) f |= KDBUS_NAME_REPLACE_EXISTING; - if (!(flags & SD_BUS_NAME_DO_NOT_QUEUE)) + if (!(flags & SD_BUS_NAME_QUEUE)) f |= KDBUS_NAME_QUEUE; *kdbus_flags = f; diff --git a/src/libsystemd-bus/bus-protocol.h b/src/libsystemd-bus/bus-protocol.h index 982461bd9d..4726d9345d 100644 --- a/src/libsystemd-bus/bus-protocol.h +++ b/src/libsystemd-bus/bus-protocol.h @@ -60,6 +60,14 @@ enum { _BUS_MESSAGE_HEADER_MAX }; +/* RequestName parameters */ + +enum { + BUS_NAME_ALLOW_REPLACEMENT = 1, + BUS_NAME_REPLACE_EXISTING = 2, + BUS_NAME_DO_NOT_QUEUE = 4 +}; + /* RequestName returns */ enum { BUS_NAME_PRIMARY_OWNER = 1, |