Lomiri
dbuslomirisessionservice.h
1 /*
2  * Copyright (C) 2014, 2015 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License version 3, as published by
6  * the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10  * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef DBUSLOMIRISESSIONSERVICE_H
18 #define DBUSLOMIRISESSIONSERVICE_H
19 
20 #include <QDBusObjectPath>
21 
22 #include "lomiridbusobject.h"
23 
24 typedef QList<QDBusObjectPath> QDbusList;
25 Q_DECLARE_METATYPE(QList<QDBusObjectPath>)
26 
27 
34 class DBusLomiriSessionService : public LomiriDBusObject
35 {
36  Q_OBJECT
37  Q_CLASSINFO("D-Bus Interface", "com.lomiri.Shell.Session")
38 
39 public:
41  ~DBusLomiriSessionService() = default;
42 
43  // For use in QML. Javascript doesn't accept functions beginning with capital letters
44  Q_INVOKABLE void logout() { Logout(); }
45  Q_INVOKABLE void reboot() { Reboot(); }
46  Q_INVOKABLE void shutdown() { Shutdown(); }
47  Q_INVOKABLE void endSession() { EndSession(); }
48 
49  // TODO: remove duplicate signals and split D-Bus and QML API's
50  // Apparently QML needs the signals in lowercase, while DBUS spec needs the uppercase version
51 Q_SIGNALS:
60  Q_SCRIPTABLE void LogoutRequested(bool have_inhibitors);
61  void logoutRequested(bool have_inhibitors);
62 
71  Q_SCRIPTABLE void RebootRequested(bool have_inhibitors);
72  void rebootRequested(bool have_inhibitors);
73 
82  Q_SCRIPTABLE void ShutdownRequested(bool have_inhibitors);
83  void shutdownRequested(bool have_inhibitors);
84 
91  Q_SCRIPTABLE void LogoutReady();
92  void logoutReady();
93 
97  Q_SCRIPTABLE void LockRequested();
98  void lockRequested();
99 
103  Q_SCRIPTABLE void Locked();
104 
108  Q_SCRIPTABLE void Unlocked();
109  void unlocked();
110 
111 public Q_SLOTS:
119  Q_SCRIPTABLE void Logout();
120 
128  Q_SCRIPTABLE void Reboot();
129 
137  Q_SCRIPTABLE void Shutdown();
138 
144  Q_SCRIPTABLE void Suspend();
145 
151  Q_SCRIPTABLE void Hibernate();
152 
160  Q_SCRIPTABLE void HybridSleep();
161 
170  Q_SCRIPTABLE void RequestLogout();
171 
180  Q_SCRIPTABLE void RequestReboot();
181 
191  Q_SCRIPTABLE void RequestShutdown();
192 
199  Q_SCRIPTABLE void EndSession();
200 
204  Q_SCRIPTABLE bool CanHibernate() const;
205 
209  Q_SCRIPTABLE bool CanSuspend() const;
210 
215  Q_SCRIPTABLE bool CanHybridSleep() const;
216 
221  Q_SCRIPTABLE bool CanReboot() const;
222 
226  Q_SCRIPTABLE bool CanShutdown() const;
227 
231  Q_SCRIPTABLE bool CanLock() const;
232 
236  Q_SCRIPTABLE QString UserName() const;
237 
241  Q_SCRIPTABLE QString RealName() const;
242 
246  Q_SCRIPTABLE QString HostName() const;
247 
251  Q_SCRIPTABLE void PromptLock();
252 
256  Q_SCRIPTABLE void Lock();
257 
261  Q_SCRIPTABLE bool IsLocked() const;
262 
263 private Q_SLOTS:
264  void doUnlock();
265 
266 private:
267  void switchToGreeter();
268 };
269 
270 class DBusGnomeSessionManagerWrapper : public LomiriDBusObject
271 {
272  Q_OBJECT
273  Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager")
274 
275 public:
276  DBusGnomeSessionManagerWrapper();
277  ~DBusGnomeSessionManagerWrapper() = default;
278 
279 public Q_SLOTS:
280  Q_SCRIPTABLE void Logout(quint32 mode);
281  Q_SCRIPTABLE void Reboot();
282  Q_SCRIPTABLE void RequestReboot();
283  Q_SCRIPTABLE void RequestShutdown();
284  Q_SCRIPTABLE void Shutdown();
285 };
286 
287 class DBusGnomeSessionManagerDialogWrapper : public LomiriDBusObject
288 {
289  Q_OBJECT
290  Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.EndSessionDialog")
291 
292 public:
293  DBusGnomeSessionManagerDialogWrapper();
294  ~DBusGnomeSessionManagerDialogWrapper() = default;
295 
296 public Q_SLOTS:
297  Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);
298 };
299 
300 class DBusGnomeScreensaverWrapper: public LomiriDBusObject
301 {
302  Q_OBJECT
303  Q_CLASSINFO("D-Bus Interface", "org.gnome.ScreenSaver")
304 
305 public:
306  DBusGnomeScreensaverWrapper();
307  ~DBusGnomeScreensaverWrapper() = default;
308 
309 public Q_SLOTS:
313  Q_SCRIPTABLE bool GetActive() const;
314 
318  Q_SCRIPTABLE void SetActive(bool lock);
319 
323  Q_SCRIPTABLE void Lock();
324 
328  Q_SCRIPTABLE quint32 GetActiveTime() const;
329 
330  Q_SCRIPTABLE void SimulateUserActivity();
331 
332 Q_SIGNALS:
333  void ActiveChanged(bool active);
334 };
335 
336 class DBusScreensaverWrapper: public LomiriDBusObject
337 {
338  Q_OBJECT
339  Q_CLASSINFO("D-Bus Interface", "org.freedesktop.ScreenSaver")
340 
341 public:
342  DBusScreensaverWrapper();
343  ~DBusScreensaverWrapper() = default;
344 
345 public Q_SLOTS:
349  Q_SCRIPTABLE bool GetActive() const;
350 
354  Q_SCRIPTABLE bool SetActive(bool lock);
355 
359  Q_SCRIPTABLE void Lock();
360 
364  Q_SCRIPTABLE quint32 GetActiveTime() const;
365 
369  Q_SCRIPTABLE quint32 GetSessionIdleTime() const;
370 
371  Q_SCRIPTABLE void SimulateUserActivity();
372 
373 Q_SIGNALS:
374  void ActiveChanged(bool active);
375 };
376 
377 #endif // DBUSLOMIRISESSIONSERVICE_H
DBusLomiriSessionService
Definition: dbuslomirisessionservice.h:34