diff options
19 files changed, 510 insertions, 423 deletions
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri index 169c8b7..0450961 100644 --- a/src/network/bearer/bearer.pri +++ b/src/network/bearer/bearer.pri @@ -10,12 +10,7 @@ SOURCES += bearer/qnetworksession.cpp \ bearer/qnetworkconfigmanager.cpp \ bearer/qnetworkconfiguration.cpp -symbian_disabled { - HEADERS += bearer/qnetworksession_s60_p.h - - SOURCES += bearer/qnetworkconfiguration_s60_p.cpp \ - bearer/qnetworksession_s60_p.cpp -} else:maemo { +maemo { QT += dbus CONFIG += link_pkgconfig @@ -50,7 +45,6 @@ symbian_disabled { bearer/qbearerplugin.h SOURCES += bearer/qnetworkconfigmanager_p.cpp \ - bearer/qnetworksession_p.cpp \ bearer/qnetworksessionengine.cpp \ bearer/qbearerplugin.cpp diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index d7a813b..4ef1f09 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -110,7 +110,7 @@ private Q_SLOTS: void configurationChanged(QNetworkConfigurationPrivatePointer ptr); }; -QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate(); +Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate(); QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h index bfc42f5..40aea8b 100644 --- a/src/network/bearer/qnetworkconfiguration_p.h +++ b/src/network/bearer/qnetworkconfiguration_p.h @@ -75,13 +75,15 @@ public: serviceNetworkMembers.clear(); } - QString name; - QString bearer; - inline QString bearerName() const + virtual QString bearerName() const { return bearer; } + QString bearer; + + QString name; + bool isValid; QString id; QNetworkConfiguration::StateFlags state; diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.cpp b/src/network/bearer/qnetworkconfiguration_s60_p.cpp deleted file mode 100644 index 142415a..0000000 --- a/src/network/bearer/qnetworkconfiguration_s60_p.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtNetwork module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -QT_BEGIN_NAMESPACE - -QString QNetworkConfigurationPrivate::bearerName() const -{ - switch (bearer) { - case QNetworkConfigurationPrivate::BearerEthernet: return QLatin1String("Ethernet"); - case QNetworkConfigurationPrivate::BearerWLAN: return QLatin1String("WLAN"); - case QNetworkConfigurationPrivate::Bearer2G: return QLatin1String("2G"); - case QNetworkConfigurationPrivate::BearerCDMA2000: return QLatin1String("CDMA2000"); - case QNetworkConfigurationPrivate::BearerWCDMA: return QLatin1String("WCDMA"); - case QNetworkConfigurationPrivate::BearerHSPA: return QLatin1String("HSPA"); - case QNetworkConfigurationPrivate::BearerBluetooth: return QLatin1String("Bluetooth"); - case QNetworkConfigurationPrivate::BearerWiMAX: return QLatin1String("WiMAX"); - default: return QString(); - } -} - -QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp index 5f87d95..6b0ccaf 100644 --- a/src/network/bearer/qnetworksession.cpp +++ b/src/network/bearer/qnetworksession.cpp @@ -43,6 +43,8 @@ #include <QTimer> #include "qnetworksession.h" +#include "qnetworksessionengine_p.h" +#include "qnetworkconfigmanager_p.h" #if Q_WS_MAEMO_6 #include "qnetworksession_maemo_p.h" @@ -224,14 +226,25 @@ QT_BEGIN_NAMESPACE \sa QNetworkConfiguration */ QNetworkSession::QNetworkSession(const QNetworkConfiguration& connectionConfig, QObject* parent) - : QObject(parent) +: QObject(parent), d(0) { - d = new QNetworkSessionPrivate; - d->q = this; - d->publicConfig = connectionConfig; - d->syncStateWithInterface(); - QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()), - this, SIGNAL(opened())); + foreach (QNetworkSessionEngine *engine, qNetworkConfigurationManagerPrivate()->sessionEngines) { + if (engine->hasIdentifier(connectionConfig.identifier())) { + d = engine->createSessionBackend(); + d->q = this; + d->publicConfig = connectionConfig; + d->syncStateWithInterface(); + connect(d, SIGNAL(quitPendingWaitsForOpened()), this, SIGNAL(opened())); + connect(d, SIGNAL(error(QNetworkSession::SessionError)), + this, SIGNAL(error(QNetworkSession::SessionError))); + connect(d, SIGNAL(stateChanged(QNetworkSession::State)), + this, SIGNAL(stateChanged(QNetworkSession::State))); + connect(d, SIGNAL(closed()), this, SIGNAL(closed())); + connect(d, SIGNAL(newConfigurationActivated()), + this, SIGNAL(newConfigurationActivated())); + break; + } + } } /*! @@ -261,7 +274,8 @@ QNetworkSession::~QNetworkSession() */ void QNetworkSession::open() { - d->open(); + if (d) + d->open(); } /*! @@ -283,6 +297,9 @@ void QNetworkSession::open() */ bool QNetworkSession::waitForOpened(int msecs) { + if (!d) + return false; + if (d->isOpen) return true; @@ -320,7 +337,8 @@ bool QNetworkSession::waitForOpened(int msecs) */ void QNetworkSession::close() { - d->close(); + if (d) + d->close(); } /*! @@ -332,7 +350,8 @@ void QNetworkSession::close() */ void QNetworkSession::stop() { - d->stop(); + if (d) + d->stop(); } /*! @@ -342,61 +361,9 @@ void QNetworkSession::stop() */ QNetworkConfiguration QNetworkSession::configuration() const { - return d->publicConfig; + return d ? d->publicConfig : QNetworkConfiguration(); } -/* - Returns the type of bearer currently used by this session. The string is not translated and - therefore can not be shown to the user. The subsequent table presents the currently known - bearer types: - - \table - \header - \o Value - \o Description - \row - \o Unknown - \o The session is based on an unknown or unspecified bearer type. - \row - \o Ethernet - \o The session is based on Ethernet. - \row - \o WLAN - \o The session is based on Wireless LAN. - \row - \o 2G - \o The session uses CSD, GPRS, HSCSD, EDGE or cdmaOne. - \row - \o CDMA2000 - \o The session uses CDMA. - \row - \o WCDMA - \o The session uses W-CDMA/UMTS. - \row - \o HSPA - \o The session uses High Speed Packet Access. - \row - \o Bluetooth - \o The session uses Bluetooth. - \row - \o WiMAX - \o The session uses WiMAX. - \endtable - - If the session is based on a network configuration of type - \l QNetworkConfiguration::ServiceNetwork the type of the preferred or currently - active configuration is returned. Therefore the bearer type may change - over time. - - This function returns an empty string if this session is based on an invalid configuration, or - a network configuration of type \l QNetworkConfiguration::ServiceNetwork with no - \l {QNetworkConfiguration::children()}{children}. -*/ -/*QString QNetworkSession::bearerName() const -{ - return d->bearerName(); -}*/ - /*! Returns the network interface that is used by this session. @@ -408,7 +375,7 @@ QNetworkConfiguration QNetworkSession::configuration() const */ QNetworkInterface QNetworkSession::interface() const { - return d->currentInterface(); + return d ? d->currentInterface() : QNetworkInterface(); } /*! @@ -419,7 +386,7 @@ QNetworkInterface QNetworkSession::interface() const */ bool QNetworkSession::isOpen() const { - return d->isOpen; + return d ? d->isOpen : false; } /*! @@ -441,7 +408,7 @@ bool QNetworkSession::isOpen() const */ QNetworkSession::State QNetworkSession::state() const { - return d->state; + return d ? d->state : QNetworkSession::Invalid; } /*! @@ -451,7 +418,7 @@ QNetworkSession::State QNetworkSession::state() const */ QNetworkSession::SessionError QNetworkSession::error() const { - return d->error(); + return d ? d->error() : InvalidConfigurationError; } /*! @@ -462,7 +429,7 @@ QNetworkSession::SessionError QNetworkSession::error() const */ QString QNetworkSession::errorString() const { - return d->errorString(); + return d ? d->errorString() : tr("Invalid configuration."); } /*! @@ -520,6 +487,9 @@ QString QNetworkSession::errorString() const */ QVariant QNetworkSession::sessionProperty(const QString& key) const { + if (!d) + return QVariant(); + if (!d->publicConfig.isValid()) return QVariant(); @@ -553,6 +523,9 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const */ void QNetworkSession::setSessionProperty(const QString& key, const QVariant& value) { + if (!d) + return; + if (key == QLatin1String("ActiveConfiguration") || key == QLatin1String("UserChoiceConfiguration")) { return; @@ -571,7 +544,8 @@ void QNetworkSession::setSessionProperty(const QString& key, const QVariant& val */ void QNetworkSession::migrate() { - d->migrate(); + if (d) + d->migrate(); } /*! @@ -583,7 +557,8 @@ void QNetworkSession::ignore() { // Needed on at least Symbian platform: the roaming must be explicitly // ignore()'d or migrate()'d - d->ignore(); + if (d) + d->ignore(); } /*! @@ -596,7 +571,8 @@ void QNetworkSession::ignore() */ void QNetworkSession::accept() { - d->accept(); + if (d) + d->accept(); } /*! @@ -608,7 +584,8 @@ void QNetworkSession::accept() */ void QNetworkSession::reject() { - d->reject(); + if (d) + d->reject(); } @@ -626,7 +603,7 @@ void QNetworkSession::reject() */ quint64 QNetworkSession::bytesWritten() const { - return d->bytesWritten(); + return d ? d->bytesWritten() : Q_UINT64_C(0); } /*! @@ -643,7 +620,7 @@ quint64 QNetworkSession::bytesWritten() const */ quint64 QNetworkSession::bytesReceived() const { - return d->bytesReceived(); + return d ? d->bytesReceived() : Q_UINT64_C(0); } /*! @@ -651,7 +628,7 @@ quint64 QNetworkSession::bytesReceived() const */ quint64 QNetworkSession::activeTime() const { - return d->activeTime(); + return d ? d->activeTime() : Q_UINT64_C(0); } /*! @@ -670,11 +647,11 @@ void QNetworkSession::connectNotify(const char *signal) QObject::connectNotify(signal); //check for preferredConfigurationChanged() signal connect notification //This is not required on all platforms -#ifdef Q_OS_SYMBIAN_disabled - if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0) { + if (!d) + return; + + if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0) d->setALREnabled(true); - } -#endif } /*! @@ -690,11 +667,11 @@ void QNetworkSession::disconnectNotify(const char *signal) QObject::disconnectNotify(signal); //check for preferredConfigurationChanged() signal disconnect notification //This is not required on all platforms -#ifdef Q_OS_SYMBIAN_disabled - if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0) { + if (!d) + return; + + if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0) d->setALREnabled(false); - } -#endif } #include "moc_qnetworksession.cpp" diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h index cd73c9a..6395250 100644 --- a/src/network/bearer/qnetworksession_p.h +++ b/src/network/bearer/qnetworksession_p.h @@ -53,28 +53,26 @@ // We mean it. // -#include "qnetworkconfigmanager_p.h" #include "qnetworksession.h" -#include "qnetworksessionengine_p.h" +#include "qnetworkconfiguration_p.h" -#include "qnetworksession.h" #include <QNetworkInterface> -#include <QDateTime> QT_BEGIN_NAMESPACE -class QNetworkSessionEngine; - -class QNetworkSessionPrivate : public QObject +class Q_NETWORK_EXPORT QNetworkSessionPrivate : public QObject { Q_OBJECT + + friend class QNetworkSession; + public: - QNetworkSessionPrivate() : - tx_data(0), rx_data(0), m_activeTime(0), isOpen(false) + QNetworkSessionPrivate() + : state(QNetworkSession::Invalid), isOpen(false) { } - ~QNetworkSessionPrivate() + virtual ~QNetworkSessionPrivate() { } @@ -82,49 +80,46 @@ public: //that the state is immediately updated (w/o actually opening //a session). Also this function should take care of //notification hooks to discover future state changes. - void syncStateWithInterface(); + virtual void syncStateWithInterface() = 0; + + virtual QNetworkInterface currentInterface() const = 0; + virtual QVariant sessionProperty(const QString& key) const = 0; + virtual void setSessionProperty(const QString& key, const QVariant& value) = 0; - QNetworkInterface currentInterface() const; - QVariant sessionProperty(const QString& key) const; - void setSessionProperty(const QString& key, const QVariant& value); - QString bearerName() const; + virtual void open() = 0; + virtual void close() = 0; + virtual void stop() = 0; - void open(); - void close(); - void stop(); - void migrate(); - void accept(); - void ignore(); - void reject(); + virtual void setALREnabled(bool enabled) { } + virtual void migrate() = 0; + virtual void accept() = 0; + virtual void ignore() = 0; + virtual void reject() = 0; - QString errorString() const; //must return translated string - QNetworkSession::SessionError error() const; + virtual QString errorString() const = 0; //must return translated string + virtual QNetworkSession::SessionError error() const = 0; - quint64 bytesWritten() const; - quint64 bytesReceived() const; - quint64 activeTime() const; + virtual quint64 bytesWritten() const = 0; + virtual quint64 bytesReceived() const = 0; + virtual quint64 activeTime() const = 0; -private: - void updateStateFromServiceNetwork(); - void updateStateFromActiveConfig(); +protected: + inline QNetworkConfigurationPrivatePointer privateConfiguration(const QNetworkConfiguration &config) const + { + return config.d; + } Q_SIGNALS: //releases any pending waitForOpened() calls void quitPendingWaitsForOpened(); -private Q_SLOTS: - void networkConfigurationsChanged(); - void configurationChanged(const QNetworkConfiguration &config); - void forcedSessionClose(const QNetworkConfiguration &config); - void connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error); - -private: - QNetworkConfigurationManager manager; - - quint64 tx_data; - quint64 rx_data; - quint64 m_activeTime; + void error(QNetworkSession::SessionError error); + void stateChanged(QNetworkSession::State state); + void closed(); + void newConfigurationActivated(); + void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless); +protected: // The config set on QNetworkSession. QNetworkConfiguration publicConfig; @@ -140,19 +135,7 @@ private: QNetworkSession::State state; bool isOpen; - bool opened; - - QNetworkSessionEngine *engine; - - QNetworkSession::SessionError lastError; - - QNetworkSession* q; - friend class QNetworkSession; - -#if defined(BACKEND_NM) - QDateTime startTime; - void setActiveTimeStamp(); -#endif + QNetworkSession *q; }; QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworksessionengine_p.h b/src/network/bearer/qnetworksessionengine_p.h index a1a3370..02772cb 100644 --- a/src/network/bearer/qnetworksessionengine_p.h +++ b/src/network/bearer/qnetworksessionengine_p.h @@ -97,6 +97,8 @@ public: virtual QNetworkConfigurationManager::Capabilities capabilities() const = 0; + virtual QNetworkSessionPrivate *createSessionBackend() = 0; + public: //this table contains an up to date list of all configs at any time. //it must be updated if configurations change, are added/removed or diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro index 0015041..d039731 100644 --- a/src/plugins/bearer/generic/generic.pro +++ b/src/plugins/bearer/generic/generic.pro @@ -4,8 +4,11 @@ include(../../qpluginbase.pri) QT += network HEADERS += qgenericengine.h \ + ../qnetworksession_impl.h \ ../platformdefs_win.h -SOURCES += qgenericengine.cpp main.cpp +SOURCES += qgenericengine.cpp \ + ../qnetworksession_impl.cpp \ + main.cpp QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer target.path += $$[QT_INSTALL_PLUGINS]/bearer diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index d50aa75..e9770e1 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qgenericengine.h" +#include "../qnetworksession_impl.h" #include <QtNetwork/private/qnetworkconfiguration_p.h> @@ -142,8 +143,6 @@ static QString qGetInterfaceType(const QString &interface) QGenericEngine::QGenericEngine(QObject *parent) : QNetworkSessionEngine(parent) { - qDebug() << Q_FUNC_INFO; - connect(&pollTimer, SIGNAL(timeout()), this, SLOT(doRequestUpdate())); pollTimer.setInterval(10000); doRequestUpdate(); @@ -321,5 +320,10 @@ QNetworkConfigurationManager::Capabilities QGenericEngine::capabilities() const return QNetworkConfigurationManager::ForcedRoaming; } +QNetworkSessionPrivate *QGenericEngine::createSessionBackend() +{ + return new QNetworkSessionPrivateImpl; +} + QT_END_NAMESPACE diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h index 730301b..04b845e 100644 --- a/src/plugins/bearer/generic/qgenericengine.h +++ b/src/plugins/bearer/generic/qgenericengine.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate; +class QNetworkSessionPrivate; class QGenericEngine : public QNetworkSessionEngine { @@ -73,6 +74,8 @@ public: QNetworkConfigurationManager::Capabilities capabilities() const; + QNetworkSessionPrivate *createSessionBackend(); + private Q_SLOTS: void doRequestUpdate(); diff --git a/src/network/bearer/qnetworksession_p.cpp b/src/plugins/bearer/qnetworksession_impl.cpp index b615797..49a2d72 100644 --- a/src/network/bearer/qnetworksession_p.cpp +++ b/src/plugins/bearer/qnetworksession_impl.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,10 +39,11 @@ ** ****************************************************************************/ -#include "qnetworksession_p.h" -#include "qnetworksession.h" -#include "qnetworksessionengine_p.h" -#include "qnetworkconfigmanager_p.h" +#include "qnetworksession_impl.h" + +#include <QtNetwork/qnetworksession.h> +#include <QtNetwork/private/qnetworksessionengine_p.h> +#include <QtNetwork/private/qnetworkconfigmanager_p.h> #include <QtCore/qstringlist.h> #include <QtCore/qdebug.h> @@ -96,7 +97,7 @@ void QNetworkSessionManagerPrivate::forceSessionClose(const QNetworkConfiguratio emit forcedSessionClose(config); } -void QNetworkSessionPrivate::syncStateWithInterface() +void QNetworkSessionPrivateImpl::syncStateWithInterface() { connect(&manager, SIGNAL(updateCompleted()), this, SLOT(networkConfigurationsChanged())); connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)), @@ -136,16 +137,16 @@ void QNetworkSessionPrivate::syncStateWithInterface() networkConfigurationsChanged(); } -void QNetworkSessionPrivate::open() +void QNetworkSessionPrivateImpl::open() { if (serviceConfig.isValid()) { lastError = QNetworkSession::OperationNotSupportedError; - emit q->error(lastError); + emit QNetworkSessionPrivate::error(lastError); } else if (!isOpen) { if ((activeConfig.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) { lastError =QNetworkSession::InvalidConfigurationError; - emit q->error(lastError); + emit QNetworkSessionPrivate::error(lastError); return; } opened = true; @@ -153,7 +154,7 @@ void QNetworkSessionPrivate::open() if ((activeConfig.state() & QNetworkConfiguration::Active) != QNetworkConfiguration::Active && (activeConfig.state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) { state = QNetworkSession::Connecting; - emit q->stateChanged(state); + emit stateChanged(state); engine->connectToId(activeConfig.identifier()); } @@ -164,27 +165,27 @@ void QNetworkSessionPrivate::open() } } -void QNetworkSessionPrivate::close() +void QNetworkSessionPrivateImpl::close() { if (serviceConfig.isValid()) { lastError = QNetworkSession::OperationNotSupportedError; - emit q->error(lastError); + emit QNetworkSessionPrivate::error(lastError); } else if (isOpen) { opened = false; isOpen = false; - emit q->closed(); + emit closed(); } } -void QNetworkSessionPrivate::stop() +void QNetworkSessionPrivateImpl::stop() { if (serviceConfig.isValid()) { lastError = QNetworkSession::OperationNotSupportedError; - emit q->error(lastError); + emit QNetworkSessionPrivate::error(lastError); } else { if ((activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) { state = QNetworkSession::Closing; - emit q->stateChanged(state); + emit stateChanged(state); engine->disconnectFromId(activeConfig.identifier()); @@ -193,31 +194,31 @@ void QNetworkSessionPrivate::stop() opened = false; isOpen = false; - emit q->closed(); + emit closed(); } } -void QNetworkSessionPrivate::migrate() +void QNetworkSessionPrivateImpl::migrate() { qWarning("This platform does not support roaming (%s).", __FUNCTION__); } -void QNetworkSessionPrivate::accept() +void QNetworkSessionPrivateImpl::accept() { qWarning("This platform does not support roaming (%s).", __FUNCTION__); } -void QNetworkSessionPrivate::ignore() +void QNetworkSessionPrivateImpl::ignore() { qWarning("This platform does not support roaming (%s).", __FUNCTION__); } -void QNetworkSessionPrivate::reject() +void QNetworkSessionPrivateImpl::reject() { qWarning("This platform does not support roaming (%s).", __FUNCTION__); } -QNetworkInterface QNetworkSessionPrivate::currentInterface() const +QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const { if (!publicConfig.isValid() || !engine || state != QNetworkSession::Connected) return QNetworkInterface(); @@ -229,16 +230,16 @@ QNetworkInterface QNetworkSessionPrivate::currentInterface() const return QNetworkInterface::interfaceFromName(interface); } -QVariant QNetworkSessionPrivate::sessionProperty(const QString& /*key*/) const +QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString& /*key*/) const { return QVariant(); } -void QNetworkSessionPrivate::setSessionProperty(const QString& /*key*/, const QVariant& /*value*/) +void QNetworkSessionPrivateImpl::setSessionProperty(const QString& /*key*/, const QVariant& /*value*/) { } -/*QString QNetworkSessionPrivate::bearerName() const +/*QString QNetworkSessionPrivateImpl::bearerName() const { if (!publicConfig.isValid() || !engine) return QString(); @@ -246,7 +247,7 @@ void QNetworkSessionPrivate::setSessionProperty(const QString& /*key*/, const QV return engine->bearerName(activeConfig.identifier()); }*/ -QString QNetworkSessionPrivate::errorString() const +QString QNetworkSessionPrivateImpl::errorString() const { switch (lastError) { case QNetworkSession::UnknownSessionError: @@ -265,12 +266,12 @@ QString QNetworkSessionPrivate::errorString() const return QString(); } -QNetworkSession::SessionError QNetworkSessionPrivate::error() const +QNetworkSession::SessionError QNetworkSessionPrivateImpl::error() const { return lastError; } -quint64 QNetworkSessionPrivate::bytesWritten() const +quint64 QNetworkSessionPrivateImpl::bytesWritten() const { #if defined(BACKEND_NM) && 0 if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) { @@ -288,7 +289,7 @@ quint64 QNetworkSessionPrivate::bytesWritten() const return tx_data; } -quint64 QNetworkSessionPrivate::bytesReceived() const +quint64 QNetworkSessionPrivateImpl::bytesReceived() const { #if defined(BACKEND_NM) && 0 if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) { @@ -306,7 +307,7 @@ quint64 QNetworkSessionPrivate::bytesReceived() const return rx_data; } -quint64 QNetworkSessionPrivate::activeTime() const +quint64 QNetworkSessionPrivateImpl::activeTime() const { #if defined(BACKEND_NM) if (startTime.isNull()) { @@ -318,7 +319,7 @@ quint64 QNetworkSessionPrivate::activeTime() const return m_activeTime; } -void QNetworkSessionPrivate::updateStateFromServiceNetwork() +void QNetworkSessionPrivateImpl::updateStateFromServiceNetwork() { QNetworkSession::State oldState = state; @@ -339,13 +340,13 @@ void QNetworkSessionPrivate::updateStateFromServiceNetwork() this, SLOT(connectionError(QString,QNetworkSessionEngine::ConnectionError)), Qt::QueuedConnection); } - emit q->newConfigurationActivated(); + emit newConfigurationActivated(); } state = QNetworkSession::Connected; qDebug() << oldState << "->" << state; if (state != oldState) - emit q->stateChanged(state); + emit stateChanged(state); return; } @@ -357,10 +358,10 @@ void QNetworkSessionPrivate::updateStateFromServiceNetwork() qDebug() << oldState << "->" << state; if (state != oldState) - emit q->stateChanged(state); + emit stateChanged(state); } -void QNetworkSessionPrivate::updateStateFromActiveConfig() +void QNetworkSessionPrivateImpl::updateStateFromActiveConfig() { if (!engine) return; @@ -375,13 +376,13 @@ void QNetworkSessionPrivate::updateStateFromActiveConfig() if (!oldActive && isOpen) emit quitPendingWaitsForOpened(); if (oldActive && !isOpen) - emit q->closed(); + emit closed(); if (oldState != state) - emit q->stateChanged(state); + emit stateChanged(state); } -void QNetworkSessionPrivate::networkConfigurationsChanged() +void QNetworkSessionPrivateImpl::networkConfigurationsChanged() { if (serviceConfig.isValid()) updateStateFromServiceNetwork(); @@ -392,7 +393,7 @@ void QNetworkSessionPrivate::networkConfigurationsChanged() #endif } -void QNetworkSessionPrivate::configurationChanged(const QNetworkConfiguration &config) +void QNetworkSessionPrivateImpl::configurationChanged(const QNetworkConfiguration &config) { if (serviceConfig.isValid() && (config == serviceConfig || config == activeConfig)) updateStateFromServiceNetwork(); @@ -400,20 +401,20 @@ void QNetworkSessionPrivate::configurationChanged(const QNetworkConfiguration &c updateStateFromActiveConfig(); } -void QNetworkSessionPrivate::forcedSessionClose(const QNetworkConfiguration &config) +void QNetworkSessionPrivateImpl::forcedSessionClose(const QNetworkConfiguration &config) { if (activeConfig == config) { opened = false; isOpen = false; - emit q->closed(); + emit closed(); lastError = QNetworkSession::SessionAbortedError; - emit q->error(lastError); + emit QNetworkSessionPrivate::error(lastError); } } -void QNetworkSessionPrivate::connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error) +void QNetworkSessionPrivateImpl::connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error) { if (activeConfig.identifier() == id) { networkConfigurationsChanged(); @@ -430,12 +431,12 @@ void QNetworkSessionPrivate::connectionError(const QString &id, QNetworkSessionE } emit quitPendingWaitsForOpened(); - emit q->error(lastError); + emit QNetworkSessionPrivate::error(lastError); } } #if defined(BACKEND_NM) && 0 -void QNetworkSessionPrivate::setActiveTimeStamp() +void QNetworkSessionPrivateImpl::setActiveTimeStamp() { if(NetworkManagerAvailable()) { startTime = QDateTime(); diff --git a/src/plugins/bearer/qnetworksession_impl.h b/src/plugins/bearer/qnetworksession_impl.h new file mode 100644 index 0000000..104d1f0 --- /dev/null +++ b/src/plugins/bearer/qnetworksession_impl.h @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNETWORKSESSION_IMPL_H +#define QNETWORKSESSION_IMPL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtNetwork/private/qnetworkconfigmanager_p.h> +#include <QtNetwork/private/qnetworksessionengine_p.h> +#include <QtNetwork/private/qnetworksession_p.h> + +#include <QtCore/qdatetime.h> + +QT_BEGIN_NAMESPACE + +class QNetworkSessionEngine; + +class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate +{ + Q_OBJECT +public: + QNetworkSessionPrivateImpl() : + tx_data(0), rx_data(0), m_activeTime(0) + { + } + + ~QNetworkSessionPrivateImpl() + { + } + + //called by QNetworkSession constructor and ensures + //that the state is immediately updated (w/o actually opening + //a session). Also this function should take care of + //notification hooks to discover future state changes. + void syncStateWithInterface(); + + QNetworkInterface currentInterface() const; + QVariant sessionProperty(const QString& key) const; + void setSessionProperty(const QString& key, const QVariant& value); + + void open(); + void close(); + void stop(); + void migrate(); + void accept(); + void ignore(); + void reject(); + + QString errorString() const; //must return translated string + QNetworkSession::SessionError error() const; + + quint64 bytesWritten() const; + quint64 bytesReceived() const; + quint64 activeTime() const; + +private: + void updateStateFromServiceNetwork(); + void updateStateFromActiveConfig(); + +private Q_SLOTS: + void networkConfigurationsChanged(); + void configurationChanged(const QNetworkConfiguration &config); + void forcedSessionClose(const QNetworkConfiguration &config); + void connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error); + +private: + QNetworkConfigurationManager manager; + + quint64 tx_data; + quint64 rx_data; + quint64 m_activeTime; + + bool opened; + + QNetworkSessionEngine *engine; + + QNetworkSession::SessionError lastError; + +#if defined(BACKEND_NM) + QDateTime startTime; + void setActiveTimeStamp(); +#endif +}; + +QT_END_NAMESPACE + +#endif //QNETWORKSESSION_IMPL_H + diff --git a/src/plugins/bearer/symbian/main.cpp b/src/plugins/bearer/symbian/main.cpp index 8865f4d..22d654a 100644 --- a/src/plugins/bearer/symbian/main.cpp +++ b/src/plugins/bearer/symbian/main.cpp @@ -72,8 +72,6 @@ QStringList QSymbianEnginePlugin::keys() const QBearerEngine *QSymbianEnginePlugin::create(const QString &key) const { - qDebug() << Q_FUNC_INFO; - if (key == QLatin1String("symbian")) return new SymbianEngine; else diff --git a/src/network/bearer/qnetworksession_s60_p.cpp b/src/plugins/bearer/symbian/qnetworksession_impl.cpp index 4d427c8..24948cf 100644 --- a/src/network/bearer/qnetworksession_s60_p.cpp +++ b/src/plugins/bearer/symbian/qnetworksession_impl.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,10 +39,9 @@ ** ****************************************************************************/ -#include <qmobilityglobal.h> -#include "qnetworksession_s60_p.h" -#include "qnetworkconfiguration_s60_p.h" -#include "qnetworkconfigmanager_s60_p.h" +#include "qnetworksession_impl.h" +#include "symbianengine.h" + #include <es_enum.h> #include <es_sock.h> #include <in_sock.h> @@ -51,9 +50,9 @@ QT_BEGIN_NAMESPACE -QNetworkSessionPrivate::QNetworkSessionPrivate() - : CActive(CActive::EPriorityStandard), state(QNetworkSession::Invalid), - isOpen(false), ipConnectionNotifier(0), iError(QNetworkSession::UnknownSessionError), +QNetworkSessionPrivateImpl::QNetworkSessionPrivateImpl(SymbianEngine *engine) + : CActive(CActive::EPriorityStandard), engine(engine), ipConnectionNotifier(0), + iError(QNetworkSession::UnknownSessionError), iALREnabled(0) { CActiveScheduler::Add(this); @@ -67,7 +66,7 @@ QNetworkSessionPrivate::QNetworkSessionPrivate() TRAP_IGNORE(iConnectionMonitor.ConnectL()); } -QNetworkSessionPrivate::~QNetworkSessionPrivate() +QNetworkSessionPrivateImpl::~QNetworkSessionPrivateImpl() { isOpen = false; @@ -99,11 +98,10 @@ QNetworkSessionPrivate::~QNetworkSessionPrivate() iOpenCLibrary.Close(); } -void QNetworkSessionPrivate::syncStateWithInterface() +void QNetworkSessionPrivateImpl::syncStateWithInterface() { - if (!publicConfig.d) { + if (!privateConfiguration(publicConfig)) return; - } // Start monitoring changes in IAP states TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this)); @@ -143,7 +141,7 @@ void QNetworkSessionPrivate::syncStateWithInterface() if (state != QNetworkSession::Connected) { // There were no open connections to used IAP or SNAP - if ((publicConfig.d.data()->state & QNetworkConfiguration::Discovered) == + if ((privateConfiguration(publicConfig)->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) { newState(QNetworkSession::Disconnected); } else { @@ -152,7 +150,7 @@ void QNetworkSessionPrivate::syncStateWithInterface() } } -QNetworkInterface QNetworkSessionPrivate::interface(TUint iapId) const +QNetworkInterface QNetworkSessionPrivateImpl::interface(TUint iapId) const { QString interfaceName; @@ -190,7 +188,7 @@ QNetworkInterface QNetworkSessionPrivate::interface(TUint iapId) const return QNetworkInterface::interfaceFromName(interfaceName); } -QNetworkInterface QNetworkSessionPrivate::currentInterface() const +QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const { if (!publicConfig.isValid() || state != QNetworkSession::Connected) { return QNetworkInterface(); @@ -199,16 +197,16 @@ QNetworkInterface QNetworkSessionPrivate::currentInterface() const return activeInterface; } -QVariant QNetworkSessionPrivate::sessionProperty(const QString& /*key*/) const +QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString& /*key*/) const { return QVariant(); } -void QNetworkSessionPrivate::setSessionProperty(const QString& /*key*/, const QVariant& /*value*/) +void QNetworkSessionPrivateImpl::setSessionProperty(const QString& /*key*/, const QVariant& /*value*/) { } -QString QNetworkSessionPrivate::errorString() const +QString QNetworkSessionPrivateImpl::errorString() const { switch (iError) { case QNetworkSession::UnknownSessionError: @@ -226,14 +224,14 @@ QString QNetworkSessionPrivate::errorString() const return QString(); } -QNetworkSession::SessionError QNetworkSessionPrivate::error() const +QNetworkSession::SessionError QNetworkSessionPrivateImpl::error() const { return iError; } -void QNetworkSessionPrivate::open() +void QNetworkSessionPrivateImpl::open() { - if (isOpen || !publicConfig.d || (state == QNetworkSession::Connecting)) { + if (isOpen || !privateConfiguration(publicConfig) || (state == QNetworkSession::Connecting)) { return; } @@ -246,7 +244,7 @@ void QNetworkSessionPrivate::open() // Could not open RSocketServ newState(QNetworkSession::Invalid); iError = QNetworkSession::UnknownSessionError; - emit q->error(iError); + emit QNetworkSessionPrivate::error(iError); syncStateWithInterface(); return; } @@ -257,7 +255,7 @@ void QNetworkSessionPrivate::open() iSocketServ.Close(); newState(QNetworkSession::Invalid); iError = QNetworkSession::UnknownSessionError; - emit q->error(iError); + emit QNetworkSessionPrivate::error(iError); syncStateWithInterface(); return; } @@ -282,10 +280,10 @@ void QNetworkSessionPrivate::open() for (TUint i=1; i<=count; i++) { // Note: GetConnectionInfo expects 1-based index. if (iConnection.GetConnectionInfo(i, connInfo) == KErrNone) { - if (connInfo().iIapId == publicConfig.d.data()->numericId) { + if (connInfo().iIapId == toSymbianConfig(privateConfiguration(publicConfig))->numericId) { if (iConnection.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) { activeConfig = publicConfig; - activeInterface = interface(activeConfig.d.data()->numericId); + activeInterface = interface(toSymbianConfig(privateConfiguration(activeConfig))->numericId); connected = ETrue; startTime = QDateTime::currentDateTime(); if (iDynamicSetdefaultif) { @@ -309,7 +307,7 @@ void QNetworkSessionPrivate::open() if (!connected) { TCommDbConnPref pref; pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); - pref.SetIapId(publicConfig.d.data()->numericId); + pref.SetIapId(toSymbianConfig(privateConfiguration(publicConfig))->numericId); iConnection.Start(pref, iStatus); if (!IsActive()) { SetActive(); @@ -317,14 +315,14 @@ void QNetworkSessionPrivate::open() newState(QNetworkSession::Connecting); } } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { - TConnSnapPref snapPref(publicConfig.d.data()->numericId); + TConnSnapPref snapPref(toSymbianConfig(privateConfiguration(publicConfig))->numericId); iConnection.Start(snapPref, iStatus); if (!IsActive()) { SetActive(); } newState(QNetworkSession::Connecting); } else if (publicConfig.type() == QNetworkConfiguration::UserChoice) { - iKnownConfigsBeforeConnectionStart = ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->accessPointConfigurations.keys(); + iKnownConfigsBeforeConnectionStart = engine->accessPointConfigurations.keys(); iConnection.Start(iStatus); if (!IsActive()) { SetActive(); @@ -335,7 +333,7 @@ void QNetworkSessionPrivate::open() if (error != KErrNone) { isOpen = false; iError = QNetworkSession::UnknownSessionError; - emit q->error(iError); + emit QNetworkSessionPrivate::error(iError); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); } @@ -343,7 +341,7 @@ void QNetworkSessionPrivate::open() } } -TUint QNetworkSessionPrivate::iapClientCount(TUint aIAPId) const +TUint QNetworkSessionPrivateImpl::iapClientCount(TUint aIAPId) const { TRequestStatus status; TUint connectionCount; @@ -370,13 +368,13 @@ TUint QNetworkSessionPrivate::iapClientCount(TUint aIAPId) const return 0; } -void QNetworkSessionPrivate::close(bool allowSignals) +void QNetworkSessionPrivateImpl::close(bool allowSignals) { if (!isOpen) { return; } - TUint activeIap = activeConfig.d.data()->numericId; + TUint activeIap = toSymbianConfig(privateConfiguration(activeConfig))->numericId; isOpen = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); @@ -413,11 +411,11 @@ void QNetworkSessionPrivate::close(bool allowSignals) if (publicConfig.type() == QNetworkConfiguration::UserChoice) { newState(QNetworkSession::Disconnected); } - emit q->closed(); + emit closed(); } } -void QNetworkSessionPrivate::stop() +void QNetworkSessionPrivateImpl::stop() { if (!isOpen) { return; @@ -427,17 +425,17 @@ void QNetworkSessionPrivate::stop() iConnection.Stop(RConnection::EStopAuthoritative); isOpen = true; close(false); - emit q->closed(); + emit closed(); } -void QNetworkSessionPrivate::migrate() +void QNetworkSessionPrivateImpl::migrate() { #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility->MigrateToPreferredCarrier(); #endif } -void QNetworkSessionPrivate::ignore() +void QNetworkSessionPrivateImpl::ignore() { #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility->IgnorePreferredCarrier(); @@ -449,7 +447,7 @@ void QNetworkSessionPrivate::ignore() #endif } -void QNetworkSessionPrivate::accept() +void QNetworkSessionPrivateImpl::accept() { #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility->NewCarrierAccepted(); @@ -465,7 +463,7 @@ void QNetworkSessionPrivate::accept() #endif } -void QNetworkSessionPrivate::reject() +void QNetworkSessionPrivateImpl::reject() { #ifdef SNAP_FUNCTIONALITY_AVAILABLE iMobility->NewCarrierRejected(); @@ -478,7 +476,7 @@ void QNetworkSessionPrivate::reject() } #ifdef SNAP_FUNCTIONALITY_AVAILABLE -void QNetworkSessionPrivate::PreferredCarrierAvailable(TAccessPointInfo aOldAPInfo, +void QNetworkSessionPrivateImpl::PreferredCarrierAvailable(TAccessPointInfo aOldAPInfo, TAccessPointInfo aNewAPInfo, TBool aIsUpgrade, TBool aIsSeamless) @@ -490,8 +488,8 @@ void QNetworkSessionPrivate::PreferredCarrierAvailable(TAccessPointInfo aOldAPIn iALRUpgradingConnection = aIsUpgrade; QList<QNetworkConfiguration> configs = publicConfig.children(); for (int i=0; i < configs.count(); i++) { - if (configs[i].d.data()->numericId == aNewAPInfo.AccessPoint()) { - emit q->preferredConfigurationChanged(configs[i],aIsSeamless); + if (toSymbianConfig(privateConfiguration(configs[i]))->numericId == aNewAPInfo.AccessPoint()) { + emit preferredConfigurationChanged(configs[i], aIsSeamless); } } } else { @@ -499,23 +497,23 @@ void QNetworkSessionPrivate::PreferredCarrierAvailable(TAccessPointInfo aOldAPIn } } -void QNetworkSessionPrivate::NewCarrierActive(TAccessPointInfo /*aNewAPInfo*/, TBool /*aIsSeamless*/) +void QNetworkSessionPrivateImpl::NewCarrierActive(TAccessPointInfo /*aNewAPInfo*/, TBool /*aIsSeamless*/) { if (iALREnabled > 0) { - emit q->newConfigurationActivated(); + emit newConfigurationActivated(); } else { accept(); } } -void QNetworkSessionPrivate::Error(TInt /*aError*/) +void QNetworkSessionPrivateImpl::Error(TInt /*aError*/) { if (isOpen) { isOpen = false; activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::RoamingError; - emit q->error(iError); + emit QNetworkSessionPrivate::error(iError); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); @@ -526,12 +524,12 @@ void QNetworkSessionPrivate::Error(TInt /*aError*/) // => Following call makes sure that Session state // changes immediately to Disconnected. newState(QNetworkSession::Disconnected); - emit q->closed(); + emit closed(); } } #endif -void QNetworkSessionPrivate::setALREnabled(bool enabled) +void QNetworkSessionPrivateImpl::setALREnabled(bool enabled) { if (enabled) { iALREnabled++; @@ -540,7 +538,7 @@ void QNetworkSessionPrivate::setALREnabled(bool enabled) } } -QNetworkConfiguration QNetworkSessionPrivate::bestConfigFromSNAP(const QNetworkConfiguration& snapConfig) const +QNetworkConfiguration QNetworkSessionPrivateImpl::bestConfigFromSNAP(const QNetworkConfiguration& snapConfig) const { QNetworkConfiguration config; QList<QNetworkConfiguration> subConfigurations = snapConfig.children(); @@ -558,17 +556,17 @@ QNetworkConfiguration QNetworkSessionPrivate::bestConfigFromSNAP(const QNetworkC return config; } -quint64 QNetworkSessionPrivate::bytesWritten() const +quint64 QNetworkSessionPrivateImpl::bytesWritten() const { return transferredData(KUplinkData); } -quint64 QNetworkSessionPrivate::bytesReceived() const +quint64 QNetworkSessionPrivateImpl::bytesReceived() const { return transferredData(KDownlinkData); } -quint64 QNetworkSessionPrivate::transferredData(TUint dataType) const +quint64 QNetworkSessionPrivateImpl::transferredData(TUint dataType) const { if (!publicConfig.isValid()) { return 0; @@ -614,12 +612,12 @@ quint64 QNetworkSessionPrivate::transferredData(TUint dataType) const if (config.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> configs = config.children(); for (int i=0; i < configs.count(); i++) { - if (configs[i].d.data()->numericId == apId) { + if (toSymbianConfig(privateConfiguration(configs[i]))->numericId == apId) { configFound = true; break; } } - } else if (config.d.data()->numericId == apId) { + } else if (toSymbianConfig(privateConfiguration(config))->numericId == apId) { configFound = true; } if (configFound) { @@ -637,7 +635,7 @@ quint64 QNetworkSessionPrivate::transferredData(TUint dataType) const return transferredData; } -quint64 QNetworkSessionPrivate::activeTime() const +quint64 QNetworkSessionPrivateImpl::activeTime() const { if (!isOpen || startTime.isNull()) { return 0; @@ -645,7 +643,7 @@ quint64 QNetworkSessionPrivate::activeTime() const return startTime.secsTo(QDateTime::currentDateTime()); } -QNetworkConfiguration QNetworkSessionPrivate::activeConfiguration(TUint32 iapId) const +QNetworkConfiguration QNetworkSessionPrivateImpl::activeConfiguration(TUint32 iapId) const { if (iapId == 0) { _LIT(KSetting, "IAP\\Id"); @@ -657,7 +655,7 @@ QNetworkConfiguration QNetworkSessionPrivate::activeConfiguration(TUint32 iapId) // Try to search IAP from the used SNAP using IAP Id QList<QNetworkConfiguration> children = publicConfig.children(); for (int i=0; i < children.count(); i++) { - if (children[i].d.data()->numericId == iapId) { + if (toSymbianConfig(privateConfiguration(children[i]))->numericId == iapId) { return children[i]; } } @@ -671,11 +669,10 @@ QNetworkConfiguration QNetworkSessionPrivate::activeConfiguration(TUint32 iapId) // <=> 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; - pt.d = ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->accessPointConfigurations.value(QString::number(qHash(iapId))); - if (pt.d) { + QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier(QString::number(qHash(iapId))); + if (privateConfiguration(pt)) { for (int i=0; i < children.count(); i++) { - if (children[i].d.data()->mappingName == pt.d.data()->mappingName) { + if (toSymbianConfig(privateConfiguration(children[i]))->mappingName == toSymbianConfig(privateConfiguration(pt))->mappingName) { return children[i]; } } @@ -692,18 +689,17 @@ QNetworkConfiguration QNetworkSessionPrivate::activeConfiguration(TUint32 iapId) #endif if (publicConfig.type() == QNetworkConfiguration::UserChoice) { - if (publicConfig.d.data()->manager) { - QNetworkConfiguration pt; + if (engine) { + QNetworkConfiguration pt = QNetworkConfigurationManager().configurationFromIdentifier(QString::number(qHash(iapId))); // Try to found User Selected IAP from known IAPs (accessPointConfigurations) - pt.d = ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->accessPointConfigurations.value(QString::number(qHash(iapId))); - if (pt.d) { + if (pt.isValid()) { return pt; } else { // Check if new (WLAN) IAP was created in IAP/SNAP dialog // 1. Sync internal configurations array to commsdb first - ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->updateConfigurations(); + engine->updateConfigurations(); // 2. Check if new configuration was created during connection creation - QList<QString> knownConfigs = ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->accessPointConfigurations.keys(); + QList<QString> knownConfigs = engine->accessPointConfigurations.keys(); if (knownConfigs.count() > iKnownConfigsBeforeConnectionStart.count()) { // Configuration count increased => new configuration was created // => Search new, created configuration @@ -717,10 +713,9 @@ QNetworkConfiguration QNetworkSessionPrivate::activeConfiguration(TUint32 iapId) if (newIapId.isEmpty()) { newIapId = knownConfigs[knownConfigs.count()-1]; } - pt.d = ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->accessPointConfigurations.value(newIapId); - if (pt.d) { + pt = QNetworkConfigurationManager().configurationFromIdentifier(newIapId); + if (pt.isValid()) return pt; - } } } } @@ -730,7 +725,7 @@ QNetworkConfiguration QNetworkSessionPrivate::activeConfiguration(TUint32 iapId) return publicConfig; } -void QNetworkSessionPrivate::RunL() +void QNetworkSessionPrivateImpl::RunL() { TInt statusCode = iStatus.Int(); @@ -753,7 +748,7 @@ void QNetworkSessionPrivate::RunL() if (error != KErrNone) { isOpen = false; iError = QNetworkSession::UnknownSessionError; - emit q->error(iError); + emit QNetworkSessionPrivate::error(iError); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); @@ -770,11 +765,9 @@ void QNetworkSessionPrivate::RunL() #endif isOpen = true; activeConfig = newActiveConfig; - activeInterface = interface(activeConfig.d.data()->numericId); + activeInterface = interface(toSymbianConfig(privateConfiguration(activeConfig))->numericId); if (publicConfig.type() == QNetworkConfiguration::UserChoice) { - QNetworkConfiguration pt; - pt.d = activeConfig.d.data()->serviceNetworkPtr; - serviceConfig = pt; + serviceConfig = QNetworkConfigurationManager().configurationFromIdentifier(toSymbianConfig(privateConfiguration(activeConfig))->serviceNetworkPtr->id); } startTime = QDateTime::currentDateTime(); @@ -788,7 +781,7 @@ void QNetworkSessionPrivate::RunL() activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::InvalidConfigurationError; - emit q->error(iError); + emit QNetworkSessionPrivate::error(iError); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); @@ -802,7 +795,7 @@ void QNetworkSessionPrivate::RunL() activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::UnknownSessionError; - emit q->error(iError); + emit QNetworkSessionPrivate::error(iError); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); @@ -812,19 +805,19 @@ void QNetworkSessionPrivate::RunL() } } -void QNetworkSessionPrivate::DoCancel() +void QNetworkSessionPrivateImpl::DoCancel() { iConnection.Close(); } -bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint accessPointId) +bool QNetworkSessionPrivateImpl::newState(QNetworkSession::State newState, TUint accessPointId) { // Make sure that activeConfig is always updated when SNAP is signaled to be // connected. if (isOpen && publicConfig.type() == QNetworkConfiguration::ServiceNetwork && newState == QNetworkSession::Connected) { activeConfig = activeConfiguration(accessPointId); - activeInterface = interface(activeConfig.d.data()->numericId); + activeInterface = interface(toSymbianConfig(privateConfiguration(activeConfig))->numericId); } // Make sure that same state is not signaled twice in a row. @@ -847,7 +840,7 @@ bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint acc activeConfig = QNetworkConfiguration(); serviceConfig = QNetworkConfiguration(); iError = QNetworkSession::SessionAbortedError; - emit q->error(iError); + emit QNetworkSessionPrivate::error(iError); Cancel(); if (ipConnectionNotifier) { ipConnectionNotifier->StopNotifications(); @@ -860,44 +853,44 @@ bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint acc bool retVal = false; if (accessPointId == 0) { state = newState; - emit q->stateChanged(state); + emit stateChanged(state); retVal = true; } else { if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - if (publicConfig.d.data()->numericId == accessPointId) { + if (toSymbianConfig(privateConfiguration(publicConfig))->numericId == accessPointId) { state = newState; - emit q->stateChanged(state); + emit stateChanged(state); retVal = true; } } else if (publicConfig.type() == QNetworkConfiguration::UserChoice && isOpen) { - if (activeConfig.d.data()->numericId == accessPointId) { + if (toSymbianConfig(privateConfiguration(activeConfig))->numericId == accessPointId) { state = newState; - emit q->stateChanged(state); + emit stateChanged(state); retVal = true; } } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); for (int i = 0; i < subConfigurations.count(); i++) { - if (subConfigurations[i].d.data()->numericId == accessPointId) { + if (toSymbianConfig(privateConfiguration(subConfigurations[i]))->numericId == accessPointId) { if (newState == QNetworkSession::Connected) { // Make sure that when AccessPoint is reported to be Connected // also state of the related configuration changes to Active. - subConfigurations[i].d.data()->state = QNetworkConfiguration::Active; + privateConfiguration(subConfigurations[i])->state = QNetworkConfiguration::Active; state = newState; - emit q->stateChanged(state); + emit stateChanged(state); retVal = true; } else { if (newState == QNetworkSession::Disconnected) { // Make sure that when AccessPoint is reported to be disconnected // also state of the related configuration changes from Active to Defined. - subConfigurations[i].d.data()->state = QNetworkConfiguration::Defined; + privateConfiguration(subConfigurations[i])->state = QNetworkConfiguration::Defined; } QNetworkConfiguration config = bestConfigFromSNAP(publicConfig); if ((config.state() == QNetworkConfiguration::Defined) || (config.state() == QNetworkConfiguration::Discovered)) { state = newState; - emit q->stateChanged(state); + emit stateChanged(state); retVal = true; } } @@ -907,13 +900,13 @@ bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint acc } if (emitSessionClosed) { - emit q->closed(); + emit closed(); } return retVal; } -void QNetworkSessionPrivate::handleSymbianConnectionStatusChange(TInt aConnectionStatus, +void QNetworkSessionPrivateImpl::handleSymbianConnectionStatusChange(TInt aConnectionStatus, TInt aError, TUint accessPointId) { @@ -1000,7 +993,7 @@ void QNetworkSessionPrivate::handleSymbianConnectionStatusChange(TInt aConnectio } } -void QNetworkSessionPrivate::EventL(const CConnMonEventBase& aEvent) +void QNetworkSessionPrivateImpl::EventL(const CConnMonEventBase& aEvent) { switch (aEvent.EventType()) { @@ -1017,14 +1010,14 @@ void QNetworkSessionPrivate::EventL(const CConnMonEventBase& aEvent) if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); for (int i = 0; i < subConfigurations.count(); i++ ) { - if (subConfigurations[i].d.data()->connectionId == connectionId) { - apId = subConfigurations[i].d.data()->numericId; + if (toSymbianConfig(privateConfiguration(subConfigurations[i]))->connectionId == connectionId) { + apId = toSymbianConfig(privateConfiguration(subConfigurations[i]))->numericId; break; } } } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - if (publicConfig.d.data()->connectionId == connectionId) { - apId = publicConfig.d.data()->numericId; + if (toSymbianConfig(privateConfiguration(publicConfig))->connectionId == connectionId) { + apId = toSymbianConfig(privateConfiguration(publicConfig))->numericId; } } @@ -1048,14 +1041,14 @@ void QNetworkSessionPrivate::EventL(const CConnMonEventBase& aEvent) if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); for (int i = 0; i < subConfigurations.count(); i++ ) { - if (subConfigurations[i].d.data()->numericId == apId) { - subConfigurations[i].d.data()->connectionId = connectionId; + if (toSymbianConfig(privateConfiguration(subConfigurations[i]))->numericId == apId) { + toSymbianConfig(privateConfiguration(subConfigurations[i]))->connectionId = connectionId; break; } } } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - if (publicConfig.d.data()->numericId == apId) { - publicConfig.d.data()->connectionId = connectionId; + if (toSymbianConfig(privateConfiguration(publicConfig))->numericId == apId) { + toSymbianConfig(privateConfiguration(publicConfig))->connectionId = connectionId; } } } @@ -1071,14 +1064,14 @@ void QNetworkSessionPrivate::EventL(const CConnMonEventBase& aEvent) if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { QList<QNetworkConfiguration> subConfigurations = publicConfig.children(); for (int i = 0; i < subConfigurations.count(); i++ ) { - if (subConfigurations[i].d.data()->connectionId == connectionId) { - subConfigurations[i].d.data()->connectionId = 0; + if (toSymbianConfig(privateConfiguration(subConfigurations[i]))->connectionId == connectionId) { + toSymbianConfig(privateConfiguration(subConfigurations[i]))->connectionId = 0; break; } } } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) { - if (publicConfig.d.data()->connectionId == connectionId) { - publicConfig.d.data()->connectionId = 0; + if (toSymbianConfig(privateConfiguration(publicConfig))->connectionId == connectionId) { + toSymbianConfig(privateConfiguration(publicConfig))->connectionId = 0; } } } @@ -1090,7 +1083,7 @@ void QNetworkSessionPrivate::EventL(const CConnMonEventBase& aEvent) } } -ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivate& owner, RConnection& connection) +ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivateImpl &owner, RConnection &connection) : CActive(CActive::EPriorityStandard), iOwner(owner), iConnection(connection) { CActiveScheduler::Add(this); @@ -1129,6 +1122,4 @@ void ConnectionProgressNotifier::RunL() } } -#include "moc_qnetworksession_s60_p.cpp" - QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworksession_s60_p.h b/src/plugins/bearer/symbian/qnetworksession_impl.h index 9ac5ed8..2e75d96 100644 --- a/src/network/bearer/qnetworksession_s60_p.h +++ b/src/plugins/bearer/symbian/qnetworksession_impl.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QNETWORKSESSIONPRIVATE_H -#define QNETWORKSESSIONPRIVATE_H +#ifndef QNETWORKSESSION_IMPL_H +#define QNETWORKSESSION_IMPL_H // // W A R N I N G @@ -53,7 +53,7 @@ // We mean it. // -#include "qnetworksession.h" +#include <QtNetwork/private/qnetworksession_p.h> #include <QDateTime> @@ -70,18 +70,19 @@ typedef int(*TOpenCSetdefaultifFunction)(const struct ifreq*); QT_BEGIN_NAMESPACE class ConnectionProgressNotifier; +class SymbianEngine; #ifdef SNAP_FUNCTIONALITY_AVAILABLE -class QNetworkSessionPrivate : public QObject, public CActive, public MMobilityProtocolResp, - public MConnectionMonitorObserver +class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive, public MMobilityProtocolResp, + public MConnectionMonitorObserver #else -class QNetworkSessionPrivate : public QObject, public CActive, public MConnectionMonitorObserver +class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate, public CActive, public MConnectionMonitorObserver #endif { Q_OBJECT public: - QNetworkSessionPrivate(); - ~QNetworkSessionPrivate(); + QNetworkSessionPrivateImpl(SymbianEngine *engine); + ~QNetworkSessionPrivateImpl(); //called by QNetworkSession constructor and ensures //that the state is immediately updated (w/o actually opening @@ -96,7 +97,8 @@ public: void setALREnabled(bool enabled); void open(); - void close(bool allowSignals = true); + inline void close() { close(true); } + void close(bool allowSignals); void stop(); void migrate(); void accept(); @@ -105,6 +107,7 @@ public: QString errorString() const; //must return translated string QNetworkSession::SessionError error() const; + quint64 bytesWritten() const; quint64 bytesReceived() const; quint64 activeTime() const; @@ -121,10 +124,6 @@ public: // From MMobilityProtocolResp void Error(TInt aError); #endif -Q_SIGNALS: - //releases any pending waitForOpened() calls - void quitPendingWaitsForOpened(); - protected: // From CActive void RunL(); void DoCancel(); @@ -142,24 +141,10 @@ private: QNetworkInterface interface(TUint iapId) const; private: // data - // The config set on QNetworkSession - mutable QNetworkConfiguration publicConfig; - - // If publicConfig is a ServiceNetwork this is a copy of publicConfig. - // If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual - // ServiceNetwork configuration. - mutable QNetworkConfiguration serviceConfig; + SymbianEngine *engine; - // This is the actual active configuration currently in use by the session. - // Either a copy of publicConfig or one of serviceConfig.children(). - mutable QNetworkConfiguration activeConfig; - mutable QNetworkInterface activeInterface; - QNetworkSession::State state; - bool isOpen; - - QNetworkSession* q; QDateTime startTime; RLibrary iOpenCLibrary; @@ -182,14 +167,13 @@ private: // data TUint32 iOldRoamingIap; TUint32 iNewRoamingIap; - friend class QNetworkSession; friend class ConnectionProgressNotifier; }; class ConnectionProgressNotifier : public CActive { public: - ConnectionProgressNotifier(QNetworkSessionPrivate& owner, RConnection& connection); + ConnectionProgressNotifier(QNetworkSessionPrivateImpl &owner, RConnection &connection); ~ConnectionProgressNotifier(); void StartNotifications(); @@ -200,7 +184,7 @@ protected: // From CActive void DoCancel(); private: // Data - QNetworkSessionPrivate& iOwner; + QNetworkSessionPrivateImpl &iOwner; RConnection& iConnection; TNifProgressBuf iProgress; @@ -208,5 +192,5 @@ private: // Data QT_END_NAMESPACE -#endif //QNETWORKSESSIONPRIVATE_H +#endif //QNETWORKSESSION_IMPL_H diff --git a/src/plugins/bearer/symbian/symbian.pro b/src/plugins/bearer/symbian/symbian.pro index d3ffb37..9fd1a74 100644 --- a/src/plugins/bearer/symbian/symbian.pro +++ b/src/plugins/bearer/symbian/symbian.pro @@ -3,8 +3,12 @@ include(../../qpluginbase.pri) QT += network -HEADERS += symbianengine.h -SOURCES += symbianengine.cpp main.cpp +HEADERS += symbianengine.h \ + qnetworksession_impl.h + +SOURCES += symbianengine.cpp \ + qnetworksession_impl.cpp \ + main.cpp exists($${EPOCROOT}epoc32/release/winscw/udeb/cmmanager.lib)| \ exists($${EPOCROOT}epoc32/release/armv5/lib/cmmanager.lib) { diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp index 8c31990..f5c5007 100644 --- a/src/plugins/bearer/symbian/symbianengine.cpp +++ b/src/plugins/bearer/symbian/symbianengine.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "symbianengine.h" +#include "qnetworksession_impl.h" #include <commdb.h> #include <cdbcols.h> @@ -64,7 +65,7 @@ static const int KValueThatWillBeAddedToSNAPId = 1000; static const int KUserChoiceIAPId = 0; SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate() -: bearer(BearerUnknown), numericId(0), connectionId(0), manager(0) +: bearer(BearerUnknown), numericId(0), connectionId(0) { } @@ -72,16 +73,33 @@ SymbianNetworkConfigurationPrivate::~SymbianNetworkConfigurationPrivate() { } -inline SymbianNetworkConfigurationPrivate *toSymbianConfig(QNetworkConfigurationPrivatePointer ptr) -{ - return static_cast<SymbianNetworkConfigurationPrivate *>(ptr.data()); +QString SymbianNetworkConfigurationPrivate::bearerName() const +{ + switch (bearer) { + case BearerEthernet: + return QLatin1String("Ethernet"); + case BearerWLAN: + return QLatin1String("WLAN"); + case Bearer2G: + return QLatin1String("2G"); + case BearerCDMA2000: + return QLatin1String("CDMA2000"); + case BearerWCDMA: + return QLatin1String("WCDMA"); + case BearerHSPA: + return QLatin1String("HSPA"); + case BearerBluetooth: + return QLatin1String("Bluetooth"); + case BearerWiMAX: + return QLatin1String("WiMAX"); + default: + return QString(); + } } SymbianEngine::SymbianEngine(QObject *parent) : QNetworkSessionEngine(parent), CActive(CActive::EPriorityIdle), iInitOk(true) { - qDebug() << Q_FUNC_INFO; - CActiveScheduler::Add(this); TRAPD(error, ipCommsDB = CCommsDatabase::NewL(EDatabaseTypeIAP)); @@ -112,7 +130,6 @@ SymbianEngine::SymbianEngine(QObject *parent) cpPriv->type = QNetworkConfiguration::UserChoice; cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; cpPriv->roamingSupported = false; - cpPriv->manager = this; QNetworkConfigurationPrivatePointer ptr(cpPriv); userChoiceConfigurations.insert(ptr->id, ptr); @@ -139,6 +156,34 @@ SymbianEngine::~SymbianEngine() delete ipCommsDB; } +QString SymbianEngine::getInterfaceFromId(const QString &id) +{ + qFatal("getInterfaceFromId(%s) not implemented\n", qPrintable(id)); + return QString(); +} + +bool SymbianEngine::hasIdentifier(const QString &id) +{ + return accessPointConfigurations.contains(id) || + snapConfigurations.contains(id) || + userChoiceConfigurations.contains(id); +} + +void SymbianEngine::connectToId(const QString &id) +{ + qFatal("connectToId(%s) not implemented\n", qPrintable(id)); +} + +void SymbianEngine::disconnectFromId(const QString &id) +{ + qFatal("disconnectFromId(%s) not implemented\n", qPrintable(id)); +} + +QNetworkSession::State SymbianEngine::sessionStateForId(const QString &id) +{ + qFatal("sessionStateForId(%s) not implemented\n", qPrintable(id)); + return QNetworkSession::Invalid; +} QNetworkConfigurationManager::Capabilities SymbianEngine::capabilities() const { @@ -157,6 +202,11 @@ QNetworkConfigurationManager::Capabilities SymbianEngine::capabilities() const return capFlags; } +QNetworkSessionPrivate *SymbianEngine::createSessionBackend() +{ + return new QNetworkSessionPrivateImpl(this); +} + void SymbianEngine::requestUpdate() { if (!iInitOk || iUpdateGoingOn) { @@ -239,7 +289,6 @@ void SymbianEngine::updateConfigurationsL() cpPriv->type = QNetworkConfiguration::ServiceNetwork; cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; cpPriv->roamingSupported = false; - cpPriv->manager = this; QNetworkConfigurationPrivatePointer ptr(cpPriv); snapConfigurations.insert(ident, ptr); @@ -428,7 +477,6 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL( cpPriv->type = QNetworkConfiguration::InternetAccessPoint; cpPriv->purpose = QNetworkConfiguration::UnknownPurpose; cpPriv->roamingSupported = false; - cpPriv->manager = this; CleanupStack::Pop(cpPriv); return cpPriv; @@ -498,7 +546,6 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL( apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown; break; } - apNetworkConfiguration->manager = this; CleanupStack::PopAndDestroy(pApUtils); CleanupStack::PopAndDestroy(pAPItem); diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h index 0ca30da..cd5aa43 100644 --- a/src/plugins/bearer/symbian/symbianengine.h +++ b/src/plugins/bearer/symbian/symbianengine.h @@ -80,18 +80,23 @@ public: SymbianNetworkConfigurationPrivate(); ~SymbianNetworkConfigurationPrivate(); + QString bearerName() const; + Bearer bearer; TUint32 numericId; TUint connectionId; - TAny *manager; - QNetworkConfigurationPrivatePointer serviceNetworkPtr; QString mappingName; }; +inline SymbianNetworkConfigurationPrivate *toSymbianConfig(QNetworkConfigurationPrivatePointer ptr) +{ + return static_cast<SymbianNetworkConfigurationPrivate *>(ptr.data()); +} + class SymbianEngine : public QNetworkSessionEngine, public CActive, public MConnectionMonitorObserver { @@ -101,18 +106,20 @@ public: SymbianEngine(QObject *parent = 0); virtual ~SymbianEngine(); - QString getInterfaceFromId(const QString &id) { return QString(); } - bool hasIdentifier(const QString &id) { return false; } + QString getInterfaceFromId(const QString &id); + bool hasIdentifier(const QString &id); - void connectToId(const QString &id) { } - void disconnectFromId(const QString &id) { } + void connectToId(const QString &id); + void disconnectFromId(const QString &id); void requestUpdate(); - QNetworkSession::State sessionStateForId(const QString &id) { return QNetworkSession::Invalid; } + QNetworkSession::State sessionStateForId(const QString &id); QNetworkConfigurationManager::Capabilities capabilities() const; + QNetworkSessionPrivate *createSessionBackend(); + QNetworkConfigurationPrivatePointer defaultConfiguration(); Q_SIGNALS: diff --git a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp index 061108a..d3923e9 100644 --- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp +++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp @@ -82,7 +82,7 @@ private slots: private: QNetworkConfigurationManager manager; - uint inProcessSessionManagementCount; + int inProcessSessionManagementCount; #ifdef Q_WS_MAEMO_6 Maemo::IAPConf *iapconf; @@ -249,6 +249,9 @@ void tst_QNetworkSession::sessionProperties() if (!configuration.isValid()) { QVERIFY(configuration.bearerName().isEmpty()); } else { + qDebug() << "Type:" << configuration.type() + << "Bearer:" << configuration.bearerName(); + switch (configuration.type()) { case QNetworkConfiguration::ServiceNetwork: @@ -264,6 +267,8 @@ void tst_QNetworkSession::sessionProperties() // QNetworkSession::interface() should return an invalid interface unless // session is in the connected state. + qDebug() << "Session state:" << session.state(); + qDebug() << "Session iface:" << session.interface().isValid() << session.interface().name(); QCOMPARE(session.state() == QNetworkSession::Connected, session.interface().isValid()); if (!configuration.isValid()) { @@ -790,6 +795,8 @@ QDebug operator<<(QDebug debug, const QList<QNetworkConfiguration> &list) void tst_QNetworkSession::outOfProcessSession() { + qDebug() << "START"; + QNetworkConfigurationManager manager; QList<QNetworkConfiguration> before = manager.allConfigurations(QNetworkConfiguration::Active); @@ -805,13 +812,16 @@ void tst_QNetworkSession::outOfProcessSession() QLocalServer::removeServer("tst_qnetworksession"); oopServer.listen("tst_qnetworksession"); + qDebug() << "starting lackey"; QProcess lackey; lackey.start("qnetworksessionlackey"); + qDebug() << lackey.error() << lackey.errorString(); QVERIFY(lackey.waitForStarted()); + qDebug() << "waiting for connection"; QVERIFY(oopServer.waitForNewConnection(-1)); QLocalSocket *oopSocket = oopServer.nextPendingConnection(); - + qDebug() << "got connection"; do { QByteArray output; @@ -875,12 +885,12 @@ void tst_QNetworkSession::outOfProcessSession() break; case 1: QSKIP("No discovered configurations found.", SkipAll); - break; case 2: QSKIP("Lackey could not start session.", SkipAll); default: QSKIP("Lackey failed", SkipAll); } + qDebug("STOP"); } QTEST_MAIN(tst_QNetworkSession) |