on feea33f help sign in
unity8/plugins/Unity/Session/dbusunitysessionservice.h
144 lines 4.7 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 "unitydbusobject.h"
22/**
23 * DBusUnitySessionService provides com.canonical.Unity.Session dbus
24 * interface.
25 *
26 * com.canonical.Unity.Session interface provides public methods
27 * and signals to handle Logout/Reboot/Shutdown.
28 */
29class DBusUnitySessionService : public UnityDBusObject
31 Q_OBJECT
32 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")
34public:
35 DBusUnitySessionService();
36 ~DBusUnitySessionService();
38 // For use in QML. Javascript doesn't accept functions beginning with capital letters
39 Q_INVOKABLE void logout() { Logout(); }
40 Q_INVOKABLE void reboot() { Reboot(); }
41 Q_INVOKABLE void shutdown() { Shutdown(); }
43Q_SIGNALS:
44 /**
45 * logoutRequested signal
46 *
47 * This signal is emitted when some applications request the system to
48 * logout.
49 * @param have_inhibitors if there are any special running applications
50 * which inhibit the logout.
51 */
52 void logoutRequested(bool have_inhibitors);
54 /**
55 * rebootRequested signal
56 *
57 * This signal is emitted when some applications request the system to
58 * reboot.
59 * @param have_inhibitors if there are any special running applications
60 * which inhibit the reboot.
61 */
62 void rebootRequested(bool have_inhibitors);
64 /**
65 * shutdownRequested signal
66 *
67 * This signal is emitted when some applications request the system to
68 * shutdown.
69 * @param have_inhibitors if there are any special running applications
70 * which inhibit the shutdown.
71 */
72 void shutdownRequested(bool have_inhibitors);
75 /**
76 * logoutReady signal
77 *
78 * This signal is emitted when all the apps are closed. And the system
79 * is safe to logout.
80 */
81 void logoutReady();
83public Q_SLOTS:
84 /**
85 * Logout the system.
86 *
87 * This method directly logout the system without user's confirmation.
88 * Ordinary applications should avoid calling this method. Please call
89 * RequestLogout() to ask the user to decide logout or not.
90 */
91 Q_SCRIPTABLE void Logout();
93 /**
94 * Reboot the system.
95 *
96 * This method directly reboot the system without user's confirmation.
97 * Ordinary applications should avoid calling this method. Please call
98 * RequestReboot() to ask the user to decide reboot or not.
99 */
100 Q_SCRIPTABLE void Reboot();
102 /**
103 * Shutdown the system.
104 *
105 * This method directly shutdown the system without user's confirmation.
106 * Ordinary applications should avoid calling this method. Please call
107 * RequestShutdown() to ask the user to decide shutdown or not.
108 */
109 Q_SCRIPTABLE void Shutdown();
111 /**
112 * Issue a logout request.
113 *
114 * This method emit the logoutRequested signal to the shell with a boolean
115 * which indicates if there's any inhibitors. The shell should receive
116 * this signal and display a dialog to ask the user to confirm the logout
117 * action. If confirmed, shell can call Logout() method to logout.
118 */
119 Q_SCRIPTABLE void RequestLogout();
121 /**
122 * Issue a reboot request.
123 *
124 * This method emit the rebootRequested signal to the shell with a boolean
125 * which indicates if there's any inhibitors. The shell should receive
126 * this signal and display a dialog to ask the user to confirm the reboot
127 * action. If confirmed, shell can call Reboot() method to reboot
128 */
129 Q_SCRIPTABLE void RequestReboot();
131 /**
132 * Issue a shutdown request.
133 *
134 * This method emit the shutdownRequested signal to the shell with a
135 * boolean which indicates if there's any inhibitors.
136 * The shell should receive
137 * this signal and display a dialog to ask the user to confirm the reboot
138 * action. If confirmed, shell can call Shutdown() method to reboot
139 */
140 Q_SCRIPTABLE void RequestShutdown();
142};
144#endif // DBUSUNITYSESSIONSERVICE_H