summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/networkaccessmanager.cpp49
-rw-r--r--src/networkaccessmanager.h14
2 files changed, 33 insertions, 30 deletions
diff --git a/src/networkaccessmanager.cpp b/src/networkaccessmanager.cpp
index 90d27cd0..c7f9790b 100644
--- a/src/networkaccessmanager.cpp
+++ b/src/networkaccessmanager.cpp
@@ -57,7 +57,6 @@
NetworkAccessManager::NetworkAccessManager(QObject *parent)
: AccessManager(parent)
- , m_diskCache(0)
{
connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)),
SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*)));
@@ -102,25 +101,14 @@ void NetworkAccessManager::loadSettings()
void NetworkAccessManager::resetDiskCache()
{
- if(!m_diskCache)
+ if(!cache())
{
- m_diskCache = new QNetworkDiskCache(this);
- QString location = KStandardDirs::locateLocal("cache", "", true);
-
- m_diskCache->setCacheDirectory(location);
- setCache(m_diskCache);
+ QNetworkDiskCache *diskCache = new QNetworkDiskCache(this);
+ setCache(diskCache);
}
else
{
- QString location = m_diskCache->cacheDirectory();
-
- QDir cacheDir(location + QString("/http") );
- QStringList fileList = cacheDir.entryList();
- Q_FOREACH(QString str, fileList)
- {
- QFile file(str);
- file.remove();
- }
+ cache()->clear();
}
}
@@ -203,26 +191,39 @@ void NetworkAccessManager::slotSSLErrors(QNetworkReply *reply, const QList<QSslE
#endif
-KIO::MetaData& NetworkAccessManager::metaData()
+KIO::MetaData& NetworkAccessManager::sessionMetaData()
{
- return m_metaData;
-};
+ return m_sessionMetaData;
+}
+
+
+KIO::MetaData& NetworkAccessManager::requestMetaData()
+{
+ return m_requestMetaData;
+}
QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkRequest &req, QIODevice *outgoingData)
{
// TODO implement Ad-Block here (refuse connections..)
-
- QNetworkRequest request(req);
- KIO::MetaData metaData(m_metaData);
+ QNetworkRequest request(req);
+ KIO::MetaData metaData = m_sessionMetaData;
+ metaData += m_requestMetaData;
QVariant attr = req.attribute(QNetworkRequest::User);
if (attr.isValid() && attr.type() == QVariant::Map)
{
metaData += attr.toMap();
}
- request.setAttribute(QNetworkRequest::User, metaData.toVariant());
- return AccessManager::createRequest(op,request,outgoingData);
+ if (!metaData.isEmpty())
+ {
+ attr = metaData.toVariant();
+ request.setAttribute(QNetworkRequest::User, attr);
+ }
+
+ // Clear the per request meta data...
+ m_requestMetaData.clear();
+ return AccessManager::createRequest(op, request, outgoingData);
}
diff --git a/src/networkaccessmanager.h b/src/networkaccessmanager.h
index 45a3e9f9..44f2ef3e 100644
--- a/src/networkaccessmanager.h
+++ b/src/networkaccessmanager.h
@@ -31,9 +31,6 @@
// KDE Includes
#include <kio/accessmanager.h>
-// Forward Declarations
-class QNetworkDiskCache;
-
using namespace KIO;
@@ -44,7 +41,10 @@ class NetworkAccessManager : public AccessManager
public:
NetworkAccessManager(QObject *parent = 0);
- KIO::MetaData& metaData();
+
+ KIO::MetaData& sessionMetaData();
+ KIO::MetaData& requestMetaData();
+
void resetDiskCache();
public slots:
@@ -62,8 +62,10 @@ private slots:
#endif
private:
- QNetworkDiskCache *m_diskCache;
- KIO::MetaData m_metaData;
+ KIO::MetaData m_sessionMetaData;
+ KIO::MetaData m_requestMetaData;
+
+
};
#endif // NETWORKACCESSMANAGER_H