on 1bc5ffd help sign in
unity8/plugins/Unity/Session/dbusunitysessionservice.h
169 lines 5.5 kB history raw
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 */
17#ifndef DBUSUNITYSESSIONSERVICE_H
18#define DBUSUNITYSESSIONSERVICE_H
20#include <QDBusObjectPath>
22#include "unitydbusobject.h"
24typedef QList<QDBusObjectPath> QDbusList;
25Q_DECLARE_METATYPE(QList<QDBusObjectPath>)
27/**
28 * DBusUnitySessionService provides com.canonical.Unity.Session dbus
29 * interface.
30 *
31 * com.canonical.Unity.Session interface provides public methods
32 * and signals to handle Logout/Reboot/Shutdown.
33 */
34class DBusUnitySessionService : public UnityDBusObject
36 Q_OBJECT
37 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")
39public:
40 DBusUnitySessionService();
41 ~DBusUnitySessionService();
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(); }
49Q_SIGNALS:
50 /**
51 * logoutRequested signal
52 *
53 * This signal is emitted when some applications request the system to
54 * logout.
55 * @param have_inhibitors if there are any special running applications
56 * which inhibit the logout.
57 */
58 Q_SCRIPTABLE void logoutRequested(bool have_inhibitors);
60 /**
61 * rebootRequested signal
62 *
63 * This signal is emitted when some applications request the system to
64 * reboot.
65 * @param have_inhibitors if there are any special running applications
66 * which inhibit the reboot.
67 */
68 Q_SCRIPTABLE void rebootRequested(bool have_inhibitors);
70 /**
71 * shutdownRequested signal
72 *
73 * This signal is emitted when some applications request the system to
74 * shutdown.
75 * @param have_inhibitors if there are any special running applications
76 * which inhibit the shutdown.
77 */
78 Q_SCRIPTABLE void shutdownRequested(bool have_inhibitors);
81 /**
82 * logoutReady signal
83 *
84 * This signal is emitted when all the apps are closed. And the system
85 * is safe to logout.
86 */
87 void logoutReady();
89public Q_SLOTS:
90 /**
91 * Logout the system.
92 *
93 * This method directly logout the system without user's confirmation.
94 * Ordinary applications should avoid calling this method. Please call
95 * RequestLogout() to ask the user to decide logout or not.
96 */
97 Q_SCRIPTABLE void Logout();
99 /**
100 * Reboot the system.
101 *
102 * This method directly reboot the system without user's confirmation.
103 * Ordinary applications should avoid calling this method. Please call
104 * RequestReboot() to ask the user to decide reboot or not.
105 */
106 Q_SCRIPTABLE void Reboot();
108 /**
109 * Shutdown the system.
110 *
111 * This method directly shutdown the system without user's confirmation.
112 * Ordinary applications should avoid calling this method. Please call
113 * RequestShutdown() to ask the user to decide shutdown or not.
114 */
115 Q_SCRIPTABLE void Shutdown();
117 /**
118 * Issue a logout request.
119 *
120 * This method emit the logoutRequested signal to the shell with a boolean
121 * which indicates if there's any inhibitors. The shell should receive
122 * this signal and display a dialog to ask the user to confirm the logout
123 * action. If confirmed, shell can call Logout() method to logout.
124 */
125 Q_SCRIPTABLE void RequestLogout();
127 /**
128 * Issue a reboot request.
129 *
130 * This method emit the rebootRequested signal to the shell with a boolean
131 * which indicates if there's any inhibitors. The shell should receive
132 * this signal and display a dialog to ask the user to confirm the reboot
133 * action. If confirmed, shell can call Reboot() method to reboot
134 */
135 Q_SCRIPTABLE void RequestReboot();
137 /**
138 * Issue a shutdown request.
139 *
140 * This method emit the shutdownRequested signal to the shell with a
141 * boolean which indicates if there's any inhibitors.
142 * The shell should receive
143 * this signal and display a dialog to ask the user to confirm the reboot
144 * action. If confirmed, shell can call Shutdown() method to reboot
145 */
146 Q_SCRIPTABLE void RequestShutdown();
148 /**
149 * Issue an EndSession request.
150 *
151 * This method calls the EndSession() Upstart DBus method on the
152 * current DBus session bus.
153 */
154 Q_SCRIPTABLE void EndSession();
155};
157class DBusGnomeSessionManagerWrapper : public UnityDBusObject
159 Q_OBJECT
160 Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.EndSessionDialog")
162public:
163 DBusGnomeSessionManagerWrapper();
164 ~DBusGnomeSessionManagerWrapper();
166public Q_SLOTS:
167 Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);
168};
169#endif // DBUSUNITYSESSIONSERVICE_H