Warning, /plasma/plasma-mobile/look-and-feel/contents/lockscreen/LockScreenState.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 import QtQml 2.15
0005 import QtQuick 2.15
0006 
0007 QtObject {
0008     id: root
0009     
0010     // current password being typed
0011     property string password: ""
0012     
0013     // whether waiting for authentication after trying password
0014     property bool waitingForAuth: false
0015     
0016     // the info message given
0017     property string info: ""
0018     
0019     // whether the lockscreen was passwordless
0020     property bool passwordless: true
0021     
0022     signal reset()
0023     signal unlockSucceeded()
0024     signal unlockFailed()
0025     
0026     function tryPassword() {
0027         if (root.password !== '') { // prevent typing lock when password is empty
0028             waitingForAuth = true;
0029         }
0030         connections.hasPrompt = true;
0031         authenticator.tryUnlock();
0032     }
0033     
0034     function resetPassword() {
0035         password = "";
0036         root.reset();
0037     }
0038     
0039     Component.onCompleted: {
0040         // determine whether we have passwordless login
0041         // if we do, authenticator will emit a success signal, otherwise it will emit failure
0042         authenticator.tryUnlock();
0043     }
0044     
0045     property var connections: Connections {
0046         target: authenticator
0047         
0048         // false for our test of whether we have passwordless login, otherwise it's true
0049         property bool hasPrompt: false
0050         
0051         function onSucceeded() {
0052             if (hasPrompt) {
0053                 console.log('login succeeded');
0054                 root.waitingForAuth = false;
0055                 root.unlockSucceeded();
0056                 Qt.quit();
0057             }
0058         }
0059         
0060         function onFailed() {
0061             root.passwordless = false;
0062             if (hasPrompt) {
0063                 console.log('login failed');
0064                 root.waitingForAuth = false;
0065                 root.password = "";
0066                 root.unlockFailed();
0067             }
0068         }
0069         
0070         function onInfoMessage(msg) {
0071             console.log('info: ' + msg);
0072             root.info += msg + " ";
0073         }
0074         
0075         // TODO
0076         function onErrorMessage(msg) {
0077             console.log('error: ' + msg);
0078         }
0079         
0080         // TODO
0081         function onPrompt(msg) {
0082             console.log('prompt: ' + msg);
0083         }
0084         
0085         function onPromptForSecret(msg) {
0086             console.log('prompt secret: ' + msg);
0087             authenticator.respond(root.password);
0088             authenticator.tryUnlock();
0089         }
0090         
0091     }
0092 }