summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-11-09 08:57:02 +0100
committerMontel Laurent <[email protected]>2017-11-09 08:57:02 +0100
commit6a141e8978a5b44a2b7bcd0c53961d56621e22f2 (patch)
tree5aab6e339dcc2566933ec555335f09039686dbfd
parentb803a6b6c0e8805ce87a58b2390f6f60004009ff (diff)
Reactivate some codes
-rw-r--r--plugins/webengineurlinterceptor/adblock/lib/adblockmanager.cpp1
-rw-r--r--plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.cpp22
-rw-r--r--plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.h2
3 files changed, 17 insertions, 8 deletions
diff --git a/plugins/webengineurlinterceptor/adblock/lib/adblockmanager.cpp b/plugins/webengineurlinterceptor/adblock/lib/adblockmanager.cpp
index 181e650..6dc18d6 100644
--- a/plugins/webengineurlinterceptor/adblock/lib/adblockmanager.cpp
+++ b/plugins/webengineurlinterceptor/adblock/lib/adblockmanager.cpp
@@ -46,7 +46,6 @@ void AdblockManager::reloadConfig()
loadSubscriptions();
bool enabled = AdBlock::AdBlockSettings::self()->adBlockEnabled();
Q_EMIT enabledChanged(enabled);
- qDebug() << " void AdblockManager::reloadConfig()" << enabled << " " << this;
}
void AdblockManager::loadSubscriptions()
diff --git a/plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.cpp b/plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.cpp
index c3e3573..0d564d2 100644
--- a/plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.cpp
+++ b/plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.cpp
@@ -332,15 +332,14 @@ AdBlockCustomList::AdBlockCustomList(QObject *parent)
void AdBlockCustomList::loadSubscription(const QStringList &disabledRules)
{
-#if 0
// DuckDuckGo ad whitelist rules
// They cannot be removed, but can be disabled.
// Please consider not disabling them. Thanks!
- const QString ddg1 = QSL("@@||duckduckgo.com^$document");
- const QString ddg2 = QSL("duckduckgo.com#@#.has-ad");
+ const QString ddg1 = QStringLiteral("@@||duckduckgo.com^$document");
+ const QString ddg2 = QStringLiteral("duckduckgo.com#@#.has-ad");
- const QString rules = QzTools::readAllFileContents(filePath());
+ const QString rules = QString::fromUtf8(readAllFileByteContents(filePath()));
QFile file(filePath());
if (file.open(QFile::WriteOnly | QFile::Append)) {
@@ -358,11 +357,20 @@ void AdBlockCustomList::loadSubscription(const QStringList &disabledRules)
file.close();
AdBlockSubscription::loadSubscription(disabledRules);
-#else
- Q_UNUSED(disabledRules);
-#endif
}
+QByteArray AdBlockCustomList::readAllFileByteContents(const QString &filename)
+{
+ QFile file(filename);
+
+ if (!filename.isEmpty() && file.open(QFile::ReadOnly)) {
+ const QByteArray a = file.readAll();
+ file.close();
+ return a;
+ }
+
+ return QByteArray();
+}
void AdBlockCustomList::saveSubscription()
{
QFile file(filePath());
diff --git a/plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.h b/plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.h
index 3ef50aa..e5375b0 100644
--- a/plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.h
+++ b/plugins/webengineurlinterceptor/adblock/lib/adblocksubscription.h
@@ -145,6 +145,8 @@ public:
int addRule(AdBlockRule *rule) override;
bool removeRule(int offset) override;
const AdBlockRule *replaceRule(AdBlockRule *rule, int offset) override;
+private:
+ QByteArray readAllFileByteContents(const QString &filename);
};
}