diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index fad78993..6fa9d421 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -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 diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index 6b128858..4c316bcf 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -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. *