From 1a610db4318ca9b3d3d06297818dce5c9cd45ede Mon Sep 17 00:00:00 2001 From: Jaquee Date: Tue, 29 Nov 2016 17:06:06 +0100 Subject: [PATCH 1/2] add isWindows property --- main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index fe42cb61..d5efc639 100644 --- a/main.cpp +++ b/main.cpp @@ -110,12 +110,14 @@ int main(int argc, char *argv[]) // to save the wallet file (.keys, .bin), they have to be user-accessible for // backups - I reckon we save that in My Documents\Monero Accounts\ on // Windows, ~/Monero Accounts/ on nix / osx - + bool isWindows = false; #ifdef Q_OS_WIN + isWindows = true; QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); #elif defined(Q_OS_UNIX) QStringList moneroAccountsRootDir = QStandardPaths::standardLocations(QStandardPaths::HomeLocation); #endif + engine.rootContext()->setContextProperty("isWindows", isWindows); if (!moneroAccountsRootDir.empty()) { QString moneroAccountsDir = moneroAccountsRootDir.at(0) + "/Monero/wallets"; From abd5c685af26a1ca44a2437f69f3aa011564298a Mon Sep 17 00:00:00 2001 From: Jaquee Date: Tue, 29 Nov 2016 17:14:11 +0100 Subject: [PATCH 2/2] Windows: don't allow non-ascii characters in path --- wizard/WizardCreateWallet.qml | 2 +- wizard/WizardMain.qml | 31 ++++++++++++++++++++++++------- wizard/WizardRecoveryWallet.qml | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/wizard/WizardCreateWallet.qml b/wizard/WizardCreateWallet.qml index bef91bc2..11d91e24 100644 --- a/wizard/WizardCreateWallet.qml +++ b/wizard/WizardCreateWallet.qml @@ -55,7 +55,7 @@ Item { settingsObject['words'] = uiItem.wordsTexttext settingsObject['wallet_path'] = uiItem.walletPath var walletFullPath = wizard.createWalletPath(uiItem.walletPath,uiItem.accountNameText); - return !wizard.walletExists(walletFullPath); + return wizard.walletPathValid(walletFullPath); } function checkNextButton() { diff --git a/wizard/WizardMain.qml b/wizard/WizardMain.qml index 446d7720..16fb0d23 100644 --- a/wizard/WizardMain.qml +++ b/wizard/WizardMain.qml @@ -141,12 +141,30 @@ Rectangle { return folder_path + "/" + account_name + "/" + account_name } - function walletExists(path){ - if(walletManager.walletExists(path)){ - walletExistsErrorDialog.open(); - return true; + function walletPathValid(path){ + if (walletManager.walletExists(path)) { + walletErrorDialog.text = qsTr("A wallet with same name already exists. Please change wallet name") + translationManager.emptyString; + walletErrorDialog.open(); + return false; } - return false; + + // Don't allow non ascii characters in path on windows platforms until supported by Wallet2 + if (isWindows) { + if (!isAscii(path)) { + walletErrorDialog.text = qsTr("Non-ASCII characters are not allowed in wallet path or account name") + translationManager.emptyString; + walletErrorDialog.open(); + return false; + } + } + return true; + } + + function isAscii(str){ + for (var i = 0; i < str.length; i++) { + if (str.charCodeAt(i) > 127) + return false; + } + return true; } //! actually writes the wallet @@ -197,9 +215,8 @@ Rectangle { } MessageDialog { - id: walletExistsErrorDialog + id: walletErrorDialog title: "Error" - text: qsTr("A wallet with same name already exists. Please change wallet name") + translationManager.emptyString onAccepted: { } } diff --git a/wizard/WizardRecoveryWallet.qml b/wizard/WizardRecoveryWallet.qml index 236c59a1..55f61475 100644 --- a/wizard/WizardRecoveryWallet.qml +++ b/wizard/WizardRecoveryWallet.qml @@ -59,7 +59,7 @@ Item { var restoreHeight = parseInt(uiItem.restoreHeight); settingsObject['restore_height'] = isNaN(restoreHeight)? 0 : restoreHeight var walletFullPath = wizard.createWalletPath(uiItem.walletPath,uiItem.accountNameText); - if(wizard.walletExists(walletFullPath)){ + if(!wizard.walletPathValid(walletFullPath)){ return false } return recoveryWallet(settingsObject)