Commit 3f9f28ab authored by David Faure's avatar David Faure

Try to start kcookiejar if the dcop call to it failed. Allows using cookies

from javascript over any protocol, not just HTTP. Code from Waldo.

svn path=/trunk/kdelibs/; revision=121620
parent 78d8a562
...@@ -196,16 +196,21 @@ DOMString HTMLDocument::cookie() const ...@@ -196,16 +196,21 @@ DOMString HTMLDocument::cookie() const
QDataStream stream(params, IO_WriteOnly); QDataStream stream(params, IO_WriteOnly);
stream << URL().string(); stream << URL().string();
if (!kapp->dcopClient()->call("kcookiejar", "kcookiejar", if (!kapp->dcopClient()->call("kcookiejar", "kcookiejar",
"findDOMCookies(QString)", params, replyType, reply)) { "findDOMCookies(QString)", params, replyType, reply)) {
kdWarning(6010) << "Can't communicate with cookiejar!" << endl; // Maybe it wasn't running (e.g. we're opening local html files)
return DOMString(); KApplication::startServiceByDesktopName( "kcookiejar");
if (!kapp->dcopClient()->call("kcookiejar", "kcookiejar",
"findDOMCookies(QString)", params, replyType, reply)) {
kdWarning(6010) << "Can't communicate with cookiejar!" << endl;
return DOMString();
}
} }
QDataStream stream2(reply, IO_ReadOnly); QDataStream stream2(reply, IO_ReadOnly);
if(replyType != "QString") { if(replyType != "QString") {
kdError(6010) << "DCOP function findDOMCookies(...) returns " kdError(6010) << "DCOP function findDOMCookies(...) returns "
<< replyType << ", expected QString" << endl; << replyType << ", expected QString" << endl;
return DOMString(); return DOMString();
} }
QString result; QString result;
...@@ -223,9 +228,13 @@ void HTMLDocument::setCookie( const DOMString & value ) ...@@ -223,9 +228,13 @@ void HTMLDocument::setCookie( const DOMString & value )
fake_header.append("\n"); fake_header.append("\n");
stream << URL().string() << fake_header.utf8() << windowId; stream << URL().string() << fake_header.utf8() << windowId;
if (!kapp->dcopClient()->send("kcookiejar", "kcookiejar", if (!kapp->dcopClient()->send("kcookiejar", "kcookiejar",
"addCookies(QString,QCString,long int)", params)) "addCookies(QString,QCString,long int)", params))
{ {
kdWarning(6010) << "Can't communicate with cookiejar!" << endl; // Maybe it wasn't running (e.g. we're opening local html files)
KApplication::startServiceByDesktopName( "kcookiejar");
if (!kapp->dcopClient()->send("kcookiejar", "kcookiejar",
"addCookies(QString,QCString,long int)", params))
kdWarning(6010) << "Can't communicate with cookiejar!" << endl;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment