summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
Diffstat (limited to 'src/network')
-rw-r--r--src/network/bearer/bearer.pri83
-rw-r--r--src/network/bearer/bearer.pro162
-rw-r--r--src/network/bearer/qbearerplugin.cpp (renamed from src/network/bearer/qnativewifiengine_win_p.h)60
-rw-r--r--src/network/bearer/qbearerplugin.h (renamed from src/network/bearer/qgenericengine_p.h)64
-rw-r--r--src/network/bearer/qcorewlanengine_mac.mm454
-rw-r--r--src/network/bearer/qcorewlanengine_mac_p.h101
-rw-r--r--src/network/bearer/qgenericengine.cpp259
-rw-r--r--src/network/bearer/qnativewifiengine_win.cpp729
-rw-r--r--src/network/bearer/qnetworkconfigmanager.cpp81
-rw-r--r--src/network/bearer/qnetworkconfigmanager.h10
-rw-r--r--src/network/bearer/qnetworkconfigmanager_maemo.cpp6
-rw-r--r--src/network/bearer/qnetworkconfigmanager_maemo_p.h6
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.cpp440
-rw-r--r--src/network/bearer/qnetworkconfigmanager_p.h95
-rw-r--r--src/network/bearer/qnetworkconfigmanager_s60_p.cpp6
-rw-r--r--src/network/bearer/qnetworkconfigmanager_s60_p.h6
-rw-r--r--src/network/bearer/qnetworkconfiguration.cpp6
-rw-r--r--src/network/bearer/qnetworkconfiguration.h11
-rw-r--r--src/network/bearer/qnetworkconfiguration_maemo_p.h6
-rw-r--r--src/network/bearer/qnetworkconfiguration_p.h20
-rw-r--r--src/network/bearer/qnetworkconfiguration_s60_p.cpp6
-rw-r--r--src/network/bearer/qnetworkconfiguration_s60_p.h6
-rw-r--r--src/network/bearer/qnetworkmanagerservice_p.cpp1047
-rw-r--r--src/network/bearer/qnetworkmanagerservice_p.h400
-rw-r--r--src/network/bearer/qnetworksession.cpp15
-rw-r--r--src/network/bearer/qnetworksession.h10
-rw-r--r--src/network/bearer/qnetworksession_maemo.cpp6
-rw-r--r--src/network/bearer/qnetworksession_maemo_p.h6
-rw-r--r--src/network/bearer/qnetworksession_p.cpp98
-rw-r--r--src/network/bearer/qnetworksession_p.h18
-rw-r--r--src/network/bearer/qnetworksession_s60_p.cpp6
-rw-r--r--src/network/bearer/qnetworksession_s60_p.h6
-rw-r--r--src/network/bearer/qnetworksessionengine.cpp17
-rw-r--r--src/network/bearer/qnetworksessionengine_p.h37
-rw-r--r--src/network/bearer/qnetworksessionengine_win_p.h145
-rw-r--r--src/network/bearer/qnlaengine_win.cpp600
-rw-r--r--src/network/bearer/qnlaengine_win_p.h104
-rw-r--r--src/network/bearer/qnmdbushelper.cpp117
-rw-r--r--src/network/bearer/qnmdbushelper_p.h90
-rw-r--r--src/network/bearer/qnmwifiengine_unix.cpp906
-rw-r--r--src/network/bearer/qnmwifiengine_unix_p.h161
-rw-r--r--src/network/network.pro1
42 files changed, 492 insertions, 5915 deletions
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri
new file mode 100644
index 0000000..4f6c549
--- /dev/null
+++ b/src/network/bearer/bearer.pri
@@ -0,0 +1,83 @@
+# Qt network bearer management module
+
+#DEFINES += BEARER_MANAGEMENT_DEBUG
+
+HEADERS += bearer/qnetworkconfiguration.h \
+ bearer/qnetworksession.h \
+ bearer/qnetworkconfigmanager.h \
+ bearer/qbearerplugin.h
+
+SOURCES += bearer/qnetworksession.cpp \
+ bearer/qnetworkconfigmanager.cpp \
+ bearer/qnetworkconfiguration.cpp \
+ bearer/qbearerplugin.cpp
+
+symbian {
+ exists($${EPOCROOT}epoc32/release/winscw/udeb/cmmanager.lib)| \
+ exists($${EPOCROOT}epoc32/release/armv5/lib/cmmanager.lib) {
+ message("Building with SNAP support")
+ DEFINES += SNAP_FUNCTIONALITY_AVAILABLE
+ LIBS += -lcmmanager
+ } else {
+ message("Building without SNAP support")
+ LIBS += -lapengine
+ }
+
+ INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+ HEADERS += bearer/qnetworkconfigmanager_s60_p.h \
+ bearer/qnetworkconfiguration_s60_p.h \
+ bearer/qnetworksession_s60_p.h
+ SOURCES += bearer/qnetworkconfigmanager_s60_p.cpp \
+ bearer/qnetworkconfiguration_s60_p.cpp \
+ bearer/qnetworksession_s60_p.cpp
+
+ LIBS += -lcommdb \
+ -lapsettingshandlerui \
+ -lconnmon \
+ -lcentralrepository \
+ -lesock \
+ -linsock \
+ -lecom \
+ -lefsrv \
+ -lnetmeta
+} else:maemo {
+ QT += dbus
+ CONFIG += link_pkgconfig
+
+ exists(../debug) {
+ message("Enabling debug messages.")
+ DEFINES += BEARER_MANAGEMENT_DEBUG
+ }
+
+ HEADERS += bearer/qnetworksession_maemo_p.h \
+ bearer/qnetworkconfigmanager_maemo_p.h \
+ bearer/qnetworkconfiguration_maemo_p.h
+
+ SOURCES += bearer/qnetworkconfigmanager_maemo.cpp \
+ bearer/qnetworksession_maemo.cpp
+
+ documentation.path = $$QT_MOBILITY_PREFIX/doc
+ documentation.files = doc/html
+
+ PKGCONFIG += glib-2.0 dbus-glib-1 gconf-2.0 osso-ic conninet
+
+ CONFIG += create_pc create_prl
+ QMAKE_PKGCONFIG_REQUIRES = glib-2.0 dbus-glib-1 gconf-2.0 osso-ic conninet
+ pkgconfig.path = $$QT_MOBILITY_LIB/pkgconfig
+ pkgconfig.files = QtBearer.pc
+
+ INSTALLS += pkgconfig documentation
+} else {
+ HEADERS += bearer/qnetworkconfigmanager_p.h \
+ bearer/qnetworkconfiguration_p.h \
+ bearer/qnetworksession_p.h \
+ bearer/qnetworksessionengine_p.h
+
+ SOURCES += bearer/qnetworkconfigmanager_p.cpp \
+ bearer/qnetworksession_p.cpp \
+ bearer/qnetworksessionengine.cpp
+
+ contains(QT_CONFIG, networkmanager):DEFINES += BACKEND_NM
+}
+
diff --git a/src/network/bearer/bearer.pro b/src/network/bearer/bearer.pro
deleted file mode 100644
index ce39db6..0000000
--- a/src/network/bearer/bearer.pro
+++ /dev/null
@@ -1,162 +0,0 @@
-# Qt bearer management library
-TEMPLATE = lib
-TARGET = QtBearer
-
-QT += network
-include (../../common.pri)
-
-DEFINES += QT_BUILD_BEARER_LIB QT_MAKEDLL
-
-#DEFINES += BEARER_MANAGEMENT_DEBUG
-
-PUBLIC_HEADERS += qnetworkconfiguration.h \
- qnetworksession.h \
- qnetworkconfigmanager.h
-
-HEADERS += $$PUBLIC_HEADERS
-SOURCES += qnetworksession.cpp \
- qnetworkconfigmanager.cpp \
- qnetworkconfiguration.cpp
-
-symbian: {
- contains(snap_enabled, yes) {
- message("Building with SNAP support")
- DEFINES += SNAP_FUNCTIONALITY_AVAILABLE=1
- LIBS += -lcmmanager
- } else {
- message("Building without SNAP support")
- LIBS += -lapengine
- }
-
- INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
-
- HEADERS += qnetworkconfigmanager_s60_p.h \
- qnetworkconfiguration_s60_p.h \
- qnetworksession_s60_p.h
- SOURCES += qnetworkconfigmanager_s60_p.cpp \
- qnetworkconfiguration_s60_p.cpp \
- qnetworksession_s60_p.cpp
-
- LIBS += -lcommdb \
- -lapsettingshandlerui \
- -lconnmon \
- -lcentralrepository \
- -lesock \
- -linsock \
- -lecom \
- -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)"
- }
-
- QtBearerManagement.sources = QtBearer.dll
- QtBearerManagement.path = /sys/bin
- DEPLOYMENT += QtBearerManagement
-} else {
- maemo6 {
- QT += dbus
- CONFIG += link_pkgconfig
-
- exists(../debug) {
- message("Enabling debug messages.")
- DEFINES += BEARER_MANAGEMENT_DEBUG
- }
-
- HEADERS += qnetworksession_maemo_p.h \
- qnetworkconfigmanager_maemo_p.h \
- qnetworkconfiguration_maemo_p.h
-
- SOURCES += qnetworkconfigmanager_maemo.cpp \
- qnetworksession_maemo.cpp
-
- documentation.path = $$QT_MOBILITY_PREFIX/doc
- documentation.files = doc/html
-
- PKGCONFIG += glib-2.0 dbus-glib-1 gconf-2.0 osso-ic conninet
-
- CONFIG += create_pc create_prl
- QMAKE_PKGCONFIG_REQUIRES = glib-2.0 dbus-glib-1 gconf-2.0 osso-ic conninet
- pkgconfig.path = $$QT_MOBILITY_LIB/pkgconfig
- pkgconfig.files = QtBearer.pc
-
- INSTALLS += pkgconfig documentation
-
- } else {
-
- DEFINES += BEARER_ENGINE
-
- HEADERS += qnetworkconfigmanager_p.h \
- qnetworkconfiguration_p.h \
- qnetworksession_p.h \
- qnetworksessionengine_p.h \
- qgenericengine_p.h
-
- SOURCES += qnetworkconfigmanager_p.cpp \
- qnetworksession_p.cpp \
- qnetworksessionengine.cpp \
- qgenericengine.cpp
-
- unix:!mac:contains(networkmanager_enabled, yes) {
- contains(QT_CONFIG,dbus) {
- DEFINES += BACKEND_NM
- QT += dbus
-
- HEADERS += qnmdbushelper_p.h \
- qnetworkmanagerservice_p.h \
- qnmwifiengine_unix_p.h
-
- SOURCES += qnmdbushelper.cpp \
- qnetworkmanagerservice_p.cpp \
- qnmwifiengine_unix.cpp
- } else {
- message("NetworkManager backend requires Qt DBus support")
- }
- }
-
- win32: {
- HEADERS += qnlaengine_win_p.h \
- qnetworksessionengine_win_p.h
-
- !wince*:HEADERS += qnativewifiengine_win_p.h
-
- SOURCES += qnlaengine_win.cpp
-
- !wince*:SOURCES += qnativewifiengine_win.cpp
-
- !wince*:LIBS += -lWs2_32
- wince*:LIBS += -lWs2
- }
- }
- macx: {
- HEADERS += qcorewlanengine_mac_p.h
- SOURCES+= qcorewlanengine_mac.mm
- LIBS += -framework Foundation -framework SystemConfiguration
-
- contains(corewlan_enabled, yes) {
- isEmpty(QMAKE_MAC_SDK) {
- SDK6="yes"
- } else {
- contains(QMAKE_MAC_SDK, "/Developer/SDKs/MacOSX10.6.sdk") {
- SDK6="yes"
- }
- }
-
- !isEmpty(SDK6) {
- LIBS += -framework CoreWLAN
- DEFINES += MAC_SDK_10_6
- }
- }
-
-
- }
-}
-
-include(../../features/deploy.pri)
diff --git a/src/network/bearer/qnativewifiengine_win_p.h b/src/network/bearer/qbearerplugin.cpp
index e911746..7b81b13 100644
--- a/src/network/bearer/qnativewifiengine_win_p.h
+++ b/src/network/bearer/qbearerplugin.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,57 +39,19 @@
**
****************************************************************************/
-#ifndef QNATIVEWIFIENGINE_P_H
-#define QNATIVEWIFIENGINE_P_H
+#include "qbearerplugin.h"
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
+#include <QtCore/qdebug.h>
-#include "qnetworksessionengine_p.h"
+QT_BEGIN_NAMESPACE
-#include <QtCore/qtimer.h>
-
-QTM_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-
-class QNativeWifiEngine : public QNetworkSessionEngine
+QBearerEnginePlugin::QBearerEnginePlugin(QObject *parent)
+: QObject(parent)
{
- Q_OBJECT
-
-public:
- QNativeWifiEngine(QObject *parent = 0);
- ~QNativeWifiEngine();
-
- QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0);
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
-
- //QString bearerName(const QString &id);
-
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
+}
- void requestUpdate();
-
- inline void emitConfigurationsChanged() { emit configurationsChanged(); }
-
- static QNativeWifiEngine *instance();
-
-private:
- QTimer pollTimer;
-
- Qt::HANDLE handle;
-};
-
-QTM_END_NAMESPACE
+QBearerEnginePlugin::~QBearerEnginePlugin()
+{
+}
-#endif
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qgenericengine_p.h b/src/network/bearer/qbearerplugin.h
index 5c08aa2..036d712 100644
--- a/src/network/bearer/qgenericengine_p.h
+++ b/src/network/bearer/qbearerplugin.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -39,56 +39,44 @@
**
****************************************************************************/
-#ifndef QGENERICENGINE_P_H
-#define QGENERICENGINE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
+#ifndef QBEARERPLUGIN_H
+#define QBEARERPLUGIN_H
#include "qnetworksessionengine_p.h"
-#include <QMap>
-#include <QTimer>
-
-QTM_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
-class QGenericEngine : public QNetworkSessionEngine
-{
- Q_OBJECT
+QT_BEGIN_HEADER
-public:
- QGenericEngine(QObject *parent = 0);
- ~QGenericEngine();
+QT_BEGIN_NAMESPACE
- QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0);
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
+QT_MODULE(Network)
- //QString bearerName(const QString &id);
+struct Q_NETWORK_EXPORT QBearerEngineFactoryInterface : public QFactoryInterface
+{
+ virtual QBearerEngine *create(const QString &key = QString()) const = 0;
+};
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
+#define QBearerEngineFactoryInterface_iid "com.trolltech.Qt.QBearerEngineFactoryInterface"
+Q_DECLARE_INTERFACE(QBearerEngineFactoryInterface, QBearerEngineFactoryInterface_iid)
- void requestUpdate();
+class Q_NETWORK_EXPORT QBearerEnginePlugin : public QObject, public QBearerEngineFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QBearerEngineFactoryInterface:QFactoryInterface)
- static QGenericEngine *instance();
+public:
+ explicit QBearerEnginePlugin(QObject *parent = 0);
+ virtual ~QBearerEnginePlugin();
-private:
- QMap<uint, QString> configurationInterface;
- QTimer pollTimer;
+ virtual QStringList keys() const = 0;
+ virtual QBearerEngine *create(const QString &key = QString()) const = 0;
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
+
+QT_END_HEADER
#endif
diff --git a/src/network/bearer/qcorewlanengine_mac.mm b/src/network/bearer/qcorewlanengine_mac.mm
deleted file mode 100644
index 41ec79a..0000000
--- a/src/network/bearer/qcorewlanengine_mac.mm
+++ /dev/null
@@ -1,454 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcorewlanengine_mac_p.h"
-#include "qnetworkconfiguration_p.h"
-
-#include <QtCore/qthread.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qstringlist.h>
-
-#include <QtCore/qdebug.h>
-
-#if defined(MAC_SDK_10_6) //not much functionality without this
-#include <CoreWLAN/CoreWLAN.h>
-#include <CoreWLAN/CWInterface.h>
-#include <CoreWLAN/CWNetwork.h>
-#include <CoreWLAN/CWNetwork.h>
-#endif
-
-#include <Foundation/NSEnumerator.h>
-#include <Foundation/NSKeyValueObserving.h>
-#include <Foundation/NSAutoreleasePool.h>
-
-#include <SystemConfiguration/SCNetworkConfiguration.h>
-QMap <QString, QString> networkInterfaces;
-
-QTM_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QCoreWlanEngine, coreWlanEngine)
-
-inline QString cfstringRefToQstring(CFStringRef cfStringRef) {
-// return QString([cfStringRef UTF8String]);
- QString retVal;
- CFIndex maxLength = 2 * CFStringGetLength(cfStringRef) + 1/*zero term*/; // max UTF8
- char *cstring = new char[maxLength];
- if (CFStringGetCString(CFStringRef(cfStringRef), cstring, maxLength, kCFStringEncodingUTF8)) {
- retVal = QString::fromUtf8(cstring);
- }
- delete cstring;
- return retVal;
-}
-
-inline CFStringRef qstringToCFStringRef(const QString &string)
-{
- return CFStringCreateWithCharacters(0, reinterpret_cast<const UniChar *>(string.unicode()),
- string.length());
-}
-
-inline NSString *qstringToNSString(const QString &qstr)
-{ return [reinterpret_cast<const NSString *>(qstringToCFStringRef(qstr)) autorelease]; }
-
-inline QString nsstringToQString(const NSString *nsstr)
-{ return cfstringRefToQstring(reinterpret_cast<const CFStringRef>(nsstr)); }
-
-inline QStringList nsarrayToQStringList(void *nsarray)
-{
- QStringList result;
- NSArray *array = static_cast<NSArray *>(nsarray);
- for (NSUInteger i=0; i<[array count]; ++i)
- result << nsstringToQString([array objectAtIndex:i]);
- return result;
-}
-
-static QString qGetInterfaceType(const QString &interfaceString)
-{
- return networkInterfaces.value(interfaceString, QLatin1String("Unknown"));
-}
-
-QCoreWlanEngine::QCoreWlanEngine(QObject *parent)
-: QNetworkSessionEngine(parent)
-{
- getAllScInterfaces();
- connect(&pollTimer, SIGNAL(timeout()), this, SIGNAL(configurationsChanged()));
- pollTimer.setInterval(10000);
-}
-
-QCoreWlanEngine::~QCoreWlanEngine()
-{
- QNetworkConfigurationPrivate* cpPriv = 0;
- foundConfigurations.clear();
- while(!foundConfigurations.isEmpty()) {
- cpPriv = foundConfigurations.takeFirst();
- delete cpPriv;
- }
-}
-
-QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::getConfigurations(bool *ok)
-{
- if (ok)
- *ok = true;
- 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();
- cpPriv = fetchedConfigurations.at(i);
- config->name = cpPriv->name;
- config->isValid = cpPriv->isValid;
- config->id = cpPriv->id;
-
- 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();
- const QString humanReadableName = interface.humanReadableName();
- cpPriv->name = humanReadableName.isEmpty() ? interface.name() : humanReadableName;
- cpPriv->isValid = true;
-
- if (interface.index())
- identifier = interface.index();
- else
- identifier = qHash(interface.hardwareAddress());
-
- cpPriv->id = QString::number(identifier);
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
- cpPriv->state = QNetworkConfiguration::Undefined;
-
- if (interface.flags() & QNetworkInterface::IsRunning) {
- cpPriv->state = QNetworkConfiguration::Defined;
- cpPriv->internet = true;
- }
- if ( !interface.addressEntries().isEmpty()) {
- cpPriv->state |= QNetworkConfiguration::Active;
- cpPriv->internet = true;
- }
- configurationInterface[identifier] = interface.name();
- cpPriv->bearer = interface.name().isEmpty()? QLatin1String("Unknown") : qGetInterfaceType(interface.name());
- foundConfigurations.append(cpPriv);
- }
-
- pollTimer.start();
- return foundConfigurations;
-}
-
-QString QCoreWlanEngine::getInterfaceFromId(const QString &id)
-{
- return configurationInterface.value(id.toUInt());
-}
-
-bool QCoreWlanEngine::hasIdentifier(const QString &id)
-{
- return configurationInterface.contains(id.toUInt());
-}
-
-void QCoreWlanEngine::connectToId(const QString &id)
-{
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- QString interfaceString = getInterfaceFromId(id);
-
- if(networkInterfaces.value(interfaceString) == "WLAN") {
-#if defined(MAC_SDK_10_6)
- CWInterface *wifiInterface = [CWInterface interfaceWithName: qstringToNSString(interfaceString)];
- CWConfiguration *userConfig = [ wifiInterface configuration];
-
- NSSet *remNets = [userConfig rememberedNetworks]; //CWWirelessProfile
-
- 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])) {
- user8021XProfile = nil;
- user8021XProfile = [ wProfile user8021XProfile];
-
- err = nil;
- params = [NSMutableDictionary dictionaryWithCapacity:0];
-
- if(user8021XProfile) {
- [params setValue: user8021XProfile forKey:kCWAssocKey8021XProfile];
- } else {
- [params setValue: [wProfile passphrase] forKey: kCWAssocKeyPassphrase];
- }
-
- parametersDict = nil;
- apArray = [NSMutableArray arrayWithArray:[wifiInterface scanForNetworksWithParameters:parametersDict error:&err]];
-
- if(!err) {
-
- for(uint row=0; row < [apArray count]; 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;
- }
- }
- }
- }
- }
- index++;
- }
- [apNetwork release];
-
- emit connectionError(id, InterfaceLookupError);
-#endif
- } else {
- // not wifi
- }
- emit connectionError(id, OperationNotSupported);
- [autoreleasepool release];
-}
-
-void QCoreWlanEngine::disconnectFromId(const QString &id)
-{
- QString interfaceString = getInterfaceFromId(id);
- if(networkInterfaces.value(getInterfaceFromId(id)) == "WLAN") { //wifi only for now
-#if defined(MAC_SDK_10_6)
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
- CWInterface *wifiInterface = [CWInterface interfaceWithName: qstringToNSString(interfaceString)];
- [wifiInterface disassociate];
- if([[wifiInterface interfaceState]intValue] != kCWInterfaceStateInactive) {
- emit connectionError(id, DisconnectionError);
- }
- [autoreleasepool release];
- return;
-#endif
- } else {
-
- }
- emit connectionError(id, OperationNotSupported);
-}
-
-void QCoreWlanEngine::requestUpdate()
-{
- getAllScInterfaces();
- emit configurationsChanged();
-}
-
-QCoreWlanEngine *QCoreWlanEngine::instance()
-{
- return coreWlanEngine();
-}
-
-QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::scanForSsids(const QString &interfaceName)
-{
- QList<QNetworkConfigurationPrivate *> foundConfigs;
-#if defined(MAC_SDK_10_6)
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
-
- CWInterface *currentInterface = [CWInterface interfaceWithName:qstringToNSString(interfaceName)];
- NSError *err = nil;
- NSDictionary *parametersDict = nil;
- NSArray* apArray = [NSMutableArray arrayWithArray:[currentInterface scanForNetworksWithParameters:parametersDict error:&err]];
-
- CWNetwork *apNetwork;
- if(!err) {
- for(uint row=0; row < [apArray count]; 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(interfaceName);
-
- if( [currentInterface.interfaceState intValue] == kCWInterfaceStateRunning) {
- QString interfaceSsidString = nsstringToQString( [currentInterface ssid]);
- if( cpPriv->name == interfaceSsidString) {
- cpPriv->state |= QNetworkConfiguration::Active;
- }
- } else {
- if(isKnownSsid(cpPriv->serviceInterface.name(), networkSsid)) {
- cpPriv->state = QNetworkConfiguration::Discovered;
- } else {
- cpPriv->state = QNetworkConfiguration::Defined;
- }
- }
- if(!cpPriv->state) {
- cpPriv->state = QNetworkConfiguration::Undefined;
- }
- if([[apNetwork securityMode ] intValue]== kCWSecurityModeOpen)
- cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
- else
- cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
- foundConfigs.append(cpPriv);
- [looppool release];
- }
- } else {
- qWarning() << "ERROR scanning for ssids" << nsstringToQString([err localizedDescription])
- <<nsstringToQString([err domain]);
- }
-
- [autoreleasepool drain];
-#else
- Q_UNUSED(interfaceName);
-#endif
- return foundConfigs;
-}
-
-bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
-{
-#if defined(MAC_SDK_10_6)
- CWInterface *defaultInterface = [CWInterface interfaceWithName: qstringToNSString(wifiDeviceName)];
- if([defaultInterface power])
- return true;
-#else
- Q_UNUSED(wifiDeviceName);
-#endif
- return false;
-}
-
-bool QCoreWlanEngine::isKnownSsid(const QString &interfaceName, const QString &ssid)
-{
-#if defined(MAC_SDK_10_6)
- CWInterface *wifiInterface = [CWInterface interfaceWithName: qstringToNSString(interfaceName)];
- CWConfiguration *userConfig = [wifiInterface configuration];
- NSSet *remNets = [userConfig rememberedNetworks];
- for (CWWirelessProfile *wProfile in remNets) {
- if(ssid == nsstringToQString([wProfile ssid]))
- return true;
- }
-#else
- Q_UNUSED(interfaceName);
- Q_UNUSED(ssid);
-#endif
- return false;
-}
-
-QList<QNetworkConfigurationPrivate *> QCoreWlanEngine::getWlanProfiles(const QString &interfaceName)
-{
- Q_UNUSED(interfaceName)
-#if defined(MAC_SDK_10_6)
-// for( CW8021XProfile *each8021XProfile in [CW8021XProfile allUser8021XProfiles] ) {
-// qWarning() << "Profile name" << nsstringToQString([each8021XProfile ssid]);
-// }
-
-#endif
- return QList<QNetworkConfigurationPrivate *> ();
-}
-
-bool QCoreWlanEngine::getAllScInterfaces()
-{
- networkInterfaces.clear();
- NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
-
- CFArrayRef interfaces = SCNetworkInterfaceCopyAll();
- if (interfaces != NULL) {
- CFIndex interfaceCount;
- CFIndex interfaceIndex;
- interfaceCount = CFArrayGetCount(interfaces);
- for (interfaceIndex = 0; interfaceIndex < interfaceCount; interfaceIndex++) {
- NSAutoreleasePool *looppool = [[NSAutoreleasePool alloc] init];
-
- CFStringRef bsdName;
- CFTypeRef thisInterface = CFArrayGetValueAtIndex(interfaces, interfaceIndex);
- bsdName = SCNetworkInterfaceGetBSDName((SCNetworkInterfaceRef)thisInterface);
- QString interfaceName = cfstringRefToQstring(bsdName);
- QString typeStr;
- CFStringRef type = SCNetworkInterfaceGetInterfaceType((SCNetworkInterfaceRef)thisInterface);
- if ( CFEqual(type, kSCNetworkInterfaceTypeIEEE80211)) {
- typeStr = "WLAN";
-// } else if (CFEqual(type, kSCNetworkInterfaceTypeBluetooth)) {
-// typeStr = "Bluetooth";
- } else if(CFEqual(type, kSCNetworkInterfaceTypeEthernet)) {
- typeStr = "Ethernet";
- } else if(CFEqual(type, kSCNetworkInterfaceTypeFireWire)) {
- typeStr = "Ethernet"; //ok a bit fudged
- }
- if(!networkInterfaces.contains(interfaceName) && !typeStr.isEmpty()) {
- networkInterfaces.insert(interfaceName,typeStr);
- }
- [looppool release];
- }
- }
- CFRelease(interfaces);
-
- [autoreleasepool drain];
- return true;
-}
-
-#include "moc_qcorewlanengine_mac_p.cpp"
-
-QTM_END_NAMESPACE
-
diff --git a/src/network/bearer/qcorewlanengine_mac_p.h b/src/network/bearer/qcorewlanengine_mac_p.h
deleted file mode 100644
index 6ad093a..0000000
--- a/src/network/bearer/qcorewlanengine_mac_p.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOREWLANENGINE_P_H
-#define QCOREWLANENGINE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qnetworksessionengine_p.h"
-#include <QMap>
-#include <QTimer>
-QTM_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-
-class QCoreWlanEngine : public QNetworkSessionEngine
-{
- Q_OBJECT
-
-public:
- QCoreWlanEngine(QObject *parent = 0);
- ~QCoreWlanEngine();
-
- QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0);
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
-
- QString bearerName(const QString &id);
-
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
-
- void requestUpdate();
-
- static QCoreWlanEngine *instance();
- static bool getAllScInterfaces();
-
-private:
- bool isWifiReady(const QString &dev);
- QMap<uint, QString> configurationInterface;
- QTimer pollTimer;
- QList<QNetworkConfigurationPrivate *> scanForSsids(const QString &interfaceName);
-
- QList<QNetworkConfigurationPrivate *> getWlanProfiles(const QString &interfaceName);
-
- bool isKnownSsid(const QString &interfaceName, const QString &ssid);
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
-};
-
-QTM_END_NAMESPACE
-
-#endif
-
diff --git a/src/network/bearer/qgenericengine.cpp b/src/network/bearer/qgenericengine.cpp
deleted file mode 100644
index 10cea0c..0000000
--- a/src/network/bearer/qgenericengine.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgenericengine_p.h"
-#include "qnetworkconfiguration_p.h"
-
-#include <QtCore/qthread.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qstringlist.h>
-
-#include <QtCore/qdebug.h>
-
-#ifdef Q_OS_WIN
-#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)
-
-static QString qGetInterfaceType(const QString &interface)
-{
-#ifdef Q_OS_WIN32
- unsigned long oid;
- DWORD bytesWritten;
-
- NDIS_MEDIUM medium;
- NDIS_PHYSICAL_MEDIUM physicalMedium;
-
- HANDLE handle = CreateFile((TCHAR *)QString("\\\\.\\%1").arg(interface).utf16(), 0,
- FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
- if (handle == INVALID_HANDLE_VALUE)
- return QLatin1String("Unknown");
-
- oid = OID_GEN_MEDIA_SUPPORTED;
- bytesWritten = 0;
- bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
- &medium, sizeof(medium), &bytesWritten, 0);
- if (!result) {
- CloseHandle(handle);
- return QLatin1String("Unknown");
- }
-
- oid = OID_GEN_PHYSICAL_MEDIUM;
- bytesWritten = 0;
- result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
- &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0);
- if (!result) {
- CloseHandle(handle);
-
- if (medium == NdisMedium802_3)
- return QLatin1String("Ethernet");
- else
- return QLatin1String("Unknown");
- }
-
- CloseHandle(handle);
-
- if (medium == NdisMedium802_3) {
- switch (physicalMedium) {
- case NdisPhysicalMediumWirelessLan:
- return QLatin1String("WLAN");
- case NdisPhysicalMediumBluetooth:
- return QLatin1String("Bluetooth");
- case NdisPhysicalMediumWiMax:
- return QLatin1String("WiMAX");
- default:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "Physical Medium" << physicalMedium;
-#endif
- return QLatin1String("Ethernet");
- }
- }
-
-#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 QLatin1String("Unknown");
-}
-
-QGenericEngine::QGenericEngine(QObject *parent)
-: QNetworkSessionEngine(parent)
-{
- connect(&pollTimer, SIGNAL(timeout()), this, SIGNAL(configurationsChanged()));
- pollTimer.setInterval(10000);
-}
-
-QGenericEngine::~QGenericEngine()
-{
-}
-
-QList<QNetworkConfigurationPrivate *> QGenericEngine::getConfigurations(bool *ok)
-{
- if (ok)
- *ok = true;
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
- // Immediately after connecting with a wireless access point
- // QNetworkInterface::allInterfaces() will sometimes return an empty list. Calling it again a
- // second time results in a non-empty list. If we loose interfaces we will end up removing
- // network configurations which will break current sessions.
- QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
- if (interfaces.isEmpty())
- interfaces = QNetworkInterface::allInterfaces();
-
- // create configuration for each interface
- while (!interfaces.isEmpty()) {
- QNetworkInterface interface = interfaces.takeFirst();
-
- if (!interface.isValid())
- continue;
-
- // ignore loopback interface
- if (interface.flags() & QNetworkInterface::IsLoopBack)
- continue;
-
- // ignore WLAN interface handled in seperate engine
- if (qGetInterfaceType(interface.name()) == "WLAN")
- continue;
-
- QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
- const QString humanReadableName = interface.humanReadableName();
- cpPriv->name = humanReadableName.isEmpty() ? interface.name() : humanReadableName;
- cpPriv->isValid = true;
-
- uint identifier;
- if (interface.index())
- identifier = qHash(QLatin1String("NLA:") + QString::number(interface.index()));
- else
- identifier = qHash(QLatin1String("NLA:") + interface.hardwareAddress());
-
- 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;
-
- configurationInterface[identifier] = interface.name();
-
- foundConfigurations.append(cpPriv);
- }
-
- pollTimer.start();
-
- return foundConfigurations;
-}
-
-QString QGenericEngine::getInterfaceFromId(const QString &id)
-{
- return configurationInterface.value(id.toUInt());
-}
-
-bool QGenericEngine::hasIdentifier(const QString &id)
-{
- return configurationInterface.contains(id.toUInt());
-}
-
-/*QString QGenericEngine::bearerName(const QString &id)
-{
- QString interface = getInterfaceFromId(id);
-
- if (interface.isEmpty())
- return QLatin1String("Unknown");
-
- return qGetInterfaceType(interface);
-}*/
-
-void QGenericEngine::connectToId(const QString &id)
-{
- emit connectionError(id, OperationNotSupported);
-}
-
-void QGenericEngine::disconnectFromId(const QString &id)
-{
- emit connectionError(id, OperationNotSupported);
-}
-
-void QGenericEngine::requestUpdate()
-{
- emit configurationsChanged();
-}
-
-QGenericEngine *QGenericEngine::instance()
-{
- return genericEngine();
-}
-
-#include "moc_qgenericengine_p.cpp"
-QTM_END_NAMESPACE
-
diff --git a/src/network/bearer/qnativewifiengine_win.cpp b/src/network/bearer/qnativewifiengine_win.cpp
deleted file mode 100644
index 008a9cf..0000000
--- a/src/network/bearer/qnativewifiengine_win.cpp
+++ /dev/null
@@ -1,729 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qnativewifiengine_win_p.h"
-#include "qnetworkconfiguration_p.h"
-
-#include <QtCore/qmutex.h>
-#include <QtCore/private/qmutexpool_p.h>
-#include <QtCore/qlibrary.h>
-#include <QtCore/qstringlist.h>
-
-#include <QtCore/qdebug.h>
-
-#include <wtypes.h>
-#undef interface
-
-QTM_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QNativeWifiEngine, nativeWifiEngine)
-
-#define WLAN_MAX_NAME_LENGTH 256
-#define WLAN_MAX_PHY_TYPE_NUMBER 8
-#define WLAN_NOTIFICATION_SOURCE_ALL 0x0000ffff
-#define WLAN_AVAILABLE_NETWORK_CONNECTED 1
-#define WLAN_AVAILABLE_NETWORK_HAS_PROFILE 2
-#define DOT11_SSID_MAX_LENGTH 32
-
-struct WLAN_NOTIFICATION_DATA {
- DWORD NotificationSource;
- DWORD NotificationCode;
- GUID InterfaceGuid;
- DWORD dwDataSize;
- PVOID pData;
-};
-
-enum WLAN_INTERFACE_STATE {
- wlan_interface_state_not_ready = 0,
- wlan_interface_state_connected,
- wlan_interface_state_ad_hoc_network_formed,
- wlan_interface_state_disconnecting,
- wlan_interface_state_disconnected,
- wlan_interface_state_associating,
- wlan_interface_state_discovering,
- wlan_interface_state_authenticating
-};
-
-struct WLAN_INTERFACE_INFO {
- GUID InterfaceGuid;
- WCHAR strInterfaceDescription[WLAN_MAX_NAME_LENGTH];
- WLAN_INTERFACE_STATE isState;
-};
-
-struct WLAN_INTERFACE_INFO_LIST {
- DWORD dwNumberOfItems;
- DWORD dwIndex;
- WLAN_INTERFACE_INFO InterfaceInfo[1];
-};
-
-struct DOT11_SSID {
- ULONG uSSIDLength;
- UCHAR ucSSID[DOT11_SSID_MAX_LENGTH];
-};
-
-struct NDIS_OBJECT_HEADER {
- UCHAR Type;
- UCHAR Revision;
- USHORT Size;
-};
-
-typedef UCHAR DOT11_MAC_ADDRESS[6];
-struct DOT11_BSSID_LIST {
- NDIS_OBJECT_HEADER Header;
- ULONG uNumberOfEntries;
- ULONG uTotalNumOfEntries;
- DOT11_MAC_ADDRESS BSSIDs[1];
-};
-
-enum DOT11_BSS_TYPE {
- dot11_BSS_type_infrastructure = 1,
- dot11_BSS_type_independent = 2,
- dot11_BSS_type_any = 3
-};
-
-enum DOT11_PHY_TYPE {
- dot11_phy_type_unknown = 0,
- dot11_phy_type_any = dot11_phy_type_unknown,
- dot11_phy_type_fhss = 1,
- dot11_phy_type_dsss = 2,
- dot11_phy_type_irbaseband = 3,
- dot11_phy_type_ofdm = 4,
- dot11_phy_type_hrdsss = 5,
- dot11_phy_type_erp = 6,
- dot11_phy_type_ht = 7,
- dot11_phy_type_IHV_start = 0x80000000,
- dot11_phy_type_IHV_end = 0xffffffff
-};
-
-enum DOT11_AUTH_ALGORITHM {
- DOT11_AUTH_ALGO_80211_OPEN = 1,
- DOT11_AUTH_ALGO_80211_SHARED_KEY = 2,
- DOT11_AUTH_ALGO_WPA = 3,
- DOT11_AUTH_ALGO_WPA_PSK = 4,
- DOT11_AUTH_ALGO_WPA_NONE = 5,
- DOT11_AUTH_ALGO_RSNA = 6,
- DOT11_AUTH_ALGO_RSNA_PSK = 7,
- DOT11_AUTH_ALGO_IHV_START = 0x80000000,
- DOT11_AUTH_ALGO_IHV_END = 0xffffffff
-};
-
-enum DOT11_CIPHER_ALGORITHM {
- DOT11_CIPHER_ALGO_NONE = 0x00,
- DOT11_CIPHER_ALGO_WEP40 = 0x01,
- DOT11_CIPHER_ALGO_TKIP = 0x02,
- DOT11_CIPHER_ALGO_CCMP = 0x04,
- DOT11_CIPHER_ALGO_WEP104 = 0x05,
- DOT11_CIPHER_ALGO_WPA_USE_GROUP = 0x100,
- DOT11_CIPHER_ALGO_RSN_USE_GROUP = 0x100,
- DOT11_CIPHER_ALGO_WEP = 0x101,
- DOT11_CIPHER_ALGO_IHV_START = 0x80000000,
- DOT11_CIPHER_ALGO_IHV_END = 0xffffffff
-};
-
-struct WLAN_AVAILABLE_NETWORK {
- WCHAR strProfileName[WLAN_MAX_NAME_LENGTH];
- DOT11_SSID dot11Ssid;
- DOT11_BSS_TYPE dot11BssType;
- ULONG uNumberOfBssids;
- BOOL bNetworkConnectable;
- DWORD wlanNotConnectableReason;
- ULONG uNumberOfPhyTypes;
- DOT11_PHY_TYPE dot11PhyTypes[WLAN_MAX_PHY_TYPE_NUMBER];
- BOOL bMorePhyTypes;
- ULONG wlanSignalQuality;
- BOOL bSecurityEnabled;
- DOT11_AUTH_ALGORITHM dot11DefaultAuthAlgorithm;
- DOT11_CIPHER_ALGORITHM dot11DefaultCipherAlgorithm;
- DWORD dwFlags;
- DWORD dwReserved;
-};
-
-struct WLAN_AVAILABLE_NETWORK_LIST {
- DWORD dwNumberOfItems;
- DWORD dwIndex;
- WLAN_AVAILABLE_NETWORK Network[1];
-};
-
-enum WLAN_INTF_OPCODE {
- wlan_intf_opcode_autoconf_start = 0x000000000,
- wlan_intf_opcode_autoconf_enabled,
- wlan_intf_opcode_background_scan_enabled,
- wlan_intf_opcode_media_streaming_mode,
- wlan_intf_opcode_radio_state,
- wlan_intf_opcode_bss_type,
- wlan_intf_opcode_interface_state,
- wlan_intf_opcode_current_connection,
- wlan_intf_opcode_channel_number,
- wlan_intf_opcode_supported_infrastructure_auth_cipher_pairs,
- wlan_intf_opcode_supported_adhoc_auth_cipher_pairs,
- wlan_intf_opcode_supported_country_or_region_string_list,
- wlan_intf_opcode_current_operation_mode,
- wlan_intf_opcode_supported_safe_mode,
- wlan_intf_opcode_certified_safe_mode,
- wlan_intf_opcode_autoconf_end = 0x0fffffff,
- wlan_intf_opcode_msm_start = 0x10000100,
- wlan_intf_opcode_statistics,
- wlan_intf_opcode_rssi,
- wlan_intf_opcode_msm_end = 0x1fffffff,
- wlan_intf_opcode_security_start = 0x20010000,
- wlan_intf_opcode_security_end = 0x2fffffff,
- wlan_intf_opcode_ihv_start = 0x30000000,
- wlan_intf_opcode_ihv_end = 0x3fffffff
-};
-
-enum WLAN_OPCODE_VALUE_TYPE {
- wlan_opcode_value_type_query_only = 0,
- wlan_opcode_value_type_set_by_group_policy,
- wlan_opcode_value_type_set_by_user,
- wlan_opcode_value_type_invalid
-};
-
-enum WLAN_CONNECTION_MODE {
- wlan_connection_mode_profile = 0,
- wlan_connection_mode_temporary_profile,
- wlan_connection_mode_discovery_secure,
- wlan_connection_mode_discovery_unsecure,
- wlan_connection_mode_auto,
- wlan_connection_mode_invalid
-};
-
-struct WLAN_CONNECTION_PARAMETERS {
- WLAN_CONNECTION_MODE wlanConnectionMode;
- LPCWSTR strProfile;
- DOT11_SSID *pDot11Ssid;
- DOT11_BSSID_LIST *pDesiredBssidList;
- DOT11_BSS_TYPE dot11BssType;
- DWORD dwFlags;
-};
-
-struct WLAN_RAW_DATA {
- DWORD dwDataSize;
- BYTE DataBlob[1];
-};
-
-enum WLAN_NOTIFICATION_ACM {
- wlan_notification_acm_start = 0,
- wlan_notification_acm_autoconf_enabled,
- wlan_notification_acm_autoconf_disabled,
- wlan_notification_acm_background_scan_enabled,
- wlan_notification_acm_background_scan_disabled,
- wlan_notification_acm_bss_type_change,
- wlan_notification_acm_power_setting_change,
- wlan_notification_acm_scan_complete,
- wlan_notification_acm_scan_fail,
- wlan_notification_acm_connection_start,
- wlan_notification_acm_connection_complete,
- wlan_notification_acm_connection_attempt_fail,
- wlan_notification_acm_filter_list_change,
- wlan_notification_acm_interface_arrival,
- wlan_notification_acm_interface_removal,
- wlan_notification_acm_profile_change,
- wlan_notification_acm_profile_name_change,
- wlan_notification_acm_profiles_exhausted,
- wlan_notification_acm_network_not_available,
- wlan_notification_acm_network_available,
- wlan_notification_acm_disconnecting,
- wlan_notification_acm_disconnected,
- wlan_notification_acm_adhoc_network_state_change,
- wlan_notification_acm_end
-};
-
-struct WLAN_ASSOCIATION_ATTRIBUTES {
- DOT11_SSID dot11Ssid;
- DOT11_BSS_TYPE dot11BssType;
- DOT11_MAC_ADDRESS dot11Bssid;
- DOT11_PHY_TYPE dot11PhyType;
- ULONG uDot11PhyIndex;
- ULONG wlanSignalQuality;
- ULONG ulRxRate;
- ULONG ulTxRate;
-};
-
-struct WLAN_SECURITY_ATTRIBUTES {
- BOOL bSecurityEnabled;
- BOOL bOneXEnabled;
- DOT11_AUTH_ALGORITHM dot11AuthAlgorithm;
- DOT11_CIPHER_ALGORITHM dot11CipherAlgorithm;
-};
-
-struct WLAN_CONNECTION_ATTRIBUTES {
- WLAN_INTERFACE_STATE isState;
- WLAN_CONNECTION_MODE wlanConnectionMode;
- WCHAR strProfileName[WLAN_MAX_NAME_LENGTH];
- WLAN_ASSOCIATION_ATTRIBUTES wlanAssociationAttributes;
- WLAN_SECURITY_ATTRIBUTES wlanSecurityAttributes;
-};
-
-typedef void (WINAPI *WLAN_NOTIFICATION_CALLBACK)(WLAN_NOTIFICATION_DATA *, PVOID);
-
-typedef DWORD (WINAPI *WlanOpenHandleProto)
- (DWORD dwClientVersion, PVOID pReserved, PDWORD pdwNegotiatedVersion, PHANDLE phClientHandle);
-typedef DWORD (WINAPI *WlanRegisterNotificationProto)
- (HANDLE hClientHandle, DWORD dwNotifSource, BOOL bIgnoreDuplicate,
- WLAN_NOTIFICATION_CALLBACK funcCallback, PVOID pCallbackContext,
- PVOID pReserved, PDWORD pdwPrevNotifSource);
-typedef DWORD (WINAPI *WlanEnumInterfacesProto)
- (HANDLE hClientHandle, PVOID pReserved, WLAN_INTERFACE_INFO_LIST **ppInterfaceList);
-typedef DWORD (WINAPI *WlanGetAvailableNetworkListProto)
- (HANDLE hClientHandle, const GUID* pInterfaceGuid, DWORD dwFlags, PVOID pReserved,
- WLAN_AVAILABLE_NETWORK_LIST **ppAvailableNetworkList);
-typedef DWORD (WINAPI *WlanQueryInterfaceProto)
- (HANDLE hClientHandle, const GUID *pInterfaceGuid, WLAN_INTF_OPCODE OpCode, PVOID pReserved,
- PDWORD pdwDataSize, PVOID *ppData, WLAN_OPCODE_VALUE_TYPE *pWlanOpcodeValueType);
-typedef DWORD (WINAPI *WlanConnectProto)
- (HANDLE hClientHandle, const GUID *pInterfaceGuid,
- const WLAN_CONNECTION_PARAMETERS *pConnectionParameters, PVOID pReserved);
-typedef DWORD (WINAPI *WlanDisconnectProto)
- (HANDLE hClientHandle, const GUID *pInterfaceGuid, PVOID pReserved);
-typedef DWORD (WINAPI *WlanScanProto)
- (HANDLE hClientHandle, const GUID *pInterfaceGuid, const DOT11_SSID *pDot11Ssid,
- const WLAN_RAW_DATA *pIeData, PVOID pReserved);
-typedef VOID (WINAPI *WlanFreeMemoryProto)(PVOID pMemory);
-typedef DWORD (WINAPI *WlanCloseHandleProto)(HANDLE hClientHandle, PVOID pReserved);
-
-static WlanOpenHandleProto local_WlanOpenHandle = 0;
-static WlanRegisterNotificationProto local_WlanRegisterNotification = 0;
-static WlanEnumInterfacesProto local_WlanEnumInterfaces = 0;
-static WlanGetAvailableNetworkListProto local_WlanGetAvailableNetworkList = 0;
-static WlanQueryInterfaceProto local_WlanQueryInterface = 0;
-static WlanConnectProto local_WlanConnect = 0;
-static WlanDisconnectProto local_WlanDisconnect = 0;
-static WlanScanProto local_WlanScan = 0;
-static WlanFreeMemoryProto local_WlanFreeMemory = 0;
-static WlanCloseHandleProto local_WlanCloseHandle = 0;
-
-static void resolveLibrary()
-{
- static volatile bool triedResolve = false;
-
- if (!triedResolve) {
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&local_WlanOpenHandle));
-#endif
-
- if (!triedResolve) {
- local_WlanOpenHandle = (WlanOpenHandleProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanOpenHandle");
- local_WlanRegisterNotification = (WlanRegisterNotificationProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanRegisterNotification");
- local_WlanEnumInterfaces = (WlanEnumInterfacesProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanEnumInterfaces");
- local_WlanGetAvailableNetworkList = (WlanGetAvailableNetworkListProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanGetAvailableNetworkList");
- local_WlanQueryInterface = (WlanQueryInterfaceProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanQueryInterface");
- local_WlanConnect = (WlanConnectProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanConnect");
- local_WlanDisconnect = (WlanDisconnectProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanDisconnect");
- local_WlanScan = (WlanScanProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanScan");
- local_WlanFreeMemory = (WlanFreeMemoryProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanFreeMemory");
- local_WlanCloseHandle = (WlanCloseHandleProto)
- QLibrary::resolve(QLatin1String("wlanapi.dll"), "WlanCloseHandle");
-
- triedResolve = true;
- }
- }
-}
-
-void qNotificationCallback(WLAN_NOTIFICATION_DATA *data, QNativeWifiEngine *d)
-{
- Q_UNUSED(d);
-
- switch (data->NotificationCode) {
- case wlan_notification_acm_connection_complete:
- case wlan_notification_acm_disconnected:
- d->emitConfigurationsChanged();
- break;
- default:
- qDebug() << "wlan unknown notification";
- }
-}
-
-QNativeWifiEngine::QNativeWifiEngine(QObject *parent)
-: QNetworkSessionEngine(parent), handle(0)
-{
- DWORD clientVersion;
-
- DWORD result = local_WlanOpenHandle(1, 0, &clientVersion, &handle);
- if (result != ERROR_SUCCESS) {
- if (result != ERROR_SERVICE_NOT_ACTIVE)
- qWarning("%s: WlanOpenHandle failed with error %ld\n", __FUNCTION__, result);
-
- return;
- }
-
- result = local_WlanRegisterNotification(handle, WLAN_NOTIFICATION_SOURCE_ALL, true,
- WLAN_NOTIFICATION_CALLBACK(qNotificationCallback),
- this, 0, 0);
- if (result != ERROR_SUCCESS)
- qWarning("%s: WlanRegisterNotification failed with error %ld\n", __FUNCTION__, result);
-
- // On Windows XP SP2 and SP3 only connection and disconnection notifications are available.
- // We need to poll for changes in available wireless networks.
- connect(&pollTimer, SIGNAL(timeout()), this, SIGNAL(configurationsChanged()));
- pollTimer.setInterval(10000);
-}
-
-QNativeWifiEngine::~QNativeWifiEngine()
-{
- local_WlanCloseHandle(handle, 0);
-}
-
-QList<QNetworkConfigurationPrivate *> QNativeWifiEngine::getConfigurations(bool *ok)
-{
- if (ok)
- *ok = false;
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
- // enumerate interfaces
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
- return foundConfigurations;
- }
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
-
- WLAN_AVAILABLE_NETWORK_LIST *networkList;
- result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
- 3, 0, &networkList);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
- continue;
- }
-
- QStringList seenNetworks;
-
- for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
- WLAN_AVAILABLE_NETWORK &network = networkList->Network[j];
-
- QString networkName;
-
- if (network.strProfileName[0] != 0) {
- networkName = QString::fromWCharArray(network.strProfileName);
- } else {
- networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID),
- network.dot11Ssid.uSSIDLength);
- }
-
- // don't add duplicate networks
- if (seenNetworks.contains(networkName))
- continue;
- else
- seenNetworks.append(networkName);
-
- QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
-
- cpPriv->isValid = true;
-
- cpPriv->name = networkName;
- cpPriv->id = QString::number(qHash(QLatin1String("WLAN:") + cpPriv->name));
-
- if (!(network.dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE))
- cpPriv->state = QNetworkConfiguration::Undefined;
-
- if (network.strProfileName[0] != 0) {
- if (network.bNetworkConnectable) {
- if (network.dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED)
- cpPriv->state = QNetworkConfiguration::Active;
- else
- cpPriv->state = QNetworkConfiguration::Discovered;
- } else {
- cpPriv->state = QNetworkConfiguration::Defined;
- }
- }
-
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
- cpPriv->bearer = QLatin1String("WLAN");
-
-
- foundConfigurations.append(cpPriv);
- }
-
- local_WlanFreeMemory(networkList);
- }
-
- local_WlanFreeMemory(interfaceList);
-
- if (ok)
- *ok = true;
-
- pollTimer.start();
-
- return foundConfigurations;
-}
-
-QString QNativeWifiEngine::getInterfaceFromId(const QString &id)
-{
- // enumerate interfaces
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
- return QString();
- }
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
-
- DWORD dataSize;
- WLAN_CONNECTION_ATTRIBUTES *connectionAttributes;
- result = local_WlanQueryInterface(handle, &interface.InterfaceGuid,
- wlan_intf_opcode_current_connection, 0, &dataSize,
- reinterpret_cast<PVOID *>(&connectionAttributes), 0);
- if (result != ERROR_SUCCESS) {
- if (result != ERROR_INVALID_STATE)
- qWarning("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result);
-
- continue;
- }
-
- if (qHash(QLatin1String("WLAN:") +
- QString::fromWCharArray(connectionAttributes->strProfileName)) == id.toUInt()) {
- QString guid("{%1-%2-%3-%4%5-%6%7%8%9%10%11}");
-
- guid = guid.arg(interface.InterfaceGuid.Data1, 8, 16, QChar('0'));
- guid = guid.arg(interface.InterfaceGuid.Data2, 4, 16, QChar('0'));
- guid = guid.arg(interface.InterfaceGuid.Data3, 4, 16, QChar('0'));
- for (int i = 0; i < 8; ++i)
- guid = guid.arg(interface.InterfaceGuid.Data4[i], 2, 16, QChar('0'));
-
- local_WlanFreeMemory(connectionAttributes);
-
- return guid.toUpper();
- }
-
- local_WlanFreeMemory(connectionAttributes);
- local_WlanFreeMemory(interfaceList);
- }
-
- return QString();
-}
-
-bool QNativeWifiEngine::hasIdentifier(const QString &id)
-{
- // enumerate interfaces
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
- return false;
- }
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
-
- WLAN_AVAILABLE_NETWORK_LIST *networkList;
- result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
- 3, 0, &networkList);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
- continue;
- }
-
- for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
- WLAN_AVAILABLE_NETWORK &network = networkList->Network[j];
-
- QString networkName;
-
- if (network.strProfileName[0] != 0) {
- networkName = QString::fromWCharArray(network.strProfileName);
- } else {
- networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID),
- network.dot11Ssid.uSSIDLength);
- }
-
- if (qHash(QLatin1String("WLAN:") + networkName) == id.toUInt()) {
- local_WlanFreeMemory(networkList);
- local_WlanFreeMemory(interfaceList);
- return true;
- }
- }
-
- local_WlanFreeMemory(networkList);
- }
-
- local_WlanFreeMemory(interfaceList);
-
- return false;
-}
-
-/*QString QNativeWifiEngine::bearerName(const QString &)
-{
- return QLatin1String("WLAN");
-}*/
-
-void QNativeWifiEngine::connectToId(const QString &id)
-{
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
- emit connectionError(id, InterfaceLookupError);
- return;
- }
-
- QString profile;
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i];
-
- WLAN_AVAILABLE_NETWORK_LIST *networkList;
- result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid,
- 3, 0, &networkList);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanGetAvailableNetworkList failed with error %ld\n",
- __FUNCTION__, result);
- continue;
- }
-
- for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) {
- WLAN_AVAILABLE_NETWORK &network = networkList->Network[j];
-
- profile = QString::fromWCharArray(network.strProfileName);
-
- if (qHash(QLatin1String("WLAN:") + profile) == id.toUInt())
- break;
- else
- profile.clear();
- }
-
- local_WlanFreeMemory(networkList);
-
- if (!profile.isEmpty()) {
- WLAN_CONNECTION_PARAMETERS parameters;
- parameters.wlanConnectionMode = wlan_connection_mode_profile;
- parameters.strProfile = reinterpret_cast<LPCWSTR>(profile.utf16());
- parameters.pDot11Ssid = 0;
- parameters.pDesiredBssidList = 0;
- parameters.dot11BssType = dot11_BSS_type_any;
- parameters.dwFlags = 0;
-
- DWORD result = local_WlanConnect(handle, &interface.InterfaceGuid, &parameters, 0);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanConnect failed with error %ld\n", __FUNCTION__, result);
- emit connectionError(id, ConnectError);
- break;
- }
-
- break;
- }
- }
-
- local_WlanFreeMemory(interfaceList);
-
- if (profile.isEmpty())
- emit connectionError(id, InterfaceLookupError);
-}
-
-void QNativeWifiEngine::disconnectFromId(const QString &id)
-{
- QString interface = getInterfaceFromId(id);
-
- if (interface.isEmpty()) {
- emit connectionError(id, InterfaceLookupError);
- return;
- }
-
- QStringList split = interface.mid(1, interface.length() - 2).split('-');
-
- GUID guid;
- guid.Data1 = split.at(0).toUInt(0, 16);
- guid.Data2 = split.at(1).toUShort(0, 16);
- guid.Data3 = split.at(2).toUShort(0, 16);
- guid.Data4[0] = split.at(3).left(2).toUShort(0, 16);
- guid.Data4[1] = split.at(3).right(2).toUShort(0, 16);
- for (int i = 0; i < 6; ++i)
- guid.Data4[i + 2] = split.at(4).mid(i*2, 2).toUShort(0, 16);
-
- DWORD result = local_WlanDisconnect(handle, &guid, 0);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanDisconnect failed with error %ld\n", __FUNCTION__, result);
- emit connectionError(id, DisconnectionError);
- return;
- }
-}
-
-void QNativeWifiEngine::requestUpdate()
-{
- // enumerate interfaces
- WLAN_INTERFACE_INFO_LIST *interfaceList;
- DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList);
- if (result != ERROR_SUCCESS) {
- qWarning("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result);
- return;
- }
-
- for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) {
- result = local_WlanScan(handle, &interfaceList->InterfaceInfo[i].InterfaceGuid, 0, 0, 0);
- if (result != ERROR_SUCCESS)
- qWarning("%s: WlanScan failed with error %ld\n", __FUNCTION__, result);
- }
-}
-
-QNativeWifiEngine *QNativeWifiEngine::instance()
-{
- resolveLibrary();
-
- // native wifi dll not available
- if (!local_WlanOpenHandle)
- return 0;
-
- QNativeWifiEngine *engine = nativeWifiEngine();
-
- // could not initialise subsystem
- if (engine && engine->handle == 0)
- return 0;
-
- return engine;
-}
-
-#include "moc_qnativewifiengine_win_p.cpp"
-
-QTM_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp
index 264f0df..6b73e3c 100644
--- a/src/network/bearer/qnetworkconfigmanager.cpp
+++ b/src/network/bearer/qnetworkconfigmanager.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -45,12 +45,22 @@
#include "qnetworkconfigmanager_s60_p.h"
#else
#include "qnetworkconfigmanager_p.h"
+#include "qnetworksessionengine_p.h"
#endif
-QTM_BEGIN_NAMESPACE
+#include <QtCore/qstringlist.h>
+
+QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QNetworkConfigurationManagerPrivate, connManager);
+#ifndef Q_OS_SYMBIAN
+QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
+{
+ return connManager();
+}
+#endif
+
/*!
\class QNetworkConfigurationManager
@@ -227,28 +237,31 @@ QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNe
{
QList<QNetworkConfiguration> result;
QNetworkConfigurationManagerPrivate* conPriv = connManager();
- QList<QString> cpsIdents = conPriv->accessPointConfigurations.keys();
-
- //find all InternetAccessPoints
- foreach( QString ii, cpsIdents) {
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> p =
- conPriv->accessPointConfigurations.value(ii);
- if ( (p->state & filter) == filter ) {
- QNetworkConfiguration pt;
- pt.d = conPriv->accessPointConfigurations.value(ii);
- result << pt;
+
+ foreach (QNetworkSessionEngine *engine, conPriv->sessionEngines) {
+ QStringList cpsIdents = engine->accessPointConfigurations.keys();
+
+ //find all InternetAccessPoints
+ foreach (const QString &ii, cpsIdents) {
+ QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> p =
+ engine->accessPointConfigurations.value(ii);
+ if ((p->state & filter) == filter) {
+ QNetworkConfiguration pt;
+ pt.d = engine->accessPointConfigurations.value(ii);
+ result << pt;
+ }
}
- }
- //find all service networks
- cpsIdents = conPriv->snapConfigurations.keys();
- foreach( QString ii, cpsIdents) {
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> p =
- conPriv->snapConfigurations.value(ii);
- if ( (p->state & filter) == filter ) {
- QNetworkConfiguration pt;
- pt.d = conPriv->snapConfigurations.value(ii);
- result << pt;
+ //find all service networks
+ cpsIdents = engine->snapConfigurations.keys();
+ foreach (const QString &ii, cpsIdents) {
+ QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> p =
+ engine->snapConfigurations.value(ii);
+ if ((p->state & filter) == filter) {
+ QNetworkConfiguration pt;
+ pt.d = engine->snapConfigurations.value(ii);
+ result << pt;
+ }
}
}
@@ -264,15 +277,23 @@ QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNe
QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(const QString& identifier) const
{
QNetworkConfigurationManagerPrivate* conPriv = connManager();
+
QNetworkConfiguration item;
- if (conPriv->accessPointConfigurations.contains(identifier))
- item.d = conPriv->accessPointConfigurations.value(identifier);
- else if (conPriv->snapConfigurations.contains(identifier))
- item.d = conPriv->snapConfigurations.value(identifier);
- else if (conPriv->userChoiceConfigurations.contains(identifier))
- item.d = conPriv->userChoiceConfigurations.value(identifier);
- return item;
+ foreach (QNetworkSessionEngine *engine, conPriv->sessionEngines) {
+ if (engine->accessPointConfigurations.contains(identifier))
+ item.d = engine->accessPointConfigurations.value(identifier);
+ else if (engine->snapConfigurations.contains(identifier))
+ item.d = engine->snapConfigurations.value(identifier);
+ else if (engine->userChoiceConfigurations.contains(identifier))
+ item.d = engine->userChoiceConfigurations.value(identifier);
+ else
+ continue;
+
+ return item;
+ }
+
+ return item;
}
/*!
@@ -329,5 +350,5 @@ void QNetworkConfigurationManager::updateConfigurations()
#include "moc_qnetworkconfigmanager.cpp"
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfigmanager.h b/src/network/bearer/qnetworkconfigmanager.h
index 98641f6..b7ab72b 100644
--- a/src/network/bearer/qnetworkconfigmanager.h
+++ b/src/network/bearer/qnetworkconfigmanager.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -42,17 +42,15 @@
#ifndef QNETWORKCONFIGURATIONMANAGER_H
#define QNETWORKCONFIGURATIONMANAGER_H
-#include "qmobilityglobal.h"
-
#include <QtCore/qobject.h>
#include "qnetworkconfiguration.h"
QT_BEGIN_HEADER
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class QNetworkConfigurationManagerPrivate;
-class Q_BEARER_EXPORT QNetworkConfigurationManager : public QObject
+class Q_NETWORK_EXPORT QNetworkConfigurationManager : public QObject
{
Q_OBJECT
@@ -93,7 +91,7 @@ Q_SIGNALS:
Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities)
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/network/bearer/qnetworkconfigmanager_maemo.cpp b/src/network/bearer/qnetworkconfigmanager_maemo.cpp
index 795b054..2188d61 100644
--- a/src/network/bearer/qnetworkconfigmanager_maemo.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_maemo.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -53,7 +53,7 @@
#include <iapconf.h>
#include <iapmonitor.h>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
#define IAP "/system/osso/connectivity/IAP"
static int iap_prefix_len;
@@ -757,4 +757,4 @@ void QNetworkConfigurationManagerPrivate::configChanged(QNetworkConfigurationPri
#include "qnetworkconfigmanager_maemo.moc"
#include "moc_qnetworkconfigmanager_maemo_p.cpp"
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfigmanager_maemo_p.h b/src/network/bearer/qnetworkconfigmanager_maemo_p.h
index e182495..5cc99c2 100644
--- a/src/network/bearer/qnetworkconfigmanager_maemo_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_maemo_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -60,7 +60,7 @@
#include <QHash>
#include <QStringList>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class QNetworkConfigurationManagerPrivate : public QObject
@@ -136,6 +136,6 @@ Q_SIGNALS:
void onlineStateChanged(bool isOnline);
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
#endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H
diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp
index 39426d0..cb83789 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_p.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -40,73 +40,48 @@
****************************************************************************/
#include "qnetworkconfigmanager_p.h"
-#include "qgenericengine_p.h"
+#include "qbearerplugin.h"
-#ifdef Q_OS_WIN
-#include "qnlaengine_win_p.h"
-#endif
-#ifdef Q_OS_WIN32
-#include "qnativewifiengine_win_p.h"
-#endif
-#if defined(BACKEND_NM)
-#include "qnmwifiengine_unix_p.h"
-#endif
-#ifdef Q_OS_DARWIN
-#include "qcorewlanengine_mac_p.h"
-#endif
+#include <QtCore/private/qfactoryloader_p.h>
#include <QtCore/qdebug.h>
#include <QtCore/qtimer.h>
#include <QtCore/qstringlist.h>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")))
+
+QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
+{
+ while (!sessionEngines.isEmpty())
+ delete sessionEngines.takeFirst();
+}
void QNetworkConfigurationManagerPrivate::registerPlatformCapabilities()
{
capFlags = QNetworkConfigurationManager::ForcedRoaming;
}
-void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurationPrivate *cpPriv, QNetworkSessionEngine *engine)
+void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurationPrivatePointer ptr)
{
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(new QNetworkConfigurationPrivate);
-
- ptr.data()->isValid = cpPriv->isValid;
- ptr.data()->name = cpPriv->name;
- ptr.data()->id = cpPriv->id;
- ptr.data()->state = cpPriv->state;
- ptr.data()->type = cpPriv->type;
- 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);
-
if (!firstUpdate) {
QNetworkConfiguration item;
item.d = ptr;
emit configurationAdded(item);
}
- if (ptr.data()->state == QNetworkConfiguration::Active) {
- ++onlineConfigurations;
- if (!firstUpdate && onlineConfigurations == 1)
+ if (ptr->state == QNetworkConfiguration::Active) {
+ onlineConfigurations.insert(ptr);
+ if (!firstUpdate && onlineConfigurations.count() == 1)
emit onlineStateChanged(true);
}
}
-void QNetworkConfigurationManagerPrivate::configurationRemoved(const QString &id)
+void QNetworkConfigurationManagerPrivate::configurationRemoved(QNetworkConfigurationPrivatePointer ptr)
{
- if (!accessPointConfigurations.contains(id))
- return;
-
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr =
- accessPointConfigurations.take(id);
-
- configurationEngine.remove(id);
-
- ptr.data()->isValid = false;
+ ptr->isValid = false;
if (!firstUpdate) {
QNetworkConfiguration item;
@@ -114,66 +89,36 @@ void QNetworkConfigurationManagerPrivate::configurationRemoved(const QString &id
emit configurationRemoved(item);
}
- if (ptr.data()->state == QNetworkConfiguration::Active) {
- --onlineConfigurations;
- if (!firstUpdate && onlineConfigurations == 0)
- emit onlineStateChanged(false);
- }
+ onlineConfigurations.remove(ptr);
+ if (!firstUpdate && onlineConfigurations.isEmpty())
+ emit onlineStateChanged(false);
}
-void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigurationPrivate *cpPriv)
+void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigurationPrivatePointer ptr)
{
- if (!accessPointConfigurations.contains(cpPriv->id))
- return;
+ if (!firstUpdate) {
+ QNetworkConfiguration item;
+ item.d = ptr;
+ emit configurationChanged(item);
+ }
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr =
- accessPointConfigurations.value(cpPriv->id);
-
- if (ptr.data()->isValid != cpPriv->isValid ||
- ptr.data()->name != cpPriv->name ||
- ptr.data()->id != cpPriv->id ||
- ptr.data()->state != cpPriv->state ||
- 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;
-
- ptr.data()->isValid = cpPriv->isValid;
- ptr.data()->name = cpPriv->name;
- ptr.data()->id = cpPriv->id;
- ptr.data()->state = cpPriv->state;
- ptr.data()->type = cpPriv->type;
- ptr.data()->roamingSupported = cpPriv->roamingSupported;
- ptr.data()->purpose = cpPriv->purpose;
- ptr.data()->internet = cpPriv->internet;
- ptr.data()->bearer = cpPriv->bearer;
+ bool previous = !onlineConfigurations.isEmpty();
- if (!firstUpdate) {
- QNetworkConfiguration item;
- item.d = ptr;
- emit configurationChanged(item);
- }
+ if (ptr->state == QNetworkConfiguration::Active)
+ onlineConfigurations.insert(ptr);
+ else
+ onlineConfigurations.remove(ptr);
- if (ptr.data()->state == QNetworkConfiguration::Active && oldState != ptr.data()->state) {
- // configuration went online
- ++onlineConfigurations;
- if (!firstUpdate && onlineConfigurations == 1)
- emit onlineStateChanged(true);
- } else if (ptr.data()->state != QNetworkConfiguration::Active && oldState == QNetworkConfiguration::Active) {
- // configuration went offline
- --onlineConfigurations;
- if (!firstUpdate && onlineConfigurations == 0)
- emit onlineStateChanged(false);
- }
- }
+ bool online = !onlineConfigurations.isEmpty();
+
+ if (!firstUpdate && online != previous)
+ emit onlineStateChanged(online);
}
void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration()
{
- if (!snapConfigurations.contains(QLatin1String("Internet Service Network"))) {
+#if 0
+ if (!generic->snapConfigurations.contains(QLatin1String("Internet Service Network"))) {
QNetworkConfigurationPrivate *serviceNetwork = new QNetworkConfigurationPrivate;
serviceNetwork->name = tr("Internet");
serviceNetwork->isValid = true;
@@ -183,7 +128,7 @@ void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration()
QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr(serviceNetwork);
- snapConfigurations.insert(serviceNetwork->id, ptr);
+ generic->snapConfigurations.insert(serviceNetwork->id, ptr);
if (!firstUpdate) {
QNetworkConfiguration item;
@@ -193,15 +138,15 @@ void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration()
}
QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> ptr =
- snapConfigurations.value(QLatin1String("Internet Service Network"));
+ generic->snapConfigurations.value(QLatin1String("Internet Service Network"));
QList<QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > serviceNetworkMembers;
QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> >::const_iterator i =
- accessPointConfigurations.constBegin();
+ generic->accessPointConfigurations.constBegin();
QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined;
- while (i != accessPointConfigurations.constEnd()) {
+ while (i != generic->accessPointConfigurations.constEnd()) {
QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> child = i.value();
if (child.data()->internet && ((child.data()->state & QNetworkConfiguration::Defined)
@@ -223,148 +168,128 @@ void QNetworkConfigurationManagerPrivate::updateInternetServiceConfiguration()
item.d = ptr;
emit configurationChanged(item);
}
+#endif
}
void QNetworkConfigurationManagerPrivate::updateConfigurations()
{
if (firstUpdate) {
- updateState = NotUpdating;
- onlineConfigurations = 0;
-
-#if defined (Q_OS_DARWIN)
- coreWifi = QCoreWlanEngine::instance();
- if (coreWifi) {
- connect(coreWifi, SIGNAL(configurationsChanged()),
- this, SLOT(updateConfigurations()));
- }
-#else
-#if defined(BACKEND_NM)
- nmWifi = QNmWifiEngine::instance();
- if (nmWifi) {
- connect(nmWifi, SIGNAL(configurationsChanged()),
- this, SLOT(updateConfigurations()));
- } else {
-#endif
- generic = QGenericEngine::instance();
- if (generic) {
- connect(generic, SIGNAL(configurationsChanged()),
- this, SLOT(updateConfigurations()));
+ updating = false;
+
+ QFactoryLoader *l = loader();
+ QStringList keys = l->keys();
+
+ if (keys.contains(QLatin1String("corewlan"))) {
+ QBearerEnginePlugin *coreWlanPlugin =
+ qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("corewlan")));
+ if (coreWlanPlugin) {
+ QNetworkSessionEngine *coreWifi = coreWlanPlugin->create(QLatin1String("corewlan"));
+ if (coreWifi) {
+ sessionEngines.append(coreWifi);
+ connect(coreWifi, SIGNAL(updateCompleted()),
+ this, SLOT(updateConfigurations()));
+ connect(coreWifi, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer)));
+ connect(coreWifi, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)));
+ connect(coreWifi, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)));
+ }
}
-#if defined(BACKEND_NM)
}
-#endif
-#endif
-#ifdef Q_OS_WIN
- nla = QNlaEngine::instance();
- if (nla) {
- connect(nla, SIGNAL(configurationsChanged()),
- this, SLOT(updateConfigurations()));
+ if (keys.contains(QLatin1String("networkmanager"))) {
+ QBearerEnginePlugin *nmPlugin =
+ qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("networkmanager")));
+ if (nmPlugin) {
+ QNetworkSessionEngine *nmWifi = nmPlugin->create(QLatin1String("networkmanager"));
+ if (nmWifi) {
+ sessionEngines.append(nmWifi);
+ connect(nmWifi, SIGNAL(updateCompleted()),
+ this, SLOT(updateConfigurations()));
+ connect(nmWifi, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer)));
+ connect(nmWifi, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)));
+ connect(nmWifi, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)));
+ }
}
-#endif
-
-#ifdef Q_OS_WIN32
- nativeWifi = QNativeWifiEngine::instance();
- if (nativeWifi) {
- connect(nativeWifi, SIGNAL(configurationsChanged()),
- this, SLOT(updateConfigurations()));
+ }
- capFlags |= QNetworkConfigurationManager::CanStartAndStopInterfaces;
+ if (keys.contains(QLatin1String("generic"))) {
+ QBearerEnginePlugin *genericPlugin =
+ qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("generic")));
+ if (genericPlugin) {
+ QNetworkSessionEngine *generic = genericPlugin->create(QLatin1String("generic"));
+ if (generic) {
+ sessionEngines.append(generic);
+ connect(generic, SIGNAL(updateCompleted()),
+ this, SLOT(updateConfigurations()));
+ connect(generic, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer)));
+ connect(generic, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)));
+ connect(generic, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)));
+ }
}
-#endif
- }
-
- QNetworkSessionEngine *engine = qobject_cast<QNetworkSessionEngine *>(sender());
- if (updateState & Updating && engine) {
-#if defined (Q_OS_DARWIN)
- if (engine == coreWifi)
- updateState &= ~CoreWifiUpdating;
-#else
-#if defined(BACKEND_NM)
- if (engine == nmWifi)
- updateState &= ~NmUpdating;
- else if (engine == generic)
- updateState &= ~GenericUpdating;
-#else
- if (engine == generic)
- updateState &= ~GenericUpdating;
-#endif
-#endif
-
-#ifdef Q_OS_WIN
- else if (engine == nla)
- updateState &= ~NlaUpdating;
-#ifdef Q_OS_WIN32
- else if (engine == nativeWifi)
- updateState &= ~NativeWifiUpdating;
-#endif
-#endif
- }
- QList<QNetworkSessionEngine *> engines;
- if (firstUpdate) {
-#if defined (Q_OS_DARWIN)
- if (coreWifi)
- engines << coreWifi;
-#else
-#if defined(BACKEND_NM)
- if (nmWifi)
- engines << nmWifi;
- else if (generic)
- engines << generic;
-#else
- if (generic)
- engines << generic;
-#endif
-#endif
-
-#ifdef Q_OS_WIN
- if (nla)
- engines << nla;
-#ifdef Q_OS_WIN32
- if (nativeWifi)
- engines << nativeWifi;
-#endif
-#endif
- } else if (engine) {
- engines << engine;
- }
-
- while (!engines.isEmpty()) {
- engine = engines.takeFirst();
-
- bool ok;
- QList<QNetworkConfigurationPrivate *> foundConfigurations = engine->getConfigurations(&ok);
-
- // Find removed configurations.
- QList<QString> removedIdentifiers = configurationEngine.keys();
- for (int i = 0; i < foundConfigurations.count(); ++i)
- removedIdentifiers.removeOne(foundConfigurations.at(i)->id);
-
- // Update or add configurations.
- while (!foundConfigurations.isEmpty()) {
- QNetworkConfigurationPrivate *cpPriv = foundConfigurations.takeFirst();
-
- if (accessPointConfigurations.contains(cpPriv->id))
- configurationChanged(cpPriv);
- else
- configurationAdded(cpPriv, engine);
-
- delete cpPriv;
}
- // Remove configurations.
- while (!removedIdentifiers.isEmpty()) {
- const QString id = removedIdentifiers.takeFirst();
+ if (keys.contains(QLatin1String("nla"))) {
+ QBearerEnginePlugin *nlaPlugin =
+ qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("nla")));
+ if (nlaPlugin) {
+ QNetworkSessionEngine *nla = nlaPlugin->create(QLatin1String("nla"));
+ if (nla) {
+ sessionEngines.append(nla);
+ connect(nla, SIGNAL(updateCompleted()),
+ this, SLOT(updateConfigurations()));
+ connect(nla, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer)));
+ connect(nla, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)));
+ connect(nla, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)));
+ }
+ }
+ }
- if (configurationEngine.value(id) == engine)
- configurationRemoved(id);
+ if (keys.contains(QLatin1String("nativewifi"))) {
+ QBearerEnginePlugin *nativeWifiPlugin =
+ qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("nativewifi")));
+ if (nativeWifiPlugin) {
+ QNetworkSessionEngine *nativeWifi =
+ nativeWifiPlugin->create(QLatin1String("nativewifi"));
+ if (nativeWifi) {
+ sessionEngines.append(nativeWifi);
+ connect(nativeWifi, SIGNAL(updateCompleted()),
+ this, SLOT(updateConfigurations()));
+ connect(nativeWifi,
+ SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer)));
+ connect(nativeWifi,
+ SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)));
+ connect(nativeWifi,
+ SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
+ this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)));
+
+ capFlags |= QNetworkConfigurationManager::CanStartAndStopInterfaces;
+ }
+ }
}
}
- updateInternetServiceConfiguration();
+ QNetworkSessionEngine *engine = qobject_cast<QNetworkSessionEngine *>(sender());
+ if (!updatingEngines.isEmpty() && engine) {
+ int index = sessionEngines.indexOf(engine);
+ if (index >= 0)
+ updatingEngines.remove(index);
+ }
- if (updateState == Updating) {
- updateState = NotUpdating;
+ if (updating && updatingEngines.isEmpty()) {
+ updating = false;
emit configurationUpdateComplete();
}
@@ -380,22 +305,25 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations()
*/
QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration()
{
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> firstActive;
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> firstDiscovered;
+ QNetworkConfigurationPrivatePointer firstActive;
+ QNetworkConfigurationPrivatePointer firstDiscovered;
- QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> >::const_iterator i =
- accessPointConfigurations.constBegin();
- while (i != accessPointConfigurations.constEnd()) {
- QNetworkConfigurationPrivate *priv = i.value().data();
+ foreach (QNetworkSessionEngine *engine, sessionEngines) {
+ QHash<QString, QNetworkConfigurationPrivatePointer>::const_iterator i =
+ engine->accessPointConfigurations.constBegin();
- if (!firstActive && priv->isValid &&
- (priv->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active)
- firstActive = i.value();
- if (!firstDiscovered && priv->isValid &&
- (priv->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
- firstDiscovered = i.value();
+ while (i != engine->accessPointConfigurations.constEnd()) {
+ QNetworkConfigurationPrivatePointer priv = i.value();
- ++i;
+ if (!firstActive && priv->isValid &&
+ (priv->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active)
+ firstActive = priv;
+ if (!firstDiscovered && priv->isValid &&
+ (priv->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
+ firstDiscovered = priv;
+
+ ++i;
+ }
}
QNetworkConfiguration item;
@@ -410,44 +338,12 @@ QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration(
void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate()
{
- updateState = Updating;
-#if defined (Q_OS_DARWIN)
- if (coreWifi) {
- updateState |= CoreWifiUpdating;
- coreWifi->requestUpdate();
- }
-#else
-#if defined(BACKEND_NM)
- if (nmWifi) {
- updateState |= NmUpdating;
- nmWifi->requestUpdate();
- } else if (generic) {
- updateState |= GenericUpdating;
- generic->requestUpdate();
- }
-#else
- if (generic) {
- updateState |= GenericUpdating;
- generic->requestUpdate();
- }
-#endif
-#endif
-#ifdef Q_OS_WIN
- if (nla) {
- updateState |= NlaUpdating;
- nla->requestUpdate();
- }
-#endif
+ updating = true;
-#ifdef Q_OS_WIN32
- if (nativeWifi) {
- updateState |= NativeWifiUpdating;
- nativeWifi->requestUpdate();
+ for (int i = 0; i < sessionEngines.count(); ++i) {
+ updatingEngines.insert(i);
+ sessionEngines.at(i)->requestUpdate();
}
-#endif
}
-#include "moc_qnetworkconfigmanager_p.cpp"
-
-QTM_END_NAMESPACE
-
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h
index 0c42f9b..a45d534 100644
--- a/src/network/bearer/qnetworkconfigmanager_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -56,20 +56,9 @@
#include "qnetworkconfigmanager.h"
#include "qnetworkconfiguration_p.h"
-#include <QHash>
-#include <QStringList>
+QT_BEGIN_NAMESPACE
-QTM_BEGIN_NAMESPACE
-
-#ifdef BEARER_ENGINE
class QNetworkSessionEngine;
-class QGenericEngine;
-class QNlaEngine;
-class QNativeWifiEngine;
-class QNmWifiEngine;
-class QCoreWlanEngine;
-#endif
-
class QNetworkConfigurationManagerPrivate : public QObject
{
@@ -82,22 +71,7 @@ public:
updateConfigurations();
}
- virtual ~QNetworkConfigurationManagerPrivate()
- {
- QList<QString> configIdents = snapConfigurations.keys();
- foreach(const QString oldIface, configIdents) {
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = snapConfigurations.take(oldIface);
- priv->isValid = false;
- priv->id.clear();
- }
-
- configIdents = accessPointConfigurations.keys();
- foreach(const QString oldIface, configIdents) {
- QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> priv = accessPointConfigurations.take(oldIface);
- priv->isValid = false;
- priv->id.clear();
- }
- }
+ virtual ~QNetworkConfigurationManagerPrivate();
QNetworkConfiguration defaultConfiguration();
@@ -106,15 +80,6 @@ public:
void performAsyncConfigurationUpdate();
- //this table contains an up to date list of all configs at any time.
- //it must be updated if configurations change, are added/removed or
- //the members of ServiceNetworks change
- QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > accessPointConfigurations;
- QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > snapConfigurations;
- QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > userChoiceConfigurations;
-#ifdef BEARER_ENGINE
- QHash<QString, QNetworkSessionEngine *> configurationEngine;
-#endif
bool firstUpdate;
public slots:
@@ -128,51 +93,27 @@ Q_SIGNALS:
void onlineStateChanged(bool isOnline);
private:
-#ifdef BEARER_ENGINE
void updateInternetServiceConfiguration();
void abort();
-#endif
-
-#ifdef BEARER_ENGINE
- QGenericEngine *generic;
-#ifdef Q_OS_WIN
- QNlaEngine *nla;
-#ifndef Q_OS_WINCE
- QNativeWifiEngine *nativeWifi;
-#endif
-#endif
-#ifdef BACKEND_NM
- QNmWifiEngine *nmWifi;
-#endif
-#ifdef Q_OS_DARWIN
- QCoreWlanEngine *coreWifi;
-#endif
-
- uint onlineConfigurations;
-
- enum EngineUpdate {
- NotUpdating = 0x00,
- Updating = 0x01,
- GenericUpdating = 0x02,
- NlaUpdating = 0x04,
- NativeWifiUpdating = 0x08,
- NmUpdating = 0x20,
- CoreWifiUpdating = 0x40,
- };
- Q_DECLARE_FLAGS(EngineUpdateState, EngineUpdate)
-
- EngineUpdateState updateState;
-#endif
+
+public:
+ QList<QNetworkSessionEngine *> sessionEngines;
+
+private:
+ QSet<QNetworkConfigurationPrivatePointer> onlineConfigurations;
+
+ bool updating;
+ QSet<int> updatingEngines;
private Q_SLOTS:
-#ifdef BEARER_ENGINE
- void configurationAdded(QNetworkConfigurationPrivate *cpPriv, QNetworkSessionEngine *engine);
- void configurationRemoved(const QString &id);
- void configurationChanged(QNetworkConfigurationPrivate *cpPriv);
-#endif
+ void configurationAdded(QNetworkConfigurationPrivatePointer ptr);
+ void configurationRemoved(QNetworkConfigurationPrivatePointer ptr);
+ void configurationChanged(QNetworkConfigurationPrivatePointer ptr);
};
-QTM_END_NAMESPACE
+QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate();
+
+QT_END_NAMESPACE
#endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H
diff --git a/src/network/bearer/qnetworkconfigmanager_s60_p.cpp b/src/network/bearer/qnetworkconfigmanager_s60_p.cpp
index 760a194..b5bd4d2 100644
--- a/src/network/bearer/qnetworkconfigmanager_s60_p.cpp
+++ b/src/network/bearer/qnetworkconfigmanager_s60_p.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -58,7 +58,7 @@
#include <aputils.h>
#endif
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
static const int KValueThatWillBeAddedToSNAPId = 1000;
static const int KUserChoiceIAPId = 0;
@@ -971,4 +971,4 @@ void AccessPointsAvailabilityScanner::RunL()
}
}
#include "moc_qnetworkconfigmanager_s60_p.cpp"
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfigmanager_s60_p.h b/src/network/bearer/qnetworkconfigmanager_s60_p.h
index 679fa6c..568803d 100644
--- a/src/network/bearer/qnetworkconfigmanager_s60_p.h
+++ b/src/network/bearer/qnetworkconfigmanager_s60_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -68,7 +68,7 @@ QT_BEGIN_NAMESPACE
class QTimer;
QT_END_NAMESPACE
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class QNetworkSessionPrivate;
class AccessPointsAvailabilityScanner;
@@ -180,6 +180,6 @@ private: // Data
TConnMonIapInfoBuf iIapBuf;
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
#endif //QNETWORKCONFIGURATIONMANAGERPRIVATE_H
diff --git a/src/network/bearer/qnetworkconfiguration.cpp b/src/network/bearer/qnetworkconfiguration.cpp
index 56907c3..e1b2828 100644
--- a/src/network/bearer/qnetworkconfiguration.cpp
+++ b/src/network/bearer/qnetworkconfiguration.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -47,7 +47,7 @@
#include "qnetworkconfiguration_p.h"
#endif
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
/*!
\class QNetworkConfiguration
@@ -395,5 +395,5 @@ QString QNetworkConfiguration::bearerName() const
}
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h
index 860be4b..dede2b1 100644
--- a/src/network/bearer/qnetworkconfiguration.h
+++ b/src/network/bearer/qnetworkconfiguration.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -42,18 +42,17 @@
#ifndef QNETWORKCONFIGURATION_H
#define QNETWORKCONFIGURATION_H
-#include "qmobilityglobal.h"
-
+#include <QtCore/qglobal.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
#include <QtCore/qlist.h>
QT_BEGIN_HEADER
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class QNetworkConfigurationPrivate;
-class Q_BEARER_EXPORT QNetworkConfiguration
+class Q_NETWORK_EXPORT QNetworkConfiguration
{
public:
QNetworkConfiguration();
@@ -107,7 +106,7 @@ private:
QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> d;
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/network/bearer/qnetworkconfiguration_maemo_p.h b/src/network/bearer/qnetworkconfiguration_maemo_p.h
index 2597605..3b43312 100644
--- a/src/network/bearer/qnetworkconfiguration_maemo_p.h
+++ b/src/network/bearer/qnetworkconfiguration_maemo_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -57,7 +57,7 @@
#include <QtCore/qshareddata.h>
#include <QNetworkInterface>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class QNetworkConfigurationPrivate : public QSharedData
{
@@ -117,6 +117,6 @@ private:
QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other);
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
#endif //QNETWORKCONFIGURATIONPRIVATE_H
diff --git a/src/network/bearer/qnetworkconfiguration_p.h b/src/network/bearer/qnetworkconfiguration_p.h
index c2834e6..68d6ba4 100644
--- a/src/network/bearer/qnetworkconfiguration_p.h
+++ b/src/network/bearer/qnetworkconfiguration_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -55,20 +55,18 @@
#include "qnetworkconfiguration.h"
#include <QtCore/qshareddata.h>
-#include <QNetworkInterface>
+#include <QtNetwork/QNetworkInterface>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
+typedef QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfigurationPrivatePointer;
class QNetworkConfigurationPrivate : public QSharedData
{
public:
QNetworkConfigurationPrivate ()
- : isValid(false), type(QNetworkConfiguration::Invalid),
- roamingSupported(false), purpose(QNetworkConfiguration::UnknownPurpose)
+ : isValid(false), type(QNetworkConfiguration::Invalid),
+ roamingSupported(false), purpose(QNetworkConfiguration::UnknownPurpose), internet(false)
{
-#ifdef BEARER_ENGINE
- internet = false;
-#endif
}
~QNetworkConfigurationPrivate()
@@ -91,11 +89,9 @@ public:
bool roamingSupported;
QNetworkConfiguration::Purpose purpose;
-#ifdef BEARER_ENGINE
bool internet;
-#endif
- QList<QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > serviceNetworkMembers;
+ QList<QNetworkConfigurationPrivatePointer> serviceNetworkMembers;
QNetworkInterface serviceInterface;
private:
@@ -105,6 +101,6 @@ private:
QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other);
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
#endif //QNETWORKCONFIGURATIONPRIVATE_H
diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.cpp b/src/network/bearer/qnetworkconfiguration_s60_p.cpp
index 02115d9..3064840 100644
--- a/src/network/bearer/qnetworkconfiguration_s60_p.cpp
+++ b/src/network/bearer/qnetworkconfiguration_s60_p.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -41,7 +41,7 @@
#include "qnetworkconfiguration_s60_p.h"
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
QNetworkConfigurationPrivate::QNetworkConfigurationPrivate()
: isValid(false), type(QNetworkConfiguration::Invalid),
@@ -73,4 +73,4 @@ QString QNetworkConfigurationPrivate::bearerName() const
}
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkconfiguration_s60_p.h b/src/network/bearer/qnetworkconfiguration_s60_p.h
index 6c87200..0973152 100644
--- a/src/network/bearer/qnetworkconfiguration_s60_p.h
+++ b/src/network/bearer/qnetworkconfiguration_s60_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -56,7 +56,7 @@
#include <qnetworkconfiguration.h>
#include <QtCore/qshareddata.h>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class QNetworkConfigurationPrivate : public QSharedData
{
@@ -103,7 +103,7 @@ private:
QNetworkConfigurationPrivate(const QNetworkConfigurationPrivate &other);
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
#endif //QNETWORKCONFIGURATIONPRIVATE_H
diff --git a/src/network/bearer/qnetworkmanagerservice_p.cpp b/src/network/bearer/qnetworkmanagerservice_p.cpp
deleted file mode 100644
index 5804686..0000000
--- a/src/network/bearer/qnetworkmanagerservice_p.cpp
+++ /dev/null
@@ -1,1047 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QObject>
-#include <QList>
-#include <QtDBus>
-#include <QDBusConnection>
-#include <QDBusError>
-#include <QDBusInterface>
-#include <QDBusMessage>
-#include <QDBusReply>
-#include <QDBusPendingCallWatcher>
-#include <QDBusObjectPath>
-#include <QDBusPendingCall>
-
-#include <NetworkManager/NetworkManager.h>
-
-#include <qnmdbushelper_p.h>
-#include "qnetworkmanagerservice_p.h"
-
-//Q_DECLARE_METATYPE(QList<uint>)
-QTM_BEGIN_NAMESPACE
-
-static QDBusConnection dbusConnection = QDBusConnection::systemBus();
-//static QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbusConnection);
-
-class QNetworkManagerInterfacePrivate
-{
-public:
- QDBusInterface *connectionInterface;
- bool valid;
-};
-
-QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
- : QObject(parent), nmDBusHelper(0)
-{
- d = new QNetworkManagerInterfacePrivate();
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- NM_DBUS_INTERFACE,
- dbusConnection);
- if (!d->connectionInterface->isValid()) {
- qWarning() << "Could not find NetworkManager";
- d->valid = false;
- return;
- }
- d->valid = true;
- nmDBusHelper = new QNmDBusHelper;
- connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
- this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
- connect(nmDBusHelper,SIGNAL(pathForStateChanged(const QString &, quint32)),
- this, SIGNAL(stateChanged(const QString&, quint32)));
-
-}
-
-QNetworkManagerInterface::~QNetworkManagerInterface()
-{
- if (nmDBusHelper)
- delete nmDBusHelper;
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterface::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerInterface::setConnections()
-{
- if(!isValid() )
- return false;
- bool allOk = false;
- if (!dbusConnection.connect(NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- NM_DBUS_INTERFACE,
- "PropertiesChanged",
- nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>)))) {
- allOk = true;
- }
- if (!dbusConnection.connect(NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- NM_DBUS_INTERFACE,
- "DeviceAdded",
- this,SIGNAL(deviceAdded(QDBusObjectPath)))) {
- allOk = true;
- }
- if (!dbusConnection.connect(NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- NM_DBUS_INTERFACE,
- "DeviceRemoved",
- this,SIGNAL(deviceRemoved(QDBusObjectPath)))) {
- allOk = true;
- }
-
- return allOk;
-}
-
-QDBusInterface *QNetworkManagerInterface::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() const
-{
- QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call("GetDevices");
- return reply.value();
-}
-
-void QNetworkManagerInterface::activateConnection( const QString &serviceName,
- QDBusObjectPath connectionPath,
- QDBusObjectPath devicePath,
- QDBusObjectPath specificObject)
-{
- QDBusPendingCall pendingCall = d->connectionInterface->asyncCall("ActivateConnection",
- QVariant(serviceName),
- QVariant::fromValue(connectionPath),
- QVariant::fromValue(devicePath),
- QVariant::fromValue(specificObject));
-
- QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall, this);
- connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SIGNAL(activationFinished(QDBusPendingCallWatcher*)));
-}
-
-void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) const
-{
- d->connectionInterface->call("DeactivateConnection", QVariant::fromValue(connectionPath));
-}
-
-bool QNetworkManagerInterface::wirelessEnabled() const
-{
- return d->connectionInterface->property("WirelessEnabled").toBool();
-}
-
-bool QNetworkManagerInterface::wirelessHardwareEnabled() const
-{
- return d->connectionInterface->property("WirelessHardwareEnabled").toBool();
-}
-
-QList <QDBusObjectPath> QNetworkManagerInterface::activeConnections() const
-{
- QVariant prop = d->connectionInterface->property("ActiveConnections");
- return prop.value<QList<QDBusObjectPath> >();
-}
-
-quint32 QNetworkManagerInterface::state()
-{
- return d->connectionInterface->property("State").toUInt();
-}
-
-/////////////
-class QNetworkManagerInterfaceAccessPointPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
-QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent)
- : QObject(parent), nmDBusHelper(0)
-{
- d = new QNetworkManagerInterfaceAccessPointPrivate();
- d->path = dbusPathName;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_ACCESS_POINT,
- dbusConnection);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
- qWarning() << "Could not find InterfaceAccessPoint";
- return;
- }
- d->valid = true;
-
-}
-
-QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint()
-{
- if (nmDBusHelper)
- delete nmDBusHelper;
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceAccessPoint::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerInterfaceAccessPoint::setConnections()
-{
- if(!isValid() )
- 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>)));
-
- if(dbusConnection.connect(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_ACCESS_POINT,
- "PropertiesChanged",
- nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>))) ) {
- allOk = true;
-
- }
- return allOk;
-}
-
-QDBusInterface *QNetworkManagerInterfaceAccessPoint::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::flags() const
-{
- return d->connectionInterface->property("Flags").toUInt();
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::wpaFlags() const
-{
- return d->connectionInterface->property("WpaFlags").toUInt();
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::rsnFlags() const
-{
- return d->connectionInterface->property("RsnFlags").toUInt();
-}
-
-QString QNetworkManagerInterfaceAccessPoint::ssid() const
-{
- return d->connectionInterface->property("Ssid").toString();
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::frequency() const
-{
- return d->connectionInterface->property("Frequency").toUInt();
-}
-
-QString QNetworkManagerInterfaceAccessPoint::hwAddress() const
-{
- return d->connectionInterface->property("HwAddress").toString();
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::mode() const
-{
- return d->connectionInterface->property("Mode").toUInt();
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::maxBitrate() const
-{
- return d->connectionInterface->property("MaxBitrate").toUInt();
-}
-
-quint32 QNetworkManagerInterfaceAccessPoint::strength() const
-{
- return d->connectionInterface->property("Strength").toUInt();
-}
-
-/////////////
-class QNetworkManagerInterfaceDevicePrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
-QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent)
- : QObject(parent), nmDBusHelper(0)
-{
- d = new QNetworkManagerInterfaceDevicePrivate();
- d->path = deviceObjectPath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_DEVICE,
- dbusConnection);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
- qWarning() << "Could not find NetworkManager";
- return;
- }
- d->valid = true;
-}
-
-QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice()
-{
- if (nmDBusHelper)
- delete nmDBusHelper;
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceDevice::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerInterfaceDevice::setConnections()
-{
- if(!isValid() )
- 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)));
- if(dbusConnection.connect(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_DEVICE,
- "StateChanged",
- nmDBusHelper,SLOT(deviceStateChanged(quint32)))) {
- allOk = true;
- }
- return allOk;
-}
-
-QDBusInterface *QNetworkManagerInterfaceDevice::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-QString QNetworkManagerInterfaceDevice::udi() const
-{
- return d->connectionInterface->property("Udi").toString();
-}
-
-QNetworkInterface QNetworkManagerInterfaceDevice::interface() const
-{
- return QNetworkInterface::interfaceFromName(d->connectionInterface->property("Interface").toString());
-}
-
-quint32 QNetworkManagerInterfaceDevice::ip4Address() const
-{
- return d->connectionInterface->property("Ip4Address").toUInt();
-}
-
-quint32 QNetworkManagerInterfaceDevice::state() const
-{
- return d->connectionInterface->property("State").toUInt();
-}
-
-quint32 QNetworkManagerInterfaceDevice::deviceType() const
-{
- return d->connectionInterface->property("DeviceType").toUInt();
-}
-
-QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const
-{
- QVariant prop = d->connectionInterface->property("Ip4Config");
- return prop.value<QDBusObjectPath>();
-}
-
-/////////////
-class QNetworkManagerInterfaceDeviceWiredPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
-QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent)
- : QObject(parent), nmDBusHelper(0)
-{
- d = new QNetworkManagerInterfaceDeviceWiredPrivate();
- d->path = ifaceDevicePath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRED,
- dbusConnection, parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
- qWarning() << "Could not find InterfaceDeviceWired";
- return;
- }
- d->valid = true;
-}
-
-QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired()
-{
- if (nmDBusHelper)
- delete nmDBusHelper;
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceDeviceWired::isValid()
-{
-
- return d->valid;
-}
-
-bool QNetworkManagerInterfaceDeviceWired::setConnections()
-{
- if(!isValid() )
- 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>)));
- if(dbusConnection.connect(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRED,
- "PropertiesChanged",
- nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>))) ) {
- allOk = true;
- }
- return allOk;
-}
-
-QDBusInterface *QNetworkManagerInterfaceDeviceWired::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-QString QNetworkManagerInterfaceDeviceWired::hwAddress() const
-{
- return d->connectionInterface->property("HwAddress").toString();
-}
-
-quint32 QNetworkManagerInterfaceDeviceWired::speed() const
-{
- return d->connectionInterface->property("Speed").toUInt();
-}
-
-bool QNetworkManagerInterfaceDeviceWired::carrier() const
-{
- return d->connectionInterface->property("Carrier").toBool();
-}
-
-/////////////
-class QNetworkManagerInterfaceDeviceWirelessPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
-QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent)
- : QObject(parent), nmDBusHelper(0)
-{
- d = new QNetworkManagerInterfaceDeviceWirelessPrivate();
- d->path = ifaceDevicePath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- dbusConnection, parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
- qWarning() << "Could not find InterfaceDeviceWireless";
- return;
- }
- d->valid = true;
-}
-
-QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless()
-{
- if (nmDBusHelper)
- delete nmDBusHelper;
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerInterfaceDeviceWireless::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerInterfaceDeviceWireless::setConnections()
-{
- if(!isValid() )
- 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>)));
-
- connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(const QString &,QDBusObjectPath)),
- this,SIGNAL(accessPointAdded(const QString &,QDBusObjectPath)));
-
- connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(const QString &,QDBusObjectPath)),
- this,SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath)));
-
- if(!dbusConnection.connect(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- "AccessPointAdded",
- nmDBusHelper, SLOT(slotAccessPointAdded( QDBusObjectPath )))) {
- allOk = true;
- }
-
-
- if(!dbusConnection.connect(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- "AccessPointRemoved",
- nmDBusHelper, SLOT(slotAccessPointRemoved( QDBusObjectPath )))) {
- allOk = true;
- }
-
-
- if(!dbusConnection.connect(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- "PropertiesChanged",
- nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>)))) {
- allOk = true;
- }
-
- return allOk;
-}
-
-QDBusInterface *QNetworkManagerInterfaceDeviceWireless::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints()
-{
- QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call("GetAccessPoints");
- return reply.value();
-}
-
-QString QNetworkManagerInterfaceDeviceWireless::hwAddress() const
-{
- return d->connectionInterface->property("HwAddress").toString();
-}
-
-quint32 QNetworkManagerInterfaceDeviceWireless::mode() const
-{
- return d->connectionInterface->property("Mode").toUInt();
-}
-
-quint32 QNetworkManagerInterfaceDeviceWireless::bitrate() const
-{
- return d->connectionInterface->property("Bitrate").toUInt();
-}
-
-QDBusObjectPath QNetworkManagerInterfaceDeviceWireless::activeAccessPoint() const
-{
- return d->connectionInterface->property("ActiveAccessPoint").value<QDBusObjectPath>();
-}
-
-quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const
-{
- return d->connectionInterface->property("WirelelessCapabilities").toUInt();
-}
-
-/////////////
-class QNetworkManagerSettingsPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
-QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerSettingsPrivate();
- d->path = settingsService;
- d->connectionInterface = new QDBusInterface(settingsService,
- NM_DBUS_PATH_SETTINGS,
- NM_DBUS_IFACE_SETTINGS,
- dbusConnection);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
- qWarning() << "Could not find NetworkManagerSettings";
- return;
- }
- d->valid = true;
-}
-
-QNetworkManagerSettings::~QNetworkManagerSettings()
-{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerSettings::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerSettings::setConnections()
-{
- bool allOk = false;
-
- if (!dbusConnection.connect(d->path, NM_DBUS_PATH_SETTINGS,
- NM_DBUS_IFACE_SETTINGS, "NewConnection",
- this, SIGNAL(newConnection(QDBusObjectPath)))) {
- allOk = true;
- }
-
- return allOk;
-}
-
-QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
-{
- QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call("ListConnections");
- return reply.value();
-}
-
-QDBusInterface *QNetworkManagerSettings::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-
-/////////////
-class QNetworkManagerSettingsConnectionPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- QString service;
- QNmSettingsMap settingsMap;
- bool valid;
-};
-
-QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent)
- : QObject(parent), nmDBusHelper(0)
-{
- qDBusRegisterMetaType<QNmSettingsMap>();
- d = new QNetworkManagerSettingsConnectionPrivate();
- d->path = connectionObjectPath;
- d->service = settingsService;
- d->connectionInterface = new QDBusInterface(settingsService,
- d->path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION,
- dbusConnection, parent);
- if (!d->connectionInterface->isValid()) {
- qWarning() << "Could not find NetworkManagerSettingsConnection";
- d->valid = false;
- return;
- }
- d->valid = true;
- QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call("GetSettings");
- d->settingsMap = rep.value();
-}
-
-QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection()
-{
- if (nmDBusHelper)
- delete nmDBusHelper;
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerSettingsConnection::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerSettingsConnection::setConnections()
-{
- if(!isValid() )
- return false;
-
- bool allOk = false;
- if(!dbusConnection.connect(d->service, d->path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION, "NewConnection",
- this, SIGNAL(updated(QNmSettingsMap)))) {
- allOk = true;
- }
-
- if (nmDBusHelper)
- delete nmDBusHelper;
- nmDBusHelper = 0;
- nmDBusHelper = new QNmDBusHelper;
- connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(const QString &)),
- this,SIGNAL(removed( const QString &)));
-
- if (!dbusConnection.connect(d->service, d->path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION, "Removed",
- nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
- allOk = true;
- }
-
- return allOk;
-}
-//QNetworkManagerSettingsConnection::update(QNmSettingsMap map)
-//{
-// d->connectionInterface->call("Update", QVariant::fromValue(map));
-//}
-
-QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-QNmSettingsMap QNetworkManagerSettingsConnection::getSettings()
-{
- QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call("GetSettings");
- d->settingsMap = rep.value();
- return d->settingsMap;
-}
-
-NMDeviceType QNetworkManagerSettingsConnection::getType()
-{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("type");
- while (ii != innerMap.end() && ii.key() == "type") {
- QString devType = ii.value().toString();
- if (devType == "802-3-ethernet") {
- return DEVICE_TYPE_802_3_ETHERNET;
- }
- if (devType == "802-11-wireless") {
- return DEVICE_TYPE_802_11_WIRELESS;
- }
- ii++;
- }
- i++;
- }
- return DEVICE_TYPE_UNKNOWN;
-}
-
-bool QNetworkManagerSettingsConnection::isAutoConnect()
-{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("autoconnect");
- while (ii != innerMap.end() && ii.key() == "autoconnect") {
- return ii.value().toBool();
- ii++;
- }
- i++;
- }
- return true; //default networkmanager is autoconnect
-}
-
-quint64 QNetworkManagerSettingsConnection::getTimestamp()
-{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("timestamp");
- while (ii != innerMap.end() && ii.key() == "timestamp") {
- return ii.value().toUInt();
- ii++;
- }
- i++;
- }
- return 0;
-}
-
-QString QNetworkManagerSettingsConnection::getId()
-{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("id");
- while (ii != innerMap.end() && ii.key() == "id") {
- return ii.value().toString();
- ii++;
- }
- i++;
- }
- return QString();
-}
-
-QString QNetworkManagerSettingsConnection::getUuid()
-{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("uuid");
- while (ii != innerMap.end() && ii.key() == "uuid") {
- return ii.value().toString();
- ii++;
- }
- i++;
- }
- // is no uuid, return the connection path
- return d->connectionInterface->path();
-}
-
-QString QNetworkManagerSettingsConnection::getSsid()
-{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("802-11-wireless");
- while (i != d->settingsMap.end() && i.key() == "802-11-wireless") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("ssid");
- while (ii != innerMap.end() && ii.key() == "ssid") {
- return ii.value().toString();
- ii++;
- }
- i++;
- }
- return QString();
-}
-
-QString QNetworkManagerSettingsConnection::getMacAddress()
-{
- if(getType() == DEVICE_TYPE_802_3_ETHERNET) {
- QNmSettingsMap::const_iterator i = d->settingsMap.find("802-3-ethernet");
- while (i != d->settingsMap.end() && i.key() == "802-3-ethernet") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("mac-address");
- while (ii != innerMap.end() && ii.key() == "mac-address") {
- return ii.value().toString();
- ii++;
- }
- i++;
- }
- }
-
- else if(getType() == DEVICE_TYPE_802_11_WIRELESS) {
- QNmSettingsMap::const_iterator i = d->settingsMap.find("802-11-wireless");
- while (i != d->settingsMap.end() && i.key() == "802-11-wireless") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("mac-address");
- while (ii != innerMap.end() && ii.key() == "mac-address") {
- return ii.value().toString();
- ii++;
- }
- i++;
- }
- }
- return QString();
-}
-
-QStringList QNetworkManagerSettingsConnection::getSeenBssids()
-{
- if(getType() == DEVICE_TYPE_802_11_WIRELESS) {
- QNmSettingsMap::const_iterator i = d->settingsMap.find("802-11-wireless");
- while (i != d->settingsMap.end() && i.key() == "802-11-wireless") {
- QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("seen-bssids");
- while (ii != innerMap.end() && ii.key() == "seen-bssids") {
- return ii.value().toStringList();
- ii++;
- }
- i++;
- }
- }
- return QStringList();
-}
-
-/////////////
-class QNetworkManagerConnectionActivePrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
-QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString &activeConnectionObjectPath, QObject *parent)
- : QObject(parent), nmDBusHelper(0)
-{
- d = new QNetworkManagerConnectionActivePrivate();
- d->path = activeConnectionObjectPath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
- dbusConnection, parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
- qWarning() << "Could not find NetworkManagerSettingsConnection";
- return;
- }
- d->valid = true;
-}
-
-QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive()
-{
- if (nmDBusHelper)
- delete nmDBusHelper;
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerConnectionActive::isValid()
-{
- return d->valid;
-}
-
-bool QNetworkManagerConnectionActive::setConnections()
-{
- if(!isValid() )
- 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>)));
- if(dbusConnection.connect(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
- "PropertiesChanged",
- nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>))) ) {
- allOk = true;
- }
-
- return allOk;
-}
-
-QDBusInterface *QNetworkManagerConnectionActive::connectionInterface() const
-{
- return d->connectionInterface;
-}
-
-QString QNetworkManagerConnectionActive::serviceName() const
-{
- return d->connectionInterface->property("ServiceName").toString();
-}
-
-QDBusObjectPath QNetworkManagerConnectionActive::connection() const
-{
- QVariant prop = d->connectionInterface->property("Connection");
- return prop.value<QDBusObjectPath>();
-}
-
-QDBusObjectPath QNetworkManagerConnectionActive::specificObject() const
-{
- QVariant prop = d->connectionInterface->property("SpecificObject");
- return prop.value<QDBusObjectPath>();
-}
-
-QList<QDBusObjectPath> QNetworkManagerConnectionActive::devices() const
-{
- QVariant prop = d->connectionInterface->property("Devices");
- return prop.value<QList<QDBusObjectPath> >();
-}
-
-quint32 QNetworkManagerConnectionActive::state() const
-{
- return d->connectionInterface->property("State").toUInt();
-}
-
-bool QNetworkManagerConnectionActive::defaultRoute() const
-{
- return d->connectionInterface->property("Default").toBool();
-}
-
-
-////
-class QNetworkManagerIp4ConfigPrivate
-{
-public:
- QDBusInterface *connectionInterface;
- QString path;
- bool valid;
-};
-
-QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectPath, QObject *parent)
- : QObject(parent)
-{
- d = new QNetworkManagerIp4ConfigPrivate();
- d->path = deviceObjectPath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
- d->path,
- NM_DBUS_INTERFACE_IP4_CONFIG,
- dbusConnection, parent);
- if (!d->connectionInterface->isValid()) {
- d->valid = false;
- qWarning() << "Could not find NetworkManagerIp4Config";
- return;
- }
- d->valid = true;
-}
-
-QNetworkManagerIp4Config::~QNetworkManagerIp4Config()
-{
- delete d->connectionInterface;
- delete d;
-}
-
-bool QNetworkManagerIp4Config::isValid()
-{
- return d->valid;
-}
-
-QStringList QNetworkManagerIp4Config::domains() const
-{
- return d->connectionInterface->property("Domains").toStringList();
-}
-
-#include "moc_qnetworkmanagerservice_p.cpp"
-
-QTM_END_NAMESPACE
diff --git a/src/network/bearer/qnetworkmanagerservice_p.h b/src/network/bearer/qnetworkmanagerservice_p.h
deleted file mode 100644
index 8569e71..0000000
--- a/src/network/bearer/qnetworkmanagerservice_p.h
+++ /dev/null
@@ -1,400 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKMANAGERSERVICE_H
-#define QNETWORKMANAGERSERVICE_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <NetworkManager/NetworkManager.h>
-#include <QtDBus>
-#include <QDBusConnection>
-#include <QDBusError>
-#include <QDBusInterface>
-#include <QDBusMessage>
-#include <QDBusReply>
-#include <QNetworkInterface>
-
-
-#include <QDBusPendingCallWatcher>
-#include <qnmdbushelper_p.h>
-
-
-QTM_BEGIN_NAMESPACE
-typedef QMap< QString, QMap<QString,QVariant> > QNmSettingsMap;
-typedef QList<quint32> ServerThing;
-QTM_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QNmSettingsMap))
-Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(ServerThing))
-
-
-QTM_BEGIN_NAMESPACE
-class QNetworkManagerInterfacePrivate;
-class QNetworkManagerInterface : public QObject
-{
- Q_OBJECT
-
-public:
-
- QNetworkManagerInterface(QObject *parent = 0);
- ~QNetworkManagerInterface();
-
- QList <QDBusObjectPath> getDevices() const;
- void activateConnection(const QString &serviceName, QDBusObjectPath connection, QDBusObjectPath device, QDBusObjectPath specificObject);
- void deactivateConnection(QDBusObjectPath connectionPath) const;
-
- QDBusObjectPath path() const;
- QDBusInterface *connectionInterface() const;
-
- bool wirelessEnabled() const;
- bool wirelessHardwareEnabled() const;
- QList <QDBusObjectPath> activeConnections() const;
- quint32 state();
- bool setConnections();
- bool isValid();
-
-Q_SIGNALS:
- void deviceAdded(QDBusObjectPath);
- void deviceRemoved(QDBusObjectPath);
- void propertiesChanged( const QString &, QMap<QString,QVariant>);
- void stateChanged(const QString&, quint32);
- void activationFinished(QDBusPendingCallWatcher*);
-
-private Q_SLOTS:
-private:
-// Q_DISABLE_COPY(QNetworkManagerInterface); ??
- QNetworkManagerInterfacePrivate *d;
- QNmDBusHelper *nmDBusHelper;
-}; //end QNetworkManagerInterface
-
-////////
-class QNetworkManagerInterfaceAccessPointPrivate;
-class QNetworkManagerInterfaceAccessPoint : public QObject
-{
- Q_OBJECT
-
-public:
-
- // NM_DEVICE_STATE
- enum DeviceState {
- Unknown = 0,
- Unmanaged,
- Unavailable,
- Disconnected,
- Prepare,
- Config,
- NeedAuthentication,
- IpConfig,
- Activated,
- Failed
- };
-
- enum ApFlag {
- ApNone = 0x0,
- Privacy = 0x1
- };
-
- Q_DECLARE_FLAGS(ApFlags, ApFlag);
-
- enum ApSecurityFlag {
- ApSecurityNone = 0x0,
- PairWep40 = 0x1,
- PairWep104 = 0x2,
- PairTkip = 0x4,
- PairCcmp = 0x8,
- GroupWep40 = 0x10,
- GroupWep104 = 0x20,
- GroupTkip = 0x40,
- GroupCcmp = 0x80,
- KeyPsk = 0x100,
- Key8021x = 0x200
- };
-
- Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag);
-
- QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = 0);
- ~QNetworkManagerInterfaceAccessPoint();
-
- QDBusInterface *connectionInterface() const;
-
- quint32 flags() const;
- quint32 wpaFlags() const;
- quint32 rsnFlags() const;
- QString ssid() const;
- quint32 frequency() const;
- QString hwAddress() const;
- quint32 mode() const;
- quint32 maxBitrate() const;
- quint32 strength() const;
- bool setConnections();
- bool isValid();
-
-Q_SIGNALS:
- void propertiesChanged(QMap <QString,QVariant>);
- void propertiesChanged( const QString &, QMap<QString,QVariant>);
-private:
- QNetworkManagerInterfaceAccessPointPrivate *d;
- QNmDBusHelper *nmDBusHelper;
-
-}; //end QNetworkManagerInterfaceAccessPoint
-
-////////
-class QNetworkManagerInterfaceDevicePrivate;
-class QNetworkManagerInterfaceDevice : public QObject
-{
- Q_OBJECT
-
-public:
-
- QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = 0);
- ~QNetworkManagerInterfaceDevice();
-
- QString udi() const;
- QNetworkInterface interface() const;
- QDBusInterface *connectionInterface() const;
- quint32 ip4Address() const;
- quint32 state() const;
- quint32 deviceType() const;
-
- QDBusObjectPath ip4config() const;
- bool setConnections();
- bool isValid();
-
-Q_SIGNALS:
- void stateChanged(const QString &, quint32);
-
-private:
- QNetworkManagerInterfaceDevicePrivate *d;
- QNmDBusHelper *nmDBusHelper;
-}; //end QNetworkManagerInterfaceDevice
-
-////////
-class QNetworkManagerInterfaceDeviceWiredPrivate;
-class QNetworkManagerInterfaceDeviceWired : public QObject
-{
- Q_OBJECT
-
-public:
-
- QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent = 0);
- ~QNetworkManagerInterfaceDeviceWired();
-
- QDBusInterface *connectionInterface() const;
- QString hwAddress() const;
- quint32 speed() const;
- bool carrier() const;
- bool setConnections();
- bool isValid();
-
-Q_SIGNALS:
- void propertiesChanged( const QString &, QMap<QString,QVariant>);
-private:
- QNetworkManagerInterfaceDeviceWiredPrivate *d;
- QNmDBusHelper *nmDBusHelper;
-}; // end QNetworkManagerInterfaceDeviceWired
-
-////
-class QNetworkManagerInterfaceDeviceWirelessPrivate;
-class QNetworkManagerInterfaceDeviceWireless : public QObject
-{
- Q_OBJECT
-
-public:
-
- enum DeviceCapability {
- None = 0x0,
- Wep40 = 0x1,
- Wep104 = 0x2,
- Tkip = 0x4,
- Ccmp = 0x8,
- Wpa = 0x10,
- Rsn = 0x20
- };
-
- QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent = 0);
- ~QNetworkManagerInterfaceDeviceWireless();
-
- QDBusObjectPath path() const;
- QList <QDBusObjectPath> getAccessPoints();
- QDBusInterface *connectionInterface() const;
-
- QString hwAddress() const;
- quint32 mode() const;
- quint32 bitrate() const;
- QDBusObjectPath activeAccessPoint() const;
- quint32 wirelessCapabilities() const;
- bool setConnections();
- bool isValid();
-
-Q_SIGNALS:
- void propertiesChanged( const QString &, QMap<QString,QVariant>);
- void accessPointAdded(const QString &,QDBusObjectPath);
- void accessPointRemoved(const QString &,QDBusObjectPath);
-private:
- QNetworkManagerInterfaceDeviceWirelessPrivate *d;
- QNmDBusHelper *nmDBusHelper;
-}; // end QNetworkManagerInterfaceDeviceWireless
-
-////
-class QNetworkManagerSettingsPrivate;
-class QNetworkManagerSettings : public QObject
-{
- Q_OBJECT
-
-public:
-
- QNetworkManagerSettings(const QString &settingsService, QObject *parent = 0);
- ~QNetworkManagerSettings();
-
- QDBusInterface *connectionInterface() const;
- QList <QDBusObjectPath> listConnections();
- bool setConnections();
- bool isValid();
-
-Q_SIGNALS:
- void newConnection(QDBusObjectPath);
-private:
- QNetworkManagerSettingsPrivate *d;
-}; //end QNetworkManagerSettings
-
-////
-class QNetworkManagerSettingsConnectionPrivate;
-class QNetworkManagerSettingsConnection : public QObject
-{
- Q_OBJECT
-
-public:
-
- QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = 0);
- ~QNetworkManagerSettingsConnection();
-
- QDBusInterface *connectionInterface() const;
- QNmSettingsMap getSettings();
- // void update(QNmSettingsMap map);
- bool setConnections();
- NMDeviceType getType();
- bool isAutoConnect();
- quint64 getTimestamp();
- QString getId();
- QString getUuid();
- QString getSsid();
- QString getMacAddress();
- QStringList getSeenBssids();
- bool isValid();
-
-Q_SIGNALS:
-
- void updated(QMap< QString, QMap<QString,QVariant> > s);
- void removed(const QString &);
-
-private:
- QNmDBusHelper *nmDBusHelper;
- QNetworkManagerSettingsConnectionPrivate *d;
-}; //end QNetworkManagerSettingsConnection
-
-////
-class QNetworkManagerConnectionActivePrivate;
-class QNetworkManagerConnectionActive : public QObject
-{
- Q_OBJECT
-
-public:
-
- enum ActiveConnectionState {
- Unknown = 0,
- Activating = 1,
- Activated = 2
- };
-
- QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = 0);
- ~ QNetworkManagerConnectionActive();
-
- QDBusInterface *connectionInterface() const;
- QString serviceName() const;
- QDBusObjectPath connection() const;
- QDBusObjectPath specificObject() const;
- QList<QDBusObjectPath> devices() const;
- quint32 state() const;
- bool defaultRoute() const;
- bool setConnections();
- bool isValid();
-
-
-Q_SIGNALS:
- void propertiesChanged(QList<QDBusObjectPath>);
- void propertiesChanged( const QString &, QMap<QString,QVariant>);
-private:
- QNetworkManagerConnectionActivePrivate *d;
- QNmDBusHelper *nmDBusHelper;
-}; //QNetworkManagerConnectionActive
-
-////
-class QNetworkManagerIp4ConfigPrivate;
-class QNetworkManagerIp4Config : public QObject
-{
- Q_OBJECT
-
-public:
- QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0);
- ~QNetworkManagerIp4Config();
-
- // QList<quint32> nameservers();
- QStringList domains() const;
- bool isValid();
-
- private:
- QNetworkManagerIp4ConfigPrivate *d;
-};
-////
-
-QTM_END_NAMESPACE
-
-#endif //QNETWORKMANAGERSERVICE_H
diff --git a/src/network/bearer/qnetworksession.cpp b/src/network/bearer/qnetworksession.cpp
index 6171350..74b9787 100644
--- a/src/network/bearer/qnetworksession.cpp
+++ b/src/network/bearer/qnetworksession.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -52,7 +52,7 @@
#include "qnetworksession_p.h"
#endif
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
/*!
\class QNetworkSession
@@ -525,14 +525,14 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const
if (!d->publicConfig.isValid())
return QVariant();
- if (key == "ActiveConfiguration") {
+ if (key == QLatin1String("ActiveConfiguration")) {
if (!d->isOpen)
return QString();
else
return d->activeConfig.identifier();
}
- if (key == "UserChoiceConfiguration") {
+ if (key == QLatin1String("UserChoiceConfiguration")) {
if (!d->isOpen || d->publicConfig.type() != QNetworkConfiguration::UserChoice)
return QString();
@@ -555,9 +555,10 @@ QVariant QNetworkSession::sessionProperty(const QString& key) const
*/
void QNetworkSession::setSessionProperty(const QString& key, const QVariant& value)
{
- if (key == "ActiveConfiguration"
- || key == "UserChoiceConfiguration")
+ if (key == QLatin1String("ActiveConfiguration") ||
+ key == QLatin1String("UserChoiceConfiguration")) {
return;
+ }
d->setSessionProperty(key, value);
}
@@ -700,4 +701,4 @@ void QNetworkSession::disconnectNotify(const char *signal)
#include "moc_qnetworksession.cpp"
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworksession.h b/src/network/bearer/qnetworksession.h
index 7e52674..6138166 100644
--- a/src/network/bearer/qnetworksession.h
+++ b/src/network/bearer/qnetworksession.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -42,8 +42,6 @@
#ifndef QNETWORKSESSION_H
#define QNETWORKSESSION_H
-#include "qmobilityglobal.h"
-
#include <QtCore/qobject.h>
#include <QtCore/qshareddata.h>
#include <QtCore/qstring.h>
@@ -54,10 +52,10 @@
QT_BEGIN_HEADER
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class QNetworkSessionPrivate;
-class Q_BEARER_EXPORT QNetworkSession : public QObject
+class Q_NETWORK_EXPORT QNetworkSession : public QObject
{
Q_OBJECT
public:
@@ -127,7 +125,7 @@ private:
friend class QNetworkSessionPrivate;
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/network/bearer/qnetworksession_maemo.cpp b/src/network/bearer/qnetworksession_maemo.cpp
index b3afc77..6fb4453 100644
--- a/src/network/bearer/qnetworksession_maemo.cpp
+++ b/src/network/bearer/qnetworksession_maemo.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -54,7 +54,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
static QHash<QString, QVariant> properties;
@@ -1161,4 +1161,4 @@ QNetworkSession::SessionError QNetworkSessionPrivate::error() const
#include "qnetworksession_maemo.moc"
#include "moc_qnetworksession_maemo_p.cpp"
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworksession_maemo_p.h b/src/network/bearer/qnetworksession_maemo_p.h
index 892262d..6febce4 100644
--- a/src/network/bearer/qnetworksession_maemo_p.h
+++ b/src/network/bearer/qnetworksession_maemo_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -62,7 +62,7 @@
#include <icd/dbus_api.h>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class QNetworkSessionPrivate : public QObject
{
@@ -159,7 +159,7 @@ private:
void cleanupSession(void);
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
#endif //QNETWORKSESSIONPRIVATE_H
diff --git a/src/network/bearer/qnetworksession_p.cpp b/src/network/bearer/qnetworksession_p.cpp
index 1dfc949..b615797 100644
--- a/src/network/bearer/qnetworksession_p.cpp
+++ b/src/network/bearer/qnetworksession_p.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -42,73 +42,24 @@
#include "qnetworksession_p.h"
#include "qnetworksession.h"
#include "qnetworksessionengine_p.h"
-#include "qgenericengine_p.h"
+#include "qnetworkconfigmanager_p.h"
-#ifdef Q_OS_WIN
-#include "qnlaengine_win_p.h"
-#endif
-#ifdef Q_OS_WIN32
-#include "qnativewifiengine_win_p.h"
-#endif
-#ifdef Q_OS_DARWIN
-#include "qcorewlanengine_mac_p.h"
-#endif
#include <QtCore/qstringlist.h>
#include <QtCore/qdebug.h>
#include <QtCore/qmutex.h>
#include <QtNetwork/qnetworkinterface.h>
-#if defined(BACKEND_NM)
-#include "qnmwifiengine_unix_p.h"
-#endif
-
-QTM_BEGIN_NAMESPACE
-
-#if defined(BACKEND_NM)
-static bool NetworkManagerAvailable()
-{
- QDBusConnection dbusConnection = QDBusConnection::systemBus();
- if (dbusConnection.isConnected()) {
- QDBusConnectionInterface *dbiface = dbusConnection.interface();
- QDBusReply<bool> reply = dbiface->isServiceRegistered("org.freedesktop.NetworkManager");
- if (reply.isValid())
- return reply.value();
- }
- return false;
-}
-#endif
+QT_BEGIN_NAMESPACE
static QNetworkSessionEngine *getEngineFromId(const QString &id)
{
-#ifdef Q_OS_WIN
- QNlaEngine *nla = QNlaEngine::instance();
- if (nla && nla->hasIdentifier(id))
- return nla;
-#endif
+ QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
-#ifdef Q_OS_WIN32
- QNativeWifiEngine *nativeWifi = QNativeWifiEngine::instance();
- if (nativeWifi && nativeWifi->hasIdentifier(id))
- return nativeWifi;
-#endif
-
-#if defined(BACKEND_NM)
- if(NetworkManagerAvailable()) {
- QNmWifiEngine *nmwiifi = QNmWifiEngine::instance();
- if (nmwiifi && nmwiifi->hasIdentifier(id))
- return nmwiifi;
+ foreach (QNetworkSessionEngine *engine, priv->sessionEngines) {
+ if (engine->hasIdentifier(id))
+ return engine;
}
-#endif
-#ifdef Q_OS_DARWIN
- QCoreWlanEngine *coreWifi = QCoreWlanEngine::instance();
- if (coreWifi && coreWifi->hasIdentifier(id))
- return coreWifi;
-
-#endif
- QGenericEngine *generic = QGenericEngine::instance();
- if (generic && generic->hasIdentifier(id))
- return generic;
return 0;
}
@@ -154,6 +105,7 @@ void QNetworkSessionPrivate::syncStateWithInterface()
this, SLOT(forcedSessionClose(QNetworkConfiguration)));
opened = false;
+ isOpen = false;
state = QNetworkSession::Invalid;
lastError = QNetworkSession::UnknownSessionError;
@@ -320,7 +272,7 @@ QNetworkSession::SessionError QNetworkSessionPrivate::error() const
quint64 QNetworkSessionPrivate::bytesWritten() const
{
-#if defined(BACKEND_NM)
+#if defined(BACKEND_NM) && 0
if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) {
if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
foreach (const QNetworkConfiguration &config, publicConfig.children()) {
@@ -338,7 +290,7 @@ quint64 QNetworkSessionPrivate::bytesWritten() const
quint64 QNetworkSessionPrivate::bytesReceived() const
{
-#if defined(BACKEND_NM)
+#if defined(BACKEND_NM) && 0
if( NetworkManagerAvailable() && state == QNetworkSession::Connected ) {
if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) {
foreach (const QNetworkConfiguration &config, publicConfig.children()) {
@@ -391,6 +343,7 @@ void QNetworkSessionPrivate::updateStateFromServiceNetwork()
}
state = QNetworkSession::Connected;
+ qDebug() << oldState << "->" << state;
if (state != oldState)
emit q->stateChanged(state);
@@ -402,31 +355,22 @@ void QNetworkSessionPrivate::updateStateFromServiceNetwork()
else
state = QNetworkSession::Disconnected;
+ qDebug() << oldState << "->" << state;
if (state != oldState)
emit q->stateChanged(state);
}
void QNetworkSessionPrivate::updateStateFromActiveConfig()
{
- QNetworkSession::State oldState = state;
+ if (!engine)
+ return;
- bool newActive = false;
+ QNetworkSession::State oldState = state;
- if (!activeConfig.isValid()) {
- state = QNetworkSession::Invalid;
- } else if ((activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
- state = QNetworkSession::Connected;
- newActive = opened;
- } else if ((activeConfig.state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
- state = QNetworkSession::Disconnected;
- } else if ((activeConfig.state() & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
- state = QNetworkSession::NotAvailable;
- } else if ((activeConfig.state() & QNetworkConfiguration::Undefined) == QNetworkConfiguration::Undefined) {
- state = QNetworkSession::NotAvailable;
- }
+ state = engine->sessionStateForId(activeConfig.identifier());
bool oldActive = isOpen;
- isOpen = newActive;
+ isOpen = (state == QNetworkSession::Connected) ? opened : false;
if (!oldActive && isOpen)
emit quitPendingWaitsForOpened();
@@ -443,7 +387,7 @@ void QNetworkSessionPrivate::networkConfigurationsChanged()
updateStateFromServiceNetwork();
else
updateStateFromActiveConfig();
-#if defined(BACKEND_NM)
+#if defined(BACKEND_NM) && 0
setActiveTimeStamp();
#endif
}
@@ -490,7 +434,7 @@ void QNetworkSessionPrivate::connectionError(const QString &id, QNetworkSessionE
}
}
-#if defined(BACKEND_NM)
+#if defined(BACKEND_NM) && 0
void QNetworkSessionPrivate::setActiveTimeStamp()
{
if(NetworkManagerAvailable()) {
@@ -537,6 +481,4 @@ if(serviceName.isEmpty())
}
#endif
-#include "moc_qnetworksession_p.cpp"
-QTM_END_NAMESPACE
-
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworksession_p.h b/src/network/bearer/qnetworksession_p.h
index 09fcfca..cd73c9a 100644
--- a/src/network/bearer/qnetworksession_p.h
+++ b/src/network/bearer/qnetworksession_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -55,18 +55,15 @@
#include "qnetworkconfigmanager_p.h"
#include "qnetworksession.h"
-#ifdef BEARER_ENGINE
#include "qnetworksessionengine_p.h"
-#endif
#include "qnetworksession.h"
#include <QNetworkInterface>
#include <QDateTime>
-QTM_BEGIN_NAMESPACE
-#ifdef BEARER_ENGINE
+QT_BEGIN_NAMESPACE
+
class QNetworkSessionEngine;
-#endif
class QNetworkSessionPrivate : public QObject
{
@@ -116,12 +113,10 @@ Q_SIGNALS:
void quitPendingWaitsForOpened();
private Q_SLOTS:
-#ifdef BEARER_ENGINE
void networkConfigurationsChanged();
void configurationChanged(const QNetworkConfiguration &config);
void forcedSessionClose(const QNetworkConfiguration &config);
void connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error);
-#endif
private:
QNetworkConfigurationManager manager;
@@ -145,23 +140,22 @@ private:
QNetworkSession::State state;
bool isOpen;
-#ifdef BEARER_ENGINE
bool opened;
QNetworkSessionEngine *engine;
-#endif
+
QNetworkSession::SessionError lastError;
QNetworkSession* q;
friend class QNetworkSession;
-#if defined(BEARER_ENGINE) && defined(BACKEND_NM)
+#if defined(BACKEND_NM)
QDateTime startTime;
void setActiveTimeStamp();
#endif
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
#endif //QNETWORKSESSIONPRIVATE_H
diff --git a/src/network/bearer/qnetworksession_s60_p.cpp b/src/network/bearer/qnetworksession_s60_p.cpp
index f9cb09f..4d427c8 100644
--- a/src/network/bearer/qnetworksession_s60_p.cpp
+++ b/src/network/bearer/qnetworksession_s60_p.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -49,7 +49,7 @@
#include <stdapis/sys/socket.h>
#include <stdapis/net/if.h>
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
QNetworkSessionPrivate::QNetworkSessionPrivate()
: CActive(CActive::EPriorityStandard), state(QNetworkSession::Invalid),
@@ -1131,4 +1131,4 @@ void ConnectionProgressNotifier::RunL()
#include "moc_qnetworksession_s60_p.cpp"
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworksession_s60_p.h b/src/network/bearer/qnetworksession_s60_p.h
index ed322dd..9ac5ed8 100644
--- a/src/network/bearer/qnetworksession_s60_p.h
+++ b/src/network/bearer/qnetworksession_s60_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -67,7 +67,7 @@
typedef int(*TOpenCSetdefaultifFunction)(const struct ifreq*);
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
class ConnectionProgressNotifier;
@@ -206,7 +206,7 @@ private: // Data
};
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
#endif //QNETWORKSESSIONPRIVATE_H
diff --git a/src/network/bearer/qnetworksessionengine.cpp b/src/network/bearer/qnetworksessionengine.cpp
index 55fc4f3..0aa9d19 100644
--- a/src/network/bearer/qnetworksessionengine.cpp
+++ b/src/network/bearer/qnetworksessionengine.cpp
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -41,7 +41,7 @@
#include "qnetworksessionengine_p.h"
-QTM_BEGIN_NAMESPACE
+QT_BEGIN_NAMESPACE
QNetworkSessionEngine::QNetworkSessionEngine(QObject *parent)
: QObject(parent)
@@ -50,8 +50,19 @@ QNetworkSessionEngine::QNetworkSessionEngine(QObject *parent)
QNetworkSessionEngine::~QNetworkSessionEngine()
{
+ foreach (const QString &oldIface, snapConfigurations.keys()) {
+ QNetworkConfigurationPrivatePointer priv = snapConfigurations.take(oldIface);
+ priv->isValid = false;
+ priv->id.clear();
+ }
+
+ foreach (const QString &oldIface, accessPointConfigurations.keys()) {
+ QNetworkConfigurationPrivatePointer priv = accessPointConfigurations.take(oldIface);
+ priv->isValid = false;
+ priv->id.clear();
+ }
}
#include "moc_qnetworksessionengine_p.cpp"
-QTM_END_NAMESPACE
+QT_END_NAMESPACE
diff --git a/src/network/bearer/qnetworksessionengine_p.h b/src/network/bearer/qnetworksessionengine_p.h
index 3977b15..202a7dc 100644
--- a/src/network/bearer/qnetworksessionengine_p.h
+++ b/src/network/bearer/qnetworksessionengine_p.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
-** This file is part of the Qt Mobility Components.
+** This file is part of the QtNetwork module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
@@ -53,16 +53,21 @@
// We mean it.
//
-#include <qmobilityglobal.h>
+#include "qnetworkconfiguration_p.h"
+#include "qnetworksession.h"
+
#include <QtCore/qobject.h>
#include <QtCore/qglobal.h>
#include <QtCore/qlist.h>
#include <QtCore/qstring.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qsharedpointer.h>
+
+QT_BEGIN_NAMESPACE
-QTM_BEGIN_NAMESPACE
+class QNetworkConfiguration;
-class QNetworkConfigurationPrivate;
-class QNetworkSessionEngine : public QObject
+class Q_NETWORK_EXPORT QNetworkSessionEngine : public QObject
{
Q_OBJECT
@@ -77,7 +82,6 @@ public:
QNetworkSessionEngine(QObject *parent = 0);
virtual ~QNetworkSessionEngine();
- virtual QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0) = 0;
virtual QString getInterfaceFromId(const QString &id) = 0;
virtual bool hasIdentifier(const QString &id) = 0;
@@ -88,11 +92,28 @@ public:
virtual void requestUpdate() = 0;
+ virtual QNetworkSession::State sessionStateForId(const QString &id) = 0;
+
+public:
+ //this table contains an up to date list of all configs at any time.
+ //it must be updated if configurations change, are added/removed or
+ //the members of ServiceNetworks change
+ QHash<QString, QNetworkConfigurationPrivatePointer> accessPointConfigurations;
+ QHash<QString, QNetworkConfigurationPrivatePointer> snapConfigurations;
+ QHash<QString, QNetworkConfigurationPrivatePointer> userChoiceConfigurations;
+
Q_SIGNALS:
- void configurationsChanged();
+ void configurationAdded(QNetworkConfigurationPrivatePointer config);
+ void configurationRemoved(QNetworkConfigurationPrivatePointer config);
+ void configurationChanged(QNetworkConfigurationPrivatePointer config);
+
+ void updateCompleted();
+
void connectionError(const QString &id, QNetworkSessionEngine::ConnectionError error);
};
-QTM_END_NAMESPACE
+typedef QNetworkSessionEngine QBearerEngine;
+
+QT_END_NAMESPACE
#endif
diff --git a/src/network/bearer/qnetworksessionengine_win_p.h b/src/network/bearer/qnetworksessionengine_win_p.h
deleted file mode 100644
index cf01719..0000000
--- a/src/network/bearer/qnetworksessionengine_win_p.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNETWORKSESSIONENGINE_WIN_P_H
-#define QNETWORKSESSIONENGINE_WIN_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <winsock2.h>
-#include <mswsock.h>
-#undef interface
-#include <winioctl.h>
-
-#ifndef NS_NLA
-
-#define NS_NLA 15
-
-enum NLA_BLOB_DATA_TYPE {
- NLA_RAW_DATA = 0,
- NLA_INTERFACE = 1,
- NLA_802_1X_LOCATION = 2,
- NLA_CONNECTIVITY = 3,
- NLA_ICS = 4
-};
-
-enum NLA_CONNECTIVITY_TYPE {
- NLA_NETWORK_AD_HOC = 0,
- NLA_NETWORK_MANAGED = 1,
- NLA_NETWORK_UNMANAGED = 2,
- NLA_NETWORK_UNKNOWN = 3
-};
-
-enum NLA_INTERNET {
- NLA_INTERNET_UNKNOWN = 0,
- NLA_INTERNET_NO = 1,
- NLA_INTERNET_YES = 2
-};
-
-struct NLA_BLOB {
- struct {
- NLA_BLOB_DATA_TYPE type;
- DWORD dwSize;
- DWORD nextOffset;
- } header;
-
- union {
- // NLA_RAW_DATA
- CHAR rawData[1];
-
- // NLA_INTERFACE
- struct {
- DWORD dwType;
- DWORD dwSpeed;
- CHAR adapterName[1];
- } interfaceData;
-
- // NLA_802_1X_LOCATION
- struct {
- CHAR information[1];
- } locationData;
-
- // NLA_CONNECTIVITY
- struct {
- NLA_CONNECTIVITY_TYPE type;
- NLA_INTERNET internet;
- } connectivity;
-
- // NLA_ICS
- struct {
- struct {
- DWORD speed;
- DWORD type;
- DWORD state;
- WCHAR machineName[256];
- WCHAR sharedAdapterName[256];
- } remote;
- } ICS;
- } data;
-};
-#endif
-
-enum NDIS_MEDIUM {
- NdisMedium802_3 = 0,
-};
-
-enum NDIS_PHYSICAL_MEDIUM {
- NdisPhysicalMediumWirelessLan = 1,
- NdisPhysicalMediumBluetooth = 10,
- NdisPhysicalMediumWiMax = 12,
-};
-
-#define OID_GEN_MEDIA_SUPPORTED 0x00010103
-#define OID_GEN_PHYSICAL_MEDIUM 0x00010202
-
-#define IOCTL_NDIS_QUERY_GLOBAL_STATS \
- CTL_CODE(FILE_DEVICE_PHYSICAL_NETCARD, 0, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
-
-#endif // QNETWORKSESSIONENGINE_WIN_P_H
diff --git a/src/network/bearer/qnlaengine_win.cpp b/src/network/bearer/qnlaengine_win.cpp
deleted file mode 100644
index a3f6017..0000000
--- a/src/network/bearer/qnlaengine_win.cpp
+++ /dev/null
@@ -1,600 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qnlaengine_win_p.h"
-#include "qnetworkconfiguration_p.h"
-
-#include <QtCore/qthread.h>
-#include <QtCore/qmutex.h>
-#include <QtCore/qcoreapplication.h>
-#include <QtCore/qstringlist.h>
-
-#include <QtCore/qdebug.h>
-
-#include "qnetworksessionengine_win_p.h"
-
-QTM_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QNlaEngine, nlaEngine)
-
-QWindowsSockInit::QWindowsSockInit()
-: version(0)
-{
- //### should we try for 2.2 on all platforms ??
- WSAData wsadata;
-
- // IPv6 requires Winsock v2.0 or better.
- if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) {
- qWarning("QBearerManagementAPI: WinSock v2.0 initialization failed.");
- } else {
- version = 0x20;
- }
-}
-
-QWindowsSockInit::~QWindowsSockInit()
-{
- WSACleanup();
-}
-
-#ifdef BEARER_MANAGEMENT_DEBUG
-static void printBlob(NLA_BLOB *blob)
-{
- qDebug() << "==== BEGIN NLA_BLOB ====";
-
- qDebug() << "type:" << blob->header.type;
- qDebug() << "size:" << blob->header.dwSize;
- qDebug() << "next offset:" << blob->header.nextOffset;
-
- switch (blob->header.type) {
- case NLA_RAW_DATA:
- qDebug() << "Raw Data";
- qDebug() << '\t' << blob->data.rawData;
- break;
- case NLA_INTERFACE:
- qDebug() << "Interface";
- qDebug() << "\ttype:" << blob->data.interfaceData.dwType;
- qDebug() << "\tspeed:" << blob->data.interfaceData.dwSpeed;
- qDebug() << "\tadapter:" << blob->data.interfaceData.adapterName;
- break;
- case NLA_802_1X_LOCATION:
- qDebug() << "802.1x Location";
- qDebug() << '\t' << blob->data.locationData.information;
- break;
- case NLA_CONNECTIVITY:
- qDebug() << "Connectivity";
- qDebug() << "\ttype:" << blob->data.connectivity.type;
- qDebug() << "\tinternet:" << blob->data.connectivity.internet;
- break;
- case NLA_ICS:
- qDebug() << "ICS";
- qDebug() << "\tspeed:" << blob->data.ICS.remote.speed;
- qDebug() << "\ttype:" << blob->data.ICS.remote.type;
- qDebug() << "\tstate:" << blob->data.ICS.remote.state;
- qDebug() << "\tmachine name:" << blob->data.ICS.remote.machineName;
- qDebug() << "\tshared adapter name:" << blob->data.ICS.remote.sharedAdapterName;
- break;
- default:
- qDebug() << "UNKNOWN BLOB TYPE";
- }
-
- qDebug() << "===== END NLA_BLOB =====";
-}
-#endif
-
-static QString qGetInterfaceType(const QString &interface)
-{
-#ifdef Q_OS_WINCE
- Q_UNUSED(interface)
-#else
- unsigned long oid;
- DWORD bytesWritten;
-
- NDIS_MEDIUM medium;
- NDIS_PHYSICAL_MEDIUM physicalMedium;
-
- HANDLE handle = CreateFile((TCHAR *)QString("\\\\.\\%1").arg(interface).utf16(), 0,
- FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
- if (handle == INVALID_HANDLE_VALUE)
- return QLatin1String("Unknown");
-
- oid = OID_GEN_MEDIA_SUPPORTED;
- bytesWritten = 0;
- bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
- &medium, sizeof(medium), &bytesWritten, 0);
- if (!result) {
- CloseHandle(handle);
- return QLatin1String("Unknown");
- }
-
- oid = OID_GEN_PHYSICAL_MEDIUM;
- bytesWritten = 0;
- result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid),
- &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0);
- if (!result) {
- CloseHandle(handle);
-
- if (medium == NdisMedium802_3)
- return QLatin1String("Ethernet");
- else
- return QLatin1String("Unknown");
- }
-
- CloseHandle(handle);
-
- if (medium == NdisMedium802_3) {
- switch (physicalMedium) {
- case NdisPhysicalMediumWirelessLan:
- return QLatin1String("WLAN");
- case NdisPhysicalMediumBluetooth:
- return QLatin1String("Bluetooth");
- case NdisPhysicalMediumWiMax:
- return QLatin1String("WiMAX");
- default:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "Physical Medium" << physicalMedium;
-#endif
- return QLatin1String("Ethernet");
- }
- }
-
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << medium << physicalMedium;
-#endif
-
-#endif
-
- return QLatin1String("Unknown");
-}
-
-class QNlaThread : public QThread
-{
- Q_OBJECT
-
-public:
- QNlaThread(QNlaEngine *parent = 0);
- ~QNlaThread();
-
- QList<QNetworkConfigurationPrivate *> getConfigurations();
-
- void forceUpdate();
-
-protected:
- virtual void run();
-
-private:
- void updateConfigurations(QList<QNetworkConfigurationPrivate *> &configs);
- DWORD parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv) const;
- QNetworkConfigurationPrivate *parseQuerySet(const WSAQUERYSET *querySet) const;
- void fetchConfigurations();
-
-signals:
- void networksChanged();
-
-private:
- QMutex mutex;
- HANDLE handle;
- bool done;
- QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
-};
-
-QNlaThread::QNlaThread(QNlaEngine *parent)
-: QThread(parent), handle(0), done(false)
-{
-}
-
-QNlaThread::~QNlaThread()
-{
- mutex.lock();
-
- done = true;
-
- if (handle) {
- /* cancel completion event */
- if (WSALookupServiceEnd(handle) == SOCKET_ERROR)
- qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
- }
- mutex.unlock();
-
- wait();
-}
-
-QList<QNetworkConfigurationPrivate *> QNlaThread::getConfigurations()
-{
- QMutexLocker locker(&mutex);
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
- 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;
- 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;
- if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) {
- config->bearer = engine->bearerName(config->id);
- }
-
- foundConfigurations.append(config);
- }
-
- return foundConfigurations;
-}
-
-void QNlaThread::forceUpdate()
-{
- mutex.lock();
-
- if (handle) {
- /* cancel completion event */
- if (WSALookupServiceEnd(handle) == SOCKET_ERROR)
- qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
- handle = 0;
- }
- mutex.unlock();
-}
-
-void QNlaThread::run()
-{
- WSAEVENT changeEvent = WSACreateEvent();
- if (changeEvent == WSA_INVALID_EVENT) {
- qWarning("WSACreateEvent error %d", WSAGetLastError());
- return;
- }
-
- while (true) {
- fetchConfigurations();
-
- WSAQUERYSET qsRestrictions;
-
- memset(&qsRestrictions, 0, sizeof(qsRestrictions));
- qsRestrictions.dwSize = sizeof(qsRestrictions);
- qsRestrictions.dwNameSpace = NS_NLA;
-
- mutex.lock();
- if (done) {
- mutex.unlock();
- break;
- }
- int result = WSALookupServiceBegin(&qsRestrictions, LUP_RETURN_ALL, &handle);
- mutex.unlock();
-
- if (result == SOCKET_ERROR) {
- qWarning("%s: WSALookupServiceBegin error %d", __FUNCTION__, WSAGetLastError());
- break;
- }
-
- WSACOMPLETION completion;
- WSAOVERLAPPED overlapped;
-
- memset(&overlapped, 0, sizeof(overlapped));
- overlapped.hEvent = changeEvent;
-
- memset(&completion, 0, sizeof(completion));
- completion.Type = NSP_NOTIFY_EVENT;
- completion.Parameters.Event.lpOverlapped = &overlapped;
-
- DWORD bytesReturned = 0;
- result = WSANSPIoctl(handle, SIO_NSP_NOTIFY_CHANGE, 0, 0, 0, 0,
- &bytesReturned, &completion);
- if (result == SOCKET_ERROR) {
- int error = WSAGetLastError();
- if (error != WSA_IO_PENDING) {
- qWarning("WSANSPIoctl error %d", error);
- break;
- }
- }
-
-#ifndef Q_OS_WINCE
- // Not interested in unrelated IO completion events
- // although we also don't want to block them
- while (WaitForSingleObjectEx(changeEvent, WSA_INFINITE, true) != WAIT_IO_COMPLETION) {}
-#else
- WaitForSingleObject(changeEvent, WSA_INFINITE);
-#endif
-
- mutex.lock();
- if (handle) {
- result = WSALookupServiceEnd(handle);
- if (result == SOCKET_ERROR) {
- qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
- mutex.unlock();
- break;
- }
- handle = 0;
- }
- mutex.unlock();
- }
-
- WSACloseEvent(changeEvent);
-}
-
-void QNlaThread::updateConfigurations(QList<QNetworkConfigurationPrivate *> &configs)
-{
- mutex.lock();
-
- while (!fetchedConfigurations.isEmpty())
- delete fetchedConfigurations.takeFirst();
-
- fetchedConfigurations = configs;
-
- mutex.unlock();
-
- emit networksChanged();
-}
-
-DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv) const
-{
-#ifdef BEARER_MANAGEMENT_DEBUG
- printBlob(blob);
-#endif
-
- switch (blob->header.type) {
- case NLA_RAW_DATA:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type NLA_RAW_DATA", __FUNCTION__);
-#endif
- break;
- case NLA_INTERFACE:
- cpPriv->state = QNetworkConfiguration::Active;
- if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) {
- engine->configurationInterface[cpPriv->id.toUInt()] =
- QString(blob->data.interfaceData.adapterName);
- }
- break;
- case NLA_802_1X_LOCATION:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type NLA_802_1X_LOCATION", __FUNCTION__);
-#endif
- break;
- case NLA_CONNECTIVITY:
- if (blob->data.connectivity.internet == NLA_INTERNET_YES)
- cpPriv->internet = true;
- else
- cpPriv->internet = false;
-#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type NLA_CONNECTIVITY", __FUNCTION__);
-#endif
- break;
- case NLA_ICS:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type NLA_ICS", __FUNCTION__);
-#endif
- break;
- default:
-#ifdef BEARER_MANAGEMENT_DEBUG
- qWarning("%s: unhandled header type %d", __FUNCTION__, blob->header.type);
-#endif
- ;
- }
-
- return blob->header.nextOffset;
-}
-
-QNetworkConfigurationPrivate *QNlaThread::parseQuerySet(const WSAQUERYSET *querySet) const
-{
- QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
-
- cpPriv->name = QString::fromWCharArray(querySet->lpszServiceInstanceName);
- cpPriv->isValid = true;
- cpPriv->id = QString::number(qHash(QLatin1String("NLA:") + cpPriv->name));
- cpPriv->state = QNetworkConfiguration::Defined;
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
-
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "size:" << querySet->dwSize;
- qDebug() << "service instance name:" << QString::fromUtf16(querySet->lpszServiceInstanceName);
- qDebug() << "service class id:" << querySet->lpServiceClassId;
- qDebug() << "version:" << querySet->lpVersion;
- qDebug() << "comment:" << QString::fromUtf16(querySet->lpszComment);
- qDebug() << "namespace:" << querySet->dwNameSpace;
- qDebug() << "namespace provider id:" << querySet->lpNSProviderId;
- qDebug() << "context:" << QString::fromUtf16(querySet->lpszContext);
- qDebug() << "number of protocols:" << querySet->dwNumberOfProtocols;
- qDebug() << "protocols:" << querySet->lpafpProtocols;
- qDebug() << "query string:" << QString::fromUtf16(querySet->lpszQueryString);
- qDebug() << "number of cs addresses:" << querySet->dwNumberOfCsAddrs;
- qDebug() << "cs addresses:" << querySet->lpcsaBuffer;
- qDebug() << "output flags:" << querySet->dwOutputFlags;
-#endif
-
- if (querySet->lpBlob) {
-#ifdef BEARER_MANAGEMENT_DEBUG
- qDebug() << "blob size:" << querySet->lpBlob->cbSize;
- qDebug() << "blob data:" << querySet->lpBlob->pBlobData;
-#endif
-
- DWORD offset = 0;
- do {
- NLA_BLOB *blob = reinterpret_cast<NLA_BLOB *>(querySet->lpBlob->pBlobData + offset);
- DWORD nextOffset = parseBlob(blob, cpPriv);
- if (nextOffset == offset)
- break;
- else
- offset = nextOffset;
- } while (offset != 0 && offset < querySet->lpBlob->cbSize);
- }
-
- return cpPriv;
-}
-
-void QNlaThread::fetchConfigurations()
-{
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
-
- WSAQUERYSET qsRestrictions;
- HANDLE hLookup = 0;
-
- memset(&qsRestrictions, 0, sizeof(qsRestrictions));
- qsRestrictions.dwSize = sizeof(qsRestrictions);
- qsRestrictions.dwNameSpace = NS_NLA;
-
- int result = WSALookupServiceBegin(&qsRestrictions, LUP_RETURN_ALL | LUP_DEEP, &hLookup);
- if (result == SOCKET_ERROR) {
- qWarning("%s: WSALookupServiceBegin error %d", __FUNCTION__, WSAGetLastError());
- mutex.lock();
- fetchedConfigurations.clear();
- mutex.unlock();
- }
-
- char buffer[0x10000];
- while (result == 0) {
- DWORD bufferLength = sizeof(buffer);
- result = WSALookupServiceNext(hLookup, LUP_RETURN_ALL,
- &bufferLength, reinterpret_cast<WSAQUERYSET *>(buffer));
-
- if (result == SOCKET_ERROR) {
- int error = WSAGetLastError();
-
- if (error == WSA_E_NO_MORE)
- break;
-
- if (error == WSAEFAULT) {
- qDebug() << "buffer not big enough" << bufferLength;
- break;
- }
-
- qWarning("WSALookupServiceNext error %d", WSAGetLastError());
- break;
- }
-
- QNetworkConfigurationPrivate *cpPriv =
- parseQuerySet(reinterpret_cast<WSAQUERYSET *>(buffer));
-
- foundConfigurations.append(cpPriv);
- }
-
- if (hLookup) {
- result = WSALookupServiceEnd(hLookup);
- if (result == SOCKET_ERROR) {
- qWarning("WSALookupServiceEnd error %d", WSAGetLastError());
- }
- }
-
- updateConfigurations(foundConfigurations);
-}
-
-QNlaEngine::QNlaEngine(QObject *parent)
-: QNetworkSessionEngine(parent), nlaThread(0)
-{
- nlaThread = new QNlaThread(this);
- connect(nlaThread, SIGNAL(networksChanged()),
- this, SIGNAL(configurationsChanged()));
- nlaThread->start();
-
- qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
-}
-
-QNlaEngine::~QNlaEngine()
-{
- delete nlaThread;
-}
-
-QList<QNetworkConfigurationPrivate *> QNlaEngine::getConfigurations(bool *ok)
-{
- if (ok)
- *ok = true;
-
- return nlaThread->getConfigurations();
-}
-
-QString QNlaEngine::getInterfaceFromId(const QString &id)
-{
- return configurationInterface.value(id.toUInt());
-}
-
-bool QNlaEngine::hasIdentifier(const QString &id)
-{
- if (configurationInterface.contains(id.toUInt()))
- 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 result;
-}
-
-QString QNlaEngine::bearerName(const QString &id)
-{
- QString interface = getInterfaceFromId(id);
-
- if (interface.isEmpty())
- return QString();
-
- return qGetInterfaceType(interface);
-}
-
-void QNlaEngine::connectToId(const QString &id)
-{
- emit connectionError(id, OperationNotSupported);
-}
-
-void QNlaEngine::disconnectFromId(const QString &id)
-{
- emit connectionError(id, OperationNotSupported);
-}
-
-void QNlaEngine::requestUpdate()
-{
- nlaThread->forceUpdate();
-}
-
-QNlaEngine *QNlaEngine::instance()
-{
- return nlaEngine();
-}
-
-#include "qnlaengine_win.moc"
-#include "moc_qnlaengine_win_p.cpp"
-QTM_END_NAMESPACE
-
-
-
diff --git a/src/network/bearer/qnlaengine_win_p.h b/src/network/bearer/qnlaengine_win_p.h
deleted file mode 100644
index 394b8cf..0000000
--- a/src/network/bearer/qnlaengine_win_p.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNLAENGINE_P_H
-#define QNLAENGINE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qnetworksessionengine_p.h"
-
-#include <QMap>
-
-QTM_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-class QNlaThread;
-
-class QWindowsSockInit
-{
-public:
- QWindowsSockInit();
- ~QWindowsSockInit();
- int version;
-};
-
-class QNlaEngine : public QNetworkSessionEngine
-{
- Q_OBJECT
-
- friend class QNlaThread;
-
-public:
- QNlaEngine(QObject *parent = 0);
- ~QNlaEngine();
-
- QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0);
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
-
- QString bearerName(const QString &id);
-
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
-
- void requestUpdate();
-
- static QNlaEngine *instance();
-
-private:
- QWindowsSockInit winSock;
- QNlaThread *nlaThread;
- QMap<uint, QString> configurationInterface;
-};
-
-QTM_END_NAMESPACE
-
-#endif
diff --git a/src/network/bearer/qnmdbushelper.cpp b/src/network/bearer/qnmdbushelper.cpp
deleted file mode 100644
index 3b780f6..0000000
--- a/src/network/bearer/qnmdbushelper.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// this class is for helping qdbus get stuff
-
-#include "qnmdbushelper_p.h"
-
-#if !defined(QT_NO_DBUS) && !defined(Q_OS_MAC)
-#include <NetworkManager/NetworkManager.h>
-
-#include <QDBusError>
-#include <QDBusInterface>
-#include <QDBusMessage>
-#include <QDBusReply>
-#endif
-
-#include <QDebug>
-
-QTM_BEGIN_NAMESPACE
-
-void QNmDBusHelper::deviceStateChanged(quint32 state)
- {
- QDBusMessage msg = this->message();
- if(state == NM_DEVICE_STATE_ACTIVATED
- || state == NM_DEVICE_STATE_DISCONNECTED
- || state == NM_DEVICE_STATE_UNAVAILABLE
- || state == NM_DEVICE_STATE_FAILED) {
- emit pathForStateChanged(msg.path(), state);
- }
- }
-
-void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path)
-{
- if(path.path().length() > 2) {
- QDBusMessage msg = this->message();
- emit pathForAccessPointAdded(msg.path(), path);
- }
-}
-
-void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path)
-{
- if(path.path().length() > 2) {
- QDBusMessage msg = this->message();
- emit pathForAccessPointRemoved(msg.path(), path);
- }
-}
-
-void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
-{
- QDBusMessage msg = this->message();
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
- if( i.key() == "State") { //state only applies to device interfaces
- quint32 state = i.value().toUInt();
- if( state == NM_DEVICE_STATE_ACTIVATED
- || state == NM_DEVICE_STATE_DISCONNECTED
- || state == NM_DEVICE_STATE_UNAVAILABLE
- || state == NM_DEVICE_STATE_FAILED) {
- emit pathForPropertiesChanged( msg.path(), map);
- }
- } else if( i.key() == "ActiveAccessPoint") {
- // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path();
- // } else if( i.key() == "Strength")
- // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt();
- // else
- // qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value();
- }
- }
-}
-
-void QNmDBusHelper::slotSettingsRemoved()
-{
- QDBusMessage msg = this->message();
- emit pathForSettingsRemoved(msg.path());
-}
-
-#include "moc_qnmdbushelper_p.cpp"
-QTM_END_NAMESPACE
diff --git a/src/network/bearer/qnmdbushelper_p.h b/src/network/bearer/qnmdbushelper_p.h
deleted file mode 100644
index f0248dc..0000000
--- a/src/network/bearer/qnmdbushelper_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNMDBUSHELPERPRIVATE_H
-#define QNMDBUSHELPERPRIVATE_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qmobilityglobal.h>
-#if !defined(QT_NO_DBUS) && !defined(Q_OS_MAC)
-#include <QDBusObjectPath>
-#include <QDBusContext>
-#include <QMap>
-#endif
-
-QTM_BEGIN_NAMESPACE
-
-#if !defined(QT_NO_DBUS) && !defined(Q_OS_MAC)
-
-class QNmDBusHelper: public QObject, protected QDBusContext
- {
- Q_OBJECT
- public:
-
- public slots:
- void deviceStateChanged(quint32);
- void slotAccessPointAdded( QDBusObjectPath );
- void slotAccessPointRemoved( QDBusObjectPath );
- void slotPropertiesChanged( QMap<QString,QVariant>);
- void slotSettingsRemoved();
-
-Q_SIGNALS:
- void pathForStateChanged(const QString &, quint32);
- void pathForAccessPointAdded(const QString &, QDBusObjectPath );
- void pathForAccessPointRemoved(const QString &, QDBusObjectPath );
- void pathForPropertiesChanged(const QString &, QMap<QString,QVariant>);
- void pathForSettingsRemoved(const QString &);
-};
-#endif
-
-QTM_END_NAMESPACE
-
-#endif// QNMDBUSHELPERPRIVATE_H
diff --git a/src/network/bearer/qnmwifiengine_unix.cpp b/src/network/bearer/qnmwifiengine_unix.cpp
deleted file mode 100644
index 2444919..0000000
--- a/src/network/bearer/qnmwifiengine_unix.cpp
+++ /dev/null
@@ -1,906 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qnmwifiengine_unix_p.h"
-#include "qnetworkconfiguration_p.h"
-#include <qnetworkconfiguration.h>
-
-#include <QtCore/qstringlist.h>
-#include <QScopedPointer>
-
-#include <QtNetwork/qnetworkinterface.h>
-#include <NetworkManager/NetworkManager.h>
-#include <qnetworkmanagerservice_p.h>
-
-#include <QNetworkInterface>
-
-
-
-QTM_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC(QNmWifiEngine, nmWifiEngine)
-typedef QList<QList<uint> > QNmSettingsAddressMap;
-QTM_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QNmSettingsAddressMap))
-
-QTM_BEGIN_NAMESPACE
-
-QNmWifiEngine::QNmWifiEngine(QObject *parent)
-: QNetworkSessionEngine(parent)
-{
- iface = new QNetworkManagerInterface(this);
- if(!iface->isValid()) {
- return;
- }
- iface->setConnections();
- connect(iface,SIGNAL(deviceAdded(QDBusObjectPath)),
- 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();
-
- foreach(QDBusObjectPath path, list) {
- addDevice(path);
- }
-
- QStringList connectionServices;
- connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
- connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
- QNetworkManagerSettings *settingsiface;
- foreach (QString service, connectionServices) {
- settingsiface = new QNetworkManagerSettings(service, this);
- settingsiface->setConnections();
- connect(settingsiface,SIGNAL(newConnection(QDBusObjectPath)),
- this,(SLOT(newConnection(QDBusObjectPath))));
- }
-
- updated = false;
-}
-
-QNmWifiEngine::~QNmWifiEngine()
-{
-}
-
-QString QNmWifiEngine::getNameForConfiguration(QNetworkManagerInterfaceDevice *devIface)
-{
- QString newname;
- if (devIface->state() == NM_DEVICE_STATE_ACTIVATED) {
- QString path = devIface->ip4config().path();
- QNetworkManagerIp4Config * ipIface;
- ipIface = new QNetworkManagerIp4Config(path);
- newname = ipIface->domains().join(" ");
- delete ipIface;
- }
- //fallback to interface name
- if(newname.isEmpty())
- newname = devIface->interface().name();
- return newname;
-}
-
-
-QList<QNetworkConfigurationPrivate *> QNmWifiEngine::getConfigurations(bool *ok)
-{
- if (ok)
- *ok = false;
-
- if(!updated) {
- foundConfigurations.clear();
- if(knownSsids.isEmpty())
- updateKnownSsids(); // list of ssids that have user configurations.
-
- scanForAccessPoints();
- updateActiveConnectionsPaths();
- knownConnections();
-
- accessPointConnections();
-
-// findConnections();
- //add access points
- updated = true;
- }
- return foundConfigurations;
-}
-
-void QNmWifiEngine::knownConnections()
-{
- //// connections
- QStringList connectionServices;
- connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
- connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
-
- QString connPath;
-
- QScopedPointer<QNetworkManagerSettings> settingsiface;
- foreach (QString service, connectionServices) {
- QString ident;
- settingsiface.reset(new QNetworkManagerSettings(service));
- QList<QDBusObjectPath> list = settingsiface->listConnections();
-
- QNetworkManagerSettingsConnection *sysIface;
- foreach(QDBusObjectPath path, list) { //for each connection path
- ident = path.path();
- bool addIt = false;
- QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
- sysIface = new QNetworkManagerSettingsConnection(service, path.path(), this);
- sysIface->setConnections();
- connect(sysIface, SIGNAL(removed(QString)),
- this,SLOT(settingsConnectionRemoved(QString)));
-
- cpPriv->name = sysIface->getId();
- cpPriv->isValid = true;
- cpPriv->id = sysIface->getUuid();
- cpPriv->internet = true;
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
- 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) {
- QString devPath;
- devPath = deviceConnectionPath(mac);
-
- 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
- } else {
- cpPriv->serviceInterface = getBestInterface( DEVICE_TYPE_802_3_ETHERNET, cpPriv->id);
- }
-
- cpPriv->internet = true;//sysIface->isAutoConnect();
-
- addIt = true;
- } else if(sysIface->getType() == DEVICE_TYPE_802_11_WIRELESS) {
- QString mac = sysIface->getMacAddress();;
- if(!mac.length() > 2) {
- QString devPath;
- devPath = deviceConnectionPath(mac);
-
- QNetworkManagerInterfaceDevice devIface(devPath);
- cpPriv->serviceInterface = devIface.interface();
- // use this mac addy
- } else {
- cpPriv->serviceInterface = getBestInterface( DEVICE_TYPE_802_11_WIRELESS, cpPriv->id);
- }
- addIt = true;
- // get the wifi interface state first.. do we need this?
- // QString activeAPPath = devWirelessIface->activeAccessPoint().path();
- }
- if(addIt) {
- foundConfigurations.append(cpPriv);
- configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name();
- cpPriv->bearer = bearerName(cpPriv->id);
- }
- } //end each connection service
- }
-}
-
-void QNmWifiEngine::accessPointConnections()
-{
- QList<QDBusObjectPath> list = iface->getDevices();
- QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
- foreach(QDBusObjectPath path, list) {
- 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;
- cpPriv = addAccessPoint( devIface->connectionInterface()->path(), availableAccessPoints[*i]);
- if(cpPriv->isValid) {
- foundConfigurations.append(cpPriv);
- configurationInterface[cpPriv->id] = cpPriv->serviceInterface.name();
- cpPriv->bearer = bearerName(cpPriv->id);
- }
- }
- }
- }
-}
-
-QString QNmWifiEngine::getInterfaceFromId(const QString &id)
-{
- return configurationInterface.value(id);
-}
-
-bool QNmWifiEngine::hasIdentifier(const QString &id)
-{
- if (configurationInterface.contains(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) {
- 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;
- }
- }
- }
- return QLatin1String("Unknown");
-}
-
-void QNmWifiEngine::connectToId(const QString &id)
-{
- activatingConnectionPath = id;
- QStringList connectionSettings = getConnectionPathForId(id);
- if(connectionSettings.isEmpty()) {
- emit connectionError(id, OperationNotSupported);
- return;
- }
-
- QDBusObjectPath connectionPath(connectionSettings.at(1));
- QString interface = getInterfaceFromId(id);
-
- interface = QNetworkInterface::interfaceFromName(interface).hardwareAddress().toLower();
- QString devPath;
- devPath = deviceConnectionPath(interface);
- QDBusObjectPath devicePath(devPath);
-
- iface->activateConnection(
- connectionSettings.at(0),
- connectionPath,
- devicePath,
- connectionPath);
-}
-
-void QNmWifiEngine::disconnectFromId(const QString &id)
-{
- QString activeConnectionPath = getActiveConnectionPath(id);
-
- if (!activeConnectionPath.isEmpty()) {
- QScopedPointer<QNetworkManagerConnectionActive> activeCon;
- activeCon.reset(new QNetworkManagerConnectionActive(activeConnectionPath));
- QScopedPointer<QNetworkManagerSettingsConnection> settingsCon;
- settingsCon.reset(new QNetworkManagerSettingsConnection(activeCon->serviceName(), activeCon->connection().path()));
-
- if(settingsCon->getType() == DEVICE_TYPE_802_3_ETHERNET /*NM_DEVICE_TYPE_ETHERNET*/) { //use depreciated value for now
- emit connectionError(id, OperationNotSupported);
- } else {
- QDBusObjectPath dbpath(activeConnectionPath);
- iface->deactivateConnection(dbpath);
- activatingConnectionPath = "";
- }
- }
-}
-
-void QNmWifiEngine::requestUpdate()
-{
- updated = false;
- knownSsids.clear();
- availableAccessPoints.clear();
- emitConfigurationsChanged();
-}
-
-QNmWifiEngine *QNmWifiEngine::instance()
-{
- QDBusConnection dbusConnection = QDBusConnection::systemBus();
- if (dbusConnection.isConnected()) {
- QDBusConnectionInterface *dbiface = dbusConnection.interface();
- QDBusReply<bool> reply = dbiface->isServiceRegistered("org.freedesktop.NetworkManager");
- if (reply.isValid() && reply.value())
- return nmWifiEngine();
- }
-
- return 0;
-}
-
-void QNmWifiEngine::updateKnownSsids()
-{
- QStringList connectionServices;
- connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
- connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
-
- QScopedPointer<QNetworkManagerSettings> settingsiface;
- foreach (QString service, connectionServices) {
- settingsiface.reset(new QNetworkManagerSettings(service));
- QList<QDBusObjectPath> list = settingsiface->listConnections();
- foreach(QDBusObjectPath path, list) {
- QNetworkManagerSettingsConnection sysIface(service, path.path());
- knownSsids << sysIface.getSsid();
- }
- }
-}
-
-void QNmWifiEngine::updateActiveConnectionsPaths()
-{ //need to know which connection paths are currently active/connected
- QScopedPointer<QNetworkManagerInterface> dbIface;
- activeConnectionPaths.clear();
- dbIface.reset(new QNetworkManagerInterface);
- QList <QDBusObjectPath> connections = dbIface->activeConnections();
- foreach(QDBusObjectPath conpath, connections) {
- activeConnectionPaths << conpath.path();
- }
-}
-
-QNetworkConfigurationPrivate * QNmWifiEngine::addAccessPoint( const QString &iPath, QDBusObjectPath path)
-{
-
- QScopedPointer<QNetworkManagerInterfaceDevice> devIface(new QNetworkManagerInterfaceDevice(iPath));
- QScopedPointer<QNetworkManagerInterfaceDeviceWireless> devWirelessIface(new QNetworkManagerInterfaceDeviceWireless(iPath));
-
- QString activeAPPath = devWirelessIface->activeAccessPoint().path();
-
- QScopedPointer<QNetworkManagerInterfaceAccessPoint> accessPointIface(new QNetworkManagerInterfaceAccessPoint(path.path()));
-
- QString ident = accessPointIface->connectionInterface()->path();
- quint32 nmState = devIface->state();
-
- QString ssid = accessPointIface->ssid();
- QString hwAddy = accessPointIface->hwAddress();
- QString sInterface = devIface->interface().name();
-
- QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
- bool addIt = true;
-
-// if(availableAccessPoints.contains(ssid)) {
-// addIt = false;
-//
-// }
-// foreach (QNetworkConfigurationPrivate *cpPriv, foundConfigurations) {
-// if (cpPriv->name == ssid) { //weed out duplicate ssid's ??
-// addIt = false;
-// break;
-// }
-// }
-
- if(addIt) {
-
- cpPriv->name = ssid;
- cpPriv->isValid = true;
- cpPriv->id = ident;
- cpPriv->internet = true;
- cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
- cpPriv->serviceInterface = devIface->interface();
-
- cpPriv->state = getAPState(nmState, knownSsids.contains(cpPriv->name));
-
- if(activeAPPath == accessPointIface->connectionInterface()->path()) {
- cpPriv->state = ( cpPriv->state | QNetworkConfiguration::Active);
- }
- if(accessPointIface->flags() == NM_802_11_AP_FLAGS_PRIVACY)
- cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
- else
- cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
- return cpPriv;
- } else {
- cpPriv->isValid = false;
- }
- return cpPriv;
-}
-
-
- QNetworkConfiguration::StateFlags QNmWifiEngine::getAPState(qint32 nmState, bool isKnown)
-{
- QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined;
- // this is the state of the wifi device interface
- if(isKnown)
- state = ( QNetworkConfiguration::Defined);
-
- switch(nmState) { //device interface state, not AP state
- case NM_DEVICE_STATE_UNKNOWN:
- case NM_DEVICE_STATE_UNMANAGED:
- case NM_DEVICE_STATE_UNAVAILABLE:
- state = (QNetworkConfiguration::Undefined);
- break;
- case NM_DEVICE_STATE_DISCONNECTED:
- {
- if(isKnown)
- state = ( state | QNetworkConfiguration::Discovered);
- }
- break;
- case NM_DEVICE_STATE_PREPARE:
- case NM_DEVICE_STATE_CONFIG:
- case NM_DEVICE_STATE_NEED_AUTH:
- case NM_DEVICE_STATE_IP_CONFIG:
- if(isKnown)
- state = ( state | QNetworkConfiguration::Discovered);
- break;
- case NM_DEVICE_STATE_ACTIVATED:
- {
- if(isKnown)
- state = ( state | QNetworkConfiguration::Discovered);
- }
- break;
- };
- return state;
-}
-
-QString QNmWifiEngine::getActiveConnectionPath(const QString &id)
-{
- QStringList connectionSettings = getConnectionPathForId(id);
- QNetworkManagerInterface ifaceD;
- QList<QDBusObjectPath> connections = ifaceD.activeConnections();
- QScopedPointer<QNetworkManagerConnectionActive> conDetailsD;
- foreach(QDBusObjectPath path, connections) {
- conDetailsD.reset(new QNetworkManagerConnectionActive( path.path()));
- if(conDetailsD->connection().path() == connectionSettings.at(1)
- && conDetailsD->serviceName() == connectionSettings.at(0))
- return path.path();
- }
- return QString();
-}
-
- QNetworkConfiguration::StateFlags QNmWifiEngine::getStateFlag(quint32 nmstate)
- {
- QNetworkConfiguration::StateFlags flag;
- switch (nmstate) {
- case NM_DEVICE_STATE_UNKNOWN:
- case NM_DEVICE_STATE_FAILED:
- case NM_DEVICE_STATE_UNMANAGED:
- flag = (QNetworkConfiguration::Undefined);
- 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_UNAVAILABLE:
- flag = (QNetworkConfiguration::Defined);
- break;
- case NM_DEVICE_STATE_DISCONNECTED:
- flag = ( flag | QNetworkConfiguration::Discovered );
- break;
- case NM_DEVICE_STATE_ACTIVATED:
- {
- flag = ( flag | QNetworkConfiguration::Discovered
- | QNetworkConfiguration::Active );
- }
- break;
- default:
- flag = ( QNetworkConfiguration::Defined);
- break;
- };
- return flag;
- }
-
-void QNmWifiEngine::updateDeviceInterfaceState(const QString &/*path*/, quint32 nmState)
-{
- if(nmState == NM_DEVICE_STATE_ACTIVATED
- || nmState == NM_DEVICE_STATE_DISCONNECTED
- || nmState == NM_DEVICE_STATE_UNAVAILABLE
- || nmState == NM_DEVICE_STATE_FAILED) {
-
-/* InterfaceLookupError = 0,
- ConnectError,
- OperationNotSupported,
- DisconnectionError,
-*/
- QNetworkConfiguration::StateFlags state = (QNetworkConfiguration::Defined);
- switch (nmState) {
- case NM_DEVICE_STATE_UNKNOWN:
- case NM_DEVICE_STATE_FAILED:
- state = (QNetworkConfiguration::Undefined);
- emit connectionError(activatingConnectionPath, ConnectError);
- requestUpdate();
- break;
- case NM_DEVICE_STATE_UNAVAILABLE:
- state = (QNetworkConfiguration::Defined);
-// emit connectionError(activatingConnectionPath, ConnectError);
- requestUpdate();
- break;
- case NM_DEVICE_STATE_DISCONNECTED:
- state = ( state | QNetworkConfiguration::Discovered );
- requestUpdate();
- break;
- case NM_DEVICE_STATE_ACTIVATED:
- {
- state = ( state | QNetworkConfiguration::Discovered
- | QNetworkConfiguration::Active );
- requestUpdate();
- }
- break;
- default:
- state = ( QNetworkConfiguration::Defined);
- break;
- };
- }
-}
-
-void QNmWifiEngine::addDevice(QDBusObjectPath path)
-{
- QNetworkManagerInterfaceDevice *devIface = new QNetworkManagerInterfaceDevice(path.path(), this);
- devIface->setConnections();
- connect(devIface,SIGNAL(stateChanged(const QString &, quint32)),
- this, SLOT(updateDeviceInterfaceState(const QString&, quint32)));
-
- if(!devicePaths.contains(path.path()))
- devicePaths << path.path();
-
- switch(devIface->deviceType()) {
- case DEVICE_TYPE_802_3_ETHERNET:
- {
- QNetworkManagerInterfaceDeviceWired * devWiredIface;
- 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>)));
- requestUpdate();
- }
- break;
- case DEVICE_TYPE_802_11_WIRELESS:
- {
- QNetworkManagerInterfaceDeviceWireless *devWirelessIface;
- devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path(), this);
- devWirelessIface->setConnections();
-
- connect(devWirelessIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)),
- this,SLOT(cmpPropertiesChanged( const QString &, QMap<QString,QVariant>)));
-
- connect(devWirelessIface, SIGNAL(accessPointAdded(const QString &,QDBusObjectPath)),
- this,SLOT(accessPointAdded(const QString &,QDBusObjectPath)));
-
- connect(devWirelessIface, SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath)),
- this,SLOT(accessPointRemoved(const QString &,QDBusObjectPath)));
- requestUpdate();
-
- }
- break;
- default:
- break;
- };
-}
-
-void QNmWifiEngine::removeDevice(QDBusObjectPath /*path*/)
-{
-// qWarning() << Q_FUNC_INFO << path.path();
-// disconnect(devIface,SIGNAL(stateChanged(const QString &, quint32)),
-// this, SLOT(updateDeviceInterfaceState(const QString&, quint32)));
-//
-// if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
-// // devWirelessIface = new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path());
-// // devWirelessIface->setConnections();
-//
-// disconnect(devWirelessIface, SIGNAL(propertiesChanged(const QString &,QMap<QString,QVariant>)),
-// this,SIGNAL(cmpPropertiesChanged( const QString &, QMap<QString,QVariant>)));
-//
-// disconnect(devWirelessIface, SIGNAL(accessPointAdded(const QString &,QDBusObjectPath)),
-// this,SIGNAL(accessPointAdded(const QString &,QDBusObjectPath)));
-//
-// disconnect(devWirelessIface, SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath)),
-// this,SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath)));
-//
-// }
-}
-void QNmWifiEngine::cmpPropertiesChanged(const QString &path, QMap<QString,QVariant> map)
-{
- QMapIterator<QString, QVariant> i(map);
- while (i.hasNext()) {
- i.next();
- if( i.key() == "State") { //only applies to device interfaces
- updateDeviceInterfaceState(path, i.value().toUInt());
- }
- if( i.key() == "ActiveAccessPoint") {
- }
- if( i.key() == "Carrier") { //someone got plugged in
- // requestUpdate();
- }
- }
-}
-
-void QNmWifiEngine::accessPointRemoved( const QString &aPath, QDBusObjectPath /*oPath*/)
-{
- if(aPath.contains("devices")) {
- requestUpdate();
- }
-}
-
-void QNmWifiEngine::accessPointAdded( const QString &aPath, QDBusObjectPath oPath)
-{
- /*QNetworkConfigurationPrivate* cpPriv;
- cpPriv = addAccessPoint( aPath, oPath);*/
- requestUpdate();
-}
-
-QNetworkConfiguration::StateFlags QNmWifiEngine::getStateForId(const QString &id)
-{
- bool isAvailable = false;
- QStringList conPath = getConnectionPathForId(id);
- QString aconpath = getActiveConnectionPath(id);
-
- if(!aconpath.isEmpty()) {
- //active connection
- QNetworkManagerConnectionActive aConn(aconpath);
-
- QList <QDBusObjectPath> devs = aConn.devices();
-
- QScopedPointer<QNetworkManagerInterfaceDevice> ifaceDevice;
- QScopedPointer<QNetworkManagerInterfaceDeviceWired> devWiredIface;
- foreach(QDBusObjectPath dev, devs) {
- ifaceDevice.reset(new QNetworkManagerInterfaceDevice(dev.path()));
-
- if(ifaceDevice->deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
-
- if(isAddressOfConnection(id, ifaceDevice->ip4Address())) {
- // this is it!
- return getStateFlag(ifaceDevice->state());
- } else {
- continue;
- }
-
- if(ifaceDevice->state() == NM_DEVICE_STATE_UNAVAILABLE ||
- ifaceDevice->state() == NM_DEVICE_STATE_DISCONNECTED) {
- isAvailable = true;
-
- devWiredIface.reset(new QNetworkManagerInterfaceDeviceWired(ifaceDevice->connectionInterface()->path()));
- if(!devWiredIface->carrier())
- return QNetworkConfiguration::Defined;
- } //end eth
- } else if(ifaceDevice->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
- qWarning() << "FIXME!!!!!!!!!!!!!!!!!";
- }
-
- return getStateFlag(ifaceDevice->state());
- }
- } else {
- // not active
- 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();
- bool ok = false;
-
- if(knownSsids.contains(ssid, Qt::CaseSensitive)) {
- foreach(QString onessid, knownSsids) {
- if(onessid == ssid && availableAccessPoints.contains(ssid)) {
- ok = true;
- break;
- }
- }
- }
- if(ok)
- return getStateFlag(NM_DEVICE_STATE_DISCONNECTED);
- else
- return getStateFlag(NM_DEVICE_STATE_UNAVAILABLE);
- }
- }
- }
-
- return QNetworkConfiguration::Defined; //not active, but we know this connection so just fake it
-}
-
-bool QNmWifiEngine::isAddressOfConnection(const QString &id, quint32 ipaddress)
-{
- QStringList conPath = getConnectionPathForId(id);
- QString aConPath = getActiveConnectionPath(id);
- if(aConPath.isEmpty()) {
- // not active
- return false;
- }
-
- 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;
-}
-
-QNetworkInterface QNmWifiEngine::getBestInterface( quint32 type, const QString &id)
-{
- // check active connections first.
- QStringList conIdPath = getConnectionPathForId(id);
-
- QNetworkInterface interface;
- 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(devs[0].path()); //just take the first one
- return ifaceDevice.interface();
- }
- }
-
- //try guessing
- QList<QDBusObjectPath> list = iface->getDevices();
- QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
- foreach(QDBusObjectPath path, list) {
- devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
- if(devIface->deviceType() == type /*&& devIface->managed()*/) {
- if(devIface->state() == NM_STATE_DISCONNECTED) {
- return devIface->interface();
- }
- }
- }
- return QNetworkInterface();
-}
-
-quint64 QNmWifiEngine::receivedDataForId(const QString &id) const
-{
- if(configurationInterface.count() > 1)
- return 0;
- quint64 result = 0;
-
- QString devFile;
- devFile = configurationInterface.value(id);
- QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes");
- if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&rx);
- in >> result;
- rx.close();
- }
- return result;
-}
-
-quint64 QNmWifiEngine::sentDataForId(const QString &id) const
-{
- if(configurationInterface.count() > 1)
- return 0;
- quint64 result = 0;
- QString devFile;
- devFile = configurationInterface.value(id);
-
- QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes");
- if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&tx);
- in >> result;
- tx.close();
- }
- return result;
-}
-
-void QNmWifiEngine::newConnection(QDBusObjectPath /*path*/)
-{
- requestUpdate();
-}
-
-void QNmWifiEngine::settingsConnectionRemoved(const QString &/*path*/)
-{
- requestUpdate();
-}
-
-void QNmWifiEngine::slotActivationFinished(QDBusPendingCallWatcher *openCall)
-{
- QDBusPendingReply<QDBusObjectPath> reply = *openCall;
- if (reply.isError()) {
- qWarning() <<"Error" << reply.error().name() << reply.error().message()
- <<activatingConnectionPath;
- emit connectionError(activatingConnectionPath, ConnectError);
- } /*else {
- QDBusObjectPath result = reply.value();
- }*/
-}
-
-void QNmWifiEngine::scanForAccessPoints()
-{
- availableAccessPoints.clear();
- QList<QDBusObjectPath> list = iface->getDevices();
-
- QScopedPointer<QNetworkManagerInterfaceDevice> devIface;
- QScopedPointer<QNetworkManagerInterfaceDeviceWireless> devWirelessIface;
- QScopedPointer<QNetworkManagerInterfaceAccessPoint> accessPointIface;
- foreach(QDBusObjectPath path, list) {
- devIface.reset(new QNetworkManagerInterfaceDevice(path.path()));
-
- if(devIface->deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
-
- devWirelessIface.reset(new QNetworkManagerInterfaceDeviceWireless(devIface->connectionInterface()->path()));
- ////////////// AccessPoints
- QList<QDBusObjectPath> apList = devWirelessIface->getAccessPoints();
-
- foreach(QDBusObjectPath path, apList) {
- accessPointIface.reset(new QNetworkManagerInterfaceAccessPoint(path.path()));
- QString ssid = accessPointIface->ssid();
- availableAccessPoints.insert(ssid, path);
- }
- }
- }
-}
-
-QString QNmWifiEngine::deviceConnectionPath(const QString &mac)
-{
-// qWarning() << __FUNCTION__ << mac;
- QString newMac = mac;
- newMac = newMac.replace(":","_").toLower();
- //device object path might not contain just mac address
- //might contain extra numbers on the end. thanks HAL
- foreach(QString device, devicePaths) {
- if(device.contains(newMac)) {
- newMac = device;
- break;
- }
- }
- return newMac;
-}
-
-QStringList QNmWifiEngine::getConnectionPathForId(const QString &uuid)
-{
- QStringList connectionServices;
- connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
- connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
- QScopedPointer<QNetworkManagerSettings> settingsiface;
- foreach (QString service, connectionServices) {
- settingsiface.reset(new QNetworkManagerSettings(service));
- QList<QDBusObjectPath> list = settingsiface->listConnections();
- QScopedPointer<QNetworkManagerSettingsConnection> sysIface;
- foreach(QDBusObjectPath path, list) {
- sysIface.reset(new QNetworkManagerSettingsConnection(service, path.path()));
- if(sysIface->getUuid() == uuid)
- return QStringList() << service << sysIface->connectionInterface()->path();
- }
- }
- return QStringList();
-}
-
-#include "moc_qnmwifiengine_unix_p.cpp"
-
-QTM_END_NAMESPACE
-
diff --git a/src/network/bearer/qnmwifiengine_unix_p.h b/src/network/bearer/qnmwifiengine_unix_p.h
deleted file mode 100644
index 470c8d3..0000000
--- a/src/network/bearer/qnmwifiengine_unix_p.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Mobility Components.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QNMWIFIENGINE_P_H
-#define QNMWIFIENGINE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-//#include <QtCore/qtimer.h>
-
-#include <QHash>
-#include <QDBusPendingCallWatcher>
-#include <QExplicitlySharedDataPointer>
-#include <qnetworkmanagerservice_p.h>
-
-#include "qnetworksessionengine_p.h"
-#include <qnetworksession.h>
-#include <qnetworkconfiguration.h>
-#include <qnetworkconfigmanager_p.h>
-
-
-
-QTM_BEGIN_NAMESPACE
-
-class QNetworkConfigurationPrivate;
-
-class QNmWifiEngine : public QNetworkSessionEngine
-{
- Q_OBJECT
-
-public:
- QNmWifiEngine(QObject *parent = 0);
- ~QNmWifiEngine();
-
- QList<QNetworkConfigurationPrivate *> getConfigurations(bool *ok = 0);
- QString getInterfaceFromId(const QString &id);
- bool hasIdentifier(const QString &id);
-
- QString bearerName(const QString &id);
-
- void connectToId(const QString &id);
- void disconnectFromId(const QString &id);
-
- void requestUpdate();
-
- static QNmWifiEngine *instance();
-
- QStringList knownSsids;
- inline void emitConfigurationsChanged() { emit configurationsChanged(); }
- QNetworkConfigurationPrivate * addAccessPoint(const QString &, QDBusObjectPath );
-
- QStringList getConnectionPathForId(const QString &uuid);
- //QString getConnectionPathForId(const QString &name = QString());
- quint64 sentDataForId(const QString &id) const;
- quint64 receivedDataForId(const QString &id) const;
-
-private:
- bool updated;
- QString activatingConnectionPath;
- QStringList activeConnectionPaths;
-
-
- QMap<QString,QDBusObjectPath> availableAccessPoints;
- void scanForAccessPoints();
-
- QStringList devicePaths;
-
- void updateActiveConnectionsPaths();
- void updateKnownSsids();
- void accessPointConnections();
- void knownConnections();
- QString deviceConnectionPath(const QString &mac);
-
- QList<QNetworkConfigurationPrivate *> foundConfigurations;
- // QHash<QString, QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> > allConfigurations;
-
- QNetworkManagerInterface *iface;
-
- QNetworkConfiguration::StateFlags getAPState(qint32 vState, bool isKnown);
- QNetworkConfiguration::StateFlags getStateFlag(quint32 nmstate);
-
- QString getActiveConnectionPath(const QString &identifier);
- QString getNameForConfiguration(QNetworkManagerInterfaceDevice *devIface);
-
- QNetworkConfiguration::StateFlags getStateForId(const QString &id);
-
- QNetworkInterface getBestInterface(quint32 type, const QString &conPath);
-
- QMap<QString, QString> configurationInterface;
-
- bool isAddressOfConnection(const QString &conPath, quint32 ipaddress);
-
-private slots:
- void updateDeviceInterfaceState(const QString &, quint32);
- void addDevice(QDBusObjectPath path);
- void removeDevice(QDBusObjectPath path);
-
-Q_SIGNALS:
- void configurationChanged(const QNetworkConfiguration& config);
-
-private slots:
- void accessPointAdded( const QString &aPath, QDBusObjectPath oPath);
- void accessPointRemoved( const QString &aPath, QDBusObjectPath oPath);
- void cmpPropertiesChanged(const QString &, QMap<QString,QVariant> map);
- void newConnection(QDBusObjectPath);
- void settingsConnectionRemoved(const QString &);
- void slotActivationFinished(QDBusPendingCallWatcher*);
-};
-
-QTM_END_NAMESPACE
-
-#endif
-
-
diff --git a/src/network/network.pro b/src/network/network.pro
index e890b94..8582d8a 100644
--- a/src/network/network.pro
+++ b/src/network/network.pro
@@ -17,6 +17,7 @@ unix:QMAKE_PKGCONFIG_REQUIRES = QtCore
include(../qbase.pri)
include(access/access.pri)
+include(bearer/bearer.pri)
include(kernel/kernel.pri)
include(socket/socket.pri)
include(ssl/ssl.pri)