Merge lp:~josharenson/unity8/fix-session-icon into lp:unity8

Proposed by Josh Arenson
Status: Superseded
Proposed branch: lp:~josharenson/unity8/fix-session-icon
Merge into: lp:unity8
Diff against target: 6015 lines (+948/-3202)
106 files modified
CMakeLists.txt (+1/-0)
cmake/modules/QmlTest.cmake (+3/-3)
data/unity8.conf (+12/-12)
debian/rules (+0/-5)
plugins/AccountsService/AccountsService.cpp (+27/-1)
plugins/AccountsService/AccountsService.h (+8/-0)
plugins/LightDM/CMakeLists.txt (+16/-9)
plugins/LightDM/FullLightDM/CMakeLists.txt (+0/-28)
plugins/LightDM/Greeter.cpp (+7/-1)
plugins/LightDM/Greeter.h (+5/-1)
plugins/LightDM/IntegratedLightDM/CMakeLists.txt (+0/-33)
plugins/LightDM/IntegratedLightDM/QLightDM/Greeter (+0/-17)
plugins/LightDM/IntegratedLightDM/QLightDM/SessionsModel (+0/-17)
plugins/LightDM/IntegratedLightDM/QLightDM/UsersModel (+0/-17)
plugins/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt (+0/-55)
plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp (+0/-179)
plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.h (+0/-108)
plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp (+0/-304)
plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h (+0/-51)
plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp (+0/-88)
plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h (+0/-72)
plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp (+0/-36)
plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h (+0/-54)
plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp (+0/-110)
plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.h (+0/-67)
plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp (+0/-94)
plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h (+0/-72)
plugins/LightDM/IntegratedLightDM/qmldir (+0/-3)
plugins/LightDM/SessionsModel.cpp (+6/-2)
plugins/LightDM/SessionsModel.h (+7/-1)
plugins/LightDM/UsersModel.cpp (+8/-1)
plugins/LightDM/UsersModel.h (+4/-0)
plugins/LightDM/plugin.cpp (+2/-9)
plugins/LightDM/plugin.h (+1/-1)
plugins/LightDM/qmldir (+2/-3)
plugins/Unity/Session/dbusunitysessionservice.cpp (+3/-45)
plugins/Unity/Session/dbusunitysessionservice.h (+0/-3)
qml/Components/Dialogs.qml (+4/-4)
qml/Greeter/FullLightDMImpl.qml (+0/-30)
qml/Greeter/Greeter.qml (+36/-36)
qml/Greeter/IntegratedLightDMImpl.qml (+0/-29)
qml/Greeter/LightDMService.qml (+0/-54)
qml/Greeter/LoginList.qml (+7/-7)
qml/Greeter/NarrowView.qml (+1/-1)
qml/Greeter/SessionsList.qml (+4/-4)
qml/Greeter/WideView.qml (+10/-3)
qml/Greeter/qmldir (+0/-1)
qml/Shell.qml (+9/-2)
tests/CMakeLists.txt (+1/-1)
tests/autopilot/unity8/fixture_setup.py (+1/-1)
tests/autopilot/unity8/shell/tests/__init__.py (+1/-1)
tests/mocks/AccountsService/AccountsService.cpp (+17/-3)
tests/mocks/AccountsService/AccountsService.h (+10/-2)
tests/mocks/AccountsService/CMakeLists.txt (+6/-2)
tests/mocks/CMakeLists.txt (+1/-1)
tests/mocks/LightDM/CMakeLists.txt (+0/-1)
tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt (+0/-51)
tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp (+0/-51)
tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h (+0/-42)
tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp (+0/-66)
tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h (+0/-44)
tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp (+0/-44)
tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h (+0/-39)
tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter (+0/-17)
tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel (+0/-17)
tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel (+0/-17)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp (+0/-132)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h (+0/-54)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp (+0/-83)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h (+0/-63)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp (+0/-124)
tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h (+0/-64)
tests/mocks/LightDM/IntegratedLightDM/plugin.cpp (+0/-79)
tests/mocks/LightDM/IntegratedLightDM/plugin.h (+0/-32)
tests/mocks/LightDM/IntegratedLightDM/qmldir (+0/-2)
tests/mocks/liblightdm/CMakeLists.txt (+10/-12)
tests/mocks/liblightdm/MockController.cpp (+148/-0)
tests/mocks/liblightdm/MockController.h (+98/-0)
tests/mocks/liblightdm/MockGreeter.cpp (+88/-33)
tests/mocks/liblightdm/MockGreeter.h (+9/-15)
tests/mocks/liblightdm/MockSessionsModel.cpp (+49/-48)
tests/mocks/liblightdm/MockSessionsModel.h (+11/-12)
tests/mocks/liblightdm/MockUsersModel.cpp (+108/-23)
tests/mocks/liblightdm/MockUsersModel.h (+10/-11)
tests/mocks/libusermetrics/UserMetrics.cpp (+3/-5)
tests/plugins/AccountsService/AccountsServer.cpp (+11/-0)
tests/plugins/AccountsService/AccountsServer.h (+5/-0)
tests/plugins/AccountsService/client.cpp (+71/-21)
tests/plugins/AccountsService/interfaces.xml (+1/-0)
tests/plugins/LightDM/CMakeLists.txt (+21/-80)
tests/plugins/LightDM/IntegratedLightDM/integrated.cpp (+0/-88)
tests/plugins/LightDM/IntegratedLightDM/pam.cpp (+0/-54)
tests/plugins/LightDM/greeter.qml (+1/-6)
tests/plugins/LightDM/sessionsmodel.cpp (+14/-15)
tests/plugins/LightDM/usersmodel.cpp (+4/-14)
tests/plugins/Unity/Session/sessionbackendtest.cpp (+0/-1)
tests/qmltests/Dash/tst_DashShell.qml (+7/-0)
tests/qmltests/Greeter/TestView.qml (+1/-0)
tests/qmltests/Greeter/tst_Greeter.qml (+5/-8)
tests/qmltests/Greeter/tst_Infographics.qml (+1/-11)
tests/qmltests/Greeter/tst_NarrowView.qml (+8/-2)
tests/qmltests/Greeter/tst_WideView.qml (+29/-23)
tests/qmltests/Tutorial/tst_Tutorial.qml (+2/-3)
tests/qmltests/tst_OrientedShell.qml (+7/-1)
tests/qmltests/tst_Shell.qml (+4/-7)
tests/qmltests/tst_ShellWithPin.qml (+2/-3)
To merge this branch: bzr merge lp:~josharenson/unity8/fix-session-icon
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Needs Information
Unity8 CI Bot continuous-integration Approve
Review via email: mp+308891@code.launchpad.net

This proposal has been superseded by a proposal from 2016-11-08.

Commit message

Enable the greeter to remember which session the user last logged into

This also fixes a small issue with how the default session was handled.

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
No

* 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
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:2659
https://unity8-jenkins.ubuntu.com/job/lp-unity8-ci/2419/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/3173
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=vivid+overlay,testname=qmluitests.sh/1810
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=qmluitests.sh/1810
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/test-0-autopkgtest/label=amd64,release=yakkety,testname=qmluitests.sh/1810
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3201
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3057/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/3057
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/3057/artifact/output/*zip*/output.zip

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

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

Tested, seems to work well.

Is this something that we can autotest?

review: Needs Information
Revision history for this message
Josh Arenson (josharenson) wrote :

> Tested, seems to work well.
>
> Is this something that we can autotest?

There are some existing tests for the session icons. I think the level of effort to test this small issue would be very high, if even possible. The information for this field is delivered from AccountService via LightDM and thus, would likely require substantial updates to the mocks. Perhaps I'm overthinking this...

 It may be a good candidate for an autopilot test, however. If you disagree, lets discuss in person.

Revision history for this message
Albert Astals Cid (aacid) wrote :

talked in person, agreed that Josh will evaluate how hard is to add an autotest for the Greeter in which we have two users, set the last used session of user2 to be X (non default) and then while moving to user2 we check that the selected session is the one we set.

2581. By Josh Arenson

Correct a null parent

2582. By Josh Arenson

Return the correct role for the user session name

2583. By Josh Arenson

Add a test

2584. By Josh Arenson

Complete weird test

2585. By Josh Arenson

