summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/bearer/nativewifi/qnativewifiengine.cpp')
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.cpp98
1 files changed, 72 insertions, 26 deletions
diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
index c8015d8..b6522ad 100644
--- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
+++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
@@ -83,8 +83,10 @@ QNativeWifiEngine::QNativeWifiEngine(QObject *parent)
DWORD result = local_WlanOpenHandle(1, 0, &clientVersion, &handle);
if (result != ERROR_SUCCESS) {
+#ifdef BEARER_MANAGEMENT_DEBUG
if (result != ERROR_SERVICE_NOT_ACTIVE)
- qWarning("%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result);
+ qDebug("%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result);
+#endif
return;
}
@@ -92,13 +94,11 @@ QNativeWifiEngine::QNativeWifiEngine(QObject *parent)
result = local_WlanRegisterNotification(handle, WLAN_NOTIFICATION_SOURCE_ALL, true,
WLAN_NOTIFICATION_CALLBACK(qNotificationCallback),
this, 0, 0);
+#ifdef BEARER_MANAGEMENT_DEBUG
if (result != ERROR_SUCCESS)
- qWarning("%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result);
+ qDebug("%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result);
+#endif
- // On Windows XP SP2 and SP3 only connection and disconnection notifications are available.
- // We need to poll for changes in available wireless networks.
- connect(&pollTimer, SIGNAL(timeout()), this, SLOT(scanComplete()));
- pollTimer.setInterval(10000);
scanComplete();
}
@@ -111,16 +111,22 @@ void QNativeWifiEngine::scanComplete()
{
QMutexLocker locker(&mutex);
- QStringList previous = accessPointConfigurations.keys();
-
// enumerate interfaces
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#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];
@@ -128,8 +134,10 @@ void QNativeWifiEngine::scanComplete()
result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
3, 0, &networkList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
+ __FUNCTION__, result);
+#endif
continue;
}
@@ -222,8 +230,6 @@ void QNativeWifiEngine::scanComplete()
emit configurationRemoved(ptr);
}
- pollTimer.start();
-
emit updateCompleted();
}
@@ -235,7 +241,9 @@ QString QNativeWifiEngine::getInterfaceFromId(const QString &id)
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#endif
return QString();
}
@@ -248,8 +256,10 @@ QString QNativeWifiEngine::getInterfaceFromId(const QString &id)
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)
- qWarning("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result);
+ qDebug("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result);
+#endif
continue;
}
@@ -286,7 +296,9 @@ bool QNativeWifiEngine::hasIdentifier(const QString &id)
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#endif
return false;
}
@@ -297,8 +309,10 @@ bool QNativeWifiEngine::hasIdentifier(const QString &id)
result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
3, 0, &networkList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
+ __FUNCTION__, result);
+#endif
continue;
}
@@ -341,7 +355,9 @@ void QNativeWifiEngine::connectToId(const QString &id)
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#endif
emit connectionError(id, InterfaceLookupError);
return;
}
@@ -355,8 +371,10 @@ void QNativeWifiEngine::connectToId(const QString &id)
result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
3, 0, &networkList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n",
+ __FUNCTION__, result);
+#endif
continue;
}
@@ -384,7 +402,9 @@ void QNativeWifiEngine::connectToId(const QString &id)
DWORD result = local_WlanConnect(handle, &interface.InterfaceGuid, &parameters, 0);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result);
+#endif
emit connectionError(id, ConnectError);
break;
}
@@ -423,7 +443,9 @@ void QNativeWifiEngine::disconnectFromId(const QString &id)
DWORD result = local_WlanDisconnect(handle, &guid, 0);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result);
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result);
+#endif
emit connectionError(id, DisconnectionError);
return;
}
@@ -437,17 +459,34 @@ void QNativeWifiEngine::requestUpdate()
WLAN_INTERFACE_INFO_LIST *interfaceList;
DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
+#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)
- qWarning("%s: WlanScan failed with error %ld\n", __FUNCTION__, result);
+ 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)
@@ -492,4 +531,11 @@ QNetworkConfigurationPrivatePointer QNativeWifiEngine::defaultConfiguration()
return QNetworkConfigurationPrivatePointer();
}
+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 true;
+}
+
QT_END_NAMESPACE