• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KIOSlave

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
KCookieJar Class Reference

#include <kcookiejar.h>

Public Types

enum  KCookieDefaultPolicy { ApplyToShownCookiesOnly = 0, ApplyToCookiesFromDomain = 1, ApplyToAllCookies = 2 }
 

Public Member Functions

 KCookieJar ()
 
 ~KCookieJar ()
 
void addCookie (KHttpCookie &cookie)
 
bool changed () const
 
KCookieAdvice cookieAdvice (const KHttpCookie &cookie) const
 
bool cookieIsPersistent (const KHttpCookie &cookie) const
 
void eatAllCookies ()
 
void eatCookie (KHttpCookieList::iterator cookieIterator)
 
void eatCookiesForDomain (const QString &domain)
 
void eatSessionCookies (long windowId)
 
void eatSessionCookies (const QString &fqdn, long windowId, bool isFQDN=true)
 
void extractDomains (const QString &_fqdn, QStringList &_domainList) const
 
QString findCookies (const QString &_url, bool useDOMFormat, long windowId, KHttpCookieList *pendingCookies=0)
 
KHttpCookieList * getCookieList (const QString &_domain, const QString &_fqdn)
 
KCookieAdvice getDomainAdvice (const QString &_domain) const
 
const QStringList & getDomainList ()
 
KCookieAdvice getGlobalAdvice () const
 
void loadConfig (KConfig *_config, bool reparse=false)
 
bool loadCookies (const QString &_filename)
 
KHttpCookieList makeCookies (const QString &_url, const QByteArray &cookie_headers, long windowId)
 
KHttpCookieList makeDOMCookies (const QString &_url, const QByteArray &cookie_domstr, long windowId)
 
KCookieDefaultPolicy preferredDefaultPolicy () const
 
void saveConfig (KConfig *_config)
 
bool saveCookies (const QString &_filename)
 
void setDomainAdvice (const QString &_domain, KCookieAdvice _advice)
 
void setDomainAdvice (const KHttpCookie &_cookie, KCookieAdvice _advice)
 
void setGlobalAdvice (KCookieAdvice _advice)
 
void setPreferredDefaultPolicy (KCookieDefaultPolicy value)
 
void setShowCookieDetails (bool value)
 
bool showCookieDetails () const
 

Static Public Member Functions

static QString adviceToStr (KCookieAdvice _advice)
 
static bool parseUrl (const QString &_url, QString &_fqdn, QString &_path, int *port=0)
 
static KCookieAdvice strToAdvice (const QString &_str)
 

Protected Member Functions

void stripDomain (const QString &_fqdn, QString &_domain) const
 
QString stripDomain (const KHttpCookie &cookie) const
 

Protected Attributes

bool m_autoAcceptSessionCookies
 
bool m_configChanged
 
QHash< QString, KHttpCookieList * > m_cookieDomains
 
bool m_cookiesChanged
 
QStringList m_domainList
 
KCookieAdvice m_globalAdvice
 
QSet< QString > m_gTLDs
 
KCookieDefaultPolicy m_preferredPolicy
 
bool m_rejectCrossDomainCookies
 
bool m_showCookieDetails
 
QSet< QString > m_twoLevelTLD
 

Detailed Description

Definition at line 129 of file kcookiejar.h.

Member Enumeration Documentation

enum KCookieJar::KCookieDefaultPolicy
Enumerator
ApplyToShownCookiesOnly 
ApplyToCookiesFromDomain 
ApplyToAllCookies 

Definition at line 356 of file kcookiejar.h.

Constructor & Destructor Documentation

KCookieJar::KCookieJar ( )

Constructs a new cookie jar.

One jar should be enough for all cookies.

Definition at line 291 of file kcookiejar.cpp.

KCookieJar::~KCookieJar ( )

Destructs the cookie jar.

Poor little cookies, they will all be eaten by the cookie monster!

Definition at line 308 of file kcookiejar.cpp.

Member Function Documentation

void KCookieJar::addCookie ( KHttpCookie &  cookie)

This function hands a KHttpCookie object over to the cookie jar.

Definition at line 934 of file kcookiejar.cpp.

QString KCookieJar::adviceToStr ( KCookieAdvice  _advice)
static

Definition at line 131 of file kcookiejar.cpp.

bool KCookieJar::changed ( ) const
inline

Returns whether the cookiejar has been changed.

Definition at line 149 of file kcookiejar.h.

KCookieAdvice KCookieJar::cookieAdvice ( const KHttpCookie &  cookie) const

This function advices whether a single KHttpCookie object should be added to the cookie jar.

Possible return values are:

  • KCookieAccept, the cookie should be added
  • KCookieAcceptForSession, the cookie should be added as session cookie
  • KCookieReject, the cookie should not be added
  • KCookieAsk, the user should decide what to do

Before sending cookies back to a server this function is consulted, so that cookies having advice KCookieReject are not sent back.

Definition at line 1010 of file kcookiejar.cpp.

bool KCookieJar::cookieIsPersistent ( const KHttpCookie &  cookie) const

This function tells whether a single KHttpCookie object should be considered persistent.

Persistent cookies do not get deleted at the end of the session and are saved on disk.

Definition at line 1046 of file kcookiejar.cpp.

void KCookieJar::eatAllCookies ( )

Remove & delete all cookies.

Definition at line 1205 of file kcookiejar.cpp.

void KCookieJar::eatCookie ( KHttpCookieList::iterator  cookieIterator)

Remove & delete a cookie from the jar.

cookieIterator should be one of the entries in a KHttpCookieList. Update your KHttpCookieList by calling getCookieList after calling this function.

Definition at line 1161 of file kcookiejar.cpp.

void KCookieJar::eatCookiesForDomain ( const QString &  domain)

Remove & delete all cookies for domain.

Definition at line 1181 of file kcookiejar.cpp.

void KCookieJar::eatSessionCookies ( long  windowId)

Removes all end of session cookies set by the session windId.

Definition at line 1196 of file kcookiejar.cpp.

void KCookieJar::eatSessionCookies ( const QString &  fqdn,
long  windowId,
bool  isFQDN = true 
)

Removes all end of session cookies set by the session windId.

Definition at line 1211 of file kcookiejar.cpp.

void KCookieJar::extractDomains ( const QString &  _fqdn,
QStringList &  _domainList 
) const

Returns a list of domains in _domainList relevant for this host.

The list is sorted with the FQDN listed first and the top-most domain listed last

Definition at line 594 of file kcookiejar.cpp.

QString KCookieJar::findCookies ( const QString &  _url,
bool  useDOMFormat,
long  windowId,
KHttpCookieList *  pendingCookies = 0 
)

Looks for cookies in the cookie jar which are appropriate for _url.

Returned is a string containing all appropriate cookies in a format which can be added to a HTTP-header without any additional processing.

If useDOMFormat is true, the string is formatted in a format in compliance with the DOM standard. pendingCookies contains a list of cookies that have not been approved yet by the user but that will be included in the result none the less.

Definition at line 350 of file kcookiejar.cpp.

KHttpCookieList * KCookieJar::getCookieList ( const QString &  _domain,
const QString &  _fqdn 
)

Get a list of all cookies in the cookie jar originating from _domain.

Definition at line 1144 of file kcookiejar.cpp.

KCookieAdvice KCookieJar::getDomainAdvice ( const QString &  _domain) const

This function gets the advice for all cookies originating from _domain.

  • KCookieDunno, no specific advice for _domain
  • KCookieAccept, accept all cookies for _domain
  • KCookieAcceptForSession, accept all cookies for _domain as session cookies
  • KCookieReject, reject all cookies for _domain
  • KCookieAsk, the user decides what to do with cookies for _domain

Definition at line 1063 of file kcookiejar.cpp.

const QStringList & KCookieJar::getDomainList ( )

Get a list of all domains known to the cookie jar.

A domain is known to the cookie jar if:

  • It has a cookie originating from the domain
  • It has a specific advice set for the domain

Definition at line 1136 of file kcookiejar.cpp.

KCookieAdvice KCookieJar::getGlobalAdvice ( ) const
inline

Get the global advice for cookies.

The returned advice can have the following values:

  • KCookieAccept, accept cookies
  • KCookieAcceptForSession, accept cookies as session cookies
  • KCookieReject, reject cookies
  • KCookieAsk, the user decides what to do with cookies

The global advice is used if the domain has no advice set.

Definition at line 280 of file kcookiejar.h.

void KCookieJar::loadConfig ( KConfig *  _config,
bool  reparse = false 
)

Load the cookie configuration.

Definition at line 1527 of file kcookiejar.cpp.

bool KCookieJar::loadCookies ( const QString &  _filename)

Load all the cookies from file and add them to the cookie jar.

Definition at line 1390 of file kcookiejar.cpp.

KHttpCookieList KCookieJar::makeCookies ( const QString &  _url,
const QByteArray &  cookie_headers,
long  windowId 
)

This function parses cookie_headers and returns a linked list of valid KHttpCookie objects for all cookies found in cookie_headers.

If no cookies could be found 0 is returned.

cookie_headers should be a concatenation of all lines of a HTTP-header which start with "Set-Cookie". The lines should be separated by '
's.

Definition at line 665 of file kcookiejar.cpp.

KHttpCookieList KCookieJar::makeDOMCookies ( const QString &  _url,
const QByteArray &  cookie_domstring,
long  windowId 
)

This function parses cookie_headers and returns a linked list of valid KHttpCookie objects for all cookies found in cookie_headers.

Parses cookie_domstr and returns a linked list of KHttpCookie objects.

If no cookies could be found 0 is returned.

cookie_domstr should be a concatenation of "name=value" pairs, separated by a semicolon ';'.

