[webkit-qt] QNetworkCookieJar: Implementing filesystem storage of cookies.

Jason Martin jason at jason-knight-martin.com
Sat Jan 21 03:58:50 PST 2012


Hey All,

I am trying to implement filesystem storage of cookie. I have overidden the methods 
suggested, however, during use of the browser widget, only
one of those methods is ever called: setCookiesFromUrl.

I have placed qDebug() splats at the top of cookiesForUrl and allCookies and 
setAllCookies, the functions that read the stored files.

Could anyone give me a pointer, or some information or an example that might help?

Thanks in advance!
/Jason Knight

Here is the header file:

class SalorCookieJar : public QNetworkCookieJar
{
     Q_OBJECT
public:
     explicit SalorCookieJar(QObject *parent = 0);
     bool setCookiesFromUrl ( const QList<QNetworkCookie> & cookieList, const QUrl & 
url );
     QList<QNetworkCookie>     cookiesForUrl ( const QUrl & url );
protected:
     void setAllCookies( const QList<QNetworkCookie> & cookieList );
     QList<QNetworkCookie>     allCookies();
private:
     QList<QNetworkCookie> * p_cookies;
     QList<QNetworkCookie> p_ParseCookie(QString file);
     QString p_CookiePath(QUrl url) {
         ...
     }
signals:

public slots:

};



And here is the c code:



SalorCookieJar::SalorCookieJar(QObject *parent) :
     QNetworkCookieJar(parent)
{
     QList<QNetworkCookie> * cookies = new QList<QNetworkCookie>();
     this->p_cookies = cookies;
}

bool SalorCookieJar::setCookiesFromUrl ( const QList<QNetworkCookie> & cookieList, 
const QUrl & url ) {
     qDebug() << "setCookiesFromUrl"; // This is the only splat that shows up...
      ...
     return true;
}
QList<QNetworkCookie> SalorCookieJar::cookiesForUrl ( const QUrl & url ) {
     qDebug() << "cookiesForUrl";
     QString fname = this->p_CookiePath(url);
     return this->p_ParseCookie(fname);
}
QList<QNetworkCookie> SalorCookieJar::allCookies() {
     qDebug() << "allCookiesCalled";
     ...
     return *cookies;
}
QList<QNetworkCookie> SalorCookieJar::p_ParseCookie(QString fname) {
     qDebug() << "p_ParseCookie called with: " << fname;
       ...
     return *cookies;
}
void SalorCookieJar::setAllCookies(const QList<QNetworkCookie> &cookieList) {
     qDebug() << "setAllCookies Called";
     ...
}



More information about the webkit-qt mailing list