blob: cc67901b3e222e16e72acfed77c19b5af09aa6c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*
* 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 <QPluginLoader>
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<unsigned int>(enforce) << 2) | (static_cast<unsigned int>(check) << 1) | static_cast<unsigned int>(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 signature_state_t m_state;
QString m_sigError;
};
|