1 #pragma once 2 3 #include <QObject> 4 5 #include "net/NetJob.h" 6 #include "net/Download.h" 7 8 #include "multimc_logic_export.h" 9 10 class MULTIMC_LOGIC_EXPORT NotificationChecker : public QObject 11 { 12 Q_OBJECT 13 14 public: 15 explicit NotificationChecker(QObject *parent = 0); 16 17 void setNotificationsUrl(const QUrl ¬ificationsUrl); 18 void setApplicationPlatform(QString platform); 19 void setApplicationChannel(QString channel); 20 void setApplicationFullVersion(QString version); 21 22 struct NotificationEntry 23 { 24 int id; 25 QString message; 26 enum 27 { 28 Critical, 29 Warning, 30 Information 31 } type; 32 QString channel; 33 QString platform; 34 QString from; 35 QString to; 36 }; 37 38 QList<NotificationEntry> notificationEntries() const; 39 40 public 41 slots: 42 void checkForNotifications(); 43 44 private 45 slots: 46 void downloadSucceeded(int); 47 48 signals: 49 void notificationCheckFinished(); 50 51 private: 52 bool entryApplies(const NotificationEntry &entry) const; 53 54 private: 55 QList<NotificationEntry> m_entries; 56 QUrl m_notificationsUrl; 57 NetJobPtr m_checkJob; 58 Net::Download::Ptr m_download; 59 60 QString m_appVersionChannel; 61 QString m_appPlatform; 62 QString m_appFullVersion; 63 }; 64