Move QNetworkManagerNetworkInformationBackend to its own header file
(in preparation for the next commit) Change-Id: I1a6771dc953540dfa63cb80306a48122e97eb600 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> (cherry picked from commit 9468c0e3ca4b145ffadc83170c804db5fbf0895a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
11db1179a8
commit
f5cdefb3ab
@ -7,6 +7,7 @@ qt_internal_add_plugin(QNetworkManagerNetworkInformationPlugin
|
||||
PLUGIN_TYPE networkinformation
|
||||
DEFAULT_IF LINUX
|
||||
SOURCES
|
||||
qnetworkmanagernetworkinformationbackend.h
|
||||
qnetworkmanagernetworkinformationbackend.cpp
|
||||
qnetworkmanagerservice.h
|
||||
qnetworkmanagerservice.cpp
|
||||
|
@ -1,9 +1,7 @@
|
||||
// Copyright (C) 2021 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#include <QtNetwork/private/qnetworkinformation_p.h>
|
||||
|
||||
#include "qnetworkmanagerservice.h"
|
||||
#include "qnetworkmanagernetworkinformationbackend.h"
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/private/qobject_p.h>
|
||||
@ -104,35 +102,10 @@ static QString backendName()
|
||||
[QNetworkInformationBackend::PluginNamesLinuxIndex]);
|
||||
}
|
||||
|
||||
class QNetworkManagerNetworkInformationBackend : public QNetworkInformationBackend
|
||||
QString QNetworkManagerNetworkInformationBackend::name() const
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QNetworkManagerNetworkInformationBackend();
|
||||
~QNetworkManagerNetworkInformationBackend() = default;
|
||||
|
||||
QString name() const override { return backendName(); }
|
||||
QNetworkInformation::Features featuresSupported() const override
|
||||
{
|
||||
if (!isValid())
|
||||
return {};
|
||||
return featuresSupportedStatic();
|
||||
}
|
||||
|
||||
static QNetworkInformation::Features featuresSupportedStatic()
|
||||
{
|
||||
using Feature = QNetworkInformation::Feature;
|
||||
return QNetworkInformation::Features(Feature::Reachability | Feature::CaptivePortal
|
||||
| Feature::TransportMedium | Feature::Metered);
|
||||
}
|
||||
|
||||
bool isValid() const { return iface.isValid(); }
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(QNetworkManagerNetworkInformationBackend)
|
||||
|
||||
QNetworkManagerInterface iface;
|
||||
};
|
||||
return backendName();
|
||||
}
|
||||
|
||||
class QNetworkManagerNetworkInformationBackendFactory : public QNetworkInformationBackendFactory
|
||||
{
|
||||
|
@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2021 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
#ifndef QNETWORKMANAGERINFORMATIONBACKEND_H
|
||||
#define QNETWORKMANAGERINFORMATIONBACKEND_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtNetwork/private/qnetworkinformation_p.h>
|
||||
#include "qnetworkmanagerservice.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkManagerNetworkInformationBackend : public QNetworkInformationBackend
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QNetworkManagerNetworkInformationBackend();
|
||||
~QNetworkManagerNetworkInformationBackend() = default;
|
||||
|
||||
QString name() const override;
|
||||
QNetworkInformation::Features featuresSupported() const override
|
||||
{
|
||||
if (!isValid())
|
||||
return {};
|
||||
return featuresSupportedStatic();
|
||||
}
|
||||
|
||||
static QNetworkInformation::Features featuresSupportedStatic()
|
||||
{
|
||||
using Feature = QNetworkInformation::Feature;
|
||||
return QNetworkInformation::Features(Feature::Reachability | Feature::CaptivePortal
|
||||
| Feature::TransportMedium | Feature::Metered);
|
||||
}
|
||||
|
||||
bool isValid() const { return iface.isValid(); }
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(QNetworkManagerNetworkInformationBackend)
|
||||
|
||||
QNetworkManagerInterface iface;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user