2 * Copyright (C) 2014, 2015 Canonical, Ltd.
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.
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.
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/>.
17#ifndef DBUSUNITYSESSIONSERVICE_H
18#define DBUSUNITYSESSIONSERVICE_H
20#include <QDBusObjectPath>
22#include "unitydbusobject.h"
24typedef QList<QDBusObjectPath> QDbusList;
25Q_DECLARE_METATYPE(QList<QDBusObjectPath>)
28 * DBusUnitySessionService provides com.canonical.Unity.Session dbus
31 * com.canonical.Unity.Session interface provides public methods
32 * and signals to handle eg. Logout/Reboot/Shutdown.
34class DBusUnitySessionService : public UnityDBusObject
37 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")
40 DBusUnitySessionService();
41 ~DBusUnitySessionService() = default;
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(); }
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
53 * LogoutRequested signal
55 * This signal is emitted when some applications request the system to
57 * @param have_inhibitors if there are any special running applications
58 * which inhibit the logout.
60 Q_SCRIPTABLE void LogoutRequested(bool have_inhibitors);
61 void logoutRequested(bool have_inhibitors);
64 * RebootRequested signal
66 * This signal is emitted when some applications request the system to
68 * @param have_inhibitors if there are any special running applications
69 * which inhibit the reboot.
71 Q_SCRIPTABLE void RebootRequested(bool have_inhibitors);
72 void rebootRequested(bool have_inhibitors);
75 * ShutdownRequested signal
77 * This signal is emitted when some applications request the system to
79 * @param have_inhibitors if there are any special running applications
80 * which inhibit the shutdown.
82 Q_SCRIPTABLE void ShutdownRequested(bool have_inhibitors);
83 void shutdownRequested(bool have_inhibitors);
88 * This signal is emitted when all the apps are closed. And the system
91 Q_SCRIPTABLE void LogoutReady();
95 * Emitted as a result of calling PromptLock()
97 Q_SCRIPTABLE void LockRequested();
101 * Emitted after the session has been locked.
103 Q_SCRIPTABLE void Locked();
106 * Emitted after the session has been unlocked.
108 Q_SCRIPTABLE void Unlocked();
114 * This method directly logs out the system without user's confirmation.
115 * Ordinary applications should avoid calling this method. Please call
116 * RequestLogout() to ask the user to decide logout or not.
118 Q_SCRIPTABLE void Logout();
123 * This method directly reboots the system without user's confirmation.
124 * Ordinary applications should avoid calling this method. Please call
125 * RequestReboot() to ask the user to decide reboot or not.
127 Q_SCRIPTABLE void Reboot();
130 * Shutdown the system.
132 * This method directly shuts down the system without user's confirmation.
133 * Ordinary applications should avoid calling this method. Please call
134 * RequestShutdown() to ask the user to decide shutdown or not.
136 Q_SCRIPTABLE void Shutdown();
141 * This method puts the system into sleep without user's confirmation.
143 Q_SCRIPTABLE void Suspend();
146 * Hibernate the system
148 * This method puts the system into hibernation without user's confirmation.
150 Q_SCRIPTABLE void Hibernate();
155 * This method puts the system into hybrid sleep without user's confirmation.
159 Q_SCRIPTABLE void HybridSleep();
162 * Issue a logout request.
164 * This method emits the LogoutRequested signal to the shell with a boolean
165 * which indicates if there's any inhibitors. The shell should receive
166 * this signal and display a dialog to ask the user to confirm the logout
167 * action. If confirmed, shell can call Logout() method to logout.
169 Q_SCRIPTABLE void RequestLogout();
172 * Issue a reboot request.
174 * This method emits the RebootRequested signal to the shell with a boolean
175 * which indicates if there's any inhibitors. The shell should receive
176 * this signal and display a dialog to ask the user to confirm the reboot
177 * action. If confirmed, shell can call Reboot() method to reboot.
179 Q_SCRIPTABLE void RequestReboot();
182 * Issue a shutdown request.
184 * This method emits the ShutdownRequested signal to the shell with a
185 * boolean which indicates if there's any inhibitors.
186 * The shell should receive
187 * this signal and display a dialog to ask the user to confirm the reboot
188 * action. If confirmed, shell can call Shutdown() method to shutdown.
190 Q_SCRIPTABLE void RequestShutdown();
193 * Issue an EndSession request.
195 * This method calls the EndSession() Upstart DBus method on the
196 * current DBus session bus.
198 Q_SCRIPTABLE void EndSession();
201 * @return whether the system is capable of hibernating
203 Q_SCRIPTABLE bool CanHibernate() const;
206 * @return whether the system is capable of suspending
208 Q_SCRIPTABLE bool CanSuspend() const;
211 * @return whether the system is capable of hybrid sleep
214 Q_SCRIPTABLE bool CanHybridSleep() const;
217 * @return whether the system is capable of rebooting
220 Q_SCRIPTABLE bool CanReboot() const;
223 * @return whether the system is capable of shutting down
225 Q_SCRIPTABLE bool CanShutdown() const;
228 * @return whether the system is capable of locking the session
230 Q_SCRIPTABLE bool CanLock() const;
233 * @return the login name of the current user
235 Q_SCRIPTABLE QString UserName() const;
238 * @return the real name of the current user
240 Q_SCRIPTABLE QString RealName() const;
243 * @return the local hostname
245 Q_SCRIPTABLE QString HostName() const;
248 * Request that the session get locked, emits signal LockRequested()
250 Q_SCRIPTABLE void PromptLock();
253 * Locks the session immediately
255 Q_SCRIPTABLE void Lock();
258 * @return whether the session is currently locked
260 Q_SCRIPTABLE bool IsLocked() const;
263class DBusGnomeSessionManagerWrapper : public UnityDBusObject
266 Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.EndSessionDialog")
269 DBusGnomeSessionManagerWrapper();
270 ~DBusGnomeSessionManagerWrapper() = default;
273 Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);
276 void performAsyncCall(const QString &method);
279class DBusGnomeScreensaverWrapper: public UnityDBusObject
282 Q_CLASSINFO("D-Bus Interface", "org.gnome.ScreenSaver")
285 DBusGnomeScreensaverWrapper();
286 ~DBusGnomeScreensaverWrapper() = default;
290 * @return whether the session is currently locked (screensaver is on)
292 Q_SCRIPTABLE bool GetActive() const;
295 * Locks the session immediately if @p lock is true
297 Q_SCRIPTABLE void SetActive(bool lock);
300 * Locks the session immediately
302 Q_SCRIPTABLE void Lock();
305 * @return the number of seconds elapsed since the screensaver had been active
307 Q_SCRIPTABLE quint32 GetActiveTime() const;
309 Q_SCRIPTABLE void SimulateUserActivity();
312 void ActiveChanged(bool active);
315class DBusScreensaverWrapper: public UnityDBusObject
318 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.ScreenSaver")
321 DBusScreensaverWrapper();
322 ~DBusScreensaverWrapper() = default;
326 * @return whether the session is currently locked (screensaver is on)
328 Q_SCRIPTABLE bool GetActive() const;
331 * Locks the session immediately if @p lock is true
333 Q_SCRIPTABLE bool SetActive(bool lock);
336 * Locks the session immediately
338 Q_SCRIPTABLE void Lock();
341 * @return the number of seconds elapsed since the screensaver had been active
343 Q_SCRIPTABLE quint32 GetActiveTime() const;
346 * @return the number of seconds that this session has been idle
348 Q_SCRIPTABLE quint32 GetSessionIdleTime() const;
350 Q_SCRIPTABLE void SimulateUserActivity();
353 void ActiveChanged(bool active);
356#endif // DBUSUNITYSESSIONSERVICE_H
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list