| 1 | // For license of this file, see <project-root-folder>/LICENSE.md. |
| 2 | |
| 3 | #ifndef FORMUPDATE_H |
| 4 | #define FORMUPDATE_H |
| 5 | |
| 6 | #include "miscellaneous/systemfactory.h" |
| 7 | #include "network-web/downloader.h" |
| 8 | |
| 9 | #include "ui_formupdate.h" |
| 10 | |
| 11 | #include <QDialog> |
| 12 | #include <QNetworkReply> |
| 13 | #include <QPushButton> |
| 14 | |
| 15 | class RSSGUARD_DLLSPEC FormUpdate : public QDialog { |
| 16 | Q_OBJECT |
| 17 | |
| 18 | public: |
| 19 | // Constructors and destructors. |
| 20 | explicit FormUpdate(QWidget* parent); |
| 21 | |
| 22 | // Returns true if application can self-update |
| 23 | // on current platform. |
| 24 | bool isSelfUpdateSupported() const; |
| 25 | |
| 26 | private slots: |
| 27 | |
| 28 | // Check for updates and interprets the results. |
| 29 | void checkForUpdates(); |
| 30 | void startUpdate(); |
| 31 | |
| 32 | void updateProgress(qint64 bytes_received, qint64 bytes_total); |
| 33 | void updateCompleted(const QUrl& url, |
| 34 | QNetworkReply::NetworkError status, |
| 35 | int http_code, |
| 36 | const QByteArray& contents); |
| 37 | void saveUpdateFile(const QByteArray& file_contents); |
| 38 | |
| 39 | private: |
| 40 | void loadAvailableFiles(); |
| 41 | |
| 42 | Ui::FormUpdate m_ui; |
| 43 | QPushButton* m_btnUpdate; |
| 44 | Downloader m_downloader; |
| 45 | QString m_updateFilePath; |
| 46 | UpdateInfo m_updateInfo; |
| 47 | bool m_readyToInstall = false; |
| 48 | qint64 m_lastDownloadedBytes = 0; |
| 49 | }; |
| 50 | |
| 51 | #endif // FORMUPDATE_H |