From fdc0d441e1c1331fb639e5d5f59daf3fb22a7e24 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 24 Jun 2010 01:49:52 +0200 Subject: Make QtFontFamily::symbol_checked a bitfield. Reviewed-by: Benjamin Poulain --- src/gui/text/qfontdatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index 139139f..e6c36a4 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -413,7 +413,7 @@ struct QtFontFamily bool fixedPitchComputed : 1; #endif #ifdef Q_WS_X11 - bool symbol_checked; + bool symbol_checked : 1; #endif QString name; -- cgit v0.12 From 793fbbbf5ae3860b5091c760b3cd0d467369cc1a Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 13:22:32 +1000 Subject: Cherry pick fix for QTMOBILITY-240 from Qt Mobility. c84a6d828bcb7f66d1ac06e1a7a84c5a8ba9cec4 --- .../bearer/symbian/qnetworksession_impl.cpp | 60 ++++++++++----- src/plugins/bearer/symbian/symbianengine.cpp | 90 ++++++++++++---------- 2 files changed, 88 insertions(+), 62 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index e08d135..20e13d2 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -694,8 +694,17 @@ void QNetworkSessionPrivateImpl::PreferredCarrierAvailable(TAccessPointInfo aOld SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(configs[i])); - if (symbianConfig->numericIdentifier() == aNewAPInfo.AccessPoint()) - emit preferredConfigurationChanged(configs[i], aIsSeamless); + if (symbianConfig->numericIdentifier() == aNewAPInfo.AccessPoint()) { + // Any slot connected to the signal might throw an std::exception, + // which must not propagate into Symbian code (this function is a callback + // from platform). We could convert exception to a symbian Leave, but since the + // prototype of this function bans this (no trailing 'L'), we just catch + // and drop. + QT_TRY { + emit preferredConfigurationChanged(configs[i], aIsSeamless); + } + QT_CATCH (std::exception&) {} + } } } else { migrate(); @@ -705,7 +714,10 @@ void QNetworkSessionPrivateImpl::PreferredCarrierAvailable(TAccessPointInfo aOld void QNetworkSessionPrivateImpl::NewCarrierActive(TAccessPointInfo /*aNewAPInfo*/, TBool /*aIsSeamless*/) { if (iALREnabled > 0) { - emit newConfigurationActivated(); + QT_TRY { + emit newConfigurationActivated(); + } + QT_CATCH (std::exception&) {} } else { accept(); } @@ -727,18 +739,24 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - syncStateWithInterface(); - // In some cases IAP is still in Connected state when - // syncStateWithInterface(); is called - // => Following call makes sure that Session state - // changes immediately to Disconnected. - newState(QNetworkSession::Disconnected); - emit closed(); + QT_TRY { + syncStateWithInterface(); + // In some cases IAP is still in Connected state when + // syncStateWithInterface(); is called + // => Following call makes sure that Session state + // changes immediately to Disconnected. + newState(QNetworkSession::Disconnected); + emit closed(); + } + QT_CATCH (std::exception&) {} } else if (iStoppedByUser) { // If the user of this session has called the stop() and // configuration is based on internet SNAP, this needs to be // done here because platform might roam. - newState(QNetworkSession::Disconnected); + QT_TRY { + newState(QNetworkSession::Disconnected); + } + QT_CATCH (std::exception&) {} } } #endif @@ -978,12 +996,12 @@ void QNetworkSessionPrivateImpl::RunL() if (error != KErrNone) { isOpen = false; iError = QNetworkSession::UnknownSessionError; - emit QNetworkSessionPrivate::error(iError); + QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - syncStateWithInterface(); + QT_TRYCATCH_LEAVING(syncStateWithInterface()); return; } @@ -1010,8 +1028,10 @@ void QNetworkSessionPrivateImpl::RunL() startTime = QDateTime::currentDateTime(); - newState(QNetworkSession::Connected); - emit quitPendingWaitsForOpened(); + QT_TRYCATCH_LEAVING({ + newState(QNetworkSession::Connected); + emit quitPendingWaitsForOpened(); + }); } break; case KErrNotFound: // Connection failed @@ -1019,12 +1039,12 @@ void QNetworkSessionPrivateImpl::RunL() activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::InvalidConfigurationError; - emit QNetworkSessionPrivate::error(iError); + QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - syncStateWithInterface(); + QT_TRYCATCH_LEAVING(syncStateWithInterface()); break; case KErrCancel: // Connection attempt cancelled case KErrAlreadyExists: // Connection already exists @@ -1038,12 +1058,12 @@ void QNetworkSessionPrivateImpl::RunL() } else { iError = QNetworkSession::UnknownSessionError; } - emit QNetworkSessionPrivate::error(iError); + QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } - syncStateWithInterface(); + QT_TRYCATCH_LEAVING(syncStateWithInterface()); break; } } @@ -1364,7 +1384,7 @@ void ConnectionProgressNotifier::DoCancel() void ConnectionProgressNotifier::RunL() { if (iStatus == KErrNone) { - iOwner.handleSymbianConnectionStatusChange(iProgress().iStage, iProgress().iError); + QT_TRYCATCH_LEAVING(iOwner.handleSymbianConnectionStatusChange(iProgress().iStage, iProgress().iError)); SetActive(); iConnection.ProgressNotification(iProgress, iStatus); diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index ab1ba28..3d462ee 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -272,7 +272,11 @@ void SymbianEngine::updateConfigurationsL() accessPointConfigurations.insert(ptr->id, ptr); mutex.unlock(); - emit configurationAdded(ptr); + // Emit configuration added. Connected slots may throw execptions + // which propagate here --> must be converted to leaves (standard + // std::exception would cause any TRAP trapping this function to terminate + // program). + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); } } @@ -293,10 +297,9 @@ void SymbianEngine::updateConfigurationsL() knownSnapConfigs.removeOne(ident); } else { SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; - CleanupStack::PushL(cpPriv); HBufC *pName = destination.NameLC(); - cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length()); + QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); CleanupStack::PopAndDestroy(pName); pName = NULL; @@ -313,10 +316,8 @@ void SymbianEngine::updateConfigurationsL() snapConfigurations.insert(ident, ptr); mutex.unlock(); - emit configurationAdded(ptr); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); - - CleanupStack::Pop(cpPriv); } QNetworkConfigurationPrivatePointer privSNAP = snapConfigurations.value(ident); @@ -336,7 +337,7 @@ void SymbianEngine::updateConfigurationsL() accessPointConfigurations.insert(ptr->id, ptr); mutex.unlock(); - emit configurationAdded(ptr); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); QMutexLocker configLocker(&privSNAP->mutex); @@ -390,7 +391,7 @@ void SymbianEngine::updateConfigurationsL() accessPointConfigurations.insert(ident, ptr); mutex.unlock(); - emit configurationAdded(ptr); + QT_TRYCATCH_LEAVING(emit configurationAdded(ptr)); mutex.lock(); } else { delete cpPriv; @@ -400,7 +401,7 @@ void SymbianEngine::updateConfigurationsL() } CleanupStack::PopAndDestroy(pDbTView); #endif - updateActiveAccessPoints(); + QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); foreach (const QString &oldIface, knownConfigs) { //remove non existing IAP @@ -408,6 +409,7 @@ void SymbianEngine::updateConfigurationsL() mutex.unlock(); emit configurationRemoved(ptr); + QT_TRYCATCH_LEAVING(emit configurationRemoved(ptr)); mutex.lock(); // Remove non existing IAP from SNAPs @@ -431,6 +433,7 @@ void SymbianEngine::updateConfigurationsL() mutex.unlock(); emit configurationRemoved(ptr); + QT_TRYCATCH_LEAVING(emit configurationRemoved(ptr)); mutex.lock(); } @@ -445,14 +448,12 @@ 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()); + QT_TRYCATCH_LEAVING(cpPriv->name = QString::fromUtf16(pName->Ptr(),pName->Length())); CleanupStack::PopAndDestroy(pName); pName = NULL; @@ -500,7 +501,7 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( if (error == KErrNone && pName) { CleanupStack::PushL(pName); - cpPriv->mappingName = QString::fromUtf16(pName->Ptr(),pName->Length()); + QT_TRYCATCH_LEAVING(cpPriv->mappingName = QString::fromUtf16(pName->Ptr(),pName->Length())); CleanupStack::PopAndDestroy(pName); pName = NULL; } @@ -518,8 +519,6 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( cpPriv->type = QNetworkConfiguration::InternetAccessPoint; cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; cpPriv->roamingSupported = false; - - CleanupStack::Pop(cpPriv); return cpPriv; } #else @@ -552,7 +551,7 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( QString ident = QString::number(qHash(aApId)); - apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length()); + QT_TRYCATCH_LEAVING(apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length())); apNetworkConfiguration->isValid = true; apNetworkConfiguration->id = ident; apNetworkConfiguration->numericId = aApId; @@ -902,7 +901,7 @@ void SymbianEngine::RunL() if (event == RDbNotifier::ECommit) { TRAPD(error, updateConfigurationsL()); if (error == KErrNone) { - updateStatesToSnaps(); + QT_TRYCATCH_LEAVING(updateStatesToSnaps()); } locker.unlock(); waitRandomTime(); @@ -913,7 +912,7 @@ void SymbianEngine::RunL() locker.relock(); TRAPD(error, updateConfigurationsL()); if (error == KErrNone) { - updateStatesToSnaps(); + QT_TRYCATCH_LEAVING(updateStatesToSnaps()); } } iIgnoringUpdates = false; // Wait time done, allow updating again @@ -966,8 +965,10 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; ptr->mutex.unlock(); - emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), - connectionId, QNetworkSession::Connecting); + QT_TRYCATCH_LEAVING( + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Connecting) + ); } } else if (connectionStatus == KLinkLayerOpen) { // Connection has been successfully opened @@ -985,23 +986,27 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) ptr->mutex.unlock(); // Configuration is Active - if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) { - updateStatesToSnaps(); - } - emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), - connectionId, QNetworkSession::Connected); + QT_TRYCATCH_LEAVING( + if (changeConfigurationStateTo(ptr, QNetworkConfiguration::Active)) { + updateStatesToSnaps(); + } + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Connected); - if (!iOnline) { - iOnline = true; - emit this->onlineStateChanged(iOnline); - } + if (!iOnline) { + iOnline = true; + emit this->onlineStateChanged(iOnline); + } + ); } } else if (connectionStatus == KConfigDaemonStartingDeregistration) { TUint connectionId = realEvent->ConnectionId(); QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); if (ptr) { - emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), - connectionId, QNetworkSession::Closing); + QT_TRYCATCH_LEAVING( + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Closing) + ); } } else if (connectionStatus == KLinkLayerClosed || connectionStatus == KConnectionClosed) { @@ -1011,12 +1016,13 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QNetworkConfigurationPrivatePointer ptr = dataByConnectionId(connectionId); if (ptr) { // Configuration is either Defined or Discovered - if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) { - updateStatesToSnaps(); - } - - emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), - connectionId, QNetworkSession::Disconnected); + QT_TRYCATCH_LEAVING( + if (changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Discovered)) { + updateStatesToSnaps(); + } + emit configurationStateChanged(toSymbianConfig(ptr)->numericIdentifier(), + connectionId, QNetworkSession::Disconnected); + ); } bool online = false; @@ -1030,7 +1036,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } if (iOnline != online) { iOnline = online; - emit this->onlineStateChanged(iOnline); + QT_TRYCATCH_LEAVING(emit this->onlineStateChanged(iOnline)); } } } @@ -1048,7 +1054,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { // Configuration is either Discovered or Active - changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered); + QT_TRYCATCH_LEAVING(changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered)); unDiscoveredConfigs.removeOne(ident); } } @@ -1056,7 +1062,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(iface); if (ptr) { // Configuration is Defined - changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined); + QT_TRYCATCH_LEAVING(changeConfigurationStateAtMaxTo(ptr, QNetworkConfiguration::Defined)); } } } @@ -1198,9 +1204,9 @@ void AccessPointsAvailabilityScanner::RunL() if (iStatus.Int() != KErrNone) { iIapBuf().iCount = 0; - iOwner.accessPointScanningReady(false,iIapBuf()); + QT_TRYCATCH_LEAVING(iOwner.accessPointScanningReady(false,iIapBuf())); } else { - iOwner.accessPointScanningReady(true,iIapBuf()); + QT_TRYCATCH_LEAVING(iOwner.accessPointScanningReady(true,iIapBuf())); } } -- cgit v0.12 From 91ff19ea3233310f5db542e880661d1efe0151e2 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 14:31:01 +1000 Subject: Cherry pick fix for MOBILITY-938 from Qt Mobility. 216f4016d1b447d51630086afca179df11fd6997 --- src/plugins/bearer/symbian/symbianengine.cpp | 98 ++++++++-------- src/plugins/bearer/symbian/symbianengine.h | 5 +- tests/manual/bearerex/bearerex.cpp | 90 ++++++++------ tests/manual/bearerex/bearerex.h | 15 ++- tests/manual/bearerex/bearerex.pro | 6 +- tests/manual/bearerex/sessiondialog.ui | 168 +++++++++++++++++---------- 6 files changed, 223 insertions(+), 159 deletions(-) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 3d462ee..8780218 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -46,7 +46,6 @@ #include #include #include -#include #include #include // For randgen seeding #include // For randgen seeding @@ -115,7 +114,7 @@ QString SymbianNetworkConfigurationPrivate::bearerName() const SymbianEngine::SymbianEngine(QObject *parent) : QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true), - iIgnoringUpdates(false) + iUpdatePending(false) { } @@ -190,6 +189,28 @@ SymbianEngine::~SymbianEngine() delete cleanup; } +void SymbianEngine::delayedConfigurationUpdate() +{ + QMutexLocker locker(&mutex); + + if (iUpdatePending) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM delayed configuration update (ECommit or ERecover occurred)."); +#endif + TRAPD(error, updateConfigurationsL()); + if (error == KErrNone) { + updateStatesToSnaps(); + } + iUpdatePending = false; + // Start monitoring again. + if (!IsActive()) { + SetActive(); + // Start waiting for new notification + ipCommsDB->RequestNotification(iStatus); + } + } +} + bool SymbianEngine::hasIdentifier(const QString &id) { QMutexLocker locker(&mutex); @@ -872,55 +893,30 @@ void SymbianEngine::RunL() { QMutexLocker locker(&mutex); - if (iIgnoringUpdates) { -#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug("QNCM CommsDB event handling postponed (postpone-timer running because IAPs/SNAPs were updated very recently)."); -#endif - return; - } - - 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 */ + if (iStatus != KErrCancel) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); #endif - iIgnoringUpdates = true; - // Other events than ECommit get lower priority. In practice with those events, - // we delay_before_updating methods, whereas - // with ECommit we _update_before_delaying the reaction to next event. - // Few important notes: 1) listening to only ECommit does not seem to be adequate, - // but updates will be missed. Hence other events are reacted upon too. - // 2) RDbNotifier records the most significant event, and that will be returned once - // we issue new RequestNotification, and hence updates will not be missed even - // when we are 'not reacting to them' for few seconds. - if (event == RDbNotifier::ECommit) { - TRAPD(error, updateConfigurationsL()); - if (error == KErrNone) { - QT_TRYCATCH_LEAVING(updateStatesToSnaps()); - } - locker.unlock(); - waitRandomTime(); - locker.relock(); - } else { - locker.unlock(); - waitRandomTime(); - locker.relock(); - TRAPD(error, updateConfigurationsL()); - if (error == KErrNone) { - QT_TRYCATCH_LEAVING(updateStatesToSnaps()); + // By default, start relistening notifications. Stop only if interesting event occured. + iWaitingCommsDatabaseNotifications = true; + RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); + switch (event) { + case RDbNotifier::ECommit: /** A transaction has been committed. */ + case RDbNotifier::ERecover: /** The database has been recovered */ + // Mark that there is update pending. No need to ask more events, + // as we know we will be updating anyway when the timer expires. + if (!iUpdatePending) { + iUpdatePending = true; + iWaitingCommsDatabaseNotifications = false; + // Update after random time, so that many processes won't + // start updating simultaneously + updateConfigurationsAfterRandomTime(); } + break; + default: + // Do nothing + break; } - iIgnoringUpdates = false; // Wait time done, allow updating again - iWaitingCommsDatabaseNotifications = true; - break; - default: - // Do nothing - break; } if (iWaitingCommsDatabaseNotifications) { @@ -1135,15 +1131,13 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo } // Waits for 2..6 seconds. -void SymbianEngine::waitRandomTime() +void SymbianEngine::updateConfigurationsAfterRandomTime() { - int iTimeToWait = qMax(2000, (qAbs(qrand()) % 7) * 1000); + int iTimeToWait = qMax(1000, (qAbs(qrand()) % 68) * 100); #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug("QNCM waiting random time: %d ms", iTimeToWait); #endif - QEventLoop loop; - QTimer::singleShot(iTimeToWait, &loop, SLOT(quit())); - loop.exec(); + QTimer::singleShot(iTimeToWait, this, SLOT(delayedConfigurationUpdate())); } QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aConnectionId) @@ -1164,7 +1158,7 @@ QNetworkConfigurationPrivatePointer SymbianEngine::dataByConnectionId(TUint aCon AccessPointsAvailabilityScanner::AccessPointsAvailabilityScanner(SymbianEngine& owner, RConnectionMonitor& connectionMonitor) - : CActive(CActive::EPriorityStandard), iOwner(owner), iConnectionMonitor(connectionMonitor) + : CActive(CActive::EPriorityHigh), iOwner(owner), iConnectionMonitor(connectionMonitor) { CActiveScheduler::Add(this); } diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 18fd249..27f3db4 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -159,6 +159,7 @@ Q_SIGNALS: public Q_SLOTS: void updateConfigurations(); + void delayedConfigurationUpdate(); private: void updateStatesToSnaps(); @@ -183,7 +184,7 @@ private: void accessPointScanningReady(TBool scanSuccessful, TConnMonIapInfo iapInfo); void startCommsDatabaseNotifications(); void stopCommsDatabaseNotifications(); - void waitRandomTime(); + void updateConfigurationsAfterRandomTime(); QNetworkConfigurationPrivatePointer defaultConfigurationL(); TBool GetS60PlatformVersion(TUint& aMajor, TUint& aMinor) const; @@ -211,7 +212,7 @@ private: // Data TBool iOnline; TBool iInitOk; TBool iUpdateGoingOn; - TBool iIgnoringUpdates; + TBool iUpdatePending; AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner; diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index bf60dd1..00cb481 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** @@ -40,6 +40,7 @@ ****************************************************************************/ #include "bearerex.h" +#include "datatransferer.h" #include @@ -261,8 +262,8 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration, QListWidget* eventListWidget, int index, BearerEx * parent) - : QWidget(parent), m_http(0), m_eventListWidget(eventListWidget), - m_index(index), m_httpRequestOngoing(false), m_alrEnabled (false) + : QWidget(parent), m_dataTransferer(0), m_eventListWidget(eventListWidget), + m_index(index), m_alrEnabled (false) { setupUi(this); @@ -300,41 +301,46 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration, SessionTab::~SessionTab() { - // Need to be nulled, because modal dialogs may return after destruction of this object and - // use already released resources. - delete m_NetworkSession; - m_NetworkSession = NULL; - delete m_http; - m_http = NULL; + delete m_NetworkSession; m_NetworkSession = 0; + delete m_dataTransferer; m_dataTransferer = 0; } -void SessionTab::on_createQHttpButton_clicked() +void SessionTab::on_createQNetworkAccessManagerButton_clicked() { - if (m_httpRequestOngoing) { - return; + if (m_dataTransferer) { + disconnect(m_dataTransferer, 0, 0, 0); + delete m_dataTransferer; + m_dataTransferer = 0; } - - if (m_http) { - disconnect(m_http, 0, 0, 0); - delete m_http; + // Create new object according to current selection + QString type(comboBox->currentText()); + if (type == "QNAM") { + m_dataTransferer = new DataTransfererQNam(this); + } else if (type == "QTcpSocket") { + m_dataTransferer = new DataTransfererQTcp(this); + } else if (type == "QHttp") { + m_dataTransferer = new DataTransfererQHttp(this); + } else { + qDebug("BearerEx Warning, unknown data transfer object requested, not creating anything."); + return; } - m_http = new QHttp(this); - createQHttpButton->setText("Recreate QHttp"); - connect(m_http, SIGNAL(done(bool)), this, SLOT(done(bool))); + createQNetworkAccessManagerButton->setText("Recreate"); + connect(m_dataTransferer, SIGNAL(finished(quint32, qint64, QString)), this, SLOT(finished(quint32, qint64, QString))); } void SessionTab::on_sendRequestButton_clicked() { - if (m_http) { - QString urlstring("http://www.google.com"); - QUrl url(urlstring); - m_http->setHost(url.host(), QHttp::ConnectionModeHttp, url.port() == -1 ? 0 : url.port()); - m_http->get(urlstring); - m_httpRequestOngoing = true; + if (m_dataTransferer) { + if (!m_dataTransferer->transferData()) { + QMessageBox msgBox; + msgBox.setStandardButtons(QMessageBox::Close); + msgBox.setText("Data transfer not started. \nVery likely data transfer ongoing."); + msgBox.exec(); + } } else { QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Close); - msgBox.setText("QHttp not created.\nCreate QHttp First."); + msgBox.setText("Data object not created.\nCreate data object first."); msgBox.exec(); } } @@ -419,7 +425,7 @@ void SessionTab::opened() listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Opened")); m_eventListWidget->addItem(listItem); - QVariant identifier = m_NetworkSession->property("ActiveConfiguration"); + QVariant identifier = m_NetworkSession->sessionProperty("ActiveConfiguration"); if (!identifier.isNull()) { QString configId = identifier.toString(); QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); @@ -429,7 +435,7 @@ void SessionTab::opened() } if (m_NetworkSession->configuration().type() == QNetworkConfiguration::UserChoice) { - QVariant identifier = m_NetworkSession->property("UserChoiceConfiguration"); + QVariant identifier = m_NetworkSession->sessionProperty("UserChoiceConfiguration"); if (!identifier.isNull()) { QString configId = identifier.toString(); QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); @@ -480,6 +486,18 @@ QString SessionTab::stateString(QNetworkSession::State state) return stateString; } +void SessionTab::on_dataObjectChanged(const QString &newObjectType) +{ + qDebug() << "BearerEx SessionTab dataObjectChanged to: " << newObjectType; + if (m_dataTransferer) { + disconnect(m_dataTransferer, 0, 0, 0); + delete m_dataTransferer; m_dataTransferer = 0; + qDebug() << "BearerEx SessionTab, previous data object deleted."; + } + createQNetworkAccessManagerButton->setText("Create"); +} + + void SessionTab::stateChanged(QNetworkSession::State state) { newState(state); @@ -491,7 +509,7 @@ void SessionTab::stateChanged(QNetworkSession::State state) void SessionTab::newState(QNetworkSession::State state) { - QVariant identifier = m_NetworkSession->property("ActiveConfiguration"); + QVariant identifier = m_NetworkSession->sessionProperty("ActiveConfiguration"); if (state == QNetworkSession::Connected && !identifier.isNull()) { QString configId = identifier.toString(); QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId); @@ -542,18 +560,14 @@ void SessionTab::error(QNetworkSession::SessionError error) msgBox.exec(); } -void SessionTab::done(bool error) +void SessionTab::finished(quint32 errorCode, qint64 dataReceived, QString errorType) { - m_httpRequestOngoing = false; - QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Close); - if (error) { - msgBox.setText("HTTP request failed."); - } else { - QString result(m_http->readAll()); - msgBox.setText(QString("HTTP request finished successfully.\nReceived ")+QString::number(result.length())+QString(" bytes.")); - } + msgBox.setText(QString("Data transfer completed. \nError code: ") + QString::number(errorCode) + + "\nError type: " + errorType + + "\nBytes received: " + + QString::number(dataReceived)); msgBox.exec(); // Check if the networksession still exists - it may have gone after returning from // the modal dialog (in the case that app has been closed, and deleting QHttp will diff --git a/tests/manual/bearerex/bearerex.h b/tests/manual/bearerex/bearerex.h index 6bcb3e5..b81d486 100644 --- a/tests/manual/bearerex/bearerex.h +++ b/tests/manual/bearerex/bearerex.h @@ -55,13 +55,16 @@ #endif #include "qnetworkconfigmanager.h" #include "qnetworksession.h" +#include "datatransferer.h" #include "xqlistwidget.h" QT_BEGIN_NAMESPACE -class QHttp; +class QNetworkAccessManager; +class QNetworkReply; QT_END_NAMESPACE class SessionTab; +class DataTransferer; QT_USE_NAMESPACE @@ -113,14 +116,15 @@ public: QString stateString(QNetworkSession::State state); private Q_SLOTS: - void on_createQHttpButton_clicked(); + void on_createQNetworkAccessManagerButton_clicked(); void on_sendRequestButton_clicked(); void on_openSessionButton_clicked(); void on_closeSessionButton_clicked(); void on_stopConnectionButton_clicked(); void on_deleteSessionButton_clicked(); + void on_dataObjectChanged(const QString& newObjectType); void on_alrButton_clicked(); - void done(bool error); + void finished(quint32 errorCode, qint64 dataReceived, QString errorType); void newConfigurationActivated(); void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless); @@ -131,13 +135,14 @@ private Q_SLOTS: void error(QNetworkSession::SessionError error); private: //data - QHttp* m_http; + // QNetworkAccessManager* m_networkAccessManager; + DataTransferer* m_dataTransferer; QNetworkSession* m_NetworkSession; QNetworkConfigurationManager* m_ConfigManager; QListWidget* m_eventListWidget; QNetworkConfiguration m_config; int m_index; - bool m_httpRequestOngoing; + bool m_dataTransferOngoing; bool m_alrEnabled; }; diff --git a/tests/manual/bearerex/bearerex.pro b/tests/manual/bearerex/bearerex.pro index 7b21183..df39c85 100644 --- a/tests/manual/bearerex/bearerex.pro +++ b/tests/manual/bearerex/bearerex.pro @@ -17,10 +17,12 @@ maemo5|maemo6 { # Example headers and sources HEADERS += bearerex.h \ - xqlistwidget.h + xqlistwidget.h \ + datatransferer.h SOURCES += bearerex.cpp \ main.cpp \ - xqlistwidget.cpp + xqlistwidget.cpp \ + datatransferer.cpp symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData diff --git a/tests/manual/bearerex/sessiondialog.ui b/tests/manual/bearerex/sessiondialog.ui index fcf2136..c50af70 100644 --- a/tests/manual/bearerex/sessiondialog.ui +++ b/tests/manual/bearerex/sessiondialog.ui @@ -1,78 +1,87 @@ - + + SessionTab - - + + + + 0 + 0 + 192 + 262 + + + - - - - + + + + SNAP - - - + + + true - - - + + + IAP - - - + + + true - + true - - - + + + Bearer - - - + + + true - - - + + + Sent/Rec. - - - + + + true - - - + + + State - - - + + + true @@ -80,52 +89,71 @@ - - - - + + + + Open Session - - - + + + Close Session - - - + + + Stop Conn. - - - - Create QHttp + + + + Enable ALR - - - + + + Send Test Req. - - - - Enable ALR + + + + Create - - - + + + + + QNAM + + + + + QTcpSocket + + + + + QHttp + + + + + + + Delete Session @@ -135,5 +163,25 @@ - + + + comboBox + currentIndexChanged(QString) + SessionTab + on_dataObjectChanged(QString) + + + 40 + 211 + + + 10 + 258 + + + + + + on_dataObjectChanged(QString) + -- cgit v0.12 From 8d07f723041c223d0d1346a1ce5e5ede17af32ad Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 15:04:16 +1000 Subject: Cherry pick fix for MOBILITY-1031 from Qt Mobility. 7e8b55524bd8a00e49e11103e8c8091e1e59e612 --- .../bearer/symbian/qnetworksession_impl.cpp | 7 ++-- src/plugins/bearer/symbian/symbianengine.cpp | 41 ++++++++++++---------- src/plugins/bearer/symbian/symbianengine.h | 3 ++ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 20e13d2..04ae396 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -910,8 +910,8 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia // <=> Note: It's possible that in this case reported IAP is // clone of the one of the IAPs of the used SNAP // => If mappingName matches, clone has been found - QNetworkConfiguration pt = QNetworkConfigurationManager() - .configurationFromIdentifier(QString::number(qHash(iapId))); + QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier( + QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId))); SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(pt)); @@ -938,7 +938,8 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia if (publicConfig.type() == QNetworkConfiguration::UserChoice) { if (engine) { - QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier(QString::number(qHash(iapId))); + QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier( + QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId))); // Try to found User Selected IAP from known IAPs (accessPointConfigurations) if (pt.isValid()) { return pt; diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 8780218..cf7e7a5 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -72,9 +72,6 @@ QT_BEGIN_NAMESPACE -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - static const int KValueThatWillBeAddedToSNAPId = 1000; -#endif static const int KUserChoiceIAPId = 0; SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() @@ -113,7 +110,7 @@ QString SymbianNetworkConfigurationPrivate::bearerName() const } SymbianEngine::SymbianEngine(QObject *parent) -: QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true), +: QBearerEngine(parent), CActive(CActive::EPriorityHigh), iFirstUpdate(true), iInitOk(true), iUpdatePending(false) { } @@ -282,7 +279,7 @@ void SymbianEngine::updateConfigurationsL() RCmConnectionMethod connectionMethod = iCmManager.ConnectionMethodL(connectionMethods[i]); CleanupClosePushL(connectionMethod); TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString ident = QString::number(qHash(iapId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); if (accessPointConfigurations.contains(ident)) { knownConfigs.removeOne(ident); } else { @@ -313,7 +310,8 @@ void SymbianEngine::updateConfigurationsL() 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 + QString ident = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX + + QString::number(qHash(destination.Id())); if (snapConfigurations.contains(ident)) { knownSnapConfigs.removeOne(ident); } else { @@ -347,7 +345,7 @@ void SymbianEngine::updateConfigurationsL() CleanupClosePushL(connectionMethod); TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString iface = QString::number(qHash(iapId)); + QString iface = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); // Check that IAP can be found from accessPointConfigurations list QNetworkConfigurationPrivatePointer priv = accessPointConfigurations.value(iface); if (!priv) { @@ -402,7 +400,7 @@ void SymbianEngine::updateConfigurationsL() TInt retVal = pDbTView->GotoFirstRecord(); while (retVal == KErrNone) { pDbTView->ReadUintL(TPtrC(COMMDB_ID), apId); - QString ident = QString::number(qHash(apId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); if (accessPointConfigurations.contains(ident)) { knownConfigs.removeOne(ident); } else { @@ -470,7 +468,7 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( { SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate; TUint32 iapId = connectionMethod.GetIntAttributeL(CMManager::ECmIapId); - QString ident = QString::number(qHash(iapId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(iapId)); HBufC *pName = connectionMethod.GetStringAttributeL(CMManager::ECmName); CleanupStack::PushL(pName); @@ -570,7 +568,7 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( User::Leave(KErrNotFound); } - QString ident = QString::number(qHash(aApId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(aApId)); QT_TRYCATCH_LEAVING(apNetworkConfiguration->name = QString::fromUtf16(name.Ptr(),name.Length())); apNetworkConfiguration->isValid = true; @@ -637,10 +635,12 @@ QNetworkConfigurationPrivatePointer SymbianEngine::defaultConfigurationL() TCmDefConnValue defaultConnectionValue; iCmManager.ReadDefConnL(defaultConnectionValue); if (defaultConnectionValue.iType == ECmDefConnDestination) { - QString iface = QString::number(qHash(defaultConnectionValue.iId+KValueThatWillBeAddedToSNAPId)); + QString iface = QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX + + QString::number(qHash(defaultConnectionValue.iId)); ptr = snapConfigurations.value(iface); } else if (defaultConnectionValue.iType == ECmDefConnConnectionMethod) { - QString iface = QString::number(qHash(defaultConnectionValue.iId)); + QString iface = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(defaultConnectionValue.iId)); ptr = accessPointConfigurations.value(iface); } #endif @@ -678,7 +678,7 @@ void SymbianEngine::updateActiveAccessPoints() iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount); iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); @@ -735,7 +735,8 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn // Set state of returned IAPs to Discovered // if state is not already Active for(TUint i=0; imutex.lock(); @@ -974,7 +975,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TRequestStatus status; iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { ptr->mutex.lock(); @@ -1045,7 +1046,8 @@ void SymbianEngine::EventL(const CConnMonEventBase& 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)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(iaps.iIap[i].iIapId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { @@ -1075,7 +1077,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TRequestStatus status; iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); - QString ident = QString::number(qHash(apId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { QMutexLocker configLocker(&ptr->mutex); @@ -1109,7 +1111,8 @@ void SymbianEngine::configurationStateChangeReport(TUint32 accessPointId, QNetwo switch (newState) { case QNetworkSession::Disconnected: { - QString ident = QString::number(qHash(accessPointId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(accessPointId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { // Configuration is either Defined or Discovered diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 27f3db4..8e58994 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -55,6 +55,9 @@ // Uncomment and compile QtBearer to gain detailed state tracing // #define QT_BEARERMGMT_SYMBIAN_DEBUG +#define QT_BEARERMGMT_CONFIGURATION_SNAP_PREFIX QLatin1String("S_") +#define QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX QLatin1String("I_") + class CCommsDatabase; class QEventLoop; -- cgit v0.12 From 3c766b835fd565e3a85606ae2d4891e3954b447a Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 15:43:31 +1000 Subject: Merge bearermanagement changes from Qt Mobility. cba220f177154428d6103a93a819668be689a591 --- config.tests/mac/corewlan/corewlantest.mm | 2 +- examples/network/bearercloud/bearercloud.cpp | 2 +- examples/network/bearercloud/main.cpp | 2 +- examples/network/bearermonitor/main.cpp | 2 +- tests/auto/qbearertestcommon.h | 2 +- tests/manual/bearerex/datatransferer.cpp | 220 +++++++++++++++++++++++++++ tests/manual/bearerex/datatransferer.h | 130 ++++++++++++++++ tests/manual/bearerex/main.cpp | 2 +- tests/manual/bearerex/xqlistwidget.cpp | 2 +- tests/manual/bearerex/xqlistwidget.h | 2 +- 10 files changed, 358 insertions(+), 8 deletions(-) create mode 100644 tests/manual/bearerex/datatransferer.cpp create mode 100644 tests/manual/bearerex/datatransferer.h diff --git a/config.tests/mac/corewlan/corewlantest.mm b/config.tests/mac/corewlan/corewlantest.mm index 3a29d84..ee6f661 100644 --- a/config.tests/mac/corewlan/corewlantest.mm +++ b/config.tests/mac/corewlan/corewlantest.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/examples/network/bearercloud/bearercloud.cpp b/examples/network/bearercloud/bearercloud.cpp index 9e58c73..cc73954 100644 --- a/examples/network/bearercloud/bearercloud.cpp +++ b/examples/network/bearercloud/bearercloud.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/examples/network/bearercloud/main.cpp b/examples/network/bearercloud/main.cpp index c0c0023..6665311 100644 --- a/examples/network/bearercloud/main.cpp +++ b/examples/network/bearercloud/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp index 0bbbb56..1a22c13 100644 --- a/examples/network/bearermonitor/main.cpp +++ b/examples/network/bearermonitor/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/auto/qbearertestcommon.h b/tests/auto/qbearertestcommon.h index c9df249..138c444 100644 --- a/tests/auto/qbearertestcommon.h +++ b/tests/auto/qbearertestcommon.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/manual/bearerex/datatransferer.cpp b/tests/manual/bearerex/datatransferer.cpp new file mode 100644 index 0000000..c3c13a8 --- /dev/null +++ b/tests/manual/bearerex/datatransferer.cpp @@ -0,0 +1,220 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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 +#include +#include +#include +#include "datatransferer.h" + +DataTransferer::DataTransferer(QObject *parent) : + QObject(parent), m_dataTransferOngoing(false) +{ +} + +bool DataTransferer::dataTransferOngoing() +{ + return m_dataTransferOngoing; +} + + + +// -------- Based on QTcp + +DataTransfererQTcp::DataTransfererQTcp(QObject* parent) +: DataTransferer(parent) +{ + qDebug("BearerEx DataTransferer QTcp created."); + + connect(&m_qsocket, SIGNAL(readyRead()), this, SLOT(readyRead())); + connect(&m_qsocket, SIGNAL(connected()), this, SLOT(connected())); + connect(&m_qsocket, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(error(QAbstractSocket::SocketError))); +} + +DataTransfererQTcp::~DataTransfererQTcp() +{ + qDebug("BearerEx DataTransferer QTcp destroyed."); + m_qsocket.abort(); +} + +bool DataTransfererQTcp::transferData() +{ + if (m_dataTransferOngoing) { + return false; + } + qDebug("BearerEx datatransfer for QTcp requested."); + // Connect to host + QUrl url("http://www.google.com.au"); + m_qsocket.connectToHost(url.host(), url.port(80)); + + // m_qsocket.connectToHost("http://www.google.com", 80); + // Wait for connected() signal. + m_dataTransferOngoing = true; + return true; +} + +void DataTransfererQTcp::connected() +{ + qDebug("BearerEx DataTransfererQtcp connected, requesting data."); + // Establish HTTP request + //QByteArray request("GET / HTTP/1.1 \nHost: www.google.com\n\n"); + QByteArray request("GET / HTTP/1.1\n\n"); + + // QByteArray request("GET /index.html HTTP/1.1 \n Host: www.google.com \n\n"); + qint64 dataWritten = m_qsocket.write(request); + m_qsocket.flush(); + + qDebug() << "BearerEx DataTransferQTcp wrote " << dataWritten << " bytes"; + // Start waiting for readyRead() of error() +} + +void DataTransfererQTcp::readyRead() +{ + qDebug() << "BearerEx DataTransfererQTcp readyRead() with "; + qint64 bytesAvailable = m_qsocket.bytesAvailable(); + qDebug() << bytesAvailable << " bytes available."; + + // QDataStream in(&m_qsocket); + QByteArray array = m_qsocket.readAll(); + QString data = QString::fromAscii(array); + + // in >> data; + + qDebug() << "BearerEx DataTransferQTcp data received: " << data; + m_dataTransferOngoing = false; + // m_qsocket.error() returns uninitialized value in case no error has occured, + // so emit '0' + emit finished(0, bytesAvailable, "QAbstractSocket::SocketError"); +} + +void DataTransfererQTcp::error(QAbstractSocket::SocketError socketError) +{ + qDebug("BearerEx DataTransfererQTcp error(), aborting socket."); + m_qsocket.abort(); + m_dataTransferOngoing = false; + emit finished(socketError, 0, "QAbstractSocket::SocketError"); +} + +// -------- Based on QHttp + +DataTransfererQHttp::DataTransfererQHttp(QObject* parent) +: DataTransferer(parent) +{ + connect(&m_qhttp, SIGNAL(done(bool)), this, SLOT(done(bool))); + qDebug("BearerEx DataTransferer QHttp created."); +} + +DataTransfererQHttp::~DataTransfererQHttp() +{ + qDebug("BearerEx DataTransferer QHttp destroyed."); +} + +bool DataTransfererQHttp::transferData() +{ + qDebug("BearerEx datatransfer for QHttp requested."); + if (m_dataTransferOngoing) { + return false; + } + QString urlstring("http://www.google.com"); + QUrl url(urlstring); + m_qhttp.setHost(url.host(), QHttp::ConnectionModeHttp, url.port() == -1 ? 0 : url.port()); + m_qhttp.get(urlstring); + m_dataTransferOngoing = true; + return true; +} + +void DataTransfererQHttp::done(bool /*error*/ ) +{ + qDebug("BearerEx DatatransfererQHttp reply was finished (error code is type QHttp::Error)."); + qint64 dataReceived = 0; + quint32 errorCode = m_qhttp.error(); + if (m_qhttp.error() == QHttp::NoError) { + QString result(m_qhttp.readAll()); + dataReceived = result.length(); + } + m_dataTransferOngoing = false; + emit finished(errorCode, dataReceived, "QHttp::Error"); +} + +// -------- Based on QNetworkAccessManager + +DataTransfererQNam::DataTransfererQNam(QObject* parent) +: DataTransferer(parent) +{ + connect(&m_qnam, SIGNAL(finished(QNetworkReply*)), + this, SLOT(replyFinished(QNetworkReply*))); + qDebug("BearerEx DataTransferer QNam created."); +} + +DataTransfererQNam::~DataTransfererQNam() +{ + qDebug("BearerEx DataTransferer QNam destroyed."); +} + +bool DataTransfererQNam::transferData() +{ + qDebug("BearerEx datatransfer for QNam requested."); + if (m_dataTransferOngoing) { + return false; + } + m_qnam.get(QNetworkRequest(QUrl("http://www.google.com"))); + m_dataTransferOngoing = true; + return true; +} + +void DataTransfererQNam::replyFinished(QNetworkReply *reply) +{ + qDebug("BearerEx DatatransfererQNam reply was finished (error code is type QNetworkReply::NetworkError)."); + qint64 dataReceived = 0; + quint32 errorCode = (quint32)reply->error(); + + if (reply->error() == QNetworkReply::NoError) { + QString result(reply->readAll()); + dataReceived = result.length(); + } + m_dataTransferOngoing = false; + emit finished(errorCode, dataReceived, "QNetworkReply::NetworkError"); + reply->deleteLater(); +} + + + diff --git a/tests/manual/bearerex/datatransferer.h b/tests/manual/bearerex/datatransferer.h new file mode 100644 index 0000000..f2159b7 --- /dev/null +++ b/tests/manual/bearerex/datatransferer.h @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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 DATATRANSFERER_H +#define DATATRANSFERER_H + +#include +#include +#include +#include +#include +#include +#include + +// Interface-class for data transferring object + +class DataTransferer : public QObject +{ + Q_OBJECT +public: + explicit DataTransferer(QObject *parent = 0); + virtual ~DataTransferer() { + if (m_dataTransferOngoing) { + qDebug("BearerEx Warning: dataobjects transfer was ongoing when destroyed."); + } + } + virtual bool transferData() = 0; + bool dataTransferOngoing(); + +signals: + void finished(quint32 errorCode, qint64 dataReceived, QString errorType); + +public slots: + +protected: + bool m_dataTransferOngoing; +}; + + +// Specializations/concrete classes + +class DataTransfererQTcp : public DataTransferer +{ + Q_OBJECT +public: + DataTransfererQTcp(QObject* parent = 0); + ~DataTransfererQTcp(); + + virtual bool transferData(); + +public slots: + void readyRead(); + void error(QAbstractSocket::SocketError socketError); + void connected(); + +private: + QTcpSocket m_qsocket; +}; + +class DataTransfererQNam : public DataTransferer +{ + Q_OBJECT +public: + DataTransfererQNam(QObject* parent = 0); + ~DataTransfererQNam(); + + virtual bool transferData(); + +public slots: + void replyFinished(QNetworkReply* reply); + +private: + QNetworkAccessManager m_qnam; +}; + +class DataTransfererQHttp : public DataTransferer +{ + Q_OBJECT +public: + DataTransfererQHttp(QObject* parent = 0); + ~DataTransfererQHttp(); + + virtual bool transferData(); + +public slots: + void done(bool error); + +private: + QHttp m_qhttp; +}; + +#endif // DATATRANSFERER_H diff --git a/tests/manual/bearerex/main.cpp b/tests/manual/bearerex/main.cpp index 20b167e..704321a 100644 --- a/tests/manual/bearerex/main.cpp +++ b/tests/manual/bearerex/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/manual/bearerex/xqlistwidget.cpp b/tests/manual/bearerex/xqlistwidget.cpp index 8104779..e4b12f2 100644 --- a/tests/manual/bearerex/xqlistwidget.cpp +++ b/tests/manual/bearerex/xqlistwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** diff --git a/tests/manual/bearerex/xqlistwidget.h b/tests/manual/bearerex/xqlistwidget.h index 0649c2b..7c12138 100644 --- a/tests/manual/bearerex/xqlistwidget.h +++ b/tests/manual/bearerex/xqlistwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -- cgit v0.12 From 12c06cfb761b1c8b3575df9ad6d1aabdbd2ed402 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 15:59:23 +1000 Subject: Cherry pick fix for MOBILITY-1047 from Qt Mobility. 4f74cd44d77349759096bed091913b188a9167e4 --- examples/network/bearermonitor/bearermonitor.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp index 4a04b4c..98869ea 100644 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ b/examples/network/bearermonitor/bearermonitor.cpp @@ -80,7 +80,7 @@ BearerMonitor::BearerMonitor(QWidget *parent) break; } } - + connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool))); connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), this, SLOT(configurationAdded(const QNetworkConfiguration&))); connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), @@ -88,7 +88,6 @@ BearerMonitor::BearerMonitor(QWidget *parent) connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), this, SLOT(configurationChanged(const QNetworkConfiguration))); connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations())); - connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool))); #ifdef Q_OS_WIN connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork())); @@ -111,6 +110,10 @@ BearerMonitor::BearerMonitor(QWidget *parent) #endif connect(scanButton, SIGNAL(clicked()), this, SLOT(performScan())); + + // Just in case update all configurations so that all + // configurations are up to date. + manager.updateConfigurations(); } BearerMonitor::~BearerMonitor() @@ -209,6 +212,10 @@ void BearerMonitor::updateConfigurations() progressBar->hide(); scanButton->show(); + // Just in case update online state, on Symbian platform + // WLAN scan needs to be triggered initially to have their true state. + onlineStateChanged(manager.isOnline()); + QList items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard); QMap itemMap; while (!items.isEmpty()) { -- cgit v0.12 From 4aeb66d9c3e22a84d3c9bd916b8277537a2c4a2f Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 16:02:23 +1000 Subject: Cherry pick fix for MOBILITY-853 from Qt Mobility. 256e67963c4cb0fc150e6c47193e7c9b17296611 --- src/plugins/bearer/symbian/symbianengine.cpp | 70 ++++++++++++++++++++++++++++ src/plugins/bearer/symbian/symbianengine.h | 1 + 2 files changed, 71 insertions(+) diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index cf7e7a5..bda3e56 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -131,6 +131,9 @@ void SymbianEngine::initialize() } TRAP_IGNORE(iConnectionMonitor.ConnectL()); +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + TRAP_IGNORE(iConnectionMonitor.SetUintAttribute(EBearerIdAll, 0, KBearerGroupThreshold, 1)); +#endif TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -804,6 +807,59 @@ void SymbianEngine::updateStatesToSnaps() } } +#ifdef SNAP_FUNCTIONALITY_AVAILABLE +void SymbianEngine::updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo) +{ + QHash::const_iterator i = + accessPointConfigurations.constBegin(); + while (i != accessPointConfigurations.constEnd()) { + QNetworkConfigurationPrivatePointer ptr = i.value(); + + QMutexLocker locker(&ptr->mutex); + + SymbianNetworkConfigurationPrivate *p = toSymbianConfig(ptr); + + if (p->bearer >= SymbianNetworkConfigurationPrivate::Bearer2G && + p->bearer <= SymbianNetworkConfigurationPrivate::BearerHSPA) { + switch (bearerInfo) { + case EBearerInfoCSD: + p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EBearerInfoWCDMA: + p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; + break; + case EBearerInfoCDMA2000: + p->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000; + break; + case EBearerInfoGPRS: + p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EBearerInfoHSCSD: + p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EBearerInfoEdgeGPRS: + p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G; + break; + case EBearerInfoWcdmaCSD: + p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA; + break; + case EBearerInfoHSDPA: + p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + break; + case EBearerInfoHSUPA: + p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + break; + case EBearerInfoHSxPA: + p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA; + break; + } + } + + ++i; + } +} +#endif + bool SymbianEngine::changeConfigurationStateTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState) { @@ -941,6 +997,20 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) QMutexLocker locker(&mutex); switch (aEvent.EventType()) { +#ifdef SNAP_FUNCTIONALITY_AVAILABLE + case EConnMonBearerInfoChange: + { + CConnMonBearerInfoChange* realEvent; + realEvent = (CConnMonBearerInfoChange*) &aEvent; + TUint connectionId = realEvent->ConnectionId(); + if (connectionId == EBearerIdAll) { + //Network level event + TConnMonBearerInfo bearerInfo = (TConnMonBearerInfo)realEvent->BearerInfo(); + updateMobileBearerToConfigs(bearerInfo); + } + break; + } +#endif case EConnMonConnectionStatusChange: { CConnMonConnectionStatusChange* realEvent; diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 8e58994..d95d4d5 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -173,6 +173,7 @@ private: bool changeConfigurationStateAtMaxTo(QNetworkConfigurationPrivatePointer ptr, QNetworkConfiguration::StateFlags newState); #ifdef SNAP_FUNCTIONALITY_AVAILABLE + void updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo); SymbianNetworkConfigurationPrivate *configFromConnectionMethodL(RCmConnectionMethod& connectionMethod); #else bool readNetworkConfigurationValuesFromCommsDb( -- cgit v0.12 From 94797fdd2e752677a5665abc9b23aa22f8a9c4db Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 16:18:01 +1000 Subject: Cherry pick fix for MOBILITY-800 from Qt Mobility. a05504d2a0c643c6f253527f07bcc0dba8a799b4 --- .../bearer/symbian/qnetworksession_impl.cpp | 30 +++++++++++++++++----- src/plugins/bearer/symbian/qnetworksession_impl.h | 5 ++++ tests/manual/bearerex/bearerex.cpp | 3 ++- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 04ae396..b90d603 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -63,7 +63,12 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility = NULL; #endif - + // Try to load "Open C" dll dynamically and + // try to attach to unsetdefaultif function dynamically. + // This is to avoid build breaks with old OpenC versions. + if (iOpenCLibrary.Load(_L("libc")) == KErrNone) { + iDynamicUnSetdefaultif = (TOpenCUnSetdefaultifFunction)iOpenCLibrary.Lookup(597); + } TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -86,14 +91,15 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() iMobility = NULL; } #endif - iConnection.Close(); iSocketServ.Close(); // Close global 'Open C' RConnection + // Clears also possible unsetdefaultif() flags. setdefaultif(0); iConnectionMonitor.Close(); + iOpenCLibrary.Close(); } void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState) @@ -525,8 +531,15 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iConnection.Close(); iSocketServ.Close(); - // Close global 'Open C' RConnection - setdefaultif(0); + // Close global 'Open C' RConnection. If OpenC supports, + // close the defaultif for good to avoid difficult timing + // and bouncing issues of network going immediately back up + // because of e.g. select() thread etc. + if (iDynamicUnSetdefaultif) { + iDynamicUnSetdefaultif(); + } else { + setdefaultif(0); + } if (publicConfig.type() == QNetworkConfiguration::UserChoice) { newState(QNetworkSession::Closing); @@ -611,8 +624,13 @@ void QNetworkSessionPrivateImpl::migrate() { #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iMobility) { - // Close global 'Open C' RConnection - setdefaultif(0); + // Close global 'Open C' RConnection. If openC supports, use the 'heavy' + // version to block all subsequent requests. + if (iDynamicUnSetdefaultif) { + iDynamicUnSetdefaultif(); + } else { + setdefaultif(0); + } // Start migrating to new IAP iMobility->MigrateToPreferredCarrier(); } diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index b045ff1..4b4f28c 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -73,6 +73,8 @@ QT_BEGIN_NAMESPACE class ConnectionProgressNotifier; class SymbianEngine; +typedef void (*TOpenCUnSetdefaultifFunction)(); + class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive #ifdef SNAP_FUNCTIONALITY_AVAILABLE , public MMobilityProtocolResp @@ -153,6 +155,9 @@ private: // data QDateTime startTime; + RLibrary iOpenCLibrary; + TOpenCUnSetdefaultifFunction iDynamicUnSetdefaultif; + mutable RSocketServ iSocketServ; mutable RConnection iConnection; mutable RConnectionMonitor iConnectionMonitor; diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index 00cb481..6f280db 100644 --- a/tests/manual/bearerex/bearerex.cpp +++ b/tests/manual/bearerex/bearerex.cpp @@ -564,7 +564,8 @@ void SessionTab::finished(quint32 errorCode, qint64 dataReceived, QString errorT { QMessageBox msgBox; msgBox.setStandardButtons(QMessageBox::Close); - msgBox.setText(QString("Data transfer completed. \nError code: ") + QString::number(errorCode) + + msgBox.setText(QString("Data transfer completed. \nError code: ") + + QString::number(int(errorCode)) + "\nError type: " + errorType + "\nBytes received: " + QString::number(dataReceived)); -- cgit v0.12 From 94c64b9ae4d539e9578156a0df999de1605f858f Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Thu, 10 Jun 2010 16:23:34 +1000 Subject: Cherry pick fix for MOBILITY-965 from Qt Mobility. 50de830ded2dcc1c6b4d8be71428d9a2bfed6ae7 --- .../bearer/symbian/qnetworksession_impl.cpp | 84 ++++++++++++++++++++-- src/plugins/bearer/symbian/symbianengine.cpp | 70 ++++++++++++++++-- src/plugins/bearer/symbian/symbianengine.h | 3 + 3 files changed, 147 insertions(+), 10 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index b90d603..940281c 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -69,6 +69,7 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) if (iOpenCLibrary.Load(_L("libc")) == KErrNone) { iDynamicUnSetdefaultif = (TOpenCUnSetdefaultifFunction)iOpenCLibrary.Lookup(597); } + TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -91,6 +92,7 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() iMobility = NULL; } #endif + iConnection.Close(); iSocketServ.Close(); @@ -433,6 +435,10 @@ void QNetworkSessionPrivateImpl::open() toSymbianConfig(privateConfiguration(publicConfig)); #ifdef OCC_FUNCTIONALITY_AVAILABLE + // On Symbian^3 if service network is not reachable, it triggers a UI (aka EasyWLAN) where + // user can create new IAPs. To detect this, we need to store the number of IAPs + // there was before connection was started. + iKnownConfigsBeforeConnectionStart = engine->accessPointConfigurationIdentifiers(); TConnPrefList snapPref; TExtendedConnPref prefs; prefs.SetSnapId(symbianConfig->numericIdentifier()); @@ -511,7 +517,11 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iClosedByUser = true; isOpen = false; +#ifndef OCC_FUNCTIONALITY_AVAILABLE + // On Symbian^3 we need to keep track of active configuration longer + // in case of empty-SNAP-triggered EasyWLAN. activeConfig = QNetworkConfiguration(); +#endif serviceConfig = QNetworkConfiguration(); Cancel(); @@ -906,7 +916,7 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia _LIT(KSetting, "IAP\\Id"); iConnection.GetIntSetting(KSetting, iapId); } - + #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { // Try to search IAP from the used SNAP using IAP Id @@ -943,17 +953,54 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia } } } else { +#ifdef OCC_FUNCTIONALITY_AVAILABLE + // On Symbian^3 (only, not earlier or Symbian^4) if the SNAP was not reachable, it triggers + // user choice type of activity (EasyWLAN). As a result, a new IAP may be created, and + // hence if was not found yet. Therefore update configurations and see if there is something new. + // 1. Update knowledge from the databases. + engine->requestUpdate(); + // 2. Check if new configuration was created during connection creation + QList knownConfigs = engine->accessPointConfigurationIdentifiers(); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "opened configuration was not known beforehand, looking for new."; +#endif + if (knownConfigs.count() > iKnownConfigsBeforeConnectionStart.count()) { + // Configuration count increased => new configuration was created + // => Search new, created configuration + QString newIapId; + for (int i=0; i < iKnownConfigsBeforeConnectionStart.count(); i++) { + if (knownConfigs[i] != iKnownConfigsBeforeConnectionStart[i]) { + newIapId = knownConfigs[i]; + break; + } + } + if (newIapId.isEmpty()) { + newIapId = knownConfigs[knownConfigs.count()-1]; + } + pt = QNetworkConfigurationManager().configurationFromIdentifier(newIapId); + if (pt.isValid()) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "new configuration was found, name, IAP id: " << pt.name() << pt.identifier(); +#endif + return pt; + } + } +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "configuration was not found, returning invalid."; +#endif +#endif // OCC_FUNCTIONALITY_AVAILABLE // Given IAP Id was not found from known IAPs array return QNetworkConfiguration(); } - // Matching IAP was not found from used SNAP // => IAP from another SNAP is returned // (Note: Returned IAP matches to given IAP Id) return pt; } #endif - if (publicConfig.type() == QNetworkConfiguration::UserChoice) { if (engine) { QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier( @@ -994,6 +1041,10 @@ QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 ia void QNetworkSessionPrivateImpl::RunL() { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "RConnection::RunL with status code: " << iStatus.Int(); +#endif TInt statusCode = iStatus.Int(); switch (statusCode) { @@ -1226,7 +1277,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint QNetworkConfiguration config = bestConfigFromSNAP(publicConfig); if ((config.state() == QNetworkConfiguration::Defined) || (config.state() == QNetworkConfiguration::Discovered)) { - + activeConfig = QNetworkConfiguration(); state = newState; #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed E to: " << state; @@ -1247,6 +1298,21 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint } } } +#ifdef OCC_FUNCTIONALITY_AVAILABLE + // If the retVal is not true here, it means that the status update may apply to an IAP outside of + // SNAP (session is based on SNAP but follows IAP outside of it), which may occur on Symbian^3 EasyWlan. + if (retVal == false && activeConfig.d.data() && activeConfig.d.data()->numericId == accessPointId) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "===> EMIT State changed G to: " << state; +#endif + if (newState == QNetworkSession::Disconnected) { + activeConfig = QNetworkConfiguration(); + } + state = newState; + emit q->stateChanged(state); + retVal = true; + } +#endif } } @@ -1262,9 +1328,15 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); - iDeprecatedConnectionId = symbianConfig->connectionIdentifier(); - } + symbianConfig->mutex.lock(); + iDeprecatedConnectionId = symbianConfig->connectionId; + symbianConfig->mutex.unlock(); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + // Just in case clear activeConfiguration. + activeConfig = QNetworkConfiguration(); +#endif + } return retVal; } diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index bda3e56..ca444c1 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -683,6 +683,12 @@ void SymbianEngine::updateActiveAccessPoints() User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // If IAP was not found, check if the update was about EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { iConnectionMonitor.GetIntAttribute(connectionId, subConnectionCount, KConnectionStatus, connectionStatus, status); User::WaitForRequest(status); @@ -713,7 +719,7 @@ void SymbianEngine::updateActiveAccessPoints() if (iOnline != online) { iOnline = online; mutex.unlock(); - emit this->onlineStateChanged(iOnline); + emit this->onlineStateChanged(online); mutex.lock(); } } @@ -951,15 +957,15 @@ void SymbianEngine::RunL() QMutexLocker locker(&mutex); if (iStatus != KErrCancel) { -#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); -#endif // By default, start relistening notifications. Stop only if interesting event occured. iWaitingCommsDatabaseNotifications = true; RDbNotifier::TEvent event = STATIC_CAST(RDbNotifier::TEvent, iStatus.Int()); switch (event) { case RDbNotifier::ECommit: /** A transaction has been committed. */ case RDbNotifier::ERecover: /** The database has been recovered */ +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug("QNCM CommsDB event (of type RDbNotifier::TEvent) received: %d", iStatus.Int()); +#endif // Mark that there is update pending. No need to ask more events, // as we know we will be updating anyway when the timer expires. if (!iUpdatePending) { @@ -1026,8 +1032,15 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TRequestStatus status; iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status); User::WaitForRequest(status); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // Check if status was regarding EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; @@ -1047,6 +1060,12 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // Check for EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; @@ -1149,6 +1168,12 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) User::WaitForRequest(status); QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+QString::number(qHash(apId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // If IAP was not found, check if the update was about EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { QMutexLocker configLocker(&ptr->mutex); #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG @@ -1164,6 +1189,43 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } } +#ifdef OCC_FUNCTIONALITY_AVAILABLE +// Tries to derive configuration from EasyWLAN. +// First checks if the interface brought up was EasyWLAN, then derives the real SSID, +// and looks up configuration based on that one. +QNetworkConfigurationPrivatePointer SymbianEngine::configurationFromEasyWlan(TUint32 apId, TUint connectionId) +{ + if (apId == iCmManager.EasyWlanIdL()) { + TRequestStatus status; + TBuf<50> easyWlanNetworkName; + iConnectionMonitor.GetStringAttribute( connectionId, 0, KNetworkName, + easyWlanNetworkName, status ); + User::WaitForRequest(status); + if (status.Int() == KErrNone) { + QString realSSID = QString::fromUtf16(easyWlanNetworkName.Ptr(), easyWlanNetworkName.Length()); + + // Browser through all items and check their name for match + QHash >::const_iterator i = + accessPointConfigurations.constBegin(); + while (i != accessPointConfigurations.constEnd()) { + QNetworkConfigurationPrivatePointer ptr = i.value(); + + QMutexLocker configLocker(&ptr->mutex); + + if (ptr->name == realSSID) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNCM EasyWlan uses real SSID: " << realSSID; +#endif + return ptr; + } + ++i; + } + } + } + return QNetworkConfigurationPrivatePointer(); +} +#endif + // Sessions may use this function to report configuration state changes, // because on some Symbian platforms (especially Symbian^3) all state changes are not // reported by the RConnectionMonitor, in particular in relation to stop() call, diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index d95d4d5..cfddc29 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -206,6 +206,9 @@ private: // For QNetworkSessionPrivate to indicate about state changes void configurationStateChangeReport(TUint32 accessPointId, QNetworkSession::State newState); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + QNetworkConfigurationPrivatePointer configurationFromEasyWlan(TUint32 apId, TUint connectionId); +#endif private: // Data bool iFirstUpdate; -- cgit v0.12 From 2faa2ff804a8ed4e0bb60a4d11cd424a0e160dc8 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 11 Jun 2010 13:03:19 +1000 Subject: Cherry pick fix for MOBILITY-1063 from Qt Mobility. 37ad80914f7acb8d4f3364d78e75d48cd14e8e2a --- .../bearer/symbian/qnetworksession_impl.cpp | 69 +++++------------- .../qnetworksession/test/tst_qnetworksession.cpp | 84 ++++++++++++++++++++-- 2 files changed, 96 insertions(+), 57 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 940281c..cce8095 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -83,9 +83,6 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() delete ipConnectionNotifier; ipConnectionNotifier = NULL; - // Cancel possible RConnection::Start() - Cancel(); - #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iMobility) { delete iMobility; @@ -93,7 +90,8 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() } #endif - iConnection.Close(); + // Cancel possible RConnection::Start() + Cancel(); iSocketServ.Close(); // Close global 'Open C' RConnection @@ -366,44 +364,6 @@ void QNetworkSessionPrivateImpl::open() } if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - // Search through existing connections. - // If there is already connection which matches to given IAP - // try to attach to existing connection. - TBool connected(EFalse); - TConnectionInfoBuf connInfo; - TUint count; - if (iConnection.EnumerateConnections(count) == KErrNone) { - for (TUint i=1; i<=count; i++) { - // Note: GetConnectionInfo expects 1-based index. - if (iConnection.GetConnectionInfo(i, connInfo) == KErrNone) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - if (connInfo().iIapId == symbianConfig->numericIdentifier()) { - if (iConnection.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { - activeConfig = publicConfig; -#ifndef QT_NO_NETWORKINTERFACE - activeInterface = interface(symbianConfig->numericIdentifier()); -#endif - connected = ETrue; - startTime = QDateTime::currentDateTime(); - // Use name of the IAP to open global 'Open C' RConnection - QByteArray nameAsByteArray = publicConfig.name().toUtf8(); - ifreq ifr; - memset(&ifr, 0, sizeof(struct ifreq)); - strcpy(ifr.ifr_name, nameAsByteArray.constData()); - error = setdefaultif(&ifr); - isOpen = true; - // Make sure that state will be Connected - newState(QNetworkSession::Connected); - emit quitPendingWaitsForOpened(); - break; - } - } - } - } - } - if (!connected) { SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); @@ -429,7 +389,6 @@ void QNetworkSessionPrivateImpl::open() SetActive(); } newState(QNetworkSession::Connecting); - } } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); @@ -508,15 +467,16 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) << "close() called, session state is: " << state << " and isOpen is : " << isOpen; #endif - if (!isOpen) { + + if (!isOpen && state != QNetworkSession::Connecting) { return; } // Mark this session as closed-by-user so that we are able to report // distinguish between stop() and close() state transitions // when reporting. iClosedByUser = true; - isOpen = false; + #ifndef OCC_FUNCTIONALITY_AVAILABLE // On Symbian^3 we need to keep track of active configuration longer // in case of empty-SNAP-triggered EasyWLAN. @@ -524,7 +484,6 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) #endif serviceConfig = QNetworkConfiguration(); - Cancel(); #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iMobility) { delete iMobility; @@ -538,7 +497,7 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iHandleStateNotificationsFromManager = true; } - iConnection.Close(); + Cancel(); // closes iConnection iSocketServ.Close(); // Close global 'Open C' RConnection. If OpenC supports, @@ -551,11 +510,20 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) setdefaultif(0); } - if (publicConfig.type() == QNetworkConfiguration::UserChoice) { + // If UserChoice, go down immediately. If some other configuration, + // go down immediately if there is no reports expected from the platform; + // in practice Connection Monitor is aware of connections only after + // KFinishedSelection event, and hence reports only after that event, but + // that does not seem to be trusted on all Symbian versions --> safest + // to go down. + if (publicConfig.type() == QNetworkConfiguration::UserChoice || state == QNetworkSession::Connecting) { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "going Disconnected because session was Connecting."; +#endif newState(QNetworkSession::Closing); newState(QNetworkSession::Disconnected); } - if (allowSignals) { emit closed(); } @@ -755,7 +723,7 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "roaming Error() occured"; + << "roaming Error() occured, isOpen is: " << isOpen; #endif if (isOpen) { isOpen = false; @@ -1361,7 +1329,6 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne case KFinishedSelection: if (aError == KErrNone) { - // The user successfully selected an IAP to be used break; } else diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index e4f2486..e4b8c14 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -75,17 +75,20 @@ private slots: void robustnessBombing(); + void sessionClosing_data(); + void sessionClosing(); + void outOfProcessSession(); void invalidSession(); void repeatedOpenClose_data(); void repeatedOpenClose(); - - void roamingErrorCodes(); - + void sessionStop_data(); void sessionStop(); + void roamingErrorCodes(); + void sessionProperties_data(); void sessionProperties(); @@ -131,6 +134,7 @@ void tst_QNetworkSession::initTestCase() // If you wish to skip tests, set value as false. This is often very convinient because tests are so lengthy. // Better way still would be to make this readable from a file. testsToRun["robustnessBombing"] = true; + testsToRun["sessionClosing"] = true; testsToRun["outOfProcessSession"] = true; testsToRun["invalidSession"] = true; testsToRun["repeatedOpenClose"] = true; @@ -265,6 +269,53 @@ void tst_QNetworkSession::robustnessBombing() testSession.reject(); } +void tst_QNetworkSession::sessionClosing_data() { + QTest::addColumn("bearerType"); + QTest::addColumn("configurationType"); + + QTest::newRow("WLAN_IAP") << "WLAN" << QNetworkConfiguration::InternetAccessPoint; + QTest::newRow("Cellular_IAP") << "cellular" << QNetworkConfiguration::InternetAccessPoint; + QTest::newRow("SNAP") << "bearer_type_not_relevant_with_SNAPs" << QNetworkConfiguration::ServiceNetwork; +} + +// Testcase for closing the session at unexpected times +void tst_QNetworkSession::sessionClosing() +{ + if (!testsToRun["sessionClosing"]) { + QSKIP("Temporary skip due to value set false (or it is missing) in testsToRun map", SkipAll); + } + QFETCH(QString, bearerType); + QFETCH(QNetworkConfiguration::Type, configurationType); + + // Update configurations so that WLANs are discovered too. + updateConfigurations(); + + // First check that opening once succeeds and determine if test is doable + QNetworkConfiguration config = suitableConfiguration(bearerType, configurationType); + if (!config.isValid()) { + QSKIP("No suitable configurations, skipping this round of repeated open-close test.", SkipSingle); + } + qDebug() << "Using following configuration to bomb with close(): " << config.name(); + QNetworkSession session(config); + if (!openSession(&session) || + !closeSession(&session)) { + QSKIP("Unable to open/close session, skipping this round of close() bombing.", SkipSingle); + } + + qDebug() << "Closing without issuing open()"; + session.close(); + + for (int i = 0; i < 25; i++) { + qDebug() << "Opening and then waiting: " << i * 100 << " ms before closing."; + session.open(); + QTest::qWait(i*100); + session.close(); + // Sooner or later session must end in Disconnected state, + // no matter what the phase was. + QTRY_VERIFY(session.state() == QNetworkSession::Disconnected); + QTest::qWait(200); // Give platform a breathe, otherwise we'll be catching other errors + } +} void tst_QNetworkSession::invalidSession() { @@ -1060,15 +1111,27 @@ void tst_QNetworkSession::sessionOpenCloseStop() QTRY_VERIFY(stateChangedSpy.count() > 0); state = qvariant_cast(stateChangedSpy.at(stateChangedSpy.count() - 1).at(0)); + for (int i = 0; i < stateChangedSpy.count(); i++) { + QNetworkSession::State state_temp = + qvariant_cast(stateChangedSpy.at(i).at(0)); + // Extra debug because a fragile point in testcase because statuses vary. + qDebug() << "------- Statechange spy at: " << i << " is " << state_temp; + } + if (state == QNetworkSession::Roaming) { QTRY_VERIFY(session.state() == QNetworkSession::Connected); QTRY_VERIFY(session2.state() == QNetworkSession::Connected); roamedSuccessfully = true; + } else if (state == QNetworkSession::Closing) { + QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); + QTRY_VERIFY(session.state() == QNetworkSession::Connected); + roamedSuccessfully = true; } else if (state == QNetworkSession::Disconnected) { QTRY_VERIFY(!errorSpy.isEmpty()); QTRY_VERIFY(session2.state() == QNetworkSession::Disconnected); } else if (state == QNetworkSession::Connected) { QTRY_VERIFY(errorSpy.isEmpty()); + if (stateChangedSpy.count() > 1) { state = qvariant_cast(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0)); QVERIFY(state == QNetworkSession::Roaming); @@ -1102,9 +1165,18 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(state == QNetworkSession::Closing); state = qvariant_cast(stateChangedSpy2.at(1).at(0)); QVERIFY(state == QNetworkSession::Disconnected); - } else { // Assume .count() == 1 - QCOMPARE(stateChangedSpy2.count(), 1); - QNetworkSession::State state = qvariant_cast(stateChangedSpy2.at(0).at(0)); + } else { + QVERIFY(stateChangedSpy2.count() >= 1); + + for (int i = 0; i < stateChangedSpy2.count(); i++) { + QNetworkSession::State state_temp = + qvariant_cast(stateChangedSpy2.at(i).at(0)); + // Extra debug because a fragile point in testcase. + qDebug() << "+++++ Statechange spy at: " << i << " is " << state_temp; + } + + QNetworkSession::State state = + qvariant_cast(stateChangedSpy2.at(stateChangedSpy2.count() - 1).at(0)); // Symbian version dependant. QVERIFY(state == QNetworkSession::Disconnected); } -- cgit v0.12 From 91413d5ad27e97a95df4ab9a25f8c71548dbf3c3 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 11 Jun 2010 13:11:06 +1000 Subject: Cherry pick fix for QTMOBILITY-253 from Qt Mobility. f3d7f49b7f6975cbfa65adeb10b281e2b37172ce --- examples/network/bearermonitor/bearermonitor_240_320.ui | 2 +- examples/network/bearermonitor/bearermonitor_640_480.ui | 2 +- examples/network/bearermonitor/bearermonitor_maemo.ui | 2 +- examples/network/bearermonitor/sessionwidget.ui | 2 +- examples/network/bearermonitor/sessionwidget_maemo.ui | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/network/bearermonitor/bearermonitor_240_320.ui b/examples/network/bearermonitor/bearermonitor_240_320.ui index ce9c2d1..93cfc5e 100644 --- a/examples/network/bearermonitor/bearermonitor_240_320.ui +++ b/examples/network/bearermonitor/bearermonitor_240_320.ui @@ -11,7 +11,7 @@ - Form + BearerMonitor diff --git a/examples/network/bearermonitor/bearermonitor_640_480.ui b/examples/network/bearermonitor/bearermonitor_640_480.ui index 941eaa0..52866bc 100644 --- a/examples/network/bearermonitor/bearermonitor_640_480.ui +++ b/examples/network/bearermonitor/bearermonitor_640_480.ui @@ -11,7 +11,7 @@ - Form + BearerMonitor diff --git a/examples/network/bearermonitor/bearermonitor_maemo.ui b/examples/network/bearermonitor/bearermonitor_maemo.ui index 5f17e7d..a7940c6 100644 --- a/examples/network/bearermonitor/bearermonitor_maemo.ui +++ b/examples/network/bearermonitor/bearermonitor_maemo.ui @@ -11,7 +11,7 @@ - Form + BearerMonitor diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui index 56a2d0e..4199109 100644 --- a/examples/network/bearermonitor/sessionwidget.ui +++ b/examples/network/bearermonitor/sessionwidget.ui @@ -11,7 +11,7 @@ - Form + Session Details diff --git a/examples/network/bearermonitor/sessionwidget_maemo.ui b/examples/network/bearermonitor/sessionwidget_maemo.ui index 86f915c..ca68246 100644 --- a/examples/network/bearermonitor/sessionwidget_maemo.ui +++ b/examples/network/bearermonitor/sessionwidget_maemo.ui @@ -11,7 +11,7 @@ - Form + Session Details -- cgit v0.12 From e8fb98b6fcbace6ed7be3e4112b6a7516129ade2 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 11 Jun 2010 13:17:25 +1000 Subject: Cherry pick fix for MOBILITY-1063 from Qt Mobility. 4713262c16cb3eba1f4beccb6962a1ae210479c0 --- .../bearer/symbian/qnetworksession_impl.cpp | 35 ++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index cce8095..1c581b6 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -53,10 +53,11 @@ QT_BEGIN_NAMESPACE QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) - : CActive(CActive::EPriorityUserInput), engine(engine), - ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), - iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iDeprecatedConnectionId(0), - iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) +: CActive(CActive::EPriorityUserInput), engine(engine), + iDynamicUnSetdefaultif(0), ipConnectionNotifier(0), + iHandleStateNotificationsFromManager(false), iFirstSync(true), iStoppedByUser(false), + iClosedByUser(false), iDeprecatedConnectionId(0), + iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) { CActiveScheduler::Add(this); @@ -69,6 +70,13 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) if (iOpenCLibrary.Load(_L("libc")) == KErrNone) { iDynamicUnSetdefaultif = (TOpenCUnSetdefaultifFunction)iOpenCLibrary.Lookup(597); } +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - "; + if (iDynamicUnSetdefaultif) + qDebug() << "dynamic setdefaultif() resolution succeeded. "; + else + qDebug() << "dynamic setdefaultif() resolution failed. "; +#endif TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -517,10 +525,25 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // that does not seem to be trusted on all Symbian versions --> safest // to go down. if (publicConfig.type() == QNetworkConfiguration::UserChoice || state == QNetworkSession::Connecting) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "going Disconnected because session was Connecting."; + + symbianConfig->mutex.lock(); + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "going Disconnected right away. Deprecating connection monitor ID: " + << symbianConfig->connectionId; + symbianConfig->mutex.unlock(); #endif + + // The connection has gone down, and processing of status updates must be + // stopped. Depending on platform, there may come 'connecting/connected' states + // considerably later (almost a second). Connection id is an increasing + // number, so this does not affect next _real_ 'conneting/connected' states. + symbianConfig->mutex.lock(); + iDeprecatedConnectionId = symbianConfig->connectionId; + symbianConfig->mutex.unlock(); newState(QNetworkSession::Closing); newState(QNetworkSession::Disconnected); } -- cgit v0.12 From d24c09fe2354135d233ca3374f0b6a7488f0615c Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Fri, 11 Jun 2010 13:42:13 +1000 Subject: Cherry pick fix for MOBILITY-800 from Qt Mobility. 21abc07dc396f08c888bf3cac96b535cc296cb00 --- .../bearer/symbian/qnetworksession_impl.cpp | 91 +++++++++------------- src/plugins/bearer/symbian/qnetworksession_impl.h | 1 - .../qnetworksession/test/tst_qnetworksession.cpp | 39 ++++++---- 3 files changed, 61 insertions(+), 70 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 1c581b6..15123be 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -56,8 +56,8 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) : CActive(CActive::EPriorityUserInput), engine(engine), iDynamicUnSetdefaultif(0), ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), iFirstSync(true), iStoppedByUser(false), - iClosedByUser(false), iDeprecatedConnectionId(0), - iError(QNetworkSession::UnknownSessionError), iALREnabled(0), iConnectInBackground(false) + iClosedByUser(false), iError(QNetworkSession::UnknownSessionError), iALREnabled(0), + iConnectInBackground(false) { CActiveScheduler::Add(this); @@ -73,9 +73,9 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - "; if (iDynamicUnSetdefaultif) - qDebug() << "dynamic setdefaultif() resolution succeeded. "; + qDebug() << "dynamic unsetdefaultif() is present in PIPS library. "; else - qDebug() << "dynamic setdefaultif() resolution failed. "; + qDebug() << "dynamic unsetdefaultif() not present in PIPS library. "; #endif TRAP_IGNORE(iConnectionMonitor.ConnectL()); @@ -108,6 +108,9 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() iConnectionMonitor.Close(); iOpenCLibrary.Close(); +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - destroyed (and setdefaultif(0))"; +#endif } void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId, TUint32 connMonId, QNetworkSession::State newState) @@ -115,18 +118,12 @@ void QNetworkSessionPrivateImpl::configurationStateChanged(TUint32 accessPointId if (iHandleStateNotificationsFromManager) { #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "configurationStateChanged from manager for IAP : " << QString::number(accessPointId) - << "configurationStateChanged connMon ID : " << QString::number(connMonId) - << " : to a state: " << newState - << " whereas my current state is: " << state; -#endif - if (connMonId == iDeprecatedConnectionId) { -#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "however status update from manager ignored because it related to already closed connection."; + << "configurationStateChanged from manager for IAP : " << QString::number(accessPointId) + << "connMon ID : " << QString::number(connMonId) << " : to a state: " << newState + << "whereas my current state is: " << state; +#else + Q_UNUSED(connMonId); #endif - return; - } this->newState(newState, accessPointId); } } @@ -250,6 +247,14 @@ QNetworkInterface QNetworkSessionPrivateImpl::interface(TUint iapId) const #ifndef QT_NO_NETWORKINTERFACE QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const { +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - " + << "currentInterface() requested, state: " << state + << "publicConfig validity: " << publicConfig.isValid(); + if (activeInterface.isValid()) + qDebug() << "interface is: " << activeInterface.humanReadableName(); +#endif + if (!publicConfig.isValid() || state != QNetworkSession::Connected) { return QNetworkInterface(); } @@ -339,7 +344,6 @@ void QNetworkSessionPrivateImpl::open() // Clear possible previous states iStoppedByUser = false; iClosedByUser = false; - iDeprecatedConnectionId = 0; TInt error = iSocketServ.Connect(); if (error != KErrNone) { @@ -396,7 +400,11 @@ void QNetworkSessionPrivateImpl::open() if (!IsActive()) { SetActive(); } - newState(QNetworkSession::Connecting); + // Avoid flip flop of states if the configuration is already + // active. IsOpen/opened() will indicate when ready. + if (state != QNetworkSession::Connected) { + newState(QNetworkSession::Connecting); + } } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(publicConfig)); @@ -420,7 +428,11 @@ void QNetworkSessionPrivateImpl::open() if (!IsActive()) { SetActive(); } - newState(QNetworkSession::Connecting); + // Avoid flip flop of states if the configuration is already + // active. IsOpen/opened() will indicate when ready. + if (state != QNetworkSession::Connected) { + newState(QNetworkSession::Connecting); + } } else if (publicConfig.type() == QNetworkConfiguration::UserChoice) { iKnownConfigsBeforeConnectionStart = engine->accessPointConfigurationIdentifiers(); iConnection.Start(iStatus); @@ -485,11 +497,6 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iClosedByUser = true; isOpen = false; -#ifndef OCC_FUNCTIONALITY_AVAILABLE - // On Symbian^3 we need to keep track of active configuration longer - // in case of empty-SNAP-triggered EasyWLAN. - activeConfig = QNetworkConfiguration(); -#endif serviceConfig = QNetworkConfiguration(); #ifdef SNAP_FUNCTIONALITY_AVAILABLE @@ -525,25 +532,10 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // that does not seem to be trusted on all Symbian versions --> safest // to go down. if (publicConfig.type() == QNetworkConfiguration::UserChoice || state == QNetworkSession::Connecting) { - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG - - symbianConfig->mutex.lock(); qDebug() << "QNS this : " << QString::number((uint)this) << " - " - << "going Disconnected right away. Deprecating connection monitor ID: " - << symbianConfig->connectionId; - symbianConfig->mutex.unlock(); + << "going disconnected right away, since either UserChoice or Connecting"; #endif - - // The connection has gone down, and processing of status updates must be - // stopped. Depending on platform, there may come 'connecting/connected' states - // considerably later (almost a second). Connection id is an increasing - // number, so this does not affect next _real_ 'conneting/connected' states. - symbianConfig->mutex.lock(); - iDeprecatedConnectionId = symbianConfig->connectionId; - symbianConfig->mutex.unlock(); newState(QNetworkSession::Closing); newState(QNetworkSession::Disconnected); } @@ -1191,6 +1183,12 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint return false; } + // Make sure that some lagging 'connecting' state-changes do not overwrite + // if we are already connected (may righfully still happen with roaming though). + if (state == QNetworkSession::Connected && newState == QNetworkSession::Connecting) { + return false; + } + bool emitSessionClosed = false; // If we abruptly go down and user hasn't closed the session, we've been aborted. @@ -1306,27 +1304,12 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint #endif } } - if (emitSessionClosed) { emit closed(); } if (state == QNetworkSession::Disconnected) { - // The connection has gone down, and processing of status updates must be - // stopped. Depending on platform, there may come 'connecting/connected' states - // considerably later (almost a second). Connection id is an increasing - // number, so this does not affect next _real_ 'conneting/connected' states. - - SymbianNetworkConfigurationPrivate *symbianConfig = - toSymbianConfig(privateConfiguration(publicConfig)); - - symbianConfig->mutex.lock(); - iDeprecatedConnectionId = symbianConfig->connectionId; - symbianConfig->mutex.unlock(); - -#ifdef OCC_FUNCTIONALITY_AVAILABLE // Just in case clear activeConfiguration. activeConfig = QNetworkConfiguration(); -#endif } return retVal; } diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 4b4f28c..284e771 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -167,7 +167,6 @@ private: // data bool iFirstSync; bool iStoppedByUser; bool iClosedByUser; - TUint32 iDeprecatedConnectionId; #ifdef SNAP_FUNCTIONALITY_AVAILABLE CActiveCommsMobilityApiExt* iMobility; diff --git a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index e4b8c14..24f6e52 100644 --- a/tests/auto/qnetworksession/test/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp @@ -680,7 +680,7 @@ void tst_QNetworkSession::sessionStop() QVERIFY(openSession(&innocentSession)); qDebug("Waiting for %d ms after open to make sure all platform indications are propagated", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); - qDebug("----------4.2 Calling closedSession.stop()"); + qDebug("----------4.2 Calling closedSession.stop()"); closedSession.stop(); qDebug("Waiting for %d ms to get all configurationChange signals from platform..", configWaitdelayInMs); QTest::qWait(configWaitdelayInMs); // Wait to get all relevant configurationChange() signals @@ -1088,21 +1088,28 @@ void tst_QNetworkSession::sessionOpenCloseStop() if (configuration.type() == QNetworkConfiguration::ServiceNetwork) { bool roamedSuccessfully = false; - QCOMPARE(stateChangedSpy2.count(), 4); + QNetworkSession::State state; + if (stateChangedSpy2.count() == 4) { + state = qvariant_cast(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Connecting); - QNetworkSession::State state = - qvariant_cast(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Connecting); + state = qvariant_cast(stateChangedSpy2.at(1).at(0)); + QVERIFY(state == QNetworkSession::Connected); - state = qvariant_cast(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Connected); + state = qvariant_cast(stateChangedSpy2.at(2).at(0)); + QVERIFY(state == QNetworkSession::Closing); - state = qvariant_cast(stateChangedSpy2.at(2).at(0)); - QVERIFY(state == QNetworkSession::Closing); + state = qvariant_cast(stateChangedSpy2.at(3).at(0)); + QVERIFY(state == QNetworkSession::Disconnected); + } else if (stateChangedSpy2.count() == 2) { + state = qvariant_cast(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Closing); - state = qvariant_cast(stateChangedSpy2.at(3).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); - + state = qvariant_cast(stateChangedSpy2.at(1).at(0)); + QVERIFY(state == QNetworkSession::Disconnected); + } else { + QFAIL("Unexpected amount of state changes when roaming."); + } QTRY_VERIFY(session.state() == QNetworkSession::Roaming || session.state() == QNetworkSession::Connected || @@ -1137,16 +1144,18 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(state == QNetworkSession::Roaming); } roamedSuccessfully = true; - } + } if (roamedSuccessfully) { + // Verify that you can open session based on the disconnected configuration QString configId = session.sessionProperty("ActiveConfiguration").toString(); - QNetworkConfiguration config = manager.configurationFromIdentifier(configId); + QNetworkConfiguration config = manager.configurationFromIdentifier(configId); QNetworkSession session3(config); QSignalSpy errorSpy3(&session3, SIGNAL(error(QNetworkSession::SessionError))); QSignalSpy sessionOpenedSpy3(&session3, SIGNAL(opened())); session3.open(); - session3.waitForOpened(); + session3.waitForOpened(); + QTest::qWait(1000); // Wait awhile to get all signals from platform if (session.isOpen()) QVERIFY(!sessionOpenedSpy3.isEmpty() || !errorSpy3.isEmpty()); session.stop(); -- cgit v0.12 From c5fa9ed38561a05325c798918e87549dd880af63 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 21 Jun 2010 15:55:18 +1000 Subject: Abort open early if network session is in the process of openning. --- .../bearer/symbian/qnetworksession_impl.cpp | 23 +++++++++++++++++----- src/plugins/bearer/symbian/qnetworksession_impl.h | 2 ++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 15123be..b6e11df 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -57,7 +57,7 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) iDynamicUnSetdefaultif(0), ipConnectionNotifier(0), iHandleStateNotificationsFromManager(false), iFirstSync(true), iStoppedByUser(false), iClosedByUser(false), iError(QNetworkSession::UnknownSessionError), iALREnabled(0), - iConnectInBackground(false) + iConnectInBackground(false), isOpening(false) { CActiveScheduler::Add(this); @@ -84,6 +84,7 @@ QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() { isOpen = false; + isOpening = false; // Cancel Connection Progress Notifications first. // Note: ConnectionNotifier must be destroyed before Canceling RConnection::Start() @@ -311,12 +312,14 @@ void QNetworkSessionPrivateImpl::open() #ifdef QT_BEARERMGMT_SYMBIAN_DEBUG qDebug() << "QNS this : " << QString::number((uint)this) << " - " << "open() called, session state is: " << state << " and isOpen is: " - << isOpen; + << isOpen << isOpening; #endif - if (isOpen || (state == QNetworkSession::Connecting)) { + + if (isOpen || isOpening) return; - } - + + isOpening = true; + // Stop handling IAP state change signals from QNetworkConfigurationManagerPrivate // => RConnection::ProgressNotification will be used for IAP/SNAP monitoring iHandleStateNotificationsFromManager = false; @@ -444,6 +447,7 @@ void QNetworkSessionPrivateImpl::open() if (error != KErrNone) { isOpen = false; + isOpening = false; iError = QNetworkSession::UnknownSessionError; emit QNetworkSessionPrivate::error(iError); if (ipConnectionNotifier) { @@ -496,6 +500,7 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) // when reporting. iClosedByUser = true; isOpen = false; + isOpening = false; serviceConfig = QNetworkConfiguration(); @@ -599,6 +604,7 @@ void QNetworkSessionPrivateImpl::stop() #endif // Since we are open, use RConnection to stop the interface isOpen = false; + isOpening = false; iStoppedByUser = true; newState(QNetworkSession::Closing); if (ipConnectionNotifier) { @@ -608,6 +614,7 @@ void QNetworkSessionPrivateImpl::stop() } iConnection.Stop(RConnection::EStopAuthoritative); isOpen = true; + isOpening = false; close(false); emit closed(); } @@ -742,6 +749,7 @@ void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) #endif if (isOpen) { isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::RoamingError; @@ -1048,6 +1056,7 @@ void QNetworkSessionPrivateImpl::RunL() if (error != KErrNone) { isOpen = false; + isOpening = false; iError = QNetworkSession::UnknownSessionError; QT_TRYCATCH_LEAVING(emit QNetworkSessionPrivate::error(iError)); Cancel(); @@ -1066,6 +1075,7 @@ void QNetworkSessionPrivateImpl::RunL() #endif isOpen = true; + isOpening = false; activeConfig = newActiveConfig; SymbianNetworkConfigurationPrivate *symbianConfig = @@ -1089,6 +1099,7 @@ void QNetworkSessionPrivateImpl::RunL() break; case KErrNotFound: // Connection failed isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::InvalidConfigurationError; @@ -1103,6 +1114,7 @@ void QNetworkSessionPrivateImpl::RunL() case KErrAlreadyExists: // Connection already exists default: isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); if (publicConfig.state() == QNetworkConfiguration::Undefined || @@ -1202,6 +1214,7 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint // application or session stops connection or when network drops // unexpectedly). isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::SessionAbortedError; diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 284e771..0754ace 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -182,6 +182,8 @@ private: // data TUint32 iOldRoamingIap; TUint32 iNewRoamingIap; + bool isOpening; + friend class ConnectionProgressNotifier; }; -- cgit v0.12