From 24a55ed0785b4ec02b69e3a7a3e36ee9a45cc458 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sat, 25 Apr 2020 17:20:18 +0300 Subject: Cleanup - Don't run configuration fuzzer as test - Remove plugins/ConfigurationEditor - Move exported interfaces to include/smolbote - Install plugin interfaces --- include/filterinterface.h | 36 ------- include/meson.build | 7 +- include/plugininterface.h | 29 ----- include/smolbote/filterinterface.hpp | 39 +++++++ include/smolbote/plugininterface.hpp | 25 +++++ lib/configuration/meson.build | 7 +- lib/session_formats/meson.build | 8 +- meson.build | 5 +- .../ConfigurationEditor/ConfigurationEditor.json | 5 - .../configurationeditorplugin.cpp | 45 -------- .../configurationeditorplugin.h | 28 ----- .../forms/configurationdialog.cpp | 50 --------- .../forms/configurationdialog.h | 34 ------ .../forms/configurationdialog.ui | 119 --------------------- plugins/ConfigurationEditor/meson.build | 13 --- src/browser.cpp | 2 +- src/builtins.h | 1 - src/main.cpp | 1 - 18 files changed, 75 insertions(+), 379 deletions(-) delete mode 100644 include/filterinterface.h delete mode 100644 include/plugininterface.h create mode 100644 include/smolbote/filterinterface.hpp create mode 100644 include/smolbote/plugininterface.hpp delete mode 100644 plugins/ConfigurationEditor/ConfigurationEditor.json delete mode 100644 plugins/ConfigurationEditor/configurationeditorplugin.cpp delete mode 100644 plugins/ConfigurationEditor/configurationeditorplugin.h delete mode 100644 plugins/ConfigurationEditor/forms/configurationdialog.cpp delete mode 100644 plugins/ConfigurationEditor/forms/configurationdialog.h delete mode 100644 plugins/ConfigurationEditor/forms/configurationdialog.ui delete mode 100644 plugins/ConfigurationEditor/meson.build diff --git a/include/filterinterface.h b/include/filterinterface.h deleted file mode 100644 index fb04e25..0000000 --- a/include/filterinterface.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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: MIT - */ - -#pragma once - -#include -#include - -class Filter -{ -public: - virtual ~Filter() = default; - - virtual void filter(QWebEngineUrlRequestInfo &info) const = 0; - - virtual bool isUpToDate() const = 0; -}; - -// A class to provide filter interfaces -class QIODevice; -class FilterPlugin -{ -public: - virtual ~FilterPlugin() = default; - - virtual Filter* load(QIODevice* from) const = 0; -}; - -#define FilterPluginIid "net.iserlohn-fortress.smolbote.FilterPlugin" -Q_DECLARE_INTERFACE(FilterPlugin, FilterPluginIid) - diff --git a/include/meson.build b/include/meson.build index c2bf758..7601966 100644 --- a/include/meson.build +++ b/include/meson.build @@ -1,6 +1,5 @@ -dep_plugininterface = declare_dependency( - include_directories: include_directories('.') -) +plugininterfaces_include = include_directories('.') -plugininterface_include = include_directories('.') +install_headers('smolbote/filterinterface.hpp', 'smolbote/plugininterface.hpp', + subdir: 'smolbote') diff --git a/include/plugininterface.h b/include/plugininterface.h deleted file mode 100644 index 4c36d8a..0000000 --- a/include/plugininterface.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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: MIT - */ - -#pragma once - -#include -#include -#include -#include -#include - -typedef QHash> CommandHash_t; - -class QDialog; -class PluginInterface -{ -public: - virtual ~PluginInterface() = default; - virtual CommandHash_t commands() = 0; - virtual QDialog *createWidget(QWidget *parent = nullptr) const = 0; -}; - -#define PluginInterfaceIid "net.iserlohn-fortress.smolbote.PluginInterface" -Q_DECLARE_INTERFACE(PluginInterface, PluginInterfaceIid) diff --git a/include/smolbote/filterinterface.hpp b/include/smolbote/filterinterface.hpp new file mode 100644 index 0000000..3bbddf2 --- /dev/null +++ b/include/smolbote/filterinterface.hpp @@ -0,0 +1,39 @@ +/* + * 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: MIT + */ + +#ifndef SMOLBOTE_SMOLBLOK_INTERFACE_HPP +#define SMOLBOTE_SMOLBLOK_INTERFACE_HPP + +#include +#include +#include + +class FilterList +{ +public: + virtual ~FilterList() = default; + + [[nodiscard]] virtual bool filter(QWebEngineUrlRequestInfo &info) const = 0; + [[nodiscard]] virtual bool isUpToDate() const = 0; +}; + +// A class to provide filter interfaces +class FilterPlugin +{ +public: + virtual ~FilterPlugin() = default; + + virtual FilterList *load(QIODevice&) const = 0; + virtual bool parse(FilterList *list, QIODevice &) const = 0; +}; + +#define FilterPluginIid "net.iserlohn-fortress.smolbote.FilterPlugin" +Q_DECLARE_INTERFACE(FilterPlugin, FilterPluginIid) + +#endif // SMOLBOTE_SMOLBLOK_INTERFACE_HPP + diff --git a/include/smolbote/plugininterface.hpp b/include/smolbote/plugininterface.hpp new file mode 100644 index 0000000..5fa4530 --- /dev/null +++ b/include/smolbote/plugininterface.hpp @@ -0,0 +1,25 @@ +/* + * 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: MIT + */ + +#ifndef SMOLBOTE_PLUGIN_INTERFACE_HPP +#define SMOLBOTE_PLUGIN_INTERFACE_HPP + +#include + +class QDialog; +class PluginInterface +{ +public: + virtual ~PluginInterface() = default; + virtual QDialog *createWidget(QWidget *parent = nullptr) const = 0; +}; + +#define PluginInterfaceIid "net.iserlohn-fortress.smolbote.PluginInterface" +Q_DECLARE_INTERFACE(PluginInterface, PluginInterfaceIid) + +#endif // SMOLBOTE_PLUGIN_INTERFACE_HPP diff --git a/lib/configuration/meson.build b/lib/configuration/meson.build index 59ddb7a..0ef6f5f 100644 --- a/lib/configuration/meson.build +++ b/lib/configuration/meson.build @@ -13,10 +13,9 @@ test('conf parser', executable('configuration-parser', ) if meson.get_compiler('cpp').has_multi_arguments('-g', '-fsanitize=fuzzer') -test('conf fuzzer', executable('configuration-fuzzer', +executable('configuration-fuzzer', sources: 'configuration.cpp', cpp_args: [ '-g', '-fsanitize=fuzzer', '-DNO_QT_SPEC', '-DFUZZER' ], - link_args: [ '-fsanitize=fuzzer' ]), - args: [ '-seed=1', '-max_total_time=24', meson.current_source_dir()/'test/corpus' ] -) + link_args: [ '-fsanitize=fuzzer' ]) +# args: [ '-seed=1', '-max_total_time=24', meson.current_source_dir()/'test/corpus' ] endif diff --git a/lib/session_formats/meson.build b/lib/session_formats/meson.build index 9abf5a2..8d52455 100644 --- a/lib/session_formats/meson.build +++ b/lib/session_formats/meson.build @@ -1,10 +1,6 @@ lib_session_formats = declare_dependency( - include_directories: [ '.', include ], - link_with: library('sessionformats', - [ 'session_json.cpp' ], - include_directories: include, - dependencies: dep_qt5 - ) + include_directories: [ '.', plugininterfaces_include ], + link_with: library('sessionformats', [ 'session_json.cpp' ], include_directories: plugininterfaces_include, dependencies: dep_qt5) ) test('session: json format', executable('session_json', diff --git a/meson.build b/meson.build index f2a51bc..adee6c2 100644 --- a/meson.build +++ b/meson.build @@ -70,7 +70,6 @@ dep_SingleApplication = dependency('singleapplication', fallback: [ 'singleappli dep_args = dependency('args.hxx', fallback: [ 'args', 'args_dep' ]) # Generate config header -include = include_directories('include') poi_sourceset = sourceset.source_set() @@ -98,8 +97,8 @@ ssconfig = poi_sourceset.apply(cdata) poi_exe = executable(get_option('poi'), cpp_args: ['-DQAPPLICATION_CLASS=QApplication', poi_cpp_args], sources: [ssconfig.sources()], - include_directories: [include, include_directories('src')], - dependencies: [ dep_qt5, dep_spdlog, dep_SingleApplication, dep_args, optional_deps, dep_bookmarks, dep_configuration, dep_downloads, dep_pluginloader, dep_urlfilter, dep_plugininterface, ssconfig.dependencies(), lib_session_formats ], + 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, dep_urlfilter, ssconfig.dependencies(), lib_session_formats ], install: true, ) diff --git a/plugins/ConfigurationEditor/ConfigurationEditor.json b/plugins/ConfigurationEditor/ConfigurationEditor.json deleted file mode 100644 index 5c9d504..0000000 --- a/plugins/ConfigurationEditor/ConfigurationEditor.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Configuration Editor", - "author": "Aqua-sama", - "shortcut": "Ctrl+Shift+C" -} diff --git a/plugins/ConfigurationEditor/configurationeditorplugin.cpp b/plugins/ConfigurationEditor/configurationeditorplugin.cpp deleted file mode 100644 index 1f60cc0..0000000 --- a/plugins/ConfigurationEditor/configurationeditorplugin.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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://neueland.iserlohn-fortress.net/gitea/aqua/smolbote - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "configurationeditorplugin.h" -#include "forms/configurationdialog.h" -#include -#include - -CommandHash_t ConfigurationEditorPlugin::commands() -{ - QHash> hash; - - hash.insert("configure", [this]() -> int { - auto *dlg = createWidget(nullptr); - return dlg->exec(); - }); - - return hash; -} - -QDialog *ConfigurationEditorPlugin::createWidget(QWidget *parent) const -{ - auto *app = browser(); - Q_CHECK_PTR(app); - - auto *dlg = new ConfigurationDialog(parent); - dlg->setAttribute(Qt::WA_DeleteOnClose, true); - - for(const QString &key : app->configurationOptions()) { - dlg->addOption(key, app->configuration(key)); - } - dlg->ui->settings_treeWidget->resizeColumnToContents(0); - dlg->ui->shortcuts_treeWidget->resizeColumnToContents(0); - - connect(dlg, &ConfigurationDialog::configurationChanged, dlg, [app](const QString &key, const QString &value) { - app->setConfiguration(key, value); - }); - - return dlg; -} diff --git a/plugins/ConfigurationEditor/configurationeditorplugin.h b/plugins/ConfigurationEditor/configurationeditorplugin.h deleted file mode 100644 index 7e7ebc6..0000000 --- a/plugins/ConfigurationEditor/configurationeditorplugin.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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://neueland.iserlohn-fortress.net/gitea/aqua/smolbote - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#ifndef CONFIGURATIONEDITOR_PLUGIN_H -#define CONFIGURATIONEDITOR_PLUGIN_H - -#include -#include - -class QDialog; -class ConfigurationEditorPlugin : public QObject, public PluginInterface -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID PluginInterfaceIid FILE "ConfigurationEditor.json") - Q_INTERFACES(PluginInterface) - -public: - // PluginInterface - CommandHash_t commands() override; - QDialog *createWidget(QWidget *parent = nullptr) const override; -}; - -#endif // CONFIGURATIONEDITOR_PLUGIN_H diff --git a/plugins/ConfigurationEditor/forms/configurationdialog.cpp b/plugins/ConfigurationEditor/forms/configurationdialog.cpp deleted file mode 100644 index f433d70..0000000 --- a/plugins/ConfigurationEditor/forms/configurationdialog.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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://neueland.iserlohn-fortress.net/gitea/aqua/smolbote - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#include "configurationdialog.h" -#include -#include - -ConfigurationDialog::ConfigurationDialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::ConfigurationDialog) -{ - ui->setupUi(this); -} - -ConfigurationDialog::~ConfigurationDialog() -{ - delete ui; -} - -void ConfigurationDialog::addOption(const QString &key, const QString &value) -{ - QTreeWidgetItem *item = nullptr; - - if(key.contains(QLatin1Literal("shortcut"))) { - item = new QTreeWidgetItem(ui->shortcuts_treeWidget); - - auto *edit = new QKeySequenceEdit(value); - ui->shortcuts_treeWidget->setItemWidget(item, 1, edit); - - connect(edit, &QKeySequenceEdit::keySequenceChanged, this, [this, key](const QKeySequence &keySequence) { - emit configurationChanged(key, keySequence.toString()); - }); - - } else { - item = new QTreeWidgetItem(ui->settings_treeWidget); - - auto *edit = new QLineEdit(value); - ui->settings_treeWidget->setItemWidget(item, 1, edit); - - connect(edit, &QLineEdit::editingFinished, this, [this, key, edit]() { - emit configurationChanged(key, edit->text()); - }); - } - item->setText(0, key); -} diff --git a/plugins/ConfigurationEditor/forms/configurationdialog.h b/plugins/ConfigurationEditor/forms/configurationdialog.h deleted file mode 100644 index fd07aa8..0000000 --- a/plugins/ConfigurationEditor/forms/configurationdialog.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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://neueland.iserlohn-fortress.net/gitea/aqua/smolbote - * - * SPDX-License-Identifier: GPL-3.0 - */ - -#ifndef CONFIGURATIONDIALOG_H -#define CONFIGURATIONDIALOG_H - -#include -#include "ui_configurationdialog.h" - -class ConfigurationDialog : public QDialog -{ - Q_OBJECT - - friend class ConfigurationEditorPlugin; - -public: - explicit ConfigurationDialog(QWidget *parent = nullptr); - ~ConfigurationDialog(); - - void addOption(const QString &key, const QString &value); - -signals: - void configurationChanged(const QString &key, const QString &value); - -private: - Ui::ConfigurationDialog *ui; -}; - -#endif // CONFIGURATIONDIALOG_H diff --git a/plugins/ConfigurationEditor/forms/configurationdialog.ui b/plugins/ConfigurationEditor/forms/configurationdialog.ui deleted file mode 100644 index 738d4a1..0000000 --- a/plugins/ConfigurationEditor/forms/configurationdialog.ui +++ /dev/null @@ -1,119 +0,0 @@ - - - ConfigurationDialog - - - - 0 - 0 - 800 - 600 - - - - Configuration - - - - - - 0 - - - - Settings - - - - - - QAbstractItemView::NoEditTriggers - - - - Name - - - - - Value - - - - - - - - - Shortcuts - - - - - - QAbstractItemView::NoEditTriggers - - - - Name - - - - - Value - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - - - - buttonBox - accepted() - ConfigurationDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - ConfigurationDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/plugins/ConfigurationEditor/meson.build b/plugins/ConfigurationEditor/meson.build deleted file mode 100644 index 96acccc..0000000 --- a/plugins/ConfigurationEditor/meson.build +++ /dev/null @@ -1,13 +0,0 @@ -ConfigurationEditorPlugin_moc = mod_qt5.preprocess( - include_directories: include, - moc_headers: ['configurationeditorplugin.h', 'forms/configurationdialog.h'], - ui_files: ['forms/configurationdialog.ui'], - dependencies: dep_qt5 -) - -ConfigurationEditorPlugin_lib = shared_library('ConfigurationEditorPlugin', - [interfaces_moc, ConfigurationEditorPlugin_moc, 'configurationeditorplugin.cpp', 'forms/configurationdialog.cpp'], - dependencies: dep_qt5, - include_directories: include, - install: true, install_dir: join_paths(get_option('libdir'), 'smolbote/plugins') -) diff --git a/src/browser.cpp b/src/browser.cpp index 3c39ec7..c55120d 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -17,6 +17,7 @@ #include "mainwindow/addressbar.h" #include "mainwindow/mainwindow.h" #include "mainwindow/menubar.h" +#include "smolbote/plugininterface.hpp" #include "subwindow/subwindow.h" #include "urlfilter.h" #include "util.h" @@ -36,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/src/builtins.h b/src/builtins.h index f805f6b..cdf6642 100644 --- a/src/builtins.h +++ b/src/builtins.h @@ -10,7 +10,6 @@ #define SMOLBOTE_BUILTINS_H #include -#include typedef std::function::const_iterator, std::vector::const_iterator)> subcommand_func; typedef std::unordered_map command_map; diff --git a/src/main.cpp b/src/main.cpp index 9ceda77..ca85b65 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include -- cgit v1.2.1