summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorPeter Hartmann <phartmann@blackberry.com>2013-06-26 17:37:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-28 23:05:57 +0200
commitc1ddaf4d21429b3dc5b18467a3e4f13904e363ba (patch)
tree01f4369376de27ea24403e2e1ab2a209aae0cef7 /src/network
parentbe35b70ca1bf61d022f7dee9df4aaccbf715b25e (diff)
QNetworkConfiguration: add public member bearerTypeFamily()
... to let the user know whether he is on e.g. Wifi, 2G, 3G or 4G. In most cases, this is what the user wants to know anyhow, while e.g. BearerEVDO or BearerCDMA2000 go into too much detail. Task-number: QTBUG-31828 Change-Id: I244a4473feb40e106cbc08e09afdee07d4ecc8d7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp70
-rw-r--r--src/network/bearer/qnetworkconfiguration.h5
2 files changed, 72 insertions, 3 deletions
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp
index 52fbb2441f..fae4aad76e 100644
--- a/src/network/bearer/qnetworkconfiguration.cpp
+++ b/src/network/bearer/qnetworkconfiguration.cpp
@@ -41,10 +41,10 @@
#include "qnetworkconfiguration.h"
#include "qnetworkconfiguration_p.h"
+#include <QDebug>
#ifdef Q_OS_BLACKBERRY
#include "private/qcore_unix_p.h" // qt_safe_open
-#include <QDebug>
#include <sys/pps.h>
#endif // Q_OS_BLACKBERRY
@@ -199,6 +199,8 @@ QT_BEGIN_NAMESPACE
\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 Bearer3G The configuration is for a 3G interface.
+ \value Bearer4G The configuration is for a 4G 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.
@@ -491,6 +493,8 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const
function can be used to retrieve a textural type name for the bearer.
An invalid network configuration always returns the BearerUnknown value.
+
+ \sa bearerTypeName(), bearerTypeFamily()
*/
QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const
{
@@ -515,6 +519,58 @@ QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const
}
/*!
+ \since 5.2
+
+ Returns the bearer type family used by this network configuration.
+ The following table lists how bearerType() values map to
+ bearerTypeFamily() values:
+
+ \table
+ \header
+ \li bearer type
+ \li bearer type family
+ \row
+ \li BearerUnknown, Bearer2G, BearerEthernet, BearerWLAN,
+ BearerBluetooth
+ \li (same type)
+ \row
+ \li BearerCDMA2000, BearerEVDO, BearerWCDMA, BearerHSPA, Bearer3G
+ \li Bearer3G
+ \row
+ \li BearerWiMAX, BearerLTE, Bearer4G
+ \li Bearer4G
+ \endtable
+
+ An invalid network configuration always returns the BearerUnknown value.
+
+ \sa bearerType(), bearerTypeName()
+*/
+QNetworkConfiguration::BearerType QNetworkConfiguration::bearerTypeFamily() const
+{
+ QNetworkConfiguration::BearerType type = bearerType();
+ switch (type) {
+ case QNetworkConfiguration::BearerUnknown: // fallthrough
+ case QNetworkConfiguration::Bearer2G: // fallthrough
+ case QNetworkConfiguration::BearerEthernet: // fallthrough
+ case QNetworkConfiguration::BearerWLAN: // fallthrough
+ case QNetworkConfiguration::BearerBluetooth:
+ return type;
+ case QNetworkConfiguration::BearerCDMA2000: // fallthrough
+ case QNetworkConfiguration::BearerEVDO: // fallthrough
+ case QNetworkConfiguration::BearerWCDMA: // fallthrough
+ case QNetworkConfiguration::BearerHSPA: // fallthrough
+ case QNetworkConfiguration::Bearer3G:
+ return QNetworkConfiguration::Bearer3G;
+ case QNetworkConfiguration::BearerWiMAX: // fallthrough
+ case QNetworkConfiguration::BearerLTE: // fallthrough
+ case QNetworkConfiguration::Bearer4G:
+ return QNetworkConfiguration::Bearer4G;
+ default:
+ qWarning() << "unknown bearer type" << type;
+ return QNetworkConfiguration::BearerUnknown;
+ }
+}
+/*!
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
@@ -541,6 +597,12 @@ QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const
\li Bearer2G
\li 2G
\row
+ \li Bearer3G
+ \li 3G
+ \row
+ \li Bearer4G
+ \li 4G
+ \row
\li BearerCDMA2000
\li CDMA2000
\row
@@ -567,7 +629,7 @@ QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const
configuration of type \l QNetworkConfiguration::ServiceNetwork or
\l QNetworkConfiguration::UserChoice.
- \sa bearerType()
+ \sa bearerType(), bearerTypeFamily()
*/
QString QNetworkConfiguration::bearerTypeName() const
{
@@ -601,6 +663,10 @@ QString QNetworkConfiguration::bearerTypeName() const
}
#endif // Q_OS_BLACKBERRY
return QStringLiteral("2G");
+ case Bearer3G:
+ return QStringLiteral("3G");
+ case Bearer4G:
+ return QStringLiteral("4G");
case BearerCDMA2000:
return QStringLiteral("CDMA2000");
case BearerWCDMA:
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index 8809e5526a..8887525a2f 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -99,7 +99,9 @@ public:
BearerBluetooth,
BearerWiMAX,
BearerEVDO,
- BearerLTE
+ BearerLTE,
+ Bearer3G,
+ Bearer4G
};
StateFlags state() const;
@@ -107,6 +109,7 @@ public:
Purpose purpose() const;
BearerType bearerType() const;
+ BearerType bearerTypeFamily() const;
QString bearerTypeName() const;
QString identifier() const;