diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-15 04:57:33 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-03-15 04:57:33 (GMT) |
commit | f5fa6d1955f4fc49e7bcf2bb1ef905d5927fe158 (patch) | |
tree | 2929fc2f4afcf1fca05b33dd30ddfc9b86142b96 /src/plugins/bearer/symbian/qnetworksession_impl.cpp | |
parent | 065f26ef3996368ba67ff5d8e34b20106c359a95 (diff) | |
parent | 1edf1e7c80857165c2cdc01c97658518a20bb806 (diff) | |
download | Qt-f5fa6d1955f4fc49e7bcf2bb1ef905d5927fe158.zip Qt-f5fa6d1955f4fc49e7bcf2bb1ef905d5927fe158.tar.gz Qt-f5fa6d1955f4fc49e7bcf2bb1ef905d5927fe158.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: (56 commits)
Remove NetworkManager test-bed application.
Remove configure test for NetworkManager.
Fix QDir::entryList regression
Add DEFINES to mingw32/windres.exe command line.
Fix up whitespace in license headers.
Fix SetDialogPreference build error on Symbian.
get known wifi networks a more complicated way, but without accessing
Only enable BM by default in QNAM for appropriate platforms.
fix crash on 10.6 with no wifi interface
Fix creation of QNetworkSession.
Make QNetworkConfigurationManager and QNetworkConfiguration threadsafe.
remove qt_winQString2MB() and qt_winMB2QString()
Fix include() path in qimportbase.pri
Fix qmake crash on Windows
Compile
Revert some unfinished changes.
Fix compilation with namespaced Qt
Add a placeholder text into the new search lineedit
Ui improvements to QDBusViewer.
Make double-clicking a d-bus method work again
...
Diffstat (limited to 'src/plugins/bearer/symbian/qnetworksession_impl.cpp')
-rw-r--r-- | src/plugins/bearer/symbian/qnetworksession_impl.cpp | 198 |
1 files changed, 156 insertions, 42 deletions
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index bec562d..0737942 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -100,7 +100,7 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() void QNetworkSessionPrivateImpl::syncStateWithInterface() { - if (!privateConfiguration(publicConfig)) + if (!publicConfig.isValid()) return; // Start monitoring changes in IAP states @@ -143,9 +143,8 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() // There were no open connections to used IAP or SNAP if (iError == QNetworkSession::InvalidConfigurationError) { newState(QNetworkSession::Invalid); - } - else if ((privateConfiguration(publicConfig)->state & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { + } else if ((publicConfig.state() & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { newState(QNetworkSession::Disconnected); } else { newState(QNetworkSession::NotAvailable); @@ -293,10 +292,15 @@ void QNetworkSessionPrivateImpl::open() for (TUint i=1; i<=count; i++) { // Note: GetConnectionInfo expects 1-based index. if (iConnection.GetConnectionInfo(i, connInfo) == KErrNone) { - if (connInfo().iIapId == toSymbianConfig(privateConfiguration(publicConfig))->numericId) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + QMutexLocker configLocker(&symbianConfig->mutex); + + if (connInfo().iIapId == symbianConfig->numericId) { if (iConnection.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { activeConfig = publicConfig; - activeInterface = interface(toSymbianConfig(privateConfiguration(activeConfig))->numericId); + activeInterface = interface(symbianConfig->numericId); connected = ETrue; startTime = QDateTime::currentDateTime(); if (iDynamicSetdefaultif) { @@ -320,7 +324,12 @@ void QNetworkSessionPrivateImpl::open() if (!connected) { TCommDbConnPref pref; pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); - pref.SetIapId(toSymbianConfig(privateConfiguration(publicConfig))->numericId); + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + pref.SetIapId(symbianConfig->numericId); + symbianConfig->mutex.unlock(); iConnection.Start(pref, iStatus); if (!IsActive()) { SetActive(); @@ -328,7 +337,12 @@ void QNetworkSessionPrivateImpl::open() newState(QNetworkSession::Connecting); } } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { - TConnSnapPref snapPref(toSymbianConfig(privateConfiguration(publicConfig))->numericId); + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + TConnSnapPref snapPref(symbianConfig->numericId); + symbianConfig->mutex.unlock(); iConnection.Start(snapPref, iStatus); if (!IsActive()) { SetActive(); @@ -387,7 +401,13 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) return; } - TUint activeIap = toSymbianConfig(privateConfiguration(activeConfig))->numericId; + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(activeConfig)); + + symbianConfig->mutex.lock(); + TUint activeIap = symbianConfig->numericId; + symbianConfig->mutex.unlock(); + isOpen = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); @@ -501,7 +521,13 @@ void QNetworkSessionPrivateImpl::PreferredCarrierAvailable(TAccessPointInfo aOld iALRUpgradingConnection = aIsUpgrade; QList<QNetworkConfiguration> configs = publicConfig.children(); for (int i=0; i < configs.count(); i++) { - if (toSymbianConfig(privateConfiguration(configs[i]))->numericId == aNewAPInfo.AccessPoint()) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(configs[i])); + + QMutexLocker configLocker(&symbianConfig->mutex); + + if (symbianConfig->numericId == aNewAPInfo.AccessPoint()) { + configLocker.unlock(); emit preferredConfigurationChanged(configs[i], aIsSeamless); } } @@ -625,13 +651,24 @@ quint64 QNetworkSessionPrivateImpl::transferredData(TUint dataType) const if (config.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> configs = config.children(); for (int i=0; i < configs.count(); i++) { - if (toSymbianConfig(privateConfiguration(configs[i]))->numericId == apId) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(configs[i])); + + QMutexLocker configLocker(&symbianConfig->mutex); + + if (symbianConfig->numericId == apId) { configFound = true; break; } } - } else if (toSymbianConfig(privateConfiguration(config))->numericId == apId) { - configFound = true; + } else { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(config)); + + symbianConfig->mutex.lock(); + if (symbianConfig->numericId == apId) + configFound = true; + symbianConfig->mutex.unlock(); } if (configFound) { TUint tData; @@ -668,9 +705,12 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia // Try to search IAP from the used SNAP using IAP Id QList<QNetworkConfiguration> children = publicConfig.children(); for (int i=0; i < children.count(); i++) { - if (toSymbianConfig(privateConfiguration(children[i]))->numericId == iapId) { + SymbianNetworkConfigurationPrivate *childConfig = + toSymbianConfig(privateConfiguration(children[i])); + + QMutexLocker childLocker(&childConfig->mutex); + if (childConfig->numericId == iapId) return children[i]; - } } // Given IAP Id was not found from the used SNAP @@ -682,10 +722,21 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia // <=> Note: It's possible that in this case reported IAP is // clone of the one of the IAPs of the used SNAP // => If mappingName matches, clone has been found - QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier(QString::number(qHash(iapId))); - if (privateConfiguration(pt)) { + QNetworkConfiguration pt = QNetworkConfigurationManager() + .configurationFromIdentifier(QString::number(qHash(iapId))); + + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(pt)); + if (symbianConfig) { + QMutexLocker configLocker(&symbianConfig->mutex); + for (int i=0; i < children.count(); i++) { - if (toSymbianConfig(privateConfiguration(children[i]))->mappingName == toSymbianConfig(privateConfiguration(pt))->mappingName) { + SymbianNetworkConfigurationPrivate *childConfig = + toSymbianConfig(privateConfiguration(children[i])); + + QMutexLocker childLocker(&childConfig->mutex); + + if (childConfig->mappingName == symbianConfig->mappingName) { return children[i]; } } @@ -776,13 +827,21 @@ void QNetworkSessionPrivateImpl::RunL() iMobility = CActiveCommsMobilityApiExt::NewL(iConnection, *this); } #endif + isOpen = true; activeConfig = newActiveConfig; - activeInterface = interface(toSymbianConfig(privateConfiguration(activeConfig))->numericId); + + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(activeConfig)); + + symbianConfig->mutex.lock(); + activeInterface = interface(symbianConfig->numericId); if (publicConfig.type() == QNetworkConfiguration::UserChoice) { - serviceConfig = QNetworkConfigurationManager().configurationFromIdentifier(toSymbianConfig(privateConfiguration(activeConfig))->serviceNetworkPtr->id); + serviceConfig = QNetworkConfigurationManager() + .configurationFromIdentifier(symbianConfig->serviceNetworkPtr->id); } - + symbianConfig->mutex.unlock(); + startTime = QDateTime::currentDateTime(); newState(QNetworkSession::Connected); @@ -830,7 +889,14 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (isOpen && publicConfig.type() == QNetworkConfiguration::ServiceNetwork && newState == QNetworkSession::Connected) { activeConfig = activeConfiguration(accessPointId); - activeInterface = interface(toSymbianConfig(privateConfiguration(activeConfig))->numericId); + + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(activeConfig)); + + symbianConfig->mutex.lock(); + activeInterface = interface(symbianConfig->numericId); + symbianConfig->mutex.unlock(); + #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iDynamicSetdefaultif) { // Use name of the IAP to set default IAP @@ -880,13 +946,25 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint retVal = true; } else { if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - if (toSymbianConfig(privateConfiguration(publicConfig))->numericId == accessPointId) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + QMutexLocker configLocker(&symbianConfig->mutex); + if (symbianConfig->numericId == accessPointId) { + configLocker.unlock(); + state = newState; emit stateChanged(state); retVal = true; } } else if (publicConfig.type() == QNetworkConfiguration::UserChoice && isOpen) { - if (toSymbianConfig(privateConfiguration(activeConfig))->numericId == accessPointId) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(activeConfig)); + + QMutexLocker configLocker(&symbianConfig->mutex); + if (symbianConfig->numericId == accessPointId) { + configLocker.unlock(); + state = newState; emit stateChanged(state); retVal = true; @@ -894,11 +972,17 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); for (int i = 0; i < subConfigurations.count(); i++) { - if (toSymbianConfig(privateConfiguration(subConfigurations[i]))->numericId == accessPointId) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(subConfigurations[i])); + + QMutexLocker configLocker(&symbianConfig->mutex); + + if (symbianConfig->numericId == accessPointId) { if (newState == QNetworkSession::Connected) { // Make sure that when AccessPoint is reported to be Connected // also state of the related configuration changes to Active. - privateConfiguration(subConfigurations[i])->state = QNetworkConfiguration::Active; + symbianConfig->state = QNetworkConfiguration::Active; + configLocker.unlock(); state = newState; emit stateChanged(state); @@ -907,11 +991,14 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint if (newState == QNetworkSession::Disconnected) { // Make sure that when AccessPoint is reported to be disconnected // also state of the related configuration changes from Active to Defined. - privateConfiguration(subConfigurations[i])->state = QNetworkConfiguration::Defined; + symbianConfig->state = QNetworkConfiguration::Defined; } QNetworkConfiguration config = bestConfigFromSNAP(publicConfig); if ((config.state() == QNetworkConfiguration::Defined) || (config.state() == QNetworkConfiguration::Discovered)) { + + configLocker.unlock(); + state = newState; emit stateChanged(state); retVal = true; @@ -1033,15 +1120,24 @@ void QNetworkSessionPrivateImpl::EventL(const CConnMonEventBase& aEvent) if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); for (int i = 0; i < subConfigurations.count(); i++ ) { - if (toSymbianConfig(privateConfiguration(subConfigurations[i]))->connectionId == connectionId) { - apId = toSymbianConfig(privateConfiguration(subConfigurations[i]))->numericId; + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(subConfigurations[i])); + + QMutexLocker configLocker(&symbianConfig->mutex); + + if (symbianConfig->connectionId == connectionId) { + apId = symbianConfig->numericId; break; } } } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - if (toSymbianConfig(privateConfiguration(publicConfig))->connectionId == connectionId) { - apId = toSymbianConfig(privateConfiguration(publicConfig))->numericId; - } + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + if (symbianConfig->connectionId == connectionId) + apId = symbianConfig->numericId; + symbianConfig->mutex.unlock(); } if (apId > 0) { @@ -1064,15 +1160,24 @@ void QNetworkSessionPrivateImpl::EventL(const CConnMonEventBase& aEvent) if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); for (int i = 0; i < subConfigurations.count(); i++ ) { - if (toSymbianConfig(privateConfiguration(subConfigurations[i]))->numericId == apId) { - toSymbianConfig(privateConfiguration(subConfigurations[i]))->connectionId = connectionId; + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(subConfigurations[i])); + + QMutexLocker configLocker(&symbianConfig->mutex); + + if (symbianConfig->numericId == apId) { + symbianConfig->connectionId = connectionId; break; } } } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - if (toSymbianConfig(privateConfiguration(publicConfig))->numericId == apId) { - toSymbianConfig(privateConfiguration(publicConfig))->connectionId = connectionId; - } + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + if (symbianConfig->numericId == apId) + symbianConfig->connectionId = connectionId; + symbianConfig->mutex.unlock(); } } } @@ -1087,15 +1192,24 @@ void QNetworkSessionPrivateImpl::EventL(const CConnMonEventBase& aEvent) if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); for (int i = 0; i < subConfigurations.count(); i++ ) { - if (toSymbianConfig(privateConfiguration(subConfigurations[i]))->connectionId == connectionId) { - toSymbianConfig(privateConfiguration(subConfigurations[i]))->connectionId = 0; + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(subConfigurations[i])); + + QMutexLocker configLocker(&symbianConfig->mutex); + + if (symbianConfig->connectionId == connectionId) { + symbianConfig->connectionId = 0; break; } } } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - if (toSymbianConfig(privateConfiguration(publicConfig))->connectionId == connectionId) { - toSymbianConfig(privateConfiguration(publicConfig))->connectionId = 0; - } + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + symbianConfig->mutex.lock(); + if (symbianConfig->connectionId == connectionId) + symbianConfig->connectionId = 0; + symbianConfig->mutex.unlock(); } } break; |