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();
115 * This method directly logs out the system without user's confirmation.
116 * Ordinary applications should avoid calling this method. Please call
117 * RequestLogout() to ask the user to decide logout or not.
119 Q_SCRIPTABLE void Logout();
124 * This method directly reboots the system without user's confirmation.
125 * Ordinary applications should avoid calling this method. Please call
126 * RequestReboot() to ask the user to decide reboot or not.
128 Q_SCRIPTABLE void Reboot();
131 * Shutdown the system.
133 * This method directly shuts down the system without user's confirmation.
134 * Ordinary applications should avoid calling this method. Please call
135 * RequestShutdown() to ask the user to decide shutdown or not.
137 Q_SCRIPTABLE void Shutdown();
142 * This method puts the system into sleep without user's confirmation.
144 Q_SCRIPTABLE void Suspend();
147 * Hibernate the system
149 * This method puts the system into hibernation without user's confirmation.
151 Q_SCRIPTABLE void Hibernate();
156 * This method puts the system into hybrid sleep without user's confirmation.
160 Q_SCRIPTABLE void HybridSleep();
163 * Issue a logout request.
165 * This method emits the LogoutRequested signal to the shell with a boolean
166 * which indicates if there's any inhibitors. The shell should receive
167 * this signal and display a dialog to ask the user to confirm the logout
168 * action. If confirmed, shell can call Logout() method to logout.
170 Q_SCRIPTABLE void RequestLogout();
173 * Issue a reboot request.
175 * This method emits the RebootRequested signal to the shell with a boolean
176 * which indicates if there's any inhibitors. The shell should receive
177 * this signal and display a dialog to ask the user to confirm the reboot
178 * action. If confirmed, shell can call Reboot() method to reboot.
180 Q_SCRIPTABLE void RequestReboot();
183 * Issue a shutdown request.
185 * This method emits the ShutdownRequested signal to the shell with a
186 * boolean which indicates if there's any inhibitors.
187 * The shell should receive
188 * this signal and display a dialog to ask the user to confirm the reboot
189 * action. If confirmed, shell can call Shutdown() method to shutdown.
191 Q_SCRIPTABLE void RequestShutdown();
194 * Issue an EndSession request.
196 * This method calls the EndSession() Upstart DBus method on the
197 * current DBus session bus.
199 Q_SCRIPTABLE void EndSession();
202 * @return whether the system is capable of hibernating
204 Q_SCRIPTABLE bool CanHibernate() const;
207 * @return whether the system is capable of suspending
209 Q_SCRIPTABLE bool CanSuspend() const;
212 * @return whether the system is capable of hybrid sleep
215 Q_SCRIPTABLE bool CanHybridSleep() const;
218 * @return whether the system is capable of rebooting
221 Q_SCRIPTABLE bool CanReboot() const;
224 * @return whether the system is capable of shutting down
226 Q_SCRIPTABLE bool CanShutdown() const;
229 * @return whether the system is capable of locking the session
231 Q_SCRIPTABLE bool CanLock() const;
234 * @return the login name of the current user
236 Q_SCRIPTABLE QString UserName() const;
239 * @return the real name of the current user
241 Q_SCRIPTABLE QString RealName() const;
244 * @return the local hostname
246 Q_SCRIPTABLE QString HostName() const;
249 * Request that the session get locked, emits signal LockRequested()
251 Q_SCRIPTABLE void PromptLock();
254 * Locks the session immediately
256 Q_SCRIPTABLE void Lock();
259 * @return whether the session is currently locked
261 Q_SCRIPTABLE bool IsLocked() const;
267 void switchToGreeter();
270class DBusGnomeSessionManagerWrapper : public UnityDBusObject
273 Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.EndSessionDialog")
276 DBusGnomeSessionManagerWrapper();
277 ~DBusGnomeSessionManagerWrapper() = default;
280 Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);
283 void performAsyncCall(const QString &method);
286class DBusGnomeScreensaverWrapper: public UnityDBusObject
289 Q_CLASSINFO("D-Bus Interface", "org.gnome.ScreenSaver")
292 DBusGnomeScreensaverWrapper();
293 ~DBusGnomeScreensaverWrapper() = default;
297 * @return whether the session is currently locked (screensaver is on)
299 Q_SCRIPTABLE bool GetActive() const;
302 * Locks the session immediately if @p lock is true
304 Q_SCRIPTABLE void SetActive(bool lock);
307 * Locks the session immediately
309 Q_SCRIPTABLE void Lock();
312 * @return the number of seconds elapsed since the screensaver had been active
314 Q_SCRIPTABLE quint32 GetActiveTime() const;
316 Q_SCRIPTABLE void SimulateUserActivity();
319 void ActiveChanged(bool active);
322class DBusScreensaverWrapper: public UnityDBusObject
325 Q_CLASSINFO("D-Bus Interface", "org.freedesktop.ScreenSaver")
328 DBusScreensaverWrapper();
329 ~DBusScreensaverWrapper() = default;
333 * @return whether the session is currently locked (screensaver is on)
335 Q_SCRIPTABLE bool GetActive() const;
338 * Locks the session immediately if @p lock is true
340 Q_SCRIPTABLE bool SetActive(bool lock);
343 * Locks the session immediately
345 Q_SCRIPTABLE void Lock();
348 * @return the number of seconds elapsed since the screensaver had been active
350 Q_SCRIPTABLE quint32 GetActiveTime() const;
353 * @return the number of seconds that this session has been idle
355 Q_SCRIPTABLE quint32 GetSessionIdleTime() const;
357 Q_SCRIPTABLE void SimulateUserActivity();
360 void ActiveChanged(bool active);
363#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