@@ -21,6 +21,8 @@ import Ubuntu.Components 1.3
21import Ubuntu.SystemImage 0.1
21import Ubuntu.SystemImage 0.1
22import Unity.Launcher 0.1
22import Unity.Launcher 0.1
23import Unity.Session 0.1
23import Unity.Session 0.1
24import "../Components"
26import "../Components"
@@ -44,7 +46,7 @@ Showable {
44 readonly property bool hasLockedApp: lockedApp !== ""
46 readonly property bool hasLockedApp: lockedApp !== ""
46 property bool forcedUnlock
48 property bool forcedUnlock
47− readonly property bool locked: lightDM.greeter.active && !lightDM.greeter.authenticated && !forcedUnlock
49+ readonly property bool locked: LightDMService.greeter.active && !LightDMService.greeter.authenticated && !forcedUnlock
49 property bool tabletMode
51 property bool tabletMode
50 property url viewSource // only used for testing
52 property url viewSource // only used for testing
@@ -112,12 +114,12 @@ Showable {
112 return d.startUnlock(true /* toTheRight */);
114 return d.startUnlock(true /* toTheRight */);
115− LightDM{id:lightDM} // Provide backend access
116 QtObject {
117 QtObject {
119− readonly property bool multiUser: lightDM.users.count > 1
120+ readonly property bool multiUser: LightDMService.users.count > 1
121+ readonly property int selectUserIndex: d.getUserIndex(LightDMService.greeter.selectUser)
120− property int currentIndex
122+ property int currentIndex: Math.max(selectUserIndex, 0)
121 property bool waiting
123 property bool waiting
123 // We want 'launcherOffset' to animate down to zero. But not to animate
125 // We want 'launcherOffset' to animate down to zero. But not to animate
@@ -134,21 +136,37 @@ Showable {
134 UbuntuNumberAnimation {}
136 UbuntuNumberAnimation {}
139+ function getUserIndex(username) {
140+ if (username === "")
143+ // Find index for requested user, if it exists
144+ for (var i = 0; i < LightDMService.users.count; i++) {
145+ if (username === LightDMService.users.data(i, LightDMService.userRoles.NameRole)) {
137 function selectUser(uid, reset) {
153 function selectUser(uid, reset) {
138 d.waiting = true;
156 d.waiting = true;
139 if (reset) {
157 if (reset) {
140 loader.item.reset();
158 loader.item.reset();
142 currentIndex = uid;
160 currentIndex = uid;
143− var user = lightDM.users.data(uid, lightDM.userRoles.NameRole);
161+ var user = LightDMService.users.data(uid, LightDMService.userRoles.NameRole);
144 AccountsService.user = user;
162 AccountsService.user = user;
145 LauncherModel.setUser(user);
163 LauncherModel.setUser(user);
146− lightDM.greeter.authenticate(user); // always resets auth state
164+ LightDMService.greeter.authenticate(user); // always resets auth state
149 function login() {
167 function login() {
150 enabled = false;
168 enabled = false;
151− if (lightDM.greeter.startSessionSync()) {
169+ if (LightDMService.greeter.startSessionSync()) {
152 sessionStarted();
170 sessionStarted();
153 if (loader.item) {
171 if (loader.item) {
154 loader.item.notifyAuthenticationSucceeded();
172 loader.item.notifyAuthenticationSucceeded();
@@ -283,7 +301,7 @@ Showable {
283 root.lockedApp = "";
301 root.lockedApp = "";
284 root.forceActiveFocus();
302 root.forceActiveFocus();
285 d.selectUser(d.currentIndex, true);
303 d.selectUser(d.currentIndex, true);
286− lightDM.infographic.readyForDataChange();
304+ LightDMService.infographic.readyForDataChange();
289 Connections {
307 Connections {
@@ -291,13 +309,12 @@ Showable {
291 onSelected: {
309 onSelected: {
292 d.selectUser(index, true);
310 d.selectUser(index, true);
312+ onPromptlessLogin: d.login();
294 onResponded: {
313 onResponded: {
295 if (root.locked) {
314 if (root.locked) {
296− lightDM.greeter.respond(response);
315+ LightDMService.greeter.respond(response);
298− if (lightDM.greeter.active && !lightDM.greeter.authenticated) { // could happen if forcedUnlock
299− d.login();
317+ d.login();
301 loader.item.hide();
318 loader.item.hide();
@@ -361,18 +378,18 @@ Showable {
361 Binding {
378 Binding {
362 target: loader.item
379 target: loader.item
363 property: "userModel"
380 property: "userModel"
364− value: lightDM.users
381+ value: LightDMService.users
367 Binding {
384 Binding {
368 target: loader.item
385 target: loader.item
369 property: "infographicModel"
386 property: "infographicModel"
370− value: lightDM.infographic
387+ value: LightDMService.infographic
374 Connections {
391 Connections {
375− target: lightDM.greeter
392+ target: LightDMService.greeter
377 onShowGreeter: root.forceShow()
394 onShowGreeter: root.forceShow()
@@ -407,14 +424,14 @@ Showable {
407 onAuthenticationComplete: {
424 onAuthenticationComplete: {
408 d.waiting = false;
425 d.waiting = false;
410− if (lightDM.greeter.authenticated) {
427+ if (LightDMService.greeter.authenticated) {
411 AccountsService.failedLogins = 0;
428 AccountsService.failedLogins = 0;
413− if (!lightDM.greeter.promptless) {
429+ if (!LightDMService.greeter.promptless) {
414 loader.item.hide();
431 loader.item.hide();
417− if (!lightDM.greeter.promptless) {
434+ if (!LightDMService.greeter.promptless) {
418 AccountsService.failedLogins++;
435 AccountsService.failedLogins++;
@@ -435,21 +452,13 @@ Showable {
437 loader.item.notifyAuthenticationFailed();
454 loader.item.notifyAuthenticationFailed();
438− if (!lightDM.greeter.promptless) {
455+ if (!LightDMService.greeter.promptless) {
439 d.selectUser(d.currentIndex, false);
456 d.selectUser(d.currentIndex, false);
444− onRequestAuthenticationUser: {
461+ onRequestAuthenticationUser: d.selectUser(d.getUserIndex(user), true)
445− // Find index for requested user, if it exists
446− for (var i = 0; i < lightDM.users.count; i++) {
447− if (user === lightDM.users.data(i, lightDM.userRoles.NameRole)) {
448− d.selectUser(i, true);
455 Connections {
464 Connections {
@@ -459,19 +468,19 @@ Showable {
461 Binding {
470 Binding {
462− target: lightDM.greeter
471+ target: LightDMService.greeter
463 property: "active"
472 property: "active"
464 value: root.active
473 value: root.active
467 Binding {
476 Binding {
468− target: lightDM.infographic
477+ target: LightDMService.infographic
469 property: "username"
478 property: "username"
470− value: AccountsService.statsWelcomeScreen ? lightDM.users.data(d.currentIndex, lightDM.userRoles.NameRole) : ""
479+ value: AccountsService.statsWelcomeScreen ? LightDMService.users.data(d.currentIndex, LightDMService.userRoles.NameRole) : ""
473 Connections {
482 Connections {
474 target: i18n
483 target: i18n
475− onLanguageChanged: lightDM.infographic.readyForDataChange()
484+ onLanguageChanged: LightDMService.infographic.readyForDataChange()