From 59fe5ffdc12acb2d2f7fee14c16344ca5f0f9ce1 Mon Sep 17 00:00:00 2001 From: Liv Date: Fri, 25 Aug 2017 17:48:35 -0700 Subject: [PATCH 1/8] Initial attempt at changing first run behavior --- interface/src/Application.cpp | 50 +++-------------------------------- 1 file changed, 3 insertions(+), 47 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index affbf83081..20d7509ea5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2755,26 +2755,18 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { handControllerType = Oculus; } - // Check tutorial content versioning - bool hasTutorialContent = contentVersion >= MIN_CONTENT_VERSION.at(handControllerType); - // Check HMD use (may be technically available without being in use) bool hasHMD = PluginUtils::isHMDAvailable(); bool isUsingHMD = _displayPlugin->isHmd(); bool isUsingHMDAndHandControllers = hasHMD && hasHandControllers && isUsingHMD; - Setting::Handle tutorialComplete{ "tutorialComplete", false }; Setting::Handle firstRun{ Settings::firstRun, true }; const QString HIFI_SKIP_TUTORIAL_COMMAND_LINE_KEY = "--skipTutorial"; // Skips tutorial/help behavior, and does NOT clear firstRun setting. bool skipTutorial = arguments().contains(HIFI_SKIP_TUTORIAL_COMMAND_LINE_KEY); - bool isTutorialComplete = tutorialComplete.get(); - bool shouldGoToTutorial = isUsingHMDAndHandControllers && hasTutorialContent && !isTutorialComplete && !skipTutorial; qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMDAndHandControllers; - qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << - ", complete:" << isTutorialComplete << ", should go:" << shouldGoToTutorial; // when --url in command line, teleport to location const QString HIFI_URL_COMMAND_LINE_KEY = "--url"; @@ -2784,39 +2776,15 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { addressLookupString = arguments().value(urlIndex + 1); } - const QString TUTORIAL_PATH = "/tutorial_begin"; - - static const QString SENT_TO_TUTORIAL = "tutorial"; static const QString SENT_TO_PREVIOUS_LOCATION = "previous_location"; static const QString SENT_TO_ENTRY = "entry"; static const QString SENT_TO_SANDBOX = "sandbox"; QString sentTo; - if (shouldGoToTutorial) { - if (sandboxIsRunning) { - qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; - DependencyManager::get()->goToLocalSandbox(TUTORIAL_PATH); - sentTo = SENT_TO_TUTORIAL; - } else { - qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; - if (firstRun.get()) { - showHelp(); - } - if (addressLookupString.isEmpty()) { - DependencyManager::get()->goToEntry(); - sentTo = SENT_TO_ENTRY; - } else { - DependencyManager::get()->loadSettings(addressLookupString); - sentTo = SENT_TO_PREVIOUS_LOCATION; - } - } - } else { - // If this is a first run we short-circuit the address passed in - if (firstRun.get() && !skipTutorial) { + if (firstRun.get()) { showHelp(); - if (isUsingHMDAndHandControllers) { if (sandboxIsRunning) { qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; DependencyManager::get()->goToLocalSandbox(); @@ -2826,16 +2794,12 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { DependencyManager::get()->goToEntry(); sentTo = SENT_TO_ENTRY; } - } else { - DependencyManager::get()->goToEntry(); - sentTo = SENT_TO_ENTRY; - } + } else { qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString); DependencyManager::get()->loadSettings(addressLookupString); sentTo = SENT_TO_PREVIOUS_LOCATION; } - } UserActivityLogger::getInstance().logAction("startup_sent_to", { { "sent_to", sentTo }, @@ -2844,18 +2808,10 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { { "has_hand_controllers", hasHandControllers }, { "is_using_hmd", isUsingHMD }, { "is_using_hmd_and_hand_controllers", isUsingHMDAndHandControllers }, - { "content_version", contentVersion }, - { "is_tutorial_complete", isTutorialComplete }, - { "has_tutorial_content", hasTutorialContent }, - { "should_go_to_tutorial", shouldGoToTutorial } + { "content_version", contentVersion } }); _connectionMonitor.init(); - - // After all of the constructor is completed, then set firstRun to false. - if (!skipTutorial) { - firstRun.set(false); - } } bool Application::importJSONFromURL(const QString& urlString) { From 59deccaeb5db0479b44c5f83e1687dc2b809bb7e Mon Sep 17 00:00:00 2001 From: Liv Date: Tue, 29 Aug 2017 14:55:59 -0700 Subject: [PATCH 2/8] Remove unused skipTutorial code --- interface/src/Application.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 20d7509ea5..db28516cb0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2762,10 +2762,6 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { Setting::Handle firstRun{ Settings::firstRun, true }; - const QString HIFI_SKIP_TUTORIAL_COMMAND_LINE_KEY = "--skipTutorial"; - // Skips tutorial/help behavior, and does NOT clear firstRun setting. - bool skipTutorial = arguments().contains(HIFI_SKIP_TUTORIAL_COMMAND_LINE_KEY); - qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMDAndHandControllers; // when --url in command line, teleport to location From 2f2b406047cf34aef208bf2a0e07b6a4e840eaa6 Mon Sep 17 00:00:00 2001 From: Liv Date: Wed, 30 Aug 2017 09:23:33 -0700 Subject: [PATCH 3/8] Remove unneeded handcontrollertype code from handle first run checks --- interface/src/Application.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index db28516cb0..233aa4fe81 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2746,13 +2746,8 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { // Get controller availability bool hasHandControllers = false; - HandControllerType handControllerType = Vive; - if (PluginUtils::isViveControllerAvailable()) { + if (PluginUtils::isViveControllerAvailable() || PluginUtils::isOculusTouchControllerAvailable()) { hasHandControllers = true; - handControllerType = Vive; - } else if (PluginUtils::isOculusTouchControllerAvailable()) { - hasHandControllers = true; - handControllerType = Oculus; } // Check HMD use (may be technically available without being in use) From b5faa8ac567518aac7af91211263f52fb56ec337 Mon Sep 17 00:00:00 2001 From: beholder Date: Sat, 2 Sep 2017 18:20:00 +0300 Subject: [PATCH 4/8] 7382 Create Menu does not Work on Tablet --- interface/resources/qml/hifi/tablet/TabletButton.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/tablet/TabletButton.qml b/interface/resources/qml/hifi/tablet/TabletButton.qml index a45390b3d0..58091d9fab 100644 --- a/interface/resources/qml/hifi/tablet/TabletButton.qml +++ b/interface/resources/qml/hifi/tablet/TabletButton.qml @@ -3,6 +3,8 @@ import QtGraphicalEffects 1.0 Item { id: tabletButton + + property string captionColorOverride: "" property var uuid; property string icon: "icons/tablet-icons/edit-i.svg" property string hoverIcon: tabletButton.icon @@ -102,7 +104,7 @@ Item { Text { id: text - color: "#ffffff" + color: captionColorOverride !== "" ? captionColorOverride: "#ffffff" text: tabletButton.text font.bold: true font.pixelSize: 18 From 350cee5f35d471575509d9b0e314d48de87c6c36 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 5 Sep 2017 16:33:16 -0700 Subject: [PATCH 5/8] Wallet cleanup --- .../commerce/wallet/WalletSetupLightbox.qml | 2 +- interface/src/commerce/QmlCommerce.cpp | 8 ++++- interface/src/commerce/QmlCommerce.h | 2 +- interface/src/commerce/Wallet.cpp | 34 ++++--------------- interface/src/commerce/Wallet.h | 1 - 5 files changed, 15 insertions(+), 32 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/wallet/WalletSetupLightbox.qml b/interface/resources/qml/hifi/commerce/wallet/WalletSetupLightbox.qml index 2956dfb518..a623c2bcf7 100644 --- a/interface/resources/qml/hifi/commerce/wallet/WalletSetupLightbox.qml +++ b/interface/resources/qml/hifi/commerce/wallet/WalletSetupLightbox.qml @@ -325,7 +325,7 @@ Rectangle { onClicked: { if (passphraseSelection.validateAndSubmitPassphrase()) { root.lastPage = "choosePassphrase"; - commerce.balance(); // Do this here so that keys are generated. Order might change as backend changes? + commerce.generateKeyPair(); choosePassphraseContainer.visible = false; privateKeysReadyContainer.visible = true; } diff --git a/interface/src/commerce/QmlCommerce.cpp b/interface/src/commerce/QmlCommerce.cpp index 96f2a02f31..8681fcba50 100644 --- a/interface/src/commerce/QmlCommerce.cpp +++ b/interface/src/commerce/QmlCommerce.cpp @@ -86,7 +86,7 @@ void QmlCommerce::history() { void QmlCommerce::setPassphrase(const QString& passphrase) { auto wallet = DependencyManager::get(); - if (wallet->getPassphrase() && !wallet->getPassphrase()->isEmpty()) { + if(wallet->getPassphrase() && !wallet->getPassphrase()->isEmpty() && !passphrase.isEmpty()) { wallet->changePassphrase(passphrase); } else { wallet->setPassphrase(passphrase); @@ -94,6 +94,12 @@ void QmlCommerce::setPassphrase(const QString& passphrase) { getWalletAuthenticatedStatus(); } +void QmlCommerce::generateKeyPair() { + auto wallet = DependencyManager::get(); + wallet->generateKeyPair(); + getWalletAuthenticatedStatus(); +} + void QmlCommerce::reset() { auto ledger = DependencyManager::get(); auto wallet = DependencyManager::get(); diff --git a/interface/src/commerce/QmlCommerce.h b/interface/src/commerce/QmlCommerce.h index f66bf518f5..7d9317efae 100644 --- a/interface/src/commerce/QmlCommerce.h +++ b/interface/src/commerce/QmlCommerce.h @@ -53,7 +53,7 @@ protected: Q_INVOKABLE void balance(); Q_INVOKABLE void inventory(); Q_INVOKABLE void history(); - + Q_INVOKABLE void generateKeyPair(); Q_INVOKABLE void reset(); }; diff --git a/interface/src/commerce/Wallet.cpp b/interface/src/commerce/Wallet.cpp index 69327b09a6..8bdb8305d5 100644 --- a/interface/src/commerce/Wallet.cpp +++ b/interface/src/commerce/Wallet.cpp @@ -245,6 +245,8 @@ RSA* readPrivateKey(const char* filename) { } else { qCDebug(commerce) << "couldn't parse" << filename; + // if the passphrase is wrong, then let's not cache it + DependencyManager::get()->setPassphrase(""); } fclose(fp); } else { @@ -273,8 +275,6 @@ void Wallet::setPassphrase(const QString& passphrase) { } _passphrase = new QString(passphrase); - // no matter what, we now need to clear the keys as they - // need to be read using this passphrase _publicKeys.clear(); } @@ -413,28 +413,10 @@ bool Wallet::walletIsAuthenticatedWithPassphrase() { return false; } -bool Wallet::createIfNeeded() { - if (_publicKeys.count() > 0) return false; - +bool Wallet::generateKeyPair() { // FIXME: initialize OpenSSL elsewhere soon initialize(); - // try to read existing keys if they exist... - auto publicKey = readPublicKey(keyFilePath().toStdString().c_str()); - if (publicKey.size() > 0) { - if (auto key = readPrivateKey(keyFilePath().toStdString().c_str()) ) { - qCDebug(commerce) << "read private key"; - RSA_free(key); - // K -- add the public key since we have a legit private key associated with it - _publicKeys.push_back(publicKey.toBase64()); - return false; - } - } - qCInfo(commerce) << "Creating wallet."; - return generateKeyPair(); -} - -bool Wallet::generateKeyPair() { qCInfo(commerce) << "Generating keypair."; auto keyPair = generateRSAKeypair(); sendKeyFilePathIfExists(); @@ -453,7 +435,6 @@ bool Wallet::generateKeyPair() { QStringList Wallet::listPublicKeys() { qCInfo(commerce) << "Enumerating public keys."; - createIfNeeded(); return _publicKeys; } @@ -572,12 +553,8 @@ void Wallet::reset() { // tell the provider we got nothing updateImageProvider(); - delete _passphrase; + _passphrase->clear(); - // for now we need to maintain the hard-coded passphrase. - // FIXME: remove this line as part of wiring up the passphrase - // and probably set it to nullptr - _passphrase = new QString("pwd"); QFile keyFile(keyFilePath()); QFile imageFile(imageFilePath()); @@ -608,6 +585,7 @@ bool Wallet::changePassphrase(const QString& newPassphrase) { return false; } } - qCDebug(commerce) << "couldn't read keys"; + qCDebug(commerce) << "couldn't decrypt keys with current passphrase, clearing"; + setPassphrase(QString("")); return false; } diff --git a/interface/src/commerce/Wallet.h b/interface/src/commerce/Wallet.h index 3b470210de..f72b7adc41 100644 --- a/interface/src/commerce/Wallet.h +++ b/interface/src/commerce/Wallet.h @@ -26,7 +26,6 @@ public: ~Wallet(); // These are currently blocking calls, although they might take a moment. - bool createIfNeeded(); bool generateKeyPair(); QStringList listPublicKeys(); QString signWithKey(const QByteArray& text, const QString& key); From 1fd30b1e0fffa5fd26ce6b599efcab8d11a8196a Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 5 Sep 2017 17:03:11 -0700 Subject: [PATCH 6/8] fix passphrase reset --- interface/resources/qml/hifi/commerce/wallet/Help.qml | 1 + interface/resources/qml/hifi/commerce/wallet/Wallet.qml | 2 +- scripts/system/commerce/wallet.js | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/wallet/Help.qml b/interface/resources/qml/hifi/commerce/wallet/Help.qml index 402209f38d..19273298b6 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Help.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Help.qml @@ -55,6 +55,7 @@ Item { text: "DEBUG: Clear Cached Passphrase"; onClicked: { commerce.setPassphrase(""); + sendSignalToWallet({method: 'passphraseReset'}); } } HifiControlsUit.Button { diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index 4fcfc0c93b..169060887a 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -318,7 +318,7 @@ Rectangle { Connections { onSendSignalToWallet: { - if (msg.method === 'walletReset') { + if (msg.method === 'walletReset' || msg.method == 'passphraseReset') { sendToScript(msg); } } diff --git a/scripts/system/commerce/wallet.js b/scripts/system/commerce/wallet.js index 5f07c4cbe7..5a668a3d6e 100644 --- a/scripts/system/commerce/wallet.js +++ b/scripts/system/commerce/wallet.js @@ -71,6 +71,10 @@ case 'maybeEnableHmdPreview': Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled); break; + case 'passphraseReset': + onButtonClicked(); + onButtonClicked(); + break; case 'walletReset': onButtonClicked(); onButtonClicked(); From 89cda8d3062b7bcdee55b793f467551f40d4b6e9 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 5 Sep 2017 17:15:25 -0700 Subject: [PATCH 7/8] oops -- === not == --- interface/resources/qml/hifi/commerce/wallet/Wallet.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml index 169060887a..401ef89374 100644 --- a/interface/resources/qml/hifi/commerce/wallet/Wallet.qml +++ b/interface/resources/qml/hifi/commerce/wallet/Wallet.qml @@ -318,7 +318,7 @@ Rectangle { Connections { onSendSignalToWallet: { - if (msg.method === 'walletReset' || msg.method == 'passphraseReset') { + if (msg.method === 'walletReset' || msg.method === 'passphraseReset') { sendToScript(msg); } } From 930243539cd01d1f6d3c210fdca95a309793c7a4 Mon Sep 17 00:00:00 2001 From: Liv Date: Tue, 5 Sep 2017 17:50:25 -0700 Subject: [PATCH 8/8] add back first run to false and fix formatting --- interface/src/Application.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 233aa4fe81..79fb2a9061 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2776,15 +2776,16 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { // If this is a first run we short-circuit the address passed in if (firstRun.get()) { showHelp(); - if (sandboxIsRunning) { - qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; - DependencyManager::get()->goToLocalSandbox(); - sentTo = SENT_TO_SANDBOX; - } else { - qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; - DependencyManager::get()->goToEntry(); - sentTo = SENT_TO_ENTRY; - } + if (sandboxIsRunning) { + qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; + DependencyManager::get()->goToLocalSandbox(); + sentTo = SENT_TO_SANDBOX; + } else { + qCDebug(interfaceapp) << "Home sandbox does not appear to be running, going to Entry."; + DependencyManager::get()->goToEntry(); + sentTo = SENT_TO_ENTRY; + } + firstRun.set(false); } else { qCDebug(interfaceapp) << "Not first run... going to" << qPrintable(addressLookupString.isEmpty() ? QString("previous location") : addressLookupString);