/* * 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 */ #include class PluginLoader : public QPluginLoader { public: enum signature_level { SigIgnored = 1, SigChecked = (1 << 1), SigEnforced = (1 << 2), }; static constexpr signature_level signature_state(bool ignore, bool check, bool enforce) { return enforce ? signature_level::SigEnforced : (check ? signature_level::SigChecked : signature_level::SigIgnored); } PluginLoader(const QString &fileName, const signature_level state, QObject *parent = nullptr) : QPluginLoader(fileName, parent) , m_state(state) { } ~PluginLoader() override = default; PluginLoader(const PluginLoader &) = delete; PluginLoader &operator=(const PluginLoader &) = delete; PluginLoader(PluginLoader &&) = delete; PluginLoader &operator=(PluginLoader &&) = delete; [[nodiscard]] QString errorString() const { if(!m_sigError.isEmpty()) { return m_sigError; } return QPluginLoader::errorString(); } bool verify(const char *hashName = "SHA256"); private: const signature_level m_state; QString m_sigError; };