Bump version + updated changelog.
[simple-x264-launcher.git] / src / win_updater.h
blobc064bd83db8e72806d89f70b58ce2a015b7e161e
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2018 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
22 #pragma once
24 #include <QDialog>
25 #include <QMap>
27 class QMovie;
28 class QFile;
29 class QElapsedTimer;
30 class SysinfoModel;
32 namespace Ui
34 class UpdaterDialog;
37 namespace MUtils
39 class UpdateChecker;
42 class UpdaterDialog : public QDialog
44 Q_OBJECT
46 public:
47 UpdaterDialog(QWidget *parent, const SysinfoModel *sysinfo, const char *const updateUrl);
48 ~UpdaterDialog(void);
50 typedef struct
52 const char* name;
53 const char* hash;
54 const bool exec;
56 binary_t;
58 static const int READY_TO_INSTALL_UPDATE = 42;
59 static const binary_t BINARIES[];
61 inline bool getSuccess(void) { return m_success; }
63 protected:
64 virtual bool event(QEvent *e);
65 virtual void showEvent(QShowEvent *event);
66 virtual void closeEvent(QCloseEvent *e);
67 virtual void keyPressEvent(QKeyEvent *event);
69 private slots:
70 void initUpdate(void);
71 void checkForUpdates(void);
72 void threadStatusChanged(int status);
73 void threadMessageLogged(const QString &message);
74 void threadFinished(void);
75 void updateFinished(void);
76 void openUrl(const QString &url);
77 void installUpdate(void);
79 private:
80 Ui::UpdaterDialog *const ui;
82 bool checkBinaries();
83 bool checkFileHash(const QString &filePath, const char *expectedHash);
85 const SysinfoModel *const m_sysinfo;
86 const char *const m_updateUrl;
88 bool m_firstShow;
89 bool m_success;
91 QScopedPointer<QMovie> m_animator;
92 QScopedPointer<MUtils::UpdateChecker> m_thread;
93 QScopedPointer<QElapsedTimer> m_elapsed;
95 unsigned long m_updaterProcess;
96 QStringList m_logFile;
97 QMap<QString, QSharedPointer<QFile>> m_binaries;
98 int m_status;