mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 07:02:46 +02:00
Update qt launcher with interface killing, home location in config, and extra launch params
This commit is contained in:
parent
f236b64b06
commit
fccc7d3c2c
5 changed files with 56 additions and 8 deletions
|
@ -32,6 +32,9 @@ HRESULT createSymbolicLink(LPCSTR lpszPathObj, LPCSTR lpszPathLink, LPCSTR lpszD
|
|||
bool insertRegistryKey(const std::string& regPath, const std::string& name, const std::string& value);
|
||||
bool insertRegistryKey(const std::string& regPath, const std::string& name, DWORD value);
|
||||
bool deleteRegistryKey(const std::string& regPath);
|
||||
|
||||
BOOL isProcessRunning(const char* processName, int& processID);
|
||||
BOOL shutdownProcess(DWORD dwProcessId, UINT uExitCode);
|
||||
#endif
|
||||
|
||||
QString getHTTPUserAgent();
|
||||
|
|
|
@ -18,7 +18,8 @@ void launchClient(const QString& clientPath, const QString& homePath, const QStr
|
|||
+ " --setBookmark \"hqhome=" + homePath + "\""
|
||||
+ " --defaultScriptsOverride \"file:///" + defaultScriptsPath + "\""
|
||||
+ " --displayName \"" + displayName + "\""
|
||||
+ " --cache \"" + contentCachePath + "\"";
|
||||
+ " --cache \"" + contentCachePath + "\""
|
||||
+ " --suppress-settings-reset --no-launcher --no-updater";
|
||||
|
||||
if (!loginResponseToken.isEmpty()) {
|
||||
params += " --tokens \"" + loginResponseToken.replace("\"", "\\\"") + "\"";
|
||||
|
@ -147,3 +148,36 @@ bool deleteRegistryKey(const std::string& regPath) {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
BOOL isProcessRunning(const char* processName, int& processID) {
|
||||
bool exists = false;
|
||||
PROCESSENTRY32 entry;
|
||||
entry.dwSize = sizeof(PROCESSENTRY32);
|
||||
|
||||
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
|
||||
|
||||
if (Process32First(snapshot, &entry)) {
|
||||
while (Process32Next(snapshot, &entry)) {
|
||||
if (!_stricmp(entry.szExeFile, processName)) {
|
||||
exists = true;
|
||||
processID = entry.th32ProcessID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(snapshot);
|
||||
return exists;
|
||||
}
|
||||
|
||||
BOOL shutdownProcess(DWORD dwProcessId, UINT uExitCode) {
|
||||
DWORD dwDesiredAccess = PROCESS_TERMINATE;
|
||||
BOOL bInheritHandle = FALSE;
|
||||
HANDLE hProcess = OpenProcess(dwDesiredAccess, bInheritHandle, dwProcessId);
|
||||
if (hProcess == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
BOOL result = TerminateProcess(hProcess, uExitCode);
|
||||
CloseHandle(hProcess);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
//#define BREAK_ON_ERROR
|
||||
|
||||
const QString configHomeLocationKey { "homeLocation" };
|
||||
const QString configLoggedInKey{ "loggedIn" };
|
||||
const QString configLauncherPathKey{ "launcherPath" };
|
||||
|
||||
|
@ -223,6 +224,9 @@ void LauncherState::getCurrentClientVersion() {
|
|||
if (root.contains(configLoggedInKey)) {
|
||||
_config.loggedIn = root["loggedIn"].toBool();
|
||||
}
|
||||
if (root.contains(configHomeLocationKey)) {
|
||||
_config.homeLocation = root["homeLocation"].toString();
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Failed to open config.json";
|
||||
}
|
||||
|
@ -353,15 +357,15 @@ void LauncherState::requestSettings() {
|
|||
connect(request, &UserSettingsRequest::finished, this, [this, request]() {
|
||||
auto userSettings = request->getUserSettings();
|
||||
if (userSettings.homeLocation.isEmpty()) {
|
||||
_homeLocation = "hifi://hq";
|
||||
_config.homeLocation = "hifi://hq";
|
||||
_contentCacheURL = "";
|
||||
} else {
|
||||
_homeLocation = userSettings.homeLocation;
|
||||
auto host = QUrl(_homeLocation).host();
|
||||
_config.homeLocation = userSettings.homeLocation;
|
||||
auto host = QUrl(_config.homeLocation).host();
|
||||
_contentCacheURL = "http://orgs.highfidelity.com/host-content-cache/" + host + ".zip";
|
||||
}
|
||||
|
||||
qDebug() << "Home location is: " << _homeLocation;
|
||||
qDebug() << "Home location is: " << _config.homeLocation;
|
||||
qDebug() << "Content cache url is: " << _contentCacheURL;
|
||||
|
||||
downloadClient();
|
||||
|
@ -640,6 +644,7 @@ void LauncherState::launchClient() {
|
|||
if (configFile.open(QIODevice::WriteOnly)) {
|
||||
QJsonDocument doc = QJsonDocument::fromJson(configFile.readAll());
|
||||
doc.setObject({
|
||||
{ configHomeLocationKey, _config.homeLocation },
|
||||
{ configLoggedInKey, _config.loggedIn },
|
||||
{ configLauncherPathKey, _config.launcherPath },
|
||||
});
|
||||
|
@ -655,7 +660,7 @@ void LauncherState::launchClient() {
|
|||
|
||||
QString contentCachePath = _launcherDirectory.filePath("cache");
|
||||
|
||||
::launchClient(clientPath, _homeLocation, defaultScriptsPath, _displayName, contentCachePath, _loginTokenResponse);
|
||||
::launchClient(clientPath, _config.homeLocation, defaultScriptsPath, _displayName, contentCachePath, _loginTokenResponse);
|
||||
}
|
||||
|
||||
void LauncherState::setApplicationStateError(QString errorMessage) {
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
#include "BuildsRequest.h"
|
||||
|
||||
struct LauncherConfig {
|
||||
QString launcherPath{ QString::null };
|
||||
QString launcherPath{ "" };
|
||||
bool loggedIn{ false };
|
||||
QString homeLocation{ "" };
|
||||
};
|
||||
|
||||
class LauncherState : public QObject {
|
||||
|
@ -168,7 +169,6 @@ private:
|
|||
QString _buildTag { QString::null };
|
||||
QString _contentCacheURL;
|
||||
QString _loginTokenResponse;
|
||||
QString _homeLocation;
|
||||
QFile _clientZipFile;
|
||||
QFile _launcherZipFile;
|
||||
QFile _contentZipFile;
|
||||
|
|
|
@ -51,6 +51,12 @@ int main(int argc, char *argv[]) {
|
|||
launcherInstaller.uninstall();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int interfacePID = -1;
|
||||
if (isProcessRunning("interface.exe", interfacePID)) {
|
||||
shutdownProcess(interfacePID, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
QString name { "High Fidelity" };
|
||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
|
Loading…
Reference in a new issue