Fix whitespace

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2016-10-24 11:34:08 +0000
+++ CMakeLists.txt 2016-11-08 23:03:16 +0000
@@ -61,6 +61,7 @@
61pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)61pkg_check_modules(GEONAMES REQUIRED geonames>=0.2)
62pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)62pkg_check_modules(GIO REQUIRED gio-2.0>=2.32)
63pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)63pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32)
64pkg_check_modules(LIBLIGHTDM REQUIRED liblightdm-qt5-3)
64pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)65pkg_check_modules(QMENUMODEL REQUIRED qmenumodel)
65pkg_check_modules(GD3 REQUIRED gnome-desktop-3.0)66pkg_check_modules(GD3 REQUIRED gnome-desktop-3.0)
66pkg_check_modules(UAL REQUIRED ubuntu-app-launch-2)67pkg_check_modules(UAL REQUIRED ubuntu-app-launch-2)
6768
=== modified file 'cmake/modules/QmlTest.cmake'
--- cmake/modules/QmlTest.cmake 2016-03-04 15:07:31 +0000
+++ cmake/modules/QmlTest.cmake 2016-11-08 23:03:16 +0000
@@ -65,11 +65,11 @@
65# This function wraps add_executable_test, see below for available arguments.65# This function wraps add_executable_test, see below for available arguments.
6666
67function(add_qml_unittest PATH COMPONENT_NAME)67function(add_qml_unittest PATH COMPONENT_NAME)
68 import_executables(qmltestrunner)68 import_executables(dbus-run-session)
6969
70 add_executable_test(${COMPONENT_NAME} qmltestrunner70 add_executable_test(${COMPONENT_NAME} dbus-run-session
71 ${ARGN}71 ${ARGN}
72 ARGS -input ${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml ${QMLTEST_ARGS}72 ARGS -- qmltestrunner -input ${CMAKE_CURRENT_SOURCE_DIR}/${PATH}/tst_${COMPONENT_NAME}.qml ${QMLTEST_ARGS}
73 )73 )
74endfunction()74endfunction()
7575
7676
=== modified file 'data/unity8.conf'
--- data/unity8.conf 2016-06-27 18:42:23 +0000
+++ data/unity8.conf 2016-11-08 23:03:16 +0000
@@ -15,23 +15,23 @@
15 # Tell unity-mir to raise SIGSTOP after we start15 # Tell unity-mir to raise SIGSTOP after we start
16 initctl set-env UNITY_MIR_EMITS_SIGSTOP=116 initctl set-env UNITY_MIR_EMITS_SIGSTOP=1
1717
18 if [ -n "$MIR_SOCKET" ]; then18 if [ -n "$(initctl get-env --global MIR_SERVER_HOST_SOCKET)" ]; then
19 # FIXME Create an autopilot test that makes sure start+stop and restart19 # FIXME Create an autopilot test that makes sure start+stop and restart
20 # work fine at least 2 times20 # work fine at least 2 times
21 # Save original value of MIR_SOCKET in case we are stopped,21 # Save original value of MIR_SERVER_HOST_SOCKET in case we are stopped,
22 # as we modify the variable for future jobs, including ourself.22 # as we modify the variable for future jobs, including ourself.
23 UNITY_MIR_SOCKET=$(initctl get-env --global MIR_SOCKET)23 UNITY_MIR_SOCKET=$(initctl get-env --global MIR_SERVER_HOST_SOCKET)
24 initctl set-env --global UNITY_MIR_SOCKET=$UNITY_MIR_SOCKET24 initctl set-env --global UNITY_MIR_SOCKET=$UNITY_MIR_SOCKET
2525
26 # Point all future jobs in this session to our Mir socket instead of
27 # unity-system-compositor's socket.
28 MIR_SERVER_FILE=$XDG_RUNTIME_DIR/mir_socket
29 initctl set-env --global MIR_SERVER_HOST_SOCKET=$MIR_SERVER_FILE
30 gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.UpdateActivationEnvironment "@a{ss} {'MIR_SERVER_HOST_SOCKET': '$MIR_SERVER_FILE'}"
31
26 # Point unity8 at unity-system-compositor32 # Point unity8 at unity-system-compositor
27 MIR_SERVER_FILE=$XDG_RUNTIME_DIR/mir_socket
28 initctl set-env MIR_SERVER_FILE=$MIR_SERVER_FILE33 initctl set-env MIR_SERVER_FILE=$MIR_SERVER_FILE
29 initctl set-env MIR_SERVER_HOST_SOCKET=$UNITY_MIR_SOCKET34 initctl set-env MIR_SERVER_HOST_SOCKET=$UNITY_MIR_SOCKET
30
31 # Point all future jobs in this session to our Mir socket instead of
32 # unity-system-compositor's socket.
33 initctl set-env --global MIR_SOCKET=$MIR_SERVER_FILE
34 gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.UpdateActivationEnvironment "@a{ss} {'MIR_SOCKET': '$MIR_SERVER_FILE'}"
35 fi35 fi
3636
37 # Remove the normal and trusted sockets if still there37 # Remove the normal and trusted sockets if still there
@@ -65,7 +65,7 @@
65exec ${BINARY:-unity8} --mode=$MODE $ARGS65exec ${BINARY:-unity8} --mode=$MODE $ARGS
6666
67post-start script67post-start script
68 # If no MIR_SOCKET was defined on launch, we try to set one here68 # If no MIR_SERVER_HOST_SOCKET was defined on launch, we try to set one here
69 if [ -z "$(initctl get-env --global UNITY_MIR_SOCKET)" ]; then69 if [ -z "$(initctl get-env --global UNITY_MIR_SOCKET)" ]; then
70 if [ -S "$XDG_RUNTIME_DIR/mir_socket" ]; then70 if [ -S "$XDG_RUNTIME_DIR/mir_socket" ]; then
71 mir_socket=$XDG_RUNTIME_DIR/mir_socket71 mir_socket=$XDG_RUNTIME_DIR/mir_socket
@@ -74,7 +74,7 @@
74 fi74 fi
7575
76 if [ -n "$mir_socket" ]; then76 if [ -n "$mir_socket" ]; then
77 initctl set-env --global MIR_SOCKET="$mir_socket"77 initctl set-env --global MIR_SERVER_HOST_SOCKET="$mir_socket"
78 fi78 fi
79 fi79 fi
8080
@@ -82,7 +82,7 @@
82end script82end script
8383
84post-stop script84post-stop script
85 initctl set-env --global MIR_SOCKET=$UNITY_MIR_SOCKET85 initctl set-env --global MIR_SERVER_HOST_SOCKET=$UNITY_MIR_SOCKET
86 initctl unset-env --global UNITY_MIR_SOCKET86 initctl unset-env --global UNITY_MIR_SOCKET
87 initctl unset-env --global MIR_SERVER_PROMPT_FILE87 initctl unset-env --global MIR_SERVER_PROMPT_FILE
88 initctl emit application-end88 initctl emit application-end
8989
=== modified file 'debian/rules'
--- debian/rules 2016-08-11 17:55:45 +0000
+++ debian/rules 2016-11-08 23:03:16 +0000
@@ -36,8 +36,3 @@
36# use private lib directories36# use private lib directories
37override_dh_makeshlibs:37override_dh_makeshlibs:
38 dh_makeshlibs -Nunity8-private -Nunity8-fake-env38 dh_makeshlibs -Nunity8-private -Nunity8-fake-env
39
40override_dh_shlibdeps:
41 # Some mock libraries link against liblightdm-qt5-3.so which we want to
42 # avoid, since we only really link against our mock one, not the system one.
43 dh_shlibdeps -XlibMockLightDM-qml.so -XlibMockAccountsService-qml.so
4439
=== modified file 'plugins/AccountsService/AccountsService.cpp'
--- plugins/AccountsService/AccountsService.cpp 2016-08-11 06:25:34 +0000
+++ plugins/AccountsService/AccountsService.cpp 2016-11-08 23:03:16 +0000
@@ -80,6 +80,7 @@
80AccountsService::AccountsService(QObject* parent, const QString &user)80AccountsService::AccountsService(QObject* parent, const QString &user)
81 : QObject(parent)81 : QObject(parent)
82 , m_service(new AccountsServiceDBusAdaptor(this))82 , m_service(new AccountsServiceDBusAdaptor(this))
83 , m_greeterMode(true)
83{84{
84 m_unityInput = new QDBusInterface(QStringLiteral("com.canonical.Unity.Input"),85 m_unityInput = new QDBusInterface(QStringLiteral("com.canonical.Unity.Input"),
85 QStringLiteral("/com/canonical/Unity/Input"),86 QStringLiteral("/com/canonical/Unity/Input"),
@@ -155,6 +156,19 @@
155 refresh(!wasEmpty);156 refresh(!wasEmpty);
156}157}
157158
159bool AccountsService::greeterMode() const
160{
161 return m_greeterMode;
162}
163
164void AccountsService::setGreeterMode(bool greeterMode)
165{
166 if (m_greeterMode != greeterMode) {
167 m_greeterMode = greeterMode;
168 Q_EMIT greeterModeChanged();
169 }
170}
171
158bool AccountsService::demoEdges() const172bool AccountsService::demoEdges() const
159{173{
160 auto value = getProperty(IFACE_UNITY, PROP_DEMO_EDGES);174 auto value = getProperty(IFACE_UNITY, PROP_DEMO_EDGES);
@@ -341,7 +355,19 @@
341{355{
342 if (m_properties[interface][property].value != value) {356 if (m_properties[interface][property].value != value) {
343 m_properties[interface][property].value = value;357 m_properties[interface][property].value = value;
344 m_service->setUserPropertyAsync(m_user, interface, property, value);358 if (m_greeterMode || m_user == g_get_user_name()) {
359 // Only write any changes back to AccountsService if we are running
360 // as a proper LightDM greeter (or are writing values for our own
361 // user).
362 // (A) Only the lightdm user has permission to set everyone's
363 // properties.
364 // (B) We don't want to have policykit throw up a password dialog
365 // when we are running in the user session.
366 // (C) We only write things to AS that are safe to ignore for other
367 // users anyway (like failedLogins count, which does not NEED
368 // to be persistent).
369 m_service->setUserPropertyAsync(m_user, interface, property, value);
370 }
345 emitChangedForProperty(interface, property);371 emitChangedForProperty(interface, property);
346 }372 }
347}373}
348374
=== modified file 'plugins/AccountsService/AccountsService.h'
--- plugins/AccountsService/AccountsService.h 2016-08-08 10:10:25 +0000
+++ plugins/AccountsService/AccountsService.h 2016-11-08 23:03:16 +0000
@@ -34,6 +34,10 @@
34 READ user34 READ user
35 WRITE setUser35 WRITE setUser
36 NOTIFY userChanged)36 NOTIFY userChanged)
37 Q_PROPERTY (bool greeterMode
38 READ greeterMode
39 WRITE setGreeterMode
40 NOTIFY greeterModeChanged)
37 Q_PROPERTY (bool demoEdges41 Q_PROPERTY (bool demoEdges
38 READ demoEdges42 READ demoEdges
39 WRITE setDemoEdges43 WRITE setDemoEdges
@@ -92,6 +96,8 @@
9296
93 QString user() const;97 QString user() const;
94 void setUser(const QString &user);98 void setUser(const QString &user);
99 bool greeterMode() const;
100 void setGreeterMode(bool greeterMode);
95 bool demoEdges() const;101 bool demoEdges() const;
96 void setDemoEdges(bool demoEdges);102 void setDemoEdges(bool demoEdges);
97 QStringList demoEdgesCompleted() const;103 QStringList demoEdgesCompleted() const;
@@ -119,6 +125,7 @@
119125
120Q_SIGNALS:126Q_SIGNALS:
121 void userChanged();127 void userChanged();
128 void greeterModeChanged();
122 void demoEdgesChanged();129 void demoEdgesChanged();
123 void demoEdgesCompletedChanged();130 void demoEdgesCompletedChanged();
124 void enableFingerprintIdentificationChanged();131 void enableFingerprintIdentificationChanged();
@@ -167,6 +174,7 @@
167 AccountsServiceDBusAdaptor *m_service;174 AccountsServiceDBusAdaptor *m_service;
168 QDBusInterface *m_unityInput;175 QDBusInterface *m_unityInput;
169 QString m_user;176 QString m_user;
177 bool m_greeterMode;
170};178};
171179
172#endif180#endif
173181
=== modified file 'plugins/LightDM/CMakeLists.txt'
--- plugins/LightDM/CMakeLists.txt 2016-03-02 02:54:30 +0000
+++ plugins/LightDM/CMakeLists.txt 2016-11-08 23:03:16 +0000
@@ -1,19 +1,20 @@
1pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)1pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
22
3find_package(Qt5Core REQUIRED)
4find_package(Qt5Quick REQUIRED)
5
6include_directories(3include_directories(
7 ${CMAKE_CURRENT_SOURCE_DIR}4 ${CMAKE_CURRENT_SOURCE_DIR}
8 ${CMAKE_CURRENT_BINARY_DIR}5 ${CMAKE_CURRENT_BINARY_DIR}
9 ${CMAKE_SOURCE_DIR}/plugins/Utils6 ${CMAKE_SOURCE_DIR}/plugins/Utils
10 ${CMAKE_BINARY_DIR}/tests/mocks/LightDM/IntegratedLightDM
11 ${libunity8-private_SOURCE_DIR}7 ${libunity8-private_SOURCE_DIR}
8 )
9
10include_directories(
11 SYSTEM
12 ${LIBLIGHTDM_INCLUDE_DIRS}
12 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}13 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
13)14 )
1415
15set(QMLPLUGIN_SRC16add_library(LightDM-qml MODULE
16 ../Utils/unitysortfilterproxymodelqml.cpp17 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
17 DBusGreeter.cpp18 DBusGreeter.cpp
18 DBusGreeterList.cpp19 DBusGreeterList.cpp
19 Greeter.cpp20 Greeter.cpp
@@ -22,5 +23,11 @@
22 UsersModel.cpp23 UsersModel.cpp
23 )24 )
2425
25add_subdirectory(FullLightDM)26target_link_libraries(LightDM-qml
26add_subdirectory(IntegratedLightDM)27 unity8-private
28 ${LIBLIGHTDM_LDFLAGS}
29 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
30 )
31
32qt5_use_modules(LightDM-qml DBus Gui Qml)
33add_unity8_plugin(LightDM 0.1 LightDM TARGETS LightDM-qml)
2734
=== removed directory 'plugins/LightDM/FullLightDM'
=== removed file 'plugins/LightDM/FullLightDM/CMakeLists.txt'
--- plugins/LightDM/FullLightDM/CMakeLists.txt 2016-07-08 15:44:53 +0000
+++ plugins/LightDM/FullLightDM/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,28 +0,0 @@
1pkg_check_modules(LIBLIGHTDM REQUIRED liblightdm-qt5-3)
2
3set(PLUGIN_CLASSNAME "FullLightDM")
4
5add_definitions(-DFULL_LIGHTDM)
6
7include_directories(
8 ../
9 ${LIBLIGHTDM_INCLUDE_DIRS}
10 ${CMAKE_CURRENT_BINARY_DIR}
11 )
12
13foreach(source_file ${QMLPLUGIN_SRC})
14 list(APPEND RELATIVE_QMLPLUGIN_SRC ../${source_file})
15endforeach()
16
17add_library(FullLightDM-qml MODULE
18 ${RELATIVE_QMLPLUGIN_SRC}
19 )
20
21target_link_libraries(FullLightDM-qml
22 unity8-private
23 ${LIBLIGHTDM_LDFLAGS}
24 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
25 )
26
27qt5_use_modules(FullLightDM-qml DBus Gui Qml)
28add_unity8_plugin(FullLightDM 0.1 LightDM/FullLightDM TARGETS FullLightDM-qml)
290
=== modified file 'plugins/LightDM/Greeter.cpp'
--- plugins/LightDM/Greeter.cpp 2016-07-28 15:34:29 +0000
+++ plugins/LightDM/Greeter.cpp 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013, 2015 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -147,3 +147,9 @@
147 Q_EMIT isAuthenticatedChanged();147 Q_EMIT isAuthenticatedChanged();
148 Q_EMIT authenticationComplete();148 Q_EMIT authenticationComplete();
149}149}
150
151QObject *Greeter::mock()
152{
153 Q_D(Greeter);
154 return d->m_greeter->property("mock").value<QObject*>();
155}
150156
=== modified file 'plugins/LightDM/Greeter.h'
--- plugins/LightDM/Greeter.h 2016-07-28 15:34:29 +0000
+++ plugins/LightDM/Greeter.h 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2012,2013,2015 Canonical, Ltd.2 * Copyright (C) 2012-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -40,6 +40,8 @@
40 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)40 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
41 Q_PROPERTY(QString selectUser READ selectUser CONSTANT)41 Q_PROPERTY(QString selectUser READ selectUser CONSTANT)
4242
43 Q_PROPERTY(QObject *mock READ mock CONSTANT) // for testing
44
43public:45public:
44 explicit Greeter(QObject* parent=0);46 explicit Greeter(QObject* parent=0);
4547
@@ -50,6 +52,8 @@
50 bool promptless() const;52 bool promptless() const;
51 QString selectUser() const;53 QString selectUser() const;
5254
55 QObject *mock();
56
53public Q_SLOTS:57public Q_SLOTS:
54 void authenticate(const QString &username=QString());58 void authenticate(const QString &username=QString());
55 void respond(const QString &response);59 void respond(const QString &response);
5660
=== removed directory 'plugins/LightDM/IntegratedLightDM'
=== removed file 'plugins/LightDM/IntegratedLightDM/CMakeLists.txt'
--- plugins/LightDM/IntegratedLightDM/CMakeLists.txt 2016-07-08 15:44:53 +0000
+++ plugins/LightDM/IntegratedLightDM/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
1set(PLUGIN_CLASSNAME "IntegratedLightDM")
2
3add_definitions(-DINTEGRATED_LIGHTDM)
4
5foreach(include_directory ${QMLPLUGIN_INCLUDES})
6 list(APPEND RELATIVE_QMLPLUGIN_INCLUDES ../${include_directory})
7endforeach()
8
9include_directories(
10 . #QLightDM
11 ${QMLPLUGIN_INCLUDES}
12 ${libunity8-private_SOURCE_DIR}
13 ${CMAKE_CURRENT_BINARY_DIR}
14)
15
16foreach(source_file ${QMLPLUGIN_SRC})
17 list(APPEND RELATIVE_QMLPLUGIN_SRC ../${source_file})
18endforeach()
19
20add_library(IntegratedLightDM-qml MODULE
21 ${RELATIVE_QMLPLUGIN_SRC}
22 )
23
24target_link_libraries(IntegratedLightDM-qml
25 integratedLightDM
26 unity8-private
27 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
28 )
29
30qt5_use_modules(IntegratedLightDM-qml DBus Gui Qml)
31add_unity8_plugin(IntegratedLightDM 0.1 LightDM/IntegratedLightDM TARGETS IntegratedLightDM-qml)
32
33add_subdirectory(liblightdm)
340
=== removed directory 'plugins/LightDM/IntegratedLightDM/QLightDM'
=== removed file 'plugins/LightDM/IntegratedLightDM/QLightDM/Greeter'
--- plugins/LightDM/IntegratedLightDM/QLightDM/Greeter 2016-06-13 21:21:57 +0000
+++ plugins/LightDM/IntegratedLightDM/QLightDM/Greeter 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) 2016 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
17#include "../liblightdm/Greeter.h"
180
=== removed file 'plugins/LightDM/IntegratedLightDM/QLightDM/SessionsModel'
--- plugins/LightDM/IntegratedLightDM/QLightDM/SessionsModel 2016-06-13 21:21:57 +0000
+++ plugins/LightDM/IntegratedLightDM/QLightDM/SessionsModel 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) 2016 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
17#include "../liblightdm/SessionsModel.h"
180
=== removed file 'plugins/LightDM/IntegratedLightDM/QLightDM/UsersModel'
--- plugins/LightDM/IntegratedLightDM/QLightDM/UsersModel 2016-06-13 21:21:57 +0000
+++ plugins/LightDM/IntegratedLightDM/QLightDM/UsersModel 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) 2016 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
17#include "../liblightdm/UsersModel.h"
180
=== removed directory 'plugins/LightDM/IntegratedLightDM/liblightdm'
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt'
--- plugins/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt 2016-03-17 16:51:38 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,55 +0,0 @@
1pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
2
3set(LibLightDM_SOURCES
4 Greeter.cpp
5 SessionsModel.cpp
6 UsersModel.cpp
7 GreeterPrivate.cpp
8 SessionsModelPrivate.cpp
9 UsersModelPrivate.cpp
10 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
11 ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
12 )
13
14add_library(integratedLightDM STATIC ${LibLightDM_SOURCES})
15add_library(integratedLightDMSession STATIC ${LibLightDM_SOURCES})
16add_library(MockLightDM-demo-shared SHARED ${LibLightDM_SOURCES})
17
18include_directories(
19 ${CMAKE_SOURCE_DIR}/plugins/AccountsService
20 ${CMAKE_CURRENT_BINARY_DIR}
21 ${GLIB_INCLUDE_DIRS}
22 ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
23)
24
25target_link_libraries(integratedLightDM
26 ${GLIB_LIBRARIES}
27 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
28 -lpam
29)
30target_link_libraries(integratedLightDMSession
31 ${GLIB_LIBRARIES}
32 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
33 -lpam
34)
35target_link_libraries(MockLightDM-demo-shared
36 ${GLIB_LIBRARIES}
37 ${LIBUSERMETRICSOUTPUT_LDFLAGS}
38 -lpam
39)
40
41qt5_use_modules(integratedLightDM Concurrent DBus Gui)
42qt5_use_modules(integratedLightDMSession Concurrent DBus Gui)
43qt5_use_modules(MockLightDM-demo-shared Concurrent DBus Gui)
44
45set_target_properties(integratedLightDM PROPERTIES
46 COMPILE_FLAGS "-DSM_BUSNAME=systemBus -fPIC")
47set_target_properties(integratedLightDMSession PROPERTIES
48 COMPILE_FLAGS "-DSM_BUSNAME=sessionBus -fPIC")
49set_target_properties(MockLightDM-demo-shared PROPERTIES
50 COMPILE_FLAGS "-DSM_BUSNAME=systemBus"
51 OUTPUT_NAME lightdm-qt5-3)
52
53install(TARGETS MockLightDM-demo-shared
54 DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/IntegratedLightDM/demo
55 )
560
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp'
--- plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp 2016-07-28 15:34:29 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp 1970-01-01 00:00:00 +0000
@@ -1,179 +0,0 @@
1/*
2 * Copyright (C) 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 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 * Author: Michael Terry <michael.terry@canonical.com>
17 */
18
19
20/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21 * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
22 * COUNTERPART IN tests/mocks/Lightdm/liblightdm
23 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
24
25
26#include "Greeter.h"
27#include "GreeterPrivate.h"
28#include <QtCore/QCoreApplication>
29#include <QTimer>
30
31namespace QLightDM
32{
33
34Greeter::Greeter(QObject *parent)
35 : QObject(parent),
36 d_ptr(new GreeterPrivate(this))
37{
38}
39
40Greeter::~Greeter()
41{
42}
43
44QString Greeter::authenticationUser() const
45{
46 Q_D(const Greeter);
47 return d->authenticationUser;
48}
49
50bool Greeter::hasGuestAccountHint() const
51{
52 return true;
53}
54
55QString Greeter::getHint(const QString &name) const
56{
57 Q_UNUSED(name)
58 return QLatin1String("");
59}
60
61QString Greeter::defaultSessionHint() const
62{
63 return QStringLiteral("ubuntu");
64}
65
66bool Greeter::hideUsersHint() const
67{
68 return false;
69}
70
71bool Greeter::showManualLoginHint() const
72{
73 return true;
74}
75
76bool Greeter::showRemoteLoginHint() const
77{
78 return true;
79}
80
81QString Greeter::selectUserHint() const
82{
83 return QLatin1String("");
84}
85
86bool Greeter::selectGuestHint() const
87{
88 return false;
89}
90
91QString Greeter::autologinUserHint() const
92{
93 return QLatin1String("");
94}
95
96bool Greeter::autologinGuestHint() const
97{
98 return false;
99}
100
101int Greeter::autologinTimeoutHint() const
102{
103 return 0;
104}
105
106bool Greeter::inAuthentication() const
107{
108 return false;
109}
110
111QString Greeter::hostname() const
112{
113 return QStringLiteral("hostname1");
114}
115
116bool Greeter::isAuthenticated() const
117{
118 Q_D(const Greeter);
119 return d->authenticated;
120}
121
122bool Greeter::connectSync()
123{
124 return true;
125}
126
127void Greeter::authenticate(const QString &username)
128{
129 Q_D(Greeter);
130
131 d->authenticated = false;
132 d->authenticationUser = username;
133 d->handleAuthenticate();
134}
135
136void Greeter::authenticateAsGuest()
137{}
138
139void Greeter::authenticateAutologin()
140{}
141
142void Greeter::authenticateRemote(const QString &session, const QString &username)
143{
144 Q_UNUSED(session)
145 Q_UNUSED(username)
146}
147
148void Greeter::cancelAuthentication()
149{}
150
151void Greeter::setLanguage (const QString &language)
152{
153 Q_UNUSED(language)
154}
155
156bool Greeter::startSessionSync(const QString &session)
157{
158 Q_UNUSED(session)
159 return true;
160}
161
162void Greeter::respond(const QString &response)
163{
164 Q_D(Greeter);
165
166 d->handleRespond(response);
167}
168
169void Greeter::sendAuthenticationComplete()
170{
171 if (qEnvironmentVariableIsEmpty("UNITY_TESTING")) {
172 // simulate PAM's delay
173 QTimer::singleShot(1000, this, &Greeter::authenticationComplete);
174 } else {
175 Q_EMIT authenticationComplete();
176 }
177}
178
179}
1800
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.h'
--- plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.h 2016-07-28 15:34:29 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.h 1970-01-01 00:00:00 +0000
@@ -1,108 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 * Copyright (C) 2010-2011 David Edmundson.
4 * Copyright (C) 2010-2011 Robert Ancell
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * Author: David Edmundson <kde@davidedmundson.co.uk>
19 */
20
21#ifndef UNITY_MOCK_GREETER_H
22#define UNITY_MOCK_GREETER_H
23
24#include <QtCore/QObject>
25#include <QtCore/QVariant>
26
27/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
29 * COUNTERPART IN tests/mocks/Lightdm/liblightdm
30 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
31
32namespace QLightDM
33{
34 class GreeterPrivate;
35
36class Q_DECL_EXPORT Greeter : public QObject
37{
38 Q_OBJECT
39
40 Q_PROPERTY(bool authenticated READ isAuthenticated ) //NOTFIY authenticationComplete
41 Q_PROPERTY(QString authenticationUser READ authenticationUser )
42 Q_PROPERTY(QString defaultSession READ defaultSessionHint CONSTANT)
43 Q_PROPERTY(QString selectUser READ selectUserHint CONSTANT)
44 Q_PROPERTY(bool selectGuest READ selectGuestHint CONSTANT)
45
46 Q_PROPERTY(QString hostname READ hostname CONSTANT)
47 Q_PROPERTY(bool hasGuestAccount READ hasGuestAccountHint CONSTANT)
48
49 Q_ENUMS(PromptType MessageType)
50
51public:
52 enum PromptType {
53 PromptTypeQuestion,
54 PromptTypeSecret
55 };
56
57 enum MessageType {
58 MessageTypeInfo,
59 MessageTypeError
60 };
61
62 explicit Greeter(QObject* parent=0);
63 virtual ~Greeter();
64
65 QString getHint(const QString &name) const;
66 QString defaultSessionHint() const;
67 bool hideUsersHint() const;
68 bool showManualLoginHint() const;
69 bool showRemoteLoginHint() const;
70 bool hasGuestAccountHint() const;
71 QString selectUserHint() const;
72 bool selectGuestHint() const;
73 QString autologinUserHint() const;
74 bool autologinGuestHint() const;
75 int autologinTimeoutHint() const;
76
77 bool inAuthentication() const;
78 bool isAuthenticated() const;
79 QString authenticationUser() const;
80 QString hostname() const;
81
82public Q_SLOTS:
83 bool connectSync();
84 void authenticate(const QString &username=QString());
85 void authenticateAsGuest();
86 void authenticateAutologin();
87 void authenticateRemote(const QString &session=QString(), const QString &username=QString());
88 void respond(const QString &response);
89 void cancelAuthentication();
90 void setLanguage (const QString &language);
91 bool startSessionSync(const QString &session=QString());
92
93Q_SIGNALS:
94 void showMessage(QString text, QLightDM::Greeter::MessageType type);
95 void showPrompt(QString text, QLightDM::Greeter::PromptType type);
96 void authenticationComplete();
97 void autologinTimerExpired();
98
99protected:
100 void sendAuthenticationComplete();
101
102private:
103 GreeterPrivate *d_ptr;
104 Q_DECLARE_PRIVATE(Greeter)
105};
106}
107
108#endif // UNITY_MOCK_GREETER_H
1090
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp'
--- plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp 2015-11-02 17:22:30 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,304 +0,0 @@
1/*
2 * Copyright (C) 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 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 * Author: Michael Terry <michael.terry@canonical.com>
17 */
18
19#include "Greeter.h"
20#include "GreeterPrivate.h"
21#include <QFuture>
22#include <QFutureInterface>
23#include <QFutureWatcher>
24#include <QQueue>
25#include <QtConcurrent>
26#include <QVector>
27#include <security/pam_appl.h>
28
29namespace QLightDM
30{
31
32class GreeterImpl : public QObject
33{
34 Q_OBJECT
35
36 struct AppData
37 {
38 GreeterImpl *impl;
39 pam_handle *handle;
40 };
41
42 typedef QFutureInterface<QString> ResponseFuture;
43
44public:
45 explicit GreeterImpl(Greeter *parent, GreeterPrivate *greeterPrivate)
46 : QObject(parent),
47 greeter(parent),
48 greeterPrivate(greeterPrivate),
49 pamHandle(nullptr)
50 {
51 qRegisterMetaType<QLightDM::GreeterImpl::ResponseFuture>("QLightDM::GreeterImpl::ResponseFuture");
52
53 connect(&futureWatcher, &QFutureWatcher<int>::finished, this, &GreeterImpl::finishPam);
54 connect(this, SIGNAL(showMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)),
55 this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)));
56 // This next connect is how we pass ResponseFutures between threads
57 connect(this, SIGNAL(showPrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)),
58 this, SLOT(handlePrompt(pam_handle *, QString, QLightDM::Greeter::PromptType, QLightDM::GreeterImpl::ResponseFuture)),
59 Qt::BlockingQueuedConnection);
60 }
61
62 ~GreeterImpl()
63 {
64 cancelPam();
65 }
66
67 void start(QString username)
68 {
69 // Clear out any existing PAM interactions first
70 cancelPam();
71 if (pamHandle != nullptr) {
72 // While we were cancelling pam above, we processed Qt events.
73 // Which may have allowed someone to call start() on us again.
74 // In which case, we'll bail on our current start() call.
75 // This isn't racy because it's all in the same thread.
76 return;
77 }
78
79 AppData *appData = new AppData();
80 appData->impl = this;
81
82 // Now actually start a new conversation with PAM
83 pam_conv conversation;
84 conversation.conv = converseWithPam;
85 conversation.appdata_ptr = static_cast<void*>(appData);
86
87 if (pam_start("lightdm", username.toUtf8(), &conversation, &pamHandle) == PAM_SUCCESS) {
88 appData->handle = pamHandle;
89 futureWatcher.setFuture(QtConcurrent::mapped(QList<pam_handle*>() << pamHandle, authenticateWithPam));
90 } else {
91 delete appData;
92 greeterPrivate->authenticated = false;
93 Q_EMIT greeter->showMessage(QStringLiteral("Internal error: could not start PAM authentication"), QLightDM::Greeter::MessageTypeError);
94 Q_EMIT greeter->authenticationComplete();
95 }
96 }
97
98 static int authenticateWithPam(pam_handle* const& pamHandle)
99 {
100 int pamStatus = pam_authenticate(pamHandle, 0);
101 if (pamStatus == PAM_SUCCESS) {
102 pamStatus = pam_acct_mgmt(pamHandle, 0);
103 }
104 if (pamStatus == PAM_NEW_AUTHTOK_REQD) {
105 pamStatus = pam_chauthtok(pamHandle, PAM_CHANGE_EXPIRED_AUTHTOK);
106 }
107 if (pamStatus == PAM_SUCCESS) {
108 pam_setcred(pamHandle, PAM_REINITIALIZE_CRED);
109 }
110 return pamStatus;
111 }
112
113 static int converseWithPam(int num_msg, const pam_message** msg,
114 pam_response** resp, void* appdata_ptr)
115 {
116 if (num_msg <= 0)
117 return PAM_CONV_ERR;
118
119 auto* tmp_response = static_cast<pam_response*>(calloc(num_msg, sizeof(pam_response)));
120 if (!tmp_response)
121 return PAM_CONV_ERR;
122
123 AppData *appData = static_cast<AppData*>(appdata_ptr);
124 GreeterImpl *impl = appData->impl;
125 pam_handle *handle = appData->handle;
126
127 int count;
128 QVector<ResponseFuture> responses;
129
130 for (count = 0; count < num_msg; ++count)
131 {
132 switch (msg[count]->msg_style)
133 {
134 case PAM_PROMPT_ECHO_ON:
135 {
136 QString message(msg[count]->msg);
137 responses.append(ResponseFuture());
138 responses.last().reportStarted();
139 Q_EMIT impl->showPrompt(handle, message, Greeter::PromptTypeQuestion, responses.last());
140 break;
141 }
142 case PAM_PROMPT_ECHO_OFF:
143 {
144 QString message(msg[count]->msg);
145 responses.append(ResponseFuture());
146 responses.last().reportStarted();
147 Q_EMIT impl->showPrompt(handle, message, Greeter::PromptTypeSecret, responses.last());
148 break;
149 }
150 case PAM_TEXT_INFO:
151 {
152 QString message(msg[count]->msg);
153 Q_EMIT impl->showMessage(handle, message, Greeter::MessageTypeInfo);
154 break;
155 }
156 default:
157 {
158 QString message(msg[count]->msg);
159 Q_EMIT impl->showMessage(handle, message, Greeter::MessageTypeError);
160 break;
161 }
162 }
163 }
164
165 int i = 0;
166 bool raise_error = false;
167
168 for (auto &response : responses)
169 {
170 pam_response* resp_item = &tmp_response[i++];
171 resp_item->resp_retcode = 0;
172 resp_item->resp = strdup(response.future().result().toUtf8());
173
174 if (!resp_item->resp)
175 {
176 raise_error = true;
177 break;
178 }
179 }
180
181 delete appData;
182
183 if (raise_error)
184 {
185 for (int i = 0; i < count; ++i)
186 free(tmp_response[i].resp);
187
188 free(tmp_response);
189 return PAM_CONV_ERR;
190 }
191 else
192 {
193 *resp = tmp_response;
194 return PAM_SUCCESS;
195 }
196 }
197
198public Q_SLOTS:
199 bool respond(QString response)
200 {
201 if (!futures.isEmpty()) {
202 futures.dequeue().reportFinished(&response);
203 return true;
204 } else {
205 return false;
206 }
207 }
208
209Q_SIGNALS:
210 void showMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type);
211 void showPrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture response);
212
213private Q_SLOTS:
214 void finishPam()
215 {
216 if (pamHandle == nullptr) {
217 return;
218 }
219
220 int pamStatus = futureWatcher.result();
221
222 pam_end(pamHandle, pamStatus);
223 pamHandle = nullptr;
224
225 greeterPrivate->authenticated = (pamStatus == PAM_SUCCESS);
226 Q_EMIT greeter->authenticationComplete();
227 }
228
229 void handleMessage(pam_handle *handle, QString text, QLightDM::Greeter::MessageType type)
230 {
231 if (handle != pamHandle)
232 return;
233
234 Q_EMIT greeter->showMessage(text, type);
235 }
236
237 void handlePrompt(pam_handle *handle, QString text, QLightDM::Greeter::PromptType type, QLightDM::GreeterImpl::ResponseFuture future)
238 {
239 if (handle != pamHandle) {
240 future.reportResult(QString());
241 future.reportFinished();
242 return;
243 }
244
245 futures.enqueue(future);
246 Q_EMIT greeter->showPrompt(text, type);
247 }
248
249private:
250 void cancelPam()
251 {
252 if (pamHandle != nullptr) {
253 QFuture<int> pamFuture = futureWatcher.future();
254 pam_handle *handle = pamHandle;
255 pamHandle = nullptr; // to disable normal finishPam() handling
256 pamFuture.cancel();
257
258 // Note the empty loop, we just want to clear the futures queue.
259 // Any further prompts from the pam thread will be immediately
260 // responded to/dismissed in handlePrompt().
261 while (respond(QString()));
262
263 // Now let signal/slot handling happen so the thread can finish
264 while (!pamFuture.isFinished()) {
265 QCoreApplication::processEvents();
266 }
267
268 pam_end(handle, PAM_CONV_ERR);
269 }
270 }
271
272 Greeter *greeter;
273 GreeterPrivate *greeterPrivate;
274 pam_handle* pamHandle;
275 QFutureWatcher<int> futureWatcher;
276 QQueue<ResponseFuture> futures;
277};
278
279GreeterPrivate::GreeterPrivate(Greeter* parent)
280 : authenticated(false),
281 authenticationUser(),
282 m_impl(new GreeterImpl(parent, this)),
283 q_ptr(parent)
284{
285}
286
287GreeterPrivate::~GreeterPrivate()
288{
289 delete m_impl;
290}
291
292void GreeterPrivate::handleAuthenticate()
293{
294 m_impl->start(authenticationUser);
295}
296
297void GreeterPrivate::handleRespond(const QString &response)
298{
299 m_impl->respond(response);
300}
301
302}
303
304#include "GreeterPrivate.moc"
3050
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h'
--- plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 2015-09-11 13:38:45 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1/*
2 * Copyright (C) 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 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 * Author: Michael Terry <michael.terry@canonical.com>
17 */
18
19#ifndef UNITY_MOCK_GREETER_PRIVATE_H
20#define UNITY_MOCK_GREETER_PRIVATE_H
21
22#include <QtCore/QObject>
23
24namespace QLightDM
25{
26class Greeter;
27class GreeterImpl;
28
29class GreeterPrivate
30{
31public:
32 explicit GreeterPrivate(Greeter* parent=0);
33 virtual ~GreeterPrivate();
34
35 // These variables may not be used by all subclasses, that's no problem
36 bool authenticated;
37 QString authenticationUser;
38
39 void handleAuthenticate();
40 void handleRespond(const QString &response);
41
42protected:
43 GreeterImpl *m_impl; // if the backend needs more private data
44 Greeter * const q_ptr;
45
46private:
47 Q_DECLARE_PUBLIC(Greeter)
48};
49}
50
51#endif // UNITY_MOCK_GREETER_PRIVATE_H
520
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp'
--- plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp 2016-06-15 15:29:34 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp 1970-01-01 00:00:00 +0000
@@ -1,88 +0,0 @@
1/*
2 * Copyright (C) 2015 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 */
17
18
19/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20 * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
21 * COUNTERPART IN tests/mocks/LightDM/IntegratedLightDM/liblightdm
22 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
23
24// LightDM currently is Qt4 compatible, and so doesn't define setRoleNames.
25// To use the same method of setting role name that it does, we
26// set our compatibility to Qt4 here too.
27#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
28
29#include "SessionsModel.h"
30#include "SessionsModelPrivate.h"
31#include <QtCore/QDir>
32#include <QtCore/QString>
33
34namespace QLightDM
35{
36
37SessionsModel::SessionsModel(QObject* parent) :
38 QAbstractListModel(parent),
39 d_ptr(new SessionsModelPrivate(this))
40{
41 Q_D(SessionsModel);
42 m_roleNames = QAbstractListModel::roleNames();
43 m_roleNames[KeyRole] = "key";
44 m_roleNames[TypeRole] = "type";
45}
46
47SessionsModel::~SessionsModel()
48{
49 delete d_ptr;
50}
51
52QVariant SessionsModel::data(const QModelIndex& index, int role) const
53{
54 Q_D(const SessionsModel);
55
56 if(!index.isValid()) {
57 return QVariant();
58 }
59
60 int row = index.row();
61
62 switch (role) {
63 case QLightDM::SessionsModel::KeyRole:
64 return d->sessionItems[row].key;
65 case Qt::DisplayRole:
66 return d->sessionItems[row].name;
67 default:
68 return QVariant();
69 }
70}
71
72QHash<int, QByteArray> SessionsModel::roleNames() const
73{
74 return m_roleNames;
75}
76
77int SessionsModel::rowCount(const QModelIndex& parent) const
78{
79 Q_D(const SessionsModel);
80
81 if (parent.isValid()) {
82 return 0;
83 } else { // parent is root
84 return d->sessionItems.size();
85 }
86}
87
88} // namespace QLightDM
890
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h'
--- plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h 2015-11-23 22:45:55 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * Copyright (C) 2015 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 */
17
18#ifndef UNITY_INTEGRATED_SESSIONSMODEL_H
19#define UNITY_INTEGRATED_SESSIONSMODEL_H
20
21#include <QtCore/QAbstractListModel>
22#include <QtCore/QString>
23
24/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25 * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
26 * COUNTERPART IN tests/mocks/LightDM/IntegratedLightDM/liblightdm
27 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
28
29// This is taken from liblightdm and modified to confirm to our syle conventions
30namespace QLightDM
31{
32class SessionsModelPrivate;
33
34class Q_DECL_EXPORT SessionsModel : public QAbstractListModel
35 {
36 Q_OBJECT
37
38 Q_ENUMS(SessionModelRoles SessionType)
39
40 public:
41
42 enum SessionModelRoles {
43 //name is exposed as Qt::DisplayRole
44 //comment is exposed as Qt::TooltipRole
45 KeyRole = Qt::UserRole,
46 IdRole = KeyRole, /** Deprecated */
47 TypeRole
48 };
49
50 enum SessionType {
51 LocalSessions,
52 RemoteSessions
53 };
54
55 explicit SessionsModel(QObject* parent=0); /** Deprecated. Loads local sessions*/
56 explicit SessionsModel(SessionsModel::SessionType, QObject* parent=0);
57 virtual ~SessionsModel();
58
59 QHash<int, QByteArray> roleNames() const override;
60 int rowCount(const QModelIndex& parent) const override;
61 QVariant data(const QModelIndex& index, int role) const override;
62
63 protected:
64 SessionsModelPrivate* const d_ptr;
65
66 private:
67 QHash<int, QByteArray> m_roleNames;
68 Q_DECLARE_PRIVATE(SessionsModel)
69 };
70}
71
72#endif // UNITY_INTEGRATED_SESSIONSMODEL_H
730
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp'
--- plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp 2016-06-24 15:47:41 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,36 +0,0 @@
1/*
2 * Copyright (C) 2015 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 */
17
18#include "SessionsModelPrivate.h"
19
20#include <QDir>
21#include <QSettings>
22#include <QStringList>
23
24namespace QLightDM
25{
26
27SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent)
28 : q_ptr(parent)
29{
30 // Since this model is never visible, as there is only 1 session,
31 // just use the session name as the key
32 QString sessionName = qgetenv("XDG_SESSION_DESKTOP");
33 sessionItems.append({sessionName, "", sessionName, ""});
34}
35
36} // namespace QLightDM
370
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h'
--- plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h 2016-06-23 16:00:11 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
1/*
2 * Copyright (C) 2015 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 */
17
18#ifndef UNITY_INTEGRATED_SESSIONSMODEL_PRIVATE_H
19#define UNITY_INTEGRATED_SESSIONSMODEL_PRIVATE_H
20
21#include <QtCore/QList>
22#include <QtCore/QString>
23
24namespace QLightDM
25{
26class SessionsModel;
27
28class SessionItem
29{
30public:
31 QString key;
32 QString type; // unused
33 QString name;
34 QString comment; // unused
35};
36
37class SessionsModelPrivate
38{
39public:
40 explicit SessionsModelPrivate(SessionsModel* parent=0);
41 virtual ~SessionsModelPrivate() = default;
42
43 QList<SessionItem> sessionItems;
44
45protected:
46 SessionsModel* const q_ptr;
47
48private:
49 Q_DECLARE_PUBLIC(SessionsModel)
50};
51
52} // namespace QLightDM
53
54#endif // UNITY_INTEGRATED_SESSIONSMODEL_PRIVATE_H
550
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp'
--- plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp 2016-08-08 14:15:49 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp 1970-01-01 00:00:00 +0000
@@ -1,110 +0,0 @@
1/*
2 * Copyright (C) 2013-2016 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 * Author: Michael Terry <michael.terry@canonical.com>
17 */
18
19
20/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
21 * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
22 * COUNTERPART IN tests/mocks/Lightdm/liblightdm
23 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
24
25// LightDM currently is Qt4 compatible, and so doesn't define setRoleNames.
26// To use the same method of setting role name that it does, we
27// set our compatibility to Qt4 here too.
28#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
29
30#include "UsersModel.h"
31#include "UsersModelPrivate.h"
32#include <QtCore/QDir>
33#include <QtCore/QString>
34#include <QtGui/QIcon>
35
36namespace QLightDM
37{
38
39UsersModel::UsersModel(QObject *parent) :
40 QAbstractListModel(parent),
41 d_ptr(new UsersModelPrivate(this))
42{
43 // Extend roleNames (we want to keep the "display" role)
44 QHash<int, QByteArray> roles = roleNames();
45 roles[NameRole] = "name";
46 roles[RealNameRole] = "realName";
47 roles[LoggedInRole] = "loggedIn";
48 roles[BackgroundRole] = "background";
49 roles[BackgroundPathRole] = "backgroundPath";
50 roles[SessionRole] = "session";
51 roles[HasMessagesRole] = "hasMessages";
52 roles[ImagePathRole] = "imagePath";
53 roles[UidRole] = "uid";
54 setRoleNames(roles);
55
56 connect(d_ptr, &UsersModelPrivate::dataChanged, this, [this](int i) {
57 QModelIndex index = createIndex(i, 0);
58 Q_EMIT dataChanged(index, index);
59 });
60}
61
62int UsersModel::rowCount(const QModelIndex &parent) const
63{
64 Q_D(const UsersModel);
65
66 if (parent.isValid()) {
67 return 0;
68 } else { // parent is root
69 return d->entries.size();
70 }
71}
72
73QVariant UsersModel::data(const QModelIndex &index, int role) const
74{
75 Q_D(const UsersModel);
76
77 if (!index.isValid()) {
78 return QVariant();
79 }
80
81 int row = index.row();
82 switch (role) {
83 case Qt::DisplayRole:
84 return d->entries[row].real_name;
85 case Qt::DecorationRole:
86 return QIcon();
87 case UsersModel::NameRole:
88 return d->entries[row].username;
89 case UsersModel::RealNameRole:
90 return d->entries[row].real_name;
91 case UsersModel::SessionRole:
92 return d->entries[row].session;
93 case UsersModel::LoggedInRole:
94 return d->entries[row].is_active;
95 case UsersModel::BackgroundRole:
96 return QPixmap(d->entries[row].background);
97 case UsersModel::BackgroundPathRole:
98 return d->entries[row].background;
99 case UsersModel::HasMessagesRole:
100 return d->entries[row].has_messages;
101 case UsersModel::ImagePathRole:
102 return "";
103 case UsersModel::UidRole:
104 return d->entries[row].uid;
105 default:
106 return QVariant();
107 }
108}
109
110}
1110
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.h'
--- plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.h 2016-06-27 14:51:40 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.h 1970-01-01 00:00:00 +0000
@@ -1,67 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 * Copyright (C) 2010-2011 David Edmundson.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Author: David Edmundson <kde@davidedmundson.co.uk>
18 */
19
20#ifndef UNITY_MOCK_USERSMODEL_H
21#define UNITY_MOCK_USERSMODEL_H
22
23#include <QtCore/QString>
24#include <QtCore/QSharedDataPointer>
25#include <QAbstractListModel>
26
27/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28 * CHANGES MADE HERE MUST BE REFLECTED ON THE MOCK LIB
29 * COUNTERPART IN tests/mocks/Lightdm/liblightdm
30 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
31
32namespace QLightDM
33{
34class UsersModelPrivate;
35
36class Q_DECL_EXPORT UsersModel : public QAbstractListModel
37{
38 Q_OBJECT
39
40 Q_ENUMS(UserModelRoles)
41
42public:
43 explicit UsersModel(QObject *parent = 0);
44 virtual ~UsersModel() = default;
45
46 enum UserModelRoles {NameRole = Qt::UserRole,
47 RealNameRole,
48 LoggedInRole,
49 BackgroundRole,
50 SessionRole,
51 HasMessagesRole,
52 ImagePathRole,
53 BackgroundPathRole,
54 UidRole
55 };
56
57 int rowCount(const QModelIndex &parent) const override;
58 QVariant data(const QModelIndex &index, int role) const override;
59
60private:
61 UsersModelPrivate * const d_ptr;
62 Q_DECLARE_PRIVATE(UsersModel)
63};
64
65}
66
67#endif // UNITY_MOCK_USERSMODEL_H
680
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp'
--- plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp 2016-07-05 13:52:07 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,94 +0,0 @@
1/*
2 * Copyright (C) 2013-2016 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 * Author: Michael Terry <michael.terry@canonical.com>
17 */
18
19#include "UsersModelPrivate.h"
20
21#include "AccountsServiceDBusAdaptor.h"
22#include "UsersModel.h"
23
24#include <glib.h>
25#include <QDebug>
26#include <QDir>
27#include <QSettings>
28#include <QStringList>
29#include <unistd.h>
30
31namespace QLightDM
32{
33
34UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
35 : QObject(parent),
36 q_ptr(parent),
37 m_service(new AccountsServiceDBusAdaptor(this))
38{
39 QFileInfo demoFile(QDir::homePath() + "/.unity8-greeter-demo");
40 QString currentUser = g_get_user_name();
41 uid_t currentUid = getuid();
42
43 if (demoFile.exists()) {
44 QSettings settings(demoFile.filePath(), QSettings::NativeFormat);
45 QStringList users = settings.value(QStringLiteral("users"), QStringList() << currentUser).toStringList();
46
47 entries.reserve(users.count());
48 Q_FOREACH(const QString &user, users)
49 {
50 QString name = settings.value(user + "/name", user).toString();
51 entries.append({user, name, 0, 0, false, false, 0, 0, currentUid++});
52 }
53 } else {
54 entries.append({currentUser, 0, 0, 0, false, false, 0, 0, currentUid});
55
56 connect(m_service, &AccountsServiceDBusAdaptor::maybeChanged,
57 this, [this](const QString &user) {
58 if (user == entries[0].username) {
59 updateName(true);
60 }
61 });
62 updateName(false);
63 }
64}
65
66void UsersModelPrivate::updateName(bool async)
67{
68 auto pendingReply = m_service->getUserPropertyAsync(entries[0].username,
69 QStringLiteral("org.freedesktop.Accounts.User"),
70 QStringLiteral("RealName"));
71 auto *watcher = new QDBusPendingCallWatcher(pendingReply, this);
72
73 connect(watcher, &QDBusPendingCallWatcher::finished,
74 this, [this](QDBusPendingCallWatcher* watcher) {
75
76 QDBusPendingReply<QVariant> reply = *watcher;
77 watcher->deleteLater();
78 if (reply.isError()) {
79 qWarning() << "Failed to get 'RealName' property - " << reply.error().message();
80 return;
81 }
82
83 const QString realName = reply.value().toString();
84 if (entries[0].real_name != realName) {
85 entries[0].real_name = realName;
86 Q_EMIT dataChanged(0);
87 }
88 });
89 if (!async) {
90 watcher->waitForFinished();
91 }
92}
93
94}
950
=== removed file 'plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h'
--- plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h 2016-06-27 14:51:40 +0000
+++ plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * Copyright (C) 2013-2016 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 * Author: Michael Terry <michael.terry@canonical.com>
17 */
18
19#ifndef UNITY_MOCK_USERSMODEL_PRIVATE_H
20#define UNITY_MOCK_USERSMODEL_PRIVATE_H
21
22#include <QList>
23#include <QObject>
24#include <QString>
25
26class AccountsServiceDBusAdaptor;
27
28namespace QLightDM
29{
30class UsersModel;
31
32class Entry
33{
34public:
35 QString username;
36 QString real_name;
37 QString background;
38 QString layouts;
39 bool is_active;
40 bool has_messages;
41 QString session;
42 QString infographic;
43 uid_t uid;
44};
45
46class UsersModelPrivate : public QObject
47{
48 Q_OBJECT
49
50public:
51 explicit UsersModelPrivate(UsersModel *parent = 0);
52 virtual ~UsersModelPrivate() = default;
53
54 QList<Entry> entries;
55
56Q_SIGNALS:
57 void dataChanged(int);
58
59protected:
60 UsersModel * const q_ptr;
61
62private:
63 Q_DECLARE_PUBLIC(UsersModel)
64
65 void updateName(bool async);
66
67 AccountsServiceDBusAdaptor *m_service;
68};
69
70}
71
72#endif // UNITY_MOCK_USERSMODEL_PRIVATE_H
730
=== removed file 'plugins/LightDM/IntegratedLightDM/qmldir'
--- plugins/LightDM/IntegratedLightDM/qmldir 2016-02-03 23:45:45 +0000
+++ plugins/LightDM/IntegratedLightDM/qmldir 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1module LightDM.IntegratedLightDM
2plugin IntegratedLightDM-qml
3typeinfo IntegratedLightDM.qmltypes
40
=== modified file 'plugins/LightDM/SessionsModel.cpp'
--- plugins/LightDM/SessionsModel.cpp 2016-06-15 20:28:58 +0000
+++ plugins/LightDM/SessionsModel.cpp 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -111,6 +111,11 @@
111 }111 }
112}112}
113113
114QObject *SessionsModel::mock()
115{
116 return m_model->property("mock").value<QObject*>();
117}
118
114SessionsModel::SessionsModel(QObject* parent)119SessionsModel::SessionsModel(QObject* parent)
115 : UnitySortFilterProxyModelQML(parent)120 : UnitySortFilterProxyModelQML(parent)
116{121{
@@ -120,7 +125,6 @@
120 m_roleNames[IconRole] = "icon_url";125 m_roleNames[IconRole] = "icon_url";
121126
122 setModel(m_model);127 setModel(m_model);
123 setSourceModel(m_model);
124 setSortCaseSensitivity(Qt::CaseInsensitive);128 setSortCaseSensitivity(Qt::CaseInsensitive);
125 setSortLocaleAware(true);129 setSortLocaleAware(true);
126 setSortRole(Qt::DisplayRole);130 setSortRole(Qt::DisplayRole);
127131
=== modified file 'plugins/LightDM/SessionsModel.h'
--- plugins/LightDM/SessionsModel.h 2015-11-24 00:25:27 +0000
+++ plugins/LightDM/SessionsModel.h 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -32,6 +32,9 @@
3232
33 Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories33 Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories
34 WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged)34 WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged)
35
36 Q_PROPERTY(QObject *mock READ mock CONSTANT) // for testing
37
35Q_SIGNALS:38Q_SIGNALS:
36 void iconSearchDirectoriesChanged();39 void iconSearchDirectoriesChanged();
3740
@@ -55,6 +58,9 @@
55 Q_INVOKABLE QUrl iconUrl(const QString sessionName) const;58 Q_INVOKABLE QUrl iconUrl(const QString sessionName) const;
5659
57 void setIconSearchDirectories(const QList<QUrl> searchDirectories);60 void setIconSearchDirectories(const QList<QUrl> searchDirectories);
61
62 QObject *mock();
63
58private:64private:
59 QLightDM::SessionsModel* m_model;65 QLightDM::SessionsModel* m_model;
60 QHash<int, QByteArray> m_roleNames;66 QHash<int, QByteArray> m_roleNames;
6167
=== modified file 'plugins/LightDM/UsersModel.cpp'
--- plugins/LightDM/UsersModel.cpp 2015-10-26 20:15:08 +0000
+++ plugins/LightDM/UsersModel.cpp 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013,2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -68,4 +68,11 @@
68 sort(0);68 sort(0);
69}69}
7070
71QObject *UsersModel::mock()
72{
73 // get through MangleModel down to QLightDM::UsersModel
74 MangleModel *mangleModel = static_cast<MangleModel*>(sourceModel());
75 return mangleModel->sourceModel()->property("mock").value<QObject*>();
76}
77
71#include "UsersModel.moc"78#include "UsersModel.moc"
7279
=== modified file 'plugins/LightDM/UsersModel.h'
--- plugins/LightDM/UsersModel.h 2015-09-11 13:38:45 +0000
+++ plugins/LightDM/UsersModel.h 2016-11-08 23:03:16 +0000
@@ -30,8 +30,12 @@
30{30{
31 Q_OBJECT31 Q_OBJECT
3232
33 Q_PROPERTY(QObject *mock READ mock CONSTANT) // for testing
34
33public:35public:
34 explicit UsersModel(QObject* parent=0);36 explicit UsersModel(QObject* parent=0);
37
38 QObject *mock();
35};39};
3640
37#endif41#endif
3842
=== modified file 'plugins/LightDM/plugin.cpp'
--- plugins/LightDM/plugin.cpp 2016-06-16 17:23:24 +0000
+++ plugins/LightDM/plugin.cpp 2016-11-08 23:03:16 +0000
@@ -63,20 +63,13 @@
63 return UserMetricsOutput::UserMetrics::getInstance();63 return UserMetricsOutput::UserMetrics::getInstance();
64}64}
6565
66void PLUGIN_CLASSNAME::registerTypes(const char *uri)66void LightDM::registerTypes(const char *uri)
67{67{
68 qmlRegisterType<QAbstractItemModel>();68 qmlRegisterType<QAbstractItemModel>();
69 qmlRegisterType<UserMetricsOutput::ColorTheme>();69 qmlRegisterType<UserMetricsOutput::ColorTheme>();
7070
71#if defined INTEGRATED_LIGHTDM71 Q_ASSERT(uri == QLatin1String("LightDM"));
72 Q_ASSERT(uri == QLatin1String("LightDM.IntegratedLightDM"));
73 qmlRegisterSingletonType<Greeter>(uri, 0, 1, "Greeter", greeter_provider);
74#elif defined FULL_LIGHTDM
75 Q_ASSERT(uri == QLatin1String("LightDM.FullLightDM"));
76 qmlRegisterSingletonType<QLightDM::Greeter>(uri, 0, 1, "Greeter", greeter_provider);72 qmlRegisterSingletonType<QLightDM::Greeter>(uri, 0, 1, "Greeter", greeter_provider);
77#else
78 #error No library defined in LightDM plugin
79#endif
8073
81 qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");74 qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");
82 qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");75 qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");
8376
=== modified file 'plugins/LightDM/plugin.h'
--- plugins/LightDM/plugin.h 2015-11-02 17:37:26 +0000
+++ plugins/LightDM/plugin.h 2016-11-08 23:03:16 +0000
@@ -21,7 +21,7 @@
21#include <QtQml/QQmlEngine>21#include <QtQml/QQmlEngine>
22#include <QtQml/QQmlExtensionPlugin>22#include <QtQml/QQmlExtensionPlugin>
2323
24class PLUGIN_CLASSNAME : public QQmlExtensionPlugin24class LightDM : public QQmlExtensionPlugin
25{25{
26 Q_OBJECT26 Q_OBJECT
27 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")27 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
2828
=== renamed file 'plugins/LightDM/FullLightDM/qmldir' => 'plugins/LightDM/qmldir'
--- plugins/LightDM/FullLightDM/qmldir 2016-02-03 23:45:45 +0000
+++ plugins/LightDM/qmldir 2016-11-08 23:03:16 +0000
@@ -1,3 +1,2 @@
1module LightDM.FullLightDM1module LightDM
2plugin FullLightDM-qml2plugin LightDM-qml
3typeinfo FullLightDM.qmltypes
43
=== modified file 'plugins/Unity/Session/dbusunitysessionservice.cpp'
--- plugins/Unity/Session/dbusunitysessionservice.cpp 2016-06-22 13:38:16 +0000
+++ plugins/Unity/Session/dbusunitysessionservice.cpp 2016-11-08 23:03:16 +0000
@@ -337,58 +337,16 @@
337 // user session.337 // user session.
338 Q_EMIT LockRequested();338 Q_EMIT LockRequested();
339 Q_EMIT lockRequested();339 Q_EMIT lockRequested();
340 Q_EMIT Locked();
340}341}
341342
342void DBusUnitySessionService::Lock()343void DBusUnitySessionService::Lock()
343{344{
344 // Normal lock (with animation, as compared to PromptLock above). Usually345 // Normal lock (with animation, as compared to PromptLock above). Usually
345 // used by indicator-session to lock the session in place.346 // used by indicator-session to lock the session in place.
346 //347 // Though here we don't really worry about the difference and just call
347 // FIXME: We also -- as a bit of a hack around indicator-session not fully348 // PromptLock.
348 // supporting a phone profile -- switch to greeter here. The unity7 flow is
349 // that the user chooses "Lock/Switch" from the indicator, and then can go
350 // to greeter by selecting "Switch" again from the indicator, which is now
351 // exposed by the desktop_lockscreen profile. But since in unity8, we try
352 // to expose most things all the time, we don't use the separate lockscreen
353 // profile. Instead, we just go directly to the greeter the first time
354 // a user presses "Lock/Switch". This isn't what this DBus call is
355 // supposed to do, but we can live with it for now.
356 //
357 // Here's a bug about indicator-session growing a converged Touch profile:
358 // https://launchpad.net/bugs/1557716
359 //
360 // We only do this here in the animated-lock call because that's the only
361 // time the indicator locks without also asking the display manager to
362 // switch sessions on us. And since we are switching screens, we also
363 // don't bother respecting the animate request, simply doing a PromptLock.
364 PromptLock();349 PromptLock();
365 switchToGreeter();
366}
367
368void DBusUnitySessionService::switchToGreeter()
369{
370 // lock the session using the org.freedesktop.DisplayManager system DBUS service
371 const QString sessionPath = QString::fromLocal8Bit(qgetenv("XDG_SESSION_PATH"));
372 QDBusMessage msg = QDBusMessage::createMethodCall(QStringLiteral("org.freedesktop.DisplayManager"),
373 sessionPath,
374 QStringLiteral("org.freedesktop.DisplayManager.Session"),
375 QStringLiteral("Lock"));
376
377 QDBusPendingCall pendingCall = QDBusConnection::SM_BUSNAME().asyncCall(msg);
378 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall, this);
379 connect(watcher, &QDBusPendingCallWatcher::finished,
380 this, [this](QDBusPendingCallWatcher* watcher) {
381
382 QDBusPendingReply<void> reply = *watcher;
383 watcher->deleteLater();
384 if (reply.isError()) {
385 qWarning() << "Lock call failed" << reply.error().message();
386 return;
387 }
388
389 // emit Locked when the call succeeds
390 Q_EMIT Locked();
391 });
392}350}
393351
394void DBusUnitySessionService::doUnlock()352void DBusUnitySessionService::doUnlock()
395353
=== modified file 'plugins/Unity/Session/dbusunitysessionservice.h'
--- plugins/Unity/Session/dbusunitysessionservice.h 2016-06-22 13:38:16 +0000
+++ plugins/Unity/Session/dbusunitysessionservice.h 2016-11-08 23:03:16 +0000
@@ -262,9 +262,6 @@
262262
263private Q_SLOTS:263private Q_SLOTS:
264 void doUnlock();264 void doUnlock();
265
266private:
267 void switchToGreeter();
268};265};
269266
270class DBusGnomeSessionManagerWrapper : public UnityDBusObject267class DBusGnomeSessionManagerWrapper : public UnityDBusObject
271268
=== modified file 'qml/Components/Dialogs.qml'
--- qml/Components/Dialogs.qml 2016-07-15 19:37:39 +0000
+++ qml/Components/Dialogs.qml 2016-11-08 23:03:16 +0000
@@ -19,10 +19,10 @@
19import Unity.Application 0.119import Unity.Application 0.1
20import Unity.Session 0.120import Unity.Session 0.1
21import GlobalShortcut 1.021import GlobalShortcut 1.0
22import LightDM 0.1 as LightDM
22import Ubuntu.Components 1.323import Ubuntu.Components 1.3
23import Unity.Platform 1.024import Unity.Platform 1.0
24import Utils 0.125import Utils 0.1
25import "../Greeter"
2626
27Item {27Item {
28 id: root28 id: root
@@ -112,12 +112,12 @@
112112
113 GlobalShortcut { // lock screen113 GlobalShortcut { // lock screen
114 shortcut: Qt.Key_ScreenSaver114 shortcut: Qt.Key_ScreenSaver
115 onTriggered: LightDMService.greeter.showGreeter()115 onTriggered: LightDM.Greeter.showGreeter()
116 }116 }
117117
118 GlobalShortcut { // lock screen118 GlobalShortcut { // lock screen
119 shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_L119 shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_L
120 onTriggered: LightDMService.greeter.showGreeter()120 onTriggered: LightDM.Greeter.showGreeter()
121 }121 }
122122
123 QtObject {123 QtObject {
@@ -151,7 +151,7 @@
151 Button {151 Button {
152 text: i18n.ctr("Button: Lock the system", "Lock")152 text: i18n.ctr("Button: Lock the system", "Lock")
153 onClicked: {153 onClicked: {
154 LightDMService.greeter.showGreeter()154 LightDM.Greeter.showGreeter()
155 logoutDialog.hide();155 logoutDialog.hide();
156 }156 }
157 }157 }
158158
=== removed file 'qml/Greeter/FullLightDMImpl.qml'
--- qml/Greeter/FullLightDMImpl.qml 2015-11-19 21:47:32 +0000
+++ qml/Greeter/FullLightDMImpl.qml 1970-01-01 00:00:00 +0000
@@ -1,30 +0,0 @@
1/*
2 * Copyright (C) 2015 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
17import QtQuick 2.4
18import LightDM.FullLightDM 0.1 as LightDM
19
20Item{
21 id: implementation
22
23 property var greeter: LightDM.Greeter
24 property var infographic: LightDM.Infographic
25 property var sessions: LightDM.Sessions
26 property var sessionRoles: LightDM.SessionRoles
27 property var users: LightDM.Users
28 property var userRoles: LightDM.UserRoles
29
30}
310
=== modified file 'qml/Greeter/Greeter.qml'
--- qml/Greeter/Greeter.qml 2016-09-22 10:33:39 +0000
+++ qml/Greeter/Greeter.qml 2016-11-08 23:03:16 +0000
@@ -18,13 +18,13 @@
18import AccountsService 0.118import AccountsService 0.1
19import Biometryd 0.019import Biometryd 0.0
20import GSettings 1.020import GSettings 1.0
21import LightDM 0.1 as LightDM
21import Powerd 0.122import Powerd 0.1
22import Ubuntu.Components 1.323import Ubuntu.Components 1.3
23import Ubuntu.SystemImage 0.124import Ubuntu.SystemImage 0.1
24import Unity.Launcher 0.125import Unity.Launcher 0.1
25import Unity.Session 0.126import Unity.Session 0.1
2627
27import "." 0.1
28import "../Components"28import "../Components"
2929
30Showable {30Showable {
@@ -51,7 +51,7 @@
51 readonly property bool hasLockedApp: lockedApp !== ""51 readonly property bool hasLockedApp: lockedApp !== ""
5252
53 property bool forcedUnlock53 property bool forcedUnlock
54 readonly property bool locked: LightDMService.greeter.active && !LightDMService.greeter.authenticated && !forcedUnlock54 readonly property bool locked: LightDM.Greeter.active && !LightDM.Greeter.authenticated && !forcedUnlock
5555
56 property bool tabletMode56 property bool tabletMode
57 property url viewSource // only used for testing57 property url viewSource // only used for testing
@@ -137,26 +137,21 @@
137 }137 }
138138
139 function sessionToStart() {139 function sessionToStart() {
140 for (var i = 0; i < LightDMService.sessions.count; i++) {140 for (var i = 0; i < LightDM.Sessions.count; i++) {
141 var session = LightDMService.sessions.data(i,141 var session = LightDM.Sessions.data(i, LightDM.SessionRoles.KeyRole);
142 LightDMService.sessionRoles.KeyRole);
143 if (loader.item.sessionToStart === session) {142 if (loader.item.sessionToStart === session) {
144 return session;143 return session;
145 }144 }
146 }145 }
147146
148 if (loader.item.sessionToStart === LightDMService.greeter.defaultSession) {147 return LightDM.Greeter.defaultSession;
149 return LightDMService.greeter.defaultSession;
150 } else {
151 return "ubuntu"; // The default / fallback
152 }
153 }148 }
154149
155 QtObject {150 QtObject {
156 id: d151 id: d
157152
158 readonly property bool multiUser: LightDMService.users.count > 1153 readonly property bool multiUser: LightDM.Users.count > 1
159 readonly property int selectUserIndex: d.getUserIndex(LightDMService.greeter.selectUser)154 readonly property int selectUserIndex: d.getUserIndex(LightDM.Greeter.selectUser)
160 property int currentIndex: Math.max(selectUserIndex, 0)155 property int currentIndex: Math.max(selectUserIndex, 0)
161 property bool waiting156 property bool waiting
162 property bool isLockscreen // true when we are locking an active session, rather than first user login157 property bool isLockscreen // true when we are locking an active session, rather than first user login
@@ -184,8 +179,8 @@
184 return -1;179 return -1;
185180
186 // Find index for requested user, if it exists181 // Find index for requested user, if it exists
187 for (var i = 0; i < LightDMService.users.count; i++) {182 for (var i = 0; i < LightDM.Users.count; i++) {
188 if (username === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {183 if (username === LightDM.Users.data(i, LightDM.UserRoles.NameRole)) {
189 return i;184 return i;
190 }185 }
191 }186 }
@@ -194,17 +189,17 @@
194 }189 }
195190
196 function selectUser(index, reset) {191 function selectUser(index, reset) {
197 if (index < 0 || index >= LightDMService.users.count)192 if (index < 0 || index >= LightDM.Users.count)
198 return;193 return;
199 d.waiting = true;194 d.waiting = true;
200 if (reset) {195 if (reset) {
201 loader.item.reset(false /* forceShow */);196 loader.item.reset(false /* forceShow */);
202 }197 }
203 currentIndex = index;198 currentIndex = index;
204 var user = LightDMService.users.data(index, LightDMService.userRoles.NameRole);199 var user = LightDM.Users.data(index, LightDM.UserRoles.NameRole);
205 AccountsService.user = user;200 AccountsService.user = user;
206 LauncherModel.setUser(user);201 LauncherModel.setUser(user);
207 LightDMService.greeter.authenticate(user); // always resets auth state202 LightDM.Greeter.authenticate(user); // always resets auth state
208 }203 }
209204
210 function hideView() {205 function hideView() {
@@ -212,18 +207,22 @@
212 loader.item.enabled = false; // drop OSK and prevent interaction207 loader.item.enabled = false; // drop OSK and prevent interaction
213 loader.item.notifyAuthenticationSucceeded(false /* showFakePassword */);208 loader.item.notifyAuthenticationSucceeded(false /* showFakePassword */);
214 loader.item.hide();209 loader.item.hide();
210 sessionStarted();
215 }211 }
216 }212 }
217213
218 function login() {214 function login() {
219 d.waiting = true;215 d.waiting = true;
220 if (LightDMService.greeter.startSessionSync(root.sessionToStart())) {216 var success = LightDM.Greeter.startSessionSync(root.sessionToStart());
221 sessionStarted();217 d.waiting = false;
222 hideView();218
223 } else if (loader.item) {219 // If successful as a lockscreen, we don't need to hide ourselves.
220 // logind will tell us to unlock if our current user logged in.
221
222 if (!success) {
224 loader.item.notifyAuthenticationFailed();223 loader.item.notifyAuthenticationFailed();
224 d.selectUser(d.currentIndex, false);
225 }225 }
226 d.waiting = false;
227 }226 }
228227
229 function startUnlock(toTheRight) {228 function startUnlock(toTheRight) {
@@ -236,6 +235,7 @@
236235
237 function checkForcedUnlock(hideNow) {236 function checkForcedUnlock(hideNow) {
238 if (forcedUnlock && shown) {237 if (forcedUnlock && shown) {
238 d.waiting = false;
239 hideView();239 hideView();
240 if (hideNow) {240 if (hideNow) {
241 root.hideNow(); // skip hide animation241 root.hideNow(); // skip hide animation
@@ -382,7 +382,7 @@
382 root.lockedApp = "";382 root.lockedApp = "";
383 item.forceActiveFocus();383 item.forceActiveFocus();
384 d.selectUser(d.currentIndex, true);384 d.selectUser(d.currentIndex, true);
385 LightDMService.infographic.readyForDataChange();385 LightDM.Infographic.readyForDataChange();
386 }386 }
387387
388 Connections {388 Connections {
@@ -392,7 +392,7 @@
392 }392 }
393 onResponded: {393 onResponded: {
394 if (root.locked) {394 if (root.locked) {
395 LightDMService.greeter.respond(response);395 LightDM.Greeter.respond(response);
396 } else {396 } else {
397 d.login();397 d.login();
398 }398 }
@@ -469,18 +469,18 @@
469 Binding {469 Binding {
470 target: loader.item470 target: loader.item
471 property: "userModel"471 property: "userModel"
472 value: LightDMService.users472 value: LightDM.Users
473 }473 }
474474
475 Binding {475 Binding {
476 target: loader.item476 target: loader.item
477 property: "infographicModel"477 property: "infographicModel"
478 value: LightDMService.infographic478 value: LightDM.Infographic
479 }479 }
480 }480 }
481481
482 Connections {482 Connections {
483 target: LightDMService.greeter483 target: LightDM.Greeter
484484
485 onShowGreeter: root.forceShow()485 onShowGreeter: root.forceShow()
486 onHideGreeter: root.forcedUnlock = true486 onHideGreeter: root.forcedUnlock = true
@@ -498,12 +498,12 @@
498 onAuthenticationComplete: {498 onAuthenticationComplete: {
499 d.waiting = false;499 d.waiting = false;
500500
501 if (LightDMService.greeter.authenticated) {501 if (LightDM.Greeter.authenticated) {
502 if (!LightDMService.greeter.promptless) {502 if (!LightDM.Greeter.promptless) {
503 d.login();503 d.login();
504 }504 }
505 } else {505 } else {
506 if (!LightDMService.greeter.promptless) {506 if (!LightDM.Greeter.promptless) {
507 AccountsService.failedLogins++;507 AccountsService.failedLogins++;
508 }508 }
509509
@@ -524,7 +524,7 @@
524 }524 }
525525
526 loader.item.notifyAuthenticationFailed();526 loader.item.notifyAuthenticationFailed();
527 if (!LightDMService.greeter.promptless) {527 if (!LightDM.Greeter.promptless) {
528 d.selectUser(d.currentIndex, false);528 d.selectUser(d.currentIndex, false);
529 }529 }
530 }530 }
@@ -543,20 +543,20 @@
543 }543 }
544544
545 Binding {545 Binding {
546 target: LightDMService.greeter546 target: LightDM.Greeter
547 property: "active"547 property: "active"
548 value: root.active548 value: root.active
549 }549 }
550550
551 Binding {551 Binding {
552 target: LightDMService.infographic552 target: LightDM.Infographic
553 property: "username"553 property: "username"
554 value: AccountsService.statsWelcomeScreen ? LightDMService.users.data(d.currentIndex, LightDMService.userRoles.NameRole) : ""554 value: AccountsService.statsWelcomeScreen ? LightDM.Users.data(d.currentIndex, LightDM.UserRoles.NameRole) : ""
555 }555 }
556556
557 Connections {557 Connections {
558 target: i18n558 target: i18n
559 onLanguageChanged: LightDMService.infographic.readyForDataChange()559 onLanguageChanged: LightDM.Infographic.readyForDataChange()
560 }560 }
561561
562 Observer {562 Observer {
@@ -606,7 +606,7 @@
606 failOperation("fingerprint reader is locked");606 failOperation("fingerprint reader is locked");
607 return;607 return;
608 }608 }
609 if (result !== LightDMService.users.data(d.currentIndex, LightDMService.userRoles.UidRole)) {609 if (result !== LightDM.Users.data(d.currentIndex, LightDM.UserRoles.UidRole)) {
610 AccountsService.failedFingerprintLogins++;610 AccountsService.failedFingerprintLogins++;
611 failOperation("not the selected user");611 failOperation("not the selected user");
612 return;612 return;
613613
=== removed file 'qml/Greeter/IntegratedLightDMImpl.qml'
--- qml/Greeter/IntegratedLightDMImpl.qml 2015-11-19 21:47:32 +0000
+++ qml/Greeter/IntegratedLightDMImpl.qml 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1/*
2 * Copyright (C) 2015 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
17import QtQuick 2.4
18import LightDM.IntegratedLightDM 0.1 as LightDM
19
20Item{
21 id: implementation
22
23 property var greeter: LightDM.Greeter
24 property var infographic: LightDM.Infographic
25 property var sessions: LightDM.Sessions
26 property var sessionRoles: LightDM.SessionRoles
27 property var users: LightDM.Users
28 property var userRoles: LightDM.UserRoles
29}
300
=== removed file 'qml/Greeter/LightDMService.qml'
--- qml/Greeter/LightDMService.qml 2015-11-19 21:47:32 +0000
+++ qml/Greeter/LightDMService.qml 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
1/*
2 * Copyright (C) 2015 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
17/**
18 * Lightweight wrapper that allows for loading integrated/real LightDM
19 * plugin
20 */
21
22pragma Singleton
23import QtQuick 2.4
24
25Loader {
26 id: loader
27
28 property var greeter: d.valid ? loader.item.greeter : null
29 property var infographic: d.valid ? loader.item.infographic : null
30 property var sessions: d.valid ? loader.item.sessions : null
31 property var sessionRoles: d.valid ? loader.item.sessionRoles : null
32 property var users: d.valid ? loader.item.users : null
33 property var userRoles: d.valid ? loader.item.userRoles : null
34
35 // This trickery handles cases where applicationArguments aren't provided
36 // such as during testing
37 property var fullLightDM: {
38 if (typeof applicationArguments !== "undefined") {
39 if (applicationArguments.mode === "greeter") {
40 return true;
41 }
42 }
43 return false;
44 }
45
46 source: fullLightDM ?
47 "FullLightDMImpl.qml" : "IntegratedLightDMImpl.qml"
48
49 QtObject {
50 id: d
51
52 property bool valid: loader.item !== null
53 }
54}
550
=== modified file 'qml/Greeter/LoginList.qml'
--- qml/Greeter/LoginList.qml 2016-09-22 10:33:39 +0000
+++ qml/Greeter/LoginList.qml 2016-11-08 23:03:16 +0000
@@ -17,8 +17,8 @@
17import QtQuick 2.417import QtQuick 2.4
18import QtGraphicalEffects 1.018import QtGraphicalEffects 1.0
19import Ubuntu.Components 1.319import Ubuntu.Components 1.3
20import LightDM 0.1 as LightDM
20import "../Components"21import "../Components"
21import "." 0.1
2222
23StyledItem {23StyledItem {
24 id: root24 id: root
@@ -165,7 +165,7 @@
165 }165 }
166166
167 delegate: Item {167 delegate: Item {
168 width: parent.width168 width: userList.width
169 height: root.cellHeight169 height: root.cellHeight
170170
171 readonly property bool belowHighlight: (userList.currentIndex < 0 && index > 0) || (userList.currentIndex >= 0 && index > userList.currentIndex)171 readonly property bool belowHighlight: (userList.currentIndex < 0 && index > 0) || (userList.currentIndex >= 0 && index > userList.currentIndex)
@@ -255,8 +255,8 @@
255255
256 readonly property alias icon: badge.source256 readonly property alias icon: badge.source
257257
258 visible: LightDMService.sessions.count > 1 &&258 visible: LightDM.Sessions.count > 1 &&
259 !LightDMService.users.data(userList.currentIndex, LightDMService.userRoles.LoggedInRole)259 !LightDM.Users.data(userList.currentIndex, LightDM.UserRoles.LoggedInRole)
260260
261 height: units.gu(3.5)261 height: units.gu(3.5)
262 width: units.gu(3.5)262 width: units.gu(3.5)
@@ -287,7 +287,7 @@
287 anchors.margins: units.dp(3)287 anchors.margins: units.dp(3)
288 keyColor: "#ffffff" // icon providers give us white icons288 keyColor: "#ffffff" // icon providers give us white icons
289 color: theme.palette.normal.raisedSecondaryText289 color: theme.palette.normal.raisedSecondaryText
290 source: LightDMService.sessions.iconUrl(root.currentSession)290 source: LightDM.Sessions.iconUrl(root.currentSession)
291 }291 }
292292
293 Keys.onReturnPressed: {293 Keys.onReturnPressed: {
@@ -302,9 +302,9 @@
302 // Refresh the icon path if looking at different places at runtime302 // Refresh the icon path if looking at different places at runtime
303 // this is mainly for testing303 // this is mainly for testing
304 Connections {304 Connections {
305 target: LightDMService.sessions305 target: LightDM.Sessions
306 onIconSearchDirectoriesChanged: {306 onIconSearchDirectoriesChanged: {
307 badge.source = LightDMService.sessions.iconUrl(root.currentSession)307 badge.source = LightDM.Sessions.iconUrl(root.currentSession)
308 }308 }
309 }309 }
310 }310 }
311311
=== modified file 'qml/Greeter/NarrowView.qml'
--- qml/Greeter/NarrowView.qml 2016-08-30 20:23:15 +0000
+++ qml/Greeter/NarrowView.qml 2016-11-08 23:03:16 +0000
@@ -34,7 +34,7 @@
34 property alias alphanumeric: loginList.alphanumeric34 property alias alphanumeric: loginList.alphanumeric
35 property alias userModel: loginList.model35 property alias userModel: loginList.model
36 property alias infographicModel: coverPage.infographicModel36 property alias infographicModel: coverPage.infographicModel
37 property string sessionToStart37 property alias sessionToStart: loginList.currentSession
38 property bool waiting38 property bool waiting
39 readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown39 readonly property bool fullyShown: coverPage.showProgress === 1 || lockscreen.shown
40 readonly property bool required: coverPage.required || lockscreen.required40 readonly property bool required: coverPage.required || lockscreen.required
4141
=== modified file 'qml/Greeter/SessionsList.qml'
--- qml/Greeter/SessionsList.qml 2016-09-13 17:13:27 +0000
+++ qml/Greeter/SessionsList.qml 2016-11-08 23:03:16 +0000
@@ -17,7 +17,7 @@
17import QtQuick 2.417import QtQuick 2.4
18import Ubuntu.Components 1.318import Ubuntu.Components 1.3
19import Ubuntu.Components.ListItems 1.319import Ubuntu.Components.ListItems 1.3
20import "." 0.120import LightDM 0.1 as LightDM
21import "../Components"21import "../Components"
2222
23Item {23Item {
@@ -43,8 +43,8 @@
43 }43 }
4444
45 function currentKey() {45 function currentKey() {
46 var session = LightDMService.sessions.data(46 var session = LightDM.Sessions.data(
47 sessionsList.currentIndex, LightDMService.sessionRoles.KeyRole)47 sessionsList.currentIndex, LightDM.SessionRoles.KeyRole)
48 return session;48 return session;
49 }49 }
5050
@@ -111,7 +111,7 @@
111111
112 boundsBehavior: Flickable.StopAtBounds112 boundsBehavior: Flickable.StopAtBounds
113113
114 model: LightDMService.sessions114 model: LightDM.Sessions
115 header: ListItemLayout {115 header: ListItemLayout {
116 id: header116 id: header
117117
118118
=== modified file 'qml/Greeter/WideView.qml'
--- qml/Greeter/WideView.qml 2016-09-07 17:13:38 +0000
+++ qml/Greeter/WideView.qml 2016-11-08 23:03:16 +0000
@@ -16,7 +16,7 @@
1616
17import QtQuick 2.417import QtQuick 2.4
18import Ubuntu.Components 1.318import Ubuntu.Components 1.3
19import "." 0.119import LightDM 0.1 as LightDM
2020
21FocusScope {21FocusScope {
22 id: root22 id: root
@@ -125,6 +125,8 @@
125 id: loginList125 id: loginList
126 objectName: "loginList"126 objectName: "loginList"
127127
128 property int selectedUserIndex: 0
129
128 width: units.gu(40)130 width: units.gu(40)
129 anchors {131 anchors {
130 left: parent.left132 left: parent.left
@@ -139,9 +141,14 @@
139 Behavior on boxVerticalOffset { UbuntuNumberAnimation {} }141 Behavior on boxVerticalOffset { UbuntuNumberAnimation {} }
140142
141 model: root.userModel143 model: root.userModel
142 currentSession: LightDMService.greeter.defaultSession144 currentSession: LightDM.Users.data(selectedUserIndex,
145 LightDM.UserRoles.SessionRole);
143 onResponded: root.responded(response)146 onResponded: root.responded(response)
144 onSelected: root.selected(index)147 onSelected: {
148 LightDM.Users.mock.currentUsername = currentUser;
149 root.selected(index)
150 selectedUserIndex = index;
151 }
145 onSessionChooserButtonClicked: parent.state = "SessionsList"152 onSessionChooserButtonClicked: parent.state = "SessionsList"
146153
147 Keys.forwardTo: [sessionChooserLoader.item]154 Keys.forwardTo: [sessionChooserLoader.item]
148155
=== removed file 'qml/Greeter/qmldir'
--- qml/Greeter/qmldir 2015-10-20 00:59:12 +0000
+++ qml/Greeter/qmldir 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1singleton LightDMService 0.1 LightDMService.qml
20
=== modified file 'qml/Shell.qml'
--- qml/Shell.qml 2016-10-03 11:15:27 +0000
+++ qml/Shell.qml 2016-11-08 23:03:16 +0000
@@ -27,6 +27,7 @@
27import GlobalShortcut 1.0 // has to be before Utils, because of WindowInputFilter27import GlobalShortcut 1.0 // has to be before Utils, because of WindowInputFilter
28import GSettings 1.028import GSettings 1.0
29import ImageCache 0.129import ImageCache 0.1
30import LightDM 0.1 as LightDM
30import Utils 0.131import Utils 0.1
31import Powerd 0.132import Powerd 0.1
32import SessionBroadcast 0.133import SessionBroadcast 0.1
@@ -201,6 +202,12 @@
201 value: ApplicationManager202 value: ApplicationManager
202 }203 }
203204
205 Binding {
206 target: AccountsService
207 property: "greeterMode"
208 value: shell.mode === "greeter"
209 }
210
204 Component.onCompleted: {211 Component.onCompleted: {
205 finishStartUpTimer.start();212 finishStartUpTimer.start();
206 }213 }
@@ -430,7 +437,7 @@
430 if (shell.mode === "greeter") {437 if (shell.mode === "greeter") {
431 SessionBroadcast.requestHomeShown(AccountsService.user);438 SessionBroadcast.requestHomeShown(AccountsService.user);
432 } else {439 } else {
433 var animate = !LightDMService.greeter.active && !stages.shown;440 var animate = !LightDM.Greeter.active && !stages.shown;
434 dash.setCurrentScope(0, animate, false);441 dash.setCurrentScope(0, animate, false);
435 ApplicationManager.requestFocusApplication("unity8-dash");442 ApplicationManager.requestFocusApplication("unity8-dash");
436 }443 }
@@ -488,7 +495,7 @@
488 readonly property bool focusedSurfaceIsFullscreen: MirFocusController.focusedSurface495 readonly property bool focusedSurfaceIsFullscreen: MirFocusController.focusedSurface
489 ? MirFocusController.focusedSurface.state === Mir.FullscreenState496 ? MirFocusController.focusedSurface.state === Mir.FullscreenState
490 : false497 : false
491 fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0)498 fullscreenMode: (focusedSurfaceIsFullscreen && !LightDM.Greeter.active && launcher.progress === 0)
492 || greeter.hasLockedApp499 || greeter.hasLockedApp
493 locked: greeter && greeter.active500 locked: greeter && greeter.active
494 }501 }
495502
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2016-08-22 15:39:16 +0000
+++ tests/CMakeLists.txt 2016-11-08 23:03:16 +0000
@@ -45,8 +45,8 @@
4545
46 set(ld_paths)46 set(ld_paths)
47 list(APPEND ld_paths47 list(APPEND ld_paths
48 ${UNITY_MOCKPATH}/liblightdm
48 ${UNITY_MOCKPATH}/libusermetrics49 ${UNITY_MOCKPATH}/libusermetrics
49 ${UNITY_MOCKPATH}/LightDM/IntegratedLightDM/liblightdm
50 )50 )
5151
52 string(REPLACE ";" ":" ld_library_path "${ld_paths}")52 string(REPLACE ";" ":" ld_library_path "${ld_paths}")
5353
=== modified file 'tests/autopilot/unity8/fixture_setup.py'
--- tests/autopilot/unity8/fixture_setup.py 2015-10-26 20:15:08 +0000
+++ tests/autopilot/unity8/fixture_setup.py 2016-11-08 23:03:16 +0000
@@ -74,7 +74,7 @@
74 def _get_lightdm_mock_path(self):74 def _get_lightdm_mock_path(self):
75 lib_path = get_mocks_library_path()75 lib_path = get_mocks_library_path()
76 lightdm_mock_path = os.path.abspath(76 lightdm_mock_path = os.path.abspath(
77 os.path.join(lib_path, "LightDM" ,"IntegratedLightDM", "liblightdm")77 os.path.join(lib_path, "liblightdm")
78 )78 )
7979
80 if not os.path.exists(lightdm_mock_path):80 if not os.path.exists(lightdm_mock_path):
8181
=== modified file 'tests/autopilot/unity8/shell/tests/__init__.py'
--- tests/autopilot/unity8/shell/tests/__init__.py 2015-10-26 20:15:08 +0000
+++ tests/autopilot/unity8/shell/tests/__init__.py 2016-11-08 23:03:16 +0000
@@ -261,7 +261,7 @@
261 def _get_lightdm_mock_path(self):261 def _get_lightdm_mock_path(self):
262 lib_path = get_mocks_library_path()262 lib_path = get_mocks_library_path()
263 lightdm_mock_path = os.path.abspath(263 lightdm_mock_path = os.path.abspath(
264 os.path.join(lib_path, "LightDM" ,"IntegratedLightDM", "liblightdm")264 os.path.join(lib_path, "liblightdm")
265 )265 )
266266
267 if not os.path.exists(lightdm_mock_path):267 if not os.path.exists(lightdm_mock_path):
268268
=== modified file 'tests/mocks/AccountsService/AccountsService.cpp'
--- tests/mocks/AccountsService/AccountsService.cpp 2016-08-04 14:05:54 +0000
+++ tests/mocks/AccountsService/AccountsService.cpp 2016-11-08 23:03:16 +0000
@@ -15,7 +15,8 @@
15 */15 */
1616
17#include "AccountsService.h"17#include "AccountsService.h"
18#include "MockUsersModel.h"18#include "MockController.h"
19#include "UsersModel.h"
1920
20#include <QLightDM/UsersModel>21#include <QLightDM/UsersModel>
21#include <paths.h>22#include <paths.h>
@@ -26,6 +27,7 @@
26 m_enableLauncherWhileLocked(true),27 m_enableLauncherWhileLocked(true),
27 m_enableIndicatorsWhileLocked(true),28 m_enableIndicatorsWhileLocked(true),
28 m_backgroundFile(),29 m_backgroundFile(),
30 m_greeterMode(true),
29 m_statsWelcomeScreen(true),31 m_statsWelcomeScreen(true),
30 m_failedLogins(0),32 m_failedLogins(0),
31 m_failedFingerprintLogins(0),33 m_failedFingerprintLogins(0),
@@ -33,9 +35,8 @@
33 m_demoEdgesCompleted(),35 m_demoEdgesCompleted(),
34 m_hereEnabled(false),36 m_hereEnabled(false),
35 m_hereLicensePath(""),37 m_hereLicensePath(""),
36 m_usersModel(new MockUsersModel(this))38 m_usersModel(new UsersModel(this))
37{39{
38 m_usersModel->setMockMode("full");
39}40}
4041
41QString AccountsService::user() const42QString AccountsService::user() const
@@ -51,6 +52,19 @@
51 Q_EMIT backgroundFileChanged();52 Q_EMIT backgroundFileChanged();
52}53}
5354
55bool AccountsService::greeterMode() const
56{
57 return m_greeterMode;
58}
59
60void AccountsService::setGreeterMode(bool greeterMode)
61{
62 if (m_greeterMode != greeterMode) {
63 m_greeterMode = greeterMode;
64 Q_EMIT greeterModeChanged();
65 }
66}
67
54bool AccountsService::demoEdges() const68bool AccountsService::demoEdges() const
55{69{
56 return m_demoEdges;70 return m_demoEdges;
5771
=== modified file 'tests/mocks/AccountsService/AccountsService.h'
--- tests/mocks/AccountsService/AccountsService.h 2016-08-30 13:43:08 +0000
+++ tests/mocks/AccountsService/AccountsService.h 2016-11-08 23:03:16 +0000
@@ -22,7 +22,7 @@
22#include <QStringList>22#include <QStringList>
23#include <QVariant>23#include <QVariant>
2424
25class MockUsersModel;25class UsersModel;
2626
27class AccountsService: public QObject27class AccountsService: public QObject
28{28{
@@ -32,6 +32,10 @@
32 READ user32 READ user
33 WRITE setUser33 WRITE setUser
34 NOTIFY userChanged)34 NOTIFY userChanged)
35 Q_PROPERTY (bool greeterMode
36 READ greeterMode
37 WRITE setGreeterMode
38 NOTIFY greeterModeChanged)
35 Q_PROPERTY (bool demoEdges39 Q_PROPERTY (bool demoEdges
36 READ demoEdges40 READ demoEdges
37 WRITE setDemoEdges41 WRITE setDemoEdges
@@ -99,6 +103,8 @@
99103
100 QString user() const;104 QString user() const;
101 void setUser(const QString &user);105 void setUser(const QString &user);
106 bool greeterMode() const;
107 void setGreeterMode(bool greeterMode);
102 bool demoEdges() const;108 bool demoEdges() const;
103 void setDemoEdges(bool demoEdges);109 void setDemoEdges(bool demoEdges);
104 QStringList demoEdgesCompleted() const;110 QStringList demoEdgesCompleted() const;
@@ -133,6 +139,7 @@
133139
134Q_SIGNALS:140Q_SIGNALS:
135 void userChanged();141 void userChanged();
142 void greeterModeChanged();
136 void demoEdgesChanged();143 void demoEdgesChanged();
137 void demoEdgesCompletedChanged();144 void demoEdgesCompletedChanged();
138 void enableFingerprintIdentificationChanged();145 void enableFingerprintIdentificationChanged();
@@ -155,6 +162,7 @@
155 bool m_enableIndicatorsWhileLocked;162 bool m_enableIndicatorsWhileLocked;
156 QString m_backgroundFile;163 QString m_backgroundFile;
157 QString m_user;164 QString m_user;
165 bool m_greeterMode;
158 bool m_statsWelcomeScreen;166 bool m_statsWelcomeScreen;
159 uint m_failedLogins;167 uint m_failedLogins;
160 uint m_failedFingerprintLogins;168 uint m_failedFingerprintLogins;
@@ -165,7 +173,7 @@
165 QString m_realName;173 QString m_realName;
166 QStringList m_kbdMap;174 QStringList m_kbdMap;
167 QString m_email;175 QString m_email;
168 MockUsersModel *m_usersModel;176 UsersModel *m_usersModel;
169};177};
170178
171#endif179#endif
172180
=== modified file 'tests/mocks/AccountsService/CMakeLists.txt'
--- tests/mocks/AccountsService/CMakeLists.txt 2016-08-04 14:05:54 +0000
+++ tests/mocks/AccountsService/CMakeLists.txt 2016-11-08 23:03:16 +0000
@@ -2,13 +2,17 @@
2 ${CMAKE_CURRENT_BINARY_DIR}2 ${CMAKE_CURRENT_BINARY_DIR}
3 ${CMAKE_SOURCE_DIR}/plugins/LightDM3 ${CMAKE_SOURCE_DIR}/plugins/LightDM
4 ${CMAKE_SOURCE_DIR}/plugins/Utils4 ${CMAKE_SOURCE_DIR}/plugins/Utils
5 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM5 ${CMAKE_SOURCE_DIR}/tests/mocks/liblightdm
6 )
7
8include_directories(
9 SYSTEM
10 ${LIBLIGHTDM_INCLUDE_DIRS}
6 )11 )
712
8add_library(MockAccountsService-qml MODULE13add_library(MockAccountsService-qml MODULE
9 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp14 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
10 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp15 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
11 ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp
12 AccountsService.cpp16 AccountsService.cpp
13 plugin.cpp17 plugin.cpp
14 )18 )
1519
=== modified file 'tests/mocks/CMakeLists.txt'
--- tests/mocks/CMakeLists.txt 2016-06-29 18:05:44 +0000
+++ tests/mocks/CMakeLists.txt 2016-11-08 23:03:16 +0000
@@ -33,8 +33,8 @@
33add_subdirectory(Cursor)33add_subdirectory(Cursor)
34add_subdirectory(GSettings.1.0)34add_subdirectory(GSettings.1.0)
35add_subdirectory(indicator-service)35add_subdirectory(indicator-service)
36add_subdirectory(liblightdm)
36add_subdirectory(libusermetrics)37add_subdirectory(libusermetrics)
37add_subdirectory(LightDM)
38add_subdirectory(Lights)38add_subdirectory(Lights)
39add_subdirectory(MeeGo)39add_subdirectory(MeeGo)
40add_subdirectory(Powerd)40add_subdirectory(Powerd)
4141
=== removed directory 'tests/mocks/LightDM'
=== removed file 'tests/mocks/LightDM/CMakeLists.txt'
--- tests/mocks/LightDM/CMakeLists.txt 2015-09-25 13:01:00 +0000
+++ tests/mocks/LightDM/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
1add_subdirectory(IntegratedLightDM)
20
=== removed directory 'tests/mocks/LightDM/IntegratedLightDM'
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt'
--- tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt 2015-11-19 00:25:25 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1# This is a copy of the normal LightDM plugin, but instead of statically
2# linking in the lightdm bits, this one uses shared libraries so we can swap
3# out different sets of users for different tests. When we finally switch to
4# actually using the system liblightdm in the normal plugin, this version can
5# be deleted.
6
7add_subdirectory(liblightdm)
8
9include_directories(
10 ${CMAKE_CURRENT_SOURCE_DIR}
11 ${CMAKE_CURRENT_BINARY_DIR}
12 ${CMAKE_SOURCE_DIR}/plugins/Utils
13 ${CMAKE_SOURCE_DIR}/plugins/LightDM
14 ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics
15 ${libunity8-private_SOURCE_DIR}
16)
17
18set(QMLPLUGIN_SRC
19 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeter.cpp
20 ${CMAKE_SOURCE_DIR}/plugins/LightDM/DBusGreeterList.cpp
21 ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
22 ${CMAKE_SOURCE_DIR}/plugins/LightDM/SessionsModel.cpp
23 ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
24 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
25 MockGreeter.cpp
26 MockSessionsModel.cpp
27 MockUsersModel.cpp
28 plugin.cpp
29 )
30
31add_library(MockLightDM-qml MODULE
32 ${QMLPLUGIN_SRC}
33 )
34
35# We want to link to liblightdm-qt5-3, but we don't want to depend on it being
36# installed on the system. So we make sure we link to our full fake version
37# At run time, we can point to whichever version we happen to be using via
38# LD_LIBRARY_PATH.
39target_link_libraries(MockLightDM-qml
40 MockLightDM
41 MockUserMetrics
42 unity8-private
43 )
44
45qt5_use_modules(MockLightDM-qml DBus Gui Qml)
46
47add_unity8_mock(LightDM.IntegratedLightDM 0.1 LightDM/IntegratedLightDM
48 PREFIX mocks
49 TARGETS MockLightDM-qml
50 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/liblightdm"
51)
520
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp 2016-06-09 21:45:09 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
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 */
17
18#include "MockGreeter.h"
19#include <GreeterPrivate.h>
20
21QString MockGreeter::mockMode() const
22{
23 Q_D(const Greeter);
24 return d->m_greeter->mockMode();
25}
26
27void MockGreeter::setMockMode(QString mockMode)
28{
29 Q_D(Greeter);
30
31 if (d->m_greeter->mockMode() != mockMode) {
32 d->m_greeter->setMockMode(mockMode);
33 Q_EMIT mockModeChanged(mockMode);
34 }
35}
36
37QString MockGreeter::selectUserHint() const
38{
39 Q_D(const Greeter);
40 return d->m_greeter->selectUserHint();
41}
42
43void MockGreeter::setSelectUserHint(const QString &selectUserHint)
44{
45 Q_D(Greeter);
46
47 if (d->m_greeter->selectUserHint() != selectUserHint) {
48 d->m_greeter->setSelectUserHint(selectUserHint);
49 Q_EMIT selectUserHintChanged();
50 }
51}
520
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h'
--- tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h 2016-06-09 21:45:09 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h 1970-01-01 00:00:00 +0000
@@ -1,42 +0,0 @@
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 */
17
18// The real, production, Greeter
19#include <Greeter.h>
20
21#ifndef MOCK_UNITY_GREETER_H
22#define MOCK_UNITY_GREETER_H
23
24class MockGreeter : public Greeter {
25 Q_OBJECT
26
27 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
28 Q_PROPERTY(QString selectUser READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged)
29
30public:
31 QString mockMode() const;
32 void setMockMode(QString mockMode);
33
34 QString selectUserHint() const;
35 void setSelectUserHint(const QString &selectUserHint);
36
37Q_SIGNALS:
38 void mockModeChanged(QString mode);
39 void selectUserHintChanged();
40};
41
42#endif // MOCK_UNITY_GREETER_H
430
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp 2016-07-13 20:24:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp 1970-01-01 00:00:00 +0000
@@ -1,66 +0,0 @@
1/*
2 * Copyright (C) 2015 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 */
17
18#include "MockSessionsModel.h"
19#include <QLightDM/SessionsModel>
20
21
22int MockSessionsModel::numSessions() const
23{
24 QLightDM::SessionsModel* qSessionsModel =
25 static_cast<QLightDM::SessionsModel*>(sourceModel());
26
27 return qSessionsModel->numSessions();
28}
29
30int MockSessionsModel::numAvailableSessions() const
31{
32 QLightDM::SessionsModel* qSessionsModel =
33 static_cast<QLightDM::SessionsModel*>(sourceModel());
34
35 return qSessionsModel->numAvailableSessions();
36}
37
38QString MockSessionsModel::testScenario() const
39{
40 QLightDM::SessionsModel* qSessionsModel =
41 static_cast<QLightDM::SessionsModel*>(sourceModel());
42
43 return qSessionsModel->testScenario();
44}
45
46void MockSessionsModel::setNumSessions(const int numSessions)
47{
48 QLightDM::SessionsModel* qSessionsModel =
49 static_cast<QLightDM::SessionsModel*>(sourceModel());
50
51 if (qSessionsModel->numSessions() != numSessions) {
52 qSessionsModel->setNumSessions(numSessions);
53 Q_EMIT numSessionsChanged();
54 }
55}
56
57void MockSessionsModel::setTestScenario(const QString testScenario)
58{
59 QLightDM::SessionsModel* qSessionsModel =
60 static_cast<QLightDM::SessionsModel*>(sourceModel());
61
62 if (qSessionsModel->testScenario() != testScenario) {
63 qSessionsModel->setTestScenario(testScenario);
64 Q_EMIT testScenarioChanged();
65 }
66}
670
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h'
--- tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h 2016-07-13 20:24:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
1/*
2 * Copyright (C) 2015 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 */
17
18#ifndef MOCK_UNITY_SESSIONSMODEL_H
19#define MOCK_UNITY_SESSIONSMODEL_H
20
21#include <SessionsModel.h>
22
23class MockSessionsModel : public SessionsModel
24{
25 Q_OBJECT
26
27 Q_PROPERTY(int numAvailableSessions READ numAvailableSessions CONSTANT)
28 Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)
29 Q_PROPERTY(QString testScenario READ testScenario WRITE setTestScenario NOTIFY testScenarioChanged)
30
31public:
32 int numAvailableSessions() const;
33 int numSessions() const;
34 QString testScenario() const;
35 void setNumSessions(const int numSessions);
36 void setTestScenario(const QString testScenario);
37
38Q_SIGNALS:
39 void numSessionsChanged();
40 void testScenarioChanged();
41
42};
43
44#endif // MOCK_UNITY_SESSIONSMODEL_H
450
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp 2016-08-04 14:05:54 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp 1970-01-01 00:00:00 +0000
@@ -1,44 +0,0 @@
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 */
17
18#include "MockUsersModel.h"
19#include <QLightDM/UsersModel>
20#include <QSortFilterProxyModel>
21
22MockUsersModel::MockUsersModel(QObject* parent)
23 : UsersModel(parent)
24{
25}
26
27QString MockUsersModel::mockMode() const
28{
29 QLightDM::UsersModel* qUsersModel =
30 static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel());
31
32 return qUsersModel->mockMode();
33}
34
35void MockUsersModel::setMockMode(QString mockMode)
36{
37 QLightDM::UsersModel* qUsersModel =
38 static_cast<QLightDM::UsersModel*>(static_cast<QSortFilterProxyModel*>(sourceModel())->sourceModel());
39
40 if (qUsersModel->mockMode() != mockMode) {
41 qUsersModel->setMockMode(mockMode);
42 Q_EMIT mockModeChanged(mockMode);
43 }
44}
450
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h'
--- tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h 2016-08-04 14:05:54 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
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 */
17
18#ifndef MOCK_UNITY_USERSMODEL_H
19#define MOCK_UNITY_USERSMODEL_H
20
21#include <UsersModel.h>
22
23class MockUsersModel : public UsersModel
24{
25 Q_OBJECT
26
27 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
28
29public:
30 explicit MockUsersModel(QObject* parent=0);
31
32 QString mockMode() const;
33 void setMockMode(QString mockMode);
34
35Q_SIGNALS:
36 void mockModeChanged(QString mode);
37};
38
39#endif // MOCK_UNITY_USERSMODEL_H
400
=== removed directory 'tests/mocks/LightDM/IntegratedLightDM/QLightDM'
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter'
--- tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter 2015-01-20 11:50:19 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
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
17#include "../liblightdm/Greeter.h"
180
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel'
--- tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel 2015-11-18 03:52:01 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
1/*
2 * Copyright (C) 2015 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
17#include "../liblightdm/SessionsModel.h"
180
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel'
--- tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel 2015-01-20 11:50:19 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel 1970-01-01 00:00:00 +0000
@@ -1,17 +0,0 @@
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
17#include "../liblightdm/UsersModel.h"
180
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp 2016-06-09 21:45:09 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,132 +0,0 @@
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
17#include "Greeter.h"
18#include "GreeterPrivate.h"
19
20namespace QLightDM
21{
22
23GreeterPrivate::GreeterPrivate(Greeter* parent)
24 : authenticated(false),
25 authenticationUser(),
26 twoFactorDone(false),
27 mockMode("single"),
28 q_ptr(parent)
29{
30 char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE");
31 if (envMockMode) {
32 mockMode = envMockMode;
33 }
34}
35
36void GreeterPrivate::handleAuthenticate()
37{
38 Q_Q(Greeter);
39
40 if (mockMode == "single") {
41 authenticated = true;
42 Q_EMIT q->authenticationComplete();
43 } else if (mockMode == "single-passphrase" || mockMode == "single-pin") {
44 Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
45 } else if (mockMode == "full") {
46 handleAuthenticate_full();
47 }
48}
49
50void GreeterPrivate::handleAuthenticate_full()
51{
52 Q_Q(Greeter);
53
54 // Send out any messages we need to
55 if (authenticationUser == "info-prompt")
56 Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
57 else if (authenticationUser == "wide-info-prompt")
58 Q_EMIT q->showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo);
59 else if (authenticationUser == "html-info-prompt")
60 Q_EMIT q->showMessage("<b>&</b>", Greeter::MessageTypeInfo);
61 else if (authenticationUser == "long-info-prompt")
62 Q_EMIT q->showMessage("Welcome to Unity Greeter\n\nWe like to annoy you with super ridiculously long messages.\nLike this one\n\nThis is the last line of a multiple line message.", Greeter::MessageTypeInfo);
63 else if (authenticationUser == "multi-info-prompt") {
64 Q_EMIT q->showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
65 Q_EMIT q->showMessage("This is an error", Greeter::MessageTypeError);
66 Q_EMIT q->showMessage("You should have seen three messages", Greeter::MessageTypeInfo);
67 }
68
69 // OK, now actually do the prompt
70 if (authenticationUser == "no-password") {
71 authenticated = true;
72 Q_EMIT q->authenticationComplete();
73 } else if (authenticationUser == "has-pin"){
74 Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
75 } else if (authenticationUser == "auth-error") {
76 authenticated = false;
77 Q_EMIT q->authenticationComplete();
78 } else if (authenticationUser == "different-prompt") {
79 Q_EMIT q->showPrompt("Secret word: ", Greeter::PromptTypeSecret);
80 } else {
81 Q_EMIT q->showPrompt("Password: ", Greeter::PromptTypeSecret);
82 }
83}
84
85void GreeterPrivate::handleRespond(QString const &response)
86{
87 Q_Q(Greeter);
88
89 if (mockMode == "single") {
90 // NOOP
91 } else if (mockMode == "single-passphrase") {
92 authenticated = (response == "password");
93 q->sendAuthenticationComplete();
94 } else if (mockMode == "single-pin") {
95 authenticated = (response == "1234");
96 q->sendAuthenticationComplete();
97 } else if (mockMode == "full") {
98 handleRespond_full(response);
99 }
100}
101
102void GreeterPrivate::handleRespond_full(const QString &response)
103{
104 Q_Q(Greeter);
105
106 if (authenticationUser == "no-response")
107 return;
108 else if (authenticationUser == "two-factor") {
109 if (!twoFactorDone) {
110 if (response == "password") {
111 twoFactorDone = true;
112 Q_EMIT q->showPrompt("otp", Greeter::PromptTypeQuestion);
113 } else {
114 authenticated = false;
115 q->sendAuthenticationComplete();
116 }
117 } else {
118 authenticated = (response == "otp");
119 q->sendAuthenticationComplete();
120 }
121 return;
122 }
123
124 if (authenticationUser == "has-pin") {
125 authenticated = (response == "1234");
126 } else {
127 authenticated = (response == "password");
128 }
129 q->sendAuthenticationComplete();
130}
131
132}
1330
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 2016-06-09 21:45:09 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,54 +0,0 @@
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
17#ifndef UNITY_MOCK_GREETER_PRIVATE_H
18#define UNITY_MOCK_GREETER_PRIVATE_H
19
20#include <QtCore/QObject>
21
22namespace QLightDM
23{
24class Greeter;
25class GreeterImpl;
26
27class GreeterPrivate
28{
29public:
30 explicit GreeterPrivate(Greeter* parent=0);
31 virtual ~GreeterPrivate() = default;
32
33 // These variables may not be used by all subclasses, that's no problem
34 bool authenticated;
35 QString authenticationUser;
36 bool twoFactorDone;
37 QString selectUserHint;
38
39 QString mockMode;
40
41 void handleAuthenticate();
42 void handleRespond(const QString &response);
43
44protected:
45 Greeter * const q_ptr;
46
47private:
48 void handleAuthenticate_full();
49 void handleRespond_full(const QString &response);
50 Q_DECLARE_PUBLIC(Greeter)
51};
52}
53
54#endif // UNITY_MOCK_GREETER_PRIVATE_H
550
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp 2016-07-13 20:24:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,83 +0,0 @@
1/*
2 * Copyright (C) 2015 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
17#include "SessionsModel.h"
18#include "SessionsModelPrivate.h"
19#include <QDebug>
20namespace QLightDM
21{
22
23SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent)
24 : testScenario("singleSession")
25 , m_availableSessions(
26 {
27 {"ubuntu", "", "Ubuntu", ""},
28 {"ubuntu-2d", "", "Ubuntu 2D", ""},
29 {"gnome", "", "GNOME", ""},
30 {"gnome-classic", "", "GNOME Classic", ""},
31 {"gnome-flashback-compiz", "", "GNOME Flashback (Compiz)", ""},
32 {"gnome-flashback-metacity", "", "GNOME Flashback (Metacity)", ""},
33 {"gnome-wayland", "", "GNOME on Wayland", ""},
34 {"plasma", "", "Plasma", ""},
35 {"kde", "", "KDE" , ""},
36 {"xterm", "", "Recovery Console", ""},
37 {"", "", "Unknown?", ""}
38 })
39 , q_ptr(parent)
40{
41 numSessions = numAvailableSessions();
42 resetEntries();
43}
44
45int SessionsModelPrivate::numAvailableSessions() const
46{
47 return m_availableSessions.length();
48}
49
50void SessionsModelPrivate::resetEntries()
51{
52 Q_Q(SessionsModel);
53
54 q->beginResetModel();
55 if (testScenario == "multipleSessions") {
56 resetEntries_multipleSessions(numSessions);
57 } else if (testScenario == "noSessions") {
58 resetEntries_noSessions();
59 } else {
60 resetEntries_singleSession();
61 }
62 q->endResetModel();
63}
64
65void SessionsModelPrivate::resetEntries_multipleSessions(int numSessions)
66{
67 sessionItems.clear();
68 for (int i = 0; i < numSessions; i++) {
69 sessionItems.append(m_availableSessions.value(i));
70 }
71}
72
73void SessionsModelPrivate::resetEntries_noSessions()
74{
75 sessionItems = {};
76}
77
78void SessionsModelPrivate::resetEntries_singleSession()
79{
80 sessionItems = {{"ubuntu", "", "Ubuntu", ""}};
81}
82
83} // namespace QLightDM
840
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h 2016-07-13 20:24:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,63 +0,0 @@
1/*
2 * Copyright (C) 2015 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 */
17
18#ifndef UNITY_MOCK_SESSIONSMODEL_PRIVATE_H
19#define UNITY_MOCK_SESSIONSMODEL_PRIVATE_H
20
21#include <QtCore/QList>
22#include <QtCore/QString>
23
24namespace QLightDM
25{
26class SessionsModel;
27
28class SessionItem
29{
30public:
31 QString key;
32 QString type; // unused
33 QString name;
34 QString comment; // unused
35};
36
37class SessionsModelPrivate
38{
39public:
40 explicit SessionsModelPrivate(SessionsModel* parent=0);
41 virtual ~SessionsModelPrivate() = default;
42
43 int numAvailableSessions() const;
44
45 QList<SessionItem> sessionItems;
46 int numSessions;
47 QString testScenario;
48
49 void resetEntries();
50protected:
51 SessionsModel* const q_ptr;
52
53private:
54 const QList<SessionItem> m_availableSessions;
55 void resetEntries_multipleSessions(int numSessions);
56 void resetEntries_noSessions();
57 void resetEntries_singleSession();
58 Q_DECLARE_PUBLIC(SessionsModel)
59};
60
61} // namespace QLightDM
62
63#endif // UNITY_MOCK_SESSIONSMODEL_PRIVATE_H
640
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp 2016-08-30 13:46:17 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp 1970-01-01 00:00:00 +0000
@@ -1,124 +0,0 @@
1/*
2 * Copyright (C) 2014-2016 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
17#include "UsersModelPrivate.h"
18#include "UsersModel.h"
19
20#include <QDir>
21
22namespace QLightDM
23{
24
25UsersModelPrivate::UsersModelPrivate(UsersModel* parent)
26 : mockMode("single")
27 , q_ptr(parent)
28{
29 char *envMockMode = getenv("LIBLIGHTDM_MOCK_MODE");
30 if (envMockMode) {
31 mockMode = envMockMode;
32 }
33 resetEntries();
34}
35
36void UsersModelPrivate::resetEntries()
37{
38 Q_Q(UsersModel);
39
40 q->beginResetModel();
41
42 if (mockMode == "single") {
43 resetEntries_single();
44 } else if (mockMode == "single-passphrase") {
45 resetEntries_singlePassphrase();
46 } else if (mockMode == "single-pin") {
47 resetEntries_singlePin();
48 } else if (mockMode == "full") {
49 resetEntries_full();
50 }
51
52 // Assign uids in a loop, just to avoid having to muck with them when
53 // adding or removing test users.
54 for (int i = 0; i < entries.size(); i++) {
55 entries[i].uid = i + 1;
56 }
57
58 // Assign backgrounds
59 QDir backgroundDir("/usr/share/backgrounds");
60 QStringList backgrounds = backgroundDir.entryList(QDir::Files);
61 if (!backgrounds.empty()) {
62 for (int i = 0; i < entries.size(); i++) {
63 if (entries[i].background.isNull()) {
64 entries[i].background = backgroundDir.filePath(backgrounds[i % backgrounds.size()]);
65 }
66 }
67 }
68
69 q->endResetModel();
70}
71
72void UsersModelPrivate::resetEntries_single()
73{
74 entries =
75 {
76 { "single", "Single User", 0, 0, false, false, "ubuntu", 0 },
77 };
78}
79
80void UsersModelPrivate::resetEntries_singlePassphrase()
81{
82 entries =
83 {
84 { "single", "Single User", 0, 0, false, false, "ubuntu", 0 },
85 };
86}
87
88void UsersModelPrivate::resetEntries_singlePin()
89{
90 entries =
91 {
92 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
93 };
94}
95
96void UsersModelPrivate::resetEntries_full()
97{
98 entries =
99 {
100 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
101 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
102 { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
103 { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
104 { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
105 { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
106 { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
107 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 },
108 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
109 { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
110 { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
111 { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0 },
112 { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
113 // white and black are a bit redundant, but useful for manually testing if UI is still readable
114 { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
115 { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
116 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
117 { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
118 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
119 { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
120 { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
121 };
122}
123
124} // namespace QLightDM
1250
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h 2016-05-24 22:11:21 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h 1970-01-01 00:00:00 +0000
@@ -1,64 +0,0 @@
1/*
2 * Copyright (C) 2014-2016 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
17#ifndef UNITY_MOCK_USERSMODEL_PRIVATE_H
18#define UNITY_MOCK_USERSMODEL_PRIVATE_H
19
20#include <QtCore/QList>
21#include <QtCore/QString>
22
23namespace QLightDM
24{
25class UsersModel;
26
27class Entry
28{
29public:
30 QString username;
31 QString real_name;
32 QString background;
33 QString layouts;
34 bool is_active;
35 bool has_messages;
36 QString session;
37 QString infographic;
38 uid_t uid;
39};
40
41class UsersModelPrivate
42{
43public:
44 explicit UsersModelPrivate(UsersModel *parent = 0);
45 virtual ~UsersModelPrivate() = default;
46
47 QList<Entry> entries;
48 QString mockMode;
49
50 void resetEntries();
51protected:
52 UsersModel * const q_ptr;
53
54private:
55 void resetEntries_single();
56 void resetEntries_singlePassphrase();
57 void resetEntries_singlePin();
58 void resetEntries_full();
59 Q_DECLARE_PUBLIC(UsersModel)
60};
61
62}
63
64#endif // UNITY_MOCK_USERSMODEL_PRIVATE_H
650
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/plugin.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/plugin.cpp 2016-06-16 17:23:24 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/plugin.cpp 1970-01-01 00:00:00 +0000
@@ -1,79 +0,0 @@
1/*
2 * Copyright (C) 2014, 2015 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
17#include "plugin.h"
18#include <DBusGreeter.h>
19#include <DBusGreeterList.h>
20#include "MockGreeter.h"
21#include "MockSessionsModel.h"
22#include "MockUsersModel.h"
23#include <QLightDM/SessionsModel>
24#include "ColorTheme.h"
25#include "UserMetrics.h"
26#include <QLightDM/UsersModel>
27
28#include <QAbstractItemModel>
29#include <QDBusConnection>
30#include <QtQml/qqml.h>
31
32static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
33{
34 Q_UNUSED(engine)
35 Q_UNUSED(scriptEngine)
36
37 MockGreeter *greeter = new MockGreeter;
38 new DBusGreeter(greeter, "/");
39 new DBusGreeterList(greeter, "/list");
40
41 return greeter;
42}
43
44static QObject *sessions_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
45{
46 Q_UNUSED(engine)
47 Q_UNUSED(scriptEngine)
48 return new MockSessionsModel;
49}
50
51static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
52{
53 Q_UNUSED(engine)
54 Q_UNUSED(scriptEngine)
55 return new MockUsersModel;
56}
57
58static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
59{
60 Q_UNUSED(engine)
61 Q_UNUSED(scriptEngine)
62 return UserMetricsOutput::UserMetrics::getInstance();
63}
64
65void LightDMPlugin::registerTypes(const char *uri)
66{
67 qmlRegisterType<QAbstractItemModel>();
68 qmlRegisterType<UserMetricsOutput::ColorTheme>();
69
70 Q_ASSERT(uri == QLatin1String("LightDM.IntegratedLightDM"));
71 qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");
72 qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");
73 qmlRegisterSingletonType<MockGreeter>(uri, 0, 1, "Greeter", greeter_provider);
74 qmlRegisterSingletonType<MockSessionsModel>(uri, 0, 1, "Sessions", sessions_provider);
75 qmlRegisterUncreatableType<QLightDM::SessionsModel>(uri, 0, 1, "SessionRoles", "Type is not instantiable");
76 qmlRegisterSingletonType<MockUsersModel>(uri, 0, 1, "Users", users_provider);
77 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
78 qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);
79}
800
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/plugin.h'
--- tests/mocks/LightDM/IntegratedLightDM/plugin.h 2015-09-25 13:01:00 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/plugin.h 1970-01-01 00:00:00 +0000
@@ -1,32 +0,0 @@
1/*
2 * Copyright (C) 2014, 2015 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
17#ifndef MOCK_LIGHTDM_PLUGIN_H
18#define MOCK_LIGHTDM_PLUGIN_H
19
20#include <QtQml/QQmlEngine>
21#include <QtQml/QQmlExtensionPlugin>
22
23class LightDMPlugin : public QQmlExtensionPlugin
24{
25 Q_OBJECT
26 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
27
28public:
29 void registerTypes(const char *uri) override;
30};
31
32#endif
330
=== removed file 'tests/mocks/LightDM/IntegratedLightDM/qmldir'
--- tests/mocks/LightDM/IntegratedLightDM/qmldir 2015-09-25 13:01:00 +0000
+++ tests/mocks/LightDM/IntegratedLightDM/qmldir 1970-01-01 00:00:00 +0000
@@ -1,2 +0,0 @@
1module LightDM.IntegratedLightDM
2plugin MockLightDM-qml
30
=== renamed directory 'tests/mocks/LightDM/IntegratedLightDM/liblightdm' => 'tests/mocks/liblightdm'
=== modified file 'tests/mocks/liblightdm/CMakeLists.txt'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt 2015-11-18 03:52:01 +0000
+++ tests/mocks/liblightdm/CMakeLists.txt 2016-11-08 23:03:16 +0000
@@ -1,20 +1,18 @@
1set(LibLightDM_SOURCES1set(MockLightDM_SOURCES
2 Greeter.cpp2 MockController.cpp
3 SessionsModel.cpp3 MockGreeter.cpp
4 UsersModel.cpp4 MockSessionsModel.cpp
5 GreeterPrivate.cpp5 MockUsersModel.cpp
6 SessionsModelPrivate.cpp
7 UsersModelPrivate.cpp
8 ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
9 )6 )
107
11add_library(MockLightDM SHARED ${LibLightDM_SOURCES})8add_library(MockLightDM SHARED ${MockLightDM_SOURCES})
129
13qt5_use_modules(MockLightDM Gui)10qt5_use_modules(MockLightDM DBus Gui)
1411
15set_target_properties(MockLightDM PROPERTIES12set_target_properties(MockLightDM PROPERTIES
16 OUTPUT_NAME lightdm-qt5-3)13 OUTPUT_NAME lightdm-qt5-3
14 VERSION 0)
1715
18install(TARGETS MockLightDM16install(TARGETS MockLightDM
19 DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/IntegratedLightDM/liblightdm17 DESTINATION ${SHELL_INSTALL_QML}/mocks/liblightdm
20 )18 )
2119
=== added file 'tests/mocks/liblightdm/MockController.cpp'
--- tests/mocks/liblightdm/MockController.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/liblightdm/MockController.cpp 2016-11-08 23:03:16 +0000
@@ -0,0 +1,148 @@
1/*
2 * Copyright (C) 2016 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
17#include "MockController.h"
18
19static QLightDM::MockController *m_instance = nullptr;
20
21namespace QLightDM
22{
23
24MockController::MockController(QObject *parent)
25 : QObject(parent)
26 , m_fullSessions(
27 {
28 {"ubuntu", "Ubuntu"},
29 {"ubuntu-2d", "Ubuntu 2D"},
30 {"gnome", "GNOME"},
31 {"gnome-classic", "GNOME Classic"},
32 {"gnome-flashback-compiz", "GNOME Flashback (Compiz)"},
33 {"gnome-flashback-metacity", "GNOME Flashback (Metacity)"},
34 {"gnome-wayland", "GNOME on Wayland"},
35 {"plasma", "Plasma"},
36 {"kde", "KDE" },
37 {"xterm", "Recovery Console"},
38 {"", "Unknown?"}
39 })
40{
41 m_userMode = qgetenv("LIBLIGHTDM_MOCK_MODE");
42 if (m_userMode.isEmpty()) {
43 m_userMode = "full";
44 }
45 m_sessionMode = "full";
46 m_numSessions = numFullSessions();
47}
48
49MockController::~MockController()
50{
51 m_instance = nullptr;
52}
53
54MockController *MockController::instance()
55{
56 if (!m_instance) {
57 m_instance = new MockController;
58 }
59 return m_instance;
60}
61
62QString MockController::selectUserHint() const
63{
64 return m_selectUserHint;
65}
66
67void MockController::setSelectUserHint(const QString &selectUserHint)
68{
69 if (m_selectUserHint != selectUserHint) {
70 m_selectUserHint = selectUserHint;
71 Q_EMIT selectUserHintChanged();
72 }
73}
74
75QString MockController::userMode() const
76{
77 return m_userMode;
78}
79
80void MockController::setUserMode(const QString &userMode)
81{
82 if (m_userMode != userMode) {
83 m_userMode = userMode;
84 Q_EMIT userModeChanged();
85 }
86}
87
88QString MockController::sessionMode() const
89{
90 return m_sessionMode;
91}
92
93void MockController::setSessionMode(const QString &sessionMode)
94{
95 if (m_sessionMode != sessionMode) {
96 m_sessionMode = sessionMode;
97 Q_EMIT sessionModeChanged();
98 }
99}
100
101QString MockController::sessionName() const
102{
103 return QString("INVALID - Please read directly from the UserModel");
104}
105
106void MockController::setSessionName(const QString &sessionName)
107{
108 // Let the user model deal with this
109 Q_EMIT sessionNameChanged(sessionName, m_currentUsername);
110}
111
112QString MockController::currentUsername() const
113{
114 return m_currentUsername;
115}
116
117void MockController::setCurrentUsername(const QString &username)
118{
119 if (m_currentUsername != username) {
120 m_currentUsername = username;
121 Q_EMIT currentUsernameChanged();
122 }
123}
124
125const QList<MockController::SessionItem> &MockController::fullSessionItems() const
126{
127 return m_fullSessions;
128}
129
130int MockController::numFullSessions() const
131{
132 return m_fullSessions.size();
133}
134
135int MockController::numSessions() const
136{
137 return m_numSessions;
138}
139
140void MockController::setNumSessions(int numSessions)
141{
142 if (m_numSessions != numSessions) {
143 m_numSessions = numSessions;
144 Q_EMIT numSessionsChanged();
145 }
146}
147
148}
0149
=== added file 'tests/mocks/liblightdm/MockController.h'
--- tests/mocks/liblightdm/MockController.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/liblightdm/MockController.h 2016-11-08 23:03:16 +0000
@@ -0,0 +1,98 @@
1/*
2 * Copyright (C) 2016 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
17#ifndef UNITY_MOCK_LIBLIGHTDM_CONTROLLER_H
18#define UNITY_MOCK_LIBLIGHTDM_CONTROLLER_H
19
20#include <QObject>
21#include <QString>
22
23
24namespace QLightDM
25{
26class Q_DECL_EXPORT MockController : public QObject
27{
28 Q_OBJECT
29
30 Q_PROPERTY(QString selectUserHint READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged)
31
32 // single, single-pin, single-passphrase, full
33 Q_PROPERTY(QString userMode READ userMode WRITE setUserMode NOTIFY userModeChanged)
34
35 // single, none, full
36 Q_PROPERTY(QString sessionMode READ sessionMode WRITE setSessionMode NOTIFY sessionModeChanged)
37
38 // This would be best as a Q_INVOKABLE, but using a property allows for
39 // keeping the mock cleaner
40 Q_PROPERTY(QString sessionName READ sessionName WRITE setSessionName NOTIFY sessionNameChanged)
41 Q_PROPERTY(QString currentUsername READ currentUsername WRITE setCurrentUsername NOTIFY currentUsernameChanged)
42
43 Q_PROPERTY(int numAvailableSessions READ numFullSessions CONSTANT)
44 Q_PROPERTY(int numSessions READ numSessions WRITE setNumSessions NOTIFY numSessionsChanged)
45
46public:
47 static MockController *instance();
48 virtual ~MockController();
49
50 QString selectUserHint() const;
51 void setSelectUserHint(const QString &selectUserHint);
52
53 QString userMode() const;
54 void setUserMode(const QString &userMode);
55
56 QString sessionMode() const;
57 void setSessionMode(const QString &sessionMode);
58
59 QString sessionName() const;
60 void setSessionName(const QString &sessionName);
61
62 QString currentUsername() const;
63 void setCurrentUsername(const QString &userIndex);
64
65 class SessionItem
66 {
67 public:
68 QString key;
69 QString name;
70 };
71 int numFullSessions() const;
72 const QList<SessionItem> &fullSessionItems() const;
73
74 int numSessions() const;
75 void setNumSessions(int numSessions);
76
77Q_SIGNALS:
78 void currentUsernameChanged();
79 void selectUserHintChanged();
80 void userModeChanged();
81 void sessionModeChanged();
82 void sessionNameChanged(const QString &sessionName, const QString &username);
83 void numSessionsChanged();
84
85private:
86 explicit MockController(QObject* parent=0);
87
88 QString m_currentUsername;
89 QString m_sessionName;
90 QString m_selectUserHint;
91 QString m_userMode;
92 QString m_sessionMode;
93 QList<SessionItem> m_fullSessions;
94 int m_numSessions;
95};
96}
97
98#endif
099
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp' => 'tests/mocks/liblightdm/MockGreeter.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp 2016-07-28 15:34:29 +0000
+++ tests/mocks/liblightdm/MockGreeter.cpp 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2014 Canonical, Ltd.2 * Copyright (C) 2014-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -14,27 +14,38 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17#include "Greeter.h"17#include "MockController.h"
18#include "GreeterPrivate.h"18#include "MockGreeter.h"
19#include <QtCore/QCoreApplication>19#include <QDBusInterface>
20#include <QDBusPendingCall>
20#include <QTimer>21#include <QTimer>
2122
22namespace QLightDM23namespace QLightDM
23{24{
2425
26class GreeterPrivate
27{
28public:
29 bool authenticated = false;
30 QString authenticationUser;
31 bool twoFactorDone = false;
32};
33
25Greeter::Greeter(QObject *parent)34Greeter::Greeter(QObject *parent)
26 : QObject(parent),35 : QObject(parent)
27 d_ptr(new GreeterPrivate(this))36 , d_ptr(new GreeterPrivate)
28{37{
29}38}
3039
31Greeter::~Greeter()40Greeter::~Greeter()
32{41{
42 delete d_ptr;
33}43}
3444
35QString Greeter::authenticationUser() const45QString Greeter::authenticationUser() const
36{46{
37 Q_D(const Greeter);47 Q_D(const Greeter);
48
38 return d->authenticationUser;49 return d->authenticationUser;
39}50}
4051
@@ -71,14 +82,7 @@
7182
72QString Greeter::selectUserHint() const83QString Greeter::selectUserHint() const
73{84{
74 Q_D(const Greeter);85 return MockController::instance()->selectUserHint();
75 return d->selectUserHint;
76}
77
78void Greeter::setSelectUserHint(const QString &selectUserHint)
79{
80 Q_D(Greeter);
81 d->selectUserHint = selectUserHint;
82}86}
8387
84bool Greeter::selectGuestHint() const88bool Greeter::selectGuestHint() const
@@ -114,6 +118,7 @@
114bool Greeter::isAuthenticated() const118bool Greeter::isAuthenticated() const
115{119{
116 Q_D(const Greeter);120 Q_D(const Greeter);
121
117 return d->authenticated;122 return d->authenticated;
118}123}
119124
@@ -129,13 +134,42 @@
129 d->authenticated = false;134 d->authenticated = false;
130 d->authenticationUser = username;135 d->authenticationUser = username;
131 d->twoFactorDone = false;136 d->twoFactorDone = false;
132 QTimer::singleShot(0, this, &Greeter::delayedAuthentication);137 QTimer::singleShot(0, this, &Greeter::handleAuthenticate);
133}138}
134139
135void Greeter::delayedAuthentication()140void Greeter::handleAuthenticate()
136{141{
137 Q_D(Greeter);142 Q_D(Greeter);
138 d->handleAuthenticate();143
144 // Send out any messages we need to
145 if (d->authenticationUser == "info-prompt")
146 Q_EMIT showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
147 else if (d->authenticationUser == "wide-info-prompt")
148 Q_EMIT showMessage("Welcome to Unity Greeter, the greeteriest greeter that ever did appear in these fine lands", Greeter::MessageTypeInfo);
149 else if (d->authenticationUser == "html-info-prompt")
150 Q_EMIT showMessage("<b>&</b>", Greeter::MessageTypeInfo);
151 else if (d->authenticationUser == "long-info-prompt")
152 Q_EMIT showMessage("Welcome to Unity Greeter\n\nWe like to annoy you with super ridiculously long messages.\nLike this one\n\nThis is the last line of a multiple line message.", Greeter::MessageTypeInfo);
153 else if (d->authenticationUser == "multi-info-prompt") {
154 Q_EMIT showMessage("Welcome to Unity Greeter", Greeter::MessageTypeInfo);
155 Q_EMIT showMessage("This is an error", Greeter::MessageTypeError);
156 Q_EMIT showMessage("You should have seen three messages", Greeter::MessageTypeInfo);
157 }
158
159 // OK, now actually do the prompt
160 if (d->authenticationUser == "no-password") {
161 d->authenticated = true;
162 Q_EMIT authenticationComplete();
163 } else if (d->authenticationUser == "has-pin"){
164 Q_EMIT showPrompt("Password: ", Greeter::PromptTypeSecret);
165 } else if (d->authenticationUser == "auth-error") {
166 d->authenticated = false;
167 Q_EMIT authenticationComplete();
168 } else if (d->authenticationUser == "different-prompt") {
169 Q_EMIT showPrompt("Secret word: ", Greeter::PromptTypeSecret);
170 } else {
171 Q_EMIT showPrompt("Password: ", Greeter::PromptTypeSecret);
172 }
139}173}
140174
141void Greeter::authenticateAsGuest()175void Greeter::authenticateAsGuest()
@@ -161,6 +195,16 @@
161bool Greeter::startSessionSync(const QString &session)195bool Greeter::startSessionSync(const QString &session)
162{196{
163 Q_UNUSED(session)197 Q_UNUSED(session)
198
199 // Send a request to hide the greeter. This is normally done by logind,
200 // but when testing, we don't want the bother of mocking that out. Instead,
201 // just send the request directly ourselves.
202 QDBusInterface iface("com.canonical.UnityGreeter",
203 "/",
204 "com.canonical.UnityGreeter",
205 QDBusConnection::sessionBus());
206 iface.asyncCall("HideGreeter");
207
164 return true;208 return true;
165}209}
166210
@@ -168,7 +212,30 @@
168{212{
169 Q_D(Greeter);213 Q_D(Greeter);
170214
171 d->handleRespond(response);215 if (d->authenticationUser == "no-response")
216 return;
217 else if (d->authenticationUser == "two-factor") {
218 if (!d->twoFactorDone) {
219 if (response == "password") {
220 d->twoFactorDone = true;
221 Q_EMIT showPrompt("otp", Greeter::PromptTypeQuestion);
222 } else {
223 d->authenticated = false;
224 sendAuthenticationComplete();
225 }
226 } else {
227 d->authenticated = (response == "otp");
228 sendAuthenticationComplete();
229 }
230 return;
231 }
232
233 if (d->authenticationUser == "has-pin") {
234 d->authenticated = (response == "1234");
235 } else {
236 d->authenticated = (response == "password");
237 }
238 sendAuthenticationComplete();
172}239}
173240
174void Greeter::sendAuthenticationComplete()241void Greeter::sendAuthenticationComplete()
@@ -181,21 +248,9 @@
181 }248 }
182}249}
183250
184QString Greeter::mockMode() const251QObject *Greeter::mock()
185{252{
186 Q_D(const Greeter);253 return MockController::instance();
187 return d->mockMode;
188}
189
190
191void Greeter::setMockMode(QString mockMode)
192{
193 Q_D(Greeter);
194
195 if (d->mockMode != mockMode) {
196 d->mockMode = mockMode;
197 Q_EMIT mockModeChanged(mockMode);
198 }
199}254}
200255
201}256}
202257
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h' => 'tests/mocks/liblightdm/MockGreeter.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h 2016-07-28 15:34:29 +0000
+++ tests/mocks/liblightdm/MockGreeter.h 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 * Copyright (C) 2010-2011 David Edmundson.3 * Copyright (C) 2010-2011 David Edmundson.
4 * Copyright (C) 2010-2011 Robert Ancell4 * Copyright (C) 2010-2011 Robert Ancell
5 *5 *
@@ -21,13 +21,12 @@
21#ifndef UNITY_MOCK_GREETER_H21#ifndef UNITY_MOCK_GREETER_H
22#define UNITY_MOCK_GREETER_H22#define UNITY_MOCK_GREETER_H
2323
24#include <QtCore/QObject>24#include <QObject>
25#include <QtCore/QVariant>25#include <QVariant>
26
2726
28namespace QLightDM27namespace QLightDM
29{28{
30 class GreeterPrivate;29class GreeterPrivate;
3130
32class Q_DECL_EXPORT Greeter : public QObject31class Q_DECL_EXPORT Greeter : public QObject
33{32{
@@ -44,8 +43,7 @@
4443
45 Q_ENUMS(PromptType MessageType)44 Q_ENUMS(PromptType MessageType)
4645
47 //Mock-only API for testing purposes46 Q_PROPERTY(QObject *mock READ mock CONSTANT) // only in mock
48 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
4947
50public:48public:
51 enum PromptType {49 enum PromptType {
@@ -68,7 +66,6 @@
68 bool showRemoteLoginHint() const;66 bool showRemoteLoginHint() const;
69 bool hasGuestAccountHint() const;67 bool hasGuestAccountHint() const;
70 QString selectUserHint() const;68 QString selectUserHint() const;
71 void setSelectUserHint(const QString &selectUserHint); // only in mock
72 bool selectGuestHint() const;69 bool selectGuestHint() const;
73 QString autologinUserHint() const;70 QString autologinUserHint() const;
74 bool autologinGuestHint() const;71 bool autologinGuestHint() const;
@@ -79,8 +76,7 @@
79 QString authenticationUser() const;76 QString authenticationUser() const;
80 QString hostname() const;77 QString hostname() const;
8178
82 QString mockMode() const;79 QObject *mock();
83 void setMockMode(QString mockMode);
8480
85public Q_SLOTS:81public Q_SLOTS:
86 bool connectSync();82 bool connectSync();
@@ -98,15 +94,13 @@
98 void showPrompt(QString text, QLightDM::Greeter::PromptType type);94 void showPrompt(QString text, QLightDM::Greeter::PromptType type);
99 void authenticationComplete();95 void authenticationComplete();
100 void autologinTimerExpired();96 void autologinTimerExpired();
101 void mockModeChanged(QString mode);
102
103protected:
104 void sendAuthenticationComplete();
10597
106private Q_SLOTS:98private Q_SLOTS:
107 void delayedAuthentication();99 void handleAuthenticate();
108100
109private:101private:
102 void sendAuthenticationComplete();
103
110 GreeterPrivate *d_ptr;104 GreeterPrivate *d_ptr;
111 Q_DECLARE_PRIVATE(Greeter)105 Q_DECLARE_PRIVATE(Greeter)
112};106};
113107
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp' => 'tests/mocks/liblightdm/MockSessionsModel.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp 2016-07-13 20:24:24 +0000
+++ tests/mocks/liblightdm/MockSessionsModel.cpp 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -21,22 +21,34 @@
21// set our compatibility to Qt4 here too.21// set our compatibility to Qt4 here too.
22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
2323
24#include "SessionsModel.h"24#include "MockController.h"
25#include "SessionsModelPrivate.h"25#include "MockSessionsModel.h"
26#include <QtCore/QDir>
27#include <QtCore/QString>
2826
29namespace QLightDM27namespace QLightDM
30{28{
3129
32SessionsModel::SessionsModel(QObject* parent) :30class SessionsModelPrivate
33 QAbstractListModel(parent),31{
34 d_ptr(new SessionsModelPrivate(this))32public:
33 QHash<int, QByteArray> roleNames;
34 QList<MockController::SessionItem> sessionItems;
35};
36
37SessionsModel::SessionsModel(QObject* parent)
38 : QAbstractListModel(parent)
39 , d_ptr(new SessionsModelPrivate)
35{40{
36 Q_D(SessionsModel);41 Q_D(SessionsModel);
37 m_roleNames = QAbstractListModel::roleNames();42
38 m_roleNames[KeyRole] = "key";43 d->roleNames = QAbstractListModel::roleNames();
39 m_roleNames[TypeRole] = "type";44 d->roleNames[KeyRole] = "key";
45 d->roleNames[TypeRole] = "type";
46
47 connect(MockController::instance(), &MockController::sessionModeChanged,
48 this, &SessionsModel::resetEntries);
49 connect(MockController::instance(), &MockController::numSessionsChanged,
50 this, &SessionsModel::resetEntries);
51 resetEntries();
40}52}
4153
42SessionsModel::~SessionsModel()54SessionsModel::~SessionsModel()
@@ -66,7 +78,9 @@
6678
67QHash<int, QByteArray> SessionsModel::roleNames() const79QHash<int, QByteArray> SessionsModel::roleNames() const
68{80{
69 return m_roleNames;81 Q_D(const SessionsModel);
82
83 return d->roleNames;
70}84}
7185
72int SessionsModel::rowCount(const QModelIndex& parent) const86int SessionsModel::rowCount(const QModelIndex& parent) const
@@ -80,42 +94,29 @@
80 }94 }
81}95}
8296
83int SessionsModel::numSessions() const97void SessionsModel::resetEntries()
84{98{
85 Q_D(const SessionsModel);99 Q_D(SessionsModel);
86 return d->numSessions;100
87}101 beginResetModel();
88102
89int SessionsModel::numAvailableSessions() const103 QString sessionMode = MockController::instance()->sessionMode();
90{104
91 Q_D(const SessionsModel);105 if (sessionMode == "full") {
92 return d->numAvailableSessions();106 d->sessionItems = MockController::instance()->fullSessionItems();
93}107 d->sessionItems = d->sessionItems.mid(0, MockController::instance()->numSessions());
94108 } else if (sessionMode == "single") {
95QString SessionsModel::testScenario() const109 d->sessionItems = {MockController::instance()->fullSessionItems()[0]};
96{110 } else {
97 Q_D(const SessionsModel);111 d->sessionItems = {};
98 return d->testScenario;112 }
99}113
100114 endResetModel();
101void SessionsModel::setNumSessions(int numSessions)115}
102{116
103 Q_D(SessionsModel);117QObject *SessionsModel::mock()
104118{
105 if (d->numSessions != numSessions) {119 return MockController::instance();
106 d->numSessions = numSessions;
107 d->resetEntries();
108 }
109}
110
111void SessionsModel::setTestScenario(QString testScenario)
112{
113 Q_D(SessionsModel);
114
115 if (d->testScenario != testScenario) {
116 d->testScenario = testScenario;
117 d->resetEntries();
118 }
119}120}
120121
121} // namespace QLightDM122} // namespace QLightDM
122123
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h' => 'tests/mocks/liblightdm/MockSessionsModel.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h 2016-07-13 20:24:24 +0000
+++ tests/mocks/liblightdm/MockSessionsModel.h 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2015 Canonical, Ltd.2 * Copyright (C) 2015-2016 Canonical, Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * 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 by5 * it under the terms of the GNU General Public License as published by
@@ -18,8 +18,10 @@
18#ifndef UNITY_MOCK_SESSIONSMODEL_H18#ifndef UNITY_MOCK_SESSIONSMODEL_H
19#define UNITY_MOCK_SESSIONSMODEL_H19#define UNITY_MOCK_SESSIONSMODEL_H
2020
21#include <QtCore/QAbstractListModel>21#include <QAbstractListModel>
22#include <QtCore/QString>22#include <QByteArray>
23#include <QHash>
24#include <QString>
2325
24namespace QLightDM26namespace QLightDM
25{27{
@@ -29,10 +31,11 @@
29 {31 {
30 Q_OBJECT32 Q_OBJECT
3133
34 Q_PROPERTY(QObject *mock READ mock CONSTANT) // only in mock
35
32 Q_ENUMS(SessionModelRoles SessionType)36 Q_ENUMS(SessionModelRoles SessionType)
3337
34 public:38 public:
35
36 enum SessionModelRoles {39 enum SessionModelRoles {
37 //name is exposed as Qt::DisplayRole40 //name is exposed as Qt::DisplayRole
38 //comment is exposed as Qt::TooltipRole41 //comment is exposed as Qt::TooltipRole
@@ -54,17 +57,13 @@
54 int rowCount(const QModelIndex& parent) const override;57 int rowCount(const QModelIndex& parent) const override;
55 QVariant data(const QModelIndex& index, int role) const override;58 QVariant data(const QModelIndex& index, int role) const override;
5659
57 int numSessions() const;60 QObject *mock();
58 int numAvailableSessions() const;
59 QString testScenario() const;
60 void setNumSessions(int numSessions);
61 void setTestScenario(QString testScenario);
6261
63 protected:62 private Q_SLOTS:
64 SessionsModelPrivate* const d_ptr;63 void resetEntries();
6564
66 private:65 private:
67 QHash<int, QByteArray> m_roleNames;66 SessionsModelPrivate *d_ptr;
68 Q_DECLARE_PRIVATE(SessionsModel)67 Q_DECLARE_PRIVATE(SessionsModel)
69 };68 };
70}69}
7170
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp' => 'tests/mocks/liblightdm/MockUsersModel.cpp'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp 2016-05-24 22:11:21 +0000
+++ tests/mocks/liblightdm/MockUsersModel.cpp 2016-11-08 23:03:16 +0000
@@ -21,21 +21,37 @@
21// set our compatibility to Qt4 here too.21// set our compatibility to Qt4 here too.
22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)22#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
2323
24#include "UsersModel.h"24#include "MockController.h"
25#include "UsersModelPrivate.h"25#include "MockUsersModel.h"
26#include <QtCore/QDir>26#include <QDir>
27#include <QtCore/QString>27#include <QIcon>
28#include <QtGui/QIcon>
2928
30namespace QLightDM29namespace QLightDM
31{30{
3231
33UsersModel::UsersModel(QObject *parent) :32class Entry
34 QAbstractListModel(parent),33{
35 d_ptr(new UsersModelPrivate(this))34public:
36{35 QString username;
37 Q_D(UsersModel);36 QString real_name;
3837 QString background;
38 QString layouts;
39 bool is_active;
40 bool has_messages;
41 QString session;
42 uid_t uid;
43};
44
45class UsersModelPrivate
46{
47public:
48 QList<Entry> entries;
49};
50
51UsersModel::UsersModel(QObject *parent)
52 : QAbstractListModel(parent)
53 , d_ptr(new UsersModelPrivate)
54{
39 // Extend roleNames (we want to keep the "display" role)55 // Extend roleNames (we want to keep the "display" role)
40 QHash<int, QByteArray> roles = roleNames();56 QHash<int, QByteArray> roles = roleNames();
41 roles[NameRole] = "name";57 roles[NameRole] = "name";
@@ -48,6 +64,12 @@
48 roles[ImagePathRole] = "imagePath";64 roles[ImagePathRole] = "imagePath";
49 roles[UidRole] = "uid";65 roles[UidRole] = "uid";
50 setRoleNames(roles);66 setRoleNames(roles);
67
68 connect(MockController::instance(), &MockController::userModeChanged,
69 this, &UsersModel::resetEntries);
70 connect(MockController::instance(), &MockController::sessionNameChanged,
71 this, &UsersModel::setCurrentSessionName);
72 resetEntries();
51}73}
5274
53UsersModel::~UsersModel()75UsersModel::~UsersModel()
@@ -55,6 +77,21 @@
55 delete d_ptr;77 delete d_ptr;
56}78}
5779
80void UsersModel::setCurrentSessionName(const QString &sessionName, const QString &username)
81{
82 Q_D(UsersModel);
83
84 for (auto &entry : d->entries) {
85 if (username == entry.username) {
86 entry.session = sessionName;
87
88 // Since the incides are mangled, there is no easy way to emit dataChanged
89 // and that doesn't matter for the limited use of this function
90 return;
91 }
92 }
93}
94
58int UsersModel::rowCount(const QModelIndex &parent) const95int UsersModel::rowCount(const QModelIndex &parent) const
59{96{
60 Q_D(const UsersModel);97 Q_D(const UsersModel);
@@ -103,21 +140,69 @@
103 }140 }
104}141}
105142
106QString UsersModel::mockMode() const143void UsersModel::resetEntries()
107{
108 Q_D(const UsersModel);
109 return d->mockMode;
110}
111
112void UsersModel::setMockMode(QString mockMode)
113{144{
114 Q_D(UsersModel);145 Q_D(UsersModel);
115146
116 if (d->mockMode != mockMode) {147 beginResetModel();
117 d->mockMode = mockMode;148
118 Q_EMIT mockModeChanged(mockMode);149 QString userMode = MockController::instance()->userMode();
119 d->resetEntries();150
120 }151 if (userMode == "single") {
152 d->entries = {{"no-password", "No Password", "", 0, false, false, "ubuntu", 0}};
153 } else if (userMode == "single-passphrase") {
154 d->entries = {{"has-password", "Has Password", "", 0, false, false, "ubuntu", 0}};
155 } else if (userMode == "single-pin") {
156 d->entries = {{"has-pin", "Has PIN", "", 0, false, false, "ubuntu", 0}};
157 } else if (userMode == "full") {
158 d->entries = {
159 { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
160 { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
161 { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
162 { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
163 { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
164 { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
165 { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
166 { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 },
167 { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
168 { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
169 { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
170 { "long-name", "Long name (far far too long to fit, seriously this would never fit on the screen, you will never see this part of the name)", 0, 0, false, false, "ubuntu", 0 },
171 { "color-background", "Color Background", "#E95420", 0, false, false, "ubuntu", 0 },
172 // white and black are a bit redundant, but useful for manually testing if UI is still readable
173 { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
174 { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
175 { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
176 { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
177 { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
178 { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
179 { "active", "Active Account", 0, 0, true, false, "ubuntu", 0 },
180 };
181 }
182
183 // Assign uids in a loop, just to avoid having to muck with them when
184 // adding or removing test users.
185 for (int i = 0; i < d->entries.size(); i++) {
186 d->entries[i].uid = i + 1;
187 }
188
189 // Assign backgrounds
190 QDir backgroundDir("/usr/share/backgrounds");
191 QStringList backgrounds = backgroundDir.entryList(QDir::Files);
192 if (!backgrounds.empty()) {
193 for (int i = 0; i < d->entries.size(); i++) {
194 if (d->entries[i].background.isNull()) {
195 d->entries[i].background = backgroundDir.filePath(backgrounds[i % backgrounds.size()]);
196 }
197 }
198 }
199
200 endResetModel();
201}
202
203QObject *UsersModel::mock()
204{
205 return MockController::instance();
121}206}
122207
123}208}
124209
=== renamed file 'tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.h' => 'tests/mocks/liblightdm/MockUsersModel.h'
--- tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.h 2016-05-24 22:11:21 +0000
+++ tests/mocks/liblightdm/MockUsersModel.h 2016-11-08 23:03:16 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013-2014 Canonical, Ltd.2 * Copyright (C) 2013-2016 Canonical, Ltd.
3 * Copyright (C) 2010-2011 David Edmundson.3 * Copyright (C) 2010-2011 David Edmundson.
4 *4 *
5 * This program is free software; you can redistribute it and/or modify5 * This program is free software; you can redistribute it and/or modify
@@ -18,10 +18,9 @@
18#ifndef UNITY_MOCK_USERSMODEL_H18#ifndef UNITY_MOCK_USERSMODEL_H
19#define UNITY_MOCK_USERSMODEL_H19#define UNITY_MOCK_USERSMODEL_H
2020
21#include <QtCore/QString>
22#include <QtCore/QSharedDataPointer>
23#include <QAbstractListModel>21#include <QAbstractListModel>
2422#include <QList>
23#include <QString>
2524
26namespace QLightDM25namespace QLightDM
27{26{
@@ -33,11 +32,7 @@
3332
34 Q_ENUMS(UserModelRoles)33 Q_ENUMS(UserModelRoles)
3534
36 //Mock-only API for testing purposes35 Q_PROPERTY(QObject *mock READ mock CONSTANT) // only in mock
37 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
38
39Q_SIGNALS:
40 void mockModeChanged(QString mode);
4136
42public:37public:
43 explicit UsersModel(QObject *parent = 0);38 explicit UsersModel(QObject *parent = 0);
@@ -57,8 +52,12 @@
57 int rowCount(const QModelIndex &parent) const override;52 int rowCount(const QModelIndex &parent) const override;
58 QVariant data(const QModelIndex &index, int role) const override;53 QVariant data(const QModelIndex &index, int role) const override;
5954
60 QString mockMode() const;55 void setCurrentSessionName(const QString &sessionName, const QString &username);
61 void setMockMode(QString mockMode);56
57 QObject *mock();
58
59private Q_SLOTS:
60 void resetEntries();
6261
63private:62private:
64 UsersModelPrivate * const d_ptr;63 UsersModelPrivate * const d_ptr;
6564
=== modified file 'tests/mocks/libusermetrics/UserMetrics.cpp'
--- tests/mocks/libusermetrics/UserMetrics.cpp 2016-05-26 13:15:35 +0000
+++ tests/mocks/libusermetrics/UserMetrics.cpp 2016-11-08 23:03:16 +0000
@@ -288,7 +288,7 @@
288 QSharedPointer<UserMetricsData> data(288 QSharedPointer<UserMetricsData> data(
289 new UserMetricsData("<b>52km</b> travelled", first, firstMonth,289 new UserMetricsData("<b>52km</b> travelled", first, firstMonth,
290 ninth, secondMonth, this));290 ninth, secondMonth, this));
291 m_fakeData.insert("single", data);291 m_fakeData.insert("has-password", data);
292 m_fakeData.insert("has-pin", data);292 m_fakeData.insert("has-pin", data);
293 }293 }
294294
@@ -304,7 +304,7 @@
304 QSharedPointer<UserMetricsData> data(304 QSharedPointer<UserMetricsData> data(
305 new UserMetricsData("<b>33</b> messages today", second,305 new UserMetricsData("<b>33</b> messages today", second,
306 firstMonth, eighth, secondMonth, this));306 firstMonth, eighth, secondMonth, this));
307 m_fakeData.insert("single", data);307 m_fakeData.insert("has-password", data);
308 m_fakeData.insert("has-pin", data);308 m_fakeData.insert("has-pin", data);
309 }309 }
310310
@@ -321,10 +321,8 @@
321 QSharedPointer<UserMetricsData> data(321 QSharedPointer<UserMetricsData> data(
322 new UserMetricsData("<b>19</b> minutes talk time", eighth,322 new UserMetricsData("<b>19</b> minutes talk time", eighth,
323 firstMonth, second, secondMonth, this));323 firstMonth, second, secondMonth, this));
324 m_fakeData.insert("single", data);324 m_fakeData.insert("has-password", data);
325 m_fakeData.insert("has-pin", data);325 m_fakeData.insert("has-pin", data);
326 // Also use same data for some tablet users
327 m_fakeData.insert("has-password", data);
328 m_fakeData.insert("no-password", data);326 m_fakeData.insert("no-password", data);
329 m_fakeData.insert("empty-name", data);327 m_fakeData.insert("empty-name", data);
330 }328 }
331329
=== modified file 'tests/plugins/AccountsService/AccountsServer.cpp'
--- tests/plugins/AccountsService/AccountsServer.cpp 2015-10-26 14:05:14 +0000
+++ tests/plugins/AccountsService/AccountsServer.cpp 2016-11-08 23:03:16 +0000
@@ -40,6 +40,8 @@
40 if (QDBusConnection::sessionBus().objectRegisteredAt(path) != nullptr)40 if (QDBusConnection::sessionBus().objectRegisteredAt(path) != nullptr)
41 return true;41 return true;
4242
43 m_users.insert(path);
44
43 auto props = new PropertiesServer(this);45 auto props = new PropertiesServer(this);
44 new PropertiesAdaptor(props);46 new PropertiesAdaptor(props);
45 new AccountsUserAdaptor(props);47 new AccountsUserAdaptor(props);
@@ -52,6 +54,15 @@
52 if (QDBusConnection::sessionBus().objectRegisteredAt(path) == nullptr)54 if (QDBusConnection::sessionBus().objectRegisteredAt(path) == nullptr)
53 return false;55 return false;
5456
57 m_users.remove(path);
55 QDBusConnection::sessionBus().unregisterObject(path);58 QDBusConnection::sessionBus().unregisterObject(path);
56 return true;59 return true;
57}60}
61
62void AccountsServer::RemoveAllUsers()
63{
64 Q_FOREACH(const QString &path, m_users) {
65 m_users.remove(path);
66 QDBusConnection::sessionBus().unregisterObject(path);
67 }
68}
5869
=== modified file 'tests/plugins/AccountsService/AccountsServer.h'
--- tests/plugins/AccountsService/AccountsServer.h 2015-10-26 14:05:14 +0000
+++ tests/plugins/AccountsService/AccountsServer.h 2016-11-08 23:03:16 +0000
@@ -23,6 +23,7 @@
23#include <QDBusContext>23#include <QDBusContext>
24#include <QDBusObjectPath>24#include <QDBusObjectPath>
25#include <QObject>25#include <QObject>
26#include <QSet>
26#include <QString>27#include <QString>
2728
28class AccountsServer: public QObject, protected QDBusContext29class AccountsServer: public QObject, protected QDBusContext
@@ -39,6 +40,10 @@
39 // mock only.40 // mock only.
40 bool AddUser(const QString &user);41 bool AddUser(const QString &user);
41 bool RemoveUser(const QString &user);42 bool RemoveUser(const QString &user);
43 void RemoveAllUsers();
44
45private:
46 QSet<QString> m_users;
42};47};
4348
44#endif49#endif
4550
=== modified file 'tests/plugins/AccountsService/client.cpp'
--- tests/plugins/AccountsService/client.cpp 2016-03-31 03:15:03 +0000
+++ tests/plugins/AccountsService/client.cpp 2016-11-08 23:03:16 +0000
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches