From d5f7dab2308859d98837f76f3b2374645130e082 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 2 May 2009 18:50:31 +0000 Subject: Cleanup and un-gui ZipInstaller class: - Use signals for updating the progress logger from ZipInstaller class. - Move ZipInstaller class to base folder as it doesn't rely on QtGui anymore. - cleanup debugging output a bit. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20845 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/base/zipinstaller.cpp | 205 ++++++++++++++++++++++++++++++ rbutil/rbutilqt/base/zipinstaller.h | 84 +++++++++++++ rbutil/rbutilqt/install.cpp | 6 +- rbutil/rbutilqt/rbutilqt.cpp | 31 ++++- rbutil/rbutilqt/rbutilqt.pro | 4 +- rbutil/rbutilqt/themesinstallwindow.cpp | 6 +- rbutil/rbutilqt/zipinstaller.cpp | 214 -------------------------------- rbutil/rbutilqt/zipinstaller.h | 82 ------------ 8 files changed, 326 insertions(+), 306 deletions(-) create mode 100644 rbutil/rbutilqt/base/zipinstaller.cpp create mode 100644 rbutil/rbutilqt/base/zipinstaller.h delete mode 100644 rbutil/rbutilqt/zipinstaller.cpp delete mode 100644 rbutil/rbutilqt/zipinstaller.h diff --git a/rbutil/rbutilqt/base/zipinstaller.cpp b/rbutil/rbutilqt/base/zipinstaller.cpp new file mode 100644 index 0000000000..268ae49935 --- /dev/null +++ b/rbutil/rbutilqt/base/zipinstaller.cpp @@ -0,0 +1,205 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Wenger + * $Id$ + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include "zipinstaller.h" +#include "rbunzip.h" +#include "utils.h" + +ZipInstaller::ZipInstaller(QObject* parent): QObject(parent) +{ + m_unzip = true; + m_usecache = false; +} + + +void ZipInstaller::install() +{ + qDebug() << "[ZipInstall] install()"; + + runner = 0; + connect(this, SIGNAL(cont()), this, SLOT(installContinue())); + m_url = m_urllist.at(runner); + m_logsection = m_loglist.at(runner); + m_logver = m_verlist.at(runner); + installStart(); +} + + +void ZipInstaller::abort() +{ + qDebug() << "[ZipInstall] Aborted"; + emit internalAborted(); +} + + +void ZipInstaller::installContinue() +{ + qDebug() << "[ZipInstall] installContinue"; + + runner++; // this gets called when a install finished, so increase first. + qDebug() << "[ZipInstall] runner done:" << runner << "/" << m_urllist.size(); + if(runner < m_urllist.size()) { + emit logItem(tr("done."), LOGOK); + m_url = m_urllist.at(runner); + m_logsection = m_loglist.at(runner); + if(runner < m_verlist.size()) m_logver = m_verlist.at(runner); + else m_logver = "0"; + installStart(); + } + else { + emit logItem(tr("Installation finished successfully."), LOGOK); + + emit done(false); + return; + } + +} + + +void ZipInstaller::installStart() +{ + qDebug() << "[ZipInstall] installStart"; + + emit logItem(tr("Downloading file %1.%2").arg(QFileInfo(m_url).baseName(), + QFileInfo(m_url).completeSuffix()),LOGINFO); + + // temporary file needs to be opened to get the filename + // make sure to get a fresh one on each run. + // making this a parent of the temporary file ensures the file gets deleted + // after the class object gets destroyed. + downloadFile = new QTemporaryFile(this); + downloadFile->open(); + m_file = downloadFile->fileName(); + downloadFile->close(); + // get the real file. + getter = new HttpGet(this); + if(m_usecache) { + getter->setCache(true); + } + getter->setFile(downloadFile); + + connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); + connect(getter, SIGNAL(dataReadProgress(int, int)), this, SIGNAL(logProgress(int, int))); + connect(this, SIGNAL(internalAborted()), getter, SLOT(abort())); + + getter->getFile(QUrl(m_url)); +} + + +void ZipInstaller::downloadDone(bool error) +{ + qDebug() << "[ZipInstall] downloadDone, error:" << error; + QStringList zipContents; // needed later + // update progress bar + + emit logProgress(1, 1); + if(getter->httpResponse() != 200 && !getter->isCached()) { + emit logItem(tr("Download error: received HTTP error %1.") + .arg(getter->httpResponse()),LOGERROR); + emit done(true); + return; + } + if(getter->isCached()) + emit logItem(tr("Cached file used."), LOGINFO); + if(error) { + emit logItem(tr("Download error: %1").arg(getter->errorString()), LOGERROR); + emit done(true); + return; + } + else emit logItem(tr("Download finished."),LOGOK); + QCoreApplication::processEvents(); + if(m_unzip) { + // unzip downloaded file + qDebug() << "[ZipInstall] about to unzip " << m_file << "to" << m_mountpoint; + + emit logItem(tr("Extracting file."), LOGINFO); + QCoreApplication::processEvents(); + + UnZip::ErrorCode ec; + RbUnZip uz; + connect(&uz, SIGNAL(unzipProgress(int, int)), this, SIGNAL(logProgress(int, int))); + connect(this, SIGNAL(internalAborted()), &uz, SLOT(abortUnzip())); + ec = uz.openArchive(m_file); + if(ec != UnZip::Ok) { + emit logItem(tr("Opening archive failed: %1.") + .arg(uz.formatError(ec)),LOGERROR); + emit logProgress(1, 1); + emit done(true); + return; + } + + // check for free space. Make sure after installation will still be + // some room for operating (also includes calculation mistakes due to + // cluster sizes on the player). + if(filesystemFree(m_mountpoint) < (uz.totalSize() + 1000000)) { + emit logItem(tr("Not enough disk space! Aborting."), LOGERROR); + emit logProgress(1, 1); + emit done(true); + return; + } + ec = uz.extractArchive(m_mountpoint); + // TODO: better handling of aborted unzip operation. + if(ec != UnZip::Ok) { + emit logItem(tr("Extracting failed: %1.") + .arg(uz.formatError(ec)),LOGERROR); + emit logProgress(1, 1); + emit done(true); + return; + } + // prepare file list for log + zipContents = uz.fileList(); + } + else { + // only copy the downloaded file to the output location / name + emit logItem(tr("Installing file."), LOGINFO); + qDebug() << "[ZipInstall] saving downloaded file (no extraction)"; + + downloadFile->open(); // copy fails if file is not opened (filename issue?) + // make sure the required path is existing + QString path = QFileInfo(m_mountpoint + m_target).absolutePath(); + QDir p; + p.mkpath(path); + // QFile::copy() doesn't overwrite files, so remove old one first + QFile(m_mountpoint + m_target).remove(); + if(!downloadFile->copy(m_mountpoint + m_target)) { + emit logItem(tr("Installing file failed."), LOGERROR); + emit done(true); + return; + } + + // add file to log + zipContents.append( m_target); + } + + emit logItem(tr("Creating installation log"),LOGINFO); + QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); + + installlog.beginGroup(m_logsection); + for(int i = 0; i < zipContents.size(); i++) + { + installlog.setValue(zipContents.at(i), m_logver); + } + installlog.endGroup(); + installlog.sync(); + + emit cont(); +} + + diff --git a/rbutil/rbutilqt/base/zipinstaller.h b/rbutil/rbutilqt/base/zipinstaller.h new file mode 100644 index 0000000000..c0e13efa20 --- /dev/null +++ b/rbutil/rbutilqt/base/zipinstaller.h @@ -0,0 +1,84 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * + * Copyright (C) 2007 by Dominik Wenger + * $Id$ + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + + +#ifndef INSTALLZIP_H +#define INSTALLZIP_H + + + +#include + +#include "progressloggerinterface.h" +#include "httpget.h" + +class ZipInstaller : public QObject +{ + Q_OBJECT +public: + ZipInstaller(QObject* parent) ; + ~ZipInstaller(){} + void install(void); + void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;} + void setUrl(QString url){m_urllist = QStringList(url);} + void setUrl(QStringList url) { m_urllist = url; } + void setLogSection(QString name) {m_loglist = QStringList(name);} + void setLogSection(QStringList name) { m_loglist = name; } + void setLogVersion(QString v) { m_verlist = QStringList(v); qDebug() << m_verlist;} + void setLogVersion(QStringList v) { m_verlist = v; qDebug() << m_verlist;} + void setUnzip(bool i) { m_unzip = i; } + void setTarget(QString t) { m_target = t; } + void setCache(QDir c) { m_cache = c; m_usecache = true; }; + void setCache(bool c) { m_usecache = c; }; + void setCache(QString c) { m_cache = QDir(c); m_usecache = true; } + +public slots: + void abort(void); + +private slots: + void downloadDone(bool); + void installStart(void); + void installContinue(void); + +signals: + void done(bool error); + void cont(); + void logItem(QString, int); //! set logger item + void logProgress(int, int); //! set progress bar. + void internalAborted(void); + +private: + QString m_url, m_file, m_mountpoint, m_logsection, m_logver; + QStringList m_urllist, m_loglist, m_verlist; + bool m_unzip; + QString m_target; + int runner; + QDir m_cache; + bool m_usecache; + + HttpGet *getter; + QTemporaryFile *downloadFile; +}; + + + +#endif + diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp index 946c7013fa..69d5823258 100644 --- a/rbutil/rbutilqt/install.cpp +++ b/rbutil/rbutilqt/install.cpp @@ -189,7 +189,11 @@ void Install::accept() connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); - installer->install(logger); + connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int))); + connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int))); + connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished())); + connect(logger, SIGNAL(aborted()), installer, SLOT(abort())); + installer->install(); } diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index d36f9637c0..3412b47ff9 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -584,8 +584,11 @@ bool RbUtilQt::installAuto() installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString()); connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); - - installer->install(logger); + connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int))); + connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int))); + connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished())); + connect(logger, SIGNAL(aborted()), installer, SLOT(abort())); + installer->install(); return true; } @@ -827,7 +830,11 @@ void RbUtilQt::installFonts() installer->setCache(true); connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); - installer->install(logger); + connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int))); + connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int))); + connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished())); + connect(logger, SIGNAL(aborted()), installer, SLOT(abort())); + installer->install(); } @@ -865,7 +872,11 @@ void RbUtilQt::installVoice() installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString()); if(!settings->value(RbSettings::CacheDisabled).toBool()) installer->setCache(true); - installer->install(logger); + connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int))); + connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int))); + connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished())); + connect(logger, SIGNAL(aborted()), installer, SLOT(abort())); + installer->install(); } @@ -912,7 +923,11 @@ void RbUtilQt::installDoom() if(!settings->value(RbSettings::CacheDisabled).toBool()) installer->setCache(true); connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); - installer->install(logger); + connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int))); + connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int))); + connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished())); + connect(logger, SIGNAL(aborted()), installer, SLOT(abort())); + installer->install(); } @@ -1058,7 +1073,11 @@ void RbUtilQt::downloadManual(void) installer->setUrl(manualurl); installer->setUnzip(false); installer->setTarget(target); - installer->install(logger); + connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int))); + connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int))); + connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished())); + connect(logger, SIGNAL(aborted()), installer, SLOT(abort())); + installer->install(); } diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index 0723e2b4f9..3edcbdc11b 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro @@ -50,7 +50,7 @@ SOURCES += rbutilqt.cpp \ configure.cpp \ zip/zip.cpp \ zip/unzip.cpp \ - zipinstaller.cpp \ + base/zipinstaller.cpp \ progressloggergui.cpp \ installtalkwindow.cpp \ talkfile.cpp \ @@ -95,7 +95,7 @@ HEADERS += rbutilqt.h \ zip/unzip_p.h \ zip/zip_p.h \ version.h \ - zipinstaller.h \ + base/zipinstaller.h \ installtalkwindow.h \ talkfile.h \ base/autodetection.h \ diff --git a/rbutil/rbutilqt/themesinstallwindow.cpp b/rbutil/rbutilqt/themesinstallwindow.cpp index 56a917cfc6..a112e6d748 100644 --- a/rbutil/rbutilqt/themesinstallwindow.cpp +++ b/rbutil/rbutilqt/themesinstallwindow.cpp @@ -339,7 +339,11 @@ void ThemesInstallWindow::accept() installer->setCache(true); connect(logger, SIGNAL(closed()), this, SLOT(close())); - installer->install(logger); + connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int))); + connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int))); + connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished())); + connect(logger, SIGNAL(aborted()), installer, SLOT(abort())); + installer->install(); } diff --git a/rbutil/rbutilqt/zipinstaller.cpp b/rbutil/rbutilqt/zipinstaller.cpp deleted file mode 100644 index deff52768a..0000000000 --- a/rbutil/rbutilqt/zipinstaller.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Dominik Wenger - * $Id$ - * - * All files in this archive are subject to the GNU General Public License. - * See the file COPYING in the source tree root for full license agreement. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - -#include "zipinstaller.h" -#include "rbunzip.h" -#include "utils.h" - -ZipInstaller::ZipInstaller(QObject* parent): QObject(parent) -{ - m_unzip = true; - m_usecache = false; -} - - -void ZipInstaller::install(ProgressloggerInterface *dp) -{ - qDebug() << "install(ProgressloggerInterface*)"; - m_dp = dp; - runner = 0; - connect(this, SIGNAL(cont()), this, SLOT(installContinue())); - m_url = m_urllist.at(runner); - m_logsection = m_loglist.at(runner); - m_logver = m_verlist.at(runner); - installStart(); - -} - - -void ZipInstaller::installContinue() -{ - qDebug() << "installContinue()"; - - runner++; // this gets called when a install finished, so increase first. - qDebug() << "runner is now at" << runner << "size is" << m_urllist.size(); - if(runner < m_urllist.size()) { - qDebug() << "==> runner at" << runner; - m_dp->addItem(tr("done."), LOGOK); - m_url = m_urllist.at(runner); - m_logsection = m_loglist.at(runner); - if(runner < m_verlist.size()) m_logver = m_verlist.at(runner); - else m_logver = "0"; - installStart(); - } - else { - m_dp->addItem(tr("Installation finished successfully."),LOGOK); - m_dp->setFinished(); - - emit done(false); - return; - } - -} - - -void ZipInstaller::installStart() -{ - qDebug() << "installStart()"; - - m_dp->addItem(tr("Downloading file %1.%2") - .arg(QFileInfo(m_url).baseName(), QFileInfo(m_url).completeSuffix()),LOGINFO); - - // temporary file needs to be opened to get the filename - // make sure to get a fresh one on each run. - // making this a parent of the temporary file ensures the file gets deleted - // after the class object gets destroyed. - downloadFile = new QTemporaryFile(this); - downloadFile->open(); - m_file = downloadFile->fileName(); - downloadFile->close(); - // get the real file. - getter = new HttpGet(this); - if(m_usecache) { - getter->setCache(true); - } - getter->setFile(downloadFile); - - connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); - connect(getter, SIGNAL(dataReadProgress(int, int)), m_dp, SLOT(setProgress(int, int))); - connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort())); - - getter->getFile(QUrl(m_url)); -} - - -void ZipInstaller::downloadDone(bool error) -{ - qDebug() << "Install::downloadDone, error:" << error; - QStringList zipContents; // needed later - // update progress bar - - int max = m_dp->getProgressMax(); - if(max == 0) { - max = 100; - m_dp->setProgressMax(max); - } - m_dp->setProgressValue(max); - if(getter->httpResponse() != 200 && !getter->isCached()) { - m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR); - m_dp->setFinished(); - emit done(true); - return; - } - if(getter->isCached()) m_dp->addItem(tr("Cached file used."), LOGINFO); - if(error) { - m_dp->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR); - m_dp->setFinished(); - emit done(true); - return; - } - else m_dp->addItem(tr("Download finished."),LOGOK); - QCoreApplication::processEvents(); - if(m_unzip) { - // unzip downloaded file - qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint; - - m_dp->addItem(tr("Extracting file."),LOGINFO); - QCoreApplication::processEvents(); - - qDebug() << "file to unzip: " << m_file; - UnZip::ErrorCode ec; - RbUnZip uz; - connect(&uz, SIGNAL(unzipProgress(int, int)), m_dp, SLOT(setProgress(int, int))); - connect(m_dp, SIGNAL(aborted()), &uz, SLOT(abortUnzip())); - ec = uz.openArchive(m_file); - if(ec != UnZip::Ok) { - m_dp->addItem(tr("Opening archive failed: %1.") - .arg(uz.formatError(ec)),LOGERROR); - m_dp->setProgressMax(1); - m_dp->setProgressValue(1); - m_dp->setFinished(); - emit done(true); - return; - } - - // check for free space. Make sure after installation will still be - // some room for operating (also includes calculation mistakes due to - // cluster sizes on the player). - if(filesystemFree(m_mountpoint) < (uz.totalSize() + 1000000)) { - m_dp->addItem(tr("Not enough disk space! Aborting."), LOGERROR); - m_dp->setFinished(); - m_dp->setProgressMax(1); - m_dp->setProgressValue(1); - emit done(true); - return; - } - ec = uz.extractArchive(m_mountpoint); - // TODO: better handling of aborted unzip operation. - if(ec != UnZip::Ok) { - m_dp->addItem(tr("Extracting failed: %1.") - .arg(uz.formatError(ec)),LOGERROR); - m_dp->setFinished(); - m_dp->setProgressMax(1); - m_dp->setProgressValue(1); - - emit done(true); - return; - } - // prepare file list for log - zipContents = uz.fileList(); - } - else { - // only copy the downloaded file to the output location / name - m_dp->addItem(tr("Installing file."), LOGINFO); - qDebug() << "saving downloaded file (no extraction)"; - - downloadFile->open(); // copy fails if file is not opened (filename issue?) - // make sure the required path is existing - QString path = QFileInfo(m_mountpoint + m_target).absolutePath(); - QDir p; - p.mkpath(path); - // QFile::copy() doesn't overwrite files, so remove old one first - QFile(m_mountpoint + m_target).remove(); - if(!downloadFile->copy(m_mountpoint + m_target)) { - m_dp->addItem(tr("Installing file failed."), LOGERROR); - m_dp->setFinished(); - emit done(true); - return; - } - - // add file to log - zipContents.append( m_target); - } - - m_dp->addItem(tr("Creating installation log"),LOGINFO); - QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); - - installlog.beginGroup(m_logsection); - for(int i = 0; i < zipContents.size(); i++) - { - installlog.setValue(zipContents.at(i), m_logver); - } - installlog.endGroup(); - installlog.sync(); - - emit cont(); -} - - diff --git a/rbutil/rbutilqt/zipinstaller.h b/rbutil/rbutilqt/zipinstaller.h deleted file mode 100644 index b9cf9b4616..0000000000 --- a/rbutil/rbutilqt/zipinstaller.h +++ /dev/null @@ -1,82 +0,0 @@ -/*************************************************************************** - * __________ __ ___. - * Open \______ \ ____ ____ | | _\_ |__ _______ ___ - * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / - * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < - * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ - * \/ \/ \/ \/ \/ - * - * Copyright (C) 2007 by Dominik Wenger - * $Id$ - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY - * KIND, either express or implied. - * - ****************************************************************************/ - - -#ifndef INSTALLZIP_H -#define INSTALLZIP_H - - - -#include -#include - -#include "progressloggerinterface.h" -#include "httpget.h" - -class ZipInstaller : public QObject -{ - Q_OBJECT -public: - ZipInstaller(QObject* parent) ; - ~ZipInstaller(){} - void install(ProgressloggerInterface* dp); - void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;} - void setUrl(QString url){m_urllist = QStringList(url);} - void setUrl(QStringList url) { m_urllist = url; } - void setLogSection(QString name) {m_loglist = QStringList(name);} - void setLogSection(QStringList name) { m_loglist = name; } - void setLogVersion(QString v) { m_verlist = QStringList(v); qDebug() << m_verlist;} - void setLogVersion(QStringList v) { m_verlist = v; qDebug() << m_verlist;} - void setUnzip(bool i) { m_unzip = i; } - void setTarget(QString t) { m_target = t; } - void setCache(QDir c) { m_cache = c; m_usecache = true; }; - void setCache(bool c) { m_usecache = c; }; - void setCache(QString c) { m_cache = QDir(c); m_usecache = true; } - -signals: - void done(bool error); - void cont(); - -private slots: - void downloadDone(bool); - void installStart(void); - void installContinue(void); - -private: - void installSingle(ProgressloggerInterface *dp); - QString m_url, m_file, m_mountpoint, m_logsection, m_logver; - QStringList m_urllist, m_loglist, m_verlist; - bool m_unzip; - QString m_target; - int runner; - QDir m_cache; - bool m_usecache; - - HttpGet *getter; - QTemporaryFile *downloadFile; - - ProgressloggerInterface* m_dp; -}; - - - -#endif - -- cgit v1.2.3