2013-07-23 20:37:42 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
const Clutter = imports.gi.Clutter;
|
2014-09-18 20:04:00 -04:00
|
|
|
const Gio = imports.gi.Gio;
|
2016-04-19 13:12:46 -04:00
|
|
|
const GLib = imports.gi.GLib;
|
2013-07-23 20:37:42 -04:00
|
|
|
const Lang = imports.lang;
|
2017-06-28 03:34:20 -04:00
|
|
|
const Pango = imports.gi.Pango;
|
2013-07-23 20:37:42 -04:00
|
|
|
const Signals = imports.signals;
|
|
|
|
const St = imports.gi.St;
|
|
|
|
|
|
|
|
const Animation = imports.ui.animation;
|
2013-07-22 11:07:35 -04:00
|
|
|
const Batch = imports.gdm.batch;
|
|
|
|
const GdmUtil = imports.gdm.util;
|
2015-10-05 15:26:18 -04:00
|
|
|
const Meta = imports.gi.Meta;
|
2013-07-22 11:07:35 -04:00
|
|
|
const Params = imports.misc.params;
|
2013-07-23 20:37:42 -04:00
|
|
|
const ShellEntry = imports.ui.shellEntry;
|
|
|
|
const Tweener = imports.ui.tweener;
|
|
|
|
const UserWidget = imports.ui.userWidget;
|
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var DEFAULT_BUTTON_WELL_ICON_SIZE = 16;
|
|
|
|
var DEFAULT_BUTTON_WELL_ANIMATION_DELAY = 1.0;
|
|
|
|
var DEFAULT_BUTTON_WELL_ANIMATION_TIME = 0.3;
|
2013-07-23 20:37:42 -04:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var MESSAGE_FADE_OUT_ANIMATION_TIME = 0.5;
|
2013-07-24 10:53:48 -04:00
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var AuthPromptMode = {
|
2013-07-22 11:07:35 -04:00
|
|
|
UNLOCK_ONLY: 0,
|
|
|
|
UNLOCK_OR_LOG_IN: 1
|
|
|
|
};
|
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var AuthPromptStatus = {
|
2013-07-28 16:24:31 -04:00
|
|
|
NOT_VERIFYING: 0,
|
|
|
|
VERIFYING: 1,
|
|
|
|
VERIFICATION_FAILED: 2,
|
|
|
|
VERIFICATION_SUCCEEDED: 3
|
|
|
|
};
|
|
|
|
|
2017-07-18 13:47:27 -04:00
|
|
|
var BeginRequestType = {
|
2013-07-28 17:49:50 -04:00
|
|
|
PROVIDE_USERNAME: 0,
|
|
|
|
DONT_PROVIDE_USERNAME: 1
|
|
|
|
};
|
|
|
|
|
2017-07-18 13:41:25 -04:00
|
|
|
var AuthPrompt = new Lang.Class({
|
2013-07-23 20:37:42 -04:00
|
|
|
Name: 'AuthPrompt',
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_init(gdmClient, mode) {
|
2013-07-28 16:24:31 -04:00
|
|
|
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
|
2013-07-22 11:07:35 -04:00
|
|
|
|
|
|
|
this._gdmClient = gdmClient;
|
|
|
|
this._mode = mode;
|
|
|
|
|
2015-10-05 15:26:18 -04:00
|
|
|
this._idleMonitor = Meta.IdleMonitor.get_core();
|
|
|
|
|
2013-07-22 11:07:35 -04:00
|
|
|
let reauthenticationOnly;
|
|
|
|
if (this._mode == AuthPromptMode.UNLOCK_ONLY)
|
|
|
|
reauthenticationOnly = true;
|
|
|
|
else if (this._mode == AuthPromptMode.UNLOCK_OR_LOG_IN)
|
|
|
|
reauthenticationOnly = false;
|
|
|
|
|
|
|
|
this._userVerifier = new GdmUtil.ShellUserVerifier(this._gdmClient, { reauthenticationOnly: reauthenticationOnly });
|
|
|
|
|
2017-12-01 19:27:35 -05:00
|
|
|
this._userVerifier.connect('ask-question', this._onAskQuestion.bind(this));
|
|
|
|
this._userVerifier.connect('show-message', this._onShowMessage.bind(this));
|
|
|
|
this._userVerifier.connect('verification-failed', this._onVerificationFailed.bind(this));
|
|
|
|
this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
|
|
|
|
this._userVerifier.connect('reset', this._onReset.bind(this));
|
|
|
|
this._userVerifier.connect('smartcard-status-changed', this._onSmartcardStatusChanged.bind(this));
|
|
|
|
this._userVerifier.connect('ovirt-user-authenticated', this._onOVirtUserAuthenticated.bind(this));
|
2013-06-27 08:54:19 -04:00
|
|
|
this.smartcardDetected = this._userVerifier.smartcardDetected;
|
2013-07-22 11:07:35 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this.connect('next', () => {
|
|
|
|
this.updateSensitivity(false);
|
|
|
|
if (this._queryingService) {
|
2015-09-30 14:36:33 -04:00
|
|
|
this.startSpinning();
|
2017-10-30 20:38:18 -04:00
|
|
|
this._userVerifier.answerQuery(this._queryingService, this._entry.text);
|
|
|
|
} else {
|
|
|
|
this._preemptiveAnswer = this._entry.text;
|
2015-10-05 15:26:18 -04:00
|
|
|
|
|
|
|
if (this._preemptiveAnswerWatchId) {
|
|
|
|
this._idleMonitor.remove_watch(this._preemptiveAnswerWatchId);
|
|
|
|
this._preemptiveAnswerWatchId = 0;
|
|
|
|
}
|
2017-10-30 20:38:18 -04:00
|
|
|
}
|
|
|
|
});
|
2013-07-22 11:07:35 -04:00
|
|
|
|
2013-07-23 20:37:42 -04:00
|
|
|
this.actor = new St.BoxLayout({ style_class: 'login-dialog-prompt-layout',
|
|
|
|
vertical: true });
|
2017-12-01 19:27:35 -05:00
|
|
|
this.actor.connect('destroy', this._onDestroy.bind(this));
|
2017-10-30 20:38:18 -04:00
|
|
|
this.actor.connect('key-press-event', (actor, event) => {
|
|
|
|
if (event.get_key_symbol() == Clutter.KEY_Escape)
|
|
|
|
this.cancel();
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
});
|
2013-07-23 20:37:42 -04:00
|
|
|
|
|
|
|
this._userWell = new St.Bin({ x_fill: true,
|
|
|
|
x_align: St.Align.START });
|
|
|
|
this.actor.add(this._userWell,
|
|
|
|
{ x_align: St.Align.START,
|
|
|
|
x_fill: true,
|
|
|
|
y_fill: true,
|
|
|
|
expand: true });
|
|
|
|
this._label = new St.Label({ style_class: 'login-dialog-prompt-label' });
|
|
|
|
|
|
|
|
this.actor.add(this._label,
|
|
|
|
{ expand: true,
|
2013-12-11 15:36:15 -05:00
|
|
|
x_fill: false,
|
2013-07-23 20:37:42 -04:00
|
|
|
y_fill: true,
|
|
|
|
x_align: St.Align.START });
|
|
|
|
this._entry = new St.Entry({ style_class: 'login-dialog-prompt-entry',
|
|
|
|
can_focus: true });
|
|
|
|
ShellEntry.addContextMenu(this._entry, { isPassword: true });
|
|
|
|
|
|
|
|
this.actor.add(this._entry,
|
|
|
|
{ expand: true,
|
|
|
|
x_fill: true,
|
|
|
|
y_fill: false,
|
|
|
|
x_align: St.Align.START });
|
|
|
|
|
|
|
|
this._entry.grab_key_focus();
|
|
|
|
|
2016-04-19 13:12:46 -04:00
|
|
|
this._timedLoginIndicator = new St.Bin({ style_class: 'login-dialog-timed-login-indicator',
|
|
|
|
scale_x: 0 });
|
|
|
|
|
|
|
|
this.actor.add(this._timedLoginIndicator);
|
|
|
|
|
2013-08-27 10:17:26 -04:00
|
|
|
this._message = new St.Label({ opacity: 0,
|
|
|
|
styleClass: 'login-dialog-message' });
|
2013-07-28 12:40:55 -04:00
|
|
|
this._message.clutter_text.line_wrap = true;
|
2016-10-13 00:29:21 -04:00
|
|
|
this._message.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
2013-12-11 15:36:15 -05:00
|
|
|
this.actor.add(this._message, { x_fill: false, x_align: St.Align.START, y_align: St.Align.START });
|
2013-07-23 20:37:42 -04:00
|
|
|
|
|
|
|
this._buttonBox = new St.BoxLayout({ style_class: 'login-dialog-button-box',
|
|
|
|
vertical: false });
|
|
|
|
this.actor.add(this._buttonBox,
|
|
|
|
{ expand: true,
|
|
|
|
x_align: St.Align.MIDDLE,
|
|
|
|
y_align: St.Align.END });
|
|
|
|
|
2013-08-26 15:47:52 -04:00
|
|
|
this._defaultButtonWell = new St.Widget({ layout_manager: new Clutter.BinLayout() });
|
2013-07-23 20:37:42 -04:00
|
|
|
this._defaultButtonWellActor = null;
|
|
|
|
|
|
|
|
this._initButtons();
|
|
|
|
|
2014-09-18 22:24:46 -04:00
|
|
|
let spinnerIcon = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
|
2013-07-23 20:37:42 -04:00
|
|
|
this._spinner = new Animation.AnimatedIcon(spinnerIcon, DEFAULT_BUTTON_WELL_ICON_SIZE);
|
|
|
|
this._spinner.actor.opacity = 0;
|
|
|
|
this._spinner.actor.show();
|
|
|
|
this._defaultButtonWell.add_child(this._spinner.actor);
|
|
|
|
},
|
|
|
|
|
2016-04-19 13:12:46 -04:00
|
|
|
showTimedLoginIndicator(time) {
|
|
|
|
let hold = new Batch.Hold();
|
|
|
|
|
|
|
|
this.hideTimedLoginIndicator();
|
|
|
|
|
|
|
|
let startTime = GLib.get_monotonic_time();
|
|
|
|
|
|
|
|
this._timedLoginTimeoutId = GLib.timeout_add (GLib.PRIORITY_DEFAULT, 33,
|
|
|
|
() => {
|
|
|
|
let currentTime = GLib.get_monotonic_time();
|
|
|
|
let elapsedTime = (currentTime - startTime) / GLib.USEC_PER_SEC;
|
|
|
|
this._timedLoginIndicator.scale_x = elapsedTime / time;
|
|
|
|
if (elapsedTime >= time) {
|
|
|
|
this._timedLoginTimeoutId = 0;
|
|
|
|
hold.release();
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GLib.SOURCE_CONTINUE;
|
|
|
|
});
|
|
|
|
|
|
|
|
GLib.Source.set_name_by_id(this._timedLoginTimeoutId, '[gnome-shell] this._timedLoginTimeoutId');
|
|
|
|
|
|
|
|
return hold;
|
|
|
|
},
|
|
|
|
|
|
|
|
hideTimedLoginIndicator() {
|
|
|
|
if (this._timedLoginTimeoutId) {
|
|
|
|
GLib.source_remove(this._timedLoginTimeoutId);
|
|
|
|
this._timedLoginTimeoutId = 0;
|
|
|
|
}
|
|
|
|
this._timedLoginIndicator.scale_x = 0.;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onDestroy() {
|
2015-10-05 15:26:18 -04:00
|
|
|
if (this._preemptiveAnswerWatchId) {
|
|
|
|
this._idleMonitor.remove_watch(this._preemptiveAnswerWatchId);
|
|
|
|
this._preemptiveAnswerWatchId = 0;
|
|
|
|
}
|
|
|
|
|
2014-10-09 14:10:12 -04:00
|
|
|
this._userVerifier.destroy();
|
2013-07-29 13:24:36 -04:00
|
|
|
this._userVerifier = null;
|
2013-07-22 11:07:35 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_initButtons() {
|
2015-01-16 09:33:56 -05:00
|
|
|
this.cancelButton = new St.Button({ style_class: 'modal-dialog-button button',
|
2013-07-23 20:37:42 -04:00
|
|
|
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
|
|
|
|
reactive: true,
|
|
|
|
can_focus: true,
|
|
|
|
label: _("Cancel") });
|
2017-10-30 20:38:18 -04:00
|
|
|
this.cancelButton.connect('clicked', () => { this.cancel(); });
|
2013-07-23 20:37:42 -04:00
|
|
|
this._buttonBox.add(this.cancelButton,
|
|
|
|
{ expand: false,
|
|
|
|
x_fill: false,
|
|
|
|
y_fill: false,
|
|
|
|
x_align: St.Align.START,
|
|
|
|
y_align: St.Align.END });
|
|
|
|
|
|
|
|
this._buttonBox.add(this._defaultButtonWell,
|
|
|
|
{ expand: true,
|
|
|
|
x_fill: false,
|
|
|
|
y_fill: false,
|
|
|
|
x_align: St.Align.END,
|
|
|
|
y_align: St.Align.MIDDLE });
|
2015-01-16 09:33:56 -05:00
|
|
|
this.nextButton = new St.Button({ style_class: 'modal-dialog-button button',
|
2013-07-23 20:37:42 -04:00
|
|
|
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
|
|
|
|
reactive: true,
|
|
|
|
can_focus: true,
|
|
|
|
label: _("Next") });
|
2017-10-30 20:38:18 -04:00
|
|
|
this.nextButton.connect('clicked', () => { this.emit('next'); });
|
2013-07-23 20:37:42 -04:00
|
|
|
this.nextButton.add_style_pseudo_class('default');
|
|
|
|
this._buttonBox.add(this.nextButton,
|
|
|
|
{ expand: false,
|
|
|
|
x_fill: false,
|
|
|
|
y_fill: false,
|
|
|
|
x_align: St.Align.END,
|
|
|
|
y_align: St.Align.END });
|
|
|
|
|
|
|
|
this._updateNextButtonSensitivity(this._entry.text.length > 0);
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this._entry.clutter_text.connect('text-changed', () => {
|
2015-09-30 12:51:24 -04:00
|
|
|
if (!this._userVerifier.hasPendingMessages && this._queryingService && !this._preemptiveAnswer)
|
2017-10-30 20:38:18 -04:00
|
|
|
this._fadeOutMessage();
|
2013-07-24 10:53:48 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
this._updateNextButtonSensitivity(this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING);
|
|
|
|
});
|
|
|
|
this._entry.clutter_text.connect('activate', () => {
|
2016-01-07 17:03:41 -05:00
|
|
|
if (this.nextButton.reactive)
|
|
|
|
this.emit('next');
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2013-07-23 20:37:42 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onAskQuestion(verifier, serviceName, question, passwordChar) {
|
2013-07-22 11:07:35 -04:00
|
|
|
if (this._queryingService)
|
|
|
|
this.clear();
|
|
|
|
|
|
|
|
this._queryingService = serviceName;
|
2015-04-07 15:53:42 -04:00
|
|
|
if (this._preemptiveAnswer) {
|
|
|
|
this._userVerifier.answerQuery(this._queryingService, this._preemptiveAnswer);
|
|
|
|
this._preemptiveAnswer = null;
|
|
|
|
return;
|
|
|
|
}
|
2013-07-22 11:07:35 -04:00
|
|
|
this.setPasswordChar(passwordChar);
|
|
|
|
this.setQuestion(question);
|
|
|
|
|
|
|
|
if (passwordChar) {
|
2013-07-22 10:59:57 -04:00
|
|
|
if (this._userVerifier.reauthenticating)
|
2013-07-22 11:07:35 -04:00
|
|
|
this.nextButton.label = _("Unlock");
|
2013-07-22 10:59:57 -04:00
|
|
|
else
|
2013-07-22 11:07:35 -04:00
|
|
|
this.nextButton.label = C_("button", "Sign In");
|
|
|
|
} else {
|
|
|
|
this.nextButton.label = _("Next");
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateSensitivity(true);
|
|
|
|
this.emit('prompted');
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onOVirtUserAuthenticated() {
|
2013-10-10 04:21:47 -04:00
|
|
|
if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onSmartcardStatusChanged() {
|
2013-06-27 08:54:19 -04:00
|
|
|
this.smartcardDetected = this._userVerifier.smartcardDetected;
|
|
|
|
|
|
|
|
// Most of the time we want to reset if the user inserts or removes
|
|
|
|
// a smartcard. Smartcard insertion "preempts" what the user was
|
|
|
|
// doing, and smartcard removal aborts the preemption.
|
|
|
|
// The exceptions are: 1) Don't reset on smartcard insertion if we're already verifying
|
|
|
|
// with a smartcard
|
|
|
|
// 2) Don't reset if we've already succeeded at verification and
|
|
|
|
// the user is getting logged in.
|
|
|
|
if (this._userVerifier.serviceIsDefault(GdmUtil.SMARTCARD_SERVICE_NAME) &&
|
|
|
|
this.verificationStatus == AuthPromptStatus.VERIFYING &&
|
|
|
|
this.smartcardDetected)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onShowMessage(userVerifier, message, type) {
|
2013-08-19 12:00:33 -04:00
|
|
|
this.setMessage(message, type);
|
2013-07-29 14:37:10 -04:00
|
|
|
this.emit('prompted');
|
2013-07-22 11:07:35 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onVerificationFailed() {
|
2013-09-18 14:23:53 -04:00
|
|
|
this._queryingService = null;
|
2013-07-22 11:07:35 -04:00
|
|
|
this.clear();
|
|
|
|
|
|
|
|
this.updateSensitivity(true);
|
|
|
|
this.setActorInDefaultButtonWell(null);
|
2013-07-28 16:24:31 -04:00
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFICATION_FAILED;
|
2013-07-22 11:07:35 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onVerificationComplete() {
|
2015-08-31 15:21:15 -04:00
|
|
|
this.setActorInDefaultButtonWell(null);
|
2013-07-28 16:24:31 -04:00
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFICATION_SUCCEEDED;
|
2017-06-29 19:16:11 -04:00
|
|
|
this.cancelButton.reactive = false;
|
2013-07-22 11:07:35 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onReset() {
|
2013-11-25 22:30:53 -05:00
|
|
|
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
|
|
|
|
this.reset();
|
2013-07-22 11:07:35 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
addActorToDefaultButtonWell(actor) {
|
2013-07-23 20:37:42 -04:00
|
|
|
this._defaultButtonWell.add_child(actor);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setActorInDefaultButtonWell(actor, animate) {
|
2013-07-23 20:37:42 -04:00
|
|
|
if (!this._defaultButtonWellActor &&
|
|
|
|
!actor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let oldActor = this._defaultButtonWellActor;
|
|
|
|
|
|
|
|
if (oldActor)
|
|
|
|
Tweener.removeTweens(oldActor);
|
|
|
|
|
2015-08-21 09:09:39 -04:00
|
|
|
let wasSpinner;
|
|
|
|
if (oldActor == this._spinner.actor)
|
|
|
|
wasSpinner = true;
|
|
|
|
else
|
|
|
|
wasSpinner = false;
|
|
|
|
|
2013-07-23 20:37:42 -04:00
|
|
|
let isSpinner;
|
|
|
|
if (actor == this._spinner.actor)
|
|
|
|
isSpinner = true;
|
|
|
|
else
|
|
|
|
isSpinner = false;
|
|
|
|
|
|
|
|
if (this._defaultButtonWellActor != actor && oldActor) {
|
|
|
|
if (!animate) {
|
|
|
|
oldActor.opacity = 0;
|
2015-08-21 09:09:39 -04:00
|
|
|
|
|
|
|
if (wasSpinner) {
|
|
|
|
if (this._spinner)
|
|
|
|
this._spinner.stop();
|
|
|
|
}
|
2013-07-23 20:37:42 -04:00
|
|
|
} else {
|
|
|
|
Tweener.addTween(oldActor,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: DEFAULT_BUTTON_WELL_ANIMATION_TIME,
|
|
|
|
delay: DEFAULT_BUTTON_WELL_ANIMATION_DELAY,
|
|
|
|
transition: 'linear',
|
|
|
|
onCompleteScope: this,
|
2017-10-30 20:03:21 -04:00
|
|
|
onComplete() {
|
2015-08-21 09:09:39 -04:00
|
|
|
if (wasSpinner) {
|
2013-07-23 20:37:42 -04:00
|
|
|
if (this._spinner)
|
|
|
|
this._spinner.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor) {
|
|
|
|
if (isSpinner)
|
|
|
|
this._spinner.play();
|
|
|
|
|
|
|
|
if (!animate)
|
|
|
|
actor.opacity = 255;
|
|
|
|
else
|
|
|
|
Tweener.addTween(actor,
|
|
|
|
{ opacity: 255,
|
|
|
|
time: DEFAULT_BUTTON_WELL_ANIMATION_TIME,
|
|
|
|
delay: DEFAULT_BUTTON_WELL_ANIMATION_DELAY,
|
|
|
|
transition: 'linear' });
|
|
|
|
}
|
|
|
|
|
|
|
|
this._defaultButtonWellActor = actor;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
startSpinning() {
|
2013-07-23 20:37:42 -04:00
|
|
|
this.setActorInDefaultButtonWell(this._spinner.actor, true);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
stopSpinning() {
|
2013-07-23 20:37:42 -04:00
|
|
|
this.setActorInDefaultButtonWell(null, false);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
clear() {
|
2013-07-23 20:37:42 -04:00
|
|
|
this._entry.text = '';
|
|
|
|
this.stopSpinning();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setPasswordChar(passwordChar) {
|
2013-07-23 20:37:42 -04:00
|
|
|
this._entry.clutter_text.set_password_char(passwordChar);
|
|
|
|
this._entry.menu.isPassword = passwordChar != '';
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setQuestion(question) {
|
2015-10-05 15:26:18 -04:00
|
|
|
if (this._preemptiveAnswerWatchId) {
|
|
|
|
this._idleMonitor.remove_watch(this._preemptiveAnswerWatchId);
|
|
|
|
this._preemptiveAnswerWatchId = 0;
|
|
|
|
}
|
|
|
|
|
2013-07-23 20:37:42 -04:00
|
|
|
this._label.set_text(question);
|
|
|
|
|
|
|
|
this._label.show();
|
|
|
|
this._entry.show();
|
|
|
|
|
|
|
|
this._entry.grab_key_focus();
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
getAnswer() {
|
2013-08-02 14:10:16 -04:00
|
|
|
let text;
|
|
|
|
|
|
|
|
if (this._preemptiveAnswer) {
|
|
|
|
text = this._preemptiveAnswer;
|
|
|
|
this._preemptiveAnswer = null;
|
|
|
|
} else {
|
|
|
|
text = this._entry.get_text();
|
|
|
|
}
|
2013-07-23 20:37:42 -04:00
|
|
|
|
|
|
|
return text;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_fadeOutMessage() {
|
2013-07-24 10:53:48 -04:00
|
|
|
if (this._message.opacity == 0)
|
|
|
|
return;
|
|
|
|
Tweener.removeTweens(this._message);
|
|
|
|
Tweener.addTween(this._message,
|
|
|
|
{ opacity: 0,
|
|
|
|
time: MESSAGE_FADE_OUT_ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad'
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setMessage(message, type) {
|
2013-08-27 10:17:26 -04:00
|
|
|
if (type == GdmUtil.MessageType.ERROR)
|
|
|
|
this._message.add_style_class_name('login-dialog-message-warning');
|
|
|
|
else
|
|
|
|
this._message.remove_style_class_name('login-dialog-message-warning');
|
2013-08-19 12:00:33 -04:00
|
|
|
|
2013-08-27 10:17:26 -04:00
|
|
|
if (type == GdmUtil.MessageType.HINT)
|
|
|
|
this._message.add_style_class_name('login-dialog-message-hint');
|
|
|
|
else
|
|
|
|
this._message.remove_style_class_name('login-dialog-message-hint');
|
2013-08-19 12:00:33 -04:00
|
|
|
|
2013-07-23 20:37:42 -04:00
|
|
|
if (message) {
|
2013-07-24 10:53:48 -04:00
|
|
|
Tweener.removeTweens(this._message);
|
2013-07-23 20:37:42 -04:00
|
|
|
this._message.text = message;
|
|
|
|
this._message.opacity = 255;
|
|
|
|
} else {
|
|
|
|
this._message.opacity = 0;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateNextButtonSensitivity(sensitive) {
|
2013-07-23 20:37:42 -04:00
|
|
|
this.nextButton.reactive = sensitive;
|
|
|
|
this.nextButton.can_focus = sensitive;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
updateSensitivity(sensitive) {
|
2017-06-14 10:05:36 -04:00
|
|
|
this._updateNextButtonSensitivity(sensitive && (this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING));
|
2013-07-23 20:37:42 -04:00
|
|
|
this._entry.reactive = sensitive;
|
|
|
|
this._entry.clutter_text.editable = sensitive;
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
hide() {
|
2013-07-23 20:37:42 -04:00
|
|
|
this.setActorInDefaultButtonWell(null, true);
|
|
|
|
this.actor.hide();
|
2013-08-19 12:00:33 -04:00
|
|
|
this._message.opacity = 0;
|
2013-07-23 20:37:42 -04:00
|
|
|
|
|
|
|
this.setUser(null);
|
|
|
|
|
|
|
|
this.updateSensitivity(true);
|
|
|
|
this._entry.set_text('');
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
setUser(user) {
|
2014-10-09 12:05:11 -04:00
|
|
|
let oldChild = this._userWell.get_child();
|
|
|
|
if (oldChild)
|
|
|
|
oldChild.destroy();
|
|
|
|
|
2013-07-23 20:37:42 -04:00
|
|
|
if (user) {
|
|
|
|
let userWidget = new UserWidget.UserWidget(user);
|
|
|
|
this._userWell.set_child(userWidget.actor);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-10-05 15:26:18 -04:00
|
|
|
_onUserStoppedTypePreemptiveAnswer() {
|
|
|
|
if (!this._preemptiveAnswerWatchId ||
|
|
|
|
this._preemptiveAnswer ||
|
|
|
|
this._queryingService)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._idleMonitor.remove_watch(this._preemptiveAnswerWatchId);
|
|
|
|
this._preemptiveAnswerWatchId = 0;
|
|
|
|
|
|
|
|
this._entry.text = '';
|
|
|
|
this.updateSensitivity(false);
|
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
reset() {
|
2013-07-29 08:46:37 -04:00
|
|
|
let oldStatus = this.verificationStatus;
|
2013-07-28 16:24:31 -04:00
|
|
|
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
|
2014-10-05 16:27:00 -04:00
|
|
|
this.cancelButton.reactive = true;
|
2015-07-17 12:57:21 -04:00
|
|
|
this.nextButton.label = _("Next");
|
2013-07-29 08:46:37 -04:00
|
|
|
|
2015-10-05 15:26:18 -04:00
|
|
|
if (this._preemptiveAnswerWatchId) {
|
|
|
|
this._idleMonitor.remove_watch(this._preemptiveAnswerWatchId);
|
|
|
|
}
|
|
|
|
this._preemptiveAnswerWatchId = this._idleMonitor.add_idle_watch (500,
|
|
|
|
this._onUserStoppedTypePreemptiveAnswer.bind(this));
|
|
|
|
|
2015-07-15 15:52:29 -04:00
|
|
|
if (this._userVerifier)
|
2013-07-29 08:46:37 -04:00
|
|
|
this._userVerifier.cancel();
|
|
|
|
|
2013-07-22 11:07:35 -04:00
|
|
|
this._queryingService = null;
|
|
|
|
this.clear();
|
2013-07-23 20:37:42 -04:00
|
|
|
this._message.opacity = 0;
|
|
|
|
this.setUser(null);
|
|
|
|
this.stopSpinning();
|
2013-07-22 11:07:35 -04:00
|
|
|
|
2013-07-28 16:06:04 -04:00
|
|
|
if (oldStatus == AuthPromptStatus.VERIFICATION_FAILED)
|
|
|
|
this.emit('failed');
|
|
|
|
|
2013-06-27 08:54:19 -04:00
|
|
|
let beginRequestType;
|
|
|
|
|
|
|
|
if (this._mode == AuthPromptMode.UNLOCK_ONLY) {
|
|
|
|
// The user is constant at the unlock screen, so it will immediately
|
|
|
|
// respond to the request with the username
|
|
|
|
beginRequestType = BeginRequestType.PROVIDE_USERNAME;
|
2013-10-10 04:21:47 -04:00
|
|
|
} else if (this._userVerifier.serviceIsForeground(GdmUtil.OVIRT_SERVICE_NAME) ||
|
2014-03-13 13:43:36 -04:00
|
|
|
this._userVerifier.serviceIsForeground(GdmUtil.SMARTCARD_SERVICE_NAME)) {
|
2013-06-27 08:54:19 -04:00
|
|
|
// We don't need to know the username if the user preempted the login screen
|
2013-10-10 04:21:47 -04:00
|
|
|
// with a smartcard or with preauthenticated oVirt credentials
|
2013-06-27 08:54:19 -04:00
|
|
|
beginRequestType = BeginRequestType.DONT_PROVIDE_USERNAME;
|
|
|
|
} else {
|
|
|
|
// In all other cases, we should get the username up front.
|
|
|
|
beginRequestType = BeginRequestType.PROVIDE_USERNAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.emit('reset', beginRequestType);
|
2013-07-23 20:37:42 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
addCharacter(unichar) {
|
2013-07-23 20:37:42 -04:00
|
|
|
if (!this._entry.visible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._entry.grab_key_focus();
|
|
|
|
this._entry.clutter_text.insert_unichar(unichar);
|
2013-07-22 11:07:35 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
begin(params) {
|
2013-07-22 11:07:35 -04:00
|
|
|
params = Params.parse(params, { userName: null,
|
|
|
|
hold: null });
|
|
|
|
|
|
|
|
this.updateSensitivity(false);
|
|
|
|
|
|
|
|
let hold = params.hold;
|
|
|
|
if (!hold)
|
|
|
|
hold = new Batch.Hold();
|
|
|
|
|
|
|
|
this._userVerifier.begin(params.userName, hold);
|
2013-07-28 16:24:31 -04:00
|
|
|
this.verificationStatus = AuthPromptStatus.VERIFYING;
|
2013-07-22 11:07:35 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
finish(onComplete) {
|
2013-07-22 11:07:35 -04:00
|
|
|
if (!this._userVerifier.hasPendingMessages) {
|
2015-08-03 14:07:17 -04:00
|
|
|
this._userVerifier.clear();
|
2013-07-22 11:07:35 -04:00
|
|
|
onComplete();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
let signalId = this._userVerifier.connect('no-more-messages', () => {
|
|
|
|
this._userVerifier.disconnect(signalId);
|
|
|
|
this._userVerifier.clear();
|
|
|
|
onComplete();
|
|
|
|
});
|
2013-07-22 11:07:35 -04:00
|
|
|
},
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
cancel() {
|
2015-07-23 13:17:54 -04:00
|
|
|
if (this.verificationStatus == AuthPromptStatus.VERIFICATION_SUCCEEDED) {
|
2014-10-05 16:27:00 -04:00
|
|
|
return;
|
|
|
|
}
|
2013-07-22 11:07:35 -04:00
|
|
|
this.reset();
|
2013-07-28 16:06:04 -04:00
|
|
|
this.emit('cancelled');
|
2013-07-23 20:37:42 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(AuthPrompt.prototype);
|