summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/installbootloader.cpp125
-rw-r--r--rbutil/rbutilqt/installbootloader.h25
-rw-r--r--rbutil/rbutilqt/installzip.cpp1
-rw-r--r--rbutil/rbutilqt/rbutil.ini2
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp57
5 files changed, 190 insertions, 20 deletions
diff --git a/rbutil/rbutilqt/installbootloader.cpp b/rbutil/rbutilqt/installbootloader.cpp
index c124c71150..11798c1232 100644
--- a/rbutil/rbutilqt/installbootloader.cpp
+++ b/rbutil/rbutilqt/installbootloader.cpp
@@ -22,7 +22,7 @@
BootloaderInstaller::BootloaderInstaller(QObject* parent): QObject(parent)
{
-
+
}
void BootloaderInstaller::install(ProgressloggerInterface* dp)
@@ -179,6 +179,108 @@ void BootloaderInstaller::installEnded(bool error)
m_dp->abort();
}
+bool BootloaderInstaller::downloadInfo()
+{
+ // try to get the current build information
+ infodownloader = new HttpGet(this);
+
+ connect(infodownloader, SIGNAL(done(bool)), this, SLOT(infoDownloadDone(bool)));
+ connect(infodownloader, SIGNAL(requestFinished(int, bool)), this, SLOT(infoRequestFinished(int, bool)));
+
+ infodownloader->setProxy(m_proxy);
+
+ qDebug() << "downloading bootloader info";
+ infodownloader->setFile(&bootloaderInfo);
+ infodownloader->getFile(QUrl(m_bootloaderinfoUrl));
+
+ // block until its downloaded
+ qDebug() << "Waiting for Download finished";
+ infoDownloaded=false;
+ infoError = false;
+ while(!infoDownloaded )
+ QApplication::processEvents();
+ return !infoError;
+}
+
+void BootloaderInstaller::infoDownloadDone(bool error)
+{
+ if(error)
+ {
+ qDebug() << "network error:" << infodownloader->error();
+ return;
+ }
+ qDebug() << "network status:" << infodownloader->error();
+
+ infoDownloaded = true;
+}
+
+void BootloaderInstaller::infoRequestFinished(int id, bool error)
+{
+
+ if(error)
+ {
+ QString errorString;
+ errorString = tr("Network error: %1. Please check your network and proxy settings.")
+ .arg(infodownloader->errorString());
+ if(error) QMessageBox::about(NULL, "Network Error", errorString);
+ qDebug() << "downloadDone:" << id << error;
+
+ infoError = true;
+ infoDownloaded = true;
+ }
+ qDebug() << "infoRequestFinished:" << id << error;
+}
+
+
+void BootloaderInstaller::createInstallLog()
+{
+ m_dp->addItem(tr("Creating installation log"),LOGINFO);
+ QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
+
+ bootloaderInfo.open();
+ QSettings info(bootloaderInfo.fileName(), QSettings::IniFormat, this);
+ bootloaderInfo.close();
+ info.beginGroup(m_device);
+
+ installlog.beginGroup("Bootloader");
+ installlog.setValue("md5sum",info.value("md5sum").toString());
+ installlog.endGroup();
+ installlog.sync();
+}
+
+void BootloaderInstaller::removeInstallLog()
+{
+ m_dp->addItem(tr("Editing installation log"),LOGINFO);
+ QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
+ installlog.beginGroup("Bootloader");
+ installlog.remove("md5sum");
+ installlog.endGroup();
+ installlog.sync();
+}
+
+
+bool BootloaderInstaller::uptodate()
+{
+ QString installedMd5;
+ QString serverMd5;
+
+ QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
+ installlog.beginGroup("Bootloader");
+ installedMd5 = installlog.value("md5sum").toString();
+ installlog.endGroup();
+
+ bootloaderInfo.open();
+ QSettings info(bootloaderInfo.fileName(), QSettings::IniFormat, this);
+ bootloaderInfo.close();
+ info.beginGroup(m_device);
+ serverMd5 = info.value("md5sum").toString();
+ info.endGroup();
+
+ if(installedMd5 != serverMd5)
+ return false;
+ else
+ return true;
+}
/**************************************************
*** gigabeat secific code
@@ -244,6 +346,8 @@ void BootloaderInstaller::gigabeatPrepare()
return;
}
+ removeInstallLog();
+
emit done(false); //success
}
@@ -301,6 +405,8 @@ void BootloaderInstaller::gigabeatFinish()
downloadFile.remove();
+ createInstallLog();
+
m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);
@@ -357,6 +463,8 @@ void BootloaderInstaller::iaudioFinish()
downloadFile.remove();
+ createInstallLog();
+
m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);
@@ -448,6 +556,8 @@ void BootloaderInstaller::h10Prepare()
return;
}
+ removeInstallLog();
+
emit done(false); //success
}
@@ -503,7 +613,9 @@ void BootloaderInstaller::h10Finish()
}
downloadFile.remove();
-
+
+ createInstallLog();
+
m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
m_dp->abort();
@@ -639,6 +751,7 @@ void BootloaderInstaller::ipodPrepare()
if (delete_bootloader(&ipod)==0)
{
m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK);
+ removeInstallLog();
emit done(false);
ipod_close(&ipod);
return;
@@ -729,6 +842,7 @@ void BootloaderInstaller::ipodFinish()
if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0)
{
m_dp->addItem(tr("Successfully added Bootloader"),LOGOK);
+ createInstallLog();
emit done(false);
ipod_close(&ipod);
return;
@@ -839,6 +953,7 @@ void BootloaderInstaller::sansaPrepare()
if (sansa_delete_bootloader(&sansa)==0)
{
m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK);
+ removeInstallLog();
emit done(false);
sansa_close(&sansa);
return;
@@ -903,6 +1018,7 @@ void BootloaderInstaller::sansaFinish()
if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0)
{
m_dp->addItem(tr("Successfully added Bootloader"),LOGOK);
+ createInstallLog();
emit done(false);
sansa_close(&sansa);
return;
@@ -1070,7 +1186,10 @@ void BootloaderInstaller::iriverFinish()
dest = m_mountpoint + "/ihp_120.hex";
else if(series == 300)
dest = m_mountpoint + "/H300.hex";
+
// copy file
+ QFile destfile(dest);
+ if(destfile.exists()) destfile.remove();
if(!newHex.copy(dest))
{
m_dp->addItem(tr("Could not copy: %1 to %2")
@@ -1082,6 +1201,8 @@ void BootloaderInstaller::iriverFinish()
downloadFile.remove();
newHex.remove();
+ createInstallLog();
+
m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);
diff --git a/rbutil/rbutilqt/installbootloader.h b/rbutil/rbutilqt/installbootloader.h
index 1d5bc465c2..496389e9dc 100644
--- a/rbutil/rbutilqt/installbootloader.h
+++ b/rbutil/rbutilqt/installbootloader.h
@@ -48,23 +48,31 @@ public:
void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;}
void setProxy(QUrl proxy) {m_proxy= proxy;}
- void setDevice(QString device) {m_device= device;} // the current plattform
+ void setDevice(QString device) {m_device= device;} //!< the current plattform
void setBootloaderMethod(QString method) {m_bootloadermethod= method;}
void setBootloaderName(QString name){m_bootloadername= name;}
void setBootloaderBaseUrl(QString baseUrl){m_bootloaderUrlBase = baseUrl;}
- void setOrigFirmwarePath(QString path) {m_origfirmware = path;} //for iriver original firmware
-
+ void setOrigFirmwarePath(QString path) {m_origfirmware = path;} //!< for iriver original firmware
+ void setBootloaderInfoUrl(QString url) {m_bootloaderinfoUrl =url; } //!< the url for the info file
+ bool downloadInfo(); //!< should be called before install/uninstall, blocks until downloaded.
+ bool uptodate(); //!< returns wether the bootloader is uptodate
+
signals:
void done(bool error); //installation finished.
- // internal signals. Dont use this from out side.
+signals: // internal signals. Dont use this from out side.
void prepare();
- void finish();
+ void finish();
private slots:
+ void createInstallLog(); // adds the bootloader entry to the log
+ void removeInstallLog(); // removes the bootloader entry from the log
+
void updateDataReadProgress(int, int);
void downloadDone(bool);
void downloadRequestFinished(int, bool);
+ void infoDownloadDone(bool);
+ void infoRequestFinished(int, bool);
void installEnded(bool);
// gigabeat specific routines
@@ -92,9 +100,16 @@ private slots:
void iriverFinish();
private:
+
+ HttpGet *infodownloader;
+ QTemporaryFile bootloaderInfo;
+ volatile bool infoDownloaded;
+ volatile bool infoError;
+
QString m_mountpoint, m_device,m_bootloadermethod,m_bootloadername;
QString m_bootloaderUrlBase,m_tempfilename,m_origfirmware;
QUrl m_proxy;
+ QString m_bootloaderinfoUrl;
bool m_install;
int series,table_entry; // for fwpatcher
diff --git a/rbutil/rbutilqt/installzip.cpp b/rbutil/rbutilqt/installzip.cpp
index c5e91d8e36..2c7eac6451 100644
--- a/rbutil/rbutilqt/installzip.cpp
+++ b/rbutil/rbutilqt/installzip.cpp
@@ -192,6 +192,7 @@ void ZipInstaller::downloadDone(bool error)
installlog.setValue(zipContents.at(i), m_logver);
}
installlog.endGroup();
+ installlog.sync();
emit cont();
}
diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini
index d617f0fb98..09d9e24647 100644
--- a/rbutil/rbutilqt/rbutil.ini
+++ b/rbutil/rbutilqt/rbutil.ini
@@ -3,6 +3,8 @@ download_url=http://www.rockbox.org/download/
daily_url=http://download.rockbox.org/daily/
bleeding_url=http://build.rockbox.org/dist/build-
server_conf_url=http://www.rockbox.org/daily/build-info
+#bootloader_info_url=http://download.rockbox.org/bootloader/bootloaders-info
+bootloader_info_url=http://b23.org/~domonoky/bootloaders-info
bleeding_info=http://build.rockbox.org/cvsmod/build-info
font_url=http://www.rockbox.org/daily/fonts/rockbox-fonts.zip
last_release=2.5
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 3d700b7e81..a374737bd8 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -337,6 +337,40 @@ void RbUtilQt::installBl()
logger->show();
QString platform = userSettings->value("defaults/platform").toString();
+
+ // create installer
+ blinstaller = new BootloaderInstaller(this);
+
+ blinstaller->setMountPoint(userSettings->value("defaults/mountpoint").toString());
+
+ blinstaller->setProxy(proxy());
+ blinstaller->setDevice(platform);
+ blinstaller->setBootloaderMethod(devices->value(platform + "/bootloadermethod").toString());
+ blinstaller->setBootloaderName(devices->value(platform + "/bootloadername").toString());
+ blinstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString());
+ blinstaller->setBootloaderInfoUrl(devices->value("bootloader_info_url").toString());
+ if(!blinstaller->downloadInfo())
+ {
+ logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR);
+ logger->abort();
+ return;
+ }
+
+ if(blinstaller->uptodate())
+ {
+ int ret = QMessageBox::question(this, tr("Bootloader Installation"),
+ tr("It seem your Bootloader is already uptodate.\n"
+ "Do really want to install it?"),
+ QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Cancel);
+ if(ret == QMessageBox::Cancel)
+ {
+ logger->addItem(tr("Bootloader installation Canceled!"),LOGERROR);
+ logger->abort();
+ return;
+ }
+
+ }
// if fwpatcher , ask for extra file
QString offirmware;
@@ -367,22 +401,11 @@ void RbUtilQt::installBl()
return;
}
}
-
- // create installer
- blinstaller = new BootloaderInstaller(this);
-
- blinstaller->setMountPoint(userSettings->value("defaults/mountpoint").toString());
-
- blinstaller->setProxy(proxy());
- blinstaller->setDevice(platform);
- blinstaller->setBootloaderMethod(devices->value(platform + "/bootloadermethod").toString());
- blinstaller->setBootloaderName(devices->value(platform + "/bootloadername").toString());
- blinstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString());
blinstaller->setOrigFirmwarePath(offirmware);
- blinstaller->install(logger);
- // connect(blinstaller, SIGNAL(done(bool)), this, SLOT(done(bool)));
+ blinstaller->install(logger);
+
}
@@ -507,6 +530,14 @@ void RbUtilQt::uninstallBootloader(void)
blinstaller.setBootloaderMethod(devices->value(plattform + "/bootloadermethod").toString());
blinstaller.setBootloaderName(devices->value(plattform + "/bootloadername").toString());
blinstaller.setBootloaderBaseUrl(devices->value("bootloader_url").toString());
+ blinstaller.setBootloaderInfoUrl(devices->value("bootloader_info_url").toString());
+ if(!blinstaller.downloadInfo())
+ {
+ logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR);
+ logger->abort();
+ return;
+ }
+
blinstaller.uninstall(logger);
}