forked from linuxdeepin/dde-network-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvpncontroller.h
75 lines (56 loc) · 2.5 KB
/
vpncontroller.h
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
// SPDX-FileCopyrightText: 2018 - 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#ifndef VPNCONTROLLER_H
#define VPNCONTROLLER_H
#include "networkconst.h"
#include "netutils.h"
#include <QObject>
namespace dde {
namespace network {
class NetworkDBusProxy;
class VPNItem;
class VPNController : public QObject
{
Q_OBJECT
friend class NetworkInterProcesser;
friend class NetworkManagerProcesser;
public:
void setEnabled(const bool enabled); // 开启或者关闭VPN
inline bool enabled() const { return m_enabled; } // VPN开启还是关闭
void connectItem(VPNItem *item); // 连接VPN
void connectItem(const QString &uuid); // 连接VPN(重载函数)
void disconnectItem(); // 断开当前活动VPN连接
inline QList<VPNItem *> items() { return m_vpnItems; } // 获取所有的VPN列表
Q_SIGNALS:
void enableChanged(const bool); // 开启关闭VPN发出的信号
void itemAdded(const QList<VPNItem *> &); // 新增VPN发出的信号
void itemRemoved(const QList<VPNItem *> &); // 移除VPN发出的信号
void itemChanged(const QList<VPNItem *> &); // VPN项发生变化(ID)
void activeConnectionChanged(); // 活动连接发生变化的时候发出的信号
protected:
explicit VPNController(NetworkDBusProxy *networkInter, QObject *parent = Q_NULLPTR);
~VPNController();
void updateVPNItems(const QJsonArray &vpnArrays);
void updateActiveConnection(const QJsonObject &activeConection);
private:
VPNItem *findItem(const QString &path);
VPNItem *findItemByUuid(const QString &uuid);
private Q_SLOTS:
void onEnableChanged(const bool enabled);
private:
NetworkDBusProxy *m_networkInter;
bool m_enabled;
QList<VPNItem *> m_vpnItems;
QString m_activePath;
};
class VPNItem : public ControllItems
{
friend class VPNController;
protected:
VPNItem();
~VPNItem();
};
}
}
#endif // UVPNCONTROLLER_H