-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconnectionapi.h
166 lines (129 loc) · 3.58 KB
/
connectionapi.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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#ifndef CONNECTIONAPI_H
#define CONNECTIONAPI_H
#include <QObject>
#include "fbxapi.h"
/*! ConnectionStatus Object */
class ConnectionStatus{
public:
enum State{GoingUp, Up,GoingDown, Down };
enum Type{ Ethernet, Rfc2684, PPPoAtm};
enum Media { Ftth, XDsl};
static QString stateToString(State state){
switch (state){
case GoingUp: return "going_up";
case GoingDown: return "going_down";
case Up: return "up";
case Down: return "down";
}
return "down";
}
static QString typeToString(Type type){
switch (type){
case Ethernet: return "ethernet";
case Rfc2684: return "rfc2684";
case PPPoAtm: return "pppoatm";
}
return "unknown";
}
static QString mediaToString(Media media){
switch (media){
case Ftth:return "ftth";
case XDsl:return "xdsl";
}
return "unknown";
}
static Media mediaFromString(const QString& string){
if (string == "ftth")
return Ftth;
if (string == "xdsl")
return XDsl;
return Ftth;
}
static Type typeFromString(const QString& string){
if (string == "ethernet")
return Ethernet;
if (string == "rfc2684")
return Rfc2684;
if (string == "pppoatm")
return PPPoAtm;
return Ethernet;
}
static State stateFromString(const QString& string){
if (string == "going_up")
return GoingUp;
if (string == "going_down")
return GoingDown;
if (string == "up")
return Up;
if (string == "down")
return Down;
return GoingDown;
}
QString ipv4;
QString ipv6;
int rateUp;
int rateDown;
int rateUpPriv;
int rateDownPriv;
int bandwidthUp;
int bandwidthDown;
int bytesUp;
int bytesDown;
int bytesUpPriv;
int bytesDownPriv;
State state;
Type type;
Media media;
};
/*! ConnectionConfiguration Object */
class ConnectionConfiguration{
public:
bool ping;
bool isSecurePass; //ronly
bool remoteAccess;
int remoteAccessPort;
QString remoteAccessIp;//ronly
bool apiRemoteAccess;//ronly
bool wol;
bool adblock;
bool adblockNotSet;//ronly
bool allowTokenRequest;
};
/*! ConnectionIpv6Delegation Object */
class ConnectionIpv6Delegation{
public:
QString prefix;
QString nextHop; // next_hop ipv6 the next hop for the prefix.. Bizarre le type
};
class ConnectionIpv6Configuration{
public:
bool ipv6Enabled;
QList<ConnectionIpv6Delegation> delegations;
};
class ConnectionApi : public QObject
{
Q_OBJECT
public:
explicit ConnectionApi(QObject *parent = 0);
void requestStatus();
void requestConfiguration();
void requestUpdateConfigurationFinished(bool ping,
bool remoteAccess,
int remoteAccessPort,
bool wool,
bool adblock,
bool allowTokenRequest);
signals:
void statusReceived(const ConnectionStatus& status);
void configurationReceived(const ConnectionConfiguration& config);
void updateConfigurationFinished();
protected slots:
void requestStatusFinished();
void requestConfigurationFinished();
void requestUpdateConfigurationFinished();
protected:
FbxAPI * fbx() {
return qobject_cast<FbxAPI*>(parent());
}
};
#endif // CONNECTIONAPI_H