logind session manager: capability queries, session/power actions, inhibitor locks, and the sleep + session signals. More...
#include <PhosphorServiceSession/SessionHost.h>
Public Types | |
| enum class | Availability { Unknown , Yes , No , NotApplicable , Challenge } |
| logind capability state, parsed from the Can* query strings. More... | |
Signals | |
| void | capabilitiesChanged () |
| Emitted whenever any capability value actually changes (each async Can* reply that differs from the cached value fires this once). | |
| void | interactiveChanged () |
| void | logoutRequested () |
| Emitted by logout() so the shell / compositor can end the session gracefully (close clients, save state) rather than via a blunt logind terminate. | |
| void | prepareForSleep (bool beforeSleep) |
Raw logind PrepareForSleep passthrough: beforeSleep is true just before the system sleeps and false just after it resumes. | |
| void | aboutToSleep () |
| Emitted on PrepareForSleep(true) while the delay inhibitor is held: the shell should lock now, then call allowSleep() once the surface is up. | |
| void | lockRequested () |
| The logind session was asked to lock / unlock (e.g. | |
| void | unlockRequested () |
Public Member Functions | |
| SessionHost (QObject *parent=nullptr) | |
| Whether action calls pass logind interactive=true, routing an action that needs authorization to an in-session polkit agent (we ship one in 2.6) for a native prompt. | |
| SessionHost (QDBusConnection connection, QString service, QObject *parent=nullptr) | |
| Injectable wiring for tests / advanced consumers. | |
| ~SessionHost () override | |
| Availability | canPowerOff () const |
| Availability | canReboot () const |
| Availability | canHalt () const |
| Availability | canSuspend () const |
| Availability | canHibernate () const |
| Availability | canHybridSleep () const |
| Availability | canSuspendThenHibernate () const |
| void | refreshCapabilities () |
| Re-read every capability from logind. | |
| bool | interactive () const |
| void | setInteractive (bool interactive) |
| void | lock () |
| Lock this session (resolved via XDG_SESSION_ID / GetSession, falling back to GetSessionByPID): logind emits its Lock signal, which the shell routes to the lock surface (2.9). | |
| void | logout () |
| End this session. | |
| void | terminateSession () |
| void | suspend () |
| Capability-gated power actions. | |
| void | hibernate () |
| void | hybridSleep () |
| void | suspendThenHibernate () |
| void | reboot () |
| void | powerOff () |
| void | halt () |
| void | allowSleep () |
| Drop the sleep delay-inhibitor so a pending suspend proceeds. | |
logind session manager: capability queries, session/power actions, inhibitor locks, and the sleep + session signals.
Talks to org.freedesktop.login1.Manager on the system bus. The capability queries (CanSuspend and siblings) are read up front and cached; the actions are capability-gated; the inhibitor locks let the shell lock before suspend and own the power / lid keys. Inert when logind is unreachable (capabilities Unknown, actions no-op with a warning, inhibitors not taken).
The (connection, service) are injectable so the whole surface is testable against a fake logind Manager with no real system bus and no daemon.
Beyond the capability queries it issues the capability-gated session / power actions, holds the logind delay (sleep) and block (handle-keys) inhibitors, runs the PrepareForSleep lock-before-sleep handshake, and surfaces the session Lock / Unlock signals.
|
strong |
logind capability state, parsed from the Can* query strings.
|
explicit |
Whether action calls pass logind interactive=true, routing an action that needs authorization to an in-session polkit agent (we ship one in 2.6) for a native prompt.
Defaults true on the QML host; the CLI sets it false (no agent in a dev shell, so logind just returns an auth error). Production wiring: the system bus and org.freedesktop.login1.
| PhosphorServiceSession::SessionHost::SessionHost | ( | QDBusConnection | connection, |
| QString | service, | ||
| QObject * | parent = nullptr ) |
Injectable wiring for tests / advanced consumers.
connection and service select the bus and the logind well-known name; the fake-logind unit tests inject a session-bus Manager so no real logind is required.
|
override |
|
signal |
Emitted on PrepareForSleep(true) while the delay inhibitor is held: the shell should lock now, then call allowSleep() once the surface is up.
| void PhosphorServiceSession::SessionHost::allowSleep | ( | ) |
Drop the sleep delay-inhibitor so a pending suspend proceeds.
The shell calls this once the lock surface (2.9) is confirmed up, completing the lock-before-sleep handshake. A safety timeout drops it anyway if the shell never confirms, so a missing lock cannot wedge suspend.
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
nodiscard |
|
signal |
Emitted whenever any capability value actually changes (each async Can* reply that differs from the cached value fires this once).
| void PhosphorServiceSession::SessionHost::halt | ( | ) |
| void PhosphorServiceSession::SessionHost::hibernate | ( | ) |
| void PhosphorServiceSession::SessionHost::hybridSleep | ( | ) |
|
nodiscard |
|
signal |
| void PhosphorServiceSession::SessionHost::lock | ( | ) |
Lock this session (resolved via XDG_SESSION_ID / GetSession, falling back to GetSessionByPID): logind emits its Lock signal, which the shell routes to the lock surface (2.9).
Falls back to Manager.LockSessions() when this session cannot be resolved.
|
signal |
The logind session was asked to lock / unlock (e.g.
loginctl lock-session, a hardware lock key routed through logind, or our own lock()). The shell routes lockRequested() to 2.9's lock surface.
| void PhosphorServiceSession::SessionHost::logout | ( | ) |
End this session.
Emits logoutRequested() so the shell / compositor can exit gracefully; terminateSession() is the logind fallback (the resolved session's Terminate) for contexts with no graceful owner.
|
signal |
Emitted by logout() so the shell / compositor can end the session gracefully (close clients, save state) rather than via a blunt logind terminate.
| void PhosphorServiceSession::SessionHost::powerOff | ( | ) |
|
signal |
Raw logind PrepareForSleep passthrough: beforeSleep is true just before the system sleeps and false just after it resumes.
| void PhosphorServiceSession::SessionHost::reboot | ( | ) |
| void PhosphorServiceSession::SessionHost::refreshCapabilities | ( | ) |
Re-read every capability from logind.
Called once at construction and exposed so the shell can refresh before opening a power menu, since the answers move with inhibitor locks, lid state, and swap availability.
| void PhosphorServiceSession::SessionHost::setInteractive | ( | bool | interactive | ) |
| void PhosphorServiceSession::SessionHost::suspend | ( | ) |
Capability-gated power actions.
Each is a no-op (with a warning) when its capability is not Yes or Challenge, and otherwise issues the logind Manager call with the current interactive flag.
| void PhosphorServiceSession::SessionHost::suspendThenHibernate | ( | ) |
| void PhosphorServiceSession::SessionHost::terminateSession | ( | ) |
|
signal |