diff options
Diffstat (limited to 'utils/rbutilqt/base/bootloaderinstallbase.h')
-rw-r--r-- | utils/rbutilqt/base/bootloaderinstallbase.h | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/utils/rbutilqt/base/bootloaderinstallbase.h b/utils/rbutilqt/base/bootloaderinstallbase.h new file mode 100644 index 0000000000..23aac4f92f --- /dev/null +++ b/utils/rbutilqt/base/bootloaderinstallbase.h | |||
@@ -0,0 +1,118 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2008 by Dominik Riebeling | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | ****************************************************************************/ | ||
18 | |||
19 | #ifndef BOOTLOADERINSTALLBASE_H | ||
20 | #define BOOTLOADERINSTALLBASE_H | ||
21 | |||
22 | #include <QtCore> | ||
23 | #include "progressloggerinterface.h" | ||
24 | #include "httpget.h" | ||
25 | |||
26 | //! baseclass for all Bootloader installs | ||
27 | class BootloaderInstallBase : public QObject | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | public: | ||
31 | enum Capability | ||
32 | { Install = 0x01, Uninstall = 0x02, Backup = 0x04, | ||
33 | IsFile = 0x08, IsRaw = 0x10, NeedsOf = 0x20, | ||
34 | CanCheckInstalled = 0x40, CanCheckVersion = 0x80 }; | ||
35 | Q_DECLARE_FLAGS(Capabilities, Capability) | ||
36 | |||
37 | enum BootloaderType | ||
38 | { BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown }; | ||
39 | |||
40 | BootloaderInstallBase(QObject *parent) : QObject(parent) | ||
41 | { } | ||
42 | |||
43 | //! install the bootloader, must be implemented | ||
44 | virtual bool install(void) = 0; | ||
45 | //! uninstall the bootloader, must be implemented | ||
46 | virtual bool uninstall(void) = 0; | ||
47 | //! returns the installed bootloader | ||
48 | virtual BootloaderType installed(void)=0; | ||
49 | //! returns the capabilities of the bootloader class | ||
50 | virtual Capabilities capabilities(void)=0; | ||
51 | //! returns a OF Firmware hint or empty if there is none | ||
52 | virtual QString ofHint() {return QString();} | ||
53 | |||
54 | //! backup a already installed bootloader | ||
55 | bool backup(QString to); | ||
56 | |||
57 | //! set the different filenames and paths | ||
58 | void setBlFile(QStringList f); | ||
59 | void setBlUrl(QUrl u) | ||
60 | { m_blurl = u; } | ||
61 | void setLogfile(QString f) | ||
62 | { m_logfile = f; } | ||
63 | bool setOfFile(QString of, QStringList blfile); | ||
64 | |||
65 | //! returns a port Install Hint or empty if there is none | ||
66 | //! static and in the base class, so the installer classes dont need to | ||
67 | // be modified for new targets | ||
68 | static QString postinstallHints(QString model); | ||
69 | |||
70 | //! returns the correct BootloaderInstaller object for the requested type | ||
71 | static BootloaderInstallBase* createBootloaderInstaller(QObject* parent,QString type); | ||
72 | protected slots: | ||
73 | void downloadReqFinished(int id, bool error); | ||
74 | void downloadBlFinish(bool error); | ||
75 | void installBlfile(void); | ||
76 | void progressAborted(void); | ||
77 | |||
78 | // NOTE: we need to keep this slot even on targets that don't need it | ||
79 | // -- using the preprocessor here confused moc. | ||
80 | void checkRemount(void); | ||
81 | protected: | ||
82 | enum LogMode | ||
83 | { LogAdd, LogRemove }; | ||
84 | |||
85 | void downloadBlStart(QUrl source); | ||
86 | int logInstall(LogMode mode); | ||
87 | |||
88 | HttpGet m_http; //! http download object | ||
89 | QString m_blfile; //! bootloader filename on player | ||
90 | QString m_logfile; //! file for installation log | ||
91 | QUrl m_blurl; //! bootloader download URL | ||
92 | QTemporaryFile m_tempfile; //! temporary file for download | ||
93 | QTemporaryFile m_tempof; //! temporary file for OF extracted from archive | ||
94 | QDateTime m_blversion; //! download timestamp used for version information | ||
95 | QString m_offile; //! path to the offile | ||
96 | #if defined(Q_OS_MACX) | ||
97 | void waitRemount(void); | ||
98 | |||
99 | int m_remountTries; | ||
100 | QString m_remountDevice; | ||
101 | #endif | ||
102 | |||
103 | signals: | ||
104 | void downloadDone(void); //! internal signal sent when download finished. | ||
105 | void installAborted(void); //! internal signal sent on abort button click. | ||
106 | void done(bool); | ||
107 | void logItem(QString, int); //! set logger item | ||
108 | void logProgress(int, int); //! set progress bar. | ||
109 | |||
110 | // NOTE: we need to keep this signal even on targets that don't need it | ||
111 | // -- using the preprocessor here confused moc. | ||
112 | void remounted(bool); | ||
113 | }; | ||
114 | |||
115 | Q_DECLARE_OPERATORS_FOR_FLAGS(BootloaderInstallBase::Capabilities) | ||
116 | |||
117 | #endif | ||
118 | |||