diff options
Diffstat (limited to 'src/network/bearer')
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 24 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration.cpp | 117 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration.h | 19 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfiguration_p.h | 9 |
4 files changed, 133 insertions, 36 deletions
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 5d4274f..c4f7c00 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -150,25 +150,29 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration( end = engine->accessPointConfigurations.end(); it != end; ++it) { QNetworkConfigurationPrivatePointer ptr = it.value(); - const QString bearerName = ptr->bearerName(); QMutexLocker configLocker(&ptr->mutex); + QNetworkConfiguration::BearerType bearerType = ptr->bearerType; if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) { if (!defaultConfiguration) { defaultConfiguration = ptr; } else { + QMutexLocker defaultConfigLocker(&defaultConfiguration->mutex); + if (defaultConfiguration->state == ptr->state) { - if (defaultConfiguration->bearerName() == QLatin1String("Ethernet")) { + switch (defaultConfiguration->bearerType) { + case QNetworkConfiguration::BearerEthernet: // do nothing - } else if (defaultConfiguration->bearerName() == QLatin1String("WLAN")) { - // ethernet beats wlan - if (bearerName == QLatin1String("Ethernet")) - defaultConfiguration = ptr; - } else { - // ethernet and wlan beats other - if (bearerName == QLatin1String("Ethernet") || - bearerName == QLatin1String("WLAN")) { + break; + case QNetworkConfiguration::BearerWLAN: + // Ethernet beats WLAN + defaultConfiguration = ptr; + break; + default: + // Ethernet and WLAN beats other + if (bearerType == QNetworkConfiguration::BearerEthernet || + bearerType == QNetworkConfiguration::BearerWLAN) { defaultConfiguration = ptr; } } diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp index d7fceba..3190a30 100644 --- a/src/network/bearer/qnetworkconfiguration.cpp +++ b/src/network/bearer/qnetworkconfiguration.cpp @@ -183,6 +183,23 @@ QT_BEGIN_NAMESPACE */ /*! + \enum QNetworkConfiguration::BearerType + + Specifies the type of bearer used by a configuration. + + \value BearerUnknown The type of bearer is unknown or unspecified. The bearerTypeName() + function may return additional information. + \value BearerEthernet The configuration is for an Ethernet interfaces. + \value BearerWLAN The configuration is for a Wireless LAN interface. + \value Bearer2G The configuration is for a CSD, GPRS, HSCSD, EDGE or cdmaOne interface. + \value BearerCDMA2000 The configuration is for CDMA interface. + \value BearerWCDMA The configuration is for W-CDMA/UMTS interface. + \value BearerHSPA The configuration is for High Speed Packet Access (HSPA) interface. + \value BearerBluetooth The configuration is for a Bluetooth interface. + \value BearerWiMAX The configuration is for a WiMAX interface. +*/ + +/*! Constructs an invalid configuration object. \sa isValid() @@ -383,53 +400,113 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const } /*! - Returns the type of bearer. The string is not translated and - therefore can not be shown to the user. The subsequent table presents the currently known - bearer types: + \fn QString QNetworkConfiguration::bearerName() const + \deprecated + + This function is deprecated. It is equivalent to calling bearerTypeName(), however + bearerType() should be used in preference. +*/ + +/*! + Returns the type of bearer used by this network configuration. + + If the bearer type is \l {QNetworkConfiguration::BearerUnknown}{unknown} the bearerTypeName() + function can be used to retrieve a textural type name for the bearer. + + An invalid network configuration always returns the BearerUnknown value. +*/ +QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const +{ + if (!isValid()) + return BearerUnknown; + + QMutexLocker locker(&d->mutex); + + return d->bearerType; +} + +/*! + Returns the type of bearer used by this network configuration as a string. + + The string is not translated and therefore can not be shown to the user. The subsequent table + shows the fixed mappings between BearerType and the bearer type name for known types. If the + BearerType is unknown this function may return additional information if it is available; + otherwise an empty string will be returned. \table - \header + \header + \o BearerType \o Value - \o Description \row - \o Unknown - \o The session is based on an unknown or unspecified bearer type. + \o BearerUnknown + \o + \o The session is based on an unknown or unspecified bearer type. The value of the + string returned describes the bearer type. \row + \o BearerEthernet \o Ethernet - \o The session is based on Ethernet. \row + \o BearerWLAN \o WLAN - \o The session is based on Wireless LAN. \row + \o Bearer2G \o 2G - \o The session uses CSD, GPRS, HSCSD, EDGE or cdmaOne. - \row + \row + \o BearerCDMA2000 \o CDMA2000 - \o The session uses CDMA. \row + \o BearerWCDMA \o WCDMA - \o The session uses W-CDMA/UMTS. \row + \o BearerHSPA \o HSPA - \o The session uses High Speed Packet Access. \row + \o BearerBluetooth \o Bluetooth - \o The session uses Bluetooth. \row + \o BearerWiMAX \o WiMAX - \o The session uses WiMAX. \endtable - This function returns an empty string if this is an invalid configuration, - a network configuration of type \l QNetworkConfiguration::ServiceNetwork or + This function returns an empty string if this is an invalid configuration, a network + configuration of type \l QNetworkConfiguration::ServiceNetwork or \l QNetworkConfiguration::UserChoice. + + \sa bearerType() */ -QString QNetworkConfiguration::bearerName() const +QString QNetworkConfiguration::bearerTypeName() const { if (!isValid()) return QString(); - return d->bearerName(); + QMutexLocker locker(&d->mutex); + + if (d->type == QNetworkConfiguration::ServiceNetwork || + d->type == QNetworkConfiguration::UserChoice) + return QString(); + + switch (d->bearerType) { + case BearerUnknown: + return d->bearerTypeName(); + case BearerEthernet: + return QLatin1String("Ethernet"); + case BearerWLAN: + return QLatin1String("WLAN"); + case Bearer2G: + return QLatin1String("2G"); + case BearerCDMA2000: + return QLatin1String("CDMA2000"); + case BearerWCDMA: + return QLatin1String("WCDMA"); + case BearerHSPA: + return QLatin1String("HSPA"); + case BearerBluetooth: + return QLatin1String("Bluetooth"); + case BearerWiMAX: + return QLatin1String("WiMAX"); + } + + return QLatin1String("Unknown"); } QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h index dce39eb..d9d36fd 100644 --- a/src/network/bearer/qnetworkconfiguration.h +++ b/src/network/bearer/qnetworkconfiguration.h @@ -103,10 +103,27 @@ public: Q_DECLARE_FLAGS(StateFlags, StateFlag) + enum BearerType { + BearerUnknown, + BearerEthernet, + BearerWLAN, + Bearer2G, + BearerCDMA2000, + BearerWCDMA, + BearerHSPA, + BearerBluetooth, + BearerWiMAX + }; + StateFlags state() const; Type type() const; Purpose purpose() const; - QString bearerName() const; + + // Required to maintain source compatibility with Qt Mobility. + QT_DEPRECATED inline QString bearerName() const { return bearerTypeName(); } + BearerType bearerType() const; + QString bearerTypeName() const; + QString identifier() const; bool isRoamingAvailable() const; QList<QNetworkConfiguration> children() const; diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h index 966dfb2..2b0bbf6 100644 --- a/src/network/bearer/qnetworkconfiguration_p.h +++ b/src/network/bearer/qnetworkconfiguration_p.h @@ -68,6 +68,7 @@ public: QNetworkConfigurationPrivate () : mutex(QMutex::Recursive), type(QNetworkConfiguration::Invalid), purpose(QNetworkConfiguration::UnknownPurpose), + bearerType(QNetworkConfiguration::BearerUnknown), isValid(false), roamingSupported(false) { } @@ -78,24 +79,22 @@ public: serviceNetworkMembers.clear(); } - virtual QString bearerName() const + virtual QString bearerTypeName() const { - QMutexLocker locker(&mutex); - - return bearer; + return QLatin1String("Unknown"); } QMap<unsigned int, QNetworkConfigurationPrivatePointer> serviceNetworkMembers; mutable QMutex mutex; - QString bearer; QString name; QString id; QNetworkConfiguration::StateFlags state; QNetworkConfiguration::Type type; QNetworkConfiguration::Purpose purpose; + QNetworkConfiguration::BearerType bearerType; bool isValid; bool roamingSupported; |