From 94a18b734a67ee59bc3ac48012c48d06d1362e8b Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Tue, 20 Sep 2011 15:53:38 +0100 Subject: symbian: Implement QNetworkConfiguration::purpose() QNetworkConfiguration::purpose() will now return translated values for the system SNAPs rather than always UnknownPurpose. e.g. the "Internet" SNAP returns PublicPurpose, and the WAP/MMS SNAPs return ServiceSpecificPurpose. IAPs inherit the purpose of the service network that contains them, unless the same IAP is present in more than one with conflicting purposes, in which case UnknownPurpose is returned. Task-Number: QTBUG-19166 Reviewed-By: mread --- src/plugins/bearer/symbian/symbianengine.cpp | 52 +++++++++++++++++++++++++++- src/plugins/bearer/symbian/symbianengine.h | 1 + 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index fdfe94a..ee80297 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -329,7 +329,27 @@ void SymbianEngine::updateConfigurationsL() cpPriv->connectionId = 0; cpPriv->state = QNetworkConfiguration::Defined; cpPriv->type = QNetworkConfiguration::ServiceNetwork; - cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + + // determine purpose of this SNAP + TUint32 purpose = CMManager::ESnapPurposeUnknown; + TRAP_IGNORE(purpose = destination.MetadataL(CMManager::ESnapMetadataPurpose)); + switch (purpose) { + case CMManager::ESnapPurposeInternet: + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + break; + case CMManager::ESnapPurposeIntranet: + cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; + break; + case CMManager::ESnapPurposeMMS: + case CMManager::ESnapPurposeOperator: + cpPriv->purpose = QNetworkConfiguration::ServiceSpecificPurpose; + break; + case CMManager::ESnapPurposeUnknown: + default: + cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + break; + } + cpPriv->roamingSupported = false; QNetworkConfigurationPrivatePointer ptr(cpPriv); @@ -482,9 +502,39 @@ void SymbianEngine::updateConfigurationsL() #ifdef SNAP_FUNCTIONALITY_AVAILABLE updateStatesToSnaps(); + updatePurposeToIaps(); #endif } +//copy purpose from SNAP to child IAPs, unless child is contained in more than one SNAP with conflicting purposes. +void SymbianEngine::updatePurposeToIaps() +{ + QMutexLocker lock(&mutex); + QHash purposes; + foreach (QNetworkConfigurationPrivatePointer snap, snapConfigurations.values()) { + QMutexLocker snaplock(&snap->mutex); + foreach (QNetworkConfigurationPrivatePointer iap, snap->serviceNetworkMembers.values()) { + QMutexLocker iaplock(&iap->mutex); + QString id = iap->id; + if (purposes.contains(id) && purposes.value(id) != snap->purpose) + purposes[id] = -1; //conflict detected + else + purposes[id] = snap->purpose; + } + } + + for (QHash::const_iterator it = purposes.constBegin(); it != purposes.constEnd(); ++it) { + if (accessPointConfigurations.contains(it.key())) { + QNetworkConfigurationPrivatePointer iap = accessPointConfigurations.value(it.key()); + QMutexLocker iaplock(&iap->mutex); + int purpose = it.value(); + if (purpose == -1) //resolve conflicts as unknown + purpose = QNetworkConfiguration::UnknownPurpose; + iap->purpose = (QNetworkConfiguration::Purpose)purpose; + } + } +} + #ifdef SNAP_FUNCTIONALITY_AVAILABLE SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( RCmConnectionMethod& connectionMethod) diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index a205c97..b75f27e 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -155,6 +155,7 @@ public Q_SLOTS: private: void updateStatesToSnaps(); + void updatePurposeToIaps(); bool changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState); bool changeConfigurationStateAtMinTo(QNetworkConfigurationPrivatePointer ptr, -- cgit v0.12