diff options
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 77 | ||||
-rw-r--r-- | rbutil/rbutilqt/configure.h | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/configurefrm.ui | 15 | ||||
-rw-r--r-- | rbutil/rbutilqt/httpget.cpp | 81 | ||||
-rw-r--r-- | rbutil/rbutilqt/httpget.h | 11 | ||||
-rw-r--r-- | rbutil/rbutilqt/icons/package-x-generic.png | bin | 0 -> 540 bytes | |||
-rw-r--r-- | rbutil/rbutilqt/icons/user-trash-full.png | bin | 0 -> 786 bytes | |||
-rw-r--r-- | rbutil/rbutilqt/install.cpp | 2 | ||||
-rw-r--r-- | rbutil/rbutilqt/installthemes.cpp | 6 | ||||
-rw-r--r-- | rbutil/rbutilqt/installzip.cpp | 9 | ||||
-rw-r--r-- | rbutil/rbutilqt/installzip.h | 3 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 17 |
12 files changed, 206 insertions, 19 deletions
diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 989581529f..7a182965bc 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp | |||
@@ -66,14 +66,9 @@ Config::Config(QWidget *parent) : QDialog(parent) | |||
66 | connect(ui.radioSystemProxy, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool))); | 66 | connect(ui.radioSystemProxy, SIGNAL(toggled(bool)), this, SLOT(setSystemProxy(bool))); |
67 | connect(ui.browseMountPoint, SIGNAL(clicked()), this, SLOT(browseFolder())); | 67 | connect(ui.browseMountPoint, SIGNAL(clicked()), this, SLOT(browseFolder())); |
68 | connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect())); | 68 | connect(ui.buttonAutodetect,SIGNAL(clicked()),this,SLOT(autodetect())); |
69 | 69 | connect(ui.buttonCacheBrowse, SIGNAL(clicked()), this, SLOT(browseCache())); | |
70 | // disable unimplemented stuff | 70 | connect(ui.buttonCacheClear, SIGNAL(clicked()), this, SLOT(cacheClear())); |
71 | ui.buttonCacheBrowse->setEnabled(false); | ||
72 | ui.cacheDisable->setEnabled(false); | ||
73 | ui.cacheOfflineMode->setEnabled(false); | ||
74 | ui.buttonCacheClear->setEnabled(false); | ||
75 | 71 | ||
76 | //ui.buttonAutodetect->setEnabled(false); | ||
77 | } | 72 | } |
78 | 73 | ||
79 | 74 | ||
@@ -116,6 +111,14 @@ void Config::accept() | |||
116 | userSettings->setValue("defaults/platform", nplat); | 111 | userSettings->setValue("defaults/platform", nplat); |
117 | } | 112 | } |
118 | 113 | ||
114 | // cache settings | ||
115 | if(QFileInfo(ui.cachePath->text()).isDir()) | ||
116 | userSettings->setValue("defaults/cachepath", ui.cachePath->text()); | ||
117 | else // default to system temp path | ||
118 | userSettings->setValue("defaults/cachepath", QDir::tempPath()); | ||
119 | userSettings->setValue("defaults/cachedisable", ui.cacheDisable->isChecked()); | ||
120 | userSettings->setValue("defaults/offline", ui.cacheOfflineMode->isChecked()); | ||
121 | |||
119 | // sync settings | 122 | // sync settings |
120 | userSettings->sync(); | 123 | userSettings->sync(); |
121 | this->close(); | 124 | this->close(); |
@@ -169,6 +172,20 @@ void Config::setUserSettings(QSettings *user) | |||
169 | // devices tab | 172 | // devices tab |
170 | ui.mountPoint->setText(userSettings->value("defaults/mountpoint").toString()); | 173 | ui.mountPoint->setText(userSettings->value("defaults/mountpoint").toString()); |
171 | 174 | ||
175 | // cache tab | ||
176 | if(!QFileInfo(userSettings->value("defaults/cachepath").toString()).isDir()) | ||
177 | userSettings->setValue("defaults/cachepath", QDir::tempPath()); | ||
178 | ui.cachePath->setText(userSettings->value("defaults/cachepath").toString()); | ||
179 | ui.cacheDisable->setChecked(userSettings->value("defaults/cachedisable").toBool()); | ||
180 | ui.cacheOfflineMode->setChecked(userSettings->value("defaults/offline").toBool()); | ||
181 | QList<QFileInfo> fs = QDir(userSettings->value("defaults/cachepath").toString() + "/rbutil-cache/").entryInfoList(QDir::Files | QDir::NoDotAndDotDot); | ||
182 | qint64 sz = 0; | ||
183 | for(int i = 0; i < fs.size(); i++) { | ||
184 | sz += fs.at(i).size(); | ||
185 | qDebug() << fs.at(i).fileName() << fs.at(i).size(); | ||
186 | } | ||
187 | ui.cacheSize->setText(tr("Current cache size is %1 kiB.") | ||
188 | .arg(sz/1024)); | ||
172 | } | 189 | } |
173 | 190 | ||
174 | 191 | ||
@@ -344,12 +361,32 @@ void Config::browseFolder() | |||
344 | } | 361 | } |
345 | 362 | ||
346 | 363 | ||
364 | void Config::browseCache() | ||
365 | { | ||
366 | cbrowser = new BrowseDirtree(this); | ||
367 | #if defined(Q_OS_LINUX) || defined(Q_OS_MACX) | ||
368 | cbrowser->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); | ||
369 | #elif defined(Q_OS_WIN32) | ||
370 | cbrowser->setFilter(QDir::Drives); | ||
371 | #endif | ||
372 | QDir d(ui.cachePath->text()); | ||
373 | cbrowser->setDir(d); | ||
374 | cbrowser->show(); | ||
375 | connect(cbrowser, SIGNAL(itemChanged(QString)), this, SLOT(setCache(QString))); | ||
376 | } | ||
377 | |||
347 | void Config::setMountpoint(QString m) | 378 | void Config::setMountpoint(QString m) |
348 | { | 379 | { |
349 | ui.mountPoint->setText(m); | 380 | ui.mountPoint->setText(m); |
350 | } | 381 | } |
351 | 382 | ||
352 | 383 | ||
384 | void Config::setCache(QString c) | ||
385 | { | ||
386 | ui.cachePath->setText(c); | ||
387 | } | ||
388 | |||
389 | |||
353 | void Config::autodetect() | 390 | void Config::autodetect() |
354 | { | 391 | { |
355 | Autodetection detector(this); | 392 | Autodetection detector(this); |
@@ -403,3 +440,29 @@ void Config::autodetect() | |||
403 | } | 440 | } |
404 | } | 441 | } |
405 | 442 | ||
443 | void Config::cacheClear() | ||
444 | { | ||
445 | if(QMessageBox::critical(this, tr("Really delete cache?"), | ||
446 | tr("Do you really want to delete the cache? " | ||
447 | "Make absolutely sure this setting is correct as it will " | ||
448 | "remove <b>all</b> files in this folder!").arg(ui.cachePath->text()), | ||
449 | QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) | ||
450 | return; | ||
451 | |||
452 | QString cache = ui.cachePath->text() + "/rbutil-cache/"; | ||
453 | if(!QFileInfo(cache).isDir()) { | ||
454 | QMessageBox::critical(this, tr("Path wrong!"), | ||
455 | tr("The cache path is invalid. Aborting."), QMessageBox::Ok); | ||
456 | return; | ||
457 | } | ||
458 | QDir dir(cache); | ||
459 | QStringList fn; | ||
460 | fn = dir.entryList(QStringList("*"), QDir::Files, QDir::Name); | ||
461 | qDebug() << fn; | ||
462 | |||
463 | for(int i = 0; i < fn.size(); i++) { | ||
464 | QString f = cache + fn.at(i); | ||
465 | QFile::remove(f); | ||
466 | qDebug() << "removed:" << f; | ||
467 | } | ||
468 | } | ||
diff --git a/rbutil/rbutilqt/configure.h b/rbutil/rbutilqt/configure.h index 43bc117567..33f30acc0f 100644 --- a/rbutil/rbutilqt/configure.h +++ b/rbutil/rbutilqt/configure.h | |||
@@ -51,14 +51,18 @@ class Config : public QDialog | |||
51 | QUrl proxy; | 51 | QUrl proxy; |
52 | 52 | ||
53 | BrowseDirtree *browser; | 53 | BrowseDirtree *browser; |
54 | BrowseDirtree *cbrowser; | ||
54 | 55 | ||
55 | private slots: | 56 | private slots: |
56 | void setNoProxy(bool); | 57 | void setNoProxy(bool); |
57 | void setSystemProxy(bool); | 58 | void setSystemProxy(bool); |
58 | void updateLanguage(void); | 59 | void updateLanguage(void); |
59 | void browseFolder(void); | 60 | void browseFolder(void); |
61 | void browseCache(void); | ||
60 | void autodetect(void); | 62 | void autodetect(void); |
61 | void setMountpoint(QString); | 63 | void setMountpoint(QString); |
64 | void setCache(QString); | ||
65 | void cacheClear(void); | ||
62 | }; | 66 | }; |
63 | 67 | ||
64 | #endif | 68 | #endif |
diff --git a/rbutil/rbutilqt/configurefrm.ui b/rbutil/rbutilqt/configurefrm.ui index 006661ba08..087cdf34bd 100644 --- a/rbutil/rbutilqt/configurefrm.ui +++ b/rbutil/rbutilqt/configurefrm.ui | |||
@@ -270,6 +270,9 @@ | |||
270 | <attribute name="title" > | 270 | <attribute name="title" > |
271 | <string>Cac&he</string> | 271 | <string>Cac&he</string> |
272 | </attribute> | 272 | </attribute> |
273 | <attribute name="icon" > | ||
274 | <iconset resource="rbutilqt.qrc" >:/icons/icons/package-x-generic.png</iconset> | ||
275 | </attribute> | ||
273 | <attribute name="toolTip" > | 276 | <attribute name="toolTip" > |
274 | <string>Download cache settings</string> | 277 | <string>Download cache settings</string> |
275 | </attribute> | 278 | </attribute> |
@@ -304,7 +307,11 @@ | |||
304 | </widget> | 307 | </widget> |
305 | </item> | 308 | </item> |
306 | <item> | 309 | <item> |
307 | <widget class="QLineEdit" name="cachePath" /> | 310 | <widget class="QLineEdit" name="cachePath" > |
311 | <property name="toolTip" > | ||
312 | <string>Entering an invalid folder will reset the path to the systems temporary path.</string> | ||
313 | </property> | ||
314 | </widget> | ||
308 | </item> | 315 | </item> |
309 | <item> | 316 | <item> |
310 | <widget class="QPushButton" name="buttonCacheBrowse" > | 317 | <widget class="QPushButton" name="buttonCacheBrowse" > |
@@ -329,6 +336,9 @@ | |||
329 | </item> | 336 | </item> |
330 | <item> | 337 | <item> |
331 | <widget class="QCheckBox" name="cacheOfflineMode" > | 338 | <widget class="QCheckBox" name="cacheOfflineMode" > |
339 | <property name="toolTip" > | ||
340 | <string>This will try to use all information from the cache, even information about updates. Only use this option if you want to install without network connection. Note: you need to do the same install you want to perform later with network access first to download all required files to the cache.</string> | ||
341 | </property> | ||
332 | <property name="text" > | 342 | <property name="text" > |
333 | <string>O&ffline mode</string> | 343 | <string>O&ffline mode</string> |
334 | </property> | 344 | </property> |
@@ -367,6 +377,9 @@ | |||
367 | <property name="text" > | 377 | <property name="text" > |
368 | <string>Clean cache &now</string> | 378 | <string>Clean cache &now</string> |
369 | </property> | 379 | </property> |
380 | <property name="icon" > | ||
381 | <iconset resource="rbutilqt.qrc" >:/icons/icons/user-trash-full.png</iconset> | ||
382 | </property> | ||
370 | </widget> | 383 | </widget> |
371 | </item> | 384 | </item> |
372 | </layout> | 385 | </layout> |
diff --git a/rbutil/rbutilqt/httpget.cpp b/rbutil/rbutilqt/httpget.cpp index 60c8a58a6d..7680cb2d53 100644 --- a/rbutil/rbutilqt/httpget.cpp +++ b/rbutil/rbutilqt/httpget.cpp | |||
@@ -27,8 +27,10 @@ | |||
27 | HttpGet::HttpGet(QObject *parent) | 27 | HttpGet::HttpGet(QObject *parent) |
28 | : QObject(parent) | 28 | : QObject(parent) |
29 | { | 29 | { |
30 | m_usecache = false; | ||
30 | qDebug() << "--> HttpGet::HttpGet()"; | 31 | qDebug() << "--> HttpGet::HttpGet()"; |
31 | outputToBuffer = true; | 32 | outputToBuffer = true; |
33 | cached = false; | ||
32 | getRequest = -1; | 34 | getRequest = -1; |
33 | connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool))); | 35 | connect(&http, SIGNAL(done(bool)), this, SLOT(httpDone(bool))); |
34 | connect(&http, SIGNAL(dataReadProgress(int, int)), this, SLOT(httpProgress(int, int))); | 36 | connect(&http, SIGNAL(dataReadProgress(int, int)), this, SLOT(httpProgress(int, int))); |
@@ -42,6 +44,27 @@ HttpGet::HttpGet(QObject *parent) | |||
42 | } | 44 | } |
43 | 45 | ||
44 | 46 | ||
47 | void HttpGet::setCache(QDir d) | ||
48 | { | ||
49 | m_cachedir = d; | ||
50 | bool result = true; | ||
51 | |||
52 | QString p = m_cachedir.absolutePath() + "/rbutil-cache"; | ||
53 | if(QFileInfo(m_cachedir.absolutePath()).isDir()) | ||
54 | if(!QFileInfo(p).isDir()) | ||
55 | result = m_cachedir.mkdir("rbutil-cache"); | ||
56 | else result = false; | ||
57 | qDebug() << "HttpGet::setCache(QDir)" << result; | ||
58 | m_usecache = !result; | ||
59 | } | ||
60 | |||
61 | |||
62 | void HttpGet::setCache(bool c) | ||
63 | { | ||
64 | m_usecache = c; | ||
65 | } | ||
66 | |||
67 | |||
45 | QByteArray HttpGet::readAll() | 68 | QByteArray HttpGet::readAll() |
46 | { | 69 | { |
47 | return dataBuffer; | 70 | return dataBuffer; |
@@ -108,6 +131,40 @@ bool HttpGet::getFile(const QUrl &url) | |||
108 | return false; | 131 | return false; |
109 | } | 132 | } |
110 | } | 133 | } |
134 | // put hash generation here so it can get reused later | ||
135 | QString hash = QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Md5).toHex(); | ||
136 | cachefile = m_cachedir.absolutePath() + "/rbutil-cache/" + hash; | ||
137 | if(m_usecache) { | ||
138 | // check if the file is present in cache | ||
139 | qDebug() << "[HTTP] cache ENABLED for" << url.toEncoded(); | ||
140 | if(QFileInfo(cachefile).isReadable() && QFileInfo(cachefile).size() > 0) { | ||
141 | qDebug() << "[HTTP] cached file found!" << cachefile; | ||
142 | getRequest = -1; | ||
143 | QFile c(cachefile); | ||
144 | if(!outputToBuffer) { | ||
145 | qDebug() << outputFile->fileName(); | ||
146 | c.open(QIODevice::ReadOnly); | ||
147 | outputFile->open(QIODevice::ReadWrite); | ||
148 | outputFile->write(c.readAll()); | ||
149 | outputFile->close(); | ||
150 | c.close(); | ||
151 | } | ||
152 | else { | ||
153 | c.open(QIODevice::ReadOnly); | ||
154 | dataBuffer = c.readAll(); | ||
155 | c.close(); | ||
156 | } | ||
157 | response = 200; // fake "200 OK" HTTP response | ||
158 | cached = true; | ||
159 | httpDone(false); // we're done now. This will emit the correct signal too. | ||
160 | return true; | ||
161 | } | ||
162 | else qDebug() << "[HTTP] file not cached, downloading to" << cachefile; | ||
163 | |||
164 | } | ||
165 | else { | ||
166 | qDebug() << "[HTTP] cache DISABLED"; | ||
167 | } | ||
111 | http.setHost(url.host(), url.port(80)); | 168 | http.setHost(url.host(), url.port(80)); |
112 | // construct query (if any) | 169 | // construct query (if any) |
113 | QList<QPair<QString, QString> > qitems = url.queryItems(); | 170 | QList<QPair<QString, QString> > qitems = url.queryItems(); |
@@ -119,14 +176,14 @@ bool HttpGet::getFile(const QUrl &url) | |||
119 | } | 176 | } |
120 | 177 | ||
121 | if(outputToBuffer) { | 178 | if(outputToBuffer) { |
122 | qDebug() << "downloading to buffer:" << url.toString(); | 179 | qDebug() << "[HTTP] downloading to buffer:" << url.toString(); |
123 | getRequest = http.get(url.path() + query); | 180 | getRequest = http.get(url.path() + query); |
124 | } | 181 | } |
125 | else { | 182 | else { |
126 | qDebug() << "downloading to file:" << url.toString() << qPrintable(outputFile->fileName()); | 183 | qDebug() << "[HTTP] downloading to file:" << url.toString() << qPrintable(outputFile->fileName()); |
127 | getRequest = http.get(url.path() + query, outputFile); | 184 | getRequest = http.get(url.path() + query, outputFile); |
128 | } | 185 | } |
129 | qDebug() << "request scheduled: GET" << getRequest; | 186 | qDebug() << "[HTTP] request scheduled: GET" << getRequest; |
130 | 187 | ||
131 | return true; | 188 | return true; |
132 | } | 189 | } |
@@ -135,11 +192,25 @@ bool HttpGet::getFile(const QUrl &url) | |||
135 | void HttpGet::httpDone(bool error) | 192 | void HttpGet::httpDone(bool error) |
136 | { | 193 | { |
137 | if (error) { | 194 | if (error) { |
138 | qDebug() << "Error: " << qPrintable(http.errorString()) << httpResponse(); | 195 | qDebug() << "[HTTP] Error: " << qPrintable(http.errorString()) << httpResponse(); |
139 | } | 196 | } |
140 | if(!outputToBuffer) | 197 | if(!outputToBuffer) |
141 | outputFile->close(); | 198 | outputFile->close(); |
142 | 199 | ||
200 | if(m_usecache && !cached) { | ||
201 | qDebug() << "[HTTP] creating cache file" << cachefile; | ||
202 | QFile c(cachefile); | ||
203 | c.open(QIODevice::ReadWrite); | ||
204 | if(!outputToBuffer) { | ||
205 | outputFile->open(QIODevice::ReadOnly | QIODevice::Truncate); | ||
206 | c.write(outputFile->readAll()); | ||
207 | outputFile->close(); | ||
208 | } | ||
209 | else | ||
210 | c.write(dataBuffer); | ||
211 | |||
212 | c.close(); | ||
213 | } | ||
143 | emit done(error); | 214 | emit done(error); |
144 | } | 215 | } |
145 | 216 | ||
diff --git a/rbutil/rbutilqt/httpget.h b/rbutil/rbutilqt/httpget.h index 86eddf9df6..4a3d811e05 100644 --- a/rbutil/rbutilqt/httpget.h +++ b/rbutil/rbutilqt/httpget.h | |||
@@ -21,8 +21,8 @@ | |||
21 | #ifndef HTTPGET_H | 21 | #ifndef HTTPGET_H |
22 | #define HTTPGET_H | 22 | #define HTTPGET_H |
23 | 23 | ||
24 | #include <QFile> | 24 | #include <QtCore> |
25 | #include <QHttp> | 25 | #include <QtNetwork> |
26 | 26 | ||
27 | class QUrl; | 27 | class QUrl; |
28 | 28 | ||
@@ -38,8 +38,11 @@ class HttpGet : public QObject | |||
38 | QHttp::Error error(void); | 38 | QHttp::Error error(void); |
39 | QString errorString(void); | 39 | QString errorString(void); |
40 | void setFile(QFile*); | 40 | void setFile(QFile*); |
41 | void setCache(QDir); | ||
42 | void setCache(bool); | ||
41 | int httpResponse(void); | 43 | int httpResponse(void); |
42 | QByteArray readAll(void); | 44 | QByteArray readAll(void); |
45 | bool isCached() { return cached; } | ||
43 | 46 | ||
44 | public slots: | 47 | public slots: |
45 | void abort(void); | 48 | void abort(void); |
@@ -65,6 +68,10 @@ class HttpGet : public QObject | |||
65 | QByteArray dataBuffer; | 68 | QByteArray dataBuffer; |
66 | bool outputToBuffer; | 69 | bool outputToBuffer; |
67 | QString query; | 70 | QString query; |
71 | bool m_usecache; | ||
72 | QDir m_cachedir; | ||
73 | QString cachefile; | ||
74 | bool cached; | ||
68 | }; | 75 | }; |
69 | 76 | ||
70 | #endif | 77 | #endif |
diff --git a/rbutil/rbutilqt/icons/package-x-generic.png b/rbutil/rbutilqt/icons/package-x-generic.png new file mode 100644 index 0000000000..9015426153 --- /dev/null +++ b/rbutil/rbutilqt/icons/package-x-generic.png | |||
Binary files differ | |||
diff --git a/rbutil/rbutilqt/icons/user-trash-full.png b/rbutil/rbutilqt/icons/user-trash-full.png new file mode 100644 index 0000000000..695d215a7e --- /dev/null +++ b/rbutil/rbutilqt/icons/user-trash-full.png | |||
Binary files differ | |||
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp index 93e9413d71..b1b8d638fa 100644 --- a/rbutil/rbutilqt/install.cpp +++ b/rbutil/rbutilqt/install.cpp | |||
@@ -99,6 +99,8 @@ void Install::accept() | |||
99 | installer->setUrl(file); | 99 | installer->setUrl(file); |
100 | installer->setProxy(proxy); | 100 | installer->setProxy(proxy); |
101 | installer->setLogSection("rockboxbase"); | 101 | installer->setLogSection("rockboxbase"); |
102 | if(!userSettings->value("defaults/cachedisable").toBool()) | ||
103 | installer->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
102 | installer->setLogVersion(myversion); | 104 | installer->setLogVersion(myversion); |
103 | installer->setMountPoint(mountPoint); | 105 | installer->setMountPoint(mountPoint); |
104 | installer->install(logger); | 106 | installer->install(logger); |
diff --git a/rbutil/rbutilqt/installthemes.cpp b/rbutil/rbutilqt/installthemes.cpp index 70a6ed6ec5..33bee10b42 100644 --- a/rbutil/rbutilqt/installthemes.cpp +++ b/rbutil/rbutilqt/installthemes.cpp | |||
@@ -77,6 +77,8 @@ void ThemesInstallWindow::downloadInfo() | |||
77 | qDebug() << "downloadInfo()" << url; | 77 | qDebug() << "downloadInfo()" << url; |
78 | qDebug() << url.queryItems(); | 78 | qDebug() << url.queryItems(); |
79 | getter->setProxy(proxy); | 79 | getter->setProxy(proxy); |
80 | if(userSettings->value("defaults/offline").toBool()) | ||
81 | getter->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
80 | getter->setFile(&themesInfo); | 82 | getter->setFile(&themesInfo); |
81 | getter->getFile(url); | 83 | getter->getFile(url); |
82 | } | 84 | } |
@@ -182,6 +184,8 @@ void ThemesInstallWindow::updateDetails(int row) | |||
182 | 184 | ||
183 | igetter.abort(); | 185 | igetter.abort(); |
184 | igetter.setProxy(proxy); | 186 | igetter.setProxy(proxy); |
187 | if(!userSettings->value("defaults/cachedisable").toBool()) | ||
188 | igetter.setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
185 | igetter.getFile(img); | 189 | igetter.getFile(img); |
186 | connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool))); | 190 | connect(&igetter, SIGNAL(done(bool)), this, SLOT(updateImage(bool))); |
187 | } | 191 | } |
@@ -294,6 +298,8 @@ void ThemesInstallWindow::accept() | |||
294 | installer->setLogSection(names); | 298 | installer->setLogSection(names); |
295 | installer->setLogVersion(version); | 299 | installer->setLogVersion(version); |
296 | installer->setMountPoint(mountPoint); | 300 | installer->setMountPoint(mountPoint); |
301 | if(!userSettings->value("defaults/cachedisable").toBool()) | ||
302 | installer->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
297 | installer->install(logger); | 303 | installer->install(logger); |
298 | connect(logger, SIGNAL(closed()), this, SLOT(close())); | 304 | connect(logger, SIGNAL(closed()), this, SLOT(close())); |
299 | } | 305 | } |
diff --git a/rbutil/rbutilqt/installzip.cpp b/rbutil/rbutilqt/installzip.cpp index 2c7eac6451..154cc9665b 100644 --- a/rbutil/rbutilqt/installzip.cpp +++ b/rbutil/rbutilqt/installzip.cpp | |||
@@ -25,6 +25,7 @@ | |||
25 | ZipInstaller::ZipInstaller(QObject* parent): QObject(parent) | 25 | ZipInstaller::ZipInstaller(QObject* parent): QObject(parent) |
26 | { | 26 | { |
27 | m_unzip = true; | 27 | m_unzip = true; |
28 | m_cache = ""; | ||
28 | } | 29 | } |
29 | 30 | ||
30 | 31 | ||
@@ -86,6 +87,10 @@ void ZipInstaller::installStart() | |||
86 | // get the real file. | 87 | // get the real file. |
87 | getter = new HttpGet(this); | 88 | getter = new HttpGet(this); |
88 | getter->setProxy(m_proxy); | 89 | getter->setProxy(m_proxy); |
90 | if(m_cache.exists()) { | ||
91 | getter->setCache(m_cache); | ||
92 | qDebug() << "installzip: setting cache to" << m_cache; | ||
93 | } | ||
89 | getter->setFile(downloadFile); | 94 | getter->setFile(downloadFile); |
90 | getter->getFile(QUrl(m_url)); | 95 | getter->getFile(QUrl(m_url)); |
91 | 96 | ||
@@ -117,12 +122,13 @@ void ZipInstaller::downloadDone(bool error) | |||
117 | m_dp->setProgressMax(max); | 122 | m_dp->setProgressMax(max); |
118 | } | 123 | } |
119 | m_dp->setProgressValue(max); | 124 | m_dp->setProgressValue(max); |
120 | if(getter->httpResponse() != 200) { | 125 | if(getter->httpResponse() != 200 && !getter->isCached()) { |
121 | m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR); | 126 | m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR); |
122 | m_dp->abort(); | 127 | m_dp->abort(); |
123 | emit done(true); | 128 | emit done(true); |
124 | return; | 129 | return; |
125 | } | 130 | } |
131 | if(getter->isCached()) m_dp->addItem(tr("Cached file used."), LOGINFO); | ||
126 | if(error) { | 132 | if(error) { |
127 | m_dp->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR); | 133 | m_dp->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR); |
128 | m_dp->abort(); | 134 | m_dp->abort(); |
@@ -205,3 +211,4 @@ void ZipInstaller::updateDataReadProgress(int read, int total) | |||
205 | 211 | ||
206 | } | 212 | } |
207 | 213 | ||
214 | |||
diff --git a/rbutil/rbutilqt/installzip.h b/rbutil/rbutilqt/installzip.h index 376bc470e1..9beeb9bbeb 100644 --- a/rbutil/rbutilqt/installzip.h +++ b/rbutil/rbutilqt/installzip.h | |||
@@ -46,6 +46,8 @@ public: | |||
46 | void setLogVersion(QStringList v) { m_verlist = v; qDebug() << m_verlist;} | 46 | void setLogVersion(QStringList v) { m_verlist = v; qDebug() << m_verlist;} |
47 | void setUnzip(bool i) { m_unzip = i; } | 47 | void setUnzip(bool i) { m_unzip = i; } |
48 | void setTarget(QString t) { m_target = t; } | 48 | void setTarget(QString t) { m_target = t; } |
49 | void setCache(QDir c) { m_cache = c; }; | ||
50 | void setCache(QString c) { m_cache = QDir(c); qDebug() << "!!!set cache:" << m_cache;} | ||
49 | 51 | ||
50 | signals: | 52 | signals: |
51 | void done(bool error); | 53 | void done(bool error); |
@@ -66,6 +68,7 @@ private: | |||
66 | bool m_unzip; | 68 | bool m_unzip; |
67 | QString m_target; | 69 | QString m_target; |
68 | int runner; | 70 | int runner; |
71 | QDir m_cache; | ||
69 | 72 | ||
70 | HttpGet *getter; | 73 | HttpGet *getter; |
71 | QTemporaryFile *downloadFile; | 74 | QTemporaryFile *downloadFile; |
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index f26a1ef54e..5f96a592c1 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp | |||
@@ -128,11 +128,11 @@ void RbUtilQt::downloadInfo() | |||
128 | connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); | 128 | connect(daily, SIGNAL(done(bool)), this, SLOT(downloadDone(bool))); |
129 | connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); | 129 | connect(daily, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); |
130 | daily->setProxy(proxy()); | 130 | daily->setProxy(proxy()); |
131 | 131 | if(userSettings->value("defaults/offline").toBool()) | |
132 | daily->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
132 | qDebug() << "downloading build info"; | 133 | qDebug() << "downloading build info"; |
133 | daily->setFile(&buildInfo); | 134 | daily->setFile(&buildInfo); |
134 | daily->getFile(QUrl(devices->value("server_conf_url").toString())); | 135 | daily->getFile(QUrl(devices->value("server_conf_url").toString())); |
135 | |||
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
@@ -154,7 +154,8 @@ void RbUtilQt::downloadDone(bool error) | |||
154 | connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool))); | 154 | connect(bleeding, SIGNAL(done(bool)), this, SLOT(downloadBleedingDone(bool))); |
155 | connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); | 155 | connect(bleeding, SIGNAL(requestFinished(int, bool)), this, SLOT(downloadDone(int, bool))); |
156 | bleeding->setProxy(proxy()); | 156 | bleeding->setProxy(proxy()); |
157 | 157 | if(userSettings->value("defaults/offline").toBool()) | |
158 | bleeding->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
158 | bleeding->setFile(&bleedingInfo); | 159 | bleeding->setFile(&bleedingInfo); |
159 | bleeding->getFile(QUrl(devices->value("bleeding_info").toString())); | 160 | bleeding->getFile(QUrl(devices->value("bleeding_info").toString())); |
160 | } | 161 | } |
@@ -462,6 +463,8 @@ bool RbUtilQt::installAuto() | |||
462 | installer->setProxy(proxy()); | 463 | installer->setProxy(proxy()); |
463 | installer->setLogSection("rockboxbase"); | 464 | installer->setLogSection("rockboxbase"); |
464 | installer->setLogVersion(myversion); | 465 | installer->setLogVersion(myversion); |
466 | if(!userSettings->value("defaults/cachedisable").toBool()) | ||
467 | installer->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
465 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); | 468 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); |
466 | installer->install(logger); | 469 | installer->install(logger); |
467 | 470 | ||
@@ -623,6 +626,8 @@ void RbUtilQt::installFonts() | |||
623 | installer->setLogSection("Fonts"); | 626 | installer->setLogSection("Fonts"); |
624 | installer->setLogVersion(versmap.value("arch_date")); | 627 | installer->setLogVersion(versmap.value("arch_date")); |
625 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); | 628 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); |
629 | if(!userSettings->value("defaults/cachedisable").toBool()) | ||
630 | installer->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
626 | installer->install(logger); | 631 | installer->install(logger); |
627 | } | 632 | } |
628 | 633 | ||
@@ -651,6 +656,8 @@ void RbUtilQt::installVoice() | |||
651 | installer->setLogVersion(versmap.value("arch_date")); | 656 | installer->setLogVersion(versmap.value("arch_date")); |
652 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); | 657 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); |
653 | installer->setTarget("/.rockbox/langs/english.voice"); | 658 | installer->setTarget("/.rockbox/langs/english.voice"); |
659 | if(!userSettings->value("defaults/cachedisable").toBool()) | ||
660 | installer->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
654 | installer->install(logger); | 661 | installer->install(logger); |
655 | 662 | ||
656 | //connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); | 663 | //connect(installer, SIGNAL(done(bool)), this, SLOT(done(bool))); |
@@ -684,6 +691,8 @@ void RbUtilQt::installDoom() | |||
684 | installer->setLogSection("Game Addons"); | 691 | installer->setLogSection("Game Addons"); |
685 | installer->setLogVersion(versmap.value("arch_date")); | 692 | installer->setLogVersion(versmap.value("arch_date")); |
686 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); | 693 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); |
694 | if(!userSettings->value("defaults/cachedisable").toBool()) | ||
695 | installer->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
687 | installer->install(logger); | 696 | installer->install(logger); |
688 | 697 | ||
689 | } | 698 | } |
@@ -783,6 +792,8 @@ void RbUtilQt::downloadManual(void) | |||
783 | logger->show(); | 792 | logger->show(); |
784 | installer = new ZipInstaller(this); | 793 | installer = new ZipInstaller(this); |
785 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); | 794 | installer->setMountPoint(userSettings->value("defaults/mountpoint").toString()); |
795 | if(!userSettings->value("defaults/cachedisable").toBool()) | ||
796 | installer->setCache(userSettings->value("defaults/cachepath", QDir::tempPath()).toString()); | ||
786 | installer->setProxy(proxy()); | 797 | installer->setProxy(proxy()); |
787 | installer->setLogSection(section); | 798 | installer->setLogSection(section); |
788 | installer->setUrl(manualurl); | 799 | installer->setUrl(manualurl); |