From 596e85667d9b2863340318a061dafa676111ff2c Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 26 Jul 2009 12:46:21 +0200 Subject: New Clear Private Data action Needs some fixes.. --- src/application.cpp | 1 - src/cleardata.ui | 12 ++++++++++++ src/mainwindow.cpp | 4 ++-- src/networkmanager.cpp | 43 ++++++++++++++++++++++++++++++++++++++----- src/networkmanager.h | 6 ++++++ 5 files changed, 58 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/application.cpp b/src/application.cpp index 8581c56d..60d5ee48 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -131,7 +131,6 @@ void Application::postLaunch() } - void Application::slotSaveConfiguration() const { ReKonfig::self()->writeConfig(); diff --git a/src/cleardata.ui b/src/cleardata.ui index 217ef136..94a39c69 100644 --- a/src/cleardata.ui +++ b/src/cleardata.ui @@ -26,6 +26,9 @@ history + + true + @@ -33,6 +36,9 @@ Cookies + + true + @@ -40,6 +46,9 @@ Cached web pages + + true + @@ -47,6 +56,9 @@ Website Icons + + true + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2d809162..ea9f1fea 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -965,12 +965,12 @@ void MainWindow::clearPrivateData() if(clearWidget.clearCachedPages->isChecked()) { - Application::historyManager()->clear(); + Application::networkAccessManager()->resetDiskCache(); } if(clearWidget.clearWebIcons->isChecked()) { - Application::historyManager()->clear(); + QWebSettings::clearIconDatabase(); } } delete dialog; diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 2cf65e1c..3d6df204 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -50,10 +50,12 @@ #include #include #include +#include NetworkAccessManager::NetworkAccessManager(QObject *parent) : AccessManager(parent) + , m_diskCache(0) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*, QAuthenticator*))); @@ -65,12 +67,11 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) SLOT(slotSSLErrors(QNetworkReply*, const QList&))); #endif + // load AccessManager Settings loadSettings(); - - QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); - QString location = KStandardDirs::locateLocal("cache", "", true); - diskCache->setCacheDirectory(location); - setCache(diskCache); + + // resetting disk cache + resetDiskCache(); } @@ -97,6 +98,38 @@ void NetworkAccessManager::loadSettings() } +void NetworkAccessManager::resetDiskCache() +{ + if(!m_diskCache) + { + m_diskCache = new QNetworkDiskCache(this); + QString location = KStandardDirs::locateLocal("cache", "", true); + kDebug() << location; + + m_diskCache->setCacheDirectory(location); + setCache(m_diskCache); + } + else + { + QString location = m_diskCache->cacheDirectory(); +// setCache(0); +// delete m_diskCache; + + QDir cacheDir(location + QString("/http") ); + QStringList fileList = cacheDir.entryList(); + foreach(QString str, fileList) + { + QFile file(str); + file.remove(); + } + +// m_diskCache = new QNetworkDiskCache(this); +// m_diskCache->setCacheDirectory(location); +// setCache(m_diskCache); + } +} + + void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) { MainWindow *mainWindow = Application::instance()->mainWindow(); diff --git a/src/networkmanager.h b/src/networkmanager.h index 62c01e99..1f1af2ef 100644 --- a/src/networkmanager.h +++ b/src/networkmanager.h @@ -26,6 +26,7 @@ #include // Forward Declarations +class QNetworkDiskCache; using namespace KIO; @@ -36,6 +37,8 @@ class NetworkAccessManager : public AccessManager public: NetworkAccessManager(QObject *parent = 0); + void resetDiskCache(); + public slots: void loadSettings(); @@ -47,6 +50,9 @@ private slots: void slotSSLErrors(QNetworkReply *reply, const QList &error); #endif +private: + QNetworkDiskCache *m_diskCache; + }; #endif // NETWORKMANAGER_H -- cgit v1.2.1