OSDN Git Service

Refactored update checks into a separate thread, for better code reusability.
[lamexp/LameXP.git] / src / Dialog_Update.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2013 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, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 //
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #pragma once
24
25 #include <QDialog>
26
27 class UpdateInfo;
28 class SettingsModel;
29 class QMovie;
30 class UpdateCheckThread;
31
32 //UIC forward declartion
33 namespace Ui {
34         class UpdateDialog;
35 }
36
37 //UpdateDialog class
38 class UpdateDialog : public QDialog
39 {
40         Q_OBJECT
41
42 public:
43         UpdateDialog(SettingsModel *settings, QWidget *parent = 0);
44         ~UpdateDialog(void);
45
46         bool getSuccess(void) { return m_success; }
47         bool updateReadyToInstall(void) { return m_updateReadyToInstall; }
48
49 private slots:
50         void updateInit(void);
51         void checkForUpdates(void);
52         void linkActivated(const QString &link);
53         void applyUpdate(void);
54         void logButtonClicked(void);
55         void progressBarValueChanged(int value);
56
57         void threadStatusChanged(const int status);
58         void threadProgressChanged(const int progress);
59         void threadMessageLogged(const QString &message);
60         void threadFinished(void);
61
62 protected:
63         virtual void showEvent(QShowEvent *event);
64         virtual void closeEvent(QCloseEvent *event);
65         virtual void keyPressEvent(QKeyEvent *e);
66         virtual bool winEvent(MSG *message, long *result);
67         virtual bool event(QEvent *e);
68
69         const bool m_betaUpdates;
70
71 private:
72         Ui::UpdateDialog *ui; //for Qt UIC
73
74         const QString m_binaryUpdater;
75
76         UpdateCheckThread *m_thread;
77         QStringList *m_logFile;
78         SettingsModel *m_settings;
79         QMovie *m_animator;
80
81         unsigned long m_updaterProcess;
82
83         bool m_success;
84         bool m_updateReadyToInstall;
85         bool m_firstShow;
86         
87         void testKnownHosts(void);
88
89 };