forked from Qv2ray/QvPlugin-Trojan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrojanPlugin.cpp
67 lines (57 loc) · 1.6 KB
/
TrojanPlugin.cpp
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
#include "TrojanPlugin.hpp"
#include "ui/TrojanOutboundEditor.hpp"
#include <QDateTime>
#include <QLabel>
#include <QMetaEnum>
std::shared_ptr<QvPluginKernel> TrojanPlugin::GetKernel()
{
return kernel;
}
bool TrojanPlugin::UpdateSettings(const QJsonObject &conf)
{
settings = conf;
return true;
}
bool TrojanPlugin::Initialize(const QString &, const QJsonObject &settings)
{
this->settings = settings;
serializer = std::make_shared<TrojanSerializer>(this);
eventHandler = std::make_shared<TrojanEventHandler>(this);
kernel = std::make_shared<TrojanKernel>(this);
return true;
}
const QJsonObject TrojanPlugin::GetSettngs()
{
return settings;
}
std::shared_ptr<QvPluginEventHandler> TrojanPlugin::GetEventHandler()
{
return eventHandler;
}
std::unique_ptr<QWidget> TrojanPlugin::GetSettingsWidget()
{
auto t = std::make_unique<QTextBrowser>();
t->setText("Qv2ray-Trojan plugin was ported from the Trojan-Qt5:"
"\r\n"
"Credits should also give to @TheWanderingCoel"
"\r\n"
"\r\n"
"Go and check more about Trojan-Qt5: "
"\r\n"
"https://github.com/TheWanderingCoel/Trojan-Qt5");
return t;
}
std::unique_ptr<QvPluginEditor> TrojanPlugin::GetEditorWidget(UI_TYPE type)
{
switch (type)
{
case UI_TYPE_INBOUND_EDITOR:
case UI_TYPE_GROUP_EDITOR: break;
case UI_TYPE_OUTBOUND_EDITOR: return std::make_unique<TrojanOutboundEditor>();
}
return nullptr;
}
std::shared_ptr<QvPluginSerializer> TrojanPlugin::GetSerializer()
{
return serializer;
}