Save work.

This commit is contained in:
Martin Rotter 2017-07-20 09:11:36 +02:00
parent dcfa6fd97e
commit 570bc03c37
3 changed files with 156 additions and 114 deletions

View file

@ -59,6 +59,10 @@ Application::Application(const QString &id, int &argc, char **argv)
connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested, this, &Application::downloadRequested); connect(QWebEngineProfile::defaultProfile(), &QWebEngineProfile::downloadRequested, this, &Application::downloadRequested);
QWebEngineProfile::defaultProfile()->setRequestInterceptor(m_urlInterceptor); QWebEngineProfile::defaultProfile()->setRequestInterceptor(m_urlInterceptor);
// TODO: Teď tam žádný nastavení není, ale jestli se DNT třeba
// přidá do dialogu nastavení, tak toto volat při ukládání nastavení.
m_urlInterceptor->loadSettings();
#endif #endif
} }

View file

@ -17,43 +17,46 @@
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>. // along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#include "network-web/adblock/adblockmanager.h" #include "network-web/adblock/adblockmanager.h"
#include "network-web/adblock/adblockdialog.h"
#include "network-web/adblock/adblockmatcher.h"
#include "network-web/adblock/adblocksubscription.h"
#include "network-web/adblock/adblockurlinterceptor.h"
#include "miscellaneous/application.h" #include "miscellaneous/application.h"
#include "miscellaneous/settings.h" #include "miscellaneous/settings.h"
#include "network-web/adblock/adblockdialog.h"
#include "network-web/adblock/adblockmatcher.h"
#include "network-web/adblock/adblocksubscription.h"
#include "network-web/adblock/adblockurlinterceptor.h"
#include "network-web/networkurlinterceptor.h" #include "network-web/networkurlinterceptor.h"
#include <QDateTime> #include <QDateTime>
#include <QTextStream>
#include <QDir> #include <QDir>
#include <QTimer>
#include <QMessageBox> #include <QMessageBox>
#include <QUrlQuery>
#include <QMutexLocker> #include <QMutexLocker>
#include <QSaveFile> #include <QSaveFile>
#include <QWebEngineUrlRequestInfo> #include <QTextStream>
#include <QTimer>
#include <QUrlQuery>
#include <QWebEngineProfile> #include <QWebEngineProfile>
#include <QWebEngineUrlRequestInfo>
Q_GLOBAL_STATIC(AdBlockManager, qz_adblock_manager) Q_GLOBAL_STATIC(AdBlockManager, qz_adblock_manager)
AdBlockManager::AdBlockManager(QObject *parent) AdBlockManager::AdBlockManager(QObject* parent)
: QObject(parent), m_loaded(false), m_enabled(true), m_matcher(new AdBlockMatcher(this)), m_interceptor(new AdBlockUrlInterceptor(this)) { : QObject(parent)
, m_loaded(false)
, m_enabled(true)
, m_matcher(new AdBlockMatcher(this))
, m_interceptor(new AdBlockUrlInterceptor(this))
{
load(); load();
} }
AdBlockManager::~AdBlockManager() { AdBlockManager::~AdBlockManager() { qDeleteAll(m_subscriptions); }
qDeleteAll(m_subscriptions);
}
AdBlockManager *AdBlockManager::instance() { AdBlockManager* AdBlockManager::instance() { return qz_adblock_manager(); }
return qz_adblock_manager();
}
void AdBlockManager::setEnabled(bool enabled) { void AdBlockManager::setEnabled(bool enabled)
{
if (m_enabled == enabled) { if (m_enabled == enabled) {
return; return;
} }
@ -61,26 +64,28 @@ void AdBlockManager::setEnabled(bool enabled) {
m_enabled = enabled; m_enabled = enabled;
emit enabledChanged(enabled); emit enabledChanged(enabled);
qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled, m_enabled); qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled,
m_enabled);
load(); load();
// TODO: Reload user stylesheet. // TODO: Reload user stylesheet.
//mApp->reloadUserStyleSheet(); // mApp->reloadUserStyleSheet();
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
if (m_enabled) { if (m_enabled) {
m_matcher->update(); m_matcher->update();
} } else {
else {
m_matcher->clear(); m_matcher->clear();
} }
} }
QList<AdBlockSubscription*> AdBlockManager::subscriptions() const { QList<AdBlockSubscription*> AdBlockManager::subscriptions() const
{
return m_subscriptions; return m_subscriptions;
} }
bool AdBlockManager::block(QWebEngineUrlRequestInfo &request) { bool AdBlockManager::block(QWebEngineUrlRequestInfo& request)
{
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
if (!isEnabled()) { if (!isEnabled()) {
@ -96,47 +101,49 @@ bool AdBlockManager::block(QWebEngineUrlRequestInfo &request) {
} }
bool res = false; bool res = false;
const AdBlockRule *blockedRule = m_matcher->match(request, urlDomain, urlString); const AdBlockRule* blockedRule = m_matcher->match(request, urlDomain, urlString);
if (blockedRule) { if (blockedRule) {
res = true; res = true;
if (request.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) { if (request.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) {
// We are blocking main URL frame, we can display "AdBlock error page" or redirect to somewhere. // We are blocking main URL frame, we can display "AdBlock error page" or
// redirect to somewhere.
// TODO: dodělat lepší // TODO: dodělat lepší
QMessageBox::warning(nullptr, "blocked website", "blocket"); QMessageBox::warning(nullptr, "blocked website", "blocket");
// TODO request.redirect() přesměrovat na "chybovou stranku"; // TODO request.redirect() přesměrovat na "chybovou stranku";
//QUrl url(QSL("rssguard:adblock")); // QUrl url(QSL("rssguard:adblock"));
//QUrlQuery query; // QUrlQuery query;
//query.addQueryItem(QSL("rule"), blockedRule->filter()); // query.addQueryItem(QSL("rule"), blockedRule->filter());
//query.addQueryItem(QSL("subscription"), blockedRule->subscription()->title()); // query.addQueryItem(QSL("subscription"),
//url.setQuery(query); // blockedRule->subscription()->title());
//request.redirect(url); // url.setQuery(query);
// request.redirect(url);
request.block(true); request.block(true);
} } else {
else {
request.block(true); request.block(true);
} }
} }
return res; return res;
} }
QStringList AdBlockManager::disabledRules() const { QStringList AdBlockManager::disabledRules() const { return m_disabledRules; }
return m_disabledRules;
}
void AdBlockManager::addDisabledRule(const QString &filter) { void AdBlockManager::addDisabledRule(const QString& filter)
{
m_disabledRules.append(filter); m_disabledRules.append(filter);
} }
void AdBlockManager::removeDisabledRule(const QString &filter) { void AdBlockManager::removeDisabledRule(const QString& filter)
{
m_disabledRules.removeOne(filter); m_disabledRules.removeOne(filter);
} }
bool AdBlockManager::addSubscriptionFromUrl(const QUrl &url) { bool AdBlockManager::addSubscriptionFromUrl(const QUrl& url)
const QList<QPair<QString, QString> > queryItems = QUrlQuery(url).queryItems(QUrl::FullyDecoded); {
const QList<QPair<QString, QString>> queryItems = QUrlQuery(url).queryItems(QUrl::FullyDecoded);
QString subscriptionTitle; QString subscriptionTitle;
QString subscriptionUrl; QString subscriptionUrl;
@ -146,8 +153,7 @@ bool AdBlockManager::addSubscriptionFromUrl(const QUrl &url) {
if (pair.first == QL1S("location")) { if (pair.first == QL1S("location")) {
subscriptionUrl = pair.second; subscriptionUrl = pair.second;
} } else if (pair.first == QL1S("title")) {
else if (pair.first == QL1S("title")) {
subscriptionTitle = pair.second; subscriptionTitle = pair.second;
} }
} }
@ -158,35 +164,43 @@ bool AdBlockManager::addSubscriptionFromUrl(const QUrl &url) {
const QString message = tr("Do you want to add <b>%1</b> subscription?").arg(subscriptionTitle); const QString message = tr("Do you want to add <b>%1</b> subscription?").arg(subscriptionTitle);
QMessageBox::StandardButton result = QMessageBox::question(nullptr, tr("Add AdBlock subscription"), message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); QMessageBox::StandardButton result = QMessageBox::question(
nullptr, tr("Add AdBlock subscription"), message,
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (result == QMessageBox::Yes) { if (result == QMessageBox::Yes) {
AdBlockManager::instance()->addSubscription(subscriptionTitle, subscriptionUrl); AdBlockManager::instance()->addSubscription(subscriptionTitle,
subscriptionUrl);
AdBlockManager::instance()->showDialog(); AdBlockManager::instance()->showDialog();
} }
return true; return true;
} }
AdBlockSubscription *AdBlockManager::addSubscription(const QString &title, const QString &url) { AdBlockSubscription* AdBlockManager::addSubscription(const QString& title,
const QString& url)
{
if (title.isEmpty() || url.isEmpty()) { if (title.isEmpty() || url.isEmpty()) {
return 0; return 0;
} }
QString fileName = title + QSL(".txt"); QString fileName = title + QSL(".txt");
QString filePath = storedListsPath() + QDir::separator() + fileName; QString filePath = storedListsPath() + QDir::separator() + fileName;
QByteArray data = QString("Title: %1\nUrl: %2\n[Adblock Plus 1.1.1]").arg(title, url).toLatin1(); QByteArray data = QString("Title: %1\nUrl: %2\n[Adblock Plus 1.1.1]")
.arg(title, url)
.toLatin1();
QSaveFile file(filePath); QSaveFile file(filePath);
if (!file.open(QFile::WriteOnly)) { if (!file.open(QFile::WriteOnly)) {
qWarning("Cannot save AdBlock subscription to file '%s'.", qPrintable(filePath)); qWarning("Cannot save AdBlock subscription to file '%s'.",
qPrintable(filePath));
return 0; return 0;
} }
file.write(data); file.write(data);
file.commit(); file.commit();
AdBlockSubscription *subscription = new AdBlockSubscription(title, this); AdBlockSubscription* subscription = new AdBlockSubscription(title, this);
subscription->setUrl(QUrl(url)); subscription->setUrl(QUrl(url));
subscription->setFilePath(filePath); subscription->setFilePath(filePath);
subscription->loadSubscription(m_disabledRules); subscription->loadSubscription(m_disabledRules);
@ -194,13 +208,16 @@ AdBlockSubscription *AdBlockManager::addSubscription(const QString &title, const
m_subscriptions.insert(m_subscriptions.count() - 1, subscription); m_subscriptions.insert(m_subscriptions.count() - 1, subscription);
// TODO: po změně subskripce přehrat user css? // TODO: po změně subskripce přehrat user css?
//connect(subscription, SIGNAL(subscriptionUpdated()), mApp, SLOT(reloadUserStyleSheet())); // connect(subscription, SIGNAL(subscriptionUpdated()), mApp,
connect(subscription, SIGNAL(subscriptionChanged()), this, SLOT(updateMatcher())); // SLOT(reloadUserStyleSheet()));
connect(subscription, SIGNAL(subscriptionChanged()), this,
SLOT(updateMatcher()));
return subscription; return subscription;
} }
bool AdBlockManager::removeSubscription(AdBlockSubscription* subscription) { bool AdBlockManager::removeSubscription(AdBlockSubscription* subscription)
{
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
if (!m_subscriptions.contains(subscription) || !subscription->canBeRemoved()) { if (!m_subscriptions.contains(subscription) || !subscription->canBeRemoved()) {
@ -216,9 +233,10 @@ bool AdBlockManager::removeSubscription(AdBlockSubscription* subscription) {
return true; return true;
} }
AdBlockCustomList *AdBlockManager::customList() const { AdBlockCustomList* AdBlockManager::customList() const
foreach (AdBlockSubscription *subscription, m_subscriptions) { {
AdBlockCustomList *list = qobject_cast<AdBlockCustomList*>(subscription); foreach (AdBlockSubscription* subscription, m_subscriptions) {
AdBlockCustomList* list = qobject_cast<AdBlockCustomList*>(subscription);
if (list) { if (list) {
return list; return list;
@ -228,20 +246,28 @@ AdBlockCustomList *AdBlockManager::customList() const {
return 0; return 0;
} }
QString AdBlockManager::storedListsPath() const { QString AdBlockManager::storedListsPath() const
{
return qApp->getUserDataPath() + QDir::separator() + ADBLOCK_LISTS_SUBDIRECTORY; return qApp->getUserDataPath() + QDir::separator() + ADBLOCK_LISTS_SUBDIRECTORY;
} }
void AdBlockManager::load() { void AdBlockManager::load()
{
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
if (m_loaded) { if (m_loaded) {
return; return;
} }
m_enabled = qApp->settings()->value(GROUP(AdBlock), SETTING(AdBlock::AdBlockEnabled)).toBool(); m_enabled = qApp->settings()
m_disabledRules = qApp->settings()->value(GROUP(AdBlock), SETTING(AdBlock::DisabledRules)).toStringList(); ->value(GROUP(AdBlock), SETTING(AdBlock::AdBlockEnabled))
QDateTime lastUpdate = qApp->settings()->value(GROUP(AdBlock), SETTING(AdBlock::LastUpdatedOn)).toDateTime(); .toBool();
m_disabledRules = qApp->settings()
->value(GROUP(AdBlock), SETTING(AdBlock::DisabledRules))
.toStringList();
QDateTime lastUpdate = qApp->settings()
->value(GROUP(AdBlock), SETTING(AdBlock::LastUpdatedOn))
.toDateTime();
if (!m_enabled) { if (!m_enabled) {
return; return;
@ -254,7 +280,8 @@ void AdBlockManager::load() {
QDir().mkpath(storedListsPath()); QDir().mkpath(storedListsPath());
} }
foreach (const QString &fileName, adblockDir.entryList(QStringList("*.txt"), QDir::Files)) { foreach (const QString& fileName,
adblockDir.entryList(QStringList("*.txt"), QDir::Files)) {
if (fileName == ADBLOCK_CUSTOMLIST_NAME) { if (fileName == ADBLOCK_CUSTOMLIST_NAME) {
continue; continue;
} }
@ -272,7 +299,8 @@ void AdBlockManager::load() {
QUrl url = QUrl(textStream.readLine(1024).remove(QLatin1String("Url: "))); QUrl url = QUrl(textStream.readLine(1024).remove(QLatin1String("Url: ")));
if (title.isEmpty() || !url.isValid()) { if (title.isEmpty() || !url.isValid()) {
qWarning("Invalid AdBlock subscription file '%s'.", qPrintable(absolutePath)); qWarning("Invalid AdBlock subscription file '%s'.",
qPrintable(absolutePath));
continue; continue;
} }
@ -294,16 +322,18 @@ void AdBlockManager::load() {
} }
// Append CustomList. // Append CustomList.
AdBlockCustomList *customList = new AdBlockCustomList(this); AdBlockCustomList* customList = new AdBlockCustomList(this);
m_subscriptions.append(customList); m_subscriptions.append(customList);
// Load all subscriptions // Load all subscriptions
foreach (AdBlockSubscription *subscription, m_subscriptions) { foreach (AdBlockSubscription* subscription, m_subscriptions) {
subscription->loadSubscription(m_disabledRules); subscription->loadSubscription(m_disabledRules);
// TODO: po zmene subskripce prehrat user css? // TODO: po zmene subskripce prehrat user css?
//connect(subscription, SIGNAL(subscriptionUpdated()), mApp, SLOT(reloadUserStyleSheet())); // connect(subscription, SIGNAL(subscriptionUpdated()), mApp,
connect(subscription, SIGNAL(subscriptionChanged()), this, SLOT(updateMatcher())); // SLOT(reloadUserStyleSheet()));
connect(subscription, SIGNAL(subscriptionChanged()), this,
SLOT(updateMatcher()));
} }
if (lastUpdate.addDays(5) < QDateTime::currentDateTime()) { if (lastUpdate.addDays(5) < QDateTime::currentDateTime()) {
@ -316,65 +346,73 @@ void AdBlockManager::load() {
qApp->urlIinterceptor()->installUrlInterceptor(m_interceptor); qApp->urlIinterceptor()->installUrlInterceptor(m_interceptor);
} }
void AdBlockManager::updateMatcher() { void AdBlockManager::updateMatcher()
{
QMutexLocker locker(&m_mutex); QMutexLocker locker(&m_mutex);
m_matcher->update(); m_matcher->update();
} }
void AdBlockManager::updateAllSubscriptions() { void AdBlockManager::updateAllSubscriptions()
{
foreach (AdBlockSubscription* subscription, m_subscriptions) { foreach (AdBlockSubscription* subscription, m_subscriptions) {
subscription->updateSubscription(); subscription->updateSubscription();
} }
qApp->settings()->setValue(GROUP(AdBlock), AdBlock::LastUpdatedOn, QDateTime::currentDateTime()); qApp->settings()->setValue(GROUP(AdBlock), AdBlock::LastUpdatedOn,
QDateTime::currentDateTime());
} }
void AdBlockManager::save() { void AdBlockManager::save()
{
if (!m_loaded) { if (!m_loaded) {
return; return;
} }
foreach (AdBlockSubscription *subscription, m_subscriptions) { foreach (AdBlockSubscription* subscription, m_subscriptions) {
subscription->saveSubscription(); subscription->saveSubscription();
} }
qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled, m_enabled); qApp->settings()->setValue(GROUP(AdBlock), AdBlock::AdBlockEnabled,
qApp->settings()->setValue(GROUP(AdBlock), AdBlock::DisabledRules, m_disabledRules); m_enabled);
qApp->settings()->setValue(GROUP(AdBlock), AdBlock::DisabledRules,
m_disabledRules);
} }
bool AdBlockManager::isEnabled() const { bool AdBlockManager::isEnabled() const { return m_enabled; }
return m_enabled;
}
bool AdBlockManager::canRunOnScheme(const QString &scheme) const { bool AdBlockManager::canRunOnScheme(const QString& scheme) const
{
return !(scheme == QSL("file") || scheme == QSL("qrc") || scheme == QSL("data") || scheme == QSL("abp")); return !(scheme == QSL("file") || scheme == QSL("qrc") || scheme == QSL("data") || scheme == QSL("abp"));
} }
bool AdBlockManager::canBeBlocked(const QUrl &url) const { bool AdBlockManager::canBeBlocked(const QUrl& url) const
{
return !m_matcher->adBlockDisabledForUrl(url); return !m_matcher->adBlockDisabledForUrl(url);
} }
QString AdBlockManager::elementHidingRules(const QUrl &url) const { QString AdBlockManager::elementHidingRules(const QUrl& url) const
{
if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) { if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) {
return QString(); return QString();
} } else {
else {
return m_matcher->elementHidingRules(); return m_matcher->elementHidingRules();
} }
} }
QString AdBlockManager::elementHidingRulesForDomain(const QUrl &url) const { QString AdBlockManager::elementHidingRulesForDomain(const QUrl& url) const
{
if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) { if (!isEnabled() || !canRunOnScheme(url.scheme()) || !canBeBlocked(url)) {
return QString(); return QString();
} } else {
else {
return m_matcher->elementHidingRulesForDomain(url.host()); return m_matcher->elementHidingRulesForDomain(url.host());
} }
} }
AdBlockSubscription* AdBlockManager::subscriptionByName(const QString &name) const { AdBlockSubscription* AdBlockManager::subscriptionByName(
foreach (AdBlockSubscription *subscription, m_subscriptions) { const QString& name) const
{
foreach (AdBlockSubscription* subscription, m_subscriptions) {
if (subscription->title() == name) { if (subscription->title() == name) {
return subscription; return subscription;
} }
@ -383,7 +421,8 @@ AdBlockSubscription* AdBlockManager::subscriptionByName(const QString &name) con
return 0; return 0;
} }
AdBlockDialog *AdBlockManager::showDialog() { AdBlockDialog* AdBlockManager::showDialog()
{
if (!m_adBlockDialog) { if (!m_adBlockDialog) {
m_adBlockDialog = new AdBlockDialog; m_adBlockDialog = new AdBlockDialog;
} }
@ -395,9 +434,10 @@ AdBlockDialog *AdBlockManager::showDialog() {
return m_adBlockDialog.data(); return m_adBlockDialog.data();
} }
void AdBlockManager::showRule() { void AdBlockManager::showRule()
if (QAction *action = qobject_cast<QAction*>(sender())) { {
const AdBlockRule *rule = static_cast<const AdBlockRule*>(action->data().value<void*>()); if (QAction* action = qobject_cast<QAction*>(sender())) {
const AdBlockRule* rule = static_cast<const AdBlockRule*>(action->data().value<void*>());
if (rule) { if (rule) {
showDialog()->showRule(rule); showDialog()->showRule(rule);

View file

@ -19,57 +19,56 @@
#ifndef ADBLOCKMANAGER_H #ifndef ADBLOCKMANAGER_H
#define ADBLOCKMANAGER_H #define ADBLOCKMANAGER_H
#include <QObject>
#include <QStringList>
#include <QPointer>
#include <QMutex> #include <QMutex>
#include <QObject>
#include <QPointer>
#include <QStringList>
class QUrl; class QUrl;
class QWebEngineUrlRequestInfo; class QWebEngineUrlRequestInfo;
class AdBlockRule;
class AdBlockDialog;
class AdBlockMatcher; class AdBlockMatcher;
class AdBlockCustomList; class AdBlockCustomList;
class AdBlockSubscription; class AdBlockSubscription;
class AdBlockRule;
class AdBlockDialog;
class AdBlockUrlInterceptor; class AdBlockUrlInterceptor;
class AdBlockManager : public QObject { class AdBlockManager : public QObject {
Q_OBJECT Q_OBJECT
public: public:
explicit AdBlockManager(QObject *parent = 0); explicit AdBlockManager(QObject* parent = 0);
virtual ~AdBlockManager(); virtual ~AdBlockManager();
void load(); void load();
void save(); void save();
bool isEnabled() const; bool isEnabled() const;
bool canRunOnScheme(const QString &scheme) const; bool canRunOnScheme(const QString& scheme) const;
QString elementHidingRules(const QUrl &url) const; QString elementHidingRules(const QUrl& url) const;
QString elementHidingRulesForDomain(const QUrl &url) const; QString elementHidingRulesForDomain(const QUrl& url) const;
AdBlockSubscription *subscriptionByName(const QString &name) const; AdBlockSubscription* subscriptionByName(const QString& name) const;
QList<AdBlockSubscription*> subscriptions() const; QList<AdBlockSubscription*> subscriptions() const;
bool block(QWebEngineUrlRequestInfo &request); bool block(QWebEngineUrlRequestInfo& request);
QStringList disabledRules() const; QStringList disabledRules() const;
void addDisabledRule(const QString &filter); void addDisabledRule(const QString& filter);
void removeDisabledRule(const QString &filter); void removeDisabledRule(const QString& filter);
bool addSubscriptionFromUrl(const QUrl &url); bool addSubscriptionFromUrl(const QUrl& url);
AdBlockSubscription *addSubscription(const QString &title, const QString &url); AdBlockSubscription* addSubscription(const QString& title,
bool removeSubscription(AdBlockSubscription *subscription); const QString& url);
bool removeSubscription(AdBlockSubscription* subscription);
AdBlockCustomList *customList() const; AdBlockCustomList* customList() const;
QString storedListsPath() const; QString storedListsPath() const;
static AdBlockManager *instance(); static AdBlockManager* instance();
signals: signals:
void enabledChanged(bool enabled); void enabledChanged(bool enabled);
@ -81,22 +80,21 @@ class AdBlockManager : public QObject {
void updateMatcher(); void updateMatcher();
void updateAllSubscriptions(); void updateAllSubscriptions();
AdBlockDialog *showDialog(); AdBlockDialog* showDialog();
private: private:
inline bool canBeBlocked(const QUrl &url) const; inline bool canBeBlocked(const QUrl& url) const;
bool m_loaded; bool m_loaded;
bool m_enabled; bool m_enabled;
QList<AdBlockSubscription*> m_subscriptions; QList<AdBlockSubscription*> m_subscriptions;
AdBlockMatcher *m_matcher; AdBlockMatcher* m_matcher;
QStringList m_disabledRules; QStringList m_disabledRules;
AdBlockUrlInterceptor *m_interceptor; AdBlockUrlInterceptor* m_interceptor;
QPointer<AdBlockDialog> m_adBlockDialog; QPointer<AdBlockDialog> m_adBlockDialog;
QMutex m_mutex; QMutex m_mutex;
}; };
#endif // ADBLOCKMANAGER_H #endif // ADBLOCKMANAGER_H