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.
Revision history for this message
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)
Revision history for this message
Andrea Cimitan (cimi) wrote :

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

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :
review: Needs Information
Revision history for this message
Albert Astals Cid (aacid) wrote :

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

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

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

No.

Revision history for this message
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
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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
Revision history for this message
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.

Revision history for this message
Albert Astals Cid (aacid) :
review: Abstain
Revision history for this message
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
Revision history for this message
Michał Sawicz (saviq) wrote :

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

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

As Michał says it does not compile

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~paulliu/unity8/logout updated
842. By Ying-Chun Liu

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.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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

Fix FTBFS

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

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

review: Abstain
Revision history for this message
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

remove generated seq number in header.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~paulliu/unity8/logout updated
845. By Ying-Chun Liu

Rename destination.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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.

Revision history for this message
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

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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?

Revision history for this message
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

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

Revision history for this message
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
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
lp:~paulliu/unity8/logout updated
847. By Ying-Chun Liu

Add dbus interface test.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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

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)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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 :/

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
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.

Revision history for this message
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

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)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :
Revision history for this message
Albert Astals Cid (aacid) wrote :

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

lp:~paulliu/unity8/logout updated
850. By Ying-Chun Liu

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

Remove unnecessary lines

852. By Ying-Chun Liu

clean CMakefile.txt again

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

looks ok now.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~paulliu/unity8/logout updated
853. By Ying-Chun Liu

