Changeset View
Changeset View
Standalone View
Standalone View
libs/declarative/networkstatus.cpp
Show All 14 Lines | 1 | /* | |||
---|---|---|---|---|---|
15 | Lesser General Public License for more details. | 15 | Lesser General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU Lesser General Public | 17 | You should have received a copy of the GNU Lesser General Public | ||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "networkstatus.h" | 21 | #include "networkstatus.h" | ||
22 | #include "uiutils.h" | 22 | #include "uiutils.h" | ||
23 | | ||||
24 | #include <QDBusConnection> | 23 | #include <QDBusConnection> | ||
25 | 24 | | |||
26 | #include <NetworkManagerQt/ActiveConnection> | 25 | #include <NetworkManagerQt/ActiveConnection> | ||
27 | #include <NetworkManagerQt/Connection> | 26 | #include <NetworkManagerQt/Connection> | ||
28 | 27 | | |||
29 | #include <KLocalizedString> | 28 | #include <KLocalizedString> | ||
30 | 29 | | |||
31 | NetworkStatus::SortedConnectionType NetworkStatus::connectionTypeToSortedType(NetworkManager::ConnectionSettings::ConnectionType type) | 30 | NetworkStatus::SortedConnectionType NetworkStatus::connectionTypeToSortedType(NetworkManager::ConnectionSettings::ConnectionType type) | ||
Show All 24 Lines | 54 | case NetworkManager::ConnectionSettings::Vpn: | |||
56 | return NetworkStatus::Vpn; | 55 | return NetworkStatus::Vpn; | ||
57 | break; | 56 | break; | ||
58 | case NetworkManager::ConnectionSettings::Wired: | 57 | case NetworkManager::ConnectionSettings::Wired: | ||
59 | return NetworkStatus::Wired; | 58 | return NetworkStatus::Wired; | ||
60 | break; | 59 | break; | ||
61 | case NetworkManager::ConnectionSettings::Wireless: | 60 | case NetworkManager::ConnectionSettings::Wireless: | ||
62 | return NetworkStatus::Wireless; | 61 | return NetworkStatus::Wireless; | ||
63 | break; | 62 | break; | ||
63 | case NetworkManager::ConnectionSettings::WireGuard: | ||||
64 | return NetworkStatus::Wireguard; | ||||
65 | break; | ||||
64 | default: | 66 | default: | ||
65 | return NetworkStatus::Other; | 67 | return NetworkStatus::Other; | ||
66 | break; | 68 | break; | ||
67 | } | 69 | } | ||
68 | } | 70 | } | ||
69 | 71 | | |||
70 | NetworkStatus::NetworkStatus(QObject* parent) | 72 | NetworkStatus::NetworkStatus(QObject* parent) | ||
71 | : QObject(parent) | 73 | : QObject(parent) | ||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 154 | { | |||
164 | { | 166 | { | ||
165 | return NetworkStatus::connectionTypeToSortedType(left->type()) < NetworkStatus::connectionTypeToSortedType(right->type()); | 167 | return NetworkStatus::connectionTypeToSortedType(left->type()) < NetworkStatus::connectionTypeToSortedType(right->type()); | ||
166 | }); | 168 | }); | ||
167 | 169 | | |||
168 | for (const NetworkManager::ActiveConnection::Ptr &active : activeConnectionList) { | 170 | for (const NetworkManager::ActiveConnection::Ptr &active : activeConnectionList) { | ||
169 | if (!active->devices().isEmpty() && UiUtils::isConnectionTypeSupported(active->type())) { | 171 | if (!active->devices().isEmpty() && UiUtils::isConnectionTypeSupported(active->type())) { | ||
170 | 172 | | |||
171 | NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(active->devices().first()); | 173 | NetworkManager::Device::Ptr device = NetworkManager::findNetworkInterface(active->devices().first()); | ||
172 | if (device && device->type() != NetworkManager::Device::Generic && device->type() <= NetworkManager::Device::Team) { | 174 | if (device && ((device->type() != NetworkManager::Device::Generic && device->type() <= NetworkManager::Device::Team) | ||
175 | || device->type() == 29)) { // TODO: Change to WireGuard enum value when it is added | ||||
jgrulich: You can use now NetworkManager::Device::WireGuard. It should be part of NMQT 5.58 so we can use… | |||||
173 | bool connecting = false; | 176 | bool connecting = false; | ||
174 | bool connected = false; | 177 | bool connected = false; | ||
175 | QString conType; | 178 | QString conType; | ||
176 | QString status; | 179 | QString status; | ||
177 | NetworkManager::VpnConnection::Ptr vpnConnection; | 180 | NetworkManager::VpnConnection::Ptr vpnConnection; | ||
178 | 181 | | |||
179 | if (active->vpn()) { | 182 | if (active->vpn()) { | ||
180 | conType = i18n("VPN"); | 183 | conType = i18n("VPN"); | ||
Show All 12 Lines | |||||
193 | } else { | 196 | } else { | ||
194 | if (active->state() == NetworkManager::ActiveConnection::Activated) { | 197 | if (active->state() == NetworkManager::ActiveConnection::Activated) { | ||
195 | connected = true; | 198 | connected = true; | ||
196 | } else if (active->state() == NetworkManager::ActiveConnection::Activating) { | 199 | } else if (active->state() == NetworkManager::ActiveConnection::Activating) { | ||
197 | connecting = true; | 200 | connecting = true; | ||
198 | } | 201 | } | ||
199 | } | 202 | } | ||
200 | 203 | | |||
204 | if (active->type() == NetworkManager::ConnectionSettings::ConnectionType::WireGuard) { | ||||
205 | conType = i18n("WireGuard"); | ||||
206 | connected = true; | ||||
207 | } | ||||
208 | | ||||
201 | NetworkManager::Connection::Ptr connection = active->connection(); | 209 | NetworkManager::Connection::Ptr connection = active->connection(); | ||
202 | if (connecting) { | 210 | if (connecting) { | ||
203 | status = i18n("Connecting to %1", connection->name()); | 211 | status = i18n("Connecting to %1", connection->name()); | ||
204 | } else if (connected) { | 212 | } else if (connected) { | ||
205 | status = i18n("Connected to %1", connection->name()); | 213 | status = i18n("Connected to %1", connection->name()); | ||
206 | } | 214 | } | ||
207 | 215 | | |||
208 | if (!activeConnections.isEmpty()) { | 216 | if (!activeConnections.isEmpty()) { | ||
Show All 27 Lines |
You can use now NetworkManager::Device::WireGuard. It should be part of NMQT 5.58 so we can use it for Plasma 5.16.