diff options
Diffstat (limited to 'wizard')
| -rw-r--r-- | wizard/WizardController.qml | 65 | ||||
| -rw-r--r-- | wizard/WizardCreateDevice1.qml | 19 |
2 files changed, 72 insertions, 12 deletions
diff --git a/wizard/WizardController.qml b/wizard/WizardController.qml index 4224e904..e380aed9 100644 --- a/wizard/WizardController.qml +++ b/wizard/WizardController.qml @@ -44,6 +44,7 @@ Rectangle { anchors.fill: parent signal useMoneroClicked() + signal walletCreatedFromDevice(bool success) function restart() { wizardStateView.state = "wizardHome" @@ -65,6 +66,7 @@ Rectangle { wizardController.walletRestoreMode = 'seed' wizardController.walletOptionsSubaddressLookahead = ''; wizardController.remoteNodes = {}; + disconnect(); } property var m_wallet; @@ -366,6 +368,28 @@ Rectangle { return success; } + function disconnect(){ + walletManager.walletCreated.disconnect(onWalletCreated); + walletManager.walletPassphraseNeeded.disconnect(onWalletPassphraseNeeded); + walletManager.deviceButtonRequest.disconnect(onDeviceButtonRequest); + walletManager.deviceButtonPressed.disconnect(onDeviceButtonPressed); + } + + function connect(){ + walletManager.walletCreated.connect(onWalletCreated); + walletManager.walletPassphraseNeeded.connect(onWalletPassphraseNeeded); + walletManager.deviceButtonRequest.connect(onDeviceButtonRequest); + walletManager.deviceButtonPressed.connect(onDeviceButtonPressed); + } + + function deviceAttentionSplash(){ + appWindow.showProcessingSplash(qsTr("Please proceed to the device...")); + } + + function creatingWalletDeviceSplash(){ + appWindow.showProcessingSplash(qsTr("Creating wallet from device...")); + } + function createWalletFromDevice() { // TODO: create wallet in temporary filename and a) move it to the path specified by user after the final // page submitted or b) delete it when program closed before reaching final page @@ -376,30 +400,61 @@ Rectangle { console.log("deleting wallet") } - var tmp_wallet_filename = oshelper.temporaryFilename(); - console.log("Creating temporary wallet", tmp_wallet_filename) + tmpWalletFilename = oshelper.temporaryFilename(); + console.log("Creating temporary wallet", tmpWalletFilename) var nettype = persistentSettings.nettype; var restoreHeight = wizardController.walletOptionsRestoreHeight; var subaddressLookahead = wizardController.walletOptionsSubaddressLookahead; var deviceName = wizardController.walletOptionsDeviceName; - var wallet = walletManager.createWalletFromDevice(tmp_wallet_filename, "", nettype, deviceName, restoreHeight, subaddressLookahead); + connect(); + walletManager.createWalletFromDeviceAsync(tmpWalletFilename, "", nettype, deviceName, restoreHeight, subaddressLookahead); + creatingWalletDeviceSplash(); + } + + function onWalletCreated(wallet) { + splash.close() var success = wallet.status === Wallet.Status_Ok; if (success) { wizardController.m_wallet = wallet; wizardController.walletOptionsIsRecoveringFromDevice = true; - wizardController.tmpWalletFilename = tmp_wallet_filename; if (!wizardController.walletOptionsDeviceIsRestore) { // User creates a hardware wallet for the first time. Use a recent block height from API. wizardController.walletOptionsRestoreHeight = wizardController.m_wallet.walletCreationHeight; } } else { console.log(wallet.errorString) + wizardController.tmpWalletFilename = ''; appWindow.showStatusMessage(qsTr(wallet.errorString), 5); walletManager.closeWallet(); } - return success; + + disconnect(); + walletCreatedFromDevice(success); + } + + function onWalletPassphraseNeeded(){ + splash.close() + + console.log(">>> wallet passphrase needed: "); + passphraseDialog.onAcceptedCallback = function() { + walletManager.onPassphraseEntered(passphraseDialog.passphrase); + creatingWalletDeviceSplash(); + } + passphraseDialog.onRejectedCallback = function() { + walletManager.onPassphraseEntered("", true); + creatingWalletDeviceSplash(); + } + passphraseDialog.open() + } + + function onDeviceButtonRequest(code){ + deviceAttentionSplash(); + } + + function onDeviceButtonPressed(){ + creatingWalletDeviceSplash(); } function openWallet(){ diff --git a/wizard/WizardCreateDevice1.qml b/wizard/WizardCreateDevice1.qml index 9ad2ca33..81130aa1 100644 --- a/wizard/WizardCreateDevice1.qml +++ b/wizard/WizardCreateDevice1.qml @@ -207,13 +207,9 @@ Rectangle { } wizardController.walletOptionsRestoreHeight = _restoreHeight; } - var written = wizardController.createWalletFromDevice(); - if(written){ - wizardController.walletOptionsIsRecoveringFromDevice = true; - wizardStateView.state = "wizardCreateWallet2"; - } else { - errorMsg.text = qsTr("Error writing wallet from hardware device. Check application logs.") + translationManager.emptyString; - } + + wizardController.walletCreatedFromDevice.connect(onCreateWalletFromDeviceCompleted); + wizardController.createWalletFromDevice(); } } } @@ -230,4 +226,13 @@ Rectangle { walletInput.reset(); } } + + function onCreateWalletFromDeviceCompleted(written){ + if(written){ + wizardStateView.state = "wizardCreateWallet2"; + } else { + errorMsg.text = qsTr("Error writing wallet from hardware device. Check application logs.") + translationManager.emptyString; + } + wizardController.walletCreatedFromDevice.disconnect(onCreateWalletFromDeviceCompleted); + } } |
