diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-21 00:55:47 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-05-21 00:55:47 (GMT) |
commit | 5942fcab9e3a0d2bc6d770e697518dc181f3a139 (patch) | |
tree | 8c69a29355c13274085afa82af119122eb2ef495 /src/plugins/bearer | |
parent | c12af169a157a5ba2e25289b996648a9a8e3cb9f (diff) | |
parent | af2df9e88705eeda2df5cdd46c5f7ec195facb8a (diff) | |
download | Qt-5942fcab9e3a0d2bc6d770e697518dc181f3a139.zip Qt-5942fcab9e3a0d2bc6d770e697518dc181f3a139.tar.gz Qt-5942fcab9e3a0d2bc6d770e697518dc181f3a139.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (22 commits)
Fix formating of license header.
fix irix build
clarify wording of warning message
close scope while inside assignment only if the last char is a closing brace
deprecate undocumented -E option
use qtPrepareTool for qdoc
unify QMAKE_QMAKE path separator fixing
simplify arcane conditional, once again
qdoc: Propagate the language information into the XML as before.
Removed a change from the 4.7.0 change log.
Improve look and feel of itemviews on mac
doc: Fixed many broken links.
doc: Fixed many broken links.
update 4.7.0 changes
QPushButton's click area exceeds the button area by far on Mac OS X
QApplication::closeAllWindows() should ignore windows being closed
Examples: Fix compilation with namespace.
Use QApplication::arguments() to check for command line args
Added support for .rc files on VS2010.
Doc: Updating CSS and JS
...
Diffstat (limited to 'src/plugins/bearer')
-rw-r--r-- | src/plugins/bearer/nativewifi/qnativewifiengine.cpp | 91 | ||||
-rw-r--r-- | src/plugins/bearer/nativewifi/qnativewifiengine.h | 5 |
2 files changed, 73 insertions, 23 deletions
diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp index 9b6ffa0..1a55402 100644 --- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp @@ -46,6 +46,7 @@ #include <QtNetwork/private/qnetworkconfiguration_p.h> #include <QtCore/qstringlist.h> +#include <QtCore/qcoreapplication.h> #include <QtCore/qdebug.h> @@ -79,38 +80,26 @@ void qNotificationCallback(WLAN_NOTIFICATION_DATA *data, QNativeWifiEngine *d) } QNativeWifiEngine::QNativeWifiEngine(QObject *parent) -: QBearerEngineImpl(parent), handle(0) +: QBearerEngineImpl(parent), handle(INVALID_HANDLE_VALUE) { - 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; - } - - 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 + connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(closeHandle())); } QNativeWifiEngine::~QNativeWifiEngine() { - local_WlanCloseHandle(handle, 0); + 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); @@ -249,6 +238,9 @@ 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); @@ -304,6 +296,9 @@ 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); @@ -364,6 +359,12 @@ 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) { @@ -440,6 +441,12 @@ 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()) { @@ -479,6 +486,12 @@ 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); @@ -555,6 +568,42 @@ 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. diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.h b/src/plugins/bearer/nativewifi/qnativewifiengine.h index 3b21985..0e9576b 100644 --- a/src/plugins/bearer/nativewifi/qnativewifiengine.h +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.h @@ -91,12 +91,13 @@ public: QNetworkConfigurationPrivatePointer defaultConfiguration(); - inline bool available() const { return handle != 0; } + bool available(); bool requiresPolling() const; -public Q_SLOTS: +private Q_SLOTS: void scanComplete(); + void closeHandle(); private: Qt::HANDLE handle; |