summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
24#include "progressloggerinterface.h" 24#include "progressloggerinterface.h"
25#include "httpget.h" 25#include "httpget.h"
26 26
27 27//! baseclass for all Bootloader installs
28class BootloaderInstallBase : public QObject 28class BootloaderInstallBase : public QObject
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31
32 public: 31 public:
33 enum Capability 32 enum Capability
34 { Install = 0x01, Uninstall = 0x02, Backup = 0x04, 33 { Install = 0x01, Uninstall = 0x02, Backup = 0x04,
35 IsFile = 0x08, IsRaw = 0x10, NeedsFlashing = 0x20, 34 IsFile = 0x08, IsRaw = 0x10, NeedsOf = 0x20,
36 CanCheckInstalled = 0x40, CanCheckVersion = 0x80 }; 35 CanCheckInstalled = 0x40, CanCheckVersion = 0x80 };
37 Q_DECLARE_FLAGS(Capabilities, Capability) 36 Q_DECLARE_FLAGS(Capabilities, Capability)
38 37
39 enum BootloaderType 38 enum BootloaderType
40 { BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown }; 39 { BootloaderNone, BootloaderRockbox, BootloaderOther, BootloaderUnknown };
41 40
42 BootloaderInstallBase(QObject *parent = 0) : QObject(parent) 41 BootloaderInstallBase(QObject *parent) : QObject(parent)
43 { } 42 { }
44 43
45 virtual bool install(void) 44 //! install the bootloader, must be implemented
46 { return false; } 45 virtual bool install(void) = 0;
47 virtual bool uninstall(void) 46 //! uninstall the bootloader, must be implemented
48 { return false; } 47 virtual bool uninstall(void) = 0;
49 virtual BootloaderType installed(void); 48 //! returns the installed bootloader
50 virtual Capabilities capabilities(void); 49 virtual BootloaderType installed(void)=0;
50 //! returns the capabilities of the bootloader class
51 virtual Capabilities capabilities(void)=0;
52 //! returns a OF Firmware hint or empty if there is none
53 virtual QString ofHint() {return QString();}
54
55
56 //! backup a already installed bootloader
51 bool backup(QString to); 57 bool backup(QString to);
52 58
59 //! set the differen filenames and paths
53 void setBlFile(QString f) 60 void setBlFile(QString f)
54 { m_blfile = f; } 61 { m_blfile = f; }
55 void setBlUrl(QUrl u) 62 void setBlUrl(QUrl u)
56 { m_blurl = u; } 63 { m_blurl = u; }
57 void setLogfile(QString f) 64 void setLogfile(QString f)
58 { m_logfile = f; } 65 { m_logfile = f; }
59 66 void setOfFile(QString f)
67 {m_offile = f;}
68
69 //! returns a port Install Hint or empty if there is none
70 //! static and in the base class, so the installer classes dont need to be modified for new targets
60 static QString postinstallHints(QString model); 71 static QString postinstallHints(QString model);
61 72
62 protected slots: 73 protected slots:
@@ -76,7 +87,7 @@ class BootloaderInstallBase : public QObject
76 QUrl m_blurl; //! bootloader download URL 87 QUrl m_blurl; //! bootloader download URL
77 QTemporaryFile m_tempfile; //! temporary file for download 88 QTemporaryFile m_tempfile; //! temporary file for download
78 QDateTime m_blversion; //! download timestamp used for version information 89 QDateTime m_blversion; //! download timestamp used for version information
79 90 QString m_offile; //! path to the offile
80 signals: 91 signals:
81 void downloadDone(void); //! internal signal sent when download finished. 92 void downloadDone(void); //! internal signal sent when download finished.
82 void done(bool); 93 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
30 Q_OBJECT 30 Q_OBJECT
31 31
32 public: 32 public:
33 BootloaderInstallFile(QObject *parent = 0); 33 BootloaderInstallFile(QObject *parent);
34 bool install(void); 34 bool install(void);
35 bool uninstall(void); 35 bool uninstall(void);
36 BootloaderInstallBase::BootloaderType installed(void); 36 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)
44{ 44{
45} 45}
46 46
47QString BootloaderInstallHex::ofHint()
48{
49 return tr("Bootloader installation requires you to provide "
50 "a firmware file of the original firmware (hex file). "
51 "You need to download this file yourself due to legal "
52 "reasons. Please refer to the "
53 "<a href='http://www.rockbox.org/manual.shtml'>manual</a> and the "
54 "<a href='http://www.rockbox.org/wiki/IriverBoot"
55 "#Download_and_extract_a_recent_ve'>IriverBoot</a> wiki page on "
56 "how to obtain this file.<br/>"
57 "Press Ok to continue and browse your computer for the firmware "
58 "file.");
59}
47 60
48bool BootloaderInstallHex::install(void) 61bool BootloaderInstallHex::install(void)
49{ 62{
50 if(m_hex.isEmpty()) 63 if(m_offile.isEmpty())
51 return false; 64 return false;
52 m_hashindex = -1; 65 m_hashindex = -1;
53 66
@@ -55,7 +68,7 @@ bool BootloaderInstallHex::install(void)
55 emit logItem(tr("checking MD5 hash of input file ..."), LOGINFO); 68 emit logItem(tr("checking MD5 hash of input file ..."), LOGINFO);
56 QByteArray filedata; 69 QByteArray filedata;
57 // read hex file into QByteArray 70 // read hex file into QByteArray
58 QFile file(m_hex); 71 QFile file(m_offile);
59 file.open(QIODevice::ReadOnly); 72 file.open(QIODevice::ReadOnly);
60 filedata = file.readAll(); 73 filedata = file.readAll();
61 file.close(); 74 file.close();
@@ -97,7 +110,7 @@ bool BootloaderInstallHex::install(void)
97 emit logItem(tr("Descrambling file"), LOGINFO); 110 emit logItem(tr("Descrambling file"), LOGINFO);
98 m_descrambled.open(); 111 m_descrambled.open();
99 int result; 112 int result;
100 result = iriver_decode(m_hex.toAscii().data(), 113 result = iriver_decode(m_offile.toAscii().data(),
101 m_descrambled.fileName().toAscii().data(), FALSE, STRIP_NONE); 114 m_descrambled.fileName().toAscii().data(), FALSE, STRIP_NONE);
102 qDebug() << "iriver_decode" << result; 115 qDebug() << "iriver_decode" << result;
103 116
@@ -223,7 +236,7 @@ BootloaderInstallBase::BootloaderType BootloaderInstallHex::installed(void)
223 236
224BootloaderInstallBase::Capabilities BootloaderInstallHex::capabilities(void) 237BootloaderInstallBase::Capabilities BootloaderInstallHex::capabilities(void)
225{ 238{
226 return (Install | NeedsFlashing); 239 return (Install | NeedsOf);
227} 240}
228 241
229QString BootloaderInstallHex::scrambleError(int err) 242QString 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
37 bool uninstall(void); 37 bool uninstall(void);
38 BootloaderInstallBase::BootloaderType installed(void); 38 BootloaderInstallBase::BootloaderType installed(void);
39 Capabilities capabilities(void); 39 Capabilities capabilities(void);
40 40 QString ofHint();
41 void setHexfile(QString h)
42 { m_hex = h; }
43 41
44 private: 42 private:
45 QString m_hex;
46 int m_hashindex; 43 int m_hashindex;
47 int m_model; 44 int m_model;
48 QTemporaryFile m_descrambled; 45 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
31 Q_OBJECT 31 Q_OBJECT
32 32
33 public: 33 public:
34 BootloaderInstallIpod(QObject *parent = 0); 34 BootloaderInstallIpod(QObject *parent);
35 ~BootloaderInstallIpod(); 35 ~BootloaderInstallIpod();
36 bool install(void); 36 bool install(void);
37 bool uninstall(void); 37 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
30 Q_OBJECT 30 Q_OBJECT
31 31
32 public: 32 public:
33 BootloaderInstallMi4(QObject *parent = 0); 33 BootloaderInstallMi4(QObject *parent);
34 bool install(void); 34 bool install(void);
35 bool uninstall(void); 35 bool uninstall(void);
36 BootloaderInstallBase::BootloaderType installed(void); 36 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()
714 } 714 }
715 } 715 }
716 716
717 if(bl->capabilities() & BootloaderInstallBase::NeedsFlashing) 717 if(bl->capabilities() & BootloaderInstallBase::NeedsOf)
718 { 718 {
719 int ret; 719 int ret;
720 ret = QMessageBox::information(this, tr("Prerequisites"), 720 ret = QMessageBox::information(this, tr("Prerequisites"),
721 tr("Bootloader installation requires you to provide " 721 bl->ofHint(),QMessageBox::Ok | QMessageBox::Abort);
722 "a firmware file of the original firmware (hex file). "
723 "You need to download this file yourself due to legal "
724 "reasons. Please refer to the "
725 "<a href='http://www.rockbox.org/manual.shtml'>manual</a> and the "
726 "<a href='http://www.rockbox.org/wiki/IriverBoot"
727 "#Download_and_extract_a_recent_ve'>IriverBoot</a> wiki page on "
728 "how to obtain this file.<br/>"
729 "Press Ok to continue and browse your computer for the firmware "
730 "file."),
731 QMessageBox::Ok | QMessageBox::Abort);
732 if(ret != QMessageBox::Ok) { 722 if(ret != QMessageBox::Ok) {
733 // consider aborting an error to close window / abort automatic 723 // consider aborting an error to close window / abort automatic
734 // installation. 724 // installation.
@@ -736,16 +726,16 @@ void RbUtilQt::installBootloader()
736 logger->addItem(tr("Bootloader installation aborted"), LOGINFO); 726 logger->addItem(tr("Bootloader installation aborted"), LOGINFO);
737 return; 727 return;
738 } 728 }
739 // open dialog to browse to hex file 729 // open dialog to browse to of file
740 QString hexfile; 730 QString offile;
741 hexfile = QFileDialog::getOpenFileName(this, 731 offile = QFileDialog::getOpenFileName(this,
742 tr("Select firmware file"), QDir::homePath(), "*.hex"); 732 tr("Select firmware file"), QDir::homePath());
743 if(!QFileInfo(hexfile).isReadable()) { 733 if(!QFileInfo(offile).isReadable()) {
744 logger->addItem(tr("Error opening firmware file"), LOGERROR); 734 logger->addItem(tr("Error opening firmware file"), LOGERROR);
745 m_error = true; 735 m_error = true;
746 return; 736 return;
747 } 737 }
748 ((BootloaderInstallHex*)bl)->setHexfile(hexfile); 738 bl->setOfFile(offile);
749 } 739 }
750 740
751 // the bootloader install class does NOT use any GUI stuff. 741 // the bootloader install class does NOT use any GUI stuff.
@@ -983,19 +973,19 @@ void RbUtilQt::uninstallBootloader(void)
983 BootloaderInstallBase *bl; 973 BootloaderInstallBase *bl;
984 QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString(); 974 QString type = RbSettings::value(RbSettings::CurBootloaderMethod).toString();
985 if(type == "mi4") { 975 if(type == "mi4") {
986 bl = new BootloaderInstallMi4(); 976 bl = new BootloaderInstallMi4(this);
987 } 977 }
988 else if(type == "hex") { 978 else if(type == "hex") {
989 bl = new BootloaderInstallHex(); 979 bl = new BootloaderInstallHex(this);
990 } 980 }
991 else if(type == "sansa") { 981 else if(type == "sansa") {
992 bl = new BootloaderInstallSansa(); 982 bl = new BootloaderInstallSansa(this);
993 } 983 }
994 else if(type == "ipod") { 984 else if(type == "ipod") {
995 bl = new BootloaderInstallIpod(); 985 bl = new BootloaderInstallIpod(this);
996 } 986 }
997 else if(type == "file") { 987 else if(type == "file") {
998 bl = new BootloaderInstallFile(); 988 bl = new BootloaderInstallFile(this);
999 } 989 }
1000 else { 990 else {
1001 logger->addItem(tr("No uninstall method known."), LOGERROR); 991 logger->addItem(tr("No uninstall method known."), LOGERROR);