From 737d688e5b173ef5155db3e4fc9e8debf9b33a11 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 31 May 2020 21:53:52 +0300 Subject: enable smolblok Build both HostlistFilter and AdblockFitler plugins by default. --- plugins/HostlistFilter/filterlist.h | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 plugins/HostlistFilter/filterlist.h (limited to 'plugins/HostlistFilter/filterlist.h') diff --git a/plugins/HostlistFilter/filterlist.h b/plugins/HostlistFilter/filterlist.h new file mode 100644 index 0000000..7301f20 --- /dev/null +++ b/plugins/HostlistFilter/filterlist.h @@ -0,0 +1,58 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://library.iserlohn-fortress.net/aqua/smolbote.git + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#pragma once + +#include +#include + +namespace Hostlist +{ + +class Filterlist final : public FilterList +{ +public: + typedef uint DomainHash; + struct Rule { + QString domain; + QString redirect; + }; + + Filterlist() = default; + ~Filterlist() = default; + + [[nodiscard]] bool findMatch(const QString &domain) const + { + const auto hash = qHash(domain, 0); + const auto found = rules.find(hash); + if(found != rules.end()) { + return true; + } + return false; + } + int count() const + { + return rules.size(); + } + + [[nodiscard]] bool filter(QWebEngineUrlRequestInfo &info) const + { + return false; + } + [[nodiscard]] bool isUpToDate() const + { + return true; + } + + bool load(QIODevice &device); + [[nodiscard]] static std::map parseRule(const QString &line); + +private: + std::map rules; +}; +} // namespace Hostlist -- cgit v1.2.1