diff options
Diffstat (limited to 'src/plugins/bearer/nativewifi')
-rw-r--r-- | src/plugins/bearer/nativewifi/main.cpp | 127 | ||||
-rw-r--r-- | src/plugins/bearer/nativewifi/nativewifi.json | 3 | ||||
-rw-r--r-- | src/plugins/bearer/nativewifi/nativewifi.pro | 15 | ||||
-rw-r--r-- | src/plugins/bearer/nativewifi/platformdefs.h | 327 | ||||
-rw-r--r-- | src/plugins/bearer/nativewifi/qnativewifiengine.cpp | 622 | ||||
-rw-r--r-- | src/plugins/bearer/nativewifi/qnativewifiengine.h | 106 |
6 files changed, 0 insertions, 1200 deletions
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, ¶meters, 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 |