diff --git a/launchers/qt/CMakeLists.txt b/launchers/qt/CMakeLists.txt index 9896e3f5d9..e633d7f0e4 100644 --- a/launchers/qt/CMakeLists.txt +++ b/launchers/qt/CMakeLists.txt @@ -131,6 +131,7 @@ set(src_files src/Unzipper.h src/Unzipper.cpp src/Helper.h + src/Helper.cpp deps/miniz/miniz.h deps/miniz/miniz.cpp ) diff --git a/launchers/qt/src/Helper.cpp b/launchers/qt/src/Helper.cpp index 8bbab41698..2c7f89f0df 100644 --- a/launchers/qt/src/Helper.cpp +++ b/launchers/qt/src/Helper.cpp @@ -1,5 +1,49 @@ #include "Helper.h" +#ifdef Q_OS_WIN +#include +#endif + +#if defined(Q_OS_WIN) void launchClient(const QString& homePath, const QString& defaultScriptOverride, const QString& displayName, const QString& contentCachePath, const QString& loginResponseToken) { + + // TODO Fix parameters + QString params = "--url " + homePath + + " --setBookmark hqhome=\"" + homePath + "\"" + + " --defaultScriptsOverride " + defaultScriptsPath + + " --displayName " + displayName + + " --cache " + contentCachePath; + + if (!_loginTokenResponse.isEmpty()) { + params += " --tokens \"" + _loginTokenResponse.replace("\"", "\\\"") + "\""; + } + + STARTUPINFO si; + PROCESS_INFORMATION pi; + + // set the size of the structures + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + ZeroMemory(&pi, sizeof(pi)); + + // start the program up + BOOL success = CreateProcess( + clientPath.toUtf8().data(), + params.toUtf8().data(), + nullptr, // Process handle not inheritable + nullptr, // Thread handle not inheritable + FALSE, // Set handle inheritance to FALSE + CREATE_NEW_CONSOLE, // Opens file in a separate console + nullptr, // Use parent's environment block + nullptr, // Use parent's starting directory + &si, // Pointer to STARTUPINFO structure + &pi // Pointer to PROCESS_INFORMATION structure + ); + // Close process and thread handles. + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + exit(0); } + +#endif diff --git a/launchers/qt/src/LauncherState.cpp b/launchers/qt/src/LauncherState.cpp index 2111568780..0f32aeb6b7 100644 --- a/launchers/qt/src/LauncherState.cpp +++ b/launchers/qt/src/LauncherState.cpp @@ -416,56 +416,26 @@ void LauncherState::launchClient() { setApplicationState(ApplicationState::LaunchingHighFidelity); QDir installDirectory = _launcherDirectory.filePath("interface_install"); - auto clientPath = installDirectory.absoluteFilePath("interface.app/Contents/MacOS/interface"); + QString clientPath; +#if defined(Q_OS_WIN) + clientPath = installDirectory.absoluteFilePath("interface.exe"); +#elif defined(Q_OS_MACOS) + clientPath = installDirectory.absoluteFilePath("interface.app/Contents/MacOS/interface"); +#endif QString homePath = "hifi://hq"; - QString defaultScriptsPath = installDirectory.filePath("scripts/simplifiedUIBootstrapper"); + QString defaultScriptsPath; +#if defined(Q_OS_WIN) + defaultScriptsPath = installDirectory.filePath("scripts/simplifiedUIBootstrapper.js"); +#elif defined(Q_OS_MACOS) + defaultScriptsPath = installDirectory.filePath("interface.app/Contents/Resources/scripts/simplifiedUIBootstrapper.js"); +#endif + + qDebug() << "------> " << defaultScriptsPath; QString displayName = "fixMe"; QString contentCachePath = _launcherDirectory.filePath("cache"); - //::launchClient(clientPath, homePath, defaultScriptsPath, displayName, contentCachePath, _loginTokenResponse); - /* // TODO Fix parameters - QString params = "--url " + homePath - + " --setBookmark hqhome=\"" + homePath + "\"" - + " --defaultScriptsOverride " + QDir::toNativeSeparators(defaultScriptsPath) - + " --displayName " + displayName - + " --cache " + contentCachePath; - - if (!_loginTokenResponse.isEmpty()) { - params += " --tokens \"" + _loginTokenResponse.replace("\"", "\\\"") + "\""; - } - -#if defined(Q_OS_WIN) - STARTUPINFO si; - PROCESS_INFORMATION pi; - - // set the size of the structures - ZeroMemory(&si, sizeof(si)); - si.cb = sizeof(si); - ZeroMemory(&pi, sizeof(pi)); - - // start the program up - BOOL success = CreateProcess( - clientPath.toUtf8().data(), - params.toUtf8().data(), - nullptr, // Process handle not inheritable - nullptr, // Thread handle not inheritable - FALSE, // Set handle inheritance to FALSE - CREATE_NEW_CONSOLE, // Opens file in a separate console - nullptr, // Use parent's environment block - nullptr, // Use parent's starting directory - &si, // Pointer to STARTUPINFO structure - &pi // Pointer to PROCESS_INFORMATION structure - ); - // Close process and thread handles. - CloseHandle(pi.hProcess); - CloseHandle(pi.hThread); - exit(0); -#elif defined(Q_OS_MACOS) - // TODO Implement launching of client -#else -#error UNSUPPORTED PLATFORM -#endif*/ + ::launchClient(clientPath, homePath, QDir::toNativeSeparators(defaultScriptsPath), displayName, contentCachePath, _loginTokenResponse); } void LauncherState::setApplicationState(ApplicationState state) {