diff --git a/launchers/qt/src/Helper.cpp b/launchers/qt/src/Helper.cpp index 43f633bb57..d09088a0e6 100644 --- a/launchers/qt/src/Helper.cpp +++ b/launchers/qt/src/Helper.cpp @@ -62,22 +62,17 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt outFile.close(); } -void swapLaunchers(const QString& oldLauncherPath, const QString& newLauncherPath) { +bool swapLaunchers(const QString& oldLauncherPath, const QString& newLauncherPath) { if (!(QFileInfo::exists(oldLauncherPath) && QFileInfo::exists(newLauncherPath))) { qDebug() << "old launcher: " << oldLauncherPath << "new launcher: " << newLauncherPath << " file does not exist"; } bool success = false; #ifdef Q_OS_MAC + qDebug() << "replacing launchers -> old launcher: " << oldLauncherPath << " new launcher: " << newLauncherPath; success = replaceDirectory(oldLauncherPath, newLauncherPath); #endif - - if (success) { - qDebug() << "succeessfully replaced"; - } else { - qDebug() << "failed"; - exit(0); - } + return success; } diff --git a/launchers/qt/src/Helper.h b/launchers/qt/src/Helper.h index 2d1f06052f..619b754c5a 100644 --- a/launchers/qt/src/Helper.h +++ b/launchers/qt/src/Helper.h @@ -12,7 +12,7 @@ void launchClient(const QString& clientPath, const QString& homePath, const QStr void launchAutoUpdater(const QString& autoUpdaterPath); -void swapLaunchers(const QString& oldLauncherPath = QString(), const QString& newLauncherPath = QString()); +bool swapLaunchers(const QString& oldLauncherPath = QString(), const QString& newLauncherPath = QString()); void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message); void cleanLogFile(); diff --git a/launchers/qt/src/Helper_darwin.mm b/launchers/qt/src/Helper_darwin.mm index 2015c830cf..8b7ad16a87 100644 --- a/launchers/qt/src/Helper_darwin.mm +++ b/launchers/qt/src/Helper_darwin.mm @@ -97,10 +97,17 @@ void launchAutoUpdater(const QString& autoUpdaterPath) { bool replaceDirectory(const QString& orginalDirectory, const QString& newDirectory) { + NSError *error = nil; NSFileManager* fileManager = [NSFileManager defaultManager]; NSURL* destinationUrl = [UpdaterHelper NSStringToNSURL:newDirectory.toNSString()]; - return (bool) [fileManager replaceItemAtURL:[UpdaterHelper NSStringToNSURL:orginalDirectory.toNSString()] withItemAtURL:[UpdaterHelper NSStringToNSURL:newDirectory.toNSString()] - backupItemName:nil options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:&destinationUrl error:nil]; + bool success = (bool) [fileManager replaceItemAtURL:[UpdaterHelper NSStringToNSURL:orginalDirectory.toNSString()] withItemAtURL:[UpdaterHelper NSStringToNSURL:newDirectory.toNSString()] + backupItemName:nil options:NSFileManagerItemReplacementUsingNewMetadataOnly resultingItemURL:&destinationUrl error:&error]; + + if (error != nil) { + qDebug() << "NSFileManager::replaceItemAtURL -> error: " << error; + } + + return success; } @@ -124,7 +131,6 @@ void waitForInterfaceToClose() { bool isLauncherAlreadyRunning() { NSArray* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.highfidelity.launcher"]; if ([apps count] > 1) { - NSLog(@"launcher is already running"); qDebug() << "launcher is already running"; return true; } diff --git a/launchers/qt/src/Helper_windows.cpp b/launchers/qt/src/Helper_windows.cpp index 662e64daae..ec4f5c4063 100644 --- a/launchers/qt/src/Helper_windows.cpp +++ b/launchers/qt/src/Helper_windows.cpp @@ -161,7 +161,7 @@ BOOL isProcessRunning(const char* processName, int& processID) { entry.dwSize = sizeof(PROCESSENTRY32); HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); - + if (Process32First(snapshot, &entry)) { while (Process32Next(snapshot, &entry)) { if (!_stricmp(entry.szExeFile, processName)) { diff --git a/launchers/qt/src/LauncherInstaller_windows.cpp b/launchers/qt/src/LauncherInstaller_windows.cpp index 9be8c6cc1b..7ba8b8e2d2 100644 --- a/launchers/qt/src/LauncherInstaller_windows.cpp +++ b/launchers/qt/src/LauncherInstaller_windows.cpp @@ -53,7 +53,7 @@ void LauncherInstaller::install() { deleteShortcuts(); createShortcuts(); - + deleteApplicationRegistryKeys(); createApplicationRegistryKeys(); } else { qDebug() << "Failed to install HQ Launcher"; @@ -85,17 +85,31 @@ void LauncherInstaller::createShortcuts() { (LPCSTR)("Click to Setup and Launch HQ")); } +QString randomQtString() { + const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); + const int randomStringLength = 5; + auto now = std::chrono::system_clock::now(); + auto duration = std::chrono::duration_cast(now.time_since_epoch()); + qsrand(duration.count()); + + QString randomString; + for(int i = 0; i < randomStringLength; i++) + { + int index = qrand() % possibleCharacters.length(); + QChar nextChar = possibleCharacters.at(index); + randomString.append(nextChar); + } + return randomString; +} + void LauncherInstaller::uninstall() { qDebug() << "Uninstall Launcher"; deleteShortcuts(); CommandlineOptions* options = CommandlineOptions::getInstance(); if (!options->contains("--resumeUninstall")) { QDir tmpDirectory = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - QString destination = tmpDirectory.absolutePath() + "/HQ Launcher.exe"; - qDebug() << destination; - if (QFile::exists(destination)) { - QFile::remove(destination); - } + QString destination = tmpDirectory.absolutePath() + "/" + randomQtString() + ".exe"; + qDebug() << "temp file destination: " << destination; bool copied = QFile::copy(_launcherRunningFilePath, destination); if (copied) { @@ -195,12 +209,14 @@ void LauncherInstaller::uninstallOldLauncher() { void LauncherInstaller::createApplicationRegistryKeys() { const std::string REGISTRY_PATH = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\HQ"; bool success = insertRegistryKey(REGISTRY_PATH, "DisplayName", "HQ"); - std::string installPath = _launcherInstallDir.absolutePath().toStdString(); + std::string installPath = _launcherInstallDir.absolutePath().replace("/", "\\").toStdString(); success = insertRegistryKey(REGISTRY_PATH, "InstallLocation", installPath); - std::string applicationExe = installPath + "/HQ Launcher.exe"; - std::string uninstallPath = '"' + applicationExe + '"' + " --uninstall"; + std::string applicationExe = installPath + "\\HQ Launcher.exe"; + std::string uninstallPath = applicationExe + " --uninstall"; + qDebug() << QString::fromStdString(applicationExe); + qDebug() << QString::fromStdString(uninstallPath); success = insertRegistryKey(REGISTRY_PATH, "UninstallString", uninstallPath); - success = insertRegistryKey(REGISTRY_PATH, "DisplayVersion", "DEV"); + success = insertRegistryKey(REGISTRY_PATH, "DisplayVersion", std::string(LAUNCHER_BUILD_VERSION)); success = insertRegistryKey(REGISTRY_PATH, "DisplayIcon", applicationExe); success = insertRegistryKey(REGISTRY_PATH, "Publisher", "High Fidelity"); @@ -209,7 +225,7 @@ void LauncherInstaller::createApplicationRegistryKeys() { std::stringstream date; date << std::put_time(std::localtime(&now), "%Y-%m-%d") ; success = insertRegistryKey(REGISTRY_PATH, "InstallDate", date.str()); - //success = LauncherUtils::insertRegistryKey(REGISTRY_PATH, "EstimatedSize", (DWORD)size); + success = insertRegistryKey(REGISTRY_PATH, "EstimatedSize", (DWORD)14181); success = insertRegistryKey(REGISTRY_PATH, "NoModify", (DWORD)1); success = insertRegistryKey(REGISTRY_PATH, "NoRepair", (DWORD)1); @@ -218,7 +234,6 @@ void LauncherInstaller::createApplicationRegistryKeys() { void LauncherInstaller::deleteApplicationRegistryKeys() { const std::string regPath= "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\HQ"; - if (!deleteRegistryKey(regPath.c_str())) { - qDebug() << "Failed to delete registryKeys"; - } + bool success = deleteRegistryKey(regPath.c_str()); + qDebug() << "Did delete Application Registry Keys: " << success; } diff --git a/launchers/qt/src/LoginRequest.cpp b/launchers/qt/src/LoginRequest.cpp index ecbbd8d743..5aed5d2700 100644 --- a/launchers/qt/src/LoginRequest.cpp +++ b/launchers/qt/src/LoginRequest.cpp @@ -73,7 +73,7 @@ void LoginRequest::receivedResponse() { _token.refreshToken = root["refresh_token"].toString(); _token.tokenType = root["token_type"].toString(); - qDebug() << "Got response for login: " << data; + qDebug() << "Got response for login"; _rawLoginToken = data; emit finished(); diff --git a/launchers/qt/src/main.cpp b/launchers/qt/src/main.cpp index 33351dfbdf..c7925a79dc 100644 --- a/launchers/qt/src/main.cpp +++ b/launchers/qt/src/main.cpp @@ -37,6 +37,8 @@ int main(int argc, char *argv[]) { Q_INIT_RESOURCE(resources); cleanLogFile(); qInstallMessageHandler(messageHandler); + CommandlineOptions* options = CommandlineOptions::getInstance(); + options->parse(argc, argv); bool didUpdate = false; #ifdef Q_OS_MAC @@ -46,15 +48,16 @@ int main(int argc, char *argv[]) { closeInterfaceIfRunning(); if (argc == 3) { if (hasSuffix(argv[1], "app") && hasSuffix(argv[2], "app")) { - swapLaunchers(argv[1], argv[2]); + bool success = swapLaunchers(argv[1], argv[2]); + qDebug() << "Launcher install success: " << success; + if (!success) { + options->append("--noUpdate"); + } didUpdate = true; } } #endif - CommandlineOptions* options = CommandlineOptions::getInstance(); - options->parse(argc, argv); - if (options->contains("--version")) { std::cout << LAUNCHER_BUILD_VERSION << std::endl; return 0; diff --git a/tools/qt-builder/qt-lite-osx-config.opt b/tools/qt-builder/qt-lite-osx-config.opt new file mode 100644 index 0000000000..28bb1b88e2 --- /dev/null +++ b/tools/qt-builder/qt-lite-osx-config.opt @@ -0,0 +1,184 @@ +-static +-optimize-size +-qt-libpng +-no-libjpeg +-qt-sqlite +-qt-zlib +-qt-freetype +-qt-pcre +-strip +-opensource +-release +-nomake +tests +-nomake +examples +-nomake +tests +-no-compile-examples +-no-pch +-confirm-license +-skip +qtmultimedia +-prefix +./qt-install +-openssl-linked +OPENSSL_LIBS=-lssl -lcrypto +-L/usr/local/Cellar/openssl/1.0.2s/lib +-I/usr/local/Cellar/openssl/1.0.2s/include +-no-feature-widgets +-no-feature-dbus +-no-feature-xml +-no-feature-sql +-no-feature-concurrent +-no-feature-quicktemplates2-hover +-no-feature-quicktemplates2-multitouch +-no-feature-quickcontrols2-material +-no-feature-quickcontrols2-universal +-no-feature-qml-network +-no-feature-qml-profiler +-no-feature-quick-listview +-no-feature-quick-particles +-no-feature-abstractbutton +-no-feature-abstractslider +-no-feature-buttongroup +-no-feature-calendarwidget +-no-feature-checkbox +-no-feature-combobox +-no-feature-commandlinkbutton +-no-feature-contextmenu +-no-feature-datetimeedit +-no-feature-dial +-no-feature-dockwidget +-no-feature-fontcombobox +-no-feature-formlayout +-no-feature-graphicseffect +-no-feature-graphicsview +-no-feature-groupbox +-no-feature-keysequenceedit +-no-feature-label +-no-feature-lcdnumber +-no-feature-lineedit +-no-feature-listwidget +-no-feature-mainwindow +-no-feature-mdiarea +-no-feature-menu +-no-feature-menubar +-no-feature-printpreviewwidget +-no-feature-progressbar +-no-feature-pushbutton +-no-feature-radiobutton +-no-feature-resizehandler +-no-feature-rubberband +-no-feature-scrollarea +-no-feature-scrollbar +-no-feature-scroller +-no-feature-sizegrip +-no-feature-slider +-no-feature-spinbox +-no-feature-splashscreen +-no-feature-splitter +-no-feature-stackedwidget +-no-feature-statusbar +-no-feature-statustip +-no-feature-syntaxhighlighter +-no-feature-tabbar +-no-feature-tablewidget +-no-feature-tabwidget +-no-feature-textbrowser +-no-feature-textedit +-no-feature-toolbar +-no-feature-toolbox +-no-feature-toolbutton +-no-feature-tooltip +-no-feature-treewidget +-no-feature-validator +-no-feature-widgettextcontrol +-no-feature-quick-designer +-no-feature-quick-flipable +-no-feature-quick-pathview +-no-feature-qml-profiler +-no-feature-gif +-no-feature-ico +-no-feature-harfbuzz +-no-feature-qml-debug +-no-feature-quick-listview +-no-feature-quick-sprite +-no-feature-quick-path +-no-feature-quick-canvas +-no-feature-quick-animatedimage +-no-feature-qml-interpreter +-no-feature-action +-no-feature-cssparser +-no-feature-sharedmemory +-no-feature-tabletevent +-no-feature-texthtmlparser +-no-feature-textodfwriter +-no-feature-sessionmanager +-no-feature-systemsemaphore +-no-feature-im +-no-feature-effects +-no-feature-appstore-compliant +-no-feature-big_codecs +-no-feature-codecs +-no-feature-colordialog +-no-feature-colornames +-no-feature-columnview +-no-feature-commandlineparser +-no-feature-cups +-no-feature-d3d12 +-no-feature-datawidgetmapper +-no-feature-datetimeparser +-no-feature-desktopservices +-no-feature-dialog +-no-feature-dialogbuttonbox +-no-feature-dirmodel +-no-feature-dom +-no-feature-errormessage +-no-feature-filedialog +-no-feature-filesystemiterator +-no-feature-filesystemwatcher +-no-feature-fontdialog +-no-feature-fscompleter +-no-feature-gestures +-no-feature-iconv +-no-feature-wizard +-no-feature-xmlstreamwriter +-no-feature-whatsthis +-no-feature-undoview +-no-feature-undostack +-no-feature-undogroup +-no-feature-undocommand +-no-feature-treeview +-no-feature-translation +-no-feature-topleveldomain +-no-feature-tableview +-no-feature-style-stylesheet +-no-feature-stringlistmodel +-no-feature-sortfilterproxymodel +-no-feature-wheelevent +-no-feature-statemachine +-no-feature-standarditemmodel +-no-feature-proxymodel +-no-feature-printer +-no-feature-printpreviewdialog +-no-feature-printdialog +-no-feature-picture +-no-feature-pdf +-no-feature-movie +-no-feature-messagebox +-no-feature-listview +-no-feature-itemmodel +-no-feature-inputdialog +-no-feature-filesystemmodel +-no-feature-identityproxymodel +-no-feature-mimetype +-no-feature-paint_debug +-no-feature-progressdialog +-no-feature-quick-positioners +-no-feature-sha3-fast +-no-feature-shortcut +-no-feature-completer +-no-feature-image_heuristic_mask +-no-feature-image_text +-no-feature-imageformat_bmp