From f437f86f03abcb266c215f985162b3d9462b8007 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 14 May 2010 00:14:19 +0200 Subject: AdBlock clean up, step 1 --- src/adblock/adblockmanager.cpp | 3 +++ src/adblock/adblocknetworkreply.cpp | 5 +++++ src/adblock/adblocknetworkreply.h | 2 +- src/adblock/adblockrule.cpp | 37 +------------------------------------ src/adblock/adblockrule.h | 3 --- 5 files changed, 10 insertions(+), 40 deletions(-) (limited to 'src/adblock') diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index e195c705..9080aa66 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -56,6 +56,9 @@ AdBlockManager::AdBlockManager(QObject *parent) AdBlockManager::~AdBlockManager() { + _whiteList.clear(); + _blackList.clear(); + _hideList.clear(); } diff --git a/src/adblock/adblocknetworkreply.cpp b/src/adblock/adblocknetworkreply.cpp index 13677daa..24f3a86f 100644 --- a/src/adblock/adblocknetworkreply.cpp +++ b/src/adblock/adblocknetworkreply.cpp @@ -75,6 +75,11 @@ AdBlockNetworkReply::AdBlockNetworkReply(const QNetworkRequest &request, const Q } +void AdBlockNetworkReply::abort() +{ +} + + qint64 AdBlockNetworkReply::readData(char *data, qint64 maxSize) { Q_UNUSED(data); diff --git a/src/adblock/adblocknetworkreply.h b/src/adblock/adblocknetworkreply.h index 14a0672c..16ba945a 100644 --- a/src/adblock/adblocknetworkreply.h +++ b/src/adblock/adblocknetworkreply.h @@ -71,7 +71,7 @@ class REKONQ_TESTS_EXPORT AdBlockNetworkReply : public QNetworkReply public: AdBlockNetworkReply(const QNetworkRequest &request, const QString &urlString, QObject *parent = 0); - void abort() {}; + void abort(); protected: qint64 readData(char *data, qint64 maxSize); diff --git a/src/adblock/adblockrule.cpp b/src/adblock/adblockrule.cpp index 7c91a692..6ff98f03 100644 --- a/src/adblock/adblockrule.cpp +++ b/src/adblock/adblockrule.cpp @@ -61,7 +61,6 @@ AdBlockRule::AdBlockRule(const QString &filter) - : m_optionMatchRule(false) { bool isRegExpRule = false; @@ -91,7 +90,6 @@ AdBlockRule::AdBlockRule(const QString &filter) if (options.contains(QL1S("match-case"))) { m_regExp.setCaseSensitivity(Qt::CaseSensitive); - m_optionMatchRule = true; } } @@ -101,40 +99,7 @@ AdBlockRule::AdBlockRule(const QString &filter) // return true means "matched rule", so stop url! bool AdBlockRule::match(const QString &encodedUrl) const { - bool matched = m_regExp.indexIn(encodedUrl) != -1; - -// TODO: Reimplement this in rekonq 0.5 :) -// -// if (matched && !m_options.isEmpty()) -// { -// // we only support domain right now -// if (m_options.count() == 1) -// { -// foreach (const QString &option, m_options) -// { -// if (option.startsWith( QL1S("domain=") )) -// { -// QUrl url = QUrl::fromEncoded(encodedUrl.toUtf8()); -// QString host = url.host(); -// QStringList domainOptions = option.mid(7).split( QL1C('|') ); -// foreach (QString domainOption, domainOptions) -// { -// bool negate = domainOption.at(0) == QL1C('~'); -// if (negate) -// domainOption = domainOption.mid(1); -// bool hostMatched = domainOption == host; -// if (hostMatched && !negate) -// return true; -// if (!hostMatched && negate) -// return true; -// } -// } -// } -// } -// return false; -// } - - return matched; + return m_regExp.indexIn(encodedUrl) != -1; } diff --git a/src/adblock/adblockrule.h b/src/adblock/adblockrule.h index 6f042fe2..28084004 100644 --- a/src/adblock/adblockrule.h +++ b/src/adblock/adblockrule.h @@ -79,9 +79,6 @@ private: QString convertPatternToRegExp(const QString &wildcardPattern); QRegExp m_regExp; - - // Rule Options - bool m_optionMatchRule; }; -- cgit v1.2.1 From 50f91796e0c4a4d23b4961fbc775a762f4ea3909 Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 14 May 2010 01:07:14 +0200 Subject: Move adblock rules conf file to appdata, to maintain central config file tiny --- src/adblock/adblockmanager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/adblock') diff --git a/src/adblock/adblockmanager.cpp b/src/adblock/adblockmanager.cpp index 9080aa66..48e2369d 100644 --- a/src/adblock/adblockmanager.cpp +++ b/src/adblock/adblockmanager.cpp @@ -80,9 +80,9 @@ void AdBlockManager::loadSettings(bool checkUpdateDate) // just to be sure.. _isHideAdsEnabled = ReKonfig::hideAdsEnabled(); - - // local settings - KSharedConfig::Ptr config = KGlobal::config(); + + // read settings + KSharedConfig::Ptr config = KSharedConfig::openConfig("adblock", KConfig::SimpleConfig, "appdata"); KConfigGroup rulesGroup(config, "rules"); QStringList rules; rules = rulesGroup.readEntry("local-rules" , QStringList()); @@ -306,7 +306,7 @@ void AdBlockManager::saveRules(const QStringList &rules) QStringList titles = ReKonfig::subscriptionTitles(); QString title = titles.at(_index) + "-rules"; - KSharedConfig::Ptr config = KGlobal::config(); + KSharedConfig::Ptr config = KSharedConfig::openConfig("adblock", KConfig::SimpleConfig, "appdata"); KConfigGroup cg(config , "rules"); cg.writeEntry(title, cleanedRules); } -- cgit v1.2.1