@@ -0,0 +1,84 @@
1+/* -*- mode: c++; indent-tabs-mode: nil; tab-width: 4 -*- */
2+/*
3+ * Copyright (C) 2014 Canonical, Ltd.
4+ *
5+ * This program is free software: you can redistribute it and/or modify it under
6+ * the terms of the GNU Lesser General Public License version 3, as published by
7+ * the Free Software Foundation.
8+ *
9+ * This program is distributed in the hope that it will be useful, but WITHOUT
10+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
11+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+ * Lesser General Public License for more details.
13+ *
14+ * You should have received a copy of the GNU Lesser General Public License
15+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
16+ */
17+
18+#ifndef DBUSUNITYSESSIONSERVICE_H_1397562297
19+#define DBUSUNITYSESSIONSERVICE_H_1397562297
20+
21+#include <QObject>
22+
23+/**
24+ * DBusUnitySessionService provides com.canonical.Unity.Session dbus
25+ * interface.
26+ *
27+ * com.canonical.Unity.Session interface provides public methods
28+ * and signals to handle Logout/Reboot/Shutdown.
29+ */
30+class DBusUnitySessionService : public QObject
31+{
32+ Q_OBJECT
33+ Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")
34+
35+public:
36+ DBusUnitySessionService();
37+ explicit DBusUnitySessionService(QObject* parent);
38+ ~DBusUnitySessionService();
39+
40+Q_SIGNALS:
41+ /**
42+ * logoutRequested signal
43+ *
44+ * This signal is emitted when some applications request the system to
45+ * logout.
46+ * @param have_inhibitors if there are any special running applications
47+ * which inhibit the logout.
48+ */
49+ void logoutRequested(bool have_inhibitors);
50+
51+ /**
52+ * logoutReady signal
53+ *
54+ * This signal is emitted when all the apps are closed. And the system
55+ * is safe to logout.
56+ */
57+ void logoutReady();
58+
59+public Q_SLOTS:
60+ /**
61+ * Logout the system.
62+ *
63+ * This method directly logout the system without user's confirmation.
64+ * Ordinary applications should avoid calling this method. Please call
65+ * RequestLogout() to ask the user to decide logout or not.
66+ * This method will stop all the running applications and then signal
67+ * logoutReady when all the apps stopped.
68+ */
69+ Q_SCRIPTABLE void Logout();
70+
71+ /**
72+ * Issue a logout request.
73+ *
74+ * This method emit the logoutRequested signal to the shell with a boolean
75+ * which indicates if there's any inhibitors. The shell should receive
76+ * this signal and display a dialog to ask the user to confirm the logout
77+ * action. If confirmed, shell can call Logout() method to kill the apps
78+ * and then logout
79+ */
80+ Q_SCRIPTABLE void RequestLogout();
81+
82+};
83+
84+#endif // DBUSUNITYSESSIONSERVICE_H_1397562297