summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cookiejar.cpp48
-rw-r--r--src/cookiejar.h2
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