diff options
Diffstat (limited to 'src/core/dbus-kill.c')
-rw-r--r-- | src/core/dbus-kill.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/core/dbus-kill.c b/src/core/dbus-kill.c index 811adb1b5a..42488b1f54 100644 --- a/src/core/dbus-kill.c +++ b/src/core/dbus-kill.c @@ -19,43 +19,44 @@ along with systemd; If not, see <http://www.gnu.org/licenses/>. ***/ -#include <errno.h> -#include <dbus/dbus.h> - +#include "bus-util.h" +#include "kill.h" #include "dbus-kill.h" -#include "dbus-common.h" +#include "bus-util.h" -static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_kill_append_mode, kill_mode, KillMode); +static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_kill_mode, kill_mode, KillMode); -const BusProperty bus_kill_context_properties[] = { - { "KillMode", bus_kill_append_mode, "s", offsetof(KillContext, kill_mode) }, - { "KillSignal", bus_property_append_int, "i", offsetof(KillContext, kill_signal) }, - { "SendSIGKILL", bus_property_append_bool, "b", offsetof(KillContext, send_sigkill) }, - { "SendSIGHUP", bus_property_append_bool, "b", offsetof(KillContext, send_sighup) }, - {} +const sd_bus_vtable bus_kill_vtable[] = { + SD_BUS_VTABLE_START(0), + SD_BUS_PROPERTY("KillMode", "s", property_get_kill_mode, offsetof(KillContext, kill_mode), 0), + SD_BUS_PROPERTY("KillSignal", "i", bus_property_get_int, offsetof(KillContext, kill_signal), 0), + SD_BUS_PROPERTY("SendSIGKILL", "b", bus_property_get_bool, offsetof(KillContext, send_sigkill), 0), + SD_BUS_PROPERTY("SendSIGHUP", "b", bus_property_get_bool, offsetof(KillContext, send_sighup), 0), + SD_BUS_VTABLE_END }; int bus_kill_context_set_transient_property( Unit *u, KillContext *c, const char *name, - DBusMessageIter *i, + sd_bus_message *message, UnitSetPropertiesMode mode, - DBusError *error) { + sd_bus_error *error) { + + int r; assert(u); assert(c); assert(name); - assert(i); + assert(message); if (streq(name, "KillMode")) { const char *m; KillMode k; - if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_STRING) - return -EINVAL; - - dbus_message_iter_get_basic(i, &m); + r = sd_bus_message_read(message, "s", &m); + if (r < 0) + return r; k = kill_mode_from_string(m); if (k < 0) @@ -70,14 +71,13 @@ int bus_kill_context_set_transient_property( return 1; } else if (streq(name, "SendSIGHUP")) { + int b; - if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN) - return -EINVAL; + r = sd_bus_message_read(message, "b", &b); + if (r < 0) + return r; if (mode != UNIT_CHECK) { - dbus_bool_t b; - - dbus_message_iter_get_basic(i, &b); c->send_sighup = b; unit_write_drop_in_private_format(u, mode, name, "SendSIGHUP=%s\n", yes_no(b)); @@ -86,14 +86,13 @@ int bus_kill_context_set_transient_property( return 1; } else if (streq(name, "SendSIGKILL")) { + int b; - if (dbus_message_iter_get_arg_type(i) != DBUS_TYPE_BOOLEAN) - return -EINVAL; + r = sd_bus_message_read(message, "b", &b); + if (r < 0) + return r; if (mode != UNIT_CHECK) { - dbus_bool_t b; - - dbus_message_iter_get_basic(i, &b); c->send_sigkill = b; unit_write_drop_in_private_format(u, mode, name, "SendSIGKILL=%s\n", yes_no(b)); |