diff options
Diffstat (limited to 'src/network/bearer')
-rw-r--r-- | src/network/bearer/qbearerengine.cpp | 104 | ||||
-rw-r--r-- | src/network/bearer/qbearerengine_p.h | 34 | ||||
-rw-r--r-- | src/network/bearer/qbearerplugin.cpp | 34 | ||||
-rw-r--r-- | src/network/bearer/qbearerplugin_p.h | 34 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager.cpp | 34 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager.h | 34 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 124 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.h | 34 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration.cpp | 149 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration.h | 34 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration_p.h | 45 | ||||
-rw-r--r-- | src/network/bearer/qnetworksession.cpp | 37 | ||||
-rw-r--r-- | src/network/bearer/qnetworksession.h | 34 | ||||
-rw-r--r-- | src/network/bearer/qnetworksession_p.h | 36 | ||||
-rw-r--r-- | src/network/bearer/qsharednetworksession.cpp | 43 | ||||
-rw-r--r-- | src/network/bearer/qsharednetworksession_p.h | 38 |
16 files changed, 392 insertions, 456 deletions
diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp index c6236009eb..215cd3fddd 100644 --- a/src/network/bearer/qbearerengine.cpp +++ b/src/network/bearer/qbearerengine.cpp @@ -1,42 +1,67 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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 <algorithm> #ifndef QT_NO_BEARERMANAGEMENT QT_BEGIN_NAMESPACE +static void cleanUpConfigurations(QHash<QString, QNetworkConfigurationPrivatePointer> &configurations) +{ + for (const auto &ptr : qAsConst(configurations)) { + ptr->isValid = false; + ptr->id.clear(); + } + configurations.clear(); +} + +static bool hasUsedConfiguration(const QHash<QString, QNetworkConfigurationPrivatePointer> &configurations) +{ + auto isUsed = [](const QNetworkConfigurationPrivatePointer &ptr) { + return ptr->ref.load() > 1; + }; + const auto end = configurations.end(); + return std::find_if(configurations.begin(), end, isUsed) != end; +} + QBearerEngine::QBearerEngine(QObject *parent) : QObject(parent), mutex(QMutex::Recursive) { @@ -44,28 +69,9 @@ QBearerEngine::QBearerEngine(QObject *parent) QBearerEngine::~QBearerEngine() { - QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it; - QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end; - - for (it = snapConfigurations.begin(), end = snapConfigurations.end(); it != end; ++it) { - it.value()->isValid = false; - it.value()->id.clear(); - } - snapConfigurations.clear(); - - for (it = accessPointConfigurations.begin(), end = accessPointConfigurations.end(); - it != end; ++it) { - it.value()->isValid = false; - it.value()->id.clear(); - } - accessPointConfigurations.clear(); - - for (it = userChoiceConfigurations.begin(), end = userChoiceConfigurations.end(); - it != end; ++it) { - it.value()->isValid = false; - it.value()->id.clear(); - } - userChoiceConfigurations.clear(); + cleanUpConfigurations(snapConfigurations); + cleanUpConfigurations(accessPointConfigurations); + cleanUpConfigurations(userChoiceConfigurations); } bool QBearerEngine::requiresPolling() const @@ -81,30 +87,10 @@ bool QBearerEngine::requiresPolling() const */ bool QBearerEngine::configurationsInUse() const { - QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator it; - QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator end; - QMutexLocker locker(&mutex); - - for (it = accessPointConfigurations.constBegin(), - end = accessPointConfigurations.constEnd(); it != end; ++it) { - if (it.value()->ref.load() > 1) - return true; - } - - for (it = snapConfigurations.constBegin(), - end = snapConfigurations.constEnd(); it != end; ++it) { - if (it.value()->ref.load() > 1) - return true; - } - - for (it = userChoiceConfigurations.constBegin(), - end = userChoiceConfigurations.constEnd(); it != end; ++it) { - if (it.value()->ref.load() > 1) - return true; - } - - return false; + return hasUsedConfiguration(accessPointConfigurations) + || hasUsedConfiguration(snapConfigurations) + || hasUsedConfiguration(userChoiceConfigurations); } #include "moc_qbearerengine_p.cpp" diff --git a/src/network/bearer/qbearerengine_p.h b/src/network/bearer/qbearerengine_p.h index b4f82a6388..b36fedb741 100644 --- a/src/network/bearer/qbearerengine_p.h +++ b/src/network/bearer/qbearerengine_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/src/network/bearer/qbearerplugin.cpp b/src/network/bearer/qbearerplugin.cpp index f73d242db0..ec0d06e94c 100644 --- a/src/network/bearer/qbearerplugin.cpp +++ b/src/network/bearer/qbearerplugin.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/src/network/bearer/qbearerplugin_p.h b/src/network/bearer/qbearerplugin_p.h index ade59851e2..caaa71ca1f 100644 --- a/src/network/bearer/qbearerplugin_p.h +++ b/src/network/bearer/qbearerplugin_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 2ee448a267..7d7b7cc5b0 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h index 84080ba83e..4d841d8e33 100644 --- a/src/network/bearer/qnetworkconfigmanager.h +++ b/src/network/bearer/qnetworkconfigmanager.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index ccda9dd509..2da073fa5a 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -46,16 +52,13 @@ #include <QtCore/qbytearray.h> #include <QtCore/qglobal.h> +#include <utility> + #ifndef QT_NO_BEARERMANAGEMENT QT_BEGIN_NAMESPACE -#ifndef QT_NO_LIBRARY -Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, - (QBearerEngineFactoryInterface_iid, QLatin1String("/bearer"))) -#endif - QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() : QObject(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) { @@ -97,7 +100,7 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration( { QMutexLocker locker(&mutex); - foreach (QBearerEngine *engine, sessionEngines) { + for (QBearerEngine *engine : sessionEngines) { QNetworkConfigurationPrivatePointer ptr = engine->defaultConfiguration(); if (ptr) { QNetworkConfiguration config; @@ -111,16 +114,10 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration( // Return first active snap QNetworkConfigurationPrivatePointer defaultConfiguration; - foreach (QBearerEngine *engine, sessionEngines) { - QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it; - QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end; - + for (QBearerEngine *engine : sessionEngines) { QMutexLocker locker(&engine->mutex); - for (it = engine->snapConfigurations.begin(), - end = engine->snapConfigurations.end(); it != end; ++it) { - QNetworkConfigurationPrivatePointer ptr = it.value(); - + for (const auto &ptr : qAsConst(engine->snapConfigurations)) { QMutexLocker configLocker(&ptr->mutex); if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { @@ -153,15 +150,11 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration( 6. Discovered Other */ - foreach (QBearerEngine *engine, sessionEngines) { - QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it; - QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end; + for (QBearerEngine *engine : sessionEngines) { QMutexLocker locker(&engine->mutex); - for (it = engine->accessPointConfigurations.begin(), - end = engine->accessPointConfigurations.end(); it != end; ++it) { - QNetworkConfigurationPrivatePointer ptr = it.value(); + for (const auto &ptr : qAsConst(engine->accessPointConfigurations)) { QMutexLocker configLocker(&ptr->mutex); QNetworkConfiguration::BearerType bearerType = ptr->bearerType; @@ -216,17 +209,12 @@ QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurati QMutexLocker locker(&mutex); - foreach (QBearerEngine *engine, sessionEngines) { - QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it; - QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end; + for (QBearerEngine *engine : sessionEngines) { QMutexLocker locker(&engine->mutex); //find all InternetAccessPoints - for (it = engine->accessPointConfigurations.begin(), - end = engine->accessPointConfigurations.end(); it != end; ++it) { - QNetworkConfigurationPrivatePointer ptr = it.value(); - + for (const auto &ptr : qAsConst(engine->accessPointConfigurations)) { QMutexLocker configLocker(&ptr->mutex); if ((ptr->state & filter) == filter) { @@ -237,10 +225,7 @@ QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurati } //find all service networks - for (it = engine->snapConfigurations.begin(), - end = engine->snapConfigurations.end(); it != end; ++it) { - QNetworkConfigurationPrivatePointer ptr = it.value(); - + for (const auto &ptr : qAsConst(engine->snapConfigurations)) { QMutexLocker configLocker(&ptr->mutex); if ((ptr->state & filter) == filter) { @@ -260,19 +245,20 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIden QMutexLocker locker(&mutex); - foreach (QBearerEngine *engine, sessionEngines) { + for (QBearerEngine *engine : sessionEngines) { QMutexLocker locker(&engine->mutex); - - if (engine->accessPointConfigurations.contains(identifier)) - item.d = engine->accessPointConfigurations[identifier]; - else if (engine->snapConfigurations.contains(identifier)) - item.d = engine->snapConfigurations[identifier]; - else if (engine->userChoiceConfigurations.contains(identifier)) - item.d = engine->userChoiceConfigurations[identifier]; - else - continue; - - return item; + 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; @@ -293,7 +279,7 @@ QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate:: QNetworkConfigurationManager::Capabilities capFlags; - foreach (QBearerEngine *engine, sessionEngines) + for (QBearerEngine *engine : sessionEngines) capFlags |= engine->capabilities(); return capFlags; @@ -366,10 +352,8 @@ void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigura void QNetworkConfigurationManagerPrivate::updateConfigurations() { -#ifndef QT_NO_LIBRARY typedef QMultiMap<int, QString> PluginKeyMap; typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator; -#endif QMutexLocker locker(&mutex); if (firstUpdate) { @@ -378,11 +362,11 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() updating = false; -#ifndef QT_NO_LIBRARY bool envOK = false; - const int skipGeneric = qgetenv("QT_EXCLUDE_GENERIC_BEARER").toInt(&envOK); + const int skipGeneric = qEnvironmentVariableIntValue("QT_EXCLUDE_GENERIC_BEARER", &envOK); QBearerEngine *generic = 0; - QFactoryLoader *l = loader(); + static QFactoryLoader loader(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")); + QFactoryLoader *l = &loader; const PluginKeyMap keyMap = l->keyMap(); const PluginKeyMapConstIterator cend = keyMap.constEnd(); QStringList addedEngines; @@ -421,7 +405,6 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() else delete generic; } -#endif // QT_NO_LIBRARY } QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender()); @@ -441,11 +424,10 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() if (firstUpdate) { firstUpdate = false; - QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex + const QList<QBearerEngine*> enginesToInitialize = sessionEngines; //shallow copy the list in case it is modified when we unlock mutex locker.unlock(); - foreach (QBearerEngine* engine, enginesToInitialize) { + for (QBearerEngine* engine : enginesToInitialize) QMetaObject::invokeMethod(engine, "initialize", Qt::BlockingQueuedConnection); - } } } @@ -460,7 +442,7 @@ void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() updating = true; - foreach (QBearerEngine *engine, sessionEngines) { + for (QBearerEngine *engine : qAsConst(sessionEngines)) { updatingEngines.insert(engine); QMetaObject::invokeMethod(engine, "requestUpdate"); } @@ -479,7 +461,7 @@ void QNetworkConfigurationManagerPrivate::startPolling() if (!pollTimer) { pollTimer = new QTimer(this); bool ok; - int interval = qgetenv("QT_BEARER_POLL_TIMEOUT").toInt(&ok); + int interval = qEnvironmentVariableIntValue("QT_BEARER_POLL_TIMEOUT", &ok); if (!ok) interval = 10000;//default 10 seconds pollTimer->setInterval(interval); @@ -490,7 +472,7 @@ void QNetworkConfigurationManagerPrivate::startPolling() if (pollTimer->isActive()) return; - foreach (QBearerEngine *engine, sessionEngines) { + for (QBearerEngine *engine : qAsConst(sessionEngines)) { if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) { pollTimer->start(); break; @@ -503,7 +485,7 @@ void QNetworkConfigurationManagerPrivate::pollEngines() { QMutexLocker locker(&mutex); - foreach (QBearerEngine *engine, sessionEngines) { + for (QBearerEngine *engine : qAsConst(sessionEngines)) { if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) { pollingEngines.insert(engine); QMetaObject::invokeMethod(engine, "requestUpdate"); diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 73407d344f..a322fb5cfe 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp index 378245ce3e..533a27357c 100644 --- a/src/network/bearer/qnetworkconfiguration.cpp +++ b/src/network/bearer/qnetworkconfiguration.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -35,11 +41,6 @@ #include "qnetworkconfiguration_p.h" #include <QDebug> -#ifdef Q_OS_BLACKBERRY -#include "private/qcore_unix_p.h" // qt_safe_open -#include <sys/pps.h> -#endif // Q_OS_BLACKBERRY - QT_BEGIN_NAMESPACE /*! @@ -202,77 +203,6 @@ QT_BEGIN_NAMESPACE \value BearerLTE The configuration is for a LTE (4G) interface. */ -#ifdef Q_OS_BLACKBERRY -static const char cellularStatusFile[] = "/pps/services/radioctrl/modem0/status_public"; - -static QNetworkConfiguration::BearerType cellularStatus() -{ - QNetworkConfiguration::BearerType ret = QNetworkConfiguration::BearerUnknown; - - int cellularStatusFD; - if ((cellularStatusFD = qt_safe_open(cellularStatusFile, O_RDONLY)) == -1) { - qWarning() << "failed to open" << cellularStatusFile; - return ret; - } - char buf[2048]; - if (qt_safe_read(cellularStatusFD, &buf, sizeof(buf)) == -1) { - qWarning() << "read from PPS file failed:" << strerror(errno); - qt_safe_close(cellularStatusFD); - return ret; - } - pps_decoder_t ppsDecoder; - if (pps_decoder_initialize(&ppsDecoder, buf) != PPS_DECODER_OK) { - qWarning("failed to initialize PPS decoder"); - qt_safe_close(cellularStatusFD); - return ret; - } - pps_decoder_error_t err; - if ((err = pps_decoder_push(&ppsDecoder, 0)) != PPS_DECODER_OK) { - qWarning() << "pps_decoder_push failed" << err; - pps_decoder_cleanup(&ppsDecoder); - qt_safe_close(cellularStatusFD); - return ret; - } - if (!pps_decoder_is_integer(&ppsDecoder, "network_technology")) { - qWarning("field has not the expected data type"); - pps_decoder_cleanup(&ppsDecoder); - qt_safe_close(cellularStatusFD); - return ret; - } - int type; - if (!pps_decoder_get_int(&ppsDecoder, "network_technology", &type) - == PPS_DECODER_OK) { - qWarning("could not read bearer type from PPS"); - pps_decoder_cleanup(&ppsDecoder); - qt_safe_close(cellularStatusFD); - return ret; - } - switch (type) { - case 0: // 0 == NONE - break; // unhandled - case 1: // fallthrough, 1 == GSM - case 4: // 4 == CDMA_1X - ret = QNetworkConfiguration::Bearer2G; - break; - case 2: // 2 == UMTS - ret = QNetworkConfiguration::BearerWCDMA; - break; - case 8: // 8 == EVDO - ret = QNetworkConfiguration::BearerEVDO; - break; - case 16: // 16 == LTE - ret = QNetworkConfiguration::BearerLTE; - break; - default: - qWarning() << "unhandled bearer type" << type; - break; - } - pps_decoder_cleanup(&ppsDecoder); - qt_safe_close(cellularStatusFD); - return ret; -} -#endif // Q_OS_BLACKBERRY - /*! Constructs an invalid configuration object. @@ -454,25 +384,21 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const if (d->type != QNetworkConfiguration::ServiceNetwork || !d->isValid) return results; - QMutableMapIterator<unsigned int, QNetworkConfigurationPrivatePointer> i(d->serviceNetworkMembers); - while (i.hasNext()) { - i.next(); - - QNetworkConfigurationPrivatePointer p = i.value(); - + for (auto it = d->serviceNetworkMembers.begin(), end = d->serviceNetworkMembers.end(); it != end;) { + QNetworkConfigurationPrivatePointer p = it.value(); //if we have an invalid member get rid of it -> was deleted earlier on { QMutexLocker childLocker(&p->mutex); if (!p->isValid) { - i.remove(); + it = d->serviceNetworkMembers.erase(it); continue; } } - QNetworkConfiguration item; item.d = p; results << item; + ++it; } return results; @@ -494,19 +420,6 @@ QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const return BearerUnknown; QMutexLocker locker(&d->mutex); - -#ifdef Q_OS_BLACKBERRY - // for cellular configurations, we need to determine the exact - // type right now, because it might have changed after the last scan - if (d->bearerType == QNetworkConfiguration::Bearer2G) { - QNetworkConfiguration::BearerType type = cellularStatus(); - // if reading the status failed for some reason, just - // fall back to 2G - return (type == QNetworkConfiguration::BearerUnknown) - ? QNetworkConfiguration::Bearer2G : type; - } -#endif // Q_OS_BLACKBERRY - return d->bearerType; } @@ -639,20 +552,6 @@ QString QNetworkConfiguration::bearerTypeName() const case BearerWLAN: return QStringLiteral("WLAN"); case Bearer2G: -#ifdef Q_OS_BLACKBERRY - { - // for cellular configurations, we need to determine the exact - // type right now, because it might have changed after the last scan - QNetworkConfiguration::BearerType type = cellularStatus(); - if (type == QNetworkConfiguration::BearerWCDMA) { - return QStringLiteral("WCDMA"); - } else if (type == QNetworkConfiguration::BearerEVDO) { - return QStringLiteral("EVDO"); - }else if (type == QNetworkConfiguration::BearerLTE) { - return QStringLiteral("LTE"); - } - } -#endif // Q_OS_BLACKBERRY return QStringLiteral("2G"); case Bearer3G: return QStringLiteral("3G"); diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h index 317c232bea..45f7402992 100644 --- a/src/network/bearer/qnetworkconfiguration.h +++ b/src/network/bearer/qnetworkconfiguration.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h index 75df36fbd9..316000c717 100644 --- a/src/network/bearer/qnetworkconfiguration_p.h +++ b/src/network/bearer/qnetworkconfiguration_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -51,10 +57,6 @@ #include <QtCore/qmutex.h> #include <QtCore/qmap.h> -#ifdef Q_OS_BLACKBERRY -#include <bps/netstatus.h> -#endif - QT_BEGIN_NAMESPACE typedef QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfigurationPrivatePointer; @@ -66,9 +68,6 @@ public: type(QNetworkConfiguration::Invalid), purpose(QNetworkConfiguration::UnknownPurpose), bearerType(QNetworkConfiguration::BearerUnknown), -#ifdef Q_OS_BLACKBERRY - oldIpStatus(NETSTATUS_IP_STATUS_ERROR_UNKNOWN), -#endif isValid(false), roamingSupported(false) {} virtual ~QNetworkConfigurationPrivate() @@ -89,10 +88,6 @@ public: QNetworkConfiguration::Purpose purpose; QNetworkConfiguration::BearerType bearerType; -#ifdef Q_OS_BLACKBERRY - netstatus_ip_status_t oldIpStatus; -#endif - bool isValid; bool roamingSupported; diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index 6f83fd25ca..6d864a7d3e 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -243,7 +249,8 @@ QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, { // invalid configuration if (!connectionConfig.identifier().isEmpty()) { - foreach (QBearerEngine *engine, qNetworkConfigurationManagerPrivate()->engines()) { + const auto engines = qNetworkConfigurationManagerPrivate()->engines(); + for (QBearerEngine *engine : engines) { if (engine->hasIdentifier(connectionConfig.identifier())) { d = engine->createSessionBackend(); d->q = this; diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h index bee4be7eb6..2ff1d89564 100644 --- a/src/network/bearer/qnetworksession.h +++ b/src/network/bearer/qnetworksession.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h index f2ecf9902a..45596ea003 100644 --- a/src/network/bearer/qnetworksession_p.h +++ b/src/network/bearer/qnetworksession_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -106,7 +112,7 @@ protected: } inline void setPrivateConfiguration(QNetworkConfiguration &config, - QNetworkConfigurationPrivatePointer ptr) const + const QNetworkConfigurationPrivatePointer &ptr) const { config.d = ptr; } diff --git a/src/network/bearer/qsharednetworksession.cpp b/src/network/bearer/qsharednetworksession.cpp index 0879bfbc2b..fc01acb8b4 100644 --- a/src/network/bearer/qsharednetworksession.cpp +++ b/src/network/bearer/qsharednetworksession.cpp @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -56,12 +62,13 @@ static void doDeleteLater(QObject* obj) obj->deleteLater(); } -QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(QNetworkConfiguration config) +QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(const QNetworkConfiguration &config) { QSharedNetworkSessionManager *m(sharedNetworkSessionManager()); + const auto it = m->sessions.constFind(config); //if already have a session, return it - if (m->sessions.contains(config)) { - QSharedPointer<QNetworkSession> p = m->sessions.value(config).toStrongRef(); + if (it != m->sessions.cend()) { + QSharedPointer<QNetworkSession> p = it.value().toStrongRef(); if (!p.isNull()) return p; } @@ -71,7 +78,7 @@ QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(QNetwor return session; } -void QSharedNetworkSessionManager::setSession(QNetworkConfiguration config, QSharedPointer<QNetworkSession> session) +void QSharedNetworkSessionManager::setSession(const QNetworkConfiguration &config, QSharedPointer<QNetworkSession> session) { QSharedNetworkSessionManager *m(sharedNetworkSessionManager()); m->sessions[config] = session; diff --git a/src/network/bearer/qsharednetworksession_p.h b/src/network/bearer/qsharednetworksession_p.h index 3525c8359c..ba4bd500ac 100644 --- a/src/network/bearer/qsharednetworksession_p.h +++ b/src/network/bearer/qsharednetworksession_p.h @@ -1,31 +1,37 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** 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. ** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -61,8 +67,8 @@ uint qHash(const QNetworkConfiguration& config); class QSharedNetworkSessionManager { public: - static QSharedPointer<QNetworkSession> getSession(QNetworkConfiguration config); - static void setSession(QNetworkConfiguration config, QSharedPointer<QNetworkSession> session); + static QSharedPointer<QNetworkSession> getSession(const QNetworkConfiguration &config); + static void setSession(const QNetworkConfiguration &config, QSharedPointer<QNetworkSession> session); private: QHash<QNetworkConfiguration, QWeakPointer<QNetworkSession> > sessions; }; |