summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/bearer/bearer.pri6
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp25
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h2
-rw-r--r--src/network/bearer/qnetworksession_p.cpp9
-rw-r--r--src/plugins/bearer/bearer.pro1
-rw-r--r--src/plugins/bearer/nativewifi/main.cpp143
-rw-r--r--src/plugins/bearer/nativewifi/nativewifi.pro13
-rw-r--r--src/plugins/bearer/nativewifi/platformdefs.h322
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.cpp (renamed from src/network/bearer/qnativewifiengine_win.cpp)354
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.h (renamed from src/network/bearer/qnativewifiengine_win_p.h)6
10 files changed, 517 insertions, 364 deletions
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri
index 2c2d255..9476239 100644
--- a/src/network/bearer/bearer.pri
+++ b/src/network/bearer/bearer.pri
@@ -82,12 +82,6 @@ symbian {
contains(QT_CONFIG, networkmanager):DEFINES += BACKEND_NM
- win32:!wince* {
- HEADERS += bearer/qnativewifiengine_win_p.h
-
- SOURCES += bearer/qnativewifiengine_win.cpp
- }
-
macx {
HEADERS += bearer/qcorewlanengine_mac_p.h
SOURCES+= bearer/qcorewlanengine_mac.mm
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index c61bcd3..c35edbf 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -41,9 +41,6 @@
#include "qnetworkconfigmanager_p.h"
-#ifdef Q_OS_WIN32
-#include "qnativewifiengine_win_p.h"
-#endif
#ifdef Q_OS_DARWIN
#include "qcorewlanengine_mac_p.h"
#endif
@@ -239,6 +236,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
}
#else
#ifdef BACKEND_NM
+ nmWifi = 0;
if (keys.contains(QLatin1String("networkmanager"))) {
QBearerEnginePlugin *nmPlugin =
qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("networkmanager")));
@@ -252,6 +250,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
}
#endif
+ generic = 0;
if (keys.contains(QLatin1String("generic"))) {
QBearerEnginePlugin *genericPlugin =
qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("generic")));
@@ -266,10 +265,12 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
#endif
#ifdef Q_OS_WIN
+ nla = 0;
if (keys.contains(QLatin1String("nla"))) {
QBearerEnginePlugin *nlaPlugin =
qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("nla")));
if (nlaPlugin) {
+ qDebug() << "creating nla backend";
nla = nlaPlugin->create(QLatin1String("nla"));
if (nla) {
connect(nla, SIGNAL(configurationsChanged()),
@@ -280,13 +281,21 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
#endif
#ifdef Q_OS_WIN32
- nativeWifi = QNativeWifiEngine::instance();
- if (nativeWifi) {
- connect(nativeWifi, SIGNAL(configurationsChanged()),
- this, SLOT(updateConfigurations()));
+ nativeWifi = 0;
+ if (keys.contains(QLatin1String("nativewifi"))) {
+ QBearerEnginePlugin *nativeWifiPlugin =
+ qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("nativewifi")));
+ if (nativeWifiPlugin) {
+ qDebug() << "Creating native wifi backend";
+ nativeWifi = nativeWifiPlugin->create(QLatin1String("nativewifi"));
+ if (nativeWifi) {
+ connect(nativeWifi, SIGNAL(configurationsChanged()),
+ this, SLOT(updateConfigurations()));
- capFlags |= QNetworkConfigurationManager::CanStartAndStopInterfaces;
+ capFlags |= QNetworkConfigurationManager::CanStartAndStopInterfaces;
+ }
}
+ }
#endif
}
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
index 7b824f0..5d0df18 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_p.h
@@ -139,7 +139,7 @@ private:
#ifdef Q_OS_WIN
QNetworkSessionEngine *nla;
#ifndef Q_OS_WINCE
- QNativeWifiEngine *nativeWifi;
+ QNetworkSessionEngine *nativeWifi;
#endif
#endif
#ifdef BACKEND_NM
diff --git a/src/network/bearer/qnetworksession_p.cpp b/src/network/bearer/qnetworksession_p.cpp
index 1ce94e2..3c9054b 100644
--- a/src/network/bearer/qnetworksession_p.cpp
+++ b/src/network/bearer/qnetworksession_p.cpp
@@ -44,9 +44,6 @@
#include "qnetworksessionengine_p.h"
#include "qnetworkconfigmanager_p.h"
-#ifdef Q_OS_WIN32
-#include "qnativewifiengine_win_p.h"
-#endif
#ifdef Q_OS_DARWIN
#include "qcorewlanengine_mac_p.h"
#endif
@@ -64,12 +61,6 @@ static QNetworkSessionEngine *getEngineFromId(const QString &id)
{
QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
-#ifdef Q_OS_WIN32
- QNativeWifiEngine *nativeWifi = QNativeWifiEngine::instance();
- if (nativeWifi && nativeWifi->hasIdentifier(id))
- return nativeWifi;
-#endif
-
#ifdef Q_OS_DARWIN
QCoreWlanEngine *coreWifi = QCoreWlanEngine::instance();
if (coreWifi && coreWifi->hasIdentifier(id))
diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro
index 51323b0..80d6f4b 100644
--- a/src/plugins/bearer/bearer.pro
+++ b/src/plugins/bearer/bearer.pro
@@ -3,3 +3,4 @@ TEMPLATE = subdirs
SUBDIRS += generic
contains(QT_CONFIG, dbus):contains(QT_CONFIG, networkmanager):SUBDIRS += networkmanager
win32:SUBDIRS += nla
+win32:!wince*:SUBDIRS += nativewifi
diff --git a/src/plugins/bearer/nativewifi/main.cpp b/src/plugins/bearer/nativewifi/main.cpp
new file mode 100644
index 0000000..2aced02
--- /dev/null
+++ b/src/plugins/bearer/nativewifi/main.cpp
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qnativewifiengine.h"
+#include "platformdefs.h"
+
+#include <QtCore/qmutex.h>
+#include <QtCore/private/qmutexpool_p.h>
+#include <QtCore/qlibrary.h>
+
+#include <QtNetwork/qbearerplugin.h>
+
+#include <QtCore/qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+static void resolveLibrary()
+{
+ static volatile bool triedResolve = false;
+
+ if (!triedResolve) {
+#ifndef QT_NO_THREAD
+ QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle));
+#endif
+
+ if (!triedResolve) {
+ local_WlanOpenHandle = (WlanOpenHandleProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanOpenHandle");
+ local_WlanRegisterNotification = (WlanRegisterNotificationProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanRegisterNotification");
+ local_WlanEnumInterfaces = (WlanEnumInterfacesProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanEnumInterfaces");
+ local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanGetAvailableNetworkList");
+ local_WlanQueryInterface = (WlanQueryInterfaceProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanQueryInterface");
+ local_WlanConnect = (WlanConnectProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanConnect");
+ local_WlanDisconnect = (WlanDisconnectProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanDisconnect");
+ local_WlanScan = (WlanScanProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanScan");
+ local_WlanFreeMemory = (WlanFreeMemoryProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanFreeMemory");
+ local_WlanCloseHandle = (WlanCloseHandleProto)
+ QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanCloseHandle");
+
+ triedResolve = true;
+ }
+ }
+}
+
+class QNativeWifiEnginePlugin : public QBearerEnginePlugin
+{
+public:
+ QNativeWifiEnginePlugin();
+ ~QNativeWifiEnginePlugin();
+
+ QStringList keys() const;
+ QBearerEngine *create(const QString &key) const;
+};
+
+QNativeWifiEnginePlugin::QNativeWifiEnginePlugin()
+{
+}
+
+QNativeWifiEnginePlugin::~QNativeWifiEnginePlugin()
+{
+}
+
+QStringList QNativeWifiEnginePlugin::keys() const
+{
+ qDebug() << Q_FUNC_INFO;
+
+ return QStringList() << QLatin1String("nativewifi");
+}
+
+QBearerEngine *QNativeWifiEnginePlugin::create(const QString &key) const
+{
+ qDebug() << Q_FUNC_INFO;
+
+ 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;
+}
+
+Q_EXPORT_STATIC_PLUGIN(QNativeWifiEnginePlugin)
+Q_EXPORT_PLUGIN2(qnativewifibearer, QNativeWifiEnginePlugin)
+
+QT_END_NAMESPACE
diff --git a/src/plugins/bearer/nativewifi/nativewifi.pro b/src/plugins/bearer/nativewifi/nativewifi.pro
new file mode 100644
index 0000000..3aab552
--- /dev/null
+++ b/src/plugins/bearer/nativewifi/nativewifi.pro
@@ -0,0 +1,13 @@
+TARGET = qnativewifibearer
+include(../../qpluginbase.pri)
+
+QT += network
+
+DEFINES += BEARER_ENGINE
+
+HEADERS += qnativewifiengine.h platformdefs.h
+SOURCES += qnativewifiengine.cpp main.cpp
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer
+target.path += $$[QT_INSTALL_PLUGINS]/bearer
+INSTALLS += target
diff --git a/src/plugins/bearer/nativewifi/platformdefs.h b/src/plugins/bearer/nativewifi/platformdefs.h
new file mode 100644
index 0000000..38fbae4
--- /dev/null
+++ b/src/plugins/bearer/nativewifi/platformdefs.h
@@ -0,0 +1,322 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PLATFORMDEFS_H
+#define PLATFORMDEFS_H
+
+#include <wtypes.h>
+#undef interface
+
+#define WLAN_MAX_NAME_LENGTH 256
+#define WLAN_MAX_PHY_TYPE_NUMBER 8
+#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
+
+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;
+
+#endif // PLATFORMDEFS_H
diff --git a/src/network/bearer/qnativewifiengine_win.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
index 46d4ead..5ca49a9 100644
--- a/src/network/bearer/qnativewifiengine_win.cpp
+++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtNetwork module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,332 +39,31 @@
**
****************************************************************************/
-#include "qnativewifiengine_win_p.h"
-#include "qnetworkconfiguration_p.h"
+#include "qnativewifiengine.h"
+#include "platformdefs.h"
+
+#include <QtNetwork/private/qnetworkconfiguration_p.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/private/qmutexpool_p.h>
-#include <QtCore/qlibrary.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qdebug.h>
-#include <wtypes.h>
-#undef interface
-
QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QNativeWifiEngine, nativeWifiEngine)
-#define WLAN_MAX_NAME_LENGTH 256
-#define WLAN_MAX_PHY_TYPE_NUMBER 8
-#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
-
-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);
-
-static WlanOpenHandleProto local_WlanOpenHandle = 0;
-static WlanRegisterNotificationProto local_WlanRegisterNotification = 0;
-static WlanEnumInterfacesProto local_WlanEnumInterfaces = 0;
-static WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList = 0;
-static WlanQueryInterfaceProto local_WlanQueryInterface = 0;
-static WlanConnectProto local_WlanConnect = 0;
-static WlanDisconnectProto local_WlanDisconnect = 0;
-static WlanScanProto local_WlanScan = 0;
-static WlanFreeMemoryProto local_WlanFreeMemory = 0;
-static WlanCloseHandleProto local_WlanCloseHandle = 0;
-
-static void resolveLibrary()
-{
- static volatile bool triedResolve = false;
-
- if (!triedResolve) {
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle));
-#endif
-
- if (!triedResolve) {
- local_WlanOpenHandle = (WlanOpenHandleProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanOpenHandle");
- local_WlanRegisterNotification = (WlanRegisterNotificationProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanRegisterNotification");
- local_WlanEnumInterfaces = (WlanEnumInterfacesProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanEnumInterfaces");
- local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanGetAvailableNetworkList");
- local_WlanQueryInterface = (WlanQueryInterfaceProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanQueryInterface");
- local_WlanConnect = (WlanConnectProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanConnect");
- local_WlanDisconnect = (WlanDisconnectProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanDisconnect");
- local_WlanScan = (WlanScanProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanScan");
- local_WlanFreeMemory = (WlanFreeMemoryProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanFreeMemory");
- local_WlanCloseHandle = (WlanCloseHandleProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanCloseHandle");
-
- triedResolve = true;
- }
- }
-}
+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)
{
@@ -704,23 +403,4 @@ void QNativeWifiEngine::requestUpdate()
}
}
-QNativeWifiEngine *QNativeWifiEngine::instance()
-{
- resolveLibrary();
-
- // native wifi dll not available
- if (!local_WlanOpenHandle)
- return 0;
-
- QNativeWifiEngine *engine = nativeWifiEngine();
-
- // could not initialise subsystem
- if (engine && engine->handle == 0)
- return 0;
-
- return engine;
-}
-
-#include "moc_qnativewifiengine_win_p.cpp"
-
QT_END_NAMESPACE
diff --git a/src/network/bearer/qnativewifiengine_win_p.h b/src/plugins/bearer/nativewifi/qnativewifiengine.h
index 4817867..6686ea8 100644
--- a/src/network/bearer/qnativewifiengine_win_p.h
+++ b/src/plugins/bearer/nativewifi/qnativewifiengine.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the QtNetwork module of the Qt Toolkit.
+** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -53,7 +53,7 @@
// We mean it.
//
-#include "qnetworksessionengine_p.h"
+#include <QtNetwork/private/qnetworksessionengine_p.h>
#include <QtCore/qtimer.h>
@@ -82,7 +82,7 @@ public:
inline void emitConfigurationsChanged() { emit configurationsChanged(); }
- static QNativeWifiEngine *instance();
+ inline bool available() const { return handle != 0; }
private:
QTimer pollTimer;