Add back quit signal connect.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Yup.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/Unity/CMakeLists.txt'
--- plugins/Unity/CMakeLists.txt 2013-11-25 11:27:16 +0000
+++ plugins/Unity/CMakeLists.txt 2014-06-20 17:04:32 +0000
@@ -1,2 +1,3 @@
1add_subdirectory(Indicators)1add_subdirectory(Indicators)
2add_subdirectory(Launcher)2add_subdirectory(Launcher)
3add_subdirectory(Session)
34
=== added directory 'plugins/Unity/Session'
=== added file 'plugins/Unity/Session/CMakeLists.txt'
--- plugins/Unity/Session/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Session/CMakeLists.txt 2014-06-20 17:04:32 +0000
@@ -0,0 +1,17 @@
1include_directories(
2 ${CMAKE_CURRENT_SOURCE_DIR}
3)
4
5set(QMLSESSIONPLUGIN_SRC
6 plugin.cpp
7 dbusunitysessionservice.cpp
8 )
9
10add_library(UnitySession-qml MODULE
11 ${QMLSESSIONPLUGIN_SRC}
12 )
13
14qt5_use_modules(UnitySession-qml DBus Qml)
15
16# export the qmldir and qmltypes files
17add_unity8_plugin(Unity.Session 0.1 Unity/Session TARGETS UnitySession-qml)
018
=== added file 'plugins/Unity/Session/dbusunitysessionservice.cpp'
--- plugins/Unity/Session/dbusunitysessionservice.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Session/dbusunitysessionservice.cpp 2014-06-20 17:04:32 +0000
@@ -0,0 +1,46 @@
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 */
16
17// local
18#include "dbusunitysessionservice.h"
19
20// Qt
21#include <QDBusConnection>
22
23DBusUnitySessionService::DBusUnitySessionService() : QObject()
24{
25 QDBusConnection connection = QDBusConnection::sessionBus();
26
27 connection.registerService("com.canonical.Unity");
28 connection.registerObject("/com/canonical/Unity/Session", this,
29 QDBusConnection::ExportScriptableSignals
30 | QDBusConnection::ExportScriptableSlots
31 | QDBusConnection::ExportScriptableInvokables);
32}
33
34DBusUnitySessionService::~DBusUnitySessionService()
35{
36}
37
38void DBusUnitySessionService::Logout()
39{
40 Q_EMIT logoutReady();
41}
42
43void DBusUnitySessionService::RequestLogout()
44{
45 Q_EMIT logoutRequested(false);
46}
047
=== added file 'plugins/Unity/Session/dbusunitysessionservice.h'
--- plugins/Unity/Session/dbusunitysessionservice.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Session/dbusunitysessionservice.h 2014-06-20 17:04:32 +0000
@@ -0,0 +1,82 @@
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 */
16
17#ifndef DBUSUNITYSESSIONSERVICE_H
18#define DBUSUNITYSESSIONSERVICE_H
19
20#include <QObject>
21
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 QObject
30{
31 Q_OBJECT
32 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity.Session")
33
34public:
35 DBusUnitySessionService();
36 ~DBusUnitySessionService();
37
38Q_SIGNALS:
39 /**
40 * logoutRequested signal
41 *
42 * This signal is emitted when some applications request the system to
43 * logout.
44 * @param have_inhibitors if there are any special running applications
45 * which inhibit the logout.
46 */
47 void logoutRequested(bool have_inhibitors);
48
49 /**
50 * logoutReady signal
51 *
52 * This signal is emitted when all the apps are closed. And the system
53 * is safe to logout.
54 */
55 void logoutReady();
56
57public Q_SLOTS:
58 /**
59 * Logout the system.
60 *
61 * This method directly logout the system without user's confirmation.
62 * Ordinary applications should avoid calling this method. Please call
63 * RequestLogout() to ask the user to decide logout or not.
64 * This method will stop all the running applications and then signal
65 * logoutReady when all the apps stopped.
66 */
67 Q_SCRIPTABLE void Logout();
68
69 /**
70 * Issue a logout request.
71 *
72 * This method emit the logoutRequested signal to the shell with a boolean
73 * which indicates if there's any inhibitors. The shell should receive
74 * this signal and display a dialog to ask the user to confirm the logout
75 * action. If confirmed, shell can call Logout() method to kill the apps
76 * and then logout
77 */
78 Q_SCRIPTABLE void RequestLogout();
79
80};
81
82#endif // DBUSUNITYSESSIONSERVICE_H
083
=== added file 'plugins/Unity/Session/plugin.cpp'
--- plugins/Unity/Session/plugin.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Session/plugin.cpp 2014-06-20 17:04:32 +0000
@@ -0,0 +1,40 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
17 */
18
19#include "plugin.h"
20#include "dbusunitysessionservice.h"
21
22#include <QAbstractItemModel>
23#include <QDBusConnection>
24#include <QtQml/qqml.h>
25
26static QObject *dbusunitysessionservice_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
27{
28 Q_UNUSED(engine)
29 Q_UNUSED(scriptEngine)
30
31 return new DBusUnitySessionService();
32}
33
34void SessionPlugin::registerTypes(const char *uri)
35{
36 qmlRegisterType<QAbstractItemModel>();
37
38 Q_ASSERT(uri == QLatin1String("Unity.Session"));
39 qmlRegisterSingletonType<DBusUnitySessionService>(uri, 0, 1, "DBusUnitySessionService", dbusunitysessionservice_provider);
40}
041
=== added file 'plugins/Unity/Session/plugin.h'
--- plugins/Unity/Session/plugin.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Session/plugin.h 2014-06-20 17:04:32 +0000
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors: Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
17 */
18
19#ifndef SESSION_PLUGIN_H
20#define SESSION_PLUGIN_H
21
22#include <QtQml/QQmlEngine>
23#include <QtQml/QQmlExtensionPlugin>
24
25class SessionPlugin : public QQmlExtensionPlugin
26{
27 Q_OBJECT
28 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29
30public:
31 void registerTypes(const char *uri);
32};
33
34#endif
035
=== added file 'plugins/Unity/Session/qmldir'
--- plugins/Unity/Session/qmldir 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Session/qmldir 2014-06-20 17:04:32 +0000
@@ -0,0 +1,3 @@
1module Unity.Session
2plugin UnitySession-qml
3typeinfo UnitySession.qmltypes
04
=== modified file 'qml/Shell.qml'
--- qml/Shell.qml 2014-06-11 15:36:51 +0000
+++ qml/Shell.qml 2014-06-20 17:04:32 +0000
@@ -31,6 +31,7 @@
31import "Components"31import "Components"
32import "Notifications"32import "Notifications"
33import Unity.Notifications 1.0 as NotificationBackend33import Unity.Notifications 1.0 as NotificationBackend
34import Unity.Session 0.1
3435
35FocusScope {36FocusScope {
36 id: shell37 id: shell
@@ -267,6 +268,30 @@
267 }268 }
268 }269 }
269270
271 Connections {
272 target: DBusUnitySessionService
273
274 function closeAllApps() {
275 while (true) {
276 var app = ApplicationManager.get(0);
277 if (app === null) {
278 break;
279 }
280 ApplicationManager.stopApplication(app.appId);
281 }
282 }
283
284 onLogoutRequested: {
285 // TODO: Display a dialog to ask the user to confirm.
286 DBusUnitySessionService.Logout();
287 }
288
289 onLogoutReady: {
290 closeAllApps();
291 Qt.quit();
292 }
293 }
294
270 Loader {295 Loader {
271 id: applicationsDisplayLoader296 id: applicationsDisplayLoader
272 anchors.fill: parent297 anchors.fill: parent
273298
=== modified file 'src/main.cpp'
--- src/main.cpp 2014-06-11 15:36:51 +0000
+++ src/main.cpp 2014-06-20 17:04:32 +0000
@@ -161,6 +161,7 @@
161161
162 view->setSource(source);162 view->setSource(source);
163 view->setColor("transparent");163 view->setColor("transparent");
164 QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
164165
165 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || parser.isSet(fullscreenOption)) {166 if (qgetenv("QT_QPA_PLATFORM") == "ubuntu" || isUbuntuMirServer || parser.isSet(fullscreenOption)) {
166 view->showFullScreen();167 view->showFullScreen();
167168
=== modified file 'tests/plugins/Unity/CMakeLists.txt'
--- tests/plugins/Unity/CMakeLists.txt 2013-11-12 18:21:40 +0000
+++ tests/plugins/Unity/CMakeLists.txt 2014-06-20 17:04:32 +0000
@@ -1,2 +1,3 @@
1add_subdirectory(Indicators)1add_subdirectory(Indicators)
2add_subdirectory(Launcher)2add_subdirectory(Launcher)
3add_subdirectory(Session)
34
=== added directory 'tests/plugins/Unity/Session'
=== added file 'tests/plugins/Unity/Session/CMakeLists.txt'
--- tests/plugins/Unity/Session/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ tests/plugins/Unity/Session/CMakeLists.txt 2014-06-20 17:04:32 +0000
@@ -0,0 +1,20 @@
1include_directories(
2 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session
4)
5
6add_definitions(-DSM_BUSNAME=sessionBus)
7add_definitions(-DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
8add_definitions(-DSESSION_TESTING)
9
10### SessionBackendTest
11set(testBackendCommand dbus-test-runner --task ${CMAKE_CURRENT_BINARY_DIR}/sessionbackendtestExec
12 --parameter -o --parameter ${CMAKE_BINARY_DIR}/sessionbackendtest.xml,xunitxml
13 --parameter -o --parameter -,txt)
14add_test(NAME sessionbackendtest COMMAND ${testBackendCommand})
15add_custom_target(sessionbackendtest ${testBackendCommand})
16add_executable(sessionbackendtestExec
17 sessionbackendtest.cpp
18 ${CMAKE_SOURCE_DIR}/plugins/Unity/Session/dbusunitysessionservice.cpp
19)
20qt5_use_modules(sessionbackendtestExec Test Core Qml DBus)
021
=== added file 'tests/plugins/Unity/Session/sessionbackendtest.cpp'
--- tests/plugins/Unity/Session/sessionbackendtest.cpp 1970-01-01 00:00:00 +0000
+++ tests/plugins/Unity/Session/sessionbackendtest.cpp 2014-06-20 17:04:32 +0000
@@ -0,0 +1,64 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU 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 *
16 * Authors:
17 * Ying-Chun Liu (PaulLiu) <paul.liu@canonical.com>
18 */
19
20#include <QtTest>
21#include <QDBusConnection>
22#include <QDBusMessage>
23#include <QDBusInterface>
24#include <QDBusReply>
25#include <QDBusVariant>
26
27#include "dbusunitysessionservice.h"
28
29class SessionBackendTest : public QObject
30{
31 Q_OBJECT
32
33private Q_SLOTS:
34
35 void initTestCase() {
36 }
37
38 void testDbusIfaceMethods_data() {
39 QTest::addColumn<QString>("method");
40
41 QTest::newRow("Logout") << "RequestLogout";
42 }
43
44 void testDbusIfaceMethods() {
45 QFETCH(QString, method);
46
47 DBusUnitySessionService dbusUnitySessionService;
48
49 QDBusConnection con = QDBusConnection::sessionBus();
50 QDBusInterface interface ("com.canonical.Unity",
51 "/com/canonical/Unity/Session",
52 "com.canonical.Unity.Session",
53 con);
54 QDBusReply<void> reply;
55
56 QCOMPARE(interface.isValid(), true);
57 reply = interface.call(method);
58 QCOMPARE(reply.isValid(), true);
59
60 }
61};
62
63QTEST_GUILESS_MAIN(SessionBackendTest)
64#include "sessionbackendtest.moc"

Subscribers

People subscribed via source and target branches