diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2010-12-10 03:47:27 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-12-10 03:47:27 (GMT) |
commit | 36f88ca5bdace12bb713085a11351d06318534d7 (patch) | |
tree | 67f95824ce3b3bef88349f6cf5cde6023b817b39 /src/network | |
parent | 85a7b344571b5bb4b06bdef88a11a4e01f97d6ad (diff) | |
download | Qt-36f88ca5bdace12bb713085a11351d06318534d7.zip Qt-36f88ca5bdace12bb713085a11351d06318534d7.tar.gz Qt-36f88ca5bdace12bb713085a11351d06318534d7.tar.bz2 |
minor clean-ups and styling fixes
Merge-request: 899
Reviewed-by: Aaron McCarthy <aaron.mccarthy@nokia.com>
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/bearer/bearer.pri | 1 | ||||
-rw-r--r-- | src/network/bearer/qbearerengine.cpp | 14 | ||||
-rw-r--r-- | src/network/bearer/qbearerengine_p.h | 5 | ||||
-rw-r--r-- | src/network/bearer/qbearerplugin.cpp | 4 | ||||
-rw-r--r-- | src/network/bearer/qbearerplugin_p.h | 2 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager.cpp | 16 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager.h | 18 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 57 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.h | 28 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration.cpp | 30 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration.h | 11 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration_p.h | 17 | ||||
-rw-r--r-- | src/network/bearer/qnetworksession.cpp | 91 | ||||
-rw-r--r-- | src/network/bearer/qnetworksession.h | 17 | ||||
-rw-r--r-- | src/network/bearer/qnetworksession_p.h | 20 |
15 files changed, 145 insertions, 186 deletions
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..3dbea9d 100644 --- a/src/network/bearer/qbearerplugin_p.h +++ b/src/network/bearer/qbearerplugin_p.h @@ -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..a2c5504 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,24 @@ 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; + QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const; void updateConfigurations(); bool isOnline() const; 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 +112,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..d33cda1 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(), pollTimer(0), mutex(QMutex::Recursive), forcedPolling(0), firstUpdate(true) { qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration"); qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer"); @@ -79,7 +79,6 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration( 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 { @@ -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; @@ -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,9 +425,9 @@ 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"); } } @@ -482,7 +469,6 @@ void QNetworkConfigurationManagerPrivate::startPolling() pollTimer->setSingleShot(true); connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines())); } - pollTimer->start(); } } @@ -491,13 +477,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"); } } } diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 0649031..45c1fb4 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -91,17 +91,22 @@ public: 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; @@ -112,19 +117,12 @@ private: 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 +131,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..dedbbf9 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; + } } } } @@ -320,7 +320,7 @@ bool QNetworkSession::waitForOpened(int msecs) loop, SLOT(quit())); //final call - if (msecs>=0) + if (msecs >= 0) QTimer::singleShot(msecs, loop, SLOT(quit())); loop->exec(); @@ -471,7 +471,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 +516,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 +545,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 +579,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 +673,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 |