LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
customcookiejar.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <QNetworkCookieJar>
12 #include <QByteArray>
13 #include <QRegExp>
14 #include "networkconfig.h"
15 
16 namespace LC::Util
17 {
25  class UTIL_NETWORK_API CustomCookieJar : public QNetworkCookieJar
26  {
27  Q_OBJECT
28 
29  bool FilterTrackingCookies_ = false;
30  bool Enabled_ = true;
31  bool MatchDomainExactly_ = false;
32 
33  QList<QRegExp> WL_;
34  QList<QRegExp> BL_;
35  public:
43  explicit CustomCookieJar (QObject *parent = nullptr);
44 
49  void SetFilterTrackingCookies (bool filter);
50 
59  void SetEnabled (bool enabled);
60 
65  void SetExactDomainMatch (bool enabled);
66 
83  void SetWhitelist (const QList<QRegExp>& list);
84 
95  void SetBlacklist (const QList<QRegExp>& list);
96 
104  [[nodiscard]] QByteArray Save () const;
105 
112  void Load (const QByteArray& data);
113 
116  void CollectGarbage ();
117 
127  QList<QNetworkCookie> cookiesForUrl (const QUrl& url) const override;
128 
137  bool setCookiesFromUrl (const QList<QNetworkCookie>& cookieList, const QUrl& url) override;
138 
139  using QNetworkCookieJar::allCookies;
140  using QNetworkCookieJar::setAllCookies;
141  signals:
142  void cookiesAdded (const QList<QNetworkCookie>&);
143  void cookiesRemoved (const QList<QNetworkCookie>&);
144  };
145 }
QList< QRegExp >
LC::Util
Definition: icoreproxy.h:33
networkconfig.h
UTIL_NETWORK_API
#define UTIL_NETWORK_API
Definition: networkconfig.h:16