mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 18:24:09 +02:00
Add build tags to Windows launcher
This commit is contained in:
parent
4d71891763
commit
83bc5e3fd6
2 changed files with 73 additions and 30 deletions
|
@ -36,6 +36,7 @@ void LauncherManager::init(BOOL allowUpdate, ContinueActionOnStart continueActio
|
||||||
}
|
}
|
||||||
addToLog(_T("Launcher is running version: " + _launcherVersion));
|
addToLog(_T("Launcher is running version: " + _launcherVersion));
|
||||||
addToLog(_T("Getting most recent builds"));
|
addToLog(_T("Getting most recent builds"));
|
||||||
|
_isInstalled = isApplicationInstalled(_currentVersion, _domainURL, _contentURL, _loggedIn, _organizationBuildTag);
|
||||||
getMostRecentBuilds(_latestLauncherURL, _latestLauncherVersion, _latestApplicationURL, _latestVersion);
|
getMostRecentBuilds(_latestLauncherURL, _latestLauncherVersion, _latestApplicationURL, _latestVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,14 +261,14 @@ BOOL LauncherManager::deleteShortcuts() {
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL LauncherManager::isApplicationInstalled(CString& version, CString& domain,
|
BOOL LauncherManager::isApplicationInstalled(CString& version, CString& domain,
|
||||||
CString& content, bool& loggedIn) {
|
CString& content, bool& loggedIn, CString& organizationBuildTag) {
|
||||||
CString applicationDir;
|
CString applicationDir;
|
||||||
getAndCreatePaths(PathType::Launcher_Directory, applicationDir);
|
getAndCreatePaths(PathType::Launcher_Directory, applicationDir);
|
||||||
CString applicationPath = applicationDir + "interface\\interface.exe";
|
CString applicationPath = applicationDir + "interface\\interface.exe";
|
||||||
BOOL isInstalled = PathFileExistsW(applicationPath);
|
BOOL isInstalled = PathFileExistsW(applicationPath);
|
||||||
BOOL configFileExist = PathFileExistsW(applicationDir + _T("interface\\config.json"));
|
BOOL configFileExist = PathFileExistsW(applicationDir + _T("interface\\config.json"));
|
||||||
if (configFileExist) {
|
if (configFileExist) {
|
||||||
LauncherUtils::ResponseError status = readConfigJSON(version, domain, content, loggedIn);
|
LauncherUtils::ResponseError status = readConfigJSON(version, domain, content, loggedIn, organizationBuildTag);
|
||||||
return isInstalled && status == LauncherUtils::ResponseError::NoError;
|
return isInstalled && status == LauncherUtils::ResponseError::NoError;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -326,7 +327,6 @@ BOOL LauncherManager::getInstalledVersion(const CString& path, CString& version)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HWND LauncherManager::launchApplication() {
|
HWND LauncherManager::launchApplication() {
|
||||||
CString installDir;
|
CString installDir;
|
||||||
LauncherManager::getAndCreatePaths(PathType::Interface_Directory, installDir);
|
LauncherManager::getAndCreatePaths(PathType::Interface_Directory, installDir);
|
||||||
|
@ -368,6 +368,7 @@ BOOL LauncherManager::createConfigJSON() {
|
||||||
config["launcherPath"] = LauncherUtils::cStringToStd(applicationPath);
|
config["launcherPath"] = LauncherUtils::cStringToStd(applicationPath);
|
||||||
config["version"] = LauncherUtils::cStringToStd(_latestVersion);
|
config["version"] = LauncherUtils::cStringToStd(_latestVersion);
|
||||||
config["domain"] = LauncherUtils::cStringToStd(_domainURL);
|
config["domain"] = LauncherUtils::cStringToStd(_domainURL);
|
||||||
|
config["organizationBuildTag"] = LauncherUtils::cStringToStd(_organizationBuildTag);
|
||||||
CString content;
|
CString content;
|
||||||
getAndCreatePaths(PathType::Content_Directory, content);
|
getAndCreatePaths(PathType::Content_Directory, content);
|
||||||
config["content"] = LauncherUtils::cStringToStd(content);
|
config["content"] = LauncherUtils::cStringToStd(content);
|
||||||
|
@ -377,7 +378,7 @@ BOOL LauncherManager::createConfigJSON() {
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherUtils::ResponseError LauncherManager::readConfigJSON(CString& version, CString& domain,
|
LauncherUtils::ResponseError LauncherManager::readConfigJSON(CString& version, CString& domain,
|
||||||
CString& content, bool& loggedIn) {
|
CString& content, bool& loggedIn, CString& organizationBuildTag) {
|
||||||
CString configPath;
|
CString configPath;
|
||||||
getAndCreatePaths(PathType::Interface_Directory, configPath);
|
getAndCreatePaths(PathType::Interface_Directory, configPath);
|
||||||
configPath += "\\config.json";
|
configPath += "\\config.json";
|
||||||
|
@ -394,6 +395,13 @@ LauncherUtils::ResponseError LauncherManager::readConfigJSON(CString& version, C
|
||||||
version = config["version"].asCString();
|
version = config["version"].asCString();
|
||||||
domain = config["domain"].asCString();
|
domain = config["domain"].asCString();
|
||||||
content = config["content"].asCString();
|
content = config["content"].asCString();
|
||||||
|
|
||||||
|
if (config["organizationBuildTag"].isString()) {
|
||||||
|
organizationBuildTag = config["organizationBuildTag"].asCString();
|
||||||
|
} else {
|
||||||
|
organizationBuildTag = "";
|
||||||
|
}
|
||||||
|
|
||||||
configFile.close();
|
configFile.close();
|
||||||
return LauncherUtils::ResponseError::NoError;
|
return LauncherUtils::ResponseError::NoError;
|
||||||
}
|
}
|
||||||
|
@ -401,6 +409,37 @@ LauncherUtils::ResponseError LauncherManager::readConfigJSON(CString& version, C
|
||||||
return LauncherUtils::ResponseError::ParsingJSON;
|
return LauncherUtils::ResponseError::ParsingJSON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool findBuildInResponse(const Json::Value& json, const CString& tag, CString& interfaceUrlOut, CString& interfaceVersionOut) {
|
||||||
|
if (json["results"].isArray()) {
|
||||||
|
auto& results = json["results"];
|
||||||
|
int count = results.size();
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
if (results[i].isObject()) {
|
||||||
|
Json::Value result = results[i];
|
||||||
|
if (result["name"].asCString() == tag) {
|
||||||
|
if (result["latest_version"].isInt()) {
|
||||||
|
std::string version = std::to_string(result["latest_version"].asInt());
|
||||||
|
interfaceVersionOut = CString(version.c_str());
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (result["installers"].isObject() &&
|
||||||
|
result["installers"]["windows"].isObject() &&
|
||||||
|
result["installers"]["windows"]["zip_url"].isString()) {
|
||||||
|
interfaceUrlOut = result["installers"]["windows"]["zip_url"].asCString();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
LauncherUtils::ResponseError LauncherManager::readOrganizationJSON(const CString& hash) {
|
LauncherUtils::ResponseError LauncherManager::readOrganizationJSON(const CString& hash) {
|
||||||
CString contentTypeJson = L"content-type:application/json";
|
CString contentTypeJson = L"content-type:application/json";
|
||||||
CString response;
|
CString response;
|
||||||
|
@ -417,6 +456,13 @@ LauncherUtils::ResponseError LauncherManager::readOrganizationJSON(const CString
|
||||||
if (json["content_set_url"].isString() && json["domain"].isString()) {
|
if (json["content_set_url"].isString() && json["domain"].isString()) {
|
||||||
_contentURL = json["content_set_url"].asCString();
|
_contentURL = json["content_set_url"].asCString();
|
||||||
_domainURL = json["domain"].asCString();
|
_domainURL = json["domain"].asCString();
|
||||||
|
_organizationBuildTag = json.get("build_tag", "").asCString();
|
||||||
|
auto buildTag = _organizationBuildTag.IsEmpty() ? _defaultBuildTag : _organizationBuildTag;
|
||||||
|
|
||||||
|
if (!findBuildInResponse(_latestBuilds, buildTag, _latestApplicationURL, _latestVersion)) {
|
||||||
|
return LauncherUtils::ResponseError::ParsingJSON;
|
||||||
|
}
|
||||||
|
|
||||||
return LauncherUtils::ResponseError::NoError;
|
return LauncherUtils::ResponseError::NoError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,7 +475,9 @@ void LauncherManager::getMostRecentBuilds(CString& launcherUrlOut, CString& laun
|
||||||
std::function<void(CString, int)> httpCallback = [&](CString response, int err) {
|
std::function<void(CString, int)> httpCallback = [&](CString response, int err) {
|
||||||
LauncherUtils::ResponseError error = LauncherUtils::ResponseError(err);
|
LauncherUtils::ResponseError error = LauncherUtils::ResponseError(err);
|
||||||
if (error == LauncherUtils::ResponseError::NoError) {
|
if (error == LauncherUtils::ResponseError::NoError) {
|
||||||
Json::Value json;
|
Json::Value& json = _latestBuilds;
|
||||||
|
_defaultBuildTag = json.get("default_tag", "hqlauncher").asCString();
|
||||||
|
auto buildTag = _organizationBuildTag.IsEmpty() ? _defaultBuildTag : _organizationBuildTag;
|
||||||
if (LauncherUtils::parseJSON(response, json)) {
|
if (LauncherUtils::parseJSON(response, json)) {
|
||||||
if (json["launcher"].isObject()) {
|
if (json["launcher"].isObject()) {
|
||||||
if (json["launcher"]["windows"].isObject() && json["launcher"]["windows"]["url"].isString()) {
|
if (json["launcher"]["windows"].isObject() && json["launcher"]["windows"]["url"].isString()) {
|
||||||
|
@ -440,24 +488,12 @@ void LauncherManager::getMostRecentBuilds(CString& launcherUrlOut, CString& laun
|
||||||
launcherVersionOut = CString(version.c_str());
|
launcherVersionOut = CString(version.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int count = json["count"].isInt() ? json["count"].asInt() : 0;
|
|
||||||
if (count > 0 && json["results"].isArray()) {
|
if (launcherUrlOut.IsEmpty() || launcherVersionOut.IsEmpty()) {
|
||||||
for (int i = 0; i < count; i++) {
|
error = LauncherUtils::ResponseError::ParsingJSON;
|
||||||
if (json["results"][i].isObject()) {
|
|
||||||
Json::Value result = json["results"][i];
|
|
||||||
if (result["latest_version"].isInt()) {
|
|
||||||
std::string version = std::to_string(result["latest_version"].asInt());
|
|
||||||
interfaceVersionOut = CString(version.c_str());
|
|
||||||
}
|
}
|
||||||
if (result["installers"].isObject() &&
|
|
||||||
result["installers"]["windows"].isObject() &&
|
if (!findBuildInResponse(json, buildTag, _latestApplicationURL, _latestVersion)) {
|
||||||
result["installers"]["windows"]["zip_url"].isString()) {
|
|
||||||
interfaceUrlOut = result["installers"]["windows"]["zip_url"].asCString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (launcherUrlOut.IsEmpty() || launcherVersionOut.IsEmpty() || interfaceUrlOut.IsEmpty() || interfaceVersionOut.IsEmpty()) {
|
|
||||||
error = LauncherUtils::ResponseError::ParsingJSON;
|
error = LauncherUtils::ResponseError::ParsingJSON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,8 +509,8 @@ void LauncherManager::getMostRecentBuilds(CString& launcherUrlOut, CString& laun
|
||||||
void LauncherManager::onMostRecentBuildsReceived(const CString& response, LauncherUtils::ResponseError error) {
|
void LauncherManager::onMostRecentBuildsReceived(const CString& response, LauncherUtils::ResponseError error) {
|
||||||
if (error == LauncherUtils::ResponseError::NoError) {
|
if (error == LauncherUtils::ResponseError::NoError) {
|
||||||
addToLog(_T("Latest launcher version: ") + _latestLauncherVersion);
|
addToLog(_T("Latest launcher version: ") + _latestLauncherVersion);
|
||||||
CString currentVersion;
|
CString currentVersion = _currentVersion;
|
||||||
BOOL isInstalled = (isApplicationInstalled(currentVersion, _domainURL, _contentURL, _loggedIn) && _loggedIn);
|
BOOL isInstalled = _isInstalled && _loggedIn;
|
||||||
bool newInterfaceVersion = _latestVersion.Compare(currentVersion) != 0;
|
bool newInterfaceVersion = _latestVersion.Compare(currentVersion) != 0;
|
||||||
bool newLauncherVersion = _latestLauncherVersion.Compare(_launcherVersion) != 0 && _updateLauncherAllowed;
|
bool newLauncherVersion = _latestLauncherVersion.Compare(_launcherVersion) != 0 && _updateLauncherAllowed;
|
||||||
if (newLauncherVersion) {
|
if (newLauncherVersion) {
|
||||||
|
@ -511,7 +547,7 @@ void LauncherManager::onMostRecentBuildsReceived(const CString& response, Launch
|
||||||
_shouldWait = FALSE;
|
_shouldWait = FALSE;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_hasFailed = true;
|
setFailed(true);
|
||||||
CString msg;
|
CString msg;
|
||||||
msg.Format(_T("Getting most recent builds has failed with error: %d"), error);
|
msg.Format(_T("Getting most recent builds has failed with error: %d"), error);
|
||||||
addToLog(msg);
|
addToLog(msg);
|
||||||
|
@ -611,7 +647,7 @@ BOOL LauncherManager::extractApplication() {
|
||||||
onZipExtracted((ProcessType)type, size);
|
onZipExtracted((ProcessType)type, size);
|
||||||
} else {
|
} else {
|
||||||
addToLog(_T("Error decompressing application zip file."));
|
addToLog(_T("Error decompressing application zip file."));
|
||||||
_hasFailed = true;
|
setFailed(true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::function<void(float)> onProgress = [&](float progress) {
|
std::function<void(float)> onProgress = [&](float progress) {
|
||||||
|
@ -688,7 +724,7 @@ BOOL LauncherManager::installContent() {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
addToLog(_T("Error decompressing content zip file."));
|
addToLog(_T("Error decompressing content zip file."));
|
||||||
_hasFailed = true;
|
setFailed(_hasFailed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::function<void(float)> onProgress = [&](float progress) {
|
std::function<void(float)> onProgress = [&](float progress) {
|
||||||
|
@ -728,7 +764,7 @@ BOOL LauncherManager::downloadFile(ProcessType type, const CString& url, CString
|
||||||
} else {
|
} else {
|
||||||
addToLog(_T("Error downloading application."));
|
addToLog(_T("Error downloading application."));
|
||||||
}
|
}
|
||||||
_hasFailed = true;
|
setFailed(_hasFailed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
std::function<void(float)> onProgress = [&, type](float progress) {
|
std::function<void(float)> onProgress = [&, type](float progress) {
|
||||||
|
|
|
@ -76,7 +76,7 @@ public:
|
||||||
BOOL getAndCreatePaths(PathType type, CString& outPath);
|
BOOL getAndCreatePaths(PathType type, CString& outPath);
|
||||||
BOOL getInstalledVersion(const CString& path, CString& version);
|
BOOL getInstalledVersion(const CString& path, CString& version);
|
||||||
BOOL isApplicationInstalled(CString& version, CString& domain,
|
BOOL isApplicationInstalled(CString& version, CString& domain,
|
||||||
CString& content, bool& loggedIn);
|
CString& content, bool& loggedIn, CString& organizationBuildTag);
|
||||||
LauncherUtils::ResponseError getAccessTokenForCredentials(const CString& username, const CString& password);
|
LauncherUtils::ResponseError getAccessTokenForCredentials(const CString& username, const CString& password);
|
||||||
void getMostRecentBuilds(CString& launcherUrlOut,
|
void getMostRecentBuilds(CString& launcherUrlOut,
|
||||||
CString& launcherVersionOut,
|
CString& launcherVersionOut,
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
CString& interfaceVersionOut);
|
CString& interfaceVersionOut);
|
||||||
LauncherUtils::ResponseError readOrganizationJSON(const CString& hash);
|
LauncherUtils::ResponseError readOrganizationJSON(const CString& hash);
|
||||||
LauncherUtils::ResponseError readConfigJSON(CString& version, CString& domain,
|
LauncherUtils::ResponseError readConfigJSON(CString& version, CString& domain,
|
||||||
CString& content, bool& loggedIn);
|
CString& content, bool& loggedIn, CString& organizationBuildTag);
|
||||||
BOOL createConfigJSON();
|
BOOL createConfigJSON();
|
||||||
BOOL createApplicationRegistryKeys(int size);
|
BOOL createApplicationRegistryKeys(int size);
|
||||||
BOOL deleteApplicationRegistryKeys();
|
BOOL deleteApplicationRegistryKeys();
|
||||||
|
@ -139,10 +139,12 @@ public:
|
||||||
private:
|
private:
|
||||||
ProcessType _currentProcess { ProcessType::DownloadApplication };
|
ProcessType _currentProcess { ProcessType::DownloadApplication };
|
||||||
void onMostRecentBuildsReceived(const CString& response, LauncherUtils::ResponseError error);
|
void onMostRecentBuildsReceived(const CString& response, LauncherUtils::ResponseError error);
|
||||||
|
|
||||||
CString _latestApplicationURL;
|
CString _latestApplicationURL;
|
||||||
CString _latestVersion;
|
CString _latestVersion;
|
||||||
CString _latestLauncherURL;
|
CString _latestLauncherURL;
|
||||||
CString _latestLauncherVersion;
|
CString _latestLauncherVersion;
|
||||||
|
|
||||||
CString _contentURL;
|
CString _contentURL;
|
||||||
CString _domainURL;
|
CString _domainURL;
|
||||||
CString _version;
|
CString _version;
|
||||||
|
@ -152,6 +154,8 @@ private:
|
||||||
CString _contentZipPath;
|
CString _contentZipPath;
|
||||||
CString _launcherVersion;
|
CString _launcherVersion;
|
||||||
CString _tempLauncherPath;
|
CString _tempLauncherPath;
|
||||||
|
CString _currentVersion;
|
||||||
|
bool _isInstalled{ false };
|
||||||
bool _loggedIn { false };
|
bool _loggedIn { false };
|
||||||
bool _hasFailed { false };
|
bool _hasFailed { false };
|
||||||
BOOL _shouldUpdate { FALSE };
|
BOOL _shouldUpdate { FALSE };
|
||||||
|
@ -171,4 +175,7 @@ private:
|
||||||
float _progressOffset { 0.0f };
|
float _progressOffset { 0.0f };
|
||||||
float _progress { 0.0f };
|
float _progress { 0.0f };
|
||||||
CStdioFile _logFile;
|
CStdioFile _logFile;
|
||||||
|
Json::Value _latestBuilds;
|
||||||
|
CString _defaultBuildTag;
|
||||||
|
CString _organizationBuildTag;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue