diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2009-12-22 05:08:34 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2009-12-22 05:08:34 (GMT) |
commit | 5c07b6b24144774f16a20115eec1a6700d0db254 (patch) | |
tree | 0bd004ec8151036e38f212512c549ddfb956679c /src | |
parent | 70d0623570936696ca28536a46a3be63c691f50b (diff) | |
download | Qt-5c07b6b24144774f16a20115eec1a6700d0db254.zip Qt-5c07b6b24144774f16a20115eec1a6700d0db254.tar.gz Qt-5c07b6b24144774f16a20115eec1a6700d0db254.tar.bz2 |
Convert NetworkManager engine into a plugin.
Conflicts:
src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
src/plugins/bearer/networkmanager/qnmdbushelper.cpp
src/plugins/bearer/networkmanager/qnmdbushelper.h
src/plugins/bearer/networkmanager/qnmwifiengine.cpp
src/plugins/bearer/networkmanager/qnmwifiengine.h
Diffstat (limited to 'src')
13 files changed, 150 insertions, 85 deletions
diff --git a/src/network/bearer/bearer.pri b/src/network/bearer/bearer.pri index 4f53621..bed2597 100644 --- a/src/network/bearer/bearer.pri +++ b/src/network/bearer/bearer.pri @@ -80,22 +80,7 @@ symbian { bearer/qnetworksession_p.cpp \ bearer/qnetworksessionengine.cpp - unix:!mac:contains(networkmanager_enabled, yes) { - contains(QT_CONFIG,dbus) { - DEFINES += BACKEND_NM - QT += dbus - - HEADERS += bearer/qnmdbushelper_p.h \ - bearer/qnetworkmanagerservice_p.h \ - bearer/qnmwifiengine_unix_p.h - - SOURCES += bearer/qnmdbushelper.cpp \ - bearer/qnetworkmanagerservice_p.cpp \ - bearer/qnmwifiengine_unix.cpp - } else { - message("NetworkManager backend requires Qt DBus support") - } - } + contains(QT_CONFIG, networkmanager):DEFINES += BACKEND_NM win32 { HEADERS += bearer/qnlaengine_win_p.h \ diff --git a/src/network/bearer/qnetworkconfigmanager_p.cpp b/src/network/bearer/qnetworkconfigmanager_p.cpp index 3e82ab7..7b68394 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.cpp +++ b/src/network/bearer/qnetworkconfigmanager_p.cpp @@ -47,9 +47,6 @@ #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 @@ -244,13 +241,21 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() this, SLOT(updateConfigurations())); } #else -#if defined(BACKEND_NM) - nmWifi = QNmWifiEngine::instance(); - if (nmWifi) { - connect(nmWifi, SIGNAL(configurationsChanged()), - this, SLOT(updateConfigurations())); - } else { +#ifdef BACKEND_NM + if (keys.contains(QLatin1String("networkmanager"))) { + QBearerEnginePlugin *nmPlugin = + qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("networkmanager"))); + if (nmPlugin) { + nmWifi = nmPlugin->create(QLatin1String("networkmanager")); + if (nmWifi) { + connect(nmWifi, SIGNAL(configurationsChanged()), + this, SLOT(updateConfigurations())); + } + } + } #endif + + if (keys.contains(QLatin1String("generic"))) { QBearerEnginePlugin *genericPlugin = qobject_cast<QBearerEnginePlugin *>(l->instance(QLatin1String("generic"))); if (genericPlugin) { @@ -260,10 +265,8 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() this, SLOT(updateConfigurations())); } } -#if defined(BACKEND_NM) } #endif -#endif #ifdef Q_OS_WIN nla = QNlaEngine::instance(); @@ -293,7 +296,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() #if defined(BACKEND_NM) if (engine == nmWifi) updateState &= ~NmUpdating; - else if (engine == generic) + if (engine == generic) updateState &= ~GenericUpdating; #else if (engine == generic) @@ -319,7 +322,7 @@ void QNetworkConfigurationManagerPrivate::updateConfigurations() #if defined(BACKEND_NM) if (nmWifi) engines << nmWifi; - else if (generic) + if (generic) engines << generic; #else if (generic) @@ -431,7 +434,8 @@ void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate() if (nmWifi) { updateState |= NmUpdating; nmWifi->requestUpdate(); - } else if (generic) { + } + if (generic) { updateState |= GenericUpdating; generic->requestUpdate(); } diff --git a/src/network/bearer/qnetworkconfigmanager_p.h b/src/network/bearer/qnetworkconfigmanager_p.h index 2ac6401..6a61891 100644 --- a/src/network/bearer/qnetworkconfigmanager_p.h +++ b/src/network/bearer/qnetworkconfigmanager_p.h @@ -143,7 +143,7 @@ private: #endif #endif #ifdef BACKEND_NM - QNmWifiEngine *nmWifi; + QNetworkSessionEngine *nmWifi; #endif #ifdef Q_OS_DARWIN QCoreWlanEngine *coreWifi; diff --git a/src/network/bearer/qnetworksession_p.cpp b/src/network/bearer/qnetworksession_p.cpp index c2491ae..cb170e8 100644 --- a/src/network/bearer/qnetworksession_p.cpp +++ b/src/network/bearer/qnetworksession_p.cpp @@ -59,26 +59,8 @@ #include <QtNetwork/qnetworkinterface.h> -#if defined(BACKEND_NM) -#include "qnmwifiengine_unix_p.h" -#endif - QT_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 - static QNetworkSessionEngine *getEngineFromId(const QString &id) { QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate(); @@ -95,13 +77,6 @@ static QNetworkSessionEngine *getEngineFromId(const QString &id) return nativeWifi; #endif -#if defined(BACKEND_NM) - if(NetworkManagerAvailable()) { - QNmWifiEngine *nmwiifi = QNmWifiEngine::instance(); - if (nmwiifi && nmwiifi->hasIdentifier(id)) - return nmwiifi; - } -#endif #ifdef Q_OS_DARWIN QCoreWlanEngine *coreWifi = QCoreWlanEngine::instance(); if (coreWifi && coreWifi->hasIdentifier(id)) @@ -322,7 +297,7 @@ QNetworkSession::SessionError QNetworkSessionPrivate::error() const quint64 QNetworkSessionPrivate::bytesWritten() const { -#if defined(BACKEND_NM) +#if defined(BACKEND_NM) && 0 if( state == QNetworkSession::Connected ) { if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { foreach (const QNetworkConfiguration &config, publicConfig.children()) { @@ -340,7 +315,7 @@ quint64 QNetworkSessionPrivate::bytesWritten() const quint64 QNetworkSessionPrivate::bytesReceived() const { -#if defined(BACKEND_NM) +#if defined(BACKEND_NM) && 0 if( state == QNetworkSession::Connected ) { if (publicConfig.type() == QNetworkConfiguration::ServiceNetwork) { foreach (const QNetworkConfiguration &config, publicConfig.children()) { @@ -445,7 +420,7 @@ void QNetworkSessionPrivate::networkConfigurationsChanged() updateStateFromServiceNetwork(); else updateStateFromActiveConfig(); -#if defined(BACKEND_NM) +#if defined(BACKEND_NM) && 0 setActiveTimeStamp(); #endif } @@ -492,7 +467,7 @@ void QNetworkSessionPrivate::connectionError(const QString &id, QNetworkSessionE } } -#if defined(BACKEND_NM) +#if defined(BACKEND_NM) && 0 void QNetworkSessionPrivate::setActiveTimeStamp() { if(NetworkManagerAvailable()) { diff --git a/src/plugins/bearer/bearer.pro b/src/plugins/bearer/bearer.pro index 0e3ef48..60ba81b 100644 --- a/src/plugins/bearer/bearer.pro +++ b/src/plugins/bearer/bearer.pro @@ -1,3 +1,4 @@ TEMPLATE = subdirs SUBDIRS += generic +contains(QT_CONFIG, dbus):contains(QT_CONFIG, networkmanager):SUBDIRS += networkmanager diff --git a/src/plugins/bearer/networkmanager/main.cpp b/src/plugins/bearer/networkmanager/main.cpp new file mode 100644 index 0000000..c79fe91 --- /dev/null +++ b/src/plugins/bearer/networkmanager/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 "qnmwifiengine.h" + +#include <QtNetwork/qbearerplugin.h> + +#include <QtCore/qdebug.h> + +QT_BEGIN_NAMESPACE + +class QNetworkManagerEnginePlugin : public QBearerEnginePlugin +{ +public: + QNetworkManagerEnginePlugin(); + ~QNetworkManagerEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QNetworkManagerEnginePlugin::QNetworkManagerEnginePlugin() +{ +} + +QNetworkManagerEnginePlugin::~QNetworkManagerEnginePlugin() +{ +} + +QStringList QNetworkManagerEnginePlugin::keys() const +{ + qDebug() << Q_FUNC_INFO; + + return QStringList() << QLatin1String("networkmanager"); +} + +QBearerEngine *QNetworkManagerEnginePlugin::create(const QString &key) const +{ + qDebug() << Q_FUNC_INFO; + + if (key == QLatin1String("networkmanager")) + return new QNmWifiEngine; + else + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QNetworkManagerEnginePlugin) +Q_EXPORT_PLUGIN2(qnmbearer, QNetworkManagerEnginePlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro new file mode 100644 index 0000000..36d150a --- /dev/null +++ b/src/plugins/bearer/networkmanager/networkmanager.pro @@ -0,0 +1,19 @@ +TARGET = qnmbearer +include(../../qpluginbase.pri) + +QT += network dbus + +DEFINES += BEARER_ENGINE BACKEND_NM + +HEADERS += qnmdbushelper.h \ + qnetworkmanagerservice.h \ + qnmwifiengine.h + +SOURCES += main.cpp \ + qnmdbushelper.cpp \ + qnetworkmanagerservice.cpp \ + qnmwifiengine.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target diff --git a/src/network/bearer/qnetworkmanagerservice_p.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 9516f31..e95c2e6 100644 --- a/src/network/bearer/qnetworkmanagerservice_p.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -53,8 +53,8 @@ #include <NetworkManager/NetworkManager.h> -#include <qnmdbushelper_p.h> -#include "qnetworkmanagerservice_p.h" +#include "qnmdbushelper.h" +#include "qnetworkmanagerservice.h" //Q_DECLARE_METATYPE(QList<uint>) QT_BEGIN_NAMESPACE @@ -1006,6 +1006,4 @@ QStringList QNetworkManagerIp4Config::domains() const return d->connectionInterface->property("Domains").toStringList(); } -#include "moc_qnetworkmanagerservice_p.cpp" - QT_END_NAMESPACE diff --git a/src/network/bearer/qnetworkmanagerservice_p.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h index 520aeac..8bed45b 100644 --- a/src/network/bearer/qnetworkmanagerservice_p.h +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -64,7 +64,7 @@ #include <QDBusPendingCallWatcher> -#include "qnmdbushelper_p.h" +#include "qnmdbushelper.h" QT_BEGIN_NAMESPACE diff --git a/src/network/bearer/qnmdbushelper.cpp b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp index 5d7403b..1d16e55 100644 --- a/src/network/bearer/qnmdbushelper.cpp +++ b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -41,16 +41,14 @@ // this class is for helping qdbus get stuff -#include "qnmdbushelper_p.h" +#include "qnmdbushelper.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> @@ -113,5 +111,4 @@ void QNmDBusHelper::slotSettingsRemoved() emit pathForSettingsRemoved(msg.path()); } -#include "moc_qnmdbushelper_p.cpp" QT_END_NAMESPACE diff --git a/src/network/bearer/qnmdbushelper_p.h b/src/plugins/bearer/networkmanager/qnmdbushelper.h index 99b0357..9794f98 100644 --- a/src/network/bearer/qnmdbushelper_p.h +++ b/src/plugins/bearer/networkmanager/qnmdbushelper.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -53,11 +53,9 @@ // We mean it. // -#if !defined(QT_NO_DBUS) && !defined(Q_OS_MAC) #include <QDBusObjectPath> #include <QDBusContext> #include <QMap> -#endif QT_BEGIN_NAMESPACE diff --git a/src/network/bearer/qnmwifiengine_unix.cpp b/src/plugins/bearer/networkmanager/qnmwifiengine.cpp index 5870a9f..4a814ec 100644 --- a/src/network/bearer/qnmwifiengine_unix.cpp +++ b/src/plugins/bearer/networkmanager/qnmwifiengine.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -39,15 +39,16 @@ ** ****************************************************************************/ -#include "qnmwifiengine_unix_p.h" -#include "qnetworkconfiguration_p.h" +#include "qnmwifiengine.h" + +#include <QtNetwork/private/qnetworkconfiguration_p.h> #include <qnetworkconfiguration.h> #include <QtCore/qstringlist.h> #include <QtNetwork/qnetworkinterface.h> #include <NetworkManager/NetworkManager.h> -#include <qnetworkmanagerservice_p.h> +#include "qnetworkmanagerservice.h" #include <QNetworkInterface> @@ -1123,7 +1124,5 @@ QStringList QNmWifiEngine::getConnectionPathForId(const QString &uuid) return QStringList(); } -#include "moc_qnmwifiengine_unix_p.cpp" - QT_END_NAMESPACE diff --git a/src/network/bearer/qnmwifiengine_unix_p.h b/src/plugins/bearer/networkmanager/qnmwifiengine.h index 3af73ea..4d514e7 100644 --- a/src/network/bearer/qnmwifiengine_unix_p.h +++ b/src/plugins/bearer/networkmanager/qnmwifiengine.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the plugins of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage @@ -58,12 +58,13 @@ #include <QHash> #include <QDBusPendingCallWatcher> #include <QExplicitlySharedDataPointer> -#include <qnetworkmanagerservice_p.h> -#include "qnetworksessionengine_p.h" +#include "qnetworkmanagerservice.h" + +#include <QtNetwork/private/qnetworksessionengine_p.h> #include <qnetworksession.h> #include <qnetworkconfiguration.h> -#include <qnetworkconfigmanager_p.h> +#include <QtNetwork/private/qnetworkconfigmanager_p.h> |