From e620ab4a391ea1c86718856b31f6a5c4928a18a7 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Tue, 12 Jan 2010 16:15:26 +1000 Subject: Partially convert Symbian backend into a plugin. QNetworkSession functionality not converted yet. --- src/network/bearer/bearer.pri | 30 +- src/network/bearer/qnetworkconfigmanager.cpp | 42 - src/network/bearer/qnetworkconfigmanager_p.cpp | 122 +-- src/network/bearer/qnetworkconfigmanager_p.h | 2 - src/network/bearer/qnetworkconfigmanager_s60_p.cpp | 974 --------------------- src/network/bearer/qnetworkconfigmanager_s60_p.h | 185 ---- src/network/bearer/qnetworkconfiguration.cpp | 4 - src/network/bearer/qnetworkconfiguration_p.h | 1 - src/network/bearer/qnetworkconfiguration_s60_p.cpp | 17 - src/network/bearer/qnetworkconfiguration_s60_p.h | 109 --- src/network/bearer/qnetworksession.cpp | 8 +- src/network/bearer/qnetworksessionengine.cpp | 6 + src/network/bearer/qnetworksessionengine_p.h | 3 + src/plugins/bearer/bearer.pro | 3 +- src/plugins/bearer/corewlan/qcorewlanengine.h | 2 + src/plugins/bearer/corewlan/qcorewlanengine.mm | 5 + src/plugins/bearer/generic/qgenericengine.cpp | 7 + src/plugins/bearer/generic/qgenericengine.h | 2 + .../bearer/nativewifi/qnativewifiengine.cpp | 6 + src/plugins/bearer/nativewifi/qnativewifiengine.h | 2 + .../networkmanager/qnetworkmanagerengine.cpp | 6 + .../bearer/networkmanager/qnetworkmanagerengine.h | 2 + src/plugins/bearer/nla/qnlaengine.cpp | 5 + src/plugins/bearer/nla/qnlaengine.h | 2 + src/plugins/bearer/symbian/main.cpp | 86 ++ src/plugins/bearer/symbian/symbian.pro | 33 + src/plugins/bearer/symbian/symbianengine.cpp | 931 ++++++++++++++++++++ src/plugins/bearer/symbian/symbianengine.h | 201 +++++ src/s60installs/s60installs.pro | 10 +- 29 files changed, 1334 insertions(+), 1472 deletions(-) delete mode 100644 src/network/bearer/qnetworkconfigmanager_s60_p.cpp delete mode 100644 src/network/bearer/qnetworkconfigmanager_s60_p.h delete mode 100644 src/network/bearer/qnetworkconfiguration_s60_p.h create mode 100644 src/plugins/bearer/symbian/main.cpp create mode 100644 src/plugins/bearer/symbian/symbian.pro create mode 100644 src/plugins/bearer/symbian/symbianengine.cpp create mode 100644 src/plugins/bearer/symbian/symbianengine.h diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri index 766e717..169c8b7 100644 --- a/src/network/bearer/bearer.pri +++ b/src/network/bearer/bearer.pri @@ -10,35 +10,11 @@ SOURCES += bearer/qnetworksession.cpp \ bearer/qnetworkconfigmanager.cpp \ bearer/qnetworkconfiguration.cpp -symbian { - exists($${EPOCROOT}epoc32/release/winscw/udeb/cmmanager.lib)| \ - exists($${EPOCROOT}epoc32/release/armv5/lib/cmmanager.lib) { - message("Building with SNAP support") - DEFINES += SNAP_FUNCTIONALITY_AVAILABLE - LIBS += -lcmmanager - } else { - message("Building without SNAP support") - LIBS += -lapengine - } - - INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE +symbian_disabled { + HEADERS += bearer/qnetworksession_s60_p.h - HEADERS += bearer/qnetworkconfigmanager_s60_p.h \ - bearer/qnetworkconfiguration_s60_p.h \ - bearer/qnetworksession_s60_p.h - SOURCES += bearer/qnetworkconfigmanager_s60_p.cpp \ - bearer/qnetworkconfiguration_s60_p.cpp \ + SOURCES += bearer/qnetworkconfiguration_s60_p.cpp \ bearer/qnetworksession_s60_p.cpp - - LIBS += -lcommdb \ - -lapsettingshandlerui \ - -lconnmon \ - -lcentralrepository \ - -lesock \ - -linsock \ - -lecom \ - -lefsrv \ - -lnetmeta } else:maemo { QT += dbus CONFIG += link_pkgconfig diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 7f58e07..f4daf4a 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -41,12 +41,8 @@ #include "qnetworkconfigmanager.h" -#ifdef Q_OS_SYMBIAN -#include "qnetworkconfigmanager_s60_p.h" -#else #include "qnetworkconfigmanager_p.h" #include "qnetworksessionengine_p.h" -#endif #include @@ -54,12 +50,10 @@ QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QNetworkConfigurationManagerPrivate, connManager); -#ifndef Q_OS_SYMBIAN QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate() { return connManager(); } -#endif /*! \class QNetworkConfigurationManager @@ -238,32 +232,6 @@ QList QNetworkConfigurationManager::allConfigurations(QNe QList result; QNetworkConfigurationManagerPrivate* conPriv = connManager(); -#ifdef Q_OS_SYMBIAN - QList cpsIdents = conPriv->accessPointConfigurations.keys(); - - //find all InternetAccessPoints - foreach (const QString &ii, cpsIdents) { - QExplicitlySharedDataPointer p = - conPriv->accessPointConfigurations.value(ii); - if ( (p->state & filter) == filter ) { - QNetworkConfiguration pt; - pt.d = conPriv->accessPointConfigurations.value(ii); - result << pt; - } - } - - //find all service networks - cpsIdents = conPriv->snapConfigurations.keys(); - foreach (const QString &ii, cpsIdents) { - QExplicitlySharedDataPointer p = - conPriv->snapConfigurations.value(ii); - if ( (p->state & filter) == filter ) { - QNetworkConfiguration pt; - pt.d = conPriv->snapConfigurations.value(ii); - result << pt; - } - } -#else foreach (QNetworkSessionEngine *engine, conPriv->sessionEngines) { QStringList cpsIdents = engine->accessPointConfigurations.keys(); @@ -290,7 +258,6 @@ QList QNetworkConfigurationManager::allConfigurations(QNe } } } -#endif return result; } @@ -307,14 +274,6 @@ QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier( QNetworkConfiguration item; -#ifdef Q_OS_SYMBIAN - if (conPriv->accessPointConfigurations.contains(identifier)) - item.d = conPriv->accessPointConfigurations.value(identifier); - else if (conPriv->snapConfigurations.contains(identifier)) - item.d = conPriv->snapConfigurations.value(identifier); - else if (conPriv->userChoiceConfigurations.contains(identifier)) - item.d = conPriv->userChoiceConfigurations.value(identifier); -#else foreach (QNetworkSessionEngine *engine, conPriv->sessionEngines) { if (engine->accessPointConfigurations.contains(identifier)) item.d = engine->accessPointConfigurations.value(identifier); @@ -327,7 +286,6 @@ QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier( return item; } -#endif return item; } diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index cb83789..c00d6d3 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -59,11 +59,6 @@ QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() delete sessionEngines.takeFirst(); } -void QNetworkConfigurationManagerPrivate::registerPlatformCapabilities() -{ - capFlags = QNetworkConfigurationManager::ForcedRoaming; -} - void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurationPrivatePointer ptr) { if (!firstUpdate) { @@ -177,106 +172,25 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() updating = false; QFactoryLoader *l = loader(); - QStringList keys = l->keys(); - - if (keys.contains(QLatin1String("corewlan"))) { - QBearerEnginePlugin *coreWlanPlugin = - qobject_cast(l->instance(QLatin1String("corewlan"))); - if (coreWlanPlugin) { - QNetworkSessionEngine *coreWifi = coreWlanPlugin->create(QLatin1String("corewlan")); - if (coreWifi) { - sessionEngines.append(coreWifi); - connect(coreWifi, SIGNAL(updateCompleted()), - this, SLOT(updateConfigurations())); - connect(coreWifi, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); - connect(coreWifi, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); - connect(coreWifi, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); - } - } - } - - if (keys.contains(QLatin1String("networkmanager"))) { - QBearerEnginePlugin *nmPlugin = - qobject_cast(l->instance(QLatin1String("networkmanager"))); - if (nmPlugin) { - QNetworkSessionEngine *nmWifi = nmPlugin->create(QLatin1String("networkmanager")); - if (nmWifi) { - sessionEngines.append(nmWifi); - connect(nmWifi, SIGNAL(updateCompleted()), - this, SLOT(updateConfigurations())); - connect(nmWifi, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); - connect(nmWifi, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); - connect(nmWifi, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); - } - } - } - - if (keys.contains(QLatin1String("generic"))) { - QBearerEnginePlugin *genericPlugin = - qobject_cast(l->instance(QLatin1String("generic"))); - if (genericPlugin) { - QNetworkSessionEngine *generic = genericPlugin->create(QLatin1String("generic")); - if (generic) { - sessionEngines.append(generic); - connect(generic, SIGNAL(updateCompleted()), - this, SLOT(updateConfigurations())); - connect(generic, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); - connect(generic, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); - connect(generic, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); - } - } - } - - if (keys.contains(QLatin1String("nla"))) { - QBearerEnginePlugin *nlaPlugin = - qobject_cast(l->instance(QLatin1String("nla"))); - if (nlaPlugin) { - QNetworkSessionEngine *nla = nlaPlugin->create(QLatin1String("nla")); - if (nla) { - sessionEngines.append(nla); - connect(nla, SIGNAL(updateCompleted()), - this, SLOT(updateConfigurations())); - connect(nla, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); - connect(nla, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); - connect(nla, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); - } - } - } - if (keys.contains(QLatin1String("nativewifi"))) { - QBearerEnginePlugin *nativeWifiPlugin = - qobject_cast(l->instance(QLatin1String("nativewifi"))); - if (nativeWifiPlugin) { - QNetworkSessionEngine *nativeWifi = - nativeWifiPlugin->create(QLatin1String("nativewifi")); - if (nativeWifi) { - sessionEngines.append(nativeWifi); - connect(nativeWifi, SIGNAL(updateCompleted()), - this, SLOT(updateConfigurations())); - connect(nativeWifi, - SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); - connect(nativeWifi, - SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); - connect(nativeWifi, - SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), - this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); - - capFlags |= QNetworkConfigurationManager::CanStartAndStopInterfaces; - } + foreach (const QString &key, l->keys()) { + QBearerEnginePlugin *plugin = qobject_cast(l->instance(key)); + if (plugin) { + QNetworkSessionEngine *engine = plugin->create(key); + if (!engine) + continue; + + sessionEngines.append(engine); + connect(engine, SIGNAL(updateCompleted()), + this, SLOT(updateConfigurations())); + connect(engine, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer))); + connect(engine, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer))); + connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)), + this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer))); + + capFlags |= engine->capabilities(); } } } diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index a45d534..d7a813b 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -67,7 +67,6 @@ public: QNetworkConfigurationManagerPrivate() : QObject(0), capFlags(0), firstUpdate(true) { - registerPlatformCapabilities(); updateConfigurations(); } @@ -76,7 +75,6 @@ public: QNetworkConfiguration defaultConfiguration(); QNetworkConfigurationManager::Capabilities capFlags; - void registerPlatformCapabilities(); void performAsyncConfigurationUpdate(); diff --git a/src/network/bearer/qnetworkconfigmanager_s60_p.cpp b/src/network/bearer/qnetworkconfigmanager_s60_p.cpp deleted file mode 100644 index b5bd4d2..0000000 --- a/src/network/bearer/qnetworkconfigmanager_s60_p.cpp +++ /dev/null @@ -1,974 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qnetworkconfigmanager_s60_p.h" - -#include -#include -#include - -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - #include - #include - #include - #include - #include - #include -#else - #include - #include - #include -#endif - -QT_BEGIN_NAMESPACE - -static const int KValueThatWillBeAddedToSNAPId = 1000; -static const int KUserChoiceIAPId = 0; - -QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate() - : QObject(0), CActive(CActive::EPriorityIdle), capFlags(0), iFirstUpdate(true), iInitOk(true) -{ - CActiveScheduler::Add(this); - - registerPlatformCapabilities(); - TRAPD(error, ipCommsDB = CCommsDatabase::NewL(EDatabaseTypeIAP)); - if (error != KErrNone) { - iInitOk = false; - return; - } - - TRAP_IGNORE(iConnectionMonitor.ConnectL()); - TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); - -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - TRAP(error, iCmManager.OpenL()); - if (error != KErrNone) { - iInitOk = false; - return; - } -#endif - - QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); - cpPriv->name = "UserChoice"; - cpPriv->bearer = QNetworkConfigurationPrivate::BearerUnknown; - cpPriv->state = QNetworkConfiguration::Discovered; - cpPriv->isValid = true; - cpPriv->id = QString::number(qHash(KUserChoiceIAPId)); - cpPriv->numericId = KUserChoiceIAPId; - cpPriv->connectionId = 0; - cpPriv->type = QNetworkConfiguration::UserChoice; - cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; - cpPriv->roamingSupported = false; - cpPriv->manager = this; - QExplicitlySharedDataPointer ptr(cpPriv); - userChoiceConfigurations.insert(cpPriv->id, ptr); - - updateConfigurations(); - updateStatesToSnaps(); - - // Start monitoring IAP and/or SNAP changes in Symbian CommsDB - startCommsDatabaseNotifications(); -} - -QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate() -{ - Cancel(); - - QList configIdents = snapConfigurations.keys(); - foreach(QString oldIface, configIdents) { - QExplicitlySharedDataPointer priv = snapConfigurations.take(oldIface); - priv->isValid = false; - priv->id.clear(); - } - - configIdents = accessPointConfigurations.keys(); - foreach(QString oldIface, configIdents) { - QExplicitlySharedDataPointer priv = accessPointConfigurations.take(oldIface); - priv->isValid = false; - priv->id.clear(); - } - - configIdents = userChoiceConfigurations.keys(); - foreach(QString oldIface, configIdents) { - QExplicitlySharedDataPointer priv = userChoiceConfigurations.take(oldIface); - priv->isValid = false; - priv->id.clear(); - priv->manager = 0; - } - - iConnectionMonitor.CancelNotifications(); - iConnectionMonitor.Close(); - -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - iCmManager.Close(); -#endif - - delete ipAccessPointsAvailabilityScanner; - delete ipCommsDB; -} - - -void QNetworkConfigurationManagerPrivate::registerPlatformCapabilities() -{ - capFlags |= QNetworkConfigurationManager::CanStartAndStopInterfaces; - capFlags |= QNetworkConfigurationManager::DirectConnectionRouting; - capFlags |= QNetworkConfigurationManager::SystemSessionSupport; -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - capFlags |= QNetworkConfigurationManager::ApplicationLevelRoaming; - capFlags |= QNetworkConfigurationManager::ForcedRoaming; -#endif - capFlags |= QNetworkConfigurationManager::DataStatistics; -} - -void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() -{ - if (!iInitOk || iUpdateGoingOn) { - return; - } - iUpdateGoingOn = true; - - stopCommsDatabaseNotifications(); - updateConfigurations(); // Synchronous call - updateAvailableAccessPoints(); // Asynchronous call -} - -void QNetworkConfigurationManagerPrivate::updateConfigurations() -{ - if (!iInitOk) { - return; - } - - TRAP_IGNORE(updateConfigurationsL()); -} - -void QNetworkConfigurationManagerPrivate::updateConfigurationsL() -{ - QList knownConfigs = accessPointConfigurations.keys(); - QList knownSnapConfigs = snapConfigurations.keys(); - -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - // S60 version is >= Series60 3rd Edition Feature Pack 2 - TInt error = KErrNone; - - // Loop through all IAPs - RArray connectionMethods; // IAPs - CleanupClosePushL(connectionMethods); - iCmManager.ConnectionMethodL(connectionMethods); - for(int i = 0; i < connectionMethods.Count(); i++) { - RCmConnectionMethod connectionMethod = iCmManager.ConnectionMethodL(connectionMethods[i]); - CleanupClosePushL(connectionMethod); - TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString ident = QString::number(qHash(iapId)); - if (accessPointConfigurations.contains(ident)) { - knownConfigs.removeOne(ident); - } else { - QNetworkConfigurationPrivate* cpPriv = NULL; - TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); - if (error == KErrNone) { - QExplicitlySharedDataPointer ptr(cpPriv); - accessPointConfigurations.insert(cpPriv->id, ptr); - if (!iFirstUpdate) { - QNetworkConfiguration item; - item.d = ptr; - emit configurationAdded(item); - } - } - } - CleanupStack::PopAndDestroy(&connectionMethod); - } - CleanupStack::PopAndDestroy(&connectionMethods); - - // Loop through all SNAPs - RArray destinations; - CleanupClosePushL(destinations); - iCmManager.AllDestinationsL(destinations); - for(int i = 0; i < destinations.Count(); i++) { - RCmDestination destination; - destination = iCmManager.DestinationL(destinations[i]); - CleanupClosePushL(destination); - QString ident = QString::number(qHash(destination.Id()+KValueThatWillBeAddedToSNAPId)); //TODO: Check if it's ok to add 1000 SNAP Id to prevent SNAP ids overlapping IAP ids - if (snapConfigurations.contains(ident)) { - knownSnapConfigs.removeOne(ident); - } else { - QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); - CleanupStack::PushL(cpPriv); - - HBufC *pName = destination.NameLC(); - cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length()); - CleanupStack::PopAndDestroy(pName); - pName = NULL; - - cpPriv->isValid = true; - cpPriv->id = ident; - cpPriv->numericId = destination.Id(); - cpPriv->connectionId = 0; - cpPriv->state = QNetworkConfiguration::Defined; - cpPriv->type = QNetworkConfiguration::ServiceNetwork; - cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; - cpPriv->roamingSupported = false; - cpPriv->manager = this; - - QExplicitlySharedDataPointer ptr(cpPriv); - snapConfigurations.insert(ident, ptr); - if (!iFirstUpdate) { - QNetworkConfiguration item; - item.d = ptr; - emit configurationAdded(item); - } - - CleanupStack::Pop(cpPriv); - } - QExplicitlySharedDataPointer privSNAP = snapConfigurations.value(ident); - - for (int j=0; j < destination.ConnectionMethodCount(); j++) { - RCmConnectionMethod connectionMethod = destination.ConnectionMethodL(j); - CleanupClosePushL(connectionMethod); - - TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString iface = QString::number(qHash(iapId)); - // Check that IAP can be found from accessPointConfigurations list - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(iface); - if (priv.data() == 0) { - QNetworkConfigurationPrivate* cpPriv = NULL; - TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); - if (error == KErrNone) { - QExplicitlySharedDataPointer ptr(cpPriv); - ptr.data()->serviceNetworkPtr = privSNAP; - accessPointConfigurations.insert(cpPriv->id, ptr); - if (!iFirstUpdate) { - QNetworkConfiguration item; - item.d = ptr; - emit configurationAdded(item); - } - privSNAP->serviceNetworkMembers.append(ptr); - } - } else { - knownConfigs.removeOne(iface); - // Check that IAP can be found from related SNAP's configuration list - bool iapFound = false; - for (int i=0; iserviceNetworkMembers.count(); i++) { - if (privSNAP->serviceNetworkMembers[i]->numericId == iapId) { - iapFound = true; - break; - } - } - if (!iapFound) { - priv.data()->serviceNetworkPtr = privSNAP; - privSNAP->serviceNetworkMembers.append(priv); - } - } - - CleanupStack::PopAndDestroy(&connectionMethod); - } - - if (privSNAP->serviceNetworkMembers.count() > 1) { - // Roaming is supported only if SNAP contains more than one IAP - privSNAP->roamingSupported = true; - } - - CleanupStack::PopAndDestroy(&destination); - } - CleanupStack::PopAndDestroy(&destinations); - -#else - // S60 version is < Series60 3rd Edition Feature Pack 2 - CCommsDbTableView* pDbTView = ipCommsDB->OpenTableLC(TPtrC(IAP)); - - // Loop through all IAPs - TUint32 apId = 0; - TInt retVal = pDbTView->GotoFirstRecord(); - while (retVal == KErrNone) { - pDbTView->ReadUintL(TPtrC(COMMDB_ID), apId); - QString ident = QString::number(qHash(apId)); - if (accessPointConfigurations.contains(ident)) { - knownConfigs.removeOne(ident); - } else { - QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); - if (readNetworkConfigurationValuesFromCommsDb(apId, cpPriv)) { - QExplicitlySharedDataPointer ptr(cpPriv); - accessPointConfigurations.insert(ident, ptr); - if (!iFirstUpdate) { - QNetworkConfiguration item; - item.d = ptr; - emit configurationAdded(item); - } - } else { - delete cpPriv; - } - } - retVal = pDbTView->GotoNextRecord(); - } - CleanupStack::PopAndDestroy(pDbTView); -#endif - updateActiveAccessPoints(); - - foreach (QString oldIface, knownConfigs) { - //remove non existing IAP - QExplicitlySharedDataPointer priv = accessPointConfigurations.take(oldIface); - priv->isValid = false; - if (!iFirstUpdate) { - QNetworkConfiguration item; - item.d = priv; - emit configurationRemoved(item); - } - // Remove non existing IAP from SNAPs - QList snapConfigIdents = snapConfigurations.keys(); - foreach (QString iface, snapConfigIdents) { - QExplicitlySharedDataPointer priv2 = snapConfigurations.value(iface); - // => Check if one of the IAPs of the SNAP is active - for (int i=0; iserviceNetworkMembers.count(); i++) { - if (priv2->serviceNetworkMembers[i]->numericId == priv->numericId) { - priv2->serviceNetworkMembers.removeAt(i); - break; - } - } - } - } - foreach (QString oldIface, knownSnapConfigs) { - //remove non existing SNAPs - QExplicitlySharedDataPointer priv = snapConfigurations.take(oldIface); - priv->isValid = false; - if (!iFirstUpdate) { - QNetworkConfiguration item; - item.d = priv; - emit configurationRemoved(item); - } - } - - iFirstUpdate = false; -} - -#ifdef SNAP_FUNCTIONALITY_AVAILABLE -QNetworkConfigurationPrivate* QNetworkConfigurationManagerPrivate::configFromConnectionMethodL( - RCmConnectionMethod& connectionMethod) -{ - QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); - CleanupStack::PushL(cpPriv); - - TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString ident = QString::number(qHash(iapId)); - - HBufC *pName = connectionMethod.GetStringAttributeL(CMManager::ECmName); - CleanupStack::PushL(pName); - cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length()); - CleanupStack::PopAndDestroy(pName); - pName = NULL; - - TUint32 bearerId = connectionMethod.GetIntAttributeL(CMManager::ECmCommsDBBearerType); - switch (bearerId) { - case KCommDbBearerCSD: - cpPriv->bearer = QNetworkConfigurationPrivate::Bearer2G; - break; - case KCommDbBearerWcdma: - cpPriv->bearer = QNetworkConfigurationPrivate::BearerWCDMA; - break; - case KCommDbBearerLAN: - cpPriv->bearer = QNetworkConfigurationPrivate::BearerEthernet; - break; - case KCommDbBearerVirtual: - cpPriv->bearer = QNetworkConfigurationPrivate::BearerUnknown; - break; - case KCommDbBearerPAN: - cpPriv->bearer = QNetworkConfigurationPrivate::BearerUnknown; - break; - case KCommDbBearerWLAN: - cpPriv->bearer = QNetworkConfigurationPrivate::BearerWLAN; - break; - default: - cpPriv->bearer = QNetworkConfigurationPrivate::BearerUnknown; - break; - } - - TInt error = KErrNone; - TUint32 bearerType = connectionMethod.GetIntAttributeL(CMManager::ECmBearerType); - switch (bearerType) { - case KUidPacketDataBearerType: - // "Packet data" Bearer => Mapping is done using "Access point name" - TRAP(error, pName = connectionMethod.GetStringAttributeL(CMManager::EPacketDataAPName)); - break; - case KUidWlanBearerType: - // "Wireless LAN" Bearer => Mapping is done using "WLAN network name" = SSID - TRAP(error, pName = connectionMethod.GetStringAttributeL(CMManager::EWlanSSID)); - break; - } - if (!pName) { - // "Data call" Bearer or "High Speed (GSM)" Bearer => Mapping is done using "Dial-up number" - TRAP(error, pName = connectionMethod.GetStringAttributeL(CMManager::EDialDefaultTelNum)); - } - - if (error == KErrNone && pName) { - CleanupStack::PushL(pName); - cpPriv->mappingName = QString::fromUtf16(pName->Ptr(),pName->Length()); - CleanupStack::PopAndDestroy(pName); - pName = NULL; - } - - cpPriv->state = QNetworkConfiguration::Defined; - TBool isConnected = connectionMethod.GetBoolAttributeL(CMManager::ECmConnected); - if (isConnected) { - cpPriv->state = QNetworkConfiguration::Active; - } - - cpPriv->isValid = true; - cpPriv->id = ident; - cpPriv->numericId = iapId; - cpPriv->connectionId = 0; - cpPriv->type = QNetworkConfiguration::InternetAccessPoint; - cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; - cpPriv->roamingSupported = false; - cpPriv->manager = this; - - CleanupStack::Pop(cpPriv); - return cpPriv; -} -#else -bool QNetworkConfigurationManagerPrivate::readNetworkConfigurationValuesFromCommsDb( - TUint32 aApId, QNetworkConfigurationPrivate* apNetworkConfiguration) -{ - TRAPD(error, readNetworkConfigurationValuesFromCommsDbL(aApId,apNetworkConfiguration)); - if (error != KErrNone) { - return false; - } - return true; -} - -void QNetworkConfigurationManagerPrivate::readNetworkConfigurationValuesFromCommsDbL( - TUint32 aApId, QNetworkConfigurationPrivate* apNetworkConfiguration) -{ - CApDataHandler* pDataHandler = CApDataHandler::NewLC(*ipCommsDB); - CApAccessPointItem* pAPItem = CApAccessPointItem::NewLC(); - TBuf name; - - CApUtils* pApUtils = CApUtils::NewLC(*ipCommsDB); - TUint32 apId = pApUtils->WapIdFromIapIdL(aApId); - - pDataHandler->AccessPointDataL(apId,*pAPItem); - pAPItem->ReadTextL(EApIapName, name); - if (name.Compare(_L("Easy WLAN")) == 0) { - // "Easy WLAN" won't be accepted to the Configurations list - User::Leave(KErrNotFound); - } - - QString ident = QString::number(qHash(aApId)); - - apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length()); - apNetworkConfiguration->isValid = true; - apNetworkConfiguration->id = ident; - apNetworkConfiguration->numericId = aApId; - apNetworkConfiguration->connectionId = 0; - apNetworkConfiguration->state = (QNetworkConfiguration::Defined); - apNetworkConfiguration->type = QNetworkConfiguration::InternetAccessPoint; - apNetworkConfiguration->purpose = QNetworkConfiguration::UnknownPurpose; - apNetworkConfiguration->roamingSupported = false; - switch (pAPItem->BearerTypeL()) { - case EApBearerTypeCSD: - apNetworkConfiguration->bearer = QNetworkConfigurationPrivate::Bearer2G; - break; - case EApBearerTypeGPRS: - apNetworkConfiguration->bearer = QNetworkConfigurationPrivate::Bearer2G; - break; - case EApBearerTypeHSCSD: - apNetworkConfiguration->bearer = QNetworkConfigurationPrivate::BearerHSPA; - break; - case EApBearerTypeCDMA: - apNetworkConfiguration->bearer = QNetworkConfigurationPrivate::BearerCDMA2000; - break; - case EApBearerTypeWLAN: - apNetworkConfiguration->bearer = QNetworkConfigurationPrivate::BearerWLAN; - break; - case EApBearerTypeLAN: - apNetworkConfiguration->bearer = QNetworkConfigurationPrivate::BearerEthernet; - break; - case EApBearerTypeLANModem: - apNetworkConfiguration->bearer = QNetworkConfigurationPrivate::BearerEthernet; - break; - default: - apNetworkConfiguration->bearer = QNetworkConfigurationPrivate::BearerUnknown; - break; - } - apNetworkConfiguration->manager = this; - - CleanupStack::PopAndDestroy(pApUtils); - CleanupStack::PopAndDestroy(pAPItem); - CleanupStack::PopAndDestroy(pDataHandler); -} -#endif - -QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() -{ - QNetworkConfiguration config; - - if (iInitOk) { - stopCommsDatabaseNotifications(); - TRAP_IGNORE(config = defaultConfigurationL()); - startCommsDatabaseNotifications(); - } - - return config; -} - -QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfigurationL() -{ - QNetworkConfiguration item; - -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - // Check Default Connection (SNAP or IAP) - TCmDefConnValue defaultConnectionValue; - iCmManager.ReadDefConnL(defaultConnectionValue); - if (defaultConnectionValue.iType == ECmDefConnDestination) { - QString iface = QString::number(qHash(defaultConnectionValue.iId+KValueThatWillBeAddedToSNAPId)); - QExplicitlySharedDataPointer priv = snapConfigurations.value(iface); - if (priv.data() != 0) { - item.d = priv; - } - } else if (defaultConnectionValue.iType == ECmDefConnConnectionMethod) { - QString iface = QString::number(qHash(defaultConnectionValue.iId)); - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(iface); - if (priv.data() != 0) { - item.d = priv; - } - } -#endif - - if (!item.isValid()) { - QString iface = QString::number(qHash(KUserChoiceIAPId)); - QExplicitlySharedDataPointer priv = userChoiceConfigurations.value(iface); - if (priv.data() != 0) { - item.d = priv; - } - } - - return item; -} - -void QNetworkConfigurationManagerPrivate::updateActiveAccessPoints() -{ - bool online = false; - QList inactiveConfigs = accessPointConfigurations.keys(); - - TRequestStatus status; - TUint connectionCount; - iConnectionMonitor.GetConnectionCount(connectionCount, status); - User::WaitForRequest(status); - - // Go through all connections and set state of related IAPs to Active - 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); - QString ident = QString::number(qHash(apId)); - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(ident); - if (priv.data()) { - online = true; - inactiveConfigs.removeOne(ident); - priv.data()->connectionId = connectionId; - // Configuration is Active - changeConfigurationStateTo(priv, QNetworkConfiguration::Active); - } - } - } - - // Make sure that state of rest of the IAPs won't be Active - foreach (QString iface, inactiveConfigs) { - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(iface); - if (priv.data()) { - // Configuration is either Defined or Discovered - changeConfigurationStateAtMaxTo(priv, QNetworkConfiguration::Discovered); - } - } - - if (iOnline != online) { - iOnline = online; - emit this->onlineStateChanged(iOnline); - } -} - -void QNetworkConfigurationManagerPrivate::updateAvailableAccessPoints() -{ - if (!ipAccessPointsAvailabilityScanner) { - ipAccessPointsAvailabilityScanner = new AccessPointsAvailabilityScanner(*this, iConnectionMonitor); - } - if (ipAccessPointsAvailabilityScanner) { - // Scanning may take a while because WLAN scanning will be done (if device supports WLAN). - ipAccessPointsAvailabilityScanner->StartScanning(); - } -} - -void QNetworkConfigurationManagerPrivate::accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo) -{ - iUpdateGoingOn = false; - if (scanSuccessful) { - QList unavailableConfigs = accessPointConfigurations.keys(); - - // Set state of returned IAPs to Discovered - // if state is not already Active - for(TUint i=0; i priv = accessPointConfigurations.value(ident); - if (priv.data()) { - unavailableConfigs.removeOne(ident); - if (priv.data()->state < QNetworkConfiguration::Active) { - // Configuration is either Discovered or Active - changeConfigurationStateAtMinTo(priv, QNetworkConfiguration::Discovered); - } - } - } - - // Make sure that state of rest of the IAPs won't be Discovered or Active - foreach (QString iface, unavailableConfigs) { - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(iface); - if (priv.data()) { - // Configuration is Defined - changeConfigurationStateAtMaxTo(priv, QNetworkConfiguration::Defined); - } - } - } - - updateStatesToSnaps(); - - startCommsDatabaseNotifications(); - - emit this->configurationUpdateComplete(); -} - -void QNetworkConfigurationManagerPrivate::updateStatesToSnaps() -{ - // Go through SNAPs and set correct state to SNAPs - QList snapConfigIdents = snapConfigurations.keys(); - foreach (QString iface, snapConfigIdents) { - bool discovered = false; - bool active = false; - QExplicitlySharedDataPointer priv = snapConfigurations.value(iface); - // => 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; iserviceNetworkMembers.count(); i++) { - QExplicitlySharedDataPointer priv2 = priv->serviceNetworkMembers[i]; - if ((priv->serviceNetworkMembers[i]->state & QNetworkConfiguration::Active) - == QNetworkConfiguration::Active) { - active = true; - break; - } else if ((priv->serviceNetworkMembers[i]->state & QNetworkConfiguration::Discovered) - == QNetworkConfiguration::Discovered) { - discovered = true; - } - } - if (active) { - changeConfigurationStateTo(priv, QNetworkConfiguration::Active); - } else if (discovered) { - changeConfigurationStateTo(priv, QNetworkConfiguration::Discovered); - } else { - changeConfigurationStateTo(priv, QNetworkConfiguration::Defined); - } - } -} - -bool QNetworkConfigurationManagerPrivate::changeConfigurationStateTo(QExplicitlySharedDataPointer& sharedData, - QNetworkConfiguration::StateFlags newState) -{ - if (newState != sharedData.data()->state) { - sharedData.data()->state = newState; - QNetworkConfiguration item; - item.d = sharedData; - if (!iFirstUpdate) { - emit configurationChanged(item); - } - return true; - } - return false; -} - -/* changeConfigurationStateAtMinTo function does not overwrite possible better - * state (e.g. Discovered state does not overwrite Active state) but - * makes sure that state is at minimum given state. -*/ -bool QNetworkConfigurationManagerPrivate::changeConfigurationStateAtMinTo(QExplicitlySharedDataPointer& sharedData, - QNetworkConfiguration::StateFlags newState) -{ - if ((newState | sharedData.data()->state) != sharedData.data()->state) { - sharedData.data()->state = (sharedData.data()->state | newState); - QNetworkConfiguration item; - item.d = sharedData; - if (!iFirstUpdate) { - emit configurationChanged(item); - } - return true; - } - return false; -} - -/* changeConfigurationStateAtMaxTo function overwrites possible better - * state (e.g. Discovered state overwrites Active state) and - * makes sure that state is at maximum given state (e.g. Discovered state - * does not overwrite Defined state). -*/ -bool QNetworkConfigurationManagerPrivate::changeConfigurationStateAtMaxTo(QExplicitlySharedDataPointer& sharedData, - QNetworkConfiguration::StateFlags newState) -{ - if ((newState & sharedData.data()->state) != sharedData.data()->state) { - sharedData.data()->state = (newState & sharedData.data()->state); - QNetworkConfiguration item; - item.d = sharedData; - if (!iFirstUpdate) { - emit configurationChanged(item); - } - return true; - } - return false; -} - -void QNetworkConfigurationManagerPrivate::startCommsDatabaseNotifications() -{ - if (!iWaitingCommsDatabaseNotifications) { - iWaitingCommsDatabaseNotifications = ETrue; - if (!IsActive()) { - SetActive(); - // Start waiting for new notification - ipCommsDB->RequestNotification(iStatus); - } - } -} - -void QNetworkConfigurationManagerPrivate::stopCommsDatabaseNotifications() -{ - if (iWaitingCommsDatabaseNotifications) { - iWaitingCommsDatabaseNotifications = EFalse; - if (!IsActive()) { - SetActive(); - // Make sure that notifier recorded events will not be returned - // as soon as the client issues the next RequestNotification() request. - ipCommsDB->RequestNotification(iStatus); - ipCommsDB->CancelRequestNotification(); - } else { - ipCommsDB->CancelRequestNotification(); - } - } -} - -void QNetworkConfigurationManagerPrivate::RunL() -{ - if (iStatus != KErrCancel) { - RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); - switch (event) { - case RDbNotifier::EUnlock: /** All read locks have been removed. */ - case RDbNotifier::ECommit: /** A transaction has been committed. */ - case RDbNotifier::ERollback: /** A transaction has been rolled back */ - case RDbNotifier::ERecover: /** The database has been recovered */ - // Note that if further database events occur while a client is handling - // a request completion, the notifier records the most significant database - // event and this is signalled as soon as the client issues the next - // RequestNotification() request. - // => Stop recording notifications - stopCommsDatabaseNotifications(); - TRAPD(error, updateConfigurationsL()); - if (error == KErrNone) { - updateStatesToSnaps(); - } - iWaitingCommsDatabaseNotifications = true; - break; - default: - // Do nothing - break; - } - } - - if (iWaitingCommsDatabaseNotifications) { - if (!IsActive()) { - SetActive(); - // Start waiting for new notification - ipCommsDB->RequestNotification(iStatus); - } - } -} - -void QNetworkConfigurationManagerPrivate::DoCancel() -{ - ipCommsDB->CancelRequestNotification(); -} - - -void QNetworkConfigurationManagerPrivate::EventL(const CConnMonEventBase& aEvent) -{ - switch (aEvent.EventType()) { - case EConnMonCreateConnection: - { - CConnMonCreateConnection* realEvent; - realEvent = (CConnMonCreateConnection*) &aEvent; - TUint subConnectionCount = 0; - TUint apId; - TUint connectionId = realEvent->ConnectionId(); - TRequestStatus status; - iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); - User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(ident); - if (priv.data()) { - priv.data()->connectionId = connectionId; - // Configuration is Active - if (changeConfigurationStateTo(priv, QNetworkConfiguration::Active)) { - updateStatesToSnaps(); - } - if (!iOnline) { - iOnline = true; - emit this->onlineStateChanged(iOnline); - } - } - } - break; - - case EConnMonDeleteConnection: - { - CConnMonDeleteConnection* realEvent; - realEvent = (CConnMonDeleteConnection*) &aEvent; - TUint connectionId = realEvent->ConnectionId(); - QExplicitlySharedDataPointer priv = dataByConnectionId(connectionId); - if (priv.data()) { - priv.data()->connectionId = 0; - // Configuration is either Defined or Discovered - if (changeConfigurationStateAtMaxTo(priv, QNetworkConfiguration::Discovered)) { - updateStatesToSnaps(); - } - } - - bool online = false; - QList iapConfigs = accessPointConfigurations.keys(); - foreach (QString iface, iapConfigs) { - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(iface); - if (priv.data()->state == QNetworkConfiguration::Active) { - online = true; - break; - } - } - if (iOnline != online) { - iOnline = online; - emit this->onlineStateChanged(iOnline); - } - } - break; - - case EConnMonIapAvailabilityChange: - { - CConnMonIapAvailabilityChange* realEvent; - realEvent = (CConnMonIapAvailabilityChange*) &aEvent; - TConnMonIapInfo iaps = realEvent->IapAvailability(); - QList unDiscoveredConfigs = accessPointConfigurations.keys(); - for ( TUint i = 0; i < iaps.Count(); i++ ) { - QString ident = QString::number(qHash(iaps.iIap[i].iIapId)); - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(ident); - if (priv.data()) { - // Configuration is either Discovered or Active - changeConfigurationStateAtMinTo(priv, QNetworkConfiguration::Discovered); - unDiscoveredConfigs.removeOne(ident); - } - } - foreach (QString iface, unDiscoveredConfigs) { - QExplicitlySharedDataPointer priv = accessPointConfigurations.value(iface); - if (priv.data()) { - // Configuration is Defined - changeConfigurationStateAtMaxTo(priv, QNetworkConfiguration::Defined); - } - } - } - break; - - default: - // For unrecognized events - break; - } -} - -QExplicitlySharedDataPointer QNetworkConfigurationManagerPrivate::dataByConnectionId(TUint aConnectionId) -{ - QNetworkConfiguration item; - - QHash >::const_iterator i = - accessPointConfigurations.constBegin(); - while (i != accessPointConfigurations.constEnd()) { - QExplicitlySharedDataPointer priv = i.value(); - if (priv.data()->connectionId == aConnectionId) { - return priv; - } - ++i; - } - - return QExplicitlySharedDataPointer(); -} - -AccessPointsAvailabilityScanner::AccessPointsAvailabilityScanner(QNetworkConfigurationManagerPrivate& owner, - RConnectionMonitor& connectionMonitor) - : CActive(CActive::EPriorityStandard), iOwner(owner), iConnectionMonitor(connectionMonitor) -{ - CActiveScheduler::Add(this); -} - -AccessPointsAvailabilityScanner::~AccessPointsAvailabilityScanner() -{ - Cancel(); -} - -void AccessPointsAvailabilityScanner::DoCancel() -{ - iConnectionMonitor.CancelAsyncRequest(EConnMonGetPckgAttribute); -} - -void AccessPointsAvailabilityScanner::StartScanning() -{ - iConnectionMonitor.GetPckgAttribute(EBearerIdAll, 0, KIapAvailability, iIapBuf, iStatus); - if (!IsActive()) { - SetActive(); - } -} - -void AccessPointsAvailabilityScanner::RunL() -{ - if (iStatus.Int() != KErrNone) { - iIapBuf().iCount = 0; - iOwner.accessPointScanningReady(false,iIapBuf()); - } else { - iOwner.accessPointScanningReady(true,iIapBuf()); - } -} -#include "moc_qnetworkconfigmanager_s60_p.cpp" -QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfigmanager_s60_p.h b/src/network/bearer/qnetworkconfigmanager_s60_p.h deleted file mode 100644 index 3378898..0000000 --- a/src/network/bearer/qnetworkconfigmanager_s60_p.h +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QNETWORKCONFIGURATIONMANAGERPRIVATE_H -#define QNETWORKCONFIGURATIONMANAGERPRIVATE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include "qnetworkconfiguration_s60_p.h" - -#include -#include -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - #include -#endif - -class CCommsDatabase; - -QT_BEGIN_NAMESPACE -class QTimer; -QT_END_NAMESPACE - -QT_BEGIN_NAMESPACE - -class QNetworkSessionPrivate; -class AccessPointsAvailabilityScanner; - -class QNetworkConfigurationManagerPrivate : public QObject, public CActive, public MConnectionMonitorObserver -{ - Q_OBJECT - -public: - QNetworkConfigurationManagerPrivate(); - virtual ~QNetworkConfigurationManagerPrivate(); - - QNetworkConfiguration defaultConfiguration(); - void performAsyncConfigurationUpdate(); - -Q_SIGNALS: - void configurationAdded(const QNetworkConfiguration& config); - void configurationRemoved(const QNetworkConfiguration& config); - void configurationUpdateComplete(); - void configurationChanged(const QNetworkConfiguration& config); - void onlineStateChanged(bool isOnline); - -public Q_SLOTS: - void updateConfigurations(); - -private: - void registerPlatformCapabilities(); - void updateStatesToSnaps(); - bool changeConfigurationStateTo(QExplicitlySharedDataPointer& sharedData, - QNetworkConfiguration::StateFlags newState); - bool changeConfigurationStateAtMinTo(QExplicitlySharedDataPointer& sharedData, - QNetworkConfiguration::StateFlags newState); - bool changeConfigurationStateAtMaxTo(QExplicitlySharedDataPointer& sharedData, - QNetworkConfiguration::StateFlags newState); -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - QNetworkConfigurationPrivate* configFromConnectionMethodL(RCmConnectionMethod& connectionMethod); -#else - bool readNetworkConfigurationValuesFromCommsDb( - TUint32 aApId, QNetworkConfigurationPrivate* apNetworkConfiguration); - void readNetworkConfigurationValuesFromCommsDbL( - TUint32 aApId, QNetworkConfigurationPrivate* apNetworkConfiguration); -#endif - - void updateConfigurationsL(); - void updateActiveAccessPoints(); - void updateAvailableAccessPoints(); - void accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo); - void startCommsDatabaseNotifications(); - void stopCommsDatabaseNotifications(); - - QNetworkConfiguration defaultConfigurationL(); - TBool GetS60PlatformVersion(TUint& aMajor, TUint& aMinor) const; - void startMonitoringIAPData(TUint32 aIapId); - QExplicitlySharedDataPointer dataByConnectionId(TUint aConnectionId); - -protected: // From CActive - void RunL(); - void DoCancel(); - -private: // MConnectionMonitorObserver - void EventL(const CConnMonEventBase& aEvent); - -public: // Data - //this table contains an up to date list of all configs at any time. - //it must be updated if configurations change, are added/removed or - //the members of ServiceNetworks change - QHash > accessPointConfigurations; - QHash > snapConfigurations; - QHash > userChoiceConfigurations; - QNetworkConfigurationManager::Capabilities capFlags; - -private: // Data - bool iFirstUpdate; - CCommsDatabase* ipCommsDB; - RConnectionMonitor iConnectionMonitor; - - TBool iWaitingCommsDatabaseNotifications; - TBool iOnline; - TBool iInitOk; - TBool iUpdateGoingOn; - - - AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner; - - friend class QNetworkSessionPrivate; - friend class AccessPointsAvailabilityScanner; - -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - RCmManager iCmManager; -#endif -}; - -class AccessPointsAvailabilityScanner : public CActive -{ -public: - AccessPointsAvailabilityScanner(QNetworkConfigurationManagerPrivate& owner, - RConnectionMonitor& connectionMonitor); - ~AccessPointsAvailabilityScanner(); - - void StartScanning(); - -protected: // From CActive - void RunL(); - void DoCancel(); - -private: // Data - QNetworkConfigurationManagerPrivate& iOwner; - RConnectionMonitor& iConnectionMonitor; - TConnMonIapInfoBuf iIapBuf; -}; - -QT_END_NAMESPACE - -#endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp index e1b2828..1585be1 100644 --- a/src/network/bearer/qnetworkconfiguration.cpp +++ b/src/network/bearer/qnetworkconfiguration.cpp @@ -41,11 +41,7 @@ #include "qnetworkconfiguration.h" -#ifdef Q_OS_SYMBIAN -#include "qnetworkconfiguration_s60_p.h" -#else #include "qnetworkconfiguration_p.h" -#endif QT_BEGIN_NAMESPACE diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h index 68d6ba4..bfc42f5 100644 --- a/src/network/bearer/qnetworkconfiguration_p.h +++ b/src/network/bearer/qnetworkconfiguration_p.h @@ -92,7 +92,6 @@ public: bool internet; QList serviceNetworkMembers; - QNetworkInterface serviceInterface; private: diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.cpp b/src/network/bearer/qnetworkconfiguration_s60_p.cpp index d01d4d9..142415a 100644 --- a/src/network/bearer/qnetworkconfiguration_s60_p.cpp +++ b/src/network/bearer/qnetworkconfiguration_s60_p.cpp @@ -39,24 +39,8 @@ ** ****************************************************************************/ -#include "qnetworkconfiguration_s60_p.h" - QT_BEGIN_NAMESPACE -QNetworkConfigurationPrivate::QNetworkConfigurationPrivate() - : isValid(false), type(QNetworkConfiguration::Invalid), - roamingSupported(false), purpose(QNetworkConfiguration::UnknownPurpose), - bearer(QNetworkConfigurationPrivate::BearerUnknown), numericId(0), - connectionId(0), manager(0) -{ -} - -QNetworkConfigurationPrivate::~QNetworkConfigurationPrivate() -{ - //release pointers to member configurations - serviceNetworkMembers.clear(); -} - QString QNetworkConfigurationPrivate::bearerName() const { switch (bearer) { @@ -72,5 +56,4 @@ QString QNetworkConfigurationPrivate::bearerName() const } } - QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.h b/src/network/bearer/qnetworkconfiguration_s60_p.h deleted file mode 100644 index 5e75c13..0000000 --- a/src/network/bearer/qnetworkconfiguration_s60_p.h +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QNETWORKCONFIGURATIONPRIVATE_H -#define QNETWORKCONFIGURATIONPRIVATE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include - -QT_BEGIN_NAMESPACE - -class QNetworkConfigurationPrivate : public QSharedData -{ -public: - enum Bearer { - BearerEthernet, - BearerWLAN, - Bearer2G, - BearerCDMA2000, - BearerWCDMA, - BearerHSPA, - BearerBluetooth, - BearerWiMAX, - BearerUnknown = -1 - }; - - QNetworkConfigurationPrivate(); - ~QNetworkConfigurationPrivate(); - - QString name; - bool isValid; - QString id; - QNetworkConfiguration::StateFlags state; - QNetworkConfiguration::Type type; - bool roamingSupported; - QNetworkConfiguration::Purpose purpose; - - QList > serviceNetworkMembers; - - QNetworkConfigurationPrivate::Bearer bearer; - QString bearerName() const; - TUint32 numericId; - TUint connectionId; - - TAny* manager; - - QString mappingName; - - QExplicitlySharedDataPointer serviceNetworkPtr; - -private: - // disallow detaching - QNetworkConfigurationPrivate &operator=(const QNetworkConfigurationPrivate &other); - QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other); -}; - -QT_END_NAMESPACE - -#endif //QNETWORKCONFIGURATIONPRIVATE_H - diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index 74b9787..5f87d95 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -44,9 +44,7 @@ #include "qnetworksession.h" -#ifdef Q_OS_SYMBIAN -#include "qnetworksession_s60_p.h" -#elif Q_WS_MAEMO_6 +#if Q_WS_MAEMO_6 #include "qnetworksession_maemo_p.h" #else #include "qnetworksession_p.h" @@ -672,7 +670,7 @@ void QNetworkSession::connectNotify(const char *signal) QObject::connectNotify(signal); //check for preferredConfigurationChanged() signal connect notification //This is not required on all platforms -#ifdef Q_OS_SYMBIAN +#ifdef Q_OS_SYMBIAN_disabled if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0) { d->setALREnabled(true); } @@ -692,7 +690,7 @@ void QNetworkSession::disconnectNotify(const char *signal) QObject::disconnectNotify(signal); //check for preferredConfigurationChanged() signal disconnect notification //This is not required on all platforms -#ifdef Q_OS_SYMBIAN +#ifdef Q_OS_SYMBIAN_disabled if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0) { d->setALREnabled(false); } diff --git a/src/network/bearer/qnetworksessionengine.cpp b/src/network/bearer/qnetworksessionengine.cpp index 0aa9d19..0744add 100644 --- a/src/network/bearer/qnetworksessionengine.cpp +++ b/src/network/bearer/qnetworksessionengine.cpp @@ -61,6 +61,12 @@ QNetworkSessionEngine::~QNetworkSessionEngine() priv->isValid = false; priv->id.clear(); } + + foreach (const QString &oldIface, userChoiceConfigurations.keys()) { + QNetworkConfigurationPrivatePointer priv = userChoiceConfigurations.take(oldIface); + priv->isValid = false; + priv->id.clear(); + } } #include "moc_qnetworksessionengine_p.cpp" diff --git a/src/network/bearer/qnetworksessionengine_p.h b/src/network/bearer/qnetworksessionengine_p.h index 202a7dc..a1a3370 100644 --- a/src/network/bearer/qnetworksessionengine_p.h +++ b/src/network/bearer/qnetworksessionengine_p.h @@ -55,6 +55,7 @@ #include "qnetworkconfiguration_p.h" #include "qnetworksession.h" +#include "qnetworkconfigmanager.h" #include #include @@ -94,6 +95,8 @@ public: virtual QNetworkSession::State sessionStateForId(const QString &id) = 0; + virtual QNetworkConfigurationManager::Capabilities capabilities() const = 0; + public: //this table contains an up to date list of all configs at any time. //it must be updated if configurations change, are added/removed or diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro index 05fce8c..ab0a816 100644 --- a/src/plugins/bearer/bearer.pro +++ b/src/plugins/bearer/bearer.pro @@ -1,9 +1,10 @@ TEMPLATE = subdirs -!symbian:!maemo { +!maemo { SUBDIRS += generic contains(QT_CONFIG, dbus):contains(QT_CONFIG, networkmanager):SUBDIRS += networkmanager win32:SUBDIRS += nla win32:!wince*:SUBDIRS += nativewifi macx:SUBDIRS += corewlan +symbian:SUBDIRS += symbian } diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h index 45a5ee9..dd07d83 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.h +++ b/src/plugins/bearer/corewlan/qcorewlanengine.h @@ -71,6 +71,8 @@ public: QNetworkSession::State sessionStateForId(const QString &id); + QNetworkConfigurationManager::Capabilities capabilities() const; + static bool getAllScInterfaces(); private Q_SLOTS: diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 2a3fecf..7ee0723 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -512,4 +512,9 @@ QNetworkSession::State QCoreWlanEngine::sessionStateForId(const QString &id) return QNetworkSession::Invalid; } +QNetworkConfigurationManager::Capabilities QCoreWlanEngine::capabilities() const +{ + return QNetworkConfigurationManager::ForcedRoaming; +} + QT_END_NAMESPACE diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 9294fad..d50aa75 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -142,6 +142,8 @@ static QString qGetInterfaceType(const QString &interface) QGenericEngine::QGenericEngine(QObject *parent) : QNetworkSessionEngine(parent) { + qDebug() << Q_FUNC_INFO; + connect(&pollTimer, SIGNAL(timeout()), this, SLOT(doRequestUpdate())); pollTimer.setInterval(10000); doRequestUpdate(); @@ -314,5 +316,10 @@ QNetworkSession::State QGenericEngine::sessionStateForId(const QString &id) return QNetworkSession::Invalid; } +QNetworkConfigurationManager::Capabilities QGenericEngine::capabilities() const +{ + return QNetworkConfigurationManager::ForcedRoaming; +} + QT_END_NAMESPACE diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h index a671ceb..730301b 100644 --- a/src/plugins/bearer/generic/qgenericengine.h +++ b/src/plugins/bearer/generic/qgenericengine.h @@ -71,6 +71,8 @@ public: QNetworkSession::State sessionStateForId(const QString &id); + QNetworkConfigurationManager::Capabilities capabilities() const; + private Q_SLOTS: void doRequestUpdate(); diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp index 0050770..82ddaf9 100644 --- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp @@ -461,4 +461,10 @@ QNetworkSession::State QNativeWifiEngine::sessionStateForId(const QString &id) return QNetworkSession::Invalid; } +QNetworkConfigurationManager::Capabilities QNativeWifiEngine::capabilities() const +{ + return QNetworkConfigurationManager::ForcedRoaming | + QNetworkConfigurationManager::CanStartAndStopInterfaces; +} + QT_END_NAMESPACE diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.h b/src/plugins/bearer/nativewifi/qnativewifiengine.h index 511a6a4..9d92562 100644 --- a/src/plugins/bearer/nativewifi/qnativewifiengine.h +++ b/src/plugins/bearer/nativewifi/qnativewifiengine.h @@ -82,6 +82,8 @@ public: QNetworkSession::State sessionStateForId(const QString &id); + QNetworkConfigurationManager::Capabilities capabilities() const; + inline bool available() const { return handle != 0; } public Q_SLOTS: diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index 20dee1f..e1fcd46 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -667,5 +667,11 @@ QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &i return QNetworkSession::Invalid; } +QNetworkConfigurationManager::Capabilities QNetworkManagerEngine::capabilities() const +{ + return QNetworkConfigurationManager::ForcedRoaming | + QNetworkConfigurationManager::CanStartAndStopInterfaces; +} + QT_END_NAMESPACE diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h index 1636c91..3752dce 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h @@ -82,6 +82,8 @@ public: QNetworkSession::State sessionStateForId(const QString &id); + QNetworkConfigurationManager::Capabilities capabilities() const; + private Q_SLOTS: void interfacePropertiesChanged(const QString &path, const QMap &properties); diff --git a/src/plugins/bearer/nla/qnlaengine.cpp b/src/plugins/bearer/nla/qnlaengine.cpp index 51897f0..d3e3fd2 100644 --- a/src/plugins/bearer/nla/qnlaengine.cpp +++ b/src/plugins/bearer/nla/qnlaengine.cpp @@ -631,6 +631,11 @@ QNetworkSession::State QNlaEngine::sessionStateForId(const QString &id) return QNetworkSession::Invalid; } +QNetworkConfigurationManager::Capabilities QNlaEngine::capabilities() const +{ + return QNetworkConfigurationManager::ForcedRoaming; +} + #include "qnlaengine.moc" QT_END_NAMESPACE diff --git a/src/plugins/bearer/nla/qnlaengine.h b/src/plugins/bearer/nla/qnlaengine.h index dd038d1..5e80db1 100644 --- a/src/plugins/bearer/nla/qnlaengine.h +++ b/src/plugins/bearer/nla/qnlaengine.h @@ -93,6 +93,8 @@ public: QNetworkSession::State sessionStateForId(const QString &id); + QNetworkConfigurationManager::Capabilities capabilities() const; + private Q_SLOTS: void networksChanged(); diff --git a/src/plugins/bearer/symbian/main.cpp b/src/plugins/bearer/symbian/main.cpp new file mode 100644 index 0000000..8865f4d --- /dev/null +++ b/src/plugins/bearer/symbian/main.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "symbianengine.h" + +#include + +#include + +QT_BEGIN_NAMESPACE + +class QSymbianEnginePlugin : public QBearerEnginePlugin +{ +public: + QSymbianEnginePlugin(); + ~QSymbianEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QSymbianEnginePlugin::QSymbianEnginePlugin() +{ +} + +QSymbianEnginePlugin::~QSymbianEnginePlugin() +{ +} + +QStringList QSymbianEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("symbian"); +} + +QBearerEngine *QSymbianEnginePlugin::create(const QString &key) const +{ + qDebug() << Q_FUNC_INFO; + + if (key == QLatin1String("symbian")) + return new SymbianEngine; + else + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QSymbianEnginePlugin) +Q_EXPORT_PLUGIN2(qsymbianbearer, QSymbianEnginePlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/bearer/symbian/symbian.pro b/src/plugins/bearer/symbian/symbian.pro new file mode 100644 index 0000000..d3ffb37 --- /dev/null +++ b/src/plugins/bearer/symbian/symbian.pro @@ -0,0 +1,33 @@ +TARGET = qsymbianbearer +include(../../qpluginbase.pri) + +QT += network + +HEADERS += symbianengine.h +SOURCES += symbianengine.cpp main.cpp + +exists($${EPOCROOT}epoc32/release/winscw/udeb/cmmanager.lib)| \ +exists($${EPOCROOT}epoc32/release/armv5/lib/cmmanager.lib) { + message("Building with SNAP support") + DEFINES += SNAP_FUNCTIONALITY_AVAILABLE + LIBS += -lcmmanager +} else { + message("Building without SNAP support") + LIBS += -lapengine +} + +INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE + +LIBS += -lcommdb \ + -lapsettingshandlerui \ + -lconnmon \ + -lcentralrepository \ + -lesock \ + -linsock \ + -lecom \ + -lefsrv \ + -lnetmeta + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp new file mode 100644 index 0000000..8c31990 --- /dev/null +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -0,0 +1,931 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "symbianengine.h" + +#include +#include +#include + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + #include + #include + #include + #include + #include + #include +#else + #include + #include + #include +#endif + +QT_BEGIN_NAMESPACE + +static const int KValueThatWillBeAddedToSNAPId = 1000; +static const int KUserChoiceIAPId = 0; + +SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() +: bearer(BearerUnknown), numericId(0), connectionId(0), manager(0) +{ +} + +SymbianNetworkConfigurationPrivate::~SymbianNetworkConfigurationPrivate() +{ +} + +inline SymbianNetworkConfigurationPrivate *toSymbianConfig(QNetworkConfigurationPrivatePointer ptr) +{ + return static_cast(ptr.data()); +} + +SymbianEngine::SymbianEngine(QObject *parent) +: QNetworkSessionEngine(parent), CActive(CActive::EPriorityIdle), iInitOk(true) +{ + qDebug() << Q_FUNC_INFO; + + CActiveScheduler::Add(this); + + TRAPD(error, ipCommsDB = CCommsDatabase::NewL(EDatabaseTypeIAP)); + if (error != KErrNone) { + iInitOk = false; + return; + } + + TRAP_IGNORE(iConnectionMonitor.ConnectL()); + TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + TRAP(error, iCmManager.OpenL()); + if (error != KErrNone) { + iInitOk = false; + return; + } +#endif + + SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; + cpPriv->name = "UserChoice"; + cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + cpPriv->state = QNetworkConfiguration::Discovered; + cpPriv->isValid = true; + cpPriv->id = QString::number(qHash(KUserChoiceIAPId)); + cpPriv->numericId = KUserChoiceIAPId; + cpPriv->connectionId = 0; + cpPriv->type = QNetworkConfiguration::UserChoice; + cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + cpPriv->roamingSupported = false; + cpPriv->manager = this; + + QNetworkConfigurationPrivatePointer ptr(cpPriv); + userChoiceConfigurations.insert(ptr->id, ptr); + + updateConfigurations(); + updateStatesToSnaps(); + + // Start monitoring IAP and/or SNAP changes in Symbian CommsDB + startCommsDatabaseNotifications(); +} + +SymbianEngine::~SymbianEngine() +{ + Cancel(); + + iConnectionMonitor.CancelNotifications(); + iConnectionMonitor.Close(); + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + iCmManager.Close(); +#endif + + delete ipAccessPointsAvailabilityScanner; + delete ipCommsDB; +} + + +QNetworkConfigurationManager::Capabilities SymbianEngine::capabilities() const +{ + QNetworkConfigurationManager::Capabilities capFlags; + + capFlags = QNetworkConfigurationManager::CanStartAndStopInterfaces | + QNetworkConfigurationManager::DirectConnectionRouting | + QNetworkConfigurationManager::SystemSessionSupport | + QNetworkConfigurationManager::DataStatistics; + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + capFlags |= QNetworkConfigurationManager::ApplicationLevelRoaming | + QNetworkConfigurationManager::ForcedRoaming; +#endif + + return capFlags; +} + +void SymbianEngine::requestUpdate() +{ + if (!iInitOk || iUpdateGoingOn) { + return; + } + iUpdateGoingOn = true; + + stopCommsDatabaseNotifications(); + updateConfigurations(); // Synchronous call + updateAvailableAccessPoints(); // Asynchronous call +} + +void SymbianEngine::updateConfigurations() +{ + if (!iInitOk) { + return; + } + + TRAP_IGNORE(updateConfigurationsL()); +} + +void SymbianEngine::updateConfigurationsL() +{ + QList knownConfigs = accessPointConfigurations.keys(); + QList knownSnapConfigs = snapConfigurations.keys(); + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + // S60 version is >= Series60 3rd Edition Feature Pack 2 + TInt error = KErrNone; + + // Loop through all IAPs + RArray connectionMethods; // IAPs + CleanupClosePushL(connectionMethods); + iCmManager.ConnectionMethodL(connectionMethods); + for(int i = 0; i < connectionMethods.Count(); i++) { + RCmConnectionMethod connectionMethod = iCmManager.ConnectionMethodL(connectionMethods[i]); + CleanupClosePushL(connectionMethod); + TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); + QString ident = QString::number(qHash(iapId)); + if (accessPointConfigurations.contains(ident)) { + knownConfigs.removeOne(ident); + } else { + SymbianNetworkConfigurationPrivate* cpPriv = NULL; + TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); + if (error == KErrNone) { + QNetworkConfigurationPrivatePointer ptr(cpPriv); + accessPointConfigurations.insert(ptr->id, ptr); + emit configurationAdded(ptr); + } + } + CleanupStack::PopAndDestroy(&connectionMethod); + } + CleanupStack::PopAndDestroy(&connectionMethods); + + // Loop through all SNAPs + RArray destinations; + CleanupClosePushL(destinations); + iCmManager.AllDestinationsL(destinations); + for(int i = 0; i < destinations.Count(); i++) { + RCmDestination destination; + destination = iCmManager.DestinationL(destinations[i]); + CleanupClosePushL(destination); + QString ident = QString::number(qHash(destination.Id()+KValueThatWillBeAddedToSNAPId)); //TODO: Check if it's ok to add 1000 SNAP Id to prevent SNAP ids overlapping IAP ids + if (snapConfigurations.contains(ident)) { + knownSnapConfigs.removeOne(ident); + } else { + SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; + CleanupStack::PushL(cpPriv); + + HBufC *pName = destination.NameLC(); + cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length()); + CleanupStack::PopAndDestroy(pName); + pName = NULL; + + cpPriv->isValid = true; + cpPriv->id = ident; + cpPriv->numericId = destination.Id(); + cpPriv->connectionId = 0; + cpPriv->state = QNetworkConfiguration::Defined; + cpPriv->type = QNetworkConfiguration::ServiceNetwork; + cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + cpPriv->roamingSupported = false; + cpPriv->manager = this; + + QNetworkConfigurationPrivatePointer ptr(cpPriv); + snapConfigurations.insert(ident, ptr); + emit configurationAdded(ptr); + + CleanupStack::Pop(cpPriv); + } + QNetworkConfigurationPrivatePointer privSNAP = snapConfigurations.value(ident); + + for (int j=0; j < destination.ConnectionMethodCount(); j++) { + RCmConnectionMethod connectionMethod = destination.ConnectionMethodL(j); + CleanupClosePushL(connectionMethod); + + TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); + QString iface = QString::number(qHash(iapId)); + // Check that IAP can be found from accessPointConfigurations list + QNetworkConfigurationPrivatePointer priv = accessPointConfigurations.value(iface); + if (!priv) { + SymbianNetworkConfigurationPrivate *cpPriv = NULL; + TRAP(error, cpPriv = configFromConnectionMethodL(connectionMethod)); + if (error == KErrNone) { + QNetworkConfigurationPrivatePointer ptr(cpPriv); + toSymbianConfig(ptr)->serviceNetworkPtr = privSNAP; + accessPointConfigurations.insert(ptr->id, ptr); + emit configurationAdded(ptr); + privSNAP->serviceNetworkMembers.append(ptr); + } + } else { + knownConfigs.removeOne(iface); + // Check that IAP can be found from related SNAP's configuration list + bool iapFound = false; + for (int i = 0; i < privSNAP->serviceNetworkMembers.count(); i++) { + if (toSymbianConfig(privSNAP->serviceNetworkMembers[i])->numericId == iapId) { + iapFound = true; + break; + } + } + if (!iapFound) { + toSymbianConfig(priv)->serviceNetworkPtr = privSNAP; + privSNAP->serviceNetworkMembers.append(priv); + } + } + + CleanupStack::PopAndDestroy(&connectionMethod); + } + + if (privSNAP->serviceNetworkMembers.count() > 1) { + // Roaming is supported only if SNAP contains more than one IAP + privSNAP->roamingSupported = true; + } + + CleanupStack::PopAndDestroy(&destination); + } + CleanupStack::PopAndDestroy(&destinations); + +#else + // S60 version is < Series60 3rd Edition Feature Pack 2 + CCommsDbTableView* pDbTView = ipCommsDB->OpenTableLC(TPtrC(IAP)); + + // Loop through all IAPs + TUint32 apId = 0; + TInt retVal = pDbTView->GotoFirstRecord(); + while (retVal == KErrNone) { + pDbTView->ReadUintL(TPtrC(COMMDB_ID), apId); + QString ident = QString::number(qHash(apId)); + if (accessPointConfigurations.contains(ident)) { + knownConfigs.removeOne(ident); + } else { + SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; + if (readNetworkConfigurationValuesFromCommsDb(apId, cpPriv)) { + QNetworkConfigurationPrivatePointer ptr(cpPriv); + accessPointConfigurations.insert(ident, ptr); + + emit configurationAdded(ptr); + } else { + delete cpPriv; + } + } + retVal = pDbTView->GotoNextRecord(); + } + CleanupStack::PopAndDestroy(pDbTView); +#endif + updateActiveAccessPoints(); + + foreach (const QString &oldIface, knownConfigs) { + //remove non existing IAP + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(oldIface); + emit configurationRemoved(ptr); + + // Remove non existing IAP from SNAPs + foreach (const QString &iface, snapConfigurations.keys()) { + QNetworkConfigurationPrivatePointer ptr2 = snapConfigurations.value(iface); + // => Check if one of the IAPs of the SNAP is active + for (int i = 0; i < ptr2->serviceNetworkMembers.count(); ++i) { + if (toSymbianConfig(ptr2->serviceNetworkMembers[i])->numericId == + toSymbianConfig(ptr)->numericId) { + ptr2->serviceNetworkMembers.removeAt(i); + break; + } + } + } + } + + foreach (const QString &oldIface, knownSnapConfigs) { + //remove non existing SNAPs + QNetworkConfigurationPrivatePointer ptr = snapConfigurations.take(oldIface); + emit configurationRemoved(ptr); + } +} + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE +SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( + RCmConnectionMethod& connectionMethod) +{ + SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; + CleanupStack::PushL(cpPriv); + + TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); + QString ident = QString::number(qHash(iapId)); + + HBufC *pName = connectionMethod.GetStringAttributeL(CMManager::ECmName); + CleanupStack::PushL(pName); + cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length()); + CleanupStack::PopAndDestroy(pName); + pName = NULL; + + TUint32 bearerId = connectionMethod.GetIntAttributeL(CMManager::ECmCommsDBBearerType); + switch (bearerId) { + case KCommDbBearerCSD: + cpPriv->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case KCommDbBearerWcdma: + cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; + break; + case KCommDbBearerLAN: + cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; + break; + case KCommDbBearerVirtual: + cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + break; + case KCommDbBearerPAN: + cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + break; + case KCommDbBearerWLAN: + cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerWLAN; + break; + default: + cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + break; + } + + TInt error = KErrNone; + TUint32 bearerType = connectionMethod.GetIntAttributeL(CMManager::ECmBearerType); + switch (bearerType) { + case KUidPacketDataBearerType: + // "Packet data" Bearer => Mapping is done using "Access point name" + TRAP(error, pName = connectionMethod.GetStringAttributeL(CMManager::EPacketDataAPName)); + break; + case KUidWlanBearerType: + // "Wireless LAN" Bearer => Mapping is done using "WLAN network name" = SSID + TRAP(error, pName = connectionMethod.GetStringAttributeL(CMManager::EWlanSSID)); + break; + } + if (!pName) { + // "Data call" Bearer or "High Speed (GSM)" Bearer => Mapping is done using "Dial-up number" + TRAP(error, pName = connectionMethod.GetStringAttributeL(CMManager::EDialDefaultTelNum)); + } + + if (error == KErrNone && pName) { + CleanupStack::PushL(pName); + cpPriv->mappingName = QString::fromUtf16(pName->Ptr(),pName->Length()); + CleanupStack::PopAndDestroy(pName); + pName = NULL; + } + + cpPriv->state = QNetworkConfiguration::Defined; + TBool isConnected = connectionMethod.GetBoolAttributeL(CMManager::ECmConnected); + if (isConnected) { + cpPriv->state = QNetworkConfiguration::Active; + } + + cpPriv->isValid = true; + cpPriv->id = ident; + cpPriv->numericId = iapId; + cpPriv->connectionId = 0; + cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; + cpPriv->roamingSupported = false; + cpPriv->manager = this; + + CleanupStack::Pop(cpPriv); + return cpPriv; +} +#else +bool SymbianEngine::readNetworkConfigurationValuesFromCommsDb( + TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration) +{ + TRAPD(error, readNetworkConfigurationValuesFromCommsDbL(aApId,apNetworkConfiguration)); + if (error != KErrNone) { + return false; + } + return true; +} + +void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( + TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration) +{ + CApDataHandler* pDataHandler = CApDataHandler::NewLC(*ipCommsDB); + CApAccessPointItem* pAPItem = CApAccessPointItem::NewLC(); + TBuf name; + + CApUtils* pApUtils = CApUtils::NewLC(*ipCommsDB); + TUint32 apId = pApUtils->WapIdFromIapIdL(aApId); + + pDataHandler->AccessPointDataL(apId,*pAPItem); + pAPItem->ReadTextL(EApIapName, name); + if (name.Compare(_L("Easy WLAN")) == 0) { + // "Easy WLAN" won't be accepted to the Configurations list + User::Leave(KErrNotFound); + } + + QString ident = QString::number(qHash(aApId)); + + apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length()); + apNetworkConfiguration->isValid = true; + apNetworkConfiguration->id = ident; + apNetworkConfiguration->numericId = aApId; + apNetworkConfiguration->connectionId = 0; + apNetworkConfiguration->state = (QNetworkConfiguration::Defined); + apNetworkConfiguration->type = QNetworkConfiguration::InternetAccessPoint; + apNetworkConfiguration->purpose = QNetworkConfiguration::UnknownPurpose; + apNetworkConfiguration->roamingSupported = false; + switch (pAPItem->BearerTypeL()) { + case EApBearerTypeCSD: + apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EApBearerTypeGPRS: + apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EApBearerTypeHSCSD: + apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + break; + case EApBearerTypeCDMA: + apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000; + break; + case EApBearerTypeWLAN: + apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerWLAN; + break; + case EApBearerTypeLAN: + apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; + break; + case EApBearerTypeLANModem: + apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet; + break; + default: + apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; + break; + } + apNetworkConfiguration->manager = this; + + CleanupStack::PopAndDestroy(pApUtils); + CleanupStack::PopAndDestroy(pAPItem); + CleanupStack::PopAndDestroy(pDataHandler); +} +#endif + +QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfiguration() +{ + QNetworkConfigurationPrivatePointer ptr; + + if (iInitOk) { + stopCommsDatabaseNotifications(); + TRAP_IGNORE(ptr = defaultConfigurationL()); + startCommsDatabaseNotifications(); + } + + return ptr; +} + +QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL() +{ + QNetworkConfigurationPrivatePointer ptr; + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + // Check Default Connection (SNAP or IAP) + TCmDefConnValue defaultConnectionValue; + iCmManager.ReadDefConnL(defaultConnectionValue); + if (defaultConnectionValue.iType == ECmDefConnDestination) { + QString iface = QString::number(qHash(defaultConnectionValue.iId+KValueThatWillBeAddedToSNAPId)); + ptr = snapConfigurations.value(iface); + } else if (defaultConnectionValue.iType == ECmDefConnConnectionMethod) { + QString iface = QString::number(qHash(defaultConnectionValue.iId)); + ptr = accessPointConfigurations.value(iface); + } +#endif + + if (!ptr->isValid) { + QString iface = QString::number(qHash(KUserChoiceIAPId)); + ptr = userChoiceConfigurations.value(iface); + } + + return ptr; +} + +void SymbianEngine::updateActiveAccessPoints() +{ + bool online = false; + QList inactiveConfigs = accessPointConfigurations.keys(); + + TRequestStatus status; + TUint connectionCount; + iConnectionMonitor.GetConnectionCount(connectionCount, status); + User::WaitForRequest(status); + + // Go through all connections and set state of related IAPs to Active + 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); + QString ident = QString::number(qHash(apId)); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + online = true; + inactiveConfigs.removeOne(ident); + + toSymbianConfig(ptr)->connectionId = connectionId; + + // Configuration is Active + changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); + } + } + } + + // Make sure that state of rest of the IAPs won't be Active + foreach (const QString &iface, inactiveConfigs) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); + if (ptr) { + // Configuration is either Defined or Discovered + changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered); + } + } + + if (iOnline != online) { + iOnline = online; + emit this->onlineStateChanged(iOnline); + } +} + +void SymbianEngine::updateAvailableAccessPoints() +{ + if (!ipAccessPointsAvailabilityScanner) { + ipAccessPointsAvailabilityScanner = new AccessPointsAvailabilityScanner(*this, iConnectionMonitor); + } + if (ipAccessPointsAvailabilityScanner) { + // Scanning may take a while because WLAN scanning will be done (if device supports WLAN). + ipAccessPointsAvailabilityScanner->StartScanning(); + } +} + +void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo) +{ + iUpdateGoingOn = false; + if (scanSuccessful) { + QList unavailableConfigs = accessPointConfigurations.keys(); + + // Set state of returned IAPs to Discovered + // if state is not already Active + for(TUint i=0; istate < QNetworkConfiguration::Active) { + // Configuration is either Discovered or Active + changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered); + } + } + } + + // Make sure that state of rest of the IAPs won't be Discovered or Active + foreach (const QString &iface, unavailableConfigs) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); + if (ptr) { + // Configuration is Defined + changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined); + } + } + } + + updateStatesToSnaps(); + + startCommsDatabaseNotifications(); + + qDebug() << Q_FUNC_INFO << "updateCompleted()"; + emit updateCompleted(); +} + +void SymbianEngine::updateStatesToSnaps() +{ + // Go through SNAPs and set correct state to SNAPs + QList snapConfigIdents = snapConfigurations.keys(); + foreach (QString iface, snapConfigIdents) { + bool discovered = false; + bool active = false; + QNetworkConfigurationPrivatePointer ptr = snapConfigurations.value(iface); + // => 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; iserviceNetworkMembers.count(); i++) { + if ((ptr->serviceNetworkMembers[i]->state & QNetworkConfiguration::Active) + == QNetworkConfiguration::Active) { + active = true; + break; + } else if ((ptr->serviceNetworkMembers[i]->state & QNetworkConfiguration::Discovered) + == QNetworkConfiguration::Discovered) { + discovered = true; + } + } + if (active) { + changeConfigurationStateTo(ptr, QNetworkConfiguration::Active); + } else if (discovered) { + changeConfigurationStateTo(ptr, QNetworkConfiguration::Discovered); + } else { + changeConfigurationStateTo(ptr, QNetworkConfiguration::Defined); + } + } +} + +bool SymbianEngine::changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr, + QNetworkConfiguration::StateFlags newState) +{ + if (newState != ptr->state) { + ptr->state = newState; + emit configurationChanged(ptr); + return true; + } + return false; +} + +/* changeConfigurationStateAtMinTo function does not overwrite possible better + * state (e.g. Discovered state does not overwrite Active state) but + * makes sure that state is at minimum given state. +*/ +bool SymbianEngine::changeConfigurationStateAtMinTo(QNetworkConfigurationPrivatePointer ptr, + QNetworkConfiguration::StateFlags newState) +{ + if ((newState | ptr->state) != ptr->state) { + ptr->state = (ptr->state | newState); + emit configurationChanged(ptr); + return true; + } + return false; +} + +/* changeConfigurationStateAtMaxTo function overwrites possible better + * state (e.g. Discovered state overwrites Active state) and + * makes sure that state is at maximum given state (e.g. Discovered state + * does not overwrite Defined state). +*/ +bool SymbianEngine::changeConfigurationStateAtMaxTo(QNetworkConfigurationPrivatePointer ptr, + QNetworkConfiguration::StateFlags newState) +{ + if ((newState & ptr->state) != ptr->state) { + ptr->state = (newState & ptr->state); + emit configurationChanged(ptr); + return true; + } + return false; +} + +void SymbianEngine::startCommsDatabaseNotifications() +{ + if (!iWaitingCommsDatabaseNotifications) { + iWaitingCommsDatabaseNotifications = ETrue; + if (!IsActive()) { + SetActive(); + // Start waiting for new notification + ipCommsDB->RequestNotification(iStatus); + } + } +} + +void SymbianEngine::stopCommsDatabaseNotifications() +{ + if (iWaitingCommsDatabaseNotifications) { + iWaitingCommsDatabaseNotifications = EFalse; + if (!IsActive()) { + SetActive(); + // Make sure that notifier recorded events will not be returned + // as soon as the client issues the next RequestNotification() request. + ipCommsDB->RequestNotification(iStatus); + ipCommsDB->CancelRequestNotification(); + } else { + ipCommsDB->CancelRequestNotification(); + } + } +} + +void SymbianEngine::RunL() +{ + if (iStatus != KErrCancel) { + RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); + switch (event) { + case RDbNotifier::EUnlock: /** All read locks have been removed. */ + case RDbNotifier::ECommit: /** A transaction has been committed. */ + case RDbNotifier::ERollback: /** A transaction has been rolled back */ + case RDbNotifier::ERecover: /** The database has been recovered */ + // Note that if further database events occur while a client is handling + // a request completion, the notifier records the most significant database + // event and this is signalled as soon as the client issues the next + // RequestNotification() request. + // => Stop recording notifications + stopCommsDatabaseNotifications(); + TRAPD(error, updateConfigurationsL()); + if (error == KErrNone) { + updateStatesToSnaps(); + } + iWaitingCommsDatabaseNotifications = true; + break; + default: + // Do nothing + break; + } + } + + if (iWaitingCommsDatabaseNotifications) { + if (!IsActive()) { + SetActive(); + // Start waiting for new notification + ipCommsDB->RequestNotification(iStatus); + } + } +} + +void SymbianEngine::DoCancel() +{ + ipCommsDB->CancelRequestNotification(); +} + + +void SymbianEngine::EventL(const CConnMonEventBase& aEvent) +{ + switch (aEvent.EventType()) { + case EConnMonCreateConnection: + { + CConnMonCreateConnection* realEvent; + realEvent = (CConnMonCreateConnection*) &aEvent; + TUint subConnectionCount = 0; + TUint apId; + TUint connectionId = realEvent->ConnectionId(); + TRequestStatus status; + iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); + User::WaitForRequest(status); + QString ident = QString::number(qHash(apId)); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + toSymbianConfig(ptr)->connectionId = connectionId; + // Configuration is Active + if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) + updateStatesToSnaps(); + + if (!iOnline) { + iOnline = true; + emit this->onlineStateChanged(iOnline); + } + } + } + break; + + case EConnMonDeleteConnection: + { + CConnMonDeleteConnection* realEvent; + realEvent = (CConnMonDeleteConnection*) &aEvent; + TUint connectionId = realEvent->ConnectionId(); + + QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); + if (ptr) { + toSymbianConfig(ptr)->connectionId = 0; + // Configuration is either Defined or Discovered + if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) + updateStatesToSnaps(); + } + + bool online = false; + foreach (const QString &iface, accessPointConfigurations.keys()) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); + if (ptr->state == QNetworkConfiguration::Active) { + online = true; + break; + } + } + if (iOnline != online) { + iOnline = online; + emit this->onlineStateChanged(iOnline); + } + } + break; + + case EConnMonIapAvailabilityChange: + { + CConnMonIapAvailabilityChange* realEvent; + realEvent = (CConnMonIapAvailabilityChange*) &aEvent; + TConnMonIapInfo iaps = realEvent->IapAvailability(); + QList unDiscoveredConfigs = accessPointConfigurations.keys(); + for ( TUint i = 0; i < iaps.Count(); i++ ) { + QString ident = QString::number(qHash(iaps.iIap[i].iIapId)); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); + if (ptr) { + // Configuration is either Discovered or Active + changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered); + unDiscoveredConfigs.removeOne(ident); + } + } + foreach (const QString &iface, unDiscoveredConfigs) { + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); + if (ptr) { + // Configuration is Defined + changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined); + } + } + } + break; + + default: + // For unrecognized events + break; + } +} + +QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aConnectionId) +{ + QNetworkConfiguration item; + + QHash::const_iterator i = + accessPointConfigurations.constBegin(); + while (i != accessPointConfigurations.constEnd()) { + QNetworkConfigurationPrivatePointer ptr = i.value(); + if (toSymbianConfig(ptr)->connectionId == aConnectionId) + return ptr; + + ++i; + } + + return QNetworkConfigurationPrivatePointer(); +} + +AccessPointsAvailabilityScanner::AccessPointsAvailabilityScanner(SymbianEngine& owner, + RConnectionMonitor& connectionMonitor) + : CActive(CActive::EPriorityStandard), iOwner(owner), iConnectionMonitor(connectionMonitor) +{ + CActiveScheduler::Add(this); +} + +AccessPointsAvailabilityScanner::~AccessPointsAvailabilityScanner() +{ + Cancel(); +} + +void AccessPointsAvailabilityScanner::DoCancel() +{ + iConnectionMonitor.CancelAsyncRequest(EConnMonGetPckgAttribute); +} + +void AccessPointsAvailabilityScanner::StartScanning() +{ + iConnectionMonitor.GetPckgAttribute(EBearerIdAll, 0, KIapAvailability, iIapBuf, iStatus); + if (!IsActive()) { + SetActive(); + } +} + +void AccessPointsAvailabilityScanner::RunL() +{ + if (iStatus.Int() != KErrNone) { + iIapBuf().iCount = 0; + iOwner.accessPointScanningReady(false,iIapBuf()); + } else { + iOwner.accessPointScanningReady(true,iIapBuf()); + } +} + +QT_END_NAMESPACE diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h new file mode 100644 index 0000000..0ca30da --- /dev/null +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -0,0 +1,201 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SYMBIANENGINE_H +#define SYMBIANENGINE_H + +#include +#include + +#include +#include +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + #include +#endif + +class CCommsDatabase; + +QT_BEGIN_NAMESPACE +class QTimer; +QT_END_NAMESPACE + +QT_BEGIN_NAMESPACE + +class QNetworkSessionPrivate; +class AccessPointsAvailabilityScanner; + +class SymbianNetworkConfigurationPrivate : public QNetworkConfigurationPrivate +{ +public: + enum Bearer { + BearerEthernet, + BearerWLAN, + Bearer2G, + BearerCDMA2000, + BearerWCDMA, + BearerHSPA, + BearerBluetooth, + BearerWiMAX, + BearerUnknown = -1 + }; + + SymbianNetworkConfigurationPrivate(); + ~SymbianNetworkConfigurationPrivate(); + + Bearer bearer; + + TUint32 numericId; + TUint connectionId; + + TAny *manager; + + QNetworkConfigurationPrivatePointer serviceNetworkPtr; + + QString mappingName; +}; + +class SymbianEngine : public QNetworkSessionEngine, public CActive, + public MConnectionMonitorObserver +{ + Q_OBJECT + +public: + SymbianEngine(QObject *parent = 0); + virtual ~SymbianEngine(); + + QString getInterfaceFromId(const QString &id) { return QString(); } + bool hasIdentifier(const QString &id) { return false; } + + void connectToId(const QString &id) { } + void disconnectFromId(const QString &id) { } + + void requestUpdate(); + + QNetworkSession::State sessionStateForId(const QString &id) { return QNetworkSession::Invalid; } + + QNetworkConfigurationManager::Capabilities capabilities() const; + + QNetworkConfigurationPrivatePointer defaultConfiguration(); + +Q_SIGNALS: + void onlineStateChanged(bool isOnline); + +public Q_SLOTS: + void updateConfigurations(); + +private: + void updateStatesToSnaps(); + bool changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr, + QNetworkConfiguration::StateFlags newState); + bool changeConfigurationStateAtMinTo(QNetworkConfigurationPrivatePointer ptr, + QNetworkConfiguration::StateFlags newState); + bool changeConfigurationStateAtMaxTo(QNetworkConfigurationPrivatePointer ptr, + QNetworkConfiguration::StateFlags newState); +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + SymbianNetworkConfigurationPrivate *configFromConnectionMethodL(RCmConnectionMethod& connectionMethod); +#else + bool readNetworkConfigurationValuesFromCommsDb( + TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration); + void readNetworkConfigurationValuesFromCommsDbL( + TUint32 aApId, SymbianNetworkConfigurationPrivate *apNetworkConfiguration); +#endif + + void updateConfigurationsL(); + void updateActiveAccessPoints(); + void updateAvailableAccessPoints(); + void accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo); + void startCommsDatabaseNotifications(); + void stopCommsDatabaseNotifications(); + + QNetworkConfigurationPrivatePointer defaultConfigurationL(); + TBool GetS60PlatformVersion(TUint& aMajor, TUint& aMinor) const; + void startMonitoringIAPData(TUint32 aIapId); + QNetworkConfigurationPrivatePointer dataByConnectionId(TUint aConnectionId); + +protected: // From CActive + void RunL(); + void DoCancel(); + +private: // MConnectionMonitorObserver + void EventL(const CConnMonEventBase& aEvent); + +private: // Data + CCommsDatabase* ipCommsDB; + RConnectionMonitor iConnectionMonitor; + + TBool iWaitingCommsDatabaseNotifications; + TBool iOnline; + TBool iInitOk; + TBool iUpdateGoingOn; + + + AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner; + + friend class QNetworkSessionPrivate; + friend class AccessPointsAvailabilityScanner; + +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + RCmManager iCmManager; +#endif +}; + +class AccessPointsAvailabilityScanner : public CActive +{ +public: + AccessPointsAvailabilityScanner(SymbianEngine& owner, + RConnectionMonitor& connectionMonitor); + ~AccessPointsAvailabilityScanner(); + + void StartScanning(); + +protected: // From CActive + void RunL(); + void DoCancel(); + +private: // Data + SymbianEngine& iOwner; + RConnectionMonitor& iConnectionMonitor; + TConnMonIapInfoBuf iIapBuf; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 2d9c489..57df601 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -79,7 +79,12 @@ symbian: { DEPLOYMENT += phonon_backend_plugins } - DEPLOYMENT += qtresources qtlibraries imageformats_plugins codecs_plugins graphicssystems_plugins + DEPLOYMENT += qtresources \ + qtlibraries \ + imageformats_plugins \ + codecs_plugins \ + graphicssystems_plugins \ + bearer_plugins contains(QT_CONFIG, svg): { qtlibraries.sources += QtSvg.dll @@ -115,6 +120,9 @@ symbian: { graphicssystems_plugins.sources += qvggraphicssystem.dll } + bearer_plugins.path = c:$$QT_PLUGINS_BASE_DIR/bearer + bearer_plugins.sources += qgenericbearer.dll qsymbianbearer.dll + BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" BLD_INF_RULES.prj_exports += "qtdemoapps.iby $$CORE_APP_LAYER_IBY_EXPORT_PATH(qtdemoapps.iby)" } -- cgit v0.12