diff options
-rw-r--r-- | lib/smolblok/README.md (renamed from staging/smolblok/README.md) | 0 | ||||
-rw-r--r-- | lib/smolblok/filtermanager.hpp (renamed from staging/smolblok/filtermanager.hpp) | 0 | ||||
-rw-r--r-- | lib/smolblok/meson.build (renamed from staging/smolblok/meson.build) | 8 | ||||
-rw-r--r-- | lib/smolblok/smolblok.cpp (renamed from staging/smolblok/smolblok.cpp) | 0 | ||||
-rw-r--r-- | lib/smolblok/smolblok.hpp (renamed from staging/smolblok/smolblok.hpp) | 4 | ||||
-rw-r--r-- | lib/smolblok/test/loader.cpp (renamed from staging/smolblok/test/loader.cpp) | 0 | ||||
-rw-r--r-- | lib/smolblok/test/main.cpp (renamed from staging/smolblok/test/main.cpp) | 0 | ||||
-rw-r--r-- | lib/smolblok/test/sample-filters.txt (renamed from staging/smolblok/test/sample-filters.txt) | 0 | ||||
-rw-r--r-- | meson.build | 14 | ||||
-rw-r--r-- | plugins/AdblockFilter/filterlist.cpp (renamed from staging/adblock/filterlist.cpp) | 8 | ||||
-rw-r--r-- | plugins/AdblockFilter/filterlist.h (renamed from staging/adblock/filterlist.h) | 6 | ||||
-rw-r--r-- | plugins/AdblockFilter/meson.build (renamed from staging/adblock/meson.build) | 0 | ||||
-rw-r--r-- | plugins/AdblockFilter/options.cpp (renamed from staging/adblock/options.cpp) | 0 | ||||
-rw-r--r-- | plugins/AdblockFilter/options.h (renamed from staging/adblock/options.h) | 0 | ||||
-rw-r--r-- | plugins/AdblockFilter/plugin/AdblockPlusPlugin.json (renamed from staging/adblock/plugin/AdblockPlusPlugin.json) | 0 | ||||
-rw-r--r-- | plugins/AdblockFilter/plugin/plugin.cpp (renamed from staging/adblock/plugin/plugin.cpp) | 0 | ||||
-rw-r--r-- | plugins/AdblockFilter/plugin/plugin.h (renamed from staging/adblock/plugin/plugin.h) | 0 | ||||
-rw-r--r-- | plugins/AdblockFilter/rule.h (renamed from staging/adblock/rule.h) | 0 | ||||
-rw-r--r-- | plugins/AdblockFilter/test/filterlist.cpp (renamed from staging/adblock/test/filterlist.cpp) | 12 | ||||
-rw-r--r-- | plugins/AdblockFilter/test/options.cpp (renamed from staging/adblock/test/options.cpp) | 0 | ||||
-rw-r--r-- | plugins/AdblockFilter/test/rule.cpp (renamed from staging/adblock/test/rule.cpp) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/corpus/apple.txt (renamed from plugins/smolblok_hostlist/corpus/apple.txt) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/corpus/banana.txt (renamed from plugins/smolblok_hostlist/corpus/banana.txt) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/corpus/kiwi.txt (renamed from plugins/smolblok_hostlist/corpus/kiwi.txt) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/corpus/orange.txt (renamed from plugins/smolblok_hostlist/corpus/orange.txt) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/filterlist.cpp (renamed from plugins/smolblok_hostlist/filterlist.cpp) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/filterlist.h (renamed from plugins/smolblok_hostlist/filterlist.h) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/meson.build (renamed from plugins/smolblok_hostlist/meson.build) | 11 | ||||
-rw-r--r-- | plugins/HostlistFilter/plugin/plugin.cpp (renamed from plugins/smolblok_hostlist/plugin/plugin.cpp) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/plugin/plugin.h (renamed from plugins/smolblok_hostlist/plugin/plugin.h) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/plugin/smolblokHostlistPlugin.json (renamed from plugins/smolblok_hostlist/plugin/smolblokHostlistPlugin.json) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/test/filterlist.cpp (renamed from plugins/smolblok_hostlist/test/filterlist.cpp) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/test/hostlist.txt (renamed from plugins/smolblok_hostlist/test/hostlist.txt) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/test/plugin.cpp (renamed from plugins/smolblok_hostlist/test/plugin.cpp) | 0 | ||||
-rw-r--r-- | plugins/HostlistFilter/test/rule.cpp (renamed from plugins/smolblok_hostlist/test/rule.cpp) | 0 | ||||
-rw-r--r-- | src/browser.cpp | 10 | ||||
-rw-r--r-- | src/browser.h | 4 |
37 files changed, 37 insertions, 40 deletions
diff --git a/staging/smolblok/README.md b/lib/smolblok/README.md index 1793009..1793009 100644 --- a/staging/smolblok/README.md +++ b/lib/smolblok/README.md diff --git a/staging/smolblok/filtermanager.hpp b/lib/smolblok/filtermanager.hpp index 6ee4d3f..6ee4d3f 100644 --- a/staging/smolblok/filtermanager.hpp +++ b/lib/smolblok/filtermanager.hpp diff --git a/staging/smolblok/meson.build b/lib/smolblok/meson.build index 6105179..ea9e715 100644 --- a/staging/smolblok/meson.build +++ b/lib/smolblok/meson.build @@ -1,12 +1,10 @@ dep_smolblok = declare_dependency( include_directories: [ '.', smolbote_interfaces ], - link_with: library('smolblok', - [ 'smolblok.cpp' ], - include_directories: smolbote_interfaces, - dependencies: dep_qt5 - ) + link_with: library('smolblok', [ 'smolblok.cpp' ], include_directories: smolbote_interfaces, dependencies: dep_qt5) ) +poi_sourceset.add(dep_smolblok) + smolblok_load = executable('smolblok-load', dependencies: [ dep_qt5, dep_spdlog, dep_smolblok ], sources: [ 'test/loader.cpp' ] diff --git a/staging/smolblok/smolblok.cpp b/lib/smolblok/smolblok.cpp index 465c348..465c348 100644 --- a/staging/smolblok/smolblok.cpp +++ b/lib/smolblok/smolblok.cpp diff --git a/staging/smolblok/smolblok.hpp b/lib/smolblok/smolblok.hpp index e547d67..dc79232 100644 --- a/staging/smolblok/smolblok.hpp +++ b/lib/smolblok/smolblok.hpp @@ -10,9 +10,9 @@ #define SMOLBOTE_SMOLBLOK_HPP #include "filtermanager.hpp" +#include "smolbote/filterinterface.hpp" #include <QPluginLoader> #include <QWebEngineUrlRequestInterceptor> -#include <smolbote/filterinterface.hpp> class smolblok { @@ -56,7 +56,7 @@ public: return ret; } - const auto formats() const + auto formats() const { return m_formats.keys(); } diff --git a/staging/smolblok/test/loader.cpp b/lib/smolblok/test/loader.cpp index 9e27a26..9e27a26 100644 --- a/staging/smolblok/test/loader.cpp +++ b/lib/smolblok/test/loader.cpp diff --git a/staging/smolblok/test/main.cpp b/lib/smolblok/test/main.cpp index 5624ee9..5624ee9 100644 --- a/staging/smolblok/test/main.cpp +++ b/lib/smolblok/test/main.cpp diff --git a/staging/smolblok/test/sample-filters.txt b/lib/smolblok/test/sample-filters.txt index 59e0e7b..59e0e7b 100644 --- a/staging/smolblok/test/sample-filters.txt +++ b/lib/smolblok/test/sample-filters.txt diff --git a/meson.build b/meson.build index 8290125..926fe8b 100644 --- a/meson.build +++ b/meson.build @@ -89,9 +89,6 @@ dep_qt5 = dependency('qt5', dep_spdlog = dependency('spdlog', fallback: ['spdlog', 'spdlog_dep'], version: '>=1.3.1') -optional_deps = [] -poi_cpp_args = [] - dep_breakpad = dependency('breakpad-client', include_type: 'system', required: get_option('crashhandler')) dep_threads = dependency('threads', include_type: 'system', required: get_option('crashhandler')) @@ -111,6 +108,7 @@ subdir('lib/configuration') subdir('lib/downloads') subdir('lib/pluginloader') subdir('lib/session_formats') +subdir('lib/smolblok') subdir('src') subdir('lang') @@ -118,20 +116,18 @@ subdir('doc') subdir('tools') subdir('plugins/ProfileEditor') +subdir('plugins/HostlistFilter') +subdir('plugins/AdblockFilter') subdir('test/firefox-bookmarks-json-parser') -subdir('test/matcherbenchmark') - -subdir('staging/smolblok') -subdir('plugins/smolblok_hostlist') ssconfig = poi_sourceset.apply(cdata) poi_exe = executable(get_option('poi'), - cpp_args: ['-DQAPPLICATION_CLASS=QApplication', poi_cpp_args], + cpp_args: ['-DQAPPLICATION_CLASS=QApplication'], sources: [ssconfig.sources()], include_directories: [ plugininterfaces_include, include_directories('src') ], - dependencies: [ dep_qt5, dep_spdlog, dep_SingleApplication, dep_args, optional_deps, dep_bookmarks, dep_configuration, dep_downloads, dep_pluginloader, ssconfig.dependencies(), lib_session_formats ], + dependencies: [ dep_qt5, dep_spdlog, dep_SingleApplication, dep_args, dep_bookmarks, dep_configuration, dep_downloads, dep_pluginloader, ssconfig.dependencies(), lib_session_formats ], install: true, ) diff --git a/staging/adblock/filterlist.cpp b/plugins/AdblockFilter/filterlist.cpp index 1846ff6..76953fc 100644 --- a/staging/adblock/filterlist.cpp +++ b/plugins/AdblockFilter/filterlist.cpp @@ -26,7 +26,7 @@ const QLatin1String comment_expires("! Expires: "); using namespace AdblockPlus; -FilterList::FilterList(QIODevice &from) +Filterlist::Filterlist(QIODevice &from) { if(from.isReadable() && from.isTextModeEnabled()) { while(from.bytesAvailable() > 0) { @@ -46,7 +46,7 @@ FilterList::FilterList(QIODevice &from) } } -void FilterList::parseComment(const QString &line) +void Filterlist::parseComment(const QString &line) { if(line.startsWith(comment_lastModified)) { lastModified = QDateTime::fromString(line.mid(comment_lastModified.size()), "dd MMM yyyy HH:mm 'UTC'"); @@ -62,7 +62,7 @@ void FilterList::parseComment(const QString &line) } } -Rule *FilterList::parseRule(const QByteArray &line) +Rule *Filterlist::parseRule(const QByteArray &line) { QString pattern = line; Options opt; @@ -122,7 +122,7 @@ Rule *FilterList::parseRule(const QByteArray &line) return nullptr; } -bool FilterList::filter(QWebEngineUrlRequestInfo &info) const +bool Filterlist::filter(QWebEngineUrlRequestInfo &info) const { return false; } diff --git a/staging/adblock/filterlist.h b/plugins/AdblockFilter/filterlist.h index 24464c8..dba2138 100644 --- a/staging/adblock/filterlist.h +++ b/plugins/AdblockFilter/filterlist.h @@ -16,11 +16,11 @@ namespace AdblockPlus { -class FilterList : public Filter +class Filterlist : public FilterList { public: - explicit FilterList(QIODevice &from); - ~FilterList() + explicit Filterlist(QIODevice &from); + ~Filterlist() { qDeleteAll(m_rules); } diff --git a/staging/adblock/meson.build b/plugins/AdblockFilter/meson.build index 942f325..942f325 100644 --- a/staging/adblock/meson.build +++ b/plugins/AdblockFilter/meson.build diff --git a/staging/adblock/options.cpp b/plugins/AdblockFilter/options.cpp index 08f30ee..08f30ee 100644 --- a/staging/adblock/options.cpp +++ b/plugins/AdblockFilter/options.cpp diff --git a/staging/adblock/options.h b/plugins/AdblockFilter/options.h index efc47a6..efc47a6 100644 --- a/staging/adblock/options.h +++ b/plugins/AdblockFilter/options.h diff --git a/staging/adblock/plugin/AdblockPlusPlugin.json b/plugins/AdblockFilter/plugin/AdblockPlusPlugin.json index 053826a..053826a 100644 --- a/staging/adblock/plugin/AdblockPlusPlugin.json +++ b/plugins/AdblockFilter/plugin/AdblockPlusPlugin.json diff --git a/staging/adblock/plugin/plugin.cpp b/plugins/AdblockFilter/plugin/plugin.cpp index 028c83f..028c83f 100644 --- a/staging/adblock/plugin/plugin.cpp +++ b/plugins/AdblockFilter/plugin/plugin.cpp diff --git a/staging/adblock/plugin/plugin.h b/plugins/AdblockFilter/plugin/plugin.h index db419bd..db419bd 100644 --- a/staging/adblock/plugin/plugin.h +++ b/plugins/AdblockFilter/plugin/plugin.h diff --git a/staging/adblock/rule.h b/plugins/AdblockFilter/rule.h index aaab49a..aaab49a 100644 --- a/staging/adblock/rule.h +++ b/plugins/AdblockFilter/rule.h diff --git a/staging/adblock/test/filterlist.cpp b/plugins/AdblockFilter/test/filterlist.cpp index ca122ac..d3ec513 100644 --- a/staging/adblock/test/filterlist.cpp +++ b/plugins/AdblockFilter/test/filterlist.cpp @@ -16,7 +16,7 @@ TEST_CASE("placeholder") QBuffer buffer(&sampleList); buffer.open(QIODevice::ReadOnly | QIODevice::Text); - AdblockPlus::FilterList list(buffer); + AdblockPlus::Filterlist list(buffer); REQUIRE(!list.isUpToDate()); } @@ -32,7 +32,7 @@ TEST_CASE("domain match") const QString allow1 = "http://ads.example.com.ua/foo.gif"; const QString allow2 = "http://example.com/redirect/http://ads.example.com/"; - auto *rule = FilterList::parseRule("||ads.example.com^"); + auto *rule = Filterlist::parseRule("||ads.example.com^"); REQUIRE(rule->shouldBlock()); REQUIRE(!rule->shouldRedirect()); @@ -56,7 +56,7 @@ TEST_CASE("string equals") const QString allow1 = "http://example.com/foo.gif"; const QString allow2 = "http://example.info/redirect/http://example.com/"; - auto *rule = FilterList::parseRule("|http://example.com/|"); + auto *rule = Filterlist::parseRule("|http://example.com/|"); REQUIRE(rule->shouldBlock()); REQUIRE(!rule->shouldRedirect()); @@ -72,7 +72,7 @@ TEST_CASE("string starts with") { const QString defaultUrl = ""; - auto *rule = FilterList::parseRule("|http://baddomain.example/"); + auto *rule = Filterlist::parseRule("|http://baddomain.example/"); REQUIRE(rule->shouldBlock()); REQUIRE(!rule->shouldRedirect()); @@ -88,7 +88,7 @@ TEST_CASE("string ends with") { const QString defaultUrl = ""; - auto *rule = FilterList::parseRule("swf|"); + auto *rule = Filterlist::parseRule("swf|"); REQUIRE(rule->shouldBlock()); REQUIRE(!rule->shouldRedirect()); @@ -104,7 +104,7 @@ TEST_CASE("regular expressions") { const QString defaultUrl = ""; - auto *rule = FilterList::parseRule("/banner\\d+/"); + auto *rule = Filterlist::parseRule("/banner\\d+/"); const QString matches1 = "banner123"; const QString matches2 = "banner321"; diff --git a/staging/adblock/test/options.cpp b/plugins/AdblockFilter/test/options.cpp index 67dc143..67dc143 100644 --- a/staging/adblock/test/options.cpp +++ b/plugins/AdblockFilter/test/options.cpp diff --git a/staging/adblock/test/rule.cpp b/plugins/AdblockFilter/test/rule.cpp index 07186b9..07186b9 100644 --- a/staging/adblock/test/rule.cpp +++ b/plugins/AdblockFilter/test/rule.cpp diff --git a/plugins/smolblok_hostlist/corpus/apple.txt b/plugins/HostlistFilter/corpus/apple.txt index 3a8973b..3a8973b 100644 --- a/plugins/smolblok_hostlist/corpus/apple.txt +++ b/plugins/HostlistFilter/corpus/apple.txt diff --git a/plugins/smolblok_hostlist/corpus/banana.txt b/plugins/HostlistFilter/corpus/banana.txt index c30aa84..c30aa84 100644 --- a/plugins/smolblok_hostlist/corpus/banana.txt +++ b/plugins/HostlistFilter/corpus/banana.txt diff --git a/plugins/smolblok_hostlist/corpus/kiwi.txt b/plugins/HostlistFilter/corpus/kiwi.txt index 77c325c..77c325c 100644 --- a/plugins/smolblok_hostlist/corpus/kiwi.txt +++ b/plugins/HostlistFilter/corpus/kiwi.txt diff --git a/plugins/smolblok_hostlist/corpus/orange.txt b/plugins/HostlistFilter/corpus/orange.txt index 583273d..583273d 100644 --- a/plugins/smolblok_hostlist/corpus/orange.txt +++ b/plugins/HostlistFilter/corpus/orange.txt diff --git a/plugins/smolblok_hostlist/filterlist.cpp b/plugins/HostlistFilter/filterlist.cpp index a0fd414..a0fd414 100644 --- a/plugins/smolblok_hostlist/filterlist.cpp +++ b/plugins/HostlistFilter/filterlist.cpp diff --git a/plugins/smolblok_hostlist/filterlist.h b/plugins/HostlistFilter/filterlist.h index 7301f20..7301f20 100644 --- a/plugins/smolblok_hostlist/filterlist.h +++ b/plugins/HostlistFilter/filterlist.h diff --git a/plugins/smolblok_hostlist/meson.build b/plugins/HostlistFilter/meson.build index c9ff303..1562524 100644 --- a/plugins/smolblok_hostlist/meson.build +++ b/plugins/HostlistFilter/meson.build @@ -1,18 +1,11 @@ -lib_hostlistfilter = static_library('hostlistfilter', - [ 'filterlist.cpp' ], - include_directories: smolbote_interfaces, - dependencies: [dep_qt5] -) - dep_hostlistfilter = declare_dependency( include_directories: [ '.', smolbote_interfaces ], - link_with: lib_hostlistfilter + link_with: static_library('hostlistfilter', [ 'filterlist.cpp' ], include_directories: smolbote_interfaces, dependencies: [dep_qt5]) ) # plugin plugin = shared_library('smolblokHostlistPlugin', - [ 'plugin/plugin.cpp', - mod_qt5.preprocess(include_directories: smolbote_interfaces, moc_headers: 'plugin/plugin.h', dependencies: dep_qt5) ], + [ 'plugin/plugin.cpp', mod_qt5.preprocess(include_directories: smolbote_interfaces, moc_headers: 'plugin/plugin.h', dependencies: dep_qt5) ], include_directories: smolbote_interfaces, dependencies: [ dep_hostlistfilter, dep_qt5 ], install: true, diff --git a/plugins/smolblok_hostlist/plugin/plugin.cpp b/plugins/HostlistFilter/plugin/plugin.cpp index 28a7706..28a7706 100644 --- a/plugins/smolblok_hostlist/plugin/plugin.cpp +++ b/plugins/HostlistFilter/plugin/plugin.cpp diff --git a/plugins/smolblok_hostlist/plugin/plugin.h b/plugins/HostlistFilter/plugin/plugin.h index 53b5d36..53b5d36 100644 --- a/plugins/smolblok_hostlist/plugin/plugin.h +++ b/plugins/HostlistFilter/plugin/plugin.h diff --git a/plugins/smolblok_hostlist/plugin/smolblokHostlistPlugin.json b/plugins/HostlistFilter/plugin/smolblokHostlistPlugin.json index aa53cdd..aa53cdd 100644 --- a/plugins/smolblok_hostlist/plugin/smolblokHostlistPlugin.json +++ b/plugins/HostlistFilter/plugin/smolblokHostlistPlugin.json diff --git a/plugins/smolblok_hostlist/test/filterlist.cpp b/plugins/HostlistFilter/test/filterlist.cpp index 4aa532b..4aa532b 100644 --- a/plugins/smolblok_hostlist/test/filterlist.cpp +++ b/plugins/HostlistFilter/test/filterlist.cpp diff --git a/plugins/smolblok_hostlist/test/hostlist.txt b/plugins/HostlistFilter/test/hostlist.txt index a0b4e5c..a0b4e5c 100644 --- a/plugins/smolblok_hostlist/test/hostlist.txt +++ b/plugins/HostlistFilter/test/hostlist.txt diff --git a/plugins/smolblok_hostlist/test/plugin.cpp b/plugins/HostlistFilter/test/plugin.cpp index fad34f2..fad34f2 100644 --- a/plugins/smolblok_hostlist/test/plugin.cpp +++ b/plugins/HostlistFilter/test/plugin.cpp diff --git a/plugins/smolblok_hostlist/test/rule.cpp b/plugins/HostlistFilter/test/rule.cpp index b5ba6e0..b5ba6e0 100644 --- a/plugins/smolblok_hostlist/test/rule.cpp +++ b/plugins/HostlistFilter/test/rule.cpp diff --git a/src/browser.cpp b/src/browser.cpp index ff948e4..a04f87d 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -19,7 +19,6 @@ #include "smolbote/plugininterface.hpp" #include "subwindow/subwindow.h" #include "util.h" -#include "webengine/urlinterceptor.h" #include "webengine/webprofile.h" #include "webengine/webprofilemanager.h" #include "webengine/webview.h" @@ -70,6 +69,14 @@ Browser::Browser(int &argc, char *argv[], bool allowSecondary) } } + // content filter - register format plugins + if(const auto hostlist_plugin = conf.value<QString>("smolblok.plugins.hostlist")) { + content_filter.registerFormatPlugin("hostlist", hostlist_plugin.value()); + } + if(const auto adblock_plugin = conf.value<QString>("smolblok.plugins.adblock")) { + content_filter.registerFormatPlugin("adblock", adblock_plugin.value()); + } + // load profiles { const auto profiles = Util::files(conf.value<QString>("profile.path").value(), { "*.profile" }); @@ -92,6 +99,7 @@ Browser::Browser(int &argc, char *argv[], bool allowSecondary) // downloads m_downloads = std::make_unique<DownloadsWidget>(conf.value<QString>("downloads.path").value()); m_profileManager->walk([this](const QString &, WebProfile *profile, QSettings *) { + profile->setUrlRequestInterceptor(content_filter.interceptor()); connect(profile, &QWebEngineProfile::downloadRequested, m_downloads.get(), &DownloadsWidget::addDownload); }); diff --git a/src/browser.h b/src/browser.h index 0a0b201..69cf804 100644 --- a/src/browser.h +++ b/src/browser.h @@ -9,8 +9,9 @@ #ifndef SMOLBOTE_BROWSER_H #define SMOLBOTE_BROWSER_H -#include "webengine/webprofilemanager.h" +#include "smolblok.hpp" #include "smolbote/session.hpp" +#include "webengine/webprofilemanager.h" #include <QJsonObject> #include <QMenu> #include <QPluginLoader> @@ -79,6 +80,7 @@ private: std::shared_ptr<BookmarksWidget> m_bookmarks; std::unique_ptr<DownloadsWidget> m_downloads; std::unique_ptr<WebProfileManager<false>> m_profileManager{ nullptr }; + smolblok content_filter; QVector<MainWindow *> m_windows; QVector<PluginInfo *> m_plugins; |