diff options
author | Dominik Wenger <domonoky@googlemail.com> | 2007-07-28 11:32:32 +0000 |
---|---|---|
committer | Dominik Wenger <domonoky@googlemail.com> | 2007-07-28 11:32:32 +0000 |
commit | 999676bdd9b19c9fddb143698bfb5e3f4f4ae62a (patch) | |
tree | eaf0cdd8316d80f2d0c146351d29c1c2cbc87ce0 /rbutil | |
parent | cb3412a7ef8d40c334bad11c160669a3f9374d24 (diff) |
rbutilqt: added sansapatcher to bootloader installation. now only iriver bootloaders are missing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14039 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/icons/talkfile_btn.png | bin | 2796 -> 3776 bytes | |||
-rw-r--r-- | rbutil/rbutilqt/installbootloader.cpp | 190 | ||||
-rw-r--r-- | rbutil/rbutilqt/installbootloader.h | 6 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.pro | 12 |
4 files changed, 203 insertions, 5 deletions
diff --git a/rbutil/rbutilqt/icons/talkfile_btn.png b/rbutil/rbutilqt/icons/talkfile_btn.png Binary files differindex ba168676e1..64e2763c94 100644 --- a/rbutil/rbutilqt/icons/talkfile_btn.png +++ b/rbutil/rbutilqt/icons/talkfile_btn.png diff --git a/rbutil/rbutilqt/installbootloader.cpp b/rbutil/rbutilqt/installbootloader.cpp index 5c278ee5a7..85dd369693 100644 --- a/rbutil/rbutilqt/installbootloader.cpp +++ b/rbutil/rbutilqt/installbootloader.cpp @@ -54,6 +54,12 @@ void BootloaderInstaller::install(Ui::InstallProgressFrm* dp) connect(this,SIGNAL(prepare()),this,SLOT(ipodPrepare())); connect(this,SIGNAL(finish()),this,SLOT(ipodFinish())); } + else if(m_bootloadermethod == "sansapatcher") + { + // connect internal signal + connect(this,SIGNAL(prepare()),this,SLOT(sansaPrepare())); + connect(this,SIGNAL(finish()),this,SLOT(sansaFinish())); + } else { m_dp->listProgress->addItem(tr("unsupported install Method")); @@ -91,6 +97,11 @@ void BootloaderInstaller::uninstall(Ui::InstallProgressFrm* dp) // connect internal signal connect(this,SIGNAL(prepare()),this,SLOT(ipodPrepare())); } + else if(m_bootloadermethod == "sansapatcher") + { + // connect internal signal + connect(this,SIGNAL(prepare()),this,SLOT(sansaPrepare())); + } else { m_dp->listProgress->addItem(tr("unsupported install Method")); @@ -596,7 +607,7 @@ void BootloaderInstaller::ipodPrepare() if (delete_bootloader(&ipod)==0) { m_dp->listProgress->addItem(tr("Successfully removed Bootloader")); - emit done(true); + emit done(false); ipod_close(&ipod); return; } @@ -604,6 +615,7 @@ void BootloaderInstaller::ipodPrepare() { m_dp->listProgress->addItem(tr("--delete-bootloader failed.")); emit done(true); + ipod_close(&ipod); return; } } @@ -685,7 +697,7 @@ void BootloaderInstaller::ipodFinish() if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0) { m_dp->listProgress->addItem(tr("Successfully added Bootloader")); - emit done(true); + emit done(false); ipod_close(&ipod); return; } @@ -695,8 +707,182 @@ void BootloaderInstaller::ipodFinish() ipod_close(&ipod); emit done(true); return; + } +} + +/************************************************** +*** sansa secific code +***************************************************/ +// reserves memory for sansapatcher +bool initSansaPatcher() +{ + if (sansa_alloc_buffer(§orbuf,BUFFER_SIZE) < 0) return true; + else return false; +} + + +void BootloaderInstaller::sansaPrepare() +{ + m_dp->listProgress->addItem(tr("Searching for sansas")); + struct sansa_t sansa; + + int n = sansa_scan(&sansa); + if (n == 0) + { + m_dp->listProgress->addItem(tr("No Sansa found")); + emit done(true); + return; } + if (n > 1) + { + m_dp->listProgress->addItem(tr("Too many Sansas found")); + emit done(true); + } + + if(m_install) // Installation + { + QString url = m_bootloaderUrlBase + "/sandisk-sansa/e200/" + m_bootloadername; + + m_dp->listProgress->addItem(tr("Downloading file %1.%2") + .arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix())); + + // temporary file needs to be opened to get the filename + downloadFile.open(); + m_tempfilename = downloadFile.fileName(); + downloadFile.close(); + // get the real file. + getter = new HttpGet(this); + getter->setProxy(m_proxy); + getter->setFile(&downloadFile); + getter->getFile(QUrl(url)); + // connect signals from HttpGet + connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); + //connect(getter, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadRequestFinished(int, bool))); + connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int))); + } + else // Uninstallation + { + + if (sansa_open(&sansa, 0) < 0) + { + m_dp->listProgress->addItem(tr("could not open Sansa")); + emit done(true); + return; + } + + if (sansa_read_partinfo(&sansa,0) < 0) + { + m_dp->listProgress->addItem(tr("could not read partitiontable")); + emit done(true); + return; + } + + int i = is_e200(&sansa); + if (i < 0) { + m_dp->listProgress->addItem(tr("Disk is not an E200 (%1), aborting.").arg(i)); + emit done(true); + return; + } + + if (sansa.hasoldbootloader) + { + m_dp->listProgress->addItem(tr("********************************************\n" + "OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n" + "You must reinstall the original Sansa firmware before running\n" + "sansapatcher for the first time.\n" + "See http://www.rockbox.org/twiki/bin/view/Main/SansaE200Install\n" + "*********************************************\n")); + emit done(true); + return; + } + + + if (sansa_reopen_rw(&sansa) < 0) + { + m_dp->listProgress->addItem(tr("Could not open Sansa in RW mode")); + emit done(true); + return; + } + if (sansa_delete_bootloader(&sansa)==0) + { + m_dp->listProgress->addItem(tr("Successfully removed Bootloader")); + emit done(false); + sansa_close(&sansa); + return; + } + else + { + m_dp->listProgress->addItem(tr("--delete-bootloader failed.")); + emit done(true); + sansa_close(&sansa); + return; + } + } +} + +void BootloaderInstaller::sansaFinish() +{ + struct sansa_t sansa; + sansa_scan(&sansa); + + if (sansa_open(&sansa, 0) < 0) + { + m_dp->listProgress->addItem(tr("could not open Sansa")); + emit done(true); + return; + } + + if (sansa_read_partinfo(&sansa,0) < 0) + { + m_dp->listProgress->addItem(tr("could not read partitiontable")); + emit done(true); + return; + } + + + int i = is_e200(&sansa); + if (i < 0) { + + m_dp->listProgress->addItem(tr("Disk is not an E200 (%1), aborting.").arg(i)); + emit done(true); + return; + } + + if (sansa.hasoldbootloader) + { + m_dp->listProgress->addItem(tr("********************************************\n" + "OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n" + "You must reinstall the original Sansa firmware before running\n" + "sansapatcher for the first time.\n" + "See http://www.rockbox.org/twiki/bin/view/Main/SansaE200Install\n" + "*********************************************\n")); + emit done(true); + return; + } + + if (sansa_reopen_rw(&sansa) < 0) + { + m_dp->listProgress->addItem(tr("Could not open Sansa in RW mode")); + emit done(true); + return; + } + + if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0) + { + m_dp->listProgress->addItem(tr("Successfully added Bootloader")); + emit done(false); + sansa_close(&sansa); + return; + } + else + { + m_dp->listProgress->addItem(tr("failed to add Bootloader")); + sansa_close(&sansa); + emit done(true); + return; + } + } diff --git a/rbutil/rbutilqt/installbootloader.h b/rbutil/rbutilqt/installbootloader.h index 24d1fe33e4..8f3b6d4b64 100644 --- a/rbutil/rbutilqt/installbootloader.h +++ b/rbutil/rbutilqt/installbootloader.h @@ -28,9 +28,11 @@ extern "C" { // Ipodpatcher #include "../ipodpatcher/ipodpatcher.h" + #include "../sansapatcher/sansapatcher.h" }; bool initIpodpatcher(); +bool initSansapatcher(); class BootloaderInstaller : public QObject { @@ -78,6 +80,10 @@ private slots: void ipodPrepare(); void ipodFinish(); + //sansa specific routines + void sansaPrepare(); + void sansaFinish(); + private: QString m_mountpoint, m_device,m_bootloadermethod,m_bootloadername; QString m_bootloaderUrlBase,m_tempfilename; diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index ef558de6a8..dd8e1bca2c 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro @@ -8,7 +8,8 @@ SOURCES += rbutilqt.cpp \ installzip.cpp \ installbootloader.cpp \ installbl.cpp \ - ../ipodpatcher/ipodpatcher.c + ../ipodpatcher/ipodpatcher.c \ + ../sansapatcher/sansapatcher.c HEADERS += rbutilqt.h \ @@ -27,7 +28,9 @@ HEADERS += rbutilqt.h \ installbl.h \ ../ipodpatcher/ipodpatcher.h \ ../ipodpatcher/ipodio.h \ - ../ipodpatcher/parttypes.h + ../ipodpatcher/parttypes.h \ + ../sansapatcher/sansapatcher.h \ + ../sansapatcher/sansaio.h TEMPLATE = app @@ -46,11 +49,14 @@ RESOURCES += rbutilqt.qrc TRANSLATIONS += rbutil_de.ts QT += network +DEFINES += RBUTIL win32{ SOURCES += ../ipodpatcher/ipodio-win32.c + SOURCES += ../sansapatcher/sansaio-win32.c } -!win32{ +unix{ SOURCES += ../ipodpatcher/ipodio-posix.c + SOURCES += ../sansapatcher/sansaio-posix.c } |