Merge lp:~mterry/unity8/gnome-session-quit into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 2870
Merged at revision: 2869
Proposed branch: lp:~mterry/unity8/gnome-session-quit
Merge into: lp:unity8
Diff against target: 291 lines (+186/-8)
6 files modified
plugins/Unity/Session/dbusunitysessionservice.cpp (+46/-1)
plugins/Unity/Session/dbusunitysessionservice.h (+18/-4)
tests/plugins/Unity/Session/LogindServer.cpp (+10/-0)
tests/plugins/Unity/Session/LogindServer.h (+5/-0)
tests/plugins/Unity/Session/interfaces.xml (+12/-0)
tests/plugins/Unity/Session/sessionbackendtest.cpp (+95/-3)
To merge this branch: bzr merge lp:~mterry/unity8/gnome-session-quit
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
Unity8 CI Bot continuous-integration Approve
Review via email: mp+319992@code.launchpad.net

Commit message

Support GNOME-style logout DBus API (making the Logout, Reboot, and Shutdown launcher commands work)

Description of the change

As noted in bug 1673229, the launcher items "Logout", "Shutdown", and "Reboot" don't do anything in unity8. They are holdovers from GNOME, making calls to the org.gnome.SessionManager interface.

Despite being old-world commands, it would still be nice if we supported them (and other bits of code in classic Ubuntu might try similar calls to the API). Unity7 supports them. And we support the similar (older?) org.gnome.SessionManager.EndSessionDialog interface. So this is a small change for us.

You can test by logging into deb-based unity8 and running those commands from the launcher. There's still a momentary, jarring splash window created for the command. But that's a separate issue.

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
lp:~mterry/unity8/gnome-session-quit updated
2870. By Michael Terry

Drop extra whitespace

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2870
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3417/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4504
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2708
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2708
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4532
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4359
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4359/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4359
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4359/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4359
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4359/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4359
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4359/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4359
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4359/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4359
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4359/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3417/rebuild

