OSDN Git Service

Updated RHash and UPX to the latest versions.
[x264-launcher/x264-launcher.git] / src / win_updater.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2016 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.
14 //
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.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #pragma once
23
24 #include <QDialog>
25 #include <QMap>
26
27 class QMovie;
28 class SysinfoModel;
29
30 namespace Ui
31 {
32         class UpdaterDialog;
33 }
34
35 namespace MUtils
36 {
37         class UpdateChecker;
38 }
39
40 class UpdaterDialog : public QDialog
41 {
42         Q_OBJECT
43
44 public:
45         UpdaterDialog(QWidget *parent, const SysinfoModel *sysinfo, const char *const updateUrl);
46         ~UpdaterDialog(void);
47
48         typedef struct
49         {
50                 const char* name;
51                 const char* hash;
52                 const bool  exec;
53         }
54         binary_t;
55
56         static const int READY_TO_INSTALL_UPDATE = 42;
57         static const binary_t BINARIES[];
58
59         inline bool getSuccess(void) { return m_success; }
60
61 protected:
62         virtual bool event(QEvent *e);
63         virtual void showEvent(QShowEvent *event);
64         virtual void closeEvent(QCloseEvent *e);
65         virtual void keyPressEvent(QKeyEvent *event);
66
67 private slots:
68         void initUpdate(void);
69         void checkForUpdates(void);
70         void threadStatusChanged(int status);
71         void threadMessageLogged(const QString &message);
72         void threadFinished(void);
73         void updateFinished(void);
74         void openUrl(const QString &url);
75         void installUpdate(void);
76
77 private:
78         Ui::UpdaterDialog *const ui;
79
80         bool checkBinaries();
81         bool checkFileHash(const QString &filePath, const char *expectedHash);
82         void cleanFiles(void);
83
84         const SysinfoModel *const m_sysinfo;
85         const char *const m_updateUrl;
86
87         bool m_firstShow;
88         bool m_success;
89
90         QScopedPointer<QMovie> m_animator;
91         QScopedPointer<MUtils::UpdateChecker> m_thread;
92
93         unsigned long m_updaterProcess;
94         QStringList m_logFile;
95         QMap<QString,QString> m_binaries;
96         int m_status;
97 };