summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/network/bearercloud/cloud.cpp28
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp24
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp97
-rw-r--r--src/network/bearer/qnetworkconfiguration.h13
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h9
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.h2
-rw-r--r--src/plugins/bearer/corewlan/qcorewlanengine.mm6
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp28
-rw-r--r--src/plugins/bearer/generic/qgenericengine.h2
-rw-r--r--src/plugins/bearer/icd/qicdengine.cpp18
-rw-r--r--src/plugins/bearer/icd/qicdengine.h14
-rw-r--r--src/plugins/bearer/icd/qnetworksession_impl.cpp3
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.cpp7
-rw-r--r--src/plugins/bearer/nativewifi/qnativewifiengine.h2
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp34
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.h2
-rw-r--r--src/plugins/bearer/nla/qnlaengine.cpp47
-rw-r--r--src/plugins/bearer/nla/qnlaengine.h2
-rw-r--r--src/plugins/bearer/symbian/symbianengine.cpp84
-rw-r--r--src/plugins/bearer/symbian/symbianengine.h16
20 files changed, 228 insertions, 210 deletions
diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp
index f45ae0d..8deaab3 100644
--- a/examples/network/bearercloud/cloud.cpp
+++ b/examples/network/bearercloud/cloud.cpp
@@ -53,7 +53,7 @@
#include <math.h>
-static QMap<QString, QSvgRenderer *> svgCache;
+static QMap<QNetworkConfiguration::BearerType, QSvgRenderer *> svgCache;
//! [0]
Cloud::Cloud(const QNetworkConfiguration &config, QGraphicsItem *parent)
@@ -313,17 +313,25 @@ void Cloud::stateChanged(QNetworkSession::State state)
//! [1]
void Cloud::newConfigurationActivated()
{
- const QString bearerTypeName = configuration.bearerTypeName();
- if (!svgCache.contains(bearerTypeName)) {
- if (bearerTypeName == QLatin1String("WLAN"))
- svgCache.insert(bearerTypeName, new QSvgRenderer(QLatin1String(":wlan.svg")));
- else if (bearerTypeName == QLatin1String("Ethernet"))
- svgCache.insert(bearerTypeName, new QSvgRenderer(QLatin1String(":lan.svg")));
- else
- svgCache.insert(bearerTypeName, new QSvgRenderer(QLatin1String(":unknown.svg")));
+ QNetworkConfiguration::BearerType bearerType = configuration.bearerType();
+ if (!svgCache.contains(bearerType)) {
+ QSvgRenderer *renderer = 0;
+ switch (bearerType) {
+ case QNetworkConfiguration::BearerWLAN:
+ renderer = new QSvgRenderer(QLatin1String(":wlan.svg"));
+ break;
+ case QNetworkConfiguration::BearerEthernet:
+ renderer = new QSvgRenderer(QLatin1String(":lan.svg"));
+ break;
+ default:
+ renderer = new QSvgRenderer(QLatin1String(":unknown.svg"));
+ }
+
+ if (renderer)
+ svgCache.insert(bearerType, renderer);
}
- icon->setSharedRenderer(svgCache[bearerTypeName]);
+ icon->setSharedRenderer(svgCache[bearerType]);
if (configuration.name().isEmpty()) {
text->setPlainText(tr("HIDDEN NETWORK"));
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 b939342..b645916 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()
@@ -386,58 +403,110 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const
\fn QString QNetworkConfiguration::bearerName() const
\deprecated
- This function is deprecated. It is equivalent to calling bearerTypeName().
+ 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
- presents the currently known bearer types:
+ 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
+ \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
+ \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
\l QNetworkConfiguration::UserChoice.
+
+ \sa bearerType()
*/
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 QString();
}
QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index 42e8b6a..d9d36fd 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -103,12 +103,25 @@ 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;
// 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;
diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h
index 966dfb2..0fc6ee9 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 QString();
}
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;
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.h b/src/plugins/bearer/corewlan/qcorewlanengine.h
index 4d90648..56da66a 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.h
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.h
@@ -68,8 +68,6 @@ public:
QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
- QString bearerName(const QString &id);
-
void connectToId(const QString &id);
void disconnectFromId(const QString &id);
diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm
index 6ba9504..131f36d 100644
--- a/src/plugins/bearer/corewlan/qcorewlanengine.mm
+++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm
@@ -264,7 +264,7 @@ QStringList QScanThread::foundNetwork(const QString &id, const QString &name, co
ptr->id = id;
ptr->state = state;
ptr->type = QNetworkConfiguration::InternetAccessPoint;
- ptr->bearer = QLatin1String("WLAN");
+ ptr->bearerType = QNetworkConfiguration::BearerWLAN;
ptr->purpose = purpose;
fetchedConfigurations.append( ptr);
@@ -789,8 +789,8 @@ void QCoreWlanEngine::networksChanged()
changed = true;
}
- if (ptr->bearer != cpPriv->bearer) {
- ptr->bearer = cpPriv->bearer;
+ if (ptr->bearerType != cpPriv->bearerType) {
+ ptr->bearerType = cpPriv->bearerType;
changed = true;
}
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index 652fe4a..fad3ae8 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -69,7 +69,7 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_NETWORKINTERFACE
-static QString qGetInterfaceType(const QString &interface)
+static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
{
#ifdef Q_OS_WIN32
unsigned long oid;
@@ -78,10 +78,10 @@ static QString qGetInterfaceType(const QString &interface)
NDIS_MEDIUM medium;
NDIS_PHYSICAL_MEDIUM physicalMedium;
- HANDLE handle = CreateFile((TCHAR *)QString("\\\\.\\%1").arg(interface).utf16(), 0,
+ HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0,
FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (handle == INVALID_HANDLE_VALUE)
- return QLatin1String("Unknown");
+ return QNetworkConfiguration::BearerUnknown;
oid = OID_GEN_MEDIA_SUPPORTED;
bytesWritten = 0;
@@ -89,7 +89,7 @@ static QString qGetInterfaceType(const QString &interface)
&medium, sizeof(medium), &bytesWritten, 0);
if (!result) {
CloseHandle(handle);
- return QLatin1String("Unknown");
+ return QNetworkConfiguration::BearerUnknown;
}
oid = OID_GEN_PHYSICAL_MEDIUM;
@@ -100,9 +100,9 @@ static QString qGetInterfaceType(const QString &interface)
CloseHandle(handle);
if (medium == NdisMedium802_3)
- return QLatin1String("Ethernet");
+ return QNetworkConfiguration::BearerEthernet;
else
- return QLatin1String("Unknown");
+ return QNetworkConfiguration::BearerUnknown;
}
CloseHandle(handle);
@@ -110,16 +110,16 @@ static QString qGetInterfaceType(const QString &interface)
if (medium == NdisMedium802_3) {
switch (physicalMedium) {
case NdisPhysicalMediumWirelessLan:
- return QLatin1String("WLAN");
+ return QNetworkConfiguration::BearerWLAN;
case NdisPhysicalMediumBluetooth:
- return QLatin1String("Bluetooth");
+ return QNetworkConfiguration::BearerBluetooth;
case NdisPhysicalMediumWiMax:
- return QLatin1String("WiMAX");
+ return QNetworkConfiguration::BearerWiMAX;
default:
#ifdef BEARER_MANAGEMENT_DEBUG
qDebug() << "Physical Medium" << physicalMedium;
#endif
- return QLatin1String("Ethernet");
+ return QNetworkConfiguration::BearerEthernet;
}
}
@@ -135,12 +135,12 @@ static QString qGetInterfaceType(const QString &interface)
close(sock);
if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER)
- return QLatin1String("Ethernet");
+ return QNetworkConfiguration::BearerEthernet;
#else
Q_UNUSED(interface);
#endif
- return QLatin1String("Unknown");
+ return QNetworkConfiguration::BearerUnknown;
}
#endif
@@ -214,7 +214,7 @@ void QGenericEngine::doRequestUpdate()
continue;
// ignore WLAN interface handled in separate engine
- if (qGetInterfaceType(interface.name()) == QLatin1String("WLAN"))
+ if (qGetInterfaceType(interface.name()) == QNetworkConfiguration::BearerWLAN)
continue;
uint identifier;
@@ -277,7 +277,7 @@ void QGenericEngine::doRequestUpdate()
ptr->id = id;
ptr->state = state;
ptr->type = QNetworkConfiguration::InternetAccessPoint;
- ptr->bearer = qGetInterfaceType(interface.name());
+ ptr->bearerType = qGetInterfaceType(interface.name());
accessPointConfigurations.insert(id, ptr);
configurationInterface.insert(id, interface.name());
diff --git a/src/plugins/bearer/generic/qgenericengine.h b/src/plugins/bearer/generic/qgenericengine.h
index cdbbc9d..021b35b 100644
--- a/src/plugins/bearer/generic/qgenericengine.h
+++ b/src/plugins/bearer/generic/qgenericengine.h
@@ -65,8 +65,6 @@ public:
QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
- QString bearerName(const QString &id);
-
void connectToId(const QString &id);
void disconnectFromId(const QString &id);
diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp
index 0083380..6060a09 100644
--- a/src/plugins/bearer/icd/qicdengine.cpp
+++ b/src/plugins/bearer/icd/qicdengine.cpp
@@ -60,16 +60,11 @@ IcdNetworkConfigurationPrivate::~IcdNetworkConfigurationPrivate()
{
}
-QString IcdNetworkConfigurationPrivate::bearerName() const
+QString IcdNetworkConfigurationPrivate::bearerTypeName() const
{
- if (iap_type == QLatin1String("WLAN_INFRA") ||
- iap_type == QLatin1String("WLAN_ADHOC")) {
- return QLatin1String("WLAN");
- } else if (iap_type == QLatin1String("GPRS")) {
- return QLatin1String("HSPA");
- } else {
- return iap_type;
- }
+ QMutexLocker locker(&mutex);
+
+ return iap_type;
}
/* The IapAddTimer is a helper class that makes sure we update
@@ -400,6 +395,7 @@ void QIcdEngine::addConfiguration(QString& iap_id)
ptr->mutex.lock();
ptr->id = iap_id;
toIcdConfig(ptr)->iap_type = iap_type;
+ ptr->bearerType = bearerTypeFromIapType(iap_type);
toIcdConfig(ptr)->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString());
toIcdConfig(ptr)->network_id = ssid;
toIcdConfig(ptr)->service_id = saved_iap.value("service_id").toString();
@@ -424,6 +420,7 @@ void QIcdEngine::addConfiguration(QString& iap_id)
cpPriv->isValid = true;
cpPriv->id = iap_id;
cpPriv->iap_type = iap_type;
+ cpPriv->bearerType = bearerTypeFromIapType(iap_type);
cpPriv->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString());
cpPriv->service_id = saved_iap.value("service_id").toString();
cpPriv->service_type = saved_iap.value("service_type").toString();
@@ -480,6 +477,7 @@ void QIcdEngine::addConfiguration(QString& iap_id)
ptr->isValid = true;
if (toIcdConfig(ptr)->iap_type != iap_type) {
toIcdConfig(ptr)->iap_type = iap_type;
+ ptr->bearerType = bearerTypeFromIapType(iap_type);
update_needed = true;
}
if (iap_type.startsWith(QLatin1String("WLAN"))) {
@@ -580,6 +578,7 @@ void QIcdEngine::doRequestUpdate(QList<Maemo::IcdScanResult> scanned)
cpPriv->network_id = ssid;
cpPriv->network_attrs = getNetworkAttrs(true, iap_id, iap_type, QString());
cpPriv->iap_type = iap_type;
+ cpPriv->bearerType = bearerTypeFromIapType(iap_type);
cpPriv->service_id = saved_ap.value("service_id").toString();
cpPriv->service_type = saved_ap.value("service_type").toString();
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
@@ -688,6 +687,7 @@ rescan_list:
cpPriv->id = scanned_ssid.data(); // Note: id is now ssid, it should be set to IAP id if the IAP is saved
cpPriv->network_id = scanned_ssid;
cpPriv->iap_type = ap.scan.network_type;
+ cpPriv->bearerType = bearerTypeFromIapType(cpPriv->iap_type);
cpPriv->network_attrs = ap.scan.network_attrs;
cpPriv->service_id = ap.scan.service_id;
cpPriv->service_type = ap.scan.service_type;
diff --git a/src/plugins/bearer/icd/qicdengine.h b/src/plugins/bearer/icd/qicdengine.h
index 1b291eb..16dc979 100644
--- a/src/plugins/bearer/icd/qicdengine.h
+++ b/src/plugins/bearer/icd/qicdengine.h
@@ -54,13 +54,25 @@ class QNetworkConfigurationPrivate;
class IapMonitor;
class QDBusInterface;
+inline QNetworkConfiguration::BearerType bearerTypeFromIapType(const QString &iapType)
+{
+ if (iapType == QLatin1String("WLAN_INFRA") ||
+ iapType == QLatin1String("WLAN_ADHOC")) {
+ return QNetworkConfiguration::BearerWLAN;
+ } else if (iapType == QLatin1String("GPRS")) {
+ return QNetworkConfiguration::BearerHSPA;
+ } else {
+ return QNetworkConfiguration::BearerUnknown;
+ }
+}
+
class IcdNetworkConfigurationPrivate : public QNetworkConfigurationPrivate
{
public:
IcdNetworkConfigurationPrivate();
~IcdNetworkConfigurationPrivate();
- QString bearerName() const;
+ virtual QString bearerTypeName() const;
// In Maemo the id field (defined in QNetworkConfigurationPrivate)
// is the IAP id (which typically is UUID)
diff --git a/src/plugins/bearer/icd/qnetworksession_impl.cpp b/src/plugins/bearer/icd/qnetworksession_impl.cpp
index 7af9962..cafcfca 100644
--- a/src/plugins/bearer/icd/qnetworksession_impl.cpp
+++ b/src/plugins/bearer/icd/qnetworksession_impl.cpp
@@ -318,6 +318,7 @@ QNetworkConfiguration& QNetworkSessionPrivateImpl::copyConfig(QNetworkConfigurat
cpPriv->purpose = fromPriv->purpose;
cpPriv->network_id = fromPriv->network_id;
cpPriv->iap_type = fromPriv->iap_type;
+ cpPriv->bearerType = fromPriv->bearerType;
cpPriv->network_attrs = fromPriv->network_attrs;
cpPriv->service_type = fromPriv->service_type;
cpPriv->service_id = fromPriv->service_id;
@@ -443,6 +444,7 @@ void QNetworkSessionPrivateImpl::syncStateWithInterface()
ptr->id = toIcdConfig(ptr)->network_id;
toIcdConfig(ptr)->network_attrs = state_results.first().params.network_attrs;
toIcdConfig(ptr)->iap_type = state_results.first().params.network_type;
+ ptr->bearerType = bearerTypeFromIapType(toIcdConfig(ptr)->iap_type);
toIcdConfig(ptr)->service_type = state_results.first().params.service_type;
toIcdConfig(ptr)->service_id = state_results.first().params.service_id;
toIcdConfig(ptr)->service_attrs = state_results.first().params.service_attrs;
@@ -816,6 +818,7 @@ void QNetworkSessionPrivateImpl::stateChange(const QDBusMessage& rep)
icdConfig->name = name;
icdConfig->iap_type = rep.arguments().at(3).toString(); // connect_result.connect.network_type;
+ icdConfig->bearerType = bearerTypeFromIapType(icdConfig->iap_type);
icdConfig->isValid = true;
icdConfig->state = QNetworkConfiguration::Active;
icdConfig->type = QNetworkConfiguration::InternetAccessPoint;
diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
index 1a55402..ba8297e 100644
--- a/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
+++ b/src/plugins/bearer/nativewifi/qnativewifiengine.cpp
@@ -206,7 +206,7 @@ void QNativeWifiEngine::scanComplete()
ptr->id = id;
ptr->state = state;
ptr->type = QNetworkConfiguration::InternetAccessPoint;
- ptr->bearer = QLatin1String("WLAN");
+ ptr->bearerType = QNetworkConfiguration::BearerWLAN;
accessPointConfigurations.insert(id, ptr);
@@ -350,11 +350,6 @@ bool QNativeWifiEngine::hasIdentifier(const QString &id)
return false;
}
-/*QString QNativeWifiEngine::bearerName(const QString &)
-{
- return QLatin1String("WLAN");
-}*/
-
void QNativeWifiEngine::connectToId(const QString &id)
{
QMutexLocker locker(&mutex);
diff --git a/src/plugins/bearer/nativewifi/qnativewifiengine.h b/src/plugins/bearer/nativewifi/qnativewifiengine.h
index 0e9576b..dccf2e2 100644
--- a/src/plugins/bearer/nativewifi/qnativewifiengine.h
+++ b/src/plugins/bearer/nativewifi/qnativewifiengine.h
@@ -75,8 +75,6 @@ public:
QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
- //QString bearerName(const QString &id);
-
void connectToId(const QString &id);
void disconnectFromId(const QString &id);
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index 3ebc356..f3f693b 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -181,30 +181,6 @@ bool QNetworkManagerEngine::hasIdentifier(const QString &id)
return false;
}
-QString QNetworkManagerEngine::bearerName(const QString &id)
-{
- QMutexLocker locker(&mutex);
-
- QNetworkManagerSettingsConnection *connection = connectionFromId(id);
-
- if (!connection)
- return QString();
-
- QNmSettingsMap map = connection->getSettings();
- const QString connectionType = map.value("connection").value("type").toString();
-
- if (connectionType == "802-3-ethernet")
- return QLatin1String("Ethernet");
- else if (connectionType == "802-11-wireless")
- return QLatin1String("WLAN");
- else if (connectionType == "gsm")
- return QLatin1String("2G");
- else if (connectionType == "cdma")
- return QLatin1String("CDMA2000");
- else
- return QString();
-}
-
void QNetworkManagerEngine::connectToId(const QString &id)
{
QMutexLocker locker(&mutex);
@@ -611,7 +587,7 @@ void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjec
ptr->purpose = QNetworkConfiguration::PublicPurpose;
}
ptr->state = QNetworkConfiguration::Undefined;
- ptr->bearer = QLatin1String("WLAN");
+ ptr->bearerType = QNetworkConfiguration::BearerWLAN;
accessPointConfigurations.insert(ptr->id, ptr);
@@ -724,7 +700,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
const QString connectionType = map.value("connection").value("type").toString();
if (connectionType == QLatin1String("802-3-ethernet")) {
- cpPriv->bearer = QLatin1String("Ethernet");
+ cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
@@ -739,7 +715,7 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
}
}
} else if (connectionType == QLatin1String("802-11-wireless")) {
- cpPriv->bearer = QLatin1String("WLAN");
+ cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString();
const QString connectionSecurity = map.value("802-11-wireless").value("security").toString();
@@ -767,9 +743,9 @@ QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QStri
}
}
} else if (connectionType == "gsm") {
- cpPriv->bearer = QLatin1String("2G");
+ cpPriv->bearerType = QNetworkConfiguration::Bearer2G;
} else if (connectionType == "cdma") {
- cpPriv->bearer = QLatin1String("CDMA2000");
+ cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000;
}
return cpPriv;
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
index 8e95a2c..ffb8395 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
@@ -78,8 +78,6 @@ public:
QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
- QString bearerName(const QString &id);
-
void connectToId(const QString &id);
void disconnectFromId(const QString &id);
diff --git a/src/plugins/bearer/nla/qnlaengine.cpp b/src/plugins/bearer/nla/qnlaengine.cpp
index 9ab9924..fd50099 100644
--- a/src/plugins/bearer/nla/qnlaengine.cpp
+++ b/src/plugins/bearer/nla/qnlaengine.cpp
@@ -119,7 +119,7 @@ static void printBlob(NLA_BLOB *blob)
}
#endif
-static QString qGetInterfaceType(const QString &interface)
+static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
{
#ifdef Q_OS_WINCE
Q_UNUSED(interface)
@@ -130,10 +130,10 @@ static QString qGetInterfaceType(const QString &interface)
NDIS_MEDIUM medium;
NDIS_PHYSICAL_MEDIUM physicalMedium;
- HANDLE handle = CreateFile((TCHAR *)QString(QLatin1String("\\\\.\\%1")).arg(interface).utf16(),
- 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
+ HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0,
+ FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (handle == INVALID_HANDLE_VALUE)
- return QLatin1String("Unknown");
+ return QNetworkConfiguration::BearerUnknown;
oid = OID_GEN_MEDIA_SUPPORTED;
bytesWritten = 0;
@@ -141,7 +141,7 @@ static QString qGetInterfaceType(const QString &interface)
&medium, sizeof(medium), &bytesWritten, 0);
if (!result) {
CloseHandle(handle);
- return QLatin1String("Unknown");
+ return QNetworkConfiguration::BearerUnknown;
}
oid = OID_GEN_PHYSICAL_MEDIUM;
@@ -152,9 +152,9 @@ static QString qGetInterfaceType(const QString &interface)
CloseHandle(handle);
if (medium == NdisMedium802_3)
- return QLatin1String("Ethernet");
+ return QNetworkConfiguration::BearerEthernet;
else
- return QLatin1String("Unknown");
+ return QNetworkConfiguration::BearerUnknown;
}
CloseHandle(handle);
@@ -162,16 +162,16 @@ static QString qGetInterfaceType(const QString &interface)
if (medium == NdisMedium802_3) {
switch (physicalMedium) {
case NdisPhysicalMediumWirelessLan:
- return QLatin1String("WLAN");
+ return QNetworkConfiguration::BearerWLAN;
case NdisPhysicalMediumBluetooth:
- return QLatin1String("Bluetooth");
+ return QNetworkConfiguration::BearerBluetooth;
case NdisPhysicalMediumWiMax:
- return QLatin1String("WiMAX");
+ return QNetworkConfiguration::BearerWiMAX;
default:
#ifdef BEARER_MANAGEMENT_DEBUG
qDebug() << "Physical Medium" << physicalMedium;
#endif
- return QLatin1String("Ethernet");
+ return QNetworkConfiguration::BearerEthernet;
}
}
@@ -181,7 +181,7 @@ static QString qGetInterfaceType(const QString &interface)
#endif
- return QLatin1String("Unknown");
+ return QNetworkConfiguration::BearerUnknown;
}
class QNlaThread : public QThread
@@ -374,10 +374,9 @@ DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv
#endif
break;
case NLA_CONNECTIVITY:
- if (blob->data.connectivity.internet == NLA_INTERNET_YES)
- cpPriv->internet = true;
- else
- cpPriv->internet = false;
+#ifdef BEARER_MANAGEMENT_DEBUG
+ qDebug("%s: unhandled header type NLA_CONNECTIVITY", __FUNCTION__);
+#endif
break;
case NLA_ICS:
#ifdef BEARER_MANAGEMENT_DEBUG
@@ -438,8 +437,10 @@ QNetworkConfigurationPrivate *QNlaThread::parseQuerySet(const WSAQUERYSET *query
} while (offset != 0 && offset < querySet->lpBlob->cbSize);
}
- if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent()))
- cpPriv->bearer = engine->bearerName(cpPriv->id);
+ if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) {
+ const QString interface = engine->getInterfaceFromId(cpPriv->id);
+ cpPriv->bearerType = qGetInterfaceType(interface);
+ }
return cpPriv;
}
@@ -586,16 +587,6 @@ bool QNlaEngine::hasIdentifier(const QString &id)
return configurationInterface.contains(id.toUInt());
}
-QString QNlaEngine::bearerName(const QString &id)
-{
- QString interface = getInterfaceFromId(id);
-
- if (interface.isEmpty())
- return QString();
-
- return qGetInterfaceType(interface);
-}
-
void QNlaEngine::connectToId(const QString &id)
{
emit connectionError(id, OperationNotSupported);
diff --git a/src/plugins/bearer/nla/qnlaengine.h b/src/plugins/bearer/nla/qnlaengine.h
index 1d49464..69f54c9 100644
--- a/src/plugins/bearer/nla/qnlaengine.h
+++ b/src/plugins/bearer/nla/qnlaengine.h
@@ -85,8 +85,6 @@ public:
QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
- QString bearerName(const QString &id);
-
void connectToId(const QString &id);
void disconnectFromId(const QString &id);
diff --git a/src/plugins/bearer/symbian/symbianengine.cpp b/src/plugins/bearer/symbian/symbianengine.cpp
index 4bd6d2f..078e8dd 100644
--- a/src/plugins/bearer/symbian/symbianengine.cpp
+++ b/src/plugins/bearer/symbian/symbianengine.cpp
@@ -75,7 +75,7 @@ QT_BEGIN_NAMESPACE
static const int KUserChoiceIAPId = 0;
SymbianNetworkConfigurationPrivate::SymbianNetworkConfigurationPrivate()
-: bearer(BearerUnknown), numericId(0), connectionId(0)
+: numericId(0), connectionId(0)
{
}
@@ -83,32 +83,6 @@ SymbianNetworkConfigurationPrivate::~SymbianNetworkConfigurationPrivate()
{
}
-QString SymbianNetworkConfigurationPrivate::bearerName() const
-{
- QMutexLocker locker(&mutex);
-
- switch (bearer) {
- 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");
- default:
- return QString();
- }
-}
-
SymbianEngine::SymbianEngine(QObject *parent)
: QBearerEngine(parent), CActive(CActive::EPriorityHigh), iFirstUpdate(true), iInitOk(true),
iUpdatePending(false)
@@ -146,7 +120,7 @@ void SymbianEngine::initialize()
SymbianNetworkConfigurationPrivate *cpPriv = new SymbianNetworkConfigurationPrivate;
cpPriv->name = "UserChoice";
- cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown;
+ cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
cpPriv->state = QNetworkConfiguration::Discovered;
cpPriv->isValid = true;
cpPriv->id = QString::number(qHash(KUserChoiceIAPId));
@@ -517,25 +491,25 @@ SymbianNetworkConfigurationPrivate *SymbianEngine::configFromConnectionMethodL(
TUint32 bearerId = connectionMethod.GetIntAttributeL(CMManager::ECmCommsDBBearerType);
switch (bearerId) {
case KCommDbBearerCSD:
- cpPriv->bearer = SymbianNetworkConfigurationPrivate::Bearer2G;
+ cpPriv->bearerType = QNetworkConfiguration::Bearer2G;
break;
case KCommDbBearerWcdma:
- cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA;
+ cpPriv->bearerType = QNetworkConfiguration::BearerWCDMA;
break;
case KCommDbBearerLAN:
- cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet;
+ cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
break;
case KCommDbBearerVirtual:
- cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown;
+ cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
break;
case KCommDbBearerPAN:
- cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown;
+ cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
break;
case KCommDbBearerWLAN:
- cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerWLAN;
+ cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
break;
default:
- cpPriv->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown;
+ cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
break;
}
@@ -619,28 +593,28 @@ void SymbianEngine::readNetworkConfigurationValuesFromCommsDbL(
apNetworkConfiguration->roamingSupported = false;
switch (pAPItem->BearerTypeL()) {
case EApBearerTypeCSD:
- apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::Bearer2G;
+ apNetworkConfiguration->bearerType = QNetworkConfiguration::Bearer2G;
break;
case EApBearerTypeGPRS:
- apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::Bearer2G;
+ apNetworkConfiguration->bearerType = QNetworkConfiguration::Bearer2G;
break;
case EApBearerTypeHSCSD:
- apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA;
+ apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerHSPA;
break;
case EApBearerTypeCDMA:
- apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000;
+ apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerCDMA2000;
break;
case EApBearerTypeWLAN:
- apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerWLAN;
+ apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerWLAN;
break;
case EApBearerTypeLAN:
- apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet;
+ apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerEthernet;
break;
case EApBearerTypeLANModem:
- apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerEthernet;
+ apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerEthernet;
break;
default:
- apNetworkConfiguration->bearer = SymbianNetworkConfigurationPrivate::BearerUnknown;
+ apNetworkConfiguration->bearerType = QNetworkConfiguration::BearerUnknown;
break;
}
@@ -870,38 +844,38 @@ void SymbianEngine::updateMobileBearerToConfigs(TConnMonBearerInfo bearerInfo)
SymbianNetworkConfigurationPrivate *p = toSymbianConfig(ptr);
- if (p->bearer >= SymbianNetworkConfigurationPrivate::Bearer2G &&
- p->bearer <= SymbianNetworkConfigurationPrivate::BearerHSPA) {
+ if (p->bearerType >= QNetworkConfiguration::Bearer2G &&
+ p->bearerType <= QNetworkConfiguration::BearerHSPA) {
switch (bearerInfo) {
case EBearerInfoCSD:
- p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G;
+ p->bearerType = QNetworkConfiguration::Bearer2G;
break;
case EBearerInfoWCDMA:
- p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA;
+ p->bearerType = QNetworkConfiguration::BearerWCDMA;
break;
case EBearerInfoCDMA2000:
- p->bearer = SymbianNetworkConfigurationPrivate::BearerCDMA2000;
+ p->bearerType = QNetworkConfiguration::BearerCDMA2000;
break;
case EBearerInfoGPRS:
- p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G;
+ p->bearerType = QNetworkConfiguration::Bearer2G;
break;
case EBearerInfoHSCSD:
- p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G;
+ p->bearerType = QNetworkConfiguration::Bearer2G;
break;
case EBearerInfoEdgeGPRS:
- p->bearer = SymbianNetworkConfigurationPrivate::Bearer2G;
+ p->bearerType = QNetworkConfiguration::Bearer2G;
break;
case EBearerInfoWcdmaCSD:
- p->bearer = SymbianNetworkConfigurationPrivate::BearerWCDMA;
+ p->bearerType = QNetworkConfiguration::BearerWCDMA;
break;
case EBearerInfoHSDPA:
- p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA;
+ p->bearerType = QNetworkConfiguration::BearerHSPA;
break;
case EBearerInfoHSUPA:
- p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA;
+ p->bearerType = QNetworkConfiguration::BearerHSPA;
break;
case EBearerInfoHSxPA:
- p->bearer = SymbianNetworkConfigurationPrivate::BearerHSPA;
+ p->bearerType = QNetworkConfiguration::BearerHSPA;
break;
}
}
diff --git a/src/plugins/bearer/symbian/symbianengine.h b/src/plugins/bearer/symbian/symbianengine.h
index ecd858d..1fe6395 100644
--- a/src/plugins/bearer/symbian/symbianengine.h
+++ b/src/plugins/bearer/symbian/symbianengine.h
@@ -73,23 +73,9 @@ class AccessPointsAvailabilityScanner;
class SymbianNetworkConfigurationPrivate : public QNetworkConfigurationPrivate
{
public:
- enum Bearer {
- BearerEthernet,
- BearerWLAN,
- Bearer2G,
- BearerCDMA2000,
- BearerWCDMA,
- BearerHSPA,
- BearerBluetooth,
- BearerWiMAX,
- BearerUnknown = -1
- };
-
SymbianNetworkConfigurationPrivate();
~SymbianNetworkConfigurationPrivate();
- QString bearerName() const;
-
inline TUint32 numericIdentifier() const
{
QMutexLocker locker(&mutex);
@@ -110,8 +96,6 @@ public:
QString mappingName;
- Bearer bearer;
-
// So called IAP id from the platform. Remains constant as long as the
// platform is aware of the configuration ie. it is stored in the databases
// --> does not depend on whether connections are currently open or not.