Moved version number check to Application class
This commit is contained in:
@@ -7,6 +7,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <yaml-cpp/yaml.h>
|
#include <yaml-cpp/yaml.h>
|
||||||
#include <yaml-cpp/exceptions.h>
|
#include <yaml-cpp/exceptions.h>
|
||||||
|
#include <QtNetwork/QNetworkAccessManager>
|
||||||
|
#include <QtNetwork/QNetworkRequest>
|
||||||
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QUrlQuery>
|
||||||
|
|
||||||
#include "src/Services/ProcessService.hpp"
|
#include "src/Services/ProcessService.hpp"
|
||||||
|
|
||||||
@@ -72,6 +77,7 @@ namespace Bloom
|
|||||||
this->activateInsight();
|
this->activateInsight();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
this->checkBloomVersion();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can't run our own event loop here - we have to use Qt's event loop. But we still need to be able to
|
* We can't run our own event loop here - we have to use Qt's event loop. But we still need to be able to
|
||||||
@@ -514,6 +520,36 @@ namespace Bloom
|
|||||||
this->applicationEventListener->dispatchCurrentEvents();
|
this->applicationEventListener->dispatchCurrentEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::checkBloomVersion() {
|
||||||
|
const auto currentVersionNumber = Application::VERSION;
|
||||||
|
|
||||||
|
auto* networkAccessManager = new QNetworkAccessManager(this);
|
||||||
|
auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/latest-version"));
|
||||||
|
queryVersionEndpointUrl.setScheme("http");
|
||||||
|
queryVersionEndpointUrl.setQuery(QUrlQuery({
|
||||||
|
{"currentVersionNumber", QString::fromStdString(currentVersionNumber.toString())}
|
||||||
|
}));
|
||||||
|
|
||||||
|
QObject::connect(
|
||||||
|
networkAccessManager,
|
||||||
|
&QNetworkAccessManager::finished,
|
||||||
|
this,
|
||||||
|
[this, currentVersionNumber] (QNetworkReply* response) {
|
||||||
|
const auto jsonResponseObject = QJsonDocument::fromJson(response->readAll()).object();
|
||||||
|
const auto latestVersionNumber = VersionNumber(jsonResponseObject.value("latestVersionNumber").toString());
|
||||||
|
|
||||||
|
if (latestVersionNumber > currentVersionNumber) {
|
||||||
|
Logger::warning(
|
||||||
|
"Bloom v" + latestVersionNumber.toString()
|
||||||
|
+ " is available to download - upgrade via " + Services::PathService::homeDomainName()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
networkAccessManager->get(QNetworkRequest(queryVersionEndpointUrl));
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef EXCLUDE_INSIGHT
|
#ifndef EXCLUDE_INSIGHT
|
||||||
void Application::activateInsight() {
|
void Application::activateInsight() {
|
||||||
assert(!this->insight);
|
assert(!this->insight);
|
||||||
|
|||||||
@@ -251,6 +251,13 @@ namespace Bloom
|
|||||||
*/
|
*/
|
||||||
void dispatchEvents();
|
void dispatchEvents();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
|
||||||
#ifndef EXCLUDE_INSIGHT
|
#ifndef EXCLUDE_INSIGHT
|
||||||
/**
|
/**
|
||||||
* Activate the Insight GUI.
|
* Activate the Insight GUI.
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QtNetwork/QNetworkAccessManager>
|
|
||||||
#include <QtNetwork/QNetworkRequest>
|
|
||||||
#include <QtNetwork/QNetworkReply>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QUrlQuery>
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
#include "src/Services/PathService.hpp"
|
#include "src/Services/PathService.hpp"
|
||||||
@@ -167,8 +162,6 @@ namespace Bloom
|
|||||||
workerThread->start();
|
workerThread->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->checkBloomVersion();
|
|
||||||
|
|
||||||
this->mainWindow->init(this->targetControllerService.getTargetDescriptor());
|
this->mainWindow->init(this->targetControllerService.getTargetDescriptor());
|
||||||
this->mainWindow->show();
|
this->mainWindow->show();
|
||||||
}
|
}
|
||||||
@@ -190,36 +183,6 @@ namespace Bloom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Insight::checkBloomVersion() {
|
|
||||||
const auto currentVersionNumber = Application::VERSION;
|
|
||||||
|
|
||||||
auto* networkAccessManager = new QNetworkAccessManager(this);
|
|
||||||
auto queryVersionEndpointUrl = QUrl(QString::fromStdString(Services::PathService::homeDomainName() + "/latest-version"));
|
|
||||||
queryVersionEndpointUrl.setScheme("http");
|
|
||||||
queryVersionEndpointUrl.setQuery(QUrlQuery({
|
|
||||||
{"currentVersionNumber", QString::fromStdString(currentVersionNumber.toString())}
|
|
||||||
}));
|
|
||||||
|
|
||||||
QObject::connect(
|
|
||||||
networkAccessManager,
|
|
||||||
&QNetworkAccessManager::finished,
|
|
||||||
this,
|
|
||||||
[this, currentVersionNumber] (QNetworkReply* response) {
|
|
||||||
const auto jsonResponseObject = QJsonDocument::fromJson(response->readAll()).object();
|
|
||||||
const auto latestVersionNumber = VersionNumber(jsonResponseObject.value("latestVersionNumber").toString());
|
|
||||||
|
|
||||||
if (latestVersionNumber > currentVersionNumber) {
|
|
||||||
Logger::warning(
|
|
||||||
"Bloom v" + latestVersionNumber.toString()
|
|
||||||
+ " is available to download - upgrade via " + Services::PathService::homeDomainName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
networkAccessManager->get(QNetworkRequest(queryVersionEndpointUrl));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Insight::onInsightWindowActivated() {
|
void Insight::onInsightWindowActivated() {
|
||||||
const auto getTargetStateTask = QSharedPointer<GetTargetState>(new GetTargetState(), &QObject::deleteLater);
|
const auto getTargetStateTask = QSharedPointer<GetTargetState>(new GetTargetState(), &QObject::deleteLater);
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
|
|||||||
@@ -98,13 +98,6 @@ namespace Bloom
|
|||||||
|
|
||||||
InsightSignals* insightSignals = InsightSignals::instance();
|
InsightSignals* insightSignals = InsightSignals::instance();
|
||||||
|
|
||||||
/**
|
|
||||||
* 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();
|
|
||||||
|
|
||||||
void onInsightWindowActivated();
|
void onInsightWindowActivated();
|
||||||
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
||||||
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
|
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
|
||||||
|
|||||||
Reference in New Issue
Block a user