mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-13 22:27:13 +02:00
override defualt latest build url and add commandlineOption
This commit is contained in:
parent
1d50856931
commit
836e23f5cf
10 changed files with 81 additions and 40 deletions
|
@ -139,6 +139,8 @@ set(src_files
|
|||
src/Unzipper.cpp
|
||||
src/Helper.h
|
||||
src/Helper.cpp
|
||||
src/CommandlineOptions.h
|
||||
src/CommandlineOptions.cpp
|
||||
deps/miniz/miniz.h
|
||||
deps/miniz/miniz.cpp
|
||||
#${RES_SOURCES}
|
||||
|
|
|
@ -78,6 +78,10 @@ Item {
|
|||
topMargin: 15
|
||||
horizontalCenter: description.horizontalCenter
|
||||
}
|
||||
|
||||
onClicked: {
|
||||
LauncherState.restart();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ Item {
|
|||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
loader.source = LauncherState.getCurrentUISource();
|
||||
loader.source = "./SplashScreen.qml";
|
||||
LauncherState.updateSourceUrl.connect(function(url) {
|
||||
loader.source = url;
|
||||
});
|
||||
|
|
30
launchers/qt/src/CommandlineOptions.cpp
Normal file
30
launchers/qt/src/CommandlineOptions.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include "CommandlineOptions.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
bool isCommandlineOption(const std::string& option) {
|
||||
if (option.rfind("--", 0) == 0 && option.at(2) != '-') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool CommandlineOptions::contains(const std::string& option) {
|
||||
auto iter = std::find(_commandlineOptions.begin(), _commandlineOptions.end(), option);
|
||||
return (iter != _commandlineOptions.end());
|
||||
}
|
||||
|
||||
void CommandlineOptions::parse(const int argc, char** argv) {
|
||||
for (int index = 1; index < argc; index++) {
|
||||
std::string option = argv[index];
|
||||
if (isCommandlineOption(option)) {
|
||||
std::cout << "adding commandline option: " << option << "\n";
|
||||
_commandlineOptions.push_back(option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CommandlineOptions* CommandlineOptions::getInstance() {
|
||||
static CommandlineOptions commandlineOptions;
|
||||
return &commandlineOptions;
|
||||
}
|
16
launchers/qt/src/CommandlineOptions.h
Normal file
16
launchers/qt/src/CommandlineOptions.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CommandlineOptions {
|
||||
public:
|
||||
CommandlineOptions() = default;
|
||||
~CommandlineOptions() = default;
|
||||
|
||||
void parse(const int argc, char** argv);
|
||||
bool contains(const std::string& option);
|
||||
static CommandlineOptions* getInstance();
|
||||
private:
|
||||
std::vector<std::string> _commandlineOptions;
|
||||
};
|
|
@ -7,7 +7,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
void launchClient(const QString& clientPath, const QString& homePath, const QString& defaultScriptOverride,
|
||||
const QString& displayName, const QString& contentCachePath, QString& loginTokenResponse) {
|
||||
const QString& displayName, const QString& contentCachePath, QString loginTokenResponse) {
|
||||
|
||||
NSString* homeBookmark = [[NSString stringWithFormat:@"hqhome="] stringByAppendingString:homePath.toNSString()];
|
||||
NSArray* arguments;
|
||||
|
|
|
@ -13,7 +13,6 @@ Launcher::Launcher(int& argc, char**argv) : QGuiApplication(argc, argv) {
|
|||
qDebug() << "resources.rcc path: " << resourceBinaryLocation;
|
||||
QResource::registerResource(resourceBinaryLocation);
|
||||
_launcherState = std::make_shared<LauncherState>();
|
||||
//_launcherState->setUIState(LauncherState::SPLASH_SCREEN);
|
||||
_launcherWindow = std::make_unique<LauncherWindow>();
|
||||
_launcherWindow->rootContext()->setContextProperty("LauncherState", _launcherState.get());
|
||||
_launcherWindow->rootContext()->setContextProperty("PathUtils", new PathUtils());
|
||||
|
|
|
@ -151,12 +151,25 @@ void LauncherState::requestBuilds() {
|
|||
setApplicationState(ApplicationState::RequestingBuilds);
|
||||
|
||||
// TODO Show splash screen until this request is complete
|
||||
auto request = new QNetworkRequest(QUrl("https://thunder.highfidelity.com/builds/api/tags/latest/?format=json"));
|
||||
|
||||
QString latestBuildRequestUrl { "https://thunder.highfidelity.com/builds/api/tags/latest/?format=json" };
|
||||
QProcessEnvironment processEnvironment =QProcessEnvironment::systemEnvironment();
|
||||
|
||||
if (processEnvironment.contains("HQ_LAUNCHER_BUILDS_URL")) {
|
||||
latestBuildRequestUrl = processEnvironment.value("HQ_LAUNCHER_BUILDS_URL");
|
||||
}
|
||||
|
||||
auto request = new QNetworkRequest(QUrl(latestBuildRequestUrl));
|
||||
auto reply = _networkAccessManager.get(*request);
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, &LauncherState::receivedBuildsReply);
|
||||
}
|
||||
|
||||
void LauncherState::restart() {
|
||||
setApplicationState(ApplicationState::Init);
|
||||
requestBuilds();
|
||||
}
|
||||
|
||||
void LauncherState::receivedBuildsReply() {
|
||||
auto reply = static_cast<QNetworkReply*>(sender());
|
||||
|
||||
|
@ -219,7 +232,7 @@ void LauncherState::receivedBuildsReply() {
|
|||
}
|
||||
|
||||
if (shouldDownloadLauncher()) {
|
||||
downloadLauncher();
|
||||
//downloadLauncher();
|
||||
}
|
||||
getCurrentClientVersion();
|
||||
}
|
||||
|
@ -239,27 +252,12 @@ void LauncherState::getCurrentClientVersion() {
|
|||
|
||||
//connect(&client, &QProcess::errorOccurred, &loop, &QEventLoop::exit);
|
||||
connect(&client, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), &loop, &QEventLoop::exit);
|
||||
/*
|
||||
connect(&client, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [&]() {
|
||||
qDebug() << "Finished";
|
||||
});
|
||||
connect(&client, &QProcess::errorOccurred, [&](QProcess::ProcessError err) {
|
||||
qDebug() << "Error occurred" << err << client.error();
|
||||
});
|
||||
connect(&client, &QProcess::started, [&]() {
|
||||
qDebug() << "Started";
|
||||
});
|
||||
connect(&client, &QProcess::stateChanged, [&]() {
|
||||
qDebug() << "State changed " << client.state();
|
||||
});
|
||||
*/
|
||||
connect(&client, &QProcess::errorOccurred, &loop, &QEventLoop::exit, Qt::QueuedConnection);
|
||||
|
||||
//qDebug() << "Starting client";
|
||||
client.start(getClientExecutablePath(), { "--version" });
|
||||
//qDebug() << "Started" << client.error();
|
||||
|
||||
if (client.state() != QProcess::NotRunning) {
|
||||
//qDebug() << "Starting loop";
|
||||
|
||||
loop.exec();
|
||||
} else {
|
||||
qDebug() << "Not waiting for client, there was an error starting it: " << client.error();
|
||||
|
@ -389,12 +387,13 @@ void LauncherState::receivedSettingsReply() {
|
|||
}
|
||||
|
||||
_homeLocation = "hifi://hq";
|
||||
_contentCacheURL = "http://orgs.highfidelity.com/host-content-cache/" + QUrl(_homeLocation).host() + ".zip";
|
||||
if (root["data"].toObject().contains("home_location")) {
|
||||
auto homeLocation = root["data"].toObject()["home_location"];
|
||||
if (homeLocation.isString()) {
|
||||
_homeLocation = homeLocation.toString();
|
||||
auto host = QUrl(_homeLocation).host();
|
||||
_contentCacheURL = "http://orgs.highfidelity.com/host-content-cache/" + host + ".zip";
|
||||
//_contentCacheURL = "http://orgs.highfidelity.com/host-content-cache/" + host + ".zip";
|
||||
qDebug() << "Home location is: " << _homeLocation;
|
||||
qDebug() << "Content cache url is: " << _contentCacheURL;
|
||||
}
|
||||
|
|
|
@ -110,6 +110,8 @@ public:
|
|||
void requestSettings();
|
||||
Q_INVOKABLE void receivedSettingsReply();
|
||||
|
||||
Q_INVOKABLE void restart();
|
||||
|
||||
// Launcher
|
||||
void downloadLauncher();
|
||||
void installLauncher();
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "LauncherWindow.h"
|
||||
#include "Launcher.h"
|
||||
#include "CommandlineOptions.h"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "Helper.h"
|
||||
|
@ -27,31 +28,19 @@ bool hasSuffix(const std::string path, const std::string suffix) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool containsOption(int argc, char* argv[], const std::string& option) {
|
||||
for (int index = 0; index < argc; index++) {
|
||||
if (option.compare(argv[index]) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
//std::cout << "Launcher version: " << LAUNCHER_BUILD_VERSION;
|
||||
#ifdef Q_OS_MAC
|
||||
// auto updater
|
||||
if (argc == 3) {
|
||||
if (hasSuffix(argv[1], "app") && hasSuffix(argv[2], "app")) {
|
||||
std::cout << "swapping launcher \n";
|
||||
swapLaunchers(argv[1], argv[2]);
|
||||
} else {
|
||||
std::cout << "not swapping launcher \n";
|
||||
}
|
||||
}
|
||||
#elif defined(Q_OS_WIN)
|
||||
// try-install
|
||||
|
||||
if (containsOption(argc, argv, "--restart")) {
|
||||
#endif
|
||||
CommandlineOptions* options = CommandlineOptions::getInstance();
|
||||
options->parse(argc, argv);
|
||||
#ifdef Q_OS_WIN
|
||||
if (options->contains("--restart")) {
|
||||
LauncherInstaller launcherInstaller(argv[0]);
|
||||
launcherInstaller.install();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue