Files
fedora-tools/plasma-always-show-unlock/FedoraToolsFingerprintRetry.qml
T

68 lines
1.7 KiB
QML

// SPDX-License-Identifier: MIT
import QtQml
Timer {
id: retry
required property QtObject auth
required property int fingerprintType
property bool enabled: true
readonly property bool fingerprintActive: (auth.authenticatorTypes & fingerprintType) !== 0
property bool sawInfo: false
property bool sawError: false
interval: 6000
function reset() {
stop();
sawInfo = false;
sawError = false;
}
onEnabledChanged: {
if (!enabled) {
reset();
}
}
onFingerprintActiveChanged: {
if (fingerprintActive) {
reset();
} else if (enabled && sawInfo && !sawError) {
// An idle conversation ended. Consume the retry until another
// conversation actually supplies fingerprint instructions.
sawInfo = false;
restart();
}
}
onTriggered: {
if (enabled && !fingerprintActive) {
auth.startAuthenticating();
}
}
property Connections authenticationSignals: Connections {
target: retry.auth
function onNoninteractiveInfo(kind, source) {
if (retry.enabled && (kind & retry.fingerprintType)) {
retry.sawInfo = true;
}
}
function onNoninteractiveError(kind, source) {
if (kind & retry.fingerprintType) {
// Do not automatically replenish failed scan attempts.
retry.sawError = true;
retry.stop();
}
}
function onFailed(kind, source) {
if (kind === 0) {
retry.reset();
}
}
function onSucceeded() {
retry.reset();
}
}
}