Streamlined handling with single parameter source.

This commit is contained in:
Penguin-Guru 2021-10-26 11:58:54 -07:00
parent dd75c14dba
commit e1d79c7b59
3 changed files with 149 additions and 136 deletions

View file

@ -26,7 +26,6 @@
#include <QtCore/QResource> #include <QtCore/QResource>
#include <QtCore/QAbstractNativeEventFilter> #include <QtCore/QAbstractNativeEventFilter>
#include <QtCore/QCommandLineParser>
#include <QtCore/QMimeData> #include <QtCore/QMimeData>
#include <QtCore/QThreadPool> #include <QtCore/QThreadPool>
#include <QtCore/QFileSelector> #include <QtCore/QFileSelector>
@ -724,12 +723,9 @@ extern DisplayPluginList getDisplayPlugins();
extern InputPluginList getInputPlugins(); extern InputPluginList getInputPlugins();
extern void saveInputPluginSettings(const InputPluginList& plugins); extern void saveInputPluginSettings(const InputPluginList& plugins);
// Parameters used for running tests from teh command line // Parameters used for running tests from the command line
const QString TEST_SCRIPT_COMMAND{ "--testScript" };
const QString TEST_QUIT_WHEN_FINISHED_OPTION{ "quitWhenFinished" };
const QString TEST_RESULTS_LOCATION_COMMAND{ "--testResultsLocation" };
bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { bool setupEssentials(int& argc, char** argv, const QCommandLineParser* parser, bool runningMarkerExisted) {
const char** constArgv = const_cast<const char**>(argv); const char** constArgv = const_cast<const char**>(argv);
qInstallMessageHandler(messageHandler); qInstallMessageHandler(messageHandler);
@ -737,6 +733,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
// HRS: I could not figure out how to move these any earlier in startup, so when using this option, be sure to also supply // 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 // --allowMultipleInstances
auto reportAndQuit = [&](const char* commandSwitch, std::function<void(FILE* fp)> report) { auto reportAndQuit = [&](const char* commandSwitch, std::function<void(FILE* fp)> report) {
// Do something about this:
const char* reportfile = getCmdOption(argc, constArgv, commandSwitch); const char* reportfile = getCmdOption(argc, constArgv, commandSwitch);
// Reports to the specified file, because stdout is set up to be captured for logging. // Reports to the specified file, because stdout is set up to be captured for logging.
if (reportfile) { if (reportfile) {
@ -755,36 +752,23 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
reportAndQuit("--protocolVersion", [&](FILE* fp) { reportAndQuit("--protocolVersion", [&](FILE* fp) {
auto version = protocolVersionsSignatureBase64(); auto version = protocolVersionsSignatureBase64();
fputs(version.toLatin1().data(), fp); fputs(version.toLatin1().data(), fp);
}); }); // This doesn't seem to work.
reportAndQuit("--version", [&](FILE* fp) { /*reportAndQuit("--version", [&](FILE* fp) {
fputs(BuildInfo::VERSION.toLatin1().data(), fp); fputs(BuildInfo::VERSION.toLatin1().data(), fp);
}); });*/
const char* portStr = getCmdOption(argc, constArgv, "--listenPort"); const int listenPort = parser->isSet("listenPort") ? parser->value("listenPort").toInt() : INVALID_PORT;
const int listenPort = portStr ? atoi(portStr) : INVALID_PORT;
static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset"; bool suppressPrompt = parser->isSet("suppress-settings-reset");
bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);
// set the OCULUS_STORE property so the oculus plugin can know if we ran from the Oculus Store // set the OCULUS_STORE property so the oculus plugin can know if we ran from the Oculus Store
static const auto OCULUS_STORE_ARG = "--oculus-store"; qApp->setProperty(hifi::properties::OCULUS_STORE, parser->isSet("oculus-store"));
bool isStore = cmdOptionExists(argc, const_cast<const char**>(argv), OCULUS_STORE_ARG);
qApp->setProperty(hifi::properties::OCULUS_STORE, isStore);
// emulate standalone device // emulate standalone device
static const auto STANDALONE_ARG = "--standalone"; qApp->setProperty(hifi::properties::STANDALONE, parser->isSet("standalone"));
bool isStandalone = cmdOptionExists(argc, const_cast<const char**>(argv), STANDALONE_ARG);
qApp->setProperty(hifi::properties::STANDALONE, isStandalone);
// Ignore any previous crashes if running from command line with a test script. // Ignore any previous crashes if running from command line with a test script.
bool inTestMode { false }; bool inTestMode = parser->isSet("testScript");
for (int i = 0; i < argc; ++i) {
QString parameter(argv[i]);
if (parameter == TEST_SCRIPT_COMMAND) {
inTestMode = true;
break;
}
}
bool previousSessionCrashed { false }; bool previousSessionCrashed { false };
if (!inTestMode) { if (!inTestMode) {
@ -792,10 +776,8 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
} }
// get dir to use for cache // get dir to use for cache
static const auto CACHE_SWITCH = "--cache"; if (parser->isSet("cache")) {
QString cacheDir = getCmdOption(argc, const_cast<const char**>(argv), CACHE_SWITCH); qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, parser->value("cache"));
if (!cacheDir.isEmpty()) {
qApp->setProperty(hifi::properties::APP_LOCAL_DATA_PATH, cacheDir);
} }
{ {
@ -837,7 +819,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
QCoreApplication::addLibraryPath(audioDLLPath); QCoreApplication::addLibraryPath(audioDLLPath);
#endif #endif
QString defaultScriptsOverrideOption = getCmdOption(argc, constArgv, "--defaultScriptsOverride"); QString defaultScriptsOverrideOption = parser->value("defaultScriptsOverride");
DependencyManager::registerInheritance<LimitedNodeList, NodeList>(); DependencyManager::registerInheritance<LimitedNodeList, NodeList>();
DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>(); DependencyManager::registerInheritance<AvatarHashMap, AvatarManager>();
@ -963,7 +945,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
}); });
QString setBookmarkValue = getCmdOption(argc, constArgv, "--setBookmark"); QString setBookmarkValue = parser->value("setBookmark");
if (!setBookmarkValue.isEmpty()) { if (!setBookmarkValue.isEmpty()) {
// Bookmarks are expected to be in a name=url form. // Bookmarks are expected to be in a name=url form.
// An `=` character in the name or url is unsupported. // An `=` character in the name or url is unsupported.
@ -1020,14 +1002,19 @@ QSharedPointer<OffscreenUi> getOffscreenUI() {
#endif #endif
} }
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runningMarkerExisted) : Application::Application(
int& argc, char** argv,
const QCommandLineParser* parser,
QElapsedTimer& startupTimer,
bool runningMarkerExisted
) :
QApplication(argc, argv), QApplication(argc, argv),
_window(new MainWindow(desktop())), _window(new MainWindow(desktop())),
_sessionRunTimer(startupTimer), _sessionRunTimer(startupTimer),
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
_logger(new FileLogger(this)), _logger(new FileLogger(this)),
#endif #endif
_previousSessionCrashed(setupEssentials(argc, argv, runningMarkerExisted)), _previousSessionCrashed(setupEssentials(argc, argv, parser, runningMarkerExisted)),
_entitySimulation(std::make_shared<PhysicalEntitySimulation>()), _entitySimulation(std::make_shared<PhysicalEntitySimulation>()),
_physicsEngine(std::make_shared<PhysicsEngine>(Vectors::ZERO)), _physicsEngine(std::make_shared<PhysicsEngine>(Vectors::ZERO)),
_entityClipboard(std::make_shared<EntityTree>()), _entityClipboard(std::make_shared<EntityTree>()),
@ -1064,12 +1051,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
LogHandler::getInstance().setupRepeatedMessageFlusher(); LogHandler::getInstance().setupRepeatedMessageFlusher();
{ {
const QStringList args = arguments(); if (parser->isSet("testScript")) {
QString testScriptPath = parser->value("testScript");
for (int i = 0; i < args.size() - 1; ++i) {
if (args.at(i) == TEST_SCRIPT_COMMAND && (i + 1) < args.size()) {
QString testScriptPath = args.at(i + 1);
// If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file // If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file
// This is done so as not break previous command line scripts // This is done so as not break previous command line scripts
if (testScriptPath.left(HIFI_URL_SCHEME_HTTP.length()) == HIFI_URL_SCHEME_HTTP || if (testScriptPath.left(HIFI_URL_SCHEME_HTTP.length()) == HIFI_URL_SCHEME_HTTP ||
@ -1080,20 +1063,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath));
} }
// quite when finished parameter must directly follow the test script if (parser->isSet("quitWhenFinished")) {
if ((i + 2) < args.size() && args.at(i + 2) == TEST_QUIT_WHEN_FINISHED_OPTION) {
quitWhenFinished = true; quitWhenFinished = true;
} }
} else if (args.at(i) == TEST_RESULTS_LOCATION_COMMAND) { }
// Set test snapshot location only if it is a writeable directory if (parser->isSet("testResultsLocation")) {
QString path(args.at(i + 1)); // Set test snapshot location only if it is a writeable directory
QString path = parser->value("testResultsLocation");
QFileInfo fileInfo(path); QFileInfo fileInfo(path);
if (fileInfo.isDir() && fileInfo.isWritable()) { if (fileInfo.isDir() && fileInfo.isWritable()) {
TestScriptingInterface::getInstance()->setTestResultsLocation(path); TestScriptingInterface::getInstance()->setTestResultsLocation(path);
}
} }
} }
_urlParam = parser->value("url");
} }
{ {
@ -1159,8 +1142,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
auto addressManager = DependencyManager::get<AddressManager>(); auto addressManager = DependencyManager::get<AddressManager>();
addressManager->moveToThread(nodeList->thread()); addressManager->moveToThread(nodeList->thread());
const char** constArgv = const_cast<const char**>(argv); if (parser->isSet("disableWatchdog")) {
if (cmdOptionExists(argc, constArgv, "--disableWatchdog")) {
DISABLE_WATCHDOG = true; DISABLE_WATCHDOG = true;
} }
// Set up a watchdog thread to intentionally crash the application on deadlocks // Set up a watchdog thread to intentionally crash the application on deadlocks
@ -1481,24 +1463,26 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent); connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);
connect(&_entityEditSender, &EntityEditPacketSender::addingEntityWithCertificate, this, &Application::addingEntityWithCertificate); connect(&_entityEditSender, &EntityEditPacketSender::addingEntityWithCertificate, this, &Application::addingEntityWithCertificate);
QString concurrentDownloadsStr = getCmdOption(argc, constArgv, "--concurrent-downloads"); if (parser->isSet("concurrent-downloads")) {
bool success; bool success;
uint32_t concurrentDownloads = concurrentDownloadsStr.toUInt(&success); uint32_t concurrentDownloads = parser->value("concurrent-downloads").toUInt(&success);
if (!success) { if (!success) {
concurrentDownloads = MAX_CONCURRENT_RESOURCE_DOWNLOADS; concurrentDownloads = MAX_CONCURRENT_RESOURCE_DOWNLOADS;
}
ResourceCache::setRequestLimit(concurrentDownloads);
} }
ResourceCache::setRequestLimit(concurrentDownloads);
// perhaps override the avatar url. Since we will test later for validity // perhaps override the avatar url. Since we will test later for validity
// we don't need to do so here. // we don't need to do so here.
QString avatarURL = getCmdOption(argc, constArgv, "--avatarURL"); if (parser->isSet("avatarURL")) {
_avatarOverrideUrl = QUrl::fromUserInput(avatarURL); _avatarOverrideUrl = QUrl::fromUserInput(parser->value("avatarURL"));
}
// If someone specifies both --avatarURL and --replaceAvatarURL, // If someone specifies both --avatarURL and --replaceAvatarURL,
// the replaceAvatarURL wins. So only set the _overrideUrl if this // the replaceAvatarURL wins. So only set the _overrideUrl if this
// does have a non-empty string. // does have a non-empty string.
QString replaceURL = getCmdOption(argc, constArgv, "--replaceAvatarURL"); if (parser->isSet("replaceAvatarURL")) {
if (!replaceURL.isEmpty()) { QString replaceURL = parser->value("replaceAvatarURL");
_avatarOverrideUrl = QUrl::fromUserInput(replaceURL); _avatarOverrideUrl = QUrl::fromUserInput(replaceURL);
_saveAvatarOverrideUrl = true; _saveAvatarOverrideUrl = true;
} }
@ -1516,7 +1500,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
_glWidget->setFocusPolicy(Qt::StrongFocus); _glWidget->setFocusPolicy(Qt::StrongFocus);
_glWidget->setFocus(); _glWidget->setFocus();
if (cmdOptionExists(argc, constArgv, "--system-cursor")) { if (parser->isSet("system-cursor")) {
_preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM)); _preferredCursor.set(Cursor::Manager::getIconName(Cursor::Icon::SYSTEM));
} }
showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get())); showCursor(Cursor::Manager::lookupIcon(_preferredCursor.get()));
@ -1585,21 +1569,23 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
} }
}); });
#if defined(Q_OS_ANDROID) || defined(DISABLE_QML)
connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() { connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() {
#if !defined(Q_OS_ANDROID) && !defined(DISABLE_QML)
// Do not show login dialog if requested not to on the command line
QString hifiNoLoginCommandLineKey = QString("--").append(HIFI_NO_LOGIN_COMMAND_LINE_KEY);
int index = arguments().indexOf(hifiNoLoginCommandLineKey);
if (index != -1 || _disableLoginScreen) {
resumeAfterLoginDialogActionTaken();
return;
}
showLoginScreen();
#else
resumeAfterLoginDialogActionTaken(); resumeAfterLoginDialogActionTaken();
#endif
}); });
#else
// Do not show login dialog if requested not to on the command line
if (_disableLoginScreen || parser->isSet("no-login-suggestion")) {
connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() {
resumeAfterLoginDialogActionTaken();
});
} else {
connect(offscreenUi.data(), &OffscreenUi::keyboardFocusActive, [this]() {
showLoginScreen();
resumeAfterLoginDialogActionTaken();
});
}
#endif
// Initialize the user interface and menu system // Initialize the user interface and menu system
// Needs to happen AFTER the render engine initialization to access its configuration // Needs to happen AFTER the render engine initialization to access its configuration
@ -1961,13 +1947,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice()); userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice());
} }
QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH); if (parser->isSet("scripts")) {
_defaultScriptsLocation.setPath(getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str())); _defaultScriptsLocation.setPath(parser->value("scripts")); // Already done in "main.cpp".
_overrideDefaultScriptsLocation = true;
} else {
_overrideDefaultScriptsLocation = false;
}
// Make sure we don't time out during slow operations at startup // Make sure we don't time out during slow operations at startup
updateHeartbeat(); updateHeartbeat();
loadSettings(); loadSettings(parser);
updateVerboseLogging(); updateVerboseLogging();
@ -2018,11 +2008,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// If launched from Steam, let it handle updates // If launched from Steam, let it handle updates
const QString HIFI_NO_UPDATER_COMMAND_LINE_KEY = "--no-updater";
bool noUpdater = arguments().indexOf(HIFI_NO_UPDATER_COMMAND_LINE_KEY) != -1;
bool buildCanUpdate = BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable bool buildCanUpdate = BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Stable
|| BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Master; || BuildInfo::BUILD_TYPE == BuildInfo::BuildType::Master;
if (!noUpdater && buildCanUpdate) { if (!parser->isSet("no-updater") && buildCanUpdate) {
constexpr auto INSTALLER_TYPE_CLIENT_ONLY = "client_only"; constexpr auto INSTALLER_TYPE_CLIENT_ONLY = "client_only";
auto applicationUpdater = DependencyManager::set<AutoUpdater>(); auto applicationUpdater = DependencyManager::set<AutoUpdater>();
@ -2191,8 +2179,12 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
static int NEARBY_AVATAR_RADIUS_METERS = 10; static int NEARBY_AVATAR_RADIUS_METERS = 10;
// setup the stats interval depending on if the 1s faster hearbeat was requested // setup the stats interval depending on if the 1s faster hearbeat was requested
static const QString FAST_STATS_ARG = "--fast-heartbeat"; static int SEND_STATS_INTERVAL_MS;
static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000; if (parser->isSet("fast-heartbeat")) {
SEND_STATS_INTERVAL_MS = 1000;
} else {
SEND_STATS_INTERVAL_MS = 10000;
}
static glm::vec3 lastAvatarPosition = myAvatar->getWorldPosition(); static glm::vec3 lastAvatarPosition = myAvatar->getWorldPosition();
static glm::mat4 lastHMDHeadPose = getHMDSensorPose(); static glm::mat4 lastHMDHeadPose = getHMDSensorPose();
@ -4022,16 +4014,11 @@ void Application::handleSandboxStatus(QNetworkReply* reply) {
QString addressLookupString; QString addressLookupString;
// when --url in command line, teleport to location // when --url in command line, teleport to location
QCommandLineParser parser; if (!_urlParam.isEmpty()) { // Not sure if format supported by isValid().
QCommandLineOption urlOption("url", "", "value"); if (_urlParam.scheme() == URL_SCHEME_VIRCADIAAPP) {
parser.addOption(urlOption); Setting::Handle<QVariant>("startUpApp").set(_urlParam.path());
parser.parse(arguments());
if (parser.isSet(urlOption)) {
QUrl url = QUrl(parser.value(urlOption));
if (url.scheme() == URL_SCHEME_VIRCADIAAPP) {
Setting::Handle<QVariant>("startUpApp").set(url.path());
} else { } else {
addressLookupString = url.toString(); addressLookupString = _urlParam.toString();
} }
} }
@ -5514,7 +5501,7 @@ bool Application::exportEntities(const QString& filename, float x, float y, floa
return exportEntities(filename, entities, &center); return exportEntities(filename, entities, &center);
} }
void Application::loadSettings() { void Application::loadSettings(const QCommandLineParser* parser) {
sessionRunTime.set(0); // Just clean living. We're about to saveSettings, which will update value. sessionRunTime.set(0); // Just clean living. We're about to saveSettings, which will update value.
DependencyManager::get<AudioClient>()->loadSettings(); DependencyManager::get<AudioClient>()->loadSettings();
@ -5544,7 +5531,7 @@ void Application::loadSettings() {
} }
bool isFirstPerson = false; bool isFirstPerson = false;
if (arguments().contains("--no-launcher")) { if (parser->isSet("no-launcher")) {
const auto& displayPlugins = pluginManager->getDisplayPlugins(); const auto& displayPlugins = pluginManager->getDisplayPlugins();
for (const auto& plugin : displayPlugins) { for (const auto& plugin : displayPlugins) {
if (!plugin->isHmd()) { if (!plugin->isHmd()) {
@ -5849,7 +5836,7 @@ void Application::resumeAfterLoginDialogActionTaken() {
scriptEngines->reloadLocalFiles(); scriptEngines->reloadLocalFiles();
// if the --scripts command-line argument was used. // if the --scripts command-line argument was used.
if (_defaultScriptsLocation.exists() && (arguments().indexOf(QString("--").append(SCRIPTS_SWITCH))) != -1) { if (_overrideDefaultScriptsLocation && _defaultScriptsLocation.exists()) {
scriptEngines->loadDefaultScripts(); scriptEngines->loadDefaultScripts();
scriptEngines->defaultScriptsLocationOverridden(true); scriptEngines->defaultScriptsLocationOverridden(true);
} else { } else {
@ -5869,7 +5856,7 @@ void Application::resumeAfterLoginDialogActionTaken() {
// Set last parameter to exit interface when the test script finishes, if so requested // Set last parameter to exit interface when the test script finishes, if so requested
DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished); DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished);
// This is done so we don't get a "connection time-out" message when we haven't passed in a URL. // This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
if (arguments().contains("--url")) { if (!_urlParam.isEmpty()) {
auto reply = SandboxUtils::getStatus(); auto reply = SandboxUtils::getStatus();
connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); }); connect(reply, &QNetworkReply::finished, this, [this, reply] { handleSandboxStatus(reply); });
} }
@ -8831,31 +8818,21 @@ void Application::sendLambdaEvent(const std::function<void()>& f) {
} }
} }
void Application::initPlugins(const QStringList& arguments) { void Application::initPlugins(const QCommandLineParser* parser) {
QCommandLineOption display("display", "Preferred displays", "displays"); if (parser->isSet("display")) {
QCommandLineOption disableDisplays("disable-displays", "Displays to disable", "displays"); auto preferredDisplays = parser->value("display").split(',', Qt::SkipEmptyParts);
QCommandLineOption disableInputs("disable-inputs", "Inputs to disable", "inputs");
QCommandLineParser parser;
parser.addOption(display);
parser.addOption(disableDisplays);
parser.addOption(disableInputs);
parser.parse(arguments);
if (parser.isSet(display)) {
auto preferredDisplays = parser.value(display).split(',', Qt::SkipEmptyParts);
qInfo() << "Setting prefered display plugins:" << preferredDisplays; qInfo() << "Setting prefered display plugins:" << preferredDisplays;
PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays); PluginManager::getInstance()->setPreferredDisplayPlugins(preferredDisplays);
} }
if (parser.isSet(disableDisplays)) { if (parser->isSet("disable-displays")) {
auto disabledDisplays = parser.value(disableDisplays).split(',', Qt::SkipEmptyParts); auto disabledDisplays = parser->value("disableDisplays").split(',', Qt::SkipEmptyParts);
qInfo() << "Disabling following display plugins:" << disabledDisplays; qInfo() << "Disabling following display plugins:" << disabledDisplays;
PluginManager::getInstance()->disableDisplays(disabledDisplays); PluginManager::getInstance()->disableDisplays(disabledDisplays);
} }
if (parser.isSet(disableInputs)) { if (parser->isSet("disable-inputs")) {
auto disabledInputs = parser.value(disableInputs).split(',', Qt::SkipEmptyParts); auto disabledInputs = parser->value("disableInputs").split(',', Qt::SkipEmptyParts);
qInfo() << "Disabling following input plugins:" << disabledInputs; qInfo() << "Disabling following input plugins:" << disabledInputs;
PluginManager::getInstance()->disableInputs(disabledInputs); PluginManager::getInstance()->disableInputs(disabledInputs);
} }

View file

@ -15,6 +15,7 @@
#include <functional> #include <functional>
#include <QtCore/QCommandLineParser>
#include <QtCore/QHash> #include <QtCore/QHash>
#include <QtCore/QPointer> #include <QtCore/QPointer>
#include <QtCore/QSet> #include <QtCore/QSet>
@ -22,6 +23,7 @@
#include <QtCore/QStringList> #include <QtCore/QStringList>
#include <QtQuick/QQuickItem> #include <QtQuick/QQuickItem>
#include <QtGui/QImage> #include <QtGui/QImage>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
@ -96,8 +98,6 @@ namespace controller {
static const QString RUNNING_MARKER_FILENAME = "Interface.running"; static const QString RUNNING_MARKER_FILENAME = "Interface.running";
static const QString SCRIPTS_SWITCH = "scripts";
static const QString HIFI_NO_LOGIN_COMMAND_LINE_KEY = "no-login-suggestion";
class Application; class Application;
#if defined(qApp) #if defined(qApp)
@ -130,10 +130,15 @@ public:
virtual DisplayPluginPointer getActiveDisplayPlugin() const override; virtual DisplayPluginPointer getActiveDisplayPlugin() const override;
// FIXME? Empty methods, do we still need them? // FIXME? Empty methods, do we still need them?
static void initPlugins(const QStringList& arguments); static void initPlugins(const QCommandLineParser* parser);
static void shutdownPlugins(); static void shutdownPlugins();
Application(int& argc, char** argv, QElapsedTimer& startup_time, bool runningMarkerExisted); Application(
int& argc, char** argv,
const QCommandLineParser* parser,
QElapsedTimer& startup_time,
bool runningMarkerExisted
);
~Application(); ~Application();
void postLambdaEvent(const std::function<void()>& f) override; void postLambdaEvent(const std::function<void()>& f) override;
@ -505,7 +510,7 @@ private slots:
void notifyPacketVersionMismatch(); void notifyPacketVersionMismatch();
void loadSettings(); void loadSettings(const QCommandLineParser* parser);
void saveSettings() const; void saveSettings() const;
void setFailedToConnectToEntityServer(); void setFailedToConnectToEntityServer();
@ -705,6 +710,8 @@ private:
QPointer<LogDialog> _logDialog; QPointer<LogDialog> _logDialog;
QPointer<EntityScriptServerLogDialog> _entityScriptServerLogDialog; QPointer<EntityScriptServerLogDialog> _entityScriptServerLogDialog;
QDir _defaultScriptsLocation; QDir _defaultScriptsLocation;
// If above is only set by parameter, below is unnecessary.
bool _overrideDefaultScriptsLocation;
TouchEvent _lastTouchEvent; TouchEvent _lastTouchEvent;
@ -830,6 +837,8 @@ private:
bool quitWhenFinished { false }; bool quitWhenFinished { false };
QUrl _urlParam;
bool _showTrackedObjects { false }; bool _showTrackedObjects { false };
bool _prevShowTrackedObjects { false }; bool _prevShowTrackedObjects { false };

View file

@ -78,7 +78,8 @@ int main(int argc, const char* argv[]) {
); );
QCommandLineOption protocolVersionOption( QCommandLineOption protocolVersionOption(
"protocolVersion", "protocolVersion",
"Displays the protocol version." "Writes the protocol version base64 signature to a file?",
"path" // Why??
); );
QCommandLineOption noUpdaterOption( QCommandLineOption noUpdaterOption(
"no-updater", "no-updater",
@ -106,11 +107,11 @@ int main(int argc, const char* argv[]) {
"set test cache <dir>.", "set test cache <dir>.",
"dir" "dir"
); );
//QCommandLineOption scriptsOption( QCommandLineOption scriptsOption(
// "scripts", "scripts",
// "Set path for defaultScripts.", "Set path for defaultScripts.",
// "dir" "dir"
//); // Use this once SCRIPTS_SWITCH is removed. );
QCommandLineOption allowMultipleInstancesOption( QCommandLineOption allowMultipleInstancesOption(
"allowMultipleInstances", "allowMultipleInstances",
"Allow multiple instances to run." "Allow multiple instances to run."
@ -122,11 +123,13 @@ int main(int argc, const char* argv[]) {
); );
QCommandLineOption disableDisplaysOption( QCommandLineOption disableDisplaysOption(
"disable-displays", "disable-displays",
"Displays to disable." "Displays to disable.",
"string"
); );
QCommandLineOption disableInputsOption( QCommandLineOption disableInputsOption(
"disable-inputs", "disable-inputs",
"Inputs to disable." "Inputs to disable.",
"string"
); );
QCommandLineOption suppressSettingsResetOption( QCommandLineOption suppressSettingsResetOption(
"suppress-settings-reset", "suppress-settings-reset",
@ -175,11 +178,11 @@ int main(int argc, const char* argv[]) {
"no-launcher", "no-launcher",
"Do not execute the launcher." "Do not execute the launcher."
); );
QCommandLineOption overrideScriptsPathOption( /*QCommandLineOption overrideScriptsPathOption(
SCRIPTS_SWITCH, SCRIPTS_SWITCH,
"Set scripts <path>", "Set scripts <path>",
"path" "path"
); );*/
QCommandLineOption defaultScriptOverrideOption( QCommandLineOption defaultScriptOverrideOption(
"defaultScriptsOverride", "defaultScriptsOverride",
"Override defaultsScripts.js.", "Override defaultsScripts.js.",
@ -195,6 +198,10 @@ int main(int argc, const char* argv[]) {
"Set user display name <string>.", "Set user display name <string>.",
"string" "string"
); );
QCommandLineOption noLoginOption(
"no-login-suggestion",
"Do not show log-in dialogue."
);
QCommandLineOption traceFileOption( QCommandLineOption traceFileOption(
"traceFile", "traceFile",
"Probably writes a trace to a file?", "Probably writes a trace to a file?",
@ -210,6 +217,24 @@ int main(int argc, const char* argv[]) {
"Forces client instance's clock to skew for demonstration purposes.", "Forces client instance's clock to skew for demonstration purposes.",
"value" "value"
); );
QCommandLineOption testScriptOption(
"testScript",
"Undocumented. Accepts parameter as U.R.L.",
"string"
);
QCommandLineOption testResultsLocationOption(
"testResultsLocation",
"Undocumented",
"path"
);
QCommandLineOption quitWhenFinishedOption(
"quitWhenFinished",
"Only works if \"--testScript\" is provided."
); // Should probably also work on testResultsLocationOption.
QCommandLineOption fastHeartbeatOption(
"fast-heartbeat",
"Change stats polling interval from 10000ms to 1000ms."
);
// "--qmljsdebugger", which appears in output from "--help-all". // "--qmljsdebugger", which appears in output from "--help-all".
// Those below don't seem to be optional. // Those below don't seem to be optional.
// --ignore-gpu-blacklist // --ignore-gpu-blacklist
@ -223,7 +248,7 @@ int main(int argc, const char* argv[]) {
parser.addOption(listenPortOption); parser.addOption(listenPortOption);
parser.addOption(serverContentPathOption); parser.addOption(serverContentPathOption);
parser.addOption(overrideAppLocalDataPathOption); parser.addOption(overrideAppLocalDataPathOption);
//parser.addOption(scriptsOption); // Use this once SCRIPTS_SWITCH is removed. parser.addOption(scriptsOption); // Also known as "overrideScriptsPathOption"?
parser.addOption(allowMultipleInstancesOption); parser.addOption(allowMultipleInstancesOption);
parser.addOption(displaysOption); parser.addOption(displaysOption);
parser.addOption(disableDisplaysOption); parser.addOption(disableDisplaysOption);
@ -239,15 +264,17 @@ int main(int argc, const char* argv[]) {
parser.addOption(setBookmarkOption); parser.addOption(setBookmarkOption);
parser.addOption(forceCrashReportingOption); parser.addOption(forceCrashReportingOption);
parser.addOption(noLauncherOption); parser.addOption(noLauncherOption);
parser.addOption(overrideScriptsPathOption); // Remove this along with SCRIPTS_SWITCH.
parser.addOption(responseTokensOption); parser.addOption(responseTokensOption);
parser.addOption(displayNameOption); parser.addOption(displayNameOption);
parser.addOption(defaultScriptOverrideOption); parser.addOption(defaultScriptOverrideOption);
parser.addOption(traceFileOption); parser.addOption(traceFileOption);
parser.addOption(traceDurationOption); parser.addOption(traceDurationOption);
parser.addOption(clockSkewOption); parser.addOption(clockSkewOption);
parser.addOption(testScriptOption);
parser.addOption(testResultsLocationOption);
parser.addOption(quitWhenFinishedOption);
parser.addOption(fastHeartbeatOption);
QStringList arguments;
QString applicationPath; QString applicationPath;
// A temporary application instance is needed to get the location of the running executable // A temporary application instance is needed to get the location of the running executable
// Tests using high_resolution_clock show that this takes about 30-50 microseconds (on my machine, YMMV) // Tests using high_resolution_clock show that this takes about 30-50 microseconds (on my machine, YMMV)
@ -257,7 +284,6 @@ int main(int argc, const char* argv[]) {
QCoreApplication tempApp(argc, const_cast<char**>(argv)); QCoreApplication tempApp(argc, const_cast<char**>(argv));
parser.process(QCoreApplication::arguments()); // Must be run after QCoreApplication is initalised. parser.process(QCoreApplication::arguments()); // Must be run after QCoreApplication is initalised.
arguments = parser.positionalArguments(); // Must be run after parser processes arguments.
#ifdef Q_OS_OSX #ifdef Q_OS_OSX
if (QFileInfo::exists(QCoreApplication::applicationDirPath() + "/../../../config.json")) { if (QFileInfo::exists(QCoreApplication::applicationDirPath() + "/../../../config.json")) {
@ -386,12 +412,13 @@ int main(int argc, const char* argv[]) {
// this needs to be done here in main, as the mechanism for setting the // this needs to be done here in main, as the mechanism for setting the
// scripts directory appears not to work. See the bug report // scripts directory appears not to work. See the bug report
// https://highfidelity.fogbugz.com/f/cases/5759/Issues-changing-scripts-directory-in-ScriptsEngine // https://highfidelity.fogbugz.com/f/cases/5759/Issues-changing-scripts-directory-in-ScriptsEngine
if (parser.isSet(overrideScriptsPathOption)) { // It is currently also done in "Application.cpp". Not sure if necessary.
/*if (parser.isSet(overrideScriptsPathOption)) {
QDir scriptsPath(parser.value(overrideScriptsPathOption)); QDir scriptsPath(parser.value(overrideScriptsPathOption));
if (scriptsPath.exists()) { if (scriptsPath.exists()) {
PathUtils::defaultScriptsLocation(scriptsPath.path()); PathUtils::defaultScriptsLocation(scriptsPath.path());
} }
} }*/
if (instanceMightBeRunning) { if (instanceMightBeRunning) {
// Try to connect and send message to existing interface instance // Try to connect and send message to existing interface instance
@ -469,7 +496,7 @@ int main(int argc, const char* argv[]) {
// Oculus initialization MUST PRECEDE OpenGL context creation. // Oculus initialization MUST PRECEDE OpenGL context creation.
// The nature of the Application constructor means this has to be either here, // The nature of the Application constructor means this has to be either here,
// or in the main window ctor, before GL startup. // or in the main window ctor, before GL startup.
Application::initPlugins(arguments); Application::initPlugins(&parser);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec // If we're running in steam mode, we need to do an explicit check to ensure we're up to the required min spec
@ -517,7 +544,7 @@ int main(int argc, const char* argv[]) {
PROFILE_SYNC_END(startup, "main startup", ""); PROFILE_SYNC_END(startup, "main startup", "");
PROFILE_SYNC_BEGIN(startup, "app full ctor", ""); PROFILE_SYNC_BEGIN(startup, "app full ctor", "");
Application app(argcExtended, const_cast<char**>(argvExtended.data()), startupTime, runningMarkerExisted); Application app(argcExtended, const_cast<char**>(argvExtended.data()), &parser, startupTime, runningMarkerExisted);
PROFILE_SYNC_END(startup, "app full ctor", ""); PROFILE_SYNC_END(startup, "app full ctor", "");
#if defined(Q_OS_LINUX) #if defined(Q_OS_LINUX)