summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-05-20 06:48:54 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-05-20 06:48:54 (GMT)
commit94cbd9e4e90c06378c70ed49ca0f798b7129a5ea (patch)
tree30214747d6339279928bd40441bf6ad43ce7f542 /src
parent99f6250a4ac031b70757442715b226bc339ab699 (diff)
parent01aa65ecf92d5d24cd833a3583bb40ac1360c23b (diff)
downloadQt-94cbd9e4e90c06378c70ed49ca0f798b7129a5ea.zip
Qt-94cbd9e4e90c06378c70ed49ca0f798b7129a5ea.tar.gz
Qt-94cbd9e4e90c06378c70ed49ca0f798b7129a5ea.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: Docs: added an intro for qml, Quick for Beginners. Fix crash on exit in native wifi plugin on Vista+ when run in debugger.
Diffstat (limited to 'src')
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.cpp91
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.h5
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;