Merge lp:~paulliu/unity8/logout into lp:unity8

Proposed by Ying-Chun Liu
Status: Merged
Approved by: Michał Sawicz
Approved revision: 853
Merged at revision: 983
Proposed branch: lp:~paulliu/unity8/logout
Merge into: lp:unity8
Diff against target: 418 lines (+334/-0)
12 files modified
plugins/Unity/CMakeLists.txt (+1/-0)
plugins/Unity/Session/CMakeLists.txt (+17/-0)
plugins/Unity/Session/dbusunitysessionservice.cpp (+46/-0)
plugins/Unity/Session/dbusunitysessionservice.h (+82/-0)
plugins/Unity/Session/plugin.cpp (+40/-0)
plugins/Unity/Session/plugin.h (+34/-0)
plugins/Unity/Session/qmldir (+3/-0)
qml/Shell.qml (+25/-0)
src/main.cpp (+1/-0)
tests/plugins/Unity/CMakeLists.txt (+1/-0)
tests/plugins/Unity/Session/CMakeLists.txt (+20/-0)
tests/plugins/Unity/Session/sessionbackendtest.cpp (+64/-0)
To merge this branch: bzr merge lp:~paulliu/unity8/logout
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Daniel d'Andrada (community) Approve
Albert Astals Cid (community) Needs Fixing
Review via email: mp+216373@code.launchpad.net

Commit message

Add logout support.

Reviewed by: Daniel d'Andrada

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
https://code.launchpad.net/~aacid/unity8-desktop-session/fix_logout/+merge/221905
https://code.launchpad.net/~charlesk/indicator-session/lp-1296814-logout-using-unity-session/+merge/221378

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

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:835
http://jenkins.qa.ubuntu.com/job/unity8-ci/2847/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-trusty-touch/323
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4939/console
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1711
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/1368
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1372
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1372/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/1368
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/298
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4526
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4526/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/6178
    FAILURE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/4259/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5095
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/5095/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2847/rebuild

review: Needs Fixing (continuous-integration)
Andrea Cimitan (cimi) wrote :

It's fine on unity8 side, shall we add an autopilot test for it?

Albert Astals Cid (aacid) wrote :
review: Needs Information
Albert Astals Cid (aacid) wrote :

Do we need/use DBusUnitySessionService(QObject *parent) somewhere?

Daniel d'Andrada (dandrader) wrote :

> Does this code still need https://code.launchpad.net/~paulliu/unity-
> mir/logout/+merge/216336 ?

No.

Daniel d'Andrada (dandrader) wrote :

Please take that line out the beginning of all files.

/* -*- mode: c++; indent-tabs-mode: nil; tab-width: 4 -*- */

review: Needs Fixing
Daniel d'Andrada (dandrader) wrote :

Code looks ok.

Just some minor things that could be improved, but nothing blocker:

