Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
LockService.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <PhosphorServiceLock/phosphorservicelock_export.h>
7
8#include <QObject>
9#include <QString>
10
11#include <memory>
12
13namespace PhosphorServiceLock {
14
34class PHOSPHORSERVICELOCK_EXPORT LockService : public QObject
35{
36 Q_OBJECT
37 Q_PROPERTY(QString userName READ userName CONSTANT)
38 Q_PROPERTY(bool supported READ isSupported CONSTANT)
39 Q_PROPERTY(State state READ state NOTIFY stateChanged)
40 Q_PROPERTY(bool locked READ isLocked NOTIFY stateChanged)
41
42public:
44 enum class State {
45 Unlocked,
46 Locking,
47 Locked,
48 Authenticating,
49 Releasing,
50 };
51 Q_ENUM(State)
52
53 explicit LockService(QObject* parent = nullptr);
54 ~LockService() override;
55
57 [[nodiscard]] QString userName() const;
58
61 [[nodiscard]] bool isSupported() const;
62
64 [[nodiscard]] State state() const;
65
67 [[nodiscard]] bool isLocked() const;
68
71 Q_INVOKABLE void lock();
72
76 Q_INVOKABLE void unlock(const QString& password);
77
85 Q_INVOKABLE void finishUnlock();
86
87Q_SIGNALS:
92 void authenticationFailed(const QString& reason);
97 void unlocked();
98
99private:
100 Q_DISABLE_COPY_MOVE(LockService)
101
102 class Private;
103 std::unique_ptr<Private> d;
104};
105
106} // namespace PhosphorServiceLock
void unlocked()
The session was successfully unlocked after authentication.
void unlock(const QString &password)
Attempt to unlock by authenticating the session user with password.
void authenticationFailed(const QString &reason)
An unlock() attempt was rejected; reason is a human-readable, non-sensitive explanation.
QString userName() const
The same local account that PAM authenticates, resolved from the process uid.
State state() const
The current lock state.
bool isSupported() const
Whether the compositor advertises the ext-session-lock-v1 protocol this service builds on.
LockService(QObject *parent=nullptr)
State
The lock lifecycle.
Definition LockService.h:44
bool isLocked() const
True while the session is locked (whether idle or authenticating).
void stateChanged()
state() changed.
void finishUnlock()
Release the compositor lock after a successful authentication.
void aboutToUnlock()
Authentication succeeded and the lock is about to be released.
void lock()
Request that the compositor lock the session.
Definition IAuthenticator.h:11