summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-12-10 17:52:49 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-12-10 17:52:49 (GMT)
commitc8a2533cb39ce0c7479880cd889ad594d569ecc0 (patch)
tree99ca377b6c66eceb6bb11e3b68e6179d349c4e75
parent9dc3c41a076ee647d64700eff01da863a0df7012 (diff)
parent9fe927a54f0c465c0dcbcc5790ad0ddb17d4cc18 (diff)
downloadQt-c8a2533cb39ce0c7479880cd889ad594d569ecc0.zip
Qt-c8a2533cb39ce0c7479880cd889ad594d569ecc0.tar.gz
Qt-c8a2533cb39ce0c7479880cd889ad594d569ecc0.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Proposed fix for QTBUG-10499 remove useless overload simplify polling code a bit promote QNetworkConfigurationManager::updateConfigurations() to a slot simplify waitForOpened() fix CV-qualifiers for some members minor clean-ups and styling fixes
-rw-r--r--src/gui/kernel/qx11embed_x11.cpp12
-rw-r--r--src/network/bearer/bearer.pri1
-rw-r--r--src/network/bearer/qbearerengine.cpp14
-rw-r--r--src/network/bearer/qbearerengine_p.h5
-rw-r--r--src/network/bearer/qbearerplugin.cpp4
-rw-r--r--src/network/bearer/qbearerplugin_p.h6
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp16
-rw-r--r--src/network/bearer/qnetworkconfigmanager.h22
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp102
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h48
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp30
-rw-r--r--src/network/bearer/qnetworkconfiguration.h11
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h17
-rw-r--r--src/network/bearer/qnetworksession.cpp106
-rw-r--r--src/network/bearer/qnetworksession.h17
-rw-r--r--src/network/bearer/qnetworksession_p.h20
-rw-r--r--src/plugins/bearer/platformdefs_win.h2
-rw-r--r--src/plugins/bearer/qbearerengine_impl.h7
-rw-r--r--src/plugins/bearer/qnetworksession_impl.cpp67
-rw-r--r--src/plugins/bearer/qnetworksession_impl.h23
20 files changed, 217 insertions, 313 deletions
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/gui/kernel/qx11embed_x11.cpp
index e6e3bfb..f2f95d3 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/gui/kernel/qx11embed_x11.cpp
@@ -512,7 +512,7 @@ QX11EmbedWidget::~QX11EmbedWidget()
<< "from container with winId" << d->container;
#endif
XUnmapWindow(x11Info().display(), internalWinId());
- XReparentWindow(x11Info().display(), internalWinId(), x11Info().appRootWindow(), 0, 0);
+ XReparentWindow(x11Info().display(), internalWinId(), x11Info().appRootWindow(x11Info().screen()), 0, 0);
}
#ifdef QX11EMBED_DEBUG
@@ -791,13 +791,13 @@ bool QX11EmbedWidget::x11Event(XEvent *event)
qDebug() << "QX11EmbedWidget::x11Event: client"
<< (void *)this << "with winId" << winId()
<< "received a ReparentNotify to"
- << ((event->xreparent.parent == x11Info().appRootWindow())
+ << ((event->xreparent.parent == x11Info().appRootWindow(x11Info().screen()))
? QString::fromLatin1("root") : QString::number(event->xreparent.parent));
#endif
// If the container shuts down, we will be reparented to the
// root window. We must also consider the case that we may be
// reparented from one container to another.
- if (event->xreparent.parent == x11Info().appRootWindow()) {
+ if (event->xreparent.parent == x11Info().appRootWindow(x11Info().screen())) {
if (((QHackWidget *)this)->topData()->embedded) {
d->container = 0;
emit containerClosed();
@@ -1115,7 +1115,7 @@ QX11EmbedContainer::~QX11EmbedContainer()
Q_D(QX11EmbedContainer);
if (d->client) {
XUnmapWindow(x11Info().display(), d->client);
- XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(), 0, 0);
+ XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(x11Info().screen()), 0, 0);
}
if (d->xgrab)
@@ -1379,7 +1379,7 @@ bool QX11EmbedContainer::eventFilter(QObject *o, QEvent *event)
// Wait until the messages have been processed. Then ask
// the window manager to delete the window.
XUnmapWindow(x11Info().display(), d->client);
- XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(), 0, 0);
+ XReparentWindow(x11Info().display(), d->client, x11Info().appRootWindow(x11Info().screen()), 0, 0);
XSync(x11Info().display(), false);
XEvent ev;
@@ -1627,7 +1627,7 @@ void QX11EmbedContainerPrivate::rejectClient(WId window)
Q_Q(QX11EmbedContainer);
q->setEnabled(false);
XRemoveFromSaveSet(q->x11Info().display(), client);
- XReparentWindow(q->x11Info().display(), window, q->x11Info().appRootWindow(), 0, 0);
+ XReparentWindow(q->x11Info().display(), window, q->x11Info().appRootWindow(q->x11Info().screen()), 0, 0);
}
/*! \internal
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri
index 44e97fd..bc5b0b5 100644
--- a/src/network/bearer/bearer.pri
+++ b/src/network/bearer/bearer.pri
@@ -15,4 +15,3 @@ SOURCES += bearer/qnetworksession.cpp \
bearer/qnetworkconfigmanager_p.cpp \
bearer/qbearerengine.cpp \
bearer/qbearerplugin.cpp
-
diff --git a/src/network/bearer/qbearerengine.cpp b/src/network/bearer/qbearerengine.cpp
index b074924..ee7c66e 100644
--- a/src/network/bearer/qbearerengine.cpp
+++ b/src/network/bearer/qbearerengine.cpp
@@ -46,7 +46,7 @@
QT_BEGIN_NAMESPACE
QBearerEngine::QBearerEngine(QObject *parent)
-: QObject(parent), mutex(QMutex::Recursive)
+ : QObject(parent), mutex(QMutex::Recursive)
{
}
@@ -54,6 +54,7 @@ QBearerEngine::~QBearerEngine()
{
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
+
for (it = snapConfigurations.begin(), end = snapConfigurations.end(); it != end; ++it) {
it.value()->isValid = false;
it.value()->id.clear();
@@ -93,19 +94,20 @@ bool QBearerEngine::configurationsInUse() const
QMutexLocker locker(&mutex);
- for (it = accessPointConfigurations.begin(),
- end = accessPointConfigurations.end(); it != end; ++it) {
+ for (it = accessPointConfigurations.constBegin(),
+ end = accessPointConfigurations.constEnd(); it != end; ++it) {
if (it.value()->ref > 1)
return true;
}
- for (it = snapConfigurations.begin(), end = snapConfigurations.end(); it != end; ++it) {
+ for (it = snapConfigurations.constBegin(),
+ end = snapConfigurations.constEnd(); it != end; ++it) {
if (it.value()->ref > 1)
return true;
}
- for (it = userChoiceConfigurations.begin(),
- end = userChoiceConfigurations.end(); it != end; ++it) {
+ for (it = userChoiceConfigurations.constBegin(),
+ end = userChoiceConfigurations.constEnd(); it != end; ++it) {
if (it.value()->ref > 1)
return true;
}
diff --git a/src/network/bearer/qbearerengine_p.h b/src/network/bearer/qbearerengine_p.h
index 70aa5fa..bac6b14 100644
--- a/src/network/bearer/qbearerengine_p.h
+++ b/src/network/bearer/qbearerengine_p.h
@@ -78,7 +78,7 @@ class Q_NETWORK_EXPORT QBearerEngine : public QObject
friend class QNetworkConfigurationManagerPrivate;
public:
- QBearerEngine(QObject *parent = 0);
+ explicit QBearerEngine(QObject *parent = 0);
virtual ~QBearerEngine();
virtual bool hasIdentifier(const QString &id) = 0;
@@ -96,7 +96,6 @@ Q_SIGNALS:
void configurationAdded(QNetworkConfigurationPrivatePointer config);
void configurationRemoved(QNetworkConfigurationPrivatePointer config);
void configurationChanged(QNetworkConfigurationPrivatePointer config);
-
void updateCompleted();
protected:
@@ -114,4 +113,4 @@ QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif
+#endif // QBEARERENGINE_P_H
diff --git a/src/network/bearer/qbearerplugin.cpp b/src/network/bearer/qbearerplugin.cpp
index a5e8918..b92982f 100644
--- a/src/network/bearer/qbearerplugin.cpp
+++ b/src/network/bearer/qbearerplugin.cpp
@@ -41,14 +41,12 @@
#include "qbearerplugin_p.h"
-#include <QtCore/qdebug.h>
-
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
QBearerEnginePlugin::QBearerEnginePlugin(QObject *parent)
-: QObject(parent)
+ : QObject(parent)
{
}
diff --git a/src/network/bearer/qbearerplugin_p.h b/src/network/bearer/qbearerplugin_p.h
index 9652f14..aee189b 100644
--- a/src/network/bearer/qbearerplugin_p.h
+++ b/src/network/bearer/qbearerplugin_p.h
@@ -68,7 +68,7 @@ QT_MODULE(Network)
struct Q_NETWORK_EXPORT QBearerEngineFactoryInterface : public QFactoryInterface
{
- virtual QBearerEngine *create(const QString &key = QString()) const = 0;
+ virtual QBearerEngine *create(const QString &key) const = 0;
};
#define QBearerEngineFactoryInterface_iid "com.trolltech.Qt.QBearerEngineFactoryInterface"
@@ -84,7 +84,7 @@ public:
virtual ~QBearerEnginePlugin();
virtual QStringList keys() const = 0;
- virtual QBearerEngine *create(const QString &key = QString()) const = 0;
+ virtual QBearerEngine *create(const QString &key) const = 0;
};
QT_END_NAMESPACE
@@ -93,4 +93,4 @@ QT_END_HEADER
#endif // QT_NO_BEARERMANAGEMENT
-#endif
+#endif // QBEARERPLUGIN_P_H
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 4c149a2..8b6d45f 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -124,14 +124,14 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
*/
/*!
- \fn void QNetworkConfigurationManager::configurationAdded(const QNetworkConfiguration& config)
+ \fn void QNetworkConfigurationManager::configurationAdded(const QNetworkConfiguration &config)
This signal is emitted whenever a new network configuration is added to the system. The new
configuration is specified by \a config.
*/
/*!
- \fn void QNetworkConfigurationManager::configurationRemoved(const QNetworkConfiguration& configuration)
+ \fn void QNetworkConfigurationManager::configurationRemoved(const QNetworkConfiguration &config)
This signal is emitted when a configuration is about to be removed from the system. The removed
\a configuration is invalid but retains name and identifier.
@@ -144,7 +144,7 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
be initiated via \l updateConfigurations().
*/
-/*! \fn void QNetworkConfigurationManager::configurationChanged(const QNetworkConfiguration& config)
+/*! \fn void QNetworkConfigurationManager::configurationChanged(const QNetworkConfiguration &config)
This signal is emitted when the \l {QNetworkConfiguration::state()}{state} of \a config changes.
*/
@@ -204,7 +204,7 @@ QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
/*!
Constructs a QNetworkConfigurationManager with the given \a parent.
*/
-QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent )
+QNetworkConfigurationManager::QNetworkConfigurationManager(QObject *parent)
: QObject(parent)
{
QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
@@ -213,12 +213,12 @@ QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent )
this, SIGNAL(configurationAdded(QNetworkConfiguration)));
connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)),
this, SIGNAL(configurationRemoved(QNetworkConfiguration)));
- connect(priv, SIGNAL(configurationUpdateComplete()),
- this, SIGNAL(updateCompleted()));
- connect(priv, SIGNAL(onlineStateChanged(bool)),
- this, SIGNAL(onlineStateChanged(bool)));
connect(priv, SIGNAL(configurationChanged(QNetworkConfiguration)),
this, SIGNAL(configurationChanged(QNetworkConfiguration)));
+ connect(priv, SIGNAL(onlineStateChanged(bool)),
+ this, SIGNAL(onlineStateChanged(bool)));
+ connect(priv, SIGNAL(configurationUpdateComplete()),
+ this, SIGNAL(updateCompleted()));
priv->enablePolling();
}
diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h
index 3e44be1..9ddebe5 100644
--- a/src/network/bearer/qnetworkconfigmanager.h
+++ b/src/network/bearer/qnetworkconfigmanager.h
@@ -68,7 +68,6 @@ class QNetworkConfigurationManagerExport QNetworkConfigurationManager : public Q
Q_OBJECT
public:
-
enum Capability {
CanStartAndStopInterfaces = 0x00000001,
DirectConnectionRouting = 0x00000002,
@@ -81,26 +80,26 @@ public:
Q_DECLARE_FLAGS(Capabilities, Capability)
- QNetworkConfigurationManager( QObject* parent = 0 );
+ explicit QNetworkConfigurationManager(QObject *parent = 0);
virtual ~QNetworkConfigurationManager();
-
QNetworkConfigurationManager::Capabilities capabilities() const;
- QNetworkConfiguration defaultConfiguration() const;
+ QNetworkConfiguration defaultConfiguration() const;
QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags flags = 0) const;
- QNetworkConfiguration configurationFromIdentifier(const QString& identifier) const;
- void updateConfigurations();
+ QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const;
bool isOnline() const;
+public Q_SLOTS:
+ void updateConfigurations();
+
Q_SIGNALS:
- void configurationAdded(const QNetworkConfiguration& config);
- void configurationRemoved(const QNetworkConfiguration& config);
- void configurationChanged(const QNetworkConfiguration& config);
+ void configurationAdded(const QNetworkConfiguration &config);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
void onlineStateChanged(bool isOnline);
void updateCompleted();
-
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities)
@@ -115,5 +114,4 @@ QT_END_HEADER
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKCONFIGURATIONMANAGER_H
-
+#endif // QNETWORKCONFIGURATIONMANAGER_H
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index d388920..fd1052c 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -60,7 +60,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
#endif
QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
-: pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true)
+ : QObject(), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true)
{
qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration");
qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
@@ -73,13 +73,12 @@ QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
qDeleteAll(sessionEngines);
}
-QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration()
+QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() const
{
QMutexLocker locker(&mutex);
foreach (QBearerEngine *engine, sessionEngines) {
QNetworkConfigurationPrivatePointer ptr = engine->defaultConfiguration();
-
if (ptr) {
QNetworkConfiguration config;
config.d = ptr;
@@ -98,8 +97,8 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
QMutexLocker locker(&engine->mutex);
- for (it = engine->snapConfigurations.begin(), end = engine->snapConfigurations.end();
- it != end; ++it) {
+ for (it = engine->snapConfigurations.begin(),
+ end = engine->snapConfigurations.end(); it != end; ++it) {
QNetworkConfigurationPrivatePointer ptr = it.value();
QMutexLocker configLocker(&ptr->mutex);
@@ -109,10 +108,8 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
config.d = ptr;
return config;
} else if (!defaultConfiguration) {
- if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
+ if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
defaultConfiguration = ptr;
- }
}
}
}
@@ -136,8 +133,6 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
6. Discovered Other
*/
- defaultConfiguration.reset();
-
foreach (QBearerEngine *engine, sessionEngines) {
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
@@ -151,8 +146,7 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
QMutexLocker configLocker(&ptr->mutex);
QNetworkConfiguration::BearerType bearerType = ptr->bearerType;
- if ((ptr->state & QNetworkConfiguration::Discovered) ==
- QNetworkConfiguration::Discovered) {
+ if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
if (!defaultConfiguration) {
defaultConfiguration = ptr;
} else {
@@ -196,7 +190,7 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
return QNetworkConfiguration();
}
-QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(QNetworkConfiguration::StateFlags filter)
+QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(QNetworkConfiguration::StateFlags filter) const
{
QList<QNetworkConfiguration> result;
@@ -240,7 +234,7 @@ QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurati
return result;
}
-QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(const QString &identifier)
+QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(const QString &identifier) const
{
QNetworkConfiguration item;
@@ -250,11 +244,11 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIden
QMutexLocker locker(&engine->mutex);
if (engine->accessPointConfigurations.contains(identifier))
- item.d = engine->accessPointConfigurations.value(identifier);
+ item.d = engine->accessPointConfigurations[identifier];
else if (engine->snapConfigurations.contains(identifier))
- item.d = engine->snapConfigurations.value(identifier);
+ item.d = engine->snapConfigurations[identifier];
else if (engine->userChoiceConfigurations.contains(identifier))
- item.d = engine->userChoiceConfigurations.value(identifier);
+ item.d = engine->userChoiceConfigurations[identifier];
else
continue;
@@ -264,14 +258,14 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIden
return item;
}
-bool QNetworkConfigurationManagerPrivate::isOnline()
+bool QNetworkConfigurationManagerPrivate::isOnline() const
{
QMutexLocker locker(&mutex);
return !onlineConfigurations.isEmpty();
}
-QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities()
+QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities() const
{
QMutexLocker locker(&mutex);
@@ -353,7 +347,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
QMutexLocker locker(&mutex);
if (firstUpdate) {
- if (sender())
+ if (qobject_cast<QBearerEngine *>(sender()))
return;
if (thread() != QCoreApplicationPrivate::mainThread()) {
@@ -366,10 +360,9 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
updating = false;
#ifndef QT_NO_LIBRARY
- QFactoryLoader *l = loader();
-
QBearerEngine *generic = 0;
+ QFactoryLoader *l = loader();
foreach (const QString &key, l->keys()) {
QBearerEnginePlugin *plugin = qobject_cast<QBearerEnginePlugin *>(l->instance(key));
if (plugin) {
@@ -403,11 +396,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
}
QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender());
- if (!updatingEngines.isEmpty() && engine) {
- int index = sessionEngines.indexOf(engine);
- if (index >= 0)
- updatingEngines.remove(index);
- }
+ if (engine && !updatingEngines.isEmpty())
+ updatingEngines.remove(engine);
if (updating && updatingEngines.isEmpty()) {
updating = false;
@@ -415,10 +405,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
}
if (engine && !pollingEngines.isEmpty()) {
- int index = sessionEngines.indexOf(engine);
- if (index >= 0)
- pollingEngines.remove(index);
-
+ pollingEngines.remove(engine);
if (pollingEngines.isEmpty())
startPolling();
}
@@ -438,13 +425,13 @@ void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate()
updating = true;
- for (int i = 0; i < sessionEngines.count(); ++i) {
- updatingEngines.insert(i);
- QMetaObject::invokeMethod(sessionEngines.at(i), "requestUpdate");
+ foreach (QBearerEngine *engine, sessionEngines) {
+ updatingEngines.insert(engine);
+ QMetaObject::invokeMethod(engine, "requestUpdate");
}
}
-QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::engines()
+QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::engines() const
{
QMutexLocker locker(&mutex);
@@ -455,35 +442,11 @@ void QNetworkConfigurationManagerPrivate::startPolling()
{
QMutexLocker locker(&mutex);
- bool pollingRequired = false;
-
- if (forcedPolling > 0) {
- foreach (QBearerEngine *engine, sessionEngines) {
- if (engine->requiresPolling()) {
- pollingRequired = true;
- break;
- }
- }
- }
-
- if (!pollingRequired) {
- foreach (QBearerEngine *engine, sessionEngines) {
- if (engine->configurationsInUse()) {
- pollingRequired = true;
- break;
- }
- }
- }
-
- if (pollingRequired) {
- if (!pollTimer) {
- pollTimer = new QTimer(this);
- pollTimer->setInterval(10000);
- pollTimer->setSingleShot(true);
- connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines()));
+ foreach (QBearerEngine *engine, sessionEngines) {
+ if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
+ QTimer::singleShot(10000, this, SLOT(pollEngines()));
+ break;
}
-
- pollTimer->start();
}
}
@@ -491,13 +454,10 @@ void QNetworkConfigurationManagerPrivate::pollEngines()
{
QMutexLocker locker(&mutex);
- for (int i = 0; i < sessionEngines.count(); ++i) {
- if (!sessionEngines.at(i)->requiresPolling())
- continue;
-
- if (forcedPolling || sessionEngines.at(i)->configurationsInUse()) {
- pollingEngines.insert(i);
- QMetaObject::invokeMethod(sessionEngines.at(i), "requestUpdate");
+ foreach (QBearerEngine *engine, sessionEngines) {
+ if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
+ pollingEngines.insert(engine);
+ QMetaObject::invokeMethod(engine, "requestUpdate");
}
}
}
@@ -509,7 +469,7 @@ void QNetworkConfigurationManagerPrivate::enablePolling()
++forcedPolling;
if (forcedPolling == 1)
- QMetaObject::invokeMethod(this, "startPolling");
+ startPolling();
}
void QNetworkConfigurationManagerPrivate::disablePolling()
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
index 0649031..16c2c4b 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_p.h
@@ -64,7 +64,6 @@
QT_BEGIN_NAMESPACE
class QBearerEngine;
-class QTimer;
class Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate : public QObject
{
@@ -74,57 +73,54 @@ public:
QNetworkConfigurationManagerPrivate();
virtual ~QNetworkConfigurationManagerPrivate();
- QNetworkConfiguration defaultConfiguration();
- QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags filter);
- QNetworkConfiguration configurationFromIdentifier(const QString &identifier);
+ QNetworkConfiguration defaultConfiguration() const;
+ QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags filter) const;
+ QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const;
- bool isOnline();
+ bool isOnline() const;
- QNetworkConfigurationManager::Capabilities capabilities();
+ QNetworkConfigurationManager::Capabilities capabilities() const;
void performAsyncConfigurationUpdate();
- QList<QBearerEngine *> engines();
-
- Q_INVOKABLE void startPolling();
+ QList<QBearerEngine *> engines() const;
void enablePolling();
void disablePolling();
-public slots:
+public Q_SLOTS:
void updateConfigurations();
Q_SIGNALS:
- void configurationAdded(const QNetworkConfiguration& config);
- void configurationRemoved(const QNetworkConfiguration& config);
+ void configurationAdded(const QNetworkConfiguration &config);
+ void configurationRemoved(const QNetworkConfiguration &config);
+ void configurationChanged(const QNetworkConfiguration &config);
void configurationUpdateComplete();
- void configurationChanged(const QNetworkConfiguration& config);
void onlineStateChanged(bool isOnline);
- void abort();
+private Q_SLOTS:
+ void configurationAdded(QNetworkConfigurationPrivatePointer ptr);
+ void configurationRemoved(QNetworkConfigurationPrivatePointer ptr);
+ void configurationChanged(QNetworkConfigurationPrivatePointer ptr);
+
+ void pollEngines();
private:
- QTimer *pollTimer;
+ void startPolling();
- QMutex mutex;
+private:
+ mutable QMutex mutex;
QList<QBearerEngine *> sessionEngines;
QSet<QString> onlineConfigurations;
- QSet<int> pollingEngines;
- QSet<int> updatingEngines;
+ QSet<QBearerEngine *> pollingEngines;
+ QSet<QBearerEngine *> updatingEngines;
int forcedPolling;
bool updating;
bool firstUpdate;
-
-private Q_SLOTS:
- void configurationAdded(QNetworkConfigurationPrivatePointer ptr);
- void configurationRemoved(QNetworkConfigurationPrivatePointer ptr);
- void configurationChanged(QNetworkConfigurationPrivatePointer ptr);
-
- void pollEngines();
};
Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate();
@@ -133,4 +129,4 @@ QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H
+#endif // QNETWORKCONFIGURATIONMANAGERPRIVATE_H
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp
index 3190a30..96d8bff 100644
--- a/src/network/bearer/qnetworkconfiguration.cpp
+++ b/src/network/bearer/qnetworkconfiguration.cpp
@@ -212,44 +212,38 @@ QNetworkConfiguration::QNetworkConfiguration()
/*!
Creates a copy of the QNetworkConfiguration object contained in \a other.
*/
-QNetworkConfiguration::QNetworkConfiguration(const QNetworkConfiguration& other)
+QNetworkConfiguration::QNetworkConfiguration(const QNetworkConfiguration &other)
: d(other.d)
{
}
/*!
- Copies the content of the QNetworkConfiguration object contained in \a other into this one.
+ Frees the resources associated with the QNetworkConfiguration object.
*/
-QNetworkConfiguration& QNetworkConfiguration::operator=(const QNetworkConfiguration& other)
+QNetworkConfiguration::~QNetworkConfiguration()
{
- d = other.d;
- return *this;
}
/*!
- Frees the resources associated with the QNetworkConfiguration object.
+ Copies the content of the QNetworkConfiguration object contained in \a other into this one.
*/
-QNetworkConfiguration::~QNetworkConfiguration()
+QNetworkConfiguration &QNetworkConfiguration::operator=(const QNetworkConfiguration &other)
{
+ d = other.d;
+ return *this;
}
/*!
Returns true, if this configuration is the same as the \a other
configuration given; otherwise returns false.
*/
-bool QNetworkConfiguration::operator==(const QNetworkConfiguration& other) const
+bool QNetworkConfiguration::operator==(const QNetworkConfiguration &other) const
{
- if (!d)
- return !other.d;
-
- if (!other.d)
- return false;
-
return (d == other.d);
}
/*!
- \fn bool QNetworkConfiguration::operator!=(const QNetworkConfiguration& other) const
+ \fn bool QNetworkConfiguration::operator!=(const QNetworkConfiguration &other) const
Returns true if this configuration is not the same as the \a other
configuration given; otherwise returns false.
@@ -370,11 +364,14 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const
{
QList<QNetworkConfiguration> results;
- if (type() != QNetworkConfiguration::ServiceNetwork || !isValid())
+ if (!d)
return results;
QMutexLocker locker(&d->mutex);
+ if (d->type != QNetworkConfiguration::ServiceNetwork || !d->isValid)
+ return results;
+
QMutableMapIterator<unsigned int, QNetworkConfigurationPrivatePointer> i(d->serviceNetworkMembers);
while (i.hasNext()) {
i.next();
@@ -510,4 +507,3 @@ QString QNetworkConfiguration::bearerTypeName() const
}
QT_END_NAMESPACE
-
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index 593dbbe..475df9e 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -73,12 +73,12 @@ class QNetworkConfigurationExport QNetworkConfiguration
public:
QNetworkConfiguration();
QNetworkConfiguration(const QNetworkConfiguration& other);
- QNetworkConfiguration &operator=(const QNetworkConfiguration& other);
+ QNetworkConfiguration &operator=(const QNetworkConfiguration &other);
~QNetworkConfiguration();
- bool operator==(const QNetworkConfiguration& cp) const;
- inline bool operator!=(const QNetworkConfiguration& cp) const
- { return !operator==(cp); }
+ bool operator==(const QNetworkConfiguration &other) const;
+ inline bool operator!=(const QNetworkConfiguration &other) const
+ { return !operator==(other); }
enum Type {
InternetAccessPoint = 0,
@@ -100,7 +100,6 @@ public:
Discovered = 0x0000006,
Active = 0x000000e
};
-
Q_DECLARE_FLAGS(StateFlags, StateFlag)
#ifndef QT_MOBILITY_BEARER
@@ -155,4 +154,4 @@ QTM_END_NAMESPACE
QT_END_HEADER
-#endif //QNETWORKCONFIGURATION_H
+#endif // QNETWORKCONFIGURATION_H
diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h
index 2b0bbf6..4d41acb 100644
--- a/src/network/bearer/qnetworkconfiguration_p.h
+++ b/src/network/bearer/qnetworkconfiguration_p.h
@@ -65,18 +65,17 @@ typedef QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfi
class QNetworkConfigurationPrivate : public QSharedData
{
public:
- QNetworkConfigurationPrivate ()
- : mutex(QMutex::Recursive), type(QNetworkConfiguration::Invalid),
+ QNetworkConfigurationPrivate() :
+ mutex(QMutex::Recursive),
+ type(QNetworkConfiguration::Invalid),
purpose(QNetworkConfiguration::UnknownPurpose),
bearerType(QNetworkConfiguration::BearerUnknown),
isValid(false), roamingSupported(false)
- {
- }
-
+ {}
virtual ~QNetworkConfigurationPrivate()
{
//release pointers to member configurations
- serviceNetworkMembers.clear();
+ serviceNetworkMembers.clear();
}
virtual QString bearerTypeName() const
@@ -100,11 +99,9 @@ public:
bool roamingSupported;
private:
- // disallow detaching
- QNetworkConfigurationPrivate &operator=(const QNetworkConfigurationPrivate &other);
- QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other);
+ Q_DISABLE_COPY(QNetworkConfigurationPrivate)
};
QT_END_NAMESPACE
-#endif //QNETWORKCONFIGURATIONPRIVATE_H
+#endif // QNETWORKCONFIGURATIONPRIVATE_H
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index 226c3c5..eac0456 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -39,11 +39,12 @@
**
****************************************************************************/
+#include "qnetworksession.h"
+#include "qbearerengine_p.h"
+
#include <QEventLoop>
#include <QTimer>
-#include "qnetworksession.h"
-#include "qbearerengine_p.h"
#include "qnetworkconfigmanager_p.h"
#include "qnetworksession_p.h"
@@ -165,7 +166,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QNetworkSession::preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless)
+ \fn void QNetworkSession::preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless)
This signal is emitted when the preferred configuration/access point for the
session changes. Only sessions which are based on service network configurations
@@ -224,30 +225,29 @@ QT_BEGIN_NAMESPACE
\sa QNetworkConfiguration
*/
-QNetworkSession::QNetworkSession(const QNetworkConfiguration& connectionConfig, QObject* parent)
-: QObject(parent), d(0)
+QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, QObject *parent)
+ : QObject(parent), d(0)
{
// invalid configuration
- if (connectionConfig.identifier().isNull())
- return;
-
- foreach (QBearerEngine *engine, qNetworkConfigurationManagerPrivate()->engines()) {
- 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(preferredConfigurationChanged(QNetworkConfiguration,bool)),
- this, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)));
- connect(d, SIGNAL(newConfigurationActivated()),
- this, SIGNAL(newConfigurationActivated()));
- break;
+ if (!connectionConfig.identifier().isEmpty()) {
+ foreach (QBearerEngine *engine, qNetworkConfigurationManagerPrivate()->engines()) {
+ 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(preferredConfigurationChanged(QNetworkConfiguration,bool)),
+ this, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)));
+ connect(d, SIGNAL(newConfigurationActivated()),
+ this, SIGNAL(newConfigurationActivated()));
+ break;
+ }
}
}
}
@@ -313,19 +313,16 @@ bool QNetworkSession::waitForOpened(int msecs)
if (d->state != Connecting)
return false;
- QEventLoop* loop = new QEventLoop(this);
- QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()),
- loop, SLOT(quit()));
- QObject::connect(this, SIGNAL(error(QNetworkSession::SessionError)),
- loop, SLOT(quit()));
+ QEventLoop loop;
+ QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()), &loop, SLOT(quit()));
+ QObject::connect(this, SIGNAL(error(QNetworkSession::SessionError)), &loop, SLOT(quit()));
//final call
- if (msecs>=0)
- QTimer::singleShot(msecs, loop, SLOT(quit()));
+ if (msecs >= 0)
+ QTimer::singleShot(msecs, &loop, SLOT(quit()));
- loop->exec();
- loop->disconnect();
- loop->deleteLater();
+ // enter the event loop and wait for opened/error/timeout
+ loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
return d->isOpen;
}
@@ -471,7 +468,7 @@ QString QNetworkSession::errorString() const
\code
QNetworkConfigurationManager mgr;
QNetworkConfiguration ap = mgr.defaultConfiguration();
- QNetworkSession* session = new QNetworkSession(ap);
+ QNetworkSession *session = new QNetworkSession(ap);
... //code activates session
QString ident = session->sessionProperty("ActiveConfiguration").toString();
@@ -516,20 +513,13 @@ QString QNetworkSession::errorString() const
has no effect for sessions that do not require polling.
\endtable
*/
-QVariant QNetworkSession::sessionProperty(const QString& key) const
+QVariant QNetworkSession::sessionProperty(const QString &key) const
{
- if (!d)
- return QVariant();
-
- if (!d->publicConfig.isValid())
+ if (!d || !d->publicConfig.isValid())
return QVariant();
- if (key == QLatin1String("ActiveConfiguration")) {
- if (!d->isOpen)
- return QString();
- else
- return d->activeConfig.identifier();
- }
+ if (key == QLatin1String("ActiveConfiguration"))
+ return d->isOpen ? d->activeConfig.identifier() : QString();
if (key == QLatin1String("UserChoiceConfiguration")) {
if (!d->isOpen || d->publicConfig.type() != QNetworkConfiguration::UserChoice)
@@ -552,7 +542,7 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const
Note that the \e UserChoiceConfiguration and \e ActiveConfiguration
properties are read only and cannot be changed using this method.
*/
-void QNetworkSession::setSessionProperty(const QString& key, const QVariant& value)
+void QNetworkSession::setSessionProperty(const QString &key, const QVariant &value)
{
if (!d)
return;
@@ -586,7 +576,7 @@ void QNetworkSession::migrate()
*/
void QNetworkSession::ignore()
{
- // Needed on at least Symbian platform: the roaming must be explicitly
+ // Needed on at least Symbian platform: the roaming must be explicitly
// ignore()'d or migrate()'d
if (d)
d->ignore();
@@ -680,32 +670,34 @@ quint64 QNetworkSession::activeTime() const
void QNetworkSession::connectNotify(const char *signal)
{
QObject::connectNotify(signal);
- //check for preferredConfigurationChanged() signal connect notification
- //This is not required on all platforms
+
if (!d)
return;
- if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0)
+ //check for preferredConfigurationChanged() signal connect notification
+ //This is not required on all platforms
+ if (QLatin1String(signal) == SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)))
d->setALREnabled(true);
}
/*!
\internal
- This function is called when the client disconnects from the preferredConfigurationChanged()
- signal.
+ This function is called when the client disconnects from the
+ preferredConfigurationChanged() signal.
\sa connectNotify()
*/
void QNetworkSession::disconnectNotify(const char *signal)
{
QObject::disconnectNotify(signal);
- //check for preferredConfigurationChanged() signal disconnect notification
- //This is not required on all platforms
+
if (!d)
return;
- if (qstrcmp(signal, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool))) == 0)
+ //check for preferredConfigurationChanged() signal disconnect notification
+ //This is not required on all platforms
+ if (QLatin1String(signal) == SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)))
d->setALREnabled(false);
}
diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h
index 0b40147..717e085 100644
--- a/src/network/bearer/qnetworksession.h
+++ b/src/network/bearer/qnetworksession.h
@@ -71,6 +71,7 @@ class QNetworkSessionPrivate;
class QNetworkSessionExport QNetworkSession : public QObject
{
Q_OBJECT
+
public:
enum State {
Invalid = 0,
@@ -89,7 +90,8 @@ public:
OperationNotSupportedError,
InvalidConfigurationError
};
- explicit QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0);
+
+ explicit QNetworkSession(const QNetworkConfiguration &connConfig, QObject *parent = 0);
virtual ~QNetworkSession();
bool isOpen() const;
@@ -101,8 +103,8 @@ public:
State state() const;
SessionError error() const;
QString errorString() const;
- QVariant sessionProperty(const QString& key) const;
- void setSessionProperty(const QString& key, const QVariant& value);
+ QVariant sessionProperty(const QString &key) const;
+ void setSessionProperty(const QString &key, const QVariant &value);
quint64 bytesWritten() const;
quint64 bytesReceived() const;
@@ -121,13 +123,12 @@ public Q_SLOTS:
void accept();
void reject();
-
Q_SIGNALS:
void stateChanged(QNetworkSession::State);
void opened();
void closed();
void error(QNetworkSession::SessionError);
- void preferredConfigurationChanged(const QNetworkConfiguration& config, bool isSeamless);
+ void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
void newConfigurationActivated();
protected:
@@ -135,9 +136,9 @@ protected:
virtual void disconnectNotify(const char *signal);
private:
- QNetworkSessionPrivate* d;
friend class QNetworkSessionPrivate;
- };
+ QNetworkSessionPrivate *d;
+};
#ifndef QT_MOBILITY_BEARER
QT_END_NAMESPACE
@@ -149,4 +150,4 @@ QT_END_HEADER
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKSESSION_H
+#endif // QNETWORKSESSION_H
diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h
index c7b5718..943841f 100644
--- a/src/network/bearer/qnetworksession_p.h
+++ b/src/network/bearer/qnetworksession_p.h
@@ -67,14 +67,11 @@ class Q_NETWORK_EXPORT QNetworkSessionPrivate : public QObject
friend class QNetworkSession;
public:
- QNetworkSessionPrivate()
- : state(QNetworkSession::Invalid), isOpen(false)
- {
- }
-
+ QNetworkSessionPrivate() : QObject(),
+ state(QNetworkSession::Invalid), isOpen(false)
+ {}
virtual ~QNetworkSessionPrivate()
- {
- }
+ {}
//called by QNetworkSession constructor and ensures
//that the state is immediately updated (w/o actually opening
@@ -85,14 +82,14 @@ public:
#ifndef QT_NO_NETWORKINTERFACE
virtual QNetworkInterface currentInterface() const = 0;
#endif
- virtual QVariant sessionProperty(const QString& key) const = 0;
- virtual void setSessionProperty(const QString& key, const QVariant& value) = 0;
+ virtual QVariant sessionProperty(const QString &key) const = 0;
+ virtual void setSessionProperty(const QString &key, const QVariant &value) = 0;
virtual void open() = 0;
virtual void close() = 0;
virtual void stop() = 0;
- virtual void setALREnabled(bool /*enabled*/) { }
+ virtual void setALREnabled(bool /*enabled*/) {}
virtual void migrate() = 0;
virtual void accept() = 0;
virtual void ignore() = 0;
@@ -150,5 +147,4 @@ QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKSESSIONPRIVATE_H
-
+#endif // QNETWORKSESSIONPRIVATE_H
diff --git a/src/plugins/bearer/platformdefs_win.h b/src/plugins/bearer/platformdefs_win.h
index 68343cf..0968e71 100644
--- a/src/plugins/bearer/platformdefs_win.h
+++ b/src/plugins/bearer/platformdefs_win.h
@@ -138,4 +138,4 @@ enum NDIS_PHYSICAL_MEDIUM {
QT_END_NAMESPACE
-#endif
+#endif // QPLATFORMDEFS_WIN_H
diff --git a/src/plugins/bearer/qbearerengine_impl.h b/src/plugins/bearer/qbearerengine_impl.h
index 6c30d0f..2325bd0 100644
--- a/src/plugins/bearer/qbearerengine_impl.h
+++ b/src/plugins/bearer/qbearerengine_impl.h
@@ -60,8 +60,8 @@ public:
DisconnectionError,
};
- QBearerEngineImpl(QObject *parent = 0) : QBearerEngine(parent) { }
- ~QBearerEngineImpl() { }
+ QBearerEngineImpl(QObject *parent = 0) : QBearerEngine(parent) {}
+ ~QBearerEngineImpl() {}
virtual void connectToId(const QString &id) = 0;
virtual void disconnectFromId(const QString &id) = 0;
@@ -81,4 +81,5 @@ Q_SIGNALS:
QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif
+
+#endif // QBEARERENGINE_IMPL_H
diff --git a/src/plugins/bearer/qnetworksession_impl.cpp b/src/plugins/bearer/qnetworksession_impl.cpp
index ef5f347..27e14b1 100644
--- a/src/plugins/bearer/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/qnetworksession_impl.cpp
@@ -45,9 +45,10 @@
#include <QtNetwork/qnetworksession.h>
#include <QtNetwork/private/qnetworkconfigmanager_p.h>
-#include <QtCore/qstringlist.h>
+#include <QtCore/qdatetime.h>
#include <QtCore/qdebug.h>
#include <QtCore/qmutex.h>
+#include <QtCore/qstringlist.h>
#ifndef QT_NO_BEARERMANAGEMENT
@@ -71,10 +72,11 @@ class QNetworkSessionManagerPrivate : public QObject
Q_OBJECT
public:
- QNetworkSessionManagerPrivate(QObject *parent = 0);
- ~QNetworkSessionManagerPrivate();
+ QNetworkSessionManagerPrivate(QObject *parent = 0) : QObject(parent) {}
+ ~QNetworkSessionManagerPrivate() {}
- void forceSessionClose(const QNetworkConfiguration &config);
+ inline void forceSessionClose(const QNetworkConfiguration &config)
+ { emit forcedSessionClose(config); }
Q_SIGNALS:
void forcedSessionClose(const QNetworkConfiguration &config);
@@ -84,20 +86,6 @@ Q_SIGNALS:
Q_GLOBAL_STATIC(QNetworkSessionManagerPrivate, sessionManager);
-QNetworkSessionManagerPrivate::QNetworkSessionManagerPrivate(QObject *parent)
-: QObject(parent)
-{
-}
-
-QNetworkSessionManagerPrivate::~QNetworkSessionManagerPrivate()
-{
-}
-
-void QNetworkSessionManagerPrivate::forceSessionClose(const QNetworkConfiguration &config)
-{
- emit forcedSessionClose(config);
-}
-
void QNetworkSessionPrivateImpl::syncStateWithInterface()
{
connect(sessionManager(), SIGNAL(forcedSessionClose(QNetworkConfiguration)),
@@ -108,8 +96,7 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface()
state = QNetworkSession::Invalid;
lastError = QNetworkSession::UnknownSessionError;
- qRegisterMetaType<QBearerEngineImpl::ConnectionError>
- ("QBearerEngineImpl::ConnectionError");
+ qRegisterMetaType<QBearerEngineImpl::ConnectionError>("QBearerEngineImpl::ConnectionError");
switch (publicConfig.type()) {
case QNetworkConfiguration::InternetAccessPoint:
@@ -145,9 +132,8 @@ void QNetworkSessionPrivateImpl::open()
lastError = QNetworkSession::OperationNotSupportedError;
emit QNetworkSessionPrivate::error(lastError);
} else if (!isOpen) {
- if ((activeConfig.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- lastError =QNetworkSession::InvalidConfigurationError;
+ if ((activeConfig.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) {
+ lastError = QNetworkSession::InvalidConfigurationError;
state = QNetworkSession::Invalid;
emit stateChanged(state);
emit QNetworkSessionPrivate::error(lastError);
@@ -221,11 +207,10 @@ void QNetworkSessionPrivateImpl::reject()
#ifndef QT_NO_NETWORKINTERFACE
QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
{
- if (!publicConfig.isValid() || !engine || state != QNetworkSession::Connected)
+ if (!engine || state != QNetworkSession::Connected || !publicConfig.isValid())
return QNetworkInterface();
QString interface = engine->getInterfaceFromId(activeConfig.identifier());
-
if (interface.isEmpty())
return QNetworkInterface();
return QNetworkInterface::interfaceFromName(interface);
@@ -237,10 +222,7 @@ QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString &key) const
if (key == QLatin1String("AutoCloseSessionTimeout")) {
if (engine && engine->requiresPolling() &&
!(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
- if (sessionTimeout >= 0)
- return sessionTimeout * 10000;
- else
- return -1;
+ return sessionTimeout >= 0 ? sessionTimeout * 10000 : -1;
}
}
@@ -278,7 +260,8 @@ QString QNetworkSessionPrivateImpl::errorString() const
return tr("The specified configuration cannot be used.");
case QNetworkSession::RoamingError:
return tr("Roaming was aborted or is not possible.");
-
+ default:
+ break;
}
return QString();
@@ -293,24 +276,21 @@ quint64 QNetworkSessionPrivateImpl::bytesWritten() const
{
if (engine && state == QNetworkSession::Connected)
return engine->bytesWritten(activeConfig.identifier());
- else
- return Q_UINT64_C(0);
+ return Q_UINT64_C(0);
}
quint64 QNetworkSessionPrivateImpl::bytesReceived() const
{
if (engine && state == QNetworkSession::Connected)
return engine->bytesReceived(activeConfig.identifier());
- else
- return Q_UINT64_C(0);
+ return Q_UINT64_C(0);
}
quint64 QNetworkSessionPrivateImpl::activeTime() const
{
if (state == QNetworkSession::Connected && startTime != Q_UINT64_C(0))
return QDateTime::currentDateTime().toTime_t() - startTime;
- else
- return Q_UINT64_C(0);
+ return Q_UINT64_C(0);
}
void QNetworkSessionPrivateImpl::updateStateFromServiceNetwork()
@@ -323,17 +303,15 @@ void QNetworkSessionPrivateImpl::updateStateFromServiceNetwork()
if (activeConfig != config) {
if (engine) {
- disconnect(engine,
- SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
- this,
- SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)));
+ disconnect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
+ this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)));
}
activeConfig = config;
engine = getEngineFromId(activeConfig.identifier());
+
if (engine) {
- connect(engine,
- SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
+ connect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)),
Qt::QueuedConnection);
}
@@ -362,7 +340,6 @@ void QNetworkSessionPrivateImpl::updateStateFromActiveConfig()
return;
QNetworkSession::State oldState = state;
-
state = engine->sessionStateForId(activeConfig.identifier());
bool oldActive = isOpen;
@@ -410,8 +387,7 @@ void QNetworkSessionPrivateImpl::forcedSessionClose(const QNetworkConfiguration
}
}
-void QNetworkSessionPrivateImpl::connectionError(const QString &id,
- QBearerEngineImpl::ConnectionError error)
+void QNetworkSessionPrivateImpl::connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
{
if (activeConfig.identifier() == id) {
networkConfigurationsChanged();
@@ -443,4 +419,3 @@ void QNetworkSessionPrivateImpl::decrementTimeout()
QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-
diff --git a/src/plugins/bearer/qnetworksession_impl.h b/src/plugins/bearer/qnetworksession_impl.h
index a4902eb..d8f4803 100644
--- a/src/plugins/bearer/qnetworksession_impl.h
+++ b/src/plugins/bearer/qnetworksession_impl.h
@@ -58,8 +58,6 @@
#include <QtNetwork/private/qnetworkconfigmanager_p.h>
#include <QtNetwork/private/qnetworksession_p.h>
-#include <QtCore/qdatetime.h>
-
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
@@ -69,15 +67,13 @@ class QBearerEngineImpl;
class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate
{
Q_OBJECT
+
public:
QNetworkSessionPrivateImpl()
- : startTime(0), sessionTimeout(-1)
- {
- }
-
+ : startTime(0), sessionTimeout(-1)
+ {}
~QNetworkSessionPrivateImpl()
- {
- }
+ {}
//called by QNetworkSession constructor and ensures
//that the state is immediately updated (w/o actually opening
@@ -106,10 +102,6 @@ public:
quint64 bytesReceived() const;
quint64 activeTime() const;
-private:
- void updateStateFromServiceNetwork();
- void updateStateFromActiveConfig();
-
private Q_SLOTS:
void networkConfigurationsChanged();
void configurationChanged(QNetworkConfigurationPrivatePointer config);
@@ -118,6 +110,10 @@ private Q_SLOTS:
void decrementTimeout();
private:
+ void updateStateFromServiceNetwork();
+ void updateStateFromActiveConfig();
+
+private:
QBearerEngineImpl *engine;
quint64 startTime;
@@ -133,5 +129,4 @@ QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
-#endif //QNETWORKSESSION_IMPL_H
-
+#endif // QNETWORKSESSION_IMPL_H