@@ -23,6 +23,8 @@ import Ubuntu.Components 1.3
23import Ubuntu.SystemImage 0.1
23import Ubuntu.SystemImage 0.1
24import Unity.Launcher 0.1
24import Unity.Launcher 0.1
25import Unity.Session 0.1
25import Unity.Session 0.1
26import "../Components"
28import "../Components"
@@ -48,7 +50,7 @@ Showable {
48 readonly property bool hasLockedApp: lockedApp !== ""
50 readonly property bool hasLockedApp: lockedApp !== ""
50 property bool forcedUnlock
52 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
53 property bool tabletMode
55 property bool tabletMode
54 property url viewSource // only used for testing
56 property url viewSource // only used for testing
@@ -120,12 +122,12 @@ Showable {
120 return d.startUnlock(true /* toTheRight */);
122 return d.startUnlock(true /* toTheRight */);
123− LightDM{id:lightDM} // Provide backend access
124 QtObject {
125 QtObject {
127− readonly property bool multiUser: lightDM.users.count > 1
128+ readonly property bool multiUser: LightDMService.users.count > 1
129+ readonly property int selectUserIndex: d.getUserIndex(LightDMService.greeter.selectUser)
128− property int currentIndex
130+ property int currentIndex: Math.max(selectUserIndex, 0)
129 property bool waiting
131 property bool waiting
130 property bool isLockscreen // true when we are locking an active session, rather than first user login
132 property bool isLockscreen // true when we are locking an active session, rather than first user login
131 readonly property bool secureFingerprint: isLockscreen &&
133 readonly property bool secureFingerprint: isLockscreen &&
@@ -147,21 +149,37 @@ Showable {
147 UbuntuNumberAnimation {}
149 UbuntuNumberAnimation {}
152+ function getUserIndex(username) {
153+ if (username === "")
156+ // Find index for requested user, if it exists
157+ for (var i = 0; i < LightDMService.users.count; i++) {
158+ if (username === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
150 function selectUser(uid, reset) {
166 function selectUser(uid, reset) {
151 d.waiting = true;
169 d.waiting = true;
152 if (reset) {
170 if (reset) {
153 loader.item.reset();
171 loader.item.reset();
155 currentIndex = uid;
173 currentIndex = uid;
156− var user = lightDM.users.data(uid, lightDM.userRoles.NameRole);
174+ var user = LightDMService.users.data(uid, LightDMService.userRoles.NameRole);
157 AccountsService.user = user;
175 AccountsService.user = user;
158 LauncherModel.setUser(user);
176 LauncherModel.setUser(user);
159− lightDM.greeter.authenticate(user); // always resets auth state
177+ LightDMService.greeter.authenticate(user); // always resets auth state
162 function login() {
180 function login() {
163 enabled = false;
181 enabled = false;
164− if (lightDM.greeter.startSessionSync()) {
182+ if (LightDMService.greeter.startSessionSync()) {
165 sessionStarted();
183 sessionStarted();
166 if (loader.item) {
184 if (loader.item) {
167 loader.item.notifyAuthenticationSucceeded(false /* showFakePassword */);
185 loader.item.notifyAuthenticationSucceeded(false /* showFakePassword */);
@@ -307,7 +325,7 @@ Showable {
307 root.lockedApp = "";
325 root.lockedApp = "";
308 root.forceActiveFocus();
326 root.forceActiveFocus();
309 d.selectUser(d.currentIndex, true);
327 d.selectUser(d.currentIndex, true);
310− lightDM.infographic.readyForDataChange();
328+ LightDMService.infographic.readyForDataChange();
313 Connections {
331 Connections {
@@ -315,13 +333,12 @@ Showable {
315 onSelected: {
333 onSelected: {
316 d.selectUser(index, true);
334 d.selectUser(index, true);
336+ onPromptlessLogin: d.login();
318 onResponded: {
337 onResponded: {
319 if (root.locked) {
338 if (root.locked) {
320− lightDM.greeter.respond(response);
339+ LightDMService.greeter.respond(response);
322− if (lightDM.greeter.active && !lightDM.greeter.authenticated) { // could happen if forcedUnlock
323− d.login();
341+ d.login();
325 loader.item.hide();
342 loader.item.hide();
@@ -385,18 +402,18 @@ Showable {
385 Binding {
402 Binding {
386 target: loader.item
403 target: loader.item
387 property: "userModel"
404 property: "userModel"
388− value: lightDM.users
405+ value: LightDMService.users
391 Binding {
408 Binding {
392 target: loader.item
409 target: loader.item
393 property: "infographicModel"
410 property: "infographicModel"
394− value: lightDM.infographic
411+ value: LightDMService.infographic
398 Connections {
415 Connections {
399− target: lightDM.greeter
416+ target: LightDMService.greeter
401 onShowGreeter: root.forceShow()
418 onShowGreeter: root.forceShow()
@@ -431,13 +448,13 @@ Showable {
431 onAuthenticationComplete: {
448 onAuthenticationComplete: {
432 d.waiting = false;
449 d.waiting = false;
434− if (lightDM.greeter.authenticated) {
451+ if (LightDMService.greeter.authenticated) {
452+ if (!LightDMService.greeter.promptless) {
435− d.login();
453+ d.login();
436− if (!lightDM.greeter.promptless) {
437 loader.item.hide();
454 loader.item.hide();
440− if (!lightDM.greeter.promptless) {
457+ if (!LightDMService.greeter.promptless) {
441 AccountsService.failedLogins++;
458 AccountsService.failedLogins++;
@@ -458,21 +475,13 @@ Showable {
460 loader.item.notifyAuthenticationFailed();
477 loader.item.notifyAuthenticationFailed();
461− if (!lightDM.greeter.promptless) {
478+ if (!LightDMService.greeter.promptless) {
462 d.selectUser(d.currentIndex, false);
479 d.selectUser(d.currentIndex, false);
467− onRequestAuthenticationUser: {
484+ onRequestAuthenticationUser: d.selectUser(d.getUserIndex(user), true)
468− // Find index for requested user, if it exists
469− for (var i = 0; i < lightDM.users.count; i++) {
470− if (user === lightDM.users.data(i, lightDM.userRoles.NameRole)) {
471− d.selectUser(i, true);
478 Connections {
487 Connections {
@@ -485,20 +494,20 @@ Showable {
487 Binding {
496 Binding {
488− target: lightDM.greeter
497+ target: LightDMService.greeter
489 property: "active"
498 property: "active"
490 value: root.active
499 value: root.active
493 Binding {
502 Binding {
494− target: lightDM.infographic
503+ target: LightDMService.infographic
495 property: "username"
504 property: "username"
496− value: AccountsService.statsWelcomeScreen ? lightDM.users.data(d.currentIndex, lightDM.userRoles.NameRole) : ""
505+ value: AccountsService.statsWelcomeScreen ? LightDMService.users.data(d.currentIndex, LightDMService.userRoles.NameRole) : ""
499 Connections {
508 Connections {
500 target: i18n
509 target: i18n
501− onLanguageChanged: lightDM.infographic.readyForDataChange()
510+ onLanguageChanged: LightDMService.infographic.readyForDataChange()
504 Observer {
513 Observer {
@@ -550,7 +559,7 @@ Showable {
550 failOperation("fingerprint reader is locked");
559 failOperation("fingerprint reader is locked");
553− if (result !== lightDM.users.data(d.currentIndex, lightDM.userRoles.UidRole)) {
562+ if (result !== LightDMService.users.data(d.currentIndex, LightDMService.userRoles.UidRole)) {
554 AccountsService.failedFingerprintLogins++;
563 AccountsService.failedFingerprintLogins++;
555 failOperation("not the selected user");
564 failOperation("not the selected user");