LeechCraft  0.6.70-18450-gabe19ee3b0
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 <QNetworkCookie>
12 #include <QNetworkCookieJar>
13 #include <QByteArray>
14 #include <QRegularExpression>
15 #include "networkconfig.h"
16 
17 namespace LC::Util
18 {
26  class UTIL_NETWORK_API CustomCookieJar : public QNetworkCookieJar
27  {
28  Q_OBJECT
29 
30  bool FilterTrackingCookies_ = false;
31  bool Enabled_ = true;
32  bool MatchDomainExactly_ = false;
33 
36  public:
44  explicit CustomCookieJar (QObject *parent = nullptr);
45 
50  void SetFilterTrackingCookies (bool filter);
51 
60  void SetEnabled (bool enabled);
61 
66  void SetExactDomainMatch (bool enabled);
67 
84  void SetWhitelist (const QList<QRegularExpression>& list);
85 
96  void SetBlacklist (const QList<QRegularExpression>& list);
97 
105  [[nodiscard]] QByteArray Save () const;
106 
107  [[nodiscard]] static QByteArray Save (const QList<QNetworkCookie>&);
108 
115  void Load (const QByteArray& data);
116 
119  void CollectGarbage ();
120 
130  QList<QNetworkCookie> cookiesForUrl (const QUrl& url) const override;
131 
140  bool setCookiesFromUrl (const QList<QNetworkCookie>& cookieList, const QUrl& url) override;
141 
142  using QNetworkCookieJar::allCookies;
143  using QNetworkCookieJar::setAllCookies;
144  signals:
145  void cookiesAdded (const QList<QNetworkCookie>&);
146  void cookiesRemoved (const QList<QNetworkCookie>&);
147  };
148 }
#define UTIL_NETWORK_API
Definition: networkconfig.h:16