summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-14 23:11:46 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2007-08-14 23:11:46 +0000
commit498bae30b7fb70def90b386b35fb5a0cc36005fe (patch)
tree8480eb5bb0c70163d5b5e88371f7a91711de710d /rbutil/rbutilqt
parent07e4ddb79da7d0c3e0b4819ef8e7fc89adbae0aa (diff)
extend ZipInstaller to support installing of multiple files at once (for use by the theme installation).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14348 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt')
-rw-r--r--rbutil/rbutilqt/install.cpp1
-rw-r--r--rbutil/rbutilqt/installzip.cpp66
-rw-r--r--rbutil/rbutilqt/installzip.h17
3 files changed, 62 insertions, 22 deletions
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp
index 6a240f4807..91a9534061 100644
--- a/rbutil/rbutilqt/install.cpp
+++ b/rbutil/rbutilqt/install.cpp
@@ -110,7 +110,6 @@ void Install::accept()
userSettings->sync();
installer = new ZipInstaller(this);
- installer->setFilename(fileName);
installer->setUrl(file);
installer->setProxy(proxy);
installer->setLogSection("rockboxbase");
diff --git a/rbutil/rbutilqt/installzip.cpp b/rbutil/rbutilqt/installzip.cpp
index ac295da963..14e1feb55f 100644
--- a/rbutil/rbutilqt/installzip.cpp
+++ b/rbutil/rbutilqt/installzip.cpp
@@ -28,21 +28,61 @@ ZipInstaller::ZipInstaller(QObject* parent): QObject(parent)
}
-void ZipInstaller::install(ProgressloggerInterface* dp)
+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);
+ installStart();
+
+}
+
+
+void ZipInstaller::installContinue()
+{
+ qDebug() << "installContinue()";
+
+ runner++; // this gets called when a install finished, so increase first.
+ 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);
+ installStart();
+ }
+ else {
+ m_dp->addItem(tr("Installation finished successfully."),LOGOK);
+ m_dp->abort();
+
+ 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
- downloadFile.open();
- m_file = downloadFile.fileName();
- downloadFile.close();
+ // 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);
getter->setProxy(m_proxy);
- getter->setFile(&downloadFile);
+ getter->setFile(downloadFile);
getter->getFile(QUrl(m_url));
connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
@@ -51,6 +91,7 @@ void ZipInstaller::install(ProgressloggerInterface* dp)
connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort()));
}
+
void ZipInstaller::downloadRequestFinished(int id, bool error)
{
qDebug() << "Install::downloadRequestFinished" << id << error;
@@ -59,6 +100,7 @@ void ZipInstaller::downloadRequestFinished(int id, bool error)
downloadDone(error);
}
+
void ZipInstaller::downloadDone(bool error)
{
qDebug() << "Install::downloadDone, error:" << error;
@@ -99,7 +141,6 @@ void ZipInstaller::downloadDone(bool error)
m_dp->addItem(tr("Opening archive failed: %1.")
.arg(uz.formatError(ec)),LOGERROR);
m_dp->abort();
- downloadFile.remove();
emit done(false);
return;
}
@@ -109,7 +150,6 @@ void ZipInstaller::downloadDone(bool error)
m_dp->addItem(tr("Extracting failed: %1.")
.arg(uz.formatError(ec)),LOGERROR);
m_dp->abort();
- downloadFile.remove();
emit done(false);
return;
}
@@ -121,17 +161,16 @@ void ZipInstaller::downloadDone(bool error)
m_dp->addItem(tr("Installing file."), LOGINFO);
qDebug() << "saving downloaded file (no extraction)";
- downloadFile.open(); // copy fails if file is not opened (filename issue?)
+ 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)) {
+ if(!downloadFile->copy(m_mountpoint + m_target)) {
m_dp->addItem(tr("Installing file failed."), LOGERROR);
m_dp->abort();
- downloadFile.remove();
emit done(false);
return;
}
@@ -149,13 +188,8 @@ void ZipInstaller::downloadDone(bool error)
installlog.setValue(zipContents.at(i),installlog.value(zipContents.at(i),0).toInt()+1);
}
installlog.endGroup();
-
- // remove temporary file
- downloadFile.remove();
- m_dp->addItem(tr("Installation finished successfully."),LOGOK);
- m_dp->abort();
- emit done(false);
+ emit cont();
}
void ZipInstaller::updateDataReadProgress(int read, int total)
diff --git a/rbutil/rbutilqt/installzip.h b/rbutil/rbutilqt/installzip.h
index 1d9d024ff6..07558e8e4f 100644
--- a/rbutil/rbutilqt/installzip.h
+++ b/rbutil/rbutilqt/installzip.h
@@ -37,29 +37,36 @@ public:
~ZipInstaller(){}
void install(ProgressloggerInterface* dp);
void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;}
- void setFilename(QString filename){m_file = filename;}
- void setUrl(QString url){m_url = url;}
+ void setUrl(QString url){m_urllist = QStringList(url);}
+ void setUrl(QStringList url) { m_urllist = url; }
void setProxy(QUrl proxy) {m_proxy= proxy;}
- void setLogSection(QString name) {m_logsection = name;}
+ void setLogSection(QString name) {m_loglist = QStringList(name);}
+ void setLogSection(QStringList name) { m_loglist = name; }
void setUnzip(bool i) { m_unzip = i; }
void setTarget(QString t) { m_target = t; }
signals:
void done(bool error);
+ void cont();
private slots:
void updateDataReadProgress(int, int);
void downloadDone(bool);
void downloadRequestFinished(int, bool);
+ void installStart(void);
+ void installContinue(void);
private:
- QString m_url,m_file,m_mountpoint,m_logsection;
+ void installSingle(ProgressloggerInterface *dp);
+ QString m_url, m_file, m_mountpoint, m_logsection;
+ QStringList m_urllist, m_loglist;
QUrl m_proxy;
bool m_unzip;
QString m_target;
+ int runner;
HttpGet *getter;
- QTemporaryFile downloadFile;
+ QTemporaryFile *downloadFile;
ProgressloggerInterface* m_dp;
};