-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathQvPluginProcessor.hpp
88 lines (77 loc) · 3.5 KB
/
QvPluginProcessor.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
#pragma once
#include "QvPluginInterfaceModels.hpp"
#include <QJsonObject>
#include <QObject>
#define __QVPLUGIN_EVENT_HANDLER_SIG(type) const ::Qv2rayPlugin::Events::type::EventObject &pluginEvent
#define __QVPLUGIN_DECL_EVENT_HANDLER(type) void ProcessEvent_##type(__QVPLUGIN_EVENT_HANDLER_SIG(type))
#define QvPlugin_EventHandler_Decl(type) __QVPLUGIN_DECL_EVENT_HANDLER(type) override
#define QvPlugin_EventHandler(className, type) void className::ProcessEvent_##type(__QVPLUGIN_EVENT_HANDLER_SIG(type))
namespace Qv2rayPlugin
{
class PluginOutboundHandler
{
public:
explicit PluginOutboundHandler(){};
virtual const QString SerializeOutbound(const QString &protocol, //
const QString &alias, //
const QString &groupName, //
const QJsonObject &object, //
const QJsonObject &streamSettings) const = 0;
virtual const QPair<QString, QJsonObject> DeserializeOutbound(const QString &link, QString *alias, QString *errorMessage) const = 0;
virtual const OutboundInfoObject GetOutboundInfo(const QString &protocol, const QJsonObject &outbound) const = 0;
virtual const void SetOutboundInfo(const QString &protocol, const OutboundInfoObject &info, QJsonObject &outbound) const = 0;
virtual const QList<QString> SupportedProtocols() const = 0;
virtual const QList<QString> SupportedLinkPrefixes() const = 0;
};
// Subscription Adapter fetches data from an online service.
class SubscriptionDecoder
{
public:
struct SubscriptionDecodeResult
{
QList<QString> links;
QList<QPair<QString, QJsonObject>> connections;
};
virtual ~SubscriptionDecoder(){};
virtual SubscriptionDecodeResult DecodeData(const QByteArray &) const = 0;
};
class SubscriptionInterface
{
public:
virtual QList<ProtocolInfoObject> SupportedSubscriptionTypes() const = 0;
virtual std::shared_ptr<SubscriptionDecoder> GetSubscriptionDecoder(const QString &type) const = 0;
};
class PluginKernel : public QObject
{
Q_OBJECT
public:
explicit PluginKernel() : QObject(){};
virtual ~PluginKernel(){};
virtual void SetConnectionSettings(const QMap<KernelOptionFlags, QVariant> &settings, const QJsonObject &connectionInfo) = 0;
virtual bool StartKernel() = 0;
virtual bool StopKernel() = 0;
virtual QString GetKernelName() const = 0;
//
signals:
void OnKernelCrashed(const QString &);
void OnKernelLogAvailable(const QString &);
void OnKernelStatsAvailable(quint64 upSpeed, quint64 downSpeed);
private:
QString __qvKernelId;
};
class PluginKernelInterface
{
public:
virtual std::unique_ptr<PluginKernel> CreateKernel() const = 0;
virtual QList<QString> GetKernelProtocols() const = 0;
};
class PluginEventHandler
{
public:
explicit PluginEventHandler(){};
virtual __QVPLUGIN_DECL_EVENT_HANDLER(ConnectionStats){ Q_UNUSED(pluginEvent) };
virtual __QVPLUGIN_DECL_EVENT_HANDLER(SystemProxy){ Q_UNUSED(pluginEvent) };
virtual __QVPLUGIN_DECL_EVENT_HANDLER(Connectivity){ Q_UNUSED(pluginEvent) };
virtual __QVPLUGIN_DECL_EVENT_HANDLER(ConnectionEntry){ Q_UNUSED(pluginEvent) };
};
} // namespace Qv2rayPlugin