gdm: Expose the source serviceName for messages and verification failures

By giving to the AuthPrompt information regarding the source service
name (and so the ability to know whether it's a foreground service) can
give it the ability to behave differently.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1652>
This commit is contained in:
Marco Trevisan (Treviño) 2021-02-01 19:36:49 +01:00 committed by Ray Strode
parent 6ccd289691
commit 526f0711f1
2 changed files with 16 additions and 14 deletions

View File

@ -273,12 +273,12 @@ var AuthPrompt = GObject.registerClass({
this.reset(); this.reset();
} }
_onShowMessage(userVerifier, message, type) { _onShowMessage(_userVerifier, serviceName, message, type) {
this.setMessage(message, type); this.setMessage(serviceName, message, type);
this.emit('prompted'); this.emit('prompted');
} }
_onVerificationFailed(userVerifier, canRetry) { _onVerificationFailed(userVerifier, serviceName, canRetry) {
this._queryingService = null; this._queryingService = null;
this.clear(); this.clear();
@ -410,7 +410,7 @@ var AuthPrompt = GObject.registerClass({
}); });
} }
setMessage(message, type) { setMessage(serviceName, message, type) {
if (type == GdmUtil.MessageType.ERROR) if (type == GdmUtil.MessageType.ERROR)
this._message.add_style_class_name('login-dialog-message-warning'); this._message.add_style_class_name('login-dialog-message-warning');
else else

View File

@ -296,7 +296,7 @@ var ShellUserVerifier = class {
let message = this._messageQueue.shift(); let message = this._messageQueue.shift();
this.emit('show-message', message.text, message.type); this.emit('show-message', message.serviceName, message.text, message.type);
this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
message.interval, message.interval,
@ -308,11 +308,11 @@ var ShellUserVerifier = class {
GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout'); GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout');
} }
_queueMessage(message, messageType) { _queueMessage(serviceName, message, messageType) {
let interval = this._getIntervalForMessage(message); let interval = this._getIntervalForMessage(message);
this.hasPendingMessages = true; this.hasPendingMessages = true;
this._messageQueue.push({ text: message, type: messageType, interval }); this._messageQueue.push({ serviceName, text: message, type: messageType, interval });
this._queueMessageTimeout(); this._queueMessageTimeout();
} }
@ -323,7 +323,7 @@ var ShellUserVerifier = class {
GLib.source_remove(this._messageQueueTimeoutId); GLib.source_remove(this._messageQueueTimeoutId);
this._messageQueueTimeoutId = 0; this._messageQueueTimeoutId = 0;
} }
this.emit('show-message', null, MessageType.NONE); this.emit('show-message', null, null, MessageType.NONE);
} }
_checkForFingerprintReader() { _checkForFingerprintReader() {
@ -383,7 +383,7 @@ var ShellUserVerifier = class {
logError(error, where); logError(error, where);
this._hold.release(); this._hold.release();
this._queueMessage(_("Authentication error"), MessageType.ERROR); this._queueMessage(serviceName, _('Authentication error'), MessageType.ERROR);
this._failCounter++; this._failCounter++;
this._verificationFailed(serviceName, false); this._verificationFailed(serviceName, false);
} }
@ -532,7 +532,7 @@ var ShellUserVerifier = class {
_onInfo(client, serviceName, info) { _onInfo(client, serviceName, info) {
if (this.serviceIsForeground(serviceName)) { if (this.serviceIsForeground(serviceName)) {
this._queueMessage(info, MessageType.INFO); this._queueMessage(serviceName, info, MessageType.INFO);
} else if (this.serviceIsFingerprint(serviceName)) { } else if (this.serviceIsFingerprint(serviceName)) {
// We don't show fingerprint messages directly since it's // We don't show fingerprint messages directly since it's
// not the main auth service. Instead we use the messages // not the main auth service. Instead we use the messages
@ -540,11 +540,13 @@ var ShellUserVerifier = class {
if (this._fingerprintReaderType === FingerprintReaderType.SWIPE) { if (this._fingerprintReaderType === FingerprintReaderType.SWIPE) {
// Translators: this message is shown below the password entry field // Translators: this message is shown below the password entry field
// to indicate the user can swipe their finger on the fingerprint reader // to indicate the user can swipe their finger on the fingerprint reader
this._queueMessage(_('(or swipe finger across reader)'), MessageType.HINT); this._queueMessage(serviceName, _('(or swipe finger across reader)'),
MessageType.HINT);
} else { } else {
// Translators: this message is shown below the password entry field // Translators: this message is shown below the password entry field
// to indicate the user can place their finger on the fingerprint reader instead // to indicate the user can place their finger on the fingerprint reader instead
this._queueMessage(_('(or place finger on reader)'), MessageType.HINT); this._queueMessage(serviceName, _('(or place finger on reader)'),
MessageType.HINT);
} }
} }
} }
@ -555,7 +557,7 @@ var ShellUserVerifier = class {
if (!this.serviceIsForeground(serviceName) && !isFingerprint) if (!this.serviceIsForeground(serviceName) && !isFingerprint)
return; return;
this._queueMessage(problem, MessageType.ERROR); this._queueMessage(serviceName, problem, MessageType.ERROR);
if (isFingerprint) { if (isFingerprint) {
this._failCounter++; this._failCounter++;
@ -650,7 +652,7 @@ var ShellUserVerifier = class {
} }
} }
this.emit('verification-failed', canRetry); this.emit('verification-failed', serviceName, canRetry);
} }
_onConversationStopped(client, serviceName) { _onConversationStopped(client, serviceName) {