1
0
Fork 0
forked from len0rd/rockbox

rbutilQt: changed the progress/error logger, there is now an abstract interface and a progressloggergui implementation of it.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14060 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dominik Wenger 2007-07-29 18:07:31 +00:00
parent c414f46971
commit 917e0acd64
16 changed files with 724 additions and 561 deletions

View file

@ -19,8 +19,6 @@
#include "install.h" #include "install.h"
#include "ui_installfrm.h" #include "ui_installfrm.h"
#include "ui_installprogressfrm.h"
Install::Install(QWidget *parent) : QDialog(parent) Install::Install(QWidget *parent) : QDialog(parent)
{ {
@ -98,17 +96,17 @@ void Install::browseFolder()
void Install::accept() void Install::accept()
{ {
downloadProgress = new QDialog(this); logger = new ProgressLoggerGui(this);
dp.setupUi(downloadProgress); logger->show();
// show dialog with error if mount point is wrong // show dialog with error if mount point is wrong
if(QFileInfo(ui.lineMountPoint->text()).isDir()) { if(QFileInfo(ui.lineMountPoint->text()).isDir()) {
mountPoint = ui.lineMountPoint->text(); mountPoint = ui.lineMountPoint->text();
userSettings->setValue("defaults/mountpoint", mountPoint); userSettings->setValue("defaults/mountpoint", mountPoint);
} }
else { else {
dp.listProgress->addItem(tr("Mount point is wrong!")); logger->addItem(tr("Mount point is wrong!"));
dp.buttonAbort->setText(tr("&Ok")); logger->abort();
downloadProgress->show();
return; return;
} }
@ -147,26 +145,25 @@ void Install::accept()
installer->setProxy(proxy); installer->setProxy(proxy);
installer->setLogSection("rockboxbase"); installer->setLogSection("rockboxbase");
installer->setMountPoint(mountPoint); installer->setMountPoint(mountPoint);
installer->install(&dp); installer->install(logger);
connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
downloadProgress->show();
} }
// Zip installer has finished
void Install::done(bool error) void Install::done(bool error)
{ {
qDebug() << "Install::done, error:" << error; qDebug() << "Install::done, error:" << error;
if(error) if(error)
{ {
connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close())); logger->abort();
return; return;
} }
connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(close())); // no error, close the window, when the logger is closed
connect(dp.buttonAbort, SIGNAL(clicked()),downloadProgress, SLOT(close())); connect(logger,SIGNAL(closed()),this,SLOT(close()));
} }

View file

@ -25,8 +25,8 @@
#include <QSettings> #include <QSettings>
#include "ui_installfrm.h" #include "ui_installfrm.h"
#include "ui_installprogressfrm.h"
#include "installzip.h" #include "installzip.h"
#include "progressloggergui.h"
class Install : public QDialog class Install : public QDialog
{ {
@ -42,16 +42,14 @@ class Install : public QDialog
public slots: public slots:
void accept(void); void accept(void);
// void extractBuild(bool);
private: private:
Ui::InstallFrm ui; Ui::InstallFrm ui;
Ui::InstallProgressFrm dp; ProgressLoggerGui* logger;
QUrl proxy; QUrl proxy;
QString releasever; QString releasever;
QSettings *devices; QSettings *devices;
QSettings *userSettings; QSettings *userSettings;
QDialog *downloadProgress;
QHttp *download; QHttp *download;
QFile *target; QFile *target;
QString file; QString file;

View file

@ -1,176 +1,176 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* *
* Copyright (C) 2007 by Dominik Wenger * Copyright (C) 2007 by Dominik Wenger
* $Id: installbl.cpp 14027 2007-07-27 17:42:49Z domonoky $ * $Id: installbl.cpp 14027 2007-07-27 17:42:49Z domonoky $
* *
* All files in this archive are subject to the GNU General Public License. * 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. * 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 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "installbl.h" #include "installbl.h"
#include "ui_installprogressfrm.h" #include "ui_installprogressfrm.h"
InstallBl::InstallBl(QWidget *parent) : QDialog(parent) InstallBl::InstallBl(QWidget *parent) : QDialog(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder())); connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
connect(ui.buttonBrowseOF, SIGNAL(clicked()), this, SLOT(browseOF())); connect(ui.buttonBrowseOF, SIGNAL(clicked()), this, SLOT(browseOF()));
} }
void InstallBl::setProxy(QUrl proxy_url) void InstallBl::setProxy(QUrl proxy_url)
{ {
proxy = proxy_url; proxy = proxy_url;
qDebug() << "Install::setProxy" << proxy; qDebug() << "Install::setProxy" << proxy;
} }
void InstallBl::setMountPoint(QString mount) void InstallBl::setMountPoint(QString mount)
{ {
QFileInfo m(mount); QFileInfo m(mount);
if(m.isDir()) { if(m.isDir()) {
ui.lineMountPoint->clear(); ui.lineMountPoint->clear();
ui.lineMountPoint->insert(mount); ui.lineMountPoint->insert(mount);
} }
} }
void InstallBl::setOFPath(QString path) void InstallBl::setOFPath(QString path)
{ {
QFileInfo m(path); QFileInfo m(path);
if(m.exists()) { if(m.exists()) {
ui.lineOriginalFirmware->clear(); ui.lineOriginalFirmware->clear();
ui.lineOriginalFirmware->insert(path); ui.lineOriginalFirmware->insert(path);
} }
} }
void InstallBl::browseFolder() void InstallBl::browseFolder()
{ {
QFileDialog browser(this); QFileDialog browser(this);
if(QFileInfo(ui.lineMountPoint->text()).isDir()) if(QFileInfo(ui.lineMountPoint->text()).isDir())
browser.setDirectory(ui.lineMountPoint->text()); browser.setDirectory(ui.lineMountPoint->text());
else else
browser.setDirectory("/media"); browser.setDirectory("/media");
browser.setReadOnly(true); browser.setReadOnly(true);
browser.setFileMode(QFileDialog::DirectoryOnly); browser.setFileMode(QFileDialog::DirectoryOnly);
browser.setAcceptMode(QFileDialog::AcceptOpen); browser.setAcceptMode(QFileDialog::AcceptOpen);
if(browser.exec()) { if(browser.exec()) {
qDebug() << browser.directory(); qDebug() << browser.directory();
QStringList files = browser.selectedFiles(); QStringList files = browser.selectedFiles();
setMountPoint(files.at(0)); setMountPoint(files.at(0));
} }
} }
void InstallBl::browseOF() void InstallBl::browseOF()
{ {
QFileDialog browser(this); QFileDialog browser(this);
if(QFileInfo(ui.lineOriginalFirmware->text()).exists()) if(QFileInfo(ui.lineOriginalFirmware->text()).exists())
browser.setDirectory(ui.lineOriginalFirmware->text()); browser.setDirectory(ui.lineOriginalFirmware->text());
else else
browser.setDirectory("/media"); browser.setDirectory("/media");
browser.setReadOnly(true); browser.setReadOnly(true);
browser.setAcceptMode(QFileDialog::AcceptOpen); browser.setAcceptMode(QFileDialog::AcceptOpen);
if(browser.exec()) { if(browser.exec()) {
qDebug() << browser.directory(); qDebug() << browser.directory();
QStringList files = browser.selectedFiles(); QStringList files = browser.selectedFiles();
setOFPath(files.at(0)); setOFPath(files.at(0));
} }
} }
void InstallBl::accept() void InstallBl::accept()
{ {
downloadProgress = new QDialog(this); // create logger
dp.setupUi(downloadProgress); logger = new ProgressLoggerGui(this);
// show dialog with error if mount point is wrong logger->show();
if(QFileInfo(ui.lineMountPoint->text()).isDir()) {
mountPoint = ui.lineMountPoint->text(); // show dialog with error if mount point is wrong
userSettings->setValue("defaults/mountpoint", mountPoint); if(QFileInfo(ui.lineMountPoint->text()).isDir()) {
} mountPoint = ui.lineMountPoint->text();
else { userSettings->setValue("defaults/mountpoint", mountPoint);
dp.listProgress->addItem(tr("Mount point is wrong!")); }
dp.buttonAbort->setText(tr("&Ok")); else {
downloadProgress->show(); logger->addItem(tr("Mount point is wrong!"));
return; logger->abort();
} return;
}
if(QFileInfo(ui.lineOriginalFirmware->text()).exists())
{ if(QFileInfo(ui.lineOriginalFirmware->text()).exists())
m_OrigFirmware = ui.lineOriginalFirmware->text(); {
} m_OrigFirmware = ui.lineOriginalFirmware->text();
else }
{ else
dp.listProgress->addItem(tr("Original Firmware Path is wrong!")); {
dp.buttonAbort->setText(tr("&Ok")); logger->addItem(tr("Original Firmware Path is wrong!"));
downloadProgress->show(); logger->abort();
return; return;
} }
userSettings->sync(); userSettings->sync();
binstaller = new BootloaderInstaller(this); binstaller = new BootloaderInstaller(this);
binstaller->setMountPoint(mountPoint); binstaller->setMountPoint(mountPoint);
binstaller->setProxy(proxy); binstaller->setProxy(proxy);
QString plattform = userSettings->value("defaults/platform").toString(); QString plattform = userSettings->value("defaults/platform").toString();
binstaller->setDevice(plattform); binstaller->setDevice(plattform);
binstaller->setBootloaderMethod(devices->value(plattform + "/bootloadermethod").toString()); binstaller->setBootloaderMethod(devices->value(plattform + "/bootloadermethod").toString());
binstaller->setBootloaderName(devices->value(plattform + "/bootloadername").toString()); binstaller->setBootloaderName(devices->value(plattform + "/bootloadername").toString());
binstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString()); binstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString());
binstaller->setOrigFirmwarePath(m_OrigFirmware); binstaller->setOrigFirmwarePath(m_OrigFirmware);
binstaller->install(&dp); binstaller->install(logger);
connect(binstaller, SIGNAL(done(bool)), this, SLOT(done(bool))); connect(binstaller, SIGNAL(done(bool)), this, SLOT(done(bool)));
downloadProgress->show(); }
}
void InstallBl::done(bool error)
void InstallBl::done(bool error) {
{ qDebug() << "Install::done, error:" << error;
qDebug() << "Install::done, error:" << error;
if(error)
if(error) {
{ logger->abort();
connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close())); return;
return; }
}
// no error, close the window, when the logger is closed
connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(close())); connect(logger,SIGNAL(closed()),this,SLOT(close()));
connect(dp.buttonAbort, SIGNAL(clicked()),downloadProgress, SLOT(close()));
} }
void InstallBl::setDeviceSettings(QSettings *dev) void InstallBl::setDeviceSettings(QSettings *dev)
{ {
devices = dev; devices = dev;
if(userSettings->value("defaults/platform").toString() == "h100" || if(userSettings->value("defaults/platform").toString() == "h100" ||
userSettings->value("defaults/platform").toString() == "h120" || userSettings->value("defaults/platform").toString() == "h120" ||
userSettings->value("defaults/platform").toString() == "h300") userSettings->value("defaults/platform").toString() == "h300")
{ {
ui.buttonBrowseOF->show(); ui.buttonBrowseOF->show();
ui.lineOriginalFirmware->show(); ui.lineOriginalFirmware->show();
ui.label_3->show(); ui.label_3->show();
} }
else else
{ {
ui.buttonBrowseOF->hide(); ui.buttonBrowseOF->hide();
ui.lineOriginalFirmware->hide(); ui.lineOriginalFirmware->hide();
ui.label_3->hide(); ui.label_3->hide();
} }
qDebug() << "Install::setDeviceSettings:" << devices; qDebug() << "Install::setDeviceSettings:" << devices;
} }
void InstallBl::setUserSettings(QSettings *user) void InstallBl::setUserSettings(QSettings *user)
{ {
userSettings = user; userSettings = user;
} }

