From aabc1305bc19e0062acbb5b0277300f53b05ff47 Mon Sep 17 00:00:00 2001 From: Dominik Wenger Date: Sun, 26 Aug 2007 20:32:20 +0000 Subject: [PATCH] rbtutilQt: incorporate the complete and small install into rbutil.cpp, remove the multiinstaller files.. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14465 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/multiinstaller.cpp | 331 ----------------------------- rbutil/rbutilqt/multiinstaller.h | 66 ------ rbutil/rbutilqt/rbutilqt.cpp | 248 ++++++++++++++++----- rbutil/rbutilqt/rbutilqt.h | 20 +- rbutil/rbutilqt/rbutilqt.pro | 8 +- 5 files changed, 218 insertions(+), 455 deletions(-) delete mode 100644 rbutil/rbutilqt/multiinstaller.cpp delete mode 100644 rbutil/rbutilqt/multiinstaller.h diff --git a/rbutil/rbutilqt/multiinstaller.cpp b/rbutil/rbutilqt/multiinstaller.cpp deleted file mode 100644 index 55d91fd7f6..0000000000 --- a/rbutil/rbutilqt/multiinstaller.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Dominik Wenger - * $Id: multinstaller.cpp 14462 2007-08-26 16:44:23Z 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 -#include - -#include "multiinstaller.h" - -#include "installbootloader.h" -#include "progressloggergui.h" -#include "installzip.h" -#include "browseof.h" -#include "installthemes.h" - -MultiInstaller::MultiInstaller(QObject* parent): QObject(parent) -{ - -} - -void MultiInstaller::setUserSettings(QSettings* user) -{ - userSettings = user; -} -void MultiInstaller::setDeviceSettings(QSettings* dev) -{ - devices = dev; -} - -void MultiInstaller::setProxy(QUrl proxy) -{ - m_proxy = proxy; -} - -void MultiInstaller::installSmall() -{ - // create logger - logger = new ProgressLoggerGui(this); - logger->show(); - - m_plattform = userSettings->value("defaults/platform").toString(); - m_mountpoint = userSettings->value("defaults/mountpoint").toString(); - // show dialog with error if mount point is wrong - if(!QFileInfo(m_mountpoint).isDir()) { - logger->addItem(tr("Mount point is wrong!"),LOGERROR); - logger->abort(); - return; - } - - // Bootloader - m_error = false; - installed = false; - if(!installBootloader()) - return; - else - { - // wait for boot loader installation finished - while(!installed) - QApplication::processEvents(); - } - if(m_error) return; - logger->undoAbort(); - - // Rockbox - m_error = false; - installed = false; - if(!installRockbox()) - return; - else - { - // wait for boot loader installation finished - while(!installed) - QApplication::processEvents(); - } -} - -void MultiInstaller::installComplete() -{ - // create logger - logger = new ProgressLoggerGui(this); - logger->show(); - - m_plattform = userSettings->value("defaults/platform").toString(); - m_mountpoint = userSettings->value("defaults/mountpoint").toString(); - // show dialog with error if mount point is wrong - if(!QFileInfo(m_mountpoint).isDir()) { - logger->addItem(tr("Mount point is wrong!"),LOGERROR); - logger->abort(); - return; - } - // Bootloader - m_error = false; - installed = false; - if(!installBootloader()) - return; - else - { - // wait for boot loader installation finished - while(!installed) - QApplication::processEvents(); - } - if(m_error) return; - logger->undoAbort(); - - // Rockbox - m_error = false; - installed = false; - if(!installRockbox()) - return; - else - { - // wait for boot loader installation finished - while(!installed) - QApplication::processEvents(); - } - if(m_error) return; - logger->undoAbort(); - - // Fonts - m_error = false; - installed = false; - if(!installFonts()) - return; - else - { - // wait for boot loader installation finished - while(!installed) - QApplication::processEvents(); - } - if(m_error) return; - logger->undoAbort(); - - // Doom - m_error = false; - installed = false; - if(!installDoom()) - return; - else - { - // wait for boot loader installation finished - while(!installed) - QApplication::processEvents(); - } - if(m_error) return; - - - // theme - // this is a window - // it has its own logger window,so close our. - logger->close(); - installThemes(); - -} - - -void MultiInstaller::installdone(bool error) -{ - installed = true; - m_error = error; -} - - -void MultiInstaller::setVersionStrings(QMap ver) -{ - version = ver; - // version strings map is as following: - // rel_rev release version revision id - // rel_date release version release date - // same for arch_* and bleed_* - - qDebug() << "Install::setVersionStrings" << version; -} - -bool MultiInstaller::installBootloader() -{ - BootloaderInstaller* blinstaller = new BootloaderInstaller(this); - blinstaller->setMountPoint(m_mountpoint); - blinstaller->setProxy(m_proxy); - blinstaller->setDevice(m_plattform); - blinstaller->setBootloaderMethod(devices->value(m_plattform + "/bootloadermethod").toString()); - blinstaller->setBootloaderName(devices->value(m_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 false; - } - - if(blinstaller->uptodate()) - { - int ret = QMessageBox::question(NULL, tr("Bootloader Installation"), - tr("It seem your Bootloader is already uptodate.\n" - "Do really want to install it?"), - QMessageBox::Ok | QMessageBox::Ignore | - QMessageBox::Cancel, - QMessageBox::Ignore); - if(ret == QMessageBox::Cancel) - { - logger->addItem(tr("Bootloader installation Canceled!"),LOGERROR); - logger->abort(); - return false; - } - else if(ret == QMessageBox::Ignore) - { - // skip to next install step - logger->addItem(tr("Skipped Bootloader installation!"),LOGWARNING); - installed = true; - return true; - } - } - - // if fwpatcher , ask for extra file - QString offirmware; - if(devices->value(m_plattform + "/bootloadermethod").toString() == "fwpatcher") - { - BrowseOF ofbrowser(NULL); - ofbrowser.setFile(userSettings->value("defaults/ofpath").toString()); - if(ofbrowser.exec() == QDialog::Accepted) - { - offirmware = ofbrowser.getFile(); - qDebug() << offirmware; - if(!QFileInfo(offirmware).exists()) - { - logger->addItem(tr("Original Firmware Path is wrong!"),LOGERROR); - logger->abort(); - return false; - } - else - { - userSettings->setValue("defaults/ofpath",offirmware); - userSettings->sync(); - } - } - else - { - logger->addItem(tr("Original Firmware selection Canceled!"),LOGERROR); - logger->abort(); - return false; - } - } - blinstaller->setOrigFirmwarePath(offirmware); - - blinstaller->install(logger); - connect(blinstaller,SIGNAL(done(bool)),this,SLOT(installdone(bool))); - return true; -} - -bool MultiInstaller::installRockbox() -{ - QString file = QString("%1%2/rockbox.zip") - .arg(devices->value("bleeding_url").toString(), - userSettings->value("defaults/platform").toString()); - QString myversion = "r" + version.value("bleed_rev"); - - ZipInstaller* installer = new ZipInstaller(this); - installer->setUrl(file); - installer->setProxy(m_proxy); - installer->setLogSection("rockboxbase"); - installer->setLogVersion(myversion); - installer->setMountPoint(m_mountpoint); - installer->install(logger); - - connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); - - return true; -} - -bool MultiInstaller::installFonts() -{ - // create zip installer - ZipInstaller* installer = new ZipInstaller(this); - - installer->setUrl(devices->value("font_url").toString()); - installer->setProxy(m_proxy); - installer->setLogSection("Fonts"); - installer->setLogVersion(version.value("arch_date")); - installer->setMountPoint(m_mountpoint); - installer->install(logger); - - connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); - - return true; -} - -bool MultiInstaller::installDoom() -{ - // create zip installer - ZipInstaller* installer = new ZipInstaller(this); - - installer->setUrl(devices->value("doom_url").toString()); - installer->setProxy(m_proxy); - installer->setLogSection("Game Addons"); - installer->setLogVersion(version.value("arch_date")); - installer->setMountPoint(m_mountpoint); - installer->install(logger); - - connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); - - return true; -} - -bool MultiInstaller::installThemes() -{ - ThemesInstallWindow* tw = new ThemesInstallWindow(NULL); - tw->setDeviceSettings(devices); - tw->setUserSettings(userSettings); - tw->setProxy(m_proxy); - tw->setModal(true); - tw->show(); - - return true; -} - - diff --git a/rbutil/rbutilqt/multiinstaller.h b/rbutil/rbutilqt/multiinstaller.h deleted file mode 100644 index 34c593843a..0000000000 --- a/rbutil/rbutilqt/multiinstaller.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Dominik Wenger - * $Id: multiinstaller.h 14462 2007-08-26 16:44:23Z 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 MULTIINSTALLER_H -#define MULTIINSTALLER_H - -#include - -#include "progressloggerinterface.h" - - -class MultiInstaller : public QObject -{ - Q_OBJECT - -public: - MultiInstaller(QObject* parent); - - void setUserSettings(QSettings*); - void setDeviceSettings(QSettings*); - void setProxy(QUrl proxy); - void setVersionStrings(QMap); - - void installComplete(); - void installSmall(); - - -private slots: - void installdone(bool error); - -private: - bool installBootloader(); - bool installRockbox(); - bool installDoom(); - bool installFonts(); - bool installThemes(); - - ProgressloggerInterface* logger; - QSettings *devices; - QSettings *userSettings; - - QString m_mountpoint,m_plattform; - QUrl m_proxy; - QMap version; - - - volatile bool installed; - volatile bool m_error; -}; -#endif diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index 6ae5fbf5e8..0c30bd06fd 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -84,10 +84,10 @@ RbUtilQt::RbUtilQt(QWidget *parent) : QMainWindow(parent) connect(ui.action_About, SIGNAL(triggered()), this, SLOT(about())); connect(ui.action_Configure, SIGNAL(triggered()), this, SLOT(configDialog())); connect(ui.buttonChangeDevice, SIGNAL(clicked()), this, SLOT(configDialog())); - connect(ui.buttonRockbox, SIGNAL(clicked()), this, SLOT(install())); - connect(ui.buttonBootloader, SIGNAL(clicked()), this, SLOT(installBl())); - connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFonts())); - connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoom())); + connect(ui.buttonRockbox, SIGNAL(clicked()), this, SLOT(installBtn())); + connect(ui.buttonBootloader, SIGNAL(clicked()), this, SLOT(installBootloaderBtn())); + connect(ui.buttonFonts, SIGNAL(clicked()), this, SLOT(installFontsBtn())); + connect(ui.buttonGames, SIGNAL(clicked()), this, SLOT(installDoomBtn())); connect(ui.buttonTalk, SIGNAL(clicked()), this, SLOT(createTalkFiles())); connect(ui.buttonVoice, SIGNAL(clicked()), this, SLOT(installVoice())); connect(ui.buttonThemes, SIGNAL(clicked()), this, SLOT(installThemes())); @@ -305,27 +305,78 @@ void RbUtilQt::completeInstall() tr("Do you really want to make a complete Installation?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; - MultiInstaller installer(this); - installer.setUserSettings(userSettings); - installer.setDeviceSettings(devices); - installer.setProxy(proxy()); - - buildInfo.open(); - QSettings info(buildInfo.fileName(), QSettings::IniFormat, this); - buildInfo.close(); - - devices->beginGroup(platform); - QString released = devices->value("released").toString(); - devices->endGroup(); - if(released == "yes") { - // only set the keys if needed -- querying will yield an empty string - // if not set. - versmap.insert("rel_rev", devices->value("last_release").toString()); - versmap.insert("rel_date", ""); // FIXME: provide the release timestamp + // create logger + logger = new ProgressLoggerGui(this); + logger->show(); + + QString mountpoint = userSettings->value("defaults/mountpoint").toString(); + // show dialog with error if mount point is wrong + if(!QFileInfo(mountpoint).isDir()) { + logger->addItem(tr("Mount point is wrong!"),LOGERROR); + logger->abort(); + return; + } + // Bootloader + m_error = false; + m_installed = false; + if(!installBootloaderAuto()) + return; + else + { + // wait for boot loader installation finished + while(!m_installed) + QApplication::processEvents(); } - installer.setVersionStrings(versmap); - - installer.installComplete(); + if(m_error) return; + logger->undoAbort(); + + // Rockbox + m_error = false; + m_installed = false; + if(!installAuto()) + return; + else + { + // wait for boot loader installation finished + while(!m_installed) + QApplication::processEvents(); + } + if(m_error) return; + logger->undoAbort(); + + // Fonts + m_error = false; + m_installed = false; + if(!installFontsAuto()) + return; + else + { + // wait for boot loader installation finished + while(!m_installed) + QApplication::processEvents(); + } + if(m_error) return; + logger->undoAbort(); + + // Doom + m_error = false; + m_installed = false; + if(!installDoomAuto()) + return; + else + { + // wait for boot loader installation finished + while(!m_installed) + QApplication::processEvents(); + } + if(m_error) return; + + + // theme + // this is a window + // it has its own logger window,so close our. + logger->close(); + installThemes(); } @@ -335,10 +386,61 @@ void RbUtilQt::smallInstall() tr("Do you really want to make a small Installation?"), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; - MultiInstaller installer(this); - installer.setUserSettings(userSettings); - installer.setDeviceSettings(devices); - installer.setProxy(proxy()); + // create logger + logger = new ProgressLoggerGui(this); + logger->show(); + + QString mountpoint = userSettings->value("defaults/mountpoint").toString(); + // show dialog with error if mount point is wrong + if(!QFileInfo(mountpoint).isDir()) { + logger->addItem(tr("Mount point is wrong!"),LOGERROR); + logger->abort(); + return; + } + // Bootloader + m_error = false; + m_installed = false; + if(!installBootloaderAuto()) + return; + else + { + // wait for boot loader installation finished + while(!m_installed) + QApplication::processEvents(); + } + if(m_error) return; + logger->undoAbort(); + + // Rockbox + m_error = false; + m_installed = false; + if(!installAuto()) + return; + else + { + // wait for boot loader installation finished + while(!m_installed) + QApplication::processEvents(); + } +} + +void RbUtilQt::installdone(bool error) +{ + qDebug() << "install done"; + m_installed = true; + m_error = error; +} + +void RbUtilQt::installBtn() +{ + install(); +} + +bool RbUtilQt::installAuto() +{ + QString file = QString("%1%2/rockbox.zip") + .arg(devices->value("bleeding_url").toString(), + userSettings->value("defaults/platform").toString()); buildInfo.open(); QSettings info(buildInfo.fileName(), QSettings::IniFormat, this); @@ -353,10 +455,20 @@ void RbUtilQt::smallInstall() versmap.insert("rel_rev", devices->value("last_release").toString()); versmap.insert("rel_date", ""); // FIXME: provide the release timestamp } - installer.setVersionStrings(versmap); - installer.installSmall(); + QString myversion = "r" + versmap.value("bleed_rev"); + ZipInstaller* installer = new ZipInstaller(this); + installer->setUrl(file); + installer->setProxy(proxy()); + installer->setLogSection("rockboxbase"); + installer->setLogVersion(myversion); + installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); + installer->install(logger); + + connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); + + return true; } void RbUtilQt::install() @@ -384,17 +496,28 @@ void RbUtilQt::install() installWindow->show(); } +bool RbUtilQt::installBootloaderAuto() +{ + installBootloader(); + connect(blinstaller,SIGNAL(done(bool)),this,SLOT(installdone(bool))); + return !m_error; +} -void RbUtilQt::installBl() +void RbUtilQt::installBootloaderBtn() { if(QMessageBox::question(this, tr("Confirm Installation"), - tr("Do you really want to install the Bootloader?"), - QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; - + tr("Do you really want to install the Bootloader?"), + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; + // create logger logger = new ProgressLoggerGui(this); logger->show(); + installBootloader(); +} + +void RbUtilQt::installBootloader() +{ QString platform = userSettings->value("defaults/platform").toString(); // create installer @@ -412,6 +535,7 @@ void RbUtilQt::installBl() { logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR); logger->abort(); + m_error = true; return; } @@ -420,15 +544,20 @@ void RbUtilQt::installBl() 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::Ok | QMessageBox::Ignore |QMessageBox::Cancel, QMessageBox::Cancel); if(ret == QMessageBox::Cancel) { logger->addItem(tr("Bootloader installation Canceled!"),LOGERROR); logger->abort(); + m_error = true; + return; + } + else if(ret == QMessageBox::Ignore) + { + m_installed = true; return; } - } // if fwpatcher , ask for extra file @@ -445,6 +574,7 @@ void RbUtilQt::installBl() { logger->addItem(tr("Original Firmware Path is wrong!"),LOGERROR); logger->abort(); + m_error = true; return; } else @@ -457,26 +587,34 @@ void RbUtilQt::installBl() { logger->addItem(tr("Original Firmware selection Canceled!"),LOGERROR); logger->abort(); + m_error = true; return; } } blinstaller->setOrigFirmwarePath(offirmware); - blinstaller->install(logger); - } - -void RbUtilQt::installFonts() +void RbUtilQt::installFontsBtn() { if(QMessageBox::question(this, tr("Confirm Installation"), - tr("Do you really want to install the fonts package?"), - QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; + tr("Do you really want to install the fonts package?"), + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; // create logger logger = new ProgressLoggerGui(this); logger->show(); - +} + +bool RbUtilQt::installFontsAuto() +{ + installFonts(); + connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); + return !m_error; +} + +void RbUtilQt::installFonts() +{ // create zip installer installer = new ZipInstaller(this); @@ -485,9 +623,7 @@ void RbUtilQt::installFonts() installer->setLogSection("Fonts"); installer->setLogVersion(versmap.value("arch_date")); installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); - installer->install(logger); - - // connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); + installer->install(logger); } @@ -520,16 +656,26 @@ void RbUtilQt::installVoice() //connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); } - -void RbUtilQt::installDoom() +void RbUtilQt::installDoomBtn() { if(QMessageBox::question(this, tr("Confirm Installation"), - tr("Do you really want to install the game addon files?"), - QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; + tr("Do you really want to install the game addon files?"), + QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) return; // create logger logger = new ProgressLoggerGui(this); logger->show(); + installDoom(); +} +bool RbUtilQt::installDoomAuto() +{ + installDoom(); + connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); + return !m_error; +} + +void RbUtilQt::installDoom() +{ // create zip installer installer = new ZipInstaller(this); @@ -539,8 +685,6 @@ void RbUtilQt::installDoom() installer->setLogVersion(versmap.value("arch_date")); installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); installer->install(logger); - - // connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); } diff --git a/rbutil/rbutilqt/rbutilqt.h b/rbutil/rbutilqt/rbutilqt.h index 8781e08a15..51a9742d3c 100644 --- a/rbutil/rbutilqt/rbutilqt.h +++ b/rbutil/rbutilqt/rbutilqt.h @@ -56,18 +56,36 @@ class RbUtilQt : public QMainWindow BootloaderInstaller* blinstaller; QUrl proxy(void); QMap versmap; + + volatile bool m_installed; + volatile bool m_error; private slots: void about(void); void configDialog(void); void updateDevice(void); void updateSettings(void); + void completeInstall(void); void smallInstall(void); + void installdone(bool error); + + void installBtn(void); + bool installAuto(void); void install(void); - void installBl(void); + + void installBootloaderBtn(void); + bool installBootloaderAuto(void); + void installBootloader(void); + + void installFontsBtn(void); + bool installFontsAuto(void); void installFonts(void); + + void installDoomBtn(void); + bool installDoomAuto(void); void installDoom(void); + void createTalkFiles(void); void downloadDone(bool); void downloadDone(int, bool); diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index 55bb00e00e..0c8840fe1f 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro @@ -34,8 +34,7 @@ SOURCES += rbutilqt.cpp \ uninstall.cpp \ uninstallwindow.cpp \ browseof.cpp \ - preview.cpp \ - multiinstaller.cpp + preview.cpp HEADERS += rbutilqt.h \ install.h \ @@ -70,9 +69,8 @@ HEADERS += rbutilqt.h \ uninstall.h \ uninstallwindow.h \ browseof.h \ - preview.h \ - multiinstaller.h - + preview.h + # Needed by QT on Win INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher