summaryrefslogtreecommitdiffstats
path: root/src/network/bearer
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-01-18 04:26:49 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-01-18 04:26:49 (GMT)
commitb840dbe4ddd6937cd76c9c41baa16a8077224acd (patch)
treeab8d3a153b9162bf23a2472ea046353570a6a584 /src/network/bearer
parente620ab4a391ea1c86718856b31f6a5c4928a18a7 (diff)
downloadQt-b840dbe4ddd6937cd76c9c41baa16a8077224acd.zip
Qt-b840dbe4ddd6937cd76c9c41baa16a8077224acd.tar.gz
Qt-b840dbe4ddd6937cd76c9c41baa16a8077224acd.tar.bz2
Port session functionality.
Diffstat (limited to 'src/network/bearer')
-rw-r--r--src/network/bearer/bearer.pri8
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h2
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h8
-rw-r--r--src/network/bearer/qnetworkconfiguration_s60_p.cpp59
-rw-r--r--src/network/bearer/qnetworksession.cpp143
-rw-r--r--src/network/bearer/qnetworksession_p.cpp484
-rw-r--r--src/network/bearer/qnetworksession_p.h93
-rw-r--r--src/network/bearer/qnetworksession_s60_p.cpp1134
-rw-r--r--src/network/bearer/qnetworksession_s60_p.h212
-rw-r--r--src/network/bearer/qnetworksessionengine_p.h2
10 files changed, 107 insertions, 2038 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.cpp b/src/network/bearer/qnetworksession_p.cpp
deleted file mode 100644
index b615797..0000000
--- a/src/network/bearer/qnetworksession_p.cpp
+++ /dev/null
@@ -1,484 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qnetworksession_p.h"
-#include "qnetworksession.h"
-#include "qnetworksessionengine_p.h"
-#include "qnetworkconfigmanager_p.h"
-
-#include <QtCore/qstringlist.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qmutex.h>
-
-#include <QtNetwork/qnetworkinterface.h>
-
-QT_BEGIN_NAMESPACE
-
-static QNetworkSessionEngine *getEngineFromId(const QString &id)
-{
- QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
-
- foreach (QNetworkSessionEngine *engine, priv->sessionEngines) {
- if (engine->hasIdentifier(id))
- return engine;
- }
-
- return 0;
-}
-
-class QNetworkSessionManagerPrivate : public QObject
-{
- Q_OBJECT
-
-public:
- QNetworkSessionManagerPrivate(QObject *parent = 0);
- ~QNetworkSessionManagerPrivate();
-
- void forceSessionClose(const QNetworkConfiguration &config);
-
-Q_SIGNALS:
- void forcedSessionClose(const QNetworkConfiguration &config);
-};
-
-#include "qnetworksession_p.moc"
-
-Q_GLOBAL_STATIC(QNetworkSessionManagerPrivate, sessionManager);
-
-QNetworkSessionManagerPrivate::QNetworkSessionManagerPrivate(QObject *parent)
-: QObject(parent)
-{
-}
-
-QNetworkSessionManagerPrivate::~QNetworkSessionManagerPrivate()
-{
-}
-
-void QNetworkSessionManagerPrivate::forceSessionClose(const QNetworkConfiguration &config)
-{
- emit forcedSessionClose(config);
-}
-
-void QNetworkSessionPrivate::syncStateWithInterface()
-{
- connect(&manager, SIGNAL(updateCompleted()), this, SLOT(networkConfigurationsChanged()));
- connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)),
- this, SLOT(configurationChanged(QNetworkConfiguration)));
- connect(sessionManager(), SIGNAL(forcedSessionClose(QNetworkConfiguration)),
- this, SLOT(forcedSessionClose(QNetworkConfiguration)));
-
- opened = false;
- isOpen = false;
- state = QNetworkSession::Invalid;
- lastError = QNetworkSession::UnknownSessionError;
-
- qRegisterMetaType<QNetworkSessionEngine::ConnectionError>
- ("QNetworkSessionEngine::ConnectionError");
-
- switch (publicConfig.type()) {
- case QNetworkConfiguration::InternetAccessPoint:
- activeConfig = publicConfig;
- engine = getEngineFromId(activeConfig.identifier());
- if (engine) {
- connect(engine, SIGNAL(connectionError(QString,QNetworkSessionEngine::ConnectionError)),
- this, SLOT(connectionError(QString,QNetworkSessionEngine::ConnectionError)),
- Qt::QueuedConnection);
- }
- break;
- case QNetworkConfiguration::ServiceNetwork:
- serviceConfig = publicConfig;
- // Defer setting engine and signals until open().
- // fall through
- case QNetworkConfiguration::UserChoice:
- // Defer setting serviceConfig and activeConfig until open().
- // fall through
- default:
- engine = 0;
- }
-
- networkConfigurationsChanged();
-}
-
-void QNetworkSessionPrivate::open()
-{
- if (serviceConfig.isValid()) {
- lastError = QNetworkSession::OperationNotSupportedError;
- emit q->error(lastError);
- } else if (!isOpen) {
- if ((activeConfig.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- lastError =QNetworkSession::InvalidConfigurationError;
- emit q->error(lastError);
- return;
- }
- opened = true;
-
- if ((activeConfig.state() & QNetworkConfiguration::Active) != QNetworkConfiguration::Active &&
- (activeConfig.state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
- state = QNetworkSession::Connecting;
- emit q->stateChanged(state);
-
- engine->connectToId(activeConfig.identifier());
- }
-
- isOpen = (activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
- if (isOpen)
- emit quitPendingWaitsForOpened();
- }
-}
-
-void QNetworkSessionPrivate::close()
-{
- if (serviceConfig.isValid()) {
- lastError = QNetworkSession::OperationNotSupportedError;
- emit q->error(lastError);
- } else if (isOpen) {
- opened = false;
- isOpen = false;
- emit q->closed();
- }
-}
-
-void QNetworkSessionPrivate::stop()
-{
- if (serviceConfig.isValid()) {
- lastError = QNetworkSession::OperationNotSupportedError;
- emit q->error(lastError);
- } else {
- if ((activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- state = QNetworkSession::Closing;
- emit q->stateChanged(state);
-
- engine->disconnectFromId(activeConfig.identifier());
-
- sessionManager()->forceSessionClose(activeConfig);
- }
-
- opened = false;
- isOpen = false;
- emit q->closed();
- }
-}
-
-void QNetworkSessionPrivate::migrate()
-{
- qWarning("This platform does not support roaming (%s).", __FUNCTION__);
-}
-
-void QNetworkSessionPrivate::accept()
-{
- qWarning("This platform does not support roaming (%s).", __FUNCTION__);
-}
-
-void QNetworkSessionPrivate::ignore()
-{
- qWarning("This platform does not support roaming (%s).", __FUNCTION__);
-}
-
-void QNetworkSessionPrivate::reject()
-{
- qWarning("This platform does not support roaming (%s).", __FUNCTION__);
-}
-
-QNetworkInterface QNetworkSessionPrivate::currentInterface() const
-{
- if (!publicConfig.isValid() || !engine || state != QNetworkSession::Connected)
- return QNetworkInterface();
-
- QString interface = engine->getInterfaceFromId(activeConfig.identifier());
-
- if (interface.isEmpty())
- return QNetworkInterface();
- return QNetworkInterface::interfaceFromName(interface);
-}
-
-QVariant QNetworkSessionPrivate::sessionProperty(const QString& /*key*/) const
-{
- return QVariant();
-}
-
-void QNetworkSessionPrivate::setSessionProperty(const QString& /*key*/, const QVariant& /*value*/)
-{
-}
-
-/*QString QNetworkSessionPrivate::bearerName() const
-{
- if (!publicConfig.isValid() || !engine)
- return QString();
-
- return engine->bearerName(activeConfig.identifier());
-}*/
-
-QString QNetworkSessionPrivate::errorString() const
-{
- switch (lastError) {
- case QNetworkSession::UnknownSessionError:
- return tr("Unknown session error.");
- case QNetworkSession::SessionAbortedError:
- return tr("The session was aborted by the user or system.");
- case QNetworkSession::OperationNotSupportedError:
- return tr("The requested operation is not supported by the system.");
- case QNetworkSession::InvalidConfigurationError:
- return tr("The specified configuration cannot be used.");
- case QNetworkSession::RoamingError:
- return tr("Roaming was aborted or is not possible.");
-
- }
-
- return QString();
-}
-
-QNetworkSession::SessionError QNetworkSessionPrivate::error() const
-{
- return lastError;
-}
-
-quint64 QNetworkSessionPrivate::bytesWritten() const
-{
-#if defined(BACKEND_NM) && 0
- if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) {
- if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
- foreach (const QNetworkConfiguration &config, publicConfig.children()) {
- if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return static_cast<QNmWifiEngine*>(getEngineFromId(config.d->id))->sentDataForId(config.d->id);
- }
- }
- } else {
- return static_cast<QNmWifiEngine*>(getEngineFromId(activeConfig.d->id))->sentDataForId(activeConfig.d->id);
- }
- }
-#endif
- return tx_data;
-}
-
-quint64 QNetworkSessionPrivate::bytesReceived() const
-{
-#if defined(BACKEND_NM) && 0
- if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) {
- if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
- foreach (const QNetworkConfiguration &config, publicConfig.children()) {
- if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- return static_cast<QNmWifiEngine*>(getEngineFromId(activeConfig.d->id))->receivedDataForId(config.d->id);
- }
- }
- } else {
- return static_cast<QNmWifiEngine*>(getEngineFromId(activeConfig.d->id))->receivedDataForId(activeConfig.d->id);
- }
- }
-#endif
- return rx_data;
-}
-
-quint64 QNetworkSessionPrivate::activeTime() const
-{
-#if defined(BACKEND_NM)
- if (startTime.isNull()) {
- return 0;
- }
- if(state == QNetworkSession::Connected )
- return startTime.secsTo(QDateTime::currentDateTime());
-#endif
- return m_activeTime;
-}
-
-void QNetworkSessionPrivate::updateStateFromServiceNetwork()
-{
- QNetworkSession::State oldState = state;
-
- foreach (const QNetworkConfiguration &config, serviceConfig.children()) {
- if ((config.state() & QNetworkConfiguration::Active) != QNetworkConfiguration::Active)
- continue;
-
- if (activeConfig != config) {
- if (engine) {
- disconnect(engine, SIGNAL(connectionError(QString,QNetworkSessionEngine::ConnectionError)),
- this, SLOT(connectionError(QString,QNetworkSessionEngine::ConnectionError)));
- }
-
- activeConfig = config;
- engine = getEngineFromId(activeConfig.identifier());
- if (engine) {
- connect(engine, SIGNAL(connectionError(QString,QNetworkSessionEngine::ConnectionError)),
- this, SLOT(connectionError(QString,QNetworkSessionEngine::ConnectionError)),
- Qt::QueuedConnection);
- }
- emit q->newConfigurationActivated();
- }
-
- state = QNetworkSession::Connected;
- qDebug() << oldState << "->" << state;
- if (state != oldState)
- emit q->stateChanged(state);
-
- return;
- }
-
- if (serviceConfig.children().isEmpty())
- state = QNetworkSession::NotAvailable;
- else
- state = QNetworkSession::Disconnected;
-
- qDebug() << oldState << "->" << state;
- if (state != oldState)
- emit q->stateChanged(state);
-}
-
-void QNetworkSessionPrivate::updateStateFromActiveConfig()
-{
- if (!engine)
- return;
-
- QNetworkSession::State oldState = state;
-
- state = engine->sessionStateForId(activeConfig.identifier());
-
- bool oldActive = isOpen;
- isOpen = (state == QNetworkSession::Connected) ? opened : false;
-
- if (!oldActive && isOpen)
- emit quitPendingWaitsForOpened();
- if (oldActive && !isOpen)
- emit q->closed();
-
- if (oldState != state)
- emit q->stateChanged(state);
-}
-
-void QNetworkSessionPrivate::networkConfigurationsChanged()
-{
- if (serviceConfig.isValid())
- updateStateFromServiceNetwork();
- else
- updateStateFromActiveConfig();
-#if defined(BACKEND_NM) && 0
- setActiveTimeStamp();
-#endif
-}
-
-void QNetworkSessionPrivate::configurationChanged(const QNetworkConfiguration &config)
-{
- if (serviceConfig.isValid() && (config == serviceConfig || config == activeConfig))
- updateStateFromServiceNetwork();
- else if (config == activeConfig)
- updateStateFromActiveConfig();
-}
-
-void QNetworkSessionPrivate::forcedSessionClose(const QNetworkConfiguration &config)
-{
- if (activeConfig == config) {
- opened = false;
- isOpen = false;
-
- emit q->closed();
-
- lastError = QNetworkSession::SessionAbortedError;
- emit q->error(lastError);
- }
-}
-
-void QNetworkSessionPrivate::connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error)
-{
- if (activeConfig.identifier() == id) {
- networkConfigurationsChanged();
- switch (error) {
- case QNetworkSessionEngine::OperationNotSupported:
- lastError = QNetworkSession::OperationNotSupportedError;
- opened = false;
- break;
- case QNetworkSessionEngine::InterfaceLookupError:
- case QNetworkSessionEngine::ConnectError:
- case QNetworkSessionEngine::DisconnectionError:
- default:
- lastError = QNetworkSession::UnknownSessionError;
- }
-
- emit quitPendingWaitsForOpened();
- emit q->error(lastError);
- }
-}
-
-#if defined(BACKEND_NM) && 0
-void QNetworkSessionPrivate::setActiveTimeStamp()
-{
- if(NetworkManagerAvailable()) {
- startTime = QDateTime();
- return;
- }
- QString connectionIdent = q->configuration().identifier();
- QString interface = currentInterface().hardwareAddress().toLower();
- QString devicePath = "/org/freedesktop/Hal/devices/net_" + interface.replace(":","_");
-
- QString path;
- QString serviceName;
- QNetworkManagerInterface * ifaceD;
- ifaceD = new QNetworkManagerInterface();
-
- QList<QDBusObjectPath> connections = ifaceD->activeConnections();
- foreach(QDBusObjectPath conpath, connections) {
- QNetworkManagerConnectionActive *conDetails;
- conDetails = new QNetworkManagerConnectionActive(conpath.path());
- QDBusObjectPath connection = conDetails->connection();
- serviceName = conDetails->serviceName();
- QList<QDBusObjectPath> so = conDetails->devices();
- foreach(QDBusObjectPath device, so) {
-
- if(device.path() == devicePath) {
- path = connection.path();
- }
- break;
- }
- }
-if(serviceName.isEmpty())
- return;
- QNetworkManagerSettings *settingsiface;
- settingsiface = new QNetworkManagerSettings(serviceName);
- QList<QDBusObjectPath> list = settingsiface->listConnections();
- foreach(QDBusObjectPath path, list) {
- QNetworkManagerSettingsConnection *sysIface;
- sysIface = new QNetworkManagerSettingsConnection(serviceName, path.path());
- startTime = QDateTime::fromTime_t(sysIface->getTimestamp());
- // isOpen = (publicConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
- }
- if(startTime.isNull())
- startTime = QDateTime::currentDateTime();
-}
-#endif
-
-QT_END_NAMESPACE
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/qnetworksession_s60_p.cpp b/src/network/bearer/qnetworksession_s60_p.cpp
deleted file mode 100644
index 4d427c8..0000000
--- a/src/network/bearer/qnetworksession_s60_p.cpp
+++ /dev/null
@@ -1,1134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmobilityglobal.h>
-#include "qnetworksession_s60_p.h"
-#include "qnetworkconfiguration_s60_p.h"
-#include "qnetworkconfigmanager_s60_p.h"
-#include <es_enum.h>
-#include <es_sock.h>
-#include <in_sock.h>
-#include <stdapis/sys/socket.h>
-#include <stdapis/net/if.h>
-
-QT_BEGIN_NAMESPACE
-
-QNetworkSessionPrivate::QNetworkSessionPrivate()
- : CActive(CActive::EPriorityStandard), state(QNetworkSession::Invalid),
- isOpen(false), ipConnectionNotifier(0), iError(QNetworkSession::UnknownSessionError),
- iALREnabled(0)
-{
- CActiveScheduler::Add(this);
-
- // Try to load "Open C" dll dynamically and
- // try to attach to setdefaultif function dynamically.
- if (iOpenCLibrary.Load(_L("libc")) == KErrNone) {
- iDynamicSetdefaultif = (TOpenCSetdefaultifFunction)iOpenCLibrary.Lookup(564);
- }
-
- TRAP_IGNORE(iConnectionMonitor.ConnectL());
-}
-
-QNetworkSessionPrivate::~QNetworkSessionPrivate()
-{
- isOpen = false;
-
- // Cancel Connection Progress Notifications first.
- // Note: ConnectionNotifier must be destroyed before Canceling RConnection::Start()
- // => deleting ipConnectionNotifier results RConnection::CancelProgressNotification()
- delete ipConnectionNotifier;
- ipConnectionNotifier = NULL;
-
- // Cancel possible RConnection::Start()
- Cancel();
-
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- if (iMobility) {
- delete iMobility;
- iMobility = NULL;
- }
-#endif
-
- iConnection.Close();
- iSocketServ.Close();
- if (iDynamicSetdefaultif) {
- iDynamicSetdefaultif(0);
- }
-
- iConnectionMonitor.CancelNotifications();
- iConnectionMonitor.Close();
-
- iOpenCLibrary.Close();
-}
-
-void QNetworkSessionPrivate::syncStateWithInterface()
-{
- if (!publicConfig.d) {
- return;
- }
-
- // Start monitoring changes in IAP states
- TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this));
-
- // Check open connections to see if there is already
- // an open connection to selected IAP or SNAP
- TUint count;
- TRequestStatus status;
- iConnectionMonitor.GetConnectionCount(count, status);
- User::WaitForRequest(status);
- if (status.Int() != KErrNone) {
- return;
- }
-
- TUint numSubConnections;
- TUint connectionId;
- for (TUint i = 1; i <= count; i++) {
- TInt ret = iConnectionMonitor.GetConnectionInfo(i, connectionId, numSubConnections);
- if (ret == KErrNone) {
- TUint apId;
- iConnectionMonitor.GetUintAttribute(connectionId, 0, KIAPId, apId, status);
- User::WaitForRequest(status);
- if (status.Int() == KErrNone) {
- TInt connectionStatus;
- iConnectionMonitor.GetIntAttribute(connectionId, 0, KConnectionStatus, connectionStatus, status);
- User::WaitForRequest(status);
- if (connectionStatus == KLinkLayerOpen) {
- if (state != QNetworkSession::Closing) {
- if (newState(QNetworkSession::Connected, apId)) {
- return;
- }
- }
- }
- }
- }
- }
-
- if (state != QNetworkSession::Connected) {
- // There were no open connections to used IAP or SNAP
- if ((publicConfig.d.data()->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
- newState(QNetworkSession::Disconnected);
- } else {
- newState(QNetworkSession::NotAvailable);
- }
- }
-}
-
-QNetworkInterface QNetworkSessionPrivate::interface(TUint iapId) const
-{
- QString interfaceName;
-
- TSoInetInterfaceInfo ifinfo;
- TPckg<TSoInetInterfaceInfo> ifinfopkg(ifinfo);
- TSoInetIfQuery ifquery;
- TPckg<TSoInetIfQuery> ifquerypkg(ifquery);
-
- // Open dummy socket for interface queries
- RSocket socket;
- TInt retVal = socket.Open(iSocketServ, _L("udp"));
- if (retVal != KErrNone) {
- return QNetworkInterface();
- }
-
- // Start enumerating interfaces
- socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl);
- while(socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, ifinfopkg) == KErrNone) {
- ifquery.iName = ifinfo.iName;
- TInt err = socket.GetOpt(KSoInetIfQueryByName, KSolInetIfQuery, ifquerypkg);
- if(err == KErrNone && ifquery.iZone[1] == iapId) { // IAP ID is index 1 of iZone
- if(ifinfo.iAddress.Address() > 0) {
- interfaceName = QString::fromUtf16(ifinfo.iName.Ptr(),ifinfo.iName.Length());
- break;
- }
- }
- }
-
- socket.Close();
-
- if (interfaceName.isEmpty()) {
- return QNetworkInterface();
- }
-
- return QNetworkInterface::interfaceFromName(interfaceName);
-}
-
-QNetworkInterface QNetworkSessionPrivate::currentInterface() const
-{
- if (!publicConfig.isValid() || state != QNetworkSession::Connected) {
- return QNetworkInterface();
- }
-
- return activeInterface;
-}
-
-QVariant QNetworkSessionPrivate::sessionProperty(const QString& /*key*/) const
-{
- return QVariant();
-}
-
-void QNetworkSessionPrivate::setSessionProperty(const QString& /*key*/, const QVariant& /*value*/)
-{
-}
-
-QString QNetworkSessionPrivate::errorString() const
-{
- switch (iError) {
- case QNetworkSession::UnknownSessionError:
- return tr("Unknown session error.");
- case QNetworkSession::SessionAbortedError:
- return tr("The session was aborted by the user or system.");
- case QNetworkSession::OperationNotSupportedError:
- return tr("The requested operation is not supported by the system.");
- case QNetworkSession::InvalidConfigurationError:
- return tr("The specified configuration cannot be used.");
- case QNetworkSession::RoamingError:
- return tr("Roaming was aborted or is not possible.");
- }
-
- return QString();
-}
-
-QNetworkSession::SessionError QNetworkSessionPrivate::error() const
-{
- return iError;
-}
-
-void QNetworkSessionPrivate::open()
-{
- if (isOpen || !publicConfig.d || (state == QNetworkSession::Connecting)) {
- return;
- }
-
- // Cancel notifications from RConnectionMonitor
- // => RConnection::ProgressNotification will be used for IAP/SNAP monitoring
- iConnectionMonitor.CancelNotifications();
-
- TInt error = iSocketServ.Connect();
- if (error != KErrNone) {
- // Could not open RSocketServ
- newState(QNetworkSession::Invalid);
- iError = QNetworkSession::UnknownSessionError;
- emit q->error(iError);
- syncStateWithInterface();
- return;
- }
-
- error = iConnection.Open(iSocketServ);
- if (error != KErrNone) {
- // Could not open RConnection
- iSocketServ.Close();
- newState(QNetworkSession::Invalid);
- iError = QNetworkSession::UnknownSessionError;
- emit q->error(iError);
- syncStateWithInterface();
- return;
- }
-
- // Use RConnection::ProgressNotification for IAP/SNAP monitoring
- // (<=> ConnectionProgressNotifier uses RConnection::ProgressNotification)
- if (!ipConnectionNotifier) {
- ipConnectionNotifier = new ConnectionProgressNotifier(*this,iConnection);
- }
- if (ipConnectionNotifier) {
- ipConnectionNotifier->StartNotifications();
- }
-
- 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) {
- if (connInfo().iIapId == publicConfig.d.data()->numericId) {
- if (iConnection.Attach(connInfo, RConnection::EAttachTypeNormal) == KErrNone) {
- activeConfig = publicConfig;
- activeInterface = interface(activeConfig.d.data()->numericId);
- connected = ETrue;
- startTime = QDateTime::currentDateTime();
- if (iDynamicSetdefaultif) {
- // Use name of the IAP to set default IAP
- QByteArray nameAsByteArray = publicConfig.name().toUtf8();
- ifreq ifr;
- strcpy(ifr.ifr_name, nameAsByteArray.constData());
-
- error = iDynamicSetdefaultif(&ifr);
- }
- isOpen = true;
- // Make sure that state will be Connected
- newState(QNetworkSession::Connected);
- emit quitPendingWaitsForOpened();
- break;
- }
- }
- }
- }
- }
- if (!connected) {
- TCommDbConnPref pref;
- pref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
- pref.SetIapId(publicConfig.d.data()->numericId);
- iConnection.Start(pref, iStatus);
- if (!IsActive()) {
- SetActive();
- }
- newState(QNetworkSession::Connecting);
- }
- } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
- TConnSnapPref snapPref(publicConfig.d.data()->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();
- iConnection.Start(iStatus);
- if (!IsActive()) {
- SetActive();
- }
- newState(QNetworkSession::Connecting);
- }
-
- if (error != KErrNone) {
- isOpen = false;
- iError = QNetworkSession::UnknownSessionError;
- emit q->error(iError);
- if (ipConnectionNotifier) {
- ipConnectionNotifier->StopNotifications();
- }
- syncStateWithInterface();
- }
-}
-
-TUint QNetworkSessionPrivate::iapClientCount(TUint aIAPId) const
-{
- TRequestStatus status;
- TUint connectionCount;
- iConnectionMonitor.GetConnectionCount(connectionCount, status);
- User::WaitForRequest(status);
- if (status.Int() == KErrNone) {
- for (TUint i = 1; i <= connectionCount; i++) {
- TUint connectionId;
- TUint subConnectionCount;
- iConnectionMonitor.GetConnectionInfo(i, connectionId, subConnectionCount);
- TUint apId;
- iConnectionMonitor.GetUintAttribute(connectionId, subConnectionCount, KIAPId, apId, status);
- User::WaitForRequest(status);
- if (apId == aIAPId) {
- TConnMonClientEnumBuf buf;
- iConnectionMonitor.GetPckgAttribute(connectionId, 0, KClientInfo, buf, status);
- User::WaitForRequest(status);
- if (status.Int() == KErrNone) {
- return buf().iCount;
- }
- }
- }
- }
- return 0;
-}
-
-void QNetworkSessionPrivate::close(bool allowSignals)
-{
- if (!isOpen) {
- return;
- }
-
- TUint activeIap = activeConfig.d.data()->numericId;
- isOpen = false;
- activeConfig = QNetworkConfiguration();
- serviceConfig = QNetworkConfiguration();
-
- Cancel();
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- if (iMobility) {
- delete iMobility;
- iMobility = NULL;
- }
-#endif
-
- if (ipConnectionNotifier) {
- ipConnectionNotifier->StopNotifications();
- }
-
- iConnection.Close();
- iSocketServ.Close();
- if (iDynamicSetdefaultif) {
- iDynamicSetdefaultif(0);
- }
-
-#ifdef Q_CC_NOKIAX86
- if ((allowSignals && iapClientCount(activeIap) <= 0) ||
-#else
- if ((allowSignals && iapClientCount(activeIap) <= 1) ||
-#endif
- (publicConfig.type() == QNetworkConfiguration::UserChoice)) {
- newState(QNetworkSession::Closing);
- }
-
- syncStateWithInterface();
- if (allowSignals) {
- if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
- newState(QNetworkSession::Disconnected);
- }
- emit q->closed();
- }
-}
-
-void QNetworkSessionPrivate::stop()
-{
- if (!isOpen) {
- return;
- }
- isOpen = false;
- newState(QNetworkSession::Closing);
- iConnection.Stop(RConnection::EStopAuthoritative);
- isOpen = true;
- close(false);
- emit q->closed();
-}
-
-void QNetworkSessionPrivate::migrate()
-{
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- iMobility->MigrateToPreferredCarrier();
-#endif
-}
-
-void QNetworkSessionPrivate::ignore()
-{
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- iMobility->IgnorePreferredCarrier();
- if (!iALRUpgradingConnection) {
- newState(QNetworkSession::Disconnected);
- } else {
- newState(QNetworkSession::Connected,iOldRoamingIap);
- }
-#endif
-}
-
-void QNetworkSessionPrivate::accept()
-{
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- iMobility->NewCarrierAccepted();
- if (iDynamicSetdefaultif) {
- // Use name of the IAP to set default IAP
- QByteArray nameAsByteArray = activeConfig.name().toUtf8();
- ifreq ifr;
- strcpy(ifr.ifr_name, nameAsByteArray.constData());
-
- iDynamicSetdefaultif(&ifr);
- }
- newState(QNetworkSession::Connected, iNewRoamingIap);
-#endif
-}
-
-void QNetworkSessionPrivate::reject()
-{
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- iMobility->NewCarrierRejected();
- if (!iALRUpgradingConnection) {
- newState(QNetworkSession::Disconnected);
- } else {
- newState(QNetworkSession::Connected, iOldRoamingIap);
- }
-#endif
-}
-
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
-void QNetworkSessionPrivate::PreferredCarrierAvailable(TAccessPointInfo aOldAPInfo,
- TAccessPointInfo aNewAPInfo,
- TBool aIsUpgrade,
- TBool aIsSeamless)
-{
- iOldRoamingIap = aOldAPInfo.AccessPoint();
- iNewRoamingIap = aNewAPInfo.AccessPoint();
- newState(QNetworkSession::Roaming);
- if (iALREnabled > 0) {
- 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);
- }
- }
- } else {
- migrate();
- }
-}
-
-void QNetworkSessionPrivate::NewCarrierActive(TAccessPointInfo /*aNewAPInfo*/, TBool /*aIsSeamless*/)
-{
- if (iALREnabled > 0) {
- emit q->newConfigurationActivated();
- } else {
- accept();
- }
-}
-
-void QNetworkSessionPrivate::Error(TInt /*aError*/)
-{
- if (isOpen) {
- isOpen = false;
- activeConfig = QNetworkConfiguration();
- serviceConfig = QNetworkConfiguration();
- iError = QNetworkSession::RoamingError;
- emit q->error(iError);
- Cancel();
- 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 q->closed();
- }
-}
-#endif
-
-void QNetworkSessionPrivate::setALREnabled(bool enabled)
-{
- if (enabled) {
- iALREnabled++;
- } else {
- iALREnabled--;
- }
-}
-
-QNetworkConfiguration QNetworkSessionPrivate::bestConfigFromSNAP(const QNetworkConfiguration& snapConfig) const
-{
- QNetworkConfiguration config;
- QList<QNetworkConfiguration> subConfigurations = snapConfig.children();
- for (int i = 0; i < subConfigurations.count(); i++ ) {
- if (subConfigurations[i].state() == QNetworkConfiguration::Active) {
- config = subConfigurations[i];
- break;
- } else if (!config.isValid() && subConfigurations[i].state() == QNetworkConfiguration::Discovered) {
- config = subConfigurations[i];
- }
- }
- if (!config.isValid() && subConfigurations.count() > 0) {
- config = subConfigurations[0];
- }
- return config;
-}
-
-quint64 QNetworkSessionPrivate::bytesWritten() const
-{
- return transferredData(KUplinkData);
-}
-
-quint64 QNetworkSessionPrivate::bytesReceived() const
-{
- return transferredData(KDownlinkData);
-}
-
-quint64 QNetworkSessionPrivate::transferredData(TUint dataType) const
-{
- if (!publicConfig.isValid()) {
- return 0;
- }
-
- QNetworkConfiguration config;
- if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
- if (serviceConfig.isValid()) {
- config = serviceConfig;
- } else {
- if (activeConfig.isValid()) {
- config = activeConfig;
- }
- }
- } else {
- config = publicConfig;
- }
-
- if (!config.isValid()) {
- return 0;
- }
-
- TUint count;
- TRequestStatus status;
- iConnectionMonitor.GetConnectionCount(count, status);
- User::WaitForRequest(status);
- if (status.Int() != KErrNone) {
- return 0;
- }
-
- TUint transferredData = 0;
- TUint numSubConnections;
- TUint connectionId;
- bool configFound;
- for (TUint i = 1; i <= count; i++) {
- TInt ret = iConnectionMonitor.GetConnectionInfo(i, connectionId, numSubConnections);
- if (ret == KErrNone) {
- TUint apId;
- iConnectionMonitor.GetUintAttribute(connectionId, 0, KIAPId, apId, status);
- User::WaitForRequest(status);
- if (status.Int() == KErrNone) {
- configFound = false;
- 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) {
- configFound = true;
- break;
- }
- }
- } else if (config.d.data()->numericId == apId) {
- configFound = true;
- }
- if (configFound) {
- TUint tData;
- iConnectionMonitor.GetUintAttribute(connectionId, 0, dataType, tData, status );
- User::WaitForRequest(status);
- if (status.Int() == KErrNone) {
- transferredData += tData;
- }
- }
- }
- }
- }
-
- return transferredData;
-}
-
-quint64 QNetworkSessionPrivate::activeTime() const
-{
- if (!isOpen || startTime.isNull()) {
- return 0;
- }
- return startTime.secsTo(QDateTime::currentDateTime());
-}
-
-QNetworkConfiguration QNetworkSessionPrivate::activeConfiguration(TUint32 iapId) const
-{
- if (iapId == 0) {
- _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
- QList<QNetworkConfiguration> children = publicConfig.children();
- for (int i=0; i < children.count(); i++) {
- if (children[i].d.data()->numericId == iapId) {
- return children[i];
- }
- }
-
- // Given IAP Id was not found from the used SNAP
- // => Try to search matching IAP using mappingName
- // mappingName contains:
- // 1. "Access point name" for "Packet data" Bearer
- // 2. "WLAN network name" (= SSID) for "Wireless LAN" Bearer
- // 3. "Dial-up number" for "Data call Bearer" or "High Speed (GSM)" Bearer
- // <=> 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) {
- for (int i=0; i < children.count(); i++) {
- if (children[i].d.data()->mappingName == pt.d.data()->mappingName) {
- return children[i];
- }
- }
- } else {
- // 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 (publicConfig.d.data()->manager) {
- QNetworkConfiguration pt;
- // 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) {
- 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();
- // 2. Check if new configuration was created during connection creation
- QList<QString> knownConfigs = ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->accessPointConfigurations.keys();
- 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.d = ((QNetworkConfigurationManagerPrivate*)publicConfig.d.data()->manager)->accessPointConfigurations.value(newIapId);
- if (pt.d) {
- return pt;
- }
- }
- }
- }
- return QNetworkConfiguration();
- }
-
- return publicConfig;
-}
-
-void QNetworkSessionPrivate::RunL()
-{
- TInt statusCode = iStatus.Int();
-
- switch (statusCode) {
- case KErrNone: // Connection created succesfully
- {
- TInt error = KErrNone;
- QNetworkConfiguration newActiveConfig = activeConfiguration();
- if (!newActiveConfig.isValid()) {
- error = KErrGeneral;
- } else if (iDynamicSetdefaultif) {
- // Use name of the IAP to set default IAP
- QByteArray nameAsByteArray = newActiveConfig.name().toUtf8();
- ifreq ifr;
- strcpy(ifr.ifr_name, nameAsByteArray.constData());
-
- error = iDynamicSetdefaultif(&ifr);
- }
-
- if (error != KErrNone) {
- isOpen = false;
- iError = QNetworkSession::UnknownSessionError;
- emit q->error(iError);
- Cancel();
- if (ipConnectionNotifier) {
- ipConnectionNotifier->StopNotifications();
- }
- syncStateWithInterface();
- return;
- }
-
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
- // Activate ALR monitoring
- iMobility = CActiveCommsMobilityApiExt::NewL(iConnection, *this);
- }
-#endif
- isOpen = true;
- activeConfig = newActiveConfig;
- activeInterface = interface(activeConfig.d.data()->numericId);
- if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
- QNetworkConfiguration pt;
- pt.d = activeConfig.d.data()->serviceNetworkPtr;
- serviceConfig = pt;
- }
-
- startTime = QDateTime::currentDateTime();
-
- newState(QNetworkSession::Connected);
- emit quitPendingWaitsForOpened();
- }
- break;
- case KErrNotFound: // Connection failed
- isOpen = false;
- activeConfig = QNetworkConfiguration();
- serviceConfig = QNetworkConfiguration();
- iError = QNetworkSession::InvalidConfigurationError;
- emit q->error(iError);
- Cancel();
- if (ipConnectionNotifier) {
- ipConnectionNotifier->StopNotifications();
- }
- syncStateWithInterface();
- break;
- case KErrCancel: // Connection attempt cancelled
- case KErrAlreadyExists: // Connection already exists
- default:
- isOpen = false;
- activeConfig = QNetworkConfiguration();
- serviceConfig = QNetworkConfiguration();
- iError = QNetworkSession::UnknownSessionError;
- emit q->error(iError);
- Cancel();
- if (ipConnectionNotifier) {
- ipConnectionNotifier->StopNotifications();
- }
- syncStateWithInterface();
- break;
- }
-}
-
-void QNetworkSessionPrivate::DoCancel()
-{
- iConnection.Close();
-}
-
-bool QNetworkSessionPrivate::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);
- }
-
- // Make sure that same state is not signaled twice in a row.
- if (state == newState) {
- return true;
- }
-
- // Make sure that Connecting state does not overwrite Roaming state
- if (state == QNetworkSession::Roaming && newState == QNetworkSession::Connecting) {
- return false;
- }
-
- bool emitSessionClosed = false;
- if (isOpen && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) {
- // Active & Connected state should change directly to Disconnected state
- // only when something forces connection to close (eg. when another
- // application or session stops connection or when network drops
- // unexpectedly).
- isOpen = false;
- activeConfig = QNetworkConfiguration();
- serviceConfig = QNetworkConfiguration();
- iError = QNetworkSession::SessionAbortedError;
- emit q->error(iError);
- Cancel();
- if (ipConnectionNotifier) {
- ipConnectionNotifier->StopNotifications();
- }
- // Start monitoring changes in IAP states
- TRAP_IGNORE(iConnectionMonitor.NotifyEventL(*this));
- emitSessionClosed = true; // Emit SessionClosed after state change has been reported
- }
-
- bool retVal = false;
- if (accessPointId == 0) {
- state = newState;
- emit q->stateChanged(state);
- retVal = true;
- } else {
- if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
- if (publicConfig.d.data()->numericId == accessPointId) {
- state = newState;
- emit q->stateChanged(state);
- retVal = true;
- }
- } else if (publicConfig.type() == QNetworkConfiguration::UserChoice && isOpen) {
- if (activeConfig.d.data()->numericId == accessPointId) {
- state = newState;
- emit q->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 (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;
-
- state = newState;
- emit q->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;
- }
- QNetworkConfiguration config = bestConfigFromSNAP(publicConfig);
- if ((config.state() == QNetworkConfiguration::Defined) ||
- (config.state() == QNetworkConfiguration::Discovered)) {
- state = newState;
- emit q->stateChanged(state);
- retVal = true;
- }
- }
- }
- }
- }
- }
-
- if (emitSessionClosed) {
- emit q->closed();
- }
-
- return retVal;
-}
-
-void QNetworkSessionPrivate::handleSymbianConnectionStatusChange(TInt aConnectionStatus,
- TInt aError,
- TUint accessPointId)
-{
- switch (aConnectionStatus)
- {
- // Connection unitialised
- case KConnectionUninitialised:
- break;
-
- // Starting connetion selection
- case KStartingSelection:
- break;
-
- // Selection finished
- case KFinishedSelection:
- if (aError == KErrNone)
- {
- // The user successfully selected an IAP to be used
- break;
- }
- else
- {
- // The user pressed e.g. "Cancel" and did not select an IAP
- newState(QNetworkSession::Disconnected,accessPointId);
- }
- break;
-
- // Connection failure
- case KConnectionFailure:
- newState(QNetworkSession::NotAvailable);
- break;
-
- // Prepearing connection (e.g. dialing)
- case KPsdStartingConfiguration:
- case KPsdFinishedConfiguration:
- case KCsdFinishedDialling:
- case KCsdScanningScript:
- case KCsdGettingLoginInfo:
- case KCsdGotLoginInfo:
- break;
-
- // Creating connection (e.g. GPRS activation)
- case KCsdStartingConnect:
- case KCsdFinishedConnect:
- newState(QNetworkSession::Connecting,accessPointId);
- break;
-
- // Starting log in
- case KCsdStartingLogIn:
- break;
-
- // Finished login
- case KCsdFinishedLogIn:
- break;
-
- // Connection open
- case KConnectionOpen:
- break;
-
- case KLinkLayerOpen:
- newState(QNetworkSession::Connected,accessPointId);
- break;
-
- // Connection blocked or suspended
- case KDataTransferTemporarilyBlocked:
- break;
-
- // Hangup or GRPS deactivation
- case KConnectionStartingClose:
- newState(QNetworkSession::Closing,accessPointId);
- break;
-
- // Connection closed
- case KConnectionClosed:
- break;
-
- case KLinkLayerClosed:
- newState(QNetworkSession::Disconnected,accessPointId);
- break;
-
- // Unhandled state
- default:
- break;
- }
-}
-
-void QNetworkSessionPrivate::EventL(const CConnMonEventBase& aEvent)
-{
- switch (aEvent.EventType())
- {
- case EConnMonConnectionStatusChange:
- {
- CConnMonConnectionStatusChange* realEvent;
- realEvent = (CConnMonConnectionStatusChange*) &aEvent;
-
- TUint connectionId = realEvent->ConnectionId();
- TInt connectionStatus = realEvent->ConnectionStatus();
-
- // Try to Find IAP Id using connection Id
- TUint apId = 0;
- 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;
- break;
- }
- }
- } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
- if (publicConfig.d.data()->connectionId == connectionId) {
- apId = publicConfig.d.data()->numericId;
- }
- }
-
- if (apId > 0) {
- handleSymbianConnectionStatusChange(connectionStatus, KErrNone, apId);
- }
- }
- break;
-
- case EConnMonCreateConnection:
- {
- CConnMonCreateConnection* realEvent;
- realEvent = (CConnMonCreateConnection*) &aEvent;
- TUint apId;
- TUint connectionId = realEvent->ConnectionId();
- TRequestStatus status;
- iConnectionMonitor.GetUintAttribute(connectionId, 0, KIAPId, apId, status);
- User::WaitForRequest(status);
- if (status.Int() == KErrNone) {
- // Store connection id to related AccessPoint Configuration
- 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;
- break;
- }
- }
- } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
- if (publicConfig.d.data()->numericId == apId) {
- publicConfig.d.data()->connectionId = connectionId;
- }
- }
- }
- }
- break;
-
- case EConnMonDeleteConnection:
- {
- CConnMonDeleteConnection* realEvent;
- realEvent = (CConnMonDeleteConnection*) &aEvent;
- TUint connectionId = realEvent->ConnectionId();
- // Remove connection id from related AccessPoint Configuration
- 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;
- break;
- }
- }
- } else if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
- if (publicConfig.d.data()->connectionId == connectionId) {
- publicConfig.d.data()->connectionId = 0;
- }
- }
- }
- break;
-
- default:
- // For unrecognized events
- break;
- }
-}
-
-ConnectionProgressNotifier::ConnectionProgressNotifier(QNetworkSessionPrivate& owner, RConnection& connection)
- : CActive(CActive::EPriorityStandard), iOwner(owner), iConnection(connection)
-{
- CActiveScheduler::Add(this);
-}
-
-ConnectionProgressNotifier::~ConnectionProgressNotifier()
-{
- Cancel();
-}
-
-void ConnectionProgressNotifier::StartNotifications()
-{
- if (!IsActive()) {
- SetActive();
- }
- iConnection.ProgressNotification(iProgress, iStatus);
-}
-
-void ConnectionProgressNotifier::StopNotifications()
-{
- Cancel();
-}
-
-void ConnectionProgressNotifier::DoCancel()
-{
- iConnection.CancelProgressNotification();
-}
-
-void ConnectionProgressNotifier::RunL()
-{
- if (iStatus == KErrNone) {
- iOwner.handleSymbianConnectionStatusChange(iProgress().iStage, iProgress().iError);
-
- SetActive();
- iConnection.ProgressNotification(iProgress, iStatus);
- }
-}
-
-#include "moc_qnetworksession_s60_p.cpp"
-
-QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworksession_s60_p.h b/src/network/bearer/qnetworksession_s60_p.h
deleted file mode 100644
index 9ac5ed8..0000000
--- a/src/network/bearer/qnetworksession_s60_p.h
+++ /dev/null
@@ -1,212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtNetwork module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKSESSIONPRIVATE_H
-#define QNETWORKSESSIONPRIVATE_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 "qnetworksession.h"
-
-#include <QDateTime>
-
-#include <e32base.h>
-#include <CommDbConnPref.h>
-#include <es_sock.h>
-#include <rconnmon.h>
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- #include <comms-infras/cs_mobility_apiext.h>
-#endif
-
-typedef int(*TOpenCSetdefaultifFunction)(const struct ifreq*);
-
-QT_BEGIN_NAMESPACE
-
-class ConnectionProgressNotifier;
-
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
-class QNetworkSessionPrivate : public QObject, public CActive, public MMobilityProtocolResp,
- public MConnectionMonitorObserver
-#else
-class QNetworkSessionPrivate : public QObject, public CActive, public MConnectionMonitorObserver
-#endif
-{
- Q_OBJECT
-public:
- QNetworkSessionPrivate();
- ~QNetworkSessionPrivate();
-
- //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 setALREnabled(bool enabled);
-
- void open();
- void close(bool allowSignals = true);
- 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;
-
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
-public: // From MMobilityProtocolResp
- void PreferredCarrierAvailable(TAccessPointInfo aOldAPInfo,
- TAccessPointInfo aNewAPInfo,
- TBool aIsUpgrade,
- TBool aIsSeamless);
-
- void NewCarrierActive(TAccessPointInfo aNewAPInfo, TBool aIsSeamless);
-
- void Error(TInt aError);
-#endif
-
-Q_SIGNALS:
- //releases any pending waitForOpened() calls
- void quitPendingWaitsForOpened();
-
-protected: // From CActive
- void RunL();
- void DoCancel();
-
-private: // MConnectionMonitorObserver
- void EventL(const CConnMonEventBase& aEvent);
-
-private:
- TUint iapClientCount(TUint aIAPId) const;
- quint64 transferredData(TUint dataType) const;
- bool newState(QNetworkSession::State newState, TUint accessPointId = 0);
- void handleSymbianConnectionStatusChange(TInt aConnectionStatus, TInt aError, TUint accessPointId = 0);
- QNetworkConfiguration bestConfigFromSNAP(const QNetworkConfiguration& snapConfig) const;
- QNetworkConfiguration activeConfiguration(TUint32 iapId = 0) const;
- 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;
-
- // 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;
- TOpenCSetdefaultifFunction iDynamicSetdefaultif;
-
- mutable RSocketServ iSocketServ;
- mutable RConnection iConnection;
- mutable RConnectionMonitor iConnectionMonitor;
- ConnectionProgressNotifier* ipConnectionNotifier;
-#ifdef SNAP_FUNCTIONALITY_AVAILABLE
- CActiveCommsMobilityApiExt* iMobility;
-#endif
-
- QNetworkSession::SessionError iError;
- TInt iALREnabled;
- TBool iALRUpgradingConnection;
-
- QList<QString> iKnownConfigsBeforeConnectionStart;
-
- TUint32 iOldRoamingIap;
- TUint32 iNewRoamingIap;
-
- friend class QNetworkSession;
- friend class ConnectionProgressNotifier;
-};
-
-class ConnectionProgressNotifier : public CActive
-{
-public:
- ConnectionProgressNotifier(QNetworkSessionPrivate& owner, RConnection& connection);
- ~ConnectionProgressNotifier();
-
- void StartNotifications();
- void StopNotifications();
-
-protected: // From CActive
- void RunL();
- void DoCancel();
-
-private: // Data
- QNetworkSessionPrivate& iOwner;
- RConnection& iConnection;
- TNifProgressBuf iProgress;
-
-};
-
-QT_END_NAMESPACE
-
-#endif //QNETWORKSESSIONPRIVATE_H
-
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