diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-09-07 04:36:39 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-09-07 04:36:39 (GMT) |
commit | cc044de1f9c1443a482c3709cb1a7011df5729ee (patch) | |
tree | beb2fb08c27a14ee6fafcc6e36bb5eba2343fbc1 /tools | |
parent | 60d4d9c0dcc62e579a96d3909e4c04fd9e8fd1d4 (diff) | |
download | Qt-cc044de1f9c1443a482c3709cb1a7011df5729ee.zip Qt-cc044de1f9c1443a482c3709cb1a7011df5729ee.tar.gz Qt-cc044de1f9c1443a482c3709cb1a7011df5729ee.tar.bz2 |
Save and restore non-session cookies.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 3ae9a97..1c0f496 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -23,6 +23,8 @@ #include <private/qabstractanimation_p.h> #include "deviceskin.h" +#include <QSettings> +#include <QNetworkCookieJar> #include <QNetworkDiskCache> #include <QNetworkAccessManager> #include <QSignalMapper> @@ -208,6 +210,34 @@ public: } }; +class PersistentCookieJar : public QNetworkCookieJar { +public: + PersistentCookieJar(QObject *parent) : QNetworkCookieJar(parent) { load(); } + ~PersistentCookieJar() { save(); } + +private: + void save() + { + QList<QNetworkCookie> list = allCookies(); + QByteArray data; + foreach (QNetworkCookie cookie, list) { + if (!cookie.isSessionCookie()) { + data.append(cookie.toRawForm()); + data.append("\n"); + } + } + QSettings settings("Nokia", "QtQmlViewer"); + settings.setValue("Cookies",data); + } + + void load() + { + QSettings settings("Nokia", "QtQmlViewer"); + QByteArray data = settings.value("Cookies").toByteArray(); + setAllCookies(QNetworkCookie::parseCookies(data)); + } +}; + QString QmlViewer::getVideoFileName() { QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames"); @@ -271,6 +301,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) layout->addWidget(canvas); setupProxy(); + canvas->engine()->networkAccessManager()->setCookieJar(new PersistentCookieJar(this)); connect(&autoStartTimer, SIGNAL(triggered()), this, SLOT(autoStartRecording())); connect(&autoStopTimer, SIGNAL(triggered()), this, SLOT(autoStopRecording())); |