diff --git a/rbutil/rbutilqt/base/bootloaderinstallbase.cpp b/rbutil/rbutilqt/base/bootloaderinstallbase.cpp index 6a2db76392..3a94180aab 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallbase.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallbase.cpp @@ -21,6 +21,14 @@ #include #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 #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; diff --git a/rbutil/rbutilqt/base/bootloaderinstallbase.h b/rbutil/rbutilqt/base/bootloaderinstallbase.h index 07fbd9ebcf..dec140efdc 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallbase.h +++ b/rbutil/rbutilqt/base/bootloaderinstallbase.h @@ -69,7 +69,9 @@ class BootloaderInstallBase : public QObject //! static and in the base class, so the installer classes dont need to // 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); diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 1c27d48508..c9becc6eac 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -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,38 +665,14 @@ 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; } - + // set bootloader filename. Do this now as installed() needs it. QStringList blfile = SystemInfo::value(SystemInfo::CurBootloaderFile).toStringList(); QStringList blfilepath; @@ -1015,29 +983,23 @@ 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; for(int a = 0; a < blfile.size(); a++) {