review: Approve (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2870
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3422/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4514
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/2713
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=zesty,testname=qmluitests.sh/2713
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4542
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4368
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4368/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4368
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4368/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4368
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4368/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4368
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4368/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4368
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4368/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4368
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4368/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/3422/rebuild

review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass? If not, please explain why.
Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/Unity/Session/dbusunitysessionservice.cpp'
--- plugins/Unity/Session/dbusunitysessionservice.cpp 2016-12-19 19:55:07 +0000
+++ plugins/Unity/Session/dbusunitysessionservice.cpp 2017-03-16 14:04:06 +0000
@@ -468,11 +468,56 @@
468468
469469
470DBusGnomeSessionManagerWrapper::DBusGnomeSessionManagerWrapper()470DBusGnomeSessionManagerWrapper::DBusGnomeSessionManagerWrapper()
471 : UnityDBusObject(QStringLiteral("/org/gnome/SessionManager"), QStringLiteral("org.gnome.SessionManager"))
472{
473}
474
475void DBusGnomeSessionManagerWrapper::Logout(quint32 mode)
476{
477 auto call = QStringLiteral("RequestLogout");
478
479 // These modes are documented as bitwise flags, not an enum, even though
480 // they only ever seem to be used as enums.
481
482 if (mode & 1) // without dialog
483 call = QStringLiteral("Logout");
484 if (mode & 2) // without dialog, ignoring inhibitors (which we don't have)
485 call = QStringLiteral("Logout");
486
487 performAsyncUnityCall(call);
488}
489
490void DBusGnomeSessionManagerWrapper::Reboot()
491{
492 // GNOME's Reboot means with dialog (they use Request differently than us).
493 performAsyncUnityCall(QStringLiteral("RequestReboot"));
494}
495
496void DBusGnomeSessionManagerWrapper::RequestReboot()
497{
498 // GNOME's RequestReboot means no dialog (they use Request differently than us).
499 performAsyncUnityCall(QStringLiteral("Reboot"));
500}
501
502void DBusGnomeSessionManagerWrapper::RequestShutdown()
503{
504 // GNOME's RequestShutdown means no dialog (they use Request differently than us).
505 performAsyncUnityCall(QStringLiteral("Shutdown"));
506}
507
508void DBusGnomeSessionManagerWrapper::Shutdown()
509{
510 // GNOME's Shutdown means with dialog (they use Request differently than us).
511 performAsyncUnityCall(QStringLiteral("RequestShutdown"));
512}
513
514
515DBusGnomeSessionManagerDialogWrapper::DBusGnomeSessionManagerDialogWrapper()
471 : UnityDBusObject(QStringLiteral("/org/gnome/SessionManager/EndSessionDialog"), QStringLiteral("com.canonical.Unity"))516 : UnityDBusObject(QStringLiteral("/org/gnome/SessionManager/EndSessionDialog"), QStringLiteral("com.canonical.Unity"))
472{517{
473}518}
474519
475void DBusGnomeSessionManagerWrapper::Open(const unsigned type, const unsigned arg_1, const unsigned max_wait, const QList<QDBusObjectPath> &inhibitors)520void DBusGnomeSessionManagerDialogWrapper::Open(const unsigned type, const unsigned arg_1, const unsigned max_wait, const QList<QDBusObjectPath> &inhibitors)
476{521{
477 Q_UNUSED(arg_1);522 Q_UNUSED(arg_1);
478 Q_UNUSED(max_wait);523 Q_UNUSED(max_wait);
479524
=== modified file 'plugins/Unity/Session/dbusunitysessionservice.h'
--- plugins/Unity/Session/dbusunitysessionservice.h 2016-12-19 19:55:07 +0000
+++ plugins/Unity/Session/dbusunitysessionservice.h 2017-03-16 14:04:06 +0000
@@ -270,17 +270,31 @@
270class DBusGnomeSessionManagerWrapper : public UnityDBusObject270class DBusGnomeSessionManagerWrapper : public UnityDBusObject
271{271{
272 Q_OBJECT272 Q_OBJECT
273 Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.EndSessionDialog")273 Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager")
274274
275public:275public:
276 DBusGnomeSessionManagerWrapper();276 DBusGnomeSessionManagerWrapper();
277 ~DBusGnomeSessionManagerWrapper() = default;277 ~DBusGnomeSessionManagerWrapper() = default;
278278
279public Q_SLOTS:279public Q_SLOTS:
280 Q_SCRIPTABLE void Logout(quint32 mode);
281 Q_SCRIPTABLE void Reboot();
282 Q_SCRIPTABLE void RequestReboot();
283 Q_SCRIPTABLE void RequestShutdown();
284 Q_SCRIPTABLE void Shutdown();
285};
286
287class DBusGnomeSessionManagerDialogWrapper : public UnityDBusObject
288{
289 Q_OBJECT
290 Q_CLASSINFO("D-Bus Interface", "org.gnome.SessionManager.EndSessionDialog")
291
292public:
293 DBusGnomeSessionManagerDialogWrapper();
294 ~DBusGnomeSessionManagerDialogWrapper() = default;
295
296public Q_SLOTS:
280 Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);297 Q_SCRIPTABLE void Open(const unsigned int type, const unsigned int arg_1, const unsigned int max_wait, const QList<QDBusObjectPath> &inhibitors);
281
282private:
283 void performAsyncCall(const QString &method);
284};298};
285299
286class DBusGnomeScreensaverWrapper: public UnityDBusObject300class DBusGnomeScreensaverWrapper: public UnityDBusObject
287301
=== modified file 'tests/plugins/Unity/Session/LogindServer.cpp'
--- tests/plugins/Unity/Session/LogindServer.cpp 2016-06-22 13:38:16 +0000
+++ tests/plugins/Unity/Session/LogindServer.cpp 2017-03-16 14:04:06 +0000
@@ -27,6 +27,16 @@
27 return QDBusObjectPath("/logindsession");27 return QDBusObjectPath("/logindsession");
28}28}
2929
30void LogindServer::Reboot(bool interactive)
31{
32 Q_EMIT RebootCalled(interactive);
33}
34
35void LogindServer::PowerOff(bool interactive)
36{
37 Q_EMIT PowerOffCalled(interactive);
38}
39
30void LogindServer::MockEmitUnlock()40void LogindServer::MockEmitUnlock()
31{41{
32 Q_EMIT Unlock();42 Q_EMIT Unlock();
3343
=== modified file 'tests/plugins/Unity/Session/LogindServer.h'
--- tests/plugins/Unity/Session/LogindServer.h 2016-06-22 13:38:16 +0000
+++ tests/plugins/Unity/Session/LogindServer.h 2017-03-16 14:04:06 +0000
@@ -31,6 +31,8 @@
3131
32public Q_SLOTS:32public Q_SLOTS:
33 QDBusObjectPath GetSessionByPID(quint32 pid);33 QDBusObjectPath GetSessionByPID(quint32 pid);
34 void Reboot(bool interactive);
35 void PowerOff(bool interactive);
3436
35 void MockEmitUnlock(); // only in mock37 void MockEmitUnlock(); // only in mock
3638
@@ -38,6 +40,9 @@
38 void Lock();40 void Lock();
39 void Unlock();41 void Unlock();
40 void PrepareForSleep();42 void PrepareForSleep();
43
44 void RebootCalled(bool interactive); // only in mock
45 void PowerOffCalled(bool interactive); // only in mock
41};46};
4247
43#endif48#endif
4449
=== modified file 'tests/plugins/Unity/Session/interfaces.xml'
--- tests/plugins/Unity/Session/interfaces.xml 2016-06-22 13:38:16 +0000
+++ tests/plugins/Unity/Session/interfaces.xml 2017-03-16 14:04:06 +0000
@@ -7,6 +7,18 @@
7 <arg name="pid" type="u" direction="in" />7 <arg name="pid" type="u" direction="in" />
8 <arg name="session" type="o" direction="out" />8 <arg name="session" type="o" direction="out" />
9 </method>9 </method>
10 <method name="Reboot">
11 <arg name="interactive" type="b" direction="in" />
12 </method>
13 <method name="PowerOff">
14 <arg name="interactive" type="b" direction="in" />
15 </method>
16 <signal name="RebootCalled">
17 <arg name="interactive" type="b" direction="out" />
18 </signal>
19 <signal name="PowerOffCalled">
20 <arg name="interactive" type="b" direction="out" />
21 </signal>
10 <signal name="PrepareForSleep" />22 <signal name="PrepareForSleep" />
11 </interface>23 </interface>
12 <interface name="org.freedesktop.login1.Session">24 <interface name="org.freedesktop.login1.Session">
1325
=== modified file 'tests/plugins/Unity/Session/sessionbackendtest.cpp'
--- tests/plugins/Unity/Session/sessionbackendtest.cpp 2016-12-19 19:55:07 +0000
+++ tests/plugins/Unity/Session/sessionbackendtest.cpp 2017-03-16 14:04:06 +0000
@@ -81,7 +81,99 @@
81 QTRY_COMPARE(spy.count(), 1);81 QTRY_COMPARE(spy.count(), 1);
82 }82 }
8383
84 void testGnomeSessionWrapper_data() {84 void testGnomeSessionWrapperWithoutConfirmation_data() {
85 QTest::addColumn<QString>("method");
86 QTest::addColumn<QString>("signal");
87
88 QTest::newRow("Reboot") << "RequestReboot" << SIGNAL(RebootCalled(bool));
89 QTest::newRow("Shutdown") << "RequestShutdown" << SIGNAL(PowerOffCalled(bool));
90 }
91
92 void testGnomeSessionWrapperWithoutConfirmation() {
93 QFETCH(QString, method);
94 QFETCH(QString, signal);
95
96 DBusUnitySessionService dbusUnitySessionService;
97 DBusGnomeSessionManagerWrapper dbusGnomeSessionManagerWrapper;
98 QCoreApplication::processEvents(); // to let the services register on DBus
99
100 QDBusInterface login1Interface("org.freedesktop.login1",
101 "/logindsession",
102 "org.freedesktop.login1.Manager");
103 QSignalSpy spy(&login1Interface, signal.toUtf8().data());
104
105 QDBusInterface dbusGnomeSessionWrapper("org.gnome.SessionManager",
106 "/org/gnome/SessionManager",
107 "org.gnome.SessionManager",
108 QDBusConnection::sessionBus());
109 QVERIFY(dbusGnomeSessionWrapper.isValid());
110
111 QDBusReply<void> reply = dbusGnomeSessionWrapper.call(method);
112 QVERIFY(reply.isValid());
113 QTRY_COMPARE(spy.count(), 1);
114 }
115
116 void testGnomeSessionWrapperWithConfirmation_data() {
117 QTest::addColumn<QString>("method");
118 QTest::addColumn<QString>("signal");
119
120 QTest::newRow("Reboot") << "Reboot" << SIGNAL(RebootRequested(bool));
121 QTest::newRow("Shutdown") << "Shutdown" << SIGNAL(ShutdownRequested(bool));
122 }
123
124 void testGnomeSessionWrapperWithConfirmation() {
125 QFETCH(QString, method);
126 QFETCH(QString, signal);
127
128 DBusUnitySessionService dbusUnitySessionService;
129 DBusGnomeSessionManagerWrapper dbusGnomeSessionManagerWrapper;
130 QCoreApplication::processEvents(); // to let the services register on DBus
131
132 QSignalSpy spy(&dbusUnitySessionService, signal.toUtf8().data());
133
134 QDBusInterface dbusGnomeSessionWrapper("org.gnome.SessionManager",
135 "/org/gnome/SessionManager",
136 "org.gnome.SessionManager",
137 QDBusConnection::sessionBus());
138 QVERIFY(dbusGnomeSessionWrapper.isValid());
139
140 QDBusReply<void> reply = dbusGnomeSessionWrapper.call(method);
141 QVERIFY(reply.isValid());
142 QCOMPARE(spy.count(), 1);
143 }
144
145 void testGnomeSessionWrapperLogout_data() {
146 QTest::addColumn<int>("mode");
147 QTest::addColumn<QString>("signal");
148
149 QTest::newRow("Logout") << 0 << SIGNAL(LogoutRequested(bool));
150 QTest::newRow("LogoutNoDialog") << 1 << SIGNAL(LogoutReady());
151 QTest::newRow("LogoutNoInhibits") << 2 << SIGNAL(LogoutReady());
152 QTest::newRow("LogoutNoDialogNoInhibits") << 3 << SIGNAL(LogoutReady());
153 }
154
155 void testGnomeSessionWrapperLogout() {
156 QFETCH(int, mode);
157 QFETCH(QString, signal);
158
159 DBusUnitySessionService dbusUnitySessionService;
160 DBusGnomeSessionManagerWrapper dbusGnomeSessionManagerWrapper;
161 QCoreApplication::processEvents(); // to let the services register on DBus
162
163 QSignalSpy spy(&dbusUnitySessionService, signal.toUtf8().data());
164
165 QDBusInterface dbusGnomeSessionWrapper("org.gnome.SessionManager",
166 "/org/gnome/SessionManager",
167 "org.gnome.SessionManager",
168 QDBusConnection::sessionBus());
169 QVERIFY(dbusGnomeSessionWrapper.isValid());
170
171 QDBusReply<void> reply = dbusGnomeSessionWrapper.call("Logout", (quint32)mode);
172 QVERIFY(reply.isValid());
173 QCOMPARE(spy.count(), 1);
174 }
175
176 void testGnomeSessionDialogWrapper_data() {
85 QTest::addColumn<uint>("method");177 QTest::addColumn<uint>("method");
86 QTest::addColumn<QString>("signal");178 QTest::addColumn<QString>("signal");
87179
@@ -90,7 +182,7 @@
90 QTest::newRow("Reboot") << (uint)Action::REBOOT << "RebootRequested(bool)";182 QTest::newRow("Reboot") << (uint)Action::REBOOT << "RebootRequested(bool)";
91 }183 }
92184
93 void testGnomeSessionWrapper() {185 void testGnomeSessionDialogWrapper() {
94 QFETCH(uint, method);186 QFETCH(uint, method);
95 QFETCH(QString, signal);187 QFETCH(QString, signal);
96188
@@ -102,7 +194,7 @@
102 // .. because QSignalSpy checks the signal signature like this: "if (((aSignal[0] - '0') & 0x03) != QSIGNAL_CODE)"194 // .. because QSignalSpy checks the signal signature like this: "if (((aSignal[0] - '0') & 0x03) != QSIGNAL_CODE)"
103 QSignalSpy spy(&dbusUnitySessionService, qPrintable(signal.prepend(QSIGNAL_CODE)));195 QSignalSpy spy(&dbusUnitySessionService, qPrintable(signal.prepend(QSIGNAL_CODE)));
104196
105 DBusGnomeSessionManagerWrapper dbusGnomeSessionManagerWrapper;197 DBusGnomeSessionManagerDialogWrapper dbusGnomeSessionManagerDialogWrapper;
106 QCoreApplication::processEvents(); // to let the service register on DBus198 QCoreApplication::processEvents(); // to let the service register on DBus
107199
108 QDBusInterface dbusGnomeSessionWrapper("com.canonical.Unity",200 QDBusInterface dbusGnomeSessionWrapper("com.canonical.Unity",

Subscribers

People subscribed via source and target branches