LeechCraft  %{LEECHCRAFT_VERSION}
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LeechCraft::Util::CustomCookieJar Class Reference

A customized cookie jar with additional features. More...

#include "customcookiejar.h"

+ Inheritance diagram for LeechCraft::Util::CustomCookieJar:
+ Collaboration diagram for LeechCraft::Util::CustomCookieJar:

Public Member Functions

 CustomCookieJar (QObject *parent=0)
 Constructs the cookie jar. More...
 
virtual ~CustomCookieJar ()
 
void SetFilterTrackingCookies (bool filter)
 
void SetEnabled (bool enabled)
 Enables or disables the cookies. More...
 
void SetExactDomainMatch (bool enabled)
 Sets whether exact domain matching is enabled. More...
 
void SetWhitelist (const QList< QRegExp > &list)
 Sets the cookies whitelist. More...
 
void SetBlacklist (const QList< QRegExp > &list)
 Sets the cookies blacklist. More...
 
QByteArray Save () const
 
void Load (const QByteArray &data)
 
void CollectGarbage ()
 
QList< QNetworkCookie > cookiesForUrl (const QUrl &url) const
 Returns cookies for the given url. More...
 
bool setCookiesFromUrl (const QList< QNetworkCookie > &cookieList, const QUrl &url)
 Adds the cookieList for the given url to the jar. More...
 

Detailed Description

A customized cookie jar with additional features.

Allows one to filter tracking cookies, filter duplicate cookies and has unlimited storage period.

Definition at line 48 of file customcookiejar.h.

Constructor & Destructor Documentation

LeechCraft::Util::CustomCookieJar::CustomCookieJar ( QObject *  parent = 0)

Constructs the cookie jar.

Filtering of tracking cookies is false by default, and cookies aren't restored.

Parameters
[in]parentThe parent object.

Definition at line 40 of file customcookiejar.cpp.

LeechCraft::Util::CustomCookieJar::~CustomCookieJar ( )
virtual

Destructs the cookie jar.

Definition at line 48 of file customcookiejar.cpp.

Member Function Documentation

void LeechCraft::Util::CustomCookieJar::CollectGarbage ( )

Removes duplicate cookies.

Definition at line 113 of file customcookiejar.cpp.

QList< QNetworkCookie > LeechCraft::Util::CustomCookieJar::cookiesForUrl ( const QUrl &  url) const

Returns cookies for the given url.

This function automatically filters out duplicate cookies.

If the cookie jar is disabled, this function does nothing.

Parameters
[in]urlThe url to return cookies for.
Returns
The list of cookies, dup-free.

Definition at line 133 of file customcookiejar.cpp.

void LeechCraft::Util::CustomCookieJar::Load ( const QByteArray &  data)

Restores the cookies from the array previously obtained from Save().

Parameters
[in]dataSerialized cookies.
See also
Save()

Definition at line 92 of file customcookiejar.cpp.

Referenced by LeechCraft::Util::SvcAuth::VkAuthManager::clearAuthData(), and LeechCraft::Util::SvcAuth::VkAuthManager::VkAuthManager().

+ Here is the caller graph for this function:

QByteArray LeechCraft::Util::CustomCookieJar::Save ( ) const

Serializes the cookie jar contents into a QByteArray suitable for storage.

Returns
The serialized cookies.
See also
Load()

Definition at line 77 of file customcookiejar.cpp.

void LeechCraft::Util::CustomCookieJar::SetBlacklist ( const QList< QRegExp > &  list)

Sets the cookies blacklist.

Cookies whose domains match regexps from the list will always be rejected until they are also present in the whitelist, in which case they are accepted.

Parameters
[in]listThe blacklist.
See also
SetWhitelist()

Definition at line 72 of file customcookiejar.cpp.

bool LeechCraft::Util::CustomCookieJar::setCookiesFromUrl ( const QList< QNetworkCookie > &  cookieList,
const QUrl &  url 
)

Adds the cookieList for the given url to the jar.

If the cookie jar is disabled, this function does nothing.

Parameters
[in]cookieListThe list of cookies to add.
[in]urlThe url to set cookies for.
Returns
Whether the jar has been modified as the result.

Definition at line 174 of file customcookiejar.cpp.

void LeechCraft::Util::CustomCookieJar::SetEnabled ( bool  enabled)

Enables or disables the cookies.

If cookie jar is disabled, no new cookies will be saved and no cookies will be returned for any URL.

Parameters
[in]enabledWhether the cookie jar should be enabled.

Definition at line 57 of file customcookiejar.cpp.

void LeechCraft::Util::CustomCookieJar::SetExactDomainMatch ( bool  enabled)

Sets whether exact domain matching is enabled.

Parameters
[in]enabledWhether exact matching is enabled.

Definition at line 62 of file customcookiejar.cpp.

void LeechCraft::Util::CustomCookieJar::SetFilterTrackingCookies ( bool  filter)

Enables or disables filtering tracking cookies.

Parameters
[in]filterWhether to filter tracking cookies.

Definition at line 52 of file customcookiejar.cpp.

void LeechCraft::Util::CustomCookieJar::SetWhitelist ( const QList< QRegExp > &  list)

Sets the cookies whitelist.

Cookies whose domains match regexps from the list will always be accepted even despite the SetFilterTrackingCookies() and SetExactDomainMatch() settings.

If a cookie domain matches both a whitelist regexp and blacklist regexp, it is accepted.

If cookies are disabled via SetEnabled(), this option has no effect.

Parameters
[in]listThe whitelist.
See also
SetBlacklist()

Definition at line 67 of file customcookiejar.cpp.


The documentation for this class was generated from the following files: