/* * 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), }; typedef unsigned int signature_state_t; static signature_state_t signature_state(bool ignore, bool check, bool enforce) { return (static_cast(enforce) << 2) | (static_cast(check) << 1) | static_cast(ignore); } PluginLoader(const QString &fileName, const signature_state_t 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 int m_state; QString m_sigError; };