diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-23 05:31:49 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-23 05:31:49 (GMT) |
commit | 3124d14be27766ddf3c86528c913165e09317111 (patch) | |
tree | fefe8c06d483df97df528e8322366d6dceda84c5 | |
parent | 618aa624538eb0f591cfa817e1520bc8810792c7 (diff) | |
parent | 88d721fa8d28519e98207ca0249ff057faef8af0 (diff) | |
download | Qt-3124d14be27766ddf3c86528c913165e09317111.zip Qt-3124d14be27766ddf3c86528c913165e09317111.tar.gz Qt-3124d14be27766ddf3c86528c913165e09317111.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:
Show Service Network members in priority order.
Order network configurations in service networks in priority order.
-rw-r--r-- | examples/network/bearermonitor/bearermonitor.cpp | 14 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration.cpp | 19 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration_p.h | 3 | ||||
-rw-r--r-- | src/plugins/bearer/symbian/symbianengine.cpp | 83 |
4 files changed, 64 insertions, 55 deletions
diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp index 98869ea..1959919 100644 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ b/examples/network/bearermonitor/bearermonitor.cpp @@ -180,10 +180,8 @@ void BearerMonitor::configurationChanged(const QNetworkConfiguration &config) void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap) { QMap<QString, QTreeWidgetItem *> itemMap; - for (int i = 0; i < parent->childCount(); ++i) { - QTreeWidgetItem *item = parent->child(i); + foreach (QTreeWidgetItem *item, parent->takeChildren()) itemMap.insert(item->data(0, Qt::UserRole).toString(), item); - } QList<QNetworkConfiguration> allConfigurations = snap.children(); @@ -194,6 +192,8 @@ void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetw if (item) { updateItem(item, config); + parent->addChild(item); + if (config.type() == QNetworkConfiguration::ServiceNetwork) updateSnapConfiguration(item, config); } else { @@ -201,10 +201,7 @@ void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetw } } - foreach (const QString &id, itemMap.keys()) - delete itemMap.value(id); - - itemMap.clear(); + qDeleteAll(itemMap); } void BearerMonitor::updateConfigurations() @@ -239,8 +236,7 @@ void BearerMonitor::updateConfigurations() } } - foreach (const QString &id, itemMap.keys()) - delete itemMap.value(id); + qDeleteAll(itemMap); } void BearerMonitor::onlineStateChanged(bool isOnline) diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp index 4108fee..d7fceba 100644 --- a/src/network/bearer/qnetworkconfiguration.cpp +++ b/src/network/bearer/qnetworkconfiguration.cpp @@ -343,9 +343,11 @@ bool QNetworkConfiguration::isRoamingAvailable() const } /*! - Returns all sub configurations of this network configuration. - Only network configurations of type \l ServiceNetwork can have children. Otherwise - this function returns an empty list. + Returns all sub configurations of this network configuration in priority order. The first sub + configuration in the list has the highest priority. + + Only network configurations of type \l ServiceNetwork can have children. Otherwise this + function returns an empty list. */ QList<QNetworkConfiguration> QNetworkConfiguration::children() const { @@ -356,16 +358,18 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const QMutexLocker locker(&d->mutex); - QMutableListIterator<QNetworkConfigurationPrivatePointer> iter(d->serviceNetworkMembers); - while (iter.hasNext()) { - QNetworkConfigurationPrivatePointer p = iter.next(); + QMutableMapIterator<unsigned int, QNetworkConfigurationPrivatePointer> i(d->serviceNetworkMembers); + while (i.hasNext()) { + i.next(); + + QNetworkConfigurationPrivatePointer p = i.value(); //if we have an invalid member get rid of it -> was deleted earlier on { QMutexLocker childLocker(&p->mutex); if (!p->isValid) { - iter.remove(); + i.remove(); continue; } } @@ -428,6 +432,5 @@ QString QNetworkConfiguration::bearerName() const return d->bearerName(); } - QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h index 6e146e0..966dfb2 100644 --- a/src/network/bearer/qnetworkconfiguration_p.h +++ b/src/network/bearer/qnetworkconfiguration_p.h @@ -57,6 +57,7 @@ #include <QtCore/qshareddata.h> #include <QtCore/qmutex.h> +#include <QtCore/qmap.h> QT_BEGIN_NAMESPACE @@ -84,7 +85,7 @@ public: return bearer; } - QList<QNetworkConfigurationPrivatePointer> serviceNetworkMembers; + QMap<unsigned int, QNetworkConfigurationPrivatePointer> serviceNetworkMembers; mutable QMutex mutex; diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index ca444c1..d1160f7 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -341,55 +341,57 @@ void SymbianEngine::updateConfigurationsL() QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); } - QNetworkConfigurationPrivatePointer privSNAP = snapConfigurations.value(ident); - + + // Loop through all connection methods in this SNAP + QMap<unsigned int, QNetworkConfigurationPrivatePointer> connections; for (int j=0; j < destination.ConnectionMethodCount(); j++) { RCmConnectionMethod connectionMethod = destination.ConnectionMethodL(j); CleanupClosePushL(connectionMethod); - + TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); QString iface = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); // Check that IAP can be found from accessPointConfigurations list - QNetworkConfigurationPrivatePointer priv = accessPointConfigurations.value(iface); - if (!priv) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); + if (ptr) { + knownConfigs.removeOne(iface); + } else { SymbianNetworkConfigurationPrivate *cpPriv = NULL; TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); if (error == KErrNone) { - QNetworkConfigurationPrivatePointer ptr(cpPriv); + ptr = QNetworkConfigurationPrivatePointer(cpPriv); accessPointConfigurations.insert(ptr->id, ptr); mutex.unlock(); QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); - - QMutexLocker configLocker(&privSNAP->mutex); - privSNAP->serviceNetworkMembers.append(ptr); - } - } else { - knownConfigs.removeOne(iface); - // Check that IAP can be found from related SNAP's configuration list - bool iapFound = false; - QMutexLocker snapConfigLocker(&privSNAP->mutex); - for (int i = 0; i < privSNAP->serviceNetworkMembers.count(); i++) { - if (toSymbianConfig(privSNAP->serviceNetworkMembers[i])->numericIdentifier() == - iapId) { - iapFound = true; - break; - } } - if (!iapFound) - privSNAP->serviceNetworkMembers.append(priv); } - + + if (ptr) { + unsigned int priority; + TRAPD(error, priority = destination.PriorityL(connectionMethod)); + if (!error) + connections.insert(priority, ptr); + } + CleanupStack::PopAndDestroy(&connectionMethod); } - + + QNetworkConfigurationPrivatePointer privSNAP = snapConfigurations.value(ident); QMutexLocker snapConfigLocker(&privSNAP->mutex); - if (privSNAP->serviceNetworkMembers.count() > 1) { + + if (privSNAP->serviceNetworkMembers != connections) { + privSNAP->serviceNetworkMembers = connections; + // Roaming is supported only if SNAP contains more than one IAP - privSNAP->roamingSupported = true; + privSNAP->roamingSupported = privSNAP->serviceNetworkMembers.count() > 1; + + snapConfigLocker.unlock(); + mutex.unlock(); + QT_TRYCATCH_LEAVING(emit configurationChanged(privSNAP)); + mutex.lock(); } - + CleanupStack::PopAndDestroy(&destination); } CleanupStack::PopAndDestroy(&destinations); @@ -439,10 +441,13 @@ void SymbianEngine::updateConfigurationsL() QNetworkConfigurationPrivatePointer ptr2 = snapConfigurations.value(iface); // => Check if one of the IAPs of the SNAP is active QMutexLocker snapConfigLocker(&ptr2->mutex); - for (int i = 0; i < ptr2->serviceNetworkMembers.count(); ++i) { - if (toSymbianConfig(ptr2->serviceNetworkMembers[i])->numericIdentifier() == + QMutableMapIterator<unsigned int, QNetworkConfigurationPrivatePointer> i(ptr2->serviceNetworkMembers); + while (i.hasNext()) { + i.next(); + + if (toSymbianConfig(i.value())->numericIdentifier() == toSymbianConfig(ptr)->numericIdentifier()) { - ptr2->serviceNetworkMembers.removeAt(i); + i.remove(); break; } } @@ -791,15 +796,19 @@ void SymbianEngine::updateStatesToSnaps() // => Check if one of the IAPs of the SNAP is discovered or active // => If one of IAPs is active, also SNAP is active // => If one of IAPs is discovered but none of the IAPs is active, SNAP is discovered - for (int i=0; i<ptr->serviceNetworkMembers.count(); i++) { - QMutexLocker configLocker(&ptr->serviceNetworkMembers[i]->mutex); + QMapIterator<unsigned int, QNetworkConfigurationPrivatePointer> i(ptr->serviceNetworkMembers); + while (i.hasNext()) { + i.next(); + + const QNetworkConfigurationPrivatePointer child = i.value(); + + QMutexLocker configLocker(&child->mutex); - if ((ptr->serviceNetworkMembers[i]->state & QNetworkConfiguration::Active) - == QNetworkConfiguration::Active) { + if ((child->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { active = true; break; - } else if ((ptr->serviceNetworkMembers[i]->state & QNetworkConfiguration::Discovered) - == QNetworkConfiguration::Discovered) { + } else if ((child->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { discovered = true; } } |