Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a --cache-dir option, and use it in multipageloader.cc

  • Loading branch information...
commit 6e4d64ca52f5beb11ff8295773f321a38d2bdd5e 1 parent 0068788
@bkuker bkuker authored
View
2  include/wkhtmltox/loadsettings.hh
@@ -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
1  src/lib/loadsettings.cc
@@ -134,6 +134,7 @@ LoadGlobal::LoadGlobal():
LoadPage::LoadPage():
jsdelay(200),
windowStatus(""),
+ cacheDir(""),
zoomFactor(1.0),
repeatCustomHeaders(false),
blockLocalFileAccess(false),
View
2  src/lib/loadsettings.hh
@@ -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);
View
9 src/lib/multipageloader.cc
@@ -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
1  src/lib/reflect.cc
@@ -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) {
View
2  src/shared/commonarguments.cc
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.