Unity 8
 All Classes Functions Properties
dbusunitysessionservice.cpp
1 /*
2  * Copyright (C) 2014 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 // local
18 #include "dbusunitysessionservice.h"
19 
20 // Qt
21 #include <QDBusConnection>
22 #include <QDBusInterface>
23 
24 DBusUnitySessionService::DBusUnitySessionService() : QObject()
25 {
26  QDBusConnection connection = QDBusConnection::sessionBus();
27 
28  connection.registerService("com.canonical.Unity");
29  connection.registerObject("/com/canonical/Unity/Session", this,
30  QDBusConnection::ExportScriptableSignals
31  | QDBusConnection::ExportScriptableSlots
32  | QDBusConnection::ExportScriptableInvokables);
33 }
34 
35 DBusUnitySessionService::~DBusUnitySessionService()
36 {
37 }
38 
40 {
41  Q_EMIT logoutReady();
42 }
43 
45 {
46  Q_EMIT logoutRequested(false);
47 }
48 
50 {
51  QDBusConnection connection = QDBusConnection::systemBus();
52  QDBusInterface iface1 ("org.freedesktop.login1",
53  "/org/freedesktop/login1",
54  "org.freedesktop.login1.Manager",
55  connection);
56 
57  iface1.call("Reboot", false);
58 }
59 
61 {
62  Q_EMIT rebootRequested(false);
63 }
64 
66 {
67  QDBusConnection connection = QDBusConnection::systemBus();
68  QDBusInterface iface1 ("org.freedesktop.login1",
69  "/org/freedesktop/login1",
70  "org.freedesktop.login1.Manager",
71  connection);
72 
73  iface1.call("PowerOff", false);
74 }
75 
77 {
78  Q_EMIT shutdownRequested(false);
79 }
void shutdownRequested(bool have_inhibitors)
Q_SCRIPTABLE void RequestShutdown()
void logoutRequested(bool have_inhibitors)
void rebootRequested(bool have_inhibitors)