From 05e932963596e1e9273628b488b4a4a96a8d189e Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Mon, 23 Sep 2019 08:27:22 -0700 Subject: [PATCH] Add proper version checking to qt launcher --- launchers/qt/CMakeLists.txt | 4 +-- launchers/qt/src/Helper.cpp | 1 + launchers/qt/src/Helper.h | 3 -- launchers/qt/src/LauncherState.cpp | 47 +++++++++++++++++++++++++++--- launchers/qt/src/LauncherState.h | 4 +++ 5 files changed, 50 insertions(+), 9 deletions(-) diff --git a/launchers/qt/CMakeLists.txt b/launchers/qt/CMakeLists.txt index e633d7f0e4..86654930c5 100644 --- a/launchers/qt/CMakeLists.txt +++ b/launchers/qt/CMakeLists.txt @@ -37,8 +37,8 @@ if (WIN32) ExternalProject_Add( qtlite - URL "https://hifi-public.s3.amazonaws.com/huffman/launcher/qt-lite-ssl.zip" - URL_HASH MD5=83eeba1565e5727aef11655acf893c15 + URL "https://hifi-public.s3.amazonaws.com/huffman/launcher/qt-lite-ssl_2019-9-19.zip" + URL_HASH MD5=8b7a0b8fb772a014a3276274f40a9d14 #83eeba1565e5727aef11655acf893c15 CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/launchers/qt/src/Helper.cpp b/launchers/qt/src/Helper.cpp index 75519492cb..f3ed87e9ab 100644 --- a/launchers/qt/src/Helper.cpp +++ b/launchers/qt/src/Helper.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #if defined(Q_OS_WIN) diff --git a/launchers/qt/src/Helper.h b/launchers/qt/src/Helper.h index 347f4888e5..f35d890433 100644 --- a/launchers/qt/src/Helper.h +++ b/launchers/qt/src/Helper.h @@ -2,10 +2,7 @@ #include void launchClient(const QString& clientPath, const QString& homePath, const QString& defaultScriptOverride, -<<<<<<< HEAD const QString& displayName, const QString& contentCachePath, QString loginResponseToken = QString()); -======= - const QString& displayName, const QString& contentCachePath, const QString& loginResponseToken = QString()); void launchAutoUpdater(const QString& autoUpdaterPath); diff --git a/launchers/qt/src/LauncherState.cpp b/launchers/qt/src/LauncherState.cpp index 3799d691f7..cddcb43a4a 100644 --- a/launchers/qt/src/LauncherState.cpp +++ b/launchers/qt/src/LauncherState.cpp @@ -9,6 +9,8 @@ #endif #include +#include + #include #include @@ -23,10 +25,30 @@ #include #include +#include -QString getCurrentClientVersion() { - // TODO Implement client version checking - return ""; +#include + +QString LauncherState::getCurrentClientVersion() { + QProcess client; + + client.start(getClientExecutablePath(), { "--version" }); + + QEventLoop loop; + connect(&client, QOverload::of(&QProcess::finished), &loop, &QEventLoop::exit); + loop.exec(); + + auto output = client.readAllStandardOutput(); + + QRegularExpression regex { "Interface (?\\d+)(-.*)?" }; + + auto match = regex.match(output); + + if (match.hasMatch()) { + return match.captured("version"); + } + + return QString::null; } @@ -261,6 +283,19 @@ QString LauncherState::getContentCachePath() const { return _launcherDirectory.filePath("cache"); } +QString LauncherState::getClientDirectory() const { + return _launcherDirectory.filePath("interface_install"); +} + +QString LauncherState::getClientExecutablePath() const { + QDir clientDirectory = getClientDirectory(); +#if defined(Q_OS_WIN) + return clientDirectory.absoluteFilePath("interface.exe"); +#elif defined(Q_OS_MACOS) + return clientDirectory.absoluteFilePath("interface.app/Contents/MacOS/interface"); +#endif +} + bool LauncherState::shouldDownloadContentCache() const { return !_contentCacheURL.isNull() && !QFile::exists(getContentCachePath()); } @@ -500,7 +535,11 @@ void LauncherState::installContentCache() { } void LauncherState::launchClient() { - ASSERT_STATE({ ApplicationState::InstallingClient, ApplicationState::InstallingContentCache }); + ASSERT_STATE({ + ApplicationState::RequestingLogin, + ApplicationState::InstallingClient, + ApplicationState::InstallingContentCache + }); setApplicationState(ApplicationState::LaunchingHighFidelity); diff --git a/launchers/qt/src/LauncherState.h b/launchers/qt/src/LauncherState.h index 1f0ea2ffdf..0b87775e25 100644 --- a/launchers/qt/src/LauncherState.h +++ b/launchers/qt/src/LauncherState.h @@ -134,7 +134,11 @@ private slots: private: bool shouldDownloadContentCache() const; + QString getCurrentClientVersion(); + QString getContentCachePath() const; + QString getClientDirectory() const; + QString getClientExecutablePath() const; QNetworkAccessManager _networkAccessManager; LatestBuilds _latestBuilds;