diff --git a/src/core/dbus-path.c b/src/core/dbus-path.c index e59093e4154..fec67d595f0 100644 --- a/src/core/dbus-path.c +++ b/src/core/dbus-path.c @@ -47,29 +47,9 @@ static int property_get_paths( return sd_bus_message_close_container(reply); } -static int property_get_unit( - sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *error) { - - Unit *p = userdata, *trigger; - - assert(bus); - assert(reply); - assert(p); - - trigger = UNIT_TRIGGER(p); - - return sd_bus_message_append(reply, "s", trigger ? trigger->id : ""); -} - const sd_bus_vtable bus_path_vtable[] = { SD_BUS_VTABLE_START(0), - SD_BUS_PROPERTY("Unit", "s", property_get_unit, 0, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("Unit", "s", bus_property_get_triggered_unit, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("Paths", "a(ss)", property_get_paths, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("MakeDirectory", "b", bus_property_get_bool, offsetof(Path, make_directory), SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("DirectoryMode", "u", bus_property_get_mode, offsetof(Path, directory_mode), SD_BUS_VTABLE_PROPERTY_CONST), diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c index de34febb63b..eef060ff0f6 100644 --- a/src/core/dbus-timer.c +++ b/src/core/dbus-timer.c @@ -103,26 +103,6 @@ static int property_get_calendar_timers( return sd_bus_message_close_container(reply); } -static int property_get_unit( - sd_bus *bus, - const char *path, - const char *interface, - const char *property, - sd_bus_message *reply, - void *userdata, - sd_bus_error *error) { - - Unit *u = userdata, *trigger; - - assert(bus); - assert(reply); - assert(u); - - trigger = UNIT_TRIGGER(u); - - return sd_bus_message_append(reply, "s", trigger ? trigger->id : ""); -} - static int property_get_next_elapse_monotonic( sd_bus *bus, const char *path, @@ -145,7 +125,7 @@ static int property_get_next_elapse_monotonic( const sd_bus_vtable bus_timer_vtable[] = { SD_BUS_VTABLE_START(0), - SD_BUS_PROPERTY("Unit", "s", property_get_unit, 0, SD_BUS_VTABLE_PROPERTY_CONST), + SD_BUS_PROPERTY("Unit", "s", bus_property_get_triggered_unit, 0, SD_BUS_VTABLE_PROPERTY_CONST), SD_BUS_PROPERTY("TimersMonotonic", "a(stt)", property_get_monotonic_timers, 0, SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION), SD_BUS_PROPERTY("TimersCalendar", "a(sst)", property_get_calendar_timers, 0, SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION), SD_BUS_PROPERTY("NextElapseUSecRealtime", "t", bus_property_get_usec, offsetof(Timer, next_elapse_realtime), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE), diff --git a/src/core/dbus-util.c b/src/core/dbus-util.c index 2aa682f1031..15a3169bef6 100644 --- a/src/core/dbus-util.c +++ b/src/core/dbus-util.c @@ -13,6 +13,26 @@ #include "user-util.h" #include "unit.h" +int bus_property_get_triggered_unit( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + Unit *u = userdata, *trigger; + + assert(bus); + assert(reply); + assert(u); + + trigger = UNIT_TRIGGER(u); + + return sd_bus_message_append(reply, "s", trigger ? trigger->id : NULL); +} + BUS_DEFINE_SET_TRANSIENT(mode_t, "u", uint32_t, mode_t, "%040o"); BUS_DEFINE_SET_TRANSIENT(unsigned, "u", uint32_t, unsigned, "%" PRIu32); BUS_DEFINE_SET_TRANSIENT_STRING_WITH_CHECK(user, valid_user_group_name_or_id); diff --git a/src/core/dbus-util.h b/src/core/dbus-util.h index 18c40f9148c..b1f7b69d796 100644 --- a/src/core/dbus-util.h +++ b/src/core/dbus-util.h @@ -10,6 +10,8 @@ #include "sd-bus.h" #include "unit.h" +int bus_property_get_triggered_unit(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); + #define BUS_DEFINE_SET_TRANSIENT(function, bus_type, type, cast_type, fmt) \ int bus_set_transient_##function( \ Unit *u, \