[systemd-devel] [PATCH] logind: export *IgnoreInhibited settings to DBus

Lennart Poettering lennart at poettering.net
Wed Apr 23 14:31:55 PDT 2014


On Sat, 05.04.14 15:38, Mantas Mikulėnas (grawity at gmail.com) wrote:

Do you have a usecase for this? (Not opposed to the patch, just
wondering. The reason I left this out was mostly that I figured this
wouldn't be useful to anybody to query, and I wanted to keep the iface
small).

> ---
>  src/login/logind-dbus.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
> index 0af6714..0e58955 100644
> --- a/src/login/logind-dbus.c
> +++ b/src/login/logind-dbus.c
> @@ -1922,6 +1922,10 @@ const sd_bus_vtable manager_vtable[] = {
>          SD_BUS_PROPERTY("HandleSuspendKey", "s", property_get_handle_action, offsetof(Manager, handle_suspend_key), SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_PROPERTY("HandleHibernateKey", "s", property_get_handle_action, offsetof(Manager, handle_hibernate_key), SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_PROPERTY("HandleLidSwitch", "s", property_get_handle_action, offsetof(Manager, handle_lid_switch), SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("PowerKeyIgnoreInhibited", "b", NULL, offsetof(Manager, power_key_ignore_inhibited), SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("SuspendKeyIgnoreInhibited", "b", NULL, offsetof(Manager, suspend_key_ignore_inhibited), SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("HibernateKeyIgnoreInhibited", "b", NULL, offsetof(Manager, hibernate_key_ignore_inhibited), SD_BUS_VTABLE_PROPERTY_CONST),
> +        SD_BUS_PROPERTY("LidSwitchIgnoreInhibited", "b", NULL, offsetof(Manager, lid_switch_ignore_inhibited), SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_PROPERTY("IdleAction", "s", property_get_handle_action, offsetof(Manager, idle_action), SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_PROPERTY("IdleActionUSec", "t", NULL, offsetof(Manager, idle_action_usec), SD_BUS_VTABLE_PROPERTY_CONST),
>          SD_BUS_PROPERTY("PreparingForShutdown", "b", property_get_preparing, 0, 0),

You need to use bus_property_get_bool() for the props, due to the
discrepancy between the size of C99 "bool" and the C89 "int" we expose
for booleans in sd-bus. The sizes differ, so it matters how we access
the variables. 

Background: internally we use C99 bools. Externally we expose C89 ints
as bools, for example in sd-bus. This means we need some extra glue
whenever we export C99 bools.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list