mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-05 21:22:07 +02:00
Add method for overriding builds API url in win32 launcher
This commit is contained in:
parent
83bc5e3fd6
commit
da1b2e9ec8
3 changed files with 33 additions and 10 deletions
|
@ -445,7 +445,7 @@ LauncherUtils::ResponseError LauncherManager::readOrganizationJSON(const CString
|
|||
CString response;
|
||||
CString url = _T("/organizations/") + hash + _T(".json");
|
||||
LauncherUtils::ResponseError error = LauncherUtils::makeHTTPCall(getHttpUserAgent(),
|
||||
L"orgs.highfidelity.com", url,
|
||||
true, L"orgs.highfidelity.com", url,
|
||||
contentTypeJson, CStringA(),
|
||||
response, false);
|
||||
if (error != LauncherUtils::ResponseError::NoError) {
|
||||
|
@ -500,9 +500,29 @@ void LauncherManager::getMostRecentBuilds(CString& launcherUrlOut, CString& laun
|
|||
}
|
||||
onMostRecentBuildsReceived(response, error);
|
||||
};
|
||||
|
||||
bool useHTTPS{ true };
|
||||
|
||||
CString domainName;
|
||||
if (domainName.GetEnvironmentVariable(L"HQ_LAUNCHER_BUILDS_DOMAIN")) {
|
||||
addToLog(_T("Using overridden builds domain: ") + domainName);
|
||||
useHTTPS = false;
|
||||
} else {
|
||||
domainName = L"thunder.highfidelity.com";
|
||||
}
|
||||
|
||||
CString pathName;
|
||||
if (pathName.GetEnvironmentVariable(L"HQ_LAUNCHER_BUILDS_PATH")) {
|
||||
addToLog(_T("Using overridden builds path: ") + pathName);
|
||||
useHTTPS = false;
|
||||
} else {
|
||||
pathName = L"/builds/api/tags/latest?format=json";
|
||||
}
|
||||
|
||||
LauncherUtils::httpCallOnThread(getHttpUserAgent(),
|
||||
L"thunder.highfidelity.com",
|
||||
L"/builds/api/tags/latest?format=json",
|
||||
useHTTPS,
|
||||
domainName,
|
||||
pathName,
|
||||
contentTypeJson, CStringA(), false, httpCallback);
|
||||
}
|
||||
|
||||
|
@ -567,6 +587,7 @@ LauncherUtils::ResponseError LauncherManager::getAccessTokenForCredentials(const
|
|||
CString contentTypeText = L"content-type:application/x-www-form-urlencoded";
|
||||
CString response;
|
||||
LauncherUtils::ResponseError error = LauncherUtils::makeHTTPCall(getHttpUserAgent(),
|
||||
true,
|
||||
L"metaverse.highfidelity.com",
|
||||
L"/oauth/token",
|
||||
contentTypeText, post,
|
||||
|
|
|
@ -181,7 +181,7 @@ BOOL LauncherUtils::deleteRegistryKey(const CString& registryPath) {
|
|||
}
|
||||
|
||||
LauncherUtils::ResponseError LauncherUtils::makeHTTPCall(const CString& callerName,
|
||||
const CString& mainUrl, const CString& dirUrl,
|
||||
bool useHTTPS, const CString& mainUrl, const CString& dirUrl,
|
||||
const CString& contentType, CStringA& postData,
|
||||
CString& response, bool isPost = false) {
|
||||
|
||||
|
@ -190,12 +190,12 @@ LauncherUtils::ResponseError LauncherUtils::makeHTTPCall(const CString& callerNa
|
|||
if (!hopen) {
|
||||
return ResponseError::Open;
|
||||
}
|
||||
HINTERNET hconnect = WinHttpConnect(hopen, mainUrl, INTERNET_DEFAULT_HTTPS_PORT, 0);
|
||||
HINTERNET hconnect = WinHttpConnect(hopen, mainUrl, useHTTPS ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT, 0);
|
||||
if (!hconnect) {
|
||||
return ResponseError::Connect;
|
||||
}
|
||||
HINTERNET hrequest = WinHttpOpenRequest(hconnect, isPost ? L"POST" : L"GET", dirUrl,
|
||||
NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_SECURE);
|
||||
NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, useHTTPS ? WINHTTP_FLAG_SECURE : 0);
|
||||
if (!hrequest) {
|
||||
return ResponseError::OpenRequest;
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ DWORD WINAPI LauncherUtils::deleteDirectoryThread(LPVOID lpParameter) {
|
|||
DWORD WINAPI LauncherUtils::httpThread(LPVOID lpParameter) {
|
||||
HttpThreadData& data = *((HttpThreadData*)lpParameter);
|
||||
CString response;
|
||||
auto error = LauncherUtils::makeHTTPCall(data._callerName, data._mainUrl, data._dirUrl,
|
||||
auto error = LauncherUtils::makeHTTPCall(data._callerName, data._useHTTPS, data._mainUrl, data._dirUrl,
|
||||
data._contentType, data._postData, response, data._isPost);
|
||||
data._callback(response, error);
|
||||
return 0;
|
||||
|
@ -552,12 +552,13 @@ BOOL LauncherUtils::deleteDirectoryOnThread(const CString& dirPath, std::functio
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL LauncherUtils::httpCallOnThread(const CString& callerName, const CString& mainUrl, const CString& dirUrl,
|
||||
BOOL LauncherUtils::httpCallOnThread(const CString& callerName, bool useHTTPS, const CString& mainUrl, const CString& dirUrl,
|
||||
const CString& contentType, CStringA& postData, bool isPost,
|
||||
std::function<void(CString, int)> callback) {
|
||||
DWORD myThreadID;
|
||||
HttpThreadData* httpThreadData = new HttpThreadData();
|
||||
httpThreadData->_callerName = callerName;
|
||||
httpThreadData->_useHTTPS = useHTTPS;
|
||||
httpThreadData->_mainUrl = mainUrl;
|
||||
httpThreadData->_dirUrl = dirUrl;
|
||||
httpThreadData->_contentType = contentType;
|
||||
|
|
|
@ -120,6 +120,7 @@ public:
|
|||
|
||||
struct HttpThreadData {
|
||||
CString _callerName;
|
||||
bool _useHTTPS;
|
||||
CString _mainUrl;
|
||||
CString _dirUrl;
|
||||
CString _contentType;
|
||||
|
@ -137,7 +138,7 @@ public:
|
|||
};
|
||||
|
||||
static BOOL parseJSON(const CString& jsonTxt, Json::Value& jsonObject);
|
||||
static ResponseError makeHTTPCall(const CString& callerName, const CString& mainUrl,
|
||||
static ResponseError makeHTTPCall(const CString& callerName, bool useHTTPS, const CString& mainUrl,
|
||||
const CString& dirUrl, const CString& contentType,
|
||||
CStringA& postData, CString& response, bool isPost);
|
||||
static std::string cStringToStd(CString cstring);
|
||||
|
@ -163,7 +164,7 @@ public:
|
|||
std::function<void(int, bool)> callback,
|
||||
std::function<void(float)> progressCallback);
|
||||
static BOOL deleteDirectoryOnThread(const CString& dirPath, std::function<void(bool)> callback);
|
||||
static BOOL httpCallOnThread(const CString& callerName, const CString& mainUrl, const CString& dirUrl,
|
||||
static BOOL httpCallOnThread(const CString& callerName, bool useHTTPS, const CString& mainUrl, const CString& dirUrl,
|
||||
const CString& contentType, CStringA& postData, bool isPost,
|
||||
std::function<void(CString, int)> callback);
|
||||
|
||||
|
|
Loading…
Reference in a new issue