From 34691d27d03abc0c8f940b4a0a3cda4cd308642e Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 26 Jul 2010 12:48:44 +1000 Subject: Cherry pick fix for MOBILITY-1194 from Qt Mobility. 2f582953ecfc53f217317f58e4fc75b5b51a1126 --- .../bearer/symbian/qnetworksession_impl.cpp | 74 ++++++++++------------ src/plugins/bearer/symbian/symbianengine.cpp | 66 +++++++++++++++++-- src/plugins/bearer/symbian/symbianengine.h | 1 + .../qnetworksession/test/tst_qnetworksession.cpp | 11 +++- tests/manual/bearerex/bearerex.cpp | 3 +- tests/manual/bearerex/bearerex.pro | 2 +- 6 files changed, 104 insertions(+), 53 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index d6b4975..f7a52c2 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -146,12 +146,14 @@ void QNetworkSessionPrivateImpl::configurationRemoved(QNetworkConfigurationPriva } } +// Function sets the state of the session to match the state +// of the underlying interface (the configuration this session is based on) void QNetworkSessionPrivateImpl::syncStateWithInterface() { if (!publicConfig.isValid()) return; - if (iFirstSync && publicConfig.isValid()) { + if (iFirstSync) { QObject::connect(engine, SIGNAL(configurationStateChanged(TUint32, TUint32, QNetworkSession::State)), this, SLOT(configurationStateChanged(TUint32, TUint32, QNetworkSession::State))); // Listen to configuration removals, so that in case the configuration @@ -162,46 +164,25 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() // Start listening IAP state changes from QNetworkConfigurationManagerPrivate iHandleStateNotificationsFromManager = true; - // Check open connections to see if there is already - // an open connection to selected IAP or SNAP - TUint count; - TRequestStatus status; - iConnectionMonitor.GetConnectionCount(count, status); - User::WaitForRequest(status); - if (status.Int() != KErrNone) { - return; - } - - TUint numSubConnections; - TUint connectionId; - for (TUint i = 1; i <= count; i++) { - TInt ret = iConnectionMonitor.GetConnectionInfo(i, connectionId, numSubConnections); - if (ret == KErrNone) { - TUint apId; - iConnectionMonitor.GetUintAttribute(connectionId, 0, KIAPId, apId, status); - User::WaitForRequest(status); - if (status.Int() == KErrNone) { - TInt connectionStatus; - iConnectionMonitor.GetIntAttribute(connectionId, 0, KConnectionStatus, connectionStatus, status); - User::WaitForRequest(status); - if (connectionStatus == KLinkLayerOpen) { - if (state != QNetworkSession::Closing) { - if (newState(QNetworkSession::Connected, apId)) { - return; - } - } - } - } - } - } - - if (state != QNetworkSession::Connected) { - if ((publicConfig.state() & QNetworkConfiguration::Discovered) == - QNetworkConfiguration::Discovered) { - newState(QNetworkSession::Disconnected); - } else { - newState(QNetworkSession::NotAvailable); - } + // Check what is the state of the configuration this session is based on + // and set the session in appropriate state. +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "syncStateWithInterface() state of publicConfig is: " << publicConfig.state(); +#endif + switch (publicConfig.state()) { + case QNetworkConfiguration::Active: + newState(QNetworkSession::Connected); + break; + case QNetworkConfiguration::Discovered: + newState(QNetworkSession::Disconnected); + break; + case QNetworkConfiguration::Defined: + newState(QNetworkSession::NotAvailable); + break; + case QNetworkConfiguration::Undefined: + default: + newState(QNetworkSession::Invalid); } } @@ -253,7 +234,8 @@ QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const << "currentInterface() requested, state: " << state << "publicConfig validity: " << publicConfig.isValid(); if (activeInterface.isValid()) - qDebug() << "interface is: " << activeInterface.humanReadableName(); + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "interface is: " << activeInterface.humanReadableName(); #endif if (!publicConfig.isValid() || state != QNetworkSession::Connected) { @@ -906,6 +888,14 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia if (iapId == 0) { _LIT(KSetting, "IAP\\Id"); iConnection.GetIntSetting(KSetting, iapId); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + // Check if this is an Easy WLAN configuration. On Symbian^3 RConnection may report + // the used configuration as 'EasyWLAN' IAP ID if someone has just opened the configuration + // from WLAN Scan dialog, _and_ that connection is still up. We need to find the + // real matching configuration. Function alters the Easy WLAN ID to real IAP ID (only if + // easy WLAN): + engine->easyWlanTrueIapId(iapId); +#endif } #ifdef SNAP_FUNCTIONALITY_AVAILABLE diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index d1160f7..99dc544 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -270,7 +270,7 @@ void SymbianEngine::updateConfigurationsL() QList knownConfigs = accessPointConfigurations.keys(); QList knownSnapConfigs = snapConfigurations.keys(); -#ifdef SNAP_FUNCTIONALITY_AVAILABLE +#ifdef SNAP_FUNCTIONALITY_AVAILABLE // S60 version is >= Series60 3rd Edition Feature Pack 2 TInt error = KErrNone; @@ -311,7 +311,17 @@ void SymbianEngine::updateConfigurationsL() iCmManager.AllDestinationsL(destinations); for(int i = 0; i < destinations.Count(); i++) { RCmDestination destination; - destination = iCmManager.DestinationL(destinations[i]); + + // Some destinatsions require ReadDeviceData -capability (MMS/WAP) + // The below function will leave in these cases. Don't. Proceed to + // next destination (if any). + TRAPD(error, destination = iCmManager.DestinationL(destinations[i])); + if (error == KErrPermissionDenied) { + continue; + } else { + User::LeaveIfError(error); + } + CleanupClosePushL(destination); QString ident = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX + QString::number(qHash(destination.Id())); @@ -319,12 +329,12 @@ void SymbianEngine::updateConfigurationsL() knownSnapConfigs.removeOne(ident); } else { SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; - + HBufC *pName = destination.NameLC(); QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); CleanupStack::PopAndDestroy(pName); pName = NULL; - + cpPriv->isValid = true; cpPriv->id = ident; cpPriv->numericId = destination.Id(); @@ -395,7 +405,6 @@ void SymbianEngine::updateConfigurationsL() CleanupStack::PopAndDestroy(&destination); } CleanupStack::PopAndDestroy(&destinations); - #else // S60 version is < Series60 3rd Edition Feature Pack 2 CCommsDbTableView* pDbTView = ipCommsDB->OpenTableLC(TPtrC(IAP)); @@ -425,8 +434,9 @@ void SymbianEngine::updateConfigurationsL() } CleanupStack::PopAndDestroy(pDbTView); #endif + QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); - + foreach (const QString &oldIface, knownConfigs) { //remove non existing IAP QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(oldIface); @@ -692,6 +702,11 @@ void SymbianEngine::updateActiveAccessPoints() if (!ptr) { // If IAP was not found, check if the update was about EasyWLAN ptr = configurationFromEasyWlan(apId, connectionId); + // Change the ident correspondingly + if (ptr) { + ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(toSymbianConfig(ptr)->numericIdentifier())); + } } #endif if (ptr) { @@ -1233,6 +1248,45 @@ QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUi } return QNetworkConfigurationPrivatePointer(); } + +bool SymbianEngine::easyWlanTrueIapId(TUint32& trueIapId) +{ + // Check if this is easy wlan id in the first place + if (trueIapId != iCmManager.EasyWlanIdL()) + return false; + + // Loop through all connections that connection monitor is aware + // and check for IAPs based on easy WLAN + TRequestStatus status; + TUint connectionCount; + iConnectionMonitor.GetConnectionCount(connectionCount, status); + User::WaitForRequest(status); + TUint connectionId; + TUint subConnectionCount; + TUint apId; + if (status.Int() == KErrNone) { + for (TUint i = 1; i <= connectionCount; i++) { + iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); + iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, + KIAPId, apId, status); + User::WaitForRequest(status); + if (apId == trueIapId) { + QNetworkConfigurationPrivatePointer ptr = + configurationFromEasyWlan(apId, connectionId); + if (ptr) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM easyWlanTrueIapId(), found true IAP ID: " + << toSymbianConfig(ptr)->numericIdentifier(); +#endif + trueIapId = toSymbianConfig(ptr)->numericIdentifier(); + return true; + } + } + } + } + return false; +} + #endif // Sessions may use this function to report configuration state changes, diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index cfddc29..ecd858d 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -208,6 +208,7 @@ private: QNetworkSession::State newState); #ifdef OCC_FUNCTIONALITY_AVAILABLE QNetworkConfigurationPrivatePointer configurationFromEasyWlan(TUint32 apId, TUint connectionId); + bool easyWlanTrueIapId(TUint32& trueIapId); #endif private: // Data diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index 24f6e52..3388cd5 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -88,7 +88,7 @@ private slots: void sessionStop(); void roamingErrorCodes(); - + void sessionProperties_data(); void sessionProperties(); @@ -918,6 +918,10 @@ void tst_QNetworkSession::sessionOpenCloseStop() session.waitForOpened(); #endif + // Wait until the configuration is uptodate as well, it may be signaled 'connected' + // bit later than the session + QTRY_VERIFY(configuration.state() == QNetworkConfiguration::Active); + if (session.isOpen()) QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty()); if (!errorSpy.isEmpty()) { @@ -1131,8 +1135,9 @@ void tst_QNetworkSession::sessionOpenCloseStop() roamedSuccessfully = true; } else if (state == QNetworkSession::Closing) { QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); - QTRY_VERIFY(session.state() == QNetworkSession::Connected); - roamedSuccessfully = true; + QTRY_VERIFY(session.state() == QNetworkSession::Connected || + session.state() == QNetworkSession::Disconnected); + roamedSuccessfully = false; } else if (state == QNetworkSession::Disconnected) { QTRY_VERIFY(!errorSpy.isEmpty()); QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 6f280db..2f90837 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -433,6 +433,7 @@ void SessionTab::opened() iapLineEdit->setText(config.name()+" ("+config.identifier()+")"); } } + newState(m_NetworkSession->state()); // Update the "(open)" if (m_NetworkSession->configuration().type() == QNetworkConfiguration::UserChoice) { QVariant identifier = m_NetworkSession->sessionProperty("UserChoiceConfiguration"); @@ -523,7 +524,7 @@ void SessionTab::newState(QNetworkSession::State state) QString active; if (m_NetworkSession->isOpen()) { - active = " (O)"; + active = " (open)"; } stateLineEdit->setText(stateString(state)+active); } diff --git a/tests/manual/bearerex/bearerex.pro b/tests/manual/bearerex/bearerex.pro index df39c85..397261d 100644 --- a/tests/manual/bearerex/bearerex.pro +++ b/tests/manual/bearerex/bearerex.pro @@ -25,4 +25,4 @@ SOURCES += bearerex.cpp \ xqlistwidget.cpp \ datatransferer.cpp -symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData +symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData WriteDeviceData ReadDeviceData -- cgit v0.12 From ce7ccc93275043a41648a8887525be92420c3acb Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 28 Jul 2010 11:55:28 +1000 Subject: Fix detection of OCC functionality. --- src/plugins/bearer/symbian/symbian_3/symbian_3.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/bearer/symbian/symbian_3/symbian_3.pro b/src/plugins/bearer/symbian/symbian_3/symbian_3.pro index 25f18f2..ff0f11c 100644 --- a/src/plugins/bearer/symbian/symbian_3/symbian_3.pro +++ b/src/plugins/bearer/symbian/symbian_3/symbian_3.pro @@ -6,7 +6,7 @@ symbian { DEFINES += SNAP_FUNCTIONALITY_AVAILABLE LIBS += -lcmmanager - exists($$MW_LAYER_PUBLIC_EXPORT_PATH(extendedconnpref.h)) { + exists($$prependEpocroot($$MW_LAYER_PUBLIC_EXPORT_PATH(extendedconnpref.h))) { DEFINES += OCC_FUNCTIONALITY_AVAILABLE LIBS += -lextendedconnpref } -- cgit v0.12 From 6ca74af0121f6038a20bca363deaf5c3e2d760f9 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 28 Jul 2010 10:40:05 +1000 Subject: Fix compilation error on Symbian^4. The root cause is failing compilation test for SNAP when it shouldn't, but it should still not result in compilation errors in code. --- src/plugins/bearer/symbian/qnetworksession_impl.cpp | 12 ++++++------ src/plugins/bearer/symbian/qnetworksession_impl.h | 2 +- src/plugins/bearer/symbian/symbianengine.cpp | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index f7a52c2..225161d 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -364,7 +364,7 @@ void QNetworkSessionPrivateImpl::open() SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) // With One Click Connectivity (Symbian^3 onwards) it is possible // to connect silently, without any popups. TConnPrefList pref; @@ -394,7 +394,7 @@ void QNetworkSessionPrivateImpl::open() SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) // On Symbian^3 if service network is not reachable, it triggers a UI (aka EasyWLAN) where // user can create new IAPs. To detect this, we need to store the number of IAPs // there was before connection was started. @@ -888,7 +888,7 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia if (iapId == 0) { _LIT(KSetting, "IAP\\Id"); iConnection.GetIntSetting(KSetting, iapId); -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) // Check if this is an Easy WLAN configuration. On Symbian^3 RConnection may report // the used configuration as 'EasyWLAN' IAP ID if someone has just opened the configuration // from WLAN Scan dialog, _and_ that connection is still up. We need to find the @@ -934,7 +934,7 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia } } } else { -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) // On Symbian^3 (only, not earlier or Symbian^4) if the SNAP was not reachable, it triggers // user choice type of activity (EasyWLAN). As a result, a new IAP may be created, and // hence if was not found yet. Therefore update configurations and see if there is something new. @@ -972,7 +972,7 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "configuration was not found, returning invalid."; #endif -#endif // OCC_FUNCTIONALITY_AVAILABLE +#endif // Given IAP Id was not found from known IAPs array return QNetworkConfiguration(); } @@ -1305,7 +1305,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint } } } -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) // If the retVal is not true here, it means that the status update may apply to an IAP outside of // SNAP (session is based on SNAP but follows IAP outside of it), which may occur on Symbian^3 EasyWlan. if (retVal == false && activeConfig.isValid() && diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 0754ace..73e6cab 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -64,7 +64,7 @@ #ifdef SNAP_FUNCTIONALITY_AVAILABLE #include #endif -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) #include #endif diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 99dc544..664cb6e 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -698,7 +698,7 @@ void SymbianEngine::updateActiveAccessPoints() User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) if (!ptr) { // If IAP was not found, check if the update was about EasyWLAN ptr = configurationFromEasyWlan(apId, connectionId); @@ -1059,7 +1059,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) if (!ptr) { // Check if status was regarding EasyWLAN ptr = configurationFromEasyWlan(apId, connectionId); @@ -1084,7 +1084,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) if (!ptr) { // Check for EasyWLAN ptr = configurationFromEasyWlan(apId, connectionId); @@ -1192,7 +1192,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) if (!ptr) { // If IAP was not found, check if the update was about EasyWLAN ptr = configurationFromEasyWlan(apId, connectionId); @@ -1213,7 +1213,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } } -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) // Tries to derive configuration from EasyWLAN. // First checks if the interface brought up was EasyWLAN, then derives the real SSID, // and looks up configuration based on that one. -- cgit v0.12 From a259bd2841b3ce7e34bb18990332bd497f97cdd0 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 28 Jul 2010 12:12:06 +1000 Subject: Cherry pick fix for MOBILITY-1194 from Qt Mobility. f84bb604d745c512db8d53410c5fec835309f85e --- .../bearer/symbian/qnetworksession_impl.cpp | 22 +++++++ src/plugins/bearer/symbian/qnetworksession_impl.h | 3 +- src/plugins/bearer/symbian/symbianengine.cpp | 67 ++++++++++++++-------- 3 files changed, 68 insertions(+), 24 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 225161d..1de4c0f 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -146,6 +146,23 @@ void QNetworkSessionPrivateImpl::configurationRemoved(QNetworkConfigurationPriva } } +void QNetworkSessionPrivateImpl::configurationAdded(QNetworkConfigurationPrivatePointer config) +{ + Q_UNUSED(config); + // If session is based on service network, some other app may create new access points + // to the SNAP --> synchronize session's state with that of interface's. + if (!publicConfig.isValid() || publicConfig.type() != QNetworkConfiguration::ServiceNetwork) + return; + +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "configurationAdded IAP: " + << toSymbianConfig(privateConfiguration(config))->numericIdentifier(); +#endif + + syncStateWithInterface(); +} + // Function sets the state of the session to match the state // of the underlying interface (the configuration this session is based on) void QNetworkSessionPrivateImpl::syncStateWithInterface() @@ -160,6 +177,11 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() // this session is based on is removed, session knows to enter Invalid -state. QObject::connect(engine, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + // Connect to configuration additions, so that in case a configuration is added + // in a SNAP this session is based on, the session knows to synch its state with its + // interface. + QObject::connect(engine, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); } // Start listening IAP state changes from QNetworkConfigurationManagerPrivate iHandleStateNotificationsFromManager = true; diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 73e6cab..aac9321 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -134,7 +134,8 @@ protected: // From CActive private Q_SLOTS: void configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState); void configurationRemoved(QNetworkConfigurationPrivatePointer config); - + void configurationAdded(QNetworkConfigurationPrivatePointer config); + private: TUint iapClientCount(TUint aIAPId) const; quint64 transferredData(TUint dataType) const; diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 664cb6e..f87ea3c 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -291,14 +291,17 @@ void SymbianEngine::updateConfigurationsL() if (error == KErrNone) { QNetworkConfigurationPrivatePointer ptr(cpPriv); accessPointConfigurations.insert(ptr->id, ptr); - - mutex.unlock(); - // Emit configuration added. Connected slots may throw execptions - // which propagate here --> must be converted to leaves (standard - // std::exception would cause any TRAP trapping this function to terminate - // program). - QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); - mutex.lock(); + if (!iFirstUpdate) { + // Emit configuration added. Connected slots may throw execptions + // which propagate here --> must be converted to leaves (standard + // std::exception would cause any TRAP trapping this function to terminate + // program). + QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); + updateStatesToSnaps(); + mutex.unlock(); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); + mutex.lock(); + } } } CleanupStack::PopAndDestroy(&connectionMethod); @@ -346,10 +349,13 @@ void SymbianEngine::updateConfigurationsL() QNetworkConfigurationPrivatePointer ptr(cpPriv); snapConfigurations.insert(ident, ptr); - - mutex.unlock(); - QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); - mutex.lock(); + if (!iFirstUpdate) { + QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); + updateStatesToSnaps(); + mutex.unlock(); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); + mutex.lock(); + } } // Loop through all connection methods in this SNAP @@ -362,19 +368,23 @@ void SymbianEngine::updateConfigurationsL() QString iface = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); // Check that IAP can be found from accessPointConfigurations list QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); - if (ptr) { - knownConfigs.removeOne(iface); - } else { + if (!ptr) { SymbianNetworkConfigurationPrivate *cpPriv = NULL; TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); if (error == KErrNone) { ptr = QNetworkConfigurationPrivatePointer(cpPriv); accessPointConfigurations.insert(ptr->id, ptr); - mutex.unlock(); - QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); - mutex.lock(); + if (!iFirstUpdate) { + QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); + updateStatesToSnaps(); + mutex.unlock(); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); + mutex.lock(); + } } + } else { + knownConfigs.removeOne(iface); } if (ptr) { @@ -397,6 +407,9 @@ void SymbianEngine::updateConfigurationsL() privSNAP->roamingSupported = privSNAP->serviceNetworkMembers.count() > 1; snapConfigLocker.unlock(); + + updateStatesToSnaps(); + mutex.unlock(); QT_TRYCATCH_LEAVING(emit configurationChanged(privSNAP)); mutex.lock(); @@ -422,10 +435,13 @@ void SymbianEngine::updateConfigurationsL() if (readNetworkConfigurationValuesFromCommsDb(apId, cpPriv)) { QNetworkConfigurationPrivatePointer ptr(cpPriv); accessPointConfigurations.insert(ident, ptr); - - mutex.unlock(); - QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); - mutex.lock(); + if (!iFirstUpdate) { + QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); + updateStatesToSnaps(); + mutex.unlock(); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); + mutex.lock(); + } } else { delete cpPriv; } @@ -478,6 +494,10 @@ void SymbianEngine::updateConfigurationsL() stopCommsDatabaseNotifications(); TRAP_IGNORE(defaultConfig = defaultConfigurationL()); startCommsDatabaseNotifications(); + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + updateStatesToSnaps(); +#endif } #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -711,7 +731,8 @@ void SymbianEngine::updateActiveAccessPoints() #endif if (ptr) { iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); - User::WaitForRequest(status); + User::WaitForRequest(status); + if (connectionStatus == KLinkLayerOpen) { online = true; inactiveConfigs.removeOne(ident); -- cgit v0.12 From 71ef5269c03d6230e6ebbf6f3c0b6f8836739ec3 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 28 Jul 2010 14:12:30 +1000 Subject: Cherry pick fix for QTMOBILITY-408 from Qt Mobility. 7f9a8ebcfe86d3df428707888c3ab5fcd10226a4 --- src/plugins/bearer/icd/qnetworksession_impl.cpp | 59 +++++++++++-------------- src/plugins/bearer/icd/qnetworksession_impl.h | 8 +++- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp index aeac620..e8e5183 100644 --- a/src/plugins/bearer/icd/qnetworksession_impl.cpp +++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp @@ -235,7 +235,7 @@ void QNetworkSessionPrivateImpl::updateIdentifier(const QString &newId) } -quint64 QNetworkSessionPrivateImpl::getStatistics(bool sent) const +QNetworkSessionPrivateImpl::Statistics QNetworkSessionPrivateImpl::getStatistics() const { /* This could be also implemented by using the Maemo::Icd::statistics() * that gets the statistics data for a specific IAP. Change if @@ -243,56 +243,51 @@ quint64 QNetworkSessionPrivateImpl::getStatistics(bool sent) const */ Maemo::Icd icd; QList stats_results; - quint64 counter_rx = 0, counter_tx = 0; + Statistics stats = { 0, 0, 0}; - if (!icd.statistics(stats_results)) { - return 0; - } + if (!icd.statistics(stats_results)) + return stats; foreach (const Maemo::IcdStatisticsResult &res, stats_results) { - if (res.params.network_attrs & ICD_NW_ATTR_IAPNAME) { - /* network_id is the IAP UUID */ - if (QString(res.params.network_id.data()) == activeConfig.identifier()) { - counter_tx = res.bytes_sent; - counter_rx = res.bytes_received; - } - } else { - /* We probably will never get to this branch */ - IcdNetworkConfigurationPrivate *icdConfig = - toIcdConfig(privateConfiguration(activeConfig)); + if (res.params.network_attrs & ICD_NW_ATTR_IAPNAME) { + /* network_id is the IAP UUID */ + if (QString(res.params.network_id.data()) == activeConfig.identifier()) { + stats.txData = res.bytes_sent; + stats.rxData = res.bytes_received; + stats.activeTime = res.time_active; + } + } else { + /* We probably will never get to this branch */ + IcdNetworkConfigurationPrivate *icdConfig = + toIcdConfig(privateConfiguration(activeConfig)); - icdConfig->mutex.lock(); - if (res.params.network_id == icdConfig->network_id) { - counter_tx = res.bytes_sent; - counter_rx = res.bytes_received; - } - icdConfig->mutex.unlock(); - } + icdConfig->mutex.lock(); + if (res.params.network_id == icdConfig->network_id) { + stats.txData = res.bytes_sent; + stats.rxData = res.bytes_received; + stats.activeTime = res.time_active; + } + icdConfig->mutex.unlock(); + } } - if (sent) - return counter_tx; - else - return counter_rx; + return stats; } quint64 QNetworkSessionPrivateImpl::bytesWritten() const { - return getStatistics(true); + return getStatistics().txData; } quint64 QNetworkSessionPrivateImpl::bytesReceived() const { - return getStatistics(false); + return getStatistics().rxData; } quint64 QNetworkSessionPrivateImpl::activeTime() const { - if (startTime.isNull()) { - return 0; - } - return startTime.secsTo(QDateTime::currentDateTime()); + return getStatistics().activeTime; } diff --git a/src/plugins/bearer/icd/qnetworksession_impl.h b/src/plugins/bearer/icd/qnetworksession_impl.h index c43b1f0..390e508 100644 --- a/src/plugins/bearer/icd/qnetworksession_impl.h +++ b/src/plugins/bearer/icd/qnetworksession_impl.h @@ -170,6 +170,12 @@ private: QNetworkConfigurationManager manager; QIcdEngine *engine; + struct Statistics { + quint64 txData; + quint64 rxData; + quint64 activeTime; + }; + // The config set on QNetworkSession. QNetworkConfiguration config; @@ -186,7 +192,7 @@ private: friend class IcdListener; void updateState(QNetworkSession::State); void updateIdentifier(const QString &newId); - quint64 getStatistics(bool sent) const; + Statistics getStatistics() const; void cleanupSession(void); void updateProxyInformation(); -- cgit v0.12 From 9814b2225b70d6b2f758e9dbe98f8e1662049b37 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Wed, 28 Jul 2010 14:23:16 +1000 Subject: Cherry pick fix for MOBILITY-1234 from Qt Mobility. e51af0d74f8bb6ca6100d2338671d2d053bfed01 --- src/plugins/bearer/symbian/symbianengine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index f87ea3c..4bd6d2f 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -1197,6 +1197,8 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QT_TRYCATCH_LEAVING(changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined)); } } + // Something has in IAPs, update states to SNAPs + updateStatesToSnaps(); } break; -- cgit v0.12