2021-11-18 14:58:01 +00:00
|
|
|
#ifndef DUST3D_APPLICATION_UPDATES_CHECKER_H_
|
|
|
|
#define DUST3D_APPLICATION_UPDATES_CHECKER_H_
|
|
|
|
|
2019-07-24 12:41:55 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QtNetwork>
|
|
|
|
|
2022-10-18 09:35:04 +00:00
|
|
|
class UpdatesChecker : public QObject {
|
2019-07-24 12:41:55 +00:00
|
|
|
Q_OBJECT
|
|
|
|
signals:
|
|
|
|
void finished();
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2019-07-24 12:41:55 +00:00
|
|
|
public:
|
2022-10-18 09:35:04 +00:00
|
|
|
struct UpdateItem {
|
2019-07-24 12:41:55 +00:00
|
|
|
QString forTags;
|
|
|
|
QString version;
|
|
|
|
QString humanVersion;
|
|
|
|
QString descriptionUrl;
|
|
|
|
};
|
2022-10-18 09:35:04 +00:00
|
|
|
|
2019-07-24 12:41:55 +00:00
|
|
|
UpdatesChecker();
|
|
|
|
void start();
|
|
|
|
bool isLatest() const;
|
|
|
|
bool hasError() const;
|
2022-10-18 09:35:04 +00:00
|
|
|
const QString& message() const;
|
|
|
|
const UpdateItem& matchedUpdateItem() const;
|
2019-07-24 12:41:55 +00:00
|
|
|
private slots:
|
2022-10-18 09:35:04 +00:00
|
|
|
void downloadFinished(QNetworkReply* reply);
|
|
|
|
|
2019-07-24 12:41:55 +00:00
|
|
|
private:
|
|
|
|
QNetworkAccessManager m_networkAccessManager;
|
|
|
|
bool m_isLatest = false;
|
|
|
|
QString m_message;
|
|
|
|
QString m_latestUrl;
|
|
|
|
bool m_hasError = true;
|
|
|
|
UpdateItem m_matchedUpdateItem;
|
2022-10-18 09:35:04 +00:00
|
|
|
|
|
|
|
bool parseUpdateInfoXml(const QByteArray& updateInfoXml, std::vector<UpdateItem>* updateItems);
|
|
|
|
static bool isVersionLessThan(const QString& version, const QString& compareWith);
|
2019-07-24 12:41:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|