From f323d85fc3f5899426f029b934119a8875c914fc Mon Sep 17 00:00:00 2001 From: Alessandro Bono Date: Wed, 3 Aug 2022 15:43:51 +0200 Subject: [PATCH] screenShield: Add API to add/remove credential managers Extensions that provide a credential manager can (un)register themself so that the screen shield gets activated right after a user is authenticated. Part-of: --- js/ui/screenShield.js | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 2cae2732f..6c2fe25c2 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -94,12 +94,8 @@ var ScreenShield = class extends Signals.EventEmitter { this._activateDialog(); }); - this._oVirtCredentialsManager = OVirt.getOVirtCredentialsManager(); - this._oVirtCredentialsManager.connect('user-authenticated', - () => { - if (this._isLocked) - this._activateDialog(); - }); + this._credentialManagers = {}; + this.addCredentialManager(OVirt.SERVICE_NAME, OVirt.getOVirtCredentialsManager()); this._loginManager = LoginManager.getLoginManager(); this._loginManager.connect('prepare-for-sleep', @@ -641,6 +637,26 @@ var ScreenShield = class extends Signals.EventEmitter { // activate without animation in that case. } + addCredentialManager(serviceName, credentialManager) { + if (this._credentialManagers[serviceName]) + return; + + this._credentialManagers[serviceName] = credentialManager; + credentialManager.connectObject('user-authenticated', () => { + if (this._isLocked) + this._activateDialog(); + }, this); + } + + removeCredentialManager(serviceName) { + let credentialManager = this._credentialManagers[serviceName]; + if (!credentialManager) + return; + + credentialManager.disconnectObject(this); + delete this._credentialManagers[serviceName]; + } + lock(animate) { if (this._lockSettings.get_boolean(DISABLE_LOCK_KEY)) { log('Screen lock is locked down, not locking'); // lock, lock - who's there?