summaryrefslogtreecommitdiffstats
path: root/src/network/bearer
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/bearer')
-rw-r--r--src/network/bearer/bearer.pri22
-rw-r--r--src/network/bearer/qbearerengine.cpp101
-rw-r--r--src/network/bearer/qbearerengine_impl_p.h85
-rw-r--r--src/network/bearer/qbearerengine_p.h115
-rw-r--r--src/network/bearer/qbearerplugin.cpp57
-rw-r--r--src/network/bearer/qbearerplugin_p.h81
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp389
-rw-r--r--src/network/bearer/qnetworkconfigmanager.h109
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp517
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h141
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp596
-rw-r--r--src/network/bearer/qnetworkconfiguration.h147
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h99
-rw-r--r--src/network/bearer/qnetworksession.cpp743
-rw-r--r--src/network/bearer/qnetworksession.h159
-rw-r--r--src/network/bearer/qnetworksession_impl.cpp439
-rw-r--r--src/network/bearer/qnetworksession_impl_p.h134
-rw-r--r--src/network/bearer/qnetworksession_p.h157
-rw-r--r--src/network/bearer/qsharednetworksession.cpp102
-rw-r--r--src/network/bearer/qsharednetworksession_p.h92
20 files changed, 0 insertions, 4285 deletions
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri
deleted file mode 100644
index bcb7a5971e..0000000000
--- a/src/network/bearer/bearer.pri
+++ /dev/null
@@ -1,22 +0,0 @@
-# Qt network bearer management module
-
-HEADERS += bearer/qnetworkconfiguration.h \
- bearer/qnetworksession.h \
- bearer/qnetworkconfigmanager.h \
- bearer/qnetworkconfigmanager_p.h \
- bearer/qnetworkconfiguration_p.h \
- bearer/qnetworksession_p.h \
- bearer/qnetworksession_impl_p.h \
- bearer/qbearerengine_p.h \
- bearer/qbearerengine_impl_p.h \
- bearer/qbearerplugin_p.h \
- bearer/qsharednetworksession_p.h
-
-SOURCES += bearer/qnetworksession.cpp \
- bearer/qnetworksession_impl.cpp \
- bearer/qnetworkconfigmanager.cpp \
- bearer/qnetworkconfiguration.cpp \
- bearer/qnetworkconfigmanager_p.cpp \
- bearer/qbearerengine.cpp \
- bearer/qbearerplugin.cpp \
- bearer/qsharednetworksession.cpp
diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp
deleted file mode 100644
index 06bf449611..0000000000
--- a/src/network/bearer/qbearerengine.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qbearerengine_p.h"
-#include <QtCore/private/qlocking_p.h>
-
-#include <algorithm>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-static void cleanUpConfigurations(QHash<QString, QNetworkConfigurationPrivatePointer> &configurations)
-{
- for (auto &ptr : qExchange(configurations, {})) {
- ptr->isValid = false;
- ptr->id.clear();
- }
-}
-
-static bool hasUsedConfiguration(const QHash<QString, QNetworkConfigurationPrivatePointer> &configurations)
-{
- auto isUsed = [](const QNetworkConfigurationPrivatePointer &ptr) {
- return ptr->ref.loadRelaxed() > 1;
- };
- const auto end = configurations.end();
- return std::find_if(configurations.begin(), end, isUsed) != end;
-}
-
-QBearerEngine::QBearerEngine(QObject *parent)
- : QObject(parent)
-{
-}
-
-QBearerEngine::~QBearerEngine()
-{
- cleanUpConfigurations(snapConfigurations);
- cleanUpConfigurations(accessPointConfigurations);
- cleanUpConfigurations(userChoiceConfigurations);
-}
-
-bool QBearerEngine::requiresPolling() const
-{
- return false;
-}
-
-/*
- Returns \c true if configurations are in use; otherwise returns \c false.
-
- If configurations are in use and requiresPolling() returns \c true, polling will be enabled for
- this engine.
-*/
-bool QBearerEngine::configurationsInUse() const
-{
- const auto locker = qt_scoped_lock(mutex);
- return hasUsedConfiguration(accessPointConfigurations)
- || hasUsedConfiguration(snapConfigurations)
- || hasUsedConfiguration(userChoiceConfigurations);
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qbearerengine_p.cpp"
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/network/bearer/qbearerengine_impl_p.h b/src/network/bearer/qbearerengine_impl_p.h
deleted file mode 100644
index 4221b73276..0000000000
--- a/src/network/bearer/qbearerengine_impl_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBEARERENGINE_IMPL_H
-#define QBEARERENGINE_IMPL_H
-
-#include <QtNetwork/private/qbearerengine_p.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class Q_NETWORK_EXPORT QBearerEngineImpl : public QBearerEngine
-{
- Q_OBJECT
-
-public:
- enum ConnectionError {
- InterfaceLookupError = 0,
- ConnectError,
- OperationNotSupported,
- DisconnectionError,
- };
-
- QBearerEngineImpl(QObject *parent = nullptr) : QBearerEngine(parent) {}
- ~QBearerEngineImpl() {}
-
- virtual void connectToId(const QString &id) = 0;
- virtual void disconnectFromId(const QString &id) = 0;
-
- virtual QString getInterfaceFromId(const QString &id) = 0;
-
- virtual QNetworkSession::State sessionStateForId(const QString &id) = 0;
-
- virtual quint64 bytesWritten(const QString &) { return Q_UINT64_C(0); }
- virtual quint64 bytesReceived(const QString &) { return Q_UINT64_C(0); }
- virtual quint64 startTime(const QString &) { return Q_UINT64_C(0); }
-
-Q_SIGNALS:
- void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error);
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QBearerEngineImpl::ConnectionError)
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif // QBEARERENGINE_IMPL_H
diff --git a/src/network/bearer/qbearerengine_p.h b/src/network/bearer/qbearerengine_p.h
deleted file mode 100644
index c69f478b26..0000000000
--- a/src/network/bearer/qbearerengine_p.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBEARERENGINE_P_H
-#define QBEARERENGINE_P_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/qtnetworkglobal_p.h>
-#include "qnetworkconfiguration_p.h"
-#include "qnetworksession.h"
-#include "qnetworkconfigmanager.h"
-
-#include <QtCore/qobject.h>
-#include <QtCore/qglobal.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qhash.h>
-#include <QtCore/qsharedpointer.h>
-#include <QtCore/qmutex.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkConfiguration;
-
-class Q_NETWORK_EXPORT QBearerEngine : public QObject
-{
- Q_OBJECT
-
- friend class QNetworkConfigurationManagerPrivate;
-
-public:
- explicit QBearerEngine(QObject *parent = nullptr);
- virtual ~QBearerEngine();
-
- virtual bool hasIdentifier(const QString &id) = 0;
-
- virtual QNetworkConfigurationManager::Capabilities capabilities() const = 0;
-
- virtual QNetworkSessionPrivate *createSessionBackend() = 0;
-
- virtual QNetworkConfigurationPrivatePointer defaultConfiguration() = 0;
-
- virtual bool requiresPolling() const;
- bool configurationsInUse() const;
-
-Q_SIGNALS:
- void configurationAdded(QNetworkConfigurationPrivatePointer config);
- void configurationRemoved(QNetworkConfigurationPrivatePointer config);
- void configurationChanged(QNetworkConfigurationPrivatePointer config);
- void updateCompleted();
-
-protected:
- //this table contains an up to date list of all configs at any time.
- //it must be updated if configurations change, are added/removed or
- //the members of ServiceNetworks change
- QHash<QString, QNetworkConfigurationPrivatePointer> accessPointConfigurations;
- QHash<QString, QNetworkConfigurationPrivatePointer> snapConfigurations;
- QHash<QString, QNetworkConfigurationPrivatePointer> userChoiceConfigurations;
-
- mutable QRecursiveMutex mutex;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif // QBEARERENGINE_P_H
diff --git a/src/network/bearer/qbearerplugin.cpp b/src/network/bearer/qbearerplugin.cpp
deleted file mode 100644
index ec0d06e94c..0000000000
--- a/src/network/bearer/qbearerplugin.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qbearerplugin_p.h"
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-QBearerEnginePlugin::QBearerEnginePlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-QBearerEnginePlugin::~QBearerEnginePlugin()
-{
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/network/bearer/qbearerplugin_p.h b/src/network/bearer/qbearerplugin_p.h
deleted file mode 100644
index ac787d0541..0000000000
--- a/src/network/bearer/qbearerplugin_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBEARERPLUGIN_P_H
-#define QBEARERPLUGIN_P_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/qtnetworkglobal_p.h>
-#include "qbearerengine_p.h"
-
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-
-#define QBearerEngineFactoryInterface_iid "org.qt-project.Qt.QBearerEngineFactoryInterface"
-
-class Q_NETWORK_EXPORT QBearerEnginePlugin : public QObject
-{
- Q_OBJECT
-public:
- explicit QBearerEnginePlugin(QObject *parent = nullptr);
- virtual ~QBearerEnginePlugin();
-
- virtual QBearerEngine *create(const QString &key) const = 0;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif // QBEARERPLUGIN_P_H
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
deleted file mode 100644
index eb3eb59c83..0000000000
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ /dev/null
@@ -1,389 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtNetwork/private/qtnetworkglobal_p.h>
-
-#include "qnetworkconfigmanager.h"
-
-#include "qnetworkconfigmanager_p.h"
-#include "qbearerengine_p.h"
-
-#include <QtCore/qstringlist.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qthread.h>
-#include <QtCore/private/qcoreapplication_p.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-static QBasicAtomicPointer<QNetworkConfigurationManagerPrivate> connManager_ptr;
-static QBasicAtomicInt appShutdown;
-
-static void connManager_prepare()
-{
- int shutdown = appShutdown.fetchAndStoreAcquire(0);
- Q_ASSERT(shutdown == 0 || shutdown == 1);
- Q_UNUSED(shutdown);
-}
-
-static void connManager_cleanup()
-{
- // this is not atomic or thread-safe!
- int shutdown = appShutdown.fetchAndStoreAcquire(1);
- Q_ASSERT(shutdown == 0);
- Q_UNUSED(shutdown);
- QNetworkConfigurationManagerPrivate *cmp = connManager_ptr.fetchAndStoreAcquire(nullptr);
- if (cmp)
- cmp->cleanup();
-}
-
-void QNetworkConfigurationManagerPrivate::addPreAndPostRoutine()
-{
- qAddPreRoutine(connManager_prepare);
- qAddPostRoutine(connManager_cleanup);
-}
-
-QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
-{
- QNetworkConfigurationManagerPrivate *ptr = connManager_ptr.loadAcquire();
- int shutdown = appShutdown.loadAcquire();
- if (!ptr && !shutdown) {
- static QBasicMutex connManager_mutex;
- QMutexLocker locker(&connManager_mutex);
- if (!(ptr = connManager_ptr.loadAcquire())) {
- ptr = new QNetworkConfigurationManagerPrivate;
-
- if (QCoreApplicationPrivate::mainThread() == QThread::currentThread()) {
- // right thread or no main thread yet
- ptr->addPreAndPostRoutine();
- ptr->initialize();
- } else {
- // wrong thread, we need to make the main thread do this
- QObject *obj = new QObject;
- QObject::connect(obj, SIGNAL(destroyed()), ptr, SLOT(addPreAndPostRoutine()), Qt::DirectConnection);
- ptr->initialize(); // this moves us to the right thread
- obj->moveToThread(QCoreApplicationPrivate::mainThread());
- obj->deleteLater();
- }
-
- connManager_ptr.storeRelease(ptr);
- }
- }
- return ptr;
-}
-
-/*!
- \class QNetworkConfigurationManager
- \obsolete
-
- \brief The QNetworkConfigurationManager class manages the network configurations provided
- by the system.
-
- \since 4.7
-
- \inmodule QtNetwork
- \ingroup network
-
- QNetworkConfigurationManager provides access to the network configurations known to the system and
- enables applications to detect the system capabilities (with regards to network sessions) at runtime.
-
- A QNetworkConfiguration abstracts a set of configuration options describing how a
- network interface has to be configured to connect to a particular target network.
- QNetworkConfigurationManager maintains and updates the global list of
- QNetworkConfigurations. Applications can access and filter this list via
- allConfigurations(). If a new configuration is added or an existing one is removed or changed
- the configurationAdded(), configurationRemoved() and configurationChanged() signals are emitted
- respectively.
-
- The defaultConfiguration() can be used when intending to immediately create a new
- network session without caring about the particular configuration. It returns
- a \l QNetworkConfiguration::Discovered configuration. If there are not any
- discovered ones an invalid configuration is returned.
-
- Some configuration updates may require some time to perform updates. A WLAN scan is
- such an example. Unless the platform performs internal updates it may be required to
- manually trigger configuration updates via QNetworkConfigurationManager::updateConfigurations().
- The completion of the update process is indicated by emitting the updateCompleted()
- signal. The update process ensures that every existing QNetworkConfiguration instance
- is updated. There is no need to ask for a renewed configuration list via allConfigurations().
-
- \sa QNetworkConfiguration
-*/
-
-/*!
- \fn void QNetworkConfigurationManager::configurationAdded(const QNetworkConfiguration &config)
-
- This signal is emitted whenever a new network configuration is added to the system. The new
- configuration is specified by \a config.
-*/
-
-/*!
- \fn void QNetworkConfigurationManager::configurationRemoved(const QNetworkConfiguration &config)
-
- This signal is emitted when a configuration is about to be removed from the system. The removed
- configuration, specified by \a config, is invalid but retains name and identifier.
-*/
-
-/*!
- \fn void QNetworkConfigurationManager::updateCompleted()
-
- This signal is emitted when the configuration update has been completed. Such an update can
- be initiated via \l updateConfigurations().
-*/
-
-/*! \fn void QNetworkConfigurationManager::configurationChanged(const QNetworkConfiguration &config)
-
- This signal is emitted when the \l {QNetworkConfiguration::state()}{state} of \a config changes.
-*/
-
-/*!
- \fn void QNetworkConfigurationManager::onlineStateChanged(bool isOnline)
-
- This signal is emitted when the device changes from online to offline mode or vice versa.
- \a isOnline represents the new state of the device.
-
- The state is considered to be online for as long as
- \l{allConfigurations()}{allConfigurations}(QNetworkConfiguration::Active) returns a list with
- at least one entry.
-*/
-
-/*!
- \enum QNetworkConfigurationManager::Capability
-
- Specifies the system capabilities of the bearer API. The possible values are:
-
- \value CanStartAndStopInterfaces Network sessions and their underlying access points can be
- started and stopped. If this flag is not set QNetworkSession
- can only monitor but not influence the state of access points.
- On some platforms this feature may require elevated user
- permissions. This option is platform specific and may not
- always be available.
- \value DirectConnectionRouting Network sessions and their sockets can be bound to a
- particular network interface. Any packet that passes through
- the socket goes to the specified network interface and thus
- disregards standard routing table entries. This may be useful
- when two interfaces can reach overlapping IP ranges or an
- application has specific needs in regards to target networks.
- This option is platform specific and may not always be
- available.
- \value SystemSessionSupport If this flag is set the underlying platform ensures that a
- network interface is not shut down until the last network
- session has been \l{QNetworkSession::close()}{closed()}. This
- works across multiple processes. If the platform session
- support is missing this API can only ensure the above behavior
- for network sessions within the same process.
- In general mobile platforms have such
- support whereas most desktop platform lack this capability.
- \value ApplicationLevelRoaming The system gives applications control over the systems roaming
- behavior. Applications can initiate roaming (in case the
- current link is not suitable) and are consulted if the system
- has identified a more suitable access point.
- \value ForcedRoaming The system disconnects an existing access point and reconnects
- via a more suitable one. The application does not have any
- control over this process and has to reconnect its active
- sockets.
- \value DataStatistics If this flag is set QNetworkSession can provide statistics
- about transmitted and received data.
- \value NetworkSessionRequired If this flag is set the platform requires that a network
- session is created before network operations can be performed.
-*/
-
-/*!
- Constructs a QNetworkConfigurationManager with the given \a parent.
-
- Note that to ensure a valid list of current configurations immediately available, updating
- is done during construction which causes some delay.
-*/
-QNetworkConfigurationManager::QNetworkConfigurationManager(QObject *parent)
- : QObject(parent)
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv) {
- connect(priv, SIGNAL(configurationAdded(QNetworkConfiguration)),
- this, SIGNAL(configurationAdded(QNetworkConfiguration)));
- connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)),
- this, SIGNAL(configurationRemoved(QNetworkConfiguration)));
- connect(priv, SIGNAL(configurationChanged(QNetworkConfiguration)),
- this, SIGNAL(configurationChanged(QNetworkConfiguration)));
- connect(priv, SIGNAL(onlineStateChanged(bool)),
- this, SIGNAL(onlineStateChanged(bool)));
- connect(priv, SIGNAL(configurationUpdateComplete()),
- this, SIGNAL(updateCompleted()));
-
- priv->enablePolling();
- }
-}
-
-/*!
- Frees the resources associated with the QNetworkConfigurationManager object.
-*/
-QNetworkConfigurationManager::~QNetworkConfigurationManager()
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv)
- priv->disablePolling();
-}
-
-
-/*!
- Returns the default configuration to be used. This function always returns a discovered
- configuration; otherwise an invalid configuration.
-
- In some cases it may be required to call updateConfigurations() and wait for the
- updateCompleted() signal before calling this function.
-
- \sa allConfigurations()
-*/
-QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv)
- return priv->defaultConfiguration();
-
- return QNetworkConfiguration();
-}
-
-/*!
- Returns the list of configurations which comply with the given \a filter.
-
- By default this function returns all (defined and undefined) configurations.
-
- A wireless network with a particular SSID may only be accessible in a
- certain area despite the fact that the system has a valid configuration
- for it. Therefore the filter flag may be used to limit the list to
- discovered and possibly connected configurations only.
-
- If \a filter is set to zero this function returns all possible configurations.
-
- Note that this function returns the states for all configurations as they are known at
- the time of this function call. If for instance a configuration of type WLAN is defined
- the system may have to perform a WLAN scan in order to determine whether it is
- actually available. To obtain the most accurate state updateConfigurations() should
- be used to update each configuration's state. Note that such an update may require
- some time. It's completion is signalled by updateCompleted(). In the absence of a
- configuration update this function returns the best estimate at the time of the call.
- Therefore, if WLAN configurations are of interest, it is recommended that
- updateConfigurations() is called once after QNetworkConfigurationManager
- instantiation (WLAN scans are too time consuming to perform in constructor).
- After this the data is kept automatically up-to-date as the system reports
- any changes.
-*/
-QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNetworkConfiguration::StateFlags filter) const
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv)
- return priv->allConfigurations(filter);
-
- return QList<QNetworkConfiguration>();
-}
-
-/*!
- Returns the QNetworkConfiguration for \a identifier; otherwise returns an
- invalid QNetworkConfiguration.
-
- \sa QNetworkConfiguration::identifier()
-*/
-QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(const QString &identifier) const
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv)
- return priv->configurationFromIdentifier(identifier);
-
- return QNetworkConfiguration();
-}
-
-/*!
- Returns \c true if the system is considered to be connected to another device via an active
- network interface; otherwise returns \c false.
-
- This is equivalent to the following code snippet:
-
- \snippet code/src_network_bearer_qnetworkconfigmanager.cpp 0
-
- \sa onlineStateChanged()
-*/
-bool QNetworkConfigurationManager::isOnline() const
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv)
- return priv->isOnline();
-
- return false;
-}
-
-/*!
- Returns the capabilities supported by the current platform.
-*/
-QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabilities() const
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv)
- return priv->capabilities();
-
- return {};
-}
-
-/*!
- Initiates an update of all configurations. This may be used to initiate WLAN scans or other
- time consuming updates which may be required to obtain the correct state for configurations.
-
- This call is asynchronous. On completion of this update the updateCompleted() signal is
- emitted. If new configurations are discovered or old ones were removed or changed the update
- process may trigger the emission of one or multiple configurationAdded(),
- configurationRemoved() and configurationChanged() signals.
-
- If a configuration state changes as a result of this update all existing QNetworkConfiguration
- instances are updated automatically.
-
- \sa allConfigurations()
-*/
-void QNetworkConfigurationManager::updateConfigurations()
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv)
- priv->performAsyncConfigurationUpdate();
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qnetworkconfigmanager.cpp"
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h
deleted file mode 100644
index b8f09f3d68..0000000000
--- a/src/network/bearer/qnetworkconfigmanager.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKCONFIGMANAGER_H
-#define QNETWORKCONFIGMANAGER_H
-
-#if 0
-#pragma qt_class(QNetworkConfigurationManager)
-#endif
-
-#include <QtNetwork/qtnetworkglobal.h>
-#include <QtCore/qobject.h>
-#include <QtNetwork/qnetworkconfiguration.h>
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkConfigurationManagerPrivate;
-class QT_DEPRECATED_BEARER_MANAGEMENT Q_NETWORK_EXPORT QNetworkConfigurationManager : public QObject
-{
- Q_OBJECT
-
-public:
- enum Capability {
- CanStartAndStopInterfaces = 0x00000001,
- DirectConnectionRouting = 0x00000002,
- SystemSessionSupport = 0x00000004,
- ApplicationLevelRoaming = 0x00000008,
- ForcedRoaming = 0x00000010,
- DataStatistics = 0x00000020,
- NetworkSessionRequired = 0x00000040
- };
-
- Q_DECLARE_FLAGS(Capabilities, Capability)
-
- explicit QNetworkConfigurationManager(QObject *parent = nullptr);
- virtual ~QNetworkConfigurationManager();
-
- QNetworkConfigurationManager::Capabilities capabilities() const;
-
- QNetworkConfiguration defaultConfiguration() const;
- QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags flags = QNetworkConfiguration::StateFlags()) const;
- QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const;
-
- bool isOnline() const;
-
-public Q_SLOTS:
- void updateConfigurations();
-
-Q_SIGNALS:
- void configurationAdded(const QNetworkConfiguration &config);
- void configurationRemoved(const QNetworkConfiguration &config);
- void configurationChanged(const QNetworkConfiguration &config);
- void onlineStateChanged(bool isOnline);
- void updateCompleted();
-
-private:
- Q_DISABLE_COPY(QNetworkConfigurationManager)
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities)
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-QT_WARNING_POP
-
-#endif // QNETWORKCONFIGMANAGER_H
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
deleted file mode 100644
index f0aa452dd3..0000000000
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ /dev/null
@@ -1,517 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qnetworkconfigmanager_p.h"
-#include "qbearerplugin_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qstringlist.h>
-#include <QtCore/qthread.h>
-#include <QtCore/private/qcoreapplication_p.h>
-#include <QtCore/private/qlocking_p.h>
-#include <QtCore/private/qthread_p.h>
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qglobal.h>
-
-#include <utility>
-
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
- : QObject(), pollTimer(nullptr),
- loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")),
- forcedPolling(0), firstUpdate(true)
-{
- qRegisterMetaType<QNetworkConfiguration>();
- qRegisterMetaType<QNetworkConfigurationPrivatePointer>();
-}
-
-void QNetworkConfigurationManagerPrivate::initialize()
-{
- //Two stage construction, because we only want to do this heavyweight work for the winner of the Q_GLOBAL_STATIC race.
- bearerThread = new QDaemonThread();
- bearerThread->setObjectName(QStringLiteral("Qt bearer thread"));
-
- bearerThread->moveToThread(QCoreApplicationPrivate::mainThread()); // because cleanup() is called in main thread context.
- moveToThread(bearerThread);
- bearerThread->start();
- updateConfigurations();
-}
-
-QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
-{
- QMutexLocker locker(&mutex);
-
- qDeleteAll(sessionEngines);
- sessionEngines.clear();
- if (bearerThread)
- bearerThread->quit();
-}
-
-void QNetworkConfigurationManagerPrivate::cleanup()
-{
- QThread* thread = bearerThread;
- deleteLater();
- if (thread->wait(QDeadlineTimer(5000)))
- delete thread;
-}
-
-QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() const
-{
- QMutexLocker locker(&mutex);
-
- for (QBearerEngine *engine : sessionEngines) {
- QNetworkConfigurationPrivatePointer ptr = engine->defaultConfiguration();
- if (ptr) {
- QNetworkConfiguration config;
- config.d = ptr;
- return config;
- }
- }
-
- // Engines don't have a default configuration.
-
- // Return first active snap
- QNetworkConfigurationPrivatePointer defaultConfiguration;
-
- for (QBearerEngine *engine : sessionEngines) {
- const auto locker = qt_scoped_lock(engine->mutex);
-
- for (const auto &ptr : qAsConst(engine->snapConfigurations)) {
- const auto locker = qt_scoped_lock(ptr->mutex);
-
- if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- QNetworkConfiguration config;
- config.d = ptr;
- return config;
- } else if (!defaultConfiguration) {
- if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
- defaultConfiguration = ptr;
- }
- }
- }
-
- // No Active SNAPs return first Discovered SNAP.
- if (defaultConfiguration) {
- QNetworkConfiguration config;
- config.d = defaultConfiguration;
- return config;
- }
-
- /*
- No Active or Discovered SNAPs, find the perferred access point.
- The following priority order is used:
-
- 1. Active Ethernet
- 2. Active WLAN
- 3. Active Other
- 4. Discovered Ethernet
- 5. Discovered WLAN
- 6. Discovered Other
- */
-
- for (QBearerEngine *engine : sessionEngines) {
-
- QMutexLocker locker(&engine->mutex);
-
- for (const auto &ptr : qAsConst(engine->accessPointConfigurations)) {
-
- QMutexLocker configLocker(&ptr->mutex);
- QNetworkConfiguration::BearerType bearerType = ptr->bearerType;
-
- if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
- if (!defaultConfiguration) {
- defaultConfiguration = ptr;
- } else {
- QMutexLocker defaultConfigLocker(&defaultConfiguration->mutex);
-
- if (defaultConfiguration->state == ptr->state) {
- switch (defaultConfiguration->bearerType) {
- case QNetworkConfiguration::BearerEthernet:
- // do nothing
- break;
- case QNetworkConfiguration::BearerWLAN:
- // Ethernet beats WLAN
- defaultConfiguration = ptr;
- break;
- default:
- // Ethernet and WLAN beats other
- if (bearerType == QNetworkConfiguration::BearerEthernet ||
- bearerType == QNetworkConfiguration::BearerWLAN) {
- defaultConfiguration = ptr;
- }
- }
- } else {
- // active beats discovered
- if ((defaultConfiguration->state & QNetworkConfiguration::Active) !=
- QNetworkConfiguration::Active) {
- defaultConfiguration = ptr;
- }
- }
- }
- }
- }
- }
-
- // No Active InternetAccessPoint return first Discovered InternetAccessPoint.
- if (defaultConfiguration) {
- QNetworkConfiguration config;
- config.d = defaultConfiguration;
- return config;
- }
-
- return QNetworkConfiguration();
-}
-
-QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(QNetworkConfiguration::StateFlags filter) const
-{
- QList<QNetworkConfiguration> result;
-
- QMutexLocker locker(&mutex);
-
- for (QBearerEngine *engine : sessionEngines) {
-
- const auto locker = qt_scoped_lock(engine->mutex);
-
- //find all InternetAccessPoints
- for (const auto &ptr : qAsConst(engine->accessPointConfigurations)) {
- const auto locker = qt_scoped_lock(ptr->mutex);
-
- if ((ptr->state & filter) == filter) {
- QNetworkConfiguration pt;
- pt.d = ptr;
- result << pt;
- }
- }
-
- //find all service networks
- for (const auto &ptr : qAsConst(engine->snapConfigurations)) {
- const auto locker = qt_scoped_lock(ptr->mutex);
-
- if ((ptr->state & filter) == filter) {
- QNetworkConfiguration pt;
- pt.d = ptr;
- result << pt;
- }
- }
- }
-
- return result;
-}
-
-QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(const QString &identifier) const
-{
- QNetworkConfiguration item;
-
- const auto locker = qt_scoped_lock(mutex);
-
- for (QBearerEngine *engine : sessionEngines) {
- const auto locker = qt_scoped_lock(engine->mutex);
- if (auto ptr = engine->accessPointConfigurations.value(identifier)) {
- item.d = std::move(ptr);
- break;
- }
- if (auto ptr = engine->snapConfigurations.value(identifier)) {
- item.d = std::move(ptr);
- break;
- }
- if (auto ptr = engine->userChoiceConfigurations.value(identifier)) {
- item.d = std::move(ptr);
- break;
- }
- }
-
- return item;
-}
-
-bool QNetworkConfigurationManagerPrivate::isOnline() const
-{
- const auto locker = qt_scoped_lock(mutex);
-
- // We need allConfigurations since onlineConfigurations is filled with queued connections
- // and thus is not always (more importantly just after creation) up to date
- return !allConfigurations(QNetworkConfiguration::Active).isEmpty();
-}
-
-QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities() const
-{
- const auto locker = qt_scoped_lock(mutex);
-
- QNetworkConfigurationManager::Capabilities capFlags;
-
- for (QBearerEngine *engine : sessionEngines)
- capFlags |= engine->capabilities();
-
- return capFlags;
-}
-
-void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurationPrivatePointer ptr)
-{
- const auto locker = qt_scoped_lock(mutex);
-
- if (!firstUpdate) {
- QNetworkConfiguration item;
- item.d = ptr;
- emit configurationAdded(item);
- }
-
- auto ptrLocker = qt_unique_lock(ptr->mutex);
- if (ptr->state == QNetworkConfiguration::Active) {
- const auto id = ptr->id;
- ptrLocker.unlock();
- onlineConfigurations.insert(id);
- if (!firstUpdate && onlineConfigurations.count() == 1)
- emit onlineStateChanged(true);
- }
-}
-
-void QNetworkConfigurationManagerPrivate::configurationRemoved(QNetworkConfigurationPrivatePointer ptr)
-{
- const auto locker = qt_scoped_lock(mutex);
-
- {
- const auto locker = qt_scoped_lock(ptr->mutex);
- ptr->isValid = false;
- }
-
- if (!firstUpdate) {
- QNetworkConfiguration item;
- item.d = ptr;
- emit configurationRemoved(item);
- }
-
- onlineConfigurations.remove(ptr->id);
- if (!firstUpdate && onlineConfigurations.isEmpty())
- emit onlineStateChanged(false);
-}
-
-void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigurationPrivatePointer ptr)
-{
- const auto locker = qt_scoped_lock(mutex);
-
- if (!firstUpdate) {
- QNetworkConfiguration item;
- item.d = ptr;
- emit configurationChanged(item);
- }
-
- bool previous = !onlineConfigurations.isEmpty();
-
- {
- const auto locker = qt_scoped_lock(ptr->mutex);
- if (ptr->state == QNetworkConfiguration::Active)
- onlineConfigurations.insert(ptr->id);
- else
- onlineConfigurations.remove(ptr->id);
- }
-
- bool online = !onlineConfigurations.isEmpty();
-
- if (!firstUpdate && online != previous)
- emit onlineStateChanged(online);
-}
-
-void QNetworkConfigurationManagerPrivate::updateConfigurations()
-{
- typedef QMultiMap<int, QString> PluginKeyMap;
- typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
-
- auto locker = qt_unique_lock(mutex);
-
- if (firstUpdate) {
- if (qobject_cast<QBearerEngine *>(sender()))
- return;
-
- updating = false;
-
- bool envOK = false;
- const int skipGeneric = qEnvironmentVariableIntValue("QT_EXCLUDE_GENERIC_BEARER", &envOK);
- QBearerEngine *generic = nullptr;
- QFactoryLoader *l = &loader;
- const PluginKeyMap keyMap = l->keyMap();
- const PluginKeyMapConstIterator cend = keyMap.constEnd();
- QStringList addedEngines;
- for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) {
- const QString &key = it.value();
- if (addedEngines.contains(key))
- continue;
-
- addedEngines.append(key);
- if (QBearerEngine *engine = qLoadPlugin<QBearerEngine, QBearerEnginePlugin>(l, key)) {
- if (key == QLatin1String("generic"))
- generic = engine;
- else
- sessionEngines.append(engine);
-
- engine->moveToThread(bearerThread);
-
- connect(engine, SIGNAL(updateCompleted()),
- this, SLOT(updateConfigurations()),
- Qt::QueuedConnection);
- connect(engine, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)),
- this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer)),
- Qt::QueuedConnection);
- connect(engine, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
- this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)),
- Qt::QueuedConnection);
- connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
- this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)),
- Qt::QueuedConnection);
- }
- }
-
- if (generic) {
- if (!envOK || skipGeneric <= 0)
- sessionEngines.append(generic);
- else
- delete generic;
- }
- }
-
- QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender());
- if (engine && !updatingEngines.isEmpty())
- updatingEngines.remove(engine);
-
- if (updating && updatingEngines.isEmpty()) {
- updating = false;
- emit configurationUpdateComplete();
- }
-
- if (engine && !pollingEngines.isEmpty()) {
- pollingEngines.remove(engine);
- if (pollingEngines.isEmpty())
- startPolling();
- }
-
- if (firstUpdate) {
- firstUpdate = false;
- const QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex
- locker.unlock();
- for (QBearerEngine* engine : enginesToInitialize)
- QMetaObject::invokeMethod(engine, "initialize", Qt::BlockingQueuedConnection);
- }
-}
-
-void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate()
-{
- const auto locker = qt_scoped_lock(mutex);
-
- if (sessionEngines.isEmpty()) {
- emit configurationUpdateComplete();
- return;
- }
-
- updating = true;
-
- for (QBearerEngine *engine : qAsConst(sessionEngines)) {
- updatingEngines.insert(engine);
- QMetaObject::invokeMethod(engine, "requestUpdate");
- }
-}
-
-QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::engines() const
-{
- const auto locker = qt_scoped_lock(mutex);
-
- return sessionEngines;
-}
-
-void QNetworkConfigurationManagerPrivate::startPolling()
-{
- const auto locker = qt_scoped_lock(mutex);
- if (!pollTimer) {
- pollTimer = new QTimer(this);
- bool ok;
- int interval = qEnvironmentVariableIntValue("QT_BEARER_POLL_TIMEOUT", &ok);
- if (!ok)
- interval = 10000;//default 10 seconds
- pollTimer->setInterval(interval);
- pollTimer->setSingleShot(true);
- connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines()));
- }
-
- if (pollTimer->isActive())
- return;
-
- for (QBearerEngine *engine : qAsConst(sessionEngines)) {
- if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
- pollTimer->start();
- break;
- }
- }
- performAsyncConfigurationUpdate();
-}
-
-void QNetworkConfigurationManagerPrivate::pollEngines()
-{
- const auto locker = qt_scoped_lock(mutex);
-
- for (QBearerEngine *engine : qAsConst(sessionEngines)) {
- if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
- pollingEngines.insert(engine);
- QMetaObject::invokeMethod(engine, "requestUpdate");
- }
- }
-}
-
-void QNetworkConfigurationManagerPrivate::enablePolling()
-{
- const auto locker = qt_scoped_lock(mutex);
-
- ++forcedPolling;
-
- if (forcedPolling == 1)
- QMetaObject::invokeMethod(this, "startPolling");
-}
-
-void QNetworkConfigurationManagerPrivate::disablePolling()
-{
- const auto locker = qt_scoped_lock(mutex);
-
- --forcedPolling;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
deleted file mode 100644
index 4819c2027c..0000000000
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKCONFIGMANAGER_P_H
-#define QNETWORKCONFIGMANAGER_P_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/qtnetworkglobal_p.h>
-#include "qnetworkconfigmanager.h"
-#include "qnetworkconfiguration_p.h"
-
-#include <QtCore/private/qfactoryloader_p.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qset.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QBearerEngine;
-class QTimer;
-
-class Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate : public QObject
-{
- Q_OBJECT
-
-public:
- QNetworkConfigurationManagerPrivate();
- virtual ~QNetworkConfigurationManagerPrivate();
-
- QNetworkConfiguration defaultConfiguration() const;
- QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags filter) const;
- QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const;
-
- bool isOnline() const;
-
- QNetworkConfigurationManager::Capabilities capabilities() const;
-
- void performAsyncConfigurationUpdate();
-
- QList<QBearerEngine *> engines() const;
-
- void enablePolling();
- void disablePolling();
-
- void initialize();
- void cleanup();
-public Q_SLOTS:
- void updateConfigurations();
-
- static void addPreAndPostRoutine();
-
-Q_SIGNALS:
- void configurationAdded(const QNetworkConfiguration &config);
- void configurationRemoved(const QNetworkConfiguration &config);
- void configurationChanged(const QNetworkConfiguration &config);
- void configurationUpdateComplete();
- void onlineStateChanged(bool isOnline);
-
-private Q_SLOTS:
- void configurationAdded(QNetworkConfigurationPrivatePointer ptr);
- void configurationRemoved(QNetworkConfigurationPrivatePointer ptr);
- void configurationChanged(QNetworkConfigurationPrivatePointer ptr);
-
- void pollEngines();
-
-
-private:
- Q_INVOKABLE void startPolling();
- QTimer *pollTimer;
- QThread *bearerThread;
-
-private:
- mutable QRecursiveMutex mutex;
-
- QFactoryLoader loader;
- QList<QBearerEngine *> sessionEngines;
-
- QSet<QString> onlineConfigurations;
-
- QSet<QBearerEngine *> pollingEngines;
- QSet<QBearerEngine *> updatingEngines;
- int forcedPolling;
- bool updating;
-
- bool firstUpdate;
-};
-
-Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate();
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif // QNETWORKCONFMANAGER_P_H
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp
deleted file mode 100644
index f016dea590..0000000000
--- a/src/network/bearer/qnetworkconfiguration.cpp
+++ /dev/null
@@ -1,596 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtNetwork/private/qtnetworkglobal_p.h>
-
-#include "qnetworkconfiguration.h"
-#include "qnetworkconfiguration_p.h"
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QNetworkConfiguration
- \obsolete
-
- \brief The QNetworkConfiguration class provides an abstraction of one or more access point configurations.
-
- \since 4.7
-
- \inmodule QtNetwork
- \ingroup network
- \ingroup shared
-
- QNetworkConfiguration encapsulates a single access point or service network.
- In most cases a single access point configuration can be mapped to one network
- interface. However a single network interface may not always map to only one
- access point configuration. Multiple configurations for the same
- network device may enable multiple access points. An example
- device that could exhibit such a configuration might be a
- Smartphone which allows the user to manage multiple WLAN
- configurations while the device itself has only one WLAN network device.
-
- The QNetworkConfiguration also supports the concept of service networks.
- This concept allows the grouping of multiple access point configurations
- into one entity. Such a group is called service network and can be
- beneficial in cases whereby a network session to a
- particular destination network is required (e.g. a company network).
- When using a service network the user doesn't usually care which one of the
- connectivity options is chosen (e.g. corporate WLAN or VPN via GPRS)
- as long as he can reach the company's target server. Depending
- on the current position and time some of the access points that make
- up the service network may not even be available. Furthermore
- automated access point roaming can be enabled which enables the device
- to change the network interface configuration dynamically while maintaining
- the applications connection to the target network. It allows adaption
- to the changing environment and may enable optimization with regards to
- cost, speed or other network parameters.
-
- Special configurations of type UserChoice provide a placeholder configuration which is
- resolved to an actual network configuration by the platform when a
- \l {QNetworkSession}{session} is \l {QNetworkSession::open()}{opened}. Not all platforms
- support the concept of a user choice configuration.
-
- \section1 Configuration States
-
- The list of available configurations can be obtained via
- QNetworkConfigurationManager::allConfigurations(). A configuration can have
- multiple states. The \l Defined configuration state indicates that the configuration
- is stored on the device. However the configuration is not yet ready to be activated
- as e.g. a WLAN may not be available at the current time.
-
- The \l Discovered state implies that the configuration is \l Defined and
- the outside conditions are such that the configuration can be used immediately
- to open a new network session. An example of such an outside condition may be
- that the Ethernet cable is actually connected to the device or that the WLAN
- with the specified SSID is in range.
-
- The \l Active state implies that the configuration is \l Discovered. A configuration
- in this state is currently being used by an application. The underlying network
- interface has a valid IP configuration and can transfer IP packets between the
- device and the target network.
-
- The \l Undefined state indicates that the system has knowledge of possible target
- networks but cannot actually use that knowledge to connect to it. An example
- for such a state could be an encrypted WLAN that has been discovered
- but the user hasn't actually saved a configuration including the required password
- which would allow the device to connect to it.
-
- Depending on the type of configuration some states are transient in nature. A GPRS/UMTS
- connection may almost always be \l Discovered if the GSM/UMTS network is available.
- However if the GSM/UMTS network loses the connection the associated configuration may change its state
- from \l Discovered to \l Defined as well. A similar use case might be triggered by
- WLAN availability. QNetworkConfigurationManager::updateConfigurations() can be used to
- manually trigger updates of states. Note that some platforms do not require such updates
- as they implicitly change the state once it has been discovered. If the state of a
- configuration changes all related QNetworkConfiguration instances change their state automatically.
-
- \sa QNetworkSession, QNetworkConfigurationManager
-*/
-
-/*!
- \enum QNetworkConfiguration::Type
-
- This enum describes the type of configuration.
-
- \value InternetAccessPoint The configuration specifies the details for a single access point.
- Note that configurations of type InternetAccessPoint may be part
- of other QNetworkConfigurations of type ServiceNetwork.
- \value ServiceNetwork The configuration is based on a group of QNetworkConfigurations of
- type InternetAccessPoint. All group members can reach the same
- target network. This type of configuration is a mandatory
- requirement for roaming enabled network sessions. On some
- platforms this form of configuration may also be called Service
- Network Access Point (SNAP).
- \value UserChoice The configuration is a placeholder which will be resolved to an
- actual configuration by the platform when a session is opened. Depending
- on the platform the selection may generate a popup dialog asking the user
- for his preferred choice.
- \value Invalid The configuration is invalid.
-*/
-
-/*!
- \enum QNetworkConfiguration::StateFlag
-
- Specifies the configuration states.
-
- \value Undefined This state is used for transient configurations such as newly discovered
- WLANs for which the user has not actually created a configuration yet.
- \value Defined Defined configurations are known to the system but are not immediately
- usable (e.g. a configured WLAN is not within range or the Ethernet cable
- is currently not plugged into the machine).
- \value Discovered A discovered configuration can be immediately used to create a new
- QNetworkSession. An example of a discovered configuration could be a WLAN
- which is within in range. If the device moves out of range the discovered
- flag is dropped. A second example is a GPRS configuration which generally
- remains discovered for as long as the device has network coverage. A
- configuration that has this state is also in state
- QNetworkConfiguration::Defined. If the configuration is a service network
- this flag is set if at least one of the underlying access points
- configurations has the Discovered state.
- \value Active The configuration is currently used by an open network session
- (see \l QNetworkSession::isOpen()). However this does not mean that the
- current process is the entity that created the open session. It merely
- indicates that if a new QNetworkSession were to be constructed based on
- this configuration \l QNetworkSession::state() would return
- \l QNetworkSession::Connected. This state implies the
- QNetworkConfiguration::Discovered state.
-*/
-
-/*!
- \enum QNetworkConfiguration::Purpose
-
- Specifies the purpose of the configuration.
-
- \value UnknownPurpose The configuration doesn't specify any purpose. This is the default value.
- \value PublicPurpose The configuration can be used for general purpose internet access.
- \value PrivatePurpose The configuration is suitable to access a private network such as an office Intranet.
- \value ServiceSpecificPurpose The configuration can be used for operator specific services (e.g.
- receiving MMS messages or content streaming).
-*/
-
-/*!
- \enum QNetworkConfiguration::BearerType
-
- Specifies the type of bearer used by a configuration.
-
- \value BearerUnknown The type of bearer is unknown or unspecified. The bearerTypeName()
- function may return additional information.
- \value BearerEthernet The configuration is for an Ethernet interfaces.
- \value BearerWLAN The configuration is for a Wireless LAN interface.
- \value Bearer2G The configuration is for a CSD, GPRS, HSCSD, EDGE or cdmaOne interface.
- \value Bearer3G The configuration is for a 3G interface.
- \value Bearer4G The configuration is for a 4G interface.
- \value BearerCDMA2000 The configuration is for CDMA interface.
- \value BearerWCDMA The configuration is for W-CDMA/UMTS interface.
- \value BearerHSPA The configuration is for High Speed Packet Access (HSPA) interface.
- \value BearerBluetooth The configuration is for a Bluetooth interface.
- \value BearerWiMAX The configuration is for a WiMAX interface.
- \value BearerEVDO The configuration is for an EVDO (3G) interface.
- \value BearerLTE The configuration is for a LTE (4G) interface.
-*/
-
-/*!
- Constructs an invalid configuration object.
-
- \sa isValid()
-*/
-QNetworkConfiguration::QNetworkConfiguration()
- : d(nullptr)
-{
-}
-
-/*!
- Creates a copy of the QNetworkConfiguration object contained in \a other.
-*/
-QNetworkConfiguration::QNetworkConfiguration(const QNetworkConfiguration &other)
- : d(other.d)
-{
-}
-
-/*!
- Frees the resources associated with the QNetworkConfiguration object.
-*/
-QNetworkConfiguration::~QNetworkConfiguration()
-{
-}
-
-/*!
- Copies the content of the QNetworkConfiguration object contained in \a other into this one.
-*/
-QNetworkConfiguration &QNetworkConfiguration::operator=(const QNetworkConfiguration &other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- \fn void QNetworkConfiguration::swap(QNetworkConfiguration &other)
- \since 5.0
-
- Swaps this network configuration with \a other. This function is
- very fast and never fails.
-*/
-
-/*!
- Returns \c true, if this configuration is the same as the \a other
- configuration given; otherwise returns \c false.
-*/
-bool QNetworkConfiguration::operator==(const QNetworkConfiguration &other) const
-{
- return (d == other.d);
-}
-
-/*!
- \fn bool QNetworkConfiguration::operator!=(const QNetworkConfiguration &other) const
-
- Returns \c true if this configuration is not the same as the \a other
- configuration given; otherwise returns \c false.
-*/
-
-/*!
- Returns the user visible name of this configuration.
-
- The name may either be the name of the underlying access point or the
- name for service network that this configuration represents.
-*/
-QString QNetworkConfiguration::name() const
-{
- if (!d)
- return QString();
-
- QMutexLocker locker(&d->mutex);
- return d->name;
-}
-
-/*!
- Returns the unique and platform specific identifier for this network configuration;
- otherwise an empty string.
-*/
-QString QNetworkConfiguration::identifier() const
-{
- if (!d)
- return QString();
-
- QMutexLocker locker(&d->mutex);
- return d->id;
-}
-
-/*!
- Returns the type of the configuration.
-
- A configuration can represent a single access point configuration or
- a set of access point configurations. Such a set is called service network.
- A configuration that is based on a service network can potentially support
- roaming of network sessions.
-*/
-QNetworkConfiguration::Type QNetworkConfiguration::type() const
-{
- if (!d)
- return QNetworkConfiguration::Invalid;
-
- QMutexLocker locker(&d->mutex);
- return d->type;
-}
-
-/*!
- Returns \c true if this QNetworkConfiguration object is valid.
- A configuration may become invalid if the user deletes the configuration or
- the configuration was default-constructed.
-
- The addition and removal of configurations can be monitored via the
- QNetworkConfigurationManager.
-
- \sa QNetworkConfigurationManager
-*/
-bool QNetworkConfiguration::isValid() const
-{
- if (!d)
- return false;
-
- QMutexLocker locker(&d->mutex);
- return d->isValid;
-}
-
-/*!
- \since 5.9
-
- Returns the connect timeout of this configuration.
-
- \sa setConnectTimeout
-*/
-int QNetworkConfiguration::connectTimeout() const
-{
- if (!d)
- return QNetworkConfigurationPrivate::DefaultTimeout;
- QMutexLocker locker(&d->mutex);
- return d->timeout;
-}
-
-/*!
- \since 5.9
-
- Sets the connect timeout of this configuration to \a timeout.
- This allows control of the timeout used by \c QAbstractSocket
- to establish a connection.
-
- \note \a timeout is in millisecond.
-
- \warning This will have no effect if the bearer plugin doesn't have
- the CanStartAndStopInterfaces capability.
-
- Returns true if succeeded.
-
- \sa connectTimeout
-*/
-bool QNetworkConfiguration::setConnectTimeout(int timeout)
-{
- if (!d)
- return false;
- QMutexLocker locker(&d->mutex);
- d->timeout = timeout;
- return true;
-}
-
-/*!
- Returns the current state of the configuration.
-*/
-QNetworkConfiguration::StateFlags QNetworkConfiguration::state() const
-{
- if (!d)
- return QNetworkConfiguration::Undefined;
-
- QMutexLocker locker(&d->mutex);
- return d->state;
-}
-
-/*!
- Returns the purpose of this configuration.
-
- The purpose field may be used to programmatically determine the
- purpose of a configuration. Such information is usually part of the
- access point or service network meta data.
-*/
-QNetworkConfiguration::Purpose QNetworkConfiguration::purpose() const
-{
- if (!d)
- return QNetworkConfiguration::UnknownPurpose;
-
- QMutexLocker locker(&d->mutex);
- return d->purpose;
-}
-
-/*!
- Returns \c true if this configuration supports roaming; otherwise false.
-*/
-bool QNetworkConfiguration::isRoamingAvailable() const
-{
- if (!d)
- return false;
-
- QMutexLocker locker(&d->mutex);
- return d->roamingSupported;
-}
-
-/*!
- Returns all sub configurations of this network configuration in priority order. The first sub
- configuration in the list has the highest priority.
-
- Only network configurations of type \l ServiceNetwork can have children. Otherwise this
- function returns an empty list.
-*/
-QList<QNetworkConfiguration> QNetworkConfiguration::children() const
-{
- return {};
-}
-
-/*!
- Returns the type of bearer used by this network configuration.
-
- If the bearer type is \l {QNetworkConfiguration::BearerUnknown}{unknown} the bearerTypeName()
- function can be used to retrieve a textural type name for the bearer.
-
- An invalid network configuration always returns the BearerUnknown value.
-
- \sa bearerTypeName(), bearerTypeFamily()
-*/
-QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const
-{
- if (!isValid())
- return BearerUnknown;
-
- QMutexLocker locker(&d->mutex);
- return d->bearerType;
-}
-
-/*!
- \since 5.2
-
- Returns the bearer type family used by this network configuration.
- The following table lists how bearerType() values map to
- bearerTypeFamily() values:
-
- \table
- \header
- \li bearer type
- \li bearer type family
- \row
- \li BearerUnknown, Bearer2G, BearerEthernet, BearerWLAN,
- BearerBluetooth
- \li (same type)
- \row
- \li BearerCDMA2000, BearerEVDO, BearerWCDMA, BearerHSPA, Bearer3G
- \li Bearer3G
- \row
- \li BearerWiMAX, BearerLTE, Bearer4G
- \li Bearer4G
- \endtable
-
- An invalid network configuration always returns the BearerUnknown value.
-
- \sa bearerType(), bearerTypeName()
-*/
-QNetworkConfiguration::BearerType QNetworkConfiguration::bearerTypeFamily() const
-{
- QNetworkConfiguration::BearerType type = bearerType();
- switch (type) {
- case QNetworkConfiguration::BearerUnknown: // fallthrough
- case QNetworkConfiguration::Bearer2G: // fallthrough
- case QNetworkConfiguration::BearerEthernet: // fallthrough
- case QNetworkConfiguration::BearerWLAN: // fallthrough
- case QNetworkConfiguration::BearerBluetooth:
- return type;
- case QNetworkConfiguration::BearerCDMA2000: // fallthrough
- case QNetworkConfiguration::BearerEVDO: // fallthrough
- case QNetworkConfiguration::BearerWCDMA: // fallthrough
- case QNetworkConfiguration::BearerHSPA: // fallthrough
- case QNetworkConfiguration::Bearer3G:
- return QNetworkConfiguration::Bearer3G;
- case QNetworkConfiguration::BearerWiMAX: // fallthrough
- case QNetworkConfiguration::BearerLTE: // fallthrough
- case QNetworkConfiguration::Bearer4G:
- return QNetworkConfiguration::Bearer4G;
- default:
- qWarning() << "unknown bearer type" << type;
- return QNetworkConfiguration::BearerUnknown;
- }
-}
-/*!
- Returns the type of bearer used by this network configuration as a string.
-
- The string is not translated and therefore cannot be shown to the user. The subsequent table
- shows the fixed mappings between BearerType and the bearer type name for known types. If the
- BearerType is unknown this function may return additional information if it is available;
- otherwise an empty string will be returned.
-
- \table
- \header
- \li BearerType
- \li Value
- \row
- \li BearerUnknown
- \li The session is based on an unknown or unspecified bearer type. The value of the
- string returned describes the bearer type.
- \row
- \li BearerEthernet
- \li Ethernet
- \row
- \li BearerWLAN
- \li WLAN
- \row
- \li Bearer2G
- \li 2G
- \row
- \li Bearer3G
- \li 3G
- \row
- \li Bearer4G
- \li 4G
- \row
- \li BearerCDMA2000
- \li CDMA2000
- \row
- \li BearerWCDMA
- \li WCDMA
- \row
- \li BearerHSPA
- \li HSPA
- \row
- \li BearerBluetooth
- \li Bluetooth
- \row
- \li BearerWiMAX
- \li WiMAX
- \row
- \li BearerEVDO
- \li EVDO
- \row
- \li BearerLTE
- \li LTE
- \endtable
-
- This function returns an empty string if this is an invalid configuration, a network
- configuration of type \l QNetworkConfiguration::ServiceNetwork or
- \l QNetworkConfiguration::UserChoice.
-
- \sa bearerType(), bearerTypeFamily()
-*/
-QString QNetworkConfiguration::bearerTypeName() const
-{
- if (!isValid())
- return QString();
-
- QMutexLocker locker(&d->mutex);
-
- if (d->type == QNetworkConfiguration::ServiceNetwork ||
- d->type == QNetworkConfiguration::UserChoice)
- return QString();
-
- switch (d->bearerType) {
- case BearerEthernet:
- return QStringLiteral("Ethernet");
- case BearerWLAN:
- return QStringLiteral("WLAN");
- case Bearer2G:
- return QStringLiteral("2G");
- case Bearer3G:
- return QStringLiteral("3G");
- case Bearer4G:
- return QStringLiteral("4G");
- case BearerCDMA2000:
- return QStringLiteral("CDMA2000");
- case BearerWCDMA:
- return QStringLiteral("WCDMA");
- case BearerHSPA:
- return QStringLiteral("HSPA");
- case BearerBluetooth:
- return QStringLiteral("Bluetooth");
- case BearerWiMAX:
- return QStringLiteral("WiMAX");
- case BearerEVDO:
- return QStringLiteral("EVDO");
- case BearerLTE:
- return QStringLiteral("LTE");
- case BearerUnknown:
- break;
- }
- return QStringLiteral("Unknown");
-}
-
-QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
deleted file mode 100644
index 69864a3165..0000000000
--- a/src/network/bearer/qnetworkconfiguration.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKCONFIGURATION_H
-#define QNETWORKCONFIGURATION_H
-
-#if 0
-#pragma qt_class(QNetworkConfiguration)
-#endif
-
-#include <QtNetwork/qtnetworkglobal.h>
-
-#include <QtCore/qshareddata.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qmetatype.h>
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-class QT_DEPRECATED_BEARER_MANAGEMENT Q_NETWORK_EXPORT QNetworkConfiguration
-{
-public:
- QNetworkConfiguration();
- QNetworkConfiguration(const QNetworkConfiguration& other);
- QNetworkConfiguration &operator=(QNetworkConfiguration &&other) noexcept { swap(other); return *this; }
- QNetworkConfiguration &operator=(const QNetworkConfiguration &other);
- ~QNetworkConfiguration();
-
- void swap(QNetworkConfiguration &other) noexcept { qSwap(d, other.d); }
-
- bool operator==(const QNetworkConfiguration &other) const;
- inline bool operator!=(const QNetworkConfiguration &other) const
- { return !operator==(other); }
-
- enum Type {
- InternetAccessPoint = 0,
- ServiceNetwork,
- UserChoice,
- Invalid
- };
-
- enum Purpose {
- UnknownPurpose = 0,
- PublicPurpose,
- PrivatePurpose,
- ServiceSpecificPurpose
- };
-
- enum StateFlag {
- Undefined = 0x0000001,
- Defined = 0x0000002,
- Discovered = 0x0000006,
- Active = 0x000000e
- };
- Q_DECLARE_FLAGS(StateFlags, StateFlag)
-
- enum BearerType {
- BearerUnknown,
- BearerEthernet,
- BearerWLAN,
- Bearer2G,
- BearerCDMA2000,
- BearerWCDMA,
- BearerHSPA,
- BearerBluetooth,
- BearerWiMAX,
- BearerEVDO,
- BearerLTE,
- Bearer3G,
- Bearer4G
- };
-
- StateFlags state() const;
- Type type() const;
- Purpose purpose() const;
-
- BearerType bearerType() const;
- BearerType bearerTypeFamily() const;
- QString bearerTypeName() const;
-
- QString identifier() const;
- bool isRoamingAvailable() const;
- QList<QNetworkConfiguration> children() const;
-
- QString name() const;
- bool isValid() const;
-
- int connectTimeout() const;
- bool setConnectTimeout(int timeout);
-
-private:
- friend class QNetworkConfigurationPrivate;
- friend class QNetworkConfigurationManager;
- friend class QNetworkConfigurationManagerPrivate;
- friend class QNetworkSessionPrivate;
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> d;
-};
-
-Q_DECLARE_SHARED(QNetworkConfiguration)
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QNetworkConfiguration)
-
-QT_WARNING_POP
-
-#endif // QNETWORKCONFIGURATION_H
diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h
deleted file mode 100644
index 96854fe831..0000000000
--- a/src/network/bearer/qnetworkconfiguration_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKCONFIGURATIONPRIVATE_H
-#define QNETWORKCONFIGURATIONPRIVATE_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/qtnetworkglobal_p.h>
-#include "qnetworkconfiguration.h"
-
-#include <QtCore/qshareddata.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qmap.h>
-
-QT_BEGIN_NAMESPACE
-
-typedef QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfigurationPrivatePointer;
-class QNetworkConfigurationPrivate : public QSharedData
-{
-public:
- QNetworkConfigurationPrivate() :
- type(QNetworkConfiguration::Invalid),
- purpose(QNetworkConfiguration::UnknownPurpose),
- bearerType(QNetworkConfiguration::BearerUnknown),
- isValid(false), roamingSupported(false),
- timeout(DefaultTimeout)
- {}
-
- mutable QRecursiveMutex mutex;
-
- QString name;
- QString id;
-
- QNetworkConfiguration::StateFlags state;
- QNetworkConfiguration::Type type;
- QNetworkConfiguration::Purpose purpose;
- QNetworkConfiguration::BearerType bearerType;
-
- bool isValid;
- bool roamingSupported;
- int timeout;
-
- static Q_CONSTEXPR int DefaultTimeout = 30000;
-
-private:
- Q_DISABLE_COPY_MOVE(QNetworkConfigurationPrivate)
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QNetworkConfigurationPrivatePointer)
-
-#endif // QNETWORKCONFIGURATIONPRIVATE_H
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
deleted file mode 100644
index 4e8ed1619b..0000000000
--- a/src/network/bearer/qnetworksession.cpp
+++ /dev/null
@@ -1,743 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtNetwork/private/qtnetworkglobal_p.h>
-
-#include "qnetworksession.h"
-#include "qnetworksession_p.h"
-#include "qbearerengine_p.h"
-
-#include <QEventLoop>
-#include <QMetaMethod>
-#include <QTimer>
-#include <QThread>
-
-#include "qnetworkconfigmanager_p.h"
-
-// for QNetworkSession::interface
-#ifdef interface
-# undef interface
-#endif
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QNetworkSession
- \obsolete
-
- \brief The QNetworkSession class provides control over the system's access points
- and enables session management for cases when multiple clients access the same access point.
-
- \since 4.7
-
- \inmodule QtNetwork
- \ingroup network
-
- A QNetworkSession enables control over the system's network interfaces. The session's configuration
- parameter are determined via the QNetworkConfiguration object to which it is bound. Depending on the
- type of the session (single access point or service network) a session may be linked to one or more
- network interfaces. By means of \l{open()}{opening} and \l{close()}{closing} of network sessions
- a developer can start and stop the systems network interfaces. If the configuration represents
- multiple access points (see \l QNetworkConfiguration::ServiceNetwork) more advanced features such as roaming may be supported.
-
- QNetworkSession supports session management within the same process and depending on the platform's
- capabilities may support out-of-process sessions. If the same
- network configuration is used by multiple open sessions the underlying network interface is only terminated once
- the last session has been closed.
-
- \section1 Roaming
-
- Applications may connect to the preferredConfigurationChanged() signal in order to
- receive notifications when a more suitable access point becomes available.
- In response to this signal the application must either initiate the roaming via migrate()
- or ignore() the new access point. Once the session has roamed the
- newConfigurationActivated() signal is emitted. The application may now test the
- carrier and must either accept() or reject() it. The session will return to the previous
- access point if the roaming was rejected. The subsequent state diagram depicts the required
- state transitions.
-
- \image roaming-states.png
-
- Some platforms may distinguish forced roaming and application level roaming (ALR).
- ALR implies that the application controls (via migrate(), ignore(), accept() and reject())
- whether a network session can roam from one access point to the next. Such control is useful
- if the application maintains stateful socket connections and wants to control the transition from
- one interface to the next. Forced roaming implies that the system automatically roams to the next network without
- consulting the application. This has the advantage that the application can make use of roaming features
- without actually being aware of it. It is expected that the application detects that the underlying
- socket is broken and automatically reconnects via the new network link.
-
- If the platform supports both modes of roaming, an application indicates its preference
- by connecting to the preferredConfigurationChanged() signal. Connecting to this signal means that
- the application wants to take control over the roaming behavior and therefore implies application
- level roaming. If the client does not connect to the preferredConfigurationChanged(), forced roaming
- is used. If forced roaming is not supported the network session will not roam by default.
-
- Some applications may want to suppress any form of roaming altogether. Possible use cases may be
- high priority downloads or remote services which cannot handle a roaming enabled client. Clients
- can suppress roaming by connecting to the preferredConfigurationChanged() signal and answer each
- signal emission with ignore().
-
- \sa QNetworkConfiguration, QNetworkConfigurationManager
-*/
-
-/*!
- \enum QNetworkSession::State
-
- This enum describes the connectivity state of the session. If the session is based on a
- single access point configuration the state of the session is the same as the state of the
- associated network interface.
-
- \value Invalid The session is invalid due to an invalid configuration. This may
- happen due to a removed access point or a configuration that was
- invalid to begin with.
- \value NotAvailable The session is based on a defined but not yet discovered QNetworkConfiguration
- (see \l QNetworkConfiguration::StateFlag).
- \value Connecting The network session is being established.
- \value Connected The network session is connected. If the current process wishes to use this session
- it has to register its interest by calling open(). A network session
- is considered to be ready for socket operations if it isOpen() and connected.
- \value Closing The network session is in the process of being shut down.
- \value Disconnected The network session is not connected. The associated QNetworkConfiguration
- has the state QNetworkConfiguration::Discovered.
- \value Roaming The network session is roaming from one access point to another
- access point.
-*/
-
-/*!
- \enum QNetworkSession::SessionError
-
- This enum describes the session errors that can occur.
-
- \value UnknownSessionError An unidentified error occurred.
- \value SessionAbortedError The session was aborted by the user or system.
- \value RoamingError The session cannot roam to a new configuration.
- \value OperationNotSupportedError The operation is not supported for current configuration.
- \value InvalidConfigurationError The operation cannot currently be performed for the
- current configuration.
-*/
-
-/*!
- \enum QNetworkSession::UsagePolicy
- \since 5.0
-
- These flags allow the system to inform the application of network usage restrictions that
- may be in place.
-
- \value NoPolicy No policy in force, usage is unrestricted.
- \value NoBackgroundTrafficPolicy Background network traffic (not user initiated) should be avoided
- for example to save battery or data charges
-*/
-
-/*!
- \fn void QNetworkSession::stateChanged(QNetworkSession::State state)
-
- This signal is emitted whenever the state of the network session changes.
- The \a state parameter is the new state.
-
- \sa state()
-*/
-
-/*!
- \fn void QNetworkSession::error(QNetworkSession::SessionError error)
-
- This signal is emitted after an error occurred. The \a error parameter
- describes the error that occurred.
-
- \sa error(), errorString()
-*/
-
-/*!
- \fn void QNetworkSession::preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless)
-
- This signal is emitted when the preferred configuration/access point for the
- session changes. Only sessions which are based on service network configurations
- may emit this signal. \a config can be used to determine access point specific
- details such as proxy settings and \a isSeamless indicates whether roaming will
- break the sessions IP address.
-
- As a consequence to this signal the application must either start the roaming process
- by calling migrate() or choose to ignore() the new access point.
-
- If the roaming process is non-seamless the IP address will change which means that
- a socket becomes invalid. However seamless mobility can ensure that the local IP address
- does not change. This is achieved by using a virtual IP address which is bound to the actual
- link address. During the roaming process the virtual address is attached to the new link
- address.
-
- Some platforms may support the concept of Forced Roaming and Application Level Roaming (ALR).
- Forced roaming implies that the platform may simply roam to a new configuration without
- consulting applications. It is up to the application to detect the link layer loss and reestablish
- its sockets. In contrast ALR provides the opportunity to prevent the system from roaming.
- If this session is based on a configuration that supports roaming the application can choose
- whether it wants to be consulted (ALR use case) by connecting to this signal. For as long as this signal
- connection remains the session remains registered as a roaming stakeholder; otherwise roaming will
- be enforced by the platform.
-
- \sa migrate(), ignore(), QNetworkConfiguration::isRoamingAvailable()
-*/
-
-/*!
- \fn void QNetworkSession::newConfigurationActivated()
-
- This signal is emitted once the session has roamed to the new access point.
- The application may reopen its socket and test the suitability of the new network link.
- Subsequently it must either accept() or reject() the new access point.
-
- \sa accept(), reject()
-*/
-
-/*!
- \fn void QNetworkSession::opened()
-
- This signal is emitted when the network session has been opened.
-
- The underlying network interface will not be shut down as long as the session remains open.
- Note that this feature is dependent on \l{QNetworkConfigurationManager::SystemSessionSupport}{system wide session support}.
-*/
-
-/*!
- \fn void QNetworkSession::closed()
-
- This signal is emitted when the network session has been closed.
-*/
-
-/*!
- \fn void QNetworkSession::usagePoliciesChanged(QNetworkSession::UsagePolicies usagePolicies)
- \since 5.0
-
- This signal is emitted when the \a usagePolicies in force are changed by the system.
-*/
-
-/*!
- Constructs a session based on \a connectionConfig with the given \a parent.
-
- \sa QNetworkConfiguration
-*/
-QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, QObject *parent)
- : QObject(parent), d(nullptr)
-{
- qRegisterMetaType<QNetworkSession::State>();
- qRegisterMetaType<QNetworkSession::SessionError>();
- qRegisterMetaType<QNetworkSession::UsagePolicies>();
-
- // invalid configuration
- if (!connectionConfig.identifier().isEmpty()) {
- auto priv = qNetworkConfigurationManagerPrivate();
- const auto engines = priv ? priv->engines() : QList<QBearerEngine *>();
- for (QBearerEngine *engine : engines) {
- if (engine->hasIdentifier(connectionConfig.identifier())) {
- d = engine->createSessionBackend();
- d->q = this;
- d->publicConfig = connectionConfig;
- d->syncStateWithInterface();
- connect(d, SIGNAL(quitPendingWaitsForOpened()), this, SIGNAL(opened()));
- connect(d, SIGNAL(error(QNetworkSession::SessionError)),
- this, SIGNAL(error(QNetworkSession::SessionError)));
- connect(d, SIGNAL(stateChanged(QNetworkSession::State)),
- this, SIGNAL(stateChanged(QNetworkSession::State)));
- connect(d, SIGNAL(closed()), this, SIGNAL(closed()));
- connect(d, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)),
- this, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)));
- connect(d, SIGNAL(newConfigurationActivated()),
- this, SIGNAL(newConfigurationActivated()));
- connect(d, SIGNAL(usagePoliciesChanged(QNetworkSession::UsagePolicies)),
- this, SIGNAL(usagePoliciesChanged(QNetworkSession::UsagePolicies)));
- break;
- }
- }
- }
-}
-
-/*!
- Frees the resources associated with the QNetworkSession object.
-*/
-QNetworkSession::~QNetworkSession()
-{
- delete d;
-}
-
-/*!
- Creates an open session which increases the session counter on the underlying network interface.
- The system will not terminate a network interface until the session reference counter reaches zero.
- Therefore an open session allows an application to register its use of the interface.
-
- As a result of calling open() the interface will be started if it is not connected/up yet.
- Some platforms may not provide support for out-of-process sessions. On such platforms the session
- counter ignores any sessions held by another process. The platform capabilities can be
- detected via QNetworkConfigurationManager::capabilities().
-
- Note that this call is asynchronous. Depending on the outcome of this call the results can be enquired
- by connecting to the stateChanged(), opened() or error() signals.
-
- It is not a requirement to open a session in order to monitor the underlying network interface.
-
- \sa close(), stop(), isOpen()
-*/
-void QNetworkSession::open()
-{
- if (d)
- d->open();
- else
- emit error(InvalidConfigurationError);
-}
-
-/*!
- Waits until the session has been opened, up to \a msecs milliseconds. If the session has been opened, this
- function returns \c true; otherwise it returns \c false. In the case where it returns \c false, you can call error()
- to determine the cause of the error.
-
- The following example waits up to one second for the session to be opened:
-
- \snippet code/src_network_bearer_qnetworksession.cpp 0
-
- If \a msecs is -1, this function will not time out.
-
- \sa open(), error()
-*/
-bool QNetworkSession::waitForOpened(int msecs)
-{
- if (!d)
- return false;
-
- if (d->isOpen)
- return true;
-
- if (!(d->state == Connecting || d->state == Connected)) {
- return false;
- }
-
- QEventLoop loop;
- QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()), &loop, SLOT(quit()));
- QObject::connect(this, SIGNAL(error(QNetworkSession::SessionError)), &loop, SLOT(quit()));
-
- //final call
- if (msecs >= 0)
- QTimer::singleShot(msecs, &loop, SLOT(quit()));
-
- // enter the event loop and wait for opened/error/timeout
- loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
-
- return d->isOpen;
-}
-
-/*!
- Decreases the session counter on the associated network configuration. If the session counter reaches zero
- the active network interface is shut down. This also means that state() will only change from \l Connected to
- \l Disconnected if the current session was the last open session.
-
- If the platform does not support out-of-process sessions calling this function does not stop the
- interface. In this case \l{stop()} has to be used to force a shut down.
- The platform capabilities can be detected via QNetworkConfigurationManager::capabilities().
-
- Note that this call is asynchronous. Depending on the outcome of this call the results can be enquired
- by connecting to the stateChanged(), opened() or error() signals.
-
- \sa open(), stop(), isOpen()
-*/
-void QNetworkSession::close()
-{
- if (d)
- d->close();
-}
-
-/*!
- Invalidates all open sessions against the network interface and therefore stops the
- underlying network interface. This function always changes the session's state() flag to
- \l Disconnected.
-
- \sa open(), close()
-*/
-void QNetworkSession::stop()
-{
- if (d)
- d->stop();
-}
-
-/*!
- Returns the QNetworkConfiguration that this network session object is based on.
-
- \sa QNetworkConfiguration
-*/
-QNetworkConfiguration QNetworkSession::configuration() const
-{
- return d ? d->publicConfig : QNetworkConfiguration();
-}
-
-#ifndef QT_NO_NETWORKINTERFACE
-/*!
- Returns the network interface that is used by this session.
-
- This function only returns a valid QNetworkInterface when this session is \l Connected.
-
- The returned interface may change as a result of a roaming process.
-
- \sa state()
-*/
-QNetworkInterface QNetworkSession::interface() const
-{
- return d ? d->currentInterface() : QNetworkInterface();
-}
-#endif
-
-/*!
- Returns \c true if this session is open. If the number of all open sessions is greater than
- zero the underlying network interface will remain connected/up.
-
- The session can be controlled via open() and close().
-*/
-bool QNetworkSession::isOpen() const
-{
- return d ? d->isOpen : false;
-}
-
-/*!
- Returns the state of the session.
-
- If the session is based on a single access point configuration the state of the
- session is the same as the state of the associated network interface. Therefore
- a network session object can be used to monitor network interfaces.
-
- A \l QNetworkConfiguration::ServiceNetwork based session summarizes the state of all its children
- and therefore returns the \l Connected state if at least one of the service network's
- \l {QNetworkConfiguration::children()}{children()} configurations is active.
-
- Note that it is not required to hold an open session in order to obtain the network interface state.
- A connected but closed session may be used to monitor network interfaces whereas an open and connected
- session object may prevent the network interface from being shut down.
-
- \sa error(), stateChanged()
-*/
-QNetworkSession::State QNetworkSession::state() const
-{
- return d ? d->state : QNetworkSession::Invalid;
-}
-
-/*!
- Returns the type of error that last occurred.
-
- \sa state(), errorString()
-*/
-QNetworkSession::SessionError QNetworkSession::error() const
-{
- return d ? d->error() : InvalidConfigurationError;
-}
-
-/*!
- Returns a human-readable description of the last device error that
- occurred.
-
- \sa error()
-*/
-QString QNetworkSession::errorString() const
-{
- return d ? d->errorString() : tr("Invalid configuration.");
-}
-
-/*!
- Returns the value for property \a key.
-
- A network session can have properties attached which may describe the session in more details.
- This function can be used to gain access to those properties.
-
- The following property keys are guaranteed to be specified on all platforms:
-
- \table 80%
- \header
- \li Key \li Description
- \row
- \li ActiveConfiguration
- \li If the session \l isOpen() this property returns the identifier of the
- QNetworkConfiguration that is used by this session; otherwise an empty string.
-
- The main purpose of this key is to determine which Internet access point is used
- if the session is based on a \l{QNetworkConfiguration::ServiceNetwork}{ServiceNetwork}.
- The following code snippet highlights the difference:
- \snippet code/src_network_bearer_qnetworksession.cpp 1
- \row
- \li UserChoiceConfiguration
- \li If the session \l isOpen() and is bound to a QNetworkConfiguration of type
- UserChoice, this property returns the identifier of the QNetworkConfiguration that the
- configuration resolved to when \l open() was called; otherwise an empty string.
-
- The purpose of this key is to determine the real QNetworkConfiguration that the
- session is using. This key is different from \e ActiveConfiguration in that
- this key may return an identifier for either a
- \l {QNetworkConfiguration::ServiceNetwork}{service network} or a
- \l {QNetworkConfiguration::InternetAccessPoint}{Internet access points} configurations,
- whereas \e ActiveConfiguration always returns identifiers to
- \l {QNetworkConfiguration::InternetAccessPoint}{Internet access points} configurations.
- \row
- \li ConnectInBackground
- \li Setting this property to \e true before calling \l open() implies that the connection attempt
- is made but if no connection can be established, the user is not connsulted and asked to select
- a suitable connection. This property is not set by default and support for it depends on the platform.
-
- \row
- \li AutoCloseSessionTimeout
- \li If the session requires polling to keep its state up to date, this property holds
- the timeout in milliseconds before the session will automatically close. If the
- value of this property is -1 the session will not automatically close. This property
- is set to -1 by default.
-
- The purpose of this property is to minimize resource use on platforms that use
- polling to update the state of the session. Applications can set the value of this
- property to the desired timeout before the session is closed. In response to the
- closed() signal the network session should be deleted to ensure that all polling is
- stopped. The session can then be recreated once it is required again. This property
- has no effect for sessions that do not require polling.
- \endtable
-*/
-QVariant QNetworkSession::sessionProperty(const QString &key) const
-{
- if (!d || !d->publicConfig.isValid())
- return QVariant();
-
- if (key == QLatin1String("ActiveConfiguration"))
- return d->isOpen ? d->activeConfig.identifier() : QString();
-
- if (key == QLatin1String("UserChoiceConfiguration")) {
- if (!d->isOpen || d->publicConfig.type() != QNetworkConfiguration::UserChoice)
- return QString();
-
- if (d->serviceConfig.isValid())
- return d->serviceConfig.identifier();
- else
- return d->activeConfig.identifier();
- }
-
- return d->sessionProperty(key);
-}
-
-/*!
- Sets the property \a value on the session. The property is identified using
- \a key. Removing an already set property can be achieved by passing an
- invalid QVariant.
-
- Note that the \e UserChoiceConfiguration and \e ActiveConfiguration
- properties are read only and cannot be changed using this method.
-*/
-void QNetworkSession::setSessionProperty(const QString &key, const QVariant &value)
-{
- if (!d)
- return;
-
- if (key == QLatin1String("ActiveConfiguration") ||
- key == QLatin1String("UserChoiceConfiguration")) {
- return;
- }
-
- d->setSessionProperty(key, value);
-}
-
-/*!
- Instructs the session to roam to the new access point. The old access point remains active
- until the application calls accept().
-
- The newConfigurationActivated() signal is emitted once roaming has been completed.
-
- \sa accept()
-*/
-void QNetworkSession::migrate()
-{
- if (d)
- d->migrate();
-}
-
-/*!
- This function indicates that the application does not wish to roam the session.
-
- \sa migrate()
-*/
-void QNetworkSession::ignore()
-{
- if (d)
- d->ignore();
-}
-
-/*!
- Instructs the session to permanently accept the new access point. Once this function
- has been called the session may not return to the old access point.
-
- The old access point may be closed in the process if there are no other network sessions for it.
- Therefore any open socket that still uses the old access point
- may become unusable and should be closed before completing the migration.
-*/
-void QNetworkSession::accept()
-{
- if (d)
- d->accept();
-}
-
-/*!
- The new access point is not suitable for the application. By calling this function the
- session returns to the previous access point/configuration. This action may invalidate
- any socket that has been created via the not desired access point.
-
- \sa accept()
-*/
-void QNetworkSession::reject()
-{
- if (d)
- d->reject();
-}
-
-
-/*!
- Returns the amount of data sent in bytes; otherwise 0.
-
- This field value includes the usage across all open network
- sessions which use the same network interface.
-
- If the session is based on a service network configuration the number of
- sent bytes across all active member configurations are returned.
-
- This function may not always be supported on all platforms and returns 0.
- The platform capability can be detected via QNetworkConfigurationManager::DataStatistics.
-
- \note On some platforms this function may run the main event loop.
-*/
-quint64 QNetworkSession::bytesWritten() const
-{
- return d ? d->bytesWritten() : Q_UINT64_C(0);
-}
-
-/*!
- Returns the amount of data received in bytes; otherwise 0.
-
- This field value includes the usage across all open network
- sessions which use the same network interface.
-
- If the session is based on a service network configuration the number of
- sent bytes across all active member configurations are returned.
-
- This function may not always be supported on all platforms and returns 0.
- The platform capability can be detected via QNetworkConfigurationManager::DataStatistics.
-
- \note On some platforms this function may run the main event loop.
-*/
-quint64 QNetworkSession::bytesReceived() const
-{
- return d ? d->bytesReceived() : Q_UINT64_C(0);
-}
-
-/*!
- Returns the number of seconds that the session has been active.
-*/
-quint64 QNetworkSession::activeTime() const
-{
- return d ? d->activeTime() : Q_UINT64_C(0);
-}
-
-/*!
- Returns the network usage policies currently in force by the system.
-*/
-QNetworkSession::UsagePolicies QNetworkSession::usagePolicies() const
-{
- return d ? d->usagePolicies() : QNetworkSession::NoPolicy;
-}
-
-/*!
- \internal
- Change usage policies for unit testing.
- In normal use, the policies are published by the bearer plugin
-*/
-void QNetworkSessionPrivate::setUsagePolicies(QNetworkSession &session, QNetworkSession::UsagePolicies policies)
-{
- if (!session.d)
- return;
- session.d->setUsagePolicies(policies);
-}
-
-/*!
- \internal
-
- This function is required to detect whether the client wants to control
- the roaming process. If he connects to preferredConfigurationChanged() signal
- he intends to influence it. Otherwise QNetworkSession always roams
- without registering this session as a stakeholder in the roaming process.
-
- For more details check the Forced vs ALR roaming section in the QNetworkSession
- class description.
-*/
-void QNetworkSession::connectNotify(const QMetaMethod &signal)
-{
- QObject::connectNotify(signal);
-
- if (!d)
- return;
-
- //check for preferredConfigurationChanged() signal connect notification
- //This is not required on all platforms
- static const QMetaMethod preferredConfigurationChangedSignal =
- QMetaMethod::fromSignal(&QNetworkSession::preferredConfigurationChanged);
- if (signal == preferredConfigurationChangedSignal)
- d->setALREnabled(true);
-}
-
-/*!
- \internal
-
- This function is called when the client disconnects from the
- preferredConfigurationChanged() signal.
-
- \sa connectNotify()
-*/
-void QNetworkSession::disconnectNotify(const QMetaMethod &signal)
-{
- QObject::disconnectNotify(signal);
-
- if (!d)
- return;
-
- //check for preferredConfigurationChanged() signal disconnect notification
- //This is not required on all platforms
- static const QMetaMethod preferredConfigurationChangedSignal =
- QMetaMethod::fromSignal(&QNetworkSession::preferredConfigurationChanged);
- if (signal == preferredConfigurationChangedSignal)
- d->setALREnabled(false);
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qnetworksession.cpp"
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h
deleted file mode 100644
index 65d90b0a82..0000000000
--- a/src/network/bearer/qnetworksession.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKSESSION_H
-#define QNETWORKSESSION_H
-
-#if 0
-#pragma qt_class(QNetworkSession)
-#endif
-
-#include <QtNetwork/qtnetworkglobal.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qstring.h>
-#include <QtNetwork/qnetworkinterface.h>
-#include <QtCore/qvariant.h>
-#include <QtNetwork/qnetworkconfiguration.h>
-
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-#if defined(Q_OS_WIN) && defined(interface)
-#undef interface
-#endif
-
-#include <QtCore/qshareddata.h>
-QT_BEGIN_NAMESPACE
-
-class QNetworkSessionPrivate;
-class QT_DEPRECATED_BEARER_MANAGEMENT Q_NETWORK_EXPORT QNetworkSession : public QObject
-{
- Q_OBJECT
-
-public:
- enum State {
- Invalid = 0,
- NotAvailable,
- Connecting,
- Connected,
- Closing,
- Disconnected,
- Roaming
- };
-
- enum SessionError {
- UnknownSessionError = 0,
- SessionAbortedError,
- RoamingError,
- OperationNotSupportedError,
- InvalidConfigurationError
- };
-
- enum UsagePolicy {
- NoPolicy = 0,
- NoBackgroundTrafficPolicy = 1
- };
-
- Q_DECLARE_FLAGS(UsagePolicies, UsagePolicy)
-
- explicit QNetworkSession(const QNetworkConfiguration &connConfig, QObject *parent = nullptr);
- virtual ~QNetworkSession();
-
- bool isOpen() const;
- QNetworkConfiguration configuration() const;
-#ifndef QT_NO_NETWORKINTERFACE
- QNetworkInterface interface() const;
-#endif
-
- State state() const;
- SessionError error() const;
- QString errorString() const;
- QVariant sessionProperty(const QString &key) const;
- void setSessionProperty(const QString &key, const QVariant &value);
-
- quint64 bytesWritten() const;
- quint64 bytesReceived() const;
- quint64 activeTime() const;
-
- QNetworkSession::UsagePolicies usagePolicies() const;
-
- bool waitForOpened(int msecs = 30000);
-
-public Q_SLOTS:
- void open();
- void close();
- void stop();
-
- //roaming related slots
- void migrate();
- void ignore();
- void accept();
- void reject();
-
-Q_SIGNALS:
- void stateChanged(QNetworkSession::State);
- void opened();
- void closed();
- void error(QNetworkSession::SessionError);
- void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
- void newConfigurationActivated();
- void usagePoliciesChanged(QNetworkSession::UsagePolicies usagePolicies);
-
-protected:
- virtual void connectNotify(const QMetaMethod &signal) override;
- virtual void disconnectNotify(const QMetaMethod &signal) override;
-
-private:
- Q_DISABLE_COPY(QNetworkSession)
- friend class QNetworkSessionPrivate;
- QNetworkSessionPrivate *d;
-};
-
-QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QNetworkSession::State)
-Q_DECLARE_METATYPE(QNetworkSession::SessionError)
-Q_DECLARE_METATYPE(QNetworkSession::UsagePolicies)
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-QT_WARNING_POP
-
-#endif // QNETWORKSESSION_H
diff --git a/src/network/bearer/qnetworksession_impl.cpp b/src/network/bearer/qnetworksession_impl.cpp
deleted file mode 100644
index 45a00b45fd..0000000000
--- a/src/network/bearer/qnetworksession_impl.cpp
+++ /dev/null
@@ -1,439 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// see comment in ../platformdefs_win.h.
-#define WIN32_LEAN_AND_MEAN 1
-
-#include "qnetworksession_impl_p.h"
-#include "qbearerengine_impl_p.h"
-
-#include <QtNetwork/qnetworksession.h>
-#include <QtNetwork/private/qnetworkconfigmanager_p.h>
-
-#include <QtCore/qdatetime.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qstringlist.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-static QBearerEngineImpl *getEngineFromId(const QString &id)
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
- if (priv) {
- const auto engines = priv->engines();
- for (QBearerEngine *engine : engines) {
- QBearerEngineImpl *engineImpl = qobject_cast<QBearerEngineImpl *>(engine);
- if (engineImpl && engineImpl->hasIdentifier(id))
- return engineImpl;
- }
- }
-
- return nullptr;
-}
-
-class QNetworkSessionManagerPrivate : public QObject
-{
- Q_OBJECT
-
-public:
- QNetworkSessionManagerPrivate(QObject *parent = nullptr) : QObject(parent) {}
- ~QNetworkSessionManagerPrivate() {}
-
- inline void forceSessionClose(const QNetworkConfiguration &config)
- { emit forcedSessionClose(config); }
-
-Q_SIGNALS:
- void forcedSessionClose(const QNetworkConfiguration &config);
-};
-
-Q_GLOBAL_STATIC(QNetworkSessionManagerPrivate, sessionManager);
-
-void QNetworkSessionPrivateImpl::syncStateWithInterface()
-{
- connect(sessionManager(), SIGNAL(forcedSessionClose(QNetworkConfiguration)),
- this, SLOT(forcedSessionClose(QNetworkConfiguration)));
-
- opened = false;
- isOpen = false;
- state = QNetworkSession::Invalid;
- lastError = QNetworkSession::UnknownSessionError;
-
- qRegisterMetaType<QBearerEngineImpl::ConnectionError>();
-
- switch (publicConfig.type()) {
- case QNetworkConfiguration::InternetAccessPoint:
- activeConfig = publicConfig;
- engine = getEngineFromId(activeConfig.identifier());
- if (engine) {
- qRegisterMetaType<QNetworkConfigurationPrivatePointer>();
- connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
- this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)),
- Qt::QueuedConnection);
- connect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
- this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)),
- Qt::QueuedConnection);
- }
- break;
- case QNetworkConfiguration::ServiceNetwork:
- serviceConfig = publicConfig;
- // Defer setting engine and signals until open().
- Q_FALLTHROUGH();
- case QNetworkConfiguration::UserChoice:
- // Defer setting serviceConfig and activeConfig until open().
- Q_FALLTHROUGH();
- default:
- engine = nullptr;
- }
-
- networkConfigurationsChanged();
-}
-
-void QNetworkSessionPrivateImpl::open()
-{
- if (serviceConfig.isValid()) {
- lastError = QNetworkSession::OperationNotSupportedError;
- emit QNetworkSessionPrivate::error(lastError);
- } else if (!isOpen) {
- if ((activeConfig.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) {
- lastError = QNetworkSession::InvalidConfigurationError;
- state = QNetworkSession::Invalid;
- emit stateChanged(state);
- emit QNetworkSessionPrivate::error(lastError);
- return;
- }
- opened = true;
-
- if ((activeConfig.state() & QNetworkConfiguration::Active) != QNetworkConfiguration::Active &&
- (activeConfig.state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
- state = QNetworkSession::Connecting;
- emit stateChanged(state);
-
- engine->connectToId(activeConfig.identifier());
- }
-
- isOpen = (activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
- if (isOpen)
- emit quitPendingWaitsForOpened();
- }
-}
-
-void QNetworkSessionPrivateImpl::close()
-{
- if (serviceConfig.isValid()) {
- lastError = QNetworkSession::OperationNotSupportedError;
- emit QNetworkSessionPrivate::error(lastError);
- } else if (isOpen) {
- opened = false;
- isOpen = false;
- emit closed();
- }
-}
-
-void QNetworkSessionPrivateImpl::stop()
-{
- if (serviceConfig.isValid()) {
- lastError = QNetworkSession::OperationNotSupportedError;
- emit QNetworkSessionPrivate::error(lastError);
- } else {
- if ((activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- state = QNetworkSession::Closing;
- emit stateChanged(state);
-
- engine->disconnectFromId(activeConfig.identifier());
-
- sessionManager()->forceSessionClose(activeConfig);
- }
-
- opened = false;
- isOpen = false;
- emit closed();
- }
-}
-
-void QNetworkSessionPrivateImpl::migrate()
-{
-}
-
-void QNetworkSessionPrivateImpl::accept()
-{
-}
-
-void QNetworkSessionPrivateImpl::ignore()
-{
-}
-
-void QNetworkSessionPrivateImpl::reject()
-{
-}
-
-#ifndef QT_NO_NETWORKINTERFACE
-QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
-{
- if (!engine || state != QNetworkSession::Connected || !publicConfig.isValid())
- return QNetworkInterface();
-
- QString iface = engine->getInterfaceFromId(activeConfig.identifier());
- if (iface.isEmpty())
- return QNetworkInterface();
- return QNetworkInterface::interfaceFromName(iface);
-}
-#endif
-
-QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString &key) const
-{
- if (key == QLatin1String("AutoCloseSessionTimeout")) {
- if (engine && engine->requiresPolling() &&
- !(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
- return sessionTimeout >= 0 ? sessionTimeout * 10000 : -1;
- }
- }
-
- return QVariant();
-}
-
-void QNetworkSessionPrivateImpl::setSessionProperty(const QString &key, const QVariant &value)
-{
- if (key == QLatin1String("AutoCloseSessionTimeout")) {
- if (engine && engine->requiresPolling() &&
- !(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
- int timeout = value.toInt();
- if (timeout >= 0) {
- connect(engine, SIGNAL(updateCompleted()),
- this, SLOT(decrementTimeout()), Qt::UniqueConnection);
- sessionTimeout = timeout / 10000; // convert to poll intervals
- } else {
- disconnect(engine, SIGNAL(updateCompleted()), this, SLOT(decrementTimeout()));
- sessionTimeout = -1;
- }
- }
- }
-}
-
-QString QNetworkSessionPrivateImpl::errorString() const
-{
- switch (lastError) {
- case QNetworkSession::UnknownSessionError:
- return tr("Unknown session error.");
- case QNetworkSession::SessionAbortedError:
- return tr("The session was aborted by the user or system.");
- case QNetworkSession::OperationNotSupportedError:
- return tr("The requested operation is not supported by the system.");
- case QNetworkSession::InvalidConfigurationError:
- return tr("The specified configuration cannot be used.");
- case QNetworkSession::RoamingError:
- return tr("Roaming was aborted or is not possible.");
- default:
- break;
- }
-
- return QString();
-}
-
-QNetworkSession::SessionError QNetworkSessionPrivateImpl::error() const
-{
- return lastError;
-}
-
-quint64 QNetworkSessionPrivateImpl::bytesWritten() const
-{
- if (engine && state == QNetworkSession::Connected)
- return engine->bytesWritten(activeConfig.identifier());
- return Q_UINT64_C(0);
-}
-
-quint64 QNetworkSessionPrivateImpl::bytesReceived() const
-{
- if (engine && state == QNetworkSession::Connected)
- return engine->bytesReceived(activeConfig.identifier());
- return Q_UINT64_C(0);
-}
-
-quint64 QNetworkSessionPrivateImpl::activeTime() const
-{
- if (state == QNetworkSession::Connected && startTime != Q_UINT64_C(0))
- return QDateTime::currentSecsSinceEpoch() - startTime;
- return Q_UINT64_C(0);
-}
-
-QNetworkSession::UsagePolicies QNetworkSessionPrivateImpl::usagePolicies() const
-{
- return currentPolicies;
-}
-
-void QNetworkSessionPrivateImpl::setUsagePolicies(QNetworkSession::UsagePolicies newPolicies)
-{
- if (newPolicies != currentPolicies) {
- currentPolicies = newPolicies;
- emit usagePoliciesChanged(currentPolicies);
- }
-}
-
-void QNetworkSessionPrivateImpl::updateStateFromServiceNetwork()
-{
- QNetworkSession::State oldState = state;
-
- const auto configs = serviceConfig.children();
- for (const QNetworkConfiguration &config : configs) {
- if ((config.state() & QNetworkConfiguration::Active) != QNetworkConfiguration::Active)
- continue;
-
- if (activeConfig != config) {
- if (engine) {
- disconnect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
- this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)));
- }
-
- activeConfig = config;
- engine = getEngineFromId(activeConfig.identifier());
-
- if (engine) {
- connect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
- this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)),
- Qt::QueuedConnection);
- }
- emit newConfigurationActivated();
- }
-
- state = QNetworkSession::Connected;
- if (state != oldState)
- emit stateChanged(state);
-
- return;
- }
-
- if (serviceConfig.children().isEmpty())
- state = QNetworkSession::NotAvailable;
- else
- state = QNetworkSession::Disconnected;
-
- if (state != oldState)
- emit stateChanged(state);
-}
-
-void QNetworkSessionPrivateImpl::updateStateFromActiveConfig()
-{
- if (!engine)
- return;
-
- QNetworkSession::State oldState = state;
- state = engine->sessionStateForId(activeConfig.identifier());
-
- bool oldActive = isOpen;
- isOpen = (state == QNetworkSession::Connected) ? opened : false;
-
- if (!oldActive && isOpen)
- emit quitPendingWaitsForOpened();
- if (oldActive && !isOpen)
- emit closed();
-
- if (oldState != state)
- emit stateChanged(state);
-}
-
-void QNetworkSessionPrivateImpl::networkConfigurationsChanged()
-{
- if (serviceConfig.isValid())
- updateStateFromServiceNetwork();
- else
- updateStateFromActiveConfig();
-
- if (engine)
- startTime = engine->startTime(activeConfig.identifier());
-}
-
-void QNetworkSessionPrivateImpl::configurationChanged(QNetworkConfigurationPrivatePointer config)
-{
- if (serviceConfig.isValid() &&
- (config->id == serviceConfig.identifier() || config->id == activeConfig.identifier())) {
- updateStateFromServiceNetwork();
- } else if (config->id == activeConfig.identifier()) {
- updateStateFromActiveConfig();
- }
-}
-
-void QNetworkSessionPrivateImpl::forcedSessionClose(const QNetworkConfiguration &config)
-{
- if (activeConfig == config) {
- opened = false;
- isOpen = false;
-
- emit closed();
-
- lastError = QNetworkSession::SessionAbortedError;
- emit QNetworkSessionPrivate::error(lastError);
- }
-}
-
-void QNetworkSessionPrivateImpl::connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
-{
- if (activeConfig.identifier() == id) {
- networkConfigurationsChanged();
- switch (error) {
- case QBearerEngineImpl::OperationNotSupported:
- lastError = QNetworkSession::OperationNotSupportedError;
- opened = false;
- break;
- case QBearerEngineImpl::InterfaceLookupError:
- case QBearerEngineImpl::ConnectError:
- case QBearerEngineImpl::DisconnectionError:
- default:
- lastError = QNetworkSession::UnknownSessionError;
- }
-
- emit QNetworkSessionPrivate::error(lastError);
- }
-}
-
-void QNetworkSessionPrivateImpl::decrementTimeout()
-{
- if (--sessionTimeout <= 0) {
- disconnect(engine, SIGNAL(updateCompleted()), this, SLOT(decrementTimeout()));
- sessionTimeout = -1;
- close();
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qnetworksession_impl.moc"
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/network/bearer/qnetworksession_impl_p.h b/src/network/bearer/qnetworksession_impl_p.h
deleted file mode 100644
index b174760152..0000000000
--- a/src/network/bearer/qnetworksession_impl_p.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKSESSION_IMPL_H
-#define QNETWORKSESSION_IMPL_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 "qbearerengine_impl_p.h"
-
-#include <QtNetwork/private/qnetworkconfigmanager_p.h>
-#include <QtNetwork/private/qnetworksession_p.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QBearerEngineImpl;
-
-class Q_NETWORK_EXPORT QNetworkSessionPrivateImpl : public QNetworkSessionPrivate
-{
- Q_OBJECT
-
-public:
- QNetworkSessionPrivateImpl()
- : engine(nullptr), startTime(0), lastError(QNetworkSession::UnknownSessionError), sessionTimeout(-1), currentPolicies(QNetworkSession::NoPolicy), opened(false)
- {}
- ~QNetworkSessionPrivateImpl()
- {}
-
- //called by QNetworkSession constructor and ensures
- //that the state is immediately updated (w/o actually opening
- //a session). Also this function should take care of
- //notification hooks to discover future state changes.
- void syncStateWithInterface() override;
-
-#ifndef QT_NO_NETWORKINTERFACE
- QNetworkInterface currentInterface() const override;
-#endif
- QVariant sessionProperty(const QString& key) const override;
- void setSessionProperty(const QString& key, const QVariant& value) override;
-
- void open() override;
- void close() override;
- void stop() override;
- void migrate() override;
- void accept() override;
- void ignore() override;
- void reject() override;
-
- QString errorString() const override; //must return translated string
- QNetworkSession::SessionError error() const override;
-
- quint64 bytesWritten() const override;
- quint64 bytesReceived() const override;
- quint64 activeTime() const override;
-
- QNetworkSession::UsagePolicies usagePolicies() const override;
- void setUsagePolicies(QNetworkSession::UsagePolicies) override;
-
-private Q_SLOTS:
- void networkConfigurationsChanged();
- void configurationChanged(QNetworkConfigurationPrivatePointer config);
- void forcedSessionClose(const QNetworkConfiguration &config);
- void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error);
- void decrementTimeout();
-
-private:
- void updateStateFromServiceNetwork();
- void updateStateFromActiveConfig();
-
-private:
- QBearerEngineImpl *engine;
-
- quint64 startTime;
-
- QNetworkSession::SessionError lastError;
-
- int sessionTimeout;
- QNetworkSession::UsagePolicies currentPolicies;
-
- bool opened;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif // QNETWORKSESSION_IMPL_H
diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h
deleted file mode 100644
index 7c1ff63b68..0000000000
--- a/src/network/bearer/qnetworksession_p.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKSESSIONPRIVATE_H
-#define QNETWORKSESSIONPRIVATE_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/qtnetworkglobal_p.h>
-#include "qnetworksession.h"
-#include "qnetworkconfiguration_p.h"
-#include "QtCore/qsharedpointer.h"
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class Q_NETWORK_EXPORT QNetworkSessionPrivate : public QObject
-{
- Q_OBJECT
-
- friend class QNetworkSession;
-
-public:
- QNetworkSessionPrivate() : QObject(),
- state(QNetworkSession::Invalid), isOpen(false)
- {}
- virtual ~QNetworkSessionPrivate()
- {}
-
- //called by QNetworkSession constructor and ensures
- //that the state is immediately updated (w/o actually opening
- //a session). Also this function should take care of
- //notification hooks to discover future state changes.
- virtual void syncStateWithInterface() = 0;
-
-#ifndef QT_NO_NETWORKINTERFACE
- virtual QNetworkInterface currentInterface() const = 0;
-#endif
- virtual QVariant sessionProperty(const QString &key) const = 0;
- virtual void setSessionProperty(const QString &key, const QVariant &value) = 0;
-
- virtual void open() = 0;
- virtual void close() = 0;
- virtual void stop() = 0;
-
- virtual void setALREnabled(bool /*enabled*/) {}
- virtual void migrate() = 0;
- virtual void accept() = 0;
- virtual void ignore() = 0;
- virtual void reject() = 0;
-
- virtual QString errorString() const = 0; //must return translated string
- virtual QNetworkSession::SessionError error() const = 0;
-
- virtual quint64 bytesWritten() const = 0;
- virtual quint64 bytesReceived() const = 0;
- virtual quint64 activeTime() const = 0;
-
- virtual QNetworkSession::UsagePolicies usagePolicies() const = 0;
- virtual void setUsagePolicies(QNetworkSession::UsagePolicies) = 0;
-
- static void setUsagePolicies(QNetworkSession&, QNetworkSession::UsagePolicies); //for unit testing
-protected:
- inline QNetworkConfigurationPrivatePointer privateConfiguration(const QNetworkConfiguration &config) const
- {
- return config.d;
- }
-
- inline void setPrivateConfiguration(QNetworkConfiguration &config,
- const QNetworkConfigurationPrivatePointer &ptr) const
- {
- config.d = ptr;
- }
-
-Q_SIGNALS:
- //releases any pending waitForOpened() calls
- void quitPendingWaitsForOpened();
-
- void error(QNetworkSession::SessionError error);
- void stateChanged(QNetworkSession::State state);
- void closed();
- void newConfigurationActivated();
- void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
- void usagePoliciesChanged(QNetworkSession::UsagePolicies);
-
-protected:
- QNetworkSession *q;
-
- // The config set on QNetworkSession.
- QNetworkConfiguration publicConfig;
-
- // If publicConfig is a ServiceNetwork this is a copy of publicConfig.
- // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual
- // ServiceNetwork configuration.
- QNetworkConfiguration serviceConfig;
-
- // This is the actual active configuration currently in use by the session.
- // Either a copy of publicConfig or one of serviceConfig.children().
- QNetworkConfiguration activeConfig;
-
- QNetworkSession::State state;
- bool isOpen;
-
- QRecursiveMutex mutex;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif // QNETWORKSESSIONPRIVATE_H
diff --git a/src/network/bearer/qsharednetworksession.cpp b/src/network/bearer/qsharednetworksession.cpp
deleted file mode 100644
index b3e9892f4b..0000000000
--- a/src/network/bearer/qsharednetworksession.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsharednetworksession_p.h"
-#include "qbearerengine_p.h"
-#include <QThreadStorage>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-QThreadStorage<QSharedNetworkSessionManager *> tls;
-
-inline QSharedNetworkSessionManager* sharedNetworkSessionManager()
-{
- QSharedNetworkSessionManager* rv = tls.localData();
- if (!rv) {
- rv = new QSharedNetworkSessionManager;
- tls.setLocalData(rv);
- }
- return rv;
-}
-
-struct DeleteLater {
- void operator()(QObject* obj) const
- {
- obj->deleteLater();
- }
-};
-
-template <typename Container>
-static void maybe_prune_expired(Container &c)
-{
- if (c.size() > 16) {
- for (auto it = c.cbegin(), end = c.cend(); it != end; /*erasing*/) {
- if (!it->second.lock())
- it = c.erase(it);
- else
- ++it;
- }
- }
-}
-
-QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(const QNetworkConfiguration &config)
-{
- QSharedNetworkSessionManager *m = sharedNetworkSessionManager();
- maybe_prune_expired(m->sessions);
- auto &entry = m->sessions[config];
- //if already have a session, return it
- if (auto p = entry.toStrongRef())
- return p;
- //otherwise make one
- QSharedPointer<QNetworkSession> session(new QNetworkSession(config), DeleteLater{});
- entry = session;
- return session;
-}
-
-void QSharedNetworkSessionManager::setSession(const QNetworkConfiguration &config, QSharedPointer<QNetworkSession> session)
-{
- QSharedNetworkSessionManager *m = sharedNetworkSessionManager();
- m->sessions[config] = std::move(session);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/network/bearer/qsharednetworksession_p.h b/src/network/bearer/qsharednetworksession_p.h
deleted file mode 100644
index f22f9eeacb..0000000000
--- a/src/network/bearer/qsharednetworksession_p.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSHAREDNETWORKSESSIONPRIVATE_H
-#define QSHAREDNETWORKSESSIONPRIVATE_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/qtnetworkglobal_p.h>
-#include "qnetworksession.h"
-#include "qnetworkconfiguration.h"
-#include <QSharedPointer>
-#include <QWeakPointer>
-#include <QMutex>
-
-#include <unordered_map>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-namespace QtPrivate {
-struct NetworkConfigurationHash {
- using result_type = size_t;
- using argument_type = QNetworkConfiguration;
- size_t operator()(const QNetworkConfiguration &config) const noexcept
- {
- return std::hash<size_t>{}(size_t(config.type()) | (size_t(config.bearerType()) << 8) | (size_t(config.purpose()) << 16));
- }
-};
-}
-
-class QSharedNetworkSessionManager
-{
-public:
- static QSharedPointer<QNetworkSession> getSession(const QNetworkConfiguration &config);
- static void setSession(const QNetworkConfiguration &config, QSharedPointer<QNetworkSession> session);
-private:
- std::unordered_map<QNetworkConfiguration, QWeakPointer<QNetworkSession>, QtPrivate::NetworkConfigurationHash> sessions;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif //QSHAREDNETWORKSESSIONPRIVATE_H
-