Permalink
Browse files

Merge pull request #9 from bkuker/master

Enhancement for Issue 810: Browser Cache Control
  • Loading branch information...
antialize committed Jan 9, 2012
2 parents 3756746 + 6e4d64c commit 323fe91528497ff94995c9dd63a89a1304475258
@@ -118,6 +118,8 @@ struct DLL_PUBLIC LoadPage {
QString checkboxCheckedSvg;
QString radiobuttonSvg;
QString radiobuttonCheckedSvg;
+
+ QString cacheDir;
};
DLL_PUBLIC LoadPage::LoadErrorHandling strToLoadErrorHandling(const char * s, bool * ok=0);
View
@@ -134,6 +134,7 @@ LoadGlobal::LoadGlobal():
LoadPage::LoadPage():
jsdelay(200),
windowStatus(""),
+ cacheDir(""),
zoomFactor(1.0),
repeatCustomHeaders(false),
blockLocalFileAccess(false),
View
@@ -121,6 +121,8 @@ struct DLL_PUBLIC LoadPage {
QString checkboxCheckedSvg;
QString radiobuttonSvg;
QString radiobuttonCheckedSvg;
+
+ QString cacheDir;
};
DLL_PUBLIC LoadPage::LoadErrorHandling strToLoadErrorHandling(const char * s, bool * ok=0);
@@ -28,6 +28,7 @@
#include <QFile>
#include <QFileInfo>
#include <QNetworkCookie>
+#include <QNetworkDiskCache>
#include <QTimer>
#include <QUuid>
@@ -45,7 +46,13 @@ namespace wkhtmltopdf {
LoaderObject::LoaderObject(QWebPage & p): page(p), skip(false) {};
-MyNetworkAccessManager::MyNetworkAccessManager(const settings::LoadPage & s): settings(s) {}
+MyNetworkAccessManager::MyNetworkAccessManager(const settings::LoadPage & s): settings(s) {
+ if ( !s.cacheDir.isEmpty() ){
+ QNetworkDiskCache *cache = new QNetworkDiskCache(this);
+ cache->setCacheDirectory(s.cacheDir);
+ QNetworkAccessManager::setCache(cache);
+ }
+}
void MyNetworkAccessManager::allow(QString path) {
QString x = QFileInfo(path).canonicalFilePath();
View
@@ -80,6 +80,7 @@ ReflectImpl<LoadPage>::ReflectImpl(LoadPage & c) {
WKHTMLTOPDF_REFLECT(checkboxCheckedSvg);
WKHTMLTOPDF_REFLECT(radiobuttonSvg);
WKHTMLTOPDF_REFLECT(radiobuttonCheckedSvg);
+ WKHTMLTOPDF_REFLECT(cacheDir);
}
ReflectImpl<Web>::ReflectImpl(Web & c) {
@@ -219,6 +219,8 @@ void CommandLineParserBase::addPageLoadArgs(LoadPage & s) {
addarg("enable-local-file-access", 0, "Allowed conversion of a local file to read in other local files.", new ConstSetter<bool>(s.blockLocalFileAccess, false));
addarg("allow", 0, "Allow the file or files from the specified folder to be loaded (repeatable)", new StringListSetter(s.allowed,"path"));
+ addarg("cache-dir", 0, "Web cache directory", new QStrSetter(s.cacheDir,"path"));
+
addarg("debug-javascript", 0,"Show javascript debugging output", new ConstSetter<bool>(s.debugJavascript, true));
addarg("no-debug-javascript", 0,"Do not show javascript debugging output", new ConstSetter<bool>(s.debugJavascript, false));
#if QT_VERSION >= 0x040600

0 comments on commit 323fe91

Please sign in to comment.