-
Notifications
You must be signed in to change notification settings - Fork 15
/
QvPluginBase.hpp
112 lines (99 loc) · 3.79 KB
/
QvPluginBase.hpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#pragma once
#include <QJsonObject>
#include <QObject>
#include <QString>
#include <QVariant>
#include <memory>
constexpr auto QV2RAY_PLUGIN_INTERFACE_VERSION = 3;
constexpr auto QV2RAY_PLUGIN_INTERNAL_PROPERTY_KEY = "_QV2RAY_PLUGIN_OPTIONS_";
namespace Qv2rayPlugin
{
enum GlobalPluginOptions
{
OPTION_SET_TLS_ALLOW_INSECURE Q_DECL_ENUMERATOR_DEPRECATED_X("Do not use this!") = 0,
OPTION_SET_TLS_SESSION_RESUMPTION Q_DECL_ENUMERATOR_DEPRECATED_X("Do not use this!") = 1,
OPTION_SET_TLS_DISABLE_SYSTEM_CERTS = 2
};
using Qv2rayPluginOption = QMap<GlobalPluginOptions, QVariant>;
enum PluginUpdateType
{
UPDATE_NONE = 0,
UPDATE_GITHUB_RELEASE = 1,
UPDATE_URL = 2
};
enum PluginGuiComponentType
{
GUI_COMPONENT_SETTINGS = 0,
GUI_COMPONENT_OUTBOUND_EDITOR = 1,
GUI_COMPONENT_INBOUND_EDITOR = 2,
GUI_COMPONENT_MAINWINDOW_WIDGET = 3
};
enum PluginComponentType
{
COMPONENT_EVENT_HANDLER = 0,
COMPONENT_GUI = 1,
COMPONENT_KERNEL = 2,
COMPONENT_OUTBOUND_HANDLER = 3,
COMPONENT_SUBSCRIPTION_ADAPTER = 4,
};
enum OutboundInfoFlags
{
INFO_DISPLAYNAME = 0,
INFO_PROTOCOL = 1,
INFO_SERVER = 2,
INFO_PORT = 3,
INFO_SNI = 4
};
enum KernelOptionFlags
{
KERNEL_HTTP_ENABLED,
KERNEL_HTTP_PORT,
KERNEL_SOCKS_ENABLED,
KERNEL_SOCKS_PORT,
KERNEL_SOCKS_UDP_ENABLED,
KERNEL_SOCKS_LOCAL_ADDRESS,
KERNEL_LISTEN_ADDRESS
};
struct ProtocolInfoObject
{
public:
QString protocol;
QString displayName;
explicit ProtocolInfoObject(){};
explicit ProtocolInfoObject(const QString &protocol, const QString &displayName) : protocol(protocol), displayName(displayName){};
friend bool operator==(const ProtocolInfoObject &l, const ProtocolInfoObject &r)
{
return l.protocol == r.protocol && l.displayName == r.displayName;
}
};
typedef QMap<OutboundInfoFlags, QVariant> OutboundInfoObject;
struct QvPluginMetadata
{
QString Name;
QString Author;
QString InternalName;
QString Description;
QString VersionString;
QString UpdateLocation;
PluginUpdateType UpdateType;
QList<PluginComponentType> Components;
QvPluginMetadata(const QString &name, //
const QString &author, //
const QString &internalName, //
const QString &description, //
const QString &versionString, //
const QString &updateUrl, //
const QList<PluginComponentType> &supportedComponents, //
const PluginUpdateType updateType) //
: Name(name), //
Author(author), //
InternalName(internalName), //
Description(description), //
VersionString(versionString), //
UpdateLocation(updateUrl), //
UpdateType(updateType), //
Components(supportedComponents){}; //
QvPluginMetadata(){};
};
} // namespace Qv2rayPlugin
Q_DECLARE_METATYPE(Qv2rayPlugin::Qv2rayPluginOption);