Latest version check on Insight startup

This commit is contained in:
Nav
2021-10-18 01:09:53 +01:00
parent 5d3bddac01
commit 10b80e24ba
2 changed files with 38 additions and 0 deletions

View File

@@ -9,6 +9,9 @@
#include "src/Exceptions/InvalidConfig.hpp"
#include "src/Targets/TargetState.hpp"
#include "src/Application.hpp"
#include "InsightWorker/Tasks/QueryLatestVersionNumber.hpp"
using namespace Bloom;
using namespace Bloom::Exceptions;
@@ -132,6 +135,10 @@ void Insight::startup() {
this->connect(this->workerThread, &QThread::finished, this->insightWorker, &QObject::deleteLater);
this->connect(this->workerThread, &QThread::finished, this->workerThread, &QThread::deleteLater);
this->connect(this->insightWorker, &InsightWorker::ready, this, [this] {
this->checkBloomVersion();
});
this->mainWindow->show();
}
@@ -152,6 +159,30 @@ void Insight::shutdown() {
this->setThreadState(ThreadState::STOPPED);
}
void Insight::checkBloomVersion() {
auto currentVersionNumber = QString::fromStdString(Application::VERSION_STR);
auto versionQueryTask = new QueryLatestVersionNumber(
QString::fromStdString(Application::VERSION_STR)
);
this->connect(
versionQueryTask,
&QueryLatestVersionNumber::latestVersionNumberRetrieved,
this,
[this, currentVersionNumber] (const QString& latestVersionNumber) {
if (latestVersionNumber != currentVersionNumber) {
Logger::warning(
"Bloom v" + latestVersionNumber.toStdString()
+ " is available to download - upgrade via https://bloom.oscillate.io"
);
}
}
);
this->insightWorker->queueTask(versionQueryTask);
}
void Insight::onShutdownApplicationEvent(const Events::ShutdownApplication&) {
/*
* Once Insight shuts down, control of the main thread will be returned to Application::run(), which

View File

@@ -100,6 +100,13 @@ namespace Bloom
*/
void shutdown();
/**
* Queries the Bloom server for the latest version number. If the current version number doesn't match the
* latest version number returned by the server, we'll display a warning in the logs to instruct the user to
* upgrade.
*/
void checkBloomVersion();
/**
* Because Insight occupies the main thread, it must handle any application shutdown requests.
*