From c6d66d439b3c6aed17ff21e6c7c9a24ae9d8f1bf Mon Sep 17 00:00:00 2001 From: howard-stearns <howard.stearns@gmail.com> Date: Mon, 19 Jun 2017 12:57:26 -0700 Subject: [PATCH 1/4] report and quit command line switches --- interface/src/Application.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 9ce6cc9b25..1e1095c85a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -439,6 +439,32 @@ static const QString STATE_NAV_FOCUSED = "NavigationFocused"; bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { const char** constArgv = const_cast<const char**>(argv); + + // HRS: I could not figure out how to move these any earlier in startup, so when using this option, be sure to also supply + // --allowMultipleInstances + auto reportAndQuit = [&](const char* commandSwitch, std::function<void(FILE* fp)> report) { + const char* reportfile = getCmdOption(argc, constArgv, commandSwitch); + // Reports to the specified file, because stdout is set up to be captured for logging. + if (reportfile) { + FILE* fp = fopen(reportfile, "w"); + if (fp) { + report(fp); + fclose(fp); + _exit(0); + } + } + }; + reportAndQuit("--protocolVersion", [&](FILE* fp) { + DependencyManager::set<AddressManager>(); + auto version = DependencyManager::get<AddressManager>()->protocolVersion(); + fputs(version.toLatin1().data(), fp); + }); + reportAndQuit("--installationPortal", [&](FILE* fp) { + auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); + bool isSteam = steamClient && steamClient->init(); + fputs(isSteam ? "steam" : "download", fp); + }); + const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); const int listenPort = portStr ? atoi(portStr) : INVALID_PORT; From d71666f33744931344b936c1f0b30079e9f88c6f Mon Sep 17 00:00:00 2001 From: howard-stearns <howard.stearns@gmail.com> Date: Tue, 20 Jun 2017 09:59:15 -0700 Subject: [PATCH 2/4] Remove useless command line arg for steam, but add one for version. --- interface/src/Application.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a4d28b6055..6b958b08c1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -462,10 +462,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { auto version = DependencyManager::get<AddressManager>()->protocolVersion(); fputs(version.toLatin1().data(), fp); }); - reportAndQuit("--installationPortal", [&](FILE* fp) { - auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); - bool isSteam = steamClient && steamClient->init(); - fputs(isSteam ? "steam" : "download", fp); + reportAndQuit("--version", [&](FILE* fp) { + fputs(BuildInfo::VERSION.toLatin1().data(), fp); }); const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); From 480ff784b9230f74638a5c7d7d7b4591b5201571 Mon Sep 17 00:00:00 2001 From: howard-stearns <howard.stearns@gmail.com> Date: Tue, 20 Jun 2017 13:25:03 -0700 Subject: [PATCH 3/4] add a skipTutorial option, that does not change settings --- interface/src/Application.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6b958b08c1..ad49a82770 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2503,8 +2503,11 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { Setting::Handle<bool> tutorialComplete{ "tutorialComplete", false }; Setting::Handle<bool> 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; + bool shouldGoToTutorial = isUsingHMDAndHandControllers && hasTutorialContent && !isTutorialComplete && !skipTutorial; qCDebug(interfaceapp) << "HMD:" << hasHMD << ", Hand Controllers: " << hasHandControllers << ", Using HMD: " << isUsingHMDAndHandControllers; qCDebug(interfaceapp) << "Tutorial version:" << contentVersion << ", sufficient:" << hasTutorialContent << @@ -2547,14 +2550,9 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { } } else { - bool isFirstRun = firstRun.get(); - - if (isFirstRun) { - showHelp(); - } - // If this is a first run we short-circuit the address passed in - if (isFirstRun) { + if (firstRun.get() && !skipTutorial) { + showHelp(); if (isUsingHMDAndHandControllers) { if (sandboxIsRunning) { qCDebug(interfaceapp) << "Home sandbox appears to be running, going to Home."; @@ -2592,7 +2590,9 @@ void Application::handleSandboxStatus(QNetworkReply* reply) { _connectionMonitor.init(); // After all of the constructor is completed, then set firstRun to false. - firstRun.set(false); + if (!skipTutorial) { + firstRun.set(false); + } } bool Application::importJSONFromURL(const QString& urlString) { From fea8a95fc7ab9f8e4c09313f5d72b167d928bcd9 Mon Sep 17 00:00:00 2001 From: Howard Stearns <howard@highfidelity.io> Date: Tue, 20 Jun 2017 18:09:27 -0700 Subject: [PATCH 4/4] Don't leave running markers around if they weren't there before and we quit after reporting (protocol)version. --- interface/src/Application.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 34b599654e..d5f769f9a0 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -453,6 +453,10 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { if (fp) { report(fp); fclose(fp); + if (!runningMarkerExisted) { // don't leave ours around + RunningMarker runingMarker(RUNNING_MARKER_FILENAME); + runingMarker.deleteRunningMarkerFile(); // happens in deleter, but making the side-effect explicit. + } _exit(0); } }