Add proper version checking to qt launcher

This commit is contained in:
Ryan Huffman 2019-09-23 08:27:22 -07:00
parent e21885905f
commit 05e9329635
5 changed files with 50 additions and 9 deletions

View file

@ -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 ""

View file

@ -5,6 +5,7 @@
#include <QFileInfo>
#include <QDir>
#include <QFile>
#include <QProcess>
#if defined(Q_OS_WIN)

View file

@ -2,10 +2,7 @@
#include <string>
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);

View file

@ -9,6 +9,8 @@
#endif
#include <array>
#include <QProcess>
#include <QNetworkRequest>
#include <QNetworkReply>
@ -23,10 +25,30 @@
#include <QThreadPool>
#include <QStandardPaths>
#include <QEventLoop>
QString getCurrentClientVersion() {
// TODO Implement client version checking
return "";
#include <qregularexpression.h>
QString LauncherState::getCurrentClientVersion() {
QProcess client;
client.start(getClientExecutablePath(), { "--version" });
QEventLoop loop;
connect(&client, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), &loop, &QEventLoop::exit);
loop.exec();
auto output = client.readAllStandardOutput();
QRegularExpression regex { "Interface (?<version>\\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);

View file

@ -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;