Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qnetworkmanagernetworkinformationbackend.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtCore/qglobal.h>
7#include <QtCore/private/qobject_p.h>
8
9#include <QtDBus/qdbusmessage.h>
10
13Q_LOGGING_CATEGORY(lcNetInfoNM, "qt.network.info.networkmanager");
14
15namespace {
17{
18 switch (state) {
23 case QNetworkManagerInterface::NM_STATE_DISCONNECTING: // No point in starting new connections:
32 }
34}
35
37transportMediumFromDeviceType(QNetworkManagerInterface::NMDeviceType type)
38{
39 switch (type) {
48
77 break;
78 }
79 // While the list is exhaustive of the enum there can be additional
80 // entries added in NetworkManager that isn't listed here
82}
83
84bool isMeteredFromNMMetered(QNetworkManagerInterface::NMMetered metered)
85{
86 switch (metered) {
89 return true;
93 return false;
94 }
95 Q_UNREACHABLE_RETURN(false);
96}
97} // unnamed namespace
98
104
109
111{
115public:
118 QString name() const override { return backendName(); }
119 QNetworkInformation::Features featuresSupported() const override
120 {
122 return {};
124 }
125
126 QNetworkInformationBackend *create(QNetworkInformation::Features requiredFeatures) const override
127 {
128 if ((requiredFeatures & featuresSupported()) != requiredFeatures)
129 return nullptr;
131 return nullptr;
132 auto backend = new QNetworkManagerNetworkInformationBackend();
133 if (!backend->isValid())
134 delete std::exchange(backend, nullptr);
135 return backend;
136 }
137private:
139};
140
151
157
165
168{
169 setTransportMedium(transportMediumFromDeviceType(newDevice));
170}
171
177
179
180#include "qnetworkmanagernetworkinformationbackend.moc"
181#include "moc_qnetworkmanagernetworkinformationbackend.cpp"
QNetworkInformationBackendFactory provides the interface for creating instances of QNetworkInformatio...
QNetworkInformationBackend provides the interface with which QNetworkInformation does all of its actu...
static constexpr int PluginNamesLinuxIndex
void setTransportMedium(TransportMedium medium)
static const char16_t PluginNames[4][22]
void setBehindCaptivePortal(bool behindPortal)
void setReachability(QNetworkInformation::Reachability reachability)
Call this when reachability has changed.
Reachability
\value Unknown If this value is returned then we may be connected but the OS has still not confirmed ...
void setBackend(QNetworkManagerNetworkInformationBackend *ourBackend)
NMConnectivityState connectivityState() const
QString name() const override
Backend name, return the same in QNetworkInformationBackend::name().
QNetworkInformationBackend * create(QNetworkInformation::Features requiredFeatures) const override
Create and return an instance of QNetworkInformationBackend.
QNetworkInformation::Features featuresSupported() const override
Features supported, return the same in QNetworkInformationBackend::featuresSupported().
void onStateChanged(QNetworkManagerInterface::NMState state)
QString name() const override
Backend name, return the same in QNetworkInformationBackendFactory::name().
void onMeteredChanged(QNetworkManagerInterface::NMMetered metered)
void onConnectivityChanged(QNetworkManagerInterface::NMConnectivityState connectivityState)
void onDeviceTypeChanged(QNetworkManagerInterface::NMDeviceType deviceType)
\inmodule QtCore
Definition qstringview.h:78
QString toString() const
Returns a deep copy of this string view's data as a QString.
Definition qstring.h:1121
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
else opt state
[0]
void newState(QList< State > &states, const char *token, const char *lexem, bool pre)
Combined button and popup list for selecting options.
static QString backendName
#define Q_LOGGING_CATEGORY(name,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
#define QNetworkInformationBackendFactory_iid
static QString backendName()
GLenum type
#define Q_OBJECT
#define Q_PLUGIN_METADATA(x)
#define Q_INTERFACES(x)
QHostInfo info
[0]