291 + onLogoutReady: {
292 + // close all the apps.
293 + while (true) {
294 + var app = ApplicationManager.get(0);
295 + if (app === null) {
296 + break;
297 + }
298 + ApplicationManager.stopApplication(app.appId);
299 + }

To keep things more organized, you could put that code in a helper function, like this:

"""
Connections {
   function closeAllApps() {
      ...
   }
   onLogoutReady: {
      closeAllApps();
      Qt.quit();
   }
}
"""

As a rule of thumb, when a block of code requires a comment explaining what it does, it usually means that it's doing a well defined task that could therefore be put into a separate function.

---------------------------------

218 + qmlRegisterSingletonType<DBusUnitySessionService>(uri, 0, 1, "DBusUnitySessionService", dbusunitysessionservice_provider);

That line is too long. Please break it.

review: Approve
Daniel d'Andrada (dandrader) wrote :

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

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

No. Look's like there's something broken in Jenkins.

Albert Astals Cid (aacid) :
review: Abstain
Michał Sawicz (saviq) wrote :

Please strip tags:

http://people.canonical.com/~msawicz/unity8/strip-u8-tags.sh

Locally, and remotely, and don't push/pull until both are cleared.

review: Needs Fixing
Michał Sawicz (saviq) wrote :

Hey, you need to rebase on trunk, it doesn't compile now.

Albert Astals Cid (aacid) wrote :

As Michał says it does not compile

review: Needs Fixing
lp:~paulliu/unity8/logout updated
842. By Ying-Chun Liu on 2014-05-19

Merged upstream again.

[ Michal Hruby ]
* Updated scope tool to create proper config files after recent
  libunity-scopes-api changes.
[ Michał Sawicz ]
* Refactor export_qmlfiles and export_qmlplugins to be more generic
  and clean up installed mocks.
[ Albert Astals ]
* Remove empty dirs
* Set the tabbarmodel index as we do on real code It works better :D
  (LP: #1317255)
[ Thomi Richards ]
* Use new import location for ProcessSearchError in process_helpers
  script.
[ Andrea Cimitan ]
* Adds shadow for the carousel
[ Daniel d'Andrada ]
* Remove Revealer component It's not used anywhere anymore. It's been
  replaced by DragHandle.
[ Andy Doan ]
* unlock_device: support more complex reboot/wait cycles Currently
  this script only allows you to override how to "wait" on the device.
  This changes the logic to also support how you go about rebooting
  the device. This is handy for the ubuntu-emulator because adb-reboot
  is not currently supported. However, we also have a more
  sophisticated, fool-proof way we reboot/wait in the CI lab that
  would be nice to take advantage of:
  http://bazaar.launchpad.net/~ubuntu-test-case-dev/ubuntu-test-
  cases/touch/view/head:/scripts/reboot-and-wait
[ CI bot ]
* Resync trunk
[ Michael Zanetti ]
* support appid:// entries in gsettings schema and make
  findDesktopFile work with short-appid (LP: #1239750)
[ Antti Kaijanmäki ]
* Indicators/RootActionState: use g_variant_iter_loop to extract
  icons.

Michał Sawicz (saviq) wrote :

Still doesn't compile. The CMake module got renamed to "QmlPlugins" and it got refactored - you need to adapt to it, see:

https://code.launchpad.net/~saviq/unity8/cmake-plugin-cleanup/+merge/218171

review: Needs Fixing
lp:~paulliu/unity8/logout updated
843. By Ying-Chun Liu on 2014-05-20

Fix FTBFS

Albert Astals Cid (aacid) wrote :

This should be tested by someone that can get the unity8 session to work on their desktop

review: Abstain
Ying-Chun Liu (paulliu) wrote :

We can also test this on phone or run.sh by manually using qdbus after attaching to session dbus.
But the full story would be start from the indicator. I'll find someone can review this.

lp:~paulliu/unity8/logout updated
844. By Ying-Chun Liu on 2014-05-26

remove generated seq number in header.

lp:~paulliu/unity8/logout updated
845. By Ying-Chun Liu on 2014-05-27

Rename destination.

Albert Astals Cid (aacid) wrote :

Finally was able to run this on my machine, seems indicator-session is not calling the dbus api we expect and thus it does not work. Paul is opening a bug against indicator-session about this.

Ying-Chun Liu (paulliu) wrote :

> Finally was able to run this on my machine, seems indicator-session is not
> calling the dbus api we expect and thus it does not work. Paul is opening a
> bug against indicator-session about this.

https://bugs.launchpad.net/ubuntu/+source/indicator-session/+bug/1323992

Daniel d'Andrada (dandrader) wrote :

> Finally was able to run this on my machine, seems indicator-session is not
> calling the dbus api we expect and thus it does not work. Paul is opening a
> bug against indicator-session about this.

But that doesn't stop this MP from getting merged at all. What you should test is if you manually call the D-Bus method (via, eg, dbus-send), unity8 quits.

Albert Astals Cid (aacid) wrote :

Sure, using dbus, unity8 quits.

But to be honest i think we should be able to prove end-to-end that this "works", i.e. the session-indicator properly calls this api (so we make sure we agreed in the dbus api) and quitting gets you back to lightdm (which currently it doesn't, you get stuck on a black screen) before approving this.

Daniel d'Andrada (dandrader) wrote :

> Sure, using dbus, unity8 quits.
>
> But to be honest i think we should be able to prove end-to-end that this
> "works", i.e. the session-indicator properly calls this api (so we make sure
> we agreed in the dbus api) and quitting gets you back to lightdm (which
> currently it doesn't, you get stuck on a black screen) before approving this.

About "getting back to lightdm". So you mean we need the split greeter landed?

Albert Astals Cid (aacid) wrote :

> > Sure, using dbus, unity8 quits.
> >
> > But to be honest i think we should be able to prove end-to-end that this
> > "works", i.e. the session-indicator properly calls this api (so we make sure
> > we agreed in the dbus api) and quitting gets you back to lightdm (which
> > currently it doesn't, you get stuck on a black screen) before approving
> this.
>
> About "getting back to lightdm". So you mean we need the split greeter landed?

No, that's unrelated. It's just that at the moment lightdm is not "realizing" we quit, so we're stuck in a black screen.

lp:~paulliu/unity8/logout updated
846. By Ying-Chun Liu on 2014-05-27

Merge upstream
[ Albert Astals ]
* Use Interface classes from unity-api
[ Ubuntu daily release ]
* New rebuild forced
[ Albert Astals ]
* Use the new displayMargin feature Also port our DashViews to use
  same naming and behaviour + update tests

Albert Astals Cid (aacid) wrote :

The code looks good to me too, waiting for the indicator session bugfix to land to top approve.

review: Approve
lp:~paulliu/unity8/logout updated
847. By Ying-Chun Liu on 2014-05-29

Add dbus interface test.

Albert Astals Cid (aacid) wrote :

Doesn't merge cleanly with master anymore

review: Needs Fixing
lp:~paulliu/unity8/logout updated
848. By Ying-Chun Liu on 2014-06-06

Merge upstream.

[ Michael Terry ]
* Bump version so ubuntu-touch-session can reference this one
[ CI bot ]
* Resync trunk
[ Michał Sawicz ]
* Move env setup past session init in greeter wrapper. (LP: #1325882)
* no change rebuild
* drop dbus-x11 dependency of unity8-greeter, it makes us end up with
  multiple session dbus daemons which breaks many AP tests in the lab
[ Michael Terry ]
* Bump version for Breaks due to unity8-greeter
* In split mode, determine whether the application identifiers in
  AccountsService are click packages or not, so we know the correct
  url prefix to use.
* Start logrotate in the greeter's session.
[ Andrea Cimitan ]
* Passes to make tryCommand -qmljsdebugger=port:3768 to enable
  debug/profiling test apps
* Fixes carousel shadow
[ Michał Sawicz ]
* Use dpkg-architecture, not gcc, to determine the machine triplet.
[ Ying-Chun Liu ]
* Fix ZoomableImage test failure. (LP: #1317254)
[ Albert Astals ]
* We don't need iconutils in this mock
* Don't reserve space for mascot if no mascot is specified (LP:
  #1319343)
* CardHeader is no more, remove stale line in CMakeLists.txt
* GenericScopeViewTest: Wait a bit more Otherwise sometimes we end
  getting up the wrong delegate (maybe one that will be garbage
  collected?) (LP: #1322279)
* Fix crash in organicgridtest
[ Daniel d'Andrada ]
* Remove Shell's underlay background image as it cannot be seen
  anymore Now that the Dash has its own, opaque, background, the
  underlay's background image can no longer be seen. So it's just a
  waste of resources to have it.
[ Michael Terry ]
* Use the same animation when dismissing a greeter slide from the
  launcher as from a normal greeter drag. (LP: #1316513)
[ Michael Zanetti ]
* enhance lockscreen add a retry indication label (e.g. 3 attempts
  left). add an additional label (e.g. phone number for multi sim).
  add a infoPopup (e.g. to display a warning for last retry). add min
  and max limit values. add tests for the above (LP: #1302050)

Albert Astals Cid (aacid) wrote :

I tried this again with silo 13 and https://code.launchpad.net/~aacid/unity8-desktop-session/fix_logout and it did not work :/

Daniel d'Andrada (dandrader) wrote :

+target_link_libraries(UnitySession-qml)

That command doesn't do anything as you're not specifying any library that UnitySession-qml should be linked against.

Daniel d'Andrada (dandrader) wrote :

14 +include(FindPkgConfig)

And this is not being used as well.

review: Needs Fixing
lp:~paulliu/unity8/logout updated
849. By Ying-Chun Liu on 2014-06-11

merge trunk

[ Michał Sawicz ]
* Make lockscreen buttons translatable.
[ Albert Astals ]
* Correctly mark these functions as overrides
* Remove connections to non existant signal
* Better test name
* Improvements for headerless categories LVPWH: No section name -> no
  header LVPWH: New hasSectionHeader context property for delegates
  GSV: Add topMargin if no hasSectionHeader (LP: #1326415)
* Make tryVerticalJournal, tryHorizontalJournal and tryOrganicGrid
  work again
[ Michael Zanetti ]
* Don't crash when we get an invalid app from ApplicationManager (LP:
  #1309162)
[ Andrea Cimitan ]
* Workaround for lp1324159 (LP: #1322233, #1324159)
[ CI bot ]
* Resync trunk
[ Florian Boucault ]
* Application startup: changed splash rectangle to be black instead of
  white and added a neat little animation. (LP: #1124265)

Albert Astals Cid (aacid) wrote :

Text conflict in qml/Shell.qml
1 conflicts encountered.

lp:~paulliu/unity8/logout updated
850. By Ying-Chun Liu on 2014-06-13

Merge trunk

[ Michael Terry ]
* Revert split greeter for now. We will bring it back as an option
  for Desktop, but use a big hammer revert right now to get Touch back
  in shape.
[ CI bot ]
* Fix build problems. Reviewed by: Michael Terry (LP: #1328850)

851. By Ying-Chun Liu on 2014-06-13

Remove unnecessary lines

852. By Ying-Chun Liu on 2014-06-13

clean CMakefile.txt again

Daniel d'Andrada (dandrader) wrote :

looks ok now.

review: Approve
lp:~paulliu/unity8/logout updated
853. By Ying-Chun Liu on 2014-06-20

Add back quit signal connect.

Michał Sawicz (saviq) wrote :

Yup.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/Unity/CMakeLists.txt'
2--- plugins/Unity/CMakeLists.txt 2013-11-25 11:27:16 +0000
3+++ plugins/Unity/CMakeLists.txt 2014-06-20 17:04:32 +0000
4@@ -1,2 +1,3 @@
5 add_subdirectory(Indicators)
6 add_subdirectory(Launcher)
7+add_subdirectory(Session)
8
9=== added directory 'plugins/Unity/Session'
10=== added file 'plugins/Unity/Session/CMakeLists.txt'
11--- plugins/Unity/Session/CMakeLists.txt 1970-01-01 00:00:00 +0000
12+++ plugins/Unity/Session/CMakeLists.txt 2014-06-20 17:04:32 +0000
13@@ -0,0 +1,17 @@
14+include_directories(
15+ ${CMAKE_CURRENT_SOURCE_DIR}
16+)
17+
18+set(QMLSESSIONPLUGIN_SRC
19+ plugin.cpp
20+ dbusunitysessionservice.cpp
21+ )
22+
23+add_library(UnitySession-qml MODULE
24+ ${QMLSESSIONPLUGIN_SRC}
25+ )
26+
27+qt5_use_modules(UnitySession-qml DBus Qml)
28+
29+# export the qmldir and qmltypes files
30+add_unity8_plugin(Unity.Session 0.1 Unity/Session TARGETS UnitySession-qml)
31
32=== added file 'plugins/Unity/Session/dbusunitysessionservice.cpp'
33--- plugins/Unity/Session/dbusunitysessionservice.cpp 1970-01-01 00:00:00 +0000
34+++ plugins/Unity/Session/dbusunitysessionservice.cpp 2014-06-20 17:04:32 +0000
35@@ -0,0 +1,46 @@
36+/*
37+ * Copyright (C) 2014 Canonical, Ltd.
38+ *
39+ * This program is free software: you can redistribute it and/or modify it under
40+ * the terms of the GNU Lesser General Public License version 3, as published by
41+ * the Free Software Foundation.
42+ *
43+ * This program is distributed in the hope that it will be useful, but WITHOUT
44+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
45+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
46+ * Lesser General Public License for more details.
47+ *
48+ * You should have received a copy of the GNU Lesser General Public License
49+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
50+ */
51+
52+// local
53+#include "dbusunitysessionservice.h"
54+
55+// Qt
56+#include <QDBusConnection>
57+
58+DBusUnitySessionService::DBusUnitySessionService() : QObject()
59+{
60+ QDBusConnection connection = QDBusConnection::sessionBus();
61+
62+ connection.registerService("com.canonical.Unity");
63+ connection.registerObject("/com/canonical/Unity/Session", this,
64+ QDBusConnection::ExportScriptableSignals
65+ | QDBusConnection::ExportScriptableSlots
66+ | QDBusConnection::ExportScriptableInvokables);
67+}
68+
69+DBusUnitySessionService::~DBusUnitySessionService()
70+{
71+}
72+
73+void DBusUnitySessionService::Logout()
74+{
75+ Q_EMIT logoutReady();
76+}
77+
78+void DBusUnitySessionService::RequestLogout()
79+{
80+ Q_EMIT logoutRequested(false);
81+}
82
83=== added file 'plugins/Unity/Session/dbusunitysessionservice.h'
84--- plugins/Unity/Session/dbusunitysessionservice.h 1970-01-01 00:00:00 +0000
85+++ plugins/Unity/Session/dbusunitysessionservice.h 2014-06-20 17:04:32 +0000
86@@ -0,0 +1,82 @@
87+/*
88+ * Copyright (C) 2014 Canonical, Ltd.
89+ *
90+ * This program is free software: you can redistribute it and/or modify it under
91+ * the terms of the GNU Lesser General Public License version 3, as published by
92+ * the Free Software Foundation.
93+ *
94+ * This program is distributed in the hope that it will be useful, but WITHOUT
95+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
96+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
97+ * Lesser General Public License for more details.
98+ *
99+ * You should have received a copy of the GNU Lesser General Public License
100+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
101+ */
102+
103+#ifndef DBUSUNITYSESSIONSERVICE_H
104+#define DBUSUNITYSESSIONSERVICE_H
105+
106+#include <QObject>
107+
108+/**
109+ * DBusUnitySessionService provides com.canonical.Unity.Session dbus
110+ * interface.
111+ *
112+ * com.canonical.Unity.Session interface provides public methods
113+ * and signals to handle Logout/Reboot/Shutdown.
114+ */
115+class DBusUnitySessionService : public QObject
116+{
117+ Q_OBJECT
118+ Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")
119+
120+public:
121+ DBusUnitySessionService();
122+ ~DBusUnitySessionService();
123+
124+Q_SIGNALS:
125+ /**
126+ * logoutRequested signal
127+ *
128+ * This signal is emitted when some applications request the system to
129+ * logout.
130+ * @param have_inhibitors if there are any special running applications
131+ * which inhibit the logout.
132+ */
133+ void logoutRequested(bool have_inhibitors);
134+
135+ /**
136+ * logoutReady signal
137+ *
138+ * This signal is emitted when all the apps are closed. And the system
139+ * is safe to logout.
140+ */
141+ void logoutReady();
142+
143+public Q_SLOTS:
144+ /**
145+ * Logout the system.
146+ *
147+ * This method directly logout the system without user's confirmation.
148+ * Ordinary applications should avoid calling this method. Please call
149+ * RequestLogout() to ask the user to decide logout or not.
150+ * This method will stop all the running applications and then signal
151+ * logoutReady when all the apps stopped.
152+ */
153+ Q_SCRIPTABLE void Logout();
154+
155+ /**
156+ * Issue a logout request.
157+ *
158+ * This method emit the logoutRequested signal to the shell with a boolean
159+ * which indicates if there's any inhibitors. The shell should receive
160+ * this signal and display a dialog to ask the user to confirm the logout
161+ * action. If confirmed, shell can call Logout() method to kill the apps
162+ * and then logout
163+ */
164+ Q_SCRIPTABLE void RequestLogout();
165+
166+};
167+
168+#endif // DBUSUNITYSESSIONSERVICE_H
169
170=== added file 'plugins/Unity/Session/plugin.cpp'
171--- plugins/Unity/Session/plugin.cpp 1970-01-01 00:00:00 +0000
172+++ plugins/Unity/Session/plugin.cpp 2014-06-20 17:04:32 +0000
173@@ -0,0 +1,40 @@
174+/*
175+ * Copyright (C) 2014 Canonical, Ltd.
176+ *
177+ * This program is free software; you can redistribute it and/or modify
178+ * it under the terms of the GNU General Public License as published by
179+ * the Free Software Foundation; version 3.
180+ *
181+ * This program is distributed in the hope that it will be useful,
182+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
183+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
184+ * GNU General Public License for more details.
185+ *
186+ * You should have received a copy of the GNU General Public License
187+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
188+ *
189+ * Authors: Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
190+ */
191+
192+#include "plugin.h"
193+#include "dbusunitysessionservice.h"
194+
195+#include <QAbstractItemModel>
196+#include <QDBusConnection>
197+#include <QtQml/qqml.h>
198+
199+static QObject *dbusunitysessionservice_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
200+{
201+ Q_UNUSED(engine)
202+ Q_UNUSED(scriptEngine)
203+
204+ return new DBusUnitySessionService();
205+}
206+
207+void SessionPlugin::registerTypes(const char *uri)
208+{
209+ qmlRegisterType<QAbstractItemModel>();
210+
211+ Q_ASSERT(uri == QLatin1String("Unity.Session"));
212+ qmlRegisterSingletonType<DBusUnitySessionService>(uri, 0, 1, "DBusUnitySessionService", dbusunitysessionservice_provider);
213+}
214
215=== added file 'plugins/Unity/Session/plugin.h'
216--- plugins/Unity/Session/plugin.h 1970-01-01 00:00:00 +0000
217+++ plugins/Unity/Session/plugin.h 2014-06-20 17:04:32 +0000
218@@ -0,0 +1,34 @@
219+/*
220+ * Copyright (C) 2014 Canonical, Ltd.
221+ *
222+ * This program is free software; you can redistribute it and/or modify
223+ * it under the terms of the GNU General Public License as published by
224+ * the Free Software Foundation; version 3.
225+ *
226+ * This program is distributed in the hope that it will be useful,
227+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
228+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
229+ * GNU General Public License for more details.
230+ *
231+ * You should have received a copy of the GNU General Public License
232+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
233+ *
234+ * Authors: Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
235+ */
236+
237+#ifndef SESSION_PLUGIN_H
238+#define SESSION_PLUGIN_H
239+
240+#include <QtQml/QQmlEngine>
241+#include <QtQml/QQmlExtensionPlugin>
242+
243+class SessionPlugin : public QQmlExtensionPlugin
244+{
245+ Q_OBJECT
246+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
247+
248+public:
249+ void registerTypes(const char *uri);
250+};
251+
252+#endif
253
254=== added file 'plugins/Unity/Session/qmldir'
255--- plugins/Unity/Session/qmldir 1970-01-01 00:00:00 +0000
256+++ plugins/Unity/Session/qmldir 2014-06-20 17:04:32 +0000
257@@ -0,0 +1,3 @@
258+module Unity.Session
259+plugin UnitySession-qml
260+typeinfo UnitySession.qmltypes
261
262=== modified file 'qml/Shell.qml'
263--- qml/Shell.qml 2014-06-11 15:36:51 +0000
264+++ qml/Shell.qml 2014-06-20 17:04:32 +0000
265@@ -31,6 +31,7 @@
266 import "Components"
267 import "Notifications"
268 import Unity.Notifications 1.0 as NotificationBackend
269+import Unity.Session 0.1
270
271 FocusScope {
272 id: shell
273@@ -267,6 +268,30 @@
274 }
275 }
276
277+ Connections {
278+ target: DBusUnitySessionService
279+
280+ function closeAllApps() {
281+ while (true) {
282+ var app = ApplicationManager.get(0);
283+ if (app === null) {
284+ break;
285+ }
286+ ApplicationManager.stopApplication(app.appId);
287+ }
288+ }
289+
290+ onLogoutRequested: {
291+ // TODO: Display a dialog to ask the user to confirm.
292+ DBusUnitySessionService.Logout();
293+ }
294+
295+ onLogoutReady: {
296+ closeAllApps();
297+ Qt.quit();
298+ }
299+ }
300+
301 Loader {
302 id: applicationsDisplayLoader
303 anchors.fill: parent
304
305=== modified file 'src/main.cpp'
306--- src/main.cpp 2014-06-11 15:36:51 +0000
307+++ src/main.cpp 2014-06-20 17:04:32 +0000
308@@ -161,6 +161,7 @@
309
310 view->setSource(source);
311 view->setColor("transparent");
312+ QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
313
314 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || parser.isSet(fullscreenOption)) {
315 view->showFullScreen();
316
317=== modified file 'tests/plugins/Unity/CMakeLists.txt'
318--- tests/plugins/Unity/CMakeLists.txt 2013-11-12 18:21:40 +0000
319+++ tests/plugins/Unity/CMakeLists.txt 2014-06-20 17:04:32 +0000
320@@ -1,2 +1,3 @@
321 add_subdirectory(Indicators)
322 add_subdirectory(Launcher)
323+add_subdirectory(Session)
324
325=== added directory 'tests/plugins/Unity/Session'
326=== added file 'tests/plugins/Unity/Session/CMakeLists.txt'
327--- tests/plugins/Unity/Session/CMakeLists.txt 1970-01-01 00:00:00 +0000
328+++ tests/plugins/Unity/Session/CMakeLists.txt 2014-06-20 17:04:32 +0000
329@@ -0,0 +1,20 @@
330+include_directories(
331+ ${CMAKE_CURRENT_BINARY_DIR}
332+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Session
333+)
334+
335+add_definitions(-DSM_BUSNAME=sessionBus)
336+add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
337+add_definitions(-DSESSION_TESTING)
338+
339+### SessionBackendTest
340+set(testBackendCommand dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/sessionbackendtestExec
341+ --parameter -o --parameter ${CMAKE_BINARY_DIR}/sessionbackendtest.xml,xunitxml
342+ --parameter -o --parameter -,txt)
343+add_test(NAME sessionbackendtest COMMAND ${testBackendCommand})
344+add_custom_target(sessionbackendtest ${testBackendCommand})
345+add_executable(sessionbackendtestExec
346+ sessionbackendtest.cpp
347+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Session/dbusunitysessionservice.cpp
348+)
349+qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
350
351=== added file 'tests/plugins/Unity/Session/sessionbackendtest.cpp'
352--- tests/plugins/Unity/Session/sessionbackendtest.cpp 1970-01-01 00:00:00 +0000
353+++ tests/plugins/Unity/Session/sessionbackendtest.cpp 2014-06-20 17:04:32 +0000
354@@ -0,0 +1,64 @@
355+/*
356+ * Copyright 2013 Canonical Ltd.
357+ *
358+ * This program is free software; you can redistribute it and/or modify
359+ * it under the terms of the GNU Lesser General Public License as published by
360+ * the Free Software Foundation; version 3.
361+ *
362+ * This program is distributed in the hope that it will be useful,
363+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
364+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
365+ * GNU Lesser General Public License for more details.
366+ *
367+ * You should have received a copy of the GNU Lesser General Public License
368+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
369+ *
370+ * Authors:
371+ * Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
372+ */
373+
374+#include <QtTest>
375+#include <QDBusConnection>
376+#include <QDBusMessage>
377+#include <QDBusInterface>
378+#include <QDBusReply>
379+#include <QDBusVariant>
380+
381+#include "dbusunitysessionservice.h"
382+
383+class SessionBackendTest : public QObject
384+{
385+ Q_OBJECT
386+
387+private Q_SLOTS:
388+
389+ void initTestCase() {
390+ }
391+
392+ void testDbusIfaceMethods_data() {
393+ QTest::addColumn<QString>("method");
394+
395+ QTest::newRow("Logout") << "RequestLogout";
396+ }
397+
398+ void testDbusIfaceMethods() {
399+ QFETCH(QString, method);
400+
401+ DBusUnitySessionService dbusUnitySessionService;
402+
403+ QDBusConnection con = QDBusConnection::sessionBus();
404+ QDBusInterface interface ("com.canonical.Unity",
405+ "/com/canonical/Unity/Session",
406+ "com.canonical.Unity.Session",
407+ con);
408+ QDBusReply<void> reply;
409+
410+ QCOMPARE(interface.isValid(), true);
411+ reply = interface.call(method);
412+ QCOMPARE(reply.isValid(), true);
413+
414+ }
415+};
416+
417+QTEST_GUILESS_MAIN(SessionBackendTest)
418+#include "sessionbackendtest.moc"

Subscribers

People subscribed via source and target branches