summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-01-04 23:06:49 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-01-04 23:45:12 (GMT)
commit31e6fc5ae7f7fbe2f23b519cb76dcc579dac1f41 (patch)
tree0f013fe0a7407737aac96d8d0dab5ccf83815261
parent0f31f63e11d4fcb2b399979de28368a89275b911 (diff)
downloadQt-31e6fc5ae7f7fbe2f23b519cb76dcc579dac1f41.zip
Qt-31e6fc5ae7f7fbe2f23b519cb76dcc579dac1f41.tar.gz
Qt-31e6fc5ae7f7fbe2f23b519cb76dcc579dac1f41.tar.bz2
Bearer Management Integration 2.
-rw-r--r--config.tests/mac/corewlan/corewlan.pro (renamed from config.tests/mac/corelwan/corewlan.pro)0
-rw-r--r--config.tests/mac/corewlan/corewlantest.mm (renamed from config.tests/mac/corelwan/corewlantest.mm)0
-rw-r--r--examples/network/bearercloud/bearercloud.pro13
-rw-r--r--examples/network/bearercloud/cloud.cpp12
-rw-r--r--examples/network/bearercloud/cloud.h2
-rw-r--r--examples/network/bearermonitor/bearermonitor.pro12
-rw-r--r--examples/network/bearermonitor/sessionwidget.cpp15
-rw-r--r--src/network/bearer/bearer.pro19
-rw-r--r--src/network/bearer/qcorewlanengine_mac.mm121
-rw-r--r--src/network/bearer/qcorewlanengine_mac_p.h3
-rw-r--r--src/network/bearer/qgenericengine.cpp39
-rw-r--r--src/network/bearer/qgenericengine_p.h2
-rw-r--r--src/network/bearer/qnativewifiengine_win.cpp7
-rw-r--r--src/network/bearer/qnativewifiengine_win_p.h2
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp3
-rw-r--r--src/network/bearer/qnetworkconfigmanager_s60_p.h3
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp56
-rw-r--r--src/network/bearer/qnetworkconfiguration.h1
-rw-r--r--src/network/bearer/qnetworkconfiguration_maemo_p.h13
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h6
-rw-r--r--src/network/bearer/qnetworkconfiguration_s60_p.cpp16
-rw-r--r--src/network/bearer/qnetworkconfiguration_s60_p.h1
-rw-r--r--src/network/bearer/qnetworkmanagerservice_p.cpp44
-rw-r--r--src/network/bearer/qnetworksession.cpp146
-rw-r--r--src/network/bearer/qnetworksession.h3
-rw-r--r--src/network/bearer/qnetworksession_maemo.cpp47
-rw-r--r--src/network/bearer/qnetworksession_maemo_p.h6
-rw-r--r--src/network/bearer/qnetworksession_p.cpp32
-rw-r--r--src/network/bearer/qnetworksession_p.h4
-rw-r--r--src/network/bearer/qnetworksession_s60_p.cpp76
-rw-r--r--src/network/bearer/qnetworksession_s60_p.h3
-rw-r--r--src/network/bearer/qnetworksessionengine_p.h2
-rw-r--r--src/network/bearer/qnlaengine_win.cpp26
-rw-r--r--src/network/bearer/qnmwifiengine_unix.cpp473
-rw-r--r--src/network/bearer/qnmwifiengine_unix_p.h7
-rw-r--r--tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro3
-rw-r--r--tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp8
-rw-r--r--tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro3
-rw-r--r--tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp8
-rw-r--r--tests/auto/qnetworksession/lackey/lackey.pro3
-rw-r--r--tests/auto/qnetworksession/lackey/main.cpp2
-rw-r--r--tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp86
-rw-r--r--tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro3
-rw-r--r--tests/manual/bearerex/bearerex.cpp37
-rw-r--r--tests/manual/bearerex/bearerex.h3
-rw-r--r--tests/manual/bearerex/bearerex.pro11
-rw-r--r--tests/manual/networkmanager/networkmanager.pro3
-rw-r--r--tests/manual/networkmanager/nmview.cpp2
-rw-r--r--tests/manual/networkmanager/nmview.h2
49 files changed, 643 insertions, 746 deletions
diff --git a/config.tests/mac/corelwan/corewlan.pro b/config.tests/mac/corewlan/corewlan.pro
index 54a6c36..54a6c36 100644
--- a/config.tests/mac/corelwan/corewlan.pro
+++ b/config.tests/mac/corewlan/corewlan.pro
diff --git a/config.tests/mac/corelwan/corewlantest.mm b/config.tests/mac/corewlan/corewlantest.mm
index bcddf44..bcddf44 100644
--- a/config.tests/mac/corelwan/corewlantest.mm
+++ b/config.tests/mac/corewlan/corewlantest.mm
diff --git a/examples/network/bearercloud/bearercloud.pro b/examples/network/bearercloud/bearercloud.pro
index 308ddda..75e3049 100644
--- a/examples/network/bearercloud/bearercloud.pro
+++ b/examples/network/bearercloud/bearercloud.pro
@@ -15,16 +15,9 @@ INCLUDEPATH += ../../src/bearer
include(../examples.pri)
-qtAddLibrary(QtBearer)
+CONFIG += mobility
+MOBILITY = bearer
CONFIG += console
-include(../examples.pri)
-
-
-macx: {
- contains(QT_CONFIG,qt_framework):LIBS += -framework QtBearer
- INCLUDEPATH += ../../
- contains(CONFIG, debug) {
- }
-}
+symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
diff --git a/examples/network/bearercloud/cloud.cpp b/examples/network/bearercloud/cloud.cpp
index 4a1bde7..61bd88e 100644
--- a/examples/network/bearercloud/cloud.cpp
+++ b/examples/network/bearercloud/cloud.cpp
@@ -226,7 +226,7 @@ QVariant Cloud::itemChange(GraphicsItemChange change, const QVariant &value)
void Cloud::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
- if (session->isActive())
+ if (session->isOpen())
session->close();
else
session->open();
@@ -258,7 +258,7 @@ void Cloud::stateChanged(QNetworkSession::State state)
tooltip += tr("<br>Interface: %1").arg(interface.humanReadableName());
tooltip += tr("<br>Id: %1").arg(configuration.identifier());
- const QString bearerName = session->bearerName();
+ const QString bearerName = configuration.bearerName();
if (!bearerName.isEmpty())
tooltip += tr("<br>Bearer: %1").arg(bearerName);
@@ -289,10 +289,10 @@ void Cloud::stateChanged(QNetworkSession::State state)
s = s.arg(tr("Unknown"));
}
- if (session->isActive())
- s = s.arg(tr("Active"));
+ if (session->isOpen())
+ s = s.arg(tr("Open"));
else
- s = s.arg(tr("Inactive"));
+ s = s.arg(tr("Closed"));
tooltip += s;
@@ -307,7 +307,7 @@ void Cloud::stateChanged(QNetworkSession::State state)
//! [1]
void Cloud::newConfigurationActivated()
{
- const QString bearerName = session->bearerName();
+ const QString bearerName = configuration.bearerName();
if (!svgCache.contains(bearerName)) {
if (bearerName == QLatin1String("WLAN"))
svgCache.insert(bearerName, new QSvgRenderer(QLatin1String(":wlan.svg")));
diff --git a/examples/network/bearercloud/cloud.h b/examples/network/bearercloud/cloud.h
index 4ce43df..b542bf7 100644
--- a/examples/network/bearercloud/cloud.h
+++ b/examples/network/bearercloud/cloud.h
@@ -45,8 +45,10 @@
#include <QGraphicsItem>
QTM_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class QGraphicsTextItem;
class QGraphicsSvgItem;
+QT_END_NAMESPACE
class Cloud : public QObject, public QGraphicsItem
{
diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro
index c8fb3c2..acbee71 100644
--- a/examples/network/bearermonitor/bearermonitor.pro
+++ b/examples/network/bearermonitor/bearermonitor.pro
@@ -17,16 +17,12 @@ INCLUDEPATH += ../../src/bearer
include(../examples.pri)
-qtAddLibrary(QtBearer)
+CONFIG += mobility
+MOBILITY = bearer
+
win32:!wince*:LIBS += -lWs2_32
wince*:LIBS += -lWs2
CONFIG += console
-include(../examples.pri)
-
-macx: {
- contains(QT_CONFIG,qt_framework):LIBS += -framework QtBearer
- contains(CONFIG, debug) {
- }
-}
+symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp
index 7633dd7..0277d87 100644
--- a/examples/network/bearermonitor/sessionwidget.cpp
+++ b/examples/network/bearermonitor/sessionwidget.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "sessionwidget.h"
+#include "qnetworkconfigmanager.h"
SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent)
: QWidget(parent)
@@ -79,7 +80,13 @@ void SessionWidget::updateSession()
updateSessionState(session->state());
updateSessionError(session->error());
- bearer->setText(session->bearerName());
+ if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint)
+ bearer->setText(session->configuration().bearerName());
+ else {
+ QNetworkConfigurationManager mgr;
+ QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString());
+ bearer->setText(c.bearerName());
+ }
interfaceName->setText(session->interface().humanReadableName());
interfaceGuid->setText(session->interface().name());
@@ -140,10 +147,10 @@ void SessionWidget::updateSessionState(QNetworkSession::State state)
s = s.arg(tr("Unknown"));
}
- if (session->isActive())
- s = s.arg(tr("Active"));
+ if (session->isOpen())
+ s = s.arg(tr("Open"));
else
- s = s.arg(tr("Inactive"));
+ s = s.arg(tr("Closed"));
sessionState->setText(s);
}
diff --git a/src/network/bearer/bearer.pro b/src/network/bearer/bearer.pro
index 2255b7c..ce39db6 100644
--- a/src/network/bearer/bearer.pro
+++ b/src/network/bearer/bearer.pro
@@ -19,8 +19,7 @@ SOURCES += qnetworksession.cpp \
qnetworkconfiguration.cpp
symbian: {
- exists($${EPOCROOT}epoc32/release/winscw/udeb/cmmanager.lib)| \
- exists($${EPOCROOT}epoc32/release/armv5/lib/cmmanager.lib) {
+ contains(snap_enabled, yes) {
message("Building with SNAP support")
DEFINES += SNAP_FUNCTIONALITY_AVAILABLE=1
LIBS += -lcmmanager
@@ -48,21 +47,21 @@ symbian: {
-lefsrv \
-lnetmeta
+ TARGET.CAPABILITY = ALL -TCB
+ TARGET.UID3 = 0x2002AC81
+
deploy.path = $${EPOCROOT}
exportheaders.sources = $$PUBLIC_HEADERS
exportheaders.path = epoc32/include
-
for(header, exportheaders.sources) {
BLD_INF_RULES.prj_exports += "$$header $$deploy.path$$exportheaders.path/$$basename(header)"
}
-
- bearer_deployment.sources = QtBearer.dll
- bearer_deployment.path = /sys/bin
- DEPLOYMENT += bearer_deployment
-
- TARGET.CAPABILITY = All -TCB
+
+ QtBearerManagement.sources = QtBearer.dll
+ QtBearerManagement.path = /sys/bin
+ DEPLOYMENT += QtBearerManagement
} else {
- maemo {
+ maemo6 {
QT += dbus
CONFIG += link_pkgconfig
diff --git a/src/network/bearer/qcorewlanengine_mac.mm b/src/network/bearer/qcorewlanengine_mac.mm
index 5451615..41ec79a 100644
--- a/src/network/bearer/qcorewlanengine_mac.mm
+++ b/src/network/bearer/qcorewlanengine_mac.mm
@@ -102,7 +102,7 @@ inline QStringList nsarrayToQStringList(void *nsarray)
static QString qGetInterfaceType(const QString &interfaceString)
{
- return networkInterfaces.value(interfaceString);
+ return networkInterfaces.value(interfaceString, QLatin1String("Unknown"));
}
QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
@@ -115,66 +115,52 @@ QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
QCoreWlanEngine::~QCoreWlanEngine()
{
-}
-
-QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::getWifiConfigurations()
-{
- QMapIterator<QString, QString> i(networkInterfaces);
- while (i.hasNext()) {
- i.next();
- QString interfaceName = i.key();
- if (i.value() == "WLAN") {
- if(!isWifiReady(interfaceName)) {
- qWarning() << "wifi not powered on";
- return QList<QNetworkConfigurationPrivate *>();
- } else {
- // QList<QNetworkConfigurationPrivate *> profs = getWlanProfiles(interfaceName);
- scanForSsids(interfaceName);
- }
- } else {
-
- }
+ QNetworkConfigurationPrivate* cpPriv = 0;
+ foundConfigurations.clear();
+ while(!foundConfigurations.isEmpty()) {
+ cpPriv = foundConfigurations.takeFirst();
+ delete cpPriv;
}
- return QList<QNetworkConfigurationPrivate *> ();
}
QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::getConfigurations(bool *ok)
{
if (ok)
*ok = true;
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
- QList<QNetworkConfigurationPrivate *> wificonfigs = getWifiConfigurations();
+ foundConfigurations.clear();
uint identifier;
QMapIterator<QString, QString> i(networkInterfaces);
+ QNetworkConfigurationPrivate* cpPriv = 0;
while (i.hasNext()) {
i.next();
if (i.value() == "WLAN") {
QList<QNetworkConfigurationPrivate *> fetchedConfigurations = scanForSsids(i.key());
for (int i = 0; i < fetchedConfigurations.count(); ++i) {
- QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate;
- config->name = fetchedConfigurations.at(i)->name;
- config->isValid = fetchedConfigurations.at(i)->isValid;
- config->id = fetchedConfigurations.at(i)->id;
+ QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate();
+ cpPriv = fetchedConfigurations.at(i);
+ config->name = cpPriv->name;
+ config->isValid = cpPriv->isValid;
+ config->id = cpPriv->id;
- config->state = fetchedConfigurations.at(i)->state;
- config->type = fetchedConfigurations.at(i)->type;
- config->roamingSupported = fetchedConfigurations.at(i)->roamingSupported;
- config->purpose = fetchedConfigurations.at(i)->purpose;
- config->internet = fetchedConfigurations.at(i)->internet;
- config->serviceInterface = fetchedConfigurations.at(i)->serviceInterface;
+ config->state = cpPriv->state;
+ config->type = cpPriv->type;
+ config->roamingSupported = cpPriv->roamingSupported;
+ config->purpose = cpPriv->purpose;
+ config->internet = cpPriv->internet;
+ config->serviceInterface = cpPriv->serviceInterface;
+ config->bearer = cpPriv->bearer;
identifier = config->name.toUInt();
configurationInterface[identifier] = config->serviceInterface.name();
foundConfigurations.append(config);
+ delete cpPriv;
}
}
QNetworkInterface interface = QNetworkInterface::interfaceFromName(i.key());
- QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
+ QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate();
const QString humanReadableName = interface.humanReadableName();
cpPriv->name = humanReadableName.isEmpty() ? interface.name() : humanReadableName;
cpPriv->isValid = true;
@@ -197,9 +183,10 @@ QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::getConfigurations(bool *o
cpPriv->internet = true;
}
configurationInterface[identifier] = interface.name();
+ cpPriv->bearer = interface.name().isEmpty()? QLatin1String("Unknown") : qGetInterfaceType(interface.name());
foundConfigurations.append(cpPriv);
}
- [autoreleasepool release];
+
pollTimer.start();
return foundConfigurations;
}
@@ -214,16 +201,6 @@ bool QCoreWlanEngine::hasIdentifier(const QString &id)
return configurationInterface.contains(id.toUInt());
}
-QString QCoreWlanEngine::bearerName(const QString &id)
-{
- QString interface = getInterfaceFromId(id);
-
- if (interface.isEmpty())
- return QString();
-
- return qGetInterfaceType(interface);
-}
-
void QCoreWlanEngine::connectToId(const QString &id)
{
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
@@ -239,14 +216,22 @@ void QCoreWlanEngine::connectToId(const QString &id)
NSEnumerator *enumerator = [remNets objectEnumerator];
CWWirelessProfile *wProfile;
NSUInteger index=0;
+ CWNetwork *apNetwork;
+ NSDictionary *parametersDict;
+ NSArray* apArray;
+
+ CW8021XProfile *user8021XProfile;
+ NSError *err;
+ NSMutableDictionary *params;
+
while ((wProfile = [enumerator nextObject])) { //CWWirelessProfile
if(id == nsstringToQString([wProfile ssid])) {
- CW8021XProfile *user8021XProfile = nil;
+ user8021XProfile = nil;
user8021XProfile = [ wProfile user8021XProfile];
- NSError *err = nil;
- NSMutableDictionary *params = [NSMutableDictionary dictionaryWithCapacity:0];
+ err = nil;
+ params = [NSMutableDictionary dictionaryWithCapacity:0];
if(user8021XProfile) {
[params setValue: user8021XProfile forKey:kCWAssocKey8021XProfile];
@@ -254,17 +239,22 @@ void QCoreWlanEngine::connectToId(const QString &id)
[params setValue: [wProfile passphrase] forKey: kCWAssocKeyPassphrase];
}
- NSDictionary *parametersDict = nil;
- NSArray* apArray = [NSMutableArray arrayWithArray:[wifiInterface scanForNetworksWithParameters:parametersDict error:&err]];
+ parametersDict = nil;
+ apArray = [NSMutableArray arrayWithArray:[wifiInterface scanForNetworksWithParameters:parametersDict error:&err]];
+
if(!err) {
+
for(uint row=0; row < [apArray count]; row++ ) {
- CWNetwork *apNetwork = [apArray objectAtIndex:row];
+ apNetwork = [apArray objectAtIndex:row];
if([[apNetwork ssid] compare:[wProfile ssid]] == NSOrderedSame) {
+
bool result = [wifiInterface associateToNetwork: apNetwork parameters:[NSDictionary dictionaryWithDictionary:params] error:&err];
+
if(!result) {
qWarning() <<"ERROR"<< nsstringToQString([err localizedDescription ]);
emit connectionError(id, ConnectError);
} else {
+ [apNetwork release];
[autoreleasepool release];
return;
}
@@ -274,6 +264,8 @@ void QCoreWlanEngine::connectToId(const QString &id)
}
index++;
}
+ [apNetwork release];
+
emit connectionError(id, InterfaceLookupError);
#endif
} else {
@@ -325,24 +317,21 @@ QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::scanForSsids(const QStrin
NSDictionary *parametersDict = nil;
NSArray* apArray = [NSMutableArray arrayWithArray:[currentInterface scanForNetworksWithParameters:parametersDict error:&err]];
+ CWNetwork *apNetwork;
if(!err) {
for(uint row=0; row < [apArray count]; row++ ) {
- CWNetwork *apNetwork = [apArray objectAtIndex:row];
+ NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init];
+
+ apNetwork = [apArray objectAtIndex:row];
QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
QString networkSsid = nsstringToQString([apNetwork ssid]);
cpPriv->name = networkSsid;
cpPriv->isValid = true;
cpPriv->id = networkSsid;
cpPriv->internet = true;
+ cpPriv->bearer = QLatin1String("WLAN");
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
- cpPriv->serviceInterface = QNetworkInterface::interfaceFromName(nsstringToQString([[CWInterface interface] name]));
-
- CWWirelessProfile *networkProfile = apNetwork.wirelessProfile;
- CW8021XProfile *userNetworkProfile = networkProfile.user8021XProfile;
- if(!userNetworkProfile) {
- } else {
- qWarning() <<"Has profile!" ;
- }
+ cpPriv->serviceInterface = QNetworkInterface::interfaceFromName(interfaceName);
if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
QString interfaceSsidString = nsstringToQString( [currentInterface ssid]);
@@ -364,12 +353,14 @@ QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::scanForSsids(const QStrin
else
cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
foundConfigs.append(cpPriv);
+ [looppool release];
}
} else {
qWarning() << "ERROR scanning for ssids" << nsstringToQString([err localizedDescription])
<<nsstringToQString([err domain]);
}
- [autoreleasepool release];
+
+ [autoreleasepool drain];
#else
Q_UNUSED(interfaceName);
#endif
@@ -428,6 +419,7 @@ bool QCoreWlanEngine::getAllScInterfaces()
CFIndex interfaceIndex;
interfaceCount = CFArrayGetCount(interfaces);
for (interfaceIndex = 0; interfaceIndex < interfaceCount; interfaceIndex++) {
+ NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init];
CFStringRef bsdName;
CFTypeRef thisInterface = CFArrayGetValueAtIndex(interfaces, interfaceIndex);
@@ -447,11 +439,12 @@ bool QCoreWlanEngine::getAllScInterfaces()
if(!networkInterfaces.contains(interfaceName) && !typeStr.isEmpty()) {
networkInterfaces.insert(interfaceName,typeStr);
}
+ [looppool release];
}
}
CFRelease(interfaces);
- [autoreleasepool release];
+ [autoreleasepool drain];
return true;
}
diff --git a/src/network/bearer/qcorewlanengine_mac_p.h b/src/network/bearer/qcorewlanengine_mac_p.h
index fc8e4b5..6ad093a 100644
--- a/src/network/bearer/qcorewlanengine_mac_p.h
+++ b/src/network/bearer/qcorewlanengine_mac_p.h
@@ -90,8 +90,9 @@ private:
QList<QNetworkConfigurationPrivate *> getWlanProfiles(const QString &interfaceName);
- QList<QNetworkConfigurationPrivate *> getWifiConfigurations();
bool isKnownSsid(const QString &interfaceName, const QString &ssid);
+ QList<QNetworkConfigurationPrivate *> foundConfigurations;
+
};
QTM_END_NAMESPACE
diff --git a/src/network/bearer/qgenericengine.cpp b/src/network/bearer/qgenericengine.cpp
index 184a69c..10cea0c 100644
--- a/src/network/bearer/qgenericengine.cpp
+++ b/src/network/bearer/qgenericengine.cpp
@@ -53,6 +53,13 @@
#include "qnetworksessionengine_win_p.h"
#endif
+#ifdef Q_OS_LINUX
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#endif
+
QTM_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QGenericEngine, genericEngine)
@@ -69,7 +76,7 @@ static QString qGetInterfaceType(const QString &interface)
HANDLE handle = CreateFile((TCHAR *)QString("\\\\.\\%1").arg(interface).utf16(), 0,
FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (handle == INVALID_HANDLE_VALUE)
- return QString();
+ return QLatin1String("Unknown");
oid = OID_GEN_MEDIA_SUPPORTED;
bytesWritten = 0;
@@ -77,7 +84,7 @@ static QString qGetInterfaceType(const QString &interface)
&medium, sizeof(medium), &bytesWritten, 0);
if (!result) {
CloseHandle(handle);
- return QString();
+ return QLatin1String("Unknown");
}
oid = OID_GEN_PHYSICAL_MEDIUM;
@@ -90,7 +97,7 @@ static QString qGetInterfaceType(const QString &interface)
if (medium == NdisMedium802_3)
return QLatin1String("Ethernet");
else
- return QString();
+ return QLatin1String("Unknown");
}
CloseHandle(handle);
@@ -114,11 +121,24 @@ static QString qGetInterfaceType(const QString &interface)
#ifdef BEARER_MANAGEMENT_DEBUG
qDebug() << medium << physicalMedium;
#endif
+#elif defined(Q_OS_LINUX)
+ int sock = socket(AF_INET, SOCK_DGRAM, 0);
+
+ ifreq request;
+ strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name));
+ if (ioctl(sock, SIOCGIFHWADDR, &request) >= 0) {
+ switch (request.ifr_hwaddr.sa_family) {
+ case ARPHRD_ETHER:
+ return QLatin1String("Ethernet");
+ }
+ }
+
+ close(sock);
#else
Q_UNUSED(interface);
#endif
- return QString();
+ return QLatin1String("Unknown");
}
QGenericEngine::QGenericEngine(QObject *parent)
@@ -176,6 +196,11 @@ QList<QNetworkConfigurationPrivate *> QGenericEngine::getConfigurations(bool *ok
cpPriv->id = QString::number(identifier);
cpPriv->state = QNetworkConfiguration::Discovered;
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
+ if (interface.name().isEmpty())
+ cpPriv->bearer = QLatin1String("Unknown");
+ else
+ cpPriv->bearer = qGetInterfaceType(interface.name());
+
if (interface.flags() & QNetworkInterface::IsUp)
cpPriv->state |= QNetworkConfiguration::Active;
@@ -199,15 +224,15 @@ bool QGenericEngine::hasIdentifier(const QString &id)
return configurationInterface.contains(id.toUInt());
}
-QString QGenericEngine::bearerName(const QString &id)
+/*QString QGenericEngine::bearerName(const QString &id)
{
QString interface = getInterfaceFromId(id);
if (interface.isEmpty())
- return QString();
+ return QLatin1String("Unknown");
return qGetInterfaceType(interface);
-}
+}*/
void QGenericEngine::connectToId(const QString &id)
{
diff --git a/src/network/bearer/qgenericengine_p.h b/src/network/bearer/qgenericengine_p.h
index 976776e..5c08aa2 100644
--- a/src/network/bearer/qgenericengine_p.h
+++ b/src/network/bearer/qgenericengine_p.h
@@ -74,7 +74,7 @@ public:
QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
- QString bearerName(const QString &id);
+ //QString bearerName(const QString &id);
void connectToId(const QString &id);
void disconnectFromId(const QString &id);
diff --git a/src/network/bearer/qnativewifiengine_win.cpp b/src/network/bearer/qnativewifiengine_win.cpp
index d8fe5fb..008a9cf 100644
--- a/src/network/bearer/qnativewifiengine_win.cpp
+++ b/src/network/bearer/qnativewifiengine_win.cpp
@@ -479,6 +479,8 @@ QList<QNetworkConfigurationPrivate *> QNativeWifiEngine::getConfigurations(bool
}
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
+ cpPriv->bearer = QLatin1String("WLAN");
+
foundConfigurations.append(cpPriv);
}
@@ -537,6 +539,7 @@ QString QNativeWifiEngine::getInterfaceFromId(const QString &id)
}
local_WlanFreeMemory(connectionAttributes);
+ local_WlanFreeMemory(interfaceList);
}
return QString();
@@ -591,10 +594,10 @@ bool QNativeWifiEngine::hasIdentifier(const QString &id)
return false;
}
-QString QNativeWifiEngine::bearerName(const QString &)
+/*QString QNativeWifiEngine::bearerName(const QString &)
{
return QLatin1String("WLAN");
-}
+}*/
void QNativeWifiEngine::connectToId(const QString &id)
{
diff --git a/src/network/bearer/qnativewifiengine_win_p.h b/src/network/bearer/qnativewifiengine_win_p.h
index 0d5bcb0..e911746 100644
--- a/src/network/bearer/qnativewifiengine_win_p.h
+++ b/src/network/bearer/qnativewifiengine_win_p.h
@@ -73,7 +73,7 @@ public:
QString getInterfaceFromId(const QString &id);
bool hasIdentifier(const QString &id);
- QString bearerName(const QString &id);
+ //QString bearerName(const QString &id);
void connectToId(const QString &id);
void disconnectFromId(const QString &id);
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index 8b15f41..39426d0 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -78,6 +78,7 @@ void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurati
ptr.data()->roamingSupported = cpPriv->roamingSupported;
ptr.data()->purpose = cpPriv->purpose;
ptr.data()->internet = cpPriv->internet;
+ ptr.data()->bearer = cpPriv->bearer;
accessPointConfigurations.insert(cpPriv->id, ptr);
configurationEngine.insert(cpPriv->id, engine);
@@ -135,6 +136,7 @@ void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigura
ptr.data()->type != cpPriv->type ||
ptr.data()->roamingSupported != cpPriv->roamingSupported ||
ptr.data()->purpose != cpPriv->purpose ||
+ ptr.data()->bearer != cpPriv->bearer ||
ptr.data()->internet != cpPriv->internet) {
const QNetworkConfiguration::StateFlags oldState = ptr.data()->state;
@@ -147,6 +149,7 @@ void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigura
ptr.data()->roamingSupported = cpPriv->roamingSupported;
ptr.data()->purpose = cpPriv->purpose;
ptr.data()->internet = cpPriv->internet;
+ ptr.data()->bearer = cpPriv->bearer;
if (!firstUpdate) {
QNetworkConfiguration item;
diff --git a/src/network/bearer/qnetworkconfigmanager_s60_p.h b/src/network/bearer/qnetworkconfigmanager_s60_p.h
index 296d67f..679fa6c 100644
--- a/src/network/bearer/qnetworkconfigmanager_s60_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_s60_p.h
@@ -63,7 +63,10 @@
#endif
class CCommsDatabase;
+
+QT_BEGIN_NAMESPACE
class QTimer;
+QT_END_NAMESPACE
QTM_BEGIN_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp
index c92b356..56907c3 100644
--- a/src/network/bearer/qnetworkconfiguration.cpp
+++ b/src/network/bearer/qnetworkconfiguration.cpp
@@ -164,9 +164,9 @@ QTM_BEGIN_NAMESPACE
QNetworkConfiguration::Defined. If the configuration is a service network
this flag is set if at least one of the underlying access points
configurations has the Discovered state.
- \value Active The configuration is currently used by an open/active network session
- (see \l QNetworkSession::isActive()). However this does not mean that the
- current process is the entity that created the active session. It merely
+ \value Active The configuration is currently used by an open network session
+ (see \l QNetworkSession::isOpen()). However this does not mean that the
+ current process is the entity that created the open session. It merely
indicates that if a new QNetworkSession were to be constructed based on
this configuration \l QNetworkSession::state() would return
\l QNetworkSession::Connected. This state implies the
@@ -344,6 +344,56 @@ QList<QNetworkConfiguration> QNetworkConfiguration::children() const
return results;
}
+/*!
+ 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:
+
+ \table
+ \header
+ \o Value
+ \o Description
+ \row
+ \o Unknown
+ \o The session is based on an unknown or unspecified bearer type.
+ \row
+ \o Ethernet
+ \o The session is based on Ethernet.
+ \row
+ \o WLAN
+ \o The session is based on Wireless LAN.
+ \row
+ \o 2G
+ \o The session uses CSD, GPRS, HSCSD, EDGE or cdmaOne.
+ \row
+ \o CDMA2000
+ \o The session uses CDMA.
+ \row
+ \o WCDMA
+ \o The session uses W-CDMA/UMTS.
+ \row
+ \o HSPA
+ \o The session uses High Speed Packet Access.
+ \row
+ \o Bluetooth
+ \o The session uses Bluetooth.
+ \row
+ \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.
+*/
+QString QNetworkConfiguration::bearerName() const
+{
+ if (!isValid())
+ return QString();
+
+ return d->bearerName();
+}
+
QTM_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index f8c17d5..860be4b 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -91,6 +91,7 @@ public:
StateFlags state() const;
Type type() const;
Purpose purpose() const;
+ QString bearerName() const;
QString identifier() const;
bool isRoamingAvailable() const;
QList<QNetworkConfiguration> children() const;
diff --git a/src/network/bearer/qnetworkconfiguration_maemo_p.h b/src/network/bearer/qnetworkconfiguration_maemo_p.h
index 8d786aa..2597605 100644
--- a/src/network/bearer/qnetworkconfiguration_maemo_p.h
+++ b/src/network/bearer/qnetworkconfiguration_maemo_p.h
@@ -89,6 +89,19 @@ public:
/* In Maemo the id field (defined above) is the IAP id (which typically is UUID) */
QByteArray network_id; /* typically WLAN ssid or similar */
QString iap_type; /* is this one WLAN or GPRS */
+ QString bearerName() const
+ {
+ if (iap_type == "WLAN_INFRA" ||
+ iap_type == "WLAN_ADHOC")
+ return QString("WLAN");
+ else if (iap_type == "GPRS")
+ return QString("HSPA");
+
+ //return whatever it is
+ //this may have to be split up later on
+ return iap_type;
+ }
+
uint32_t network_attrs; /* network attributes for this IAP, this is the value returned by icd and passed to it when connecting */
QString service_type;
diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h
index a3bcd9a..c2834e6 100644
--- a/src/network/bearer/qnetworkconfiguration_p.h
+++ b/src/network/bearer/qnetworkconfiguration_p.h
@@ -78,6 +78,12 @@ public:
}
QString name;
+ QString bearer;
+ inline QString bearerName() const
+ {
+ return bearer;
+ }
+
bool isValid;
QString id;
QNetworkConfiguration::StateFlags state;
diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.cpp b/src/network/bearer/qnetworkconfiguration_s60_p.cpp
index 61548ba..02115d9 100644
--- a/src/network/bearer/qnetworkconfiguration_s60_p.cpp
+++ b/src/network/bearer/qnetworkconfiguration_s60_p.cpp
@@ -57,4 +57,20 @@ QNetworkConfigurationPrivate::~QNetworkConfigurationPrivate()
serviceNetworkMembers.clear();
}
+QString QNetworkConfigurationPrivate::bearerName() const
+{
+ switch (bearer) {
+ case QNetworkConfigurationPrivate::BearerEthernet: return QLatin1String("Ethernet");
+ case QNetworkConfigurationPrivate::BearerWLAN: return QLatin1String("WLAN");
+ case QNetworkConfigurationPrivate::Bearer2G: return QLatin1String("2G");
+ case QNetworkConfigurationPrivate::BearerCDMA2000: return QLatin1String("CDMA2000");
+ case QNetworkConfigurationPrivate::BearerWCDMA: return QLatin1String("WCDMA");
+ case QNetworkConfigurationPrivate::BearerHSPA: return QLatin1String("HSPA");
+ case QNetworkConfigurationPrivate::BearerBluetooth: return QLatin1String("Bluetooth");
+ case QNetworkConfigurationPrivate::BearerWiMAX: return QLatin1String("WiMAX");
+ default: return QLatin1String("Unknown");
+ }
+}
+
+
QTM_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.h b/src/network/bearer/qnetworkconfiguration_s60_p.h
index 44f8f56..6c87200 100644
--- a/src/network/bearer/qnetworkconfiguration_s60_p.h
+++ b/src/network/bearer/qnetworkconfiguration_s60_p.h
@@ -87,6 +87,7 @@ public:
QList<QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > serviceNetworkMembers;
QNetworkConfigurationPrivate::Bearer bearer;
+ QString bearerName() const;
TUint32 numericId;
TUint connectionId;
diff --git a/src/network/bearer/qnetworkmanagerservice_p.cpp b/src/network/bearer/qnetworkmanagerservice_p.cpp
index 2f91af0..5804686 100644
--- a/src/network/bearer/qnetworkmanagerservice_p.cpp
+++ b/src/network/bearer/qnetworkmanagerservice_p.cpp
@@ -70,7 +70,7 @@ public:
};
QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
- : QObject(parent)
+ : QObject(parent), nmDBusHelper(0)
{
d = new QNetworkManagerInterfacePrivate();
d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
@@ -93,6 +93,8 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
QNetworkManagerInterface::~QNetworkManagerInterface()
{
+ if (nmDBusHelper)
+ delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -195,7 +197,7 @@ public:
};
QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent)
- : QObject(parent)
+ : QObject(parent), nmDBusHelper(0)
{
d = new QNetworkManagerInterfaceAccessPointPrivate();
d->path = dbusPathName;
@@ -214,6 +216,8 @@ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const Q
QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint()
{
+ if (nmDBusHelper)
+ delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -229,6 +233,9 @@ bool QNetworkManagerInterfaceAccessPoint::setConnections()
return false;
bool allOk = false;
+ if (nmDBusHelper)
+ delete nmDBusHelper;
+ nmDBusHelper = 0;
nmDBusHelper = new QNmDBusHelper;
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
@@ -304,7 +311,7 @@ public:
};
QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent)
- : QObject(parent)
+ : QObject(parent), nmDBusHelper(0)
{
d = new QNetworkManagerInterfaceDevicePrivate();
d->path = deviceObjectPath;
@@ -322,6 +329,8 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de
QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice()
{
+ if (nmDBusHelper)
+ delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -337,6 +346,9 @@ bool QNetworkManagerInterfaceDevice::setConnections()
return false;
bool allOk = false;
+ if (nmDBusHelper)
+ delete nmDBusHelper;
+ nmDBusHelper = 0;
nmDBusHelper = new QNmDBusHelper;
connect(nmDBusHelper,SIGNAL(pathForStateChanged(const QString &, quint32)),
this, SIGNAL(stateChanged(const QString&, quint32)));
@@ -396,6 +408,7 @@ public:
};
QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent)
+ : QObject(parent), nmDBusHelper(0)
{
d = new QNetworkManagerInterfaceDeviceWiredPrivate();
d->path = ifaceDevicePath;
@@ -413,6 +426,8 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q
QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired()
{
+ if (nmDBusHelper)
+ delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -430,6 +445,9 @@ bool QNetworkManagerInterfaceDeviceWired::setConnections()
bool allOk = false;
+ if (nmDBusHelper)
+ delete nmDBusHelper;
+ nmDBusHelper = 0;
nmDBusHelper = new QNmDBusHelper;
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
@@ -473,6 +491,7 @@ public:
};
QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent)
+ : QObject(parent), nmDBusHelper(0)
{
d = new QNetworkManagerInterfaceDeviceWirelessPrivate();
d->path = ifaceDevicePath;
@@ -490,6 +509,8 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c
QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless()
{
+ if (nmDBusHelper)
+ delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -505,6 +526,9 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
return false;
bool allOk = false;
+ if (nmDBusHelper)
+ delete nmDBusHelper;
+ nmDBusHelper = 0;
nmDBusHelper = new QNmDBusHelper;
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
@@ -592,7 +616,6 @@ public:
QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService, QObject *parent)
: QObject(parent)
{
-// qWarning() << __PRETTY_FUNCTION__;
d = new QNetworkManagerSettingsPrivate();
d->path = settingsService;
d->connectionInterface = new QDBusInterface(settingsService,
@@ -655,6 +678,7 @@ public:
};
QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent)
+ : QObject(parent), nmDBusHelper(0)
{
qDBusRegisterMetaType<QNmSettingsMap>();
d = new QNetworkManagerSettingsConnectionPrivate();
@@ -676,6 +700,8 @@ QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QStri
QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection()
{
+ if (nmDBusHelper)
+ delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -697,6 +723,9 @@ bool QNetworkManagerSettingsConnection::setConnections()
allOk = true;
}
+ if (nmDBusHelper)
+ delete nmDBusHelper;
+ nmDBusHelper = 0;
nmDBusHelper = new QNmDBusHelper;
connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(const QString &)),
this,SIGNAL(removed( const QString &)));
@@ -880,6 +909,7 @@ public:
};
QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString &activeConnectionObjectPath, QObject *parent)
+ : QObject(parent), nmDBusHelper(0)
{
d = new QNetworkManagerConnectionActivePrivate();
d->path = activeConnectionObjectPath;
@@ -897,6 +927,8 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString
QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive()
{
+ if (nmDBusHelper)
+ delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -912,6 +944,9 @@ bool QNetworkManagerConnectionActive::setConnections()
return false;
bool allOk = false;
+ if (nmDBusHelper)
+ delete nmDBusHelper;
+ nmDBusHelper = 0;
nmDBusHelper = new QNmDBusHelper;
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
@@ -975,6 +1010,7 @@ public:
};
QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectPath, QObject *parent)
+ : QObject(parent)
{
d = new QNetworkManagerIp4ConfigPrivate();
d->path = deviceObjectPath;
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index d3a323a..6171350 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -46,7 +46,7 @@
#ifdef Q_OS_SYMBIAN
#include "qnetworksession_s60_p.h"
-#elif MAEMO
+#elif Q_WS_MAEMO_6
#include "qnetworksession_maemo_p.h"
#else
#include "qnetworksession_p.h"
@@ -72,34 +72,41 @@ QTM_BEGIN_NAMESPACE
QNetworkSession supports session management within the same process and depending on the platform's
capabilities may support out-of-process sessions. If the same
- network configuration is used by multiple active sessions the underlying network interface is only terminated once
+ network configuration is used by multiple open sessions the underlying network interface is only terminated once
the last session has been closed.
\section1 Roaming
Applications may connect to the preferredConfigurationChanged() signal in order to
receive notifications when a more suitable access point becomes available.
- In response to this signal the application may initiate the roaming via migrate()
- or may ignore() the new access point. Once the session has roamed the
+ In response to this signal the application must either initiate the roaming via migrate()
+ or ignore() the new access point. Once the session has roamed the
newConfigurationActivated() signal is emitted. The application may now test the
- carrier and can accept() or reject() it. The session will return to the previous
- access point if the roaming was rejected.
+ carrier and must either accept() or reject() it. The session will return to the previous
+ access point if the roaming was rejected. The subsequent state diagram depicts the required
+ state transitions.
+
+ \image roaming-states.png
- Some platforms may support the notion of forced roaming and application level roaming (ALR).
+ Some platforms may distinguish forced roaming and application level roaming (ALR).
ALR implies that the application controls (via migrate(), ignore(), accept() and reject())
- whether a network session can roam from one network configuration to the next. Such control is useful
+ whether a network session can roam from one access point to the next. Such control is useful
if the application maintains stateful socket connections and wants to control the transition from
- one interface to the next.
-
- Forced roaming implies that the system automatically roams to the next network without
+ one interface to the next. Forced roaming implies that the system automatically roams to the next network without
consulting the application. This has the advantage that the application can make use of roaming features
without actually being aware of it. It is expected that the application detects that the underlying
socket is broken and automatically reconnects via the new network link.
- If the platform supports both modes of roaming an application indicates its preference
+ If the platform supports both modes of roaming, an application indicates its preference
by connecting to the preferredConfigurationChanged() signal. Connecting to this signal means that
the application wants to take control over the roaming behavior and therefore implies application
- level roaming.
+ level roaming. If the client does not connect to the preferredConfigurationChanged(), forced roaming
+ is used. If forced roaming is not supported the network session will not roam by default.
+
+ Some applications may want to suppress any form of roaming altogether. Possible use cases may be
+ high priority downloads or remote services which cannot handle a roaming enabled client. Clients
+ can suppress roaming by connecting to the preferredConfigurationChanged() signal and answer each
+ signal emission with ignore().
\sa QNetworkConfiguration, QNetworkConfigurationManager
*/
@@ -119,7 +126,7 @@ QTM_BEGIN_NAMESPACE
\value Connecting The network session is being established.
\value Connected The network session is connected. If the current process wishes to use this session
it has to register its interest by calling open(). A network session
- is considered to be ready for socket operations if it isActive() and connected.
+ is considered to be ready for socket operations if it isOpen() and connected.
\value Closing The network session is in the process of being shut down.
\value Disconnected The network session is not connected. The associated QNetworkConfiguration
has the state QNetworkConfiguration::Discovered.
@@ -167,9 +174,8 @@ QTM_BEGIN_NAMESPACE
details such as proxy settings and \a isSeamless indicates whether roaming will
break the sessions IP address.
- As a consequence to this signal the application may start the roaming process
- by calling migrate() or may chose to ignore() the new access point. If the application
- doesn't call either of the two functions the session ignores the migration opportunity.
+ As a consequence to this signal the application must either start the roaming process
+ by calling migrate() or choose to ignore() the new access point.
If the roaming process is non-seamless the IP address will change which means that
a socket becomes invalid. However seamless mobility can ensure that the local IP address
@@ -194,7 +200,7 @@ QTM_BEGIN_NAMESPACE
This signal is emitted once the session has roamed to the new access point.
The application may reopen its socket and test the suitability of the new network link.
- Subsequently it may accept() or reject() the new access point.
+ Subsequently it must either accept() or reject() the new access point.
\sa accept(), reject()
*/
@@ -239,13 +245,13 @@ QNetworkSession::~QNetworkSession()
}
/*!
- Creates an active/open session which increases the session counter on the underlying network interface.
+ Creates an open session which increases the session counter on the underlying network interface.
The system will not terminate a network interface until the session reference counter reaches zero.
- Therefore an active session allows an application to register its use of the interface.
+ Therefore an open session allows an application to register its use of the interface.
- The interface is started if it is not active yet. Some platforms may not provide support
- for out-of-process sessions. On such platforms the session counter ignores any sessions
- held by another process. The platform capabilities can be
+ As a result of calling open() the interface will be started if it is not connected/up yet.
+ Some platforms may not provide support for out-of-process sessions. On such platforms the session
+ counter ignores any sessions held by another process. The platform capabilities can be
detected via QNetworkConfigurationManager::capabilities().
Note that this call is asynchronous. Depending on the outcome of this call the results can be enquired
@@ -253,7 +259,7 @@ QNetworkSession::~QNetworkSession()
It is not a requirement to open a session in order to monitor the underlying network interface.
- \sa close(), stop(), isActive()
+ \sa close(), stop(), isOpen()
*/
void QNetworkSession::open()
{
@@ -279,7 +285,7 @@ void QNetworkSession::open()
*/
bool QNetworkSession::waitForOpened(int msecs)
{
- if (d->isActive)
+ if (d->isOpen)
return true;
if (d->state != Connecting)
@@ -297,13 +303,13 @@ bool QNetworkSession::waitForOpened(int msecs)
loop->disconnect();
loop->deleteLater();
- return d->isActive;
+ return d->isOpen;
}
/*!
Decreases the session counter on the associated network configuration. If the session counter reaches zero
the active network interface is shut down. This also means that state() will only change from \l Connected to
- \l Disconnected if this was the last active session.
+ \l Disconnected if the current session was the last open session.
If the platform does not support out-of-process sessions calling this function does not stop the
interface. In this case \l{stop()} has to be used to force a shut down.
@@ -312,7 +318,7 @@ bool QNetworkSession::waitForOpened(int msecs)
Note that this call is asynchronous. Depending on the outcome of this call the results can be enquired
by connecting to the stateChanged(), opened() or error() signals.
- \sa open(), stop(), isActive()
+ \sa open(), stop(), isOpen()
*/
void QNetworkSession::close()
{
@@ -320,7 +326,7 @@ void QNetworkSession::close()
}
/*!
- Invalidates all active sessions against the network interface and therefore stops the
+ Invalidates all open sessions against the network interface and therefore stops the
underlying network interface. This function always changes the session's state() flag to
\l Disconnected.
@@ -341,15 +347,19 @@ QNetworkConfiguration QNetworkSession::configuration() const
return d->publicConfig;
}
-/*!
- Returns the type of bearer currently used by this session. The string is not translated and therefore can
- not be shown to the user. The subsequent table presents the currently known bearer types:
+/*
+ Returns the type of bearer currently used by this session. The string is not translated and
+ therefore can not be shown to the user. The subsequent table presents the currently known
+ bearer types:
\table
\header
\o Value
\o Description
\row
+ \o Unknown
+ \o The session is based on an unknown or unspecified bearer type.
+ \row
\o Ethernet
\o The session is based on Ethernet.
\row
@@ -380,12 +390,14 @@ QNetworkConfiguration QNetworkSession::configuration() const
active configuration is returned. Therefore the bearer type may change
over time.
- This function returns an empty string if this session is based on an invalid configuration.
+ This function returns an empty string if this session is based on an invalid configuration, or
+ a network configuration of type \l QNetworkConfiguration::ServiceNetwork with no
+ \l {QNetworkConfiguration::children()}{children}.
*/
-QString QNetworkSession::bearerName() const
+/*QString QNetworkSession::bearerName() const
{
return d->bearerName();
-}
+}*/
/*!
Returns the network interface that is used by this session.
@@ -402,25 +414,29 @@ QNetworkInterface QNetworkSession::interface() const
}
/*!
- Returns true if this object holds an active session on the underlying network interface.
+ Returns true if this session is open. If the number of all open sessions is greater than
+ zero the underlying network interface will remain connected/up.
+
The session can be controlled via open() and close().
*/
-bool QNetworkSession::isActive() const
+bool QNetworkSession::isOpen() const
{
- return d->isActive;
+ return d->isOpen;
}
/*!
- Returns the state of the session. If the session is based on a
- single access point configuration the state of the session is the same as the state of the
- associated network interface. Therefore a network session object can be used to monitor
- network interfaces.
+ Returns the state of the session.
+
+ If the session is based on a single access point configuration the state of the
+ session is the same as the state of the associated network interface. Therefore
+ a network session object can be used to monitor network interfaces.
A \l QNetworkConfiguration::ServiceNetwork based session summarizes the state of all its children
- and therefore returns the \l Connected state if at least one of its sub configurations is connected.
+ and therefore returns the \l Connected state if at least one of the service network's
+ \l {QNetworkConfiguration::children()}{children()} configurations is active.
- Note that it is not required to hold an active session in order to obtain the network interface state.
- A connected but inactive session may be used to monitor network interfaces whereas an active and connected
+ Note that it is not required to hold an open session in order to obtain the network interface state.
+ A connected but closed session may be used to monitor network interfaces whereas an open and connected
session object may prevent the network interface from being shut down.
\sa error(), stateChanged()
@@ -463,8 +479,8 @@ QString QNetworkSession::errorString() const
\header
\o Key \o Description
\row
- \o ActiveConfigurationIdentifier
- \o If the session \l isActive() this property returns the identifier of the
+ \o ActiveConfiguration
+ \o If the session \l isOpen() this property returns the identifier of the
QNetworkConfiguration that is used by this session; otherwise an empty string.
The main purpose of this key is to determine which Internet access point is used
@@ -476,7 +492,7 @@ QString QNetworkSession::errorString() const
QNetworkSession* session = new QNetworkSession(ap);
... //code activates session
- QString ident = session->sessionProperty("ActiveConfigurationIdentifier").toString();
+ QString ident = session->sessionProperty("ActiveConfiguration").toString();
if ( ap.type() == QNetworkConfiguration::ServiceNetwork ) {
Q_ASSERT( ap.identifier() != ident );
Q_ASSERT( ap.children().contains( mgr.configurationFromIdentifier(ident) ) );
@@ -485,17 +501,17 @@ QString QNetworkSession::errorString() const
}
\endcode
\row
- \o UserChoiceConfigurationIdentifier
- \o If the session \l isActive() and is bound to a QNetworkConfiguration of type
+ \o UserChoiceConfiguration
+ \o If the session \l isOpen() and is bound to a QNetworkConfiguration of type
UserChoice, this property returns the identifier of the QNetworkConfiguration that the
configuration resolved to when \l open() was called; otherwise an empty string.
The purpose of this key is to determine the real QNetworkConfiguration that the
- session is using. This key is different to \i ActiveConfigurationIdentifier in that
+ session is using. This key is different to \i ActiveConfiguration in that
this key may return an identifier for either a
\l {QNetworkConfiguration::ServiceNetwork}{service network} or a
\l {QNetworkConfiguration::InternetAccessPoint}{Internet access points} configurations
- whereas \i ActiveConfigurationIdentifier always returns identifiers for
+ whereas \i ActiveConfiguration always returns identifiers to
\l {QNetworkConfiguration::InternetAccessPoint}{Internet access points} configurations.
\row
\o ConnectInBackground
@@ -509,15 +525,15 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const
if (!d->publicConfig.isValid())
return QVariant();
- if (key == "ActiveConfigurationIdentifier") {
- if (!d->isActive)
+ if (key == "ActiveConfiguration") {
+ if (!d->isOpen)
return QString();
else
return d->activeConfig.identifier();
}
- if (key == "UserChoiceConfigurationIdentifier") {
- if (!d->isActive || d->publicConfig.type() != QNetworkConfiguration::UserChoice)
+ if (key == "UserChoiceConfiguration") {
+ if (!d->isOpen || d->publicConfig.type() != QNetworkConfiguration::UserChoice)
return QString();
if (d->serviceConfig.isValid())
@@ -534,13 +550,13 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const
\a key. Removing an already set property can be achieved by passing an
invalid QVariant.
- Note that the \i UserChoiceConfigurationIdentifier and \i ActiveConfigurationIdentifier
+ Note that the \i UserChoiceConfiguration and \i ActiveConfiguration
properties are read only and cannot be changed using this method.
*/
void QNetworkSession::setSessionProperty(const QString& key, const QVariant& value)
{
- if (key == "ActiveConfigurationIdentifier"
- || key == "UserChoiceConfigurationIdentifier")
+ if (key == "ActiveConfiguration"
+ || key == "UserChoiceConfiguration")
return;
d->setSessionProperty(key, value);
@@ -560,16 +576,14 @@ void QNetworkSession::migrate()
}
/*!
- This function indicates that the application does not wish to roam the session. This
- is the default behavior if an application doesn't call migrate() in response to a
- preferredConfigurationChanged() signal.
+ This function indicates that the application does not wish to roam the session.
\sa migrate()
*/
void QNetworkSession::ignore()
{
- //TODO Do we really need this function if we consider that this is
- // the default behavior if nobody calls migrate()?
+ // Needed on at least Symbian platform: the roaming must be explicitly
+ // ignore()'d or migrate()'d
d->ignore();
}
@@ -602,7 +616,7 @@ void QNetworkSession::reject()
/*!
Returns the amount of data sent in bytes; otherwise 0.
- This field value includes the usage across all active network
+ This field value includes the usage across all open network
sessions which use the same network interface.
If the session is based on a service network configuration the number of
@@ -619,7 +633,7 @@ quint64 QNetworkSession::bytesWritten() const
/*!
Returns the amount of data received in bytes; otherwise 0.
- This field value includes the usage across all active network
+ This field value includes the usage across all open network
sessions which use the same network interface.
If the session is based on a service network configuration the number of
diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h
index 47377c4..7e52674 100644
--- a/src/network/bearer/qnetworksession.h
+++ b/src/network/bearer/qnetworksession.h
@@ -82,9 +82,8 @@ public:
QNetworkSession(const QNetworkConfiguration& connConfig, QObject* parent =0);
virtual ~QNetworkSession();
- bool isActive() const;
+ bool isOpen() const;
QNetworkConfiguration configuration() const;
- QString bearerName() const;
QNetworkInterface interface() const;
State state() const;
diff --git a/src/network/bearer/qnetworksession_maemo.cpp b/src/network/bearer/qnetworksession_maemo.cpp
index c7c7a31..b3afc77 100644
--- a/src/network/bearer/qnetworksession_maemo.cpp
+++ b/src/network/bearer/qnetworksession_maemo.cpp
@@ -305,14 +305,14 @@ void QNetworkSessionPrivate::updateState(QNetworkSession::State newState)
state = newState;
if (state == QNetworkSession::Disconnected) {
- isActive = false;
+ isOpen = false;
currentNetworkInterface.clear();
if (publicConfig.type() == QNetworkConfiguration::UserChoice)
activeConfig.d->state = QNetworkConfiguration::Defined;
publicConfig.d->state = QNetworkConfiguration::Defined;
} else if (state == QNetworkSession::Connected) {
- isActive = true;
+ isOpen = true;
if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
activeConfig.d->state = QNetworkConfiguration::Active;
activeConfig.d->type = QNetworkConfiguration::InternetAccessPoint;
@@ -436,7 +436,7 @@ void QNetworkSessionPrivate::syncStateWithInterface()
/* Initially we are not active although the configuration might be in
* connected state.
*/
- isActive = false;
+ isOpen = false;
opened = false;
QObject::connect(&manager, SIGNAL(updateCompleted()), this, SLOT(networkConfigurationsChanged()));
@@ -684,13 +684,13 @@ void QNetworkSessionPrivate::updateStateFromActiveConfig()
clearConfiguration(activeConfig);
}
- bool oldActive = isActive;
- isActive = newActive;
+ bool oldActive = isOpen;
+ isOpen = newActive;
- if (!oldActive && isActive)
+ if (!oldActive && isOpen)
emit quitPendingWaitsForOpened();
- if (oldActive && !isActive)
+ if (oldActive && !isOpen)
emit q->closed();
if (oldState != state) {
@@ -776,7 +776,7 @@ void QNetworkSessionPrivate::open()
if (serviceConfig.isValid()) {
lastError = QNetworkSession::OperationNotSupportedError;
emit q->error(lastError);
- } else if (!isActive) {
+ } else if (!isOpen) {
if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
/* Caller is trying to connect to default IAP.
@@ -810,8 +810,8 @@ void QNetworkSessionPrivate::open()
return;
}
- isActive = (activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
- if (isActive)
+ isOpen = (activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
+ if (isOpen)
emit quitPendingWaitsForOpened();
} else {
/* We seem to be active so inform caller */
@@ -826,7 +826,6 @@ void QNetworkSessionPrivate::do_open()
bool st;
QString result;
QString iap = publicConfig.identifier();
- QString bearer_name;
if (state == QNetworkSession::Connected) {
#ifdef BEARER_MANAGEMENT_DEBUG
@@ -922,14 +921,7 @@ void QNetworkSessionPrivate::do_open()
if (!name.isEmpty())
config.d->name = name;
- bearer_name = connect_result.connect.network_type;
- if (bearer_name == "WLAN_INFRA" ||
- bearer_name == "WLAN_ADHOC")
- currentBearerName = "WLAN";
- else if (bearer_name == "GPRS")
- currentBearerName = "HSPA";
- else
- currentBearerName = bearer_name;
+ config.d->iap_type = connect_result.connect.network_type;
config.d->isValid = true;
config.d->state = QNetworkConfiguration::Active;
@@ -1032,9 +1024,9 @@ void QNetworkSessionPrivate::close()
if (serviceConfig.isValid()) {
lastError = QNetworkSession::OperationNotSupportedError;
emit q->error(lastError);
- } else if (isActive) {
+ } else if (isOpen) {
opened = false;
- isActive = false;
+ isOpen = false;
emit q->closed();
}
}
@@ -1067,11 +1059,11 @@ void QNetworkSessionPrivate::stop()
mgr->configurationChanged((QNetworkConfigurationPrivate*)activeConfig.d.data());
opened = false;
- isActive = false;
+ isOpen = false;
} else {
opened = false;
- isActive = false;
+ isOpen = false;
emit q->closed();
}
}
@@ -1142,15 +1134,6 @@ QVariant QNetworkSessionPrivate::sessionProperty(const QString& key) const
}
-QString QNetworkSessionPrivate::bearerName() const
-{
- if (!publicConfig.isValid())
- return QString();
-
- return currentBearerName;
-}
-
-
QString QNetworkSessionPrivate::errorString() const
{
QString errorStr;
diff --git a/src/network/bearer/qnetworksession_maemo_p.h b/src/network/bearer/qnetworksession_maemo_p.h
index e233087..892262d 100644
--- a/src/network/bearer/qnetworksession_maemo_p.h
+++ b/src/network/bearer/qnetworksession_maemo_p.h
@@ -69,7 +69,7 @@ class QNetworkSessionPrivate : public QObject
Q_OBJECT
public:
QNetworkSessionPrivate() :
- tx_data(0), rx_data(0), m_activeTime(0), isActive(false),
+ tx_data(0), rx_data(0), m_activeTime(0), isOpen(false),
connectFlags(ICD_CONNECTION_FLAG_USER_EVENT)
{
}
@@ -88,7 +88,6 @@ public:
QNetworkInterface currentInterface() const;
QVariant sessionProperty(const QString& key) const;
void setSessionProperty(const QString& key, const QVariant& value);
- QString bearerName() const;
void open();
void close();
@@ -142,7 +141,7 @@ private:
void cleanupAnyConfiguration();
QNetworkSession::State state;
- bool isActive;
+ bool isOpen;
bool opened;
icd_connection_flags connectFlags;
@@ -152,7 +151,6 @@ private:
friend class QNetworkSession;
QDateTime startTime;
- QString currentBearerName;
QString currentNetworkInterface;
friend class IcdListener;
void updateState(QNetworkSession::State);
diff --git a/src/network/bearer/qnetworksession_p.cpp b/src/network/bearer/qnetworksession_p.cpp
index c6f9833..1dfc949 100644
--- a/src/network/bearer/qnetworksession_p.cpp
+++ b/src/network/bearer/qnetworksession_p.cpp
@@ -189,7 +189,7 @@ void QNetworkSessionPrivate::open()
if (serviceConfig.isValid()) {
lastError = QNetworkSession::OperationNotSupportedError;
emit q->error(lastError);
- } else if (!isActive) {
+ } else if (!isOpen) {
if ((activeConfig.state() & QNetworkConfiguration::Discovered) !=
QNetworkConfiguration::Discovered) {
lastError =QNetworkSession::InvalidConfigurationError;
@@ -206,8 +206,8 @@ void QNetworkSessionPrivate::open()
engine->connectToId(activeConfig.identifier());
}
- isActive = (activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
- if (isActive)
+ isOpen = (activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
+ if (isOpen)
emit quitPendingWaitsForOpened();
}
}
@@ -217,9 +217,9 @@ void QNetworkSessionPrivate::close()
if (serviceConfig.isValid()) {
lastError = QNetworkSession::OperationNotSupportedError;
emit q->error(lastError);
- } else if (isActive) {
+ } else if (isOpen) {
opened = false;
- isActive = false;
+ isOpen = false;
emit q->closed();
}
}
@@ -240,7 +240,7 @@ void QNetworkSessionPrivate::stop()
}
opened = false;
- isActive = false;
+ isOpen = false;
emit q->closed();
}
}
@@ -286,13 +286,13 @@ void QNetworkSessionPrivate::setSessionProperty(const QString& /*key*/, const QV
{
}
-QString QNetworkSessionPrivate::bearerName() const
+/*QString QNetworkSessionPrivate::bearerName() const
{
if (!publicConfig.isValid() || !engine)
return QString();
return engine->bearerName(activeConfig.identifier());
-}
+}*/
QString QNetworkSessionPrivate::errorString() const
{
@@ -321,7 +321,7 @@ QNetworkSession::SessionError QNetworkSessionPrivate::error() const
quint64 QNetworkSessionPrivate::bytesWritten() const
{
#if defined(BACKEND_NM)
- if( state == QNetworkSession::Connected ) {
+ if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) {
if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
foreach (const QNetworkConfiguration &config, publicConfig.children()) {
if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
@@ -339,7 +339,7 @@ quint64 QNetworkSessionPrivate::bytesWritten() const
quint64 QNetworkSessionPrivate::bytesReceived() const
{
#if defined(BACKEND_NM)
- if( state == QNetworkSession::Connected ) {
+ if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) {
if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
foreach (const QNetworkConfiguration &config, publicConfig.children()) {
if ((config.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
@@ -425,12 +425,12 @@ void QNetworkSessionPrivate::updateStateFromActiveConfig()
state = QNetworkSession::NotAvailable;
}
- bool oldActive = isActive;
- isActive = newActive;
+ bool oldActive = isOpen;
+ isOpen = newActive;
- if (!oldActive && isActive)
+ if (!oldActive && isOpen)
emit quitPendingWaitsForOpened();
- if (oldActive && !isActive)
+ if (oldActive && !isOpen)
emit q->closed();
if (oldState != state)
@@ -460,7 +460,7 @@ void QNetworkSessionPrivate::forcedSessionClose(const QNetworkConfiguration &con
{
if (activeConfig == config) {
opened = false;
- isActive = false;
+ isOpen = false;
emit q->closed();
@@ -530,7 +530,7 @@ if(serviceName.isEmpty())
QNetworkManagerSettingsConnection *sysIface;
sysIface = new QNetworkManagerSettingsConnection(serviceName, path.path());
startTime = QDateTime::fromTime_t(sysIface->getTimestamp());
- // isActive = (publicConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
+ // isOpen = (publicConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
}
if(startTime.isNull())
startTime = QDateTime::currentDateTime();
diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h
index a2aaa6a..09fcfca 100644
--- a/src/network/bearer/qnetworksession_p.h
+++ b/src/network/bearer/qnetworksession_p.h
@@ -73,7 +73,7 @@ class QNetworkSessionPrivate : public QObject
Q_OBJECT
public:
QNetworkSessionPrivate() :
- tx_data(0), rx_data(0), m_activeTime(0), isActive(false)
+ tx_data(0), rx_data(0), m_activeTime(0), isOpen(false)
{
}
@@ -143,7 +143,7 @@ private:
QNetworkConfiguration activeConfig;
QNetworkSession::State state;
- bool isActive;
+ bool isOpen;
#ifdef BEARER_ENGINE
bool opened;
diff --git a/src/network/bearer/qnetworksession_s60_p.cpp b/src/network/bearer/qnetworksession_s60_p.cpp
index 764c1c4..f9cb09f 100644
--- a/src/network/bearer/qnetworksession_s60_p.cpp
+++ b/src/network/bearer/qnetworksession_s60_p.cpp
@@ -53,7 +53,7 @@ QTM_BEGIN_NAMESPACE
QNetworkSessionPrivate::QNetworkSessionPrivate()
: CActive(CActive::EPriorityStandard), state(QNetworkSession::Invalid),
- isActive(false), ipConnectionNotifier(0), iError(QNetworkSession::UnknownSessionError),
+ isOpen(false), ipConnectionNotifier(0), iError(QNetworkSession::UnknownSessionError),
iALREnabled(0)
{
CActiveScheduler::Add(this);
@@ -69,7 +69,7 @@ QNetworkSessionPrivate::QNetworkSessionPrivate()
QNetworkSessionPrivate::~QNetworkSessionPrivate()
{
- isActive = false;
+ isOpen = false;
// Cancel Connection Progress Notifications first.
// Note: ConnectionNotifier must be destroyed before Canceling RConnection::Start()
@@ -233,7 +233,7 @@ QNetworkSession::SessionError QNetworkSessionPrivate::error() const
void QNetworkSessionPrivate::open()
{
- if (isActive || !publicConfig.d || (state == QNetworkSession::Connecting)) {
+ if (isOpen || !publicConfig.d || (state == QNetworkSession::Connecting)) {
return;
}
@@ -296,7 +296,7 @@ void QNetworkSessionPrivate::open()
error = iDynamicSetdefaultif(&ifr);
}
- isActive = true;
+ isOpen = true;
// Make sure that state will be Connected
newState(QNetworkSession::Connected);
emit quitPendingWaitsForOpened();
@@ -333,7 +333,7 @@ void QNetworkSessionPrivate::open()
}
if (error != KErrNone) {
- isActive = false;
+ isOpen = false;
iError = QNetworkSession::UnknownSessionError;
emit q->error(iError);
if (ipConnectionNotifier) {
@@ -372,12 +372,12 @@ TUint QNetworkSessionPrivate::iapClientCount(TUint aIAPId) const
void QNetworkSessionPrivate::close(bool allowSignals)
{
- if (!isActive) {
+ if (!isOpen) {
return;
}
TUint activeIap = activeConfig.d.data()->numericId;
- isActive = false;
+ isOpen = false;
activeConfig = QNetworkConfiguration();
serviceConfig = QNetworkConfiguration();
@@ -419,13 +419,13 @@ void QNetworkSessionPrivate::close(bool allowSignals)
void QNetworkSessionPrivate::stop()
{
- if (!isActive) {
+ if (!isOpen) {
return;
}
- isActive = false;
+ isOpen = false;
newState(QNetworkSession::Closing);
iConnection.Stop(RConnection::EStopAuthoritative);
- isActive = true;
+ isOpen = true;
close(false);
emit q->closed();
}
@@ -510,8 +510,8 @@ void QNetworkSessionPrivate::NewCarrierActive(TAccessPointInfo /*aNewAPInfo*/, T
void QNetworkSessionPrivate::Error(TInt /*aError*/)
{
- if (isActive) {
- isActive = false;
+ if (isOpen) {
+ isOpen = false;
activeConfig = QNetworkConfiguration();
serviceConfig = QNetworkConfiguration();
iError = QNetworkSession::RoamingError;
@@ -558,40 +558,6 @@ QNetworkConfiguration QNetworkSessionPrivate::bestConfigFromSNAP(const QNetworkC
return config;
}
-QString QNetworkSessionPrivate::bearerName() const
-{
- QNetworkConfiguration config;
- if (publicConfig.type() == QNetworkConfiguration::InternetAccessPoint) {
- config = publicConfig;
- } else if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
- if (activeConfig.isValid()) {
- config = activeConfig;
- } else {
- config = bestConfigFromSNAP(publicConfig);
- }
- } else if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
- if (activeConfig.isValid()) {
- config = activeConfig;
- }
- }
-
- if (!config.isValid()) {
- return QString();
- }
-
- switch (config.d.data()->bearer) {
- case QNetworkConfigurationPrivate::BearerEthernet: return QString("Ethernet");
- case QNetworkConfigurationPrivate::BearerWLAN: return QString("WLAN");
- case QNetworkConfigurationPrivate::Bearer2G: return QString("2G");
- case QNetworkConfigurationPrivate::BearerCDMA2000: return QString("CDMA2000");
- case QNetworkConfigurationPrivate::BearerWCDMA: return QString("WCDMA");
- case QNetworkConfigurationPrivate::BearerHSPA: return QString("HSPA");
- case QNetworkConfigurationPrivate::BearerBluetooth: return QString("Bluetooth");
- case QNetworkConfigurationPrivate::BearerWiMAX: return QString("WiMAX");
- default: return QString();
- }
-}
-
quint64 QNetworkSessionPrivate::bytesWritten() const
{
return transferredData(KUplinkData);
@@ -673,7 +639,7 @@ quint64 QNetworkSessionPrivate::transferredData(TUint dataType) const
quint64 QNetworkSessionPrivate::activeTime() const
{
- if (!isActive || startTime.isNull()) {
+ if (!isOpen || startTime.isNull()) {
return 0;
}
return startTime.secsTo(QDateTime::currentDateTime());
@@ -785,7 +751,7 @@ void QNetworkSessionPrivate::RunL()
}
if (error != KErrNone) {
- isActive = false;
+ isOpen = false;
iError = QNetworkSession::UnknownSessionError;
emit q->error(iError);
Cancel();
@@ -802,7 +768,7 @@ void QNetworkSessionPrivate::RunL()
iMobility = CActiveCommsMobilityApiExt::NewL(iConnection, *this);
}
#endif
- isActive = true;
+ isOpen = true;
activeConfig = newActiveConfig;
activeInterface = interface(activeConfig.d.data()->numericId);
if (publicConfig.type() == QNetworkConfiguration::UserChoice) {
@@ -818,7 +784,7 @@ void QNetworkSessionPrivate::RunL()
}
break;
case KErrNotFound: // Connection failed
- isActive = false;
+ isOpen = false;
activeConfig = QNetworkConfiguration();
serviceConfig = QNetworkConfiguration();
iError = QNetworkSession::InvalidConfigurationError;
@@ -832,7 +798,7 @@ void QNetworkSessionPrivate::RunL()
case KErrCancel: // Connection attempt cancelled
case KErrAlreadyExists: // Connection already exists
default:
- isActive = false;
+ isOpen = false;
activeConfig = QNetworkConfiguration();
serviceConfig = QNetworkConfiguration();
iError = QNetworkSession::UnknownSessionError;
@@ -855,7 +821,7 @@ bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint acc
{
// Make sure that activeConfig is always updated when SNAP is signaled to be
// connected.
- if (isActive && publicConfig.type() == QNetworkConfiguration::ServiceNetwork &&
+ if (isOpen && publicConfig.type() == QNetworkConfiguration::ServiceNetwork &&
newState == QNetworkSession::Connected) {
activeConfig = activeConfiguration(accessPointId);
activeInterface = interface(activeConfig.d.data()->numericId);
@@ -872,12 +838,12 @@ bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint acc
}
bool emitSessionClosed = false;
- if (isActive && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) {
+ if (isOpen && state == QNetworkSession::Connected && newState == QNetworkSession::Disconnected) {
// Active & Connected state should change directly to Disconnected state
// only when something forces connection to close (eg. when another
// application or session stops connection or when network drops
// unexpectedly).
- isActive = false;
+ isOpen = false;
activeConfig = QNetworkConfiguration();
serviceConfig = QNetworkConfiguration();
iError = QNetworkSession::SessionAbortedError;
@@ -903,7 +869,7 @@ bool QNetworkSessionPrivate::newState(QNetworkSession::State newState, TUint acc
emit q->stateChanged(state);
retVal = true;
}
- } else if (publicConfig.type() == QNetworkConfiguration::UserChoice && isActive) {
+ } else if (publicConfig.type() == QNetworkConfiguration::UserChoice && isOpen) {
if (activeConfig.d.data()->numericId == accessPointId) {
state = newState;
emit q->stateChanged(state);
diff --git a/src/network/bearer/qnetworksession_s60_p.h b/src/network/bearer/qnetworksession_s60_p.h
index cfb99c9..ed322dd 100644
--- a/src/network/bearer/qnetworksession_s60_p.h
+++ b/src/network/bearer/qnetworksession_s60_p.h
@@ -92,7 +92,6 @@ public:
QNetworkInterface currentInterface() const;
QVariant sessionProperty(const QString& key) const;
void setSessionProperty(const QString& key, const QVariant& value);
- QString bearerName() const;
void setALREnabled(bool enabled);
@@ -158,7 +157,7 @@ private: // data
mutable QNetworkInterface activeInterface;
QNetworkSession::State state;
- bool isActive;
+ bool isOpen;
QNetworkSession* q;
QDateTime startTime;
diff --git a/src/network/bearer/qnetworksessionengine_p.h b/src/network/bearer/qnetworksessionengine_p.h
index 795a209..3977b15 100644
--- a/src/network/bearer/qnetworksessionengine_p.h
+++ b/src/network/bearer/qnetworksessionengine_p.h
@@ -81,7 +81,7 @@ public:
virtual QString getInterfaceFromId(const QString &id) = 0;
virtual bool hasIdentifier(const QString &id) = 0;
- virtual QString bearerName(const QString &id) = 0;
+ //virtual QString bearerName(const QString &id) = 0;
virtual void connectToId(const QString &id) = 0;
virtual void disconnectFromId(const QString &id) = 0;
diff --git a/src/network/bearer/qnlaengine_win.cpp b/src/network/bearer/qnlaengine_win.cpp
index b606ef4..a3f6017 100644
--- a/src/network/bearer/qnlaengine_win.cpp
+++ b/src/network/bearer/qnlaengine_win.cpp
@@ -133,7 +133,7 @@ static QString qGetInterfaceType(const QString &interface)
HANDLE handle = CreateFile((TCHAR *)QString("\\\\.\\%1").arg(interface).utf16(), 0,
FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (handle == INVALID_HANDLE_VALUE)
- return QString();
+ return QLatin1String("Unknown");
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 QString();
+ return QLatin1String("Unknown");
}
oid = OID_GEN_PHYSICAL_MEDIUM;
@@ -154,7 +154,7 @@ static QString qGetInterfaceType(const QString &interface)
if (medium == NdisMedium802_3)
return QLatin1String("Ethernet");
else
- return QString();
+ return QLatin1String("Unknown");
}
CloseHandle(handle);
@@ -181,7 +181,7 @@ static QString qGetInterfaceType(const QString &interface)
#endif
- return QString();
+ return QLatin1String("Unknown");
}
class QNlaThread : public QThread
@@ -252,6 +252,9 @@ QList<QNetworkConfigurationPrivate *> QNlaThread::getConfigurations()
config->roamingSupported = fetchedConfigurations.at(i)->roamingSupported;
config->purpose = fetchedConfigurations.at(i)->purpose;
config->internet = fetchedConfigurations.at(i)->internet;
+ if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) {
+ config->bearer = engine->bearerName(config->id);
+ }
foundConfigurations.append(config);
}
@@ -546,12 +549,17 @@ bool QNlaEngine::hasIdentifier(const QString &id)
if (configurationInterface.contains(id.toUInt()))
return true;
- foreach (QNetworkConfigurationPrivate *cpPriv, nlaThread->getConfigurations()) {
- if (cpPriv->id == id)
- return true;
+ bool result = false;
+ QList<QNetworkConfigurationPrivate *> l = nlaThread->getConfigurations();
+ while (!l.isEmpty()) {
+ QNetworkConfigurationPrivate* cpPriv = l.takeFirst();
+ if (!result && cpPriv->id == id) {
+ result = true;
+ }
+ delete cpPriv;
}
-
- return false;
+
+ return result;
}
QString QNlaEngine::bearerName(const QString &id)
diff --git a/src/network/bearer/qnmwifiengine_unix.cpp b/src/network/bearer/qnmwifiengine_unix.cpp
index f558fa8..2444919 100644
--- a/src/network/bearer/qnmwifiengine_unix.cpp
+++ b/src/network/bearer/qnmwifiengine_unix.cpp
@@ -44,6 +44,7 @@
#include <qnetworkconfiguration.h>
#include <QtCore/qstringlist.h>
+#include <QScopedPointer>
#include <QtNetwork/qnetworkinterface.h>
#include <NetworkManager/NetworkManager.h>
@@ -65,7 +66,7 @@ QTM_BEGIN_NAMESPACE
QNmWifiEngine::QNmWifiEngine(QObject *parent)
: QNetworkSessionEngine(parent)
{
- iface = new QNetworkManagerInterface();
+ iface = new QNetworkManagerInterface(this);
if(!iface->isValid()) {
return;
}
@@ -74,6 +75,8 @@ QNmWifiEngine::QNmWifiEngine(QObject *parent)
this,SLOT(addDevice(QDBusObjectPath)));
connect(iface,SIGNAL(deviceRemoved(QDBusObjectPath)),
this,SLOT(removeDevice(QDBusObjectPath)));
+ connect(iface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
+ this, SLOT(slotActivationFinished(QDBusPendingCallWatcher*)));
QList<QDBusObjectPath> list = iface->getDevices();
@@ -84,9 +87,9 @@ QNmWifiEngine::QNmWifiEngine(QObject *parent)
QStringList connectionServices;
connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
+ QNetworkManagerSettings *settingsiface;
foreach (QString service, connectionServices) {
- QNetworkManagerSettings *settingsiface;
- settingsiface = new QNetworkManagerSettings(service);
+ settingsiface = new QNetworkManagerSettings(service, this);
settingsiface->setConnections();
connect(settingsiface,SIGNAL(newConnection(QDBusObjectPath)),
this,(SLOT(newConnection(QDBusObjectPath))));
@@ -107,6 +110,7 @@ QString QNmWifiEngine::getNameForConfiguration(QNetworkManagerInterfaceDevice *d
QNetworkManagerIp4Config * ipIface;
ipIface = new QNetworkManagerIp4Config(path);
newname = ipIface->domains().join(" ");
+ delete ipIface;
}
//fallback to interface name
if(newname.isEmpty())
@@ -117,17 +121,16 @@ QString QNmWifiEngine::getNameForConfiguration(QNetworkManagerInterfaceDevice *d
QList<QNetworkConfigurationPrivate *> QNmWifiEngine::getConfigurations(bool *ok)
{
-// qWarning() << Q_FUNC_INFO << updated;
if (ok)
*ok = false;
if(!updated) {
foundConfigurations.clear();
if(knownSsids.isEmpty())
- getKnownSsids(); // list of ssids that have user configurations.
+ updateKnownSsids(); // list of ssids that have user configurations.
scanForAccessPoints();
- getActiveConnectionsPaths();
+ updateActiveConnectionsPaths();
knownConnections();
accessPointConnections();
@@ -139,160 +142,8 @@ QList<QNetworkConfigurationPrivate *> QNmWifiEngine::getConfigurations(bool *ok)
return foundConfigurations;
}
-void QNmWifiEngine::findConnections()
-{
- QList<QDBusObjectPath> list = iface->getDevices();
-
- foreach(QDBusObjectPath path, list) {
- QNetworkManagerInterfaceDevice *devIface = new QNetworkManagerInterfaceDevice(path.path());
-
- //// eth
- switch (devIface->deviceType()) {
-// qWarning() << devIface->connectionInterface()->path();
-
- case DEVICE_TYPE_802_3_ETHERNET:
- {
- QString ident;
- QNetworkManagerInterfaceDeviceWired *devWiredIface;
- devWiredIface = new QNetworkManagerInterfaceDeviceWired(devIface->connectionInterface()->path());
-
- ident = devWiredIface->hwAddress();
-
- QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
- cpPriv->name = getNameForConfiguration(devIface);
- cpPriv->isValid = true;
- cpPriv->id = ident;
- cpPriv->internet = devWiredIface->carrier();
-
- cpPriv->serviceInterface = devIface->interface();
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
- switch (devIface->state()) {
- case NM_DEVICE_STATE_UNKNOWN:
- case NM_DEVICE_STATE_UNMANAGED:
- case NM_DEVICE_STATE_FAILED:
- cpPriv->state = (cpPriv->state | QNetworkConfiguration::Undefined);
- break;
- case NM_DEVICE_STATE_UNAVAILABLE:
- cpPriv->state = (cpPriv->state | QNetworkConfiguration::Defined);
- break;
- case NM_DEVICE_STATE_PREPARE:
- case NM_DEVICE_STATE_CONFIG:
- case NM_DEVICE_STATE_NEED_AUTH:
- case NM_DEVICE_STATE_IP_CONFIG:
- case NM_DEVICE_STATE_DISCONNECTED:
- {
- cpPriv->state = ( cpPriv->state | QNetworkConfiguration::Discovered
- | QNetworkConfiguration::Defined);
- }
- break;
- case NM_DEVICE_STATE_ACTIVATED:
- cpPriv->state = (cpPriv->state | QNetworkConfiguration::Active );
- break;
- default:
- cpPriv->state = (cpPriv->state | QNetworkConfiguration::Undefined);
- break;
- };
- cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
- foundConfigurations.append(cpPriv);
- configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name();
- }
- break;
- case DEVICE_TYPE_802_11_WIRELESS:
- {
-// QNetworkManagerInterfaceDeviceWireless *devWirelessIface;
-// devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path());
-//
-// //// connections
-// QStringList connectionServices;
-// connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
-// connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
-//
-// QString connPath;
-//
-// foreach (QString service, connectionServices) {
-// QString ident;
-// QNetworkManagerSettings *settingsiface;
-// settingsiface = new QNetworkManagerSettings(service);
-// QList<QDBusObjectPath> list = settingsiface->listConnections();
-//
-// foreach(QDBusObjectPath path, list) { //for each connection path
-//qWarning() << path.path();
-// ident = path.path();
-// bool addIt = false;
-// QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
-// cpPriv->isValid = true;
-// cpPriv->id = ident;
-// cpPriv->internet = true;
-//
-// cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
-// cpPriv->state = ( cpPriv->state | QNetworkConfiguration::Discovered
-// | QNetworkConfiguration::Defined);
-// cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
-//
-// QNetworkManagerSettingsConnection *sysIface;
-// sysIface = new QNetworkManagerSettingsConnection(service, path.path());
-// cpPriv->name = sysIface->getId();//ii.value().toString();
-//qWarning() << cpPriv->name;
-// if(sysIface->getType() == DEVICE_TYPE_802_3_ETHERNET/*type == "802-3-ethernet"*/
-// && devIface->deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
-// cpPriv->serviceInterface = devIface->interface();
-// addIt = true;
-// } else if(sysIface->getType() == DEVICE_TYPE_802_11_WIRELESS/*type == "802-11-wireless"*/
-// && devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
-// cpPriv->serviceInterface = devIface->interface();
-// addIt = true;
-// // get the wifi interface state first.. do we need this?
-// // QString activeAPPath = devWirelessIface->activeAccessPoint().path();
-// }
-//
-// //#if 0
-// foreach(QString conpath, activeConnectionPaths) {
-// QNetworkManagerConnectionActive *aConn;
-// aConn = new QNetworkManagerConnectionActive(conpath);
-// // in case of accesspoint, specificObject will hold the accessPOintObjectPath
-// // qWarning() << aConn->connection().path() << aConn->specificObject().path() << aConn->devices().count();
-// if( aConn->connection().path() == ident) {
-//
-// QList <QDBusObjectPath> devs = aConn->devices();
-// foreach(QDBusObjectPath device, devs) {
-// QNetworkManagerInterfaceDevice *ifaceDevice;
-// ifaceDevice = new QNetworkManagerInterfaceDevice(device.path());
-// cpPriv->serviceInterface = ifaceDevice->interface();
-// cpPriv->state = getStateFlag(ifaceDevice->state());
-// //cpPriv->accessPoint = aConn->specificObject().path();
-//
-// break;
-// }
-// }
-// }
-// //#endif
-// // } //end while connection
-// if(addIt) {
-// foundConfigurations.append(cpPriv);
-// configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name();
-// }
-// }
-// } //end each connection service
-//
-// // ////////////// AccessPoints
-//// QList<QDBusObjectPath> apList = devWirelessIface->getAccessPoints();
-////// qWarning() << apList.count();
-//// foreach(QDBusObjectPath path, apList) {
-//// QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
-//// cpPriv = addAccessPoint( devIface->connectionInterface()->path(), path);
-//// if(cpPriv->isValid) {
-//// foundConfigurations.append(cpPriv);
-//// }
-//// }
- } // end DEVICE_TYPE_802_11_WIRELESS
- break;
- };
- } //end foreach device
-}
-
void QNmWifiEngine::knownConnections()
{
-// qWarning() << Q_FUNC_INFO;
//// connections
QStringList connectionServices;
connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
@@ -300,21 +151,18 @@ void QNmWifiEngine::knownConnections()
QString connPath;
+ QScopedPointer<QNetworkManagerSettings> settingsiface;
foreach (QString service, connectionServices) {
QString ident;
- QNetworkManagerSettings *settingsiface;
- settingsiface = new QNetworkManagerSettings(service);
+ settingsiface.reset(new QNetworkManagerSettings(service));
QList<QDBusObjectPath> list = settingsiface->listConnections();
-// qWarning() <<Q_FUNC_INFO << service << list.count();
-
+ QNetworkManagerSettingsConnection *sysIface;
foreach(QDBusObjectPath path, list) { //for each connection path
- //qWarning() << "COnnection path:" << path.path();
ident = path.path();
bool addIt = false;
QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
- QNetworkManagerSettingsConnection *sysIface;
- sysIface = new QNetworkManagerSettingsConnection(service, path.path());
+ sysIface = new QNetworkManagerSettingsConnection(service, path.path(), this);
sysIface->setConnections();
connect(sysIface, SIGNAL(removed(QString)),
this,SLOT(settingsConnectionRemoved(QString)));
@@ -322,27 +170,23 @@ void QNmWifiEngine::knownConnections()
cpPriv->name = sysIface->getId();
cpPriv->isValid = true;
cpPriv->id = sysIface->getUuid();
-// cpPriv->id = ident;
cpPriv->internet = true;
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
-//qWarning() << cpPriv->name;
cpPriv->state = getStateForId(cpPriv->id);
cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
+
if(sysIface->getType() == DEVICE_TYPE_802_3_ETHERNET) {
QString mac = sysIface->getMacAddress();
if(!mac.length() > 2) {
- qWarning() <<"XXXXXXXXXXXXXXXXXXXXXXXXX" << mac << "type ethernet";
QString devPath;
devPath = deviceConnectionPath(mac);
- // qWarning() << Q_FUNC_INFO << devPath;
- QNetworkManagerInterfaceDevice *devIface;
- devIface = new QNetworkManagerInterfaceDevice(devPath);
- cpPriv->serviceInterface = devIface->interface();
- QNetworkManagerInterfaceDeviceWired *devWiredIface;
- devWiredIface = new QNetworkManagerInterfaceDeviceWired(devIface->connectionInterface()->path());
+ QNetworkManagerInterfaceDevice devIface(devPath);
+ cpPriv->serviceInterface = devIface.interface();
+ QScopedPointer<QNetworkManagerInterfaceDeviceWired> devWiredIface;
+ devWiredIface.reset(new QNetworkManagerInterfaceDeviceWired(devIface.connectionInterface()->path()));
cpPriv->internet = devWiredIface->carrier();
// use this mac addy
@@ -356,19 +200,15 @@ void QNmWifiEngine::knownConnections()
} else if(sysIface->getType() == DEVICE_TYPE_802_11_WIRELESS) {
QString mac = sysIface->getMacAddress();;
if(!mac.length() > 2) {
- qWarning() <<"XXXXXXXXXXXXXXXXXXXXXXXXX" << mac << "type wireless";
QString devPath;
devPath = deviceConnectionPath(mac);
-// qWarning() << Q_FUNC_INFO << devPath;
- QNetworkManagerInterfaceDevice *devIface;
- devIface = new QNetworkManagerInterfaceDevice(devPath);
- cpPriv->serviceInterface = devIface->interface();
+ QNetworkManagerInterfaceDevice devIface(devPath);
+ cpPriv->serviceInterface = devIface.interface();
// use this mac addy
} else {
cpPriv->serviceInterface = getBestInterface( DEVICE_TYPE_802_11_WIRELESS, cpPriv->id);
}
- // cpPriv->serviceInterface = devIface->interface();
addIt = true;
// get the wifi interface state first.. do we need this?
// QString activeAPPath = devWirelessIface->activeAccessPoint().path();
@@ -376,6 +216,7 @@ void QNmWifiEngine::knownConnections()
if(addIt) {
foundConfigurations.append(cpPriv);
configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name();
+ cpPriv->bearer = bearerName(cpPriv->id);
}
} //end each connection service
}
@@ -383,22 +224,21 @@ void QNmWifiEngine::knownConnections()
void QNmWifiEngine::accessPointConnections()
{
- //qWarning() << Q_FUNC_INFO;
QList<QDBusObjectPath> list = iface->getDevices();
+ QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
foreach(QDBusObjectPath path, list) {
- QNetworkManagerInterfaceDevice *devIface;
- devIface = new QNetworkManagerInterfaceDevice(path.path());
+ devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
QList<QString> apList = availableAccessPoints.uniqueKeys();
QList<QString>::const_iterator i;
for (i = apList.constBegin(); i != apList.constEnd(); ++i) {
- QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
+ QNetworkConfigurationPrivate* cpPriv;
cpPriv = addAccessPoint( devIface->connectionInterface()->path(), availableAccessPoints[*i]);
if(cpPriv->isValid) {
foundConfigurations.append(cpPriv);
- // qWarning() << "adding" << cpPriv->name << "to things";
configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name();
+ cpPriv->bearer = bearerName(cpPriv->id);
}
}
}
@@ -414,46 +254,43 @@ bool QNmWifiEngine::hasIdentifier(const QString &id)
{
if (configurationInterface.contains(id))
return true;
- foreach (QNetworkConfigurationPrivate *cpPriv, getConfigurations()) {
- if (cpPriv->id == id)
- return true;
- }
+
return false;
}
QString QNmWifiEngine::bearerName(const QString &id)
{
QString interface = getInterfaceFromId(id);
-
+ QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
QList<QDBusObjectPath> list = iface->getDevices();
foreach(QDBusObjectPath path, list) {
- QNetworkManagerInterfaceDevice *devIface;
- devIface = new QNetworkManagerInterfaceDevice(path.path());
+ devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
+
if(interface == devIface->interface().name()) {
+
switch(devIface->deviceType()) {
- case DEVICE_TYPE_802_3_ETHERNET/*NM_DEVICE_TYPE_ETHERNET*/:
- return QLatin1String("Ethernet");
- break;
- case DEVICE_TYPE_802_11_WIRELESS/*NM_DEVICE_TYPE_WIFI*/:
- return QLatin1String("WLAN");
- break;
- case DEVICE_TYPE_GSM/*NM_DEVICE_TYPE_GSM*/:
- return QLatin1String("2G");
- break;
- case DEVICE_TYPE_CDMA/*NM_DEVICE_TYPE_CDMA*/:
- return QLatin1String("CDMA2000");
- break;
- default:
- break;
- };
+ case DEVICE_TYPE_802_3_ETHERNET/*NM_DEVICE_TYPE_ETHERNET*/:
+ return QLatin1String("Ethernet");
+ break;
+ case DEVICE_TYPE_802_11_WIRELESS/*NM_DEVICE_TYPE_WIFI*/:
+ return QLatin1String("WLAN");
+ break;
+ case DEVICE_TYPE_GSM/*NM_DEVICE_TYPE_GSM*/:
+ return QLatin1String("2G");
+ break;
+ case DEVICE_TYPE_CDMA/*NM_DEVICE_TYPE_CDMA*/:
+ return QLatin1String("CDMA2000");
+ break;
+ default:
+ break;
+ }
}
}
- return QString();
+ return QLatin1String("Unknown");
}
void QNmWifiEngine::connectToId(const QString &id)
{
-// qWarning() <<"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" << __FUNCTION__ << id;
activatingConnectionPath = id;
QStringList connectionSettings = getConnectionPathForId(id);
if(connectionSettings.isEmpty()) {
@@ -469,34 +306,26 @@ void QNmWifiEngine::connectToId(const QString &id)
devPath = deviceConnectionPath(interface);
QDBusObjectPath devicePath(devPath);
- iface = new QNetworkManagerInterface();
iface->activateConnection(
connectionSettings.at(0),
connectionPath,
devicePath,
connectionPath);
-
- connect(iface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
- this, SLOT(slotActivationFinished(QDBusPendingCallWatcher*)));
}
void QNmWifiEngine::disconnectFromId(const QString &id)
{
QString activeConnectionPath = getActiveConnectionPath(id);
- //qWarning() <<"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" << __FUNCTION__ << id << activeConnectionPath ;
if (!activeConnectionPath.isEmpty()) {
- QNetworkManagerConnectionActive *activeCon;
- activeCon = new QNetworkManagerConnectionActive(activeConnectionPath);
- QNetworkManagerSettingsConnection *settingsCon;
- settingsCon = new QNetworkManagerSettingsConnection(activeCon->serviceName(), activeCon->connection().path());
+ QScopedPointer<QNetworkManagerConnectionActive> activeCon;
+ activeCon.reset(new QNetworkManagerConnectionActive(activeConnectionPath));
+ QScopedPointer<QNetworkManagerSettingsConnection> settingsCon;
+ settingsCon.reset(new QNetworkManagerSettingsConnection(activeCon->serviceName(), activeCon->connection().path()));
- if(settingsCon->isAutoConnect()) {
-// qWarning() << id << "is autoconnect";
+ if(settingsCon->getType() == DEVICE_TYPE_802_3_ETHERNET /*NM_DEVICE_TYPE_ETHERNET*/) { //use depreciated value for now
emit connectionError(id, OperationNotSupported);
- //unsupported
} else {
-// qWarning() <<id << "is NOT autoconnect";
QDBusObjectPath dbpath(activeConnectionPath);
iface->deactivateConnection(dbpath);
activatingConnectionPath = "";
@@ -525,58 +354,43 @@ QNmWifiEngine *QNmWifiEngine::instance()
return 0;
}
-void QNmWifiEngine::getKnownSsids()
+void QNmWifiEngine::updateKnownSsids()
{
QStringList connectionServices;
connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
-//qWarning() << Q_FUNC_INFO;
+
+ QScopedPointer<QNetworkManagerSettings> settingsiface;
foreach (QString service, connectionServices) {
- QNetworkManagerSettings *settingsiface;
- settingsiface = new QNetworkManagerSettings(service);
+ settingsiface.reset(new QNetworkManagerSettings(service));
QList<QDBusObjectPath> list = settingsiface->listConnections();
foreach(QDBusObjectPath path, list) {
- QNetworkManagerSettingsConnection *sysIface;
- sysIface = new QNetworkManagerSettingsConnection(service, path.path());
-// qWarning() << sysIface->getSsid();
- knownSsids << sysIface->getSsid();
+ QNetworkManagerSettingsConnection sysIface(service, path.path());
+ knownSsids << sysIface.getSsid();
}
}
}
-void QNmWifiEngine::getActiveConnectionsPaths()
-{
-// qWarning() << Q_FUNC_INFO;
- QNetworkManagerInterface *dbIface;
+void QNmWifiEngine::updateActiveConnectionsPaths()
+{ //need to know which connection paths are currently active/connected
+ QScopedPointer<QNetworkManagerInterface> dbIface;
activeConnectionPaths.clear();
- dbIface = new QNetworkManagerInterface;
+ dbIface.reset(new QNetworkManagerInterface);
QList <QDBusObjectPath> connections = dbIface->activeConnections();
-
foreach(QDBusObjectPath conpath, connections) {
- activeConnectionPaths << conpath.path();
-// qWarning() << __FUNCTION__ << conpath.path() << activeConnectionPaths.count();
-
- QNetworkManagerConnectionActive *activeConn;
- activeConn = new QNetworkManagerConnectionActive(conpath.path());
-
-// qWarning() << activeConn->connection().path() /*<< activeConn->specificObject().path() */<< activeConn->devices()[0].path();
-
- }
+ activeConnectionPaths << conpath.path();
+ }
}
QNetworkConfigurationPrivate * QNmWifiEngine::addAccessPoint( const QString &iPath, QDBusObjectPath path)
-{ //foreach accessPoint
- //qWarning() << Q_FUNC_INFO << iPath << path.path();
+{
- QNetworkManagerInterfaceDevice *devIface;
- devIface = new QNetworkManagerInterfaceDevice(iPath);
- QNetworkManagerInterfaceDeviceWireless *devWirelessIface;
- devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(iPath);
+ QScopedPointer<QNetworkManagerInterfaceDevice> devIface(new QNetworkManagerInterfaceDevice(iPath));
+ QScopedPointer<QNetworkManagerInterfaceDeviceWireless> devWirelessIface(new QNetworkManagerInterfaceDeviceWireless(iPath));
QString activeAPPath = devWirelessIface->activeAccessPoint().path();
- QNetworkManagerInterfaceAccessPoint *accessPointIface;
- accessPointIface = new QNetworkManagerInterfaceAccessPoint(path.path());
+ QScopedPointer<QNetworkManagerInterfaceAccessPoint> accessPointIface(new QNetworkManagerInterfaceAccessPoint(path.path()));
QString ident = accessPointIface->connectionInterface()->path();
quint32 nmState = devIface->state();
@@ -587,7 +401,6 @@ QNetworkConfigurationPrivate * QNmWifiEngine::addAccessPoint( const QString &iPa
QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
bool addIt = true;
- //qWarning() << availableAccessPoints.count() << ssid;
// if(availableAccessPoints.contains(ssid)) {
// addIt = false;
@@ -609,8 +422,6 @@ QNetworkConfigurationPrivate * QNmWifiEngine::addAccessPoint( const QString &iPa
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
cpPriv->serviceInterface = devIface->interface();
- //qWarning() <<__FUNCTION__ << ssid;
-
cpPriv->state = getAPState(nmState, knownSsids.contains(cpPriv->name));
if(activeAPPath == accessPointIface->connectionInterface()->path()) {
@@ -631,7 +442,6 @@ QNetworkConfigurationPrivate * QNmWifiEngine::addAccessPoint( const QString &iPa
QNetworkConfiguration::StateFlags QNmWifiEngine::getAPState(qint32 nmState, bool isKnown)
{
QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
-//qWarning() << nmState << knownSsids;
// this is the state of the wifi device interface
if(isKnown)
state = ( QNetworkConfiguration::Defined);
@@ -667,15 +477,12 @@ QNetworkConfigurationPrivate * QNmWifiEngine::addAccessPoint( const QString &iPa
QString QNmWifiEngine::getActiveConnectionPath(const QString &id)
{
- //qWarning() << Q_FUNC_INFO << id;
- QStringList connectionSettings = getConnectionPathForId(id);
- //qWarning() << Q_FUNC_INFO << id << connectionSettings.count();
- QNetworkManagerInterface * ifaceD;
- ifaceD = new QNetworkManagerInterface();
- QList<QDBusObjectPath> connections = ifaceD->activeConnections();
+ QStringList connectionSettings = getConnectionPathForId(id);
+ QNetworkManagerInterface ifaceD;
+ QList<QDBusObjectPath> connections = ifaceD.activeConnections();
+ QScopedPointer<QNetworkManagerConnectionActive> conDetailsD;
foreach(QDBusObjectPath path, connections) {
- QNetworkManagerConnectionActive *conDetailsD;
- conDetailsD = new QNetworkManagerConnectionActive( path.path());
+ conDetailsD.reset(new QNetworkManagerConnectionActive( path.path()));
if(conDetailsD->connection().path() == connectionSettings.at(1)
&& conDetailsD->serviceName() == connectionSettings.at(0))
return path.path();
@@ -685,7 +492,6 @@ QString QNmWifiEngine::getActiveConnectionPath(const QString &id)
QNetworkConfiguration::StateFlags QNmWifiEngine::getStateFlag(quint32 nmstate)
{
-// qWarning() << Q_FUNC_INFO << nmstate;
QNetworkConfiguration::StateFlags flag;
switch (nmstate) {
case NM_DEVICE_STATE_UNKNOWN:
@@ -718,8 +524,6 @@ QString QNmWifiEngine::getActiveConnectionPath(const QString &id)
void QNmWifiEngine::updateDeviceInterfaceState(const QString &/*path*/, quint32 nmState)
{
-// qWarning() << Q_FUNC_INFO << path << nmState;
-
if(nmState == NM_DEVICE_STATE_ACTIVATED
|| nmState == NM_DEVICE_STATE_DISCONNECTED
|| nmState == NM_DEVICE_STATE_UNAVAILABLE
@@ -730,7 +534,6 @@ void QNmWifiEngine::updateDeviceInterfaceState(const QString &/*path*/, quint32
OperationNotSupported,
DisconnectionError,
*/
-// qWarning() << Q_FUNC_INFO << ident;
QNetworkConfiguration::StateFlags state = (QNetworkConfiguration::Defined);
switch (nmState) {
case NM_DEVICE_STATE_UNKNOWN:
@@ -738,7 +541,6 @@ void QNmWifiEngine::updateDeviceInterfaceState(const QString &/*path*/, quint32
state = (QNetworkConfiguration::Undefined);
emit connectionError(activatingConnectionPath, ConnectError);
requestUpdate();
-// qWarning() << Q_FUNC_INFO;
break;
case NM_DEVICE_STATE_UNAVAILABLE:
state = (QNetworkConfiguration::Defined);
@@ -765,8 +567,7 @@ void QNmWifiEngine::updateDeviceInterfaceState(const QString &/*path*/, quint32
void QNmWifiEngine::addDevice(QDBusObjectPath path)
{
- //qWarning() << Q_FUNC_INFO << path.path();
- QNetworkManagerInterfaceDevice *devIface = new QNetworkManagerInterfaceDevice(path.path());
+ QNetworkManagerInterfaceDevice *devIface = new QNetworkManagerInterfaceDevice(path.path(), this);
devIface->setConnections();
connect(devIface,SIGNAL(stateChanged(const QString &, quint32)),
this, SLOT(updateDeviceInterfaceState(const QString&, quint32)));
@@ -778,7 +579,7 @@ void QNmWifiEngine::addDevice(QDBusObjectPath path)
case DEVICE_TYPE_802_3_ETHERNET:
{
QNetworkManagerInterfaceDeviceWired * devWiredIface;
- devWiredIface = new QNetworkManagerInterfaceDeviceWired(devIface->connectionInterface()->path());
+ devWiredIface = new QNetworkManagerInterfaceDeviceWired(devIface->connectionInterface()->path(), this);
devWiredIface->setConnections();
connect(devWiredIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)),
this,SLOT(cmpPropertiesChanged( const QString &, QMap<QString,QVariant>)));
@@ -788,7 +589,7 @@ void QNmWifiEngine::addDevice(QDBusObjectPath path)
case DEVICE_TYPE_802_11_WIRELESS:
{
QNetworkManagerInterfaceDeviceWireless *devWirelessIface;
- devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path());
+ devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path(), this);
devWirelessIface->setConnections();
connect(devWirelessIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)),
@@ -834,7 +635,6 @@ void QNmWifiEngine::cmpPropertiesChanged(const QString &path, QMap<QString,QVari
QMapIterator<QString, QVariant> i(map);
while (i.hasNext()) {
i.next();
-// qWarning() << Q_FUNC_INFO << path << i.key() << i.value().toUInt();
if( i.key() == "State") { //only applies to device interfaces
updateDeviceInterfaceState(path, i.value().toUInt());
}
@@ -848,8 +648,6 @@ void QNmWifiEngine::cmpPropertiesChanged(const QString &path, QMap<QString,QVari
void QNmWifiEngine::accessPointRemoved( const QString &aPath, QDBusObjectPath /*oPath*/)
{
- //qWarning() << Q_FUNC_INFO << aPath << oPath.path();
-
if(aPath.contains("devices")) {
requestUpdate();
}
@@ -857,33 +655,27 @@ void QNmWifiEngine::accessPointRemoved( const QString &aPath, QDBusObjectPath /*
void QNmWifiEngine::accessPointAdded( const QString &aPath, QDBusObjectPath oPath)
{
- //qWarning() << Q_FUNC_INFO << aPath << oPath.path();
-
- QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
- cpPriv = addAccessPoint( aPath, oPath);
+ /*QNetworkConfigurationPrivate* cpPriv;
+ cpPriv = addAccessPoint( aPath, oPath);*/
requestUpdate();
}
QNetworkConfiguration::StateFlags QNmWifiEngine::getStateForId(const QString &id)
{
- //qWarning() << Q_FUNC_INFO << id;
bool isAvailable = false;
QStringList conPath = getConnectionPathForId(id);
QString aconpath = getActiveConnectionPath(id);
- //qWarning() << Q_FUNC_INFO << id << aconpath;
-
if(!aconpath.isEmpty()) {
//active connection
- QNetworkManagerConnectionActive *aConn;
- aConn = new QNetworkManagerConnectionActive(aconpath);
+ QNetworkManagerConnectionActive aConn(aconpath);
- QList <QDBusObjectPath> devs = aConn->devices();
+ QList <QDBusObjectPath> devs = aConn.devices();
+ QScopedPointer<QNetworkManagerInterfaceDevice> ifaceDevice;
+ QScopedPointer<QNetworkManagerInterfaceDeviceWired> devWiredIface;
foreach(QDBusObjectPath dev, devs) {
- //qWarning() << "foreach" << dev.path();
- QNetworkManagerInterfaceDevice *ifaceDevice;
- ifaceDevice = new QNetworkManagerInterfaceDevice(dev.path());
+ ifaceDevice.reset(new QNetworkManagerInterfaceDevice(dev.path()));
if(ifaceDevice->deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
@@ -898,8 +690,7 @@ QNetworkConfiguration::StateFlags QNmWifiEngine::getStateForId(const QString &id
ifaceDevice->state() == NM_DEVICE_STATE_DISCONNECTED) {
isAvailable = true;
- QNetworkManagerInterfaceDeviceWired *devWiredIface;
- devWiredIface = new QNetworkManagerInterfaceDeviceWired(ifaceDevice->connectionInterface()->path());
+ devWiredIface.reset(new QNetworkManagerInterfaceDeviceWired(ifaceDevice->connectionInterface()->path()));
if(!devWiredIface->carrier())
return QNetworkConfiguration::Defined;
} //end eth
@@ -911,9 +702,8 @@ QNetworkConfiguration::StateFlags QNmWifiEngine::getStateForId(const QString &id
}
} else {
// not active
- //qWarning() << Q_FUNC_INFO << "Not active";
- QNetworkManagerSettingsConnection *sysIface;
- sysIface = new QNetworkManagerSettingsConnection(conPath.at(0),conPath.at(1));
+ QScopedPointer<QNetworkManagerSettingsConnection> sysIface;
+ sysIface.reset(new QNetworkManagerSettingsConnection(conPath.at(0),conPath.at(1)));
if(sysIface->isValid()) {
if(sysIface->getType() == DEVICE_TYPE_802_11_WIRELESS) {
QString ssid = sysIface->getSsid();
@@ -921,21 +711,16 @@ QNetworkConfiguration::StateFlags QNmWifiEngine::getStateForId(const QString &id
if(knownSsids.contains(ssid, Qt::CaseSensitive)) {
foreach(QString onessid, knownSsids) {
- // qWarning() << ssid << onessid;
if(onessid == ssid && availableAccessPoints.contains(ssid)) {
- // qWarning() <<ssid << "In known and available SSIDS";
ok = true;
break;
}
}
- }/* else {
- }*/
- if(ok) {
+ }
+ if(ok)
return getStateFlag(NM_DEVICE_STATE_DISCONNECTED);
- } else {
- // qWarning() << "NOT In known or available SSIDS";
+ else
return getStateFlag(NM_DEVICE_STATE_UNAVAILABLE);
- }
}
}
}
@@ -945,60 +730,57 @@ QNetworkConfiguration::StateFlags QNmWifiEngine::getStateForId(const QString &id
bool QNmWifiEngine::isAddressOfConnection(const QString &id, quint32 ipaddress)
{
-// qWarning() << Q_FUNC_INFO << id;
QStringList conPath = getConnectionPathForId(id);
QString aConPath = getActiveConnectionPath(id);
if(aConPath.isEmpty()) {
// not active
return false;
}
- QNetworkManagerConnectionActive *aConn;
- aConn = new QNetworkManagerConnectionActive(aConPath);
- QList<QDBusObjectPath> devices = aConn->devices();
- foreach(QDBusObjectPath device, devices) {
- QNetworkManagerInterfaceDevice *ifaceDevice;
- ifaceDevice = new QNetworkManagerInterfaceDevice(device.path());
- if(ifaceDevice->ip4Address() == ipaddress) {
- return true;
- }
+
+ QScopedPointer<QNetworkManagerConnectionActive> aConn;
+ aConn.reset(new QNetworkManagerConnectionActive(aConPath));
+ QScopedPointer<QNetworkManagerInterfaceDevice> ifaceDevice;
+ QList<QDBusObjectPath> devices = aConn->devices();
+ foreach(QDBusObjectPath device, devices) {
+ ifaceDevice.reset(new QNetworkManagerInterfaceDevice(device.path()));
+ if(ifaceDevice->ip4Address() == ipaddress) {
+ return true;
}
- return false;
+ }
+ return false;
}
QNetworkInterface QNmWifiEngine::getBestInterface( quint32 type, const QString &id)
{
// check active connections first.
- QStringList conIdPath = getConnectionPathForId(id);
-// qWarning() << Q_FUNC_INFO << id << conIdPath;
+ QStringList conIdPath = getConnectionPathForId(id);
QNetworkInterface interface;
- foreach(QString conpath, activeConnectionPaths) {
- QNetworkManagerConnectionActive *aConn;
- aConn = new QNetworkManagerConnectionActive(conpath);
+ QScopedPointer<QNetworkManagerConnectionActive> aConn;
+ foreach(QString conpath, activeConnectionPaths) {
+ aConn.reset(new QNetworkManagerConnectionActive(conpath));
if(aConn->connection().path() == conIdPath.at(1)
&& aConn->serviceName() == conIdPath.at(0)) {
QList <QDBusObjectPath> devs = aConn->devices();
- QNetworkManagerInterfaceDevice *ifaceDevice;
- ifaceDevice = new QNetworkManagerInterfaceDevice(devs[0].path()); //just take the first one
- interface = ifaceDevice->interface();
- return interface;
+ QNetworkManagerInterfaceDevice ifaceDevice(devs[0].path()); //just take the first one
+ return ifaceDevice.interface();
}
}
-//try guessing
+ //try guessing
QList<QDBusObjectPath> list = iface->getDevices();
+ QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
foreach(QDBusObjectPath path, list) {
- QNetworkManagerInterfaceDevice *devIface = new QNetworkManagerInterfaceDevice(path.path());
+ devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
if(devIface->deviceType() == type /*&& devIface->managed()*/) {
- interface = devIface->interface();
if(devIface->state() == NM_STATE_DISCONNECTED) {
- return interface;
+ return devIface->interface();
}
}
}
- return interface;
+ return QNetworkInterface();
}
quint64 QNmWifiEngine::receivedDataForId(const QString &id) const
@@ -1037,13 +819,11 @@ quint64 QNmWifiEngine::sentDataForId(const QString &id) const
void QNmWifiEngine::newConnection(QDBusObjectPath /*path*/)
{
- //qWarning() << Q_FUNC_INFO;
requestUpdate();
}
void QNmWifiEngine::settingsConnectionRemoved(const QString &/*path*/)
{
- //qWarning() << Q_FUNC_INFO;
requestUpdate();
}
@@ -1054,10 +834,9 @@ void QNmWifiEngine::slotActivationFinished(QDBusPendingCallWatcher *openCall)
qWarning() <<"Error" << reply.error().name() << reply.error().message()
<<activatingConnectionPath;
emit connectionError(activatingConnectionPath, ConnectError);
- } else {
+ } /*else {
QDBusObjectPath result = reply.value();
- //qWarning() << result.path();
- }
+ }*/
}
void QNmWifiEngine::scanForAccessPoints()
@@ -1065,22 +844,20 @@ void QNmWifiEngine::scanForAccessPoints()
availableAccessPoints.clear();
QList<QDBusObjectPath> list = iface->getDevices();
+ QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
+ QScopedPointer<QNetworkManagerInterfaceDeviceWireless> devWirelessIface;
+ QScopedPointer<QNetworkManagerInterfaceAccessPoint> accessPointIface;
foreach(QDBusObjectPath path, list) {
- QNetworkManagerInterfaceDevice *devIface;
- devIface = new QNetworkManagerInterfaceDevice(path.path());
+ devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
-// qWarning() << devIface->connectionInterface()->path();
-
- QNetworkManagerInterfaceDeviceWireless *devWirelessIface;
- devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path());
+ devWirelessIface.reset(new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path()));
////////////// AccessPoints
QList<QDBusObjectPath> apList = devWirelessIface->getAccessPoints();
foreach(QDBusObjectPath path, apList) {
- QNetworkManagerInterfaceAccessPoint *accessPointIface;
- accessPointIface = new QNetworkManagerInterfaceAccessPoint(path.path());
+ accessPointIface.reset(new QNetworkManagerInterfaceAccessPoint(path.path()));
QString ssid = accessPointIface->ssid();
availableAccessPoints.insert(ssid, path);
}
@@ -1109,19 +886,15 @@ QStringList QNmWifiEngine::getConnectionPathForId(const QString &uuid)
QStringList connectionServices;
connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
-//qWarning() << Q_FUNC_INFO;
+ QScopedPointer<QNetworkManagerSettings> settingsiface;
foreach (QString service, connectionServices) {
- QNetworkManagerSettings *settingsiface;
- settingsiface = new QNetworkManagerSettings(service);
+ settingsiface.reset(new QNetworkManagerSettings(service));
QList<QDBusObjectPath> list = settingsiface->listConnections();
+ QScopedPointer<QNetworkManagerSettingsConnection> sysIface;
foreach(QDBusObjectPath path, list) {
- QNetworkManagerSettingsConnection *sysIface;
- sysIface = new QNetworkManagerSettingsConnection(service, path.path());
-// qWarning() << uuid << sysIface->getUuid();
- if(sysIface->getUuid() == uuid) {
-// qWarning() <<__FUNCTION__ << service << sysIface->getId() << sysIface->connectionInterface()->path();
+ sysIface.reset(new QNetworkManagerSettingsConnection(service, path.path()));
+ if(sysIface->getUuid() == uuid)
return QStringList() << service << sysIface->connectionInterface()->path();
- }
}
}
return QStringList();
diff --git a/src/network/bearer/qnmwifiengine_unix_p.h b/src/network/bearer/qnmwifiengine_unix_p.h
index 1287800..470c8d3 100644
--- a/src/network/bearer/qnmwifiengine_unix_p.h
+++ b/src/network/bearer/qnmwifiengine_unix_p.h
@@ -112,11 +112,10 @@ private:
QStringList devicePaths;
- void getActiveConnectionsPaths();
- void getKnownSsids();
+ void updateActiveConnectionsPaths();
+ void updateKnownSsids();
void accessPointConnections();
void knownConnections();
- void findConnections();
QString deviceConnectionPath(const QString &mac);
QList<QNetworkConfigurationPrivate *> foundConfigurations;
@@ -145,8 +144,6 @@ private slots:
Q_SIGNALS:
void configurationChanged(const QNetworkConfiguration& config);
- void updateAccessPointState(const QString &, quint32);
-// void slotActivationFinished(QDBusPendingCallWatcher*);
private slots:
void accessPointAdded( const QString &aPath, QDBusObjectPath oPath);
diff --git a/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro b/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro
index 0b2ed1a..bdd4926 100644
--- a/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro
+++ b/tests/auto/qnetworkconfigmanager/qnetworkconfigmanager.pro
@@ -8,7 +8,8 @@ QT = core network
INCLUDEPATH += ../../../src/bearer
include(../../../common.pri)
-qtAddLibrary(QtBearer)
+CONFIG += mobility
+MOBILITY = bearer
symbian {
TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
diff --git a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp b/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp
index 796677d..6ab0e6f 100644
--- a/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp
+++ b/tests/auto/qnetworkconfigmanager/tst_qnetworkconfigmanager.cpp
@@ -44,7 +44,7 @@
#include "qnetworkconfiguration.h"
#include "qnetworkconfigmanager.h"
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -66,7 +66,7 @@ private slots:
void configurationFromIdentifier();
private:
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -78,7 +78,7 @@ private:
void tst_QNetworkConfigurationManager::initTestCase()
{
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -152,7 +152,7 @@ void tst_QNetworkConfigurationManager::initTestCase()
void tst_QNetworkConfigurationManager::cleanupTestCase()
{
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
iapconf->clear();
delete iapconf;
iapconf2->clear();
diff --git a/tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro b/tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro
index 61e4097..c5a08b3 100644
--- a/tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro
+++ b/tests/auto/qnetworkconfiguration/qnetworkconfiguration.pro
@@ -8,7 +8,8 @@ QT = core network
INCLUDEPATH += ../../../src/bearer
include(../../../common.pri)
-qtAddLibrary(QtBearer)
+CONFIG += mobility
+MOBILITY = bearer
symbian {
TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
diff --git a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
index cbb13f3..e929a61 100644
--- a/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
+++ b/tests/auto/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
@@ -44,7 +44,7 @@
#include "qnetworkconfiguration.h"
#include "qnetworkconfigmanager.h"
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -65,7 +65,7 @@ private slots:
void isRoamingAvailable();
private:
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -77,7 +77,7 @@ private:
void tst_QNetworkConfiguration::initTestCase()
{
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -150,7 +150,7 @@ void tst_QNetworkConfiguration::initTestCase()
void tst_QNetworkConfiguration::cleanupTestCase()
{
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
iapconf->clear();
delete iapconf;
iapconf2->clear();
diff --git a/tests/auto/qnetworksession/lackey/lackey.pro b/tests/auto/qnetworksession/lackey/lackey.pro
index 4cb8555..b8a006b 100644
--- a/tests/auto/qnetworksession/lackey/lackey.pro
+++ b/tests/auto/qnetworksession/lackey/lackey.pro
@@ -9,4 +9,5 @@ CONFIG+= testcase
include(../../../../common.pri)
-qtAddLibrary(QtBearer)
+CONFIG += mobility
+MOBILITY = bearer
diff --git a/tests/auto/qnetworksession/lackey/main.cpp b/tests/auto/qnetworksession/lackey/main.cpp
index 53f6f4f..f3a7a07 100644
--- a/tests/auto/qnetworksession/lackey/main.cpp
+++ b/tests/auto/qnetworksession/lackey/main.cpp
@@ -107,7 +107,7 @@ int main(int argc, char** argv)
session->open();
session->waitForOpened();
- } while (!(session && session->isActive()));
+ } while (!(session && session->isOpen()));
qDebug() << "loop done";
diff --git a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
index cbd4c8f..86b3e46 100644
--- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
+++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.cpp
@@ -46,7 +46,7 @@
#include <qnetworkconfigmanager.h>
#include <qnetworksession.h>
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
#include <stdio.h>
#include <iapconf.h>
#endif
@@ -84,7 +84,7 @@ private:
uint inProcessSessionManagementCount;
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
Maemo::IAPConf *iapconf;
Maemo::IAPConf *iapconf2;
Maemo::IAPConf *gprsiap;
@@ -100,7 +100,7 @@ void tst_QNetworkSession::initTestCase()
qRegisterMetaType<QNetworkSession::SessionError>("QNetworkSession::SessionError");
qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration");
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
iapconf = new Maemo::IAPConf("007");
iapconf->setValue("ipv4_type", "AUTO");
iapconf->setValue("wlan_wepkey1", "connt");
@@ -186,7 +186,7 @@ void tst_QNetworkSession::cleanupTestCase()
"tests in inProcessSessionManagement()");
}
-#ifdef MAEMO
+#ifdef Q_WS_MAEMO_6
iapconf->clear();
delete iapconf;
iapconf2->clear();
@@ -212,7 +212,7 @@ void tst_QNetworkSession::cleanupTestCase()
void tst_QNetworkSession::invalidSession()
{
QNetworkSession session(QNetworkConfiguration(), 0);
- QVERIFY(!session.isActive());
+ QVERIFY(!session.isOpen());
QVERIFY(session.state() == QNetworkSession::Invalid);
}
@@ -236,7 +236,7 @@ void tst_QNetworkSession::sessionProperties()
QVERIFY(session.configuration() == configuration);
- QStringList validBearerNames = QStringList() << QString()
+ QStringList validBearerNames = QStringList() << QLatin1String("Unknown")
<< QLatin1String("Ethernet")
<< QLatin1String("WLAN")
<< QLatin1String("2G")
@@ -246,10 +246,21 @@ void tst_QNetworkSession::sessionProperties()
<< QLatin1String("Bluetooth")
<< QLatin1String("WiMAX");
- if (!configuration.isValid())
- QVERIFY(session.bearerName().isEmpty());
- else
- QVERIFY(validBearerNames.contains(session.bearerName()));
+ if (!configuration.isValid()) {
+ QVERIFY(configuration.bearerName().isEmpty());
+ } else {
+ switch (configuration.type())
+ {
+ case QNetworkConfiguration::ServiceNetwork:
+ case QNetworkConfiguration::UserChoice:
+ default:
+ QVERIFY(configuration.bearerName().isEmpty());
+ break;
+ case QNetworkConfiguration::InternetAccessPoint:
+ QVERIFY(validBearerNames.contains(configuration.bearerName()));
+ break;
+ }
+ }
// QNetworkSession::interface() should return an invalid interface unless
// session is in the connected state.
@@ -302,9 +313,9 @@ void tst_QNetworkSession::userChoiceSession()
QVERIFY(session.configuration() == configuration);
- QVERIFY(!session.isActive());
+ QVERIFY(!session.isOpen());
- QVERIFY(session.sessionProperty("ActiveConfigurationIdentifier").toString().isEmpty());
+ QVERIFY(session.sessionProperty("ActiveConfiguration").toString().isEmpty());
// The remaining tests require the session to be not NotAvailable.
@@ -324,7 +335,7 @@ void tst_QNetworkSession::userChoiceSession()
session.waitForOpened();
- if (session.isActive())
+ if (session.isOpen())
QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty());
if (!errorSpy.isEmpty()) {
QNetworkSession::SessionError error =
@@ -359,7 +370,7 @@ void tst_QNetworkSession::userChoiceSession()
QVERIFY(session.interface().isValid());
const QString userChoiceIdentifier =
- session.sessionProperty("UserChoiceConfigurationIdentifier").toString();
+ session.sessionProperty("UserChoiceConfiguration").toString();
QVERIFY(!userChoiceIdentifier.isEmpty());
QVERIFY(userChoiceIdentifier != configuration.identifier());
@@ -371,12 +382,12 @@ void tst_QNetworkSession::userChoiceSession()
QVERIFY(userChoiceConfiguration.type() != QNetworkConfiguration::UserChoice);
const QString testIdentifier("abc");
- //resetting UserChoiceConfigurationIdentifier is ignored (read only property)
- session.setSessionProperty("UserChoiceConfigurationIdentifier", testIdentifier);
- QVERIFY(session.sessionProperty("UserChoiceConfigurationIdentifier").toString() != testIdentifier);
+ //resetting UserChoiceConfiguration is ignored (read only property)
+ session.setSessionProperty("UserChoiceConfiguration", testIdentifier);
+ QVERIFY(session.sessionProperty("UserChoiceConfiguration").toString() != testIdentifier);
const QString activeIdentifier =
- session.sessionProperty("ActiveConfigurationIdentifier").toString();
+ session.sessionProperty("ActiveConfiguration").toString();
QVERIFY(!activeIdentifier.isEmpty());
QVERIFY(activeIdentifier != configuration.identifier());
@@ -387,9 +398,9 @@ void tst_QNetworkSession::userChoiceSession()
QVERIFY(activeConfiguration.isValid());
QVERIFY(activeConfiguration.type() == QNetworkConfiguration::InternetAccessPoint);
- //resetting ActiveConfigurationIdentifier is ignored (read only property)
- session.setSessionProperty("ActiveConfigurationIdentifier", testIdentifier);
- QVERIFY(session.sessionProperty("ActiveConfigurationIdentifier").toString() != testIdentifier);
+ //resetting ActiveConfiguration is ignored (read only property)
+ session.setSessionProperty("ActiveConfiguration", testIdentifier);
+ QVERIFY(session.sessionProperty("ActiveConfiguration").toString() != testIdentifier);
if (userChoiceConfiguration.type() == QNetworkConfiguration::InternetAccessPoint) {
QVERIFY(userChoiceConfiguration == activeConfiguration);
@@ -427,7 +438,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
// Test initial state of the session.
{
QVERIFY(session.configuration() == configuration);
- QVERIFY(!session.isActive());
+ QVERIFY(!session.isOpen());
// session may be invalid if configuration is removed between when
// sessionOpenCloseStop_data() is called and here.
QVERIFY((configuration.isValid() && (session.state() != QNetworkSession::Invalid)) ||
@@ -453,7 +464,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
session.waitForOpened();
- if (session.isActive())
+ if (session.isOpen())
QVERIFY(!sessionOpenedSpy.isEmpty() || !errorSpy.isEmpty());
if (!errorSpy.isEmpty()) {
QNetworkSession::SessionError error =
@@ -517,7 +528,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
// Test opening a second session.
{
QVERIFY(session2.configuration() == configuration);
- QVERIFY(!session2.isActive());
+ QVERIFY(!session2.isOpen());
QVERIFY(session2.state() == QNetworkSession::Connected);
QVERIFY(session.error() == QNetworkSession::UnknownSessionError);
@@ -525,8 +536,8 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QTRY_VERIFY(!sessionOpenedSpy2.isEmpty() || !errorSpy2.isEmpty());
- QVERIFY(session.isActive());
- QVERIFY(session2.isActive());
+ QVERIFY(session.isOpen());
+ QVERIFY(session2.isOpen());
QVERIFY(session.state() == QNetworkSession::Connected);
QVERIFY(session2.state() == QNetworkSession::Connected);
QVERIFY(session.interface().isValid());
@@ -550,7 +561,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QTRY_VERIFY(!sessionClosedSpy2.isEmpty() || !errorSpy2.isEmpty());
- QVERIFY(!session2.isActive());
+ QVERIFY(!session2.isOpen());
if (!errorSpy2.isEmpty()) {
QVERIFY(!errorSpy.isEmpty());
@@ -632,7 +643,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
}
}
if (roamedSuccessfully) {
- QString configId = session.sessionProperty("ActiveConfigurationIdentifier").toString();
+ QString configId = session.sessionProperty("ActiveConfiguration").toString();
QNetworkConfiguration config = manager.configurationFromIdentifier(configId);
QNetworkSession session3(config);
QSignalSpy errorSpy3(&session3, SIGNAL(error(QNetworkSession::SessionError)));
@@ -641,7 +652,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
session3.open();
session3.waitForOpened();
- if (session.isActive())
+ if (session.isOpen())
QVERIFY(!sessionOpenedSpy3.isEmpty() || !errorSpy3.isEmpty());
session.stop();
@@ -682,9 +693,9 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QVERIFY(!sessionClosedSpy2.isEmpty());
#ifndef Q_CC_NOKIAX86
- QVERIFY(!session.isActive());
+ QVERIFY(!session.isOpen());
#endif
- QVERIFY(!session2.isActive());
+ QVERIFY(!session2.isOpen());
} else {
// Test closing the second session.
{
@@ -698,8 +709,8 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QVERIFY(sessionClosedSpy.isEmpty());
- QVERIFY(session.isActive());
- QVERIFY(!session2.isActive());
+ QVERIFY(session.isOpen());
+ QVERIFY(!session2.isOpen());
QVERIFY(session.state() == QNetworkSession::Connected);
QVERIFY(session2.state() == QNetworkSession::Connected);
QVERIFY(session.interface().isValid());
@@ -724,7 +735,7 @@ void tst_QNetworkSession::sessionOpenCloseStop()
QTRY_VERIFY(!sessionClosedSpy.isEmpty() || !errorSpy.isEmpty());
- QVERIFY(!session.isActive());
+ QVERIFY(!session.isOpen());
if (expectStateChange)
QTRY_VERIFY(!stateChangedSpy.isEmpty() || !errorSpy.isEmpty());
@@ -781,12 +792,15 @@ void tst_QNetworkSession::outOfProcessSession()
QList<QNetworkConfiguration> before = manager.allConfigurations(QNetworkConfiguration::Active);
- QSignalSpy spy(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)));
-
+ QSignalSpy spy(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)));
+
// Cannot read/write to processes on WinCE or Symbian.
// Easiest alternative is to use sockets for IPC.
QLocalServer oopServer;
+ // First remove possible earlier listening address which would cause listen to fail
+ // (e.g. previously abruptly ended unit test might cause this)
+ QLocalServer::removeServer("tst_qnetworksession");
oopServer.listen("tst_qnetworksession");
QProcess lackey;
diff --git a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
index 1410601..ccc405e 100644
--- a/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
+++ b/tests/auto/qnetworksession/tst_qnetworksession/tst_qnetworksession.pro
@@ -8,7 +8,8 @@ QT = core network
INCLUDEPATH += ../../../../src/bearer
include(../../../../common.pri)
-qtAddLibrary(QtBearer)
+CONFIG += mobility
+MOBILITY = bearer
wince* {
LACKEY.sources = $$OUTPUT_DIR/build/tests/bin/qnetworksessionlackey.exe
diff --git a/tests/manual/bearerex/bearerex.cpp b/tests/manual/bearerex/bearerex.cpp
index 68590cc..f62d8d2 100644
--- a/tests/manual/bearerex/bearerex.cpp
+++ b/tests/manual/bearerex/bearerex.cpp
@@ -69,10 +69,6 @@ void BearerEx::createMenus()
menuBar()->addAction(act1);
connect(act1, SIGNAL(triggered()), this, SLOT(on_showDetailsButton_clicked()));
- m_openAction = new QAction(tr("Open Session"), this);
- menuBar()->addAction(m_openAction);
- connect(m_openAction, SIGNAL(triggered()), this, SLOT(on_openSessionButton_clicked()));
-
QAction* exitAct = new QAction(tr("Exit"), this);
menuBar()->addAction(exitAct);
connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
@@ -290,7 +286,7 @@ SessionTab::SessionTab(QNetworkConfiguration* apNetworkConfiguration,
} else if (apNetworkConfiguration->type() == QNetworkConfiguration::ServiceNetwork) {
snapLineEdit->setText(apNetworkConfiguration->name()+" ("+apNetworkConfiguration->identifier()+")");
}
- bearerLineEdit->setText(m_NetworkSession->bearerName());
+ bearerLineEdit->setText(apNetworkConfiguration->bearerName());
sentRecDataLineEdit->setText(QString::number(m_NetworkSession->bytesWritten())+
QString(" / ")+
QString::number(m_NetworkSession->bytesReceived()));
@@ -341,7 +337,7 @@ void SessionTab::on_sendRequestButton_clicked()
void SessionTab::on_openSessionButton_clicked()
{
m_NetworkSession->open();
- if (m_NetworkSession->isActive()) {
+ if (m_NetworkSession->isOpen()) {
newState(m_NetworkSession->state());
}
}
@@ -349,7 +345,7 @@ void SessionTab::on_openSessionButton_clicked()
void SessionTab::on_closeSessionButton_clicked()
{
m_NetworkSession->close();
- if (!m_NetworkSession->isActive()) {
+ if (!m_NetworkSession->isOpen()) {
newState(m_NetworkSession->state());
}
}
@@ -418,7 +414,7 @@ void SessionTab::opened()
listItem->setText(QString("S")+QString::number(m_index)+QString(" - ")+QString("Opened"));
m_eventListWidget->addItem(listItem);
- QVariant identifier = m_NetworkSession->property("ActiveConfigurationIdentifier");
+ QVariant identifier = m_NetworkSession->property("ActiveConfiguration");
if (!identifier.isNull()) {
QString configId = identifier.toString();
QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
@@ -428,7 +424,7 @@ void SessionTab::opened()
}
if (m_NetworkSession->configuration().type() == QNetworkConfiguration::UserChoice) {
- QVariant identifier = m_NetworkSession->property("UserChoiceConfigurationIdentifier");
+ QVariant identifier = m_NetworkSession->property("UserChoiceConfiguration");
if (!identifier.isNull()) {
QString configId = identifier.toString();
QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
@@ -490,22 +486,21 @@ void SessionTab::stateChanged(QNetworkSession::State state)
void SessionTab::newState(QNetworkSession::State state)
{
- if (state == QNetworkSession::Connected) {
- QVariant identifier = m_NetworkSession->property("ActiveConfigurationIdentifier");
- if (!identifier.isNull()) {
- QString configId = identifier.toString();
- QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
- if (config.isValid()) {
- iapLineEdit->setText(config.name()+" ("+config.identifier()+")");
- }
+ QVariant identifier = m_NetworkSession->property("ActiveConfiguration");
+ if (state == QNetworkSession::Connected && !identifier.isNull()) {
+ QString configId = identifier.toString();
+ QNetworkConfiguration config = m_ConfigManager->configurationFromIdentifier(configId);
+ if (config.isValid()) {
+ iapLineEdit->setText(config.name()+" ("+config.identifier()+")");
+ bearerLineEdit->setText(config.bearerName());
}
+ } else {
+ bearerLineEdit->setText(m_NetworkSession->configuration().bearerName());
}
- bearerLineEdit->setText(m_NetworkSession->bearerName());
-
QString active;
- if (m_NetworkSession->isActive()) {
- active = " (A)";
+ if (m_NetworkSession->isOpen()) {
+ active = " (O)";
}
stateLineEdit->setText(stateString(state)+active);
}
diff --git a/tests/manual/bearerex/bearerex.h b/tests/manual/bearerex/bearerex.h
index f18180e..b8a2393 100644
--- a/tests/manual/bearerex/bearerex.h
+++ b/tests/manual/bearerex/bearerex.h
@@ -51,7 +51,10 @@
#include "qnetworksession.h"
#include "xqlistwidget.h"
+QT_BEGIN_NAMESPACE
class QHttp;
+QT_END_NAMESPACE
+
class SessionTab;
QTM_USE_NAMESPACE
diff --git a/tests/manual/bearerex/bearerex.pro b/tests/manual/bearerex/bearerex.pro
index a870eb1..e480d43 100644
--- a/tests/manual/bearerex/bearerex.pro
+++ b/tests/manual/bearerex/bearerex.pro
@@ -24,11 +24,6 @@ SOURCES += bearerex.cpp \
main.cpp \
xqlistwidget.cpp
-symbian: {
- bearerex.sources = Qtbearer.dll
- bearerex.path = /sys/bin
- DEPLOYMENT += bearerex
-
- TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
-}
-qtAddLibrary(QtBearer)
+CONFIG += mobility
+MOBILITY = bearer
+symbian:TARGET.CAPABILITY = NetworkServices NetworkControl ReadUserData
diff --git a/tests/manual/networkmanager/networkmanager.pro b/tests/manual/networkmanager/networkmanager.pro
index 31b2af1..7ff370a 100644
--- a/tests/manual/networkmanager/networkmanager.pro
+++ b/tests/manual/networkmanager/networkmanager.pro
@@ -12,7 +12,8 @@ requires(contains(QT_CONFIG,dbus))
INCLUDEPATH += ../../src/bearer
include(../../common.pri)
-qtAddLibrary(QtBearer)
+CONFIG += mobility
+MOBILITY = bearer
#MOC_DIR = .moc
#OBJECTS_DIR = .obj
diff --git a/tests/manual/networkmanager/nmview.cpp b/tests/manual/networkmanager/nmview.cpp
index ca9d907..fde5cae 100644
--- a/tests/manual/networkmanager/nmview.cpp
+++ b/tests/manual/networkmanager/nmview.cpp
@@ -188,8 +188,6 @@ void NMView::getActiveConnections()
void NMView::update()
{
-// if(sess)
-// qWarning() << __FUNCTION__<< sess->bytesWritten() << sess->bearerName();
// QNetworkManagerInterface *dbIface;
// dbIface = new QNetworkManagerInterface;
// QList <QDBusObjectPath> connections = dbIface->activeConnections();
diff --git a/tests/manual/networkmanager/nmview.h b/tests/manual/networkmanager/nmview.h
index 641385e..e15aacd 100644
--- a/tests/manual/networkmanager/nmview.h
+++ b/tests/manual/networkmanager/nmview.h
@@ -49,9 +49,11 @@
QTM_USE_NAMESPACE
+QT_BEGIN_NAMESPACE
class QListWidget;
class QTreeWidget;
class QTreeWidgetItem;
+QT_END_NAMESPACE
class NMView : public QDialog, private Ui::Dialog
{