7#include <QtCore/qglobal.h>
8#include <QtCore/private/qobject_p.h>
10#include <QtDBus/qdbusmessage.h>
13Q_DECLARE_LOGGING_CATEGORY(lcNetInfoConnman)
14Q_LOGGING_CATEGORY(lcNetInfoConnman,
"qt.network.info.connman")
16using namespace Qt::StringLiterals;
19QNetworkInformation::Reachability reachabilityFromState(
const QString &state)
21 if (state ==
"idle"_L1)
22 return QNetworkInformation::Reachability::Disconnected;
23 else if (state ==
"ready"_L1)
24 return QNetworkInformation::Reachability::Local;
25 else if (state ==
"online"_L1)
26 return QNetworkInformation::Reachability::Online;
28 return QNetworkInformation::Reachability::Unknown;
31QNetworkInformation::TransportMedium transportMediumFromType(
const QString &type)
33 if (type ==
"ethernet"_L1)
34 return QNetworkInformation::TransportMedium::Ethernet;
35 else if (type ==
"wifi"_L1)
36 return QNetworkInformation::TransportMedium::WiFi;
37 else if (type ==
"bluetooth"_L1)
38 return QNetworkInformation::TransportMedium::Bluetooth;
39 else if (type ==
"cellular"_L1)
40 return QNetworkInformation::TransportMedium::Cellular;
42 return QNetworkInformation::TransportMedium::Unknown;
59 Q_PLUGIN_METADATA(IID QNetworkInformationBackendFactory_iid)
69 return QConnManNetworkInformationBackend::featuresSupportedStatic();
73 create(QNetworkInformation::Features requiredFeatures)
const override
75 if ((requiredFeatures & featuresSupported()) != requiredFeatures)
80 if (!backend->isValid())
81 delete std::exchange(backend,
nullptr);
93 iface.setBackend(
this);
94 onStateChanged(iface.state());
95 onTypeChanged(iface.type());
100 qCInfo(lcNetInfoConnman) <<
"network state changed to" << state;
101 QNetworkInformation::Reachability reachability = reachabilityFromState(state);
102 setReachability(reachability);
107 qCInfo(lcNetInfoConnman) <<
"network type changed to" << type;
108 QNetworkInformation::TransportMedium medium = transportMediumFromType(type);
109 setTransportMedium(medium);
114#include "qconnmannetworkinformationbackend.moc"
115#include "moc_qconnmannetworkinformationbackend.cpp"
static bool connmanAvailable()