diff options
author | Lionel Chauvin <megabigbug@yahoo.fr> | 2009-08-05 23:48:27 +0200 |
---|---|---|
committer | Lionel Chauvin <megabigbug@yahoo.fr> | 2009-08-05 23:48:27 +0200 |
commit | 109809f8fa4443bf99d3e89a4a0c4f6f5f0e32c2 (patch) | |
tree | ed4857ad517280f641a6109f26283e18f64ca6fa | |
parent | Replace privacy icon and text by history (diff) | |
download | rekonq-109809f8fa4443bf99d3e89a4a0c4f6f5f0e32c2.tar.xz |
clean code
-rw-r--r-- | src/cookiejar.cpp | 48 | ||||
-rw-r--r-- | src/cookiejar.h | 2 |
2 files changed, 19 insertions, 31 deletions
diff --git a/src/cookiejar.cpp b/src/cookiejar.cpp index e6409f3e..5146191d 100644 --- a/src/cookiejar.cpp +++ b/src/cookiejar.cpp @@ -53,6 +53,7 @@ CookieJar::CookieJar(QObject* parent) : QNetworkCookieJar(parent) , m_windowId(10) //m_windowId is important else doesn't connect with KCookieServer { + m_kcookiejar = new QDBusInterface("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer"); } @@ -63,23 +64,17 @@ CookieJar::~CookieJar() QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl & url) const { - QList<QNetworkCookie> cookieList; + QDBusReply<QString> reply = m_kcookiejar->call("findCookies", url.toString() , m_windowId); - if ( true ) // FIXME WebKitSettings::self()->isCookieJarEnabled()) + if (reply.isValid()) + { + cookieList << reply.value().toUtf8(); + //kDebug() << reply.value(); + } + else { - QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer"); - QDBusReply<QString> reply = kcookiejar.call("findCookies", url.toString() , m_windowId); - - if (reply.isValid()) - { - cookieList << reply.value().toUtf8(); - //kDebug() << reply.value(); - } - else - { - kWarning() << "Unable to communicate with the cookiejar!"; - } + kWarning() << "Unable to communicate with the cookiejar!"; } return cookieList; @@ -88,24 +83,16 @@ QList<QNetworkCookie> CookieJar::cookiesForUrl(const QUrl & url) const bool CookieJar::setCookiesFromUrl(const QList<QNetworkCookie> & cookieList, const QUrl & url) { - - if ( true ) // FIXME WebKitSettings::self()->isCookieJarEnabled()) + QByteArray cookieHeader; + foreach(const QNetworkCookie& cookie, cookieList) { - QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer"); - - QByteArray cookieHeader; - foreach(const QNetworkCookie& cookie, cookieList) - { - cookieHeader = "Set-Cookie: "; - cookieHeader += cookie.toRawForm(); - kcookiejar.call("addCookies", url.toString(), cookieHeader, m_windowId); - //kDebug() << "url: " << url.host() << ", cookie: " << cookieHeader; - } - - return !kcookiejar.lastError().isValid(); + cookieHeader = "Set-Cookie: "; + cookieHeader += cookie.toRawForm(); + m_kcookiejar->call("addCookies", url.toString(), cookieHeader, m_windowId); + //kDebug() << "url: " << url.host() << ", cookie: " << cookieHeader; } - return false; + return !m_kcookiejar->lastError().isValid(); } @@ -117,8 +104,7 @@ void CookieJar::setWindowId(qlonglong id) void CookieJar::clear() { - QDBusInterface kcookiejar("org.kde.kded", "/modules/kcookiejar", "org.kde.KCookieServer", QDBusConnection::sessionBus()); - QDBusReply<void> reply = kcookiejar.call( "deleteAllCookies" ); + QDBusReply<void> reply = m_kcookiejar->call( "deleteAllCookies" ); if (!reply.isValid()) { kWarning() << "Unable to delete all the cookies as requested."; diff --git a/src/cookiejar.h b/src/cookiejar.h index a1fe7d2d..5504cf3c 100644 --- a/src/cookiejar.h +++ b/src/cookiejar.h @@ -30,6 +30,7 @@ // Qt Includes #include <QtNetwork/QNetworkCookieJar> +#include <QtDBus/QtDBus> // Forward Declarations class QUrl; @@ -50,6 +51,7 @@ public: private: qlonglong m_windowId; + QDBusInterface *m_kcookiejar; }; #endif // RECOOKIEJAR_H |