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 "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);

View file

@ -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);

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)
{
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)

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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);