summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2009-05-09 18:17:05 +0000
committerDominik Wenger <domonoky@googlemail.com>2009-05-09 18:17:05 +0000
commit9ca29354e1de9859044bdcfce0309b0509bafb90 (patch)
tree2f2a56fbea6834eee6484d2e6d5eddcf5bfc2e73 /rbutil/rbutilqt
parent09085a30f665a2382496bc6cddf92b8833653776 (diff)
downloadrockbox-9ca29354e1de9859044bdcfce0309b0509bafb90.tar.gz
rockbox-9ca29354e1de9859044bdcfce0309b0509bafb90.zip
rbutil: enforce parents for bootloader install classes. and rework OF handling a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20892 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallbase.h35
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallfile.h2
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallhex.cpp21
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallhex.h5
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallipod.h2
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallmi4.h2
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp36
7 files changed, 57 insertions, 46 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallbase.h b/rbutil/rbutilqt/base/bootloaderinstallbase.h
index 0916935208..470a23a7ab 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallbase.h
+++ b/rbutil/rbutilqt/base/bootloaderinstallbase.h
@@ -24,39 +24,50 @@
#include "progressloggerinterface.h"
#include "httpget.h"
-
+//! baseclass for all Bootloader installs
class BootloaderInstallBase : public QObject
{
Q_OBJECT
-
public:
enum Capability
{ Install = 0x01, Uninstall = 0x02, Backup = 0x04,
- IsFile = 0x08, IsRaw = 0x10, NeedsFlashing = 0x20,
+ IsFile = 0x08, IsRaw = 0x10, NeedsOf = 0x20,
CanCheckInstalled = 0x40, CanCheckVersion = 0x80 };
Q_DECLARE_FLAGS(Capabilities, Capability)
enum BootloaderType
{ BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown };
- BootloaderInstallBase(QObject *parent = 0) : QObject(parent)
+ BootloaderInstallBase(QObject *parent) : QObject(parent)
{ }
- virtual bool install(void)
- { return false; }
- virtual bool uninstall(void)
- { return false; }
- virtual BootloaderType installed(void);
- virtual Capabilities capabilities(void);
+ //! install the bootloader, must be implemented
+ virtual bool install(void) = 0;
+ //! uninstall the bootloader, must be implemented
+ virtual bool uninstall(void) = 0;
+ //! returns the installed bootloader
+ virtual BootloaderType installed(void)=0;
+ //! returns the capabilities of the bootloader class
+ virtual Capabilities capabilities(void)=0;
+ //! returns a OF Firmware hint or empty if there is none
+ virtual QString ofHint() {return QString();}
+
+
+ //! backup a already installed bootloader
bool backup(QString to);
+ //! set the differen filenames and paths
void setBlFile(QString f)
{ m_blfile = f; }
void setBlUrl(QUrl u)
{ m_blurl = u; }
void setLogfile(QString f)
{ m_logfile = f; }
-
+ void setOfFile(QString f)
+ {m_offile = f;}
+
+ //! returns a port Install Hint or empty if there is none
+ //! static and in the base class, so the installer classes dont need to be modified for new targets
static QString postinstallHints(QString model);
protected slots:
@@ -76,7 +87,7 @@ class BootloaderInstallBase : public QObject
QUrl m_blurl; //! bootloader download URL
QTemporaryFile m_tempfile; //! temporary file for download
QDateTime m_blversion; //! download timestamp used for version information
-
+ QString m_offile; //! path to the offile
signals:
void downloadDone(void); //! internal signal sent when download finished.
void done(bool);
diff --git a/rbutil/rbutilqt/base/bootloaderinstallfile.h b/rbutil/rbutilqt/base/bootloaderinstallfile.h
index 075f047ed2..f77ec7f20d 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallfile.h
+++ b/rbutil/rbutilqt/base/bootloaderinstallfile.h
@@ -30,7 +30,7 @@ class BootloaderInstallFile : public BootloaderInstallBase
Q_OBJECT
public:
- BootloaderInstallFile(QObject *parent = 0);
+ BootloaderInstallFile(QObject *parent);
bool install(void);
bool uninstall(void);
BootloaderInstallBase::BootloaderType installed(void);
diff --git a/rbutil/rbutilqt/base/bootloaderinstallhex.cpp b/rbutil/rbutilqt/base/bootloaderinstallhex.cpp
index a52f8d0584..31659981f7 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallhex.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstallhex.cpp
@@ -44,10 +44,23 @@ BootloaderInstallHex::BootloaderInstallHex(QObject *parent)
{
}
+QString BootloaderInstallHex::ofHint()
+{
+ return tr("Bootloader installation requires you to provide "
+ "a firmware file of the original firmware (hex file). "
+ "You need to download this file yourself due to legal "
+ "reasons. Please refer to the "
+ "<a href='http://www.rockbox.org/manual.shtml'>manual</a> and the "
+ "<a href='http://www.rockbox.org/wiki/IriverBoot"
+ "#Download_and_extract_a_recent_ve'>IriverBoot</a> wiki page on "
+ "how to obtain this file.<br/>"
+ "Press Ok to continue and browse your computer for the firmware "
+ "file.");
+}
bool BootloaderInstallHex::install(void)
{
- if(m_hex.isEmpty())
+ if(m_offile.isEmpty())
return false;
m_hashindex = -1;
@@ -55,7 +68,7 @@ bool BootloaderInstallHex::install(void)
emit logItem(tr("checking MD5 hash of input file ..."), LOGINFO);
QByteArray filedata;
// read hex file into QByteArray
- QFile file(m_hex);
+ QFile file(m_offile);
file.open(QIODevice::ReadOnly);
filedata = file.readAll();
file.close();
@@ -97,7 +110,7 @@ bool BootloaderInstallHex::install(void)
emit logItem(tr("Descrambling file"), LOGINFO);
m_descrambled.open();
int result;
- result = iriver_decode(m_hex.toAscii().data(),
+ result = iriver_decode(m_offile.toAscii().data(),
m_descrambled.fileName().toAscii().data(), FALSE, STRIP_NONE);
qDebug() << "iriver_decode" << result;
@@ -223,7 +236,7 @@ BootloaderInstallBase::BootloaderType BootloaderInstallHex::installed(void)
BootloaderInstallBase::Capabilities BootloaderInstallHex::capabilities(void)
{
- return (Install | NeedsFlashing);
+ return (Install | NeedsOf);
}
QString BootloaderInstallHex::scrambleError(int err)
diff --git a/rbutil/rbutilqt/base/bootloaderinstallhex.h b/rbutil/rbutilqt/base/bootloaderinstallhex.h
index 04b657a193..1b64d4925f 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallhex.h
+++ b/rbutil/rbutilqt/base/bootloaderinstallhex.h
@@ -37,12 +37,9 @@ class BootloaderInstallHex : public BootloaderInstallBase
bool uninstall(void);
BootloaderInstallBase::BootloaderType installed(void);
Capabilities capabilities(void);
-
- void setHexfile(QString h)
- { m_hex = h; }
+ QString ofHint();
private:
- QString m_hex;
int m_hashindex;
int m_model;
QTemporaryFile m_descrambled;
diff --git a/rbutil/rbutilqt/base/bootloaderinstallipod.h b/rbutil/rbutilqt/base/bootloaderinstallipod.h
index 5867b754f1..7e24ae1539 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallipod.h
+++ b/rbutil/rbutilqt/base/bootloaderinstallipod.h
@@ -31,7 +31,7 @@ class BootloaderInstallIpod : public BootloaderInstallBase
Q_OBJECT
public:
- BootloaderInstallIpod(QObject *parent = 0);
+ BootloaderInstallIpod(QObject *parent);
~BootloaderInstallIpod();
bool install(void);
bool uninstall(void);
diff --git a/rbutil/rbutilqt/base/bootloaderinstallmi4.h b/rbutil/rbutilqt/base/bootloaderinstallmi4.h
index c746b0c87f..313f61ad12 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallmi4.h
+++ b/rbutil/rbutilqt/base/bootloaderinstallmi4.h
@@ -30,7 +30,7 @@ class BootloaderInstallMi4 : public BootloaderInstallBase
Q_OBJECT
public:
- BootloaderInstallMi4(QObject *parent = 0);
+ BootloaderInstallMi4(QObject *parent);
bool install(void);
bool uninstall(void);
BootloaderInstallBase::BootloaderType installed(void);
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 34a1990aa6..3a594ef0ad 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -714,21 +714,11 @@ void RbUtilQt::installBootloader()
}
}
- if(bl->capabilities() & BootloaderInstallBase::NeedsFlashing)
+ if(bl->capabilities() & BootloaderInstallBase::NeedsOf)
{
int ret;
ret = QMessageBox::information(this, tr("Prerequisites"),
- tr("Bootloader installation requires you to provide "
- "a firmware file of the original firmware (hex file). "
- "You need to download this file yourself due to legal "
- "reasons. Please refer to the "
- "<a href='http://www.rockbox.org/manual.shtml'>manual</a> and the "
- "<a href='http://www.rockbox.org/wiki/IriverBoot"
- "#Download_and_extract_a_recent_ve'>IriverBoot</a> wiki page on "
- "how to obtain this file.<br/>"
- "Press Ok to continue and browse your computer for the firmware "
- "file."),
- QMessageBox::Ok | QMessageBox::Abort);
+ bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort);
if(ret != QMessageBox::Ok) {
// consider aborting an error to close window / abort automatic
// installation.
@@ -736,16 +726,16 @@ void RbUtilQt::installBootloader()
logger->addItem(tr("Bootloader installation aborted"), LOGINFO);
return;
}
- // open dialog to browse to hex file
- QString hexfile;
- hexfile = QFileDialog::getOpenFileName(this,
- tr("Select firmware file"), QDir::homePath(), "*.hex");
- if(!QFileInfo(hexfile).isReadable()) {
+ // open dialog to browse to of file
+ QString offile;
+ offile = QFileDialog::getOpenFileName(this,
+ tr("Select firmware file"), QDir::homePath());
+ if(!QFileInfo(offile).isReadable()) {
logger->addItem(tr("Error opening firmware file"), LOGERROR);
m_error = true;
return;
}
- ((BootloaderInstallHex*)bl)->setHexfile(hexfile);
+ bl->setOfFile(offile);
}
// the bootloader install class does NOT use any GUI stuff.
@@ -983,19 +973,19 @@ void RbUtilQt::uninstallBootloader(void)
BootloaderInstallBase *bl;
QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString();
if(type == "mi4") {
- bl = new BootloaderInstallMi4();
+ bl = new BootloaderInstallMi4(this);
}
else if(type == "hex") {
- bl = new BootloaderInstallHex();
+ bl = new BootloaderInstallHex(this);
}
else if(type == "sansa") {
- bl = new BootloaderInstallSansa();
+ bl = new BootloaderInstallSansa(this);
}
else if(type == "ipod") {
- bl = new BootloaderInstallIpod();
+ bl = new BootloaderInstallIpod(this);
}
else if(type == "file") {
- bl = new BootloaderInstallFile();
+ bl = new BootloaderInstallFile(this);
}
else {
logger->addItem(tr("No uninstall method known."), LOGERROR);