on xenial help sign in
Add a wrapper for handling the /org/gnome/SessionManager/EndSessionDialog DBus object used by indicator-session. This allows indicator-session to properly talk to the Unity 8 session management functions.
commita93817983c663e1c09501ca35582450c7d684cca authorChris Townsend <christopher.townsend@canonical.com> dateFri 30 Jan 2015, 08:55 (12 years ago) parentc780bde
3 files changed+64
plugins/Unity/Session/dbusunitysessionservice.cpp+49 plugins/Unity/Session/dbusunitysessionservice.h+14 plugins/Unity/Session/plugin.cpp+1
plugins/Unity/Session/dbusunitysessionservice.cpp+49
@@ -71,3 +71,52 @@ void DBusUnitySessionService::RequestShutdown()
7171{
7272 Q_EMIT shutdownRequested(false);
7373}
74+
75+enum class Action : unsigned
76+{
77+ LOGOUT = 0,
78+ SHUTDOWN,
79+ REBOOT,
80+ NONE
81+};
82+
83+DBusGnomeSessionManagerWrapper::DBusGnomeSessionManagerWrapper()
84+ : UnityDBusObject("/org/gnome/SessionManager/EndSessionDialog", "com.canonical.Unity")
85+{
86+}
87+
88+DBusGnomeSessionManagerWrapper::~DBusGnomeSessionManagerWrapper()
89+{
90+}
91+
92+void DBusGnomeSessionManagerWrapper::Open(const unsigned type, const unsigned arg_1, const unsigned max_wait, const QList<QDBusObjectPath> &inhibitors)
93+{
94+ Q_UNUSED(arg_1);
95+ Q_UNUSED(max_wait);
96+ Q_UNUSED(inhibitors);
97+
98+ QDBusConnection connection = QDBusConnection::sessionBus();
99+ QDBusInterface iface1 ("com.canonical.Unity",
100+ "/com/canonical/Unity/Session",
101+ "com.canonical.Unity.Session",
102+ connection);
103+
104+ Action action = (Action)type;
105+
106+ switch (action)
107+ {
108+ case Action::LOGOUT:
109+ iface1.call("RequestLogout");
110+ break;
111+
112+ case Action::REBOOT:
113+ iface1.call("RequestShutdown");
114+ break;
115+
116+ case Action::SHUTDOWN:
117+ break;
118+
119+ default:
120+ break;
121+ }
122+}
plugins/Unity/Session/dbusunitysessionservice.h+14
@@ -17,6 +17,8 @@
1717#ifndef DBUSUNITYSESSIONSERVICE_H
1818#define DBUSUNITYSESSIONSERVICE_H
1919
20+#include <QDBusObjectPath>
21+
2022#include "unitydbusobject.h"
2123
2224/**
@@ -141,4 +143,16 @@ public Q_SLOTS:
141143
142144};
143145
146+class DBusGnomeSessionManagerWrapper : public UnityDBusObject
147+{
148+ Q_OBJECT
149+ Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.EndSessionDialog")
150+
151+public:
152+ DBusGnomeSessionManagerWrapper();
153+ ~DBusGnomeSessionManagerWrapper();
154+
155+public Q_SLOTS:
156+ Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);
157+};
144158#endif // DBUSUNITYSESSIONSERVICE_H
plugins/Unity/Session/plugin.cpp+1
@@ -26,6 +26,7 @@
2626
2727static QObject *dbusunitysessionservice_provider(QQmlEngine */*engine*/, QJSEngine */*jsEngine*/)
2828{
29+ new DBusGnomeSessionManagerWrapper();
2930 return new DBusUnitySessionService();
3031}
3132