rbutil: move bootloaderInstall object creation switches to bootloaderInstallBase .

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25882 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Wenger 2010-05-07 18:18:43 +00:00
parent e919b5d5b9
commit 26826b5ae5
3 changed files with 62 additions and 57 deletions

View file

@ -21,6 +21,14 @@
#include <QtCore>
#include "bootloaderinstallbase.h"
#include "bootloaderinstallmi4.h"
#include "bootloaderinstallhex.h"
#include "bootloaderinstallipod.h"
#include "bootloaderinstallsansa.h"
#include "bootloaderinstallfile.h"
#include "bootloaderinstallchinachip.h"
#include "bootloaderinstallams.h"
#include "bootloaderinstalltcc.h"
#include "utils.h"
#if defined(Q_OS_MACX)
@ -29,6 +37,39 @@
#include <sys/mount.h>
#endif
BootloaderInstallBase* BootloaderInstallBase::createBootloaderInstaller(QObject* parent,QString type)
{
if(type == "mi4") {
return new BootloaderInstallMi4(parent);
}
else if(type == "hex") {
return new BootloaderInstallHex(parent);
}
else if(type == "sansa") {
return new BootloaderInstallSansa(parent);
}
else if(type == "ipod") {
return new BootloaderInstallIpod(parent);
}
else if(type == "file") {
return new BootloaderInstallFile(parent);
}
else if(type == "chinachip") {
return new BootloaderInstallChinaChip(parent);
}
else if(type == "ams") {
return new BootloaderInstallAms(parent);
}
else if(type == "tcc") {
return new BootloaderInstallTcc(parent);
}
else {
return NULL;
}
}
BootloaderInstallBase::BootloaderType BootloaderInstallBase::installed(void)
{
return BootloaderUnknown;

View file

@ -70,6 +70,8 @@ class BootloaderInstallBase : public QObject
// be modified for new targets
static QString postinstallHints(QString model);
//! returns the correct BootloaderInstaller object for the requested type
static BootloaderInstallBase* createBootloaderInstaller(QObject* parent,QString type);
protected slots:
void downloadReqFinished(int id, bool error);
void downloadBlFinish(bool error);

View file

@ -43,14 +43,6 @@
#include "progressloggerinterface.h"
#include "bootloaderinstallbase.h"
#include "bootloaderinstallmi4.h"
#include "bootloaderinstallhex.h"
#include "bootloaderinstallipod.h"
#include "bootloaderinstallsansa.h"
#include "bootloaderinstallfile.h"
#include "bootloaderinstallchinachip.h"
#include "bootloaderinstallams.h"
#include "bootloaderinstalltcc.h"
#if defined(Q_OS_LINUX)
@ -673,33 +665,9 @@ void RbUtilQt::installBootloader()
m_error = false;
// create installer
BootloaderInstallBase *bl;
QString type = SystemInfo::value(SystemInfo::CurBootloaderMethod).toString();
if(type == "mi4") {
bl = new BootloaderInstallMi4(this);
}
else if(type == "hex") {
bl = new BootloaderInstallHex(this);
}
else if(type == "sansa") {
bl = new BootloaderInstallSansa(this);
}
else if(type == "ipod") {
bl = new BootloaderInstallIpod(this);
}
else if(type == "file") {
bl = new BootloaderInstallFile(this);
}
else if(type == "chinachip") {
bl = new BootloaderInstallChinaChip(this);
}
else if(type == "ams") {
bl = new BootloaderInstallAms(this);
}
else if(type == "tcc") {
bl = new BootloaderInstallTcc(this);
}
else {
BootloaderInstallBase *bl = BootloaderInstallBase::createBootloaderInstaller(this,
SystemInfo::value(SystemInfo::CurBootloaderMethod).toString());
if(bl == NULL) {
logger->addItem(tr("No install method known."), LOGERROR);
logger->setFinished();
return;
@ -1015,28 +983,22 @@ void RbUtilQt::uninstallBootloader(void)
QString platform = RbSettings::value(RbSettings::Platform).toString();
// create installer
BootloaderInstallBase *bl;
QString type = SystemInfo::value(SystemInfo::CurBootloaderMethod).toString();
if(type == "mi4") {
bl = new BootloaderInstallMi4(this);
}
else if(type == "hex") {
bl = new BootloaderInstallHex(this);
}
else if(type == "sansa") {
bl = new BootloaderInstallSansa(this);
}
else if(type == "ipod") {
bl = new BootloaderInstallIpod(this);
}
else if(type == "file") {
bl = new BootloaderInstallFile(this);
}
else {
logger->addItem(tr("No uninstall method known."), LOGERROR);
BootloaderInstallBase *bl = BootloaderInstallBase::createBootloaderInstaller(this,
SystemInfo::value(SystemInfo::CurBootloaderMethod).toString());
if(bl == NULL ) {
logger->addItem(tr("No uninstall method for this target known."), LOGERROR);
logger->setFinished();
return;
}
if( (bl->capabilities() & BootloaderInstallBase::Uninstall) == 0)
{
logger->addItem(tr("Rockbox Utility can not uninstall the bootloader on this target."
"Try a normal firmware update to remove the booloader."), LOGERROR);
logger->setFinished();
delete bl;
return;
}
QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList();
QStringList blfilepath;