1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Dominik Wenger 2009-05-09 18:17:05 +00:00
parent 09085a30f6
commit 9ca29354e1
7 changed files with 57 additions and 46 deletions

View file

@ -24,39 +24,50 @@
#include "progressloggerinterface.h" #include "progressloggerinterface.h"
#include "httpget.h" #include "httpget.h"
//! baseclass for all Bootloader installs
class BootloaderInstallBase : public QObject class BootloaderInstallBase : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
enum Capability enum Capability
{ Install = 0x01, Uninstall = 0x02, Backup = 0x04, { Install = 0x01, Uninstall = 0x02, Backup = 0x04,
IsFile = 0x08, IsRaw = 0x10, NeedsFlashing = 0x20, IsFile = 0x08, IsRaw = 0x10, NeedsOf = 0x20,
CanCheckInstalled = 0x40, CanCheckVersion = 0x80 }; CanCheckInstalled = 0x40, CanCheckVersion = 0x80 };
Q_DECLARE_FLAGS(Capabilities, Capability) Q_DECLARE_FLAGS(Capabilities, Capability)
enum BootloaderType enum BootloaderType
{ BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown }; { BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown };
BootloaderInstallBase(QObject *parent = 0) : QObject(parent) BootloaderInstallBase(QObject *parent) : QObject(parent)
{ } { }
virtual bool install(void) //! install the bootloader, must be implemented
{ return false; } virtual bool install(void) = 0;
virtual bool uninstall(void) //! uninstall the bootloader, must be implemented
{ return false; } virtual bool uninstall(void) = 0;
virtual BootloaderType installed(void); //! returns the installed bootloader
virtual Capabilities capabilities(void); 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); bool backup(QString to);
//! set the differen filenames and paths
void setBlFile(QString f) void setBlFile(QString f)
{ m_blfile = f; } { m_blfile = f; }
void setBlUrl(QUrl u) void setBlUrl(QUrl u)
{ m_blurl = u; } { m_blurl = u; }
void setLogfile(QString f) void setLogfile(QString f)
{ m_logfile = 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); static QString postinstallHints(QString model);
protected slots: protected slots:
@ -76,7 +87,7 @@ class BootloaderInstallBase : public QObject
QUrl m_blurl; //! bootloader download URL QUrl m_blurl; //! bootloader download URL
QTemporaryFile m_tempfile; //! temporary file for download QTemporaryFile m_tempfile; //! temporary file for download
QDateTime m_blversion; //! download timestamp used for version information QDateTime m_blversion; //! download timestamp used for version information
QString m_offile; //! path to the offile
signals: signals:
void downloadDone(void); //! internal signal sent when download finished. void downloadDone(void); //! internal signal sent when download finished.
void done(bool); void done(bool);

View file

@ -30,7 +30,7 @@ class BootloaderInstallFile : public BootloaderInstallBase
Q_OBJECT Q_OBJECT
public: public:
BootloaderInstallFile(QObject *parent = 0); BootloaderInstallFile(QObject *parent);
bool install(void); bool install(void);
bool uninstall(void); bool uninstall(void);
BootloaderInstallBase::BootloaderType installed(void); BootloaderInstallBase::BootloaderType installed(void);

View file

