diff --git a/src/updatechecker.h b/src/updatechecker.h --- a/src/updatechecker.h +++ b/src/updatechecker.h @@ -1,3 +1,22 @@ +/* + Copyright © 2017 Hasan Yavuz Özderya + + This file is part of serialplot. + + serialplot is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + serialplot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with serialplot. If not, see . +*/ + #ifndef UPDATECHECKER_H #define UPDATECHECKER_H @@ -6,6 +25,8 @@ #include #include +#include "versionnumber.h" + class UpdateChecker : public QObject { Q_OBJECT @@ -13,7 +34,6 @@ public: explicit UpdateChecker(QObject *parent = 0); signals: - void updateFound(); void checkFinished(bool found, QString newVersion, QString downloadUrl); void checkFailed(QString errorMessage); @@ -21,14 +41,29 @@ public slots: void checkUpdate(); private: + enum class FileArch + { + unknown, + i386, + amd64, + arm + }; + struct FileInfo { QString name; QString link; + bool hasVersion; + VersionNumber version; + FileArch arch; }; QNetworkAccessManager nam; - bool parseData(const QJsonDocument& data, QList& files); + /// Parses json and creates a list of files + bool parseData(const QJsonDocument& data, QList& files) const; + /// Finds the update file in the file list. Returns `-1` if no new version + /// is found. + bool findUpdate(const QList& files, FileInfo& foundFile) const; private slots: void onReqFinished(QNetworkReply* reply);