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_globalDnsConfiguration(NetworkManager::DnsConfiguration())
86 , m_supportedInterfaceTypes(NetworkManager::Device::UnknownType)
87{
88 connect(&iface, &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &NetworkManagerPrivate::onDeviceAdded);
89 connect(&iface, &OrgFreedesktopNetworkManagerInterface::DeviceRemoved, this, &NetworkManagerPrivate::onDeviceRemoved);
90
91#ifndef NMQT_STATIC
92 QDBusConnection::systemBus().connect(NetworkManagerPrivate::DBUS_SERVICE,
93 NetworkManagerPrivate::DBUS_DAEMON_PATH,
94 NetworkManagerPrivate::FDO_DBUS_PROPERTIES,
95 QLatin1String("PropertiesChanged"),
96 this,
97 SLOT(dbusPropertiesChanged(QString, QVariantMap, QStringList)));
98#else
99 connect(&iface, &OrgFreedesktopNetworkManagerInterface::PropertiesChanged, this, &NetworkManagerPrivate::propertiesChanged);
100#endif
101
102 // We register two listeners here:
103 // - a ServiceRegistered listener for newer NM versions that connect to the bus when the interfaces
104 // we care about are already initialized
105 // - and an InterfaceAdded listener for older NM versions that connect to the bus early,
106 // and then add interfaces dynamically
107 iface.connection().connect(NetworkManagerPrivate::DBUS_SERVICE,
108 "/org/freedesktop",
109 NetworkManagerPrivate::FDO_DBUS_OBJECT_MANAGER,
110 QLatin1String("InterfacesAdded"),
111 this,
112 SLOT(dbusInterfacesAdded(QDBusObjectPath, QVariantMap)));
113
114 connect(&watcher, &QDBusServiceWatcher::serviceRegistered, this, &NetworkManagerPrivate::daemonRegistered);
115 connect(&watcher, &QDBusServiceWatcher::serviceUnregistered, this, &NetworkManagerPrivate::daemonUnregistered);
116
117 init();
118}
119
120void NetworkManager::NetworkManagerPrivate::parseVersion(const QString &version)
121{
122 const QStringList sl = version.split('.');
123
124 if (sl.size() > 2) {
125 m_x = sl[0].toInt();
126 m_y = sl[1].toInt();
127 m_z = sl[2].toInt();
128 } else {
129 m_x = -1;
130 m_y = -1;
131 m_z = -1;
132 }
133}
134
135void NetworkManager::NetworkManagerPrivate::init()
136{
137 qDBusRegisterMetaType<UIntList>();
138 qDBusRegisterMetaType<UIntListList>();
139 // qDBusRegisterMetaType<IpV6DBusAddress>();
140 // qDBusRegisterMetaType<IpV6DBusAddressList>();
141 // qDBusRegisterMetaType<IpV6DBusNameservers>();
142 // qDBusRegisterMetaType<IpV6DBusRoute>();
143 // qDBusRegisterMetaType<IpV6DBusRouteList>();
144 qDBusRegisterMetaType<QList<QDBusObjectPath>>();
145 qDBusRegisterMetaType<DeviceDBusStateReason>();
146 qDBusRegisterMetaType<NMVariantMapMap>();
147 qDBusRegisterMetaType<NMVariantMapList>();
148 qDBusRegisterMetaType<NMStringMap>();
149
150 m_version = iface.version();
151 parseVersion(m_version);
152 /* clang-format off */
153 m_supportedInterfaceTypes = static_cast<NetworkManager::Device::Types>(
172 /* clang-format on */
173
174 // Get all Manager's properties async
175 QVariantMap initialProperties = retrieveInitialProperties(iface.staticInterfaceName(), DBUS_DAEMON_PATH);
176 if (!initialProperties.isEmpty()) {
177 propertiesChanged(initialProperties);
178 }
179
180 QTimer::singleShot(0, [] {
181 qobject_cast<SettingsPrivate *>(settingsNotifier())->init();
182 });
183
184 const QList<QDBusObjectPath> devices = iface.devices();
185 qCDebug(NMQT) << "Device list";
186 for (const QDBusObjectPath &op : devices) {
187 networkInterfaceMap.insert(op.path(), Device::Ptr());
188 Q_EMIT deviceAdded(op.path());
189 qCDebug(NMQT) << " " << op.path();
190 }
191}
192
193NetworkManager::NetworkManagerPrivate::~NetworkManagerPrivate()
194{
195}
196
197QString NetworkManager::NetworkManagerPrivate::version() const
198{
199 return m_version;
200}
201
202int NetworkManager::NetworkManagerPrivate::compareVersion(const QString &version)
203{
204 int x;
205 int y;
206 int z;
207 const auto sl = QStringView(version).split('.');
208 if (sl.size() > 2) {
209 x = sl[0].toInt();
210 y = sl[1].toInt();
211 z = sl[2].toInt();
212 } else {
213 x = -1;
214 y = -1;
215 z = -1;
216 }
217
218 return compareVersion(x, y, z);
219}
220
221int NetworkManager::NetworkManagerPrivate::compareVersion(const int x, const int y, const int z) const
222{
223 if (m_x > x) {
224 return 1;
225 } else if (m_x < x) {
226 return -1;
227 } else if (m_y > y) {
228 return 1;
229 } else if (m_y < y) {
230 return -1;
231 } else if (m_z > z) {
232 return 1;
233 } else if (m_z < z) {
234 return -1;
235 }
236 return 0;
237}
238
239bool NetworkManager::NetworkManagerPrivate::checkVersion(const int x, const int y, const int z) const
240{
241 return 0 <= compareVersion(x, y, z);
242}
243
244NetworkManager::Device::Types NetworkManager::NetworkManagerPrivate::supportedInterfaceTypes() const
245{
246 return m_supportedInterfaceTypes;
247}
248
249QVariantMap NetworkManager::NetworkManagerPrivate::retrieveInitialProperties(const QString &interfaceName, const QString &path)
250{
251 QDBusMessage message = QDBusMessage::createMethodCall(DBUS_SERVICE, path, FDO_DBUS_PROPERTIES, QLatin1String("GetAll"));
252 message << interfaceName;
253#ifdef NMQT_STATIC
254 QDBusMessage resultMessage = QDBusConnection::sessionBus().call(message);
255#else
256 QDBusMessage resultMessage = QDBusConnection::systemBus().call(message);
257#endif
258 if (resultMessage.type() == QDBusMessage::ReplyMessage) {
259 QVariantMap result;
260 QDBusArgument dbusArgument = resultMessage.arguments().at(0).value<QDBusArgument>();
261 while (!dbusArgument.atEnd()) {
262 dbusArgument >> result;
263 }
264 return result;
265 }
266
267 return QVariantMap();
268}
269
270NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::findRegisteredNetworkInterface(const QString &uni)
271{
272 NetworkManager::Device::Ptr networkInterface;
273 auto it = networkInterfaceMap.constFind(uni);
274 if (it != networkInterfaceMap.constEnd()) {
275 if (*it) {
276 networkInterface = *it;
277 } else {
278 networkInterface = createNetworkInterface(uni);
279 networkInterfaceMap[uni] = networkInterface;
280 }
281 }
282 return networkInterface;
283}
284
285NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::findRegisteredActiveConnection(const QString &uni)
286{
288 if (!uni.isEmpty() && uni != QLatin1String("/")) {
289 const auto it = m_activeConnections.constFind(uni);
290 const bool contains = it != m_activeConnections.constEnd();
291 if (contains && *it) {
292 activeConnection = *it;
293 } else {
295 if (activeConnection->connection()) {
296 m_activeConnections[uni] = activeConnection;
297 if (!contains) {
298 Q_EMIT activeConnectionAdded(uni);
299 }
300 } else {
301 activeConnection.clear();
302 }
303 }
304 }
305 return activeConnection;
306}
307
308NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::createNetworkInterface(const QString &uni)
309{
310 // qCDebug(NMQT);
311 auto message = QDBusMessage::createMethodCall(DBUS_SERVICE, uni, FDO_DBUS_PROPERTIES, QStringLiteral("Get"));
312 message.setArguments({QLatin1String(OrgFreedesktopNetworkManagerDeviceInterface::staticInterfaceName()), QStringLiteral("DeviceType")});
313#ifdef NMQT_STATIC
314 auto bus = QDBusConnection::sessionBus();
315#else
316 auto bus = QDBusConnection::systemBus();
317#endif
318 QDBusReply<QVariant> reply = bus.call(message);
319 Device::Type type = reply.isValid() ? NetworkManager::DevicePrivate::convertType(reply.value().toInt()) : Device::UnknownType;
320 switch (type) {
321 case Device::Ethernet:
322 return Device::Ptr(new NetworkManager::WiredDevice(uni), &QObject::deleteLater);
323 case Device::Wifi:
324 return Device::Ptr(new NetworkManager::WirelessDevice(uni), &QObject::deleteLater);
325 case Device::Modem:
326 return Device::Ptr(new NetworkManager::ModemDevice(uni), &QObject::deleteLater);
327 case Device::Bluetooth:
328 return Device::Ptr(new NetworkManager::BluetoothDevice(uni), &QObject::deleteLater);
329 case Device::Wimax:
330 return Device::Ptr(new NetworkManager::WimaxDevice(uni), &QObject::deleteLater);
331 case Device::OlpcMesh:
332 return Device::Ptr(new NetworkManager::OlpcMeshDevice(uni), &QObject::deleteLater);
333 case Device::InfiniBand:
334 return Device::Ptr(new NetworkManager::InfinibandDevice(uni), &QObject::deleteLater);
335 case Device::Bond:
336 return Device::Ptr(new NetworkManager::BondDevice(uni), &QObject::deleteLater);
337 case Device::Vlan:
338 return Device::Ptr(new NetworkManager::VlanDevice(uni), &QObject::deleteLater);
339 case Device::Adsl:
340 return Device::Ptr(new NetworkManager::AdslDevice(uni), &QObject::deleteLater);
341 case Device::Bridge:
342 return Device::Ptr(new NetworkManager::BridgeDevice(uni), &QObject::deleteLater);
343 // No need to check checkVersion, because we can't get Generic, Gre, MacVlan, Tun & Veth values in incompatible runtime
344 case Device::Generic:
345 return Device::Ptr(new NetworkManager::GenericDevice(uni), &QObject::deleteLater);
346 case Device::Gre:
347 return Device::Ptr(new NetworkManager::GreDevice(uni), &QObject::deleteLater);
348 case Device::MacVlan:
349 return Device::Ptr(new NetworkManager::MacVlanDevice(uni), &QObject::deleteLater);
350 case Device::Tun:
351 return Device::Ptr(new NetworkManager::TunDevice(uni), &QObject::deleteLater);
352 case Device::Veth:
353 return Device::Ptr(new NetworkManager::VethDevice(uni), &QObject::deleteLater);
354 case Device::IpTunnel:
355 return Device::Ptr(new NetworkManager::IpTunnelDevice(uni), &QObject::deleteLater);
356 case Device::WireGuard:
357 return Device::Ptr(new NetworkManager::WireGuardDevice(uni), &QObject::deleteLater);
358 default:
359 if (uni != QLatin1String("any")) { // VPN connections use "any" as uni for the network interface.
360 qCDebug(NMQT) << "Can't create device of type" << type << "for" << uni;
361 }
362 }
363
364 return Device::Ptr(new Device(uni), &QObject::deleteLater);
365}
366
367NetworkManager::Status NetworkManager::NetworkManagerPrivate::status() const
368{
369 return nmState;
370}
371
372NetworkManager::Device::List NetworkManager::NetworkManagerPrivate::networkInterfaces()
373{
374 Device::List list;
375
377 for (i = networkInterfaceMap.constBegin(); i != networkInterfaceMap.constEnd(); ++i) {
378 Device::Ptr networkInterface = findRegisteredNetworkInterface(i.key());
379 if (!networkInterface.isNull()) {
380 list.append(networkInterface);
381 } else {
382 qCWarning(NMQT) << "warning: null network Interface for" << i.key();
383 }
384 }
385
386 return list;
387}
388
389NetworkManager::Device::Ptr NetworkManager::NetworkManagerPrivate::findDeviceByIpIface(const QString &iface)
390{
392 for (i = networkInterfaceMap.constBegin(); i != networkInterfaceMap.constEnd(); ++i) {
393 Device::Ptr networkInterface = findRegisteredNetworkInterface(i.key());
394 if (networkInterface && networkInterface->udi() == iface) {
395 return networkInterface;
396 }
397 }
398
399 return Device::Ptr();
400}
401
402bool NetworkManager::NetworkManagerPrivate::isNetworkingEnabled() const
403{
404 return m_isNetworkingEnabled;
405}
406
407bool NetworkManager::NetworkManagerPrivate::isWirelessEnabled() const
408{
409 return m_isWirelessEnabled;
410}
411
412bool NetworkManager::NetworkManagerPrivate::isWirelessHardwareEnabled() const
413{
414 return m_isWirelessHardwareEnabled;
415}
416
417bool NetworkManager::NetworkManagerPrivate::isWwanEnabled() const
418{
419 return m_isWwanEnabled;
420}
421
422bool NetworkManager::NetworkManagerPrivate::isWwanHardwareEnabled() const
423{
424 return m_isWwanHardwareEnabled;
425}
426
427bool NetworkManager::NetworkManagerPrivate::isWimaxEnabled() const
428{
429 return checkVersion(1, 2, 0) ? false : m_isWimaxEnabled;
430}
431
432bool NetworkManager::NetworkManagerPrivate::isWimaxHardwareEnabled() const
433{
434 return checkVersion(1, 2, 0) ? false : m_isWimaxHardwareEnabled;
435}
436
438NetworkManager::NetworkManagerPrivate::activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter)
439{
440 QString extra_connection_parameter = connectionParameter;
441 QString extra_interface_parameter = interfaceUni;
442 if (extra_connection_parameter.isEmpty()) {
443 extra_connection_parameter = QLatin1String("/");
444 }
445 if (extra_interface_parameter.isEmpty()) {
446 extra_interface_parameter = QLatin1String("/");
447 }
448 // TODO store error code
449 QDBusObjectPath connPath(connectionUni);
450 QDBusObjectPath interfacePath(interfaceUni);
451 // qCDebug(NMQT) << "Activating connection" << connPath.path() << "on interface" << interfacePath.path() << "with extra" << extra_connection_parameter;
452 return iface.ActivateConnection(connPath, QDBusObjectPath(extra_interface_parameter), QDBusObjectPath(extra_connection_parameter));
453}
454
455QDBusPendingReply<QDBusObjectPath, QDBusObjectPath> NetworkManager::NetworkManagerPrivate::addAndActivateConnection(const NMVariantMapMap &connection,
456 const QString &interfaceUni,
457 const QString &connectionParameter)
458{
459 QString extra_connection_parameter = connectionParameter;
460 if (extra_connection_parameter.isEmpty()) {
461 extra_connection_parameter = QLatin1String("/");
462 }
463 // TODO store error code
464 QDBusObjectPath interfacePath(interfaceUni);
465 return iface.AddAndActivateConnection(connection, interfacePath, QDBusObjectPath(extra_connection_parameter));
466}
467
469NetworkManager::NetworkManagerPrivate::addAndActivateConnection2(const NMVariantMapMap &connection,
470 const QString &interfaceUni,
471 const QString &connectionParameter,
472 const QVariantMap &options)
473{
474 QString extra_connection_parameter = connectionParameter;
475 if (extra_connection_parameter.isEmpty()) {
476 extra_connection_parameter = QLatin1String("/");
477 }
478 // TODO store error code
479 QDBusObjectPath interfacePath(interfaceUni);
480 return iface.AddAndActivateConnection2(connection, interfacePath, QDBusObjectPath(extra_connection_parameter), options);
481}
482
483QDBusPendingReply<> NetworkManager::NetworkManagerPrivate::deactivateConnection(const QString &activeConnectionPath)
484{
485 return iface.DeactivateConnection(QDBusObjectPath(activeConnectionPath));
486}
487
488void NetworkManager::NetworkManagerPrivate::setNetworkingEnabled(bool enabled)
489{
490 iface.Enable(enabled);
491}
492
493void NetworkManager::NetworkManagerPrivate::setWirelessEnabled(bool enabled)
494{
495 iface.setWirelessEnabled(enabled);
496}
497
498void NetworkManager::NetworkManagerPrivate::setWwanEnabled(bool enabled)
499{
500 iface.setWwanEnabled(enabled);
501}
502
503void NetworkManager::NetworkManagerPrivate::setWimaxEnabled(bool enabled)
504{
505 if (!checkVersion(1, 2, 0)) {
506 iface.setWimaxEnabled(enabled);
507 }
508}
509
510void NetworkManager::NetworkManagerPrivate::sleep(bool sleep)
511{
512 iface.Sleep(sleep);
513}
514
515void NetworkManager::NetworkManagerPrivate::setLogging(NetworkManager::LogLevel level, NetworkManager::LogDomains domains)
516{
517 QString logLevel;
518 QStringList logDomains;
519 switch (level) {
520 case NetworkManager::Error:
521 logLevel = QLatin1String("ERR");
522 break;
523 case NetworkManager::Warning:
524 logLevel = QLatin1String("WARN");
525 break;
526 case NetworkManager::Info:
527 logLevel = QLatin1String("INFO");
528 break;
529 case NetworkManager::Debug:
530 logLevel = QLatin1String("DEBUG");
531 break;
533 logLevel = QLatin1String("TRACE");
534 break;
535 }
536 if (!domains.testFlag(NoChange)) {
537 if (domains.testFlag(NetworkManager::None)) {
538 logDomains << QLatin1String("NONE");
539 }
540 if (domains.testFlag(NetworkManager::Hardware)) {
541 logDomains << QLatin1String("PLATFORM");
542 }
543 if (domains.testFlag(NetworkManager::RFKill)) {
544 logDomains << QLatin1String("RFKILL");
545 }
546 if (domains.testFlag(NetworkManager::Ethernet)) {
547 logDomains << QLatin1String("ETHER");
548 }
549 if (domains.testFlag(NetworkManager::WiFi)) {
550 logDomains << QLatin1String("WIFI");
551 }
552 if (domains.testFlag(NetworkManager::Bluetooth)) {
553 logDomains << QLatin1String("BT");
554 }
555 if (domains.testFlag(NetworkManager::MobileBroadBand)) {
556 logDomains << QLatin1String("MB");
557 }
558 if (domains.testFlag(NetworkManager::DHCP4)) {
559 logDomains << QLatin1String("DHCP4");
560 }
561 if (domains.testFlag(NetworkManager::DHCP6)) {
562 logDomains << QLatin1String("DHCP6");
563 }
564 if (domains.testFlag(NetworkManager::PPP)) {
565 logDomains << QLatin1String("PPP");
566 }
567 if (domains.testFlag(NetworkManager::WiFiScan)) {
568 logDomains << QLatin1String("WIFI_SCAN");
569 }
570 if (domains.testFlag(NetworkManager::IPv4)) {
571 logDomains << QLatin1String("IP4");
572 }
573 if (domains.testFlag(NetworkManager::IPv6)) {
574 logDomains << QLatin1String("IP6");
575 }
576 if (domains.testFlag(NetworkManager::AutoIPv4)) {
577 logDomains << QLatin1String("AUTOIP4");
578 }
579 if (domains.testFlag(NetworkManager::DNS)) {
580 logDomains << QLatin1String("DNS");
581 }
582 if (domains.testFlag(NetworkManager::VPN)) {
583 logDomains << QLatin1String("VPN");
584 }
585 if (domains.testFlag(NetworkManager::Sharing)) {
586 logDomains << QLatin1String("SHARING");
587 }
588 if (domains.testFlag(NetworkManager::Supplicant)) {
589 logDomains << QLatin1String("SUPPLICANT");
590 }
591 if (domains.testFlag(NetworkManager::UserSet)) {
592 logDomains << QLatin1String("USER_SET");
593 }
594 if (domains.testFlag(NetworkManager::SysSet)) {
595 logDomains << QLatin1String("SYS_SET");
596 }
597 if (domains.testFlag(NetworkManager::Suspend)) {
598 logDomains << QLatin1String("SUSPEND");
599 }
600 if (domains.testFlag(NetworkManager::Core)) {
601 logDomains << QLatin1String("CORE");
602 }
603 if (domains.testFlag(NetworkManager::Devices)) {
604 logDomains << QLatin1String("DEVICE");
605 }
606 if (domains.testFlag(NetworkManager::OLPC)) {
607 logDomains << QLatin1String("OLPC");
608 }
609 if (domains.testFlag(NetworkManager::Wimax)) {
610 logDomains << QLatin1String("WIMAX");
611 }
612 if (domains.testFlag(NetworkManager::Infiniband)) {
613 logDomains << QLatin1String("INFINIBAND");
614 }
615 if (domains.testFlag(NetworkManager::Firewall)) {
616 logDomains << QLatin1String("FIREWALL");
617 }
618 if (domains.testFlag(NetworkManager::Adsl)) {
619 logDomains << QLatin1String("ADSL");
620 }
621 if (domains.testFlag(NetworkManager::Bond)) {
622 logDomains << QLatin1String("BOND");
623 }
624 if (domains.testFlag(NetworkManager::Vlan)) {
625 logDomains << QLatin1String("VLAN");
626 }
627 if (domains.testFlag(NetworkManager::Agents)) {
628 logDomains << QLatin1String("AGENTS");
629 }
630 if (domains.testFlag(NetworkManager::Settings)) {
631 logDomains << QLatin1String("SETTINGS");
632 }
633 if (domains.testFlag(NetworkManager::DbusProps)) {
634 logDomains << QLatin1String("DBUS_PROPS");
635 }
636 if (domains.testFlag(NetworkManager::Team)) {
637 logDomains << QLatin1String("TEAM");
638 }
639 if (domains.testFlag(NetworkManager::ConCheck)) {
640 logDomains << QLatin1String("CONCHECK");
641 }
642 if (domains.testFlag(NetworkManager::Dcb)) {
643 logDomains << QLatin1String("DCB");
644 }
645 if (domains.testFlag(NetworkManager::Dispatch)) {
646 logDomains << QLatin1String("DISPATCH");
647 }
648 }
649 iface.SetLogging(logLevel, logDomains.join(QLatin1Char(',')));
650}
651
652NMStringMap NetworkManager::NetworkManagerPrivate::permissions()
653{
654 return iface.GetPermissions();
655}
656
657NetworkManager::Connectivity NetworkManager::NetworkManagerPrivate::connectivity() const
658{
659 return m_connectivity;
660}
661
662QDBusPendingReply<uint> NetworkManager::NetworkManagerPrivate::checkConnectivity()
663{
664 return iface.CheckConnectivity();
665}
666
667NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::primaryConnection()
668{
669 return findRegisteredActiveConnection(m_primaryConnection);
670}
671
672NetworkManager::ActiveConnection::Ptr NetworkManager::NetworkManagerPrivate::activatingConnection()
673{
674 return findRegisteredActiveConnection(m_activatingConnection);
675}
676
677NetworkManager::ConnectionSettings::ConnectionType NetworkManager::NetworkManagerPrivate::primaryConnectionType()
678{
679 return checkVersion(1, 0, 0) ? m_primaryConnectionType : NetworkManager::ConnectionSettings::Unknown;
680}
681
682bool NetworkManager::NetworkManagerPrivate::isStartingUp() const
683{
684 return iface.startup();
685}
686
687NetworkManager::Device::MeteredStatus NetworkManager::NetworkManagerPrivate::metered() const
688{
689 return checkVersion(1, 0, 6) ? m_metered : NetworkManager::Device::UnknownStatus;
690}
691
692NetworkManager::DnsConfiguration NetworkManager::NetworkManagerPrivate::globalDnsConfiguration() const
693{
694 return m_globalDnsConfiguration;
695}
696
697void NetworkManager::NetworkManagerPrivate::setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration)
698{
699 m_globalDnsConfiguration = configuration;
700 iface.setGlobalDnsConfiguration(m_globalDnsConfiguration.toMap());
701}
702
703void NetworkManager::NetworkManagerPrivate::onDeviceAdded(const QDBusObjectPath &objpath)
704{
705 // qCDebug(NMQT);
706 if (!networkInterfaceMap.contains(objpath.path())) {
707 networkInterfaceMap.insert(objpath.path(), Device::Ptr());
708 Q_EMIT deviceAdded(objpath.path());
709 }
710}
711
712void NetworkManager::NetworkManagerPrivate::onDeviceRemoved(const QDBusObjectPath &objpath)
713{
714 // qCDebug(NMQT);
715 networkInterfaceMap.remove(objpath.path());
716 Q_EMIT deviceRemoved(objpath.path());
717}
718
719void NetworkManager::NetworkManagerPrivate::connectivityChanged(uint connectivity)
720{
721 NetworkManager::Connectivity newConnectivity = convertConnectivity(connectivity);
722 if (m_connectivity != newConnectivity) {
723 m_connectivity = newConnectivity;
724 Q_EMIT Notifier::connectivityChanged(newConnectivity);
725 }
726}
727
728void NetworkManager::NetworkManagerPrivate::stateChanged(uint state)
729{
730 NetworkManager::Status newStatus = convertNMState(state);
731 if (nmState != newStatus) {
732 nmState = newStatus;
733 Q_EMIT Notifier::statusChanged(newStatus);
734 }
735}
736
737void NetworkManager::NetworkManagerPrivate::dbusPropertiesChanged(const QString &interfaceName,
738 const QVariantMap &properties,
739 const QStringList &invalidatedProperties)
740{
741 Q_UNUSED(invalidatedProperties);
742 if (interfaceName == QLatin1String("org.freedesktop.NetworkManager")) {
743 propertiesChanged(properties);
744 }
745}
746
747void NetworkManager::NetworkManagerPrivate::propertiesChanged(const QVariantMap &changedProperties)
748{
749 // qCDebug(NMQT) << Q_FUNC_INFO << changedProperties;
750
751 QVariantMap::const_iterator it = changedProperties.constBegin();
752 while (it != changedProperties.constEnd()) {
753 const QString property = it.key();
754 if (property == QLatin1String("ActiveConnections")) {
755 const QList<QDBusObjectPath> activePaths = qdbus_cast<QList<QDBusObjectPath>>(*it);
756 if (activePaths.isEmpty()) {
757 QMap<QString, ActiveConnection::Ptr>::const_iterator it = m_activeConnections.constBegin();
758 while (it != m_activeConnections.constEnd()) {
759 Q_EMIT activeConnectionRemoved(it.key());
760 ++it;
761 }
762 m_activeConnections.clear();
763 } else {
764 QStringList knownConnections = m_activeConnections.keys();
765 for (const QDBusObjectPath &ac : activePaths) {
766 if (!m_activeConnections.contains(ac.path())) {
767 m_activeConnections.insert(ac.path(), NetworkManager::ActiveConnection::Ptr());
768 Q_EMIT activeConnectionAdded(ac.path());
769 } else {
770 knownConnections.removeOne(ac.path());
771 }
772 // qCDebug(NMQT) << " " << ac.path();
773 }
774 for (const QString &path : std::as_const(knownConnections)) {
775 m_activeConnections.remove(path);
776 Q_EMIT activeConnectionRemoved(path);
777 }
778 }
779 Q_EMIT activeConnectionsChanged();
780 } else if (property == QLatin1String("NetworkingEnabled")) {
781 m_isNetworkingEnabled = it->toBool();
782 qCDebug(NMQT) << property << m_isNetworkingEnabled;
783 Q_EMIT networkingEnabledChanged(m_isNetworkingEnabled);
784 } else if (property == QLatin1String("WirelessHardwareEnabled")) {
785 m_isWirelessHardwareEnabled = it->toBool();
786 qCDebug(NMQT) << property << m_isWirelessHardwareEnabled;
787 Q_EMIT wirelessHardwareEnabledChanged(m_isWirelessHardwareEnabled);
788 } else if (property == QLatin1String("WirelessEnabled")) {
789 m_isWirelessEnabled = it->toBool();
790 qCDebug(NMQT) << property << m_isWirelessEnabled;
791 Q_EMIT wirelessEnabledChanged(m_isWirelessEnabled);
792 } else if (property == QLatin1String("WwanHardwareEnabled")) {
793 m_isWwanHardwareEnabled = it->toBool();
794 qCDebug(NMQT) << property << m_isWwanHardwareEnabled;
795 Q_EMIT wwanHardwareEnabledChanged(m_isWwanHardwareEnabled);
796 } else if (property == QLatin1String("WwanEnabled")) {
797 m_isWwanEnabled = it->toBool();
798 qCDebug(NMQT) << property << m_isWwanEnabled;
799 Q_EMIT wwanEnabledChanged(m_isWwanEnabled);
800 } else if (property == QLatin1String("WimaxHardwareEnabled")) {
801 m_isWimaxHardwareEnabled = it->toBool();
802 qCDebug(NMQT) << property << m_isWimaxHardwareEnabled;
803 Q_EMIT wimaxHardwareEnabledChanged(m_isWimaxHardwareEnabled);
804 } else if (property == QLatin1String("WimaxEnabled")) {
805 m_isWimaxEnabled = it->toBool();
806 qCDebug(NMQT) << property << m_isWimaxEnabled;
807 Q_EMIT wimaxEnabledChanged(m_isWimaxEnabled);
808 } else if (property == QLatin1String("Version")) {
809 m_version = it->toString();
810 parseVersion(m_version);
811 } else if (property == QLatin1String("State")) {
812 stateChanged(it->toUInt());
813 } else if (property == QLatin1String("Connectivity")) {
814 connectivityChanged(it->toUInt());
815 } else if (property == QLatin1String("PrimaryConnection")) {
816 m_primaryConnection = it->value<QDBusObjectPath>().path();
817 Q_EMIT primaryConnectionChanged(m_primaryConnection);
818 } else if (property == QLatin1String("ActivatingConnection")) {
819 m_activatingConnection = it->value<QDBusObjectPath>().path();
820 Q_EMIT activatingConnectionChanged(m_activatingConnection);
821 } else if (property == QLatin1String("PrimaryConnectionType")) {
822 m_primaryConnectionType = NetworkManager::ConnectionSettings::typeFromString(it->toString());
823 Q_EMIT primaryConnectionTypeChanged(m_primaryConnectionType);
824 } else if (property == QLatin1String("Startup")) {
825 Q_EMIT isStartingUpChanged();
826 } else if (property == QLatin1String("Metered")) {
827 m_metered = (NetworkManager::Device::MeteredStatus)it->toUInt();
828 Q_EMIT meteredChanged(m_metered);
829 } else if (property == QLatin1String("GlobalDnsConfiguration")) {
830 m_globalDnsConfiguration.fromMap(qdbus_cast<QVariantMap>(*it));
831 Q_EMIT globalDnsConfigurationChanged(m_globalDnsConfiguration);
832 } else {
833 qCDebug(NMQT) << Q_FUNC_INFO << "Unhandled property" << property;
834 }
835 ++it;
836 }
837}
838
839NetworkManager::Connectivity NetworkManager::NetworkManagerPrivate::convertConnectivity(uint connectivity)
840{
842 switch (connectivity) {
843 case NM_CONNECTIVITY_UNKNOWN:
844 convertedConnectivity = NetworkManager::UnknownConnectivity;
845 break;
846 case NM_CONNECTIVITY_NONE:
847 convertedConnectivity = NetworkManager::NoConnectivity;
848 break;
849 case NM_CONNECTIVITY_PORTAL:
850 convertedConnectivity = NetworkManager::Portal;
851 break;
852 case NM_CONNECTIVITY_LIMITED:
853 convertedConnectivity = NetworkManager::Limited;
854 break;
855 case NM_CONNECTIVITY_FULL:
856 convertedConnectivity = NetworkManager::Full;
857 break;
858 }
859 return convertedConnectivity;
860}
861
862NetworkManager::Status NetworkManager::NetworkManagerPrivate::convertNMState(uint state)
863{
865 switch (state) {
866 case NM_STATE_UNKNOWN:
868 break;
869 case NM_STATE_ASLEEP:
871 break;
872 case NM_STATE_DISCONNECTED:
874 break;
875 case NM_STATE_DISCONNECTING:
877 break;
878 case NM_STATE_CONNECTING:
880 break;
881 case NM_STATE_CONNECTED_LOCAL:
883 break;
884 case NM_STATE_CONNECTED_SITE:
886 break;
887 case NM_STATE_CONNECTED_GLOBAL:
889 break;
890 }
891 return status;
892}
893
894void NetworkManager::NetworkManagerPrivate::dbusInterfacesAdded(const QDBusObjectPath &path, const QVariantMap &addedInterfaces)
895{
896 Q_UNUSED(path);
897
898 if (!addedInterfaces.contains(NetworkManagerPrivate::DBUS_DAEMON_INTERFACE)) {
899 return;
900 }
901
902 daemonRegistered();
903}
904
905void NetworkManager::NetworkManagerPrivate::daemonRegistered()
906{
907 if (iface.version().isEmpty()) {
908 // If this call fails, we've probably been called from ServiceRegistered on an old NM,
909 // and the interface isn't ready yet. Just exit and hope we get called again on InterfacesAdded.
910 return;
911 }
912
913 init();
914 Q_EMIT serviceAppeared();
915}
916
917void NetworkManager::NetworkManagerPrivate::daemonUnregistered()
918{
919 stateChanged(NM_STATE_UNKNOWN);
920 QMap<QString, Device::Ptr>::const_iterator i = networkInterfaceMap.constBegin();
921 while (i != networkInterfaceMap.constEnd()) {
922 Q_EMIT deviceRemoved(i.key());
923 ++i;
924 }
925 networkInterfaceMap.clear();
926
927 QMap<QString, ActiveConnection::Ptr>::const_iterator it = m_activeConnections.constBegin();
928 while (it != m_activeConnections.constEnd()) {
929 Q_EMIT activeConnectionRemoved(it.key());
930 ++it;
931 }
932 m_activeConnections.clear();
933
934 qobject_cast<SettingsPrivate *>(settingsNotifier())->daemonUnregistered();
935
936 Q_EMIT activeConnectionsChanged();
937 Q_EMIT serviceDisappeared();
938}
939
940NetworkManager::ActiveConnection::List NetworkManager::NetworkManagerPrivate::activeConnections()
941{
943
944 // Take a copy because findRegisteredActiveConnection() may change m_activeConnections.
945 const QStringList keyList = m_activeConnections.keys();
946 for (const QString &key : keyList) {
947 NetworkManager::ActiveConnection::Ptr activeConnection = findRegisteredActiveConnection(key);
948
949 if (activeConnection) {
950 list << activeConnection;
951 }
952 }
953 return list;
954}
955
956QStringList NetworkManager::NetworkManagerPrivate::activeConnectionsPaths() const
957{
958 return m_activeConnections.keys();
959}
960
961QDBusPendingReply<QString, QString> NetworkManager::NetworkManagerPrivate::getLogging()
962{
963 return iface.GetLogging();
964}
965
967{
968 return globalNetworkManager->version();
969}
970
971int NetworkManager::compareVersion(const QString &version)
972{
973 return globalNetworkManager->compareVersion(version);
974}
975
976int NetworkManager::compareVersion(const int x, const int y, const int z)
977{
978 return globalNetworkManager->compareVersion(x, y, z);
979}
980
981bool NetworkManager::checkVersion(const int x, const int y, const int z)
982{
983 return globalNetworkManager->checkVersion(x, y, z);
984}
985
987{
988 return globalNetworkManager->status();
989}
990
992{
993 return globalNetworkManager->activeConnections();
994}
995
997{
998 return globalNetworkManager->activeConnectionsPaths();
999}
1000
1002{
1003 return globalNetworkManager->findRegisteredActiveConnection(uni);
1004}
1005
1007{
1008 return globalNetworkManager->networkInterfaces();
1009}
1010
1012{
1013 return globalNetworkManager->isNetworkingEnabled();
1014}
1015
1017{
1018 return globalNetworkManager->isWirelessEnabled();
1019}
1020
1022{
1023 return globalNetworkManager->isWirelessHardwareEnabled();
1024}
1025
1027{
1028 return globalNetworkManager->findRegisteredNetworkInterface(uni);
1029}
1030
1032{
1033 return globalNetworkManager->findDeviceByIpIface(iface);
1034}
1035
1037NetworkManager::addAndActivateConnection(const NMVariantMapMap &connection, const QString &interfaceUni, const QString &connectionParameter)
1038{
1039 return globalNetworkManager->addAndActivateConnection(connection, interfaceUni, connectionParameter);
1040}
1041
1043 const QString &interfaceUni,
1044 const QString &connectionParameter,
1045 const QVariantMap &options)
1046{
1047 if (checkVersion(1, 16, 0)) {
1048 return globalNetworkManager->addAndActivateConnection2(connection, interfaceUni, connectionParameter, options);
1049 } else {
1050 return globalNetworkManager->addAndActivateConnection(connection, interfaceUni, connectionParameter);
1051 }
1052}
1053
1055NetworkManager::activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter)
1056{
1057 return globalNetworkManager->activateConnection(connectionUni, interfaceUni, connectionParameter);
1058}
1059
1061{
1062 return globalNetworkManager->deactivateConnection(activeConnectionPath);
1063}
1064
1066{
1067 return globalNetworkManager->getLogging();
1068}
1069
1070void NetworkManager::setNetworkingEnabled(bool enabled)
1071{
1072 globalNetworkManager->setNetworkingEnabled(enabled);
1073}
1074
1075void NetworkManager::setWirelessEnabled(bool enabled)
1076{
1077 globalNetworkManager->setWirelessEnabled(enabled);
1078}
1079
1081{
1082 return globalNetworkManager->isWwanEnabled();
1083}
1084
1086{
1087 return globalNetworkManager->isWwanHardwareEnabled();
1088}
1089
1090void NetworkManager::setWwanEnabled(bool enabled)
1091{
1092 globalNetworkManager->setWwanEnabled(enabled);
1093}
1094
1096{
1097 return globalNetworkManager->isWimaxEnabled();
1098}
1099
1101{
1102 return globalNetworkManager->isWimaxHardwareEnabled();
1103}
1104
1106{
1107 globalNetworkManager->setWimaxEnabled(enabled);
1108}
1109
1110void NetworkManager::sleep(bool sleep)
1111{
1112 globalNetworkManager->sleep(sleep);
1113}
1114
1115void NetworkManager::setLogging(NetworkManager::LogLevel level, NetworkManager::LogDomains domains)
1116{
1117 globalNetworkManager->setLogging(level, domains);
1118}
1119
1120NMStringMap NetworkManager::permissions()
1121{
1122 return globalNetworkManager->permissions();
1123}
1124
1126{
1127 return globalNetworkManager->supportedInterfaceTypes();
1128}
1129
1131{
1132 return globalNetworkManager->connectivity();
1133}
1134
1136{
1137 return globalNetworkManager->checkConnectivity();
1138}
1139
1141{
1142 return globalNetworkManager->primaryConnection();
1143}
1144
1146{
1147 return globalNetworkManager->activatingConnection();
1148}
1149
1150NetworkManager::ConnectionSettings::ConnectionType NetworkManager::primaryConnectionType()
1151{
1152 return globalNetworkManager->primaryConnectionType();
1153}
1154
1156{
1157 return globalNetworkManager->isStartingUp();
1158}
1159
1161{
1162 return globalNetworkManager->metered();
1163}
1164
1166{
1167 return globalNetworkManager->globalDnsConfiguration();
1168}
1169
1171{
1172 globalNetworkManager->setGlobalDnsConfiguration(configuration);
1173}
1174
1175NetworkManager::Notifier *NetworkManager::notifier()
1176{
1177 return globalNetworkManager;
1178}
1179
1180#include "moc_manager.cpp"
1181#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()
Type type(const QSqlDatabase &db)
KDB_EXPORT KDbVersionInfo version()
QString path(const QString &relativePath)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
NETWORKMANAGERQT_EXPORT NetworkManager::ConnectionSettings::ConnectionType primaryConnectionType()
Definition manager.cpp:1150
NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr findActiveConnection(const QString &uni)
Find an ActiveConnection object for an active connection id.
Definition manager.cpp:1001
NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr primaryConnection()
Definition manager.cpp:1140
@ 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:432
NETWORKMANAGERQT_EXPORT ActiveConnection::Ptr activatingConnection()
Definition manager.cpp:1145
@ 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:961
NETWORKMANAGERQT_EXPORT QDBusPendingReply< QDBusObjectPath > activateConnection(const QString &connectionUni, const QString &interfaceUni, const QString &connectionParameter)
Activate a connection using the supplied device.
Definition manager.cpp:438
NETWORKMANAGERQT_EXPORT void setGlobalDnsConfiguration(const NetworkManager::DnsConfiguration &configuration)
Definition manager.cpp:1170
NETWORKMANAGERQT_EXPORT bool isWwanHardwareEnabled()
Retrieves the status of wireless broadband (Wireless WAN) hardware in the system.
Definition manager.cpp:422
NETWORKMANAGERQT_EXPORT QDBusPendingReply< uint > checkConnectivity()
Re-check the network connectivity state.
Definition manager.cpp:662
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:455
NETWORKMANAGERQT_EXPORT bool isWwanEnabled()
Retrieves the status of wireless broadband (Wireless WAN) in the system.
Definition manager.cpp:417
NETWORKMANAGERQT_EXPORT ActiveConnection::List activeConnections()
Access the list of any active connections.
Definition manager.cpp:991
NETWORKMANAGERQT_EXPORT NetworkManager::Device::MeteredStatus metered()
Definition manager.cpp:1160
NETWORKMANAGERQT_EXPORT NetworkManager::Status status()
Get the manager connection state.
Definition manager.cpp:986
NETWORKMANAGERQT_EXPORT QStringList activeConnectionsPaths()
Access the list of any active connections paths.
Definition manager.cpp:956
NETWORKMANAGERQT_EXPORT Device::Ptr findNetworkInterface(const QString &uni)
Find a new NetworkInterface object given its UNI.
Definition manager.cpp:1026
NETWORKMANAGERQT_EXPORT bool isWirelessHardwareEnabled()
Retrieves the status of wireless hardware in the system.
Definition manager.cpp:412
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:469
NETWORKMANAGERQT_EXPORT NetworkManager::DnsConfiguration globalDnsConfiguration()
Definition manager.cpp:1165
NETWORKMANAGERQT_EXPORT void setWimaxEnabled(bool enabled)
Definition manager.cpp:1105
NETWORKMANAGERQT_EXPORT QDBusPendingReply deactivateConnection(const QString &activeConnection)
Deactivate this network interface, if active.
Definition manager.cpp:483
NETWORKMANAGERQT_EXPORT Connectivity connectivity()
Definition manager.cpp:1130
NETWORKMANAGERQT_EXPORT QString version()
Get the NetworkManager version.
Definition manager.cpp:966
NETWORKMANAGERQT_EXPORT bool isWimaxEnabled()
Retrieves the activation status of wimax networking in the system.
Definition manager.cpp:427
NETWORKMANAGERQT_EXPORT bool isWirelessEnabled()
Retrieves the activation status of wireless networking in the system.
Definition manager.cpp:407
NETWORKMANAGERQT_EXPORT Device::Types supportedInterfaceTypes()
Retrieves the interface types supported by this network manager.
Definition manager.cpp:244
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:402
NETWORKMANAGERQT_EXPORT int compareVersion(const QString &version)
Compares NetworkManager's version to the parameter version.
Definition manager.cpp:202
NETWORKMANAGERQT_EXPORT bool isStartingUp()
Indicates whether NM is still starting up; this becomes false when NM has finished attempting to acti...
Definition manager.cpp:682
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:1031
NETWORKMANAGERQT_EXPORT Device::List networkInterfaces()
Retrieves the list of all the network interfaces in the system.
Definition manager.cpp:372
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:239
QCA_EXPORT void init()
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
QString fromLatin1(QByteArrayView str)
bool isEmpty() const const
QString & remove(QChar ch, Qt::CaseSensitivity cs)
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 Mon Nov 18 2024 12:08:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.