diff options
author | axis <qt-info@nokia.com> | 2010-06-24 11:12:39 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2010-06-24 11:12:39 (GMT) |
commit | 5ce3b09f9b3c574fc4ab2ecc42f879e64df0e6a1 (patch) | |
tree | 8c7b8256e039f51f2642fda75471336a5a76dcfd | |
parent | 4df92b8b5e7f44d7a5e2b91f23638c92512b41f9 (diff) | |
parent | 3555687f5ff270c61499a5597444895bec0d70fb (diff) | |
download | Qt-5ce3b09f9b3c574fc4ab2ecc42f879e64df0e6a1.zip Qt-5ce3b09f9b3c574fc4ab2ecc42f879e64df0e6a1.tar.gz Qt-5ce3b09f9b3c574fc4ab2ecc42f879e64df0e6a1.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7-s60
34 files changed, 1174 insertions, 379 deletions
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/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<QTreeWidgetItem *> items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard); QMap<QString, QTreeWidgetItem *> itemMap; while (!items.isEmpty()) { 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 @@ </rect> </property> <property name="windowTitle"> - <string>Form</string> + <string>BearerMonitor</string> </property> <layout class="QVBoxLayout" name="verticalLayout_5"> <item> 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 @@ </rect> </property> <property name="windowTitle"> - <string>Form</string> + <string>BearerMonitor</string> </property> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> 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 @@ </rect> </property> <property name="windowTitle"> - <string>Form</string> + <string>BearerMonitor</string> </property> <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> 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/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 @@ </rect> </property> <property name="windowTitle"> - <string>Form</string> + <string>Session Details</string> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <item> 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 @@ </rect> </property> <property name="windowTitle"> - <string>Form</string> + <string>Session Details</string> </property> <layout class="QHBoxLayout" name="horizontalLayout"> <item> diff --git a/src/3rdparty/webkit/.tag b/src/3rdparty/webkit/.tag index 1eb0d78..21b75f0 100644 --- a/src/3rdparty/webkit/.tag +++ b/src/3rdparty/webkit/.tag @@ -1 +1 @@ -45d1c9149ef8940081fa8dd35854d2b95ebaf3cd +b3589e88fb8d581fb523578763831109f914dc2e diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 1a343eb..57c1cf6 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -4,4 +4,4 @@ This is a snapshot of the Qt port of WebKit from and has the sha1 checksum - 45d1c9149ef8940081fa8dd35854d2b95ebaf3cd + b3589e88fb8d581fb523578763831109f914dc2e diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index fd259e0..687b76b 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,12 @@ +2010-06-22 Simon Hausmann <simon.hausmann@nokia.com> + + Unreviewed Qt/Symbian build fix. + + Fix "make clean" to not try to execute clean commands for + the extra targets we use to simulate "make install". + + * WebCore.pro: Use no_clean in CONFIG of extra compilers. + 2010-06-21 Balazs Kelemen <kb@inf.u-szeged.hu> Reviewed by Simon Hausmann. diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index e0b4905..f0e41bc 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -2866,6 +2866,7 @@ HEADERS += $$WEBKIT_API_HEADERS # INSTALLS is not implemented in qmake's s60 generators, copy headers manually inst_headers.commands = $$QMAKE_COPY ${QMAKE_FILE_NAME} ${QMAKE_FILE_OUT} inst_headers.input = WEBKIT_INSTALL_HEADERS + inst_headers.CONFIG = no_clean !isEmpty(INSTALL_HEADERS): inst_headers.output = $$INSTALL_HEADERS/QtWebKit/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} else: inst_headers.output = $$[QT_INSTALL_HEADERS]/QtWebKit/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT} @@ -2875,6 +2876,7 @@ HEADERS += $$WEBKIT_API_HEADERS inst_modfile.commands = $$inst_headers.commands inst_modfile.input = moduleFile inst_modfile.output = $$[QMAKE_MKSPECS]/modules + inst_modfile.CONFIG = no_clean QMAKE_EXTRA_COMPILERS += inst_modfile diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 0e73680..050b1c1 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,31 @@ +2010-06-23 Alessandro Portale <alessandro.portale@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Provide the Webkit Qml plugin with a UID3 on Symbian + + ...otherwise we cannot Symbian sign it. + + * declarative/declarative.pro: + +2010-06-23 Simon Hausmann <simon.hausmann@nokia.com> + + Unreviewed Qt package build fix. + + When building without build-webkit, set OUTPUT_DIR if necessary, like + in the other .pro files. + + * declarative/declarative.pro: + +2010-06-22 Tasuku Suzuki <tasuku.suzuki@nokia.com> + + Reviewed by Simon Hausmann. + + [Qt] Fix compilation with QT_NO_COMBOBOX. + + * WebCoreSupport/ChromeClientQt.cpp: + (WebCore::ChromeClientQt::createSelectPopup): + 2010-06-11 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> Reviewed by nobody, build fix. diff --git a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp index 7d1c794..e253161 100644 --- a/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp +++ b/src/3rdparty/webkit/WebKit/qt/WebCoreSupport/ChromeClientQt.cpp @@ -576,7 +576,7 @@ QtAbstractWebPopup* ChromeClientQt::createSelectPopup() #elif !defined(QT_NO_COMBOBOX) return new QtFallbackWebPopup; #else - return result; + return 0; #endif } diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro index 1371e57..c75bbce 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro +++ b/src/3rdparty/webkit/WebKit/qt/declarative/declarative.pro @@ -6,6 +6,8 @@ CONFIG += qt plugin win32|mac:!wince*:!win32-msvc:!macx-xcode:CONFIG += debug_and_release +isEmpty(OUTPUT_DIR): OUTPUT_DIR = ../../.. + QMLDIRFILE = $${_PRO_FILE_PWD_}/qmldir copy2build.input = QMLDIRFILE CONFIG(QTDIR_build) { diff --git a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc index c2a38fd..fa93293 100644 --- a/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc +++ b/src/3rdparty/webkit/WebKit/qt/docs/qtwebkit-bridge.qdoc @@ -8,7 +8,7 @@ The QtWebKit bridge is a mechanism that extends WebKit's JavaScript environment to access native objects that are represented as \l{QObject}s. It takes advantage of the \l{QObject} introspection, - a part of the \l{Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, + a part of the \l{Qt Object Model}, which makes it easy to integrate with the dynamic JavaScript environment, for example \l{QObject} properties map directly to JavaScript properties. For example, both JavaScript and QObjects have properties: a construct that represent a getter/setter @@ -24,7 +24,7 @@ applications. For example, an application that contains a media-player, playlist manager, and music store. The playlist manager is usually best authored as a classic desktop application, with the native-looking robust \l{QWidget}s helping with producing that application. - The media-player control, which usually looks custom, can be written using the \l{Graphics View framework} + The media-player control, which usually looks custom, can be written using \l{The Graphics View framework} or with in a declarative way with \l{QtDeclarative}. The music store, which shows dynamic content from the internet and gets modified rapidly, is best authored in HTML and maintained on the server. 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; diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index e08d135..b6e11df 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -53,16 +53,30 @@ 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), iError(QNetworkSession::UnknownSessionError), iALREnabled(0), + iConnectInBackground(false), isOpening(false) { CActiveScheduler::Add(this); #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); + } +#ifdef QT_BEARERMGMT_SYMBIAN_DEBUG + qDebug() << "QNS this : " << QString::number((uint)this) << " - "; + if (iDynamicUnSetdefaultif) + qDebug() << "dynamic unsetdefaultif() is present in PIPS library. "; + else + qDebug() << "dynamic unsetdefaultif() not present in PIPS library. "; +#endif TRAP_IGNORE(iConnectionMonitor.ConnectL()); } @@ -70,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() @@ -77,9 +92,6 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() delete ipConnectionNotifier; ipConnectionNotifier = NULL; - // Cancel possible RConnection::Start() - Cancel(); - #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iMobility) { delete iMobility; @@ -87,13 +99,19 @@ QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() } #endif - iConnection.Close(); + // Cancel possible RConnection::Start() + Cancel(); iSocketServ.Close(); // Close global 'Open C' RConnection + // Clears also possible unsetdefaultif() flags. setdefaultif(0); 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) @@ -101,18 +119,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); } } @@ -236,6 +248,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(); } @@ -292,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; @@ -325,7 +347,6 @@ void QNetworkSessionPrivateImpl::open() // Clear possible previous states iStoppedByUser = false; iClosedByUser = false; - iDeprecatedConnectionId = 0; TInt error = iSocketServ.Connect(); if (error != KErrNone) { @@ -358,44 +379,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)); @@ -420,13 +403,20 @@ 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)); #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()); @@ -441,7 +431,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); @@ -453,6 +447,7 @@ void QNetworkSessionPrivateImpl::open() if (error != KErrNone) { isOpen = false; + isOpening = false; iError = QNetworkSession::UnknownSessionError; emit QNetworkSessionPrivate::error(iError); if (ipConnectionNotifier) { @@ -496,19 +491,19 @@ 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; - activeConfig = QNetworkConfiguration(); + isOpening = false; + serviceConfig = QNetworkConfiguration(); - Cancel(); #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iMobility) { delete iMobility; @@ -522,17 +517,33 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) iHandleStateNotificationsFromManager = true; } - iConnection.Close(); + Cancel(); // closes iConnection 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) { + // 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 right away, since either UserChoice or Connecting"; +#endif newState(QNetworkSession::Closing); newState(QNetworkSession::Disconnected); } - if (allowSignals) { emit closed(); } @@ -593,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) { @@ -602,6 +614,7 @@ void QNetworkSessionPrivateImpl::stop() } iConnection.Stop(RConnection::EStopAuthoritative); isOpen = true; + isOpening = false; close(false); emit closed(); } @@ -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(); } @@ -694,8 +712,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 +732,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(); } @@ -715,10 +745,11 @@ 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; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::RoamingError; @@ -727,18 +758,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 @@ -870,7 +907,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 @@ -892,8 +929,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)); @@ -907,20 +944,58 @@ 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<QString> 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(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; @@ -957,6 +1032,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) { @@ -977,13 +1056,14 @@ void QNetworkSessionPrivateImpl::RunL() if (error != KErrNone) { isOpen = false; + isOpening = 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; } @@ -995,6 +1075,7 @@ void QNetworkSessionPrivateImpl::RunL() #endif isOpen = true; + isOpening = false; activeConfig = newActiveConfig; SymbianNetworkConfigurationPrivate *symbianConfig = @@ -1010,26 +1091,30 @@ void QNetworkSessionPrivateImpl::RunL() startTime = QDateTime::currentDateTime(); - newState(QNetworkSession::Connected); - emit quitPendingWaitsForOpened(); + QT_TRYCATCH_LEAVING({ + newState(QNetworkSession::Connected); + emit quitPendingWaitsForOpened(); + }); } break; case KErrNotFound: // Connection failed isOpen = false; + isOpening = false; 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 default: isOpen = false; + isOpening = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); if (publicConfig.state() == QNetworkConfiguration::Undefined || @@ -1038,12 +1123,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; } } @@ -1110,6 +1195,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. @@ -1123,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; @@ -1187,7 +1279,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; @@ -1208,24 +1300,30 @@ 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 } } - 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)); - - iDeprecatedConnectionId = symbianConfig->connectionIdentifier(); + // Just in case clear activeConfiguration. + activeConfig = QNetworkConfiguration(); } - return retVal; } @@ -1250,7 +1348,6 @@ void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConne case KFinishedSelection: if (aError == KErrNone) { - // The user successfully selected an IAP to be used break; } else @@ -1364,7 +1461,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/qnetworksession_impl.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index b045ff1..0754ace 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; @@ -162,7 +167,6 @@ private: // data bool iFirstSync; bool iStoppedByUser; bool iClosedByUser; - TUint32 iDeprecatedConnectionId; #ifdef SNAP_FUNCTIONALITY_AVAILABLE CActiveCommsMobilityApiExt* iMobility; @@ -178,6 +182,8 @@ private: // data TUint32 iOldRoamingIap; TUint32 iNewRoamingIap; + bool isOpening; + friend class ConnectionProgressNotifier; }; diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index ab1ba28..ca444c1 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -46,7 +46,6 @@ #include <cdbcols.h> #include <d32dbms.h> #include <nifvar.h> -#include <QEventLoop> #include <QTimer> #include <QTime> // For randgen seeding #include <QtCore> // For randgen seeding @@ -73,9 +72,6 @@ QT_BEGIN_NAMESPACE -#ifdef SNAP_FUNCTIONALITY_AVAILABLE - static const int KValueThatWillBeAddedToSNAPId = 1000; -#endif static const int KUserChoiceIAPId = 0; SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() @@ -114,8 +110,8 @@ QString SymbianNetworkConfigurationPrivate::bearerName() const } SymbianEngine::SymbianEngine(QObject *parent) -: QBearerEngine(parent), CActive(CActive::EPriorityIdle), iFirstUpdate(true), iInitOk(true), - iIgnoringUpdates(false) +: QBearerEngine(parent), CActive(CActive::EPriorityHigh), iFirstUpdate(true), iInitOk(true), + iUpdatePending(false) { } @@ -135,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 @@ -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); @@ -261,7 +282,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 { @@ -272,7 +293,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(); } } @@ -288,15 +313,15 @@ 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 { 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 +338,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); @@ -325,7 +348,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) { @@ -336,7 +359,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); @@ -380,7 +403,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 { @@ -390,7 +413,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 +423,7 @@ void SymbianEngine::updateConfigurationsL() } CleanupStack::PopAndDestroy(pDbTView); #endif - updateActiveAccessPoints(); + QT_TRYCATCH_LEAVING(updateActiveAccessPoints()); foreach (const QString &oldIface, knownConfigs) { //remove non existing IAP @@ -408,6 +431,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 +455,7 @@ void SymbianEngine::updateConfigurationsL() mutex.unlock(); emit configurationRemoved(ptr); + QT_TRYCATCH_LEAVING(emit configurationRemoved(ptr)); mutex.lock(); } @@ -445,14 +470,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)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+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 +523,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 +541,6 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( cpPriv->type = QNetworkConfiguration::InternetAccessPoint; cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; cpPriv->roamingSupported = false; - - CleanupStack::Pop(cpPriv); return cpPriv; } #else @@ -550,9 +571,9 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( User::Leave(KErrNotFound); } - QString ident = QString::number(qHash(aApId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX+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; @@ -617,10 +638,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 @@ -658,8 +681,14 @@ 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); +#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); @@ -690,7 +719,7 @@ void SymbianEngine::updateActiveAccessPoints() if (iOnline != online) { iOnline = online; mutex.unlock(); - emit this->onlineStateChanged(iOnline); + emit this->onlineStateChanged(online); mutex.lock(); } } @@ -715,7 +744,8 @@ void SymbianEngine::accessPointScanningReady(TBool scanSuccessful, TConnMonIapIn // Set state of returned IAPs to Discovered // if state is not already Active for(TUint i=0; i<iapInfo.iCount; i++) { - QString ident = QString::number(qHash(iapInfo.iIap[i].iIapId)); + QString ident = QT_BEARERMGMT_CONFIGURATION_IAP_PREFIX + + QString::number(qHash(iapInfo.iIap[i].iIapId)); QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(ident); if (ptr) { unavailableConfigs.removeOne(ident); @@ -783,6 +813,59 @@ void SymbianEngine::updateStatesToSnaps() } } +#ifdef SNAP_FUNCTIONALITY_AVAILABLE +void SymbianEngine::updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo) +{ + QHash<QString, QNetworkConfigurationPrivatePointer>::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) { @@ -873,55 +956,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) { + // 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()); + 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) { - updateStatesToSnaps(); - } - locker.unlock(); - waitRandomTime(); - locker.relock(); - } else { - locker.unlock(); - waitRandomTime(); - locker.relock(); - TRAPD(error, updateConfigurationsL()); - if (error == KErrNone) { - updateStatesToSnaps(); + // 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) { @@ -945,6 +1003,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; @@ -960,14 +1032,23 @@ 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); +#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; 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 @@ -977,31 +1058,41 @@ 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); +#ifdef OCC_FUNCTIONALITY_AVAILABLE + if (!ptr) { + // Check for EasyWLAN + ptr = configurationFromEasyWlan(apId, connectionId); + } +#endif if (ptr) { ptr->mutex.lock(); toSymbianConfig(ptr)->connectionId = connectionId; 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 +1102,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 +1122,7 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) } if (iOnline != online) { iOnline = online; - emit this->onlineStateChanged(iOnline); + QT_TRYCATCH_LEAVING(emit this->onlineStateChanged(iOnline)); } } } @@ -1043,12 +1135,13 @@ void SymbianEngine::EventL(const CConnMonEventBase& aEvent) TConnMonIapInfo iaps = realEvent->IapAvailability(); QList<QString> 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) { // Configuration is either Discovered or Active - changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered); + QT_TRYCATCH_LEAVING(changeConfigurationStateAtMinTo(ptr, QNetworkConfiguration::Discovered)); unDiscoveredConfigs.removeOne(ident); } } @@ -1056,7 +1149,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)); } } } @@ -1073,8 +1166,14 @@ 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); +#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 @@ -1090,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<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> >::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, @@ -1107,7 +1243,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 @@ -1129,15 +1266,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) @@ -1158,7 +1293,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); } @@ -1198,9 +1333,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())); } } diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 18fd249..cfddc29 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; @@ -159,6 +162,7 @@ Q_SIGNALS: public Q_SLOTS: void updateConfigurations(); + void delayedConfigurationUpdate(); private: void updateStatesToSnaps(); @@ -169,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( @@ -183,7 +188,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; @@ -201,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; @@ -211,7 +219,7 @@ private: // Data TBool iOnline; TBool iInitOk; TBool iUpdateGoingOn; - TBool iIgnoringUpdates; + TBool iUpdatePending; AccessPointsAvailabilityScanner* ipAccessPointsAvailabilityScanner; 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/auto/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/qnetworksession/test/tst_qnetworksession.cpp index e4f2486..24f6e52 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<QString>("bearerType"); + QTest::addColumn<QNetworkConfiguration::Type>("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() { @@ -629,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 @@ -1037,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<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Connecting); - QNetworkSession::State state = - qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); - QVERIFY(state == QNetworkSession::Connecting); + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); + QVERIFY(state == QNetworkSession::Connected); - state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); - QVERIFY(state == QNetworkSession::Connected); + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(2).at(0)); + QVERIFY(state == QNetworkSession::Closing); - state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(2).at(0)); - QVERIFY(state == QNetworkSession::Closing); + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(3).at(0)); + QVERIFY(state == QNetworkSession::Disconnected); + } else if (stateChangedSpy2.count() == 2) { + state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); + QVERIFY(state == QNetworkSession::Closing); - state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(3).at(0)); - QVERIFY(state == QNetworkSession::Disconnected); - + state = qvariant_cast<QNetworkSession::State>(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 || @@ -1060,30 +1118,44 @@ void tst_QNetworkSession::sessionOpenCloseStop() QTRY_VERIFY(stateChangedSpy.count() > 0); state = qvariant_cast<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 1).at(0)); + for (int i = 0; i < stateChangedSpy.count(); i++) { + QNetworkSession::State state_temp = + qvariant_cast<QNetworkSession::State>(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<QNetworkSession::State>(stateChangedSpy.at(stateChangedSpy.count() - 2).at(0)); 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(); @@ -1102,9 +1174,18 @@ void tst_QNetworkSession::sessionOpenCloseStop() QVERIFY(state == QNetworkSession::Closing); state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(1).at(0)); QVERIFY(state == QNetworkSession::Disconnected); - } else { // Assume .count() == 1 - QCOMPARE(stateChangedSpy2.count(), 1); - QNetworkSession::State state = qvariant_cast<QNetworkSession::State>(stateChangedSpy2.at(0).at(0)); + } else { + QVERIFY(stateChangedSpy2.count() >= 1); + + for (int i = 0; i < stateChangedSpy2.count(); i++) { + QNetworkSession::State state_temp = + qvariant_cast<QNetworkSession::State>(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<QNetworkSession::State>(stateChangedSpy2.at(stateChangedSpy2.count() - 1).at(0)); // Symbian version dependant. QVERIFY(state == QNetworkSession::Disconnected); } diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp index bf60dd1..6f280db 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 <QtNetwork> @@ -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,15 @@ 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(int(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/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 <QDebug> +#include <QUrl> +#include <QByteArray> +#include <QDataStream> +#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 <QObject> +#include <QString> +#include <QNetworkReply> +#include <QNetworkAccessManager> +#include <QTcpSocket> +#include <QHttp> +#include <QDebug> + +// 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/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 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>SessionTab</class> - <widget class="QWidget" name="SessionTab" > - <layout class="QVBoxLayout" name="verticalLayout" > + <widget class="QWidget" name="SessionTab"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>192</width> + <height>262</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> <item> - <layout class="QFormLayout" name="formLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="snapLabel" > - <property name="text" > + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="snapLabel"> + <property name="text"> <string>SNAP</string> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="snapLineEdit" > - <property name="readOnly" > + <item row="0" column="1"> + <widget class="QLineEdit" name="snapLineEdit"> + <property name="readOnly"> <bool>true</bool> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QLabel" name="iapLabel" > - <property name="text" > + <item row="1" column="0"> + <widget class="QLabel" name="iapLabel"> + <property name="text"> <string>IAP</string> </property> </widget> </item> - <item row="1" column="1" > - <widget class="QLineEdit" name="iapLineEdit" > - <property name="enabled" > + <item row="1" column="1"> + <widget class="QLineEdit" name="iapLineEdit"> + <property name="enabled"> <bool>true</bool> </property> - <property name="readOnly" > + <property name="readOnly"> <bool>true</bool> </property> </widget> </item> - <item row="2" column="0" > - <widget class="QLabel" name="bearerLabel" > - <property name="text" > + <item row="2" column="0"> + <widget class="QLabel" name="bearerLabel"> + <property name="text"> <string>Bearer</string> </property> </widget> </item> - <item row="2" column="1" > - <widget class="QLineEdit" name="bearerLineEdit" > - <property name="readOnly" > + <item row="2" column="1"> + <widget class="QLineEdit" name="bearerLineEdit"> + <property name="readOnly"> <bool>true</bool> </property> </widget> </item> - <item row="3" column="0" > - <widget class="QLabel" name="sentRecDataLabel" > - <property name="text" > + <item row="3" column="0"> + <widget class="QLabel" name="sentRecDataLabel"> + <property name="text"> <string>Sent/Rec.</string> </property> </widget> </item> - <item row="3" column="1" > - <widget class="QLineEdit" name="sentRecDataLineEdit" > - <property name="readOnly" > + <item row="3" column="1"> + <widget class="QLineEdit" name="sentRecDataLineEdit"> + <property name="readOnly"> <bool>true</bool> </property> </widget> </item> - <item row="4" column="0" > - <widget class="QLabel" name="stateLabel" > - <property name="text" > + <item row="4" column="0"> + <widget class="QLabel" name="stateLabel"> + <property name="text"> <string>State</string> </property> </widget> </item> - <item row="4" column="1" > - <widget class="QLineEdit" name="stateLineEdit" > - <property name="readOnly" > + <item row="4" column="1"> + <widget class="QLineEdit" name="stateLineEdit"> + <property name="readOnly"> <bool>true</bool> </property> </widget> @@ -80,52 +89,71 @@ </layout> </item> <item> - <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" > - <widget class="QPushButton" name="openSessionButton" > - <property name="text" > + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QPushButton" name="openSessionButton"> + <property name="text"> <string>Open Session</string> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QPushButton" name="closeSessionButton" > - <property name="text" > + <item row="0" column="1"> + <widget class="QPushButton" name="closeSessionButton"> + <property name="text"> <string>Close Session</string> </property> </widget> </item> - <item row="1" column="0" > - <widget class="QPushButton" name="stopConnectionButton" > - <property name="text" > + <item row="1" column="0"> + <widget class="QPushButton" name="stopConnectionButton"> + <property name="text"> <string>Stop Conn.</string> </property> </widget> </item> - <item row="2" column="0" > - <widget class="QPushButton" name="createQHttpButton" > - <property name="text" > - <string>Create QHttp</string> + <item row="1" column="1"> + <widget class="QPushButton" name="alrButton"> + <property name="text"> + <string>Enable ALR</string> </property> </widget> </item> - <item row="2" column="1" > - <widget class="QPushButton" name="sendRequestButton" > - <property name="text" > + <item row="3" column="0"> + <widget class="QPushButton" name="sendRequestButton"> + <property name="text"> <string>Send Test Req.</string> </property> </widget> </item> - <item row="3" column="0" > - <widget class="QPushButton" name="alrButton" > - <property name="text" > - <string>Enable ALR</string> + <item row="2" column="1"> + <widget class="QPushButton" name="createQNetworkAccessManagerButton"> + <property name="text"> + <string>Create</string> </property> </widget> </item> - <item row="3" column="1" > - <widget class="QPushButton" name="deleteSessionButton" > - <property name="text" > + <item row="2" column="0"> + <widget class="QComboBox" name="comboBox"> + <item> + <property name="text"> + <string>QNAM</string> + </property> + </item> + <item> + <property name="text"> + <string>QTcpSocket</string> + </property> + </item> + <item> + <property name="text"> + <string>QHttp</string> + </property> + </item> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPushButton" name="deleteSessionButton"> + <property name="text"> <string>Delete Session</string> </property> </widget> @@ -135,5 +163,25 @@ </layout> </widget> <resources/> - <connections/> + <connections> + <connection> + <sender>comboBox</sender> + <signal>currentIndexChanged(QString)</signal> + <receiver>SessionTab</receiver> + <slot>on_dataObjectChanged(QString)</slot> + <hints> + <hint type="sourcelabel"> + <x>40</x> + <y>211</y> + </hint> + <hint type="destinationlabel"> + <x>10</x> + <y>258</y> + </hint> + </hints> + </connection> + </connections> + <slots> + <slot>on_dataObjectChanged(QString)</slot> + </slots> </ui> 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) ** |