mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-06-24 22:50:57 -04:00
retrieve login1 session object from manager (#3339)
This commit is contained in:
parent
796b5ceacb
commit
6ff3e8801d
2 changed files with 34 additions and 6 deletions
|
@ -19,7 +19,9 @@
|
||||||
|
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusMessage>
|
||||||
#include <QDBusReply>
|
#include <QDBusReply>
|
||||||
|
#include <QDebug>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
|
||||||
ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget* parent)
|
ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget* parent)
|
||||||
|
@ -57,12 +59,14 @@ ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget* parent)
|
||||||
SLOT(logindPrepareForSleep(bool)));
|
SLOT(logindPrepareForSleep(bool)));
|
||||||
|
|
||||||
QString sessionId = QProcessEnvironment::systemEnvironment().value("XDG_SESSION_ID");
|
QString sessionId = QProcessEnvironment::systemEnvironment().value("XDG_SESSION_ID");
|
||||||
systemBus.connect("", // service
|
QDBusInterface loginManager("org.freedesktop.login1", // service
|
||||||
QString("/org/freedesktop/login1/session/") + sessionId, // path
|
"/org/freedesktop/login1", // path
|
||||||
"org.freedesktop.login1.Session", // interface
|
"org.freedesktop.login1.Manager", // interface
|
||||||
"Lock", // signal name
|
systemBus);
|
||||||
this, // receiver
|
if (loginManager.isValid()) {
|
||||||
SLOT(unityLocked()));
|
QList<QVariant> args = {sessionId};
|
||||||
|
loginManager.callWithCallback("GetSession", args, this, SLOT(login1SessionObjectReceived(QDBusMessage)));
|
||||||
|
}
|
||||||
|
|
||||||
sessionBus.connect("com.canonical.Unity", // service
|
sessionBus.connect("com.canonical.Unity", // service
|
||||||
"/com/canonical/Unity/Session", // path
|
"/com/canonical/Unity/Session", // path
|
||||||
|
@ -72,6 +76,28 @@ ScreenLockListenerDBus::ScreenLockListenerDBus(QWidget* parent)
|
||||||
SLOT(unityLocked()));
|
SLOT(unityLocked()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenLockListenerDBus::login1SessionObjectReceived(QDBusMessage response)
|
||||||
|
{
|
||||||
|
if (response.arguments().isEmpty()) {
|
||||||
|
qDebug() << "org.freedesktop.login1.Manager.GetSession did not return results";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QVariant arg0 = response.arguments().at(0);
|
||||||
|
if (!arg0.canConvert<QDBusObjectPath>()) {
|
||||||
|
qDebug() << "org.freedesktop.login1.Manager.GetSession did not return a QDBusObjectPath";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QDBusObjectPath path = arg0.value<QDBusObjectPath>();
|
||||||
|
QDBusConnection systemBus = QDBusConnection::systemBus();
|
||||||
|
|
||||||
|
systemBus.connect("", // service
|
||||||
|
path.path(), // path
|
||||||
|
"org.freedesktop.login1.Session", // interface
|
||||||
|
"Lock", // signal name
|
||||||
|
this, // receiver
|
||||||
|
SLOT(unityLocked()));
|
||||||
|
}
|
||||||
|
|
||||||
void ScreenLockListenerDBus::gnomeSessionStatusChanged(uint status)
|
void ScreenLockListenerDBus::gnomeSessionStatusChanged(uint status)
|
||||||
{
|
{
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#ifndef SCREENLOCKLISTENERDBUS_H
|
#ifndef SCREENLOCKLISTENERDBUS_H
|
||||||
#define SCREENLOCKLISTENERDBUS_H
|
#define SCREENLOCKLISTENERDBUS_H
|
||||||
#include "ScreenLockListenerPrivate.h"
|
#include "ScreenLockListenerPrivate.h"
|
||||||
|
#include <QDBusMessage>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ private slots:
|
||||||
void logindPrepareForSleep(bool beforeSleep);
|
void logindPrepareForSleep(bool beforeSleep);
|
||||||
void unityLocked();
|
void unityLocked();
|
||||||
void freedesktopScreenSaver(bool status);
|
void freedesktopScreenSaver(bool status);
|
||||||
|
void login1SessionObjectReceived(QDBusMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCREENLOCKLISTENERDBUS_H
|
#endif // SCREENLOCKLISTENERDBUS_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue