continue flow implementation
This commit is contained in:
parent
5cf58a78e5
commit
101e77cc14
|
@ -1,5 +1,6 @@
|
|||
import NimQml, chronicles, std/wrapnils
|
||||
import status/[signals, status, keycard]
|
||||
import types/keycard as keycardtypes
|
||||
import view, pairing
|
||||
|
||||
logScope:
|
||||
|
@ -29,11 +30,25 @@ proc attemptOpenSecureChannel(self: KeycardController) : bool =
|
|||
if pairing == "":
|
||||
return false
|
||||
|
||||
# actually open secure channel
|
||||
discard """let err = self.status.keycard.openSecureChannel(pairing)
|
||||
|
||||
if err == Ok:
|
||||
return true
|
||||
|
||||
self.view.pairings.removePairing(self.view.appInfo.instanceUID)
|
||||
|
||||
""""
|
||||
return false
|
||||
|
||||
proc getCardState(self: KeycardController) =
|
||||
let appInfo = self.status.keycard.select()
|
||||
var appInfo: KeycardApplicationInfo
|
||||
|
||||
try:
|
||||
appInfo = self.status.keycard.select()
|
||||
except KeycardSelectException as ex:
|
||||
self.view.cardUnhandledError(ex.error)
|
||||
return
|
||||
|
||||
self.view.appInfo = appInfo
|
||||
|
||||
if not appInfo.installed:
|
||||
|
@ -43,7 +58,16 @@ proc getCardState(self: KeycardController) =
|
|||
self.view.cardState = PreInit
|
||||
self.view.cardPreInit()
|
||||
elif self.attemptOpenSecureChannel():
|
||||
# here we will also be able to check if the card is Frozen/Blocked
|
||||
discard """
|
||||
self.view.appStatus = self.status.keycard.getStatusApplication()
|
||||
if self.view.appStatus.pukRetryCounter == 0:
|
||||
self.view.cardState = Blocked
|
||||
self.view.cardBlocked()
|
||||
elif self.view.appStatus.pinRetryCounter == 0:
|
||||
self.view.cardState = Frozen
|
||||
self.view.cardFrozen()
|
||||
else:
|
||||
"""
|
||||
self.view.cardState = Paired
|
||||
self.view.cardPaired()
|
||||
elif appInfo.availableSlots > 0:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import NimQml, chronicles
|
||||
import status/[status, keycard]
|
||||
import status/types/keycard as keycardtypes
|
||||
import types/keycard as keycardtypes
|
||||
import pairing
|
||||
|
||||
logScope:
|
||||
|
@ -47,18 +47,47 @@ QtObject:
|
|||
proc cardFrozen*(self: KeycardView) {.signal.}
|
||||
proc cardBlocked*(self: KeycardView) {.signal.}
|
||||
proc cardAuthenticated*(self: KeycardView) {.signal.}
|
||||
proc cardUnhandledError*(self: KeycardView, error: string) {.signal.}
|
||||
|
||||
proc startConnection*(self: KeycardView) {.slot.} =
|
||||
discard self.status.keycard.start()
|
||||
try:
|
||||
self.status.keycard.start()
|
||||
except KeycardStartException as ex:
|
||||
self.cardUnhandledError(ex.error)
|
||||
|
||||
|
||||
proc stopConnection*(self: KeycardView) {.slot.} =
|
||||
self.cardState = Disconnected
|
||||
discard self.status.keycard.stop()
|
||||
try:
|
||||
self.status.keycard.stop()
|
||||
except KeycardStopException as ex:
|
||||
self.cardUnhandledError(ex.error)
|
||||
|
||||
proc pair*(self: KeycardView, password: string) {.slot.} =
|
||||
discard """
|
||||
on succesful pairing, save and change card state
|
||||
otherwise throw error
|
||||
let pairing = self.status.keycard.pair(password)
|
||||
|
||||
self.status.keycard.pair(password)
|
||||
if pairing == "":
|
||||
error
|
||||
|
||||
self.pairings.addPairing(self.appInfo.instanceUID, pairing)
|
||||
self.cardState = Paired
|
||||
self.cardPaired()
|
||||
"""
|
||||
|
||||
proc authenticate*(self: KeycardView, pin: string) {.slot.} =
|
||||
discard """
|
||||
let resp = self.status.keycard.verifyPIN(pin)
|
||||
if resp is error:
|
||||
handle error
|
||||
|
||||
self.cardAuthenticated()
|
||||
"""
|
||||
|
||||
proc init*(self: KeycardView, pin: string) {.slot.} =
|
||||
discard """
|
||||
"""
|
||||
|
||||
proc recoverAccount*(self: KeycardView) {.slot.} =
|
||||
discard """
|
||||
"""
|
|
@ -2,10 +2,16 @@ import QtQuick 2.13
|
|||
import "./Keycard"
|
||||
import "../shared/keycard"
|
||||
|
||||
// this will be the entry point. for now it opens all keycard-related dialogs in sequence for test
|
||||
Item {
|
||||
enum OnboardingFlow {
|
||||
Recover,
|
||||
Generate,
|
||||
ImportMnemonic
|
||||
}
|
||||
|
||||
property var onClosed: function () {}
|
||||
property bool connected: false
|
||||
property int flow: OnboardingFlow.Recover
|
||||
|
||||
id: keycardView
|
||||
anchors.fill: parent
|
||||
|
@ -17,9 +23,11 @@ Item {
|
|||
CreatePINModal {
|
||||
id: createPinModal
|
||||
onClosed: function () {
|
||||
if (!createPinModal.submitted) {
|
||||
keycardView.onClosed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PairingModal {
|
||||
id: pairingModal
|
||||
|
@ -33,9 +41,11 @@ Item {
|
|||
PINModal {
|
||||
id: pinModal
|
||||
onClosed: function () {
|
||||
if (!pinModal.submitted) {
|
||||
keycardView.onClosed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InsertCard {
|
||||
id: insertCard
|
||||
|
@ -54,13 +64,28 @@ Item {
|
|||
}
|
||||
|
||||
onCardPaired: {
|
||||
pinModal.open()
|
||||
}
|
||||
|
||||
onCardAuthenticated: {
|
||||
switch (flow) {
|
||||
case OnboardingFlow.Recover: {
|
||||
keycardModel.recoverAccount();
|
||||
break;
|
||||
}
|
||||
case OnboardingFlow.Generate: {
|
||||
break;
|
||||
}
|
||||
case OnboardingFlow.ImportMnemonic: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: support the states below
|
||||
|
||||
onCardPreInit: {
|
||||
keycardView.onClosed()
|
||||
createPinModal.open()
|
||||
}
|
||||
|
||||
onCardFrozen: {
|
||||
|
@ -76,14 +101,11 @@ Item {
|
|||
// later add factory reset option for the NoFreeSlots case
|
||||
|
||||
onCardNoFreeSlots: {
|
||||
//status-lib currently always returns availableSlots = 0 so we end up here
|
||||
//keycardView.onClosed()
|
||||
pairingModal.open()
|
||||
keycardView.onClosed()
|
||||
}
|
||||
|
||||
onCardNotKeycard: {
|
||||
keycardView.onClosed()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,12 +11,14 @@ ModalPopup {
|
|||
property bool repeatPINFieldValid: false
|
||||
property string pinValidationError: ""
|
||||
property string repeatPINValidationError: ""
|
||||
property bool submitted: false
|
||||
|
||||
id: popup
|
||||
title: qsTr("Create PIN")
|
||||
height: 500
|
||||
|
||||
onOpened: {
|
||||
submitted = false
|
||||
firstPINField.text = "";
|
||||
firstPINField.forceActiveFocus(Qt.MouseFocusReason)
|
||||
}
|
||||
|
@ -102,6 +104,9 @@ ModalPopup {
|
|||
enabled: firstPINFieldValid && repeatPINFieldValid
|
||||
|
||||
onClicked: {
|
||||
submitted = true
|
||||
keycardModel.init(firstPINField.text)
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,14 @@ import "../../shared"
|
|||
|
||||
ModalPopup {
|
||||
property bool pinFieldValid: false
|
||||
property bool submitted: false
|
||||
|
||||
id: popup
|
||||
title: qsTr("Authenticate PIN")
|
||||
height: 400
|
||||
|
||||
onOpened: {
|
||||
submitted = false
|
||||
pinField.text = "";
|
||||
pinField.forceActiveFocus(Qt.MouseFocusReason)
|
||||
}
|
||||
|
@ -58,7 +60,9 @@ ModalPopup {
|
|||
enabled: pinFieldValid
|
||||
|
||||
onClicked: {
|
||||
|
||||
submitted = true
|
||||
keycardModel.authenticate(pinField.text)
|
||||
popup.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ ModalPopup {
|
|||
height: 400
|
||||
|
||||
onOpened: {
|
||||
submitted = false
|
||||
pairingPasswordField.text = "";
|
||||
pairingPasswordField.forceActiveFocus(Qt.MouseFocusReason)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue