diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-25 17:20:18 +0300 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2020-04-29 17:23:25 +0300 |
commit | 24a55ed0785b4ec02b69e3a7a3e36ee9a45cc458 (patch) | |
tree | 1dc30b013e6b0fc6fc0650207c6b6c21a0c8e141 | |
parent | Add libfuzzer test to libconfiguration (diff) | |
download | smolbote-24a55ed0785b4ec02b69e3a7a3e36ee9a45cc458.tar.xz |
Cleanup
- Don't run configuration fuzzer as test
- Remove plugins/ConfigurationEditor
- Move exported interfaces to include/smolbote
- Install plugin interfaces
-rw-r--r-- | include/meson.build | 7 | ||||
-rw-r--r-- | include/smolbote/filterinterface.hpp (renamed from include/filterinterface.h) | 19 | ||||
-rw-r--r-- | include/smolbote/plugininterface.hpp (renamed from include/plugininterface.h) | 12 | ||||
-rw-r--r-- | lib/configuration/meson.build | 7 | ||||
-rw-r--r-- | lib/session_formats/meson.build | 8 | ||||
-rw-r--r-- | meson.build | 5 | ||||
-rw-r--r-- | plugins/ConfigurationEditor/ConfigurationEditor.json | 5 | ||||
-rw-r--r-- | plugins/ConfigurationEditor/configurationeditorplugin.cpp | 45 | ||||
-rw-r--r-- | plugins/ConfigurationEditor/configurationeditorplugin.h | 28 | ||||
-rw-r--r-- | plugins/ConfigurationEditor/forms/configurationdialog.cpp | 50 | ||||
-rw-r--r-- | plugins/ConfigurationEditor/forms/configurationdialog.h | 34 | ||||
-rw-r--r-- | plugins/ConfigurationEditor/forms/configurationdialog.ui | 119 | ||||
-rw-r--r-- | plugins/ConfigurationEditor/meson.build | 13 | ||||
-rw-r--r-- | src/browser.cpp | 2 | ||||
-rw-r--r-- | src/builtins.h | 1 | ||||
-rw-r--r-- | src/main.cpp | 1 |
16 files changed, 26 insertions, 330 deletions
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/filterinterface.h b/include/smolbote/filterinterface.hpp index fb04e25..3bbddf2 100644 --- a/include/filterinterface.h +++ b/include/smolbote/filterinterface.hpp @@ -6,31 +6,34 @@ * SPDX-License-Identifier: MIT */ -#pragma once +#ifndef SMOLBOTE_SMOLBLOK_INTERFACE_HPP +#define SMOLBOTE_SMOLBLOK_INTERFACE_HPP #include <QWebEngineUrlRequestInfo> #include <QtPlugin> +#include <QIODevice> -class Filter +class FilterList { public: - virtual ~Filter() = default; + virtual ~FilterList() = default; - virtual void filter(QWebEngineUrlRequestInfo &info) const = 0; - - virtual bool isUpToDate() const = 0; + [[nodiscard]] virtual bool filter(QWebEngineUrlRequestInfo &info) const = 0; + [[nodiscard]] 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; + 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/plugininterface.h b/include/smolbote/plugininterface.hpp index 4c36d8a..5fa4530 100644 --- a/include/plugininterface.h +++ b/include/smolbote/plugininterface.hpp @@ -6,24 +6,20 @@ * SPDX-License-Identifier: MIT */ -#pragma once +#ifndef SMOLBOTE_PLUGIN_INTERFACE_HPP +#define SMOLBOTE_PLUGIN_INTERFACE_HPP #include <QtPlugin> -#include <QHash> -#include <memory> -#include <functional> -#include <QApplication> - -typedef QHash<QString, std::function<int()>> 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) + +#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 <QDialog> -#include <QHash> - -CommandHash_t ConfigurationEditorPlugin::commands() -{ - QHash<QString, std::function<int()>> 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 <QVector> -#include <plugininterface.h> - -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 <QKeySequenceEdit> -#include <QLineEdit> - -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 <QDialog> -#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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>ConfigurationDialog</class> - <widget class="QDialog" name="ConfigurationDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>800</width> - <height>600</height> - </rect> - </property> - <property name="windowTitle"> - <string>Configuration</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="settings_tab"> - <attribute name="title"> - <string>Settings</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QTreeWidget" name="settings_treeWidget"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <column> - <property name="text"> - <string>Name</string> - </property> - </column> - <column> - <property name="text"> - <string>Value</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="shortcuts_tab"> - <attribute name="title"> - <string>Shortcuts</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QTreeWidget" name="shortcuts_treeWidget"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <column> - <property name="text"> - <string notr="true">Name</string> - </property> - </column> - <column> - <property name="text"> - <string>Value</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ConfigurationDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>ConfigurationDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> 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 <QTimer> #include <QTranslator> #include <QVersionNumber> -#include <plugininterface.h> #include <pluginloader.h> #include <spdlog/spdlog.h> #include <version.h> 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 <args.hxx> -#include <plugininterface.h> typedef std::function<int(const std::string &, std::vector<std::string>::const_iterator, std::vector<std::string>::const_iterator)> subcommand_func; typedef std::unordered_map<std::string, subcommand_func> 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 <QStandardPaths> #include <iostream> #include <memory> -#include <plugininterface.h> #include <pluginloader.h> #include <spdlog/spdlog.h> |