-
Notifications
You must be signed in to change notification settings - Fork 15
/
QvPluginInterface.hpp
77 lines (69 loc) · 2.46 KB
/
QvPluginInterface.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
#pragma once
#include "QvPluginBase.hpp"
#include "QvPluginProcessor.hpp"
namespace Qv2rayPlugin
{
class PluginGUIInterface;
class QvPluginEditor;
class QvPluginSettingsWidget;
class PluginKernelInterface;
class Qv2rayInterface;
class Qv2rayInterface
{
friend class PluginOutboundHandler;
friend class PluginKernel;
friend class PluginEventHandler;
friend class PluginGUIInterface;
public:
const int QvPluginInterfaceVersion = QV2RAY_PLUGIN_INTERFACE_VERSION;
virtual ~Qv2rayInterface() = default;
virtual const QvPluginMetadata GetMetadata() const = 0;
virtual bool InitializePlugin(const QString &, const QJsonObject &) = 0;
//
virtual std::shared_ptr<PluginOutboundHandler> GetOutboundHandler() const final
{
return outboundHandler;
}
virtual std::shared_ptr<PluginEventHandler> GetEventHandler() const final
{
return eventHandler;
}
virtual std::shared_ptr<PluginKernelInterface> GetKernel() const final
{
return kernelInterface;
}
virtual std::shared_ptr<SubscriptionInterface> GetSubscriptionAdapter() const final
{
return subscriptionAdapter;
}
virtual PluginGUIInterface *GetGUIInterface() const final
{
return guiInterface;
}
//
// Signals
virtual void PluginLog(const QString &) const = 0;
virtual void PluginErrorMessageBox(const QString &title, const QString &message) const = 0;
virtual void UpdateSettings(const QJsonObject &_settings) final
{
settings = _settings;
}
virtual const QJsonObject GetSettngs() const final
{
return settings;
}
protected:
explicit Qv2rayInterface(){};
QJsonObject settings;
std::shared_ptr<PluginOutboundHandler> outboundHandler;
std::shared_ptr<PluginEventHandler> eventHandler;
std::shared_ptr<PluginKernelInterface> kernelInterface;
std::shared_ptr<SubscriptionInterface> subscriptionAdapter;
PluginGUIInterface *guiInterface;
};
} // namespace Qv2rayPlugin
#define DECLARE_PLUGIN_INSTANCE(CLASS) inline CLASS *CLASS##Instance
QT_BEGIN_NAMESPACE
#define Qv2rayInterface_IID "com.github.Qv2ray.Qv2rayPluginInterface"
Q_DECLARE_INTERFACE(Qv2rayPlugin::Qv2rayInterface, Qv2rayInterface_IID)
QT_END_NAMESPACE