22 #include "thirdparty/tinyxml2/tinyxml2.h"
29 using tinyxml2::XMLElement;
30 using tinyxml2::XMLDocument;
34 #if CONFIG_ENABLE_UPDATE_TOOL
37 QObject::connect(
this, SIGNAL(finished(QNetworkReply*)),
this, SLOT(
onNetworkReply(QNetworkReply*)));
38 this->
get(QNetworkRequest(versionFileUrl));
46 #if CONFIG_ENABLE_UPDATE_TOOL
47 if (reply->error() == QNetworkReply::NoError) {
48 int httpstatuscode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toUInt();
49 switch(httpstatuscode) {
51 QUrl redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl().toString();
52 this->
get(QNetworkRequest(redirect));
56 if (reply->isReadable()) {
57 QString replyString = QString::fromUtf8(reply->readAll().data());
59 doc.Parse(replyString.toStdString().c_str());
64 XMLElement *root = doc.FirstChildElement();
67 XMLElement *appsElem = root->FirstChildElement(
"app");
68 XMLElement *depsElem = root->FirstChildElement(
"dependencies");
70 if (!appsElem || !depsElem) {
71 LogW(
"Required nodes not found. Requesting update.");
74 int appRolling = -1, depsRolling = -1;
75 appsElem->QueryIntAttribute(
"rolling", &appRolling);
76 depsElem->QueryIntAttribute(
"rolling", &depsRolling);
78 QString appVersion(
"Unkown"), depsVersion(
"Unknown");
79 if (appsElem->Attribute(
"string")) {appVersion = appsElem->Attribute(
"string");}
80 if (depsElem->Attribute(
"string")) {depsVersion = depsElem->Attribute(
"string");}
84 if (appRolling < 0 || depsRolling < 0) {
85 LogW(
"Required attributes not found. Requesting update.");
88 LogD(
"Update available");
91 LogV(
"No update available.");
95 LogE(
"File not readable");
101 LogD(
"Invalid network status. Code (%i)", httpstatuscode);
105 LogD(
"No network reply: %s.", reply->errorString().toStdString().c_str());
108 reply->deleteLater();
111 #endif // CONFIG_ENABLE_UPDATE_TOOL
std::string getVersionFileAddress()
#define EPT_EXCEPT(num, desc)
VersionCheck(QObject *parent=0)
void onNetworkReply(QNetworkReply *reply)
#define EPT_VERSION_ROLLING
#define EPT_DEPS_VERSION_ROLLING
static const std::string VERSION_FILENAME
void updateAvailable(VersionInformation info)