summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rbutil/rbutilqt/base/zipinstaller.cpp (renamed from rbutil/rbutilqt/zipinstaller.cpp)95
-rw-r--r--rbutil/rbutilqt/base/zipinstaller.h (renamed from rbutil/rbutilqt/zipinstaller.h)18
-rw-r--r--rbutil/rbutilqt/install.cpp6
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp31
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro4
-rw-r--r--rbutil/rbutilqt/themesinstallwindow.cpp6
6 files changed, 90 insertions, 70 deletions
diff --git a/rbutil/rbutilqt/zipinstaller.cpp b/rbutil/rbutilqt/base/zipinstaller.cpp
index deff52768a..268ae49935 100644
--- a/rbutil/rbutilqt/zipinstaller.cpp
+++ b/rbutil/rbutilqt/base/zipinstaller.cpp
@@ -17,6 +17,7 @@
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20#include <QtCore>
20#include "zipinstaller.h" 21#include "zipinstaller.h"
21#include "rbunzip.h" 22#include "rbunzip.h"
22#include "utils.h" 23#include "utils.h"
@@ -28,29 +29,34 @@ ZipInstaller::ZipInstaller(QObject* parent): QObject(parent)
28} 29}
29 30
30 31
31void ZipInstaller::install(ProgressloggerInterface *dp) 32void ZipInstaller::install()
32{ 33{
33 qDebug() << "install(ProgressloggerInterface*)"; 34 qDebug() << "[ZipInstall] install()";
34 m_dp = dp; 35
35 runner = 0; 36 runner = 0;
36 connect(this, SIGNAL(cont()), this, SLOT(installContinue())); 37 connect(this, SIGNAL(cont()), this, SLOT(installContinue()));
37 m_url = m_urllist.at(runner); 38 m_url = m_urllist.at(runner);
38 m_logsection = m_loglist.at(runner); 39 m_logsection = m_loglist.at(runner);
39 m_logver = m_verlist.at(runner); 40 m_logver = m_verlist.at(runner);
40 installStart(); 41 installStart();
42}
41 43
44
45void ZipInstaller::abort()
46{
47 qDebug() << "[ZipInstall] Aborted";
48 emit internalAborted();
42} 49}
43 50
44 51
45void ZipInstaller::installContinue() 52void ZipInstaller::installContinue()
46{ 53{
47 qDebug() << "installContinue()"; 54 qDebug() << "[ZipInstall] installContinue";
48 55
49 runner++; // this gets called when a install finished, so increase first. 56 runner++; // this gets called when a install finished, so increase first.
50 qDebug() << "runner is now at" << runner << "size is" << m_urllist.size(); 57 qDebug() << "[ZipInstall] runner done:" << runner << "/" << m_urllist.size();
51 if(runner < m_urllist.size()) { 58 if(runner < m_urllist.size()) {
52 qDebug() << "==> runner at" << runner; 59 emit logItem(tr("done."), LOGOK);
53 m_dp->addItem(tr("done."), LOGOK);
54 m_url = m_urllist.at(runner); 60 m_url = m_urllist.at(runner);
55 m_logsection = m_loglist.at(runner); 61 m_logsection = m_loglist.at(runner);
56 if(runner < m_verlist.size()) m_logver = m_verlist.at(runner); 62 if(runner < m_verlist.size()) m_logver = m_verlist.at(runner);
@@ -58,8 +64,7 @@ void ZipInstaller::installContinue()
58 installStart(); 64 installStart();
59 } 65 }
60 else { 66 else {
61 m_dp->addItem(tr("Installation finished successfully."),LOGOK); 67 emit logItem(tr("Installation finished successfully."), LOGOK);
62 m_dp->setFinished();
63 68
64 emit done(false); 69 emit done(false);
65 return; 70 return;
@@ -70,10 +75,10 @@ void ZipInstaller::installContinue()
70 75
71void ZipInstaller::installStart() 76void ZipInstaller::installStart()
72{ 77{
73 qDebug() << "installStart()"; 78 qDebug() << "[ZipInstall] installStart";
74 79
75 m_dp->addItem(tr("Downloading file %1.%2") 80 emit logItem(tr("Downloading file %1.%2").arg(QFileInfo(m_url).baseName(),
76 .arg(QFileInfo(m_url).baseName(), QFileInfo(m_url).completeSuffix()),LOGINFO); 81 QFileInfo(m_url).completeSuffix()),LOGINFO);
77 82
78 // temporary file needs to be opened to get the filename 83 // temporary file needs to be opened to get the filename
79 // make sure to get a fresh one on each run. 84 // make sure to get a fresh one on each run.
@@ -89,61 +94,53 @@ void ZipInstaller::installStart()
89 getter->setCache(true); 94 getter->setCache(true);
90 } 95 }
91 getter->setFile(downloadFile); 96 getter->setFile(downloadFile);
92 97
93 connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); 98 connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
94 connect(getter, SIGNAL(dataReadProgress(int, int)), m_dp, SLOT(setProgress(int, int))); 99 connect(getter, SIGNAL(dataReadProgress(int, int)), this, SIGNAL(logProgress(int, int)));
95 connect(m_dp, SIGNAL(aborted()), getter, SLOT(abort())); 100 connect(this, SIGNAL(internalAborted()), getter, SLOT(abort()));
96 101
97 getter->getFile(QUrl(m_url)); 102 getter->getFile(QUrl(m_url));
98} 103}
99 104
100 105
101void ZipInstaller::downloadDone(bool error) 106void ZipInstaller::downloadDone(bool error)
102{ 107{
103 qDebug() << "Install::downloadDone, error:" << error; 108 qDebug() << "[ZipInstall] downloadDone, error:" << error;
104 QStringList zipContents; // needed later 109 QStringList zipContents; // needed later
105 // update progress bar 110 // update progress bar
106 111
107 int max = m_dp->getProgressMax(); 112 emit logProgress(1, 1);
108 if(max == 0) {
109 max = 100;
110 m_dp->setProgressMax(max);
111 }
112 m_dp->setProgressValue(max);
113 if(getter->httpResponse() != 200 && !getter->isCached()) { 113 if(getter->httpResponse() != 200 && !getter->isCached()) {
114 m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR); 114 emit logItem(tr("Download error: received HTTP error %1.")
115 m_dp->setFinished(); 115 .arg(getter->httpResponse()),LOGERROR);
116 emit done(true); 116 emit done(true);
117 return; 117 return;
118 } 118 }
119 if(getter->isCached()) m_dp->addItem(tr("Cached file used."), LOGINFO); 119 if(getter->isCached())
120 emit logItem(tr("Cached file used."), LOGINFO);
120 if(error) { 121 if(error) {
121 m_dp->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR); 122 emit logItem(tr("Download error: %1").arg(getter->errorString()), LOGERROR);
122 m_dp->setFinished();
123 emit done(true); 123 emit done(true);
124 return; 124 return;
125 } 125 }
126 else m_dp->addItem(tr("Download finished."),LOGOK); 126 else emit logItem(tr("Download finished."),LOGOK);
127 QCoreApplication::processEvents(); 127 QCoreApplication::processEvents();
128 if(m_unzip) { 128 if(m_unzip) {
129 // unzip downloaded file 129 // unzip downloaded file
130 qDebug() << "about to unzip the downloaded file" << m_file << "to" << m_mountpoint; 130 qDebug() << "[ZipInstall] about to unzip " << m_file << "to" << m_mountpoint;
131 131
132 m_dp->addItem(tr("Extracting file."),LOGINFO); 132 emit logItem(tr("Extracting file."), LOGINFO);
133 QCoreApplication::processEvents(); 133 QCoreApplication::processEvents();
134 134
135 qDebug() << "file to unzip: " << m_file;
136 UnZip::ErrorCode ec; 135 UnZip::ErrorCode ec;
137 RbUnZip uz; 136 RbUnZip uz;
138 connect(&uz, SIGNAL(unzipProgress(int, int)), m_dp, SLOT(setProgress(int, int))); 137 connect(&uz, SIGNAL(unzipProgress(int, int)), this, SIGNAL(logProgress(int, int)));
139 connect(m_dp, SIGNAL(aborted()), &uz, SLOT(abortUnzip())); 138 connect(this, SIGNAL(internalAborted()), &uz, SLOT(abortUnzip()));
140 ec = uz.openArchive(m_file); 139 ec = uz.openArchive(m_file);
141 if(ec != UnZip::Ok) { 140 if(ec != UnZip::Ok) {
142 m_dp->addItem(tr("Opening archive failed: %1.") 141 emit logItem(tr("Opening archive failed: %1.")
143 .arg(uz.formatError(ec)),LOGERROR); 142 .arg(uz.formatError(ec)),LOGERROR);
144 m_dp->setProgressMax(1); 143 emit logProgress(1, 1);
145 m_dp->setProgressValue(1);
146 m_dp->setFinished();
147 emit done(true); 144 emit done(true);
148 return; 145 return;
149 } 146 }
@@ -152,22 +149,17 @@ void ZipInstaller::downloadDone(bool error)
152 // some room for operating (also includes calculation mistakes due to 149 // some room for operating (also includes calculation mistakes due to
153 // cluster sizes on the player). 150 // cluster sizes on the player).
154 if(filesystemFree(m_mountpoint) < (uz.totalSize() + 1000000)) { 151 if(filesystemFree(m_mountpoint) < (uz.totalSize() + 1000000)) {
155 m_dp->addItem(tr("Not enough disk space! Aborting."), LOGERROR); 152 emit logItem(tr("Not enough disk space! Aborting."), LOGERROR);
156 m_dp->setFinished(); 153 emit logProgress(1, 1);
157 m_dp->setProgressMax(1);
158 m_dp->setProgressValue(1);
159 emit done(true); 154 emit done(true);
160 return; 155 return;
161 } 156 }
162 ec = uz.extractArchive(m_mountpoint); 157 ec = uz.extractArchive(m_mountpoint);
163 // TODO: better handling of aborted unzip operation. 158 // TODO: better handling of aborted unzip operation.
164 if(ec != UnZip::Ok) { 159 if(ec != UnZip::Ok) {
165 m_dp->addItem(tr("Extracting failed: %1.") 160 emit logItem(tr("Extracting failed: %1.")
166 .arg(uz.formatError(ec)),LOGERROR); 161 .arg(uz.formatError(ec)),LOGERROR);
167 m_dp->setFinished(); 162 emit logProgress(1, 1);
168 m_dp->setProgressMax(1);
169 m_dp->setProgressValue(1);
170
171 emit done(true); 163 emit done(true);
172 return; 164 return;
173 } 165 }
@@ -176,8 +168,8 @@ void ZipInstaller::downloadDone(bool error)
176 } 168 }
177 else { 169 else {
178 // only copy the downloaded file to the output location / name 170 // only copy the downloaded file to the output location / name
179 m_dp->addItem(tr("Installing file."), LOGINFO); 171 emit logItem(tr("Installing file."), LOGINFO);
180 qDebug() << "saving downloaded file (no extraction)"; 172 qDebug() << "[ZipInstall] saving downloaded file (no extraction)";
181 173
182 downloadFile->open(); // copy fails if file is not opened (filename issue?) 174 downloadFile->open(); // copy fails if file is not opened (filename issue?)
183 // make sure the required path is existing 175 // make sure the required path is existing
@@ -187,8 +179,7 @@ void ZipInstaller::downloadDone(bool error)
187 // QFile::copy() doesn't overwrite files, so remove old one first 179 // QFile::copy() doesn't overwrite files, so remove old one first
188 QFile(m_mountpoint + m_target).remove(); 180 QFile(m_mountpoint + m_target).remove();
189 if(!downloadFile->copy(m_mountpoint + m_target)) { 181 if(!downloadFile->copy(m_mountpoint + m_target)) {
190 m_dp->addItem(tr("Installing file failed."), LOGERROR); 182 emit logItem(tr("Installing file failed."), LOGERROR);
191 m_dp->setFinished();
192 emit done(true); 183 emit done(true);
193 return; 184 return;
194 } 185 }
@@ -197,7 +188,7 @@ void ZipInstaller::downloadDone(bool error)
197 zipContents.append( m_target); 188 zipContents.append( m_target);
198 } 189 }
199 190
200 m_dp->addItem(tr("Creating installation log"),LOGINFO); 191 emit logItem(tr("Creating installation log"),LOGINFO);
201 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0); 192 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
202 193
203 installlog.beginGroup(m_logsection); 194 installlog.beginGroup(m_logsection);
diff --git a/rbutil/rbutilqt/zipinstaller.h b/rbutil/rbutilqt/base/zipinstaller.h
index b9cf9b4616..c0e13efa20 100644
--- a/rbutil/rbutilqt/zipinstaller.h
+++ b/rbutil/rbutilqt/base/zipinstaller.h
@@ -26,7 +26,6 @@
26 26
27 27
28#include <QtCore> 28#include <QtCore>
29#include <QtNetwork>
30 29
31#include "progressloggerinterface.h" 30#include "progressloggerinterface.h"
32#include "httpget.h" 31#include "httpget.h"
@@ -37,7 +36,7 @@ class ZipInstaller : public QObject
37public: 36public:
38 ZipInstaller(QObject* parent) ; 37 ZipInstaller(QObject* parent) ;
39 ~ZipInstaller(){} 38 ~ZipInstaller(){}
40 void install(ProgressloggerInterface* dp); 39 void install(void);
41 void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;} 40 void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;}
42 void setUrl(QString url){m_urllist = QStringList(url);} 41 void setUrl(QString url){m_urllist = QStringList(url);}
43 void setUrl(QStringList url) { m_urllist = url; } 42 void setUrl(QStringList url) { m_urllist = url; }
@@ -51,17 +50,22 @@ public:
51 void setCache(bool c) { m_usecache = c; }; 50 void setCache(bool c) { m_usecache = c; };
52 void setCache(QString c) { m_cache = QDir(c); m_usecache = true; } 51 void setCache(QString c) { m_cache = QDir(c); m_usecache = true; }
53 52
54signals: 53public slots:
55 void done(bool error); 54 void abort(void);
56 void cont();
57 55
58private slots: 56private slots:
59 void downloadDone(bool); 57 void downloadDone(bool);
60 void installStart(void); 58 void installStart(void);
61 void installContinue(void); 59 void installContinue(void);
62 60
61signals:
62 void done(bool error);
63 void cont();
64 void logItem(QString, int); //! set logger item
65 void logProgress(int, int); //! set progress bar.
66 void internalAborted(void);
67
63private: 68private:
64 void installSingle(ProgressloggerInterface *dp);
65 QString m_url, m_file, m_mountpoint, m_logsection, m_logver; 69 QString m_url, m_file, m_mountpoint, m_logsection, m_logver;
66 QStringList m_urllist, m_loglist, m_verlist; 70 QStringList m_urllist, m_loglist, m_verlist;
67 bool m_unzip; 71 bool m_unzip;
@@ -72,8 +76,6 @@ private:
72 76
73 HttpGet *getter; 77 HttpGet *getter;
74 QTemporaryFile *downloadFile; 78 QTemporaryFile *downloadFile;
75
76 ProgressloggerInterface* m_dp;
77}; 79};
78 80
79 81
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()
189 189
190 connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); 190 connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool)));
191 191
192 installer->install(logger); 192 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
193 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
194 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
195 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
196 installer->install();
193 197
194} 198}
195 199
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()
584 installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString()); 584 installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
585 585
586 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); 586 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
587 587 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
588 installer->install(logger); 588 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
589 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
590 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
591 installer->install();
589 return true; 592 return true;
590} 593}
591 594
@@ -827,7 +830,11 @@ void RbUtilQt::installFonts()
827 installer->setCache(true); 830 installer->setCache(true);
828 831
829 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); 832 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
830 installer->install(logger); 833 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
834 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
835 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
836 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
837 installer->install();
831} 838}
832 839
833 840
@@ -865,7 +872,11 @@ void RbUtilQt::installVoice()
865 installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString()); 872 installer->setMountPoint(settings->value(RbSettings::Mountpoint).toString());
866 if(!settings->value(RbSettings::CacheDisabled).toBool()) 873 if(!settings->value(RbSettings::CacheDisabled).toBool())
867 installer->setCache(true); 874 installer->setCache(true);
868 installer->install(logger); 875 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
876 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
877 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
878 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
879 installer->install();
869 880
870} 881}
871 882
@@ -912,7 +923,11 @@ void RbUtilQt::installDoom()
912 if(!settings->value(RbSettings::CacheDisabled).toBool()) 923 if(!settings->value(RbSettings::CacheDisabled).toBool())
913 installer->setCache(true); 924 installer->setCache(true);
914 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool))); 925 connect(installer, SIGNAL(done(bool)), this, SLOT(installdone(bool)));
915 installer->install(logger); 926 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
927 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
928 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
929 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
930 installer->install();
916 931
917} 932}
918 933
@@ -1058,7 +1073,11 @@ void RbUtilQt::downloadManual(void)
1058 installer->setUrl(manualurl); 1073 installer->setUrl(manualurl);
1059 installer->setUnzip(false); 1074 installer->setUnzip(false);
1060 installer->setTarget(target); 1075 installer->setTarget(target);
1061 installer->install(logger); 1076 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
1077 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
1078 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
1079 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
1080 installer->install();
1062} 1081}
1063 1082
1064 1083
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 \
50 configure.cpp \ 50 configure.cpp \
51 zip/zip.cpp \ 51 zip/zip.cpp \
52 zip/unzip.cpp \ 52 zip/unzip.cpp \
53 zipinstaller.cpp \ 53 base/zipinstaller.cpp \
54 progressloggergui.cpp \ 54 progressloggergui.cpp \
55 installtalkwindow.cpp \ 55 installtalkwindow.cpp \
56 talkfile.cpp \ 56 talkfile.cpp \
@@ -95,7 +95,7 @@ HEADERS += rbutilqt.h \
95 zip/unzip_p.h \ 95 zip/unzip_p.h \
96 zip/zip_p.h \ 96 zip/zip_p.h \
97 version.h \ 97 version.h \
98 zipinstaller.h \ 98 base/zipinstaller.h \
99 installtalkwindow.h \ 99 installtalkwindow.h \
100 talkfile.h \ 100 talkfile.h \
101 base/autodetection.h \ 101 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()
339 installer->setCache(true); 339 installer->setCache(true);
340 340
341 connect(logger, SIGNAL(closed()), this, SLOT(close())); 341 connect(logger, SIGNAL(closed()), this, SLOT(close()));
342 installer->install(logger); 342 connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
343 connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
344 connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
345 connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
346 installer->install();
343 347
344} 348}
345 349