Handle language change events in widgets.
[maemo-rb.git] / rbutil / rbutilqt / base / bootloaderinstallbase.h
blob0e970c4af6e6a974106f34b4f433a9a48ad61a00
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2008 by Dominik Riebeling
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.
14 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
15 * KIND, either express or implied.
17 ****************************************************************************/
19 #ifndef BOOTLOADERINSTALLBASE_H
20 #define BOOTLOADERINSTALLBASE_H
22 #include <QtCore>
23 #include "progressloggerinterface.h"
24 #include "httpget.h"
26 //! baseclass for all Bootloader installs
27 class BootloaderInstallBase : public QObject
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)
37 enum BootloaderType
38 { BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown };
40 BootloaderInstallBase(QObject *parent) : QObject(parent)
41 { }
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();}
54 //! backup a already installed bootloader
55 bool backup(QString to);
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);
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);
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);
77 // NOTE: we need to keep this slot even on targets that don't need it
78 // -- using the preprocessor here confused moc.
79 void checkRemount(void);
80 protected:
81 enum LogMode
82 { LogAdd, LogRemove };
84 void downloadBlStart(QUrl source);
85 int logInstall(LogMode mode);
87 HttpGet m_http; //! http download object
88 QString m_blfile; //! bootloader filename on player
89 QString m_logfile; //! file for installation log
90 QUrl m_blurl; //! bootloader download URL
91 QTemporaryFile m_tempfile; //! temporary file for download
92 QTemporaryFile m_tempof; //! temporary file for OF extracted from archive
93 QDateTime m_blversion; //! download timestamp used for version information
94 QString m_offile; //! path to the offile
95 #if defined(Q_OS_MACX)
96 void waitRemount(void);
98 int m_remountTries;
99 QString m_remountDevice;
100 #endif
102 signals:
103 void downloadDone(void); //! internal signal sent when download finished.
104 void done(bool);
105 void logItem(QString, int); //! set logger item
106 void logProgress(int, int); //! set progress bar.
108 // NOTE: we need to keep this signal even on targets that don't need it
109 // -- using the preprocessor here confused moc.
110 void remounted(bool);
113 Q_DECLARE_OPERATORS_FOR_FLAGS(BootloaderInstallBase::Capabilities)
115 #endif