on xenial help sign in
Merge in lp:~josharenson/unity8/sessions-model to make it easier to stack greeter changes
commit039514c2f52b5b27dcc653da0dee23db1845030d authorMichael Terry <michael.terry@canonical.com> dateWed 6 Jul 2016, 15:41 (10 years ago) parentbb8927282b4dbb
116 files changed+1660−303
CMakeLists.txt+1 data/51-unity8-greeter.conf+2 data/CMakeLists.txt+11 data/unity8-greeter-init.conf+12 data/unity8-greeter-wrapper+98 data/unity8-greeter.desktop.in+7 data/unity8-greeter.pkla+44 debian/control+12 debian/rules+1−1 debian/unity8-greeter.install+5 debian/unity8-private.install+1−1 plugins/CMakeLists.txt+1−1 plugins/IntegratedLightDM/CMakeLists.txt−40 plugins/LightDM/CMakeLists.txt+26 plugins/IntegratedLightDM/DBusGreeter.cpp → plugins/LightDM/DBusGreeter.cpp+5−4 plugins/IntegratedLightDM/DBusGreeter.h → plugins/LightDM/DBusGreeter.h plugins/IntegratedLightDM/DBusGreeterList.cpp → plugins/LightDM/DBusGreeterList.cpp plugins/IntegratedLightDM/DBusGreeterList.h → plugins/LightDM/DBusGreeterList.h plugins/LightDM/FullLightDM/CMakeLists.txt+27 plugins/LightDM/FullLightDM/qmldir+3 plugins/IntegratedLightDM/Greeter.cpp → plugins/LightDM/Greeter.cpp+13−2 plugins/IntegratedLightDM/Greeter.h → plugins/LightDM/Greeter.h+5−2 plugins/IntegratedLightDM/GreeterPrivate.h → plugins/LightDM/GreeterPrivate.h plugins/LightDM/IntegratedLightDM/CMakeLists.txt+30 plugins/LightDM/IntegratedLightDM/QLightDM/Greeter+17 plugins/LightDM/IntegratedLightDM/QLightDM/SessionsModel+17 plugins/LightDM/IntegratedLightDM/QLightDM/UsersModel+17 plugins/IntegratedLightDM/liblightdm/CMakeLists.txt → plugins/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt+4−2 plugins/IntegratedLightDM/liblightdm/Greeter.cpp → plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp plugins/IntegratedLightDM/liblightdm/Greeter.h → plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.h plugins/IntegratedLightDM/liblightdm/GreeterPrivate.cpp → plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp+1−2 plugins/IntegratedLightDM/liblightdm/GreeterPrivate.h → plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp+88 plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h+72 plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp+36 plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h+54 plugins/IntegratedLightDM/liblightdm/UsersModel.cpp → plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp plugins/IntegratedLightDM/liblightdm/UsersModel.h → plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.h plugins/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp → plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp plugins/IntegratedLightDM/liblightdm/UsersModelPrivate.h → plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h plugins/LightDM/IntegratedLightDM/qmldir+3 plugins/LightDM/SessionsModel.cpp+122 plugins/LightDM/SessionsModel.h+68 plugins/IntegratedLightDM/UsersModel.cpp → plugins/LightDM/UsersModel.cpp plugins/IntegratedLightDM/UsersModel.h → plugins/LightDM/UsersModel.h plugins/IntegratedLightDM/plugin.cpp → plugins/LightDM/plugin.cpp+26−4 plugins/IntegratedLightDM/plugin.h → plugins/LightDM/plugin.h+5−5 plugins/IntegratedLightDM/qmldir → plugins/LightDM/qmldir plugins/Unity/Indicators/indicatorsmanager.cpp+1−1 po/am.po+6−6 po/en_GB.po+9−9 po/ug.po+54−54 qml/Components/Dialogs.qml+3−5 qml/Greeter/FullLightDMImpl.qml+28 qml/Greeter/Greeter.qml+43−34 qml/Greeter/IntegratedLightDMImpl.qml+1−1 qml/Greeter/LightDM.qml → qml/Greeter/LightDMService.qml+14−3 qml/Greeter/LoginList.qml+2 qml/Greeter/WideView.qml+2 qml/Greeter/qmldir+1 qml/Shell.qml+11−6 qml/Wizard/Wizard.qml+6−2 src/ShellApplication.cpp+11−1 tests/CMakeLists.txt+1−1 tests/autopilot/unity8/fixture_setup.py+1−1 tests/autopilot/unity8/greeter/tests/test_args.py−5 tests/autopilot/unity8/shell/tests/__init__.py+1−1 tests/mocks/CMakeLists.txt+1−1 tests/mocks/IntegratedLightDM/qmldir−3 tests/mocks/LightDM/CMakeLists.txt+1 tests/mocks/IntegratedLightDM/CMakeLists.txt → tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txt+9−7 tests/mocks/IntegratedLightDM/MockGreeter.cpp → tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpp+16 tests/mocks/IntegratedLightDM/MockGreeter.h → tests/mocks/LightDM/IntegratedLightDM/MockGreeter.h+5 qml/Stages/ShimStage.qml → tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpp+15−21 tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.h+34 tests/mocks/IntegratedLightDM/MockUsersModel.cpp → tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpp tests/mocks/IntegratedLightDM/MockUsersModel.h → tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.h tests/mocks/IntegratedLightDM/QLightDM/Greeter → tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeter tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModel+17 tests/mocks/IntegratedLightDM/QLightDM/UsersModel → tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModel tests/mocks/IntegratedLightDM/liblightdm/CMakeLists.txt → tests/mocks/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txt+4−2 tests/mocks/IntegratedLightDM/liblightdm/Greeter.cpp → tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpp+9−2 tests/mocks/IntegratedLightDM/liblightdm/Greeter.h → tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.h+1 tests/mocks/IntegratedLightDM/liblightdm/GreeterPrivate.cpp → tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp tests/mocks/IntegratedLightDM/liblightdm/GreeterPrivate.h → tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.h+1 tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cpp+99 tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.h+72 tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cpp+73 tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.h+59 tests/mocks/IntegratedLightDM/liblightdm/UsersModel.cpp → tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpp tests/mocks/IntegratedLightDM/liblightdm/UsersModel.h → tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.h tests/mocks/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp → tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp+22−22 tests/mocks/IntegratedLightDM/liblightdm/UsersModelPrivate.h → tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.h tests/mocks/IntegratedLightDM/plugin.cpp → tests/mocks/LightDM/IntegratedLightDM/plugin.cpp+15−4 tests/mocks/IntegratedLightDM/plugin.h → tests/mocks/LightDM/IntegratedLightDM/plugin.h+1−1 tests/mocks/LightDM/IntegratedLightDM/qmldir+2 tests/mocks/libusermetrics/libusermetricsoutput/ColorTheme.h−1 tests/mocks/libusermetrics/libusermetricsoutput/UserMetrics.h−1 tests/plugins/CMakeLists.txt+1−1 tests/plugins/LightDM/CMakeLists.txt+1 tests/plugins/IntegratedLightDM/CMakeLists.txt → tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txt+36−13 tests/plugins/IntegratedLightDM/dbus.cpp → tests/plugins/LightDM/IntegratedLightDM/dbus.cpp tests/plugins/IntegratedLightDM/greeter.qml → tests/plugins/LightDM/IntegratedLightDM/greeter.qml+1−1 tests/plugins/IntegratedLightDM/integrated.cpp → tests/plugins/LightDM/IntegratedLightDM/integrated.cpp tests/plugins/IntegratedLightDM/pam.cpp → tests/plugins/LightDM/IntegratedLightDM/pam.cpp tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cpp+96 tests/plugins/IntegratedLightDM/usersmodel.cpp → tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpp tests/qmltests/Greeter/TestView.qml+1 tests/qmltests/Greeter/tst_Greeter.qml+28−10 tests/qmltests/Greeter/tst_Infographics.qml+1−1 tests/qmltests/Greeter/tst_NarrowView.qml+1−1 tests/qmltests/Greeter/tst_WideView.qml+1−1 tests/qmltests/Tutorial/tst_Tutorial.qml+1−1 tests/qmltests/tst_OrientedShell.qml+1−1 tests/qmltests/tst_Shell.qml+5−13 tests/qmltests/tst_ShellWithPin.qml+1−1
CMakeLists.txt+1
@@ -128,6 +128,7 @@ set(SHELL_APP unity8)
128128set(DASH_APP unity8-dash)
129129set(SCOPE_TOOL unity-scope-tool)
130130set(INDICATORS_CLIENT_APP indicators-client)
131+set(GREETER_APP unity8-greeter)
131132set(MOCK_INDICATOR_SERVICE_APP unity-mock-indicator-service)
132133
133134include_directories(
data/51-unity8-greeter.confnew file+2
@@ -0,0 +1,2 @@
1+[Seat:*]
2+greeter-session=unity8-greeter
data/CMakeLists.txt+11
@@ -2,6 +2,7 @@
22configure_file(${SHELL_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${SHELL_APP}.desktop @ONLY)
33configure_file(${DASH_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${DASH_APP}.desktop @ONLY)
44configure_file(${INDICATORS_CLIENT_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${INDICATORS_CLIENT_APP}.desktop @ONLY)
5+configure_file(${GREETER_APP}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${GREETER_APP}.desktop @ONLY)
56
67# install desktop files
78install(FILES
@@ -11,6 +12,16 @@ install(FILES
1112 DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
1213 )
1314
15+install(FILES
16+ ${CMAKE_CURRENT_BINARY_DIR}/${GREETER_APP}.desktop
17+ DESTINATION ${CMAKE_INSTALL_DATADIR}/lightdm/greeters
18+ )
19+
20+install(FILES
21+ 51-unity8-greeter.conf
22+ DESTINATION ${CMAKE_INSTALL_DATADIR}/lightdm/lightdm.conf.d
23+ )
24+
1425# install dash icon
1526install(FILES
1627 ${CMAKE_CURRENT_SOURCE_DIR}/${DASH_APP}.png
data/unity8-greeter-init.confnew file+12
@@ -0,0 +1,12 @@
1+description "Unity 8 Greeter initialization"
2+author "Michael Terry <mterry@ubuntu.com>"
3+
4+start on unity8-greeter-started
5+task
6+emits indicator-services-start
7+
8+script
9+ start --no-wait ofono-setup || true
10+ initctl emit --no-wait indicator-services-start || true
11+ start --no-wait maliit-server || true
12+end script
data/unity8-greeter-wrappernew file+98
@@ -0,0 +1,98 @@
1+#!/bin/sh
2+# -*- Mode: sh; indent-tabs-mode: nil; tab-width: 4 -*-
3+#
4+# Copyright (C) 2011,2013 Canonical Ltd
5+# Author: Michael Terry <michael.terry@canonical.com>
6+#
7+# This program is free software: you can redistribute it and/or modify it under
8+# the terms of the GNU General Public License as published by the Free Software
9+# Foundation, version 3 of the License.
10+#
11+# See http://www.gnu.org/copyleft/gpl.html the full text of the license.
12+
13+# This wrapper merely ensures that init and friends live only as long as this
14+# script does. Otherwise, it's very easy for some processes to not notice that
15+# the session died. We could try to do this in-process, but we want to do this
16+# cleanup even if the greeter aborts.
17+
18+trap cleanup TERM EXIT
19+
20+cleanup()
21+{
22+ trap - TERM EXIT
23+ # Kill upstart and indicators
24+ if [ -n "$INIT_PID" ]; then
25+ kill "$INIT_PID"
26+ fi
27+ if [ -n "$CMD_PID" ]; then
28+ kill "$CMD_PID"
29+ fi
30+ exit 0
31+}
32+
33+set_greeter_var()
34+{
35+ export "$1=$2"
36+ gdbus call --session --dest org.freedesktop.DBus --object-path /org/freedesktop/DBus --method org.freedesktop.DBus.UpdateActivationEnvironment "{'$1': '$2'}"
37+ if [ -n "$INIT_PID" ]; then
38+ initctl set-env --global "$1=$2"
39+ fi
40+}
41+
42+SUB_SOCKET=$XDG_RUNTIME_DIR/mir_socket
43+rm -f $SUB_SOCKET # clear socket in case we were hard shut down
44+
45+# If touch session script (which sets up grid units and mir variables) is available, use it
46+TOUCH_WRAPPER=
47+if [ -x /usr/bin/ubuntu-touch-session ]; then
48+ TOUCH_WRAPPER=/usr/bin/ubuntu-touch-session
49+fi
50+
51+# Pretend that we're in an ubuntu-touch session, so that indicator-network
52+# will start.
53+export DESKTOP_SESSION=ubuntu-touch
54+
55+# We disable ofono using pulse. It causes problems with racing with the user's
56+# pulse. We need to come up with a better long-term fix for this, because we
57+# eventually need the greeter to play ringtones for users that aren't logged in.
58+set_greeter_var PA_DISABLED 1
59+
60+# Normal unity8 sessions are entirely driven by Upstart. But greeters
61+# are special. They need access to the file descriptors that lightdm
62+# creates for them and don't want to start all the services that a normal
63+# session would. So it's inconvenient to live within an upstart session.
64+# But... we still want to use Upstart for some services. So launch here.
65+MIR_SOCKET=$SUB_SOCKET $TOUCH_WRAPPER /sbin/upstart --user --no-startup-event &
66+INIT_PID=$!
67+while [ ! -e "$XDG_RUNTIME_DIR/upstart/sessions/$INIT_PID.session" ]; do sleep 0.1; done
68+export UPSTART_SESSION=$(/sbin/initctl list-sessions | grep "^$INIT_PID " | cut -d' ' -f2)
69+
70+# Start any pre-greeter tasks if needed (like wizard)
71+/sbin/initctl emit unity8-greeter-starting
72+
73+# Define language here for phone if available. When phone user switches their
74+# language, they expect that to affect the greeter too. But the user doesn't
75+# have permission to switch system language, only their own. So we notice if
76+# the phablet user exists and use their language if so. TODO: talk to design
77+# about whether we should switch language on fly as users are selected (this
78+# is very hard to do technically).
79+#
80+# Do this after unity8-greeter-starting, in case a customization upstart job
81+# changes language.
82+if [ "$(id -u phablet 2>/dev/null)" = "32011" ]; then
83+ USER_LANG=$(gdbus call --system --dest org.freedesktop.Accounts --object-path /org/freedesktop/Accounts/User32011 --method org.freedesktop.DBus.Properties.Get org.freedesktop.Accounts.User Language | cut -d\' -f2)
84+ if [ -n "$USER_LANG" ]; then
85+ set_greeter_var LANGUAGE "$USER_LANG"
86+ fi
87+ USER_LOCALE=$(gdbus call --system --dest org.freedesktop.Accounts --object-path /org/freedesktop/Accounts/User32011 --method org.freedesktop.DBus.Properties.Get org.freedesktop.Accounts.User FormatsLocale | cut -d\' -f2)
88+ if [ -n "$USER_LOCALE" ]; then
89+ set_greeter_var LANG "$USER_LOCALE"
90+ set_greeter_var LC_ALL "$USER_LOCALE"
91+ fi
92+fi
93+
94+# And finally actually start the greeter
95+exec env QT_QPA_PLATFORM=ubuntumirclient MIR_SERVER_FILE=$SUB_SOCKET $TOUCH_WRAPPER $@ &
96+CMD_PID=$!
97+wait $CMD_PID
98+CMD_PID=
data/unity8-greeter.desktop.innew file+7
@@ -0,0 +1,7 @@
1+[Desktop Entry]
2+Type=Application
3+Name=Unity 8 Greeter
4+Comment=The converged Unity shell's Greeter
5+Exec=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity8-greeter-wrapper @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@/unity8 --mode=greeter
6+X-LightDM-Session-Type=mir
7+X-Ubuntu-Touch=true
data/unity8-greeter.pklanew file+44
@@ -0,0 +1,44 @@
1+# DO NOT EDIT THIS FILE, it will be overwritten on update
2+# Place your local configurations under /etc/polkit-1/localauthority/
3+
4+[Disable Controlling of Network Devices]
5+Identity=unix-user:lightdm
6+Action=org.freedesktop.NetworkManager.enable-disable-network;org.freedesktop.NetworkManager.enable-disable-wifi;org.freedesktop.NetworkManager.enable-disable-wwan;org.freedesktop.NetworkManager.enable-disable-wimax;
7+ResultActive=no
8+ResultInactive=no
9+ResultsAny=no
10+
11+[Disable Sleep and Wake]
12+Identity=unix-user:lightdm
13+Action=org.freedesktop.NetworkManager.sleep-wake
14+ResultActive=no
15+ResultInactive=no
16+ResultsAny=no
17+
18+[Disable WiFi Sharing]
19+Identity=unix-user:lightdm
20+Action=org.freedesktop.NetworkManager.wifi.share.protected;org.freedesktop.NetworkManager.wifi.share.open
21+ResultActive=no
22+ResultInactive=no
23+ResultsAny=no
24+
25+[Disable Settings Modifications]
26+Identity=unix-user:lightdm
27+Action=org.freedesktop.NetworkManager.settings.modify.own;org.freedesktop.NetworkManager.settings.modify.system;org.freedesktop.NetworkManager.settings.modify.hostname
28+ResultActive=no
29+ResultInactive=no
30+ResultsAny=no
31+
32+[Disable User Connections]
33+Identity=unix-user:lightdm
34+Action=org.freedesktop.NetworkManager.use-user-connections
35+ResultActive=no
36+ResultInactive=no
37+ResultsAny=no
38+
39+[Enable Controlling of Network Connections]
40+Identity=unix-user:lightdm
41+Action=org.freedesktop.NetworkManager.network-control
42+ResultActive=yes
43+ResultInactive=no
44+ResultsAny=no
debian/control+12
@@ -23,6 +23,7 @@ Build-Depends: cmake,
2323 libglib2.0-dev,
2424 libgsettings-qt-dev,
2525 libhardware-dev,
26+ liblightdm-qt5-3-dev,
2627 libpam0g-dev,
2728 libpay2-dev,
2829 libpulse-dev,
@@ -82,6 +83,17 @@ Depends: qmenumodel-qml (>= 0.2.9),
8283Description: Indicators client test application
8384 This package contains the client application for indicators used by autopilot
8485
86+Package: unity8-greeter
87+Architecture: any
88+Depends: unity8 (= ${binary:Version}),
89+ unity-system-compositor,
90+ ${misc:Depends},
91+ ${shlibs:Depends}
92+Recommends: lightdm
93+Provides: lightdm-greeter
94+Description: The Unity8 Greeter
95+ The Unity 8 greeter is the primary login greeter for Ubuntu devices.
96+
8597Package: unity-scope-tool
8698Architecture: any
8799Depends: unity8-common (= ${source:Version}),
debian/rules+1−1
@@ -37,6 +37,6 @@ override_dh_installdeb:
3737override_dh_makeshlibs:
3838 dh_makeshlibs -Nunity8-private -Nunity8-fake-env
3939
40−# libMockLightDM-qml.so links against liblightdm-qt5-2.so which doesn't exist
40+# libMockLightDM-qml.so links against liblightdm-qt5-3.so which doesn't exist
4141override_dh_shlibdeps:
4242 dh_shlibdeps -XlibMockLightDM-qml.so
debian/unity8-greeter.installnew file+5
@@ -0,0 +1,5 @@
1+data/unity8-greeter-wrapper usr/bin/
2+data/unity8-greeter-init.conf usr/share/upstart/sessions/
3+data/unity8-greeter.pkla /var/lib/polkit-1/localauthority/10-vendor.d/
4+usr/share/lightdm/greeters/unity8-greeter.desktop
5+usr/share/lightdm/lightdm.conf.d/51-unity8-greeter.conf
debian/unity8-private.install+1−1
@@ -4,7 +4,7 @@ usr/lib/*/unity8/qml/Cursor
44usr/lib/*/unity8/qml/Dash
55usr/lib/*/unity8/qml/GlobalShortcut
66usr/lib/*/unity8/qml/Greeter
7−usr/lib/*/unity8/qml/IntegratedLightDM
7+usr/lib/*/unity8/qml/LightDM
88usr/lib/*/unity8/qml/Lights
99usr/lib/*/unity8/qml/Powerd
1010usr/lib/*/unity8/qml/ScreenshotDirectory
plugins/CMakeLists.txt+1−1
@@ -15,7 +15,7 @@ add_subdirectory(AccountsService)
1515add_subdirectory(Cursor)
1616add_subdirectory(GlobalShortcut)
1717add_subdirectory(Greeter)
18−add_subdirectory(IntegratedLightDM)
18+add_subdirectory(LightDM)
1919add_subdirectory(Lights)
2020add_subdirectory(Dash)
2121add_subdirectory(Powerd)
plugins/IntegratedLightDM/CMakeLists.txtdeleted−40
@@ -1,40 +0,0 @@
1−pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
2−# TODO: Once we split out a separate greeter process, uncomment these lines
3−#pkg_check_modules(LIBLIGHTDM REQUIRED liblightdm-qt5-2)
4−
5−add_subdirectory(liblightdm)
6−
7−include_directories(
8− ${CMAKE_CURRENT_SOURCE_DIR}
9− ${CMAKE_CURRENT_BINARY_DIR}
10− ${CMAKE_SOURCE_DIR}/plugins/Utils
11− ${CMAKE_SOURCE_DIR}/tests/mocks/IntegratedLightDM
12− #${LIBLIGHTDM_INCLUDE_DIRS}
13− ${libunity8-private_SOURCE_DIR}
14− ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
15−)
16−
17−set(QMLPLUGIN_SRC
18− ../Utils/unitysortfilterproxymodelqml.cpp # FIXME evaluate a more generic approach for using other plugins
19− DBusGreeter.cpp
20− DBusGreeterList.cpp
21− Greeter.cpp
22− plugin.cpp
23− UsersModel.cpp
24− )
25−
26−add_library(IntegratedLightDM-qml MODULE
27− ${QMLPLUGIN_SRC}
28− )
29−
30−target_link_libraries(IntegratedLightDM-qml
31− integratedLightDM
32− unity8-private
33−# TODO: Once we split out a separate greeter process, uncomment these lines
34−# ${LIBLIGHTDM_LDFLAGS}
35− ${LIBUSERMETRICSOUTPUT_LDFLAGS}
36− )
37−
38−qt5_use_modules(IntegratedLightDM-qml DBus Gui Qml)
39−
40−add_unity8_plugin(IntegratedLightDM 0.1 IntegratedLightDM TARGETS IntegratedLightDM-qml)
plugins/LightDM/CMakeLists.txtnew file+26
@@ -0,0 +1,26 @@
1+pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
2+
3+find_package(Qt5Core REQUIRED)
4+find_package(Qt5Quick REQUIRED)
5+
6+include_directories(
7+ ${CMAKE_CURRENT_SOURCE_DIR}
8+ ${CMAKE_CURRENT_BINARY_DIR}
9+ ${CMAKE_SOURCE_DIR}/plugins/Utils
10+ ${CMAKE_BINARY_DIR}/tests/mocks/LightDM/IntegratedLightDM
11+ ${libunity8-private_SOURCE_DIR}
12+ ${LIBUSERMETRICSOUTPUT_INCLUDE_DIRS}
13+)
14+
15+set(QMLPLUGIN_SRC
16+ ../Utils/unitysortfilterproxymodelqml.cpp
17+ DBusGreeter.cpp
18+ DBusGreeterList.cpp
19+ Greeter.cpp
20+ plugin.cpp
21+ SessionsModel.cpp
22+ UsersModel.cpp
23+ )
24+
25+add_subdirectory(FullLightDM)
26+add_subdirectory(IntegratedLightDM)
plugins/IntegratedLightDM/DBusGreeter.cpp → plugins/LightDM/DBusGreeter.cpprenamed+5−4
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -24,7 +24,8 @@ DBusGreeter::DBusGreeter(Greeter *greeter, const QString &path)
2424 : UnityDBusObject(path, QStringLiteral("com.canonical.UnityGreeter"), true, greeter),
2525 m_greeter(greeter)
2626{
27− connect(m_greeter, &Greeter::isActiveChanged, this, &DBusGreeter::isActiveChangedHandler);
27+ connect(m_greeter, &Greeter::isActiveChanged,
28+ this, &DBusGreeter::isActiveChangedHandler);
2829}
2930
3031bool DBusGreeter::isActive() const
@@ -34,12 +35,12 @@ bool DBusGreeter::isActive() const
3435
3536void DBusGreeter::ShowGreeter()
3637{
37− return Q_EMIT m_greeter->showGreeter();
38+ Q_EMIT m_greeter->showGreeter();
3839}
3940
4041void DBusGreeter::HideGreeter()
4142{
42− return Q_EMIT m_greeter->hideGreeter();
43+ Q_EMIT m_greeter->hideGreeter();
4344}
4445
4546void DBusGreeter::isActiveChangedHandler()
plugins/IntegratedLightDM/DBusGreeter.h → plugins/LightDM/DBusGreeter.hrenamed

The content is the same.

plugins/IntegratedLightDM/DBusGreeterList.cpp → plugins/LightDM/DBusGreeterList.cpprenamed

The content is the same.

plugins/IntegratedLightDM/DBusGreeterList.h → plugins/LightDM/DBusGreeterList.hrenamed

The content is the same.

plugins/LightDM/FullLightDM/CMakeLists.txtnew file+27
@@ -0,0 +1,27 @@
1+pkg_check_modules(LIBLIGHTDM REQUIRED liblightdm-qt5-3)
2+
3+set(PLUGIN_CLASSNAME "FullLightDM")
4+
5+add_definitions(-DFULL_LIGHTDM)
6+
7+include_directories(
8+ ../
9+ ${LIBLIGHTDM_INCLUDE_DIRS}
10+ )
11+
12+foreach(source_file ${QMLPLUGIN_SRC})
13+ list(APPEND RELATIVE_QMLPLUGIN_SRC ../${source_file})
14+endforeach()
15+
16+add_library(FullLightDM-qml MODULE
17+ ${RELATIVE_QMLPLUGIN_SRC}
18+ )
19+
20+target_link_libraries(FullLightDM-qml
21+ unity8-private
22+ ${LIBLIGHTDM_LDFLAGS}
23+ ${LIBUSERMETRICSOUTPUT_LDFLAGS}
24+ )
25+
26+qt5_use_modules(FullLightDM-qml DBus Gui Qml)
27+add_unity8_plugin(FullLightDM 0.1 LightDM/FullLightDM TARGETS FullLightDM-qml)
plugins/LightDM/FullLightDM/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module LightDM.FullLightDM
2+plugin FullLightDM-qml
3+typeinfo FullLightDM.qmltypes
plugins/IntegratedLightDM/Greeter.cpp → plugins/LightDM/Greeter.cpprenamed+13−2
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -13,7 +13,6 @@
1313 * You should have received a copy of the GNU General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 *
16− * Author: Michael Terry <michael.terry@canonical.com>
1716 */
1817
1918#include "Greeter.h"
@@ -72,12 +71,24 @@ QString Greeter::authenticationUser() const
7271 return d->m_greeter->authenticationUser();
7372}
7473
74+QString Greeter::defaultSessionHint() const
75+{
76+ Q_D(const Greeter);
77+ return d->m_greeter->defaultSessionHint();
78+}
79+
7580bool Greeter::promptless() const
7681{
7782 Q_D(const Greeter);
7883 return d->promptless;
7984}
8085
86+QString Greeter::selectUser() const
87+{
88+ Q_D(const Greeter);
89+ return d->m_greeter->selectUserHint();
90+}
91+
8192void Greeter::authenticate(const QString &username)
8293{
8394 Q_D(Greeter);
plugins/IntegratedLightDM/Greeter.h → plugins/LightDM/Greeter.hrenamed+5−2
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012,2013 Canonical, Ltd.
2+ * Copyright (C) 2012,2013,2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -13,7 +13,6 @@
1313 * You should have received a copy of the GNU General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 *
16− * Authors: Michael Terry <michael.terry@canonical.com>
1716 */
1817
1918/* This class is a really tiny filter around QLightDM::Greeter. There are some
@@ -37,7 +36,9 @@ class Greeter : public QObject
3736 Q_PROPERTY(bool active READ isActive WRITE setIsActive NOTIFY isActiveChanged)
3837 Q_PROPERTY(bool authenticated READ isAuthenticated NOTIFY isAuthenticatedChanged)
3938 Q_PROPERTY(QString authenticationUser READ authenticationUser NOTIFY authenticationUserChanged)
39+ Q_PROPERTY(QString defaultSession READ defaultSessionHint CONSTANT)
4040 Q_PROPERTY(bool promptless READ promptless NOTIFY promptlessChanged)
41+ Q_PROPERTY(QString selectUser READ selectUser CONSTANT)
4142
4243public:
4344 explicit Greeter(QObject* parent=0);
@@ -45,7 +46,9 @@ public:
4546 bool isActive() const;
4647 bool isAuthenticated() const;
4748 QString authenticationUser() const;
49+ QString defaultSessionHint() const;
4850 bool promptless() const;
51+ QString selectUser() const;
4952
5053public Q_SLOTS:
5154 void authenticate(const QString &username=QString());
plugins/IntegratedLightDM/GreeterPrivate.h → plugins/LightDM/GreeterPrivate.hrenamed

The content is the same.

plugins/LightDM/IntegratedLightDM/CMakeLists.txtnew file+30
@@ -0,0 +1,30 @@
1+set(PLUGIN_CLASSNAME "IntegratedLightDM")
2+
3+add_definitions(-DINTEGRATED_LIGHTDM)
4+
5+foreach(include_directory ${QMLPLUGIN_INCLUDES})
6+ list(APPEND RELATIVE_QMLPLUGIN_INCLUDES ../${include_directory})
7+endforeach()
8+
9+include_directories(
10+ . #QLightDM
11+ )
12+
13+foreach(source_file ${QMLPLUGIN_SRC})
14+ list(APPEND RELATIVE_QMLPLUGIN_SRC ../${source_file})
15+endforeach()
16+
17+add_library(IntegratedLightDM-qml MODULE
18+ ${RELATIVE_QMLPLUGIN_SRC}
19+ )
20+
21+target_link_libraries(IntegratedLightDM-qml
22+ integratedLightDM
23+ unity8-private
24+ ${LIBUSERMETRICSOUTPUT_LDFLAGS}
25+ )
26+
27+qt5_use_modules(IntegratedLightDM-qml DBus Gui Qml)
28+add_unity8_plugin(IntegratedLightDM 0.1 LightDM/IntegratedLightDM TARGETS IntegratedLightDM-qml)
29+
30+add_subdirectory(liblightdm)
plugins/LightDM/IntegratedLightDM/QLightDM/Greeternew file+17
@@ -0,0 +1,17 @@
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"
plugins/LightDM/IntegratedLightDM/QLightDM/SessionsModelnew file+17
@@ -0,0 +1,17 @@
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"
plugins/LightDM/IntegratedLightDM/QLightDM/UsersModelnew file+17
@@ -0,0 +1,17 @@
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"
plugins/IntegratedLightDM/liblightdm/CMakeLists.txt → plugins/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txtrenamed+4−2
@@ -2,8 +2,10 @@ pkg_check_modules(LIBUSERMETRICSOUTPUT REQUIRED libusermetricsoutput-1)
22
33set(LibLightDM_SOURCES
44 Greeter.cpp
5+ SessionsModel.cpp
56 UsersModel.cpp
67 GreeterPrivate.cpp
8+ SessionsModelPrivate.cpp
79 UsersModelPrivate.cpp
810 ${CMAKE_SOURCE_DIR}/plugins/AccountsService/AccountsServiceDBusAdaptor.cpp
911 ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
@@ -46,8 +48,8 @@ set_target_properties(integratedLightDMSession PROPERTIES
4648 COMPILE_FLAGS "-DSM_BUSNAME=sessionBus -fPIC")
4749set_target_properties(MockLightDM-demo-shared PROPERTIES
4850 COMPILE_FLAGS "-DSM_BUSNAME=systemBus"
49− OUTPUT_NAME lightdm-qt5-2)
51+ OUTPUT_NAME lightdm-qt5-3)
5052
5153install(TARGETS MockLightDM-demo-shared
52− DESTINATION ${SHELL_INSTALL_QML}/mocks/IntegratedLightDM/demo
54+ DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/IntegratedLightDM/demo
5355 )
plugins/IntegratedLightDM/liblightdm/Greeter.cpp → plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.cpprenamed

The content is the same.

plugins/IntegratedLightDM/liblightdm/Greeter.h → plugins/LightDM/IntegratedLightDM/liblightdm/Greeter.hrenamed

The content is the same.

plugins/IntegratedLightDM/liblightdm/GreeterPrivate.cpp → plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpprenamed+1−2
@@ -50,8 +50,7 @@ public:
5050 {
5151 qRegisterMetaType<QLightDM::GreeterImpl::ResponseFuture>("QLightDM::GreeterImpl::ResponseFuture");
5252
53− connect(&futureWatcher, &QFutureWatcher<int>::finished,
54− this, &GreeterImpl::finishPam);
53+ connect(&futureWatcher, &QFutureWatcher<int>::finished, this, &GreeterImpl::finishPam);
5554 connect(this, SIGNAL(showMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)),
5655 this, SLOT(handleMessage(pam_handle *, QString, QLightDM::Greeter::MessageType)));
5756 // This next connect is how we pass ResponseFutures between threads
plugins/IntegratedLightDM/liblightdm/GreeterPrivate.h → plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.hrenamed

The content is the same.

plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cppnew file+88
@@ -0,0 +1,88 @@
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+
34+namespace QLightDM
35+{
36+
37+SessionsModel::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+
47+SessionsModel::~SessionsModel()
48+{
49+ delete d_ptr;
50+}
51+
52+QVariant 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+
72+QHash<int, QByteArray> SessionsModel::roleNames() const
73+{
74+ return m_roleNames;
75+}
76+
77+int 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
plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModel.hnew file+72
@@ -0,0 +1,72 @@
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
30+namespace QLightDM
31+{
32+class SessionsModelPrivate;
33+
34+class 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
plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cppnew file+36
@@ -0,0 +1,36 @@
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+
24+namespace QLightDM
25+{
26+
27+SessionsModelPrivate::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
plugins/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.hnew file+54
@@ -0,0 +1,54 @@
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+
24+namespace QLightDM
25+{
26+class SessionsModel;
27+
28+class SessionItem
29+{
30+public:
31+ QString key;
32+ QString type; // unused
33+ QString name;
34+ QString comment; // unused
35+};
36+
37+class SessionsModelPrivate
38+{
39+public:
40+ explicit SessionsModelPrivate(SessionsModel* parent=0);
41+ virtual ~SessionsModelPrivate() = default;
42+
43+ QList<SessionItem> sessionItems;
44+
45+protected:
46+ SessionsModel* const q_ptr;
47+
48+private:
49+ Q_DECLARE_PUBLIC(SessionsModel)
50+};
51+
52+} // namespace QLightDM
53+
54+#endif // UNITY_INTEGRATED_SESSIONSMODEL_PRIVATE_H
plugins/IntegratedLightDM/liblightdm/UsersModel.cpp → plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpprenamed

The content is the same.

plugins/IntegratedLightDM/liblightdm/UsersModel.h → plugins/LightDM/IntegratedLightDM/liblightdm/UsersModel.hrenamed

The content is the same.

plugins/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp → plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpprenamed

The content is the same.

plugins/IntegratedLightDM/liblightdm/UsersModelPrivate.h → plugins/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.hrenamed

The content is the same.

plugins/LightDM/IntegratedLightDM/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module LightDM.IntegratedLightDM
2+plugin IntegratedLightDM-qml
3+typeinfo IntegratedLightDM.qmltypes
plugins/LightDM/SessionsModel.cppnew file+122
@@ -0,0 +1,122 @@
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 "SessionsModel.h"
19+#include <QtCore/QFile>
20+#include <QtCore/QSortFilterProxyModel>
21+
22+QHash<int, QByteArray> SessionsModel::roleNames() const
23+{
24+ return m_roleNames;
25+}
26+
27+int SessionsModel::rowCount(const QModelIndex& parent) const
28+{
29+ return m_model->rowCount(parent);
30+}
31+
32+QList<QUrl> SessionsModel::iconSearchDirectories() const
33+{
34+ return m_iconSearchDirectories;
35+}
36+
37+void SessionsModel::setIconSearchDirectories(const QList<QUrl> searchDirectories)
38+{
39+ // QML gives us a url with file:// prepended which breaks QFile::exists()
40+ // so convert the url to a local file
41+ QList<QUrl> localList = {};
42+ Q_FOREACH(const QUrl& searchDirectory, searchDirectories)
43+ {
44+ localList.append(searchDirectory.toLocalFile());
45+ }
46+ m_iconSearchDirectories = localList;
47+ Q_EMIT iconSearchDirectoriesChanged();
48+}
49+
50+QUrl SessionsModel::iconUrl(const QString sessionName) const
51+{
52+ Q_FOREACH(const QUrl& searchDirectory, m_iconSearchDirectories)
53+ {
54+ // This is an established icon naming convention
55+ QString customIconUrl = searchDirectory.toString(QUrl::StripTrailingSlash) +
56+ "/custom_" + sessionName + "_badge.png";
57+ QString iconUrl = searchDirectory.toString(QUrl::StripTrailingSlash) +
58+ "/" + sessionName + "_badge.png";
59+
60+ QFile customIconFile(customIconUrl);
61+ QFile iconFile(iconUrl);
62+ if (customIconFile.exists()) {
63+ return QUrl(customIconUrl);
64+ } else if (iconFile.exists()) {
65+ return QUrl(iconUrl);
66+ } else{
67+ // Search the legacy way
68+ QString path = searchDirectory.toString(QUrl::StripTrailingSlash) + "/";
69+ if (sessionName == "ubuntu" || sessionName == "ubuntu-2d") {
70+ path += "ubuntu_badge.png";
71+ } else if(
72+ sessionName == "gnome-classic" ||
73+ sessionName == "gnome-flashback-compiz" ||
74+ sessionName == "gnome-flashback-metacity" ||
75+ sessionName == "gnome-shell" ||
76+ sessionName == "gnome-wayland" ||
77+ sessionName == "gnome"
78+ ){
79+ path += "gnome_badge.png";
80+ } else if (sessionName == "plasma") {
81+ path += "kde_badge.png";
82+ } else if (sessionName == "xterm") {
83+ path += "recovery_console_badge.png";
84+ } else if (sessionName == "remote-login") {
85+ path += "remote_login_help.png";
86+ }
87+
88+ if (QFile(path).exists()) {
89+ return path;
90+ }
91+ }
92+ }
93+
94+ // FIXME make this smarter
95+ return QUrl("./graphics/session_icons/unknown_badge.png");
96+}
97+
98+QVariant SessionsModel::data(const QModelIndex& index, int role) const
99+{
100+ switch (role) {
101+ case SessionsModel::IconRole:
102+ return iconUrl(m_model->data(index, Qt::DisplayRole).toString());
103+ default:
104+ return m_model->data(index, role);
105+ }
106+}
107+
108+SessionsModel::SessionsModel(QObject* parent)
109+ : UnitySortFilterProxyModelQML(parent)
110+{
111+ // Add a custom IconRole that isn't in either of the lightdm implementations
112+ m_model = new QLightDM::SessionsModel(this);
113+ m_roleNames = m_model->roleNames();
114+ m_roleNames[IconRole] = "icon_url";
115+
116+ setModel(m_model);
117+ setSourceModel(m_model);
118+ setSortCaseSensitivity(Qt::CaseInsensitive);
119+ setSortLocaleAware(true);
120+ setSortRole(Qt::DisplayRole);
121+ sort(0);
122+}
plugins/LightDM/SessionsModel.hnew file+68
@@ -0,0 +1,68 @@
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_SESSIONSMODEL_H
19+#define UNITY_SESSIONSMODEL_H
20+
21+#include <unitysortfilterproxymodelqml.h>
22+#include <QLightDM/SessionsModel>
23+#include <QtCore/QHash>
24+#include <QtCore/QObject>
25+#include <QtCore/QUrl>
26+
27+class SessionsModel : public UnitySortFilterProxyModelQML
28+{
29+ Q_OBJECT
30+
31+ Q_ENUMS(SessionModelRoles)
32+
33+ Q_PROPERTY(QList<QUrl> iconSearchDirectories READ iconSearchDirectories
34+ WRITE setIconSearchDirectories NOTIFY iconSearchDirectoriesChanged)
35+Q_SIGNALS:
36+ void iconSearchDirectoriesChanged();
37+
38+public:
39+ enum SessionModelRoles {
40+ /* This is tricky / ugly. Since we are ultimately chaining 3 enums together,
41+ * the _first_ value of this enum MUST be the _last_ value of
42+ * QLightDM::SessionsModel::SessionModelRoles and consquently, this must
43+ * also match the last value in the corresponding enum of the integrated lib
44+ */
45+ TypeRole = QLightDM::SessionsModel::SessionModelRoles::TypeRole,
46+ IconRole
47+ };
48+
49+ explicit SessionsModel(QObject* parent=nullptr);
50+
51+ QHash<int, QByteArray> roleNames() const override;
52+ int rowCount(const QModelIndex& parent) const override;
53+ QVariant data(const QModelIndex& index, int role) const override;
54+ QList<QUrl> iconSearchDirectories() const;
55+ Q_INVOKABLE QUrl iconUrl(const QString sessionName) const;
56+
57+ void setIconSearchDirectories(const QList<QUrl> searchDirectories);
58+private:
59+ QLightDM::SessionsModel* m_model;
60+ QHash<int, QByteArray> m_roleNames;
61+ QList<QUrl> m_iconSearchDirectories{
62+ QUrl("/usr/share/unity8/Greeter/graphics/session_icons"),
63+ QUrl("/usr/local/share/unity-greeter"),
64+ QUrl("/usr/share/unity-greeter/")};
65+
66+};
67+
68+#endif // UNITY_SESSIONSMODEL_H
plugins/IntegratedLightDM/UsersModel.cpp → plugins/LightDM/UsersModel.cpprenamed

The content is the same.

plugins/IntegratedLightDM/UsersModel.h → plugins/LightDM/UsersModel.hrenamed

The content is the same.

plugins/IntegratedLightDM/plugin.cpp → plugins/LightDM/plugin.cpprenamed+26−4
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012,2013, 2015 Canonical, Ltd.
2+ * Copyright (C) 2012,2013,2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -19,9 +19,11 @@
1919#include "DBusGreeter.h"
2020#include "DBusGreeterList.h"
2121#include "Greeter.h"
22+#include "SessionsModel.h"
2223#include "UsersModel.h"
2324#include <libusermetricsoutput/ColorTheme.h>
2425#include <libusermetricsoutput/UserMetrics.h>
26+#include <QLightDM/SessionsModel>
2527#include <QLightDM/UsersModel>
2628
2729#include <QAbstractItemModel>
@@ -40,6 +42,13 @@ static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
4042 return greeter;
4143}
4244
45+static QObject *sessions_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
46+{
47+ Q_UNUSED(engine)
48+ Q_UNUSED(scriptEngine)
49+ return new SessionsModel();
50+}
51+
4352static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
4453{
4554 Q_UNUSED(engine)
@@ -54,16 +63,29 @@ static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine
5463 return UserMetricsOutput::UserMetrics::getInstance();
5564}
5665
57−void IntegratedLightDMPlugin::registerTypes(const char *uri)
66+void PLUGIN_CLASSNAME::registerTypes(const char *uri)
5867{
5968 qmlRegisterType<QAbstractItemModel>();
6069 qmlRegisterType<UserMetricsOutput::ColorTheme>();
6170
62− Q_ASSERT(uri == QLatin1String("IntegratedLightDM"));
71+#if defined INTEGRATED_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);
77+#else
78+ #error No library defined in LightDM plugin
79+#endif
80+
6381 qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");
6482 qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");
65− qmlRegisterSingletonType<Greeter>(uri, 0, 1, "Greeter", greeter_provider);
83+
84+ qmlRegisterSingletonType<SessionsModel>(uri, 0, 1, "Sessions", sessions_provider);
85+ qmlRegisterUncreatableType<SessionsModel>(uri, 0, 1, "SessionRoles", QStringLiteral("Type is not instantiable"));
86+
6687 qmlRegisterSingletonType<UsersModel>(uri, 0, 1, "Users", users_provider);
6788 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", QStringLiteral("Type is not instantiable"));
89+
6890 qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);
6991}
plugins/IntegratedLightDM/plugin.h → plugins/LightDM/plugin.hrenamed+5−5
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2012,2013, 2015 Canonical, Ltd.
2+ * Copyright (C) 2012,2013,2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -15,13 +15,13 @@
1515 *
1616 */
1717
18−#ifndef INTEGRATED_LIGHTDM_PLUGIN_H
19−#define INTEGRATED_LIGHTDM_PLUGIN_H
18+#ifndef LIGHTDM_PLUGIN_H
19+#define LIGHTDM_PLUGIN_H
2020
2121#include <QtQml/QQmlEngine>
2222#include <QtQml/QQmlExtensionPlugin>
2323
24−class IntegratedLightDMPlugin : public QQmlExtensionPlugin
24+class PLUGIN_CLASSNAME : public QQmlExtensionPlugin
2525{
2626 Q_OBJECT
2727 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
@@ -30,4 +30,4 @@ public:
3030 void registerTypes(const char *uri) override;
3131};
3232
33−#endif /* INTEGRATED_LIGHTDM_PLUGIN_H */
33+#endif /* LIGHTDM_PLUGIN_H */
plugins/IntegratedLightDM/qmldir → plugins/LightDM/qmldirrenamed

The content is the same.

plugins/Unity/Indicators/indicatorsmanager.cpp+1−1
@@ -291,7 +291,7 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator_name)
291291 // The rest of the indicators respect their default profile (which is "phone", even on desktop PCs)
292292 if ((new_indicator->identifier() == QStringLiteral("indicator-session"))
293293 || (new_indicator->identifier() == QStringLiteral("indicator-power") && m_platform.isPC())) {
294− new_indicator->setProfile(QStringLiteral("desktop"));
294+ new_indicator->setProfile(m_profile.replace(QStringLiteral("phone"), QStringLiteral("desktop")));
295295 } else {
296296 new_indicator->setProfile(m_profile);
297297 }
po/am.po+6−6
@@ -8,14 +8,14 @@ msgstr ""
88"Project-Id-Version: unity8\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2016-06-27 18:49+0000\n"
11−"PO-Revision-Date: 2016-06-19 16:08+0000\n"
11+"PO-Revision-Date: 2016-07-05 02:15+0000\n"
1212"Last-Translator: samson <Unknown>\n"
1313"Language-Team: Amharic <am@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=2; plural=n > 1;\n"
18−"X-Launchpad-Export-Date: 2016-06-30 05:51+0000\n"
18+"X-Launchpad-Export-Date: 2016-07-05 05:58+0000\n"
1919"X-Generator: Launchpad (build 18115)\n"
2020
2121#: plugins/IntegratedLightDM/Greeter.cpp:112
@@ -294,12 +294,12 @@ msgstr "እሺ"
294294#: qml/Components/MediaServices/VideoPlayerControls.qml:44
295295#, qt-format
296296msgid "%1:%2:%3"
297−msgstr ""
297+msgstr "%1:%2:%3"
298298
299299#: qml/Components/MediaServices/VideoPlayerControls.qml:49
300300#, qt-format
301301msgid "%1:%2"
302−msgstr ""
302+msgstr "%1:%2"
303303
304304#: qml/Components/ModeSwitchWarningDialog.qml:32
305305msgid "Apps may have unsaved data:"
@@ -440,7 +440,7 @@ msgstr "መክፈቻ"
440440
441441#: qml/Greeter/Greeter.qml:539
442442msgid "Try again"
443−msgstr ""
443+msgstr "እንደገና ይሞክሩ"
444444
445445#: qml/Greeter/LoginList.qml:259
446446msgid "Retry"
@@ -871,7 +871,7 @@ msgstr "ያለ ሲም ለ መቀጠል መዝለያውን መታ ያድርጉ"
871871
872872#: qml/Wizard/PasswordMeter.qml:87
873873msgid "Password too short"
874−msgstr ""
874+msgstr "የ መግቢያ ቃል በጣም አጭር ነው"
875875
876876#: qml/Wizard/PasswordMeter.qml:89
877877msgid "Passwords match"
po/en_GB.po+9−9
@@ -8,14 +8,14 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2016-06-27 18:49+0000\n"
11−"PO-Revision-Date: 2016-05-10 10:10+0000\n"
11+"PO-Revision-Date: 2016-07-05 00:37+0000\n"
1212"Last-Translator: Andi Chandler <Unknown>\n"
1313"Language-Team: English (United Kingdom) <en_GB@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2016-06-30 05:53+0000\n"
18+"X-Launchpad-Export-Date: 2016-07-05 05:58+0000\n"
1919"X-Generator: Launchpad (build 18115)\n"
2020
2121#: plugins/IntegratedLightDM/Greeter.cpp:112
@@ -121,31 +121,31 @@ msgstr "Restart"
121121
122122#: qml/Components/KeyboardShortcutsOverlay.qml:41
123123msgid "Keyboard Shortcuts"
124−msgstr ""
124+msgstr "Keyboard Shortcuts"
125125
126126#: qml/Components/KeyboardShortcutsOverlay.qml:55
127127msgid "Unity 8"
128−msgstr ""
128+msgstr "Unity 8"
129129
130130#: qml/Components/KeyboardShortcutsOverlay.qml:62
131131msgid "PrtScr"
132−msgstr ""
132+msgstr "PrtScr"
133133
134134#: qml/Components/KeyboardShortcutsOverlay.qml:67
135135msgid "Takes a screenshot."
136−msgstr ""
136+msgstr "Takes a screenshot."
137137
138138#: qml/Components/KeyboardShortcutsOverlay.qml:75
139139msgid "Alt + PrtScr"
140−msgstr ""
140+msgstr "Alt + PrtScr"
141141
142142#: qml/Components/KeyboardShortcutsOverlay.qml:80
143143msgid "Takes a screenshot of a window."
144−msgstr ""
144+msgstr "Takes a screenshot of a window."
145145
146146#: qml/Components/KeyboardShortcutsOverlay.qml:88
147147msgid "Super + Space"
148−msgstr ""
148+msgstr "Super + Space"
149149
150150#: qml/Components/KeyboardShortcutsOverlay.qml:93
151151msgid "Switches to next keyboard layout."
po/ug.po+54−54
@@ -8,14 +8,14 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2016-06-27 18:49+0000\n"
11−"PO-Revision-Date: 2015-12-01 07:37+0000\n"
11+"PO-Revision-Date: 2016-07-03 13:56+0000\n"
1212"Last-Translator: Eltikin <eltikinuyghur@hotmail.com>\n"
1313"Language-Team: Uyghur Computer Science Association <UKIJ@yahoogroups.com>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=1; plural=0;\n"
18−"X-Launchpad-Export-Date: 2016-06-30 05:52+0000\n"
18+"X-Launchpad-Export-Date: 2016-07-04 06:10+0000\n"
1919"X-Generator: Launchpad (build 18115)\n"
2020
2121#: plugins/IntegratedLightDM/Greeter.cpp:112
@@ -120,15 +120,15 @@ msgstr "قايتا قوزغات"
120120
121121#: qml/Components/KeyboardShortcutsOverlay.qml:41
122122msgid "Keyboard Shortcuts"
123−msgstr ""
123+msgstr "تېزلەتمىلەر"
124124
125125#: qml/Components/KeyboardShortcutsOverlay.qml:55
126126msgid "Unity 8"
127−msgstr ""
127+msgstr "Unity 8"
128128
129129#: qml/Components/KeyboardShortcutsOverlay.qml:62
130130msgid "PrtScr"
131−msgstr ""
131+msgstr "PrtScr"
132132
133133#: qml/Components/KeyboardShortcutsOverlay.qml:67
134134msgid "Takes a screenshot."
@@ -136,7 +136,7 @@ msgstr ""
136136
137137#: qml/Components/KeyboardShortcutsOverlay.qml:75
138138msgid "Alt + PrtScr"
139−msgstr ""
139+msgstr "Alt + PrtScr"
140140
141141#: qml/Components/KeyboardShortcutsOverlay.qml:80
142142msgid "Takes a screenshot of a window."
@@ -144,7 +144,7 @@ msgstr ""
144144
145145#: qml/Components/KeyboardShortcutsOverlay.qml:88
146146msgid "Super + Space"
147−msgstr ""
147+msgstr "Super + Space"
148148
149149#: qml/Components/KeyboardShortcutsOverlay.qml:93
150150msgid "Switches to next keyboard layout."
@@ -152,7 +152,7 @@ msgstr ""
152152
153153#: qml/Components/KeyboardShortcutsOverlay.qml:101
154154msgid "Super + Shift + Space"
155−msgstr ""
155+msgstr "Super + Shift + Space"
156156
157157#: qml/Components/KeyboardShortcutsOverlay.qml:106
158158msgid "Switches to previous keyboard layout."
@@ -160,11 +160,11 @@ msgstr ""
160160
161161#: qml/Components/KeyboardShortcutsOverlay.qml:118
162162msgid "Launcher"
163−msgstr ""
163+msgstr "ئىجراچى"
164164
165165#: qml/Components/KeyboardShortcutsOverlay.qml:125
166166msgid "Super (Hold)"
167−msgstr ""
167+msgstr "Super (Hold)"
168168
169169#: qml/Components/KeyboardShortcutsOverlay.qml:130
170170msgid "Opens the launcher, displays shortcuts."
@@ -172,7 +172,7 @@ msgstr ""
172172
173173#: qml/Components/KeyboardShortcutsOverlay.qml:138
174174msgid "Alt + F1"
175−msgstr ""
175+msgstr "Alt + F1"
176176
177177#: qml/Components/KeyboardShortcutsOverlay.qml:143
178178msgid "Opens launcher keyboard navigation mode."
@@ -180,7 +180,7 @@ msgstr ""
180180
181181#: qml/Components/KeyboardShortcutsOverlay.qml:151
182182msgid "Super + Tab"
183−msgstr ""
183+msgstr "Super + Tab"
184184
185185#: qml/Components/KeyboardShortcutsOverlay.qml:156
186186msgid "Switches applications via the launcher."
@@ -188,7 +188,7 @@ msgstr ""
188188
189189#: qml/Components/KeyboardShortcutsOverlay.qml:164
190190msgid "Super + 0 to 9"
191−msgstr ""
191+msgstr "Super + 0 to 9"
192192
193193#: qml/Components/KeyboardShortcutsOverlay.qml:169
194194msgid "Same as clicking on a launcher icon."
@@ -196,11 +196,11 @@ msgstr ""
196196
197197#: qml/Components/KeyboardShortcutsOverlay.qml:181
198198msgid "Scopes"
199−msgstr ""
199+msgstr "ئەپچەلەر"
200200
201201#: qml/Components/KeyboardShortcutsOverlay.qml:188
202202msgid "Super (Tap)"
203−msgstr ""
203+msgstr "Super (Tap)"
204204
205205#: qml/Components/KeyboardShortcutsOverlay.qml:193
206206msgid "Opens the Scopes home."
@@ -208,19 +208,19 @@ msgstr ""
208208
209209#: qml/Components/KeyboardShortcutsOverlay.qml:209
210210msgid "Switching"
211−msgstr ""
211+msgstr "ئالماشتۇرۇش"
212212
213213#: qml/Components/KeyboardShortcutsOverlay.qml:216
214214msgid "Alt + Tab"
215−msgstr ""
215+msgstr "Alt + Tab"
216216
217217#: qml/Components/KeyboardShortcutsOverlay.qml:221
218218msgid "Switches between applications."
219−msgstr ""
219+msgstr "پروگراممىلارنى ئالماشتۇرىدۇ."
220220
221221#: qml/Components/KeyboardShortcutsOverlay.qml:229
222222msgid "Super + W"
223−msgstr ""
223+msgstr "Super + W"
224224
225225#: qml/Components/KeyboardShortcutsOverlay.qml:234
226226msgid "Opens the desktop spread."
@@ -228,19 +228,19 @@ msgstr ""
228228
229229#: qml/Components/KeyboardShortcutsOverlay.qml:242
230230msgid "Cursor Left or Right"
231−msgstr ""
231+msgstr "سىنبەلگە سولدىن ئوڭغا"
232232
233233#: qml/Components/KeyboardShortcutsOverlay.qml:247
234234msgid "Moves the focus."
235−msgstr ""
235+msgstr "فوكۇسنى يۆتكەيدۇ."
236236
237237#: qml/Components/KeyboardShortcutsOverlay.qml:259
238238msgid "Windows"
239−msgstr ""
239+msgstr "كۆزنەكلەر"
240240
241241#: qml/Components/KeyboardShortcutsOverlay.qml:266
242242msgid "Ctrl + Super + D"
243−msgstr ""
243+msgstr "Ctrl + Super + D"
244244
245245#: qml/Components/KeyboardShortcutsOverlay.qml:271
246246msgid "Minimizes all windows."
@@ -248,7 +248,7 @@ msgstr ""
248248
249249#: qml/Components/KeyboardShortcutsOverlay.qml:279
250250msgid "Ctrl + Super + Up"
251−msgstr ""
251+msgstr "Ctrl + Super + Up"
252252
253253#: qml/Components/KeyboardShortcutsOverlay.qml:284
254254msgid "Maximizes the current window."
@@ -256,7 +256,7 @@ msgstr ""
256256
257257#: qml/Components/KeyboardShortcutsOverlay.qml:292
258258msgid "Ctrl + Super + Down"
259−msgstr ""
259+msgstr "Ctrl + Super + Down"
260260
261261#: qml/Components/KeyboardShortcutsOverlay.qml:297
262262msgid "Minimizes or restores the current window."
@@ -264,7 +264,7 @@ msgstr ""
264264
265265#: qml/Components/KeyboardShortcutsOverlay.qml:305
266266msgid "Ctrl + Super + Left or Right"
267−msgstr ""
267+msgstr "Ctrl + Super + Left or Right"
268268
269269#: qml/Components/KeyboardShortcutsOverlay.qml:310
270270msgid "Semi-maximizes the current window."
@@ -272,11 +272,11 @@ msgstr ""
272272
273273#: qml/Components/KeyboardShortcutsOverlay.qml:318
274274msgid "Alt + F4"
275−msgstr ""
275+msgstr "Alt + F4"
276276
277277#: qml/Components/KeyboardShortcutsOverlay.qml:323
278278msgid "Closes the current window."
279−msgstr ""
279+msgstr "نۆۋەتتىكى كۆزنەكنى ياپىدۇ."
280280
281281#: qml/Components/Lockscreen.qml:239
282282msgid "Return to Call"
@@ -293,12 +293,12 @@ msgstr "تامام"
293293#: qml/Components/MediaServices/VideoPlayerControls.qml:44
294294#, qt-format
295295msgid "%1:%2:%3"
296−msgstr ""
296+msgstr "%1:%2:%3"
297297
298298#: qml/Components/MediaServices/VideoPlayerControls.qml:49
299299#, qt-format
300300msgid "%1:%2"
301−msgstr ""
301+msgstr "%1:%2"
302302
303303#: qml/Components/ModeSwitchWarningDialog.qml:32
304304msgid "Apps may have unsaved data:"
@@ -316,15 +316,15 @@ msgstr ""
316316
317317#: qml/Components/ModeSwitchWarningDialog.qml:75
318318msgid "OK, I will reconnect"
319−msgstr ""
319+msgstr "بولدىلا قايتىدىن ئۇلاي"
320320
321321#: qml/Components/ModeSwitchWarningDialog.qml:76
322322msgid "Reconnect now!"
323−msgstr ""
323+msgstr "ھازىرلا يېڭدىن ئۇلاندى"
324324
325325#: qml/Components/ModeSwitchWarningDialog.qml:88
326326msgid "Close all"
327−msgstr ""
327+msgstr "ھەممىنى ياپ"
328328
329329#: qml/Components/SharingPicker.qml:54
330330msgid "Preview Share Item"
@@ -359,7 +359,7 @@ msgstr ""
359359
360360#: qml/Dash/FiltersPopover.qml:69
361361msgid "Reset"
362−msgstr ""
362+msgstr "ئەسلىگە قايتۇر"
363363
364364#: qml/Dash/GenericScopeView.qml:580 qml/Dash/GenericScopeView.qml:775
365365msgid "Show less"
@@ -367,7 +367,7 @@ msgstr ""
367367
368368#: qml/Dash/GenericScopeView.qml:580
369369msgid "Show all"
370−msgstr ""
370+msgstr "ھەممىنى كۆرسەت"
371371
372372#: qml/Dash/GenericScopeView.qml:637
373373msgctxt "Label: Hint for dash search line edit"
@@ -376,11 +376,11 @@ msgstr "ئىزدە"
376376
377377#: qml/Dash/PageHeaderExtraPanel.qml:56
378378msgid "Recent Searches"
379−msgstr ""
379+msgstr "يېقىنقى ئىزدەشلەر"
380380
381381#: qml/Dash/PageHeaderExtraPanel.qml:67
382382msgid "Clear All"
383−msgstr ""
383+msgstr "ھەممىنى تازىلا"
384384
385385#: qml/Dash/Previews/PreviewActionCombo.qml:35
386386msgid "More..."
@@ -439,7 +439,7 @@ msgstr "قۇلۇپسىزلا"
439439
440440#: qml/Greeter/Greeter.qml:539
441441msgid "Try again"
442−msgstr ""
442+msgstr "قايتا سىنا"
443443
444444#: qml/Greeter/LoginList.qml:259
445445msgid "Retry"
@@ -447,7 +447,7 @@ msgstr "قايتا سىنا"
447447
448448#: qml/Greeter/LoginList.qml:260
449449msgid "Log In"
450−msgstr ""
450+msgstr "تىزىمغا كىر"
451451
452452#: qml/Greeter/NarrowView.qml:54
453453msgid "Sorry, incorrect passphrase."
@@ -623,7 +623,7 @@ msgstr "قايتىش"
623623
624624#: qml/Wizard/Pages/10-welcome.qml:27
625625msgid "Language"
626−msgstr ""
626+msgstr "تىل"
627627
628628#: qml/Wizard/Pages/10-welcome.qml:171 qml/Wizard/Pages/30-wifi.qml:206
629629#: qml/Wizard/Pages/40-location.qml:271 qml/Wizard/Pages/50-timezone.qml:270
@@ -632,7 +632,7 @@ msgstr ""
632632#: qml/Wizard/Pages/passcode-desktop.qml:141
633633#: qml/Wizard/Pages/password-set.qml:141
634634msgid "Next"
635−msgstr ""
635+msgstr "كېيىنكى"
636636
637637#: qml/Wizard/Pages/30-wifi.qml:29
638638msgid "Connect to Wi‑Fi"
@@ -640,7 +640,7 @@ msgstr "سىمسىز تورغا(Wi-Fi) باغلان"
640640
641641#: qml/Wizard/Pages/30-wifi.qml:130
642642msgid "Connected"
643−msgstr ""
643+msgstr "ئۇلاندى"
644644
645645#: qml/Wizard/Pages/30-wifi.qml:163
646646msgid "Available Wi-Fi networks"
@@ -689,7 +689,7 @@ msgstr ""
689689
690690#: qml/Wizard/Pages/50-timezone.qml:29
691691msgid "Time Zone"
692−msgstr ""
692+msgstr "ۋاقىت رايونى"
693693
694694#: qml/Wizard/Pages/50-timezone.qml:181
695695msgid "Enter your city"
@@ -705,7 +705,7 @@ msgstr ""
705705
706706#: qml/Wizard/Pages/70-passwd-type.qml:39
707707msgid "Lock Screen"
708−msgstr ""
708+msgstr "ئېكراننى قۇلۇپلا"
709709
710710#: qml/Wizard/Pages/70-passwd-type.qml:101
711711msgctxt "Label: Type of security method"
@@ -724,7 +724,7 @@ msgstr ""
724724
725725#: qml/Wizard/Pages/75-report-check.qml:26 qml/Wizard/Pages/here-terms.qml:108
726726msgid "Privacy Policy"
727−msgstr ""
727+msgstr "شەخسىيەت سىياسىتى"
728728
729729#: qml/Wizard/Pages/75-report-check.qml:26
730730msgid "Help Us Improve"
@@ -736,11 +736,11 @@ msgstr ""
736736
737737#: qml/Wizard/Pages/75-report-check.qml:60
738738msgid "Privacy policy"
739−msgstr ""
739+msgstr "شەخسىيەت سىياسىتى"
740740
741741#: qml/Wizard/Pages/80-finished.qml:89
742742msgid "Welcome to Ubuntu"
743−msgstr ""
743+msgstr "ئۇبۇنتۇغا مەرھابا"
744744
745745#: qml/Wizard/Pages/80-finished.qml:104
746746msgid "You are ready to use your device now"
@@ -805,7 +805,7 @@ msgstr ""
805805#: qml/Wizard/Pages/passcode-desktop.qml:76
806806#: qml/Wizard/Pages/passcode-set.qml:54
807807msgid "Choose passcode"
808−msgstr ""
808+msgstr "ئىم تاللاڭ"
809809
810810#: qml/Wizard/Pages/passcode-desktop.qml:126
811811msgid "Passcode too short"
@@ -837,7 +837,7 @@ msgstr ""
837837
838838#: qml/Wizard/Pages/password-set.qml:103
839839msgid "Confirm password"
840−msgstr ""
840+msgstr "ئىمنى جەزملەڭ"
841841
842842#: qml/Wizard/Pages/sim.qml:27
843843msgid "No SIM card installed"
@@ -869,23 +869,23 @@ msgstr ""
869869
870870#: qml/Wizard/PasswordMeter.qml:89
871871msgid "Passwords match"
872−msgstr ""
872+msgstr "ئىم ماس كەلدى"
873873
874874#: qml/Wizard/PasswordMeter.qml:91
875875msgid "Passwords do not match"
876−msgstr ""
876+msgstr "ئىم ماس كەلمىدى"
877877
878878#: qml/Wizard/PasswordMeter.qml:95
879879msgid "Strong password"
880−msgstr ""
880+msgstr "كۈچلۈك ئىم"
881881
882882#: qml/Wizard/PasswordMeter.qml:97
883883msgid "Fair password"
884−msgstr ""
884+msgstr "يامان ئەمەس ئىم"
885885
886886#: qml/Wizard/PasswordMeter.qml:99
887887msgid "Weak password"
888−msgstr ""
888+msgstr "ئاجىز ئىم"
889889
890890#: qml/Wizard/PasswordMeter.qml:101
891891msgid "Very weak password"
qml/Components/Dialogs.qml+3−5
@@ -107,12 +107,12 @@ Item {
107107
108108 GlobalShortcut { // lock screen
109109 shortcut: Qt.Key_ScreenSaver
110− onTriggered: lightDM.greeter.showGreeter()
110+ onTriggered: LightDMService.greeter.showGreeter()
111111 }
112112
113113 GlobalShortcut { // lock screen
114114 shortcut: Qt.ControlModifier|Qt.AltModifier|Qt.Key_L
115− onTriggered: lightDM.greeter.showGreeter()
115+ onTriggered: LightDMService.greeter.showGreeter()
116116 }
117117
118118 QtObject {
@@ -137,8 +137,6 @@ Item {
137137 active: false
138138 }
139139
140− LightDM {id: lightDM} // Provide backend access
141−
142140 Component {
143141 id: logoutDialogComponent
144142 ShellDialog {
@@ -148,7 +146,7 @@ Item {
148146 Button {
149147 text: i18n.ctr("Button: Lock the system", "Lock")
150148 onClicked: {
151− lightDM.greeter.showGreeter()
149+ LightDMService.greeter.showGreeter()
152150 logoutDialog.hide();
153151 }
154152 }
qml/Greeter/FullLightDMImpl.qmlnew file+28
@@ -0,0 +1,28 @@
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+import QtQuick 2.4
18+import LightDM.FullLightDM 0.1 as LightDM
19+
20+Item{
21+ id: implementation
22+
23+ property var greeter: LightDM.Greeter
24+ property var infographic: LightDM.Infographic
25+ property var users: LightDM.Users
26+ property var userRoles: LightDM.UserRoles
27+
28+}
qml/Greeter/Greeter.qml+43−34
@@ -23,6 +23,8 @@ import Ubuntu.Components 1.3
2323import Ubuntu.SystemImage 0.1
2424import Unity.Launcher 0.1
2525import Unity.Session 0.1
26+
27+import "." 0.1
2628import "../Components"
2729
2830Showable {
@@ -48,7 +50,7 @@ Showable {
4850 readonly property bool hasLockedApp: lockedApp !== ""
4951
5052 property bool forcedUnlock
51− readonly property bool locked: lightDM.greeter.active && !lightDM.greeter.authenticated && !forcedUnlock
53+ readonly property bool locked: LightDMService.greeter.active && !LightDMService.greeter.authenticated && !forcedUnlock
5254
5355 property bool tabletMode
5456 property url viewSource // only used for testing
@@ -123,12 +125,12 @@ Showable {
123125 return d.startUnlock(true /* toTheRight */);
124126 }
125127
126− LightDM{id:lightDM} // Provide backend access
127128 QtObject {
128129 id: d
129130
130− readonly property bool multiUser: lightDM.users.count > 1
131− property int currentIndex
131+ readonly property bool multiUser: LightDMService.users.count > 1
132+ readonly property int selectUserIndex: d.getUserIndex(LightDMService.greeter.selectUser)
133+ property int currentIndex: Math.max(selectUserIndex, 0)
132134 property bool waiting
133135 property bool isLockscreen // true when we are locking an active session, rather than first user login
134136 readonly property bool secureFingerprint: isLockscreen &&
@@ -150,21 +152,37 @@ Showable {
150152 UbuntuNumberAnimation {}
151153 }
152154
155+ function getUserIndex(username) {
156+ if (username === "")
157+ return -1;
158+
159+ // Find index for requested user, if it exists
160+ for (var i = 0; i < LightDMService.users.count; i++) {
161+ if (username === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
162+ return i;
163+ }
164+ }
165+
166+ return -1;
167+ }
168+
153169 function selectUser(uid, reset) {
170+ if (uid < 0)
171+ return;
154172 d.waiting = true;
155173 if (reset) {
156174 loader.item.reset();
157175 }
158176 currentIndex = uid;
159− var user = lightDM.users.data(uid, lightDM.userRoles.NameRole);
177+ var user = LightDMService.users.data(uid, LightDMService.userRoles.NameRole);
160178 AccountsService.user = user;
161179 LauncherModel.setUser(user);
162− lightDM.greeter.authenticate(user); // always resets auth state
180+ LightDMService.greeter.authenticate(user); // always resets auth state
163181 }
164182
165183 function login() {
166184 enabled = false;
167− if (lightDM.greeter.startSessionSync()) {
185+ if (LightDMService.greeter.startSessionSync()) {
168186 sessionStarted();
169187 if (loader.item) {
170188 loader.item.notifyAuthenticationSucceeded(false /* showFakePassword */);
@@ -310,7 +328,7 @@ Showable {
310328 root.lockedApp = "";
311329 root.forceActiveFocus();
312330 d.selectUser(d.currentIndex, true);
313− lightDM.infographic.readyForDataChange();
331+ LightDMService.infographic.readyForDataChange();
314332 }
315333
316334 Connections {
@@ -318,13 +336,12 @@ Showable {
318336 onSelected: {
319337 d.selectUser(index, true);
320338 }
339+ onPromptlessLogin: d.login();
321340 onResponded: {
322341 if (root.locked) {
323− lightDM.greeter.respond(response);
342+ LightDMService.greeter.respond(response);
324343 } else {
325− if (lightDM.greeter.active && !lightDM.greeter.authenticated) { // could happen if forcedUnlock
326− d.login();
327− }
344+ d.login();
328345 loader.item.hide();
329346 }
330347 }
@@ -388,18 +405,18 @@ Showable {
388405 Binding {
389406 target: loader.item
390407 property: "userModel"
391− value: lightDM.users
408+ value: LightDMService.users
392409 }
393410
394411 Binding {
395412 target: loader.item
396413 property: "infographicModel"
397− value: lightDM.infographic
414+ value: LightDMService.infographic
398415 }
399416 }
400417
401418 Connections {
402− target: lightDM.greeter
419+ target: LightDMService.greeter
403420
404421 onShowGreeter: root.forceShow()
405422
@@ -434,13 +451,13 @@ Showable {
434451 onAuthenticationComplete: {
435452 d.waiting = false;
436453
437− if (lightDM.greeter.authenticated) {
438− d.login();
439− if (!lightDM.greeter.promptless) {
454+ if (LightDMService.greeter.authenticated) {
455+ if (!LightDMService.greeter.promptless) {
456+ d.login();
440457 loader.item.hide();
441458 }
442459 } else {
443− if (!lightDM.greeter.promptless) {
460+ if (!LightDMService.greeter.promptless) {
444461 AccountsService.failedLogins++;
445462 }
446463
@@ -461,21 +478,13 @@ Showable {
461478 }
462479
463480 loader.item.notifyAuthenticationFailed();
464− if (!lightDM.greeter.promptless) {
481+ if (!LightDMService.greeter.promptless) {
465482 d.selectUser(d.currentIndex, false);
466483 }
467484 }
468485 }
469486
470− onRequestAuthenticationUser: {
471− // Find index for requested user, if it exists
472− for (var i = 0; i < lightDM.users.count; i++) {
473− if (user === lightDM.users.data(i, lightDM.userRoles.NameRole)) {
474− d.selectUser(i, true);
475− return;
476− }
477− }
478− }
487+ onRequestAuthenticationUser: d.selectUser(d.getUserIndex(user), true)
479488 }
480489
481490 Connections {
@@ -488,20 +497,20 @@ Showable {
488497 }
489498
490499 Binding {
491− target: lightDM.greeter
500+ target: LightDMService.greeter
492501 property: "active"
493502 value: root.active
494503 }
495504
496505 Binding {
497− target: lightDM.infographic
506+ target: LightDMService.infographic
498507 property: "username"
499− value: AccountsService.statsWelcomeScreen ? lightDM.users.data(d.currentIndex, lightDM.userRoles.NameRole) : ""
508+ value: AccountsService.statsWelcomeScreen ? LightDMService.users.data(d.currentIndex, LightDMService.userRoles.NameRole) : ""
500509 }
501510
502511 Connections {
503512 target: i18n
504− onLanguageChanged: lightDM.infographic.readyForDataChange()
513+ onLanguageChanged: LightDMService.infographic.readyForDataChange()
505514 }
506515
507516 Observer {
@@ -553,7 +562,7 @@ Showable {
553562 failOperation("fingerprint reader is locked");
554563 return;
555564 }
556− if (result !== lightDM.users.data(d.currentIndex, lightDM.userRoles.UidRole)) {
565+ if (result !== LightDMService.users.data(d.currentIndex, LightDMService.userRoles.UidRole)) {
557566 AccountsService.failedFingerprintLogins++;
558567 failOperation("not the selected user");
559568 return;
qml/Greeter/IntegratedLightDMImpl.qml+1−1
@@ -15,7 +15,7 @@
1515 */
1616
1717import QtQuick 2.4
18−import IntegratedLightDM 0.1 as LightDM
18+import LightDM.IntegratedLightDM 0.1 as LightDM
1919
2020Item{
2121 id: implementation
qml/Greeter/LightDM.qml → qml/Greeter/LightDMService.qmlrenamed+14−3
@@ -19,6 +19,7 @@
1919 * plugin
2020 */
2121
22+pragma Singleton
2223import QtQuick 2.4
2324
2425Loader {
@@ -29,13 +30,23 @@ Loader {
2930 property var users: d.valid ? loader.item.users : null
3031 property var userRoles: d.valid ? loader.item.userRoles : null
3132
32− // TODO: Conditionally load RealLightDMImpl if shellMode dictates it
33− source: "./IntegratedLightDMImpl.qml"
33+ // This trickery handles cases where applicationArguments aren't provided
34+ // such as during testing
35+ property var fullLightDM: {
36+ if (typeof applicationArguments !== "undefined") {
37+ if (applicationArguments.mode === "greeter") {
38+ return true;
39+ }
40+ }
41+ return false;
42+ }
43+
44+ source: fullLightDM ?
45+ "FullLightDMImpl.qml" : "IntegratedLightDMImpl.qml"
3446
3547 QtObject {
3648 id: d
3749
3850 property bool valid: loader.item !== null
3951 }
40−
4152}
qml/Greeter/LoginList.qml+2
@@ -36,6 +36,7 @@ StyledItem {
3636
3737 signal selected(int index)
3838 signal responded(string response)
39+ signal promptlessLogin()
3940
4041 function tryToUnlock() {
4142 if (wasPrompted) {
@@ -44,6 +45,7 @@ StyledItem {
4445 if (root.locked) {
4546 root.selected(currentIndex);
4647 } else {
48+ promptlessLogin();
4749 root.responded("");
4850 }
4951 }
qml/Greeter/WideView.qml+2
@@ -37,6 +37,7 @@ FocusScope {
3737 // so that it can be replaced in tests with a mock object
3838 property var inputMethod: Qt.inputMethod
3939
40+ signal promptlessLogin()
4041 signal selected(int index)
4142 signal responded(string response)
4243 signal tease()
@@ -132,6 +133,7 @@ FocusScope {
132133
133134 locked: root.locked
134135
136+ onPromptlessLogin: root.promptlessLogin()
135137 onSelected: root.selected(index)
136138 onResponded: root.responded(response)
137139 }
qml/Greeter/qmldirnew file+1
@@ -0,0 +1 @@
1+singleton LightDMService 0.1 LightDMService.qml
qml/Shell.qml+11−6
@@ -175,7 +175,6 @@ StyledItem {
175175 finishStartUpTimer.start();
176176 }
177177
178− LightDM{id: lightDM} // Provide backend access
179178 VolumeControl {
180179 id: volumeControl
181180 indicators: panel.indicators
@@ -260,8 +259,8 @@ StyledItem {
260259 ? "phone"
261260 : shell.usageScenario
262261 readonly property string qmlComponent: {
263− if(shell.mode === "greeter") {
264− return "Stages/ShimStage.qml"
262+ if (shell.mode === "greeter") {
263+ return "Stages/AbstractStage.qml"
265264 } else if (applicationsDisplayLoader.usageScenario === "phone") {
266265 return "Stages/PhoneStage.qml";
267266 } else if (applicationsDisplayLoader.usageScenario === "tablet") {
@@ -497,7 +496,7 @@ StyledItem {
497496 function showHome() {
498497 greeter.notifyUserRequestedApp("unity8-dash");
499498
500− var animate = !lightDM.greeter.active && !stages.shown
499+ var animate = !LightDMService.greeter.active && !stages.shown
501500 dash.setCurrentScope(0, animate, false)
502501 ApplicationManager.requestFocusApplication("unity8-dash")
503502 }
@@ -536,7 +535,12 @@ StyledItem {
536535
537536 indicatorsModel: Indicators.IndicatorsModel {
538537 // tablet and phone both use the same profile
539− profile: "phone"
538+ // FIXME: use just "phone" for greeter too, but first fix
539+ // greeter app launching to either load the app inside the
540+ // greeter or tell the session to load the app. This will
541+ // involve taking the url-dispatcher dbus name and using
542+ // SessionBroadcast to tell the session.
543+ profile: shell.mode === "greeter" ? "desktop_greeter" : "phone"
540544 Component.onCompleted: load();
541545 }
542546 }
@@ -548,7 +552,7 @@ StyledItem {
548552 readonly property bool focusedSurfaceIsFullscreen: MirFocusController.focusedSurface
549553 ? MirFocusController.focusedSurface.state === Mir.FullscreenState
550554 : false
551− fullscreenMode: (focusedSurfaceIsFullscreen && !lightDM.greeter.active && launcher.progress == 0)
555+ fullscreenMode: (focusedSurfaceIsFullscreen && !LightDMService.greeter.active && launcher.progress == 0)
552556 || greeter.hasLockedApp
553557 locked: greeter && greeter.active
554558 }
@@ -666,6 +670,7 @@ StyledItem {
666670 id: wizard
667671 objectName: "wizard"
668672 anchors.fill: parent
673+ deferred: shell.mode === "greeter"
669674
670675 function unlockWhenDoneWithWizard() {
671676 if (!active) {
qml/Wizard/Wizard.qml+6−2
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013 Canonical, Ltd.
2+ * Copyright (C) 2013, 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -29,6 +29,10 @@ Showable {
2929 // expected behavior of no emission on startup.
3030 readonly property bool active: loader.active
3131
32+ // The wizard should be run at a later time if, for example, unity8 is
33+ // in greeter mode
34+ property bool deferred: false
35+
3236 hideAnimation: StandardAnimation { property: "opacity"; to: 0 }
3337
3438 onRequiredChanged: {
@@ -40,7 +44,7 @@ Showable {
4044 Loader {
4145 id: loader
4246 anchors.fill: parent
43− active: System.wizardEnabled
47+ active: System.wizardEnabled && !deferred
4448 source: "Pages.qml"
4549
4650 Connections {
src/ShellApplication.cpp+11−1
@@ -18,6 +18,7 @@
1818
1919// Qt
2020#include <QLibrary>
21+#include <QProcess>
2122#include <QScreen>
2223
2324#include <libintl.h>
@@ -110,7 +111,16 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
110111 m_secondaryWindow->setVisible(true);
111112 }
112113
113− if (isMirServer || parser.hasFullscreen()) {
114+ if (parser.mode().compare("greeter") == 0) {
115+ QSize primaryScreenSize = this->primaryScreen()->size();
116+ m_shellView->setHeight(primaryScreenSize.height());
117+ m_shellView->setWidth(primaryScreenSize.width());
118+ m_shellView->show();
119+ m_shellView->requestActivate();
120+ if (!QProcess::startDetached("/sbin/initctl emit --no-wait unity8-greeter-started")) {
121+ qDebug() << "Unable to send unity8-greeter-started event to Upstart";
122+ }
123+ } else if (isMirServer || parser.hasFullscreen()) {
114124 m_shellView->showFullScreen();
115125 } else {
116126 m_shellView->show();
tests/CMakeLists.txt+1−1
@@ -47,7 +47,7 @@ macro(unity8_parse_arguments)
4747 if(U8TEST_LIGHTDM)
4848 list(APPEND ld_paths
4949 ${UNITY_MOCKPATH}/libusermetrics
50− ${UNITY_MOCKPATH}/IntegratedLightDM/liblightdm
50+ ${UNITY_MOCKPATH}/LightDM/IntegratedLightDM/liblightdm
5151 )
5252 endif()
5353
tests/autopilot/unity8/fixture_setup.py+1−1
@@ -74,7 +74,7 @@ class LaunchUnityWithFakeSensors(fixtures.Fixture):
7474 def _get_lightdm_mock_path(self):
7575 lib_path = get_mocks_library_path()
7676 lightdm_mock_path = os.path.abspath(
77− os.path.join(lib_path, "IntegratedLightDM", "liblightdm")
77+ os.path.join(lib_path, "LightDM" ,"IntegratedLightDM", "liblightdm")
7878 )
7979
8080 if not os.path.exists(lightdm_mock_path):
tests/autopilot/unity8/greeter/tests/test_args.py−5
@@ -35,11 +35,6 @@ class GreeterArgsTest(GreeterTestCase):
3535 shell = self.get_shell(unity_proxy)
3636 self.assertTrue(shell.mode == 'full-shell')
3737
38− def test_greeter_mode(self):
39− unity_proxy = self.launch_unity(mode='greeter')
40− shell = self.get_shell(unity_proxy)
41− self.assertTrue(shell.mode == 'greeter')
42−
4338 def test_nonexistent_mode(self):
4439 unity_proxy = self.launch_unity(mode=self.NONEXISTENT_MODE)
4540 shell = self.get_shell(unity_proxy)
tests/autopilot/unity8/shell/tests/__init__.py+1−1
@@ -261,7 +261,7 @@ class UnityTestCase(AutopilotTestCase):
261261 def _get_lightdm_mock_path(self):
262262 lib_path = get_mocks_library_path()
263263 lightdm_mock_path = os.path.abspath(
264− os.path.join(lib_path, "IntegratedLightDM", "liblightdm")
264+ os.path.join(lib_path, "LightDM" ,"IntegratedLightDM", "liblightdm")
265265 )
266266
267267 if not os.path.exists(lightdm_mock_path):
tests/mocks/CMakeLists.txt+1−1
@@ -34,7 +34,7 @@ add_subdirectory(Cursor)
3434add_subdirectory(GSettings.1.0)
3535add_subdirectory(indicator-service)
3636add_subdirectory(libusermetrics)
37−add_subdirectory(IntegratedLightDM)
37+add_subdirectory(LightDM)
3838add_subdirectory(Lights)
3939add_subdirectory(MeeGo)
4040add_subdirectory(Powerd)
tests/mocks/IntegratedLightDM/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module IntegratedLightDM
2−plugin MockLightDM-qml
3−typeinfo IntegratedLightDM.qmltypes
tests/mocks/LightDM/CMakeLists.txtnew file+1
@@ -0,0 +1 @@
1+add_subdirectory(IntegratedLightDM)
tests/mocks/IntegratedLightDM/CMakeLists.txt → tests/mocks/LightDM/IntegratedLightDM/CMakeLists.txtrenamed+9−7
@@ -10,18 +10,20 @@ include_directories(
1010 ${CMAKE_CURRENT_SOURCE_DIR}
1111 ${CMAKE_CURRENT_BINARY_DIR}
1212 ${CMAKE_SOURCE_DIR}/plugins/Utils
13− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM
13+ ${CMAKE_SOURCE_DIR}/plugins/LightDM
1414 ${CMAKE_SOURCE_DIR}/tests/mocks/libusermetrics
1515 ${libunity8-private_SOURCE_DIR}
1616)
1717
1818set(QMLPLUGIN_SRC
19− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/DBusGreeter.cpp
20− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/DBusGreeterList.cpp
21− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/Greeter.cpp
22− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/UsersModel.cpp
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
2324 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
2425 MockGreeter.cpp
26+ MockSessionsModel.cpp
2527 MockUsersModel.cpp
2628 plugin.cpp
2729 )
@@ -30,7 +32,7 @@ add_library(MockLightDM-qml MODULE
3032 ${QMLPLUGIN_SRC}
3133 )
3234
33−# We want to link to liblightdm-qt5-2, but we don't want to depend on it being
35+# We want to link to liblightdm-qt5-3, but we don't want to depend on it being
3436# installed on the system. So we make sure we link to our full fake version
3537# At run time, we can point to whichever version we happen to be using via
3638# LD_LIBRARY_PATH.
@@ -42,7 +44,7 @@ target_link_libraries(MockLightDM-qml
4244
4345qt5_use_modules(MockLightDM-qml DBus Gui Qml)
4446
45−add_unity8_mock(IntegratedLightDM 0.1 IntegratedLightDM
47+add_unity8_mock(LightDM.IntegratedLightDM 0.1 LightDM/IntegratedLightDM
4648 PREFIX mocks
4749 TARGETS MockLightDM-qml
4850 ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}/liblightdm"
tests/mocks/IntegratedLightDM/MockGreeter.cpp → tests/mocks/LightDM/IntegratedLightDM/MockGreeter.cpprenamed+16
@@ -33,3 +33,19 @@ void MockGreeter::setMockMode(QString mockMode)
3333 Q_EMIT mockModeChanged(mockMode);
3434 }
3535}
36+
37+QString MockGreeter::selectUserHint() const
38+{
39+ Q_D(const Greeter);
40+ return d->m_greeter->selectUserHint();
41+}
42+
43+void 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+}
tests/mocks/IntegratedLightDM/MockGreeter.h → tests/mocks/LightDM/IntegratedLightDM/MockGreeter.hrenamed+5
@@ -25,13 +25,18 @@ class MockGreeter : public Greeter {
2525 Q_OBJECT
2626
2727 Q_PROPERTY(QString mockMode READ mockMode WRITE setMockMode NOTIFY mockModeChanged)
28+ Q_PROPERTY(QString selectUser READ selectUserHint WRITE setSelectUserHint NOTIFY selectUserHintChanged)
2829
2930public:
3031 QString mockMode() const;
3132 void setMockMode(QString mockMode);
3233
34+ QString selectUserHint() const;
35+ void setSelectUserHint(const QString &selectUserHint);
36+
3337Q_SIGNALS:
3438 void mockModeChanged(QString mode);
39+ void selectUserHintChanged();
3540};
3641
3742#endif // MOCK_UNITY_GREETER_H
qml/Stages/ShimStage.qml → tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.cpprenamed+15−21
@@ -12,32 +12,26 @@
1212 *
1313 * You should have received a copy of the GNU General Public License
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
1516 */
1617
17−import QtQuick 2.4
18−import Ubuntu.Components 1.3
19−
20−AbstractStage {
21− id: shimStage
18+#include "MockSessionsModel.h"
19+#include <QLightDM/SessionsModel>
2220
23− anchors.fill: parent
21+QString MockSessionsModel::testScenario() const
22+{
23+ QLightDM::SessionsModel* qSessionsModel =
24+ static_cast<QLightDM::SessionsModel*>(sourceModel());
2425
25− Text {
26− id: greeterModeText
26+ return qSessionsModel->testScenario();
27+}
2728
28− anchors.horizontalCenter: parent.horizontalCenter
29− anchors.top: parent.top
30− anchors.topMargin: units.gu(10)
31− font.bold: true
32− horizontalAlignment: Text.AlignHCenter
33− text: "Shell is in \"greeter\" mode"
34− }
29+void MockSessionsModel::setTestScenario(const QString testScenario)
30+{
31+ QLightDM::SessionsModel* qSessionsModel =
32+ static_cast<QLightDM::SessionsModel*>(sourceModel());
3533
36− Text {
37− anchors.centerIn: parent
38− color: UbuntuColors.orange
39− font.pointSize: units.gu(8)
40− horizontalAlignment: Text.AlignHCenter
41− text: "Shim \nStage"
34+ if (qSessionsModel->testScenario() != testScenario) {
35+ qSessionsModel->setTestScenario(testScenario);
4236 }
4337}
tests/mocks/LightDM/IntegratedLightDM/MockSessionsModel.hnew file+34
@@ -0,0 +1,34 @@
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+
23+class MockSessionsModel : public SessionsModel
24+{
25+ Q_OBJECT
26+
27+ Q_PROPERTY(QString testScenario READ testScenario WRITE setTestScenario)
28+
29+public:
30+ QString testScenario() const;
31+ void setTestScenario(QString testScenario);
32+};
33+
34+#endif // MOCK_UNITY_SESSIONSMODEL_H
tests/mocks/IntegratedLightDM/MockUsersModel.cpp → tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.cpprenamed

The content is the same.

tests/mocks/IntegratedLightDM/MockUsersModel.h → tests/mocks/LightDM/IntegratedLightDM/MockUsersModel.hrenamed

The content is the same.

tests/mocks/IntegratedLightDM/QLightDM/Greeter → tests/mocks/LightDM/IntegratedLightDM/QLightDM/Greeterrenamed

The content is the same.

tests/mocks/LightDM/IntegratedLightDM/QLightDM/SessionsModelnew file+17
@@ -0,0 +1,17 @@
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"
tests/mocks/IntegratedLightDM/QLightDM/UsersModel → tests/mocks/LightDM/IntegratedLightDM/QLightDM/UsersModelrenamed

The content is the same.

tests/mocks/IntegratedLightDM/liblightdm/CMakeLists.txt → tests/mocks/LightDM/IntegratedLightDM/liblightdm/CMakeLists.txtrenamed+4−2
@@ -1,7 +1,9 @@
11set(LibLightDM_SOURCES
22 Greeter.cpp
3+ SessionsModel.cpp
34 UsersModel.cpp
45 GreeterPrivate.cpp
6+ SessionsModelPrivate.cpp
57 UsersModelPrivate.cpp
68 ${CMAKE_SOURCE_DIR}/plugins/Utils/qvariantlistmodel.cpp
79 )
@@ -11,8 +13,8 @@ add_library(MockLightDM SHARED ${LibLightDM_SOURCES})
1113qt5_use_modules(MockLightDM Gui)
1214
1315set_target_properties(MockLightDM PROPERTIES
14− OUTPUT_NAME lightdm-qt5-2)
16+ OUTPUT_NAME lightdm-qt5-3)
1517
1618install(TARGETS MockLightDM
17− DESTINATION ${SHELL_INSTALL_QML}/mocks/IntegratedLightDM/liblightdm
19+ DESTINATION ${SHELL_INSTALL_QML}/mocks/LightDM/IntegratedLightDM/liblightdm
1820 )
tests/mocks/IntegratedLightDM/liblightdm/Greeter.cpp → tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.cpprenamed+9−2
@@ -51,7 +51,7 @@ QString Greeter::getHint(const QString &name) const
5151
5252QString Greeter::defaultSessionHint() const
5353{
54− return "ubuntu";
54+ return QStringLiteral("ubuntu");
5555}
5656
5757bool Greeter::hideUsersHint() const
@@ -76,7 +76,14 @@ bool Greeter::lockHint () const
7676
7777QString Greeter::selectUserHint() const
7878{
79− return "";
79+ Q_D(const Greeter);
80+ return d->selectUserHint;
81+}
82+
83+void Greeter::setSelectUserHint(const QString &selectUserHint)
84+{
85+ Q_D(Greeter);
86+ d->selectUserHint = selectUserHint;
8087}
8188
8289bool Greeter::selectGuestHint() const
tests/mocks/IntegratedLightDM/liblightdm/Greeter.h → tests/mocks/LightDM/IntegratedLightDM/liblightdm/Greeter.hrenamed+1
@@ -70,6 +70,7 @@ public:
7070 bool lockHint () const;
7171 bool hasGuestAccountHint() const;
7272 QString selectUserHint() const;
73+ void setSelectUserHint(const QString &selectUserHint); // only in mock
7374 bool selectGuestHint() const;
7475 QString autologinUserHint() const;
7576 bool autologinGuestHint() const;
tests/mocks/IntegratedLightDM/liblightdm/GreeterPrivate.cpp → tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpprenamed

The content is the same.

tests/mocks/IntegratedLightDM/liblightdm/GreeterPrivate.h → tests/mocks/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.hrenamed+1
@@ -34,6 +34,7 @@ public:
3434 bool authenticated;
3535 QString authenticationUser;
3636 bool twoFactorDone;
37+ QString selectUserHint;
3738
3839 QString mockMode;
3940
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.cppnew file+99
@@ -0,0 +1,99 @@
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+// LightDM currently is Qt4 compatible, and so doesn't define setRoleNames.
20+// To use the same method of setting role name that it does, we
21+// set our compatibility to Qt4 here too.
22+#define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0)
23+
24+#include "SessionsModel.h"
25+#include "SessionsModelPrivate.h"
26+#include <QtCore/QDir>
27+#include <QtCore/QString>
28+
29+namespace QLightDM
30+{
31+
32+SessionsModel::SessionsModel(QObject* parent) :
33+ QAbstractListModel(parent),
34+ d_ptr(new SessionsModelPrivate(this))
35+{
36+ Q_D(SessionsModel);
37+ m_roleNames = QAbstractListModel::roleNames();
38+ m_roleNames[KeyRole] = "key";
39+ m_roleNames[TypeRole] = "type";
40+}
41+
42+SessionsModel::~SessionsModel()
43+{
44+ delete d_ptr;
45+}
46+
47+QVariant SessionsModel::data(const QModelIndex& index, int role) const
48+{
49+ Q_D(const SessionsModel);
50+
51+ if(!index.isValid()) {
52+ return QVariant();
53+ }
54+
55+ int row = index.row();
56+
57+ switch (role) {
58+ case QLightDM::SessionsModel::KeyRole:
59+ return d->sessionItems[row].key;
60+ case Qt::DisplayRole:
61+ return d->sessionItems[row].name;
62+ default:
63+ return QVariant();
64+ }
65+}
66+
67+QHash<int, QByteArray> SessionsModel::roleNames() const
68+{
69+ return m_roleNames;
70+}
71+
72+int SessionsModel::rowCount(const QModelIndex& parent) const
73+{
74+ Q_D(const SessionsModel);
75+
76+ if (parent.isValid()) {
77+ return 0;
78+ } else { // parent is root
79+ return d->sessionItems.size();
80+ }
81+}
82+
83+QString SessionsModel::testScenario() const
84+{
85+ Q_D(const SessionsModel);
86+ return d->testScenario;
87+}
88+
89+void SessionsModel::setTestScenario(QString testScenario)
90+{
91+ Q_D(SessionsModel);
92+
93+ if (d->testScenario != testScenario) {
94+ d->testScenario = testScenario;
95+ d->resetEntries();
96+ }
97+}
98+
99+} // namespace QLightDM
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModel.hnew file+72
@@ -0,0 +1,72 @@
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_H
19+#define UNITY_MOCK_SESSIONSMODEL_H
20+
21+#include <QtCore/QAbstractListModel>
22+#include <QtCore/QString>
23+
24+namespace QLightDM
25+{
26+class SessionsModelPrivate;
27+
28+class Q_DECL_EXPORT SessionsModel : public QAbstractListModel
29+ {
30+ Q_OBJECT
31+
32+ Q_ENUMS(SessionModelRoles SessionType)
33+
34+ // Mock-only API for testing purposes
35+ Q_PROPERTY(QString testScenario READ testScenario WRITE setTestScenario)
36+
37+ public:
38+
39+ enum SessionModelRoles {
40+ //name is exposed as Qt::DisplayRole
41+ //comment is exposed as Qt::TooltipRole
42+ KeyRole = Qt::UserRole,
43+ IdRole = KeyRole, /** Deprecated */
44+ TypeRole
45+ };
46+
47+ enum SessionType {
48+ LocalSessions,
49+ RemoteSessions
50+ };
51+
52+ explicit SessionsModel(QObject* parent=nullptr); /** Deprecated. Loads local sessions*/
53+ explicit SessionsModel(SessionsModel::SessionType, QObject* parent=nullptr);
54+ virtual ~SessionsModel();
55+
56+ QHash<int, QByteArray> roleNames() const override;
57+ int rowCount(const QModelIndex& parent) const override;
58+ QVariant data(const QModelIndex& index, int role) const override;
59+
60+ QString testScenario() const;
61+ void setTestScenario(QString testScenario);
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_MOCK_SESSIONSMODEL_H
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.cppnew file+73
@@ -0,0 +1,73 @@
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+
20+namespace QLightDM
21+{
22+
23+SessionsModelPrivate::SessionsModelPrivate(SessionsModel* parent)
24+ : testScenario("singleSession")
25+ , q_ptr(parent)
26+{
27+ resetEntries();
28+}
29+
30+void SessionsModelPrivate::resetEntries()
31+{
32+ Q_Q(SessionsModel);
33+
34+ q->beginResetModel();
35+ if (testScenario == "multipleSessions") {
36+ resetEntries_multipleSessions();
37+ } else if (testScenario == "noSessions") {
38+ resetEntries_noSessions();
39+ } else {
40+ resetEntries_singleSession();
41+ }
42+ q->endResetModel();
43+}
44+
45+void SessionsModelPrivate::resetEntries_multipleSessions()
46+{
47+ sessionItems =
48+ {
49+ {"ubuntu", "", "Ubuntu", ""},
50+ {"ubuntu-2d", "", "Ubuntu 2D", ""},
51+ {"gnome", "", "GNOME", ""},
52+ {"gnome-classic", "", "GNOME Classic", ""},
53+ {"gnome-flashback-compiz", "", "GNOME Flashback (Compiz)", ""},
54+ {"gnome-flashback-metacity", "", "GNOME Flashback (Metacity)", ""},
55+ {"gnome-wayland", "", "GNOME on Wayland", ""},
56+ {"plasma", "", "Plasma", ""},
57+ {"kde", "", "KDE" , ""},
58+ {"xterm", "", "Recovery Console", ""},
59+ {"", "", "Unknown?", ""}
60+ };
61+}
62+
63+void SessionsModelPrivate::resetEntries_noSessions()
64+{
65+ sessionItems = {};
66+}
67+
68+void SessionsModelPrivate::resetEntries_singleSession()
69+{
70+ sessionItems = {{"ubuntu", "", "Ubuntu", ""}};
71+}
72+
73+} // namespace QLightDM
tests/mocks/LightDM/IntegratedLightDM/liblightdm/SessionsModelPrivate.hnew file+59
@@ -0,0 +1,59 @@
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+
24+namespace QLightDM
25+{
26+class SessionsModel;
27+
28+class SessionItem
29+{
30+public:
31+ QString key;
32+ QString type; // unused
33+ QString name;
34+ QString comment; // unused
35+};
36+
37+class SessionsModelPrivate
38+{
39+public:
40+ explicit SessionsModelPrivate(SessionsModel* parent=0);
41+ virtual ~SessionsModelPrivate() = default;
42+
43+ QList<SessionItem> sessionItems;
44+ QString testScenario;
45+
46+ void resetEntries();
47+protected:
48+ SessionsModel* const q_ptr;
49+
50+private:
51+ void resetEntries_multipleSessions();
52+ void resetEntries_noSessions();
53+ void resetEntries_singleSession();
54+ Q_DECLARE_PUBLIC(SessionsModel)
55+};
56+
57+} // namespace QLightDM
58+
59+#endif // UNITY_MOCK_SESSIONSMODEL_PRIVATE_H
tests/mocks/IntegratedLightDM/liblightdm/UsersModel.cpp → tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.cpprenamed

The content is the same.

tests/mocks/IntegratedLightDM/liblightdm/UsersModel.h → tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModel.hrenamed

The content is the same.

tests/mocks/IntegratedLightDM/liblightdm/UsersModelPrivate.cpp → tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.cpprenamed+22−22
@@ -60,7 +60,7 @@ void UsersModelPrivate::resetEntries_single()
6060{
6161 entries =
6262 {
63− { "single", "Single User", 0, 0, false, false, 0, 0, 0 },
63+ { "single", "Single User", 0, 0, false, false, "ubuntu", 0 },
6464 };
6565}
6666
@@ -68,7 +68,7 @@ void UsersModelPrivate::resetEntries_singlePassphrase()
6868{
6969 entries =
7070 {
71− { "single", "Single User", 0, 0, false, false, 0, 0, 0 },
71+ { "single", "Single User", 0, 0, false, false, "ubuntu", 0 },
7272 };
7373}
7474
@@ -76,7 +76,7 @@ void UsersModelPrivate::resetEntries_singlePin()
7676{
7777 entries =
7878 {
79− { "has-pin", "Has PIN", 0, 0, false, false, 0, 0, 0 },
79+ { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
8080 };
8181}
8282
@@ -84,26 +84,26 @@ void UsersModelPrivate::resetEntries_full()
8484{
8585 entries =
8686 {
87− { "has-password", "Has Password", 0, 0, false, false, 0, 0, 0 },
88− { "has-pin", "Has PIN", 0, 0, false, false, 0, 0, 0 },
89− { "different-prompt", "Different Prompt", 0, 0, false, false, 0, 0, 0 },
90− { "no-password", "No Password", 0, 0, false, false, 0, 0, 0 },
91− { "auth-error", "Auth Error", 0, 0, false, false, 0, 0, 0 },
92− { "two-factor", "Two Factor", 0, 0, false, false, 0, 0, 0 },
93− { "info-prompt", "Info Prompt", 0, 0, false, false, 0, 0, 0 },
94− { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, 0, 0, 0 },
95− { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, 0, 0, 0 },
96− { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, 0, 0, 0 },
97− { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, 0, 0, 0 },
98− { "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, 0, 0, 0 },
99− { "color-background", "Color Background", "#dd4814", 0, false, false, 0, 0, 0 },
87+ { "has-password", "Has Password", 0, 0, false, false, "ubuntu", 0 },
88+ { "has-pin", "Has PIN", 0, 0, false, false, "ubuntu", 0 },
89+ { "different-prompt", "Different Prompt", 0, 0, false, false, "ubuntu", 0 },
90+ { "no-password", "No Password", 0, 0, false, false, "ubuntu", 0 },
91+ { "auth-error", "Auth Error", 0, 0, false, false, "ubuntu", 0 },
92+ { "two-factor", "Two Factor", 0, 0, false, false, "ubuntu", 0 },
93+ { "info-prompt", "Info Prompt", 0, 0, false, false, "ubuntu", 0 },
94+ { "html-info-prompt", "HTML Info Prompt", 0, 0, false, false, "ubuntu", 0 },
95+ { "long-info-prompt", "Long Info Prompt", 0, 0, false, false, "ubuntu", 0 },
96+ { "wide-info-prompt", "Wide Info Prompt", 0, 0, false, false, "ubuntu", 0 },
97+ { "multi-info-prompt", "Multi Info Prompt", 0, 0, false, false, "ubuntu", 0 },
98+ { "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 },
99+ { "color-background", "Color Background", "#dd4814", 0, false, false, "ubuntu", 0 },
100100 // white and black are a bit redundant, but useful for manually testing if UI is still readable
101− { "white-background", "White Background", "#ffffff", 0, false, false, 0, 0, 0 },
102− { "black-background", "Black Background", "#000000", 0, false, false, 0, 0, 0 },
103− { "no-background", "No Background", "", 0, false, false, 0, 0, 0 },
104− { "unicode", "가나다라마", 0, 0, false, false, 0, 0, 0 },
105− { "no-response", "No Response", 0, 0, false, false, 0, 0, 0 },
106− { "empty-name", "", 0, 0, false, false, 0, 0, 0 },
101+ { "white-background", "White Background", "#ffffff", 0, false, false, "ubuntu", 0 },
102+ { "black-background", "Black Background", "#000000", 0, false, false, "ubuntu", 0 },
103+ { "no-background", "No Background", "", 0, false, false, "ubuntu", 0 },
104+ { "unicode", "가나다라마", 0, 0, false, false, "ubuntu", 0 },
105+ { "no-response", "No Response", 0, 0, false, false, "ubuntu", 0 },
106+ { "empty-name", "", 0, 0, false, false, "ubuntu", 0 },
107107 };
108108}
109109
tests/mocks/IntegratedLightDM/liblightdm/UsersModelPrivate.h → tests/mocks/LightDM/IntegratedLightDM/liblightdm/UsersModelPrivate.hrenamed

The content is the same.

tests/mocks/IntegratedLightDM/plugin.cpp → tests/mocks/LightDM/IntegratedLightDM/plugin.cpprenamed+15−4
@@ -18,9 +18,11 @@
1818#include <DBusGreeter.h>
1919#include <DBusGreeterList.h>
2020#include "MockGreeter.h"
21+#include "MockSessionsModel.h"
2122#include "MockUsersModel.h"
22−#include <libusermetricsoutput/ColorTheme.h>
23−#include <libusermetricsoutput/UserMetrics.h>
23+#include <QLightDM/SessionsModel>
24+#include "ColorTheme.h"
25+#include "UserMetrics.h"
2426#include <QLightDM/UsersModel>
2527
2628#include <QAbstractItemModel>
@@ -39,6 +41,13 @@ static QObject *greeter_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
3941 return greeter;
4042}
4143
44+static QObject *sessions_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
45+{
46+ Q_UNUSED(engine)
47+ Q_UNUSED(scriptEngine)
48+ return new MockSessionsModel;
49+}
50+
4251static QObject *users_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
4352{
4453 Q_UNUSED(engine)
@@ -53,15 +62,17 @@ static QObject *infographic_provider(QQmlEngine *engine, QJSEngine *scriptEngine
5362 return UserMetricsOutput::UserMetrics::getInstance();
5463}
5564
56−void IntegratedLightDMPlugin::registerTypes(const char *uri)
65+void LightDMPlugin::registerTypes(const char *uri)
5766{
5867 qmlRegisterType<QAbstractItemModel>();
5968 qmlRegisterType<UserMetricsOutput::ColorTheme>();
6069
61− Q_ASSERT(uri == QLatin1String("IntegratedLightDM"));
70+ Q_ASSERT(uri == QLatin1String("LightDM.IntegratedLightDM"));
6271 qRegisterMetaType<QLightDM::Greeter::MessageType>("QLightDM::Greeter::MessageType");
6372 qRegisterMetaType<QLightDM::Greeter::PromptType>("QLightDM::Greeter::PromptType");
6473 qmlRegisterSingletonType<MockGreeter>(uri, 0, 1, "Greeter", greeter_provider);
74+ qmlRegisterSingletonType<MockSessionsModel>(uri, 0, 1, "Sessions", sessions_provider);
75+ qmlRegisterUncreatableType<SessionsModel>(uri, 0, 1, "SessionRoles", "Type is not instantiable");
6576 qmlRegisterSingletonType<MockUsersModel>(uri, 0, 1, "Users", users_provider);
6677 qmlRegisterUncreatableType<QLightDM::UsersModel>(uri, 0, 1, "UserRoles", "Type is not instantiable");
6778 qmlRegisterSingletonType<UserMetricsOutput::UserMetrics>(uri, 0, 1, "Infographic", infographic_provider);
tests/mocks/IntegratedLightDM/plugin.h → tests/mocks/LightDM/IntegratedLightDM/plugin.hrenamed+1−1
@@ -20,7 +20,7 @@
2020#include <QtQml/QQmlEngine>
2121#include <QtQml/QQmlExtensionPlugin>
2222
23−class IntegratedLightDMPlugin : public QQmlExtensionPlugin
23+class LightDMPlugin : public QQmlExtensionPlugin
2424{
2525 Q_OBJECT
2626 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
tests/mocks/LightDM/IntegratedLightDM/qmldirnew file+2
@@ -0,0 +1,2 @@
1+module LightDM.IntegratedLightDM
2+plugin MockLightDM-qml
tests/mocks/libusermetrics/libusermetricsoutput/ColorTheme.hdeleted−1
@@ -1 +0,0 @@
1−../ColorTheme.h
tests/mocks/libusermetrics/libusermetricsoutput/UserMetrics.hdeleted−1
@@ -1 +0,0 @@
1−../UserMetrics.h
tests/plugins/CMakeLists.txt+1−1
@@ -3,7 +3,7 @@ add_subdirectory(Cursor)
33add_subdirectory(Dash)
44add_subdirectory(GlobalShortcut)
55add_subdirectory(Greeter)
6−add_subdirectory(IntegratedLightDM)
6+add_subdirectory(LightDM)
77add_subdirectory(Ubuntu)
88add_subdirectory(Unity)
99add_subdirectory(Utils)
tests/plugins/LightDM/CMakeLists.txtnew file+1
@@ -0,0 +1 @@
1+add_subdirectory(IntegratedLightDM)
tests/plugins/IntegratedLightDM/CMakeLists.txt → tests/plugins/LightDM/IntegratedLightDM/CMakeLists.txtrenamed+36−13
@@ -8,19 +8,18 @@ include_directories(
88
99add_executable(GreeterDBusTestExec
1010 dbus.cpp
11− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/Greeter.cpp
11+ ${CMAKE_SOURCE_DIR}/plugins/LightDM/Greeter.cpp
1212 )
1313# This add_dependencies is needed since we're linking with with -L and -l below
1414# make seems to work but ninja breaks without it
1515add_dependencies(GreeterDBusTestExec MockLightDM)
1616qt5_use_modules(GreeterDBusTestExec Core DBus Quick Test)
1717target_link_libraries(GreeterDBusTestExec
18− -L${CMAKE_BINARY_DIR}/tests/mocks/IntegratedLightDM/liblightdm
19− -llightdm-qt5-2
18+ MockLightDM
2019 )
2120target_include_directories(GreeterDBusTestExec PUBLIC
22− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM
23− ${CMAKE_SOURCE_DIR}/tests/mocks/IntegratedLightDM
21+ ${CMAKE_SOURCE_DIR}/plugins/LightDM
22+ ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
2423 )
2524add_unity8_uitest(GreeterDBus dbus-test-runner
2625 ARG_PREFIX "--parameter"
@@ -32,20 +31,45 @@ add_unity8_uitest(GreeterDBus dbus-test-runner
3231
3332add_executable(GreeterPamTestExec
3433 pam.cpp
35− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/liblightdm/GreeterPrivate.cpp
34+ ${CMAKE_SOURCE_DIR}/plugins/LightDM/IntegratedLightDM/liblightdm/GreeterPrivate.cpp
3635 )
3736qt5_use_modules(GreeterPamTestExec Concurrent Core Test)
3837target_link_libraries(GreeterPamTestExec
3938 integratedLightDM
4039 )
40+
4141target_include_directories(GreeterPamTestExec PUBLIC
42− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/liblightdm
42+ ${CMAKE_SOURCE_DIR}/plugins/LightDM/IntegratedLightDM
43+ ${CMAKE_SOURCE_DIR}/plugins/LightDM/IntegratedLightDM/liblightdm
4344 )
4445add_qmltest_target(testGreeterPam GreeterPamTestExec COMMAND $<TARGET_FILE:GreeterPamTestExec>)
4546
47+# SessionsModelTest
48+add_executable(GreeterSessionsModelTestExec
49+ sessionsmodel.cpp
50+ ${CMAKE_SOURCE_DIR}/plugins/LightDM/SessionsModel.cpp
51+ ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
52+ )
53+add_dependencies(GreeterSessionsModelTestExec MockLightDM)
54+qt5_use_modules(GreeterSessionsModelTestExec Core Test)
55+target_link_libraries(GreeterSessionsModelTestExec
56+ MockLightDM
57+ )
58+target_include_directories(GreeterSessionsModelTestExec PUBLIC
59+ ${CMAKE_SOURCE_DIR}/plugins/LightDM
60+ ${CMAKE_SOURCE_DIR}/plugins/Utils
61+ ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
62+ )
63+add_unity8_uitest(GreeterSessions GreeterSessionsModelTestExec
64+ ENVIRONMENT LIBLIGHTDM_MOCK_MODE=full
65+ DEPENDS MockLightDM
66+ LIGHTDM
67+ )
68+
69+# UsersModelTest
4670add_executable(GreeterUsersModelTestExec
4771 usersmodel.cpp
48− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/UsersModel.cpp
72+ ${CMAKE_SOURCE_DIR}/plugins/LightDM/UsersModel.cpp
4973 ${CMAKE_SOURCE_DIR}/plugins/Utils/unitysortfilterproxymodelqml.cpp
5074 )
5175# This add_dependencies is needed since we're linking with with -L and -l below
@@ -53,13 +77,12 @@ add_executable(GreeterUsersModelTestExec
5377add_dependencies(GreeterUsersModelTestExec MockLightDM)
5478qt5_use_modules(GreeterUsersModelTestExec Core Test)
5579target_link_libraries(GreeterUsersModelTestExec
56− -L${CMAKE_BINARY_DIR}/tests/mocks/IntegratedLightDM/liblightdm
57− -llightdm-qt5-2
80+ MockLightDM
5881 )
5982target_include_directories(GreeterUsersModelTestExec PUBLIC
60− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM
83+ ${CMAKE_SOURCE_DIR}/plugins/LightDM
6184 ${CMAKE_SOURCE_DIR}/plugins/Utils
62− ${CMAKE_SOURCE_DIR}/tests/mocks/IntegratedLightDM
85+ ${CMAKE_SOURCE_DIR}/tests/mocks/LightDM/IntegratedLightDM
6386 )
6487add_unity8_uitest(GreeterUsers GreeterUsersModelTestExec
6588 ENVIRONMENT LIBLIGHTDM_MOCK_MODE=full
@@ -77,7 +100,7 @@ target_link_libraries(GreeterIntegratedTestExec
77100 )
78101target_include_directories(GreeterIntegratedTestExec PUBLIC
79102 ${GLIB_INCLUDE_DIRS}
80− ${CMAKE_SOURCE_DIR}/plugins/IntegratedLightDM/liblightdm
103+ ${CMAKE_SOURCE_DIR}/plugins/LightDM/IntegratedLightDM/liblightdm
81104 )
82105add_unity8_unittest(GreeterIntegrated dbus-test-runner
83106 ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/plugins/IntegratedLightDM/liblightdm/
tests/plugins/IntegratedLightDM/dbus.cpp → tests/plugins/LightDM/IntegratedLightDM/dbus.cpprenamed

The content is the same.

tests/plugins/IntegratedLightDM/greeter.qml → tests/plugins/LightDM/IntegratedLightDM/greeter.qmlrenamed+1−1
@@ -15,7 +15,7 @@
1515 */
1616
1717import QtQuick 2.4
18−import IntegratedLightDM 0.1 as LightDM
18+import LightDM.IntegratedLightDM 0.1 as LightDM
1919
2020Item {
2121 property var greeter: LightDM.Greeter
tests/plugins/IntegratedLightDM/integrated.cpp → tests/plugins/LightDM/IntegratedLightDM/integrated.cpprenamed

The content is the same.

tests/plugins/IntegratedLightDM/pam.cpp → tests/plugins/LightDM/IntegratedLightDM/pam.cpprenamed

The content is the same.

tests/plugins/LightDM/IntegratedLightDM/sessionsmodel.cppnew file+96
@@ -0,0 +1,96 @@
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+
19+#include <QLightDM/SessionsModel>
20+#include <QtCore/QModelIndex>
21+#include <QtTest>
22+#include <QString>
23+
24+class GreeterSessionsModelTest : public QObject
25+{
26+ Q_OBJECT
27+
28+private Q_SLOTS:
29+
30+ void init()
31+ {
32+ model = new SessionsModel();
33+ QVERIFY(model);
34+ sourceModel = new QLightDM::SessionsModel();
35+ QVERIFY(sourceModel);
36+ }
37+
38+ void cleanup()
39+ {
40+ delete model;
41+ delete sourceModel;
42+ }
43+
44+ static QModelIndex findByKey(QAbstractItemModel *model, const QString& key)
45+ {
46+ for (int i = 0; i < model->rowCount(QModelIndex()); i++) {
47+ if (model->data(model->index(i, 0), QLightDM::SessionsModel::KeyRole).toString() == key)
48+ return model->index(i, 0);
49+ }
50+
51+ return QModelIndex();
52+ }
53+
54+ void testIconDirectoriesAreValid()
55+ {
56+ Q_FOREACH(const QUrl& searchDirectory, model->iconSearchDirectories())
57+ {
58+ QVERIFY(searchDirectory.isValid());
59+ }
60+ }
61+
62+ void testMultipleSessionsCountIsCorrect()
63+ {
64+ sourceModel->setTestScenario("multipleSessions");
65+ QVERIFY(sourceModel->rowCount(QModelIndex()) > 1);
66+ }
67+
68+ void testNoSessionsCountIsCorrect()
69+ {
70+ sourceModel->setTestScenario("noSessions");
71+ QVERIFY(sourceModel->rowCount(QModelIndex()) == 0);
72+ }
73+
74+ void testSingleSessionCountIsCorrect()
75+ {
76+ sourceModel->setTestScenario("singleSession");
77+ QVERIFY(sourceModel->rowCount(QModelIndex()) == 1);
78+ }
79+
80+ void testSessionNameIsCorrect()
81+ {
82+ // This is testing the lookup, not the correctness of the strings,
83+ // so one test should be sufficient
84+ sourceModel->setTestScenario("multipleSessions");
85+ QVERIFY(model->data(findByKey(sourceModel, "ubuntu"),
86+ Qt::DisplayRole).toString() == "Ubuntu");
87+ }
88+
89+private:
90+ SessionsModel *model;
91+ QLightDM::SessionsModel *sourceModel;
92+};
93+
94+QTEST_MAIN(GreeterSessionsModelTest)
95+
96+#include "sessionsmodel.moc"
tests/plugins/IntegratedLightDM/usersmodel.cpp → tests/plugins/LightDM/IntegratedLightDM/usersmodel.cpprenamed

The content is the same.

tests/qmltests/Greeter/TestView.qml+1
@@ -43,6 +43,7 @@ Item {
4343 signal responded(string response)
4444 signal tease()
4545 signal emergencyCall()
46+ signal promptlessLogin()
4647
4748 signal _showMessageCalled(string html)
4849 signal _showPromptCalled(string text, bool isSecret, bool isDefaultPrompt)
tests/qmltests/Greeter/tst_Greeter.qml+28−10
@@ -22,7 +22,7 @@ import Ubuntu.Components 1.3
2222import AccountsService 0.1
2323import Biometryd 0.0
2424import GSettings 1.0
25−import IntegratedLightDM 0.1 as LightDM
25+import LightDM.IntegratedLightDM 0.1 as LightDM // This is the mock
2626import Unity.Test 0.1 as UT
2727
2828Item {
@@ -146,7 +146,9 @@ Item {
146146
147147 function init() {
148148 greeterSettings.lockedOutTime = 0;
149− resetLoader();
149+ LightDM.Greeter.selectUser = "";
150+ greeter.failedLoginsDelayAttempts = 7;
151+ greeter.failedLoginsDelayMinutes = 5;
150152 teaseSpy.clear();
151153 sessionStartedSpy.clear();
152154 activeChangedSpy.clear();
@@ -162,11 +164,7 @@ Item {
162164 viewShowErrorMessageSpy.clear();
163165 viewResetSpy.clear();
164166 viewTryToUnlockSpy.clear();
165− tryCompare(greeter, "waiting", false);
166− view = findChild(greeter, "testView");
167− verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
168− greeter.failedLoginsDelayAttempts = 7;
169− greeter.failedLoginsDelayMinutes = 5;
167+ resetLoader();
170168 }
171169
172170 function resetLoader() {
@@ -178,6 +176,8 @@ Item {
178176 loader.active = true;
179177 tryCompare(loader, "status", Loader.Ready);
180178 removeTimeConstraintsFromSwipeAreas(loader.item);
179+ tryCompare(greeter, "waiting", false);
180+ view = findChild(greeter, "testView");
181181 }
182182
183183 function getIndexOf(name) {
@@ -202,6 +202,7 @@ Item {
202202 compare(view.currentIndex, i);
203203 compare(AccountsService.user, name);
204204 compare(LightDM.Greeter.authenticationUser, name);
205+ return i;
205206 }
206207
207208 function verifyLoggedIn() {
@@ -248,11 +249,9 @@ Item {
248249
249250 function test_promptless() {
250251 selectUser("no-password");
251− tryCompare(viewAuthenticationSucceededSpy, "count", 1);
252− compare(sessionStartedSpy.count, 1);
252+ tryCompare(view, "locked", false);
253253 compare(viewShowPromptSpy.count, 0);
254254 compare(viewHideSpy.count, 0);
255− compare(view.locked, false);
256255 }
257256
258257 function test_twoFactorPass() {
@@ -573,6 +572,25 @@ Item {
573572 tryCompare(viewShowPromptSpy, "count", 1);
574573 }
575574
575+ function test_selectUserHint() {
576+ LightDM.Greeter.selectUser = "info-prompt";
577+ resetLoader();
578+ var i = verifySelected("info-prompt");
579+ verify(i != 0); // sanity-check that info-prompt isn't default 0 answer
580+ }
581+
582+ function test_selectUserHintUnset() {
583+ LightDM.Greeter.selectUser = "";
584+ resetLoader();
585+ verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
586+ }
587+
588+ function test_selectUserHintInvalid() {
589+ LightDM.Greeter.selectUser = "not-a-real-user";
590+ resetLoader();
591+ verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
592+ }
593+
576594 function test_fingerprintSuccess() {
577595 var index = selectUser("has-password");
578596 unlockAndShowGreeter(); // turn on lockscreen mode
tests/qmltests/Greeter/tst_Infographics.qml+1−1
@@ -20,7 +20,7 @@ import ".."
2020import "../../../qml/Greeter"
2121import Ubuntu.Components 1.3
2222import Unity.Test 0.1 as UT
23−import IntegratedLightDM 0.1 as LightDM
23+import LightDM.IntegratedLightDM 0.1 as LightDM
2424
2525Item {
2626 Binding {
tests/qmltests/Greeter/tst_NarrowView.qml+1−1
@@ -18,7 +18,7 @@ import QtQuick 2.4
1818import QtTest 1.0
1919import ".."
2020import "../../../qml/Greeter"
21−import IntegratedLightDM 0.1 as LightDM
21+import LightDM.IntegratedLightDM 0.1 as LightDM
2222import Ubuntu.Components 1.3
2323import Unity.Test 0.1 as UT
2424
tests/qmltests/Greeter/tst_WideView.qml+1−1
@@ -18,7 +18,7 @@ import QtQuick 2.4
1818import QtTest 1.0
1919import ".."
2020import "../../../qml/Greeter"
21−import IntegratedLightDM 0.1 as LightDM
21+import LightDM.IntegratedLightDM 0.1 as LightDM
2222import Ubuntu.Components 1.3
2323import Unity.Test 0.1 as UT
2424
tests/qmltests/Tutorial/tst_Tutorial.qml+1−1
@@ -17,7 +17,7 @@
1717import QtQuick 2.4
1818import QtTest 1.0
1919import AccountsService 0.1
20−import IntegratedLightDM 0.1 as LightDM
20+import LightDM.IntegratedLightDM 0.1 as LightDM
2121import Ubuntu.Components 1.3
2222import Ubuntu.Components.ListItems 1.3
2323import Ubuntu.Telephony 0.1 as Telephony
tests/qmltests/tst_OrientedShell.qml+1−1
@@ -22,7 +22,7 @@ import Ubuntu.Components 1.3
2222import Ubuntu.Components.ListItems 1.3 as ListItem
2323import Unity.Application 0.1
2424import Unity.Test 0.1
25−import IntegratedLightDM 0.1 as LightDM
25+import LightDM.IntegratedLightDM 0.1 as LightDM
2626import Powerd 0.1
2727import Unity.InputInfo 0.1
2828import Utils 0.1
tests/qmltests/tst_Shell.qml+5−13
@@ -18,7 +18,7 @@ import QtQuick 2.4
1818import QtTest 1.0
1919import AccountsService 0.1
2020import GSettings 1.0
21−import IntegratedLightDM 0.1 as LightDM
21+import LightDM.IntegratedLightDM 0.1 as LightDM
2222import Ubuntu.Components 1.3
2323import Ubuntu.Components.ListItems 1.3 as ListItem
2424import Ubuntu.Telephony 0.1 as Telephony
@@ -1187,16 +1187,13 @@ Rectangle {
11871187
11881188 function test_greeterLoginsAutomaticallyWhenNoPasswordSet() {
11891189 loadShell("phone");
1190− swipeAwayGreeter();
1191−
1192− sessionSpy.clear();
1193− verify(sessionSpy.valid);
1194−
1195− showGreeter();
11961190
11971191 var greeter = findChild(shell, "greeter");
11981192 verify(!greeter.locked);
1199− verify(sessionSpy.count > 0);
1193+ compare(sessionSpy.count, 0);
1194+
1195+ swipeAwayGreeter();
1196+ compare(sessionSpy.count, 1);
12001197 }
12011198
12021199 function test_fullscreen() {
@@ -2224,11 +2221,6 @@ Rectangle {
22242221 shell.usageScenario = "desktop";
22252222 GSettingsController.setAutohideLauncher(!data.launcherLocked);
22262223 waitForRendering(shell);
2227− // Not sure why 2 but it's the number of times
2228− // it triggers at this time and we need to wait
2229− // for them otherwise a sessionStarted signal will
2230− // hide the launcher and make the test fail
2231− tryCompare(sessionSpy, "count", 2);
22322224
22332225 var launcher = findChild(shell, "launcher");
22342226 var launcherPanel = findChild(launcher, "launcherPanel");
tests/qmltests/tst_ShellWithPin.qml+1−1
@@ -19,7 +19,7 @@ import Ubuntu.Components 1.3
1919import QtTest 1.0
2020import AccountsService 0.1
2121import GSettings 1.0
22−import IntegratedLightDM 0.1 as LightDM
22+import LightDM.IntegratedLightDM 0.1 as LightDM
2323import Ubuntu.SystemImage 0.1
2424import Ubuntu.Telephony 0.1 as Telephony
2525import Unity.Application 0.1