summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/CMakeLists.txt3
-rw-r--r--src/plugins/bearer/.prev_CMakeLists.txt12
-rw-r--r--src/plugins/bearer/CMakeLists.txt14
-rw-r--r--src/plugins/bearer/android/CMakeLists.txt4
-rw-r--r--src/plugins/bearer/android/android.pro4
-rw-r--r--src/plugins/bearer/android/jar/.prev_CMakeLists.txt16
-rw-r--r--src/plugins/bearer/android/jar/CMakeLists.txt22
-rw-r--r--src/plugins/bearer/android/jar/jar.pro15
-rw-r--r--src/plugins/bearer/android/jar/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java92
-rw-r--r--src/plugins/bearer/android/src/CMakeLists.txt19
-rw-r--r--src/plugins/bearer/android/src/android.json3
-rw-r--r--src/plugins/bearer/android/src/main.cpp63
-rw-r--r--src/plugins/bearer/android/src/qandroidbearerengine.cpp391
-rw-r--r--src/plugins/bearer/android/src/qandroidbearerengine.h95
-rw-r--r--src/plugins/bearer/android/src/src.pro14
-rw-r--r--src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp387
-rw-r--r--src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.h168
-rw-r--r--src/plugins/bearer/android/src/wrappers/wrappers.pri6
-rw-r--r--src/plugins/bearer/bearer.pro11
-rw-r--r--src/plugins/bearer/connman/.prev_CMakeLists.txt26
-rw-r--r--src/plugins/bearer/connman/CMakeLists.txt22
-rw-r--r--src/plugins/bearer/connman/connman.json3
-rw-r--r--src/plugins/bearer/connman/connman.pro16
-rw-r--r--src/plugins/bearer/connman/main.cpp85
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.cpp570
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.h145
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux.cpp516
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux_p.h230
-rw-r--r--src/plugins/bearer/corewlan/CMakeLists.txt30
-rw-r--r--src/plugins/bearer/corewlan/corewlan.json3
-rw-r--r--src/plugins/bearer/corewlan/corewlan.pro20
-rw-r--r--src/plugins/bearer/corewlan/main.cpp82
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.h147
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm862
-rw-r--r--src/plugins/bearer/generic/CMakeLists.txt28
-rw-r--r--src/plugins/bearer/generic/generic.json3
-rw-r--r--src/plugins/bearer/generic/generic.pro16
-rw-r--r--src/plugins/bearer/generic/main.cpp78
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp446
-rw-r--r--src/plugins/bearer/generic/qgenericengine.h90
-rw-r--r--src/plugins/bearer/nativewifi/main.cpp127
-rw-r--r--src/plugins/bearer/nativewifi/nativewifi.json3
-rw-r--r--src/plugins/bearer/nativewifi/nativewifi.pro15
-rw-r--r--src/plugins/bearer/nativewifi/platformdefs.h327
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.cpp622
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.h106
-rw-r--r--src/plugins/bearer/networkmanager/.prev_CMakeLists.txt26
-rw-r--r--src/plugins/bearer/networkmanager/CMakeLists.txt22
-rw-r--r--src/plugins/bearer/networkmanager/main.cpp84
-rw-r--r--src/plugins/bearer/networkmanager/networkmanager.json3
-rw-r--r--src/plugins/bearer/networkmanager/networkmanager.pro16
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp935
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.h153
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp1019
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h500
-rw-r--r--src/plugins/bearer/nla/main.cpp78
-rw-r--r--src/plugins/bearer/nla/nla.json3
-rw-r--r--src/plugins/bearer/nla/nla.pro17
-rw-r--r--src/plugins/bearer/nla/qnlaengine.cpp639
-rw-r--r--src/plugins/bearer/nla/qnlaengine.h110
-rw-r--r--src/plugins/bearer/platformdefs_win.h142
-rw-r--r--src/plugins/plugins.pro1
62 files changed, 0 insertions, 9705 deletions
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 6718d64ca0..8d6516b0b5 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -3,9 +3,6 @@
if(TARGET Qt::Sql)
add_subdirectory(sqldrivers)
endif()
-if(QT_FEATURE_bearermanagement AND TARGET Qt::Network)
- add_subdirectory(bearer)
-endif()
if(TARGET Qt::Gui)
add_subdirectory(platforms)
add_subdirectory(platforminputcontexts)
diff --git a/src/plugins/bearer/.prev_CMakeLists.txt b/src/plugins/bearer/.prev_CMakeLists.txt
deleted file mode 100644
index a7a36f60c6..0000000000
--- a/src/plugins/bearer/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-# Generated from bearer.pro.
-
-if(SUBDIRS_ISEMPTY OR (TARGET Qt::DBus AND linux_x_ AND NOT ANDROID))
- add_subdirectory(generic)
-endif()
-if(TARGET Qt::DBus AND linux_x_ AND NOT ANDROID)
- add_subdirectory(connman)
- add_subdirectory(networkmanager)
-endif()
-if(ANDROID AND NOT ANDROID_EMBEDDED)
- add_subdirectory(android)
-endif()
diff --git a/src/plugins/bearer/CMakeLists.txt b/src/plugins/bearer/CMakeLists.txt
deleted file mode 100644
index 528061d264..0000000000
--- a/src/plugins/bearer/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-# Generated from bearer.pro.
-
-# special case begin
-# The whole block is manual.
-if(NOT ANDROID AND LINUX AND TARGET Qt::DBus)
- add_subdirectory(generic)
- add_subdirectory(connman)
- add_subdirectory(networkmanager)
-elseif(ANDROID AND NOT ANDROID_EMBEDDED)
- add_subdirectory(android)
-else()
- add_subdirectory(generic)
-endif()
-# special case end
diff --git a/src/plugins/bearer/android/CMakeLists.txt b/src/plugins/bearer/android/CMakeLists.txt
deleted file mode 100644
index 193cbf1fe3..0000000000
--- a/src/plugins/bearer/android/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# Generated from android.pro.
-
-add_subdirectory(src)
-add_subdirectory(jar)
diff --git a/src/plugins/bearer/android/android.pro b/src/plugins/bearer/android/android.pro
deleted file mode 100644
index 6a51abf5d7..0000000000
--- a/src/plugins/bearer/android/android.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += src \
- jar
diff --git a/src/plugins/bearer/android/jar/.prev_CMakeLists.txt b/src/plugins/bearer/android/jar/.prev_CMakeLists.txt
deleted file mode 100644
index f5f25c4f8b..0000000000
--- a/src/plugins/bearer/android/jar/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-# Generated from jar.pro.
-
-set(java_sources
- src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java
-)
-
-add_jar(QtAndroidBearer
- INCLUDE_JARS ${QT_ANDROID_JAR}
- SOURCES ${java_sources}
-)
-
-install_jar(QtAndroidBearer
- DESTINATION jar
- COMPONENT Devel
-)
-
diff --git a/src/plugins/bearer/android/jar/CMakeLists.txt b/src/plugins/bearer/android/jar/CMakeLists.txt
deleted file mode 100644
index 16641d42b7..0000000000
--- a/src/plugins/bearer/android/jar/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-#####################################################################
-## QtAndroidBearer Binary:
-#####################################################################
-
-set(java_sources
- src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java
-)
-
-add_jar(QtAndroidBearer
- INCLUDE_JARS ${QT_ANDROID_JAR}
- SOURCES ${java_sources}
- )
-
-install_jar(QtAndroidBearer
- DESTINATION jar
- COMPONENT Devel)
-
-#### Keys ignored in scope 1:.:.:jar.pro:<TRUE>:
-# JAVACLASSPATH = "$$PWD/src"
-# JAVASOURCES = "$$PWD/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java"
-# _LOADED = "qt_build_paths"
-
diff --git a/src/plugins/bearer/android/jar/jar.pro b/src/plugins/bearer/android/jar/jar.pro
deleted file mode 100644
index 8277a8abc1..0000000000
--- a/src/plugins/bearer/android/jar/jar.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-CONFIG += single_arch
-
-TARGET = QtAndroidBearer
-
-load(qt_build_paths)
-CONFIG += java
-DESTDIR = $$MODULE_BASE_OUTDIR/jar
-
-JAVACLASSPATH += $$PWD/src
-
-JAVASOURCES += $$PWD/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java
-
-# install
-target.path = $$[QT_INSTALL_PREFIX]/jar
-INSTALLS += target
diff --git a/src/plugins/bearer/android/jar/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java b/src/plugins/bearer/android/jar/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java
deleted file mode 100644
index 805c90548b..0000000000
--- a/src/plugins/bearer/android/jar/src/org/qtproject/qt5/android/bearer/QtNetworkReceiver.java
+++ /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 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$
-**
-****************************************************************************/
-
-package org.qtproject.qt5.android.bearer;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.util.Log;
-import android.net.ConnectivityManager;
-
-public class QtNetworkReceiver
-{
- private static final String LOG_TAG = "QtNetworkReceiver";
- private static native void activeNetworkInfoChanged();
- private static BroadcastReceiverPrivate m_broadcastReceiver = null;
- private static final Object m_lock = new Object();
-
- private static class BroadcastReceiverPrivate extends BroadcastReceiver
- {
- @Override
- public void onReceive(Context context, Intent intent)
- {
- activeNetworkInfoChanged();
- }
- }
-
- private QtNetworkReceiver() {}
-
- public static void registerReceiver(final Context context)
- {
- synchronized (m_lock) {
- if (m_broadcastReceiver == null) {
- m_broadcastReceiver = new BroadcastReceiverPrivate();
- IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
- context.registerReceiver(m_broadcastReceiver, intentFilter);
- }
- }
- }
-
- public static void unregisterReceiver(final Context context)
- {
- synchronized (m_lock) {
- if (m_broadcastReceiver == null)
- return;
-
- context.unregisterReceiver(m_broadcastReceiver);
- }
- }
-
- public static ConnectivityManager getConnectivityManager(final Context context)
- {
- return (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
- }
-}
diff --git a/src/plugins/bearer/android/src/CMakeLists.txt b/src/plugins/bearer/android/src/CMakeLists.txt
deleted file mode 100644
index 5be89e316b..0000000000
--- a/src/plugins/bearer/android/src/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# Generated from src.pro.
-
-#####################################################################
-## QAndroidBearerEnginePlugin Plugin:
-#####################################################################
-
-qt_add_plugin(QAndroidBearerEnginePlugin
- OUTPUT_NAME qandroidbearer
- TYPE bearer
- SOURCES
- main.cpp
- qandroidbearerengine.cpp qandroidbearerengine.h
- wrappers/androidconnectivitymanager.cpp wrappers/androidconnectivitymanager.h
- INCLUDE_DIRECTORIES
- wrappers
- PUBLIC_LIBRARIES
- Qt::CorePrivate
- Qt::NetworkPrivate
-)
diff --git a/src/plugins/bearer/android/src/android.json b/src/plugins/bearer/android/src/android.json
deleted file mode 100644
index 6843bd3301..0000000000
--- a/src/plugins/bearer/android/src/android.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "android" ]
-}
diff --git a/src/plugins/bearer/android/src/main.cpp b/src/plugins/bearer/android/src/main.cpp
deleted file mode 100644
index f3a5074e5d..0000000000
--- a/src/plugins/bearer/android/src/main.cpp
+++ /dev/null
@@ -1,63 +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$
-**
-****************************************************************************/
-
-#include "qandroidbearerengine.h"
-#include <QtNetwork/private/qbearerplugin_p.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QAndroidBearerEnginePlugin : public QBearerEnginePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "android.json")
-
-public:
- QBearerEngine *create(const QString &key) const override
- {
- return (key == QLatin1String("android")) ? new QAndroidBearerEngine() : 0;
- }
-};
-
-QT_END_NAMESPACE
-
-#include "main.moc"
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/android/src/qandroidbearerengine.cpp b/src/plugins/bearer/android/src/qandroidbearerengine.cpp
deleted file mode 100644
index ad9895e0cf..0000000000
--- a/src/plugins/bearer/android/src/qandroidbearerengine.cpp
+++ /dev/null
@@ -1,391 +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$
-**
-****************************************************************************/
-
-#include "qandroidbearerengine.h"
-#include <private/qnetworksession_impl_p.h>
-#include "wrappers/androidconnectivitymanager.h"
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-static QString networkConfType(const AndroidNetworkInfo &networkInfo)
-{
- switch (networkInfo.getType()) {
- case AndroidNetworkInfo::Mobile:
- return QStringLiteral("Mobile");
- case AndroidNetworkInfo::Wifi:
- return QStringLiteral("WiFi");
- case AndroidNetworkInfo::Wimax:
- return QStringLiteral("WiMax");
- case AndroidNetworkInfo::Ethernet:
- return QStringLiteral("Ethernet");
- case AndroidNetworkInfo::Bluetooth:
- return QStringLiteral("Bluetooth");
- default:
- break;
- }
-
- return QString();
-}
-
-static inline bool isMobile(QNetworkConfiguration::BearerType type)
-{
- if (type == QNetworkConfiguration::BearerWLAN
- || type == QNetworkConfiguration::BearerWiMAX
- || type == QNetworkConfiguration::BearerBluetooth
- || type == QNetworkConfiguration::BearerEthernet
- || type == QNetworkConfiguration::BearerUnknown) {
- return false;
- }
-
- return true;
-}
-
-static QNetworkConfiguration::BearerType getBearerType(const AndroidNetworkInfo &networkInfo)
-{
- switch (networkInfo.getType()) {
- case AndroidNetworkInfo::Mobile:
- {
- switch (networkInfo.getSubtype()) {
- case AndroidNetworkInfo::Gprs:
- case AndroidNetworkInfo::Edge:
- case AndroidNetworkInfo::Iden: // 2G
- return QNetworkConfiguration::Bearer2G;
- case AndroidNetworkInfo::Umts: // BearerWCDMA (3 .5 .75 G)
- case AndroidNetworkInfo::Hsdpa: // 3G (?) UMTS
- case AndroidNetworkInfo::Hsupa: // 3G (?) UMTS
- return QNetworkConfiguration::BearerWCDMA;
- case AndroidNetworkInfo::Cdma: // CDMA ISA95[AB]
- case AndroidNetworkInfo::Cdma1xRTT: // BearerCDMA2000 (3G)
- case AndroidNetworkInfo::Ehrpd: // CDMA Bridge thing?!?
- return QNetworkConfiguration::BearerCDMA2000;
- case AndroidNetworkInfo::Evdo0: // BearerEVDO
- case AndroidNetworkInfo::EvdoA: // BearerEVDO
- case AndroidNetworkInfo::EvdoB: // BearerEVDO
- return QNetworkConfiguration::BearerEVDO;
- case AndroidNetworkInfo::Hspa:
- case AndroidNetworkInfo::Hspap: // HSPA+
- return QNetworkConfiguration::BearerHSPA;
- case AndroidNetworkInfo::Lte: // BearerLTE (4G)
- return QNetworkConfiguration::BearerLTE;
- default:
- break;
- }
- }
- case AndroidNetworkInfo::Wifi:
- return QNetworkConfiguration::BearerWLAN;
- case AndroidNetworkInfo::Wimax:
- return QNetworkConfiguration::BearerWiMAX;
- case AndroidNetworkInfo::Bluetooth:
- case AndroidNetworkInfo::MobileDun:
- return QNetworkConfiguration::BearerBluetooth;
- case AndroidNetworkInfo::Ethernet:
- return QNetworkConfiguration::BearerEthernet;
- case AndroidNetworkInfo::MobileMms:
- case AndroidNetworkInfo::MobileSupl:
- case AndroidNetworkInfo::MobileHipri:
- case AndroidNetworkInfo::Dummy:
- case AndroidNetworkInfo::UnknownType:
- break;
- }
-
- return QNetworkConfiguration::BearerUnknown;
-}
-
-QAndroidBearerEngine::QAndroidBearerEngine(QObject *parent)
- : QBearerEngineImpl(parent),
- m_connectivityManager(0)
-{
-}
-
-QAndroidBearerEngine::~QAndroidBearerEngine()
-{
-}
-
-QString QAndroidBearerEngine::getInterfaceFromId(const QString &id)
-{
- const QMutexLocker locker(&mutex);
- return m_configurationInterface.value(id);
-}
-
-bool QAndroidBearerEngine::hasIdentifier(const QString &id)
-{
- const QMutexLocker locker(&mutex);
- return m_configurationInterface.contains(id);
-}
-
-void QAndroidBearerEngine::connectToId(const QString &id)
-{
- Q_EMIT connectionError(id, OperationNotSupported);
-}
-
-void QAndroidBearerEngine::disconnectFromId(const QString &id)
-{
- Q_EMIT connectionError(id, OperationNotSupported);
-}
-
-QNetworkSession::State QAndroidBearerEngine::sessionStateForId(const QString &id)
-{
- const QMutexLocker locker(&mutex);
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- if ((!ptr || !ptr->isValid) || m_connectivityManager == 0)
- return QNetworkSession::Invalid;
-
- const QMutexLocker configLocker(&ptr->mutex);
- // Don't re-order...
- if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return QNetworkSession::Connected;
- } else if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
- return QNetworkSession::Disconnected;
- } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
- return QNetworkSession::NotAvailable;
- } else if ((ptr->state & QNetworkConfiguration::Undefined) == QNetworkConfiguration::Undefined) {
- return QNetworkSession::NotAvailable;
- }
-
- return QNetworkSession::Invalid;
-}
-
-QNetworkConfigurationManager::Capabilities QAndroidBearerEngine::capabilities() const
-{
-
- return AndroidTrafficStats::isTrafficStatsSupported()
- ? QNetworkConfigurationManager::ForcedRoaming
- | QNetworkConfigurationManager::DataStatistics
- : QNetworkConfigurationManager::ForcedRoaming;
-
-}
-
-QNetworkSessionPrivate *QAndroidBearerEngine::createSessionBackend()
-{
- return new QNetworkSessionPrivateImpl();
-}
-
-QNetworkConfigurationPrivatePointer QAndroidBearerEngine::defaultConfiguration()
-{
- return QNetworkConfigurationPrivatePointer();
-}
-
-bool QAndroidBearerEngine::requiresPolling() const
-{
- return false;
-}
-
-quint64 QAndroidBearerEngine::bytesWritten(const QString &id)
-{
- QMutexLocker lock(&mutex);
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- if (!ptr || !ptr->isValid)
- return 0;
-
- return isMobile(ptr->bearerType)
- ? AndroidTrafficStats::getMobileTxBytes()
- : AndroidTrafficStats::getTotalTxBytes() - AndroidTrafficStats::getMobileTxBytes();
-}
-
-quint64 QAndroidBearerEngine::bytesReceived(const QString &id)
-{
- QMutexLocker lock(&mutex);
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- if (!ptr || !ptr->isValid)
- return 0;
-
- return isMobile(ptr->bearerType)
- ? AndroidTrafficStats::getMobileRxBytes()
- : AndroidTrafficStats::getTotalRxBytes() - AndroidTrafficStats::getMobileRxBytes();
-}
-
-quint64 QAndroidBearerEngine::startTime(const QString &id)
-{
- Q_UNUSED(id);
- return Q_UINT64_C(0);
-}
-
-void QAndroidBearerEngine::initialize()
-{
- if (m_connectivityManager != 0)
- return;
-
- m_connectivityManager = AndroidConnectivityManager::getInstance();
- if (m_connectivityManager == 0)
- return;
-
- updateConfigurations();
-
- connect(m_connectivityManager, &AndroidConnectivityManager::activeNetworkChanged,
- this, &QAndroidBearerEngine::updateConfigurations);
-
-}
-
-void QAndroidBearerEngine::requestUpdate()
-{
- updateConfigurations();
-}
-
-void QAndroidBearerEngine::updateConfigurations()
-{
-#ifndef QT_NO_NETWORKINTERFACE
- if (m_connectivityManager == 0)
- return;
-
- {
- QMutexLocker locker(&mutex);
- QStringList oldKeys = accessPointConfigurations.keys();
-
- QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
- if (interfaces.isEmpty())
- interfaces = QNetworkInterface::allInterfaces();
-
- // Create a configuration for each of the main types (WiFi, Mobile, Bluetooth, WiMax, Ethernet)
- const auto netInfos = m_connectivityManager->getAllNetworkInfo();
- for (const AndroidNetworkInfo &netInfo : netInfos) {
-
- if (!netInfo.isValid())
- continue;
-
- const QString name = networkConfType(netInfo);
- if (name.isEmpty())
- continue;
-
- QNetworkConfiguration::BearerType bearerType = getBearerType(netInfo);
-
- QString interfaceName;
- QNetworkConfiguration::StateFlag state = QNetworkConfiguration::Defined;
- if (netInfo.isAvailable()) {
- if (netInfo.isConnected()) {
- // Attempt to map an interface to this configuration
- while (!interfaces.isEmpty()) {
- QNetworkInterface interface = interfaces.takeFirst();
- // ignore loopback interface
- if (!interface.isValid())
- continue;
-
- if (interface.flags() & QNetworkInterface::IsLoopBack)
- continue;
- // There is no way to get the interface from the NetworkInfo, so
- // look for an active interface...
- if (interface.flags() & QNetworkInterface::IsRunning
- && !interface.addressEntries().isEmpty()) {
- state = QNetworkConfiguration::Active;
- interfaceName = interface.name();
- break;
- }
- }
- }
- }
-
- const QString key = QString(QLatin1String("android:%1:%2")).arg(name).arg(interfaceName);
- const QString id = QString::number(qHash(key));
- m_configurationInterface[id] = interfaceName;
-
- oldKeys.removeAll(id);
- if (accessPointConfigurations.contains(id)) {
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- bool changed = false;
- {
- const QMutexLocker confLocker(&ptr->mutex);
-
- if (!ptr->isValid) {
- ptr->isValid = true;
- changed = true;
- }
-
- // Don't reset the bearer type to 'Unknown'
- if (ptr->bearerType != QNetworkConfiguration::BearerUnknown
- && ptr->bearerType != bearerType) {
- ptr->bearerType = bearerType;
- changed = true;
- }
-
- if (ptr->name != name) {
- ptr->name = name;
- changed = true;
- }
-
- if (ptr->id != id) {
- ptr->id = id;
- changed = true;
- }
-
- if (ptr->state != state) {
- ptr->state = state;
- changed = true;
- }
- } // Unlock configuration
-
- if (changed) {
- locker.unlock();
- Q_EMIT configurationChanged(ptr);
- locker.relock();
- }
- } else {
- QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);
- ptr->name = name;
- ptr->isValid = true;
- ptr->id = id;
- ptr->state = state;
- ptr->type = QNetworkConfiguration::InternetAccessPoint;
- ptr->bearerType = bearerType;
- accessPointConfigurations.insert(id, ptr);
- locker.unlock();
- Q_EMIT configurationAdded(ptr);
- locker.relock();
- }
- }
-
- while (!oldKeys.isEmpty()) {
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(oldKeys.takeFirst());
- m_configurationInterface.remove(ptr->id);
- locker.unlock();
- Q_EMIT configurationRemoved(ptr);
- locker.relock();
- }
-
- } // Unlock engine
-
-#endif // QT_NO_NETWORKINTERFACE
-
- Q_EMIT updateCompleted();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/android/src/qandroidbearerengine.h b/src/plugins/bearer/android/src/qandroidbearerengine.h
deleted file mode 100644
index 867d04d886..0000000000
--- a/src/plugins/bearer/android/src/qandroidbearerengine.h
+++ /dev/null
@@ -1,95 +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 QANDROIDBEARERENGINE_H
-#define QANDROIDBEARERENGINE_H
-
-#include <private/qbearerengine_impl_p.h>
-
-#include <QAbstractEventDispatcher>
-#include <QAbstractNativeEventFilter>
-#include <QtCore/private/qjni_p.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-class QNetworkSessionPrivate;
-class AndroidConnectivityManager;
-
-class QAndroidBearerEngine : public QBearerEngineImpl
-{
- Q_OBJECT
-
-public:
- explicit QAndroidBearerEngine(QObject *parent = 0);
- ~QAndroidBearerEngine() override;
-
- QString getInterfaceFromId(const QString &id) override;
- bool hasIdentifier(const QString &id) override;
- void connectToId(const QString &id) override;
- void disconnectFromId(const QString &id) override;
- QNetworkSession::State sessionStateForId(const QString &id) override;
- QNetworkConfigurationManager::Capabilities capabilities() const override;
- QNetworkSessionPrivate *createSessionBackend() override;
- QNetworkConfigurationPrivatePointer defaultConfiguration() override;
- bool requiresPolling() const override;
- quint64 bytesWritten(const QString &id) override;
- quint64 bytesReceived(const QString &id) override;
- quint64 startTime(const QString &id) override;
-
- Q_INVOKABLE void initialize();
- Q_INVOKABLE void requestUpdate();
-
-private Q_SLOTS:
- void updateConfigurations();
-
-private:
- QJNIObjectPrivate m_networkReceiver;
- AndroidConnectivityManager *m_connectivityManager;
- QMap<QString, QString> m_configurationInterface;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif // QANDROIDBEARERENGINE_H
diff --git a/src/plugins/bearer/android/src/src.pro b/src/plugins/bearer/android/src/src.pro
deleted file mode 100644
index fcd599dffe..0000000000
--- a/src/plugins/bearer/android/src/src.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qandroidbearer
-
-QT = core-private network-private
-
-HEADERS += qandroidbearerengine.h
-
-SOURCES += main.cpp \
- qandroidbearerengine.cpp
-
-include(wrappers/wrappers.pri)
-
-PLUGIN_TYPE = bearer
-PLUGIN_CLASS_NAME = QAndroidBearerEnginePlugin
-load(qt_plugin)
diff --git a/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp b/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp
deleted file mode 100644
index 6787690246..0000000000
--- a/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp
+++ /dev/null
@@ -1,387 +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$
-**
-****************************************************************************/
-
-#include "androidconnectivitymanager.h"
-#include <QtCore/private/qjni_p.h>
-#include <QtCore/private/qjnihelpers_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static inline bool exceptionCheckAndClear(JNIEnv *env)
-{
- if (!env->ExceptionCheck())
- return false;
-
-#ifdef QT_DEBUG
- env->ExceptionDescribe();
-#endif // QT_DEBUG
- env->ExceptionClear();
-
- return true;
-}
-
-struct AndroidConnectivityManagerInstance
-{
- AndroidConnectivityManagerInstance()
- : connManager(new AndroidConnectivityManager)
- { }
- ~AndroidConnectivityManagerInstance()
- {
- delete connManager;
- }
-
- AndroidConnectivityManager* connManager;
-};
-
-Q_GLOBAL_STATIC(AndroidConnectivityManagerInstance, androidConnManagerInstance)
-
-static const char networkReceiverClass[] = "org/qtproject/qt5/android/bearer/QtNetworkReceiver";
-static const char trafficStatsClass[] = "android/net/TrafficStats";
-
-/**
- * Returns the number of bytes transmitted over the mobile network since last device boot.
- */
-qint64 AndroidTrafficStats::getMobileTxBytes()
-{
- return QJNIObjectPrivate::callStaticMethod<jlong>(trafficStatsClass,
- "getMobileTxBytes",
- "()J");
-}
-
-/**
- * Returns the number of bytes received over the mobile network since last device boot.
- */
-qint64 AndroidTrafficStats::getMobileRxBytes()
-{
- return QJNIObjectPrivate::callStaticMethod<jlong>(trafficStatsClass,
- "getMobileRxBytes",
- "()J");
-}
-
-/**
- * Returns the total transmitted bytes since last device boot.
- */
-qint64 AndroidTrafficStats::getTotalTxBytes()
-{
- return QJNIObjectPrivate::callStaticMethod<jlong>(trafficStatsClass,
- "getTotalTxBytes",
- "()J");
-}
-
-/**
- * Returns the total received bytes since last device boot.
- */
-qint64 AndroidTrafficStats::getTotalRxBytes()
-{
- return QJNIObjectPrivate::callStaticMethod<jlong>(trafficStatsClass,
- "getTotalRxBytes",
- "()J");
-}
-
-bool AndroidTrafficStats::isTrafficStatsSupported()
-{
- // Before API level 18 DataStatistics might not be supported, so make sure that we get something
- // else then -1 from from getXXBytes().
- return (AndroidTrafficStats::getMobileRxBytes() != -1
- && AndroidTrafficStats::getTotalRxBytes() != -1);
-}
-
-static AndroidNetworkInfo::NetworkState stateForName(const QString &stateName)
-{
- if (stateName == QLatin1String("CONNECTED"))
- return AndroidNetworkInfo::Connected;
- else if (stateName == QLatin1String("CONNECTING"))
- return AndroidNetworkInfo::Connecting;
- else if (stateName == QLatin1String("DISCONNECTED"))
- return AndroidNetworkInfo::Disconnected;
- else if (stateName == QLatin1String("DISCONNECTING"))
- return AndroidNetworkInfo::Disconnecting;
- else if (stateName == QLatin1String("SUSPENDED"))
- return AndroidNetworkInfo::Suspended;
-
- return AndroidNetworkInfo::UnknownState;
-}
-
-AndroidNetworkInfo::NetworkState AndroidNetworkInfo::getDetailedState() const
-{
- QJNIObjectPrivate enumObject = m_networkInfo.callObjectMethod("getDetailedState",
- "()Landroid/net/NetworkInfo$DetailedState;");
- if (!enumObject.isValid())
- return UnknownState;
-
- QJNIObjectPrivate enumName = enumObject.callObjectMethod<jstring>("name");
- if (!enumName.isValid())
- return UnknownState;
-
- return stateForName(enumName.toString());
-}
-
-QString AndroidNetworkInfo::getExtraInfo() const
-{
- QJNIObjectPrivate extraInfo = m_networkInfo.callObjectMethod<jstring>("getExtraInfo");
- if (!extraInfo.isValid())
- return QString();
-
- return extraInfo.toString();
-}
-
-QString AndroidNetworkInfo::getReason() const
-{
- QJNIObjectPrivate reason = m_networkInfo.callObjectMethod<jstring>("getReason");
- if (!reason.isValid())
- return QString();
-
- return reason.toString();
-}
-
-AndroidNetworkInfo::NetworkState AndroidNetworkInfo::getState() const
-{
- QJNIObjectPrivate enumObject = m_networkInfo.callObjectMethod("getState",
- "()Landroid/net/NetworkInfo$State;");
- if (!enumObject.isValid())
- return UnknownState;
-
- QJNIObjectPrivate enumName = enumObject.callObjectMethod<jstring>("name");
- if (!enumName.isValid())
- return UnknownState;
-
- return stateForName(enumName.toString());
-}
-
-AndroidNetworkInfo::NetworkSubType AndroidNetworkInfo::getSubtype() const
-{
- return AndroidNetworkInfo::NetworkSubType(m_networkInfo.callMethod<jint>("getSubtype"));
-}
-
-QString AndroidNetworkInfo::getSubtypeName() const
-{
- QJNIObjectPrivate subtypeName = m_networkInfo.callObjectMethod<jstring>("getSubtypeName");
- if (!subtypeName.isValid())
- return QString();
-
- return subtypeName.toString();
-}
-
-AndroidNetworkInfo::NetworkType AndroidNetworkInfo::getType() const
-{
- return AndroidNetworkInfo::NetworkType(m_networkInfo.callMethod<jint>("getType"));
-}
-
-QString AndroidNetworkInfo::getTypeName() const
-{
- QJNIObjectPrivate typeName = m_networkInfo.callObjectMethod<jstring>("getTypeName");
- if (!typeName.isValid())
- return QString();
-
- return typeName.toString();
-}
-
-bool AndroidNetworkInfo::isAvailable() const
-{
- return m_networkInfo.callMethod<jboolean>("isAvailable");
-}
-
-bool AndroidNetworkInfo::isConnected() const
-{
- return m_networkInfo.callMethod<jboolean>("isConnected");
-}
-
-bool AndroidNetworkInfo::isConnectedOrConnecting() const
-{
- return m_networkInfo.callMethod<jboolean>("isConnectedOrConnecting");
-}
-
-bool AndroidNetworkInfo::isFailover() const
-{
- return m_networkInfo.callMethod<jboolean>("isFailover");
-}
-
-bool AndroidNetworkInfo::isRoaming() const
-{
- return m_networkInfo.callMethod<jboolean>("isRoaming");
-}
-
-bool AndroidNetworkInfo::isValid() const
-{
- return m_networkInfo.isValid();
-}
-
-AndroidConnectivityManager::AndroidConnectivityManager()
-{
- QJNIEnvironmentPrivate env;
- if (!registerNatives(env))
- return;
-
- m_connectivityManager = QJNIObjectPrivate::callStaticObjectMethod(networkReceiverClass,
- "getConnectivityManager",
- "(Landroid/content/Context;)Landroid/net/ConnectivityManager;",
- QtAndroidPrivate::context());
- if (!m_connectivityManager.isValid())
- return;
-
- QJNIObjectPrivate::callStaticMethod<void>(networkReceiverClass,
- "registerReceiver",
- "(Landroid/content/Context;)V",
- QtAndroidPrivate::context());
-}
-
-AndroidConnectivityManager *AndroidConnectivityManager::getInstance()
-{
- return androidConnManagerInstance->connManager->isValid()
- ? androidConnManagerInstance->connManager
- : 0;
-}
-
-AndroidConnectivityManager::~AndroidConnectivityManager()
-{
- QJNIObjectPrivate::callStaticMethod<void>(networkReceiverClass,
- "unregisterReceiver",
- "(Landroid/content/Context;)V",
- QtAndroidPrivate::context());
-}
-
-AndroidNetworkInfo AndroidConnectivityManager::getActiveNetworkInfo() const
-{
- QJNIObjectPrivate networkInfo = m_connectivityManager.callObjectMethod("getActiveNetworkInfo",
- "()Landroid/net/NetworkInfo;");
- return networkInfo;
-}
-
-QList<AndroidNetworkInfo> AndroidConnectivityManager::getAllNetworkInfo() const
-{
- QJNIEnvironmentPrivate env;
- QJNIObjectPrivate objArray = m_connectivityManager.callObjectMethod("getAllNetworkInfo",
- "()[Landroid/net/NetworkInfo;");
- QList<AndroidNetworkInfo> list;
- if (!objArray.isValid())
- return list;
-
- const jsize length = env->GetArrayLength(static_cast<jarray>(objArray.object()));
- if (exceptionCheckAndClear(env))
- return list;
-
- for (int i = 0; i != length; ++i) {
- jobject lref = env->GetObjectArrayElement(static_cast<jobjectArray>(objArray.object()), i);
- if (exceptionCheckAndClear(env))
- break;
-
- list << AndroidNetworkInfo(QJNIObjectPrivate::fromLocalRef(lref));
- }
-
- return list;
-}
-
-bool AndroidConnectivityManager::getBackgroundDataSetting() const
-{
- return m_connectivityManager.callMethod<jboolean>("getBackgroundDataSetting");
-}
-
-AndroidNetworkInfo AndroidConnectivityManager::getNetworkInfo(int networkType) const
-{
- QJNIObjectPrivate networkInfo = m_connectivityManager.callObjectMethod("getNetworkInfo",
- "(I)Landroid/net/NetworkInfo;",
- networkType);
- return networkInfo;
-}
-
-int AndroidConnectivityManager::getNetworkPreference() const
-{
- return m_connectivityManager.callMethod<jint>("getNetworkPreference");
-}
-
-bool AndroidConnectivityManager::isActiveNetworkMetered() const
-{
- return m_connectivityManager.callMethod<jboolean>("isActiveNetworkMetered");
-}
-
-bool AndroidConnectivityManager::isNetworkTypeValid(int networkType)
-{
- return QJNIObjectPrivate::callStaticMethod<jboolean>("android/net/ConnectivityManager",
- "isNetworkTypeValid",
- "(I)Z",
- networkType);
-}
-
-bool AndroidConnectivityManager::requestRouteToHost(int networkType, int hostAddress)
-{
- return m_connectivityManager.callMethod<jboolean>("requestRouteToHost", "(II)Z", networkType, hostAddress);
-}
-
-void AndroidConnectivityManager::setNetworkPreference(int preference)
-{
- m_connectivityManager.callMethod<void>("setNetworkPreference", "(I)V", preference);
-}
-
-int AndroidConnectivityManager::startUsingNetworkFeature(int networkType, const QString &feature)
-{
- QJNIObjectPrivate jfeature = QJNIObjectPrivate::fromString(feature);
- return m_connectivityManager.callMethod<jint>("startUsingNetworkFeature",
- "(ILjava/lang/String;)I",
- networkType,
- jfeature.object());
-}
-
-int AndroidConnectivityManager::stopUsingNetworkFeature(int networkType, const QString &feature)
-{
- QJNIObjectPrivate jfeature = QJNIObjectPrivate::fromString(feature);
- return m_connectivityManager.callMethod<jint>("stopUsingNetworkFeature",
- "(ILjava/lang/String;)I",
- networkType,
- jfeature.object());
-}
-
-static void activeNetworkInfoChanged()
-{
- Q_EMIT androidConnManagerInstance->connManager->activeNetworkChanged();
-}
-
-bool AndroidConnectivityManager::registerNatives(JNIEnv *env)
-{
- QJNIObjectPrivate networkReceiver(networkReceiverClass);
- if (!networkReceiver.isValid())
- return false;
-
- jclass clazz = env->GetObjectClass(networkReceiver.object());
- static JNINativeMethod method = {"activeNetworkInfoChanged", "()V", reinterpret_cast<void *>(activeNetworkInfoChanged)};
- const bool ret = (env->RegisterNatives(clazz, &method, 1) == JNI_OK);
- env->DeleteLocalRef(clazz);
- return ret;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.h b/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.h
deleted file mode 100644
index 7c410b0087..0000000000
--- a/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.h
+++ /dev/null
@@ -1,168 +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 ANDROIDCONNECTIVITYMANAGER_H
-#define ANDROIDCONNECTIVITYMANAGER_H
-
-#include <QObject>
-#include <QtCore/private/qjni_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class AndroidTrafficStats
-{
-public:
- static qint64 getMobileTxBytes();
- static qint64 getMobileRxBytes();
- static qint64 getTotalTxBytes();
- static qint64 getTotalRxBytes();
- static bool isTrafficStatsSupported();
-};
-
-class AndroidNetworkInfo
-{
-public:
- // Needs to be in sync with the values from the android api.
- enum NetworkState {
- UnknownState,
- Authenticating,
- Blocked,
- CaptivePortalCheck,
- Connected,
- Connecting,
- Disconnected,
- Disconnecting,
- Failed,
- Idle,
- ObtainingIpAddr,
- Scanning,
- Suspended,
- VerifyingPoorLink
- };
-
- enum NetworkType {
- Mobile,
- Wifi,
- MobileMms,
- MobileSupl,
- MobileDun,
- MobileHipri,
- Wimax,
- Bluetooth,
- Dummy,
- Ethernet,
- UnknownType
- };
-
- enum NetworkSubType {
- UnknownSubType,
- Gprs,
- Edge,
- Umts,
- Cdma,
- Evdo0,
- EvdoA,
- Cdma1xRTT,
- Hsdpa,
- Hsupa,
- Hspa,
- Iden,
- EvdoB,
- Lte,
- Ehrpd,
- Hspap
- };
-
- inline AndroidNetworkInfo(const QJNIObjectPrivate &obj) : m_networkInfo(obj)
- { }
-
- NetworkState getDetailedState() const;
- QString getExtraInfo() const;
- QString getReason() const;
- NetworkState getState() const;
- NetworkSubType getSubtype() const;
- QString getSubtypeName() const;
- NetworkType getType() const;
- QString getTypeName() const;
- bool isAvailable() const;
- bool isConnected() const;
- bool isConnectedOrConnecting() const;
- bool isFailover() const;
- bool isRoaming() const;
- bool isValid() const;
-
-private:
- QJNIObjectPrivate m_networkInfo;
-};
-
-class AndroidConnectivityManager : public QObject
-{
- Q_OBJECT
-public:
- static AndroidConnectivityManager *getInstance();
- ~AndroidConnectivityManager();
-
- AndroidNetworkInfo getActiveNetworkInfo() const;
- QList<AndroidNetworkInfo> getAllNetworkInfo() const;
- bool getBackgroundDataSetting() const;
- AndroidNetworkInfo getNetworkInfo(int networkType) const;
- int getNetworkPreference() const;
- bool isActiveNetworkMetered() const;
- static bool isNetworkTypeValid(int networkType);
- bool requestRouteToHost(int networkType, int hostAddress);
- void setNetworkPreference(int preference);
- int startUsingNetworkFeature(int networkType, const QString &feature);
- int stopUsingNetworkFeature(int networkType, const QString &feature);
- inline bool isValid() const
- {
- return m_connectivityManager.isValid();
- }
-
- Q_SIGNAL void activeNetworkChanged();
-
-private:
- friend struct AndroidConnectivityManagerInstance;
- AndroidConnectivityManager();
- bool registerNatives(JNIEnv *env);
- QJNIObjectPrivate m_connectivityManager;
-};
-
-QT_END_NAMESPACE
-
-#endif // ANDROIDCONNECTIVITYMANAGER_H
diff --git a/src/plugins/bearer/android/src/wrappers/wrappers.pri b/src/plugins/bearer/android/src/wrappers/wrappers.pri
deleted file mode 100644
index 209b76e533..0000000000
--- a/src/plugins/bearer/android/src/wrappers/wrappers.pri
+++ /dev/null
@@ -1,6 +0,0 @@
-INCLUDEPATH += $$PWD
-
-HEADERS += \
- $$PWD/androidconnectivitymanager.h
-SOURCES += \
- $$PWD/androidconnectivitymanager.cpp
diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro
deleted file mode 100644
index afdc613167..0000000000
--- a/src/plugins/bearer/bearer.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = subdirs
-QT_FOR_CONFIG += network-private
-
-!android:linux*:qtHaveModule(dbus) {
- SUBDIRS += generic
- SUBDIRS += connman networkmanager
-}
-
-android:!android-embedded: SUBDIRS += android
-
-isEmpty(SUBDIRS):SUBDIRS = generic
diff --git a/src/plugins/bearer/connman/.prev_CMakeLists.txt b/src/plugins/bearer/connman/.prev_CMakeLists.txt
deleted file mode 100644
index 55aaa41491..0000000000
--- a/src/plugins/bearer/connman/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-# Generated from connman.pro.
-
-#####################################################################
-## QConnmanEnginePlugin Plugin:
-#####################################################################
-
-qt_add_plugin(QConnmanEnginePlugin
- OUTPUT_NAME qconnmanbearer
- CLASS_NAME QConnmanEnginePlugin
- TYPE bearer
- SOURCES
- main.cpp
- qconnmanengine.cpp qconnmanengine.h
- qconnmanservice_linux.cpp qconnmanservice_linux_p.h
- LIBRARIES
- Qt::LinuxOfonoSupportPrivate
- Qt::NetworkPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::DBus
- Qt::LinuxOfonoSupport
- Qt::Network
-)
-
-#### Keys ignored in scope 1:.:.:connman.pro:<TRUE>:
-# OTHER_FILES = "connman.json"
diff --git a/src/plugins/bearer/connman/CMakeLists.txt b/src/plugins/bearer/connman/CMakeLists.txt
deleted file mode 100644
index 745f48b6e0..0000000000
--- a/src/plugins/bearer/connman/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# Generated from connman.pro.
-
-#####################################################################
-## QConnmanEnginePlugin Plugin:
-#####################################################################
-
-qt_add_plugin(QConnmanEnginePlugin
- OUTPUT_NAME qconnmanbearer
- TYPE bearer
- SOURCES
- main.cpp
- qconnmanengine.cpp qconnmanengine.h
- qconnmanservice_linux.cpp qconnmanservice_linux_p.h
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::DBus
- Qt::LinuxOfonoSupportPrivate
- Qt::NetworkPrivate
-)
-
-#### Keys ignored in scope 1:.:.:connman.pro:<TRUE>:
-# OTHER_FILES = "connman.json"
diff --git a/src/plugins/bearer/connman/connman.json b/src/plugins/bearer/connman/connman.json
deleted file mode 100644
index 7a80b8c9be..0000000000
--- a/src/plugins/bearer/connman/connman.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "connman" ]
-}
diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro
deleted file mode 100644
index 03e94cfe6a..0000000000
--- a/src/plugins/bearer/connman/connman.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qconnmanbearer
-
-QT = core network-private dbus linuxofono_support_private
-
-HEADERS += qconnmanservice_linux_p.h \
- qconnmanengine.h
-
-SOURCES += main.cpp \
- qconnmanservice_linux.cpp \
- qconnmanengine.cpp
-
-OTHER_FILES += connman.json
-
-PLUGIN_TYPE = bearer
-PLUGIN_CLASS_NAME = QConnmanEnginePlugin
-load(qt_plugin)
diff --git a/src/plugins/bearer/connman/main.cpp b/src/plugins/bearer/connman/main.cpp
deleted file mode 100644
index 03c8a7f6c5..0000000000
--- a/src/plugins/bearer/connman/main.cpp
+++ /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$
-**
-****************************************************************************/
-#include "qconnmanengine.h"
-
-#include <QtNetwork/private/qbearerplugin_p.h>
-
-#include <QtCore/qdebug.h>
-
-#ifndef QT_NO_DBUS
-
-QT_BEGIN_NAMESPACE
-
-class QConnmanEnginePlugin : public QBearerEnginePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "connman.json")
-
-public:
- QConnmanEnginePlugin();
- ~QConnmanEnginePlugin();
-
- QBearerEngine *create(const QString &key) const;
-};
-
-QConnmanEnginePlugin::QConnmanEnginePlugin()
-{
-}
-
-QConnmanEnginePlugin::~QConnmanEnginePlugin()
-{
-}
-
-QBearerEngine *QConnmanEnginePlugin::create(const QString &key) const
-{
- if (key == QLatin1String("connman")) {
- QConnmanEngine *engine = new QConnmanEngine;
- if (engine->connmanAvailable())
- return engine;
- else
- delete engine;
- }
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#include "main.moc"
-
-#endif
diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp
deleted file mode 100644
index a673834825..0000000000
--- a/src/plugins/bearer/connman/qconnmanengine.cpp
+++ /dev/null
@@ -1,570 +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$
-**
-****************************************************************************/
-
-#include "qconnmanengine.h"
-#include "qconnmanservice_linux_p.h"
-#include <private/qnetworksession_impl_p.h>
-
-#include <QtNetwork/private/qnetworkconfiguration_p.h>
-
-#include <QtNetwork/qnetworksession.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/private/qlocking_p.h>
-
-#include <QtDBus/QtDBus>
-#include <QtDBus/QDBusConnection>
-#include <QtDBus/QDBusInterface>
-#include <QtDBus/QDBusMessage>
-#include <QtDBus/QDBusReply>
-#ifndef QT_NO_DBUS
-
-QT_BEGIN_NAMESPACE
-
-QConnmanEngine::QConnmanEngine(QObject *parent)
-: QBearerEngineImpl(parent),
- connmanManager(new QConnmanManagerInterface(this)),
- ofonoManager(new QOfonoManagerInterface(this)),
- ofonoNetwork(0),
- ofonoContextManager(0)
-{
- qDBusRegisterMetaType<ConnmanMap>();
- qDBusRegisterMetaType<ConnmanMapList>();
- qRegisterMetaType<ConnmanMapList>("ConnmanMapList");
-}
-
-QConnmanEngine::~QConnmanEngine()
-{
-}
-
-bool QConnmanEngine::connmanAvailable() const
-{
- const auto locker = qt_scoped_lock(mutex);
- return connmanManager->isValid();
-}
-
-void QConnmanEngine::initialize()
-{
- const auto locker = qt_scoped_lock(mutex);
- connect(ofonoManager,SIGNAL(modemChanged()),this,SLOT(changedModem()));
-
- ofonoNetwork = new QOfonoNetworkRegistrationInterface(ofonoManager->currentModem(),this);
- ofonoContextManager = new QOfonoDataConnectionManagerInterface(ofonoManager->currentModem(),this);
- connect(ofonoContextManager,SIGNAL(roamingAllowedChanged(bool)),this,SLOT(reEvaluateCellular()));
-
- connect(connmanManager,SIGNAL(servicesChanged(ConnmanMapList,QList<QDBusObjectPath>)),
- this, SLOT(updateServices(ConnmanMapList,QList<QDBusObjectPath>)));
-
- connect(connmanManager,SIGNAL(servicesReady(QStringList)),this,SLOT(servicesReady(QStringList)));
- connect(connmanManager,SIGNAL(scanFinished(bool)),this,SLOT(finishedScan(bool)));
-
- const auto servPaths = connmanManager->getServices();
- for (const QString &servPath : servPaths)
- addServiceConfiguration(servPath);
- Q_EMIT updateCompleted();
-}
-
-void QConnmanEngine::changedModem()
-{
- const auto locker = qt_scoped_lock(mutex);
- if (ofonoNetwork)
- delete ofonoNetwork;
-
- ofonoNetwork = new QOfonoNetworkRegistrationInterface(ofonoManager->currentModem(),this);
-
- if (ofonoContextManager)
- delete ofonoContextManager;
- ofonoContextManager = new QOfonoDataConnectionManagerInterface(ofonoManager->currentModem(),this);
-}
-
-void QConnmanEngine::servicesReady(const QStringList &list)
-{
- const auto locker = qt_scoped_lock(mutex);
- for (const QString &servPath : list)
- addServiceConfiguration(servPath);
-
- Q_EMIT updateCompleted();
-}
-
-QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations()
-{
- const auto locker = qt_scoped_lock(mutex);
- QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
- QNetworkConfigurationPrivate* cpPriv = 0;
- const int numFoundConfigurations = foundConfigurations.count();
- fetchedConfigurations.reserve(numFoundConfigurations);
-
- for (int i = 0; i < numFoundConfigurations; ++i) {
- QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate;
- cpPriv = foundConfigurations.at(i);
-
- config->name = cpPriv->name;
- config->isValid = cpPriv->isValid;
- config->id = cpPriv->id;
- config->state = cpPriv->state;
- config->type = cpPriv->type;
- config->roamingSupported = cpPriv->roamingSupported;
- config->purpose = cpPriv->purpose;
- config->bearerType = cpPriv->bearerType;
-
- fetchedConfigurations.append(config);
- delete config;
- }
- return fetchedConfigurations;
-}
-
-QString QConnmanEngine::getInterfaceFromId(const QString &id)
-{
- const auto locker = qt_scoped_lock(mutex);
- return configInterfaces.value(id);
-}
-
-bool QConnmanEngine::hasIdentifier(const QString &id)
-{
- const auto locker = qt_scoped_lock(mutex);
- return accessPointConfigurations.contains(id);
-}
-
-void QConnmanEngine::connectToId(const QString &id)
-{
- const auto locker = qt_scoped_lock(mutex);
-
- QConnmanServiceInterface *serv = connmanServiceInterfaces.value(id);
-
- if (!serv || !serv->isValid()) {
- emit connectionError(id, QBearerEngineImpl::InterfaceLookupError);
- } else {
- if (serv->type() == QLatin1String("cellular")) {
- if (serv->roaming()) {
- if (!isRoamingAllowed(serv->path())) {
- emit connectionError(id, QBearerEngineImpl::OperationNotSupported);
- return;
- }
- }
- }
- if (serv->autoConnect())
- serv->connect();
- }
-}
-
-void QConnmanEngine::disconnectFromId(const QString &id)
-{
- const auto locker = qt_scoped_lock(mutex);
- QConnmanServiceInterface *serv = connmanServiceInterfaces.value(id);
-
- if (!serv || !serv->isValid()) {
- emit connectionError(id, DisconnectionError);
- } else {
- serv->disconnect();
- }
-}
-
-void QConnmanEngine::requestUpdate()
-{
- const auto locker = qt_scoped_lock(mutex);
- QTimer::singleShot(0, this, SLOT(doRequestUpdate()));
-}
-
-void QConnmanEngine::doRequestUpdate()
-{
- bool scanned = connmanManager->requestScan("wifi");
- if (!scanned)
- Q_EMIT updateCompleted();
-}
-
-void QConnmanEngine::finishedScan(bool error)
-{
- if (error)
- Q_EMIT updateCompleted();
-}
-
-void QConnmanEngine::updateServices(const ConnmanMapList &changed, const QList<QDBusObjectPath> &removed)
-{
- const auto locker = qt_scoped_lock(mutex);
-
- foreach (const QDBusObjectPath &objectPath, removed) {
- removeConfiguration(objectPath.path());
- }
-
- foreach (const ConnmanMap &connmanMap, changed) {
- const QString id = connmanMap.objectPath.path();
- if (accessPointConfigurations.contains(id)) {
- configurationChange(connmanServiceInterfaces.value(id));
- } else {
- addServiceConfiguration(connmanMap.objectPath.path());
- }
- }
- Q_EMIT updateCompleted();
-}
-
-QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id)
-{
- const auto locker = qt_scoped_lock(mutex);
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- if (!ptr || !ptr->isValid)
- return QNetworkSession::Invalid;
-
- QString service = id;
- QConnmanServiceInterface *serv = connmanServiceInterfaces.value(service);
- if (!serv)
- return QNetworkSession::Invalid;
-
- QString servState = serv->state();
-
- if (serv->favorite() && (servState == QLatin1String("idle") || servState == QLatin1String("failure"))) {
- return QNetworkSession::Disconnected;
- }
-
- if (servState == QLatin1String("association") || servState == QLatin1String("configuration")) {
- return QNetworkSession::Connecting;
- }
-
- if (servState == QLatin1String("online") || servState == QLatin1String("ready")) {
- return QNetworkSession::Connected;
- }
-
- if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
- return QNetworkSession::Disconnected;
- } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
- return QNetworkSession::NotAvailable;
- } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
- QNetworkConfiguration::Undefined) {
- return QNetworkSession::NotAvailable;
- }
-
- return QNetworkSession::Invalid;
-}
-
-quint64 QConnmanEngine::bytesWritten(const QString &id)
-{//TODO use connman counter API
- const auto locker = qt_scoped_lock(mutex);
- quint64 result = 0;
- QString devFile = getInterfaceFromId(id);
- QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes");
- if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&tx);
- in >> result;
- tx.close();
- }
-
- return result;
-}
-
-quint64 QConnmanEngine::bytesReceived(const QString &id)
-{//TODO use connman counter API
- const auto locker = qt_scoped_lock(mutex);
- quint64 result = 0;
- QString devFile = getInterfaceFromId(id);
- QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes");
- if (rx.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&rx);
- in >> result;
- rx.close();
- }
- return result;
-}
-
-quint64 QConnmanEngine::startTime(const QString &/*id*/)
-{
- // TODO
- const auto locker = qt_scoped_lock(mutex);
- if (activeTime.isNull()) {
- return 0;
- }
- return activeTime.secsTo(QDateTime::currentDateTime());
-}
-
-QNetworkConfigurationManager::Capabilities QConnmanEngine::capabilities() const
-{
- return QNetworkConfigurationManager::ForcedRoaming |
- QNetworkConfigurationManager::DataStatistics |
- QNetworkConfigurationManager::CanStartAndStopInterfaces |
- QNetworkConfigurationManager::NetworkSessionRequired;
-}
-
-QNetworkSessionPrivate *QConnmanEngine::createSessionBackend()
-{
- return new QNetworkSessionPrivateImpl;
-}
-
-QNetworkConfigurationPrivatePointer QConnmanEngine::defaultConfiguration()
-{
- const auto locker = qt_scoped_lock(mutex);
- const auto servPaths = connmanManager->getServices();
- for (const QString &servPath : servPaths) {
- if (connmanServiceInterfaces.contains(servPath)) {
- if (accessPointConfigurations.contains(servPath))
- return accessPointConfigurations.value(servPath);
- }
- }
- return QNetworkConfigurationPrivatePointer();
-}
-
-void QConnmanEngine::serviceStateChanged(const QString &state)
-{
- QConnmanServiceInterface *service = qobject_cast<QConnmanServiceInterface *>(sender());
- configurationChange(service);
-
- if (state == QLatin1String("failure")) {
- emit connectionError(service->path(), ConnectError);
- }
-}
-
-void QConnmanEngine::configurationChange(QConnmanServiceInterface *serv)
-{
- if (!serv)
- return;
- auto locker = qt_unique_lock(mutex);
- QString id = serv->path();
-
- if (accessPointConfigurations.contains(id)) {
- bool changed = false;
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- QString networkName = serv->name();
- QNetworkConfiguration::StateFlags curState = getStateForService(serv->path());
- ptr->mutex.lock();
-
- if (!ptr->isValid) {
- ptr->isValid = true;
- }
-
- if (ptr->name != networkName) {
- ptr->name = networkName;
- changed = true;
- }
-
- if (ptr->state != curState) {
- ptr->state = curState;
- changed = true;
- }
-
- ptr->mutex.unlock();
-
- if (changed) {
- locker.unlock();
- emit configurationChanged(ptr);
- locker.lock();
- }
- }
-
- locker.unlock();
- emit updateCompleted();
-}
-
-QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QString &service)
-{
- const auto locker = qt_scoped_lock(mutex);
- QConnmanServiceInterface *serv = connmanServiceInterfaces.value(service);
- if (!serv)
- return QNetworkConfiguration::Undefined;
-
- QString state = serv->state();
- QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
-
- if (serv->type() == QLatin1String("cellular")) {
-
- if (!serv->autoConnect()|| (serv->roaming()
- && !isRoamingAllowed(serv->path()))) {
- flag = (flag | QNetworkConfiguration::Defined);
- } else {
- flag = (flag | QNetworkConfiguration::Discovered);
- }
- } else {
- if (serv->favorite()) {
- if (serv->autoConnect()) {
- flag = (flag | QNetworkConfiguration::Discovered);
- }
- } else {
- flag = QNetworkConfiguration::Undefined;
- }
- }
- if (state == QLatin1String("online") || state == QLatin1String("ready")) {
- flag = (flag | QNetworkConfiguration::Active);
- }
-
- return flag;
-}
-
-QNetworkConfiguration::BearerType QConnmanEngine::typeToBearer(const QString &type)
-{
- if (type == QLatin1String("wifi"))
- return QNetworkConfiguration::BearerWLAN;
- if (type == QLatin1String("ethernet"))
- return QNetworkConfiguration::BearerEthernet;
- if (type == QLatin1String("bluetooth"))
- return QNetworkConfiguration::BearerBluetooth;
- if (type == QLatin1String("cellular")) {
- return ofonoTechToBearerType(type);
- }
- if (type == QLatin1String("wimax"))
- return QNetworkConfiguration::BearerWiMAX;
-
- return QNetworkConfiguration::BearerUnknown;
-}
-
-QNetworkConfiguration::BearerType QConnmanEngine::ofonoTechToBearerType(const QString &/*type*/)
-{
- if (ofonoNetwork) {
- QString currentTechnology = ofonoNetwork->getTechnology();
- if (currentTechnology == QLatin1String("gsm")) {
- return QNetworkConfiguration::Bearer2G;
- } else if (currentTechnology == QLatin1String("edge")) {
- return QNetworkConfiguration::BearerCDMA2000; //wrong, I know
- } else if (currentTechnology == QLatin1String("umts")) {
- return QNetworkConfiguration::BearerWCDMA;
- } else if (currentTechnology == QLatin1String("hspa")) {
- return QNetworkConfiguration::BearerHSPA;
- } else if (currentTechnology == QLatin1String("lte")) {
- return QNetworkConfiguration::BearerLTE;
- }
- }
- return QNetworkConfiguration::BearerUnknown;
-}
-
-bool QConnmanEngine::isRoamingAllowed(const QString &context)
-{
- const auto dcPaths = ofonoContextManager->contexts();
- for (const QString &dcPath : dcPaths) {
- if (dcPath.contains(context.section("_",-1))) {
- return ofonoContextManager->roamingAllowed();
- }
- }
- return false;
-}
-
-void QConnmanEngine::removeConfiguration(const QString &id)
-{
- auto locker = qt_unique_lock(mutex);
-
- if (accessPointConfigurations.contains(id)) {
-
- disconnect(connmanServiceInterfaces.value(id),SIGNAL(stateChanged(QString)),
- this,SLOT(serviceStateChanged(QString)));
- serviceNetworks.removeOne(id);
- QConnmanServiceInterface *service = connmanServiceInterfaces.take(id);
- delete service;
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
- foundConfigurations.removeOne(ptr.data());
- locker.unlock();
- emit configurationRemoved(ptr);
- }
-}
-
-void QConnmanEngine::addServiceConfiguration(const QString &servicePath)
-{
- auto locker = qt_unique_lock(mutex);
- if (!connmanServiceInterfaces.contains(servicePath)) {
- QConnmanServiceInterface *serv = new QConnmanServiceInterface(servicePath, this);
- connmanServiceInterfaces.insert(serv->path(),serv);
- }
-
- if (!accessPointConfigurations.contains(servicePath)) {
-
- serviceNetworks.append(servicePath);
-
- connect(connmanServiceInterfaces.value(servicePath),SIGNAL(stateChanged(QString)),
- this,SLOT(serviceStateChanged(QString)));
-
- QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
- QConnmanServiceInterface *service = connmanServiceInterfaces.value(servicePath);
-
- QString networkName = service->name();
-
- const QString connectionType = service->type();
- if (connectionType == QLatin1String("ethernet")) {
- cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
- } else if (connectionType == QLatin1String("wifi")) {
- cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
- } else if (connectionType == QLatin1String("cellular")) {
- cpPriv->bearerType = ofonoTechToBearerType(QLatin1String("cellular"));
- cpPriv->roamingSupported = service->roaming() && isRoamingAllowed(servicePath);
- } else if (connectionType == QLatin1String("wimax")) {
- cpPriv->bearerType = QNetworkConfiguration::BearerWiMAX;
- } else {
- cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
- }
-
- cpPriv->name = networkName;
- cpPriv->isValid = true;
- cpPriv->id = servicePath;
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
-
- if (service->security() == QLatin1String("none")) {
- cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
- } else {
- cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
- }
-
- cpPriv->state = getStateForService(servicePath);
-
- QNetworkConfigurationPrivatePointer ptr(cpPriv);
- accessPointConfigurations.insert(ptr->id, ptr);
- if (connectionType == QLatin1String("cellular")) {
- foundConfigurations.append(cpPriv);
- } else {
- foundConfigurations.prepend(cpPriv);
- }
- configInterfaces[cpPriv->id] = service->serviceInterface();
-
- locker.unlock();
- Q_EMIT configurationAdded(ptr);
- }
-}
-
-bool QConnmanEngine::requiresPolling() const
-{
- return false;
-}
-
-void QConnmanEngine::reEvaluateCellular()
-{
- const auto servicePaths = connmanManager->getServices();
- for (const QString &servicePath : servicePaths) {
- if (servicePath.contains("cellular") && accessPointConfigurations.contains(servicePath)) {
- configurationChange(connmanServiceInterfaces.value(servicePath));
- }
- }
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h
deleted file mode 100644
index 969eed45b1..0000000000
--- a/src/plugins/bearer/connman/qconnmanengine.h
+++ /dev/null
@@ -1,145 +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 QCONNMANENGINE_P_H
-#define QCONNMANENGINE_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 <private/qbearerengine_impl_p.h>
-
-#include "qconnmanservice_linux_p.h"
-#include <private/qofonoservice_linux_p.h>
-
-#include <QMap>
-#include <QVariant>
-
-#ifndef QT_NO_DBUS
-
-QT_BEGIN_NAMESPACE
-
-class QConnmanEngine : public QBearerEngineImpl
-{
- Q_OBJECT
-
-public:
- QConnmanEngine(QObject *parent = nullptr);
- ~QConnmanEngine();
-
- bool connmanAvailable() const;
-
- virtual QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
-
- virtual void connectToId(const QString &id);
- virtual void disconnectFromId(const QString &id);
-
- Q_INVOKABLE void initialize();
- Q_INVOKABLE void requestUpdate();
-
- QNetworkSession::State sessionStateForId(const QString &id);
- QNetworkSessionPrivate *createSessionBackend();
-
- virtual quint64 bytesWritten(const QString &id);
- virtual quint64 bytesReceived(const QString &id);
- virtual quint64 startTime(const QString &id);
-
- virtual QNetworkConfigurationManager::Capabilities capabilities() const;
- virtual QNetworkConfigurationPrivatePointer defaultConfiguration();
-
- QList<QNetworkConfigurationPrivate *> getConfigurations();
-
-private Q_SLOTS:
-
- void doRequestUpdate();
- void updateServices(const ConnmanMapList &changed, const QList<QDBusObjectPath> &removed);
-
- void servicesReady(const QStringList &);
- void finishedScan(bool error);
- void changedModem();
- void serviceStateChanged(const QString &state);
- void configurationChange(QConnmanServiceInterface * service);
- void reEvaluateCellular();
-private:
- QConnmanManagerInterface *connmanManager;
-
- QOfonoManagerInterface *ofonoManager;
- QOfonoNetworkRegistrationInterface *ofonoNetwork;
- QOfonoDataConnectionManagerInterface *ofonoContextManager;
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
- QString networkFromId(const QString &id);
-
- QNetworkConfiguration::StateFlags getStateForService(const QString &service);
- QNetworkConfiguration::BearerType typeToBearer(const QString &type);
-
- void removeConfiguration(const QString &servicePath);
- void addServiceConfiguration(const QString &servicePath);
- QDateTime activeTime;
-
-
- QMap<QString,QConnmanTechnologyInterface *> technologies; // techpath, tech interface
- QMap<QString,QString> configInterfaces; // id, interface name
- QList<QString> serviceNetworks; //servpath
-
- QNetworkConfiguration::BearerType ofonoTechToBearerType(const QString &type);
- bool isRoamingAllowed(const QString &context);
- QMap <QString,QConnmanServiceInterface *> connmanServiceInterfaces;
-
-protected:
- bool requiresPolling() const;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DBUS
-
-#endif
-
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
deleted file mode 100644
index 35d9c40680..0000000000
--- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp
+++ /dev/null
@@ -1,516 +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$
-**
-****************************************************************************/
-
-#include <QObject>
-#include <QList>
-#include <QtDBus/QtDBus>
-#include <QtDBus/QDBusConnection>
-#include <QtDBus/QDBusError>
-#include <QtDBus/QDBusInterface>
-#include <QtDBus/QDBusMessage>
-#include <QtDBus/QDBusReply>
-#include <QtDBus/QDBusPendingCallWatcher>
-#include <QtDBus/QDBusObjectPath>
-#include <QtDBus/QDBusPendingCall>
-
-#include "qconnmanservice_linux_p.h"
-
-#ifndef QT_NO_DBUS
-
-QT_BEGIN_NAMESPACE
-
-QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &map)
-{
- argument.beginStructure();
- argument << map.objectPath << map.propertyMap;
- argument.endStructure();
- return argument;
-}
-
-const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &map)
-{
- argument.beginStructure();
- argument >> map.objectPath >> map.propertyMap;
- argument.endStructure();
- return argument;
-}
-
-QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent)
- : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
- QLatin1String(CONNMAN_MANAGER_PATH),
- CONNMAN_MANAGER_INTERFACE,
- QDBusConnection::systemBus(), parent)
-{
- qDBusRegisterMetaType<ConnmanMap>();
- qDBusRegisterMetaType<ConnmanMapList>();
-
- QDBusPendingReply<QVariantMap> props_reply = asyncCall(QLatin1String("GetProperties"));
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(props_reply, this);
-
- QObject::connect(watcher,SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(propertiesReply(QDBusPendingCallWatcher*)));
-
- QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE),
- QLatin1String(CONNMAN_MANAGER_PATH),
- QLatin1String(CONNMAN_SERVICE_INTERFACE),
- QLatin1String("PropertyChanged"),
- this,SLOT(changedProperty(QString,QDBusVariant)));
-
-
- QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE),
- QLatin1String(CONNMAN_MANAGER_PATH),
- QLatin1String(CONNMAN_SERVICE_INTERFACE),
- QLatin1String("TechnologyAdded"),
- this,SLOT(technologyAdded(QDBusObjectPath,QVariantMap)));
-
- QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE),
- QLatin1String(CONNMAN_MANAGER_PATH),
- QLatin1String(CONNMAN_SERVICE_INTERFACE),
- QLatin1String("TechnologyRemoved"),
- this,SLOT(technologyRemoved(QDBusObjectPath)));
-
- QDBusPendingReply<ConnmanMapList> serv_reply = asyncCall(QLatin1String("GetServices"));
- QDBusPendingCallWatcher *watcher2 = new QDBusPendingCallWatcher(serv_reply, this);
-
- QObject::connect(watcher2,SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(servicesReply(QDBusPendingCallWatcher*)));
-
-}
-
-QConnmanManagerInterface::~QConnmanManagerInterface()
-{
-}
-
-void QConnmanManagerInterface::changedProperty(const QString &name, const QDBusVariant &value)
-{
- propertiesCacheMap[name] = value.variant();
-}
-
-void QConnmanManagerInterface::propertiesReply(QDBusPendingCallWatcher *call)
-{
- QDBusPendingReply<QVariantMap> props_reply = *call;
-
- if (props_reply.isError()) {
- qDebug() << props_reply.error().message();
- } else {
- propertiesCacheMap = props_reply.value();
- }
- call->deleteLater();
-}
-
-void QConnmanManagerInterface::servicesReply(QDBusPendingCallWatcher *call)
-{
- QDBusPendingReply<ConnmanMapList> serv_reply = *call;
-
- if (serv_reply.isError()) {
- qDebug() << serv_reply.error().message();
- } else {
- servicesList.clear(); //connman list changes order
- const ConnmanMapList connmanobjs = serv_reply.value();
- for (const ConnmanMap &connmanobj : connmanobjs)
- servicesList << connmanobj.objectPath.path();
- Q_EMIT servicesReady(servicesList);
- }
- call->deleteLater();
-}
-
-void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal)
-{
- static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanManagerInterface::propertyChanged);
- if (signal == propertyChangedSignal) {
- if (!connection().connect(QLatin1String(CONNMAN_SERVICE),
- QLatin1String(CONNMAN_MANAGER_PATH),
- QLatin1String(CONNMAN_MANAGER_INTERFACE),
- QLatin1String("PropertyChanged"),
- this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
- qWarning("PropertyChanged not connected");
- }
- }
-
- static const QMetaMethod servicesChangedSignal = QMetaMethod::fromSignal(&QConnmanManagerInterface::servicesChanged);
- if (signal == servicesChangedSignal) {
- if (!connection().connect(QLatin1String(CONNMAN_SERVICE),
- QLatin1String(CONNMAN_MANAGER_PATH),
- QLatin1String(CONNMAN_MANAGER_INTERFACE),
- QLatin1String("ServicesChanged"),
- this,SLOT(onServicesChanged(ConnmanMapList,QList<QDBusObjectPath>)))) {
- qWarning("servicesChanged not connected");
- }
- }
-}
-
-void QConnmanManagerInterface::onServicesChanged(const ConnmanMapList &changed, const QList<QDBusObjectPath> &removed)
-{
- servicesList.clear(); //connman list changes order
- for (const ConnmanMap &connmanobj : changed) {
- const QString svcPath(connmanobj.objectPath.path());
- servicesList << svcPath;
- }
-
- Q_EMIT servicesChanged(changed, removed);
-}
-
-QVariant QConnmanManagerInterface::getProperty(const QString &property)
-{
- QVariant var;
- var = propertiesCacheMap.value(property);
- return var;
-}
-
-QVariantMap QConnmanManagerInterface::getProperties()
-{
- if (propertiesCacheMap.isEmpty()) {
- QDBusPendingReply<QVariantMap> reply = call(QLatin1String("GetProperties"));
- reply.waitForFinished();
- if (!reply.isError()) {
- propertiesCacheMap = reply.value();
- }
- }
- return propertiesCacheMap;
-}
-
-QString QConnmanManagerInterface::getState()
-{
- return getProperty(QStringLiteral("State")).toString();
-}
-
-bool QConnmanManagerInterface::getOfflineMode()
-{
- QVariant var = getProperty(QStringLiteral("OfflineMode"));
- return qdbus_cast<bool>(var);
-}
-
-QStringList QConnmanManagerInterface::getTechnologies()
-{
- if (technologiesMap.isEmpty()) {
- QDBusPendingReply<ConnmanMapList> reply = call(QLatin1String("GetTechnologies"));
- reply.waitForFinished();
- if (!reply.isError()) {
- const ConnmanMapList maps = reply.value();
- for (const ConnmanMap &map : maps) {
- if (!technologiesMap.contains(map.objectPath.path())) {
- technologyAdded(map.objectPath, map.propertyMap);
- }
- }
- }
- }
- return technologiesMap.keys();
-}
-
-QStringList QConnmanManagerInterface::getServices()
-{
- if (servicesList.isEmpty()) {
- QDBusPendingReply<ConnmanMapList> reply = call(QLatin1String("GetServices"));
- reply.waitForFinished();
- if (!reply.isError()) {
- const ConnmanMapList maps = reply.value();
- for (const ConnmanMap &map : maps)
- servicesList << map.objectPath.path();
- }
- }
- return servicesList;
-}
-
-bool QConnmanManagerInterface::requestScan(const QString &type)
-{
- bool scanned = false;
- if (technologiesMap.isEmpty())
- getTechnologies();
- Q_FOREACH (QConnmanTechnologyInterface *tech, technologiesMap) {
- if (tech->type() == type) {
- tech->scan();
- scanned = true;
- }
- }
- return scanned;
-}
-
-void QConnmanManagerInterface::technologyAdded(const QDBusObjectPath &path, const QVariantMap &)
-{
- if (!technologiesList.contains(path.path())) {
- technologiesList << path.path();
- QConnmanTechnologyInterface *tech;
- tech = new QConnmanTechnologyInterface(path.path(),this);
- technologiesMap.insert(path.path(),tech);
- connect(tech,SIGNAL(scanFinished(bool)),this,SIGNAL(scanFinished(bool)));
- }
-}
-
-void QConnmanManagerInterface::technologyRemoved(const QDBusObjectPath &path)
-{
- if (technologiesList.contains(path.path())) {
- technologiesList.removeOne(path.path());
- QConnmanTechnologyInterface * tech = technologiesMap.take(path.path());
- delete tech;
- }
-}
-
-QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,QObject *parent)
- : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
- dbusPathName,
- CONNMAN_SERVICE_INTERFACE,
- QDBusConnection::systemBus(), parent)
-{
- QDBusPendingReply<QVariantMap> props_reply = asyncCall(QLatin1String("GetProperties"));
-
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(props_reply, this);
-
- QObject::connect(watcher,SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(propertiesReply(QDBusPendingCallWatcher*)));
-
- QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE),
- path(),
- QLatin1String(CONNMAN_SERVICE_INTERFACE),
- QLatin1String("PropertyChanged"),
- this,SLOT(changedProperty(QString,QDBusVariant)));
-}
-
-QConnmanServiceInterface::~QConnmanServiceInterface()
-{
-}
-
-QVariantMap QConnmanServiceInterface::getProperties()
-{
- if (propertiesCacheMap.isEmpty()) {
- QDBusPendingReply<QVariantMap> reply = call(QLatin1String("GetProperties"));
- reply.waitForFinished();
- if (!reply.isError()) {
- propertiesCacheMap = reply.value();
- Q_EMIT propertiesReady();
- }
- }
- return propertiesCacheMap;
-}
-
-void QConnmanServiceInterface::propertiesReply(QDBusPendingCallWatcher *call)
-{
- QDBusPendingReply<QVariantMap> props_reply = *call;
- if (props_reply.isError()) {
- qDebug() << props_reply.error().message();
- return;
- }
- propertiesCacheMap = props_reply.value();
- Q_EMIT propertiesReady();
-}
-
-void QConnmanServiceInterface::connectNotify(const QMetaMethod &signal)
-{
- static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanServiceInterface::propertyChanged);
- if (signal == propertyChangedSignal) {
- QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE),
- path(),
- QLatin1String(CONNMAN_SERVICE_INTERFACE),
- QLatin1String("PropertyChanged"),
- this,SIGNAL(propertyChanged(QString,QDBusVariant)));
- }
-}
-
-void QConnmanServiceInterface::changedProperty(const QString &name, const QDBusVariant &value)
-{
- propertiesCacheMap[name] = value.variant();
- if (name == QLatin1String("State"))
- Q_EMIT stateChanged(value.variant().toString());
-}
-
-QVariant QConnmanServiceInterface::getProperty(const QString &property)
-{
- QVariant var;
- QVariantMap map = getProperties();
- var = map.value(property);
- return var;
-}
-
-void QConnmanServiceInterface::connect()
-{
- asyncCall(QLatin1String("Connect"));
-}
-
-void QConnmanServiceInterface::disconnect()
-{
- asyncCall(QLatin1String("Disconnect"));
-}
-
-void QConnmanServiceInterface::remove()
-{
- asyncCall(QLatin1String("Remove"));
-}
-
-// properties
-QString QConnmanServiceInterface::state()
-{
- QVariant var = getProperty(QStringLiteral("State"));
- return qdbus_cast<QString>(var);
-}
-
-QString QConnmanServiceInterface::lastError()
-{
- QVariant var = getProperty(QStringLiteral("Error"));
- return qdbus_cast<QString>(var);
-}
-
-QString QConnmanServiceInterface::name()
-{
- QVariant var = getProperty(QStringLiteral("Name"));
- return qdbus_cast<QString>(var);
-}
-
-QString QConnmanServiceInterface::type()
-{
- QVariant var = getProperty(QStringLiteral("Type"));
- return qdbus_cast<QString>(var);
-}
-
-QString QConnmanServiceInterface::security()
-{
- QVariant var = getProperty(QStringLiteral("Security"));
- return qdbus_cast<QString>(var);
-}
-
-bool QConnmanServiceInterface::favorite()
-{
- QVariant var = getProperty(QStringLiteral("Favorite"));
- return qdbus_cast<bool>(var);
-}
-
-bool QConnmanServiceInterface::autoConnect()
-{
- QVariant var = getProperty(QStringLiteral("AutoConnect"));
- return qdbus_cast<bool>(var);
-}
-
-bool QConnmanServiceInterface::roaming()
-{
- QVariant var = getProperty(QStringLiteral("Roaming"));
- return qdbus_cast<bool>(var);
-}
-
-QVariantMap QConnmanServiceInterface::ethernet()
-{
- QVariant var = getProperty(QStringLiteral("Ethernet"));
- return qdbus_cast<QVariantMap >(var);
-}
-
-QString QConnmanServiceInterface::serviceInterface()
-{
- QVariantMap map = ethernet();
- return map.value(QStringLiteral("Interface")).toString();
-}
-
-bool QConnmanServiceInterface::isOfflineMode()
-{
- QVariant var = getProperty(QStringLiteral("OfflineMode"));
- return qdbus_cast<bool>(var);
-}
-
-QStringList QConnmanServiceInterface::services()
-{
- QVariant var = getProperty(QStringLiteral("Services"));
- return qdbus_cast<QStringList>(var);
-}
-
-//////////////////////////
-QConnmanTechnologyInterface::QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent)
- : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
- dbusPathName,
- CONNMAN_TECHNOLOGY_INTERFACE,
- QDBusConnection::systemBus(), parent)
-{
-}
-
-QConnmanTechnologyInterface::~QConnmanTechnologyInterface()
-{
-}
-
-void QConnmanTechnologyInterface::connectNotify(const QMetaMethod &signal)
-{
- static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanTechnologyInterface::propertyChanged);
- if (signal == propertyChangedSignal) {
- QDBusConnection::systemBus().connect(QLatin1String(CONNMAN_SERVICE),
- path(),
- QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE),
- QLatin1String("PropertyChanged"),
- this,SIGNAL(propertyChanged(QString,QDBusVariant)));
- }
-}
-
-QVariantMap QConnmanTechnologyInterface::properties()
-{
- if (propertiesMap.isEmpty()) {
- QDBusPendingReply<QVariantMap> reply = call(QLatin1String("GetProperties"));
- reply.waitForFinished();
- propertiesMap = reply.value();
- }
- return propertiesMap;
-}
-
-QVariant QConnmanTechnologyInterface::getProperty(const QString &property)
-{
- QVariant var;
- QVariantMap map = properties();
- var = map.value(property);
- return var;
-}
-
-QString QConnmanTechnologyInterface::type()
-{
- QVariant var = getProperty(QStringLiteral("Type"));
- return qdbus_cast<QString>(var);
-}
-
-void QConnmanTechnologyInterface::scan()
-{
- QDBusPendingReply<> reply = asyncCall(QLatin1String("Scan"));
- QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(scanReply(QDBusPendingCallWatcher*)));
-}
-
-void QConnmanTechnologyInterface::scanReply(QDBusPendingCallWatcher *call)
-{
- QDBusPendingReply<> props_reply = *call;
- if (props_reply.isError()) {
- qDebug() << props_reply.error().message();
- }
- Q_EMIT scanFinished(props_reply.isError());
- call->deleteLater();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h
deleted file mode 100644
index 790325f9a1..0000000000
--- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h
+++ /dev/null
@@ -1,230 +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 QCONNMANSERVICE_H
-#define QCONNMANSERVICE_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 <QtDBus/QtDBus>
-#include <QtDBus/QDBusConnection>
-#include <QtDBus/QDBusError>
-#include <QtDBus/QDBusInterface>
-#include <QtDBus/QDBusMessage>
-#include <QtDBus/QDBusReply>
-#include <QtDBus/QDBusArgument>
-
-#include <QtDBus/QDBusPendingCallWatcher>
-#include <QtDBus/QDBusObjectPath>
-#include <QtDBus/QDBusContext>
-#include <QMap>
-
-#ifndef QT_NO_DBUS
-
-#ifndef __CONNMAN_DBUS_H
-
-#define CONNMAN_SERVICE "net.connman"
-#define CONNMAN_PATH "/net/connman"
-#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
-#define CONNMAN_MANAGER_PATH "/"
-#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
-#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-struct ConnmanMap {
- QDBusObjectPath objectPath;
- QVariantMap propertyMap;
-};
-Q_DECLARE_TYPEINFO(ConnmanMap, Q_MOVABLE_TYPE); // QDBusObjectPath is movable, but cannot be
- // marked as such until Qt 6
-typedef QVector<ConnmanMap> ConnmanMapList;
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ConnmanMap))
-Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ConnmanMapList))
-
-QT_BEGIN_NAMESPACE
-
-QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj);
-const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj);
-
-class QConnmanTechnologyInterface;
-class QConnmanServiceInterface;
-
-class QConnmanManagerInterface : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- QConnmanManagerInterface( QObject *parent = nullptr);
- ~QConnmanManagerInterface();
-
- QDBusObjectPath path() const;
- QVariantMap getProperties();
-
- QString getState();
- bool getOfflineMode();
- QStringList getTechnologies();
- QStringList getServices();
- bool requestScan(const QString &type);
-
- QHash<QString, QConnmanTechnologyInterface *> technologiesMap;
-
-Q_SIGNALS:
- void propertyChanged(const QString &, const QDBusVariant &value);
- void stateChanged(const QString &);
- void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
- void servicesChanged(const ConnmanMapList&, const QList<QDBusObjectPath> &);
-
- void servicesReady(const QStringList &);
- void scanFinished(bool error);
-
-protected:
- void connectNotify(const QMetaMethod &signal);
- QVariant getProperty(const QString &);
-
-private:
- QVariantMap propertiesCacheMap;
- QStringList servicesList;
- QStringList technologiesList;
-
-private slots:
- void onServicesChanged(const ConnmanMapList&, const QList<QDBusObjectPath> &);
- void changedProperty(const QString &, const QDBusVariant &value);
-
- void propertiesReply(QDBusPendingCallWatcher *call);
- void servicesReply(QDBusPendingCallWatcher *call);
-
- void technologyAdded(const QDBusObjectPath &technology, const QVariantMap &properties);
- void technologyRemoved(const QDBusObjectPath &technology);
-
-};
-
-class QConnmanServiceInterface : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- explicit QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = nullptr);
- ~QConnmanServiceInterface();
-
- QVariantMap getProperties();
- // clearProperty
- void connect();
- void disconnect();
- void remove();
-
-// properties
- QString state();
- QString lastError();
- QString name();
- QString type();
- QString security();
- bool favorite();
- bool autoConnect();
- bool roaming();
- QVariantMap ethernet();
- QString serviceInterface();
-
- bool isOfflineMode();
- QStringList services();
-
-Q_SIGNALS:
- void propertyChanged(const QString &, const QDBusVariant &value);
- void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
- void propertiesReady();
- void stateChanged(const QString &state);
-
-protected:
- void connectNotify(const QMetaMethod &signal);
- QVariant getProperty(const QString &);
-private:
- QVariantMap propertiesCacheMap;
-private slots:
- void propertiesReply(QDBusPendingCallWatcher *call);
- void changedProperty(const QString &, const QDBusVariant &value);
-
-};
-
-class QConnmanTechnologyInterface : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- explicit QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = nullptr);
- ~QConnmanTechnologyInterface();
-
- QString type();
-
- void scan();
-Q_SIGNALS:
- void propertyChanged(const QString &, const QDBusVariant &value);
- void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
- void scanFinished(bool error);
-protected:
- void connectNotify(const QMetaMethod &signal);
- QVariant getProperty(const QString &);
-private:
- QVariantMap properties();
- QVariantMap propertiesMap;
-private Q_SLOTS:
- void scanReply(QDBusPendingCallWatcher *call);
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DBUS
-
-#endif //QCONNMANSERVICE_H
diff --git a/src/plugins/bearer/corewlan/CMakeLists.txt b/src/plugins/bearer/corewlan/CMakeLists.txt
deleted file mode 100644
index 31e70cc938..0000000000
--- a/src/plugins/bearer/corewlan/CMakeLists.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-# Generated from corewlan.pro.
-
-#####################################################################
-## QCoreWlanEnginePlugin Plugin:
-#####################################################################
-
-qt_add_plugin(QCoreWlanEnginePlugin
- OUTPUT_NAME qcorewlanbearer
- TYPE bearer
- SOURCES
- main.cpp
- qcorewlanengine.h qcorewlanengine.mm
- PUBLIC_LIBRARIES
- ${FWFoundation}
- ${FWSystemConfiguration}
- Qt::CorePrivate
- Qt::NetworkPrivate
-)
-
-#### Keys ignored in scope 1:.:.:corewlan.pro:<TRUE>:
-# OTHER_FILES = "corewlan.json"
-
-## Scopes:
-#####################################################################
-
-qt_extend_target(QCoreWlanEnginePlugin CONDITION QT_FEATURE_corewlan
- PUBLIC_LIBRARIES
- ${FWCoreWLAN}
- ${FWSecurity}
-)
diff --git a/src/plugins/bearer/corewlan/corewlan.json b/src/plugins/bearer/corewlan/corewlan.json
deleted file mode 100644
index b43519ea90..0000000000
--- a/src/plugins/bearer/corewlan/corewlan.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "corewlan" ]
-}
diff --git a/src/plugins/bearer/corewlan/corewlan.pro b/src/plugins/bearer/corewlan/corewlan.pro
deleted file mode 100644
index 4f08eaba71..0000000000
--- a/src/plugins/bearer/corewlan/corewlan.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGET = qcorewlanbearer
-
-QT = core-private network-private
-LIBS += -framework Foundation -framework SystemConfiguration
-
-qtConfig(corewlan) {
- LIBS += -framework CoreWLAN -framework Security
-}
-
-HEADERS += qcorewlanengine.h
-
-SOURCES += main.cpp
-
-OBJECTIVE_SOURCES += qcorewlanengine.mm
-
-OTHER_FILES += corewlan.json
-
-PLUGIN_TYPE = bearer
-PLUGIN_CLASS_NAME = QCoreWlanEnginePlugin
-load(qt_plugin)
diff --git a/src/plugins/bearer/corewlan/main.cpp b/src/plugins/bearer/corewlan/main.cpp
deleted file mode 100644
index c6663d155c..0000000000
--- a/src/plugins/bearer/corewlan/main.cpp
+++ /dev/null
@@ -1,82 +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$
-**
-****************************************************************************/
-
-#include "qcorewlanengine.h"
-
-#include <QtNetwork/private/qbearerplugin_p.h>
-
-#include <QtCore/qdebug.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QCoreWlanEnginePlugin : public QBearerEnginePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "corewlan.json")
-
-public:
- QCoreWlanEnginePlugin();
- ~QCoreWlanEnginePlugin();
-
- QBearerEngine *create(const QString &key) const;
-};
-
-QCoreWlanEnginePlugin::QCoreWlanEnginePlugin()
-{
-}
-
-QCoreWlanEnginePlugin::~QCoreWlanEnginePlugin()
-{
-}
-
-QBearerEngine *QCoreWlanEnginePlugin::create(const QString &key) const
-{
- if (key == QLatin1String("corewlan"))
- return new QCoreWlanEngine;
- else
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#include "main.moc"
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h
deleted file mode 100644
index 8775474c09..0000000000
--- a/src/plugins/bearer/corewlan/qcorewlanengine.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 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 QCOREWLANENGINE_H
-#define QCOREWLANENGINE_H
-
-#include <private/qbearerengine_impl_p.h>
-
-#include <QMap>
-#include <QTimer>
-#include <SystemConfiguration/SystemConfiguration.h>
-#include <QThread>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-class QScanThread;
-
-class QCoreWlanEngine : public QBearerEngineImpl
-{
- friend class QScanThread;
- Q_OBJECT
-
-public:
- QCoreWlanEngine(QObject *parent = 0);
- ~QCoreWlanEngine();
-
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
-
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
-
- Q_INVOKABLE void initialize();
- Q_INVOKABLE void requestUpdate();
-
- QNetworkSession::State sessionStateForId(const QString &id);
-
- quint64 bytesWritten(const QString &id);
- quint64 bytesReceived(const QString &id);
- quint64 startTime(const QString &id);
-
- QNetworkConfigurationManager::Capabilities capabilities() const;
-
- QNetworkSessionPrivate *createSessionBackend();
-
- QNetworkConfigurationPrivatePointer defaultConfiguration();
-
- bool requiresPolling() const;
-
-private Q_SLOTS:
- void doRequestUpdate();
- void networksChanged();
- void checkDisconnect();
-
-private:
- bool isWifiReady(const QString &dev);
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
- SCDynamicStoreRef storeSession;
- CFRunLoopSourceRef runloopSource;
- bool hasWifi;
- bool scanning;
- QScanThread *scanThread;
-
- quint64 getBytes(const QString &interfaceName,bool b);
- QString disconnectedInterfaceString;
-
-protected:
- void startNetworkChangeLoop();
-
-};
-
-class QScanThread : public QThread
-{
- Q_OBJECT
-
-public:
- QScanThread(QObject *parent = 0);
- ~QScanThread();
-
- void quit();
- QList<QNetworkConfigurationPrivate *> getConfigurations();
- QString interfaceName;
- QMap<QString, QString> configurationInterface;
- void getUserConfigurations();
- QString getNetworkNameFromSsid(const QString &ssid) const;
- QString getSsidFromNetworkName(const QString &name) const;
- bool isKnownSsid(const QString &ssid) const;
- QMap<QString, QMap<QString,QString> > userProfiles;
-
-signals:
- void networksChanged();
-
-protected:
- void run();
-
-private:
- QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
- mutable QMutex mutex;
- QStringList foundNetwork(const QString &id, const QString &ssid, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose);
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
deleted file mode 100644
index 01c6df74d5..0000000000
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ /dev/null
@@ -1,862 +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$
-**
-****************************************************************************/
-
-#include "qcorewlanengine.h"
-#include <private/qnetworksession_impl_p.h>
-
-#include <QtNetwork/private/qnetworkconfiguration_p.h>
-
-#include <QtCore/qthread.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qstringlist.h>
-
-#include <QtCore/qdebug.h>
-
-#include <QDir>
-#ifndef QT_NO_BEARERMANAGEMENT
-
-extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
-#import <CoreWLAN/CoreWLAN.h>
-}
-
-#include "private/qcore_mac_p.h"
-
-#include <net/if.h>
-#include <ifaddrs.h>
-
-@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject <CWEventDelegate>
-@property (assign) QCoreWlanEngine* engine;
-@end
-QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSListener);
-
-@implementation QNSListener {
- NSNotificationCenter *notificationCenter;
- CWWiFiClient *client;
- QCoreWlanEngine *engine;
- NSLock *locker;
-}
-
-- (instancetype)init
-{
- if ((self = [super init])) {
- [locker lock];
- QMacAutoReleasePool pool;
- notificationCenter = [NSNotificationCenter defaultCenter];
- client = [CWWiFiClient sharedWiFiClient];
- client.delegate = self;
- [client startMonitoringEventWithType:CWEventTypePowerDidChange error:nil];
- [locker unlock];
- }
- return self;
-}
-
-static QNSListener *listener = 0;
-
--(void)dealloc
-{
- client.delegate = nil;
- listener = nil;
- [super dealloc];
-}
-
--(void)setEngine:(QCoreWlanEngine *)coreEngine
-{
- [locker lock];
- if(!engine)
- engine = coreEngine;
- [locker unlock];
-}
-
--(QCoreWlanEngine *)engine
-{
- return engine;
-}
-
--(void)remove
-{
- [locker lock];
- [client stopMonitoringAllEventsAndReturnError:nil];
- [locker unlock];
-}
-
-- (void)powerStateDidChangeForWiFiInterfaceWithName:(NSString *)interfaceName
-{
- Q_UNUSED(interfaceName);
- engine->requestUpdate();
-}
-@end
-
-
-QT_BEGIN_NAMESPACE
-
-void networkChangeCallback(SCDynamicStoreRef/* store*/, CFArrayRef changedKeys, void *info)
-{
- for ( long i = 0; i < CFArrayGetCount(changedKeys); i++) {
-
- QString changed = QString::fromCFString((CFStringRef)CFArrayGetValueAtIndex(changedKeys, i));
- if( changed.contains("/Network/Global/IPv4")) {
- QCoreWlanEngine* wlanEngine = static_cast<QCoreWlanEngine*>(info);
- wlanEngine->requestUpdate();
- }
- }
- return;
-}
-
-
-QScanThread::QScanThread(QObject *parent)
- :QThread(parent)
-{
-}
-
-QScanThread::~QScanThread()
-{
-}
-
-void QScanThread::quit()
-{
- wait();
-}
-
-void QScanThread::run()
-{
- QMacAutoReleasePool pool;
- QStringList found;
- mutex.lock();
- CWInterface *currentInterface = [[CWWiFiClient sharedWiFiClient]
- interfaceWithName:interfaceName.toNSString()];
- mutex.unlock();
- const bool currentInterfaceServiceActive = currentInterface.serviceActive;
-
- if (currentInterface.powerOn) {
- NSError *err = nil;
-
- NSSet* apSet = [currentInterface scanForNetworksWithName:nil error:&err];
-
- if (!err) {
- for (CWNetwork *apNetwork in apSet) {
- const QString networkSsid = QString::fromNSString([apNetwork ssid]);
- const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
- found.append(id);
-
- QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
- bool known = isKnownSsid(networkSsid);
- if (currentInterfaceServiceActive) {
- if (networkSsid == QString::fromNSString([currentInterface ssid])) {
- state = QNetworkConfiguration::Active;
- }
- }
- if (state == QNetworkConfiguration::Undefined) {
- if(known) {
- state = QNetworkConfiguration::Discovered;
- } else {
- state = QNetworkConfiguration::Undefined;
- }
- }
- QNetworkConfiguration::Purpose purpose = QNetworkConfiguration::UnknownPurpose;
- if ([apNetwork supportsSecurity:kCWSecurityNone]) {
- purpose = QNetworkConfiguration::PublicPurpose;
- } else {
- purpose = QNetworkConfiguration::PrivatePurpose;
- }
-
- found.append(foundNetwork(id, networkSsid, state, interfaceName, purpose));
-
- }
- }
- }
- // add known configurations that are not around.
- for (auto i = userProfiles.cbegin(), end = userProfiles.cend(); i != end; ++i) {
-
- QString networkName = i.key();
- const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkName));
-
- if(!found.contains(id)) {
- QString networkSsid = getSsidFromNetworkName(networkName);
- const QString ssidId = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
- QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
- QString interfaceName;
- if (!i.value().isEmpty())
- interfaceName = i.value().last();
-
- if (currentInterfaceServiceActive) {
- if (networkSsid == QString::fromNSString([currentInterface ssid])) {
- state = QNetworkConfiguration::Active;
- }
- }
- if(state == QNetworkConfiguration::Undefined) {
- if( userProfiles.contains(networkName)
- && found.contains(ssidId)) {
- state = QNetworkConfiguration::Discovered;
- }
- }
-
- if(state == QNetworkConfiguration::Undefined) {
- state = QNetworkConfiguration::Defined;
- }
-
- found.append(foundNetwork(id, networkName, state, interfaceName, QNetworkConfiguration::UnknownPurpose));
- }
- }
- emit networksChanged();
-}
-
-QStringList QScanThread::foundNetwork(const QString &id, const QString &name, const QNetworkConfiguration::StateFlags state, const QString &interfaceName, const QNetworkConfiguration::Purpose purpose)
-{
- QStringList found;
- QMutexLocker locker(&mutex);
- QNetworkConfigurationPrivate *ptr = new QNetworkConfigurationPrivate;
-
- ptr->name = name;
- ptr->isValid = true;
- ptr->id = id;
- ptr->state = state;
- ptr->type = QNetworkConfiguration::InternetAccessPoint;
- ptr->bearerType = QNetworkConfiguration::BearerWLAN;
- ptr->purpose = purpose;
-
- fetchedConfigurations.append( ptr);
- configurationInterface.insert(ptr->id, interfaceName);
-
- locker.unlock();
- locker.relock();
- found.append(id);
- return found;
-}
-
-QList<QNetworkConfigurationPrivate *> QScanThread::getConfigurations()
-{
- QMutexLocker locker(&mutex);
- return qExchange(fetchedConfigurations, {});
-}
-
-void QScanThread::getUserConfigurations()
-{
- QMutexLocker locker(&mutex);
-
- QMacAutoReleasePool pool;
- userProfiles.clear();
-
- NSArray<NSString *> *wifiInterfaces = [CWWiFiClient interfaceNames];
- for (NSString *ifName in wifiInterfaces) {
-
- CWInterface *wifiInterface = [[CWWiFiClient sharedWiFiClient] interfaceWithName:ifName];
-
- NSString *nsInterfaceName = wifiInterface.ssid;
-// add user configured system networks
- SCDynamicStoreRef dynRef = SCDynamicStoreCreate(kCFAllocatorSystemDefault, (CFStringRef)@"Qt corewlan", nil, nil);
- NSDictionary * airportPlist = (NSDictionary *)SCDynamicStoreCopyValue(dynRef, (CFStringRef)[NSString stringWithFormat:@"Setup:/Network/Interface/%@/AirPort", nsInterfaceName]);
- CFRelease(dynRef);
- if(airportPlist != nil) {
- NSDictionary *prefNetDict = [airportPlist objectForKey:@"PreferredNetworks"];
-
- NSArray<NSString *> *thisSsidarray = [prefNetDict valueForKey:@"SSID_STR"];
- for (NSString *ssidkey in thisSsidarray) {
- QString thisSsid = QString::fromNSString(ssidkey);
- if(!userProfiles.contains(thisSsid)) {
- QMap <QString,QString> map;
- map.insert(thisSsid, QString::fromNSString(nsInterfaceName));
- userProfiles.insert(thisSsid, map);
- }
- }
- CFRelease(airportPlist);
- }
-
- // remembered networks
- CWConfiguration *userConfig = [wifiInterface configuration];
- NSOrderedSet *networkProfiles = [userConfig networkProfiles];
- NSEnumerator *enumerator = [networkProfiles objectEnumerator];
- CWNetworkProfile *wProfile;
- while ((wProfile = [enumerator nextObject])) {
- QString networkName = QString::fromNSString([wProfile ssid]);
-
- if (!userProfiles.contains(networkName)) {
- QMap<QString,QString> map;
- map.insert(networkName, QString::fromNSString(nsInterfaceName));
- userProfiles.insert(networkName, map);
- }
- }
-
- // 802.1X user profiles
- QString userProfilePath = QDir::homePath() + "/Library/Preferences/com.apple.eap.profiles.plist";
- NSDictionary* eapDict = [[[NSDictionary alloc] initWithContentsOfFile:userProfilePath.toNSString()] autorelease];
- if(eapDict != nil) {
- NSString *profileStr= @"Profiles";
- NSString *nameStr = @"UserDefinedName";
- NSString *networkSsidStr = @"Wireless Network";
- for (id profileKey in eapDict) {
- if ([profileStr isEqualToString:profileKey]) {
- NSDictionary *itemDict = [eapDict objectForKey:profileKey];
- for (id itemKey in itemDict) {
-
- NSInteger dictSize = [itemKey count];
- id objects[dictSize];
- id keys[dictSize];
-
- [itemKey getObjects:objects andKeys:keys];
- QString networkName;
- QString ssid;
- for (int i = 0; i < dictSize; i++) {
- if([nameStr isEqualToString:keys[i]]) {
- networkName = QString::fromNSString(objects[i]);
- }
- if ([networkSsidStr isEqualToString:keys[i]]) {
- ssid = QString::fromNSString(objects[i]);
- }
- if (!userProfiles.contains(networkName)
- && !ssid.isEmpty()) {
- QMap<QString,QString> map;
- map.insert(ssid, QString::fromNSString(nsInterfaceName));
- userProfiles.insert(networkName, map);
- }
- }
- }
- }
- }
- }
- }
-}
-
-QString QScanThread::getSsidFromNetworkName(const QString &name) const
-{
- QMutexLocker locker(&mutex);
-
- for (auto i = userProfiles.cbegin(), end = userProfiles.cend(); i != end; ++i) {
- for (auto ij = i.value().cbegin(), end = i.value().cend(); ij != end; ++ij) {
- const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") +i.key()));
- if(name == i.key() || name == networkNameHash) {
- return ij.key();
- }
- }
- }
- return QString();
-}
-
-QString QScanThread::getNetworkNameFromSsid(const QString &ssid) const
-{
- QMutexLocker locker(&mutex);
-
- for (auto i = userProfiles.cbegin(), end = userProfiles.cend(); i != end; ++i) {
- if (i.value().contains(ssid))
- return i.key();
- }
- return QString();
-}
-
-bool QScanThread::isKnownSsid(const QString &ssid) const
-{
- QMutexLocker locker(&mutex);
-
- for (auto i = userProfiles.cbegin(), end = userProfiles.cend(); i != end; ++i) {
- if (i.value().contains(ssid))
- return true;
- }
- return false;
-}
-
-
-QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
-: QBearerEngineImpl(parent), scanThread(0)
-{
- scanThread = new QScanThread(this);
- connect(scanThread, SIGNAL(networksChanged()),
- this, SLOT(networksChanged()));
-}
-
-QCoreWlanEngine::~QCoreWlanEngine()
-{
- scanThread->wait();
-
- qDeleteAll(qExchange(foundConfigurations, {}));
- [listener remove];
- [listener release];
-}
-
-void QCoreWlanEngine::initialize()
-{
- QMutexLocker locker(&mutex);
- QMacAutoReleasePool pool;
-
- if ([[CWWiFiClient interfaceNames] count] > 0 && !listener) {
- listener = [QNSListener alloc] init];
- listener.engine = this;
- hasWifi = true;
- } else {
- hasWifi = false;
- }
- storeSession = NULL;
-
- startNetworkChangeLoop();
-}
-
-
-QString QCoreWlanEngine::getInterfaceFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- return scanThread->configurationInterface.value(id);
-}
-
-bool QCoreWlanEngine::hasIdentifier(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- return scanThread->configurationInterface.contains(id);
-}
-
-void QCoreWlanEngine::connectToId(const QString &id)
-{
- QMutexLocker locker(&mutex);
- QMacAutoReleasePool pool;
- QString interfaceString = getInterfaceFromId(id);
-
- CWInterface *wifiInterface =
- [[CWWiFiClient sharedWiFiClient] interfaceWithName:interfaceString.toNSString()];
-
- if (wifiInterface.powerOn) {
- NSError *err = nil;
- QString wantedSsid;
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- const QString idHash = QString::number(qHash(QLatin1String("corewlan:") + ptr->name));
- const QString idHash2 = QString::number(qHash(QLatin1String("corewlan:") + scanThread->getNetworkNameFromSsid(ptr->name)));
-
- QString wantedNetwork;
- for (auto i = scanThread->userProfiles.cbegin(), end = scanThread->userProfiles.cend(); i != end; ++i) {
- wantedNetwork = i.key();
- const QString networkNameHash = QString::number(qHash(QLatin1String("corewlan:") + wantedNetwork));
- if (id == networkNameHash) {
- wantedSsid = scanThread->getSsidFromNetworkName(wantedNetwork);
- break;
- }
- }
-
- NSSet *scanSet = [wifiInterface scanForNetworksWithName:wantedSsid.toNSString() error:&err];
-
- if(!err) {
- for (CWNetwork *apNetwork in scanSet) {
- NSData *ssidData = [apNetwork ssidData];
- bool result = false;
-
- SecIdentityRef identity = 0;
- // Check first whether we require IEEE 802.1X authentication for the wanted SSID
- if (CWKeychainCopyWiFiEAPIdentity(kCWKeychainDomainSystem, ssidData, &identity) == errSecSuccess) {
- NSString *username = nil;
- NSString *password = nil;
- if (CWKeychainFindWiFiEAPUsernameAndPassword(kCWKeychainDomainSystem, ssidData, &username, &password) == errSecSuccess) {
- result = [wifiInterface associateToEnterpriseNetwork:apNetwork
- identity:identity username:(NSString *)username password:(NSString *)password
- error:&err];
- [username release];
- [password release];
- }
- CFRelease(identity);
- } else {
- NSString *password = nil;
- if (CWKeychainFindWiFiPassword(kCWKeychainDomainSystem, ssidData, &password) == errSecSuccess) {
- result = [wifiInterface associateToNetwork:apNetwork password:(NSString *)password error:&err];
- [password release];
- }
- }
-
- if (!err) {
- if (!result) {
- emit connectionError(id, ConnectError);
- } else {
- return;
- }
- } else {
- qDebug() <<"associate ERROR"<< QString::fromNSString([err localizedDescription ]);
- }
- } //end scan network
- } else {
- qDebug() <<"scan ERROR"<< QString::fromNSString([err localizedDescription ]);
- }
- emit connectionError(id, InterfaceLookupError);
- }
-
- locker.unlock();
- emit connectionError(id, InterfaceLookupError);
-}
-
-void QCoreWlanEngine::disconnectFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QString interfaceString = getInterfaceFromId(id);
- if (interfaceString.isEmpty()) {
- locker.unlock();
- emit connectionError(id, DisconnectionError);
- return;
- }
- QMacAutoReleasePool pool;
-
- CWInterface *wifiInterface =
- [[CWWiFiClient sharedWiFiClient] interfaceWithName:interfaceString.toNSString()];
- disconnectedInterfaceString = interfaceString;
-
- [wifiInterface disassociate];
-
- QTimer::singleShot(1000, this,SLOT(checkDisconnect()));
-}
-
-void QCoreWlanEngine::checkDisconnect()
-{
- QMutexLocker locker(&mutex);
- if (!disconnectedInterfaceString.isEmpty()) {
- QMacAutoReleasePool pool;
-
- CWInterface *wifiInterface = [[CWWiFiClient sharedWiFiClient]
- interfaceWithName:disconnectedInterfaceString.toNSString()];
-
- const QString networkSsid = QString::fromNSString([wifiInterface ssid]);
- if (!networkSsid.isEmpty()) {
- const QString id = QString::number(qHash(QLatin1String("corewlan:") + networkSsid));
- locker.unlock();
- emit connectionError(id, DisconnectionError);
- locker.relock();
- }
- disconnectedInterfaceString.clear();
- }
-}
-
-void QCoreWlanEngine::requestUpdate()
-{
- scanThread->getUserConfigurations();
- doRequestUpdate();
-}
-
-void QCoreWlanEngine::doRequestUpdate()
-{
- QMutexLocker locker(&mutex);
-
- QMacAutoReleasePool pool;
-
- NSArray<NSString *> *wifiInterfaces = [CWWiFiClient interfaceNames];
- for (NSString *ifName in wifiInterfaces) {
- scanThread->interfaceName = QString::fromNSString(ifName);
- scanThread->start();
- }
- locker.unlock();
- if ([wifiInterfaces count] == 0)
- networksChanged();
-}
-
-bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
-{
- QMutexLocker locker(&mutex);
- bool haswifi = false;
- if(hasWifi) {
- QMacAutoReleasePool pool;
- CWInterface *defaultInterface = [[CWWiFiClient sharedWiFiClient]
- interfaceWithName:wifiDeviceName.toNSString()];
- if (defaultInterface.powerOn) {
- haswifi = true;
- }
- }
- return haswifi;
-}
-
-
-QNetworkSession::State QCoreWlanEngine::sessionStateForId(const QString &id)
-{
- QMutexLocker locker(&mutex);
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- if (!ptr)
- return QNetworkSession::Invalid;
-
- if (!ptr->isValid) {
- return QNetworkSession::Invalid;
- } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return QNetworkSession::Connected;
- } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
- return QNetworkSession::Disconnected;
- } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
- return QNetworkSession::NotAvailable;
- } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
- QNetworkConfiguration::Undefined) {
- return QNetworkSession::NotAvailable;
- }
-
- return QNetworkSession::Invalid;
-}
-
-QNetworkConfigurationManager::Capabilities QCoreWlanEngine::capabilities() const
-{
- return QNetworkConfigurationManager::ForcedRoaming;
-}
-
-void QCoreWlanEngine::startNetworkChangeLoop()
-{
-
- SCDynamicStoreContext dynStoreContext = { 0, this/*(void *)storeSession*/, NULL, NULL, NULL };
- storeSession = SCDynamicStoreCreate(NULL,
- CFSTR("networkChangeCallback"),
- networkChangeCallback,
- &dynStoreContext);
- if (!storeSession ) {
- qWarning() << "could not open dynamic store: error:" << SCErrorString(SCError());
- return;
- }
-
- CFMutableArrayRef notificationKeys;
- notificationKeys = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
- CFMutableArrayRef patternsArray;
- patternsArray = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
-
- CFStringRef storeKey;
- storeKey = SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL,
- kSCDynamicStoreDomainState,
- kSCEntNetIPv4);
- CFArrayAppendValue(notificationKeys, storeKey);
- CFRelease(storeKey);
-
- storeKey = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,
- kSCDynamicStoreDomainState,
- kSCCompAnyRegex,
- kSCEntNetIPv4);
- CFArrayAppendValue(patternsArray, storeKey);
- CFRelease(storeKey);
-
- if (!SCDynamicStoreSetNotificationKeys(storeSession , notificationKeys, patternsArray)) {
- qWarning() << "register notification error:"<< SCErrorString(SCError());
- CFRelease(storeSession );
- CFRelease(notificationKeys);
- CFRelease(patternsArray);
- return;
- }
- CFRelease(notificationKeys);
- CFRelease(patternsArray);
-
- runloopSource = SCDynamicStoreCreateRunLoopSource(NULL, storeSession , 0);
- if (!runloopSource) {
- qWarning() << "runloop source error:"<< SCErrorString(SCError());
- CFRelease(storeSession );
- return;
- }
-
- CFRunLoopAddSource(CFRunLoopGetCurrent(), runloopSource, kCFRunLoopDefaultMode);
- return;
-}
-
-QNetworkSessionPrivate *QCoreWlanEngine::createSessionBackend()
-{
- return new QNetworkSessionPrivateImpl;
-}
-
-QNetworkConfigurationPrivatePointer QCoreWlanEngine::defaultConfiguration()
-{
- return QNetworkConfigurationPrivatePointer();
-}
-
-bool QCoreWlanEngine::requiresPolling() const
-{
- return true;
-}
-
-void QCoreWlanEngine::networksChanged()
-{
- QMutexLocker locker(&mutex);
-
- QStringList previous = accessPointConfigurations.keys();
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations = scanThread->getConfigurations();
- while (!foundConfigurations.isEmpty()) {
- QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst();
-
- previous.removeAll(cpPriv->id);
-
- if (accessPointConfigurations.contains(cpPriv->id)) {
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
-
- bool changed = false;
-
- ptr->mutex.lock();
-
- if (ptr->isValid != cpPriv->isValid) {
- ptr->isValid = cpPriv->isValid;
- changed = true;
- }
-
- if (ptr->name != cpPriv->name) {
- ptr->name = cpPriv->name;
- changed = true;
- }
-
- if (ptr->bearerType != cpPriv->bearerType) {
- ptr->bearerType = cpPriv->bearerType;
- changed = true;
- }
-
- if (ptr->state != cpPriv->state) {
- ptr->state = cpPriv->state;
- changed = true;
- }
-
- ptr->mutex.unlock();
-
- if (changed) {
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- }
-
- delete cpPriv;
- } else {
- QNetworkConfigurationPrivatePointer ptr(cpPriv);
-
- accessPointConfigurations.insert(ptr->id, ptr);
-
- locker.unlock();
- emit configurationAdded(ptr);
- locker.relock();
- }
- }
-
- while (!previous.isEmpty()) {
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.take(previous.takeFirst());
-
- locker.unlock();
- emit configurationRemoved(ptr);
- locker.relock();
- }
-
- locker.unlock();
- emit updateCompleted();
-
-}
-
-quint64 QCoreWlanEngine::bytesWritten(const QString &id)
-{
- QMutexLocker locker(&mutex);
- const QString interfaceStr = getInterfaceFromId(id);
- return getBytes(interfaceStr,false);
-}
-
-quint64 QCoreWlanEngine::bytesReceived(const QString &id)
-{
- QMutexLocker locker(&mutex);
- const QString interfaceStr = getInterfaceFromId(id);
- return getBytes(interfaceStr,true);
-}
-
-quint64 QCoreWlanEngine::startTime(const QString &identifier)
-{
- QMutexLocker locker(&mutex);
- QMacAutoReleasePool pool;
- quint64 timestamp = 0;
-
- NSString *filePath = @"/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist";
- NSDictionary* plistDict = [[[NSDictionary alloc] initWithContentsOfFile:filePath] autorelease];
- if(plistDict == nil)
- return timestamp;
- NSString *input = @"KnownNetworks";
- NSString *timeStampStr = @"_timeStamp";
-
- NSString *ssidStr = @"SSID_STR";
-
- for (id key in plistDict) {
- if ([input isEqualToString:key]) {
-
- NSDictionary *knownNetworksDict = [plistDict objectForKey:key];
- if(knownNetworksDict == nil)
- return timestamp;
- for (id networkKey in knownNetworksDict) {
- bool isFound = false;
- NSDictionary *itemDict = [knownNetworksDict objectForKey:networkKey];
- if(itemDict == nil)
- return timestamp;
- NSInteger dictSize = [itemDict count];
- id objects[dictSize];
- id keys[dictSize];
-
- [itemDict getObjects:objects andKeys:keys];
- bool ok = false;
- for(int i = 0; i < dictSize; i++) {
- if([ssidStr isEqualToString:keys[i]]) {
- const QString ident = QString::number(qHash(QLatin1String("corewlan:") + QString::fromNSString(objects[i])));
- if(ident == identifier) {
- ok = true;
- }
- }
- if(ok && [timeStampStr isEqualToString:keys[i]]) {
- timestamp = (quint64)[objects[i] timeIntervalSince1970];
- isFound = true;
- break;
- }
- }
- if(isFound)
- break;
- }
- }
- }
- return timestamp;
-}
-
-quint64 QCoreWlanEngine::getBytes(const QString &interfaceName, bool b)
-{
- struct ifaddrs *ifAddressList, *ifAddress;
- struct if_data *if_data;
-
- quint64 bytes = 0;
- ifAddressList = nil;
- if(getifaddrs(&ifAddressList) == 0) {
- for(ifAddress = ifAddressList; ifAddress; ifAddress = ifAddress->ifa_next) {
- if(interfaceName == ifAddress->ifa_name) {
- if_data = (struct if_data*)ifAddress->ifa_data;
- if(b) {
- bytes = if_data->ifi_ibytes;
- break;
- } else {
- bytes = if_data->ifi_obytes;
- break;
- }
- }
- }
- freeifaddrs(ifAddressList);
- }
- return bytes;
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/bearer/generic/CMakeLists.txt b/src/plugins/bearer/generic/CMakeLists.txt
deleted file mode 100644
index 6d65346b57..0000000000
--- a/src/plugins/bearer/generic/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-# Generated from generic.pro.
-
-#####################################################################
-## QGenericEnginePlugin Plugin:
-#####################################################################
-
-qt_add_plugin(QGenericEnginePlugin
- OUTPUT_NAME qgenericbearer
- TYPE bearer
- SOURCES
- ../platformdefs_win.h
- main.cpp
- qgenericengine.cpp qgenericengine.h
- PUBLIC_LIBRARIES
- Qt::CorePrivate
- Qt::NetworkPrivate
-)
-
-#### Keys ignored in scope 1:.:.:generic.pro:<TRUE>:
-# OTHER_FILES = "generic.json"
-
-## Scopes:
-#####################################################################
-
-qt_extend_target(QGenericEnginePlugin CONDITION WIN32 AND NOT WINRT
- PUBLIC_LIBRARIES
- iphlpapi
-)
diff --git a/src/plugins/bearer/generic/generic.json b/src/plugins/bearer/generic/generic.json
deleted file mode 100644
index e9357f4c72..0000000000
--- a/src/plugins/bearer/generic/generic.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "generic" ]
-}
diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro
deleted file mode 100644
index 14b858b301..0000000000
--- a/src/plugins/bearer/generic/generic.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qgenericbearer
-
-QT = core-private network-private
-
-HEADERS += qgenericengine.h \
- ../platformdefs_win.h
-SOURCES += qgenericengine.cpp \
- main.cpp
-
-OTHER_FILES += generic.json
-
-win32:!winrt:LIBS += -liphlpapi
-
-PLUGIN_TYPE = bearer
-PLUGIN_CLASS_NAME = QGenericEnginePlugin
-load(qt_plugin)
diff --git a/src/plugins/bearer/generic/main.cpp b/src/plugins/bearer/generic/main.cpp
deleted file mode 100644
index 82a9ce97f4..0000000000
--- a/src/plugins/bearer/generic/main.cpp
+++ /dev/null
@@ -1,78 +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$
-**
-****************************************************************************/
-
-#include "qgenericengine.h"
-
-#include <QtNetwork/private/qbearerplugin_p.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGenericEnginePlugin : public QBearerEnginePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "generic.json")
-
-public:
- QGenericEnginePlugin();
- ~QGenericEnginePlugin();
-
- QBearerEngine *create(const QString &key) const override;
-};
-
-QGenericEnginePlugin::QGenericEnginePlugin()
-{
-}
-
-QGenericEnginePlugin::~QGenericEnginePlugin()
-{
-}
-
-QBearerEngine *QGenericEnginePlugin::create(const QString &key) const
-{
- if (key == QLatin1String("generic"))
- return new QGenericEngine;
- else
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#include "main.moc"
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
deleted file mode 100644
index a5fba15789..0000000000
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ /dev/null
@@ -1,446 +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 "qgenericengine.h"
-#include <private/qnetworksession_impl_p.h>
-
-#include <QtNetwork/private/qnetworkconfiguration_p.h>
-
-#include <QtCore/qthread.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qstringlist.h>
-
-#include <QtCore/qdebug.h>
-#include <QtCore/private/qcoreapplication_p.h>
-
-#if defined(Q_OS_WIN32)
-// PMIB_TCPTABLE2 is only available since Vista
-#if _WIN32_WINNT < 0x0601
-# undef _WIN32_WINNT
-# define _WIN32_WINNT 0x0601
-#endif // _WIN32_WINNT < 0x0601
-#include "../platformdefs_win.h"
-#include <iphlpapi.h>
-#endif
-
-#ifdef Q_OS_WINRT
-#include <qfunctions_winrt.h>
-
-#include <wrl.h>
-#include <windows.foundation.h>
-#include <windows.foundation.collections.h>
-#include <windows.networking.connectivity.h>
-
-using namespace Microsoft::WRL;
-using namespace Microsoft::WRL::Wrappers;
-using namespace ABI::Windows::Foundation;
-using namespace ABI::Windows::Foundation::Collections;
-using namespace ABI::Windows::Networking;
-using namespace ABI::Windows::Networking::Connectivity;
-#endif // Q_OS_WINRT
-
-// needed as interface is used as parameter name in qGetInterfaceType
-#undef interface
-
-#ifdef Q_OS_LINUX
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <net/if_arp.h>
-#include <unistd.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_NETWORKINTERFACE
-static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
-{
-#if defined(Q_OS_WIN32)
- // QNetworkInterface::name returns a more friendly name on Windows. That name is not
- // accepted as an identifier for CreateFile so we have to obtain the Luid.
- std::wstring buf = interface.toStdWString();
- if (buf.size() == 0)
- return QNetworkConfiguration::BearerUnknown;
-
- NET_LUID luid;
- NETIO_STATUS status = ConvertInterfaceNameToLuidW(buf.c_str(), &luid);
- if (status != NO_ERROR)
- return QNetworkConfiguration::BearerUnknown;
-
- switch (luid.Info.IfType) {
- case IF_TYPE_ETHERNET_CSMACD:
- case IF_TYPE_ISO88025_TOKENRING:
- case IF_TYPE_PPP:
- case IF_TYPE_SOFTWARE_LOOPBACK:
- return QNetworkConfiguration::BearerEthernet;
- case IF_TYPE_IEEE80211:
- return QNetworkConfiguration::BearerWLAN;
- case IF_TYPE_ATM:
- case IF_TYPE_IEEE1394:
- case IF_TYPE_OTHER:
- case IF_TYPE_TUNNEL:
- return QNetworkConfiguration::BearerUnknown;
- default:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "Interface Type" << luid.Info.IfType;
-#endif
- return QNetworkConfiguration::BearerUnknown;
- }
- return QNetworkConfiguration::BearerUnknown;
-
-#elif defined(Q_OS_LINUX)
- int sock = socket(AF_INET, SOCK_DGRAM, 0);
-
- ifreq request;
- strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name) - 1);
- request.ifr_name[sizeof(request.ifr_name) - 1] = '\0';
- int result = ioctl(sock, SIOCGIFHWADDR, &request);
- close(sock);
-
- if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER)
- return QNetworkConfiguration::BearerEthernet;
-#elif defined(Q_OS_WINRT)
- ComPtr<INetworkInformationStatics> networkInfoStatics;
- HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_Connectivity_NetworkInformation).Get(), &networkInfoStatics);
- Q_ASSERT_SUCCEEDED(hr);
- ComPtr<IVectorView<ConnectionProfile *>> connectionProfiles;
- hr = networkInfoStatics->GetConnectionProfiles(&connectionProfiles);
- Q_ASSERT_SUCCEEDED(hr);
- if (!connectionProfiles)
- return QNetworkConfiguration::BearerUnknown;
-
- unsigned int size;
- hr = connectionProfiles->get_Size(&size);
- Q_ASSERT_SUCCEEDED(hr);
- for (unsigned int i = 0; i < size; ++i) {
- ComPtr<IConnectionProfile> profile;
- hr = connectionProfiles->GetAt(i, &profile);
- Q_ASSERT_SUCCEEDED(hr);
-
- ComPtr<INetworkAdapter> adapter;
- hr = profile->get_NetworkAdapter(&adapter);
- // Indicates that no internet connection is available/the device is in airplane mode
- if (hr == E_INVALIDARG)
- return QNetworkConfiguration::BearerUnknown;
- Q_ASSERT_SUCCEEDED(hr);
- GUID id;
- hr = adapter->get_NetworkAdapterId(&id);
- Q_ASSERT_SUCCEEDED(hr);
- OLECHAR adapterName[39]={0};
- int length = StringFromGUID2(id, adapterName, 39);
- // "length - 1" as we have to remove the null terminator from it in order to compare
- if (!length
- || QString::fromRawData(reinterpret_cast<const QChar *>(adapterName), length - 1) != interface)
- continue;
-
- ComPtr<IConnectionProfile2> profile2;
- hr = profile.As(&profile2);
- Q_ASSERT_SUCCEEDED(hr);
- boolean isWLan;
- hr = profile2->get_IsWlanConnectionProfile(&isWLan);
- Q_ASSERT_SUCCEEDED(hr);
- if (isWLan)
- return QNetworkConfiguration::BearerWLAN;
-
- boolean isWWan;
- hr = profile2->get_IsWwanConnectionProfile(&isWWan);
- Q_ASSERT_SUCCEEDED(hr);
- if (isWWan) {
- ComPtr<IWwanConnectionProfileDetails> details;
- hr = profile2->get_WwanConnectionProfileDetails(&details);
- Q_ASSERT_SUCCEEDED(hr);
- WwanDataClass dataClass;
- hr = details->GetCurrentDataClass(&dataClass);
- Q_ASSERT_SUCCEEDED(hr);
- switch (dataClass) {
- case WwanDataClass_Edge:
- case WwanDataClass_Gprs:
- return QNetworkConfiguration::Bearer2G;
- case WwanDataClass_Umts:
- return QNetworkConfiguration::BearerWCDMA;
- case WwanDataClass_LteAdvanced:
- return QNetworkConfiguration::BearerLTE;
- case WwanDataClass_Hsdpa:
- case WwanDataClass_Hsupa:
- return QNetworkConfiguration::BearerHSPA;
- case WwanDataClass_Cdma1xRtt:
- case WwanDataClass_Cdma3xRtt:
- case WwanDataClass_CdmaUmb:
- return QNetworkConfiguration::BearerCDMA2000;
- case WwanDataClass_Cdma1xEvdv:
- case WwanDataClass_Cdma1xEvdo:
- case WwanDataClass_Cdma1xEvdoRevA:
- case WwanDataClass_Cdma1xEvdoRevB:
- return QNetworkConfiguration::BearerEVDO;
- case WwanDataClass_Custom:
- case WwanDataClass_None:
- default:
- return QNetworkConfiguration::BearerUnknown;
- }
- }
- return QNetworkConfiguration::BearerEthernet;
- }
-#else
- Q_UNUSED(interface);
-#endif
-
- return QNetworkConfiguration::BearerUnknown;
-}
-#endif
-
-QGenericEngine::QGenericEngine(QObject *parent)
-: QBearerEngineImpl(parent)
-{
- //workaround for deadlock in __cxa_guard_acquire with webkit on macos x
- //initialise the Q_GLOBAL_STATIC in same thread as the AtomicallyInitializedStatic
- (void)QNetworkInterface::interfaceFromIndex(0);
-}
-
-QGenericEngine::~QGenericEngine()
-{
-}
-
-QString QGenericEngine::getInterfaceFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- return configurationInterface.value(id);
-}
-
-bool QGenericEngine::hasIdentifier(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- return configurationInterface.contains(id);
-}
-
-void QGenericEngine::connectToId(const QString &id)
-{
- emit connectionError(id, OperationNotSupported);
-}
-
-void QGenericEngine::disconnectFromId(const QString &id)
-{
- emit connectionError(id, OperationNotSupported);
-}
-
-void QGenericEngine::initialize()
-{
- doRequestUpdate();
-}
-
-void QGenericEngine::requestUpdate()
-{
- doRequestUpdate();
-}
-
-void QGenericEngine::doRequestUpdate()
-{
-#ifndef QT_NO_NETWORKINTERFACE
- QMutexLocker locker(&mutex);
-
- // Immediately after connecting with a wireless access point
- // QNetworkInterface::allInterfaces() will sometimes return an empty list. Calling it again a
- // second time results in a non-empty list. If we loose interfaces we will end up removing
- // network configurations which will break current sessions.
- QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
- if (interfaces.isEmpty())
- interfaces = QNetworkInterface::allInterfaces();
-
- QStringList previous = accessPointConfigurations.keys();
-
- // create configuration for each interface
- while (!interfaces.isEmpty()) {
- QNetworkInterface interface = interfaces.takeFirst();
-
- if (!interface.isValid())
- continue;
-
- // ignore loopback interface
- if (interface.flags() & QNetworkInterface::IsLoopBack)
- continue;
-
-#ifndef Q_OS_WIN
- // ignore WLAN interface handled in separate engine
- if (qGetInterfaceType(interface.name()) == QNetworkConfiguration::BearerWLAN)
- continue;
-#endif
-
- uint identifier;
- if (interface.index())
- identifier = qHash(QLatin1String("generic:") + QString::number(interface.index()));
- else
- identifier = qHash(QLatin1String("generic:") + interface.hardwareAddress());
-
- const QString id = QString::number(identifier);
-
- previous.removeAll(id);
-
- QString name = interface.humanReadableName();
- if (name.isEmpty())
- name = interface.name();
-
- QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined;
- if ((interface.flags() & QNetworkInterface::IsRunning) && !interface.addressEntries().isEmpty())
- state |= QNetworkConfiguration::Active;
-
- if (accessPointConfigurations.contains(id)) {
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- bool changed = false;
-
- ptr->mutex.lock();
-
- if (!ptr->isValid) {
- ptr->isValid = true;
- changed = true;
- }
-
- if (ptr->name != name) {
- ptr->name = name;
- changed = true;
- }
-
- if (ptr->id != id) {
- ptr->id = id;
- changed = true;
- }
-
- if (ptr->state != state) {
- ptr->state = state;
- changed = true;
- }
-
- ptr->mutex.unlock();
-
- if (changed) {
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- }
- } else {
- QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);
-
- ptr->name = name;
- ptr->isValid = true;
- ptr->id = id;
- ptr->state = state;
- ptr->type = QNetworkConfiguration::InternetAccessPoint;
- ptr->bearerType = qGetInterfaceType(interface.name());
-
- accessPointConfigurations.insert(id, ptr);
- configurationInterface.insert(id, interface.name());
-
- locker.unlock();
- emit configurationAdded(ptr);
- locker.relock();
- }
- }
-
- while (!previous.isEmpty()) {
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.take(previous.takeFirst());
-
- configurationInterface.remove(ptr->id);
-
- locker.unlock();
- emit configurationRemoved(ptr);
- locker.relock();
- }
-
- locker.unlock();
-#endif
-
- emit updateCompleted();
-}
-
-QNetworkSession::State QGenericEngine::sessionStateForId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- if (!ptr)
- return QNetworkSession::Invalid;
-
- QMutexLocker configLocker(&ptr->mutex);
-
- if (!ptr->isValid) {
- return QNetworkSession::Invalid;
- } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return QNetworkSession::Connected;
- } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
- return QNetworkSession::Disconnected;
- } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
- return QNetworkSession::NotAvailable;
- } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
- QNetworkConfiguration::Undefined) {
- return QNetworkSession::NotAvailable;
- }
-
- return QNetworkSession::Invalid;
-}
-
-QNetworkConfigurationManager::Capabilities QGenericEngine::capabilities() const
-{
- return QNetworkConfigurationManager::ForcedRoaming;
-}
-
-QNetworkSessionPrivate *QGenericEngine::createSessionBackend()
-{
- return new QNetworkSessionPrivateImpl;
-}
-
-QNetworkConfigurationPrivatePointer QGenericEngine::defaultConfiguration()
-{
- return QNetworkConfigurationPrivatePointer();
-}
-
-
-bool QGenericEngine::requiresPolling() const
-{
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h
deleted file mode 100644
index 6b8fb4cd0f..0000000000
--- a/src/plugins/bearer/generic/qgenericengine.h
+++ /dev/null
@@ -1,90 +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 QGENERICENGINE_H
-#define QGENERICENGINE_H
-
-#include <private/qbearerengine_impl_p.h>
-
-#include <QMap>
-#include <QTimer>
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-class QNetworkSessionPrivate;
-
-class QGenericEngine : public QBearerEngineImpl
-{
- Q_OBJECT
-
-public:
- QGenericEngine(QObject *parent = nullptr);
- ~QGenericEngine();
-
- QString getInterfaceFromId(const QString &id) override;
- bool hasIdentifier(const QString &id) override;
-
- void connectToId(const QString &id) override;
- void disconnectFromId(const QString &id) override;
-
- Q_INVOKABLE void initialize();
- Q_INVOKABLE void requestUpdate();
-
- QNetworkSession::State sessionStateForId(const QString &id) override;
-
- QNetworkConfigurationManager::Capabilities capabilities() const override;
-
- QNetworkSessionPrivate *createSessionBackend() override;
-
- QNetworkConfigurationPrivatePointer defaultConfiguration() override;
-
- bool requiresPolling() const override;
-
-private Q_SLOTS:
- void doRequestUpdate();
-
-private:
- QMap<QString, QString> configurationInterface;
-};
-
-QT_END_NAMESPACE
-
-#endif
-
diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp
deleted file mode 100644
index 826c0104e4..0000000000
--- a/src/plugins/bearer/nativewifi/main.cpp
+++ /dev/null
@@ -1,127 +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$
-**
-****************************************************************************/
-
-#include "qnativewifiengine.h"
-#include "platformdefs.h"
-
-#include <QtCore/qmutex.h>
-#include <QtCore/qlibrary.h>
-
-#include <QtNetwork/private/qbearerplugin_p.h>
-
-#include <QtCore/qdebug.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-static bool resolveLibraryInternal()
-{
- QLibrary wlanapiLib(QLatin1String("wlanapi"));
- local_WlanOpenHandle = (WlanOpenHandleProto)
- wlanapiLib.resolve("WlanOpenHandle");
- local_WlanRegisterNotification = (WlanRegisterNotificationProto)
- wlanapiLib.resolve("WlanRegisterNotification");
- local_WlanEnumInterfaces = (WlanEnumInterfacesProto)
- wlanapiLib.resolve("WlanEnumInterfaces");
- local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto)
- wlanapiLib.resolve("WlanGetAvailableNetworkList");
- local_WlanQueryInterface = (WlanQueryInterfaceProto)
- wlanapiLib.resolve("WlanQueryInterface");
- local_WlanConnect = (WlanConnectProto)
- wlanapiLib.resolve("WlanConnect");
- local_WlanDisconnect = (WlanDisconnectProto)
- wlanapiLib.resolve("WlanDisconnect");
- local_WlanScan = (WlanScanProto)
- wlanapiLib.resolve("WlanScan");
- local_WlanFreeMemory = (WlanFreeMemoryProto)
- wlanapiLib.resolve("WlanFreeMemory");
- local_WlanCloseHandle = (WlanCloseHandleProto)
- wlanapiLib.resolve("WlanCloseHandle");
- return true;
-}
-Q_GLOBAL_STATIC_WITH_ARGS(bool, resolveLibrary, (resolveLibraryInternal()))
-
-class QNativeWifiEnginePlugin : public QBearerEnginePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "nativewifi.json")
-
-public:
- QNativeWifiEnginePlugin();
- ~QNativeWifiEnginePlugin();
-
- QBearerEngine *create(const QString &key) const;
-};
-
-QNativeWifiEnginePlugin::QNativeWifiEnginePlugin()
-{
-}
-
-QNativeWifiEnginePlugin::~QNativeWifiEnginePlugin()
-{
-}
-
-QBearerEngine *QNativeWifiEnginePlugin::create(const QString &key) const
-{
- if (key != QLatin1String("nativewifi"))
- return 0;
-
- resolveLibrary();
-
- // native wifi dll not available
- if (!local_WlanOpenHandle)
- return 0;
-
- QNativeWifiEngine *engine = new QNativeWifiEngine;
-
- // could not initialise subsystem
- if (engine && !engine->available()) {
- delete engine;
- return 0;
- }
-
- return engine;
-}
-
-QT_END_NAMESPACE
-
-#include "main.moc"
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/nativewifi/nativewifi.json b/src/plugins/bearer/nativewifi/nativewifi.json
deleted file mode 100644
index f3db199150..0000000000
--- a/src/plugins/bearer/nativewifi/nativewifi.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "nativewifi" ]
-}
diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro
deleted file mode 100644
index 41bde99341..0000000000
--- a/src/plugins/bearer/nativewifi/nativewifi.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-TARGET = qnativewifibearer
-
-QT = core-private network-private
-
-HEADERS += qnativewifiengine.h \
- platformdefs.h
-
-SOURCES += main.cpp \
- qnativewifiengine.cpp
-
-OTHER_FILES += nativewifi.json
-
-PLUGIN_TYPE = bearer
-PLUGIN_CLASS_NAME = QNativeWifiEnginePlugin
-load(qt_plugin)
diff --git a/src/plugins/bearer/nativewifi/platformdefs.h b/src/plugins/bearer/nativewifi/platformdefs.h
deleted file mode 100644
index b8ac40af15..0000000000
--- a/src/plugins/bearer/nativewifi/platformdefs.h
+++ /dev/null
@@ -1,327 +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 PLATFORMDEFS_H
-#define PLATFORMDEFS_H
-
-#include <wtypes.h>
-#undef interface
-
-//proper header is wlanapi.h, but that is not included in windows XP
-
-#define WLAN_MAX_NAME_LENGTH 256
-#define WLAN_MAX_PHY_TYPE_NUMBER 8
-#define WLAN_NOTIFICATION_SOURCE_ACM 0x00000008
-#define WLAN_NOTIFICATION_SOURCE_ALL 0x0000ffff
-#define WLAN_AVAILABLE_NETWORK_CONNECTED 1
-#define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 2
-#define DOT11_SSID_MAX_LENGTH 32
-
-QT_BEGIN_NAMESPACE
-
-struct WLAN_NOTIFICATION_DATA {
- DWORD NotificationSource;
- DWORD NotificationCode;
- GUID InterfaceGuid;
- DWORD dwDataSize;
- PVOID pData;
-};
-
-enum WLAN_INTERFACE_STATE {
- wlan_interface_state_not_ready = 0,
- wlan_interface_state_connected,
- wlan_interface_state_ad_hoc_network_formed,
- wlan_interface_state_disconnecting,
- wlan_interface_state_disconnected,
- wlan_interface_state_associating,
- wlan_interface_state_discovering,
- wlan_interface_state_authenticating
-};
-
-struct WLAN_INTERFACE_INFO {
- GUID InterfaceGuid;
- WCHAR strInterfaceDescription[WLAN_MAX_NAME_LENGTH];
- WLAN_INTERFACE_STATE isState;
-};
-
-struct WLAN_INTERFACE_INFO_LIST {
- DWORD dwNumberOfItems;
- DWORD dwIndex;
- WLAN_INTERFACE_INFO InterfaceInfo[1];
-};
-
-struct DOT11_SSID {
- ULONG uSSIDLength;
- UCHAR ucSSID[DOT11_SSID_MAX_LENGTH];
-};
-
-struct NDIS_OBJECT_HEADER {
- UCHAR Type;
- UCHAR Revision;
- USHORT Size;
-};
-
-typedef UCHAR DOT11_MAC_ADDRESS[6];
-struct DOT11_BSSID_LIST {
- NDIS_OBJECT_HEADER Header;
- ULONG uNumberOfEntries;
- ULONG uTotalNumOfEntries;
- DOT11_MAC_ADDRESS BSSIDs[1];
-};
-
-enum DOT11_BSS_TYPE {
- dot11_BSS_type_infrastructure = 1,
- dot11_BSS_type_independent = 2,
- dot11_BSS_type_any = 3
-};
-
-enum DOT11_PHY_TYPE {
- dot11_phy_type_unknown = 0,
- dot11_phy_type_any = dot11_phy_type_unknown,
- dot11_phy_type_fhss = 1,
- dot11_phy_type_dsss = 2,
- dot11_phy_type_irbaseband = 3,
- dot11_phy_type_ofdm = 4,
- dot11_phy_type_hrdsss = 5,
- dot11_phy_type_erp = 6,
- dot11_phy_type_ht = 7,
- dot11_phy_type_IHV_start = 0x80000000,
- dot11_phy_type_IHV_end = 0xffffffff
-};
-
-enum DOT11_AUTH_ALGORITHM {
- DOT11_AUTH_ALGO_80211_OPEN = 1,
- DOT11_AUTH_ALGO_80211_SHARED_KEY = 2,
- DOT11_AUTH_ALGO_WPA = 3,
- DOT11_AUTH_ALGO_WPA_PSK = 4,
- DOT11_AUTH_ALGO_WPA_NONE = 5,
- DOT11_AUTH_ALGO_RSNA = 6,
- DOT11_AUTH_ALGO_RSNA_PSK = 7,
- DOT11_AUTH_ALGO_IHV_START = 0x80000000,
- DOT11_AUTH_ALGO_IHV_END = 0xffffffff
-};
-
-enum DOT11_CIPHER_ALGORITHM {
- DOT11_CIPHER_ALGO_NONE = 0x00,
- DOT11_CIPHER_ALGO_WEP40 = 0x01,
- DOT11_CIPHER_ALGO_TKIP = 0x02,
- DOT11_CIPHER_ALGO_CCMP = 0x04,
- DOT11_CIPHER_ALGO_WEP104 = 0x05,
- DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100,
- DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100,
- DOT11_CIPHER_ALGO_WEP = 0x101,
- DOT11_CIPHER_ALGO_IHV_START = 0x80000000,
- DOT11_CIPHER_ALGO_IHV_END = 0xffffffff
-};
-
-struct WLAN_AVAILABLE_NETWORK {
- WCHAR strProfileName[WLAN_MAX_NAME_LENGTH];
- DOT11_SSID dot11Ssid;
- DOT11_BSS_TYPE dot11BssType;
- ULONG uNumberOfBssids;
- BOOL bNetworkConnectable;
- DWORD wlanNotConnectableReason;
- ULONG uNumberOfPhyTypes;
- DOT11_PHY_TYPE dot11PhyTypes[WLAN_MAX_PHY_TYPE_NUMBER];
- BOOL bMorePhyTypes;
- ULONG wlanSignalQuality;
- BOOL bSecurityEnabled;
- DOT11_AUTH_ALGORITHM dot11DefaultAuthAlgorithm;
- DOT11_CIPHER_ALGORITHM dot11DefaultCipherAlgorithm;
- DWORD dwFlags;
- DWORD dwReserved;
-};
-
-struct WLAN_AVAILABLE_NETWORK_LIST {
- DWORD dwNumberOfItems;
- DWORD dwIndex;
- WLAN_AVAILABLE_NETWORK Network[1];
-};
-
-enum WLAN_INTF_OPCODE {
- wlan_intf_opcode_autoconf_start = 0x000000000,
- wlan_intf_opcode_autoconf_enabled,
- wlan_intf_opcode_background_scan_enabled,
- wlan_intf_opcode_media_streaming_mode,
- wlan_intf_opcode_radio_state,
- wlan_intf_opcode_bss_type,
- wlan_intf_opcode_interface_state,
- wlan_intf_opcode_current_connection,
- wlan_intf_opcode_channel_number,
- wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs,
- wlan_intf_opcode_supported_adhoc_auth_cipher_pairs,
- wlan_intf_opcode_supported_country_or_region_string_list,
- wlan_intf_opcode_current_operation_mode,
- wlan_intf_opcode_supported_safe_mode,
- wlan_intf_opcode_certified_safe_mode,
- wlan_intf_opcode_autoconf_end = 0x0fffffff,
- wlan_intf_opcode_msm_start = 0x10000100,
- wlan_intf_opcode_statistics,
- wlan_intf_opcode_rssi,
- wlan_intf_opcode_msm_end = 0x1fffffff,
- wlan_intf_opcode_security_start = 0x20010000,
- wlan_intf_opcode_security_end = 0x2fffffff,
- wlan_intf_opcode_ihv_start = 0x30000000,
- wlan_intf_opcode_ihv_end = 0x3fffffff
-};
-
-enum WLAN_OPCODE_VALUE_TYPE {
- wlan_opcode_value_type_query_only = 0,
- wlan_opcode_value_type_set_by_group_policy,
- wlan_opcode_value_type_set_by_user,
- wlan_opcode_value_type_invalid
-};
-
-enum WLAN_CONNECTION_MODE {
- wlan_connection_mode_profile = 0,
- wlan_connection_mode_temporary_profile,
- wlan_connection_mode_discovery_secure,
- wlan_connection_mode_discovery_unsecure,
- wlan_connection_mode_auto,
- wlan_connection_mode_invalid
-};
-
-struct WLAN_CONNECTION_PARAMETERS {
- WLAN_CONNECTION_MODE wlanConnectionMode;
- LPCWSTR strProfile;
- DOT11_SSID *pDot11Ssid;
- DOT11_BSSID_LIST *pDesiredBssidList;
- DOT11_BSS_TYPE dot11BssType;
- DWORD dwFlags;
-};
-
-struct WLAN_RAW_DATA {
- DWORD dwDataSize;
- BYTE DataBlob[1];
-};
-
-enum WLAN_NOTIFICATION_ACM {
- wlan_notification_acm_start = 0,
- wlan_notification_acm_autoconf_enabled,
- wlan_notification_acm_autoconf_disabled,
- wlan_notification_acm_background_scan_enabled,
- wlan_notification_acm_background_scan_disabled,
- wlan_notification_acm_bss_type_change,
- wlan_notification_acm_power_setting_change,
- wlan_notification_acm_scan_complete,
- wlan_notification_acm_scan_fail,
- wlan_notification_acm_connection_start,
- wlan_notification_acm_connection_complete,
- wlan_notification_acm_connection_attempt_fail,
- wlan_notification_acm_filter_list_change,
- wlan_notification_acm_interface_arrival,
- wlan_notification_acm_interface_removal,
- wlan_notification_acm_profile_change,
- wlan_notification_acm_profile_name_change,
- wlan_notification_acm_profiles_exhausted,
- wlan_notification_acm_network_not_available,
- wlan_notification_acm_network_available,
- wlan_notification_acm_disconnecting,
- wlan_notification_acm_disconnected,
- wlan_notification_acm_adhoc_network_state_change,
- wlan_notification_acm_end
-};
-
-struct WLAN_ASSOCIATION_ATTRIBUTES {
- DOT11_SSID dot11Ssid;
- DOT11_BSS_TYPE dot11BssType;
- DOT11_MAC_ADDRESS dot11Bssid;
- DOT11_PHY_TYPE dot11PhyType;
- ULONG uDot11PhyIndex;
- ULONG wlanSignalQuality;
- ULONG ulRxRate;
- ULONG ulTxRate;
-};
-
-struct WLAN_SECURITY_ATTRIBUTES {
- BOOL bSecurityEnabled;
- BOOL bOneXEnabled;
- DOT11_AUTH_ALGORITHM dot11AuthAlgorithm;
- DOT11_CIPHER_ALGORITHM dot11CipherAlgorithm;
-};
-
-struct WLAN_CONNECTION_ATTRIBUTES {
- WLAN_INTERFACE_STATE isState;
- WLAN_CONNECTION_MODE wlanConnectionMode;
- WCHAR strProfileName[WLAN_MAX_NAME_LENGTH];
- WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes;
- WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes;
-};
-
-typedef void (WINAPI *WLAN_NOTIFICATION_CALLBACK)(WLAN_NOTIFICATION_DATA *, PVOID);
-
-typedef DWORD (WINAPI *WlanOpenHandleProto)
- (DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle);
-typedef DWORD (WINAPI *WlanRegisterNotificationProto)
- (HANDLE hClientHandle, DWORD dwNotifSource, BOOL bIgnoreDuplicate,
- WLAN_NOTIFICATION_CALLBACK funcCallback, PVOID pCallbackContext,
- PVOID pReserved, PDWORD pdwPrevNotifSource);
-typedef DWORD (WINAPI *WlanEnumInterfacesProto)
- (HANDLE hClientHandle, PVOID pReserved, WLAN_INTERFACE_INFO_LIST **ppInterfaceList);
-typedef DWORD (WINAPI *WlanGetAvailableNetworkListProto)
- (HANDLE hClientHandle, const GUID* pInterfaceGuid, DWORD dwFlags, PVOID pReserved,
- WLAN_AVAILABLE_NETWORK_LIST **ppAvailableNetworkList);
-typedef DWORD (WINAPI *WlanQueryInterfaceProto)
- (HANDLE hClientHandle, const GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, PVOID pReserved,
- PDWORD pdwDataSize, PVOID *ppData, WLAN_OPCODE_VALUE_TYPE *pWlanOpcodeValueType);
-typedef DWORD (WINAPI *WlanConnectProto)
- (HANDLE hClientHandle, const GUID *pInterfaceGuid,
- const WLAN_CONNECTION_PARAMETERS *pConnectionParameters, PVOID pReserved);
-typedef DWORD (WINAPI *WlanDisconnectProto)
- (HANDLE hClientHandle, const GUID *pInterfaceGuid, PVOID pReserved);
-typedef DWORD (WINAPI *WlanScanProto)
- (HANDLE hClientHandle, const GUID *pInterfaceGuid, const DOT11_SSID *pDot11Ssid,
- const WLAN_RAW_DATA *pIeData, PVOID pReserved);
-typedef VOID (WINAPI *WlanFreeMemoryProto)(PVOID pMemory);
-typedef DWORD (WINAPI *WlanCloseHandleProto)(HANDLE hClientHandle, PVOID pReserved);
-
-extern WlanOpenHandleProto local_WlanOpenHandle;
-extern WlanRegisterNotificationProto local_WlanRegisterNotification;
-extern WlanEnumInterfacesProto local_WlanEnumInterfaces;
-extern WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList;
-extern WlanQueryInterfaceProto local_WlanQueryInterface;
-extern WlanConnectProto local_WlanConnect;
-extern WlanDisconnectProto local_WlanDisconnect;
-extern WlanScanProto local_WlanScan;
-extern WlanFreeMemoryProto local_WlanFreeMemory;
-extern WlanCloseHandleProto local_WlanCloseHandle;
-
-QT_END_NAMESPACE
-
-#endif // PLATFORMDEFS_H
diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
deleted file mode 100644
index ca8700e63b..0000000000
--- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
+++ /dev/null
@@ -1,622 +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$
-**
-****************************************************************************/
-
-#include "qnativewifiengine.h"
-#include "platformdefs.h"
-#include <private/qnetworksession_impl_p.h>
-
-#include <QtNetwork/private/qnetworkconfiguration_p.h>
-
-#include <QtCore/qstringlist.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qoperatingsystemversion.h>
-
-#include <QtCore/qdebug.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-WlanOpenHandleProto local_WlanOpenHandle = 0;
-WlanRegisterNotificationProto local_WlanRegisterNotification = 0;
-WlanEnumInterfacesProto local_WlanEnumInterfaces = 0;
-WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList = 0;
-WlanQueryInterfaceProto local_WlanQueryInterface = 0;
-WlanConnectProto local_WlanConnect = 0;
-WlanDisconnectProto local_WlanDisconnect = 0;
-WlanScanProto local_WlanScan = 0;
-WlanFreeMemoryProto local_WlanFreeMemory = 0;
-WlanCloseHandleProto local_WlanCloseHandle = 0;
-
-void qNotificationCallback(WLAN_NOTIFICATION_DATA *data, QNativeWifiEngine *d)
-{
- Q_UNUSED(d);
-
- if (data->NotificationSource == WLAN_NOTIFICATION_SOURCE_ACM) {
- switch (data->NotificationCode) {
- case wlan_notification_acm_connection_complete:
- case wlan_notification_acm_disconnected:
- case wlan_notification_acm_scan_complete:
- case wlan_notification_acm_scan_fail:
- QMetaObject::invokeMethod(d, "scanComplete", Qt::QueuedConnection);
- break;
- default:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "wlan acm notification" << (int)data->NotificationCode;
-#endif
- break;
- }
- } else {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "wlan notification source" << (int)data->NotificationSource << "code" << (int)data->NotificationCode;
-#endif
- }
-}
-
-QNativeWifiEngine::QNativeWifiEngine(QObject *parent)
-: QBearerEngineImpl(parent), handle(INVALID_HANDLE_VALUE)
-{
- connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(closeHandle()));
-}
-
-QNativeWifiEngine::~QNativeWifiEngine()
-{
- closeHandle();
-}
-
-void QNativeWifiEngine::scanComplete()
-{
- QMutexLocker locker(&mutex);
-
- if (!available()) {
- locker.unlock();
- emit updateCompleted();
- return;
- }
-
- // enumerate interfaces
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
-#endif
-
- locker.unlock();
- emit updateCompleted();
-
- return;
- }
-
- QStringList previous = accessPointConfigurations.keys();
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
-
- WLAN_AVAILABLE_NETWORK_LIST *networkList;
- result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
- 3, 0, &networkList);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
-#endif
- continue;
- }
-
- QStringList seenNetworks;
-
- for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
- WLAN_AVAILABLE_NETWORK &network = networkList->Network[j];
-
- QString networkName;
-
- if (network.strProfileName[0] != 0) {
- networkName = QString::fromWCharArray(network.strProfileName);
- } else {
- networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID),
- network.dot11Ssid.uSSIDLength);
- }
-
- const QString id = QString::number(qHash(QLatin1String("WLAN:") + networkName));
-
- previous.removeAll(id);
-
- QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
-
- if (!(network.dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE))
- state = QNetworkConfiguration::Undefined;
-
- if (network.strProfileName[0] != 0) {
- if (network.bNetworkConnectable) {
- if (network.dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED)
- state = QNetworkConfiguration::Active;
- else
- state = QNetworkConfiguration::Discovered;
- } else {
- state = QNetworkConfiguration::Defined;
- }
- }
-
- if (seenNetworks.contains(networkName))
- continue;
- else
- seenNetworks.append(networkName);
-
- if (accessPointConfigurations.contains(id)) {
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- bool changed = false;
-
- ptr->mutex.lock();
-
- if (!ptr->isValid) {
- ptr->isValid = true;
- changed = true;
- }
-
- if (ptr->name != networkName) {
- ptr->name = networkName;
- changed = true;
- }
-
- if (ptr->state != state) {
- ptr->state = state;
- changed = true;
- }
-
- ptr->mutex.unlock();
-
- if (changed) {
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- }
- } else {
- QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);
-
- ptr->name = networkName;
- ptr->isValid = true;
- ptr->id = id;
- ptr->state = state;
- ptr->type = QNetworkConfiguration::InternetAccessPoint;
- ptr->bearerType = QNetworkConfiguration::BearerWLAN;
-
- accessPointConfigurations.insert(id, ptr);
-
- locker.unlock();
- emit configurationAdded(ptr);
- locker.relock();
- }
- }
-
- local_WlanFreeMemory(networkList);
- }
-
- local_WlanFreeMemory(interfaceList);
-
- while (!previous.isEmpty()) {
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.take(previous.takeFirst());
-
- locker.unlock();
- emit configurationRemoved(ptr);
- locker.relock();
- }
-
- locker.unlock();
- emit updateCompleted();
-}
-
-QString QNativeWifiEngine::getInterfaceFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- if (!available())
- return QString();
-
- // enumerate interfaces
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
-#endif
- return QString();
- }
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
-
- DWORD dataSize;
- WLAN_CONNECTION_ATTRIBUTES *connectionAttributes;
- result = local_WlanQueryInterface(handle, &interface.InterfaceGuid,
- wlan_intf_opcode_current_connection, 0, &dataSize,
- reinterpret_cast<PVOID *>(&connectionAttributes), 0);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- if (result != ERROR_INVALID_STATE)
- qDebug("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result);
-#endif
-
- continue;
- }
-
- if (qHash(QLatin1String("WLAN:") +
- QString::fromWCharArray(connectionAttributes->strProfileName)) == id.toUInt()) {
- QString guid("{%1-%2-%3-%4%5-%6%7%8%9%10%11}");
-
- guid = guid.arg(interface.InterfaceGuid.Data1, 8, 16, QChar('0'));
- guid = guid.arg(interface.InterfaceGuid.Data2, 4, 16, QChar('0'));
- guid = guid.arg(interface.InterfaceGuid.Data3, 4, 16, QChar('0'));
- for (int i = 0; i < 8; ++i)
- guid = guid.arg(interface.InterfaceGuid.Data4[i], 2, 16, QChar('0'));
-
- local_WlanFreeMemory(connectionAttributes);
- local_WlanFreeMemory(interfaceList);
-
- return guid.toUpper();
- }
-
- local_WlanFreeMemory(connectionAttributes);
- }
-
- local_WlanFreeMemory(interfaceList);
-
- return QString();
-}
-
-bool QNativeWifiEngine::hasIdentifier(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- if (!available())
- return false;
-
- // enumerate interfaces
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
-#endif
- return false;
- }
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
-
- WLAN_AVAILABLE_NETWORK_LIST *networkList;
- result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
- 3, 0, &networkList);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
-#endif
- continue;
- }
-
- for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
- WLAN_AVAILABLE_NETWORK &network = networkList->Network[j];
-
- QString networkName;
-
- if (network.strProfileName[0] != 0) {
- networkName = QString::fromWCharArray(network.strProfileName);
- } else {
- networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID),
- network.dot11Ssid.uSSIDLength);
- }
-
- if (qHash(QLatin1String("WLAN:") + networkName) == id.toUInt()) {
- local_WlanFreeMemory(networkList);
- local_WlanFreeMemory(interfaceList);
- return true;
- }
- }
-
- local_WlanFreeMemory(networkList);
- }
-
- local_WlanFreeMemory(interfaceList);
-
- return false;
-}
-
-void QNativeWifiEngine::connectToId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- if (!available()) {
- locker.unlock();
- emit connectionError(id, InterfaceLookupError);
- return;
- }
-
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
-#endif
- locker.unlock();
- emit connectionError(id, InterfaceLookupError);
- return;
- }
-
- QString profile;
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
-
- WLAN_AVAILABLE_NETWORK_LIST *networkList;
- result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
- 3, 0, &networkList);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
-#endif
- continue;
- }
-
- for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
- WLAN_AVAILABLE_NETWORK &network = networkList->Network[j];
-
- profile = QString::fromWCharArray(network.strProfileName);
-
- if (qHash(QLatin1String("WLAN:") + profile) == id.toUInt())
- break;
- else
- profile.clear();
- }
-
- local_WlanFreeMemory(networkList);
-
- if (!profile.isEmpty()) {
- WLAN_CONNECTION_PARAMETERS parameters;
- parameters.wlanConnectionMode = wlan_connection_mode_profile;
- parameters.strProfile = reinterpret_cast<LPCWSTR>(profile.utf16());
- parameters.pDot11Ssid = 0;
- parameters.pDesiredBssidList = 0;
- parameters.dot11BssType = dot11_BSS_type_any;
- parameters.dwFlags = 0;
-
- DWORD result = local_WlanConnect(handle, &interface.InterfaceGuid, &parameters, 0);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result);
-#endif
- locker.unlock();
- emit connectionError(id, ConnectError);
- locker.relock();
- break;
- }
-
- break;
- }
- }
-
- local_WlanFreeMemory(interfaceList);
-
- if (profile.isEmpty()) {
- locker.unlock();
- emit connectionError(id, InterfaceLookupError);
- }
-}
-
-void QNativeWifiEngine::disconnectFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- if (!available()) {
- locker.unlock();
- emit connectionError(id, InterfaceLookupError);
- return;
- }
-
- QString interface = getInterfaceFromId(id);
-
- if (interface.isEmpty()) {
- locker.unlock();
- emit connectionError(id, InterfaceLookupError);
- return;
- }
-
- const QVector<QStringRef> split = interface.midRef(1, interface.length() - 2).split(QLatin1Char('-'));
-
- GUID guid;
- guid.Data1 = split.at(0).toUInt(0, 16);
- guid.Data2 = split.at(1).toUShort(0, 16);
- guid.Data3 = split.at(2).toUShort(0, 16);
- guid.Data4[0] = split.at(3).left(2).toUShort(0, 16);
- guid.Data4[1] = split.at(3).right(2).toUShort(0, 16);
- for (int i = 0; i < 6; ++i)
- guid.Data4[i + 2] = split.at(4).mid(i*2, 2).toUShort(0, 16);
-
- DWORD result = local_WlanDisconnect(handle, &guid, 0);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result);
-#endif
- locker.unlock();
- emit connectionError(id, DisconnectionError);
- return;
- }
-}
-
-void QNativeWifiEngine::initialize()
-{
- scanComplete();
-}
-
-void QNativeWifiEngine::requestUpdate()
-{
- QMutexLocker locker(&mutex);
-
- if (!available()) {
- locker.unlock();
- emit updateCompleted();
- return;
- }
-
- // enumerate interfaces
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
-#endif
-
- locker.unlock();
- emit updateCompleted();
-
- return;
- }
-
- bool requested = false;
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- result = local_WlanScan(handle, &interfaceList->InterfaceInfo[i].InterfaceGuid, 0, 0, 0);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: WlanScan failed with error %ld\n", __FUNCTION__, result);
-#endif
- } else {
- requested = true;
- }
- }
-
- local_WlanFreeMemory(interfaceList);
-
- if (!requested) {
- locker.unlock();
- emit updateCompleted();
- }
-}
-
-QNetworkSession::State QNativeWifiEngine::sessionStateForId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- if (!ptr)
- return QNetworkSession::Invalid;
-
- if (!ptr->isValid) {
- return QNetworkSession::Invalid;
- } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return QNetworkSession::Connected;
- } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
- return QNetworkSession::Disconnected;
- } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
- return QNetworkSession::NotAvailable;
- } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
- QNetworkConfiguration::Undefined) {
- return QNetworkSession::NotAvailable;
- }
-
- return QNetworkSession::Invalid;
-}
-
-QNetworkConfigurationManager::Capabilities QNativeWifiEngine::capabilities() const
-{
- return QNetworkConfigurationManager::ForcedRoaming |
- QNetworkConfigurationManager::CanStartAndStopInterfaces;
-}
-
-QNetworkSessionPrivate *QNativeWifiEngine::createSessionBackend()
-{
- return new QNetworkSessionPrivateImpl;
-}
-
-QNetworkConfigurationPrivatePointer QNativeWifiEngine::defaultConfiguration()
-{
- return QNetworkConfigurationPrivatePointer();
-}
-
-bool QNativeWifiEngine::available()
-{
- if (handle != INVALID_HANDLE_VALUE)
- return true;
-
- DWORD clientVersion;
-
- DWORD result = local_WlanOpenHandle(1, 0, &clientVersion, &handle);
- if (result != ERROR_SUCCESS) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- if (result != ERROR_SERVICE_NOT_ACTIVE)
- qDebug("%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result);
-#endif
-
- return false;
- }
-
- result = local_WlanRegisterNotification(handle, WLAN_NOTIFICATION_SOURCE_ALL, true,
- WLAN_NOTIFICATION_CALLBACK(qNotificationCallback),
- this, 0, 0);
-#ifdef BEARER_MANAGEMENT_DEBUG
- if (result != ERROR_SUCCESS)
- qDebug("%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result);
-#endif
-
- return handle != INVALID_HANDLE_VALUE;
-}
-
-void QNativeWifiEngine::closeHandle()
-{
- if (handle != INVALID_HANDLE_VALUE) {
- local_WlanCloseHandle(handle, 0);
- handle = INVALID_HANDLE_VALUE;
- }
-}
-
-bool QNativeWifiEngine::requiresPolling() const
-{
- // On Windows XP SP2 and SP3 only connection and disconnection notifications are available.
- // We need to poll for changes in available wireless networks.
- return QOperatingSystemVersion::current()
- <= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 5, 2);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.h b/src/plugins/bearer/nativewifi/qnativewifiengine.h
deleted file mode 100644
index 24e97bf6df..0000000000
--- a/src/plugins/bearer/nativewifi/qnativewifiengine.h
+++ /dev/null
@@ -1,106 +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 QNATIVEWIFIENGINE_P_H
-#define QNATIVEWIFIENGINE_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 <private/qbearerengine_impl_p.h>
-
-#include <QtCore/qtimer.h>
-
-#ifndef QT_NO_BEARERMANAGEMENT
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-struct WLAN_NOTIFICATION_DATA;
-
-class QNativeWifiEngine : public QBearerEngineImpl
-{
- Q_OBJECT
-
-public:
- QNativeWifiEngine(QObject *parent = 0);
- ~QNativeWifiEngine();
-
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
-
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
-
- Q_INVOKABLE void initialize();
- Q_INVOKABLE void requestUpdate();
-
- QNetworkSession::State sessionStateForId(const QString &id);
-
- QNetworkConfigurationManager::Capabilities capabilities() const;
-
- QNetworkSessionPrivate *createSessionBackend();
-
- QNetworkConfigurationPrivatePointer defaultConfiguration();
-
- bool available();
-
- bool requiresPolling() const;
-
-private Q_SLOTS:
- void scanComplete();
- void closeHandle();
-
-private:
- Qt::HANDLE handle;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_BEARERMANAGEMENT
-
-#endif
diff --git a/src/plugins/bearer/networkmanager/.prev_CMakeLists.txt b/src/plugins/bearer/networkmanager/.prev_CMakeLists.txt
deleted file mode 100644
index df5927024d..0000000000
--- a/src/plugins/bearer/networkmanager/.prev_CMakeLists.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-# Generated from networkmanager.pro.
-
-#####################################################################
-## QNetworkManagerEnginePlugin Plugin:
-#####################################################################
-
-qt_add_plugin(QNetworkManagerEnginePlugin
- OUTPUT_NAME qnmbearer
- CLASS_NAME QNetworkManagerEnginePlugin
- TYPE bearer
- SOURCES
- main.cpp
- qnetworkmanagerengine.cpp qnetworkmanagerengine.h
- qnetworkmanagerservice.cpp qnetworkmanagerservice.h
- LIBRARIES
- Qt::LinuxOfonoSupportPrivate
- Qt::NetworkPrivate
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::DBus
- Qt::LinuxOfonoSupport
- Qt::Network
-)
-
-#### Keys ignored in scope 1:.:.:networkmanager.pro:<TRUE>:
-# OTHER_FILES = "networkmanager.json"
diff --git a/src/plugins/bearer/networkmanager/CMakeLists.txt b/src/plugins/bearer/networkmanager/CMakeLists.txt
deleted file mode 100644
index 8f26a4c86d..0000000000
--- a/src/plugins/bearer/networkmanager/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-# Generated from networkmanager.pro.
-
-#####################################################################
-## QNetworkManagerEnginePlugin Plugin:
-#####################################################################
-
-qt_add_plugin(QNetworkManagerEnginePlugin
- OUTPUT_NAME qnmbearer
- TYPE bearer
- SOURCES
- main.cpp
- qnetworkmanagerengine.cpp qnetworkmanagerengine.h
- qnetworkmanagerservice.cpp qnetworkmanagerservice.h
- PUBLIC_LIBRARIES
- Qt::Core
- Qt::DBus
- Qt::LinuxOfonoSupportPrivate
- Qt::NetworkPrivate
-)
-
-#### Keys ignored in scope 1:.:.:networkmanager.pro:<TRUE>:
-# OTHER_FILES = "networkmanager.json"
diff --git a/src/plugins/bearer/networkmanager/main.cpp b/src/plugins/bearer/networkmanager/main.cpp
deleted file mode 100644
index 1773abe55b..0000000000
--- a/src/plugins/bearer/networkmanager/main.cpp
+++ /dev/null
@@ -1,84 +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$
-**
-****************************************************************************/
-
-#include "qnetworkmanagerengine.h"
-
-#include <QtNetwork/private/qbearerplugin_p.h>
-
-#include <QtCore/qdebug.h>
-
-#ifndef QT_NO_DBUS
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkManagerEnginePlugin : public QBearerEnginePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "networkmanager.json")
-
-public:
- QNetworkManagerEnginePlugin();
- ~QNetworkManagerEnginePlugin();
-
- QBearerEngine *create(const QString &key) const;
-};
-
-QNetworkManagerEnginePlugin::QNetworkManagerEnginePlugin()
-{
-}
-
-QNetworkManagerEnginePlugin::~QNetworkManagerEnginePlugin()
-{
-}
-
-QBearerEngine *QNetworkManagerEnginePlugin::create(const QString &key) const
-{
- if (key == QLatin1String("networkmanager")) {
- QNetworkManagerEngine *engine = new QNetworkManagerEngine;
- return engine;
- }
-
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#include "main.moc"
-
-#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/networkmanager/networkmanager.json b/src/plugins/bearer/networkmanager/networkmanager.json
deleted file mode 100644
index 3d408d5c20..0000000000
--- a/src/plugins/bearer/networkmanager/networkmanager.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "networkmanager" ]
-}
diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro
deleted file mode 100644
index 3ca217f974..0000000000
--- a/src/plugins/bearer/networkmanager/networkmanager.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qnmbearer
-
-QT = core network-private dbus linuxofono_support_private
-
-HEADERS += qnetworkmanagerservice.h \
- qnetworkmanagerengine.h
-
-SOURCES += main.cpp \
- qnetworkmanagerservice.cpp \
- qnetworkmanagerengine.cpp
-
-OTHER_FILES += networkmanager.json
-
-PLUGIN_TYPE = bearer
-PLUGIN_CLASS_NAME = QNetworkManagerEnginePlugin
-load(qt_plugin)
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
deleted file mode 100644
index cba2221587..0000000000
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ /dev/null
@@ -1,935 +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$
-**
-****************************************************************************/
-
-#include "qnetworkmanagerengine.h"
-#include "qnetworkmanagerservice.h"
-#include <private/qnetworksession_impl_p.h>
-
-#include <QtNetwork/private/qnetworkconfiguration_p.h>
-
-#include <QtNetwork/qnetworksession.h>
-
-#include <QtCore/qdebug.h>
-
-#include <QtDBus>
-#include <QDBusConnection>
-#include <QDBusError>
-#include <QDBusInterface>
-#include <QDBusMessage>
-#include <QDBusReply>
-
-#ifndef QT_NO_DBUS
-
-QT_BEGIN_NAMESPACE
-
-QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent)
-: QBearerEngineImpl(parent),
- managerInterface(NULL),
- systemSettings(NULL),
- ofonoManager(NULL),
- nmAvailable(false)
-{
- qDBusRegisterMetaType<QNmSettingsMap>();
-
- nmWatcher = new QDBusServiceWatcher(NM_DBUS_SERVICE,QDBusConnection::systemBus(),
- QDBusServiceWatcher::WatchForRegistration |
- QDBusServiceWatcher::WatchForUnregistration, this);
- connect(nmWatcher, SIGNAL(serviceRegistered(QString)),
- this, SLOT(nmRegistered(QString)));
- connect(nmWatcher, SIGNAL(serviceUnregistered(QString)),
- this, SLOT(nmUnRegistered(QString)));
-
- ofonoWatcher = new QDBusServiceWatcher("org.ofono",QDBusConnection::systemBus(),
- QDBusServiceWatcher::WatchForRegistration |
- QDBusServiceWatcher::WatchForUnregistration, this);
- connect(ofonoWatcher, SIGNAL(serviceRegistered(QString)),
- this, SLOT(ofonoRegistered(QString)));
- connect(ofonoWatcher, SIGNAL(serviceUnregistered(QString)),
- this, SLOT(ofonoUnRegistered(QString)));
-
- QDBusConnectionInterface *interface = QDBusConnection::systemBus().interface();
-
- if (!interface) return;
-
- if (interface->isServiceRegistered("org.ofono"))
- QMetaObject::invokeMethod(this, "ofonoRegistered", Qt::QueuedConnection);
-
- if (interface->isServiceRegistered(NM_DBUS_SERVICE))
- QMetaObject::invokeMethod(this, "nmRegistered", Qt::QueuedConnection);
-}
-
-QNetworkManagerEngine::~QNetworkManagerEngine()
-{
- qDeleteAll(connections);
- connections.clear();
- qDeleteAll(accessPoints);
- accessPoints.clear();
- qDeleteAll(wirelessDevices);
- wirelessDevices.clear();
- qDeleteAll(activeConnectionsList);
- activeConnectionsList.clear();
- qDeleteAll(interfaceDevices);
- interfaceDevices.clear();
-
- connectionInterfaces.clear();
-
- qDeleteAll(ofonoContextManagers);
- ofonoContextManagers.clear();
-
- qDeleteAll(wiredDevices);
- wiredDevices.clear();
-}
-
-void QNetworkManagerEngine::initialize()
-{
- if (nmAvailable)
- setupConfigurations();
-}
-
-void QNetworkManagerEngine::setupConfigurations()
-{
- QMutexLocker locker(&mutex);
- // Get active connections.
- const auto acPaths = managerInterface->activeConnections();
- for (const QDBusObjectPath &acPath : acPaths) {
-
- if (activeConnectionsList.contains(acPath.path()))
- continue;
-
- QNetworkManagerConnectionActive *activeConnection =
- new QNetworkManagerConnectionActive(acPath.path(),this);
- activeConnectionsList.insert(acPath.path(), activeConnection);
- connect(activeConnection, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
- this, SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>)));
-
- QStringList devices = activeConnection->devices();
- if (!devices.isEmpty()) {
- QNetworkManagerInterfaceDevice device(devices.at(0),this);
- connectionInterfaces.insert(activeConnection->connection().path(),device.networkInterface());
- }
- }
-
- // Get connections.
- const auto settingsPaths = systemSettings->listConnections();
- for (const QDBusObjectPath &settingsPath : settingsPaths) {
- locker.unlock();
- if (!hasIdentifier(settingsPath.path()))
- newConnection(settingsPath, systemSettings); //add system connection configs
- locker.relock();
- }
-
- Q_EMIT updateCompleted();
-}
-
-bool QNetworkManagerEngine::networkManagerAvailable() const
-{
- return nmAvailable;
-}
-
-QString QNetworkManagerEngine::getInterfaceFromId(const QString &settingsPath)
-{
- return connectionInterfaces.value(settingsPath);
-}
-
-bool QNetworkManagerEngine::hasIdentifier(const QString &id)
-{
- QMutexLocker locker(&mutex);
- return accessPointConfigurations.contains(id);
-}
-
-void QNetworkManagerEngine::connectToId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkManagerSettingsConnection *connection = connectionFromId(id);
-
- if (!connection)
- return;
-
- NMDeviceType connectionType = connection->getType();
-
- QString dbusDevicePath;
- const QString settingsPath = connection->path();
- QString specificPath = configuredAccessPoints.key(settingsPath);
-
- if (isConnectionActive(settingsPath))
- return;
-
- for (auto i = interfaceDevices.cbegin(), end = interfaceDevices.cend(); i != end; ++i) {
- const auto type = i.value()->deviceType();
- if (type == DEVICE_TYPE_ETHERNET || type == DEVICE_TYPE_WIFI || type == DEVICE_TYPE_MODEM) {
- if (type == connectionType) {
- dbusDevicePath = i.key();
- break;
- }
- }
- }
-
- if (specificPath.isEmpty())
- specificPath = "/";
-
- managerInterface->activateConnection(QDBusObjectPath(settingsPath),
- QDBusObjectPath(dbusDevicePath), QDBusObjectPath(specificPath));
-}
-
-void QNetworkManagerEngine::disconnectFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkManagerSettingsConnection *connection = connectionFromId(id);
-
- if (!connection)
- return;
-
- QNmSettingsMap map = connection->getSettings();
- bool connectionAutoconnect = map.value("connection").value("autoconnect",true).toBool(); //if not present is true !!
- if (connectionAutoconnect) { //autoconnect connections will simply be reconnected by nm
- emit connectionError(id, QBearerEngineImpl::OperationNotSupported);
- return;
- }
-
- for (auto i = activeConnectionsList.cbegin(), end = activeConnectionsList.cend(); i != end; ++i) {
- if (id == i.value()->connection().path() && accessPointConfigurations.contains(id)) {
- managerInterface->deactivateConnection(QDBusObjectPath(i.key()));
- break;
- }
- }
-}
-
-void QNetworkManagerEngine::requestUpdate()
-{
- if (managerInterface && managerInterface->wirelessEnabled()) {
- for (auto *wirelessDevice : qAsConst(wirelessDevices))
- wirelessDevice->requestScan();
- }
- QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
-}
-
-void QNetworkManagerEngine::interfacePropertiesChanged(const QMap<QString, QVariant> &properties)
-{
- QMutexLocker locker(&mutex);
-
- for (auto i = properties.cbegin(), end = properties.cend(); i != end; ++i) {
- if (i.key() == QLatin1String("ActiveConnections")) {
- // Active connections changed, update configurations.
-
- const auto activeConnections = qdbus_cast<QList<QDBusObjectPath> >(qvariant_cast<QDBusArgument>(i.value()));
-
- QStringList identifiers = accessPointConfigurations.keys();
- QStringList priorActiveConnections = activeConnectionsList.keys();
-
- for (const QDBusObjectPath &acPath : activeConnections) {
- priorActiveConnections.removeOne(acPath.path());
- QNetworkManagerConnectionActive *activeConnection =
- activeConnectionsList.value(acPath.path());
-
- if (!activeConnection) {
- activeConnection = new QNetworkManagerConnectionActive(acPath.path(),this);
- activeConnectionsList.insert(acPath.path(), activeConnection);
-
- connect(activeConnection, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
- this, SLOT(activeConnectionPropertiesChanged(QMap<QString,QVariant>)));
- }
-
- const QString id = activeConnection->connection().path();
-
- identifiers.removeOne(id);
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- if (ptr) {
- ptr->mutex.lock();
- if (activeConnection->state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
- (ptr->state & QNetworkConfiguration::Active) != QNetworkConfiguration::Active) {
-
- ptr->state |= QNetworkConfiguration::Active;
-
- if (activeConnectionsList.value(id) && activeConnectionsList.value(id)->defaultRoute()
- && managerInterface->state() < QNetworkManagerInterface::NM_STATE_CONNECTED_GLOBAL) {
- ptr->purpose = QNetworkConfiguration::PrivatePurpose;
- }
- ptr->mutex.unlock();
-
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- } else {
- ptr->mutex.unlock();
- }
- }
- }
-
- while (!priorActiveConnections.isEmpty())
- delete activeConnectionsList.take(priorActiveConnections.takeFirst());
-
- while (!identifiers.isEmpty()) {
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.value(identifiers.takeFirst());
-
- ptr->mutex.lock();
- if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
- ptr->state = (flag | QNetworkConfiguration::Discovered);
- ptr->mutex.unlock();
-
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- } else {
- ptr->mutex.unlock();
- }
- }
- }
- }
-}
-
-void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QMap<QString, QVariant> &properties)
-{
- QMutexLocker locker(&mutex);
-
- Q_UNUSED(properties)
-
- QNetworkManagerConnectionActive *activeConnection = qobject_cast<QNetworkManagerConnectionActive *>(sender());
-
- if (!activeConnection)
- return;
-
- const QString id = activeConnection->connection().path();
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- if (ptr) {
- if (properties.contains(QStringLiteral("State"))) {
- ptr->mutex.lock();
- if (properties.value("State").toUInt() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
- QStringList devices = activeConnection->devices();
- if (!devices.isEmpty()) {
- QNetworkManagerInterfaceDevice device(devices.at(0),this);
- connectionInterfaces.insert(id,device.networkInterface());
- }
-
- ptr->state |= QNetworkConfiguration::Active;
- ptr->mutex.unlock();
-
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- } else {
- connectionInterfaces.remove(id);
- ptr->mutex.unlock();
- }
- }
- }
-}
-
-void QNetworkManagerEngine::deviceConnectionsChanged(const QStringList &connectionsList)
-{
- QMutexLocker locker(&mutex);
- for (int i = 0; i < connections.count(); ++i) {
- if (connectionsList.contains(connections.at(i)->path()))
- continue;
-
- const QString settingsPath = connections.at(i)->path();
-
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.value(settingsPath);
- ptr->mutex.lock();
- QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
- ptr->state = (flag | QNetworkConfiguration::Discovered);
- ptr->mutex.unlock();
-
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- Q_EMIT updateCompleted();
- }
-}
-
-void QNetworkManagerEngine::wiredCarrierChanged(bool carrier)
-{
- QNetworkManagerInterfaceDeviceWired *deviceWired = qobject_cast<QNetworkManagerInterfaceDeviceWired *>(sender());
- if (!deviceWired)
- return;
- QMutexLocker locker(&mutex);
- const auto settingsPaths = systemSettings->listConnections();
- for (const QDBusObjectPath &settingsPath : settingsPaths) {
- for (int i = 0; i < connections.count(); ++i) {
- QNetworkManagerSettingsConnection *connection = connections.at(i);
- if (connection->getType() == DEVICE_TYPE_ETHERNET
- && settingsPath.path() == connection->path()) {
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.value(settingsPath.path());
-
- if (ptr) {
- ptr->mutex.lock();
- if (carrier)
- ptr->state |= QNetworkConfiguration::Discovered;
- else
- ptr->state = QNetworkConfiguration::Defined;
- ptr->mutex.unlock();
- locker.unlock();
- emit configurationChanged(ptr);
- return;
- }
- }
- }
- }
-}
-
-void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
- QNetworkManagerSettings *settings)
-{
- QMutexLocker locker(&mutex);
- if (!settings)
- settings = qobject_cast<QNetworkManagerSettings *>(sender());
-
- if (!settings) {
- return;
- }
-
- QNetworkManagerSettingsConnection *connection =
- new QNetworkManagerSettingsConnection(settings->service(),
- path.path(),this);
- const QString settingsPath = connection->path();
- if (accessPointConfigurations.contains(settingsPath)) {
- return;
- }
-
- connections.append(connection);
-
- connect(connection,SIGNAL(removed(QString)),this,SLOT(removeConnection(QString)));
- connect(connection,SIGNAL(updated()),this,SLOT(updateConnection()));
- connection->setConnections();
-
- NMDeviceType deviceType = connection->getType();
-
- if (deviceType == DEVICE_TYPE_WIFI) {
- QString apPath;
- for (int i = 0; i < accessPoints.count(); ++i) {
- if (connection->getSsid() == accessPoints.at(i)->ssid()) {
- // remove the corresponding accesspoint from configurations
- apPath = accessPoints.at(i)->path();
- QNetworkConfigurationPrivatePointer ptr
- = accessPointConfigurations.take(apPath);
- if (ptr) {
- locker.unlock();
- emit configurationRemoved(ptr);
- locker.relock();
- }
- }
- }
- if (!configuredAccessPoints.contains(settingsPath))
- configuredAccessPoints.insert(apPath,settingsPath);
- }
-
- QNetworkConfigurationPrivate *cpPriv =
- parseConnection(settingsPath, connection->getSettings());
-
- // Check if connection is active.
- if (isConnectionActive(settingsPath))
- cpPriv->state |= QNetworkConfiguration::Active;
-
- if (deviceType == DEVICE_TYPE_ETHERNET) {
- for (auto interfaceDevice : qAsConst(interfaceDevices)) {
- if (interfaceDevice->deviceType() == deviceType) {
- auto *wiredDevice = wiredDevices.value(interfaceDevice->path());
- if (wiredDevice && wiredDevice->carrier()) {
- cpPriv->state |= QNetworkConfiguration::Discovered;
- }
- }
- }
- }
-
- QNetworkConfigurationPrivatePointer ptr(cpPriv);
- accessPointConfigurations.insert(ptr->id, ptr);
- locker.unlock();
- emit configurationAdded(ptr);
-}
-
-bool QNetworkManagerEngine::isConnectionActive(const QString &settingsPath) const
-{
- for (QNetworkManagerConnectionActive *activeConnection : activeConnectionsList) {
- if (activeConnection->connection().path() == settingsPath) {
- const auto state = activeConnection->state();
- if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING
- || state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
- return true;
- } else {
- break;
- }
- }
- }
-
- QNetworkManagerSettingsConnection *settingsConnection = connectionFromId(settingsPath);
- if (settingsConnection && settingsConnection->getType() == DEVICE_TYPE_MODEM) {
- return isActiveContext(settingsConnection->path());
- }
-
- return false;
-}
-
-void QNetworkManagerEngine::removeConnection(const QString &path)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkManagerSettingsConnection *connection =
- qobject_cast<QNetworkManagerSettingsConnection *>(sender());
-
- if (!connection)
- return;
-
- connection->deleteLater();
- connections.removeAll(connection);
-
- const QString id = path;
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
-
- if (ptr) {
- locker.unlock();
- emit configurationRemoved(ptr);
- locker.relock();
- }
-
- // add base AP back into configurations
-
- // removed along with all AP props code...
-}
-
-void QNetworkManagerEngine::updateConnection()
-{
- QMutexLocker locker(&mutex);
-
- QNetworkManagerSettingsConnection *connection =
- qobject_cast<QNetworkManagerSettingsConnection *>(sender());
- if (!connection)
- return;
- const QString settingsPath = connection->path();
-
- QNetworkConfigurationPrivate *cpPriv = parseConnection(settingsPath, connection->getSettings());
-
- // Check if connection is active.
- const auto acPaths = managerInterface->activeConnections();
- for (const QDBusObjectPath &acPath : acPaths) {
- QNetworkManagerConnectionActive activeConnection(acPath.path());
-
- if (activeConnection.connection().path() == settingsPath &&
- activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
- cpPriv->state |= QNetworkConfiguration::Active;
- break;
- }
- }
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
-
- ptr->mutex.lock();
-
- ptr->isValid = cpPriv->isValid;
- ptr->name = cpPriv->name;
- ptr->id = cpPriv->id;
- ptr->state = cpPriv->state;
-
- ptr->mutex.unlock();
-
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- delete cpPriv;
-}
-
-void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher)
-{
- QMutexLocker locker(&mutex);
- QDBusPendingReply<QDBusObjectPath> reply(*watcher);
- watcher->deleteLater();
-
- if (!reply.isError()) {
- QDBusObjectPath result = reply.value();
-
- QNetworkManagerConnectionActive activeConnection(result.path());
-
- const QString id = activeConnection.connection().path();
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- if (ptr) {
- ptr->mutex.lock();
- if (activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED &&
- ptr->state != QNetworkConfiguration::Active) {
- ptr->state |= QNetworkConfiguration::Active;
- ptr->mutex.unlock();
-
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- } else {
- ptr->mutex.unlock();
- }
- }
- }
-}
-
-QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &settingsPath,
- const QNmSettingsMap &map)
-{
- QMutexLocker locker(&mutex);
- QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
- cpPriv->name = map.value("connection").value("id").toString();
- cpPriv->isValid = true;
- cpPriv->id = settingsPath;
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
-
- cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
-
- cpPriv->state = QNetworkConfiguration::Defined;
- const QString connectionType = map.value("connection").value("type").toString();
-
- if (connectionType == QLatin1String("802-3-ethernet")) {
- cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
-
- const auto devicePaths = managerInterface->getDevices();
- for (const QDBusObjectPath &devicePath : devicePaths) {
- QNetworkManagerInterfaceDevice device(devicePath.path(),this);
- if (device.deviceType() == DEVICE_TYPE_ETHERNET) {
- QNetworkManagerInterfaceDeviceWired *wiredDevice = wiredDevices.value(device.path());
- if (wiredDevice && wiredDevice->carrier()) {
- cpPriv->state |= QNetworkConfiguration::Discovered;
- break;
- }
- }
- }
- } else if (connectionType == QLatin1String("802-11-wireless")) {
- cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
-
- const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString();
- for (int i = 0; i < accessPoints.count(); ++i) {
- if (connectionSsid == accessPoints.at(i)->ssid()
- && map.value("802-11-wireless").value("seen-bssids").toStringList().contains(accessPoints.at(i)->hwAddress())) {
- cpPriv->state |= QNetworkConfiguration::Discovered;
- if (!configuredAccessPoints.contains(accessPoints.at(i)->path())) {
- configuredAccessPoints.insert(accessPoints.at(i)->path(),settingsPath);
-
- const QString accessPointId = accessPoints.at(i)->path();
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.take(accessPointId);
-
- if (ptr) {
- locker.unlock();
- emit configurationRemoved(ptr);
- locker.relock();
- }
- }
- break;
- }
- }
- } else if (connectionType == QLatin1String("gsm")) {
-
- const QString connectionPath = map.value("connection").value("id").toString();
- cpPriv->name = contextName(connectionPath);
- cpPriv->bearerType = currentBearerType(connectionPath);
-
- if (ofonoManager && ofonoManager->isValid()) {
- const QString contextPart = connectionPath.section('/', -1);
- for (auto i = ofonoContextManagers.cbegin(), end = ofonoContextManagers.cend(); i != end; ++i) {
- const QString path = i.key() + QLatin1Char('/') +contextPart;
- if (isActiveContext(path)) {
- cpPriv->state |= QNetworkConfiguration::Active;
- break;
- }
- }
- }
- }
-
- return cpPriv;
-}
-
-bool QNetworkManagerEngine::isActiveContext(const QString &contextPath) const
-{
- if (ofonoManager && ofonoManager->isValid()) {
- const QString contextPart = contextPath.section('/', -1);
- for (QOfonoDataConnectionManagerInterface *iface : ofonoContextManagers) {
- const PathPropertiesList list = iface->contextsWithProperties();
- for (int i = 0; i < list.size(); ++i) {
- if (list.at(i).path.path().contains(contextPart)) {
- return list.at(i).properties.value(QStringLiteral("Active")).toBool();
-
- }
- }
- }
- }
- return false;
-}
-
-QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const QString &id) const
-{
- for (int i = 0; i < connections.count(); ++i) {
- QNetworkManagerSettingsConnection *connection = connections.at(i);
- if (id == connection->path())
- return connection;
- }
-
- return 0;
-}
-
-QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &id)
-{
- QMutexLocker locker(&mutex);
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- if (!ptr)
- return QNetworkSession::Invalid;
-
- if (!ptr->isValid)
- return QNetworkSession::Invalid;
-
- for (QNetworkManagerConnectionActive *activeConnection : qAsConst(activeConnectionsList)) {
- const QString identifier = activeConnection->connection().path();
-
- if (id == identifier) {
- switch (activeConnection->state()) {
- case 0:
- return QNetworkSession::Disconnected;
- case 1:
- return QNetworkSession::Connecting;
- case 2:
- return QNetworkSession::Connected;
- }
- }
- }
-
- if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
- return QNetworkSession::Disconnected;
- else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined)
- return QNetworkSession::NotAvailable;
- else if ((ptr->state & QNetworkConfiguration::Undefined) == QNetworkConfiguration::Undefined)
- return QNetworkSession::NotAvailable;
-
- return QNetworkSession::Invalid;
-}
-
-quint64 QNetworkManagerEngine::bytesWritten(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- const QString networkInterface = connectionInterfaces.value(id);
- if (!networkInterface.isEmpty()) {
- const QString devFile = QLatin1String("/sys/class/net/") +
- networkInterface +
- QLatin1String("/statistics/tx_bytes");
-
- quint64 result = Q_UINT64_C(0);
-
- QFile tx(devFile);
- if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&tx);
- in >> result;
- tx.close();
- }
-
- return result;
- }
- }
-
- return Q_UINT64_C(0);
-}
-
-quint64 QNetworkManagerEngine::bytesReceived(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
- if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- const QString networkInterface = connectionInterfaces.value(id);
- if (!networkInterface.isEmpty()) {
- const QString devFile = QLatin1String("/sys/class/net/") +
- networkInterface +
- QLatin1String("/statistics/rx_bytes");
-
- quint64 result = Q_UINT64_C(0);
-
- QFile tx(devFile);
- if (tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&tx);
- in >> result;
- tx.close();
- }
-
- return result;
- }
- }
-
- return Q_UINT64_C(0);
-}
-
-quint64 QNetworkManagerEngine::startTime(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkManagerSettingsConnection *connection = connectionFromId(id);
- if (connection)
- return connection->getTimestamp();
- else
- return Q_UINT64_C(0);
-}
-
-QNetworkConfigurationManager::Capabilities QNetworkManagerEngine::capabilities() const
-{
- return QNetworkConfigurationManager::ForcedRoaming |
- QNetworkConfigurationManager::DataStatistics |
- QNetworkConfigurationManager::CanStartAndStopInterfaces;
-}
-
-QNetworkSessionPrivate *QNetworkManagerEngine::createSessionBackend()
-{
- return new QNetworkSessionPrivateImpl;
-}
-
-QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration()
-{
- for (QNetworkManagerConnectionActive *activeConnection : qAsConst(activeConnectionsList)) {
- if ((activeConnection->defaultRoute() || activeConnection->default6Route())) {
- return accessPointConfigurations.value(activeConnection->connection().path());
- }
- }
-
- return QNetworkConfigurationPrivatePointer();
-}
-
-QNetworkConfiguration::BearerType QNetworkManagerEngine::currentBearerType(const QString &id) const
-{
- QString contextPart = id.section('/', -1);
- for (auto i = ofonoContextManagers.begin(), end = ofonoContextManagers.end(); i != end; ++i) {
- QString contextPath = i.key() + QLatin1Char('/') +contextPart;
-
- if (i.value()->contexts().contains(contextPath)) {
-
- QString bearer = i.value()->bearer();
-
- if (bearer == QLatin1String("gsm")) {
- return QNetworkConfiguration::Bearer2G;
- } else if (bearer == QLatin1String("edge")) {
- return QNetworkConfiguration::Bearer2G;
- } else if (bearer == QLatin1String("umts")) {
- return QNetworkConfiguration::BearerWCDMA;
- } else if (bearer == QLatin1String("hspa")
- || bearer == QLatin1String("hsdpa")
- || bearer == QLatin1String("hsupa")) {
- return QNetworkConfiguration::BearerHSPA;
- } else if (bearer == QLatin1String("lte")) {
- return QNetworkConfiguration::BearerLTE;
- }
- }
- }
-
- return QNetworkConfiguration::BearerUnknown;
-}
-
-QString QNetworkManagerEngine::contextName(const QString &path) const
-{
- QString contextPart = path.section('/', -1);
- for (QOfonoDataConnectionManagerInterface *iface : ofonoContextManagers) {
- const PathPropertiesList list = iface->contextsWithProperties();
- for (int i = 0; i < list.size(); ++i) {
- if (list.at(i).path.path().contains(contextPart)) {
- return list.at(i).properties.value(QStringLiteral("Name")).toString();
- }
- }
- }
- return path;
-}
-
-void QNetworkManagerEngine::nmRegistered(const QString &)
-{
- if (ofonoManager) {
- delete ofonoManager;
- ofonoManager = NULL;
- }
- managerInterface = new QNetworkManagerInterface(this);
- systemSettings = new QNetworkManagerSettings(NM_DBUS_SERVICE, this);
-
- connect(managerInterface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
- this, SLOT(activationFinished(QDBusPendingCallWatcher*)));
- connect(managerInterface, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
- this, SLOT(interfacePropertiesChanged(QMap<QString,QVariant>)));
- managerInterface->setConnections();
-
- connect(systemSettings, SIGNAL(newConnection(QDBusObjectPath)),
- this, SLOT(newConnection(QDBusObjectPath)));
- systemSettings->setConnections();
- nmAvailable = true;
-
- setupConfigurations();
-}
-
-void QNetworkManagerEngine::nmUnRegistered(const QString &)
-{
- if (systemSettings) {
- delete systemSettings;
- systemSettings = NULL;
- }
- if (managerInterface) {
- delete managerInterface;
- managerInterface = NULL;
- }
-}
-
-void QNetworkManagerEngine::ofonoRegistered(const QString &)
-{
- if (ofonoManager) {
- delete ofonoManager;
- ofonoManager = NULL;
- }
- ofonoManager = new QOfonoManagerInterface(this);
- if (ofonoManager && ofonoManager->isValid()) {
- const auto modems = ofonoManager->getModems();
- for (const QString &modem : modems) {
- QOfonoDataConnectionManagerInterface *ofonoContextManager
- = new QOfonoDataConnectionManagerInterface(modem,this);
- ofonoContextManagers.insert(modem, ofonoContextManager);
- }
- }
-}
-
-void QNetworkManagerEngine::ofonoUnRegistered(const QString &)
-{
- ofonoContextManagers.clear();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
deleted file mode 100644
index c624d6087d..0000000000
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
+++ /dev/null
@@ -1,153 +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 QNETWORKMANAGERENGINE_P_H
-#define QNETWORKMANAGERENGINE_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 <private/qbearerengine_impl_p.h>
-
-#include "qnetworkmanagerservice.h"
-
-#include <private/qofonoservice_linux_p.h>
-
-#include <QMap>
-#include <QVariant>
-
-#ifndef QT_NO_DBUS
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkManagerEngine : public QBearerEngineImpl
-{
- Q_OBJECT
-
-public:
- QNetworkManagerEngine(QObject *parent = nullptr);
- ~QNetworkManagerEngine();
-
- bool networkManagerAvailable() const;
-
- QString getInterfaceFromId(const QString &id) override;
- bool hasIdentifier(const QString &id) override;
-
- void connectToId(const QString &id) override;
- void disconnectFromId(const QString &id) override;
-
- Q_INVOKABLE void initialize();
- Q_INVOKABLE void requestUpdate();
-
- QNetworkSession::State sessionStateForId(const QString &id) override;
-
- quint64 bytesWritten(const QString &id) override;
- quint64 bytesReceived(const QString &id) override;
- quint64 startTime(const QString &id) override;
-
- QNetworkConfigurationManager::Capabilities capabilities() const override;
-
- QNetworkSessionPrivate *createSessionBackend() override;
-
- QNetworkConfigurationPrivatePointer defaultConfiguration() override;
-
-private Q_SLOTS:
- void interfacePropertiesChanged(const QMap<QString, QVariant> &properties);
- void activeConnectionPropertiesChanged(const QMap<QString, QVariant> &properties);
-
- void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = nullptr);
- void removeConnection(const QString &path);
- void updateConnection();
- void activationFinished(QDBusPendingCallWatcher *watcher);
- void deviceConnectionsChanged(const QStringList &activeConnectionsList);
-
- void wiredCarrierChanged(bool);
-
- void nmRegistered(const QString &serviceName = QString());
- void nmUnRegistered(const QString &serviceName = QString());
-
- void ofonoRegistered(const QString &serviceName = QString());
- void ofonoUnRegistered(const QString &serviceName = QString());
-
-private:
- QNetworkConfigurationPrivate *parseConnection(const QString &settingsPath,
- const QNmSettingsMap &map);
- QNetworkManagerSettingsConnection *connectionFromId(const QString &id) const;
-
- QNetworkManagerInterface *managerInterface;
- QNetworkManagerSettings *systemSettings;
- QHash<QString, QNetworkManagerInterfaceDeviceWired *> wiredDevices;
- QHash<QString, QNetworkManagerInterfaceDeviceWireless *> wirelessDevices;
-
- QHash<QString, QNetworkManagerConnectionActive *> activeConnectionsList;
- QList<QNetworkManagerSettingsConnection *> connections;
- QList<QNetworkManagerInterfaceAccessPoint *> accessPoints;
- QHash<QString, QNetworkManagerInterfaceDevice *> interfaceDevices;
-
- QMap<QString,QString> configuredAccessPoints; //ap, settings path
- QHash<QString,QString> connectionInterfaces; // ac, interface
-
- QOfonoManagerInterface *ofonoManager;
- QHash <QString, QOfonoDataConnectionManagerInterface *> ofonoContextManagers;
- QNetworkConfiguration::BearerType currentBearerType(const QString &id) const;
- QString contextName(const QString &path) const;
-
- bool isConnectionActive(const QString &settingsPath) const;
- QDBusServiceWatcher *ofonoWatcher;
- QDBusServiceWatcher *nmWatcher;
-
- bool isActiveContext(const QString &contextPath) const;
- bool nmAvailable;
- void setupConfigurations();
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DBUS
-
-#endif
-
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
deleted file mode 100644
index 2d6cba1791..0000000000
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+++ /dev/null
@@ -1,1019 +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$
-**
-****************************************************************************/
-
-#include <QObject>
-#include <QList>
-#include <QtDBus/QtDBus>
-#include <QtDBus/QDBusConnection>
-#include <QtDBus/QDBusError>
-#include <QtDBus/QDBusInterface>
-#include <QtDBus/QDBusMessage>
-#include <QtDBus/QDBusReply>
-#include <QtDBus/QDBusPendingCallWatcher>
-#include <QtDBus/QDBusObjectPath>
-#include <QtDBus/QDBusPendingCall>
-
-#include "qnetworkmanagerservice.h"
-
-#ifndef QT_NO_DBUS
-
-#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
-
-QT_BEGIN_NAMESPACE
-
-
-QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
- : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- NM_DBUS_INTERFACE,
- QDBusConnection::systemBus(),parent)
-{
- if (!isValid()) {
- return;
- }
-
- PropertiesDBusInterface managerPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- DBUS_PROPERTIES_INTERFACE,
- QDBusConnection::systemBus());
- QDBusPendingReply<QVariantMap> propsReply
- = managerPropertiesInterface.call(QDBus::Block, QLatin1String("GetAll"), QLatin1String(NM_DBUS_INTERFACE));
-
- if (!propsReply.isError()) {
- propertyMap = propsReply.value();
- } else {
- qWarning() << "propsReply" << propsReply.error().message();
- }
-
- QDBusPendingReply<QList <QDBusObjectPath> > nmReply
- = call(QLatin1String("GetDevices"));
- nmReply.waitForFinished();
- if (!nmReply.isError()) {
- devicesPathList = nmReply.value();
- } else {
- qWarning() << "nmReply" << nmReply.error().message();
- }
-
- QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- QLatin1String(NM_DBUS_INTERFACE),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QNetworkManagerInterface::~QNetworkManagerInterface()
-{
- QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- QLatin1String(NM_DBUS_INTERFACE),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
- QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- QLatin1String(NM_DBUS_INTERFACE),
- QLatin1String("DeviceAdded"),
- this,SIGNAL(deviceAdded(QDBusObjectPath)));
- QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- QLatin1String(NM_DBUS_INTERFACE),
- QLatin1String("DeviceRemoved"),
- this,SIGNAL(deviceRemoved(QDBusObjectPath)));
-}
-
-bool QNetworkManagerInterface::setConnections()
-{
- if (!isValid())
- return false;
-
- QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- QLatin1String(NM_DBUS_INTERFACE),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-
- bool allOk = false;
- if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- QLatin1String(NM_DBUS_INTERFACE),
- QLatin1String("DeviceAdded"),
- this,SIGNAL(deviceAdded(QDBusObjectPath)))) {
- allOk = true;
- }
- if (QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- QLatin1String(NM_DBUS_PATH),
- QLatin1String(NM_DBUS_INTERFACE),
- QLatin1String("DeviceRemoved"),
- this,SIGNAL(deviceRemoved(QDBusObjectPath)))) {
- allOk = true;
- }
-
- return allOk;
-}
-
-QList <QDBusObjectPath> QNetworkManagerInterface::getDevices()
-{
- if (devicesPathList.isEmpty()) {
- //qWarning("using blocking call!");
- QDBusReply<QList<QDBusObjectPath> > reply = call(QLatin1String("GetDevices"));
- devicesPathList = reply.value();
- }
- return devicesPathList;
-}
-
-void QNetworkManagerInterface::activateConnection(QDBusObjectPath connectionPath,
- QDBusObjectPath devicePath,
- QDBusObjectPath specificObject)
-{
- QDBusPendingCall pendingCall = asyncCall(QLatin1String("ActivateConnection"),
- QVariant::fromValue(connectionPath),
- QVariant::fromValue(devicePath),
- QVariant::fromValue(specificObject));
-
- QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall);
- connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SIGNAL(activationFinished(QDBusPendingCallWatcher*)));
-}
-
-void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath)
-{
- asyncCall(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath));
-}
-
-bool QNetworkManagerInterface::wirelessEnabled() const
-{
- if (propertyMap.contains("WirelessEnabled"))
- return propertyMap.value("WirelessEnabled").toBool();
- return false;
-}
-
-bool QNetworkManagerInterface::wirelessHardwareEnabled() const
-{
- if (propertyMap.contains("WirelessHardwareEnabled"))
- return propertyMap.value("WirelessHardwareEnabled").toBool();
- return false;
-}
-
-QList <QDBusObjectPath> QNetworkManagerInterface::activeConnections() const
-{
- if (propertyMap.contains("ActiveConnections")) {
-
- const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(propertyMap.value("ActiveConnections"));
- QDBusObjectPath path;
- QList <QDBusObjectPath> list;
-
- dbusArgs.beginArray();
- while (!dbusArgs.atEnd()) {
- dbusArgs >> path;
- list.append(path);
- }
- dbusArgs.endArray();
-
- return list;
- }
-
- QList <QDBusObjectPath> list;
- list << QDBusObjectPath();
- return list;
-}
-
-QNetworkManagerInterface::NMState QNetworkManagerInterface::state()
-{
- if (propertyMap.contains("State"))
- return static_cast<QNetworkManagerInterface::NMState>(propertyMap.value("State").toUInt());
- return QNetworkManagerInterface::NM_STATE_UNKNOWN;
-}
-
-QString QNetworkManagerInterface::version() const
-{
- if (propertyMap.contains("Version"))
- return propertyMap.value("Version").toString();
- return QString();
-}
-
-void QNetworkManagerInterface::propertiesSwap(QMap<QString,QVariant> map)
-{
- for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
- propertyMap.insert(i.key(),i.value());
-
- if (i.key() == QLatin1String("State")) {
- quint32 state = i.value().toUInt();
- if (state == NM_DEVICE_STATE_ACTIVATED
- || state == NM_DEVICE_STATE_DISCONNECTED
- || state == NM_DEVICE_STATE_UNAVAILABLE
- || state == NM_DEVICE_STATE_FAILED) {
- Q_EMIT propertiesChanged(map);
- Q_EMIT stateChanged(state);
- }
- } else if (i.key() == QLatin1String("ActiveConnections")) {
- Q_EMIT propertiesChanged(map);
- }
- }
-}
-
-QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent)
- : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
- dbusPathName,
- NM_DBUS_INTERFACE_ACCESS_POINT,
- QDBusConnection::systemBus(),parent)
-{
-}
-
-QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint()
-{
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::flags() const
-{
- if (propertyMap.contains("Flags"))
- return propertyMap.value("Flags").toUInt();
- return 0;
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::wpaFlags() const
-{
- if (propertyMap.contains("WpaFlags"))
- return propertyMap.value("WpaFlags").toUInt();
- return 0;
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::rsnFlags() const
-{
- if (propertyMap.contains("RsnFlags"))
- return propertyMap.value("RsnFlags").toUInt();
- return 0;
-}
-
-QString QNetworkManagerInterfaceAccessPoint::ssid() const
-{
- if (propertyMap.contains("Ssid"))
- return propertyMap.value("Ssid").toString();
- return QString();
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::frequency() const
-{
- if (propertyMap.contains("Frequency"))
- return propertyMap.value("Frequency").toUInt();
- return 0;
-}
-
-QString QNetworkManagerInterfaceAccessPoint::hwAddress() const
-{
- if (propertyMap.contains("HwAddress"))
- return propertyMap.value("HwAddress").toString();
- return QString();
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::mode() const
-{
- if (propertyMap.contains("Mode"))
- return propertyMap.value("Mode").toUInt();
- return 0;
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::maxBitrate() const
-{
- if (propertyMap.contains("MaxBitrate"))
- return propertyMap.value("MaxBitrate").toUInt();
- return 0;
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::strength() const
-{
- if (propertyMap.contains("Strength"))
- return propertyMap.value("Strength").toUInt();
- return 0;
-}
-
-void QNetworkManagerInterfaceAccessPoint::propertiesSwap(QMap<QString,QVariant> map)
-{
- for (auto i = map.cbegin(), end = map.cend(); i != end; ++i)
- propertyMap.insert(i.key(),i.value());
-}
-
-QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent)
- : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
- deviceObjectPath,
- NM_DBUS_INTERFACE_DEVICE,
- QDBusConnection::systemBus(),parent)
-{
-
- if (!isValid()) {
- return;
- }
- PropertiesDBusInterface devicePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- deviceObjectPath,
- DBUS_PROPERTIES_INTERFACE,
- QDBusConnection::systemBus(),parent);
-
- QDBusPendingReply<QVariantMap> propsReply
- = devicePropertiesInterface.call(QDBus::Block, QLatin1String("GetAll"), QLatin1String(NM_DBUS_INTERFACE_DEVICE));
-
- if (!propsReply.isError()) {
- propertyMap = propsReply.value();
- }
-
- QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- deviceObjectPath,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice()
-{
- QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
- path(),
- QLatin1String(NM_DBUS_INTERFACE_DEVICE),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QString QNetworkManagerInterfaceDevice::udi() const
-{
- if (propertyMap.contains("Udi"))
- return propertyMap.value("Udi").toString();
- return QString();
-}
-
-QString QNetworkManagerInterfaceDevice::networkInterface() const
-{
- if (propertyMap.contains("Interface"))
- return propertyMap.value("Interface").toString();
- return QString();
-}
-
-quint32 QNetworkManagerInterfaceDevice::ip4Address() const
-{
- if (propertyMap.contains("Ip4Address"))
- return propertyMap.value("Ip4Address").toUInt();
- return 0;
-}
-
-quint32 QNetworkManagerInterfaceDevice::state() const
-{
- if (propertyMap.contains("State"))
- return propertyMap.value("State").toUInt();
- return 0;
-}
-
-quint32 QNetworkManagerInterfaceDevice::deviceType() const
-{
- if (propertyMap.contains("DeviceType"))
- return propertyMap.value("DeviceType").toUInt();
- return 0;
-}
-
-QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const
-{
- if (propertyMap.contains("Ip4Config"))
- return qvariant_cast<QDBusObjectPath>(propertyMap.value("Ip4Config"));
- return QDBusObjectPath();
-}
-
-void QNetworkManagerInterfaceDevice::propertiesSwap(QMap<QString,QVariant> map)
-{
- for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
- if (i.key() == QLatin1String("AvailableConnections")) { //Device
- const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(i.value());
- QDBusObjectPath path;
- QStringList paths;
- dbusArgs.beginArray();
- while (!dbusArgs.atEnd()) {
- dbusArgs >> path;
- paths << path.path();
- }
- dbusArgs.endArray();
- Q_EMIT connectionsChanged(paths);
- }
- propertyMap.insert(i.key(),i.value());
- }
- Q_EMIT propertiesChanged(map);
-}
-
-QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent)
- : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
- ifaceDevicePath,
- NM_DBUS_INTERFACE_DEVICE_WIRED,
- QDBusConnection::systemBus(), parent)
-{
- if (!isValid()) {
- return;
- }
- PropertiesDBusInterface deviceWiredPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- ifaceDevicePath,
- DBUS_PROPERTIES_INTERFACE,
- QDBusConnection::systemBus(),parent);
-
- QDBusPendingReply<QVariantMap> propsReply
- = deviceWiredPropertiesInterface.call(QDBus::Block, QLatin1String("GetAll"), QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED));
-
- if (!propsReply.isError()) {
- propertyMap = propsReply.value();
- }
-
- QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- ifaceDevicePath,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired()
-{
- QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
- path(),
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QString QNetworkManagerInterfaceDeviceWired::hwAddress() const
-{
- if (propertyMap.contains("HwAddress"))
- return propertyMap.value("HwAddress").toString();
- return QString();
-}
-
-quint32 QNetworkManagerInterfaceDeviceWired::speed() const
-{
- if (propertyMap.contains("Speed"))
- return propertyMap.value("Speed").toUInt();
- return 0;
-}
-
-bool QNetworkManagerInterfaceDeviceWired::carrier() const
-{
- if (propertyMap.contains("Carrier"))
- return propertyMap.value("Carrier").toBool();
- return false;
-}
-
-QStringList QNetworkManagerInterfaceDeviceWired::availableConnections()
-{
- QStringList list;
- if (propertyMap.contains("AvailableConnections")) {
- const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(propertyMap.value("Carrier"));
- QDBusObjectPath path;
- dbusArgs.beginArray();
- while (!dbusArgs.atEnd()) {
- dbusArgs >> path;
- list << path.path();
- }
- dbusArgs.endArray();
- }
-
- return list;
-}
-
-void QNetworkManagerInterfaceDeviceWired::propertiesSwap(QMap<QString,QVariant> map)
-{
- for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
- propertyMap.insert(i.key(),i.value());
- if (i.key() == QLatin1String("Carrier"))
- Q_EMIT carrierChanged(i.value().toBool());
- }
- Q_EMIT propertiesChanged(map);
-}
-
-QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent)
- : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
- ifaceDevicePath,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- QDBusConnection::systemBus(), parent)
-{
- if (!isValid()) {
- return;
- }
-
- interfacePath = ifaceDevicePath;
- QDBusPendingReply<QList <QDBusObjectPath> > nmReply
- = call(QLatin1String("GetAccessPoints"));
-
- if (!nmReply.isError()) {
- accessPointsList = nmReply.value();
- }
-
- PropertiesDBusInterface deviceWirelessPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- interfacePath,
- DBUS_PROPERTIES_INTERFACE,
- QDBusConnection::systemBus(),parent);
-
- QDBusPendingReply<QVariantMap> propsReply
- = deviceWirelessPropertiesInterface.call(QDBus::Block, QLatin1String("GetAll"), QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS));
-
- if (!propsReply.isError()) {
- propertyMap = propsReply.value();
- }
-
- QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- interfacePath,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless()
-{
- QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
- path(),
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-bool QNetworkManagerInterfaceDeviceWireless::setConnections()
-{
- return true;
-}
-
-QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints()
-{
- if (accessPointsList.isEmpty()) {
- //qWarning("Using blocking call!");
- QDBusReply<QList<QDBusObjectPath> > reply
- = call(QLatin1String("GetAccessPoints"));
- accessPointsList = reply.value();
- }
- return accessPointsList;
-}
-
-QString QNetworkManagerInterfaceDeviceWireless::hwAddress() const
-{
- if (propertyMap.contains("HwAddress"))
- return propertyMap.value("HwAddress").toString();
- return QString();
-}
-
-quint32 QNetworkManagerInterfaceDeviceWireless::mode() const
-{
- if (propertyMap.contains("Mode"))
- return propertyMap.value("Mode").toUInt();
- return 0;
-}
-
-quint32 QNetworkManagerInterfaceDeviceWireless::bitrate() const
-{
- if (propertyMap.contains("Bitrate"))
- return propertyMap.value("Bitrate").toUInt();
- return 0;
-}
-
-QDBusObjectPath QNetworkManagerInterfaceDeviceWireless::activeAccessPoint() const
-{
- if (propertyMap.contains("ActiveAccessPoint"))
- return qvariant_cast<QDBusObjectPath>(propertyMap.value("ActiveAccessPoint"));
- return QDBusObjectPath();
-}
-
-quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const
-{
- if (propertyMap.contains("WirelelessCapabilities"))
- return propertyMap.value("WirelelessCapabilities").toUInt();
- return 0;
-}
-
-void QNetworkManagerInterfaceDeviceWireless::requestScan()
-{
- asyncCall(QLatin1String("RequestScan"));
-}
-
-void QNetworkManagerInterfaceDeviceWireless::propertiesSwap(QMap<QString,QVariant> map)
-{
- for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
- propertyMap.insert(i.key(),i.value());
- if (i.key() == QLatin1String("ActiveAccessPoint")) //DeviceWireless
- Q_EMIT propertiesChanged(map);
- }
-}
-
-QNetworkManagerInterfaceDeviceModem::QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath, QObject *parent)
- : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
- ifaceDevicePath,
- NM_DBUS_INTERFACE_DEVICE_MODEM,
- QDBusConnection::systemBus(), parent)
-{
- if (!isValid()) {
- return;
- }
- PropertiesDBusInterface deviceModemPropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- ifaceDevicePath,
- QLatin1String("org.freedesktop.DBus.Properties"),
- QDBusConnection::systemBus(),parent);
-
- QDBusPendingReply<QVariantMap> propsReply
- = deviceModemPropertiesInterface.call(QDBus::Block, QLatin1String("GetAll"), QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM));
-
- if (!propsReply.isError()) {
- propertyMap = propsReply.value();
- }
-
- QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- ifaceDevicePath,
- QLatin1String(NM_DBUS_INTERFACE_DEVICE_MODEM),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QNetworkManagerInterfaceDeviceModem::~QNetworkManagerInterfaceDeviceModem()
-{
- QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
- path(),
- QLatin1String(NM_DBUS_PATH_SETTINGS),
- QLatin1String(NM_DBUS_IFACE_SETTINGS),
- QLatin1String("NewConnection"),
- this, SIGNAL(newConnection(QDBusObjectPath)));
-}
-
-QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::modemCapabilities() const
-{
- if (propertyMap.contains("ModemCapabilities"))
- return static_cast<QNetworkManagerInterfaceDeviceModem::ModemCapabilities>(propertyMap.value("ModemCapabilities").toUInt());
- return QNetworkManagerInterfaceDeviceModem::None;
-}
-
-QNetworkManagerInterfaceDeviceModem::ModemCapabilities QNetworkManagerInterfaceDeviceModem::currentCapabilities() const
-{
- if (propertyMap.contains("CurrentCapabilities"))
- return static_cast<QNetworkManagerInterfaceDeviceModem::ModemCapabilities>(propertyMap.value("CurrentCapabilities").toUInt());
- return QNetworkManagerInterfaceDeviceModem::None;
-}
-
-void QNetworkManagerInterfaceDeviceModem::propertiesSwap(QMap<QString,QVariant> map)
-{
- for (auto i = map.cbegin(), end = map.cend(); i != end; ++i)
- propertyMap.insert(i.key(),i.value());
- Q_EMIT propertiesChanged(map);
-}
-
-
-QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService, QObject *parent)
- : QDBusAbstractInterface(settingsService,
- NM_DBUS_PATH_SETTINGS,
- NM_DBUS_IFACE_SETTINGS,
- QDBusConnection::systemBus(), parent)
-{
- if (!isValid()) {
- return;
- }
- interfacePath = settingsService;
- QDBusPendingReply<QList <QDBusObjectPath> > nmReply
- = call(QLatin1String("ListConnections"));
-
- if (!nmReply.isError()) {
- connectionsList = nmReply.value();
- }
-}
-
-QNetworkManagerSettings::~QNetworkManagerSettings()
-{
-}
-
-bool QNetworkManagerSettings::setConnections()
-{
- bool allOk = true;
- if (!QDBusConnection::systemBus().connect(interfacePath,
- QLatin1String(NM_DBUS_PATH_SETTINGS),
- QLatin1String(NM_DBUS_IFACE_SETTINGS),
- QLatin1String("NewConnection"),
- this, SIGNAL(newConnection(QDBusObjectPath)))) {
- allOk = false;
- qWarning("NewConnection could not be connected");
- }
-
- return allOk;
-}
-
-QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
-{
- if (connectionsList.isEmpty()) {
- //qWarning("Using blocking call!");
- QDBusReply<QList<QDBusObjectPath> > reply
- = call(QLatin1String("ListConnections"));
- connectionsList = reply.value();
- }
- return connectionsList;
-}
-
-
-QString QNetworkManagerSettings::getConnectionByUuid(const QString &uuid)
-{
- QDBusReply<QDBusObjectPath > reply = call(QDBus::Block, QLatin1String("GetConnectionByUuid"), uuid);
- return reply.value().path();
-}
-
-QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent)
- : QDBusAbstractInterface(settingsService,
- connectionObjectPath,
- NM_DBUS_IFACE_SETTINGS_CONNECTION,
- QDBusConnection::systemBus(), parent)
-{
- qDBusRegisterMetaType<QNmSettingsMap>();
- if (!isValid()) {
- return;
- }
- interfacepath = connectionObjectPath;
- QDBusPendingReply<QNmSettingsMap> nmReply
- = call(QLatin1String("GetSettings"));
- if (!nmReply.isError()) {
- settingsMap = nmReply.value();
- }
-}
-
-QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection()
-{
- QDBusConnection::systemBus().disconnect(service(),
- path(),
- QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
- QLatin1String("Updated"),
- this, SIGNAL(updated()));
- QDBusConnection::systemBus().disconnect(service(),
- path(),
- QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
- QLatin1String("Removed"),
- this, SIGNAL(slotSettingsRemoved()));
-}
-
-bool QNetworkManagerSettingsConnection::setConnections()
-{
- if (!isValid())
- return false;
-
- QDBusConnection dbusConnection = QDBusConnection::systemBus();
- bool allOk = true;
- if (!dbusConnection.connect(service(),
- interfacepath,
- QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
- QLatin1String("Updated"),
- this, SIGNAL(updated()))) {
- allOk = false;
- }
-
- if (!dbusConnection.connect(service(),
- interfacepath,
- QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
- QLatin1String("Removed"),
- this, SIGNAL(slotSettingsRemoved()))) {
- allOk = false;
- }
- return allOk;
-}
-
-void QNetworkManagerSettingsConnection::slotSettingsRemoved()
-{
- Q_EMIT removed(interfacepath);
-}
-
-QNmSettingsMap QNetworkManagerSettingsConnection::getSettings()
-{
- if (settingsMap.isEmpty()) {
- //qWarning("Using blocking call!");
- QDBusReply<QNmSettingsMap> reply = call(QLatin1String("GetSettings"));
- settingsMap = reply.value();
- }
- return settingsMap;
-}
-
-NMDeviceType QNetworkManagerSettingsConnection::getType()
-{
- const QString devType =
- settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
-
- if (devType == QLatin1String("802-3-ethernet"))
- return DEVICE_TYPE_ETHERNET;
- else if (devType == QLatin1String("802-11-wireless"))
- return DEVICE_TYPE_WIFI;
- else if (devType == QLatin1String("gsm"))
- return DEVICE_TYPE_MODEM;
- else
- return DEVICE_TYPE_UNKNOWN;
-}
-
-bool QNetworkManagerSettingsConnection::isAutoConnect()
-{
- const QVariant autoConnect =
- settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect"));
-
- // NetworkManager default is to auto connect
- if (!autoConnect.isValid())
- return true;
-
- return autoConnect.toBool();
-}
-
-quint64 QNetworkManagerSettingsConnection::getTimestamp()
-{
- return settingsMap.value(QLatin1String("connection"))
- .value(QLatin1String("timestamp")).toUInt();
-}
-
-QString QNetworkManagerSettingsConnection::getId()
-{
- return settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString();
-}
-
-QString QNetworkManagerSettingsConnection::getUuid()
-{
- const QString id = settingsMap.value(QLatin1String("connection"))
- .value(QLatin1String("uuid")).toString();
-
- // is no uuid, return the connection path
- return id.isEmpty() ? path() : id;
-}
-
-QString QNetworkManagerSettingsConnection::getSsid()
-{
- return settingsMap.value(QLatin1String("802-11-wireless"))
- .value(QLatin1String("ssid")).toString();
-}
-
-QString QNetworkManagerSettingsConnection::getMacAddress()
-{
- NMDeviceType type = getType();
-
- if (type == DEVICE_TYPE_ETHERNET) {
- return settingsMap.value(QLatin1String("802-3-ethernet"))
- .value(QLatin1String("mac-address")).toString();
- } else if (type == DEVICE_TYPE_WIFI) {
- return settingsMap.value(QLatin1String("802-11-wireless"))
- .value(QLatin1String("mac-address")).toString();
- } else {
- return QString();
- }
-}
-
-QStringList QNetworkManagerSettingsConnection::getSeenBssids()
-{
- if (getType() == DEVICE_TYPE_WIFI) {
- return settingsMap.value(QLatin1String("802-11-wireless"))
- .value(QLatin1String("seen-bssids")).toStringList();
- } else {
- return QStringList();
- }
-}
-
-QNetworkManagerConnectionActive::QNetworkManagerConnectionActive(const QString &activeConnectionObjectPath, QObject *parent)
- : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
- activeConnectionObjectPath,
- NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
- QDBusConnection::systemBus(), parent)
-{
- if (!isValid()) {
- return;
- }
- PropertiesDBusInterface connectionActivePropertiesInterface(QLatin1String(NM_DBUS_SERVICE),
- activeConnectionObjectPath,
- QLatin1String("org.freedesktop.DBus.Properties"),
- QDBusConnection::systemBus());
-
-
- QDBusPendingReply<QVariantMap> propsReply
- = connectionActivePropertiesInterface.call(QDBus::Block, QLatin1String("GetAll"), QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION));
-
- if (!propsReply.isError()) {
- propertyMap = propsReply.value();
- } else {
- qWarning() << propsReply.error().message();
- }
-
- QDBusConnection::systemBus().connect(QLatin1String(NM_DBUS_SERVICE),
- activeConnectionObjectPath,
- QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive()
-{
- QDBusConnection::systemBus().disconnect(QLatin1String(NM_DBUS_SERVICE),
- path(),
- QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
- QLatin1String("PropertiesChanged"),
- this,SLOT(propertiesSwap(QMap<QString,QVariant>)));
-}
-
-QDBusObjectPath QNetworkManagerConnectionActive::connection() const
-{
- if (propertyMap.contains("Connection"))
- return qvariant_cast<QDBusObjectPath>(propertyMap.value("Connection"));
- return QDBusObjectPath();
-}
-
-QDBusObjectPath QNetworkManagerConnectionActive::specificObject() const
-{
- if (propertyMap.contains("SpecificObject"))
- return qvariant_cast<QDBusObjectPath>(propertyMap.value("SpecificObject"));
- return QDBusObjectPath();
-}
-
-QStringList QNetworkManagerConnectionActive::devices() const
-{
- QStringList list;
- if (propertyMap.contains("Devices")) {
- const QDBusArgument &dbusArgs = qvariant_cast<QDBusArgument>(propertyMap.value("Devices"));
- QDBusObjectPath path;
-
- dbusArgs.beginArray();
- while (!dbusArgs.atEnd()) {
- dbusArgs >> path;
- list.append(path.path());
- }
- dbusArgs.endArray();
- }
- return list;
-}
-
-quint32 QNetworkManagerConnectionActive::state() const
-{
- if (propertyMap.contains("State"))
- return propertyMap.value("State").toUInt();
- return 0;
-}
-
-bool QNetworkManagerConnectionActive::defaultRoute() const
-{
- if (propertyMap.contains("Default"))
- return propertyMap.value("Default").toBool();
- return false;
-}
-
-bool QNetworkManagerConnectionActive::default6Route() const
-{
- if (propertyMap.contains("Default6"))
- return propertyMap.value("Default6").toBool();
- return false;
-}
-
-void QNetworkManagerConnectionActive::propertiesSwap(QMap<QString,QVariant> map)
-{
- for (auto i = map.cbegin(), end = map.cend(); i != end; ++i) {
- propertyMap.insert(i.key(),i.value());
- if (i.key() == QLatin1String("State")) {
- quint32 state = i.value().toUInt();
- if (state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED
- || state == NM_ACTIVE_CONNECTION_STATE_DEACTIVATED) {
- Q_EMIT propertiesChanged(map);
- }
- }
- }
-}
-
-QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectPath, QObject *parent)
- : QDBusAbstractInterface(QLatin1String(NM_DBUS_SERVICE),
- deviceObjectPath,
- NM_DBUS_INTERFACE_IP4_CONFIG,
- QDBusConnection::systemBus(), parent)
-{
- if (!isValid()) {
- return;
- }
-}
-
-QNetworkManagerIp4Config::~QNetworkManagerIp4Config()
-{
-}
-
-QStringList QNetworkManagerIp4Config::domains() const
-{
- return property("Domains").toStringList();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
deleted file mode 100644
index bff7a71097..0000000000
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+++ /dev/null
@@ -1,500 +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 QNETWORKMANAGERSERVICE_H
-#define QNETWORKMANAGERSERVICE_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 <QtDBus/QtDBus>
-#include <QtDBus/QDBusConnection>
-#include <QtDBus/QDBusError>
-#include <QtDBus/QDBusInterface>
-#include <QtDBus/QDBusMessage>
-#include <QtDBus/QDBusReply>
-
-#include <QtDBus/QDBusPendingCallWatcher>
-#include <QtDBus/QDBusObjectPath>
-#include <QtDBus/QDBusContext>
-#include <QtDBus/QDBusAbstractInterface>
-#include <QMap>
-
-#ifndef QT_NO_DBUS
-
-#ifndef NETWORK_MANAGER_H
-typedef enum NMDeviceType
-{
- DEVICE_TYPE_UNKNOWN = 0,
- DEVICE_TYPE_ETHERNET,
- DEVICE_TYPE_WIFI,
- DEVICE_TYPE_MODEM = 8
-} NMDeviceType;
-
-typedef enum
-{
- NM_DEVICE_STATE_UNKNOWN = 0,
- NM_DEVICE_STATE_UNMANAGED = 10,
- NM_DEVICE_STATE_UNAVAILABLE = 20,
- NM_DEVICE_STATE_DISCONNECTED = 30,
- NM_DEVICE_STATE_PREPARE = 40,
- NM_DEVICE_STATE_CONFIG = 50,
- NM_DEVICE_STATE_NEED_AUTH = 60,
- NM_DEVICE_STATE_IP_CONFIG = 70,
- NM_DEVICE_STATE_ACTIVATED = 100,
- NM_DEVICE_STATE_DEACTIVATING = 110,
- NM_DEVICE_STATE_FAILED = 120
-} NMDeviceState;
-
-typedef enum
-{
- NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4
-} NMActiveConnectionState;
-
-#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
-
-#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
-#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
-#define NM_DBUS_INTERFACE_DEVICE NM_DBUS_INTERFACE ".Device"
-#define NM_DBUS_INTERFACE_DEVICE_WIRED NM_DBUS_INTERFACE_DEVICE ".Wired"
-#define NM_DBUS_INTERFACE_DEVICE_WIRELESS NM_DBUS_INTERFACE_DEVICE ".Wireless"
-#define NM_DBUS_INTERFACE_DEVICE_MODEM NM_DBUS_INTERFACE_DEVICE ".Modem"
-#define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint"
-#define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint"
-
-#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManager/Settings"
-
-#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManager.Settings.Connection"
-#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManager.Settings"
-#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
-#define NM_DBUS_INTERFACE_IP4_CONFIG NM_DBUS_INTERFACE ".IP4Config"
-
-#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings"
-#define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings"
-
-#define NM_802_11_AP_FLAGS_NONE 0x00000000
-#define NM_802_11_AP_FLAGS_PRIVACY 0x00000001
-#endif
-
-QT_BEGIN_NAMESPACE
-
-typedef QMap< QString, QMap<QString,QVariant> > QNmSettingsMap;
-typedef QList<quint32> ServerThing;
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QNmSettingsMap))
-Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ServerThing))
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkManagerInterface : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
- typedef enum
- {
- NM_STATE_UNKNOWN = 0,
- NM_STATE_ASLEEP = 10,
- NM_STATE_DISCONNECTED = 20,
- NM_STATE_DISCONNECTING = 30,
- NM_STATE_CONNECTING = 40,
- NM_STATE_CONNECTED_LOCAL = 50,
- NM_STATE_CONNECTED_SITE = 60,
- NM_STATE_CONNECTED_GLOBAL = 70
- } NMState;
-
- QNetworkManagerInterface(QObject *parent = nullptr);
- ~QNetworkManagerInterface();
-
- QList <QDBusObjectPath> getDevices();
- void activateConnection(QDBusObjectPath connection,QDBusObjectPath device, QDBusObjectPath specificObject);
- void deactivateConnection(QDBusObjectPath connectionPath);
-
- QDBusObjectPath path() const;
-
- bool wirelessEnabled() const;
- bool wirelessHardwareEnabled() const;
- QList <QDBusObjectPath> activeConnections() const;
- NMState state();
- QString version() const;
- bool setConnections();
-
-Q_SIGNALS:
- void deviceAdded(QDBusObjectPath);
- void deviceRemoved(QDBusObjectPath);
- void propertiesChanged(QMap<QString,QVariant>);
- void stateChanged(quint32);
- void activationFinished(QDBusPendingCallWatcher*);
- void propertiesReady();
- void devicesListReady();
-
-private Q_SLOTS:
- void propertiesSwap(QMap<QString,QVariant>);
-
-private:
- QVariantMap propertyMap;
- QList<QDBusObjectPath> devicesPathList;
-
-};
-
-class QNetworkManagerInterfaceAccessPoint : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- enum DeviceState {
- Unknown = 0,
- Unmanaged,
- Unavailable,
- Disconnected,
- Prepare,
- Config,
- NeedAuthentication,
- IpConfig,
- Activated,
- Failed
- };
-
- enum ApFlag {
- ApNone = 0x0,
- Privacy = 0x1
- };
-
- Q_DECLARE_FLAGS(ApFlags, ApFlag)
-
- enum ApSecurityFlag {
- ApSecurityNone = 0x0,
- PairWep40 = 0x1,
- PairWep104 = 0x2,
- PairTkip = 0x4,
- PairCcmp = 0x8,
- GroupWep40 = 0x10,
- GroupWep104 = 0x20,
- GroupTkip = 0x40,
- GroupCcmp = 0x80,
- KeyPsk = 0x100,
- Key8021x = 0x200
- };
-
- Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag)
-
- explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = nullptr);
- ~QNetworkManagerInterfaceAccessPoint();
-
- quint32 flags() const;
- quint32 wpaFlags() const;
- quint32 rsnFlags() const;
- QString ssid() const;
- quint32 frequency() const;
- QString hwAddress() const;
- quint32 mode() const;
- quint32 maxBitrate() const;
- quint32 strength() const;
- // bool setConnections();
-
-Q_SIGNALS:
- void propertiesChanged(QMap<QString,QVariant>);
- void propertiesReady();
-
-private Q_SLOTS:
- void propertiesSwap(QMap<QString,QVariant>);
-
-private:
- QVariantMap propertyMap;
-};
-
-class QNetworkManagerInterfaceDevice : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = nullptr);
- ~QNetworkManagerInterfaceDevice();
-
- QString udi() const;
- QString networkInterface() const;
- quint32 ip4Address() const;
- quint32 state() const;
- quint32 deviceType() const;
-
- QDBusObjectPath ip4config() const;
-
-Q_SIGNALS:
- void stateChanged(const QString &, quint32);
- void propertiesChanged(QMap<QString,QVariant>);
- void connectionsChanged(QStringList);
- void propertiesReady();
-private Q_SLOTS:
- void propertiesSwap(QMap<QString,QVariant>);
-private:
- QVariantMap propertyMap;
-};
-
-class QNetworkManagerInterfaceDeviceWired : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- explicit QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath,
- QObject *parent = nullptr);
- ~QNetworkManagerInterfaceDeviceWired();
-
- QString hwAddress() const;
- quint32 speed() const;
- bool carrier() const;
- QStringList availableConnections();
-
-Q_SIGNALS:
- void propertiesChanged(QMap<QString,QVariant>);
- void propertiesReady();
- void carrierChanged(bool);
-
-private Q_SLOTS:
- void propertiesSwap(QMap<QString,QVariant>);
-
-private:
- QVariantMap propertyMap;
-};
-
-class QNetworkManagerInterfaceDeviceWireless : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- enum DeviceCapability {
- None = 0x0,
- Wep40 = 0x1,
- Wep104 = 0x2,
- Tkip = 0x4,
- Ccmp = 0x8,
- Wpa = 0x10,
- Rsn = 0x20
- };
-
- explicit QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath,
- QObject *parent = nullptr);
- ~QNetworkManagerInterfaceDeviceWireless();
-
- QList <QDBusObjectPath> getAccessPoints();
-
- QString hwAddress() const;
- quint32 mode() const;
- quint32 bitrate() const;
- QDBusObjectPath activeAccessPoint() const;
- quint32 wirelessCapabilities() const;
- bool setConnections();
-
- void requestScan();
-Q_SIGNALS:
- void propertiesChanged(QMap<QString,QVariant>);
- void propertiesReady();
-
-private Q_SLOTS:
- void propertiesSwap(QMap<QString,QVariant>);
-
-private:
- QVariantMap propertyMap;
- QList <QDBusObjectPath> accessPointsList;
- QString interfacePath;
-};
-
-class QNetworkManagerInterfaceDeviceModem : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- enum ModemCapability {
- None = 0x0,
- Pots = 0x1,
- Cmda_Edvo = 0x2,
- Gsm_Umts = 0x4,
- Lte = 0x08
- };
- Q_DECLARE_FLAGS(ModemCapabilities, ModemCapability)
-
- explicit QNetworkManagerInterfaceDeviceModem(const QString &ifaceDevicePath,
- QObject *parent = nullptr);
- ~QNetworkManagerInterfaceDeviceModem();
-
- ModemCapabilities modemCapabilities() const;
- ModemCapabilities currentCapabilities() const;
-
-Q_SIGNALS:
- void propertiesChanged(QMap<QString,QVariant>);
- void propertiesReady();
-
-private Q_SLOTS:
- void propertiesSwap(QMap<QString,QVariant>);
-
-private:
- QVariantMap propertyMap;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkManagerInterfaceDeviceModem::ModemCapabilities)
-
-class QNetworkManagerSettings : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = nullptr);
- ~QNetworkManagerSettings();
-
- QList <QDBusObjectPath> listConnections();
- QString getConnectionByUuid(const QString &uuid);
- bool setConnections();
-
-Q_SIGNALS:
- void newConnection(QDBusObjectPath);
- void connectionsListReady();
-private:
- QList <QDBusObjectPath> connectionsList;
- QString interfacePath;
-};
-
-class QNetworkManagerSettingsConnection : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = nullptr);
- ~QNetworkManagerSettingsConnection();
-
- QNmSettingsMap getSettings();
- bool setConnections();
- NMDeviceType getType();
- bool isAutoConnect();
- quint64 getTimestamp();
- QString getId();
- QString getUuid();
- QString getSsid();
- QString getMacAddress();
- QStringList getSeenBssids();
-
-Q_SIGNALS:
- void updated();
- void removed(const QString &path);
- void settingsReady();
-
-private Q_SLOTS:
- void slotSettingsRemoved();
-private:
- QNmSettingsMap settingsMap;
- QString interfacepath;
-};
-
-class QNetworkManagerConnectionActive : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
-
- enum ActiveConnectionState {
- Unknown = 0,
- Activating = 1,
- Activated = 2
- };
-
- explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = nullptr);
- ~ QNetworkManagerConnectionActive();
-
- QDBusObjectPath connection() const;
- QDBusObjectPath specificObject() const;
- QStringList devices() const;
- quint32 state() const;
- bool defaultRoute() const;
- bool default6Route() const;
-
-
-Q_SIGNALS:
- void propertiesChanged(QMap<QString,QVariant>);
- void propertiesReady();
-
-private Q_SLOTS:
- void propertiesSwap(QMap<QString,QVariant>);
-
-private:
- QVariantMap propertyMap;
-};
-
-class QNetworkManagerIp4Config : public QDBusAbstractInterface
-{
- Q_OBJECT
-
-public:
- explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = nullptr);
- ~QNetworkManagerIp4Config();
-
- QStringList domains() const;
-};
-
-class PropertiesDBusInterface : public QDBusAbstractInterface
-{
-public:
- PropertiesDBusInterface(const QString &service, const QString &path,
- const QString &interface, const QDBusConnection &connection,
- QObject *parent = nullptr)
- : QDBusAbstractInterface(service, path, interface.toLatin1().data(), connection, parent)
- {}
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DBUS
-#endif //QNETWORKMANAGERSERVICE_H
diff --git a/src/plugins/bearer/nla/main.cpp b/src/plugins/bearer/nla/main.cpp
deleted file mode 100644
index 8e45c071e8..0000000000
--- a/src/plugins/bearer/nla/main.cpp
+++ /dev/null
@@ -1,78 +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$
-**
-****************************************************************************/
-
-#include "qnlaengine.h"
-
-#include <QtNetwork/private/qbearerplugin_p.h>
-
-#include <QtCore/qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class QNlaEnginePlugin : public QBearerEnginePlugin
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QBearerEngineFactoryInterface" FILE "nla.json")
-
-public:
- QNlaEnginePlugin();
- ~QNlaEnginePlugin();
-
- QBearerEngine *create(const QString &key) const;
-};
-
-QNlaEnginePlugin::QNlaEnginePlugin()
-{
-}
-
-QNlaEnginePlugin::~QNlaEnginePlugin()
-{
-}
-
-QBearerEngine *QNlaEnginePlugin::create(const QString &key) const
-{
- if (key == QLatin1String("nla"))
- return new QNlaEngine;
- else
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#include "main.moc"
diff --git a/src/plugins/bearer/nla/nla.json b/src/plugins/bearer/nla/nla.json
deleted file mode 100644
index 2554d2c5c4..0000000000
--- a/src/plugins/bearer/nla/nla.json
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "Keys": [ "nla" ]
-}
diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro
deleted file mode 100644
index 2582dc7cd4..0000000000
--- a/src/plugins/bearer/nla/nla.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TARGET = qnlabearer
-
-QT = core core-private network network-private
-
-QMAKE_USE_PRIVATE += ws2_32
-
-HEADERS += qnlaengine.h \
- ../platformdefs_win.h
-
-SOURCES += main.cpp \
- qnlaengine.cpp
-
-OTHER_FILES += nla.json
-
-PLUGIN_TYPE = bearer
-PLUGIN_CLASS_NAME = QNlaEnginePlugin
-load(qt_plugin)
diff --git a/src/plugins/bearer/nla/qnlaengine.cpp b/src/plugins/bearer/nla/qnlaengine.cpp
deleted file mode 100644
index ab3c0d0e3a..0000000000
--- a/src/plugins/bearer/nla/qnlaengine.cpp
+++ /dev/null
@@ -1,639 +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$
-**
-****************************************************************************/
-
-#include "qnlaengine.h"
-#include <private/qnetworksession_impl_p.h>
-
-#include <QtNetwork/private/qnetworkconfiguration_p.h>
-
-#include <QtCore/qthread.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qstringlist.h>
-
-#include <QtCore/qdebug.h>
-
-#include "../platformdefs_win.h"
-
-QT_BEGIN_NAMESPACE
-
-QWindowsSockInit2::QWindowsSockInit2()
-: version(0)
-{
- //### should we try for 2.2 on all platforms ??
- WSAData wsadata;
-
- // IPv6 requires Winsock v2.0 or better.
- if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) {
- qWarning("QBearerManagementAPI: WinSock v2.0 initialization failed.");
- } else {
- version = 0x20;
- }
-}
-
-QWindowsSockInit2::~QWindowsSockInit2()
-{
- WSACleanup();
-}
-
-#ifdef BEARER_MANAGEMENT_DEBUG
-static void printBlob(NLA_BLOB *blob)
-{
- qDebug() << "==== BEGIN NLA_BLOB ====" << Qt::endl
-
- << "type:" << blob->header.type << Qt::endl
- << "size:" << blob->header.dwSize << Qt::endl
- << "next offset:" << blob->header.nextOffset;
-
- switch (blob->header.type) {
- case NLA_RAW_DATA:
- qDebug() << "Raw Data" << Qt::endl
- << '\t' << blob->data.rawData;
- break;
- case NLA_INTERFACE:
- qDebug() << "Interface" << Qt::endl
- << "\ttype:" << blob->data.interfaceData.dwType << Qt::endl
- << "\tspeed:" << blob->data.interfaceData.dwSpeed << Qt::endl
- << "\tadapter:" << blob->data.interfaceData.adapterName;
- break;
- case NLA_802_1X_LOCATION:
- qDebug() << "802.1x Location" << Qt::endl
- << '\t' << blob->data.locationData.information;
- break;
- case NLA_CONNECTIVITY:
- qDebug() << "Connectivity" << Qt::endl
- << "\ttype:" << blob->data.connectivity.type << Qt::endl
- << "\tinternet:" << blob->data.connectivity.internet;
- break;
- case NLA_ICS:
- qDebug() << "ICS" << Qt::endl
- << "\tspeed:" << blob->data.ICS.remote.speed << Qt::endl
- << "\ttype:" << blob->data.ICS.remote.type << Qt::endl
- << "\tstate:" << blob->data.ICS.remote.state << Qt::endl
- << "\tmachine name:" << blob->data.ICS.remote.machineName << Qt::endl
- << "\tshared adapter name:" << blob->data.ICS.remote.sharedAdapterName;
- break;
- default:
- qDebug("UNKNOWN BLOB TYPE");
- }
-
- qDebug("===== END NLA_BLOB =====");
-}
-#endif
-
-static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
-{
- unsigned long oid;
- DWORD bytesWritten;
-
- NDIS_MEDIUM medium;
- NDIS_PHYSICAL_MEDIUM physicalMedium;
-
- HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0,
- FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
- if (handle == INVALID_HANDLE_VALUE)
- return QNetworkConfiguration::BearerUnknown;
-
- oid = OID_GEN_MEDIA_SUPPORTED;
- bytesWritten = 0;
- bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
- &medium, sizeof(medium), &bytesWritten, 0);
- if (!result) {
- CloseHandle(handle);
- return QNetworkConfiguration::BearerUnknown;
- }
-
- oid = OID_GEN_PHYSICAL_MEDIUM;
- bytesWritten = 0;
- result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
- &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0);
- if (!result) {
- CloseHandle(handle);
-
- if (medium == NdisMedium802_3)
- return QNetworkConfiguration::BearerEthernet;
- else
- return QNetworkConfiguration::BearerUnknown;
- }
-
- CloseHandle(handle);
-
- if (medium == NdisMedium802_3) {
- switch (physicalMedium) {
- case NdisPhysicalMediumWirelessLan:
- return QNetworkConfiguration::BearerWLAN;
- case NdisPhysicalMediumBluetooth:
- return QNetworkConfiguration::BearerBluetooth;
- case NdisPhysicalMediumWiMax:
- return QNetworkConfiguration::BearerWiMAX;
- default:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "Physical Medium" << physicalMedium;
-#endif
- return QNetworkConfiguration::BearerEthernet;
- }
- }
-
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << medium << physicalMedium;
-#endif
-
- return QNetworkConfiguration::BearerUnknown;
-}
-
-class QNlaThread : public QThread
-{
- Q_OBJECT
-
-public:
- QNlaThread(QNlaEngine *parent = 0);
- ~QNlaThread();
-
- QList<QNetworkConfigurationPrivate *> getConfigurations();
-
- void forceUpdate();
-
-protected:
- virtual void run();
-
-private:
- void updateConfigurations(QList<QNetworkConfigurationPrivate *> &configs);
- DWORD parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv) const;
- QNetworkConfigurationPrivate *parseQuerySet(const WSAQUERYSET *querySet) const;
- void fetchConfigurations();
-
-signals:
- void networksChanged();
-
-private:
- QMutex mutex;
- HANDLE handle;
- bool done;
- QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
-};
-
-QNlaThread::QNlaThread(QNlaEngine *parent)
-: QThread(parent), handle(0), done(false)
-{
-}
-
-QNlaThread::~QNlaThread()
-{
- mutex.lock();
-
- done = true;
-
- if (handle) {
- /* cancel completion event */
- if (WSALookupServiceEnd(handle) == SOCKET_ERROR) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("WSALookupServiceEnd error %d", WSAGetLastError());
-#endif
- }
- }
- mutex.unlock();
-
- wait();
-}
-
-QList<QNetworkConfigurationPrivate *> QNlaThread::getConfigurations()
-{
- QMutexLocker locker(&mutex);
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations = fetchedConfigurations;
- fetchedConfigurations.clear();
-
- return foundConfigurations;
-}
-
-void QNlaThread::forceUpdate()
-{
- mutex.lock();
-
- if (handle) {
- /* cancel completion event */
- if (WSALookupServiceEnd(handle) == SOCKET_ERROR) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("WSALookupServiceEnd error %d", WSAGetLastError());
-#endif
- }
- handle = 0;
- }
- mutex.unlock();
-}
-
-void QNlaThread::run()
-{
- WSAEVENT changeEvent = WSACreateEvent();
- if (changeEvent == WSA_INVALID_EVENT)
- return;
-
- while (true) {
- fetchConfigurations();
-
- WSAQUERYSET qsRestrictions;
-
- memset(&qsRestrictions, 0, sizeof(qsRestrictions));
- qsRestrictions.dwSize = sizeof(qsRestrictions);
- qsRestrictions.dwNameSpace = NS_NLA;
-
- mutex.lock();
- if (done) {
- mutex.unlock();
- break;
- }
- int result = WSALookupServiceBegin(&qsRestrictions, LUP_RETURN_ALL, &handle);
- mutex.unlock();
-
- if (result == SOCKET_ERROR)
- break;
-
- WSACOMPLETION completion;
- WSAOVERLAPPED overlapped;
-
- memset(&overlapped, 0, sizeof(overlapped));
- overlapped.hEvent = changeEvent;
-
- memset(&completion, 0, sizeof(completion));
- completion.Type = NSP_NOTIFY_EVENT;
- completion.Parameters.Event.lpOverlapped = &overlapped;
-
- DWORD bytesReturned = 0;
- result = WSANSPIoctl(handle, SIO_NSP_NOTIFY_CHANGE, 0, 0, 0, 0,
- &bytesReturned, &completion);
- if (result == SOCKET_ERROR) {
- if (WSAGetLastError() != WSA_IO_PENDING)
- break;
- }
-
- // Not interested in unrelated IO completion events
- // although we also don't want to block them
- while (WaitForSingleObjectEx(changeEvent, WSA_INFINITE, true) != WAIT_IO_COMPLETION &&
- handle)
- {
- }
-
- mutex.lock();
- if (handle) {
- result = WSALookupServiceEnd(handle);
- if (result == SOCKET_ERROR) {
- mutex.unlock();
- break;
- }
- handle = 0;
- }
- mutex.unlock();
- }
-
- WSACloseEvent(changeEvent);
-}
-
-void QNlaThread::updateConfigurations(QList<QNetworkConfigurationPrivate *> &configs)
-{
- mutex.lock();
-
- while (!fetchedConfigurations.isEmpty())
- delete fetchedConfigurations.takeFirst();
-
- fetchedConfigurations = configs;
-
- mutex.unlock();
-
- emit networksChanged();
-}
-
-DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv) const
-{
-#ifdef BEARER_MANAGEMENT_DEBUG
- printBlob(blob);
-#endif
-
- switch (blob->header.type) {
- case NLA_RAW_DATA:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: unhandled header type NLA_RAW_DATA", __FUNCTION__);
-#endif
- break;
- case NLA_INTERFACE:
- cpPriv->state = QNetworkConfiguration::Active;
- if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) {
- engine->configurationInterface[cpPriv->id.toUInt()] =
- QString::fromLatin1(blob->data.interfaceData.adapterName);
- }
- break;
- case NLA_802_1X_LOCATION:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: unhandled header type NLA_802_1X_LOCATION", __FUNCTION__);
-#endif
- break;
- case NLA_CONNECTIVITY:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: unhandled header type NLA_CONNECTIVITY", __FUNCTION__);
-#endif
- break;
- case NLA_ICS:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: unhandled header type NLA_ICS", __FUNCTION__);
-#endif
- break;
- default:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("%s: unhandled header type %d", __FUNCTION__, blob->header.type);
-#endif
- ;
- }
-
- return blob->header.nextOffset;
-}
-
-QNetworkConfigurationPrivate *QNlaThread::parseQuerySet(const WSAQUERYSET *querySet) const
-{
- QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
-
- cpPriv->name = QString::fromWCharArray(querySet->lpszServiceInstanceName);
- cpPriv->isValid = true;
- cpPriv->id = QString::number(qHash(QLatin1String("NLA:") + cpPriv->name));
- cpPriv->state = QNetworkConfiguration::Defined;
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
-
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "size:" << querySet->dwSize;
- qDebug() << "service instance name:" << QString::fromUtf16(querySet->lpszServiceInstanceName);
- qDebug() << "service class id:" << querySet->lpServiceClassId;
- qDebug() << "version:" << querySet->lpVersion;
- qDebug() << "comment:" << QString::fromUtf16(querySet->lpszComment);
- qDebug() << "namespace:" << querySet->dwNameSpace;
- qDebug() << "namespace provider id:" << querySet->lpNSProviderId;
- qDebug() << "context:" << QString::fromUtf16(querySet->lpszContext);
- qDebug() << "number of protocols:" << querySet->dwNumberOfProtocols;
- qDebug() << "protocols:" << querySet->lpafpProtocols;
- qDebug() << "query string:" << QString::fromUtf16(querySet->lpszQueryString);
- qDebug() << "number of cs addresses:" << querySet->dwNumberOfCsAddrs;
- qDebug() << "cs addresses:" << querySet->lpcsaBuffer;
- qDebug() << "output flags:" << querySet->dwOutputFlags;
-#endif
-
- if (querySet->lpBlob) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "blob size:" << querySet->lpBlob->cbSize;
- qDebug() << "blob data:" << querySet->lpBlob->pBlobData;
-#endif
-
- DWORD offset = 0;
- do {
- NLA_BLOB *blob = reinterpret_cast<NLA_BLOB *>(querySet->lpBlob->pBlobData + offset);
- DWORD nextOffset = parseBlob(blob, cpPriv);
- if (nextOffset == offset)
- break;
- else
- offset = nextOffset;
- } while (offset != 0 && offset < querySet->lpBlob->cbSize);
- }
-
- if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) {
- const QString interface = engine->getInterfaceFromId(cpPriv->id);
- cpPriv->bearerType = qGetInterfaceType(interface);
- }
-
- return cpPriv;
-}
-
-void QNlaThread::fetchConfigurations()
-{
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
- WSAQUERYSET qsRestrictions;
- HANDLE hLookup = 0;
-
- memset(&qsRestrictions, 0, sizeof(qsRestrictions));
- qsRestrictions.dwSize = sizeof(qsRestrictions);
- qsRestrictions.dwNameSpace = NS_NLA;
-
- int result = WSALookupServiceBegin(&qsRestrictions, LUP_RETURN_ALL | LUP_DEEP, &hLookup);
- if (result == SOCKET_ERROR) {
- mutex.lock();
- fetchedConfigurations.clear();
- mutex.unlock();
- }
-
- char buffer[0x10000];
- while (result == 0) {
- DWORD bufferLength = sizeof(buffer);
- result = WSALookupServiceNext(hLookup, LUP_RETURN_ALL,
- &bufferLength, reinterpret_cast<WSAQUERYSET *>(buffer));
-
- if (result == SOCKET_ERROR)
- break;
-
- QNetworkConfigurationPrivate *cpPriv =
- parseQuerySet(reinterpret_cast<WSAQUERYSET *>(buffer));
-
- foundConfigurations.append(cpPriv);
- }
-
- if (hLookup) {
- result = WSALookupServiceEnd(hLookup);
- if (result == SOCKET_ERROR) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug("WSALookupServiceEnd error %d", WSAGetLastError());
-#endif
- }
- }
-
- updateConfigurations(foundConfigurations);
-}
-
-QNlaEngine::QNlaEngine(QObject *parent)
-: QBearerEngineImpl(parent), nlaThread(0)
-{
- nlaThread = new QNlaThread(this);
- connect(nlaThread, SIGNAL(networksChanged()),
- this, SLOT(networksChanged()));
- nlaThread->start();
-
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
-}
-
-QNlaEngine::~QNlaEngine()
-{
- delete nlaThread;
-}
-
-void QNlaEngine::networksChanged()
-{
- QMutexLocker locker(&mutex);
-
- QStringList previous = accessPointConfigurations.keys();
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations = nlaThread->getConfigurations();
- while (!foundConfigurations.isEmpty()) {
- QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst();
-
- previous.removeAll(cpPriv->id);
-
- if (accessPointConfigurations.contains(cpPriv->id)) {
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
-
- bool changed = false;
-
- ptr->mutex.lock();
-
- if (ptr->isValid != cpPriv->isValid) {
- ptr->isValid = cpPriv->isValid;
- changed = true;
- }
-
- if (ptr->name != cpPriv->name) {
- ptr->name = cpPriv->name;
- changed = true;
- }
-
- if (ptr->state != cpPriv->state) {
- ptr->state = cpPriv->state;
- changed = true;
- }
-
- ptr->mutex.unlock();
-
- if (changed) {
- locker.unlock();
- emit configurationChanged(ptr);
- locker.relock();
- }
-
- delete cpPriv;
- } else {
- QNetworkConfigurationPrivatePointer ptr(cpPriv);
-
- accessPointConfigurations.insert(ptr->id, ptr);
-
- locker.unlock();
- emit configurationAdded(ptr);
- locker.relock();
- }
- }
-
- while (!previous.isEmpty()) {
- QNetworkConfigurationPrivatePointer ptr =
- accessPointConfigurations.take(previous.takeFirst());
-
- locker.unlock();
- emit configurationRemoved(ptr);
- locker.relock();
- }
-
- locker.unlock();
- emit updateCompleted();
-}
-
-QString QNlaEngine::getInterfaceFromId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- return configurationInterface.value(id.toUInt());
-}
-
-bool QNlaEngine::hasIdentifier(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- return configurationInterface.contains(id.toUInt());
-}
-
-void QNlaEngine::connectToId(const QString &id)
-{
- emit connectionError(id, OperationNotSupported);
-}
-
-void QNlaEngine::disconnectFromId(const QString &id)
-{
- emit connectionError(id, OperationNotSupported);
-}
-
-void QNlaEngine::requestUpdate()
-{
- QMutexLocker locker(&mutex);
-
- nlaThread->forceUpdate();
-}
-
-QNetworkSession::State QNlaEngine::sessionStateForId(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
-
- if (!ptr)
- return QNetworkSession::Invalid;
-
- if (!ptr->isValid) {
- return QNetworkSession::Invalid;
- } else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return QNetworkSession::Connected;
- } else if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
- return QNetworkSession::Disconnected;
- } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
- return QNetworkSession::NotAvailable;
- } else if ((ptr->state & QNetworkConfiguration::Undefined) ==
- QNetworkConfiguration::Undefined) {
- return QNetworkSession::NotAvailable;
- }
-
- return QNetworkSession::Invalid;
-}
-
-QNetworkConfigurationManager::Capabilities QNlaEngine::capabilities() const
-{
- return QNetworkConfigurationManager::ForcedRoaming;
-}
-
-QNetworkSessionPrivate *QNlaEngine::createSessionBackend()
-{
- return new QNetworkSessionPrivateImpl;
-}
-
-QNetworkConfigurationPrivatePointer QNlaEngine::defaultConfiguration()
-{
- return QNetworkConfigurationPrivatePointer();
-}
-
-#include "qnlaengine.moc"
-QT_END_NAMESPACE
-
diff --git a/src/plugins/bearer/nla/qnlaengine.h b/src/plugins/bearer/nla/qnlaengine.h
deleted file mode 100644
index 90efa50201..0000000000
--- a/src/plugins/bearer/nla/qnlaengine.h
+++ /dev/null
@@ -1,110 +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 QNLAENGINE_P_H
-#define QNLAENGINE_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 <private/qbearerengine_impl_p.h>
-
-#include <QtNetwork/private/qnativesocketengine_p.h>
-
-#include <QMap>
-
-QT_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-class QNlaThread;
-
-class QWindowsSockInit2
-{
-public:
- QWindowsSockInit2();
- ~QWindowsSockInit2();
- int version;
-};
-
-class QNlaEngine : public QBearerEngineImpl
-{
- Q_OBJECT
-
- friend class QNlaThread;
-
-public:
- QNlaEngine(QObject *parent = 0);
- ~QNlaEngine();
-
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
-
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
-
- Q_INVOKABLE void requestUpdate();
-
- QNetworkSession::State sessionStateForId(const QString &id);
-
- QNetworkConfigurationManager::Capabilities capabilities() const;
-
- QNetworkSessionPrivate *createSessionBackend();
-
- QNetworkConfigurationPrivatePointer defaultConfiguration();
-
-private Q_SLOTS:
- void networksChanged();
-
-private:
- QWindowsSockInit2 winSock;
- QNlaThread *nlaThread;
- QMap<uint, QString> configurationInterface;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/bearer/platformdefs_win.h b/src/plugins/bearer/platformdefs_win.h
deleted file mode 100644
index 0477dc45c3..0000000000
--- a/src/plugins/bearer/platformdefs_win.h
+++ /dev/null
@@ -1,142 +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 QPLATFORMDEFS_WIN_H
-#define QPLATFORMDEFS_WIN_H
-
-// Since we need to include winsock2.h, we need to define WIN32_LEAN_AND_MEAN
-// somewhere above so windows.h won't include winsock.h.
-#include <winsock2.h>
-#include <mswsock.h>
-#undef interface
-#include <wincrypt.h>
-#include <winioctl.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef NS_NLA
-
-#define NS_NLA 15
-
-#ifndef NLA_NAMESPACE_GUID
-enum NLA_BLOB_DATA_TYPE {
- NLA_RAW_DATA = 0,
- NLA_INTERFACE = 1,
- NLA_802_1X_LOCATION = 2,
- NLA_CONNECTIVITY = 3,
- NLA_ICS = 4
-};
-
-enum NLA_CONNECTIVITY_TYPE {
- NLA_NETWORK_AD_HOC = 0,
- NLA_NETWORK_MANAGED = 1,
- NLA_NETWORK_UNMANAGED = 2,
- NLA_NETWORK_UNKNOWN = 3
-};
-
-enum NLA_INTERNET {
- NLA_INTERNET_UNKNOWN = 0,
- NLA_INTERNET_NO = 1,
- NLA_INTERNET_YES = 2
-};
-
-struct NLA_BLOB {
- struct {
- NLA_BLOB_DATA_TYPE type;
- DWORD dwSize;
- DWORD nextOffset;
- } header;
-
- union {
- // NLA_RAW_DATA
- CHAR rawData[1];
-
- // NLA_INTERFACE
- struct {
- DWORD dwType;
- DWORD dwSpeed;
- CHAR adapterName[1];
- } interfaceData;
-
- // NLA_802_1X_LOCATION
- struct {
- CHAR information[1];
- } locationData;
-
- // NLA_CONNECTIVITY
- struct {
- NLA_CONNECTIVITY_TYPE type;
- NLA_INTERNET internet;
- } connectivity;
-
- // NLA_ICS
- struct {
- struct {
- DWORD speed;
- DWORD type;
- DWORD state;
- WCHAR machineName[256];
- WCHAR sharedAdapterName[256];
- } remote;
- } ICS;
- } data;
-};
-#endif // NLA_NAMESPACE_GUID
-
-#endif
-
-enum NDIS_MEDIUM {
- NdisMedium802_3 = 0,
-};
-
-enum NDIS_PHYSICAL_MEDIUM {
- NdisPhysicalMediumWirelessLan = 1,
- NdisPhysicalMediumBluetooth = 10,
- NdisPhysicalMediumWiMax = 12,
-};
-
-#define OID_GEN_MEDIA_SUPPORTED 0x00010103
-#define OID_GEN_PHYSICAL_MEDIUM 0x00010202
-
-#define IOCTL_NDIS_QUERY_GLOBAL_STATS \
- CTL_CODE(FILE_DEVICE_PHYSICAL_NETCARD, 0, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
-
-QT_END_NAMESPACE
-
-#endif // QPLATFORMDEFS_WIN_H
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index cd4d301194..df738c419f 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -2,7 +2,6 @@ TEMPLATE = subdirs
QT_FOR_CONFIG += network
qtHaveModule(sql): SUBDIRS += sqldrivers
-qtHaveModule(network):qtConfig(bearermanagement): SUBDIRS += bearer
qtHaveModule(gui) {
SUBDIRS *= platforms platforminputcontexts platformthemes
qtConfig(imageformatplugin): SUBDIRS *= imageformats