2019-09-09 15:12:58 +03:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import "utils.js" as Utils
|
|
|
|
|
|
|
|
StackView {
|
2019-10-04 14:09:35 +03:00
|
|
|
property bool isShowingAbout
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
function clearAndPush(view) {
|
2020-06-15 10:10:33 +03:00
|
|
|
clear();
|
|
|
|
push(view, StackView.Immediate);
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function goToSettings() {
|
2020-06-15 10:10:33 +03:00
|
|
|
if (currentItem.objectName !== "settingsView")
|
|
|
|
push(settingsView, StackView.Immediate);
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function goToLoading() {
|
2020-06-15 10:10:33 +03:00
|
|
|
if (currentItem.objectName !== "loadingView")
|
|
|
|
push(loadingView, StackView.Immediate);
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function goToEnterPasswordIfNotInSettings() {
|
2020-06-15 10:10:33 +03:00
|
|
|
if (currentItem.objectName !== "enterPasswordView" && currentItem.objectName !== "settingsView")
|
|
|
|
clearAndPush(enterPasswordView, StackView.Immediate);
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function home() {
|
|
|
|
if (!!yubiKey.currentDevice) {
|
|
|
|
// If locked, prompt for password
|
2020-06-15 10:10:33 +03:00
|
|
|
if (!!yubiKey.currentDevice && yubiKey.currentDevice.hasPassword && !yubiKey.currentDeviceValidated) {
|
|
|
|
clearAndPush(enterPasswordView);
|
|
|
|
return ;
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
navigator.goToCredentials();
|
2019-09-09 15:12:58 +03:00
|
|
|
} else {
|
2020-06-15 10:10:33 +03:00
|
|
|
clearAndPush(credentialsView);
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function goToCredentials(force) {
|
2020-06-15 10:10:33 +03:00
|
|
|
if (currentItem.objectName !== "credentialsView")
|
|
|
|
clearAndPush(credentialsView);
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function goToCredentialsIfNotInSettings() {
|
2020-06-15 10:10:33 +03:00
|
|
|
if (currentItem.objectName !== "credentialsView" && currentItem.objectName !== "settingsView")
|
|
|
|
clearAndPush(credentialsView);
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
2020-05-13 15:08:30 +03:00
|
|
|
function goToNewCredential(credential) {
|
2020-06-15 10:10:33 +03:00
|
|
|
if (currentItem.objectName !== "newCredentialView")
|
2019-09-09 15:12:58 +03:00
|
|
|
push(newCredentialView.createObject(app, {
|
2020-06-15 10:10:33 +03:00
|
|
|
"credential": credential
|
|
|
|
}), StackView.Immediate);
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
2019-11-05 18:43:17 +03:00
|
|
|
function confirm(options) {
|
2020-06-15 10:10:33 +03:00
|
|
|
var popup = confirmationPopup.createObject(app, options);
|
|
|
|
popup.open();
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function about() {
|
2019-10-04 14:09:35 +03:00
|
|
|
if (!isShowingAbout) {
|
2020-06-15 10:10:33 +03:00
|
|
|
var popup = aboutPopup.createObject(app);
|
|
|
|
popup.open();
|
2019-10-04 14:09:35 +03:00
|
|
|
}
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function snackBar(message) {
|
|
|
|
var sb = snackBarComponent.createObject(app, {
|
2020-06-15 10:10:33 +03:00
|
|
|
"message": message
|
|
|
|
});
|
|
|
|
sb.open();
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function snackBarError(message) {
|
|
|
|
var sbe = snackBarErrorComponent.createObject(app, {
|
2020-06-15 10:10:33 +03:00
|
|
|
"message": message
|
|
|
|
});
|
|
|
|
sbe.open();
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getErrorMessage(error_id) {
|
|
|
|
switch (error_id) {
|
2020-06-15 10:10:33 +03:00
|
|
|
case "no_credential_found":
|
|
|
|
return qsTr("No QR code found on screen");
|
|
|
|
case "incorrect_padding":
|
|
|
|
return qsTr("Secret key have the wrong format");
|
|
|
|
case "validate_failed":
|
|
|
|
return qsTr("Wrong password");
|
|
|
|
case "no_space":
|
|
|
|
return qsTr("No space available");
|
|
|
|
case "no_current_device":
|
|
|
|
return qsTr("No YubiKey found");
|
|
|
|
case "open_device_failed":
|
|
|
|
return qsTr("Failed to connect to YubiKey");
|
|
|
|
case "ccid_error":
|
|
|
|
return qsTr("Failed to connect to YubiKey");
|
|
|
|
case "timeout":
|
|
|
|
return qsTr("Failed to read from slots");
|
|
|
|
case "failed_to_parse_uri":
|
|
|
|
return qsTr("Failed to read credential from QR code");
|
|
|
|
case "no_pcscd":
|
|
|
|
return qsTr("Is the pcscd/smart card service running?");
|
|
|
|
case "no_device_custom_reader":
|
|
|
|
return qsTr("No device found");
|
2019-09-09 15:12:58 +03:00
|
|
|
default:
|
2020-06-15 10:10:33 +03:00
|
|
|
return qsTr("Unknown error");
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-15 10:10:33 +03:00
|
|
|
initialItem: credentialsView
|
|
|
|
onCurrentItemChanged: {
|
|
|
|
if (currentItem)
|
|
|
|
currentItem.forceActiveFocus();
|
|
|
|
|
|
|
|
}
|
|
|
|
Accessible.ignored: true
|
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
Component {
|
|
|
|
id: credentialsView
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
CredentialsView {
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: settingsView
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
SettingsView {
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: newCredentialView
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
NewCredentialView {
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: enterPasswordView
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
EnterPasswordView {
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: loadingView
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
LoadingView {
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: confirmationPopup
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
ConfirmationPopup {
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: aboutPopup
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
AboutPopup {
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: snackBarComponent
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
SnackBar {
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: snackBarErrorComponent
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
SnackBar {
|
|
|
|
buttonColor: yubicoRed
|
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|
2020-06-15 10:10:33 +03:00
|
|
|
|
2019-09-09 15:12:58 +03:00
|
|
|
}
|