diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-03-08 03:04:13 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-03-11 22:27:21 (GMT) |
commit | cf69144f2b5511c6e4e81bd9da8ee6acd2340e5c (patch) | |
tree | 5df42e812b7c824486cc8ae7f333e99e5b5bd176 /src/plugins/bearer/corewlan | |
parent | 0b2190dad38cbe4c8245d500a0fc7cf6f69cc0da (diff) | |
download | Qt-cf69144f2b5511c6e4e81bd9da8ee6acd2340e5c.zip Qt-cf69144f2b5511c6e4e81bd9da8ee6acd2340e5c.tar.gz Qt-cf69144f2b5511c6e4e81bd9da8ee6acd2340e5c.tar.bz2 |
Make QNetworkConfigurationManager and QNetworkConfiguration threadsafe.
Diffstat (limited to 'src/plugins/bearer/corewlan')
-rw-r--r-- | src/plugins/bearer/corewlan/qcorewlanengine.h | 2 | ||||
-rw-r--r-- | src/plugins/bearer/corewlan/qcorewlanengine.mm | 36 |
2 files changed, 33 insertions, 5 deletions
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h index cbaa9d6..4fb9fdb 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.h +++ b/src/plugins/bearer/corewlan/qcorewlanengine.h @@ -68,7 +68,7 @@ public: void connectToId(const QString &id); void disconnectFromId(const QString &id); - void requestUpdate(); + Q_INVOKABLE void requestUpdate(); QNetworkSession::State sessionStateForId(const QString &id); diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index cb278d9..26ea84f 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -240,7 +240,9 @@ void QCoreWlanEngine::connectToId(const QString &id) bool result = [wifiInterface associateToNetwork: apNetwork parameters:[NSDictionary dictionaryWithDictionary:params] error:&err]; if(!result) { + locker.unlock(); emit connectionError(id, ConnectError); + locker.relock(); } else { [autoreleasepool release]; return; @@ -252,11 +254,15 @@ void QCoreWlanEngine::connectToId(const QString &id) index++; } + locker.unlock(); emit connectionError(id, InterfaceLookupError); + locker.relock(); #endif } else { // not wifi } + + locker.unlock(); emit connectionError(id, OperationNotSupported); [autoreleasepool release]; } @@ -272,7 +278,9 @@ void QCoreWlanEngine::disconnectFromId(const QString &id) CWInterface *wifiInterface = [CWInterface interfaceWithName: qt_mac_QStringToNSString(interfaceString)]; [wifiInterface disassociate]; if([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) { + locker.unlock(); emit connectionError(id, DisconnectionError); + locker.relock(); } [autoreleasepool release]; return; @@ -280,13 +288,13 @@ void QCoreWlanEngine::disconnectFromId(const QString &id) } else { } + + locker.unlock(); emit connectionError(id, OperationNotSupported); } void QCoreWlanEngine::requestUpdate() { - QMutexLocker locker(&mutex); - doRequestUpdate(); } @@ -340,6 +348,8 @@ void QCoreWlanEngine::doRequestUpdate() bool changed = false; + ptr->mutex.lock(); + if (!ptr->isValid) { ptr->isValid = true; changed = true; @@ -360,8 +370,13 @@ void QCoreWlanEngine::doRequestUpdate() changed = true; } - if (changed) + ptr->mutex.unlock(); + + if (changed) { + locker.unlock(); emit configurationChanged(ptr); + locker.relock(); + } } } @@ -369,9 +384,13 @@ void QCoreWlanEngine::doRequestUpdate() QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(previous.takeFirst()); configurationInterface.remove(ptr->id); + + locker.unlock(); emit configurationRemoved(ptr); + locker.relock(); } + locker.unlock(); emit updateCompleted(); } @@ -418,6 +437,8 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName) bool changed = false; + ptr->mutex.lock(); + if (!ptr->isValid) { ptr->isValid = true; changed = true; @@ -438,8 +459,13 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName) changed = true; } - if (changed) + ptr->mutex.unlock(); + + if (changed) { + locker.unlock(); emit configurationChanged(ptr); + locker.relock(); + } } else { QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); @@ -453,7 +479,9 @@ QStringList QCoreWlanEngine::scanForSsids(const QString &interfaceName) accessPointConfigurations.insert(id, ptr); configurationInterface.insert(id, interfaceName); + locker.unlock(); emit configurationAdded(ptr); + locker.relock(); } } } |