Latest version check on Insight startup
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user