File indexing completed on 2023-10-03 04:55:54
0001 /* 0002 SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #pragma once 0007 0008 #include <QDBusConnection> 0009 #include <QDBusPendingCallWatcher> 0010 #include <QDBusUnixFileDescriptor> 0011 #include <QObject> 0012 0013 class QDBusServiceWatcher; 0014 0015 class LogindIntegration : public QObject 0016 { 0017 Q_OBJECT 0018 public: 0019 explicit LogindIntegration(QObject *parent = nullptr); 0020 ~LogindIntegration() override; 0021 0022 bool isConnected() const 0023 { 0024 return m_connected; 0025 } 0026 0027 void inhibit(); 0028 void uninhibit(); 0029 0030 bool isInhibited() const; 0031 0032 /** 0033 * Notify logind of our current state 0034 */ 0035 void setLocked(bool locked); 0036 bool isLocked() const; 0037 0038 Q_SIGNALS: 0039 /** 0040 * signalled when logind asks us to lock 0041 */ 0042 void requestLock(); 0043 void requestUnlock(); 0044 void connectedChanged(); 0045 void prepareForSleep(bool); 0046 void inhibited(); 0047 0048 private: 0049 friend class LogindTest; 0050 /** 0051 * The DBusConnection argument is needed for the unit test. Logind uses the system bus 0052 * on which the unit test's fake logind cannot register to. Thus the unit test need to 0053 * be able to do everything over the session bus. This ctor allows the LogindTest to 0054 * create a LogindIntegration which listens on the session bus. 0055 **/ 0056 explicit LogindIntegration(const QDBusConnection &connection, QObject *parent = nullptr); 0057 void logindServiceRegistered(); 0058 void consolekitServiceRegistered(); 0059 void commonServiceRegistered(QDBusPendingCallWatcher *watcher); 0060 QDBusConnection m_bus; 0061 QDBusServiceWatcher *m_logindServiceWatcher; 0062 bool m_connected; 0063 QDBusUnixFileDescriptor m_inhibitFileDescriptor; 0064 const QString *m_service; 0065 const QString *m_path; 0066 QString m_sessionPath; 0067 const QString *m_managerInterface; 0068 const QString *m_sessionInterface; 0069 };