@ -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) bool BootloaderInstallHex::install(void)
{ {
if(m_hex.isEmpty()) if(m_offile.isEmpty())
return false; return false;
m_hashindex = -1; m_hashindex = -1;
@ -55,7 +68,7 @@ bool BootloaderInstallHex::install(void)
emit logItem(tr("checking MD5 hash of input file ..."), LOGINFO); emit logItem(tr("checking MD5 hash of input file ..."), LOGINFO);
QByteArray filedata; QByteArray filedata;
// read hex file into QByteArray // read hex file into QByteArray
QFile file(m_hex); QFile file(m_offile);
file.open(QIODevice::ReadOnly); file.open(QIODevice::ReadOnly);
filedata = file.readAll(); filedata = file.readAll();
file.close(); file.close();
@ -97,7 +110,7 @@ bool BootloaderInstallHex::install(void)
emit logItem(tr("Descrambling file"), LOGINFO); emit logItem(tr("Descrambling file"), LOGINFO);
m_descrambled.open(); m_descrambled.open();
int result; int result;
result = iriver_decode(m_hex.toAscii().data(), result = iriver_decode(m_offile.toAscii().data(),
m_descrambled.fileName().toAscii().data(), FALSE, STRIP_NONE); m_descrambled.fileName().toAscii().data(), FALSE, STRIP_NONE);
qDebug() << "iriver_decode" << result; qDebug() << "iriver_decode" << result;
@ -223,7 +236,7 @@ BootloaderInstallBase::BootloaderType BootloaderInstallHex::installed(void)
BootloaderInstallBase::Capabilities BootloaderInstallHex::capabilities(void) BootloaderInstallBase::Capabilities BootloaderInstallHex::capabilities(void)
{ {
return (Install | NeedsFlashing); return (Install | NeedsOf);
} }
QString BootloaderInstallHex::scrambleError(int err) QString BootloaderInstallHex::scrambleError(int err)

View file

@ -37,12 +37,9 @@ class BootloaderInstallHex : public BootloaderInstallBase
bool uninstall(void); bool uninstall(void);
BootloaderInstallBase::BootloaderType installed(void); BootloaderInstallBase::BootloaderType installed(void);
Capabilities capabilities(void); Capabilities capabilities(void);
QString ofHint();
void setHexfile(QString h)
{ m_hex = h; }
private: private:
QString m_hex;
int m_hashindex; int m_hashindex;
int m_model; int m_model;
QTemporaryFile m_descrambled; QTemporaryFile m_descrambled;

View file

@ -31,7 +31,7 @@ class BootloaderInstallIpod : public BootloaderInstallBase
Q_OBJECT Q_OBJECT
public: public:
BootloaderInstallIpod(QObject *parent = 0); BootloaderInstallIpod(QObject *parent);
~BootloaderInstallIpod(); ~BootloaderInstallIpod();
bool install(void); bool install(void);
bool uninstall(void); bool uninstall(void);

View file

@ -30,7 +30,7 @@ class BootloaderInstallMi4 : public BootloaderInstallBase
Q_OBJECT Q_OBJECT
public: public:
BootloaderInstallMi4(QObject *parent = 0); BootloaderInstallMi4(QObject *parent);
bool install(void); bool install(void);
bool uninstall(void); bool uninstall(void);
BootloaderInstallBase::BootloaderType installed(void); BootloaderInstallBase::BootloaderType installed(void);

View file

@ -714,21 +714,11 @@ void RbUtilQt::installBootloader()
} }
} }
if(bl->capabilities() & BootloaderInstallBase::NeedsFlashing) if(bl->capabilities() & BootloaderInstallBase::NeedsOf)
{ {
int ret; int ret;
ret = QMessageBox::information(this, tr("Prerequisites"), ret = QMessageBox::information(this, tr("Prerequisites"),
tr("Bootloader installation requires you to provide " bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort);
"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);
if(ret != QMessageBox::Ok) { if(ret != QMessageBox::Ok) {
// consider aborting an error to close window / abort automatic // consider aborting an error to close window / abort automatic
// installation. // installation.
@ -736,16 +726,16 @@ void RbUtilQt::installBootloader()
logger->addItem(tr("Bootloader installation aborted"), LOGINFO); logger->addItem(tr("Bootloader installation aborted"), LOGINFO);
return; return;
} }
// open dialog to browse to hex file // open dialog to browse to of file
QString hexfile; QString offile;
hexfile = QFileDialog::getOpenFileName(this, offile = QFileDialog::getOpenFileName(this,
tr("Select firmware file"), QDir::homePath(), "*.hex"); tr("Select firmware file"), QDir::homePath());
if(!QFileInfo(hexfile).isReadable()) { if(!QFileInfo(offile).isReadable()) {
logger->addItem(tr("Error opening firmware file"), LOGERROR); logger->addItem(tr("Error opening firmware file"), LOGERROR);
m_error = true; m_error = true;
return; return;
} }
((BootloaderInstallHex*)bl)->setHexfile(hexfile); bl->setOfFile(offile);
} }
// the bootloader install class does NOT use any GUI stuff. // the bootloader install class does NOT use any GUI stuff.
@ -983,19 +973,19 @@ void RbUtilQt::uninstallBootloader(void)
BootloaderInstallBase *bl; BootloaderInstallBase *bl;
QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString(); QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString();
if(type == "mi4") { if(type == "mi4") {
bl = new BootloaderInstallMi4(); bl = new BootloaderInstallMi4(this);
} }
else if(type == "hex") { else if(type == "hex") {
bl = new BootloaderInstallHex(); bl = new BootloaderInstallHex(this);
} }
else if(type == "sansa") { else if(type == "sansa") {
bl = new BootloaderInstallSansa(); bl = new BootloaderInstallSansa(this);
} }
else if(type == "ipod") { else if(type == "ipod") {
bl = new BootloaderInstallIpod(); bl = new BootloaderInstallIpod(this);
} }
else if(type == "file") { else if(type == "file") {
bl = new BootloaderInstallFile(); bl = new BootloaderInstallFile(this);
} }
else { else {
logger->addItem(tr("No uninstall method known."), LOGERROR); logger->addItem(tr("No uninstall method known."), LOGERROR);