summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2007-07-27 22:46:49 +0000
committerDominik Wenger <domonoky@googlemail.com>2007-07-27 22:46:49 +0000
commit64f36a19e43b771a410ece775cba7f4dbe5ad4e1 (patch)
tree5765d16834b1f08adcf14ee4c30fe67dfcf7e103
parent794c9684307ecab734e24d7f41e8ec5954dd0cd3 (diff)
downloadrockbox-64f36a19e43b771a410ece775cba7f4dbe5ad4e1.tar.gz
rockbox-64f36a19e43b771a410ece775cba7f4dbe5ad4e1.tar.bz2
rockbox-64f36a19e43b771a410ece775cba7f4dbe5ad4e1.zip
rbutilQt: first attempt for bootloader installation. Sansa and irivers are still missing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14032 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/installbl.cpp124
-rw-r--r--rbutil/rbutilqt/installbl.h66
-rw-r--r--rbutil/rbutilqt/installbootloader.cpp702
-rw-r--r--rbutil/rbutilqt/installbootloader.h94
-rw-r--r--rbutil/rbutilqt/installbootloaderfrm.ui108
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp18
-rw-r--r--rbutil/rbutilqt/rbutilqt.h4
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro27
8 files changed, 1137 insertions, 6 deletions
diff --git a/rbutil/rbutilqt/installbl.cpp b/rbutil/rbutilqt/installbl.cpp
new file mode 100644
index 0000000000..eae8fc20f6
--- /dev/null
+++ b/rbutil/rbutilqt/installbl.cpp
@@ -0,0 +1,124 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: installbl.cpp 14027 2007-07-27 17:42:49Z domonoky $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "installbl.h"
+#include "ui_installfrm.h"
+#include "ui_installprogressfrm.h"
+
+
+InstallBl::InstallBl(QWidget *parent) : QDialog(parent)
+{
+ ui.setupUi(this);
+ connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
+}
+
+void InstallBl::setProxy(QUrl proxy_url)
+{
+ proxy = proxy_url;
+ qDebug() << "Install::setProxy" << proxy;
+}
+
+void InstallBl::setMountPoint(QString mount)
+{
+ QFileInfo m(mount);
+ if(m.isDir()) {
+ ui.lineMountPoint->clear();
+ ui.lineMountPoint->insert(mount);
+ }
+}
+
+void InstallBl::browseFolder()
+{
+ QFileDialog browser(this);
+ if(QFileInfo(ui.lineMountPoint->text()).isDir())
+ browser.setDirectory(ui.lineMountPoint->text());
+ else
+ browser.setDirectory("/media");
+ browser.setReadOnly(true);
+ browser.setFileMode(QFileDialog::DirectoryOnly);
+ browser.setAcceptMode(QFileDialog::AcceptOpen);
+ if(browser.exec()) {
+ qDebug() << browser.directory();
+ QStringList files = browser.selectedFiles();
+ setMountPoint(files.at(0));
+ }
+}
+
+void InstallBl::accept()
+{
+ QDialog *downloadProgress = new QDialog(this);
+ dp.setupUi(downloadProgress);
+ // connect close button now as it's needed if we break upon an error
+ connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
+ // show dialog with error if mount point is wrong
+ if(QFileInfo(ui.lineMountPoint->text()).isDir()) {
+ mountPoint = ui.lineMountPoint->text();
+ userSettings->setValue("defaults/mountpoint", mountPoint);
+ }
+ else {
+ dp.listProgress->addItem(tr("Mount point is wrong!"));
+ dp.buttonAbort->setText(tr("&Ok"));
+ downloadProgress->show();
+ return;
+ }
+ userSettings->sync();
+
+ binstaller = new BootloaderInstaller(this);
+
+ binstaller->setMountPoint(mountPoint);
+ binstaller->setProxy(proxy);
+ QString plattform = userSettings->value("defaults/platform").toString();
+
+ binstaller->setDevice(plattform);
+ binstaller->setBootloaderMethod(devices->value(plattform + "/bootloadermethod").toString());
+ binstaller->setBootloaderName(devices->value(plattform + "/bootloadername").toString());
+ binstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString());
+
+ binstaller->install(&dp);
+
+ connect(binstaller, SIGNAL(done(bool)), this, SLOT(done(bool)));
+
+ downloadProgress->show();
+}
+
+
+void InstallBl::done(bool error)
+{
+ qDebug() << "Install::done, error:" << error;
+
+ if(error)
+ {
+ connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(close()));
+ return;
+ }
+
+ connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(close()));
+ delete binstaller;
+}
+
+void InstallBl::setDeviceSettings(QSettings *dev)
+{
+ devices = dev;
+ qDebug() << "Install::setDeviceSettings:" << devices;
+}
+
+void InstallBl::setUserSettings(QSettings *user)
+{
+ userSettings = user;
+}
diff --git a/rbutil/rbutilqt/installbl.h b/rbutil/rbutilqt/installbl.h
new file mode 100644
index 0000000000..927cfa9b10
--- /dev/null
+++ b/rbutil/rbutilqt/installbl.h
@@ -0,0 +1,66 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: installbl.h 14027 2007-07-27 17:42:49Z domonoky $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef INSTALLBL_H
+#define INSTALLBL_H
+
+#include <QtGui>
+
+#include <QSettings>
+
+#include "ui_installbootloaderfrm.h"
+#include "ui_installprogressfrm.h"
+
+#include "installbootloader.h"
+
+class InstallBl : public QDialog
+{
+ Q_OBJECT
+ public:
+ InstallBl(QWidget *parent = 0);
+ void setProxy(QUrl);
+ void setMountPoint(QString);
+ void setUserSettings(QSettings*);
+ void setDeviceSettings(QSettings*);
+
+ public slots:
+ void accept(void);
+
+ private:
+ Ui::InstallBootloaderFrm ui;
+ Ui::InstallProgressFrm dp;
+ QUrl proxy;
+ QSettings *devices;
+ QSettings *userSettings;
+ QDialog *downloadProgress;
+ QHttp *download;
+ QFile *target;
+ QString file;
+ QString fileName;
+ QString mountPoint;
+ BootloaderInstaller* binstaller;
+
+ private slots:
+ void browseFolder(void);
+ void done(bool);
+
+};
+
+
+#endif
diff --git a/rbutil/rbutilqt/installbootloader.cpp b/rbutil/rbutilqt/installbootloader.cpp
new file mode 100644
index 0000000000..5c278ee5a7
--- /dev/null
+++ b/rbutil/rbutilqt/installbootloader.cpp
@@ -0,0 +1,702 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: installbootloader.cpp 13990 2007-07-25 22:26:10Z Dominik Wenger $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "installbootloader.h"
+
+BootloaderInstaller::BootloaderInstaller(QObject* parent): QObject(parent)
+{
+
+}
+
+void BootloaderInstaller::install(Ui::InstallProgressFrm* dp)
+{
+ m_dp = dp;
+ m_install = true;
+ m_dp->listProgress->addItem(tr("Starting bootloader installation"));
+
+ if(m_bootloadermethod == "gigabeatf")
+ {
+ // connect internal signal
+ connect(this,SIGNAL(prepare()),this,SLOT(gigabeatPrepare()));
+ connect(this,SIGNAL(finish()),this,SLOT(gigabeatFinish()));
+ }
+ else if(m_bootloadermethod == "iaudio")
+ {
+ // connect internal signal
+ connect(this,SIGNAL(prepare()),this,SLOT(iaudioPrepare()));
+ connect(this,SIGNAL(finish()),this,SLOT(iaudioFinish()));
+ }
+ else if(m_bootloadermethod == "h10")
+ {
+ // connect internal signal
+ connect(this,SIGNAL(prepare()),this,SLOT(h10Prepare()));
+ connect(this,SIGNAL(finish()),this,SLOT(h10Finish()));
+ }
+ else if(m_bootloadermethod == "ipodpatcher")
+ {
+ // connect internal signal
+ connect(this,SIGNAL(prepare()),this,SLOT(ipodPrepare()));
+ connect(this,SIGNAL(finish()),this,SLOT(ipodFinish()));
+ }
+ else
+ {
+ m_dp->listProgress->addItem(tr("unsupported install Method"));
+ emit done(true);
+ return;
+ }
+
+ emit prepare();
+}
+
+void BootloaderInstaller::uninstall(Ui::InstallProgressFrm* dp)
+{
+ m_dp = dp;
+ m_install = false;
+ m_dp->listProgress->addItem(tr("Starting bootloader uninstallation"));
+
+ if(m_bootloadermethod == "gigabeatf")
+ {
+ // connect internal signal
+ connect(this,SIGNAL(prepare()),this,SLOT(gigabeatPrepare()));
+ }
+ else if(m_bootloadermethod == "iaudio")
+ {
+ m_dp->listProgress->addItem(tr("No uninstallation possible"));
+ emit done(true);
+ return;
+ }
+ else if(m_bootloadermethod == "iaudio")
+ {
+ // connect internal signal
+ connect(this,SIGNAL(prepare()),this,SLOT(h10Prepare()));
+ }
+ else if(m_bootloadermethod == "ipodpatcher")
+ {
+ // connect internal signal
+ connect(this,SIGNAL(prepare()),this,SLOT(ipodPrepare()));
+ }
+ else
+ {
+ m_dp->listProgress->addItem(tr("unsupported install Method"));
+ emit done(true);
+ return;
+ }
+
+ emit prepare();
+}
+
+void BootloaderInstaller::downloadRequestFinished(int id, bool error)
+{
+ qDebug() << "BootloaderInstall::downloadRequestFinished" << id << error;
+ qDebug() << "error:" << getter->errorString();
+
+ downloadDone(error);
+}
+
+void BootloaderInstaller::downloadDone(bool error)
+{
+ qDebug() << "Install::downloadDone, error:" << error;
+
+ // update progress bar
+
+ int max = m_dp->progressBar->maximum();
+ if(max == 0) {
+ max = 100;
+ m_dp->progressBar->setMaximum(max);
+ }
+ m_dp->progressBar->setValue(max);
+ if(getter->httpResponse() != 200) {
+ m_dp->listProgress->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()));
+ m_dp->buttonAbort->setText(tr("&Ok"));
+ emit done(true);
+ return;
+ }
+ if(error) {
+ m_dp->listProgress->addItem(tr("Download error: %1").arg(getter->errorString()));
+ m_dp->buttonAbort->setText(tr("&Ok"));
+ emit done(true);
+ return;
+ }
+ else m_dp->listProgress->addItem(tr("Download finished."));
+
+ emit finish();
+
+}
+
+void BootloaderInstaller::updateDataReadProgress(int read, int total)
+{
+ m_dp->progressBar->setMaximum(total);
+ m_dp->progressBar->setValue(read);
+ qDebug() << "progress:" << read << "/" << total;
+}
+
+
+/**************************************************
+*** gigabeat secific code
+***************************************************/
+
+void BootloaderInstaller::gigabeatPrepare()
+{
+ if(m_install) // Installation
+ {
+ QString url = m_bootloaderUrlBase + "/gigabeat/" + 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
+ {
+ QString firmware = m_mountpoint + "/GBSYSTEM/FWIMG/FWIMG01.DAT";
+ QString firmwareOrig = firmware.append(".ORIG");
+
+ QFileInfo firmwareOrigFI(firmwareOrig);
+
+ // check if original firmware exists
+ if(!firmwareOrigFI.exists())
+ {
+ m_dp->listProgress->addItem(tr("Could not find the Original Firmware at: %1")
+ .arg(firmwareOrig));
+ emit done(true);
+ return;
+ }
+
+ QFile firmwareFile(firmware);
+ QFile firmwareOrigFile(firmwareOrig);
+
+ //remove modified firmware
+ if(!firmwareFile.remove())
+ {
+ m_dp->listProgress->addItem(tr("Could not remove the Firmware at: %1")
+ .arg(firmware));
+ emit done(true);
+ return;
+ }
+
+ //copy original firmware
+ if(!firmwareOrigFile.copy(firmware))
+ {
+ m_dp->listProgress->addItem(tr("Could not copy the Firmware from: %1 to %2")
+ .arg(firmwareOrig,firmware));
+ emit done(true);
+ return;
+ }
+
+ emit done(false); //success
+ }
+
+}
+
+void BootloaderInstaller::gigabeatFinish()
+{
+ // this step is only need for installation, so no code for uninstall here
+
+ m_dp->listProgress->addItem(tr("Finishing bootloader install"));
+
+ QString firmware = m_mountpoint + "/GBSYSTEM/FWIMG/" + m_bootloadername;
+
+ QFileInfo firmwareFI(firmware);
+
+ // check if firmware exists
+ if(!firmwareFI.exists())
+ {
+ m_dp->listProgress->addItem(tr("Could not find the Firmware at: %1")
+ .arg(firmware));
+ emit done(true);
+ return;
+ }
+
+ QString firmwareOrig = firmware;
+ firmwareOrig.append(".ORIG");
+ QFileInfo firmwareOrigFI(firmwareOrig);
+
+ // rename the firmware, if there is no original firmware there
+ if(!firmwareOrigFI.exists())
+ {
+ QFile firmwareFile(firmware);
+ if(!firmwareFile.rename(firmwareOrig))
+ {
+ m_dp->listProgress->addItem(tr("Could not rename: %1 to %2")
+ .arg(firmware,firmwareOrig));
+ emit done(true);
+ return;
+ }
+ }
+ else // or remove the normal firmware, if the original is there
+ {
+ QFile firmwareFile(firmware);
+ firmwareFile.remove();
+ }
+
+ //copy the firmware
+ if(!downloadFile.copy(firmware))
+ {
+ m_dp->listProgress->addItem(tr("Could not copy: %1 to %2")
+ .arg(m_tempfilename,firmware));
+ emit done(true);
+ return;
+ }
+
+ downloadFile.remove();
+
+ m_dp->listProgress->addItem(tr("Bootloader install finished successfully."));
+ m_dp->buttonAbort->setText(tr("&Ok"));
+
+ emit done(false); // success
+
+}
+
+/**************************************************
+*** iaudio secific code
+***************************************************/
+void BootloaderInstaller::iaudioPrepare()
+{
+
+ QString url = m_bootloaderUrlBase + "/iaudio/" + 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)));
+
+}
+
+void BootloaderInstaller::iaudioFinish()
+{
+ QString firmware = m_mountpoint + "/FIRMWARE/" + m_bootloadername;
+
+ //copy the firmware
+ if(!downloadFile.copy(firmware))
+ {
+ m_dp->listProgress->addItem(tr("Could not copy: %1 to %2")
+ .arg(m_tempfilename,firmware));
+ emit done(true);
+ return;
+ }
+
+ downloadFile.remove();
+
+ m_dp->listProgress->addItem(tr("Bootloader install finished successfully."));
+ m_dp->buttonAbort->setText(tr("&Ok"));
+
+ emit done(false); // success
+
+}
+
+
+/**************************************************
+*** h10 secific code
+***************************************************/
+void BootloaderInstaller::h10Prepare()
+{
+ if(m_install) // Installation
+ {
+ QString url = m_bootloaderUrlBase + "/iriver/" + 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
+ {
+
+ QString firmwarename = m_bootloadername.section('/', -1);
+
+ QString firmware = m_mountpoint + "/SYSTEM/" + firmwarename;
+ QString firmwareOrig = m_mountpoint + "/SYSTEM/Original.mi4";
+
+ QFileInfo firmwareFI(firmware);
+ if(!firmwareFI.exists()) //Firmware dosent exists on player
+ {
+ firmware = m_mountpoint + "/SYSTEM/H10EMP.mi4"; //attempt other firmwarename
+ firmwareFI.setFile(firmware);
+ if(!firmwareFI.exists()) //Firmware dosent exists on player
+ {
+ m_dp->listProgress->addItem(tr("Firmware doesn not exist: %1")
+ .arg(firmware));
+ emit done(true);
+ return;
+ }
+ }
+
+ QFileInfo firmwareOrigFI(firmwareOrig);
+ if(!firmwareOrigFI.exists()) //Original Firmware dosent exists on player
+ {
+ m_dp->listProgress->addItem(tr("Original Firmware doesn not exist: %1")
+ .arg(firmwareOrig));
+ emit done(true);
+ return;
+ }
+
+ QFile firmwareFile(firmware);
+ QFile firmwareOrigFile(firmwareOrig);
+
+ //remove modified firmware
+ if(!firmwareFile.remove())
+ {
+ m_dp->listProgress->addItem(tr("Could not remove the Firmware at: %1")
+ .arg(firmware));
+ emit done(true);
+ return;
+ }
+
+ //copy original firmware
+ if(!firmwareOrigFile.copy(firmware))
+ {
+ m_dp->listProgress->addItem(tr("Could not copy the Firmware from: %1 to %2")
+ .arg(firmwareOrig,firmware));
+ emit done(true);
+ return;
+ }
+
+ emit done(false); //success
+
+ }
+}
+
+void BootloaderInstaller::h10Finish()
+{
+ QString firmwarename = m_bootloadername.section('/', -1);
+
+ QString firmware = m_mountpoint + "/SYSTEM/" + firmwarename;
+ QString firmwareOrig = m_mountpoint + "/SYSTEM/Original.mi4";
+
+ QFileInfo firmwareFI(firmware);
+
+ if(!firmwareFI.exists()) //Firmware dosent exists on player
+ {
+ firmware = m_mountpoint + "/SYSTEM/H10EMP.mi4"; //attempt other firmwarename
+ firmwareFI.setFile(firmware);
+ if(!firmwareFI.exists()) //Firmware dosent exists on player
+ {
+ m_dp->listProgress->addItem(tr("Firmware does not exist: %1")
+ .arg(firmware));
+ emit done(true);
+ return;
+ }
+ }
+
+ QFileInfo firmwareOrigFI(firmwareOrig);
+
+ if(!firmwareOrigFI.exists()) //there is already a original firmware
+ {
+ QFile firmwareFile(firmware);
+ if(!firmwareFile.rename(firmwareOrig)) //rename Firmware to Original
+ {
+ m_dp->listProgress->addItem(tr("Could not rename: %1 to %2")
+ .arg(firmware,firmwareOrig));
+ emit done(true);
+ return;
+ }
+ }
+ else
+ {
+ QFile firmwareFile(firmware);
+ firmwareFile.remove();
+ }
+ //copy the firmware
+ if(!downloadFile.copy(firmware))
+ {
+ m_dp->listProgress->addItem(tr("Could not copy: %1 to %2")
+ .arg(m_tempfilename,firmware));
+ emit done(true);
+ return;
+ }
+
+ downloadFile.remove();
+
+ m_dp->listProgress->addItem(tr("Bootloader install finished successfully."));
+ m_dp->buttonAbort->setText(tr("&Ok"));
+
+ emit done(false); // success
+
+}
+
+/**************************************************
+*** ipod secific code
+***************************************************/
+int verbose =0;
+// reserves memory for ipodpatcher
+bool initIpodpatcher()
+{
+ if (ipod_alloc_buffer(&sectorbuf,BUFFER_SIZE) < 0) return true;
+ else return false;
+}
+
+void BootloaderInstaller::ipodPrepare()
+{
+ m_dp->listProgress->addItem(tr("Searching for ipods"));
+ struct ipod_t ipod;
+
+ int n = ipod_scan(&ipod);
+ if (n == 0)
+ {
+ m_dp->listProgress->addItem(tr("No Ipods found"));
+ emit done(true);
+ return;
+ }
+ if (n > 1)
+ {
+ m_dp->listProgress->addItem(tr("Too many Ipods found"));
+ emit done(true);
+ }
+
+ if(m_install) // Installation
+ {
+
+ QString url = m_bootloaderUrlBase + "/ipod/bootloader-" + m_bootloadername + ".ipod";
+
+ 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 (ipod_open(&ipod, 0) < 0)
+ {
+ m_dp->listProgress->addItem(tr("could not open ipod"));
+ emit done(true);
+ return;
+ }
+
+ if (read_partinfo(&ipod,0) < 0)
+ {
+ m_dp->listProgress->addItem(tr("could not read partitiontable"));
+ emit done(true);
+ return;
+ }
+
+ if (ipod.pinfo[0].start==0)
+ {
+ m_dp->listProgress->addItem(tr("No partition 0 on disk"));
+
+ int i;
+ double sectors_per_MB = (1024.0*1024.0)/ipod.sector_size;
+ m_dp->listProgress->addItem(tr("[INFO] Part Start Sector End Sector Size (MB) Type\n"));
+ for ( i = 0; i < 4; i++ )
+ {
+ if (ipod.pinfo[i].start != 0)
+ {
+ m_dp->listProgress->addItem(tr("[INFO] %1 %2 %3 %4 %5 (%6)").arg(
+ i).arg(
+ ipod.pinfo[i].start).arg(
+ ipod.pinfo[i].start+ipod.pinfo[i].size-1).arg(
+ ipod.pinfo[i].size/sectors_per_MB).arg(
+ get_parttype(ipod.pinfo[i].type)).arg(
+ ipod.pinfo[i].type));
+ }
+ }
+ emit done(true);
+ return;
+ }
+
+ read_directory(&ipod);
+
+ if (ipod.nimages <= 0)
+ {
+ m_dp->listProgress->addItem(tr("Failed to read firmware directory"));
+ emit done(true);
+ return;
+ }
+ if (getmodel(&ipod,(ipod.ipod_directory[0].vers>>8)) < 0)
+ {
+ m_dp->listProgress->addItem(tr("Unknown version number in firmware (%1)").arg(
+ ipod.ipod_directory[0].vers));
+ emit done(true);
+ return;
+ }
+
+ if (ipod.macpod)
+ {
+ m_dp->listProgress->addItem(tr("Warning this is a MacPod, Rockbox doesnt work on this. Convert it to WinPod"));
+ }
+
+ if (ipod_reopen_rw(&ipod) < 0)
+ {
+ m_dp->listProgress->addItem(tr("Could not open Ipod in RW mode"));
+ emit done(true);
+ return;
+ }
+
+ if (ipod.ipod_directory[0].entryOffset==0) {
+ m_dp->listProgress->addItem(tr("No bootloader detected."));
+ emit done(true);
+ return;
+ }
+
+ if (delete_bootloader(&ipod)==0)
+ {
+ m_dp->listProgress->addItem(tr("Successfully removed Bootloader"));
+ emit done(true);
+ ipod_close(&ipod);
+ return;
+ }
+ else
+ {
+ m_dp->listProgress->addItem(tr("--delete-bootloader failed."));
+ emit done(true);
+ return;
+ }
+ }
+}
+
+void BootloaderInstaller::ipodFinish()
+{
+ struct ipod_t ipod;
+ ipod_scan(&ipod);
+
+ if (ipod_open(&ipod, 0) < 0)
+ {
+ m_dp->listProgress->addItem(tr("could not open ipod"));
+ emit done(true);
+ return;
+ }
+
+ if (read_partinfo(&ipod,0) < 0)
+ {
+ m_dp->listProgress->addItem(tr("could not read partitiontable"));
+ emit done(true);
+ return;
+ }
+
+ if (ipod.pinfo[0].start==0)
+ {
+ m_dp->listProgress->addItem(tr("No partition 0 on disk"));
+
+ int i;
+ double sectors_per_MB = (1024.0*1024.0)/ipod.sector_size;
+
+ m_dp->listProgress->addItem(tr("[INFO] Part Start Sector End Sector Size (MB) Type\n"));
+
+ for ( i = 0; i < 4; i++ )
+ {
+ if (ipod.pinfo[i].start != 0)
+ {
+ m_dp->listProgress->addItem(tr("[INFO] %1 %2 %3 %4 %5 (%6)").arg(
+ i).arg(
+ ipod.pinfo[i].start).arg(
+ ipod.pinfo[i].start+ipod.pinfo[i].size-1).arg(
+ ipod.pinfo[i].size/sectors_per_MB).arg(
+ get_parttype(ipod.pinfo[i].type)).arg(
+ ipod.pinfo[i].type));
+ }
+ }
+ emit done(true);
+ return;
+ }
+
+ read_directory(&ipod);
+
+ if (ipod.nimages <= 0)
+ {
+ m_dp->listProgress->addItem(tr("Failed to read firmware directory"));
+ emit done(true);
+ return;
+ }
+ if (getmodel(&ipod,(ipod.ipod_directory[0].vers>>8)) < 0)
+ {
+ m_dp->listProgress->addItem(tr("Unknown version number in firmware (%1)").arg(
+ ipod.ipod_directory[0].vers));
+ emit done(true);
+ return;
+ }
+
+ if (ipod.macpod)
+ {
+ m_dp->listProgress->addItem(tr("Warning this is a MacPod, Rockbox doesnt work on this. Convert it to WinPod"));
+ }
+
+ if (ipod_reopen_rw(&ipod) < 0)
+ {
+ m_dp->listProgress->addItem(tr("Could not open Ipod in RW mode"));
+ emit done(true);
+ return;
+ }
+
+ if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0)
+ {
+ m_dp->listProgress->addItem(tr("Successfully added Bootloader"));
+ emit done(true);
+ ipod_close(&ipod);
+ return;
+ }
+ else
+ {
+ m_dp->listProgress->addItem(tr("failed to add Bootloader"));
+ ipod_close(&ipod);
+ emit done(true);
+ return;
+ }
+
+}
+
+
diff --git a/rbutil/rbutilqt/installbootloader.h b/rbutil/rbutilqt/installbootloader.h
new file mode 100644
index 0000000000..24d1fe33e4
--- /dev/null
+++ b/rbutil/rbutilqt/installbootloader.h
@@ -0,0 +1,94 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2007 by Dominik Wenger
+ * $Id: installbootloader.h 13990 2007-07-25 22:26:10Z Dominik Wenger $
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef INSTALLBOOTLOADER_H
+#define INSTALLBOOTLOADER_H
+
+#include <QtGui>
+
+#include "ui_installprogressfrm.h"
+#include "httpget.h"
+
+extern "C" {
+ // Ipodpatcher
+ #include "../ipodpatcher/ipodpatcher.h"
+};
+
+bool initIpodpatcher();
+
+class BootloaderInstaller : public QObject
+{
+ Q_OBJECT
+
+public:
+ BootloaderInstaller(QObject* parent);
+ ~BootloaderInstaller() {}
+
+ void install(Ui::InstallProgressFrm* dp);
+ void uninstall(Ui::InstallProgressFrm* dp);
+
+ void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;}
+ void setProxy(QUrl proxy) {m_proxy= proxy;}
+ void setDevice(QString device) {m_device= device;}
+ void setBootloaderMethod(QString method) {m_bootloadermethod= method;}
+ void setBootloaderName(QString name){m_bootloadername= name;}
+ void setBootloaderBaseUrl(QString baseUrl){m_bootloaderUrlBase = baseUrl;}
+
+signals:
+ void done(bool error); //installation finished.
+
+ // internal signals. Dont use this from out side.
+ void prepare();
+ void finish();
+
+private slots:
+ void updateDataReadProgress(int, int);
+ void downloadDone(bool);
+ void downloadRequestFinished(int, bool);
+
+ // gigabeat specific routines
+ void gigabeatPrepare();
+ void gigabeatFinish();
+
+ //iaudio specific routines
+ void iaudioPrepare();
+ void iaudioFinish();
+
+ //h10 specific routines
+ void h10Prepare();
+ void h10Finish();
+
+ //ipod specific routines
+ void ipodPrepare();
+ void ipodFinish();
+
+private:
+ QString m_mountpoint, m_device,m_bootloadermethod,m_bootloadername;
+ QString m_bootloaderUrlBase,m_tempfilename;
+ QUrl m_proxy;
+ bool m_install;
+
+
+ HttpGet *getter;
+ QTemporaryFile downloadFile;
+
+ Ui::InstallProgressFrm* m_dp;
+
+};
+#endif
diff --git a/rbutil/rbutilqt/installbootloaderfrm.ui b/rbutil/rbutilqt/installbootloaderfrm.ui
new file mode 100644
index 0000000000..93af750143
--- /dev/null
+++ b/rbutil/rbutilqt/installbootloaderfrm.ui
@@ -0,0 +1,108 @@
+<ui version="4.0" >
+ <class>InstallBootloaderFrm</class>
+ <widget class="QDialog" name="InstallBootloaderFrm" >
+ <property name="windowModality" >
+ <enum>Qt::WindowModal</enum>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>673</width>
+ <height>453</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Install Bootloader</string>
+ </property>
+ <layout class="QGridLayout" >
+ <item rowspan="8" row="0" column="0" >
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="pixmap" >
+ <pixmap resource="rbutilqt.qrc" >:/icons/icons/wizard.xpm</pixmap>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="3" >
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>Select your device in the filesystem</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="2" >
+ <widget class="QLineEdit" name="lineMountPoint" />
+ </item>
+ <item row="1" column="3" >
+ <widget class="QToolButton" name="buttonBrowse" >
+ <property name="text" >
+ <string>&amp;Browse</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="2" colspan="2" >
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item rowspan="4" row="2" column="1" colspan="3" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="rbutilqt.qrc" />
+ </resources>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>InstallBootloaderFrm</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>InstallBootloaderFrm</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 90744b5c85..d891acd0f3 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -25,7 +25,9 @@
#include "ui_aboutbox.h"
#include "configure.h"
#include "install.h"
+#include "installbl.h"
#include "httpget.h"
+#include "installbootloader.h"
RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
{
@@ -71,6 +73,7 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(configDialog()));
connect(ui.comboBoxDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDevice(int)));
connect(ui.buttonRockbox, SIGNAL(clicked()), this, SLOT(install()));
+ connect(ui.buttonBootloader, SIGNAL(clicked()), this, SLOT(installBl()));
// disable unimplemented stuff
ui.buttonThemes->setEnabled(false);
@@ -80,7 +83,9 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent)
ui.buttonGames->setEnabled(false);
ui.buttonFonts->setEnabled(false);
ui.buttonComplete->setEnabled(false);
+ ui.buttonDetect->setEnabled(false);
+ initIpodpatcher();
downloadInfo();
}
@@ -229,3 +234,16 @@ void RbUtilQt::install()
installWindow->show();
}
+
+void RbUtilQt::installBl()
+{
+ InstallBl *installWindow = new InstallBl(this);
+ installWindow->setUserSettings(userSettings);
+ installWindow->setDeviceSettings(devices);
+ if(userSettings->value("defaults/proxytype") == "manual")
+ installWindow->setProxy(QUrl(userSettings->value("defaults/proxy").toString()));
+ installWindow->setMountPoint(userSettings->value("defaults/mountpoint").toString());
+
+ installWindow->show();
+}
+
diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h
index 89a3610fba..324fe55e55 100644
--- a/rbutil/rbutilqt/rbutilqt.h
+++ b/rbutil/rbutilqt/rbutilqt.h
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
*
* Copyright (C) 2007 by Dominik Riebeling
- * $Id:$
+ * $Id$
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
@@ -26,7 +26,6 @@
#include <QSettings>
#include <QTemporaryFile>
-
class RbUtilQt : public QMainWindow
{
Q_OBJECT
@@ -50,6 +49,7 @@ class RbUtilQt : public QMainWindow
void configDialog(void);
void updateDevice(int);
void install(void);
+ void installBl(void);
void downloadDone(bool);
void downloadDone(int, bool);
void downloadInfo(void);
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 1491ab9d69..ef558de6a8 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -5,7 +5,11 @@ SOURCES += rbutilqt.cpp \
configure.cpp \
zip/zip.cpp \
zip/unzip.cpp \
- installzip.cpp
+ installzip.cpp \
+ installbootloader.cpp \
+ installbl.cpp \
+ ../ipodpatcher/ipodpatcher.c
+
HEADERS += rbutilqt.h \
settings.h \
@@ -18,8 +22,14 @@ HEADERS += rbutilqt.h \
zip/unzip_p.h \
zip/zip_p.h \
version.h \
- installzip.h
-
+ installzip.h \
+ installbootloader.h \
+ installbl.h \
+ ../ipodpatcher/ipodpatcher.h \
+ ../ipodpatcher/ipodio.h \
+ ../ipodpatcher/parttypes.h
+
+
TEMPLATE = app
CONFIG += release \
warn_on \
@@ -30,8 +40,17 @@ FORMS += rbutilqtfrm.ui \
aboutbox.ui \
installfrm.ui \
installprogressfrm.ui \
- configurefrm.ui
+ configurefrm.ui \
+ installbootloaderfrm.ui
RESOURCES += rbutilqt.qrc
TRANSLATIONS += rbutil_de.ts
QT += network
+
+win32{
+ SOURCES += ../ipodpatcher/ipodio-win32.c
+}
+
+!win32{
+ SOURCES += ../ipodpatcher/ipodio-posix.c
+}