diff options
Diffstat (limited to 'src/plugins/bearer/symbian/qnetworksession_impl.cpp')
-rw-r--r-- | src/plugins/bearer/symbian/qnetworksession_impl.cpp | 77 |
1 files changed, 65 insertions, 12 deletions
diff --git a/src/plugins/bearer/symbian/qnetworksession_impl.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 0737942..512ea51 100644 --- a/src/plugins/bearer/symbian/qnetworksession_impl.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -152,6 +152,7 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface() } } +#ifndef QT_NO_NETWORKINTERFACE QNetworkInterface QNetworkSessionPrivateImpl::interface(TUint iapId) const { QString interfaceName; @@ -189,7 +190,9 @@ QNetworkInterface QNetworkSessionPrivateImpl::interface(TUint iapId) const return QNetworkInterface::interfaceFromName(interfaceName); } +#endif +#ifndef QT_NO_NETWORKINTERFACE QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const { if (!publicConfig.isValid() || state != QNetworkSession::Connected) { @@ -198,6 +201,7 @@ QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const return activeInterface; } +#endif QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString& /*key*/) const { @@ -241,15 +245,24 @@ void QNetworkSessionPrivateImpl::open() // => RConnection::ProgressNotification will be used for IAP/SNAP monitoring iConnectionMonitor.CancelNotifications(); - // Configuration must be at least in Discovered - state for connecting purposes. - if ((publicConfig.state() & QNetworkConfiguration::Discovered) != - QNetworkConfiguration::Discovered) { + // Configuration may have been invalidated after session creation by platform + // (e.g. configuration has been deleted). + if (!publicConfig.isValid()) { newState(QNetworkSession::Invalid); iError = QNetworkSession::InvalidConfigurationError; emit QNetworkSessionPrivate::error(iError); syncStateWithInterface(); return; } + // If opening a (un)defined configuration, session emits error and enters + // NotAvailable -state. + if (publicConfig.state() == QNetworkConfiguration::Undefined || + publicConfig.state() == QNetworkConfiguration::Defined) { + newState(QNetworkSession::NotAvailable); + iError = QNetworkSession::InvalidConfigurationError; + emit QNetworkSessionPrivate::error(iError); + return; + } TInt error = iSocketServ.Connect(); if (error != KErrNone) { @@ -300,7 +313,9 @@ void QNetworkSessionPrivateImpl::open() if (connInfo().iIapId == symbianConfig->numericId) { if (iConnection.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { activeConfig = publicConfig; +#ifndef QT_NO_NETWORKINTERFACE activeInterface = interface(symbianConfig->numericId); +#endif connected = ETrue; startTime = QDateTime::currentDateTime(); if (iDynamicSetdefaultif) { @@ -450,15 +465,49 @@ void QNetworkSessionPrivateImpl::close(bool allowSignals) void QNetworkSessionPrivateImpl::stop() { - if (!isOpen) { - return; + if (!isOpen && + publicConfig.isValid() && + publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { + // If the publicConfig is type of IAP, enumerate through connections at + // connection monitor. If publicConfig is active in that list, stop it. + // Otherwise there is nothing to stop. Note: because this QNetworkSession is not open, + // activeConfig is not usable. + TUint count; + TRequestStatus status; + iConnectionMonitor.GetConnectionCount(count, status); + User::WaitForRequest(status); + if (status.Int() != KErrNone) { + return; + } + TUint numSubConnections; // Not used but needed by GetConnectionInfo i/f + TUint connectionId; + for (TInt i = 1; i <= count; ++i) { + // Get (connection monitor's assigned) connection ID + TInt ret = iConnectionMonitor.GetConnectionInfo(i, connectionId, numSubConnections); + if (ret == KErrNone) { + SymbianNetworkConfigurationPrivate *symbianConfig = + toSymbianConfig(privateConfiguration(publicConfig)); + + QMutexLocker configLocker(&symbianConfig->mutex); + + // See if connection Id matches with our Id. If so, stop() it. + if (symbianConfig->connectionId == connectionId) { + ret = iConnectionMonitor.SetBoolAttribute(connectionId, + 0, // subConnectionId don't care + KConnectionStop, + ETrue); + } + } + } + } else if (isOpen) { + // Since we are open, use RConnection to stop the interface + isOpen = false; + newState(QNetworkSession::Closing); + iConnection.Stop(RConnection::EStopAuthoritative); + isOpen = true; + close(false); + emit closed(); } - isOpen = false; - newState(QNetworkSession::Closing); - iConnection.Stop(RConnection::EStopAuthoritative); - isOpen = true; - close(false); - emit closed(); } void QNetworkSessionPrivateImpl::migrate() @@ -794,7 +843,7 @@ void QNetworkSessionPrivateImpl::RunL() TInt statusCode = iStatus.Int(); switch (statusCode) { - case KErrNone: // Connection created succesfully + case KErrNone: // Connection created successfully { TInt error = KErrNone; QNetworkConfiguration newActiveConfig = activeConfiguration(); @@ -835,7 +884,9 @@ void QNetworkSessionPrivateImpl::RunL() toSymbianConfig(privateConfiguration(activeConfig)); symbianConfig->mutex.lock(); +#ifndef QT_NO_NETWORKINTERFACE activeInterface = interface(symbianConfig->numericId); +#endif if (publicConfig.type() == QNetworkConfiguration::UserChoice) { serviceConfig = QNetworkConfigurationManager() .configurationFromIdentifier(symbianConfig->serviceNetworkPtr->id); @@ -893,9 +944,11 @@ bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint SymbianNetworkConfigurationPrivate *symbianConfig = toSymbianConfig(privateConfiguration(activeConfig)); +#ifndef QT_NO_NETWORKINTERFACE symbianConfig->mutex.lock(); activeInterface = interface(symbianConfig->numericId); symbianConfig->mutex.unlock(); +#endif #ifdef SNAP_FUNCTIONALITY_AVAILABLE if (iDynamicSetdefaultif) { |