NetworkManagerQt

manager.cpp
1/*
2 SPDX-FileCopyrightText: 2008, 2010 Will Stephenson <wstephenson@kde.org>
3 SPDX-FileCopyrightText: 2011-2013 Lamarque Souza <lamarque@kde.org>
4 SPDX-FileCopyrightText: 2013 Daniel Nicoletti <dantti12@gmail.com>
5 SPDX-FileCopyrightText: 2013 Jan Grulich <jgrulich@redhat.com>
6
7 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
8*/
9
10#include "manager.h"
11#include "manager_p.h"
12
13#include "macros.h"
14
15#undef signals
16#include <libnm/NetworkManager.h>
17#define signals Q_SIGNALS
18
19#include "adsldevice.h"
20#include "bluetoothdevice.h"
21#include "bonddevice.h"
22#include "bridgedevice.h"
23#include "dbus/deviceinterface.h"
24#include "device_p.h"
25#include "genericdevice.h"
26#include "gredevice.h"
27#include "infinibanddevice.h"
28#include "iptunneldevice.h"
29#include "macvlandevice.h"
30#include "modemdevice.h"
31#include "olpcmeshdevice.h"
32#include "settings.h"
33#include "settings_p.h"
34#include "tundevice.h"
35#include "vethdevice.h"
36#include "vlandevice.h"
37#include "vpnconnection.h"
38#include "wimaxdevice.h"
39#include "wireddevice.h"
40#include "wireguarddevice.h"
41#include "wirelessdevice.h"
42
43#include "nmdebug.h"
44
45#include <QDBusMetaType>
46#include <QDBusReply>
47#include <QTimer>
48
49#define DBUS_OBJECT_MANAGER "org.freedesktop.DBus.ObjectManager"
50#define DBUS_PROPERTIES "org.freedesktop.DBus.Properties"
51
52#ifdef NMQT_STATIC
53const QString NetworkManager::NetworkManagerPrivate::DBUS_SERVICE(QString::fromLatin1("org.kde.fakenetwork"));
54const QString NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH(QString::fromLatin1("/org/kde/fakenetwork"));
55const QString NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_INTERFACE(QString::fromLatin1("org.kde.fakenetwork"));
56const QString NetworkManager::NetworkManagerPrivate::DBUS_SETTINGS_PATH(QString::fromLatin1("/org/kde/fakenetwork/Settings"));
57#else
58const QString NetworkManager::NetworkManagerPrivate::DBUS_SERVICE(QString::fromLatin1(NM_DBUS_SERVICE));
59const QString NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH(QString::fromLatin1(NM_DBUS_PATH));
60const QString NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_INTERFACE(QString::fromLatin1(NM_DBUS_INTERFACE));
61const QString NetworkManager::NetworkManagerPrivate::DBUS_SETTINGS_PATH(QString::fromLatin1(NM_DBUS_PATH_SETTINGS));
62#endif
63const QString NetworkManager::NetworkManagerPrivate::FDO_DBUS_PROPERTIES(QString::fromLatin1(DBUS_PROPERTIES));
64const QString NetworkManager::NetworkManagerPrivate::FDO_DBUS_OBJECT_MANAGER(QString::fromLatin1(DBUS_OBJECT_MANAGER));
65
66Q_GLOBAL_STATIC(NetworkManager::NetworkManagerPrivate, globalNetworkManager)
67
68NetworkManager::NetworkManagerPrivate::NetworkManagerPrivate()
69#ifdef NMQT_STATIC
71 , iface(NetworkManager::NetworkManagerPrivate::DBUS_SERVICE, NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH, QDBusConnection::sessionBus())
72#else
74 , iface(NetworkManager::NetworkManagerPrivate::DBUS_SERVICE, NetworkManager::NetworkManagerPrivate::DBUS_DAEMON_PATH, QDBusConnection::systemBus())
75#endif
78 , m_isNetworkingEnabled(false)
79 , m_isWimaxEnabled(false)
80 , m_isWimaxHardwareEnabled(false)
81 , m_isWirelessEnabled(false)
82 , m_isWirelessHardwareEnabled(false)
83 , m_isWwanEnabled(false)
84 , m_isWwanHardwareEnabled(false)
85 , m_isConnectivityCheckAvailable(false)
86 , m_isConnectivityCheckEnabled(false)
87 , m_globalDnsConfiguration(NetworkManager::DnsConfiguration())
88 , m_supportedInterfaceTypes(NetworkManager::Device::UnknownType)
89{
90 connect(&iface, &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &NetworkManagerPrivate::onDeviceAdded);
91 connect(&iface, &OrgFreedesktopNetworkManagerInterface::DeviceRemoved, this, &NetworkManagerPrivate::onDeviceRemoved);
92
93#ifndef NMQT_STATIC
94 QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE,
95 NetworkManagerPrivate::DBUS_DAEMON_PATH,
96 NetworkManagerPrivate::FDO_DBUS_PROPERTIES,
97 QLatin1String("PropertiesChanged"),
98 this,
99 SLOT(dbusPropertiesChanged(QString, QVariantMap, QStringList)));
100#else
101 connect(&iface, &OrgFreedesktopNetworkManagerInterface::PropertiesChanged, this, &NetworkManagerPrivate::propertiesChanged);
102#endif
103
104 // We register two listeners here:
105 // - a ServiceRegistered listener for newer NM versions that connect to the bus when the interfaces
106 // we care about are already initialized
107 // - and an InterfaceAdded listener for older NM versions that connect to the bus early,
108 // and then add interfaces dynamically
109 iface.connection().connect(NetworkManagerPrivate::DBUS_SERVICE,
110 "/org/freedesktop",
111 NetworkManagerPrivate::FDO_DBUS_OBJECT_MANAGER,
112 QLatin1String("InterfacesAdded"),
113 this,
114 SLOT(dbusInterfacesAdded(QDBusObjectPath, QVariantMap)));
115
116 connect(&watcher, &QDBusServiceWatcher::serviceRegistered, this, &NetworkManagerPrivate::daemonRegistered);
117 connect(&watcher, &QDBusServiceWatcher::serviceUnregistered, this, &NetworkManagerPrivate::daemonUnregistered);
118
119 init();
120}
121
122void NetworkManager::NetworkManagerPrivate::parseVersion(const QString &version)
123{
124 const QStringList sl = version.split('.');
125
126 if (sl.size() > 2) {
127 m_x = sl[0].toInt();
128 m_y = sl[1].toInt();
129 m_z = sl[2].toInt();
130 } else {
131 m_x = -1;
132 m_y = -1;
133 m_z = -1;
134 }
135}
136
137void NetworkManager::NetworkManagerPrivate::init()
138{
139 qDBusRegisterMetaType<UIntList>();
140 qDBusRegisterMetaType<UIntListList>();
141 // qDBusRegisterMetaType<IpV6DBusAddress>();
142 // qDBusRegisterMetaType<IpV6DBusAddressList>();
143 // qDBusRegisterMetaType<IpV6DBusNameservers>();
144 // qDBusRegisterMetaType<IpV6DBusRoute>();
145 // qDBusRegisterMetaType<IpV6DBusRouteList>();
146 qDBusRegisterMetaType<QList<QDBusObjectPath>>();
147 qDBusRegisterMetaType<DeviceDBusStateReason>();
148 qDBusRegisterMetaType<NMVariantMapMap>();
149 qDBusRegisterMetaType<NMVariantMapList>();
150 qDBusRegisterMetaType<NMStringMap>();
151
152 m_version = iface.version();
153 parseVersion(m_version);
154 /* clang-format off */
155 m_supportedInterfaceTypes = static_cast<NetworkManager::Device::Types>(
174 /* clang-format on */
175
176 // Get all Manager's properties async
177 QVariantMap initialProperties = retrieveInitialProperties(iface.staticInterfaceName(), DBUS_DAEMON_PATH);
178 if (!initialProperties.isEmpty()) {
179 propertiesChanged(initialProperties);
180 }
181
182 QTimer::singleShot(0, [] {
183 qobject_cast<SettingsPrivate *>(settingsNotifier())->init();
184 });
185
186 const QList<QDBusObjectPath> devices = iface.devices();
187 qCDebug(NMQT) << "Device list";
188 for (const QDBusObjectPath &op : devices) {
189 networkInterfaceMap.insert(op.path(), Device::Ptr());
190 Q_EMIT deviceAdded(op.path());
191 qCDebug(NMQT) << " " << op.path();
192 }
193}
194
195NetworkManager::NetworkManagerPrivate::~NetworkManagerPrivate()
196{
197}
198
199QString NetworkManager::NetworkManagerPrivate::version() const
200{
201 return m_version;
202}
203
204int NetworkManager::NetworkManagerPrivate::compareVersion(const QString &version)
205{
206 int x;
207 int y;
208 int z;
209 const auto sl = QStringView(version).split('.');
210 if (sl.size() > 2) {
211 x = sl[0].toInt();
212 y = sl[1].toInt();
213 z = sl[2].toInt();
214 } else {
215 x = -1;
216 y = -1;
217 z = -1;
218 }
219
220 return compareVersion(x, y, z);
221}
222
223int NetworkManager::NetworkManagerPrivate::compareVersion(const int x, const int y, const int z) const
224{
225 if (m_x > x) {
226 return 1;
227 } else if (m_x < x) {
228 return -1;
229 } else if (m_y > y) {
230 return 1;
231 } else if (m_y < y) {
232 return -1;
233 } else if (m_z > z) {
234 return 1;
235 } else if (m_z < z) {
236 return -1;
237 }
238 return 0;
239}
240
241bool NetworkManager::NetworkManagerPrivate::checkVersion(const int x, const int y, const int z) const
242{
243 return 0 <= compareVersion(x, y, z);
244}
245
246NetworkManager::Device::Types NetworkManager::NetworkManagerPrivate::supportedInterfaceTypes() const
247{
248 return m_supportedInterfaceTypes;
249}
250
251QVariantMap NetworkManager::NetworkManagerPrivate::retrieveInitialProperties(const QString &interfaceName, const QString &path)
252{
253 QDBusMessage message = QDBusMessage::createMethodCall(DBUS_SERVICE, path, FDO_DBUS_PROPERTIES, QLatin1String("GetAll"));
254 message << interfaceName;
255#ifdef NMQT_STATIC
256 QDBusMessage resultMessage = QDBusConnection::sessionBus().call(message);
257#else
258 QDBusMessage resultMessage = QDBusConnection::systemBus().call(message);
259#endif
260 if (resultMessage.type() == QDBusMessage::ReplyMessage) {
261 QVariantMap result;
262 QDBusArgument dbusArgument = resultMessage.arguments().at(0).value<QDBusArgument>();
263 while (!dbusArgument.atEnd()) {
264 dbusArgument >> result;
265 }
266 return result;
267 }
268
269 return QVariantMap();
270}
271
272NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::findRegisteredNetworkInterface(const QString &uni)
273{
274 NetworkManager::Device::Ptr networkInterface;
275 auto it = networkInterfaceMap.constFind(uni);
276 if (it != networkInterfaceMap.constEnd()) {
277 if (*it) {
278 networkInterface = *it;
279 } else {
280 networkInterface = createNetworkInterface(uni);
281 networkInterfaceMap[uni] = networkInterface;
282 }
283 }
284 return networkInterface;
285}
286
287NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::findRegisteredActiveConnection(const QString &uni)
288{
290 if (!uni.isEmpty() && uni != QLatin1String("/")) {
291 const auto it = m_activeConnections.constFind(uni);
292 const bool contains = it != m_activeConnections.constEnd();
293 if (contains && *it) {
294 activeConnection = *it;
295 } else {
297 if (activeConnection->connection()) {
298 m_activeConnections[uni] = activeConnection;
299 if (!contains) {
300 Q_EMIT activeConnectionAdded(uni);
301 }
302 } else {
303 activeConnection.clear();
304 }
305 }
306 }
307 return activeConnection;
308}
309
310NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::createNetworkInterface(const QString &uni)
311{
312 // qCDebug(NMQT);
313 auto message = QDBusMessage::createMethodCall(DBUS_SERVICE, uni, FDO_DBUS_PROPERTIES, QStringLiteral("Get"));
314 message.setArguments({QLatin1String(OrgFreedesktopNetworkManagerDeviceInterface::staticInterfaceName()), QStringLiteral("DeviceType")});
315#ifdef NMQT_STATIC
316 auto bus = QDBusConnection::sessionBus();
317#else
318 auto bus = QDBusConnection::systemBus();
319#endif
320 QDBusReply<QVariant> reply = bus.call(message);
321 Device::Type type = reply.isValid() ? NetworkManager::DevicePrivate::convertType(reply.value().toInt()) : Device::UnknownType;
322 switch (type) {
323 case Device::Ethernet:
324 return Device::Ptr(new NetworkManager::WiredDevice(uni), &QObject::deleteLater);
325 case Device::Wifi:
326 return Device::Ptr(new NetworkManager::WirelessDevice(uni), &QObject::deleteLater);
327 case Device::Modem:
328 return Device::Ptr(new NetworkManager::ModemDevice(uni), &QObject::deleteLater);
329 case Device::Bluetooth:
330 return Device::Ptr(new NetworkManager::BluetoothDevice(uni), &QObject::deleteLater);
331 case Device::Wimax:
332 return Device::Ptr(new NetworkManager::WimaxDevice(uni), &QObject::deleteLater);
333 case Device::OlpcMesh:
334 return Device::Ptr(new NetworkManager::OlpcMeshDevice(uni), &QObject::deleteLater);
335 case Device::InfiniBand:
336 return Device::Ptr(new NetworkManager::InfinibandDevice(uni), &QObject::deleteLater);
337 case Device::Bond:
338 return Device::Ptr(new NetworkManager::BondDevice(uni), &QObject::deleteLater);
339 case Device::Vlan:
340 return Device::Ptr(new NetworkManager::VlanDevice(uni), &QObject::deleteLater);
341 case Device::Adsl:
342 return Device::Ptr(new NetworkManager::AdslDevice(uni), &QObject::deleteLater);
343 case Device::Bridge:
344 return Device::Ptr(new NetworkManager::BridgeDevice(uni), &QObject::deleteLater);
345 // No need to check checkVersion, because we can't get Generic, Gre, MacVlan, Tun & Veth values in incompatible runtime
346 case Device::Generic:
347 return Device::Ptr(new NetworkManager::GenericDevice(uni), &QObject::deleteLater);
348 case Device::Gre:
349 return Device::Ptr(new NetworkManager::GreDevice(uni), &QObject::deleteLater);
350 case Device::MacVlan:
351 return Device::Ptr(new NetworkManager::MacVlanDevice(uni), &QObject::deleteLater);
352 case Device::Tun:
353 return Device::Ptr(new NetworkManager::TunDevice(uni), &QObject::deleteLater);
354 case Device::Veth:
355 return Device::Ptr(new NetworkManager::VethDevice(uni), &QObject::deleteLater);
356 case Device::IpTunnel:
357 return Device::Ptr(new NetworkManager::IpTunnelDevice(uni), &QObject::deleteLater);
358 case Device::WireGuard:
359 return Device::Ptr(new NetworkManager::WireGuardDevice(uni), &QObject::deleteLater);
360 default:
361 if (uni != QLatin1String("any")) { // VPN connections use "any" as uni for the network interface.
362 qCDebug(NMQT) << "Can't create device of type" << type << "for" << uni;
363 }
364 }
365
366 return Device::Ptr(new Device(uni), &QObject::deleteLater);
367}
368
369NetworkManager::Status NetworkManager::NetworkManagerPrivate::status() const
370{
371 return nmState;
372}
373
374NetworkManager::Device::List NetworkManager::NetworkManagerPrivate::networkInterfaces()
375{
376 Device::List list;
377
379 for (i = networkInterfaceMap.constBegin(); i != networkInterfaceMap.constEnd(); ++i) {
380 Device::Ptr networkInterface = findRegisteredNetworkInterface(i.key());
381 if (!networkInterface.isNull()) {
382 list.append(networkInterface);
383 } else {
384 qCWarning(NMQT) << "warning: null network Interface for" << i.key();
385 }
386 }
387
388 return list;
389}
390
391NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::findDeviceByIpIface(const QString &iface)
392{
394 for (i = networkInterfaceMap.constBegin(); i != networkInterfaceMap.constEnd(); ++i) {
395 Device::Ptr networkInterface = findRegisteredNetworkInterface(i.key());
396 if (networkInterface && networkInterface->udi() == iface) {
397 return networkInterface;
398 }
399 }
400
401 return Device::Ptr();
402}
403
404bool NetworkManager::NetworkManagerPrivate::isNetworkingEnabled() const
405{
406 return m_isNetworkingEnabled;
407}
408
409bool NetworkManager::NetworkManagerPrivate::isWirelessEnabled() const
410{
411 return m_isWirelessEnabled;
412}
413
414bool NetworkManager::NetworkManagerPrivate::isWirelessHardwareEnabled() const
415{
416 return m_isWirelessHardwareEnabled;
417}
418
419bool NetworkManager::NetworkManagerPrivate::isWwanEnabled() const
420{
421 return m_isWwanEnabled;
422}
423
424bool NetworkManager::NetworkManagerPrivate::isWwanHardwareEnabled() const
425{
426 return m_isWwanHardwareEnabled;
427}
428
429bool NetworkManager::NetworkManagerPrivate::isWimaxEnabled() const
430{
431 return checkVersion(1, 2, 0) ? false : m_isWimaxEnabled;
432}
433
434bool NetworkManager::NetworkManagerPrivate::isWimaxHardwareEnabled() const
435{
436 return checkVersion(1, 2, 0) ? false : m_isWimaxHardwareEnabled;
437}
438
440NetworkManager::NetworkManagerPrivate::activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter)
441{
442 QString extra_connection_parameter = connectionParameter;
443 QString extra_interface_parameter = interfaceUni;
444 if (extra_connection_parameter.isEmpty()) {
445 extra_connection_parameter = QLatin1String("/");
446 }
447 if (extra_interface_parameter.isEmpty()) {
448 extra_interface_parameter = QLatin1String("/");
449 }
450 // TODO store error code
451 QDBusObjectPath connPath(connectionUni);
452 QDBusObjectPath interfacePath(interfaceUni);
453 // qCDebug(NMQT) << "Activating connection" << connPath.path() << "on interface" << interfacePath.path() << "with extra" << extra_connection_parameter;
454 return iface.ActivateConnection(connPath, QDBusObjectPath(extra_interface_parameter), QDBusObjectPath(extra_connection_parameter));
455}
456
457QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> NetworkManager::NetworkManagerPrivate::addAndActivateConnection(const NMVariantMapMap &connection,
458 const QString &interfaceUni,
459 const QString &connectionParameter)
460{
461 QString extra_connection_parameter = connectionParameter;
462 if (extra_connection_parameter.isEmpty()) {
463 extra_connection_parameter = QLatin1String("/");
464 }
465 // TODO store error code
466 QDBusObjectPath interfacePath(interfaceUni);
467 return iface.AddAndActivateConnection(connection, interfacePath, QDBusObjectPath(extra_connection_parameter));
468}
469
471NetworkManager::NetworkManagerPrivate::addAndActivateConnection2(const NMVariantMapMap &connection,
472 const QString &interfaceUni,
473 const QString &connectionParameter,
474 const QVariantMap &options)
475{
476 QString extra_connection_parameter = connectionParameter;
477 if (extra_connection_parameter.isEmpty()) {
478 extra_connection_parameter = QLatin1String("/");
479 }
480 // TODO store error code
481 QDBusObjectPath interfacePath(interfaceUni);
482 return iface.AddAndActivateConnection2(connection, interfacePath, QDBusObjectPath(extra_connection_parameter), options);
483}
484
485QDBusPendingReply<> NetworkManager::NetworkManagerPrivate::deactivateConnection(const QString &activeConnectionPath)
486{
487 return iface.DeactivateConnection(QDBusObjectPath(activeConnectionPath));
488}
489
490void NetworkManager::NetworkManagerPrivate::setNetworkingEnabled(bool enabled)
491{
492 iface.Enable(enabled);
493}
494
495void NetworkManager::NetworkManagerPrivate::setWirelessEnabled(bool enabled)
496{
497 iface.setWirelessEnabled(enabled);
498}
499
500void NetworkManager::NetworkManagerPrivate::setWwanEnabled(bool enabled)
501{
502 iface.setWwanEnabled(enabled);
503}
504
505void NetworkManager::NetworkManagerPrivate::setWimaxEnabled(bool enabled)
506{
507 if (!checkVersion(1, 2, 0)) {
508 iface.setWimaxEnabled(enabled);
509 }
510}
511
512void NetworkManager::NetworkManagerPrivate::sleep(bool sleep)
513{
514 iface.Sleep(sleep);
515}
516
517void NetworkManager::NetworkManagerPrivate::setLogging(NetworkManager::LogLevel level, NetworkManager::LogDomains domains)
518{
519 QString logLevel;
520 QStringList logDomains;
521 switch (level) {
522 case NetworkManager::Error:
523 logLevel = QLatin1String("ERR");
524 break;
525 case NetworkManager::Warning:
526 logLevel = QLatin1String("WARN");
527 break;
528 case NetworkManager::Info:
529 logLevel = QLatin1String("INFO");
530 break;
531 case NetworkManager::Debug:
532 logLevel = QLatin1String("DEBUG");
533 break;
535 logLevel = QLatin1String("TRACE");
536 break;
537 }
538 if (!domains.testFlag(NoChange)) {
539 if (domains.testFlag(NetworkManager::None)) {
540 logDomains << QLatin1String("NONE");
541 }
542 if (domains.testFlag(NetworkManager::Hardware)) {
543 logDomains << QLatin1String("PLATFORM");
544 }
545 if (domains.testFlag(NetworkManager::RFKill)) {
546 logDomains << QLatin1String("RFKILL");
547 }
548 if (domains.testFlag(NetworkManager::Ethernet)) {
549 logDomains << QLatin1String("ETHER");
550 }
551 if (domains.testFlag(NetworkManager::WiFi)) {
552 logDomains << QLatin1String("WIFI");
553 }
554 if (domains.testFlag(NetworkManager::Bluetooth)) {
555 logDomains << QLatin1String("BT");
556 }
557 if (domains.testFlag(NetworkManager::MobileBroadBand)) {
558 logDomains << QLatin1String("MB");
559 }
560 if (domains.testFlag(NetworkManager::DHCP4)) {
561 logDomains << QLatin1String("DHCP4");
562 }
563 if (domains.testFlag(NetworkManager::DHCP6)) {
564 logDomains << QLatin1String("DHCP6");
565 }
566 if (domains.testFlag(NetworkManager::PPP)) {
567 logDomains << QLatin1String("PPP");
568 }
569 if (domains.testFlag(NetworkManager::WiFiScan)) {
570 logDomains << QLatin1String("WIFI_SCAN");
571 }
572 if (domains.testFlag(NetworkManager::IPv4)) {
573 logDomains << QLatin1String("IP4");
574 }
575 if (domains.testFlag(NetworkManager::IPv6)) {
576 logDomains << QLatin1String("IP6");
577 }
578 if (domains.testFlag(NetworkManager::AutoIPv4)) {
579 logDomains << QLatin1String("AUTOIP4");
580 }
581 if (domains.testFlag(NetworkManager::DNS)) {
582 logDomains << QLatin1String("DNS");
583 }
584 if (domains.testFlag(NetworkManager::VPN)) {
585 logDomains << QLatin1String("VPN");
586 }
587 if (domains.testFlag(NetworkManager::Sharing)) {
588 logDomains << QLatin1String("SHARING");
589 }
590 if (domains.testFlag(NetworkManager::Supplicant)) {
591 logDomains << QLatin1String("SUPPLICANT");
592 }
593 if (domains.testFlag(NetworkManager::UserSet)) {
594 logDomains << QLatin1String("USER_SET");
595 }
596 if (domains.testFlag(NetworkManager::SysSet)) {
597 logDomains << QLatin1String("SYS_SET");
598 }
599 if (domains.testFlag(NetworkManager::Suspend)) {
600 logDomains << QLatin1String("SUSPEND");
601 }
602 if (domains.testFlag(NetworkManager::Core)) {
603 logDomains << QLatin1String("CORE");
604 }
605 if (domains.testFlag(NetworkManager::Devices)) {
606 logDomains << QLatin1String("DEVICE");
607 }
608 if (domains.testFlag(NetworkManager::OLPC)) {
609 logDomains << QLatin1String("OLPC");
610 }
611 if (domains.testFlag(NetworkManager::Wimax)) {
612 logDomains << QLatin1String("WIMAX");
613 }
614 if (domains.testFlag(NetworkManager::Infiniband)) {
615 logDomains << QLatin1String("INFINIBAND");
616 }
617 if (domains.testFlag(NetworkManager::Firewall)) {
618 logDomains << QLatin1String("FIREWALL");
619 }
620 if (domains.testFlag(NetworkManager::Adsl)) {
621 logDomains << QLatin1String("ADSL");
622 }
623 if (domains.testFlag(NetworkManager::Bond)) {
624 logDomains << QLatin1String("BOND");
625 }
626 if (domains.testFlag(NetworkManager::Vlan)) {
627 logDomains << QLatin1String("VLAN");
628 }
629 if (domains.testFlag(NetworkManager::Agents)) {
630 logDomains << QLatin1String("AGENTS");
631 }
632 if (domains.testFlag(NetworkManager::Settings)) {
633 logDomains << QLatin1String("SETTINGS");
634 }
635 if (domains.testFlag(NetworkManager::DbusProps)) {
636 logDomains << QLatin1String("DBUS_PROPS");
637 }
638 if (domains.testFlag(NetworkManager::Team)) {
639 logDomains << QLatin1String("TEAM");
640 }
641 if (domains.testFlag(NetworkManager::ConCheck)) {
642 logDomains << QLatin1String("CONCHECK");
643 }
644 if (domains.testFlag(NetworkManager::Dcb)) {
645 logDomains << QLatin1String("DCB");
646 }
647 if (domains.testFlag(NetworkManager::Dispatch)) {
648 logDomains << QLatin1String("DISPATCH");
649 }
650 }
651 iface.SetLogging(logLevel, logDomains.join(QLatin1Char(',')));
652}
653
654NMStringMap NetworkManager::NetworkManagerPrivate::permissions()
655{
656 return iface.GetPermissions();
657}
658
659NetworkManager::Connectivity NetworkManager::NetworkManagerPrivate::connectivity() const
660{
661 return m_connectivity;
662}
663
664QDBusPendingReply<uint> NetworkManager::NetworkManagerPrivate::checkConnectivity()
665{
666 return iface.CheckConnectivity();
667}
668
669NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::primaryConnection()
670{
671 return findRegisteredActiveConnection(m_primaryConnection);
672}
673
674NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::activatingConnection()
675{
676 return findRegisteredActiveConnection(m_activatingConnection);
677}
678
679NetworkManager::ConnectionSettings::ConnectionType NetworkManager::NetworkManagerPrivate::primaryConnectionType()
680{
681 return checkVersion(1, 0, 0) ? m_primaryConnectionType : NetworkManager::ConnectionSettings::Unknown;
682}
683
684bool NetworkManager::NetworkManagerPrivate::isStartingUp() const
685{
686 return iface.startup();
687}
688
689NetworkManager::Device::MeteredStatus NetworkManager::NetworkManagerPrivate::metered() const
690{
691 return checkVersion(1, 0, 6) ? m_metered : NetworkManager::Device::UnknownStatus;
692}
693
694NetworkManager::DnsConfiguration NetworkManager::NetworkManagerPrivate::globalDnsConfiguration() const
695{
696 return m_globalDnsConfiguration;
697}
698
699void NetworkManager::NetworkManagerPrivate::setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration)
700{
701 m_globalDnsConfiguration = configuration;
702 iface.setGlobalDnsConfiguration(m_globalDnsConfiguration.toMap());
703}
704
705bool NetworkManager::NetworkManagerPrivate::isConnectivityCheckAvailable() const
706{
707 return m_isConnectivityCheckAvailable;
708}
709
710bool NetworkManager::NetworkManagerPrivate::isConnectivityCheckEnabled() const
711{
712 return m_isConnectivityCheckEnabled;
713}
714
715QString NetworkManager::NetworkManagerPrivate::connectivityCheckUri() const
716{
717 return m_connectivityCheckUri;
718}
719
720void NetworkManager::NetworkManagerPrivate::onDeviceAdded(const QDBusObjectPath &objpath)
721{
722 // qCDebug(NMQT);
723 if (!networkInterfaceMap.contains(objpath.path())) {
724 networkInterfaceMap.insert(objpath.path(), Device::Ptr());
725 Q_EMIT deviceAdded(objpath.path());
726 }
727}
728
729void NetworkManager::NetworkManagerPrivate::onDeviceRemoved(const QDBusObjectPath &objpath)
730{
731 // qCDebug(NMQT);
732 networkInterfaceMap.remove(objpath.path());
733 Q_EMIT deviceRemoved(objpath.path());
734}
735
736void NetworkManager::NetworkManagerPrivate::connectivityChanged(uint connectivity)
737{
738 NetworkManager::Connectivity newConnectivity = convertConnectivity(connectivity);
739 if (m_connectivity != newConnectivity) {
740 m_connectivity = newConnectivity;
741 Q_EMIT Notifier::connectivityChanged(newConnectivity);
742 }
743}
744
745void NetworkManager::NetworkManagerPrivate::stateChanged(uint state)
746{
747 NetworkManager::Status newStatus = convertNMState(state);
748 if (nmState != newStatus) {
749 nmState = newStatus;
750 Q_EMIT Notifier::statusChanged(newStatus);
751 }
752}
753
754void NetworkManager::NetworkManagerPrivate::dbusPropertiesChanged(const QString &interfaceName,
755 const QVariantMap &properties,
756 const QStringList &invalidatedProperties)
757{
758 Q_UNUSED(invalidatedProperties);
759 if (interfaceName == QLatin1String("org.freedesktop.NetworkManager")) {
760 propertiesChanged(properties);
761 }
762}
763
764void NetworkManager::NetworkManagerPrivate::propertiesChanged(const QVariantMap &changedProperties)
765{
766 // qCDebug(NMQT) << Q_FUNC_INFO << changedProperties;
767
768 QVariantMap::const_iterator it = changedProperties.constBegin();
769 while (it != changedProperties.constEnd()) {
770 const QString property = it.key();
771 if (property == QLatin1String("ActiveConnections")) {
772 const QList<QDBusObjectPath> activePaths = qdbus_cast<QList<QDBusObjectPath>>(*it);
773 if (activePaths.isEmpty()) {
774 QMap<QString, ActiveConnection::Ptr>::const_iterator it = m_activeConnections.constBegin();
775 while (it != m_activeConnections.constEnd()) {
776 Q_EMIT activeConnectionRemoved(it.key());
777 ++it;
778 }
779 m_activeConnections.clear();
780 } else {
781 QStringList knownConnections = m_activeConnections.keys();
782 for (const QDBusObjectPath &ac : activePaths) {
783 if (!m_activeConnections.contains(ac.path())) {
784 m_activeConnections.insert(ac.path(), NetworkManager::ActiveConnection::Ptr());
785 Q_EMIT activeConnectionAdded(ac.path());
786 } else {
787 knownConnections.removeOne(ac.path());
788 }
789 // qCDebug(NMQT) << " " << ac.path();
790 }
791 for (const QString &path : std::as_const(knownConnections)) {
792 m_activeConnections.remove(path);
793 Q_EMIT activeConnectionRemoved(path);
794 }
795 }
796 Q_EMIT activeConnectionsChanged();
797 } else if (property == QLatin1String("NetworkingEnabled")) {
798 m_isNetworkingEnabled = it->toBool();
799 qCDebug(NMQT) << property << m_isNetworkingEnabled;
800 Q_EMIT networkingEnabledChanged(m_isNetworkingEnabled);
801 } else if (property == QLatin1String("WirelessHardwareEnabled")) {
802 m_isWirelessHardwareEnabled = it->toBool();
803 qCDebug(NMQT) << property << m_isWirelessHardwareEnabled;
804 Q_EMIT wirelessHardwareEnabledChanged(m_isWirelessHardwareEnabled);
805 } else if (property == QLatin1String("WirelessEnabled")) {
806 m_isWirelessEnabled = it->toBool();
807 qCDebug(NMQT) << property << m_isWirelessEnabled;
808 Q_EMIT wirelessEnabledChanged(m_isWirelessEnabled);
809 } else if (property == QLatin1String("WwanHardwareEnabled")) {
810 m_isWwanHardwareEnabled = it->toBool();
811 qCDebug(NMQT) << property << m_isWwanHardwareEnabled;
812 Q_EMIT wwanHardwareEnabledChanged(m_isWwanHardwareEnabled);
813 } else if (property == QLatin1String("WwanEnabled")) {
814 m_isWwanEnabled = it->toBool();
815 qCDebug(NMQT) << property << m_isWwanEnabled;
816 Q_EMIT wwanEnabledChanged(m_isWwanEnabled);
817 } else if (property == QLatin1String("WimaxHardwareEnabled")) {
818 m_isWimaxHardwareEnabled = it->toBool();
819 qCDebug(NMQT) << property << m_isWimaxHardwareEnabled;
820 Q_EMIT wimaxHardwareEnabledChanged(m_isWimaxHardwareEnabled);
821 } else if (property == QLatin1String("WimaxEnabled")) {
822 m_isWimaxEnabled = it->toBool();
823 qCDebug(NMQT) << property << m_isWimaxEnabled;
824 Q_EMIT wimaxEnabledChanged(m_isWimaxEnabled);
825 } else if (property == QLatin1String("Version")) {
826 m_version = it->toString();
827 parseVersion(m_version);
828 } else if (property == QLatin1String("State")) {
829 stateChanged(it->toUInt());
830 } else if (property == QLatin1String("Connectivity")) {
831 connectivityChanged(it->toUInt());
832 } else if (property == QLatin1String("PrimaryConnection")) {
833 m_primaryConnection = it->value<QDBusObjectPath>().path();
834 Q_EMIT primaryConnectionChanged(m_primaryConnection);
835 } else if (property == QLatin1String("ActivatingConnection")) {
836 m_activatingConnection = it->value<QDBusObjectPath>().path();
837 Q_EMIT activatingConnectionChanged(m_activatingConnection);
838 } else if (property == QLatin1String("PrimaryConnectionType")) {
839 m_primaryConnectionType = NetworkManager::ConnectionSettings::typeFromString(it->toString());
840 Q_EMIT primaryConnectionTypeChanged(m_primaryConnectionType);
841 } else if (property == QLatin1String("Startup")) {
842 Q_EMIT isStartingUpChanged();
843 } else if (property == QLatin1String("Metered")) {
844 m_metered = (NetworkManager::Device::MeteredStatus)it->toUInt();
845 Q_EMIT meteredChanged(m_metered);
846 } else if (property == QLatin1String("GlobalDnsConfiguration")) {
847 m_globalDnsConfiguration.fromMap(qdbus_cast<QVariantMap>(*it));
848 Q_EMIT globalDnsConfigurationChanged(m_globalDnsConfiguration);
849 } else if (property == QLatin1String("ConnectivityCheckAvailable")) {
850 m_isConnectivityCheckAvailable = it->toBool();
851 qCDebug(NMQT) << property << m_isConnectivityCheckAvailable;
852 Q_EMIT isConnectivityCheckAvailableChanged(m_isConnectivityCheckAvailable);
853 } else if (property == QLatin1String("ConnectivityCheckEnabled")) {
854 m_isConnectivityCheckEnabled = it->toBool();
855 qCDebug(NMQT) << property << m_isConnectivityCheckEnabled;
856 Q_EMIT isConnectivityCheckEnabledChanged(m_isConnectivityCheckEnabled);
857 } else if (property == QLatin1String("ConnectivityCheckUri")) {
858 QString uri = it->toString().trimmed();
859 // Remove possible quotes on the uri string (ex. \"https://connectivity-check.ubuntu.com/\")
860 if (uri.startsWith(QLatin1Char('\"'))) {
861 uri.slice(1);
862 }
863 if (uri.endsWith(QLatin1Char('\"'))) {
864 uri.chop(1);
865 }
866 m_connectivityCheckUri = uri;
867 qCDebug(NMQT) << property << m_connectivityCheckUri;
868 Q_EMIT connectivityCheckUriChanged(m_connectivityCheckUri);
869 } else {
870 qCDebug(NMQT) << Q_FUNC_INFO << "Unhandled property" << property;
871 }
872 ++it;
873 }
874}
875
876NetworkManager::Connectivity NetworkManager::NetworkManagerPrivate::convertConnectivity(uint connectivity)
877{
879 switch (connectivity) {
880 case NM_CONNECTIVITY_UNKNOWN:
881 convertedConnectivity = NetworkManager::UnknownConnectivity;
882 break;
883 case NM_CONNECTIVITY_NONE:
884 convertedConnectivity = NetworkManager::NoConnectivity;
885 break;
886 case NM_CONNECTIVITY_PORTAL:
887 convertedConnectivity = NetworkManager::Portal;
888 break;
889 case NM_CONNECTIVITY_LIMITED:
890 convertedConnectivity = NetworkManager::Limited;
891 break;
892 case NM_CONNECTIVITY_FULL:
893 convertedConnectivity = NetworkManager::Full;
894 break;
895 }
896 return convertedConnectivity;
897}
898
899NetworkManager::Status NetworkManager::NetworkManagerPrivate::convertNMState(uint state)
900{
902 switch (state) {
903 case NM_STATE_UNKNOWN:
905 break;
906 case NM_STATE_ASLEEP:
908 break;
909 case NM_STATE_DISCONNECTED:
911 break;
912 case NM_STATE_DISCONNECTING:
914 break;
915 case NM_STATE_CONNECTING:
917 break;
918 case NM_STATE_CONNECTED_LOCAL:
920 break;
921 case NM_STATE_CONNECTED_SITE:
923 break;
924 case NM_STATE_CONNECTED_GLOBAL:
926 break;
927 }
928 return status;
929}
930
931void NetworkManager::NetworkManagerPrivate::dbusInterfacesAdded(const QDBusObjectPath &path, const QVariantMap &addedInterfaces)
932{
933 Q_UNUSED(path);
934
935 if (!addedInterfaces.contains(NetworkManagerPrivate::DBUS_DAEMON_INTERFACE)) {
936 return;
937 }
938
939 daemonRegistered();
940}
941
942void NetworkManager::NetworkManagerPrivate::daemonRegistered()
943{
944 if (iface.version().isEmpty()) {
945 // If this call fails, we've probably been called from ServiceRegistered on an old NM,
946 // and the interface isn't ready yet. Just exit and hope we get called again on InterfacesAdded.
947 return;
948 }
949
950 init();
951 Q_EMIT serviceAppeared();
952}
953
954void NetworkManager::NetworkManagerPrivate::daemonUnregistered()
955{
956 stateChanged(NM_STATE_UNKNOWN);
957 QMap<QString, Device::Ptr>::const_iterator i = networkInterfaceMap.constBegin();
958 while (i != networkInterfaceMap.constEnd()) {
959 Q_EMIT deviceRemoved(i.key());
960 ++i;
961 }
962 networkInterfaceMap.clear();
963
964 QMap<QString, ActiveConnection::Ptr>::const_iterator it = m_activeConnections.constBegin();
965 while (it != m_activeConnections.constEnd()) {
966 Q_EMIT activeConnectionRemoved(it.key());
967 ++it;
968 }
969 m_activeConnections.clear();
970
971 qobject_cast<SettingsPrivate *>(settingsNotifier())->daemonUnregistered();
972
973 Q_EMIT activeConnectionsChanged();
974 Q_EMIT serviceDisappeared();
975}
976
977NetworkManager::ActiveConnection::List NetworkManager::NetworkManagerPrivate::activeConnections()
978{
980
981 // Take a copy because findRegisteredActiveConnection() may change m_activeConnections.
982 const QStringList keyList = m_activeConnections.keys();
983 for (const QString &key : keyList) {
984 NetworkManager::ActiveConnection::Ptr activeConnection = findRegisteredActiveConnection(key);
985
986 if (activeConnection) {
987 list << activeConnection;
988 }
989 }
990 return list;
991}
992
993QStringList NetworkManager::NetworkManagerPrivate::activeConnectionsPaths() const
994{
995 return m_activeConnections.keys();
996}
997
998QDBusPendingReply<QString, QString> NetworkManager::NetworkManagerPrivate::getLogging()
999{
1000 return iface.GetLogging();
1001}
1002
1004{
1005 return globalNetworkManager->version();
1006}
1007
1008int NetworkManager::compareVersion(const QString &version)
1009{
1010 return globalNetworkManager->compareVersion(version);
1011}
1012
1013int NetworkManager::compareVersion(const int x, const int y, const int z)
1014{
1015 return globalNetworkManager->compareVersion(x, y, z);
1016}
1017
1018bool NetworkManager::checkVersion(const int x, const int y, const int z)
1019{
1020 return globalNetworkManager->checkVersion(x, y, z);
1021}
1022
1024{
1025 return globalNetworkManager->status();
1026}
1027
1029{
1030 return globalNetworkManager->activeConnections();
1031}
1032
1034{
1035 return globalNetworkManager->activeConnectionsPaths();
1036}
1037
1039{
1040 return globalNetworkManager->findRegisteredActiveConnection(uni);
1041}
1042
1044{
1045 return globalNetworkManager->networkInterfaces();
1046}
1047
1049{
1050 return globalNetworkManager->isNetworkingEnabled();
1051}
1052
1054{
1055 return globalNetworkManager->isWirelessEnabled();
1056}
1057
1059{
1060 return globalNetworkManager->isWirelessHardwareEnabled();
1061}
1062
1064{
1065 return globalNetworkManager->findRegisteredNetworkInterface(uni);
1066}
1067
1069{
1070 return globalNetworkManager->findDeviceByIpIface(iface);
1071}
1072
1074NetworkManager::addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter)
1075{
1076 return globalNetworkManager->addAndActivateConnection(connection, interfaceUni, connectionParameter);
1077}
1078
1080 const QString &interfaceUni,
1081 const QString &connectionParameter,
1082 const QVariantMap &options)
1083{
1084 if (checkVersion(1, 16, 0)) {
1085 return globalNetworkManager->addAndActivateConnection2(connection, interfaceUni, connectionParameter, options);
1086 } else {
1087 return globalNetworkManager->addAndActivateConnection(connection, interfaceUni, connectionParameter);
1088 }
1089}
1090
1092NetworkManager::activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter)
1093{
1094 return globalNetworkManager->activateConnection(connectionUni, interfaceUni, connectionParameter);
1095}
1096
1098{
1099 return globalNetworkManager->deactivateConnection(activeConnectionPath);
1100}
1101
1103{
1104 return globalNetworkManager->getLogging();
1105}
1106
1107void NetworkManager::setNetworkingEnabled(bool enabled)
1108{
1109 globalNetworkManager->setNetworkingEnabled(enabled);
1110}
1111
1112void NetworkManager::setWirelessEnabled(bool enabled)
1113{
1114 globalNetworkManager->setWirelessEnabled(enabled);
1115}
1116
1118{
1119 return globalNetworkManager->isWwanEnabled();
1120}
1121
1123{
1124 return globalNetworkManager->isWwanHardwareEnabled();
1125}
1126
1127void NetworkManager::setWwanEnabled(bool enabled)
1128{
1129 globalNetworkManager->setWwanEnabled(enabled);
1130}
1131
1133{
1134 return globalNetworkManager->isWimaxEnabled();
1135}
1136
1138{
1139 return globalNetworkManager->isWimaxHardwareEnabled();
1140}
1141
1143{
1144 globalNetworkManager->setWimaxEnabled(enabled);
1145}
1146
1147void NetworkManager::sleep(bool sleep)
1148{
1149 globalNetworkManager->sleep(sleep);
1150}
1151
1152void NetworkManager::setLogging(NetworkManager::LogLevel level, NetworkManager::LogDomains domains)
1153{
1154 globalNetworkManager->setLogging(level, domains);
1155}
1156
1157NMStringMap NetworkManager::permissions()
1158{
1159 return globalNetworkManager->permissions();
1160}
1161
1163{
1164 return globalNetworkManager->supportedInterfaceTypes();
1165}
1166
1168{
1169 return globalNetworkManager->connectivity();
1170}
1171
1173{
1174 return globalNetworkManager->checkConnectivity();
1175}
1176
1178{
1179 return globalNetworkManager->primaryConnection();
1180}
1181
1183{
1184 return globalNetworkManager->activatingConnection();
1185}
1186
1187NetworkManager::ConnectionSettings::ConnectionType NetworkManager::primaryConnectionType()
1188{
1189 return globalNetworkManager->primaryConnectionType();
1190}
1191
1193{
1194 return globalNetworkManager->isStartingUp();
1195}
1196
1198{
1199 return globalNetworkManager->metered();
1200}
1201
1203{
1204 return globalNetworkManager->globalDnsConfiguration();
1205}
1206
1208{
1209 globalNetworkManager->setGlobalDnsConfiguration(configuration);
1210}
1211
1213{
1214 return globalNetworkManager->isConnectivityCheckAvailable();
1215}
1216
1218{
1219 return globalNetworkManager->isConnectivityCheckEnabled();
1220}
1221
1223{
1224 return globalNetworkManager->connectivityCheckUri();
1225}
1226
1227NetworkManager::Notifier *NetworkManager::notifier()
1228{
1229 return globalNetworkManager;
1230}
1231
1232#include "moc_manager.cpp"
1233#include "moc_manager_p.cpp"
An adsl device interface.
Definition adsldevice.h:21
A bluetooth device interface.
A bond device interface.
Definition bonddevice.h:21
A bridge device interface.
@ UnknownStatus
The device metered status is unknown.
Definition device.h:156
@ MacVlan
MacVlan virtual device.
Definition device.h:209
@ Bond
Bond virtual device.
Definition device.h:202
@ Adsl
ADSL modem device.
Definition device.h:204
@ Wifi
the Ieee80211 family of wireless networks
Definition device.h:194
@ OlpcMesh
OLPC Mesh networking device.
Definition device.h:198
@ Tun
Tun virtual device.
Definition device.h:210
@ IpTunnel
IP Tunneling Device.
Definition device.h:212
@ Veth
Veth virtual device.
Definition device.h:211
@ InfiniBand
Infiniband network device.
Definition device.h:201
@ UnknownType
Unknown device type.
Definition device.h:192
@ Vlan
Vlan virtual device.
Definition device.h:203
@ Wimax
WiMax WWAN technology.
Definition device.h:199
@ WireGuard
WireGuard Device.
Definition device.h:222
@ Generic
Generic device.
Definition device.h:206
@ Team
Team master device.
Definition device.h:207
@ Ethernet
Ieee8023 wired ethernet.
Definition device.h:193
@ Modem
POTS, GSM, CDMA or LTE modems.
Definition device.h:200
@ Bluetooth
network bluetooth device (usually a cell phone)
Definition device.h:197
@ Bridge
Bridge virtual device.
Definition device.h:205
This class represents IP configuration.
A generic device interface.
A gre device interface.
Definition gredevice.h:23
An infiniband device interface.
A Ip Tunnel device interface.
A macvlan device interface.
Represents a generic modem device, generally defined by the modemCapabilities() it exposes and at the...
Definition modemdevice.h:24
A OLPC mesh interface.
A tun device interface.
Definition tundevice.h:22
A veth device interface.
Definition vethdevice.h:22
A vlan device interface.
Definition vlandevice.h:21
An active VPN connection.
Wimax network interface.
Definition wimaxdevice.h:25
A WireGuard device interface.
A wired device interface.
Definition wireddevice.h:24
A wireless network interface.
Q_SCRIPTABLE CaptureState status()
KCOREADDONS_EXPORT unsigned int version()
void init(KXmlGuiWindow *window, KGameDifficulty *difficulty=nullptr)
QString path(const QString &relativePath)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
NETWORKMANAGERQT_EXPORT NetworkManager::ConnectionSettings::ConnectionType primaryConnectionType()
Definition manager.cpp:1187
NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr findActiveConnection(const QString &uni)
Find an ActiveConnection object for an active connection id.
Definition manager.cpp:1038
NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr primaryConnection()
Definition manager.cpp:1177
@ Trace
= Debug in runtime NM < 0.9.10
Definition manager.h:49
NETWORKMANAGERQT_EXPORT bool isWimaxHardwareEnabled()
Retrieves the status of wimax hardware in the system.
Definition manager.cpp:434
NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr activatingConnection()
Definition manager.cpp:1182
@ Connected
the system is currently connected to a network
Definition manager.h:40
@ Disconnecting
the system is breaking the connection
Definition manager.h:36
@ ConnectedLinkLocal
a network device is connected, but there is only link-local connectivity
Definition manager.h:38
@ Connecting
the system is not connected to any network
Definition manager.h:37
@ Asleep
networking is inactive and all devices are disabled
Definition manager.h:34
@ ConnectedSiteOnly
a network device is connected, but there is only site-local connectivity
Definition manager.h:39
@ Unknown
the networking system is not active or unable to report its status - proceed with caution
Definition manager.h:33
@ Disconnected
the system is not connected to any network
Definition manager.h:35
NETWORKMANAGERQT_EXPORT QDBusPendingReply< QString, QString > getLogging()
Get current logging verbosity level and operations domains.
Definition manager.cpp:998
NETWORKMANAGERQT_EXPORT bool isConnectivityCheckAvailable()
Definition manager.cpp:705
NETWORKMANAGERQT_EXPORT QDBusPendingReply< QDBusObjectPath > activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter)
Activate a connection using the supplied device.
Definition manager.cpp:440
NETWORKMANAGERQT_EXPORT void setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration)
Definition manager.cpp:1207
NETWORKMANAGERQT_EXPORT QString connectivityCheckUri()
Definition manager.cpp:1222
NETWORKMANAGERQT_EXPORT bool isWwanHardwareEnabled()
Retrieves the status of wireless broadband (Wireless WAN) hardware in the system.
Definition manager.cpp:424
NETWORKMANAGERQT_EXPORT QDBusPendingReply< uint > checkConnectivity()
Re-check the network connectivity state.
Definition manager.cpp:664
NETWORKMANAGERQT_EXPORT QDBusPendingReply< QDBusObjectPath, QDBusObjectPath > addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter)
Adds a new connection using the given details (if any) as a template (automatically filling in missin...
Definition manager.cpp:457
NETWORKMANAGERQT_EXPORT bool isWwanEnabled()
Retrieves the status of wireless broadband (Wireless WAN) in the system.
Definition manager.cpp:419
NETWORKMANAGERQT_EXPORT ActiveConnection::List activeConnections()
Access the list of any active connections.
Definition manager.cpp:1028
NETWORKMANAGERQT_EXPORT NetworkManager::Device::MeteredStatus metered()
Definition manager.cpp:1197
NETWORKMANAGERQT_EXPORT NetworkManager::Status status()
Get the manager connection state.
Definition manager.cpp:1023
NETWORKMANAGERQT_EXPORT QStringList activeConnectionsPaths()
Access the list of any active connections paths.
Definition manager.cpp:993
NETWORKMANAGERQT_EXPORT bool isConnectivityCheckEnabled()
Definition manager.cpp:710
NETWORKMANAGERQT_EXPORT Device::Ptr findNetworkInterface(const QString &uni)
Find a new NetworkInterface object given its UNI.
Definition manager.cpp:1063
NETWORKMANAGERQT_EXPORT bool isWirelessHardwareEnabled()
Retrieves the status of wireless hardware in the system.
Definition manager.cpp:414
NETWORKMANAGERQT_EXPORT QDBusPendingReply< QDBusObjectPath, QDBusObjectPath, QVariantMap > addAndActivateConnection2(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter, const QVariantMap &options)
Adds a new connection using the given details (if any) as a template (automatically filling in missin...
Definition manager.cpp:471
NETWORKMANAGERQT_EXPORT NetworkManager::DnsConfiguration globalDnsConfiguration()
Definition manager.cpp:1202
NETWORKMANAGERQT_EXPORT void setWimaxEnabled(bool enabled)
Definition manager.cpp:1142
NETWORKMANAGERQT_EXPORT QDBusPendingReply deactivateConnection(const QString &activeConnection)
Deactivate this network interface, if active.
Definition manager.cpp:485
NETWORKMANAGERQT_EXPORT Connectivity connectivity()
Definition manager.cpp:1167
NETWORKMANAGERQT_EXPORT QString version()
Get the NetworkManager version.
Definition manager.cpp:1003
NETWORKMANAGERQT_EXPORT bool isWimaxEnabled()
Retrieves the activation status of wimax networking in the system.
Definition manager.cpp:429
NETWORKMANAGERQT_EXPORT bool isWirelessEnabled()
Retrieves the activation status of wireless networking in the system.
Definition manager.cpp:409
NETWORKMANAGERQT_EXPORT Device::Types supportedInterfaceTypes()
Retrieves the interface types supported by this network manager.
Definition manager.cpp:246
Connectivity
Describes the network connectivity state.
Definition manager.h:100
@ Full
The host is connected to a network, and appears to be able to reach the full Internet.
Definition manager.h:105
@ Limited
The host is connected to a network, but does not appear to be able to reach the full Internet.
Definition manager.h:104
@ Portal
The host is behind a captive portal and cannot reach the full Internet.
Definition manager.h:103
@ NoConnectivity
The host is not connected to any network.
Definition manager.h:102
@ UnknownConnectivity
Network connectivity is unknown.
Definition manager.h:101
NETWORKMANAGERQT_EXPORT bool isNetworkingEnabled()
Retrieves the status of networking (as a whole) in the system.
Definition manager.cpp:404
NETWORKMANAGERQT_EXPORT int compareVersion(const QString &version)
Compares NetworkManager's version to the parameter version.
Definition manager.cpp:204
NETWORKMANAGERQT_EXPORT bool isStartingUp()
Indicates whether NM is still starting up; this becomes false when NM has finished attempting to acti...
Definition manager.cpp:684
NETWORKMANAGERQT_EXPORT SettingsNotifier * settingsNotifier()
Notifier object for connecting signals.
Definition settings.cpp:265
NETWORKMANAGERQT_EXPORT Device::Ptr findDeviceByIpFace(const QString &iface)
Return the network device referenced by its IP interface name.
Definition manager.cpp:1068
NETWORKMANAGERQT_EXPORT Device::List networkInterfaces()
Retrieves the list of all the network interfaces in the system.
Definition manager.cpp:374
NETWORKMANAGERQT_EXPORT bool checkVersion(const int x, const int y, const int z)
Checks if NetworkManager version is at least x.y.z.
Definition manager.cpp:241
bool atEnd() const const
QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode, int timeout) const const
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QDBusConnection sessionBus()
QDBusConnection systemBus()
QList< QVariant > arguments() const const
QDBusMessage createMethodCall(const QString &service, const QString &path, const QString &interface, const QString &method)
void setArguments(const QList< QVariant > &arguments)
MessageType type() const const
QString path() const const
bool isValid() const const
void serviceRegistered(const QString &serviceName)
void serviceUnregistered(const QString &serviceName)
bool testFlag(Enum flag) const const
void append(QList< T > &&value)
bool isEmpty() const const
bool removeOne(const AT &t)
qsizetype size() const const
void deleteLater()
bool isNull() const const
void chop(qsizetype n)
bool endsWith(QChar c, Qt::CaseSensitivity cs) const const
QString fromLatin1(QByteArrayView str)
bool isEmpty() const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString join(QChar separator) const const
QList< QStringView > split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:59:05 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.