diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2009-12-03 02:44:11 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2009-12-22 05:10:14 (GMT) |
commit | 2374a4209f9edcc865b18f63e07a50cdaddc70b7 (patch) | |
tree | 325f735e0b9ca4dc1fae7b25d4b436ea93ef7296 | |
parent | c2254fdcba61c0aceb89f2f5e6dc926a9493c1a2 (diff) | |
download | Qt-2374a4209f9edcc865b18f63e07a50cdaddc70b7.zip Qt-2374a4209f9edcc865b18f63e07a50cdaddc70b7.tar.gz Qt-2374a4209f9edcc865b18f63e07a50cdaddc70b7.tar.bz2 |
Convert NLA engine nito a plugin.
-rw-r--r-- | src/network/bearer/bearer.pri | 17 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.cpp | 17 | ||||
-rw-r--r-- | src/network/bearer/qnetworkconfigmanager_p.h | 2 | ||||
-rw-r--r-- | src/network/bearer/qnetworksession_p.cpp | 11 | ||||
-rw-r--r-- | src/plugins/bearer/bearer.pro | 1 | ||||
-rw-r--r-- | src/plugins/bearer/generic/generic.pro | 3 | ||||
-rw-r--r-- | src/plugins/bearer/generic/qgenericengine.cpp | 2 | ||||
-rw-r--r-- | src/plugins/bearer/nla/main.cpp | 88 | ||||
-rw-r--r-- | src/plugins/bearer/nla/nla.pro | 20 | ||||
-rw-r--r-- | src/plugins/bearer/nla/qnlaengine.cpp (renamed from src/network/bearer/qnlaengine_win.cpp) | 19 | ||||
-rw-r--r-- | src/plugins/bearer/nla/qnlaengine.h (renamed from src/network/bearer/qnlaengine_win_p.h) | 11 | ||||
-rw-r--r-- | src/plugins/bearer/platformdefs_win.h (renamed from src/network/bearer/qnetworksessionengine_win_p.h) | 17 |
12 files changed, 146 insertions, 62 deletions
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri index bed2597..2c2d255 100644 --- a/src/network/bearer/bearer.pri +++ b/src/network/bearer/bearer.pri @@ -82,21 +82,10 @@ symbian { contains(QT_CONFIG, networkmanager):DEFINES += BACKEND_NM - win32 { - HEADERS += bearer/qnlaengine_win_p.h \ - bearer/qnetworksessionengine_win_p.h + win32:!wince* { + HEADERS += bearer/qnativewifiengine_win_p.h - SOURCES += bearer/qnlaengine_win.cpp - - !wince* { - HEADERS += bearer/qnativewifiengine_win_p.h - - SOURCES += bearer/qnativewifiengine_win.cpp - - LIBS += -lWs2_32 - } else { - LIBS += -lWs2 - } + SOURCES += bearer/qnativewifiengine_win.cpp } macx { diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 7b68394..c61bcd3 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -41,9 +41,6 @@ #include "qnetworkconfigmanager_p.h" -#ifdef Q_OS_WIN -#include "qnlaengine_win_p.h" -#endif #ifdef Q_OS_WIN32 #include "qnativewifiengine_win_p.h" #endif @@ -269,11 +266,17 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() #endif #ifdef Q_OS_WIN - nla = QNlaEngine::instance(); - if (nla) { - connect(nla, SIGNAL(configurationsChanged()), - this, SLOT(updateConfigurations())); + if (keys.contains(QLatin1String("nla"))) { + QBearerEnginePlugin *nlaPlugin = + qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("nla"))); + if (nlaPlugin) { + nla = nlaPlugin->create(QLatin1String("nla")); + if (nla) { + connect(nla, SIGNAL(configurationsChanged()), + this, SLOT(updateConfigurations())); + } } + } #endif #ifdef Q_OS_WIN32 diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 6a61891..7b824f0 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -137,7 +137,7 @@ private: #ifdef BEARER_ENGINE QNetworkSessionEngine *generic; #ifdef Q_OS_WIN - QNlaEngine *nla; + QNetworkSessionEngine *nla; #ifndef Q_OS_WINCE QNativeWifiEngine *nativeWifi; #endif diff --git a/src/network/bearer/qnetworksession_p.cpp b/src/network/bearer/qnetworksession_p.cpp index cb170e8..1ce94e2 100644 --- a/src/network/bearer/qnetworksession_p.cpp +++ b/src/network/bearer/qnetworksession_p.cpp @@ -44,9 +44,6 @@ #include "qnetworksessionengine_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 @@ -59,18 +56,14 @@ #include <QtNetwork/qnetworkinterface.h> +#undef interface + QT_BEGIN_NAMESPACE static QNetworkSessionEngine *getEngineFromId(const QString &id) { QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate(); -#ifdef Q_OS_WIN - QNlaEngine *nla = QNlaEngine::instance(); - if (nla && nla->hasIdentifier(id)) - return nla; -#endif - #ifdef Q_OS_WIN32 QNativeWifiEngine *nativeWifi = QNativeWifiEngine::instance(); if (nativeWifi && nativeWifi->hasIdentifier(id)) diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro index 60ba81b..51323b0 100644 --- a/src/plugins/bearer/bearer.pro +++ b/src/plugins/bearer/bearer.pro @@ -2,3 +2,4 @@ TEMPLATE = subdirs SUBDIRS += generic contains(QT_CONFIG, dbus):contains(QT_CONFIG, networkmanager):SUBDIRS += networkmanager +win32:SUBDIRS += nla diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro index d32dbe6..506417c 100644 --- a/src/plugins/bearer/generic/generic.pro +++ b/src/plugins/bearer/generic/generic.pro @@ -5,7 +5,8 @@ QT += network DEFINES += BEARER_ENGINE -HEADERS += qgenericengine.h +HEADERS += qgenericengine.h \ + ../platformdefs_win.h SOURCES += qgenericengine.cpp main.cpp QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 89db82b..4be27ba 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -51,7 +51,7 @@ #include <QtCore/qdebug.h> #ifdef Q_OS_WIN -#include "qnetworksessionengine_win_p.h" +#include "../platformdefs_win.h" #endif QT_BEGIN_NAMESPACE diff --git a/src/plugins/bearer/nla/main.cpp b/src/plugins/bearer/nla/main.cpp new file mode 100644 index 0000000..f0d36c4 --- /dev/null +++ b/src/plugins/bearer/nla/main.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 plugins of the Qt Toolkit. +** +** $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.h" + +#include <QtNetwork/qbearerplugin.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +class QNlaEnginePlugin : public QBearerEnginePlugin +{ +public: + QNlaEnginePlugin(); + ~QNlaEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QNlaEnginePlugin::QNlaEnginePlugin() +{ +} + +QNlaEnginePlugin::~QNlaEnginePlugin() +{ +} + +QStringList QNlaEnginePlugin::keys() const +{ + qDebug() << Q_FUNC_INFO; + + return QStringList() << QLatin1String("nla"); +} + +QBearerEngine *QNlaEnginePlugin::create(const QString &key) const +{ + qDebug() << Q_FUNC_INFO; + + if (key == QLatin1String("nla")) + return new QNlaEngine; + else + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QNlaEnginePlugin) +Q_EXPORT_PLUGIN2(qnlabearer, QNlaEnginePlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/bearer/nla/nla.pro b/src/plugins/bearer/nla/nla.pro new file mode 100644 index 0000000..78f3271 --- /dev/null +++ b/src/plugins/bearer/nla/nla.pro @@ -0,0 +1,20 @@ +TARGET = qnlabearer +include(../../qpluginbase.pri) + +QT += network + +!wince* { + LIBS += -lWs2_32 +} else { + LIBS += -lWs2 +} + +DEFINES += BEARER_ENGINE + +HEADERS += qnlaengine.h \ + ../platformdefs_win.h +SOURCES += qnlaengine.cpp main.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target diff --git a/src/network/bearer/qnlaengine_win.cpp b/src/plugins/bearer/nla/qnlaengine.cpp index 579b0e1..527776f 100644 --- a/src/network/bearer/qnlaengine_win.cpp +++ b/src/plugins/bearer/nla/qnlaengine.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qnlaengine_win_p.h" -#include "qnetworkconfiguration_p.h" +#include "qnlaengine.h" +#include <QtNetwork/private/qnetworkconfiguration_p.h> #include <QtCore/qthread.h> #include <QtCore/qmutex.h> @@ -49,13 +49,13 @@ #include <QtCore/qdebug.h> -#include "qnetworksessionengine_win_p.h" +#include "../platformdefs_win.h" QT_BEGIN_NAMESPACE Q_GLOBAL_STATIC(QNlaEngine, nlaEngine) -QWindowsSockInit::QWindowsSockInit() +QWindowsSockInit2::QWindowsSockInit2() : version(0) { //### should we try for 2.2 on all platforms ?? @@ -69,7 +69,7 @@ QWindowsSockInit::QWindowsSockInit() } } -QWindowsSockInit::~QWindowsSockInit() +QWindowsSockInit2::~QWindowsSockInit2() { WSACleanup(); } @@ -130,8 +130,8 @@ static QString qGetInterfaceType(const QString &interface) 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); + HANDLE handle = CreateFile((TCHAR *)QString(QLatin1String("\\\\.\\%1")).arg(interface).utf16(), + 0, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); if (handle == INVALID_HANDLE_VALUE) return QString(); @@ -377,7 +377,7 @@ DWORD QNlaThread::parseBlob(NLA_BLOB *blob, QNetworkConfigurationPrivate *cpPriv cpPriv->state = QNetworkConfiguration::Active; if (QNlaEngine *engine = qobject_cast<QNlaEngine *>(parent())) { engine->configurationInterface[cpPriv->id.toUInt()] = - QString(blob->data.interfaceData.adapterName); + QString::fromLatin1(blob->data.interfaceData.adapterName); } break; case NLA_802_1X_LOCATION: @@ -584,8 +584,7 @@ QNlaEngine *QNlaEngine::instance() return nlaEngine(); } -#include "qnlaengine_win.moc" -#include "moc_qnlaengine_win_p.cpp" +#include "qnlaengine.moc" QT_END_NAMESPACE diff --git a/src/network/bearer/qnlaengine_win_p.h b/src/plugins/bearer/nla/qnlaengine.h index 1e7d051..76505fb 100644 --- a/src/network/bearer/qnlaengine_win_p.h +++ b/src/plugins/bearer/nla/qnlaengine.h @@ -53,7 +53,8 @@ // We mean it. // -#include "qnetworksessionengine_p.h" +#include <QtNetwork/private/qnetworksessionengine_p.h> +#include <QtNetwork/private/qnativesocketengine_p.h> #include <QMap> @@ -62,11 +63,11 @@ QT_BEGIN_NAMESPACE class QNetworkConfigurationPrivate; class QNlaThread; -class QWindowsSockInit +class QWindowsSockInit2 { public: - QWindowsSockInit(); - ~QWindowsSockInit(); + QWindowsSockInit2(); + ~QWindowsSockInit2(); int version; }; @@ -94,7 +95,7 @@ public: static QNlaEngine *instance(); private: - QWindowsSockInit winSock; + QWindowsSockInit2 winSock; QNlaThread *nlaThread; QMap<uint, QString> configurationInterface; }; diff --git a/src/network/bearer/qnetworksessionengine_win_p.h b/src/plugins/bearer/platformdefs_win.h index e68a35b..133b7b1 100644 --- a/src/network/bearer/qnetworksessionengine_win_p.h +++ b/src/plugins/bearer/platformdefs_win.h @@ -39,19 +39,8 @@ ** ****************************************************************************/ -#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. -// +#ifndef QPLATFORMDEFS_WIN_H +#define QPLATFORMDEFS_WIN_H #include <winsock2.h> #include <mswsock.h> @@ -142,4 +131,4 @@ enum NDIS_PHYSICAL_MEDIUM { #define IOCTL_NDIS_QUERY_GLOBAL_STATS \ CTL_CODE(FILE_DEVICE_PHYSICAL_NETCARD, 0, METHOD_OUT_DIRECT, FILE_ANY_ACCESS) -#endif // QNETWORKSESSIONENGINE_WIN_P_H +#endif |