cookie_domstr should be a semicolon-delimited list of "name=value" pairs. Any whitespace before "name" or around '=' is discarded. If no cookies are found, 0 is returned.

Definition at line 863 of file kcookiejar.cpp.

bool KCookieJar::parseUrl ( const QString &  _url,
QString &  _fqdn,
QString &  _path,
int *  port = 0 
)
static

Parses _url and returns the FQDN (_fqdn) and path (_path).

Definition at line 569 of file kcookiejar.cpp.

KCookieDefaultPolicy KCookieJar::preferredDefaultPolicy ( ) const
inline

Returns the user's choice in the cookie window.

Definition at line 362 of file kcookiejar.h.

void KCookieJar::saveConfig ( KConfig *  _config)

Save the cookie configuration.

Definition at line 1494 of file kcookiejar.cpp.

bool KCookieJar::saveCookies ( const QString &  _filename)

Store all the cookies in a safe(?) place.

Definition at line 1267 of file kcookiejar.cpp.

void KCookieJar::setDomainAdvice ( const QString &  _domain,
KCookieAdvice  _advice 
)

This function sets the advice for all cookies originating from _domain.

_advice can have the following values:

  • KCookieDunno, no specific advice for _domain
  • KCookieAccept, accept all cookies for _domain
  • KCookieAcceptForSession, accept all cookies for _domain as session cookies
  • KCookieReject, reject all cookies for _domain
  • KCookieAsk, the user decides what to do with cookies for _domain

Definition at line 1080 of file kcookiejar.cpp.

void KCookieJar::setDomainAdvice ( const KHttpCookie &  _cookie,
KCookieAdvice  _advice 
)

This function sets the advice for all cookies originating from the same domain as _cookie.

_advice can have the following values:

  • KCookieDunno, no specific advice for _domain
  • KCookieAccept, accept all cookies for _domain
  • KCookieAcceptForSession, accept all cookies for _domain as session cookies
  • KCookieReject, reject all cookies for _domain
  • KCookieAsk, the user decides what to do with cookies for _domain

Definition at line 1116 of file kcookiejar.cpp.

void KCookieJar::setGlobalAdvice ( KCookieAdvice  _advice)

This function sets the global advice for cookies.

_advice can have the following values:

  • KCookieAccept, accept cookies
  • KCookieAcceptForSession, accept cookies as session cookies
  • KCookieReject, reject cookies
  • KCookieAsk, the user decides what to do with cookies

The global advice is used if the domain has no advice set.

Definition at line 1126 of file kcookiejar.cpp.

void KCookieJar::setPreferredDefaultPolicy ( KCookieDefaultPolicy  value)
inline

Sets the user's default preference cookie policy.

Definition at line 370 of file kcookiejar.h.

void KCookieJar::setShowCookieDetails ( bool  value)
inline

Sets the user's preference of level of detail displayed by the cookie dialog.

Definition at line 376 of file kcookiejar.h.

bool KCookieJar::showCookieDetails ( ) const
inline

Returns the.

Definition at line 365 of file kcookiejar.h.

void KCookieJar::stripDomain ( const QString &  _fqdn,
QString &  _domain 
) const
protected

Definition at line 547 of file kcookiejar.cpp.

QString KCookieJar::stripDomain ( const KHttpCookie &  cookie) const
protected

Definition at line 559 of file kcookiejar.cpp.

KCookieAdvice KCookieJar::strToAdvice ( const QString &  _str)
static

Definition at line 143 of file kcookiejar.cpp.

Member Data Documentation

bool KCookieJar::m_autoAcceptSessionCookies
protected

Definition at line 393 of file kcookiejar.h.

bool KCookieJar::m_configChanged
protected

Definition at line 389 of file kcookiejar.h.

QHash<QString, KHttpCookieList*> KCookieJar::m_cookieDomains
protected

Definition at line 385 of file kcookiejar.h.

bool KCookieJar::m_cookiesChanged
protected

Definition at line 390 of file kcookiejar.h.

QStringList KCookieJar::m_domainList
protected

Definition at line 383 of file kcookiejar.h.

KCookieAdvice KCookieJar::m_globalAdvice
protected

Definition at line 384 of file kcookiejar.h.

QSet<QString> KCookieJar::m_gTLDs
protected

Definition at line 387 of file kcookiejar.h.

KCookieDefaultPolicy KCookieJar::m_preferredPolicy
protected

Definition at line 395 of file kcookiejar.h.

bool KCookieJar::m_rejectCrossDomainCookies
protected

Definition at line 392 of file kcookiejar.h.

bool KCookieJar::m_showCookieDetails
protected

Definition at line 391 of file kcookiejar.h.

QSet<QString> KCookieJar::m_twoLevelTLD
protected

Definition at line 386 of file kcookiejar.h.


The documentation for this class was generated from the following files:
  • kcookiejar.h
  • kcookiejar.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:50:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KIOSlave

Skip menu "KIOSlave"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal