summaryrefslogtreecommitdiff
path: root/src/adblock
diff options
context:
space:
mode:
Diffstat (limited to 'src/adblock')
-rw-r--r--src/adblock/adblockmanager.cpp29
-rw-r--r--src/adblock/adblockmanager.h4
2 files changed, 33 insertions, 0 deletions
diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp
index b435d437..27fb4020 100644
--- a/src/adblock/adblockmanager.cpp
+++ b/src/adblock/adblockmanager.cpp
@@ -62,6 +62,12 @@ AdBlockManager::~AdBlockManager()
}
+bool AdBlockManager::isEnabled()
+{
+ return _isAdblockEnabled;
+}
+
+
void AdBlockManager::loadSettings()
{
// first, check this...
@@ -347,3 +353,26 @@ void AdBlockManager::showSettings()
dialog->deleteLater();
}
+
+
+void AdBlockManager::addCustomRule(const QString &stringRule)
+{
+ // save rule in local filters
+ QString localRulesFilePath = KStandardDirs::locateLocal("appdata" , QL1S("adblockrules_local"));
+
+ QFile ruleFile(localRulesFilePath);
+ if (!ruleFile.open(QFile::WriteOnly | QFile::Text))
+ {
+ kDebug() << "Unable to open rule file" << localRulesFilePath;
+ return;
+ }
+
+ QTextStream out(&ruleFile);
+ out << stringRule << '\n';
+
+ // load it
+ AdBlockRule rule(stringRule);
+ _blackList << rule;
+
+ // TODO: update page?
+}
diff --git a/src/adblock/adblockmanager.h b/src/adblock/adblockmanager.h
index f853a8ed..2e7f7836 100644
--- a/src/adblock/adblockmanager.h
+++ b/src/adblock/adblockmanager.h
@@ -154,9 +154,13 @@ public:
AdBlockManager(QObject *parent = 0);
~AdBlockManager();
+ bool isEnabled();
+
QNetworkReply *block(const QNetworkRequest &request, WebPage *page);
void applyHidingRules(WebPage *page);
+ void addCustomRule(const QString &);
+
public Q_SLOTS:
void loadSettings();
void showSettings();