View file

@ -25,7 +25,7 @@
#include <QSettings> #include <QSettings>
#include "ui_installbootloaderfrm.h" #include "ui_installbootloaderfrm.h"
#include "ui_installprogressfrm.h" #include "progressloggergui.h"
#include "installbootloader.h" #include "installbootloader.h"
#include "irivertools/irivertools.h" #include "irivertools/irivertools.h"
@ -46,11 +46,10 @@ class InstallBl : public QDialog
private: private:
Ui::InstallBootloaderFrm ui; Ui::InstallBootloaderFrm ui;
Ui::InstallProgressFrm dp; ProgressLoggerGui* logger;
QUrl proxy; QUrl proxy;
QSettings *devices; QSettings *devices;
QSettings *userSettings; QSettings *userSettings;
QDialog *downloadProgress;
QHttp *download; QHttp *download;
QFile *target; QFile *target;
QString file; QString file;

View file

@ -24,11 +24,11 @@ BootloaderInstaller::BootloaderInstaller(QObject* parent): QObject(parent)
} }
void BootloaderInstaller::install(Ui::InstallProgressFrm* dp) void BootloaderInstaller::install(ProgressloggerInterface* dp)
{ {
m_dp = dp; m_dp = dp;
m_install = true; m_install = true;
m_dp->listProgress->addItem(tr("Starting bootloader installation")); m_dp->addItem(tr("Starting bootloader installation"));
if(m_bootloadermethod == "gigabeatf") if(m_bootloadermethod == "gigabeatf")
{ {
@ -68,7 +68,7 @@ void BootloaderInstaller::install(Ui::InstallProgressFrm* dp)
} }
else else
{ {
m_dp->listProgress->addItem(tr("unsupported install Method")); m_dp->addItem(tr("unsupported install Method"));
emit done(true); emit done(true);
return; return;
} }
@ -76,11 +76,11 @@ void BootloaderInstaller::install(Ui::InstallProgressFrm* dp)
emit prepare(); emit prepare();
} }
void BootloaderInstaller::uninstall(Ui::InstallProgressFrm* dp) void BootloaderInstaller::uninstall(ProgressloggerInterface* dp)
{ {
m_dp = dp; m_dp = dp;
m_install = false; m_install = false;
m_dp->listProgress->addItem(tr("Starting bootloader uninstallation")); m_dp->addItem(tr("Starting bootloader uninstallation"));
if(m_bootloadermethod == "gigabeatf") if(m_bootloadermethod == "gigabeatf")
{ {
@ -89,7 +89,7 @@ void BootloaderInstaller::uninstall(Ui::InstallProgressFrm* dp)
} }
else if(m_bootloadermethod == "iaudio") else if(m_bootloadermethod == "iaudio")
{ {
m_dp->listProgress->addItem(tr("No uninstallation possible")); m_dp->addItem(tr("No uninstallation possible"));
emit done(true); emit done(true);
return; return;
} }
@ -110,13 +110,13 @@ void BootloaderInstaller::uninstall(Ui::InstallProgressFrm* dp)
} }
else if(m_bootloadermethod == "fwpatcher") else if(m_bootloadermethod == "fwpatcher")
{ {
m_dp->listProgress->addItem(tr("No uninstallation possible")); m_dp->addItem(tr("No uninstallation possible"));
emit done(true); emit done(true);
return; return;
} }
else else
{ {
m_dp->listProgress->addItem(tr("unsupported install Method")); m_dp->addItem(tr("unsupported install Method"));
emit done(true); emit done(true);
return; return;
} }
@ -138,25 +138,25 @@ void BootloaderInstaller::downloadDone(bool error)
// update progress bar // update progress bar
int max = m_dp->progressBar->maximum(); int max = m_dp->getProgressMax();
if(max == 0) { if(max == 0) {
max = 100; max = 100;
m_dp->progressBar->setMaximum(max); m_dp->setProgressMax(max);
} }
m_dp->progressBar->setValue(max); m_dp->setProgressValue(max);
if(getter->httpResponse() != 200) { if(getter->httpResponse() != 200) {
m_dp->listProgress->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse())); m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(true); emit done(true);
return; return;
} }
if(error) { if(error) {
m_dp->listProgress->addItem(tr("Download error: %1").arg(getter->errorString())); m_dp->addItem(tr("Download error: %1").arg(getter->errorString()));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(true); emit done(true);
return; return;
} }
else m_dp->listProgress->addItem(tr("Download finished.")); else m_dp->addItem(tr("Download finished."));
emit finish(); emit finish();
@ -164,8 +164,8 @@ void BootloaderInstaller::downloadDone(bool error)
void BootloaderInstaller::updateDataReadProgress(int read, int total) void BootloaderInstaller::updateDataReadProgress(int read, int total)
{ {
m_dp->progressBar->setMaximum(total); m_dp->setProgressMax(total);
m_dp->progressBar->setValue(read); m_dp->setProgressValue(read);
qDebug() << "progress:" << read << "/" << total; qDebug() << "progress:" << read << "/" << total;
} }
@ -180,7 +180,7 @@ void BootloaderInstaller::gigabeatPrepare()
{ {
QString url = m_bootloaderUrlBase + "/gigabeat/" + m_bootloadername; QString url = m_bootloaderUrlBase + "/gigabeat/" + m_bootloadername;
m_dp->listProgress->addItem(tr("Downloading file %1.%2") m_dp->addItem(tr("Downloading file %1.%2")
.arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix())); .arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix()));
// temporary file needs to be opened to get the filename // temporary file needs to be opened to get the filename
@ -194,9 +194,8 @@ void BootloaderInstaller::gigabeatPrepare()
getter->getFile(QUrl(url)); getter->getFile(QUrl(url));
// connect signals from HttpGet // connect signals from HttpGet
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); 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))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int)));
connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort()));
} }
else //UnInstallation else //UnInstallation
{ {
@ -208,7 +207,7 @@ void BootloaderInstaller::gigabeatPrepare()
// check if original firmware exists // check if original firmware exists
if(!firmwareOrigFI.exists()) if(!firmwareOrigFI.exists())
{ {
m_dp->listProgress->addItem(tr("Could not find the Original Firmware at: %1") m_dp->addItem(tr("Could not find the Original Firmware at: %1")
.arg(firmwareOrig)); .arg(firmwareOrig));
emit done(true); emit done(true);
return; return;
@ -220,7 +219,7 @@ void BootloaderInstaller::gigabeatPrepare()
//remove modified firmware //remove modified firmware
if(!firmwareFile.remove()) if(!firmwareFile.remove())
{ {
m_dp->listProgress->addItem(tr("Could not remove the Firmware at: %1") m_dp->addItem(tr("Could not remove the Firmware at: %1")
.arg(firmware)); .arg(firmware));
emit done(true); emit done(true);
return; return;
@ -229,7 +228,7 @@ void BootloaderInstaller::gigabeatPrepare()
//copy original firmware //copy original firmware
if(!firmwareOrigFile.copy(firmware)) if(!firmwareOrigFile.copy(firmware))
{ {
m_dp->listProgress->addItem(tr("Could not copy the Firmware from: %1 to %2") m_dp->addItem(tr("Could not copy the Firmware from: %1 to %2")
.arg(firmwareOrig,firmware)); .arg(firmwareOrig,firmware));
emit done(true); emit done(true);
return; return;
@ -244,7 +243,7 @@ void BootloaderInstaller::gigabeatFinish()
{ {
// this step is only need for installation, so no code for uninstall here // this step is only need for installation, so no code for uninstall here
m_dp->listProgress->addItem(tr("Finishing bootloader install")); m_dp->addItem(tr("Finishing bootloader install"));
QString firmware = m_mountpoint + "/GBSYSTEM/FWIMG/" + m_bootloadername; QString firmware = m_mountpoint + "/GBSYSTEM/FWIMG/" + m_bootloadername;
@ -253,7 +252,7 @@ void BootloaderInstaller::gigabeatFinish()
// check if firmware exists // check if firmware exists
if(!firmwareFI.exists()) if(!firmwareFI.exists())
{ {
m_dp->listProgress->addItem(tr("Could not find the Firmware at: %1") m_dp->addItem(tr("Could not find the Firmware at: %1")
.arg(firmware)); .arg(firmware));
emit done(true); emit done(true);
return; return;
@ -269,7 +268,7 @@ void BootloaderInstaller::gigabeatFinish()
QFile firmwareFile(firmware); QFile firmwareFile(firmware);
if(!firmwareFile.rename(firmwareOrig)) if(!firmwareFile.rename(firmwareOrig))
{ {
m_dp->listProgress->addItem(tr("Could not rename: %1 to %2") m_dp->addItem(tr("Could not rename: %1 to %2")
.arg(firmware,firmwareOrig)); .arg(firmware,firmwareOrig));
emit done(true); emit done(true);
return; return;
@ -284,7 +283,7 @@ void BootloaderInstaller::gigabeatFinish()
//copy the firmware //copy the firmware
if(!downloadFile.copy(firmware)) if(!downloadFile.copy(firmware))
{ {
m_dp->listProgress->addItem(tr("Could not copy: %1 to %2") m_dp->addItem(tr("Could not copy: %1 to %2")
.arg(m_tempfilename,firmware)); .arg(m_tempfilename,firmware));
emit done(true); emit done(true);
return; return;
@ -292,8 +291,8 @@ void BootloaderInstaller::gigabeatFinish()
downloadFile.remove(); downloadFile.remove();
m_dp->listProgress->addItem(tr("Bootloader install finished successfully.")); m_dp->addItem(tr("Bootloader install finished successfully."));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(false); // success emit done(false); // success
@ -307,7 +306,7 @@ void BootloaderInstaller::iaudioPrepare()
QString url = m_bootloaderUrlBase + "/iaudio/" + m_bootloadername; QString url = m_bootloaderUrlBase + "/iaudio/" + m_bootloadername;
m_dp->listProgress->addItem(tr("Downloading file %1.%2") m_dp->addItem(tr("Downloading file %1.%2")
.arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix())); .arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix()));
// temporary file needs to be opened to get the filename // temporary file needs to be opened to get the filename
@ -321,9 +320,8 @@ void BootloaderInstaller::iaudioPrepare()
getter->getFile(QUrl(url)); getter->getFile(QUrl(url));
// connect signals from HttpGet // connect signals from HttpGet
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); 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))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int)));
connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort()));
} }
void BootloaderInstaller::iaudioFinish() void BootloaderInstaller::iaudioFinish()
@ -333,7 +331,7 @@ void BootloaderInstaller::iaudioFinish()
//copy the firmware //copy the firmware
if(!downloadFile.copy(firmware)) if(!downloadFile.copy(firmware))
{ {
m_dp->listProgress->addItem(tr("Could not copy: %1 to %2") m_dp->addItem(tr("Could not copy: %1 to %2")
.arg(m_tempfilename,firmware)); .arg(m_tempfilename,firmware));
emit done(true); emit done(true);
return; return;
@ -341,8 +339,8 @@ void BootloaderInstaller::iaudioFinish()
downloadFile.remove(); downloadFile.remove();
m_dp->listProgress->addItem(tr("Bootloader install finished successfully.")); m_dp->addItem(tr("Bootloader install finished successfully."));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(false); // success emit done(false); // success
@ -358,7 +356,7 @@ void BootloaderInstaller::h10Prepare()
{ {
QString url = m_bootloaderUrlBase + "/iriver/" + m_bootloadername; QString url = m_bootloaderUrlBase + "/iriver/" + m_bootloadername;
m_dp->listProgress->addItem(tr("Downloading file %1.%2") m_dp->addItem(tr("Downloading file %1.%2")
.arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix())); .arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix()));
// temporary file needs to be opened to get the filename // temporary file needs to be opened to get the filename
@ -372,8 +370,8 @@ void BootloaderInstaller::h10Prepare()
getter->getFile(QUrl(url)); getter->getFile(QUrl(url));
// connect signals from HttpGet // connect signals from HttpGet
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); 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))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int)));
connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort()));
} }
else // Uninstallation else // Uninstallation
{ {
@ -390,7 +388,7 @@ void BootloaderInstaller::h10Prepare()
firmwareFI.setFile(firmware); firmwareFI.setFile(firmware);
if(!firmwareFI.exists()) //Firmware dosent exists on player if(!firmwareFI.exists()) //Firmware dosent exists on player
{ {
m_dp->listProgress->addItem(tr("Firmware doesn not exist: %1") m_dp->addItem(tr("Firmware doesn not exist: %1")
.arg(firmware)); .arg(firmware));
emit done(true); emit done(true);
return; return;
@ -400,7 +398,7 @@ void BootloaderInstaller::h10Prepare()
QFileInfo firmwareOrigFI(firmwareOrig); QFileInfo firmwareOrigFI(firmwareOrig);
if(!firmwareOrigFI.exists()) //Original Firmware dosent exists on player if(!firmwareOrigFI.exists()) //Original Firmware dosent exists on player
{ {
m_dp->listProgress->addItem(tr("Original Firmware doesn not exist: %1") m_dp->addItem(tr("Original Firmware doesn not exist: %1")
.arg(firmwareOrig)); .arg(firmwareOrig));
emit done(true); emit done(true);
return; return;
@ -412,7 +410,7 @@ void BootloaderInstaller::h10Prepare()
//remove modified firmware //remove modified firmware
if(!firmwareFile.remove()) if(!firmwareFile.remove())
{ {
m_dp->listProgress->addItem(tr("Could not remove the Firmware at: %1") m_dp->addItem(tr("Could not remove the Firmware at: %1")
.arg(firmware)); .arg(firmware));
emit done(true); emit done(true);
return; return;
@ -421,7 +419,7 @@ void BootloaderInstaller::h10Prepare()
//copy original firmware //copy original firmware
if(!firmwareOrigFile.copy(firmware)) if(!firmwareOrigFile.copy(firmware))
{ {
m_dp->listProgress->addItem(tr("Could not copy the Firmware from: %1 to %2") m_dp->addItem(tr("Could not copy the Firmware from: %1 to %2")
.arg(firmwareOrig,firmware)); .arg(firmwareOrig,firmware));
emit done(true); emit done(true);
return; return;
@ -447,7 +445,7 @@ void BootloaderInstaller::h10Finish()
firmwareFI.setFile(firmware); firmwareFI.setFile(firmware);
if(!firmwareFI.exists()) //Firmware dosent exists on player if(!firmwareFI.exists()) //Firmware dosent exists on player
{ {
m_dp->listProgress->addItem(tr("Firmware does not exist: %1") m_dp->addItem(tr("Firmware does not exist: %1")
.arg(firmware)); .arg(firmware));
emit done(true); emit done(true);
return; return;
@ -461,7 +459,7 @@ void BootloaderInstaller::h10Finish()
QFile firmwareFile(firmware); QFile firmwareFile(firmware);
if(!firmwareFile.rename(firmwareOrig)) //rename Firmware to Original if(!firmwareFile.rename(firmwareOrig)) //rename Firmware to Original
{ {
m_dp->listProgress->addItem(tr("Could not rename: %1 to %2") m_dp->addItem(tr("Could not rename: %1 to %2")
.arg(firmware,firmwareOrig)); .arg(firmware,firmwareOrig));
emit done(true); emit done(true);
return; return;
@ -475,7 +473,7 @@ void BootloaderInstaller::h10Finish()
//copy the firmware //copy the firmware
if(!downloadFile.copy(firmware)) if(!downloadFile.copy(firmware))
{ {
m_dp->listProgress->addItem(tr("Could not copy: %1 to %2") m_dp->addItem(tr("Could not copy: %1 to %2")
.arg(m_tempfilename,firmware)); .arg(m_tempfilename,firmware));
emit done(true); emit done(true);
return; return;
@ -483,8 +481,8 @@ void BootloaderInstaller::h10Finish()
downloadFile.remove(); downloadFile.remove();
m_dp->listProgress->addItem(tr("Bootloader install finished successfully.")); m_dp->addItem(tr("Bootloader install finished successfully."));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(false); // success emit done(false); // success
@ -503,19 +501,19 @@ bool initIpodpatcher()
void BootloaderInstaller::ipodPrepare() void BootloaderInstaller::ipodPrepare()
{ {
m_dp->listProgress->addItem(tr("Searching for ipods")); m_dp->addItem(tr("Searching for ipods"));
struct ipod_t ipod; struct ipod_t ipod;
int n = ipod_scan(&ipod); int n = ipod_scan(&ipod);
if (n == 0) if (n == 0)
{ {
m_dp->listProgress->addItem(tr("No Ipods found")); m_dp->addItem(tr("No Ipods found"));
emit done(true); emit done(true);
return; return;
} }
if (n > 1) if (n > 1)
{ {
m_dp->listProgress->addItem(tr("Too many Ipods found")); m_dp->addItem(tr("Too many Ipods found"));
emit done(true); emit done(true);
} }
@ -524,7 +522,7 @@ void BootloaderInstaller::ipodPrepare()
QString url = m_bootloaderUrlBase + "/ipod/bootloader-" + m_bootloadername + ".ipod"; QString url = m_bootloaderUrlBase + "/ipod/bootloader-" + m_bootloadername + ".ipod";
m_dp->listProgress->addItem(tr("Downloading file %1.%2") m_dp->addItem(tr("Downloading file %1.%2")
.arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix())); .arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix()));
// temporary file needs to be opened to get the filename // temporary file needs to be opened to get the filename
@ -538,38 +536,37 @@ void BootloaderInstaller::ipodPrepare()
getter->getFile(QUrl(url)); getter->getFile(QUrl(url));
// connect signals from HttpGet // connect signals from HttpGet
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); 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))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int)));
connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort()));
} }
else // Uninstallation else // Uninstallation
{ {
if (ipod_open(&ipod, 0) < 0) if (ipod_open(&ipod, 0) < 0)
{ {
m_dp->listProgress->addItem(tr("could not open ipod")); m_dp->addItem(tr("could not open ipod"));
emit done(true); emit done(true);
return; return;
} }
if (read_partinfo(&ipod,0) < 0) if (read_partinfo(&ipod,0) < 0)
{ {
m_dp->listProgress->addItem(tr("could not read partitiontable")); m_dp->addItem(tr("could not read partitiontable"));
emit done(true); emit done(true);
return; return;
} }
if (ipod.pinfo[0].start==0) if (ipod.pinfo[0].start==0)
{ {
m_dp->listProgress->addItem(tr("No partition 0 on disk")); m_dp->addItem(tr("No partition 0 on disk"));
int i; int i;
double sectors_per_MB = (1024.0*1024.0)/ipod.sector_size; 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")); m_dp->addItem(tr("[INFO] Part Start Sector End Sector Size (MB) Type\n"));
for ( i = 0; i < 4; i++ ) for ( i = 0; i < 4; i++ )
{ {
if (ipod.pinfo[i].start != 0) if (ipod.pinfo[i].start != 0)
{ {
m_dp->listProgress->addItem(tr("[INFO] %1 %2 %3 %4 %5 (%6)").arg( m_dp->addItem(tr("[INFO] %1 %2 %3 %4 %5 (%6)").arg(
i).arg( i).arg(
ipod.pinfo[i].start).arg( ipod.pinfo[i].start).arg(
ipod.pinfo[i].start+ipod.pinfo[i].size-1).arg( ipod.pinfo[i].start+ipod.pinfo[i].size-1).arg(
@ -586,13 +583,13 @@ void BootloaderInstaller::ipodPrepare()
if (ipod.nimages <= 0) if (ipod.nimages <= 0)
{ {
m_dp->listProgress->addItem(tr("Failed to read firmware directory")); m_dp->addItem(tr("Failed to read firmware directory"));
emit done(true); emit done(true);
return; return;
} }
if (getmodel(&ipod,(ipod.ipod_directory[0].vers>>8)) < 0) if (getmodel(&ipod,(ipod.ipod_directory[0].vers>>8)) < 0)
{ {
m_dp->listProgress->addItem(tr("Unknown version number in firmware (%1)").arg( m_dp->addItem(tr("Unknown version number in firmware (%1)").arg(
ipod.ipod_directory[0].vers)); ipod.ipod_directory[0].vers));
emit done(true); emit done(true);
return; return;
@ -600,32 +597,32 @@ void BootloaderInstaller::ipodPrepare()
if (ipod.macpod) if (ipod.macpod)
{ {
m_dp->listProgress->addItem(tr("Warning this is a MacPod, Rockbox doesnt work on this. Convert it to WinPod")); m_dp->addItem(tr("Warning this is a MacPod, Rockbox doesnt work on this. Convert it to WinPod"));
} }
if (ipod_reopen_rw(&ipod) < 0) if (ipod_reopen_rw(&ipod) < 0)
{ {
m_dp->listProgress->addItem(tr("Could not open Ipod in RW mode")); m_dp->addItem(tr("Could not open Ipod in RW mode"));
emit done(true); emit done(true);
return; return;
} }
if (ipod.ipod_directory[0].entryOffset==0) { if (ipod.ipod_directory[0].entryOffset==0) {
m_dp->listProgress->addItem(tr("No bootloader detected.")); m_dp->addItem(tr("No bootloader detected."));
emit done(true); emit done(true);
return; return;
} }
if (delete_bootloader(&ipod)==0) if (delete_bootloader(&ipod)==0)
{ {
m_dp->listProgress->addItem(tr("Successfully removed Bootloader")); m_dp->addItem(tr("Successfully removed Bootloader"));
emit done(false); emit done(false);
ipod_close(&ipod); ipod_close(&ipod);
return; return;
} }
else else
{ {
m_dp->listProgress->addItem(tr("--delete-bootloader failed.")); m_dp->addItem(tr("--delete-bootloader failed."));
emit done(true); emit done(true);
ipod_close(&ipod); ipod_close(&ipod);
return; return;
@ -640,32 +637,32 @@ void BootloaderInstaller::ipodFinish()
if (ipod_open(&ipod, 0) < 0) if (ipod_open(&ipod, 0) < 0)
{ {
m_dp->listProgress->addItem(tr("could not open ipod")); m_dp->addItem(tr("could not open ipod"));
emit done(true); emit done(true);
return; return;
} }
if (read_partinfo(&ipod,0) < 0) if (read_partinfo(&ipod,0) < 0)
{ {
m_dp->listProgress->addItem(tr("could not read partitiontable")); m_dp->addItem(tr("could not read partitiontable"));
emit done(true); emit done(true);
return; return;
} }
if (ipod.pinfo[0].start==0) if (ipod.pinfo[0].start==0)
{ {
m_dp->listProgress->addItem(tr("No partition 0 on disk")); m_dp->addItem(tr("No partition 0 on disk"));
int i; int i;
double sectors_per_MB = (1024.0*1024.0)/ipod.sector_size; 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")); m_dp->addItem(tr("[INFO] Part Start Sector End Sector Size (MB) Type\n"));
for ( i = 0; i < 4; i++ ) for ( i = 0; i < 4; i++ )
{ {
if (ipod.pinfo[i].start != 0) if (ipod.pinfo[i].start != 0)
{ {
m_dp->listProgress->addItem(tr("[INFO] %1 %2 %3 %4 %5 (%6)").arg( m_dp->addItem(tr("[INFO] %1 %2 %3 %4 %5 (%6)").arg(
i).arg( i).arg(
ipod.pinfo[i].start).arg( ipod.pinfo[i].start).arg(
ipod.pinfo[i].start+ipod.pinfo[i].size-1).arg( ipod.pinfo[i].start+ipod.pinfo[i].size-1).arg(
@ -682,13 +679,13 @@ void BootloaderInstaller::ipodFinish()
if (ipod.nimages <= 0) if (ipod.nimages <= 0)
{ {
m_dp->listProgress->addItem(tr("Failed to read firmware directory")); m_dp->addItem(tr("Failed to read firmware directory"));
emit done(true); emit done(true);
return; return;
} }
if (getmodel(&ipod,(ipod.ipod_directory[0].vers>>8)) < 0) if (getmodel(&ipod,(ipod.ipod_directory[0].vers>>8)) < 0)
{ {
m_dp->listProgress->addItem(tr("Unknown version number in firmware (%1)").arg( m_dp->addItem(tr("Unknown version number in firmware (%1)").arg(
ipod.ipod_directory[0].vers)); ipod.ipod_directory[0].vers));
emit done(true); emit done(true);
return; return;
@ -696,26 +693,26 @@ void BootloaderInstaller::ipodFinish()
if (ipod.macpod) if (ipod.macpod)
{ {
m_dp->listProgress->addItem(tr("Warning this is a MacPod, Rockbox doesnt work on this. Convert it to WinPod")); m_dp->addItem(tr("Warning this is a MacPod, Rockbox doesnt work on this. Convert it to WinPod"));
} }
if (ipod_reopen_rw(&ipod) < 0) if (ipod_reopen_rw(&ipod) < 0)
{ {
m_dp->listProgress->addItem(tr("Could not open Ipod in RW mode")); m_dp->addItem(tr("Could not open Ipod in RW mode"));
emit done(true); emit done(true);
return; return;
} }
if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0) if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0)
{ {
m_dp->listProgress->addItem(tr("Successfully added Bootloader")); m_dp->addItem(tr("Successfully added Bootloader"));
emit done(false); emit done(false);
ipod_close(&ipod); ipod_close(&ipod);
return; return;
} }
else else
{ {
m_dp->listProgress->addItem(tr("failed to add Bootloader")); m_dp->addItem(tr("failed to add Bootloader"));
ipod_close(&ipod); ipod_close(&ipod);
emit done(true); emit done(true);
return; return;
@ -735,19 +732,19 @@ bool initSansaPatcher()
void BootloaderInstaller::sansaPrepare() void BootloaderInstaller::sansaPrepare()
{ {
m_dp->listProgress->addItem(tr("Searching for sansas")); m_dp->addItem(tr("Searching for sansas"));
struct sansa_t sansa; struct sansa_t sansa;
int n = sansa_scan(&sansa); int n = sansa_scan(&sansa);
if (n == 0) if (n == 0)
{ {
m_dp->listProgress->addItem(tr("No Sansa found")); m_dp->addItem(tr("No Sansa found"));
emit done(true); emit done(true);
return; return;
} }
if (n > 1) if (n > 1)
{ {
m_dp->listProgress->addItem(tr("Too many Sansas found")); m_dp->addItem(tr("Too many Sansas found"));
emit done(true); emit done(true);
} }
@ -755,7 +752,7 @@ void BootloaderInstaller::sansaPrepare()
{ {
QString url = m_bootloaderUrlBase + "/sandisk-sansa/e200/" + m_bootloadername; QString url = m_bootloaderUrlBase + "/sandisk-sansa/e200/" + m_bootloadername;
m_dp->listProgress->addItem(tr("Downloading file %1.%2") m_dp->addItem(tr("Downloading file %1.%2")
.arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix())); .arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix()));
// temporary file needs to be opened to get the filename // temporary file needs to be opened to get the filename
@ -769,36 +766,36 @@ void BootloaderInstaller::sansaPrepare()
getter->getFile(QUrl(url)); getter->getFile(QUrl(url));
// connect signals from HttpGet // connect signals from HttpGet
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); 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))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int)));
connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort()));
} }
else // Uninstallation else // Uninstallation
{ {
if (sansa_open(&sansa, 0) < 0) if (sansa_open(&sansa, 0) < 0)
{ {
m_dp->listProgress->addItem(tr("could not open Sansa")); m_dp->addItem(tr("could not open Sansa"));
emit done(true); emit done(true);
return; return;
} }
if (sansa_read_partinfo(&sansa,0) < 0) if (sansa_read_partinfo(&sansa,0) < 0)
{ {
m_dp->listProgress->addItem(tr("could not read partitiontable")); m_dp->addItem(tr("could not read partitiontable"));
emit done(true); emit done(true);
return; return;
} }
int i = is_e200(&sansa); int i = is_e200(&sansa);
if (i < 0) { if (i < 0) {
m_dp->listProgress->addItem(tr("Disk is not an E200 (%1), aborting.").arg(i)); m_dp->addItem(tr("Disk is not an E200 (%1), aborting.").arg(i));
emit done(true); emit done(true);
return; return;
} }
if (sansa.hasoldbootloader) if (sansa.hasoldbootloader)
{ {
m_dp->listProgress->addItem(tr("********************************************\n" m_dp->addItem(tr("********************************************\n"
"OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n" "OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n"
"You must reinstall the original Sansa firmware before running\n" "You must reinstall the original Sansa firmware before running\n"
"sansapatcher for the first time.\n" "sansapatcher for the first time.\n"
@ -811,21 +808,21 @@ void BootloaderInstaller::sansaPrepare()
if (sansa_reopen_rw(&sansa) < 0) if (sansa_reopen_rw(&sansa) < 0)
{ {
m_dp->listProgress->addItem(tr("Could not open Sansa in RW mode")); m_dp->addItem(tr("Could not open Sansa in RW mode"));
emit done(true); emit done(true);
return; return;
} }
if (sansa_delete_bootloader(&sansa)==0) if (sansa_delete_bootloader(&sansa)==0)
{ {
m_dp->listProgress->addItem(tr("Successfully removed Bootloader")); m_dp->addItem(tr("Successfully removed Bootloader"));
emit done(false); emit done(false);
sansa_close(&sansa); sansa_close(&sansa);
return; return;
} }
else else
{ {
m_dp->listProgress->addItem(tr("--delete-bootloader failed.")); m_dp->addItem(tr("--delete-bootloader failed."));
emit done(true); emit done(true);
sansa_close(&sansa); sansa_close(&sansa);
return; return;
@ -840,14 +837,14 @@ void BootloaderInstaller::sansaFinish()
if (sansa_open(&sansa, 0) < 0) if (sansa_open(&sansa, 0) < 0)
{ {
m_dp->listProgress->addItem(tr("could not open Sansa")); m_dp->addItem(tr("could not open Sansa"));
emit done(true); emit done(true);
return; return;
} }
if (sansa_read_partinfo(&sansa,0) < 0) if (sansa_read_partinfo(&sansa,0) < 0)
{ {
m_dp->listProgress->addItem(tr("could not read partitiontable")); m_dp->addItem(tr("could not read partitiontable"));
emit done(true); emit done(true);
return; return;
} }
@ -856,14 +853,14 @@ void BootloaderInstaller::sansaFinish()
int i = is_e200(&sansa); int i = is_e200(&sansa);
if (i < 0) { if (i < 0) {
m_dp->listProgress->addItem(tr("Disk is not an E200 (%1), aborting.").arg(i)); m_dp->addItem(tr("Disk is not an E200 (%1), aborting.").arg(i));
emit done(true); emit done(true);
return; return;
} }
if (sansa.hasoldbootloader) if (sansa.hasoldbootloader)
{ {
m_dp->listProgress->addItem(tr("********************************************\n" m_dp->addItem(tr("********************************************\n"
"OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n" "OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n"
"You must reinstall the original Sansa firmware before running\n" "You must reinstall the original Sansa firmware before running\n"
"sansapatcher for the first time.\n" "sansapatcher for the first time.\n"
@ -875,21 +872,21 @@ void BootloaderInstaller::sansaFinish()
if (sansa_reopen_rw(&sansa) < 0) if (sansa_reopen_rw(&sansa) < 0)
{ {
m_dp->listProgress->addItem(tr("Could not open Sansa in RW mode")); m_dp->addItem(tr("Could not open Sansa in RW mode"));
emit done(true); emit done(true);
return; return;
} }
if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0) if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0)
{ {
m_dp->listProgress->addItem(tr("Successfully added Bootloader")); m_dp->addItem(tr("Successfully added Bootloader"));
emit done(false); emit done(false);
sansa_close(&sansa); sansa_close(&sansa);
return; return;
} }
else else
{ {
m_dp->listProgress->addItem(tr("failed to add Bootloader")); m_dp->addItem(tr("failed to add Bootloader"));
sansa_close(&sansa); sansa_close(&sansa);
emit done(true); emit done(true);
return; return;
@ -905,7 +902,7 @@ void BootloaderInstaller::iriverPrepare()
{ {
char md5sum_str[32]; char md5sum_str[32];
if (!FileMD5(m_origfirmware, md5sum_str)) { if (!FileMD5(m_origfirmware, md5sum_str)) {
m_dp->listProgress->addItem(tr("Could not MD5Sum original firmware")); m_dp->addItem(tr("Could not MD5Sum original firmware"));
emit done(true); emit done(true);
return; return;
} }
@ -935,14 +932,14 @@ void BootloaderInstaller::iriverPrepare()
} }
if (series == 0) if (series == 0)
{ {
m_dp->listProgress->addItem(tr("Could not detect firmware type")); m_dp->addItem(tr("Could not detect firmware type"));
emit done(true); emit done(true);
return; return;
} }
QString url = m_bootloaderUrlBase + "/iriver/" + m_bootloadername; QString url = m_bootloaderUrlBase + "/iriver/" + m_bootloadername;
m_dp->listProgress->addItem(tr("Downloading file %1.%2") m_dp->addItem(tr("Downloading file %1.%2")
.arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix())); .arg(QFileInfo(url).baseName(), QFileInfo(url).completeSuffix()));
// temporary file needs to be opened to get the filename // temporary file needs to be opened to get the filename
@ -956,9 +953,8 @@ void BootloaderInstaller::iriverPrepare()
getter->getFile(QUrl(url)); getter->getFile(QUrl(url));
// connect signals from HttpGet // connect signals from HttpGet
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); 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))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int)));
connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort()));
} }
void BootloaderInstaller::iriverFinish() void BootloaderInstaller::iriverFinish()
@ -999,7 +995,7 @@ void BootloaderInstaller::iriverFinish()
// iriver decode // iriver decode
if (iriver_decode(m_origfirmware, firmwareBinName, FALSE, STRIP_NONE,m_dp) == -1) if (iriver_decode(m_origfirmware, firmwareBinName, FALSE, STRIP_NONE,m_dp) == -1)
{ {
m_dp->listProgress->addItem(tr("Error in descramble")); m_dp->addItem(tr("Error in descramble"));
firmwareBin.remove(); firmwareBin.remove();
newBin.remove(); newBin.remove();
newHex.remove(); newHex.remove();
@ -1009,7 +1005,7 @@ void BootloaderInstaller::iriverFinish()
// mkboot // mkboot
if (!mkboot(firmwareBinName, newBinName, m_tempfilename, origin,m_dp)) if (!mkboot(firmwareBinName, newBinName, m_tempfilename, origin,m_dp))
{ {
m_dp->listProgress->addItem(tr("Error in patching")); m_dp->addItem(tr("Error in patching"));
firmwareBin.remove(); firmwareBin.remove();
newBin.remove(); newBin.remove();
newHex.remove(); newHex.remove();
@ -1019,7 +1015,7 @@ void BootloaderInstaller::iriverFinish()
// iriver_encode // iriver_encode
if (iriver_encode(newBinName, newHexName, FALSE,m_dp) == -1) if (iriver_encode(newBinName, newHexName, FALSE,m_dp) == -1)
{ {
m_dp->listProgress->addItem(tr("Error in scramble")); m_dp->addItem(tr("Error in scramble"));
firmwareBin.remove(); firmwareBin.remove();
newBin.remove(); newBin.remove();
newHex.remove(); newHex.remove();
@ -1030,7 +1026,7 @@ void BootloaderInstaller::iriverFinish()
/* now md5sum it */ /* now md5sum it */
if (!FileMD5(newHexName, md5sum_str)) if (!FileMD5(newHexName, md5sum_str))
{ {
m_dp->listProgress->addItem(tr("Error in checksumming")); m_dp->addItem(tr("Error in checksumming"));
firmwareBin.remove(); firmwareBin.remove();
newBin.remove(); newBin.remove();
newHex.remove(); newHex.remove();
@ -1054,7 +1050,7 @@ void BootloaderInstaller::iriverFinish()
// copy file // copy file
if(!newHex.copy(dest)) if(!newHex.copy(dest))
{ {
m_dp->listProgress->addItem(tr("Could not copy: %1 to %2") m_dp->addItem(tr("Could not copy: %1 to %2")
.arg(newHexName,dest)); .arg(newHexName,dest));
emit done(true); emit done(true);
return; return;
@ -1063,8 +1059,8 @@ void BootloaderInstaller::iriverFinish()
downloadFile.remove(); downloadFile.remove();
newHex.remove(); newHex.remove();
m_dp->listProgress->addItem(tr("Bootloader install finished successfully.")); m_dp->addItem(tr("Bootloader install finished successfully."));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(false); // success emit done(false); // success

View file

@ -22,7 +22,7 @@
#include <QtGui> #include <QtGui>
#include "ui_installprogressfrm.h" #include "progressloggerinterface.h"
#include "httpget.h" #include "httpget.h"
#include "irivertools/irivertools.h" #include "irivertools/irivertools.h"
@ -43,8 +43,8 @@ public:
BootloaderInstaller(QObject* parent); BootloaderInstaller(QObject* parent);
~BootloaderInstaller() {} ~BootloaderInstaller() {}
void install(Ui::InstallProgressFrm* dp); void install(ProgressloggerInterface* dp);
void uninstall(Ui::InstallProgressFrm* dp); void uninstall(ProgressloggerInterface* dp);
void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;} void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;}
void setProxy(QUrl proxy) {m_proxy= proxy;} void setProxy(QUrl proxy) {m_proxy= proxy;}
@ -101,7 +101,7 @@ private:
HttpGet *getter; HttpGet *getter;
QTemporaryFile downloadFile; QTemporaryFile downloadFile;
Ui::InstallProgressFrm* m_dp; ProgressloggerInterface* m_dp;
}; };
#endif #endif

View file

@ -28,11 +28,11 @@ ZipInstaller::ZipInstaller(QObject* parent): QObject(parent)
} }
void ZipInstaller::install(Ui::InstallProgressFrm* dp) void ZipInstaller::install(ProgressloggerInterface* dp)
{ {
m_dp = dp; m_dp = dp;
m_dp->listProgress->addItem(tr("Downloading file %1.%2") m_dp->addItem(tr("Downloading file %1.%2")
.arg(QFileInfo(m_url).baseName(), QFileInfo(m_url).completeSuffix())); .arg(QFileInfo(m_url).baseName(), QFileInfo(m_url).completeSuffix()));
// temporary file needs to be opened to get the filename // temporary file needs to be opened to get the filename
@ -48,7 +48,7 @@ void ZipInstaller::install(Ui::InstallProgressFrm* dp)
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
connect(getter, SIGNAL(downloadDone(int, bool)), this, SLOT(downloadRequestFinished(int, bool))); connect(getter, SIGNAL(downloadDone(int, bool)), this, SLOT(downloadRequestFinished(int, bool)));
connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int))); connect(getter, SIGNAL(dataReadProgress(int, int)), this, SLOT(updateDataReadProgress(int, int)));
connect(m_dp->buttonAbort, SIGNAL(clicked()), getter, SLOT(abort())); connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort()));
} }
void ZipInstaller::downloadRequestFinished(int id, bool error) void ZipInstaller::downloadRequestFinished(int id, bool error)
@ -65,53 +65,53 @@ void ZipInstaller::downloadDone(bool error)
// update progress bar // update progress bar
int max = m_dp->progressBar->maximum(); int max = m_dp->getProgressMax();
if(max == 0) { if(max == 0) {
max = 100; max = 100;
m_dp->progressBar->setMaximum(max); m_dp->setProgressMax(max);
} }
m_dp->progressBar->setValue(max); m_dp->setProgressValue(max);
if(getter->httpResponse() != 200) { if(getter->httpResponse() != 200) {
m_dp->listProgress->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse())); m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(true); emit done(true);
return; return;
} }
if(error) { if(error) {
m_dp->listProgress->addItem(tr("Download error: %1").arg(getter->errorString())); m_dp->addItem(tr("Download error: %1").arg(getter->errorString()));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(true); emit done(true);
return; return;
} }
else m_dp->listProgress->addItem(tr("Download finished.")); else m_dp->addItem(tr("Download finished."));
// unzip downloaded file // unzip downloaded file
qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint; qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint;
m_dp->listProgress->addItem(tr("Extracting file.")); m_dp->addItem(tr("Extracting file."));
qDebug() << "file to unzip: " << m_file; qDebug() << "file to unzip: " << m_file;
UnZip::ErrorCode ec; UnZip::ErrorCode ec;
UnZip uz; UnZip uz;
ec = uz.openArchive(m_file); ec = uz.openArchive(m_file);
if(ec != UnZip::Ok) { if(ec != UnZip::Ok) {
m_dp->listProgress->addItem(tr("Opening archive failed: %1.") m_dp->addItem(tr("Opening archive failed: %1.")
.arg(uz.formatError(ec))); .arg(uz.formatError(ec)));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(false); emit done(false);
return; return;
} }
ec = uz.extractAll(m_mountpoint); ec = uz.extractAll(m_mountpoint);
if(ec != UnZip::Ok) { if(ec != UnZip::Ok) {
m_dp->listProgress->addItem(tr("Extracting failed: %1.") m_dp->addItem(tr("Extracting failed: %1.")
.arg(uz.formatError(ec))); .arg(uz.formatError(ec)));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(false); emit done(false);
return; return;
} }
m_dp->listProgress->addItem(tr("creating installation log")); m_dp->addItem(tr("creating installation log"));
QStringList zipContents = uz.fileList(); QStringList zipContents = uz.fileList();
@ -127,16 +127,15 @@ void ZipInstaller::downloadDone(bool error)
// remove temporary file // remove temporary file
downloadFile.remove(); downloadFile.remove();
m_dp->listProgress->addItem(tr("Extraction finished successfully.")); m_dp->addItem(tr("Extraction finished successfully."));
m_dp->buttonAbort->setText(tr("&Ok")); m_dp->abort();
emit done(false); emit done(false);
} }
void ZipInstaller::updateDataReadProgress(int read, int total) void ZipInstaller::updateDataReadProgress(int read, int total)
{ {
m_dp->progressBar->setMaximum(total); m_dp->setProgressMax(total);
m_dp->progressBar->setValue(read); m_dp->setProgressValue(read);
qDebug() << "progress:" << read << "/" << total; qDebug() << "progress:" << read << "/" << total;
} }

View file

@ -26,7 +26,7 @@
#include <QtGui> #include <QtGui>
#include <QtNetwork> #include <QtNetwork>
#include "ui_installprogressfrm.h" #include "progressloggerinterface.h"
#include "httpget.h" #include "httpget.h"
class ZipInstaller : public QObject class ZipInstaller : public QObject
@ -35,7 +35,7 @@ class ZipInstaller : public QObject
public: public:
ZipInstaller(QObject* parent) ; ZipInstaller(QObject* parent) ;
~ZipInstaller(){} ~ZipInstaller(){}
void install(Ui::InstallProgressFrm* dp); void install(ProgressloggerInterface* dp);
void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;} void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;}
void setFilename(QString filename){m_file = filename;} void setFilename(QString filename){m_file = filename;}
void setUrl(QString url){m_url = url;} void setUrl(QString url){m_url = url;}
@ -57,7 +57,7 @@ private:
HttpGet *getter; HttpGet *getter;
QTemporaryFile downloadFile; QTemporaryFile downloadFile;
Ui::InstallProgressFrm* m_dp; ProgressloggerInterface* m_dp;
}; };

View file

@ -1,128 +1,126 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* *
* Copyright (C) 2007 by Dominik Wenger * Copyright (C) 2007 by Dominik Wenger
* $Id: installzipwindow.cpp 14027 2007-07-27 17:42:49Z domonoky $ * $Id: installzipwindow.cpp 14027 2007-07-27 17:42:49Z domonoky $
* *
* All files in this archive are subject to the GNU General Public License. * 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. * 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 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "installzipwindow.h" #include "installzipwindow.h"
#include "ui_installprogressfrm.h" //#include "ui_installprogressfrm.h"
InstallZipWindow::InstallZipWindow(QWidget *parent) : QDialog(parent) InstallZipWindow::InstallZipWindow(QWidget *parent) : QDialog(parent)
{ {
ui.setupUi(this); ui.setupUi(this);
connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder())); connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
} }
void InstallZipWindow::setProxy(QUrl proxy_url) void InstallZipWindow::setProxy(QUrl proxy_url)
{ {
proxy = proxy_url; proxy = proxy_url;
qDebug() << "Install::setProxy" << proxy; qDebug() << "Install::setProxy" << proxy;
} }
void InstallZipWindow::setMountPoint(QString mount) void InstallZipWindow::setMountPoint(QString mount)
{ {
QFileInfo m(mount); QFileInfo m(mount);
if(m.isDir()) { if(m.isDir()) {
ui.lineMountPoint->clear(); ui.lineMountPoint->clear();
ui.lineMountPoint->insert(mount); ui.lineMountPoint->insert(mount);
} }
} }
void InstallZipWindow::setUrl(QString path) void InstallZipWindow::setUrl(QString path)
{ {
url = path; url = path;
} }
void InstallZipWindow::browseFolder() void InstallZipWindow::browseFolder()
{ {
QFileDialog browser(this); QFileDialog browser(this);
if(QFileInfo(ui.lineMountPoint->text()).isDir()) if(QFileInfo(ui.lineMountPoint->text()).isDir())
browser.setDirectory(ui.lineMountPoint->text()); browser.setDirectory(ui.lineMountPoint->text());
else else
browser.setDirectory("/media"); browser.setDirectory("/media");
browser.setReadOnly(true); browser.setReadOnly(true);
browser.setFileMode(QFileDialog::DirectoryOnly); browser.setFileMode(QFileDialog::DirectoryOnly);
browser.setAcceptMode(QFileDialog::AcceptOpen); browser.setAcceptMode(QFileDialog::AcceptOpen);
if(browser.exec()) { if(browser.exec()) {
qDebug() << browser.directory(); qDebug() << browser.directory();
QStringList files = browser.selectedFiles(); QStringList files = browser.selectedFiles();
setMountPoint(files.at(0)); setMountPoint(files.at(0));
} }
} }
void InstallZipWindow::accept() void InstallZipWindow::accept()
{ {
downloadProgress = new QDialog(this); // create logger
dp.setupUi(downloadProgress); logger = new ProgressLoggerGui(this);
logger->show();
// show dialog with error if mount point is wrong
if(QFileInfo(ui.lineMountPoint->text()).isDir()) { // show dialog with error if mount point is wrong
mountPoint = ui.lineMountPoint->text(); if(QFileInfo(ui.lineMountPoint->text()).isDir()) {
userSettings->setValue("defaults/mountpoint", mountPoint); mountPoint = ui.lineMountPoint->text();
} userSettings->setValue("defaults/mountpoint", mountPoint);
else { }
dp.listProgress->addItem(tr("Mount point is wrong!")); else {
dp.buttonAbort->setText(tr("&Ok")); logger->addItem(tr("Mount point is wrong!"));
downloadProgress->show(); logger->abort();
return; return;
} }
userSettings->sync(); userSettings->sync();
installer = new ZipInstaller(this); // create Zip installer
installer = new ZipInstaller(this);
QString fileName = url.section('/', -1);
QString fileName = url.section('/', -1);
installer->setFilename(fileName); installer->setFilename(fileName);
installer->setUrl(url); installer->setUrl(url);
installer->setProxy(proxy); installer->setProxy(proxy);
installer->setLogSection(logsection); installer->setLogSection(logsection);
installer->setMountPoint(mountPoint); installer->setMountPoint(mountPoint);
installer->install(&dp); installer->install(logger);
connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
downloadProgress->show();
}
}
// we are done with Zip installing
void InstallZipWindow::done(bool error)
void InstallZipWindow::done(bool error) {
{ qDebug() << "Install::done, error:" << error;
qDebug() << "Install::done, error:" << error;
if(error) // if there was an error
if(error) {
{ logger->abort();
// connect close button now as it's needed if we break upon an error return;
connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close())); }
return;
} // no error, close the window, when the logger is closed
connect(logger,SIGNAL(closed()),this,SLOT(close()));
connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(close())); }
connect(dp.buttonAbort, SIGNAL(clicked()),downloadProgress, SLOT(close()));
} void InstallZipWindow::setDeviceSettings(QSettings *dev)
{
void InstallZipWindow::setDeviceSettings(QSettings *dev) devices = dev;
{ qDebug() << "Install::setDeviceSettings:" << devices;
devices = dev; }
qDebug() << "Install::setDeviceSettings:" << devices;
} void InstallZipWindow::setUserSettings(QSettings *user)
{
void InstallZipWindow::setUserSettings(QSettings *user) userSettings = user;
{ }
userSettings = user;
}

View file

@ -1,68 +1,66 @@
/*************************************************************************** /***************************************************************************
* __________ __ ___. * __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/ * \/ \/ \/ \/ \/
* *
* Copyright (C) 2007 by Dominik Wenger * Copyright (C) 2007 by Dominik Wenger
* $Id: installzipwindow.h 14027 2007-07-27 17:42:49Z domonoky $ * $Id: installzipwindow.h 14027 2007-07-27 17:42:49Z domonoky $
* *
* All files in this archive are subject to the GNU General Public License. * 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. * 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 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#ifndef INSTALLZIPWINDOW_H #ifndef INSTALLZIPWINDOW_H
#define INSTALLZIPWINDOW_H #define INSTALLZIPWINDOW_H
#include <QtGui> #include <QtGui>
#include <QSettings> #include <QSettings>
#include "ui_installzipfrm.h" #include "ui_installzipfrm.h"
#include "ui_installprogressfrm.h" #include "installzip.h"
#include "installzip.h" #include "progressloggergui.h"
class InstallZipWindow : public QDialog
class InstallZipWindow : public QDialog {
{ Q_OBJECT
Q_OBJECT public:
public: InstallZipWindow(QWidget *parent = 0);
InstallZipWindow(QWidget *parent = 0); void setProxy(QUrl);
void setProxy(QUrl); void setMountPoint(QString);
void setMountPoint(QString); void setUrl(QString);
void setUrl(QString); void setLogSection(QString name){logsection = name; }
void setLogSection(QString name){logsection = name; } void setUserSettings(QSettings*);
void setUserSettings(QSettings*); void setDeviceSettings(QSettings*);
void setDeviceSettings(QSettings*);
public slots:
public slots: void accept(void);
void accept(void);
private:
private: Ui::InstallZipFrm ui;
Ui::InstallZipFrm ui; QUrl proxy;
Ui::InstallProgressFrm dp; QSettings *devices;
QUrl proxy; QSettings *userSettings;
QSettings *devices; ProgressLoggerGui* logger;
QSettings *userSettings; QString file;
QDialog *downloadProgress; QString fileName;
QString file; QString mountPoint;
QString fileName; QString url;
QString mountPoint; QString logsection;
QString url; ZipInstaller* installer;
QString logsection;
ZipInstaller* installer; private slots:
void browseFolder(void);
private slots: void done(bool);
void browseFolder(void);
void done(bool); };
};
#endif
#endif

View file

@ -47,7 +47,7 @@ const unsigned char header[][16] = {
/* begin mkboot.c excerpt */ /* begin mkboot.c excerpt */
unsigned char image[0x400000 + 0x220 + 0x400000/0x200]; unsigned char image[0x400000 + 0x220 + 0x400000/0x200];
bool mkboot(QString infile, QString outfile,QString bootloader,int origin,Ui::InstallProgressFrm* dp) bool mkboot(QString infile, QString outfile,QString bootloader,int origin,ProgressloggerInterface* dp)
{ {
int i; int i;
int len,bllen; int len,bllen;
@ -59,12 +59,12 @@ bool mkboot(QString infile, QString outfile,QString bootloader,int origin,Ui::In
QFile f(infile); QFile f(infile);
if(!f.open(QIODevice::ReadOnly)) if(!f.open(QIODevice::ReadOnly))
{ {
dp->listProgress->addItem("Could not open: %1" + infile); dp->addItem("Could not open: %1" + infile);
return false; return false;
} }
i = f.read((char*)image,16); i = f.read((char*)image,16);
if(i < 16) { if(i < 16) {
dp->listProgress->addItem("reading header failed"); dp->addItem("reading header failed");
return false; return false;
} }
@ -77,7 +77,7 @@ bool mkboot(QString infile, QString outfile,QString bootloader,int origin,Ui::In
len = binary_length+0x200-16; len = binary_length+0x200-16;
i = f.read((char*)image+16, len); i = f.read((char*)image+16, len);
if(i < len) { if(i < len) {
dp->listProgress->addItem("reading firmware failed"); dp->addItem("reading firmware failed");
return false; return false;
} }
@ -86,7 +86,7 @@ bool mkboot(QString infile, QString outfile,QString bootloader,int origin,Ui::In
f.setFileName(bootloader); f.setFileName(bootloader);
if(!f.open(QIODevice::ReadOnly)) if(!f.open(QIODevice::ReadOnly))
{ {
dp->listProgress->addItem("Could not open: %1" + bootloader); dp->addItem("Could not open: %1" + bootloader);
return false; return false;
} }
@ -94,7 +94,7 @@ bool mkboot(QString infile, QString outfile,QString bootloader,int origin,Ui::In
i = f.read((char*)image+0x220 + origin, bllen); i = f.read((char*)image+0x220 + origin, bllen);
if(i < bllen) { if(i < bllen) {
dp->listProgress->addItem("reading bootloader failed"); dp->addItem("reading bootloader failed");
return false; return false;
} }
@ -102,7 +102,7 @@ bool mkboot(QString infile, QString outfile,QString bootloader,int origin,Ui::In
f.setFileName(outfile); f.setFileName(outfile);
if(!f.open(QIODevice::WriteOnly)) if(!f.open(QIODevice::WriteOnly))
{ {
dp->listProgress->addItem("Could not open: %1" + outfile); dp->addItem("Could not open: %1" + outfile);
return false; return false;
} }
@ -154,7 +154,7 @@ bool mkboot(QString infile, QString outfile,QString bootloader,int origin,Ui::In
i = f.write((char*)image,total_length); i = f.write((char*)image,total_length);
if(i < total_length) { if(i < total_length) {
dp->listProgress->addItem("writing bootloader failed"); dp->addItem("writing bootloader failed");
return false; return false;
} }
@ -208,7 +208,7 @@ static void modifyheader( unsigned char * data )
}; };
int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify, int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify,
enum striptype stripmode,Ui::InstallProgressFrm* dp ) enum striptype stripmode,ProgressloggerInterface* dp )
{ {
QFile infile(infile_name); QFile infile(infile_name);
QFile outfile(outfile_name); QFile outfile(outfile_name);
@ -226,18 +226,18 @@ int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify
if(!infile.open(QIODevice::ReadOnly)) if(!infile.open(QIODevice::ReadOnly))
{ {
dp->listProgress->addItem("Could not open: %1" + infile_name); dp->addItem("Could not open: %1" + infile_name);
return -1; return -1;
} }
if(!outfile.open(QIODevice::WriteOnly)) if(!outfile.open(QIODevice::WriteOnly))
{ {
dp->listProgress->addItem("Could not open: %1" + outfile_name); dp->addItem("Could not open: %1" + outfile_name);
return -1; return -1;
} }
lenread = infile.read( (char*)headerdata, 512); lenread = infile.read( (char*)headerdata, 512);
if( lenread != 512 ) if( lenread != 512 )
{ {
dp->listProgress->addItem("This doesn't look like a valid encrypted iHP" dp->addItem("This doesn't look like a valid encrypted iHP"
"firmware - reason: header length."); "firmware - reason: header length.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -247,7 +247,7 @@ int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify
i = testheader( headerdata ); i = testheader( headerdata );
if( i == -1 ) if( i == -1 )
{ {
dp->listProgress->addItem("This firmware is for an unknown model, or is not" dp->addItem("This firmware is for an unknown model, or is not"
" a valid encrypted iHP firmware."); " a valid encrypted iHP firmware.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -270,7 +270,7 @@ int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify
dwLength2>>9 != dwLength3 || dwLength2>>9 != dwLength3 ||
dwLength2+dwLength3+512 != dwLength1 ) dwLength2+dwLength3+512 != dwLength1 )
{ {
dp->listProgress->addItem("This doesn't look like a valid encrypted " dp->addItem("This doesn't look like a valid encrypted "
"iHP firmware - reason: file 'length' data."); "iHP firmware - reason: file 'length' data.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -332,7 +332,7 @@ int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify
if( fp != dwLength2 ) if( fp != dwLength2 )
{ {
dp->listProgress->addItem("This doesn't look like a valid encrypted " dp->addItem("This doesn't look like a valid encrypted "
"iHP firmware - reason: 'length2' mismatch."); "iHP firmware - reason: 'length2' mismatch.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -349,7 +349,7 @@ int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify
outfile.write((char*) blockdata, lenread ); outfile.write((char*) blockdata, lenread );
if( memcmp( ppChecksums, blockdata, lenread ) != 0 ) if( memcmp( ppChecksums, blockdata, lenread ) != 0 )
{ {
dp->listProgress->addItem("This doesn't look like a valid encrypted " dp->addItem("This doesn't look like a valid encrypted "
"iHP firmware - reason: Checksum mismatch!"); "iHP firmware - reason: Checksum mismatch!");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -360,7 +360,7 @@ int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify
if( fp != dwLength3 ) if( fp != dwLength3 )
{ {
dp->listProgress->addItem("This doesn't look like a valid encrypted " dp->addItem("This doesn't look like a valid encrypted "
"iHP firmware - reason: 'length3' mismatch."); "iHP firmware - reason: 'length3' mismatch.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -392,7 +392,7 @@ int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify
}; };
int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify,Ui::InstallProgressFrm* dp ) int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify,ProgressloggerInterface* dp )
{ {
QFile infile(infile_name); QFile infile(infile_name);
QFile outfile(outfile_name); QFile outfile(outfile_name);
@ -409,19 +409,19 @@ int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify
if(!infile.open(QIODevice::ReadOnly)) if(!infile.open(QIODevice::ReadOnly))
{ {
dp->listProgress->addItem("Could not open: %1" + infile_name); dp->addItem("Could not open: %1" + infile_name);
return -1; return -1;
} }
if(!outfile.open(QIODevice::WriteOnly)) if(!outfile.open(QIODevice::WriteOnly))
{ {
dp->listProgress->addItem("Could not open: %1" + outfile_name); dp->addItem("Could not open: %1" + outfile_name);
return -1; return -1;
} }
lenread = infile.read((char*) headerdata, 512 ); lenread = infile.read((char*) headerdata, 512 );
if( lenread != 512 ) if( lenread != 512 )
{ {
dp->listProgress->addItem("This doesn't look like a valid decoded " dp->addItem("This doesn't look like a valid decoded "
"iHP firmware - reason: header length."); "iHP firmware - reason: header length.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -435,7 +435,7 @@ int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify
i = testheader( headerdata ); i = testheader( headerdata );
if( i == -1 ) if( i == -1 )
{ {
dp->listProgress->addItem("This firmware is for an unknown model, or is not" dp->addItem("This firmware is for an unknown model, or is not"
" a valid decoded iHP firmware."); " a valid decoded iHP firmware.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -456,7 +456,7 @@ int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify
dwLength3 > dwLength1 || dwLength3 > dwLength1 ||
dwLength2+dwLength3+512 != dwLength1 ) dwLength2+dwLength3+512 != dwLength1 )
{ {
dp->listProgress->addItem("This doesn't look like a valid decoded " dp->addItem("This doesn't look like a valid decoded "
"iHP firmware - reason:file 'length' data."); "iHP firmware - reason:file 'length' data.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -494,7 +494,7 @@ int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify
if( fp != dwLength2 ) if( fp != dwLength2 )
{ {
dp->listProgress->addItem("This doesn't look like a valid decoded " dp->addItem("This doesn't look like a valid decoded "
"iHP firmware - reason: 'length1' mismatch."); "iHP firmware - reason: 'length1' mismatch.");
infile.close(); infile.close();
outfile.close(); outfile.close();
@ -514,7 +514,7 @@ int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify
if( fp != dwLength3 ) if( fp != dwLength3 )
{ {
dp->listProgress->addItem("This doesn't look like a valid decoded " dp->addItem("This doesn't look like a valid decoded "
"iHP firmware - 'length2' mismatch."); "iHP firmware - 'length2' mismatch.");
infile.close(); infile.close();
outfile.close(); outfile.close();

View file

@ -25,7 +25,7 @@
#include <QtGui> #include <QtGui>
#include "md5sum.h" #include "md5sum.h"
#include "ui_installprogressfrm.h" #include "progressloggerinterface.h"
#define ESTF_SIZE 32 #define ESTF_SIZE 32
@ -61,9 +61,9 @@ enum striptype
int intable(char *md5, struct sumpairs *table, int len); int intable(char *md5, struct sumpairs *table, int len);
bool mkboot(QString infile, QString outfile,QString bootloader,int origin,Ui::InstallProgressFrm* dp); bool mkboot(QString infile, QString outfile,QString bootloader,int origin,ProgressloggerInterface* dp);
int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify, int iriver_decode(QString infile_name, QString outfile_name, unsigned int modify,
enum striptype stripmode,Ui::InstallProgressFrm* dp ); enum striptype stripmode,ProgressloggerInterface* dp );
int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify,Ui::InstallProgressFrm* dp); int iriver_encode(QString infile_name, QString outfile_name, unsigned int modify,ProgressloggerInterface* dp);
#endif // IRIVERTOOLS_H_INCLUDED #endif // IRIVERTOOLS_H_INCLUDED

View file

@ -0,0 +1,69 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2007 by Dominik Wenger
* $Id: progressloggergui.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 "progressloggergui.h"
ProgressLoggerGui::ProgressLoggerGui(QObject* parent): ProgressloggerInterface(parent)
{
downloadProgress = new QDialog();
dp.setupUi(downloadProgress);
connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
}
void ProgressLoggerGui::addItem(QString text)
{
dp.listProgress->addItem(text);
}
void ProgressLoggerGui::setProgressValue(int value)
{
dp.progressBar->setValue(value);
}
void ProgressLoggerGui::setProgressMax(int max)
{
dp.progressBar->setMaximum(max);
}
int ProgressLoggerGui::getProgressMax()
{
return dp.progressBar->maximum();
}
void ProgressLoggerGui::abort()
{
dp.buttonAbort->setText(tr("&Ok"));
disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
emit aborted();
}
void ProgressLoggerGui::close()
{
downloadProgress->close();
}
void ProgressLoggerGui::show()
{
downloadProgress->show();
}

View file

@ -0,0 +1,55 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2007 by Dominik Wenger
* $Id: progressloggergui.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 PROGRESSLOGGERGUI_H
#define PROGRESSLOGGERGUI_H
#include <QtGui>
#include "progressloggerinterface.h"
#include "ui_installprogressfrm.h"
class ProgressLoggerGui :public ProgressloggerInterface
{
Q_OBJECT
public:
ProgressLoggerGui(QObject * parent);
virtual void addItem(QString text) ; //adds a string to the list
virtual void setProgressValue(int value);
virtual void setProgressMax(int max);
virtual int getProgressMax();
signals:
virtual void aborted();
virtual void closed();
public slots:
virtual void abort();
virtual void close();
virtual void show();
private:
Ui::InstallProgressFrm dp;
QDialog *downloadProgress;
};
#endif

View file

@ -0,0 +1,51 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
*
* Copyright (C) 2007 by Dominik Wenger
* $Id: progressloggerinterface.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 PROGRESSLOGGERINTERFACE_H
#define PROGRESSLOGGERINTERFACE_H
#include <QtGui>
class ProgressloggerInterface : public QObject
{
Q_OBJECT
public:
ProgressloggerInterface(QObject* parent) : QObject(parent) {}
virtual void addItem(QString text) =0 ; //adds a string to the list
virtual void setProgressValue(int value)=0;
virtual void setProgressMax(int max)=0;
virtual int getProgressMax()=0;
signals:
virtual void aborted()=0;
public slots:
virtual void abort()=0;
virtual void close()=0;
virtual void show()=0;
private:
};
#endif

View file

@ -9,6 +9,7 @@ SOURCES += rbutilqt.cpp \
installbootloader.cpp \ installbootloader.cpp \
installbl.cpp \ installbl.cpp \
installzipwindow.cpp \ installzipwindow.cpp \
progressloggergui.cpp \
../ipodpatcher/ipodpatcher.c \ ../ipodpatcher/ipodpatcher.c \
../sansapatcher/sansapatcher.c \ ../sansapatcher/sansapatcher.c \
irivertools/irivertools.cpp \ irivertools/irivertools.cpp \
@ -30,6 +31,8 @@ HEADERS += rbutilqt.h \
installbootloader.h \ installbootloader.h \
installbl.h \ installbl.h \
installzipwindow.h \ installzipwindow.h \
progressloggerinterface.h \
progressloggergui.h \
../ipodpatcher/ipodpatcher.h \ ../ipodpatcher/ipodpatcher.h \
../ipodpatcher/ipodio.h \ ../ipodpatcher/ipodio.h \
../ipodpatcher/parttypes.h \ ../ipodpatcher/parttypes.h \
@ -44,7 +47,7 @@ HEADERS += rbutilqt.h \
TEMPLATE = app TEMPLATE = app
CONFIG += release \ CONFIG += release \
warn_on \ warn_on \
thread \ thread \
qt qt
TARGET = rbutilqt TARGET = rbutilqt