logind: add BlockWeakInhibited property
Fixes https://github.com/systemd/systemd/issues/34091
Follow-up for 804874d26a
This commit is contained in:
committed by
Lennart Poettering
parent
8144537a81
commit
14b0fcdf6d
@@ -216,6 +216,7 @@ node /org/freedesktop/login1 {
|
||||
readonly t IdleSinceHint = ...;
|
||||
readonly t IdleSinceHintMonotonic = ...;
|
||||
readonly s BlockInhibited = '...';
|
||||
readonly s BlockWeakInhibited = '...';
|
||||
readonly s DelayInhibited = '...';
|
||||
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
|
||||
readonly t InhibitDelayMaxUSec = ...;
|
||||
@@ -488,6 +489,8 @@ node /org/freedesktop/login1 {
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="BlockInhibited"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="BlockWeakInhibited"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="DelayInhibited"/>
|
||||
|
||||
<variablelist class="dbus-property" generated="True" extra-ref="InhibitDelayMaxUSec"/>
|
||||
@@ -805,9 +808,10 @@ node /org/freedesktop/login1 {
|
||||
timestamps of the last change of the idle hint boolean, in <constant>CLOCK_REALTIME</constant> and
|
||||
<constant>CLOCK_MONOTONIC</constant> timestamps, respectively, in microseconds since the epoch.</para>
|
||||
|
||||
<para>The <varname>BlockInhibited</varname> and <varname>DelayInhibited</varname> properties encode
|
||||
the currently active locks of the respective modes. They are colon separated lists of
|
||||
<literal>shutdown</literal>, <literal>sleep</literal>, and <literal>idle</literal> (see above).</para>
|
||||
<para>The <varname>BlockInhibited</varname>, <varname>BlockWeakInhibited</varname>, and
|
||||
<varname>DelayInhibited</varname> properties encode the currently active locks of the respective
|
||||
modes. They are colon separated lists of <literal>shutdown</literal>, <literal>sleep</literal>, and
|
||||
<literal>idle</literal> (see above).</para>
|
||||
|
||||
<para><varname>NCurrentSessions</varname> and <varname>NCurrentInhibitors</varname> contain the number
|
||||
of currently registered sessions and inhibitors.</para>
|
||||
@@ -1634,7 +1638,8 @@ node /org/freedesktop/login1/session/1 {
|
||||
<function>ListSessionsEx()</function> were added in version 256.</para>
|
||||
<para><varname>HandleSecureAttentionKey</varname>, <function>SecureAttentionKey()</function>,
|
||||
<varname>PreparingForShutdownWithMetadata</varname>, <varname>DesignatedMaintenanceTime</varname>,
|
||||
<varname>CanIdle</varname>, and <varname>CanLock</varname> were added in version 257.</para>
|
||||
<varname>CanIdle</varname>, <varname>CanLock</varname>,
|
||||
and <varname>BlockWeakInhibited</varname> were added in version 257.</para>
|
||||
</refsect2>
|
||||
<refsect2>
|
||||
<title>Session Objects</title>
|
||||
|
||||
@@ -310,7 +310,14 @@ static int property_get_inhibited(
|
||||
assert(bus);
|
||||
assert(reply);
|
||||
|
||||
w = manager_inhibit_what(m, /* block= */ streq(property, "BlockInhibited"));
|
||||
if (streq(property, "BlockInhibited"))
|
||||
w = manager_inhibit_what(m, INHIBIT_BLOCK);
|
||||
else if (streq(property, "BlockWeakInhibited"))
|
||||
w = manager_inhibit_what(m, INHIBIT_BLOCK_WEAK);
|
||||
else if (streq(property, "DelayInhibited"))
|
||||
w = manager_inhibit_what(m, INHIBIT_DELAY);
|
||||
else
|
||||
assert_not_reached();
|
||||
|
||||
return sd_bus_message_append(reply, "s", inhibit_what_to_string(w));
|
||||
}
|
||||
@@ -3745,6 +3752,7 @@ static const sd_bus_vtable manager_vtable[] = {
|
||||
SD_BUS_PROPERTY("IdleSinceHint", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("IdleSinceHintMonotonic", "t", property_get_idle_since_hint, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("BlockInhibited", "s", property_get_inhibited, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("BlockWeakInhibited", "s", property_get_inhibited, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("DelayInhibited", "s", property_get_inhibited, 0, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
|
||||
SD_BUS_PROPERTY("InhibitDelayMaxUSec", "t", NULL, offsetof(Manager, inhibit_delay_max), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("UserStopDelayUSec", "t", NULL, offsetof(Manager, user_stop_delay), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
|
||||
@@ -363,16 +363,14 @@ bool inhibitor_is_orphan(Inhibitor *i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
InhibitWhat manager_inhibit_what(Manager *m, bool block) {
|
||||
InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mode) {
|
||||
Inhibitor *i;
|
||||
InhibitWhat what = 0;
|
||||
|
||||
assert(m);
|
||||
|
||||
HASHMAP_FOREACH(i, m->inhibitors)
|
||||
if (i->started &&
|
||||
((!block && i->mode == INHIBIT_DELAY) ||
|
||||
(block && IN_SET(i->mode, INHIBIT_BLOCK, INHIBIT_BLOCK_WEAK))))
|
||||
if (i->started && i->mode == mode)
|
||||
what |= i->what;
|
||||
|
||||
return what;
|
||||
|
||||
@@ -66,7 +66,7 @@ int inhibitor_create_fifo(Inhibitor *i);
|
||||
|
||||
bool inhibitor_is_orphan(Inhibitor *i);
|
||||
|
||||
InhibitWhat manager_inhibit_what(Manager *m, bool block);
|
||||
InhibitWhat manager_inhibit_what(Manager *m, InhibitMode mode);
|
||||
bool manager_is_inhibited(Manager *m, InhibitWhat w, bool block, dual_timestamp *since, bool ignore_inactive, bool ignore_uid, uid_t uid, Inhibitor **offending);
|
||||
|
||||
static inline bool inhibit_what_is_valid(InhibitWhat w) {
|
||||
|
||||
Reference in New Issue
Block a user