logic: Added update checker connecting to online API
* connects to https://www.sourcetrail.com/api/v1/versions/latest * sends information about OS, platform, license type, current version and a unique user token * Automatic update check is enabled via Startscreen and performed once every 24 hours on window focus * Update check can be forced by clicking on "check for new version" on start screen * renamed TimePoint to TimeStamp fortune cookie message = In Träumen und im Leben ist nichts unmöglich.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#include "qt/network/QtRequest.h"
|
||||
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
QtRequest::QtRequest()
|
||||
{
|
||||
m_networkManager = new QNetworkAccessManager(this);
|
||||
QObject::connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void QtRequest::sendRequest(QString url)
|
||||
{
|
||||
LOG_INFO_STREAM(<< "send HTTP request: " << url.toStdString());
|
||||
|
||||
QNetworkRequest request;
|
||||
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
|
||||
request.setUrl(QUrl(url));
|
||||
m_networkManager->get(request);
|
||||
}
|
||||
|
||||
void QtRequest::finished(QNetworkReply *reply)
|
||||
{
|
||||
QVariant statusCodeV = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
||||
QVariant redirectionTargetUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute);
|
||||
|
||||
if (reply->error() != QNetworkReply::NoError)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "An error occured during http request. ERRORCODE: " << reply->error());
|
||||
}
|
||||
|
||||
QByteArray bytes = reply->readAll();
|
||||
LOG_INFO_STREAM(<< "received HTTP reply: " << bytes.toStdString());
|
||||
|
||||
delete reply;
|
||||
|
||||
emit receivedData(bytes);
|
||||
}
|
||||
Reference in New Issue
Block a user