diff options
-rw-r--r-- | src/plugins/bearer/icd/qnetworksession_impl.cpp | 59 | ||||
-rw-r--r-- | src/plugins/bearer/icd/qnetworksession_impl.h | 8 | ||||
-rw-r--r-- | src/plugins/bearer/symbian/qnetworksession_impl.cpp | 106 | ||||
-rw-r--r-- | src/plugins/bearer/symbian/qnetworksession_impl.h | 5 | ||||
-rw-r--r-- | src/plugins/bearer/symbian/symbian_3/symbian_3.pro | 2 | ||||
-rw-r--r-- | src/plugins/bearer/symbian/symbianengine.cpp | 145 | ||||
-rw-r--r-- | src/plugins/bearer/symbian/symbianengine.h | 1 | ||||
-rw-r--r-- | tests/auto/qnetworksession/test/tst_qnetworksession.cpp | 11 | ||||
-rw-r--r-- | tests/manual/bearerex/bearerex.cpp | 3 | ||||
-rw-r--r-- | tests/manual/bearerex/bearerex.pro | 2 |
10 files changed, 220 insertions, 122 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<Maemo::IcdStatisticsResult> 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(); diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index d6b4975..1de4c0f 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -146,62 +146,65 @@ 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() { 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 // 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; - // 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 +256,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) { @@ -382,7 +386,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; @@ -412,7 +416,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. @@ -906,6 +910,14 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia if (iapId == 0) { _LIT(KSetting, "IAP\\Id"); iConnection.GetIntSetting(KSetting, iapId); +#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 + // 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 @@ -944,7 +956,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. @@ -982,7 +994,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(); } @@ -1315,7 +1327,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..aac9321 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 <comms-infras/cs_mobility_apiext.h> #endif -#ifdef OCC_FUNCTIONALITY_AVAILABLE +#if defined(OCC_FUNCTIONALITY_AVAILABLE) && defined(SNAP_FUNCTIONALITY_AVAILABLE) #include <extendedconnpref.h> #endif @@ -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/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 } diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index d1160f7..4bd6d2f 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -270,7 +270,7 @@ void SymbianEngine::updateConfigurationsL() QList<QString> knownConfigs = accessPointConfigurations.keys(); QList<QString> knownSnapConfigs = snapConfigurations.keys(); -#ifdef SNAP_FUNCTIONALITY_AVAILABLE +#ifdef SNAP_FUNCTIONALITY_AVAILABLE // S60 version is >= Series60 3rd Edition Feature Pack 2 TInt error = KErrNone; @@ -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); @@ -311,7 +314,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 +332,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(); @@ -336,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 @@ -352,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) { @@ -387,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(); @@ -395,7 +418,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)); @@ -413,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; } @@ -425,8 +450,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); @@ -468,6 +494,10 @@ void SymbianEngine::updateConfigurationsL() stopCommsDatabaseNotifications(); TRAP_IGNORE(defaultConfig = defaultConfigurationL()); startCommsDatabaseNotifications(); + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + updateStatesToSnaps(); +#endif } #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -688,15 +718,21 @@ 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); + // Change the ident correspondingly + if (ptr) { + ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(toSymbianConfig(ptr)->numericIdentifier())); + } } #endif if (ptr) { iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); - User::WaitForRequest(status); + User::WaitForRequest(status); + if (connectionStatus == KLinkLayerOpen) { online = true; inactiveConfigs.removeOne(ident); @@ -1044,7 +1080,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); @@ -1069,7 +1105,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); @@ -1161,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; @@ -1177,7 +1215,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); @@ -1198,7 +1236,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. @@ -1233,6 +1271,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 |