aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/blockerrule.h
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-02-03 19:24:40 +0100
committerAqua-sama <aqua@iserlohn-fortress.net>2017-02-03 19:24:40 +0100
commit05dbc6fb7d8833c183485ec0d846c151b6299c92 (patch)
tree570a9710d125e618a3641822802a89233bdbd5ee /src/webengine/blockerrule.h
parentListing rules in Blocker dialog (diff)
downloadsmolbote-05dbc6fb7d8833c183485ec0d846c151b6299c92.tar.xz
option parsing
Diffstat (limited to 'src/webengine/blockerrule.h')
-rw-r--r--src/webengine/blockerrule.h32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/webengine/blockerrule.h b/src/webengine/blockerrule.h
index 95d82b7..df09d10 100644
--- a/src/webengine/blockerrule.h
+++ b/src/webengine/blockerrule.h
@@ -24,6 +24,7 @@
#include <QObject>
#include <QUrl>
#include <QRegularExpression>
+#include <QWebEngineUrlRequestInfo>
class BlockerRule : public QObject
{
@@ -36,13 +37,33 @@ public:
WildcardMatch
};
+ enum RuleOption {
+ script = 0,
+ image = 1,
+ stylesheet = 2,
+ object = 4,
+ xmlhttprequest = 8,
+ objectsubrequest = 16,
+ subdocument = 32,
+ ping = 64,
+ websocket = 128,
+ document = 256,
+
+ elemhide = 512,
+ generichide = 1024,
+ genericblock = 2048,
+
+ other = 4096
+ };
+
+ Q_DECLARE_FLAGS(RuleOptions, RuleOption)
+
explicit BlockerRule(QString rule, QObject *parent = 0);
- QString pattern() const;
- QString domain() const;
- bool match(const QUrl &url);
+ bool match(const QWebEngineUrlRequestInfo &info);
bool isValid();
bool isException();
+ QString toString() const;
signals:
@@ -52,10 +73,15 @@ private:
// TODO: subclass QRegularExpression and move this there
QString fromWildcardMatch(const QString &pattern);
+ QString m_rule;
+
RuleType m_type;
bool m_exception = false;
QString m_domain;
QRegularExpression ruleExpression;
+
+ RuleOptions m_blacklistOptions;
+ RuleOptions m_whitelistOptions;
};
#endif // ADBLOCKRULE_H