Rename login interface to UKUI ScreenSaver
Replace m_loginInterface/m_loginConnected with m_ukuiInterface/m_ukuiConnected, update connection/teardown logic and log messages, and query lock state via UKUI's GetLockState method instead of the previous login manager property call.
This commit is contained in:
parent
eaa40929bd
commit
bff9ded0fa
|
|
@ -16,10 +16,10 @@ ScreenLockDetector::ScreenLockDetector(QObject *parent)
|
|||
, m_isLocked(false)
|
||||
#ifdef Q_OS_LINUX
|
||||
, m_gnomeInterface(nullptr)
|
||||
, m_loginInterface(nullptr)
|
||||
, m_ukuiInterface(nullptr)
|
||||
, m_deepinInterface(nullptr)
|
||||
, m_gnomeConnected(false)
|
||||
, m_loginConnected(false)
|
||||
, m_ukuiConnected(false)
|
||||
, m_deepinConnected(false)
|
||||
#endif
|
||||
#ifdef Q_OS_MAC
|
||||
|
|
@ -36,9 +36,9 @@ ScreenLockDetector::~ScreenLockDetector()
|
|||
m_gnomeInterface = nullptr;
|
||||
}
|
||||
|
||||
if (m_loginInterface) {
|
||||
delete m_loginInterface;
|
||||
m_loginInterface = nullptr;
|
||||
if (m_ukuiInterface) {
|
||||
delete m_ukuiInterface;
|
||||
m_ukuiInterface = nullptr;
|
||||
}
|
||||
|
||||
if (m_deepinInterface) {
|
||||
|
|
@ -101,9 +101,9 @@ bool ScreenLockDetector::initialize()
|
|||
// 尝试连接到不同的DBus接口
|
||||
bool deepinOk = connectToDeepinDDE();
|
||||
bool gnomeOk = connectToGnomeScreenSaver();
|
||||
bool loginOk = connectToUkuiManager();
|
||||
bool ukuiOk = connectToUkuiManager();
|
||||
|
||||
if (!deepinOk && !gnomeOk && !loginOk) {
|
||||
if (!deepinOk && !gnomeOk && !ukuiOk) {
|
||||
qWarning() << "Failed to connect to any screen lock detection service";
|
||||
qWarning() << "Make sure you are running on a supported Linux desktop environment";
|
||||
return false;
|
||||
|
|
@ -116,7 +116,7 @@ bool ScreenLockDetector::initialize()
|
|||
qDebug() << "ScreenLockDetector initialized successfully on Linux";
|
||||
qDebug() << "Deepin DDE connected:" << m_deepinConnected;
|
||||
qDebug() << "GNOME ScreenSaver connected:" << m_gnomeConnected;
|
||||
qDebug() << "Login Manager connected:" << m_loginConnected;
|
||||
qDebug() << "UKUI ScreenSaver connected:" << m_ukuiConnected;
|
||||
qDebug() << "=================================================";
|
||||
|
||||
return true;
|
||||
|
|
@ -200,7 +200,7 @@ bool ScreenLockDetector::connectToUkuiManager()
|
|||
qDebug() << "\n--- Connecting to ukui ScreenSaver ---";
|
||||
|
||||
QString sessionPath = "/";
|
||||
m_loginInterface = new QDBusInterface(
|
||||
m_ukuiInterface = new QDBusInterface(
|
||||
"org.ukui.ScreenSaver",
|
||||
sessionPath,
|
||||
"org.ukui.ScreenSaver",
|
||||
|
|
@ -208,7 +208,7 @@ bool ScreenLockDetector::connectToUkuiManager()
|
|||
this
|
||||
);
|
||||
|
||||
if (m_loginInterface->isValid()) {
|
||||
if (m_ukuiInterface->isValid()) {
|
||||
qDebug() << "ukui ScreenSaver interface is valid for session:" << sessionPath;
|
||||
|
||||
// 连接Lock和Unlock信号到特定会话
|
||||
|
|
@ -234,15 +234,15 @@ bool ScreenLockDetector::connectToUkuiManager()
|
|||
qDebug() << "Session Unlock signal connected:" << unlockConnected;
|
||||
|
||||
if (lockConnected || unlockConnected) {
|
||||
m_loginConnected = true;
|
||||
qDebug() << "Successfully connected to Login Manager via session path";
|
||||
m_ukuiConnected = true;
|
||||
qDebug() << "Successfully connected to UKUI ScreenSaver via session path";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
qWarning() << "Failed to connect to Login Manager signals";
|
||||
delete m_loginInterface;
|
||||
m_loginInterface = nullptr;
|
||||
qWarning() << "Failed to connect to UKUI ScreenSaver signals";
|
||||
delete m_ukuiInterface;
|
||||
m_ukuiInterface = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -383,26 +383,15 @@ void ScreenLockDetector::queryCurrentLockState()
|
|||
}
|
||||
|
||||
// 尝试从登录管理器查询锁定状态
|
||||
if (m_loginInterface && m_loginInterface->isValid()) {
|
||||
qDebug() << "Querying Login Manager lock state...";
|
||||
if (m_ukuiInterface && m_ukuiInterface->isValid()) {
|
||||
qDebug() << "Querying UKUI ScreenSaver lock state...";
|
||||
|
||||
// 尝试读取 LockedHint 属性
|
||||
QDBusMessage msg = QDBusMessage::createMethodCall(
|
||||
"org.freedesktop.login1",
|
||||
m_loginInterface->path(),
|
||||
"org.freedesktop.DBus.Properties",
|
||||
"Get"
|
||||
);
|
||||
msg << "org.freedesktop.login1.Session" << "LockedHint";
|
||||
|
||||
QDBusReply<QVariant> reply = QDBusConnection::systemBus().call(msg);
|
||||
QDBusReply<bool> reply = m_ukuiInterface->call("GetLockState");
|
||||
if (reply.isValid()) {
|
||||
bool locked = reply.value().toBool();
|
||||
qDebug() << " LockedHint property:" << (locked ? "LOCKED" : "UNLOCKED");
|
||||
setLockState(locked);
|
||||
bool active = reply.value();
|
||||
qDebug() << " Current UKUI ScreenSaver state:" << (active ? "ACTIVE/LOCKED" : "INACTIVE/UNLOCKED");
|
||||
setLockState(active);
|
||||
return;
|
||||
} else {
|
||||
qDebug() << " Could not read LockedHint:" << reply.error().message();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -136,10 +136,10 @@ private:
|
|||
|
||||
#ifdef Q_OS_LINUX
|
||||
QDBusInterface *m_gnomeInterface; // GNOME屏幕保护程序接口
|
||||
QDBusInterface *m_loginInterface; // 登录管理器接口
|
||||
QDBusInterface *m_ukuiInterface; // UKUI屏幕保护接口
|
||||
QDBusInterface *m_deepinInterface; // Deepin DDE接口
|
||||
bool m_gnomeConnected; // GNOME接口是否连接成功
|
||||
bool m_loginConnected; // 登录管理器接口是否连接成功
|
||||
bool m_ukuiConnected; // UKUI接口是否连接成功
|
||||
bool m_deepinConnected; // Deepin DDE接口是否连接成功
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue