-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathnetutils.cpp
79 lines (69 loc) · 2.43 KB
/
netutils.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
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "netutils.h"
#include <QMetaType>
#include <QDBusMetaType>
namespace dde {
namespace network {
Connectivity connectivityValue(uint sourceConnectivity)
{
switch (sourceConnectivity) {
case 0: return Connectivity::Unknownconnectivity;
case 1: return Connectivity::Noconnectivity;
case 2: return Connectivity::Portal;
case 3: return Connectivity::Limited;
case 4: return Connectivity::Full;
default: break;
}
return Connectivity::Unknownconnectivity;
}
DeviceStatus convertDeviceStatus(int sourceDeviceStatus)
{
switch (sourceDeviceStatus) {
case 0: return DeviceStatus::Unknown;
case 10: return DeviceStatus::Unmanaged;
case 20: return DeviceStatus::Unavailable;
case 30: return DeviceStatus::Disconnected;
case 40: return DeviceStatus::Prepare;
case 50: return DeviceStatus::Config;
case 60: return DeviceStatus::Needauth;
case 70: return DeviceStatus::IpConfig;
case 80: return DeviceStatus::IpCheck;
case 90: return DeviceStatus::Secondaries;
case 100: return DeviceStatus::Activated;
case 110: return DeviceStatus::Deactivation;
case 120: return DeviceStatus::Failed;
default: break;
}
return DeviceStatus::Unknown;
}
ConnectionStatus convertConnectionStatus(int sourceConnectionStatus)
{
switch (sourceConnectionStatus) {
case 0: return ConnectionStatus::Unknown;
case 1: return ConnectionStatus::Activating;
case 2: return ConnectionStatus::Activated;
case 3: return ConnectionStatus::Deactivating;
case 4: return ConnectionStatus::Deactivated;
default: return ConnectionStatus::Unknown;
}
}
ConnectionStatus convertStateFromNetworkManager(NetworkManager::ActiveConnection::State state)
{
switch (state) {
case NetworkManager::ActiveConnection::State::Activated:
return ConnectionStatus::Activated;
case NetworkManager::ActiveConnection::State::Activating:
return ConnectionStatus::Activating;
case NetworkManager::ActiveConnection::State::Deactivated:
return ConnectionStatus::Deactivated;
case NetworkManager::ActiveConnection::State::Deactivating:
return ConnectionStatus::Deactivating;
default:
break;
}
return ConnectionStatus::Deactivated;
}
}
}