diff --git a/src/app/modules/onboarding/controller.nim b/src/app/modules/onboarding/controller.nim index 5efb332c2f0..71676fb1f89 100644 --- a/src/app/modules/onboarding/controller.nim +++ b/src/app/modules/onboarding/controller.nim @@ -272,3 +272,6 @@ proc storeMetadataAsync*(self: Controller, name: string, paths: seq[string]) = proc asyncImportLocalBackupFile*(self: Controller, filePath: string) = self.generalService.asyncImportLocalBackupFile(filePath) + +proc startKeycardDetection*(self: Controller) = + self.keycardServiceV2.startDetection() \ No newline at end of file diff --git a/src/app/modules/onboarding/io_interface.nim b/src/app/modules/onboarding/io_interface.nim index 7e696a4cea4..3e5a759ca85 100644 --- a/src/app/modules/onboarding/io_interface.nim +++ b/src/app/modules/onboarding/io_interface.nim @@ -109,6 +109,9 @@ method requestDeleteBiometrics*(self: AccessInterface, account: string) {.base.} method requestLocalBackup*(self: AccessInterface, backupImportFileUrl: string) {.base.} = raise newException(ValueError, "No implementation available") +method startKeycardDetection*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + # This way (using concepts) is used only for the modules managed by AppController type DelegateInterface* = concept c diff --git a/src/app/modules/onboarding/module.nim b/src/app/modules/onboarding/module.nim index 7a73964944e..397937f144f 100644 --- a/src/app/modules/onboarding/module.nim +++ b/src/app/modules/onboarding/module.nim @@ -446,6 +446,9 @@ method requestLocalBackup*[T](self: Module[T], backupImportFileUrl: string) = method requestDeleteBiometrics*[T](self: Module[T], account: string) = self.view.deleteBiometricsRequested(account) +method startKeycardDetection*[T](self: Module[T]) = + self.controller.startKeycardDetection() + proc runPostLoginTasks*[T](self: Module[T]) = let tasks = self.postLoginTasks for task in tasks: diff --git a/src/app/modules/onboarding/view.nim b/src/app/modules/onboarding/view.nim index 3dd161aeccf..380d9b17811 100644 --- a/src/app/modules/onboarding/view.nim +++ b/src/app/modules/onboarding/view.nim @@ -195,6 +195,9 @@ QtObject: proc startKeycardFactoryReset(self: View) {.slot.} = self.delegate.startKeycardFactoryReset() + proc startKeycardDetection(self: View) {.slot.} = + self.delegate.startKeycardDetection() + proc delete*(self: View) = self.QObject.delete diff --git a/src/app_service/service/keycardV2/service.nim b/src/app_service/service/keycardV2/service.nim index ad764b6f475..9454190be4a 100644 --- a/src/app_service/service/keycardV2/service.nim +++ b/src/app_service/service/keycardV2/service.nim @@ -262,6 +262,9 @@ QtObject: except Exception as e: error "error storing metadata", err=e.msg + proc startDetection*(self: Service) {.featureGuard(KEYCARD_ENABLED).} = + self.asyncStart(status_const.KEYCARDPAIRINGDATAFILE) + proc delete*(self: Service) = self.QObject.delete diff --git a/ui/app/AppLayouts/Onboarding/OnboardingFlow.qml b/ui/app/AppLayouts/Onboarding/OnboardingFlow.qml index 81231830580..c5db6a8a355 100644 --- a/ui/app/AppLayouts/Onboarding/OnboardingFlow.qml +++ b/ui/app/AppLayouts/Onboarding/OnboardingFlow.qml @@ -72,6 +72,7 @@ OnboardingStackView { signal linkActivated(string link) signal finished(int flow) + signal keycardRequested() // Thirdparty services required property bool privacyModeFeatureEnabled @@ -239,7 +240,7 @@ OnboardingStackView { onUnblockWithSeedphraseRequested: root.push(unblockWithSeedphraseFlow) onUnblockWithPukRequested: root.push(unblockWithPukFlow) - + onKeycardRequested: root.keycardRequested() onVisibleChanged: { if (!visible) root.dismissBiometricsRequested() @@ -277,7 +278,10 @@ OnboardingStackView { root.push(useRecoveryPhraseFlow, { type: UseRecoveryPhraseFlow.Type.NewProfile }) } - onCreateProfileWithEmptyKeycardRequested: root.push(keycardCreateProfileFlow) + onCreateProfileWithEmptyKeycardRequested: { + root.keycardRequested() + root.push(keycardCreateProfileFlow) + } } } @@ -290,7 +294,10 @@ OnboardingStackView { thirdpartyServicesEnabled: root.thirdpartyServicesEnabled onLoginWithSyncingRequested: root.push(logInBySyncingFlow) - onLoginWithKeycardRequested: root.push(loginWithKeycardFlow) + onLoginWithKeycardRequested: { + root.keycardRequested() + root.push(loginWithKeycardFlow) + } onLoginWithSeedphraseRequested: { d.flow = Onboarding.OnboardingFlow.LoginWithSeedphrase diff --git a/ui/app/AppLayouts/Onboarding/OnboardingLayout.qml b/ui/app/AppLayouts/Onboarding/OnboardingLayout.qml index 3b8075f6812..07d3567a3ff 100644 --- a/ui/app/AppLayouts/Onboarding/OnboardingLayout.qml +++ b/ui/app/AppLayouts/Onboarding/OnboardingLayout.qml @@ -200,6 +200,7 @@ Page { onExportKeysRequested: root.onboardingStore.exportRecoverKeys() onImportLocalBackupRequested: (importFilePath) => d.backupImportFileUrl = importFilePath onFinished: (flow) => d.finishFlow(flow) + onKeycardRequested: root.onboardingStore.startKeycardDetection() onBiometricsRequested: (profileId) => { const isKeycardProfile = SQUtils.ModelUtils.getByKey( diff --git a/ui/app/AppLayouts/Onboarding/pages/LoginScreen.qml b/ui/app/AppLayouts/Onboarding/pages/LoginScreen.qml index 9c355b87ae0..c0dda72dcba 100644 --- a/ui/app/AppLayouts/Onboarding/pages/LoginScreen.qml +++ b/ui/app/AppLayouts/Onboarding/pages/LoginScreen.qml @@ -91,6 +91,7 @@ OnboardingPage { signal unblockWithSeedphraseRequested() signal unblockWithPukRequested() signal lostKeycardFlowRequested() + signal keycardRequested() QtObject { id: d @@ -104,6 +105,12 @@ OnboardingPage { readonly property int loginModelCount: root.loginAccountsModel.ModelCount.count onLoginModelCountChanged: setSelectedLoginUser() + onCurrentProfileIsKeycardChanged: { + if (d.currentProfileIsKeycard) { + root.keycardRequested() + } + } + function setSelectedLoginUser() { if (loginModelCount > 0) { loginUserSelector.setSelection(d.settings.lastKeyUid) diff --git a/ui/app/AppLayouts/Onboarding/stores/OnboardingStore.qml b/ui/app/AppLayouts/Onboarding/stores/OnboardingStore.qml index c07a8d5c1e9..c2811116322 100644 --- a/ui/app/AppLayouts/Onboarding/stores/OnboardingStore.qml +++ b/ui/app/AppLayouts/Onboarding/stores/OnboardingStore.qml @@ -35,6 +35,10 @@ QtObject { readonly property int keycardRemainingPinAttempts: d.onboardingModuleInst.keycardRemainingPinAttempts readonly property int keycardRemainingPukAttempts: d.onboardingModuleInst.keycardRemainingPukAttempts + function startKeycardDetection() { + d.onboardingModuleInst.startKeycardDetection() + } + function finishOnboardingFlow(flow: int, data: Object) { // -> string return d.onboardingModuleInst.finishOnboardingFlow(flow, JSON.stringify(data)) }