summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/networkmanager
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/bearer/networkmanager')
-rw-r--r--src/plugins/bearer/networkmanager/main.cpp95
-rw-r--r--src/plugins/bearer/networkmanager/networkmanager.pro20
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp911
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.h142
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp931
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h448
-rw-r--r--src/plugins/bearer/networkmanager/qnmdbushelper.cpp130
-rw-r--r--src/plugins/bearer/networkmanager/qnmdbushelper.h79
8 files changed, 2756 insertions, 0 deletions
diff --git a/src/plugins/bearer/networkmanager/main.cpp b/src/plugins/bearer/networkmanager/main.cpp
new file mode 100644
index 0000000000..43dacca709
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/main.cpp
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qnetworkmanagerengine.h"
+
+#include <QtNetwork/private/qbearerplugin_p.h>
+
+#include <QtCore/qdebug.h>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+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
+{
+ return QStringList() << QLatin1String("networkmanager");
+}
+
+QBearerEngine *QNetworkManagerEnginePlugin::create(const QString &key) const
+{
+ if (key == QLatin1String("networkmanager")) {
+ QNetworkManagerEngine *engine = new QNetworkManagerEngine;
+ if (engine->networkManagerAvailable())
+ return engine;
+ else
+ delete engine;
+ }
+
+ return 0;
+}
+
+Q_EXPORT_STATIC_PLUGIN(QNetworkManagerEnginePlugin)
+Q_EXPORT_PLUGIN2(qnmbearer, QNetworkManagerEnginePlugin)
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/networkmanager/networkmanager.pro b/src/plugins/bearer/networkmanager/networkmanager.pro
new file mode 100644
index 0000000000..e39626336c
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/networkmanager.pro
@@ -0,0 +1,20 @@
+TARGET = qnmbearer
+include(../../qpluginbase.pri)
+
+QT = core network dbus
+
+HEADERS += qnmdbushelper.h \
+ qnetworkmanagerservice.h \
+ qnetworkmanagerengine.h \
+ ../qnetworksession_impl.h \
+ ../qbearerengine_impl.h
+
+SOURCES += main.cpp \
+ qnmdbushelper.cpp \
+ qnetworkmanagerservice.cpp \
+ qnetworkmanagerengine.cpp \
+ ../qnetworksession_impl.cpp
+
+QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer
+target.path += $$[QT_INSTALL_PLUGINS]/bearer
+INSTALLS += target
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
new file mode 100644
index 0000000000..6b37b38e8c
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -0,0 +1,911 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 "qnetworkmanagerengine.h"
+#include "qnetworkmanagerservice.h"
+#include "../qnetworksession_impl.h"
+
+#include <QtNetwork/private/qnetworkconfiguration_p.h>
+
+#include <QtNetwork/qnetworksession.h>
+
+#include <QtCore/qdebug.h>
+
+#include <QtDBus>
+#include <QDBusConnection>
+#include <QDBusError>
+#include <QDBusInterface>
+#include <QDBusMessage>
+#include <QDBusReply>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent)
+: QBearerEngineImpl(parent),
+ interface(new QNetworkManagerInterface(this)),
+ systemSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_SYSTEM_SETTINGS, this)),
+ userSettings(new QNetworkManagerSettings(NM_DBUS_SERVICE_USER_SETTINGS, this))
+{
+ if (!interface->isValid())
+ return;
+
+ interface->setConnections();
+ connect(interface, SIGNAL(deviceAdded(QDBusObjectPath)),
+ this, SLOT(deviceAdded(QDBusObjectPath)));
+ connect(interface, SIGNAL(deviceRemoved(QDBusObjectPath)),
+ this, SLOT(deviceRemoved(QDBusObjectPath)));
+#if 0
+ connect(interface, SIGNAL(stateChanged(const QString,quint32)),
+ this, SIGNAL(configurationsChanged()));
+#endif
+ connect(interface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
+ this, SLOT(activationFinished(QDBusPendingCallWatcher*)));
+ connect(interface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
+ this, SLOT(interfacePropertiesChanged(QString,QMap<QString,QVariant>)));
+
+ qDBusRegisterMetaType<QNmSettingsMap>();
+
+ systemSettings->setConnections();
+ connect(systemSettings, SIGNAL(newConnection(QDBusObjectPath)),
+ this, SLOT(newConnection(QDBusObjectPath)));
+
+ userSettings->setConnections();
+ connect(userSettings, SIGNAL(newConnection(QDBusObjectPath)),
+ this, SLOT(newConnection(QDBusObjectPath)));
+}
+
+QNetworkManagerEngine::~QNetworkManagerEngine()
+{
+ qDeleteAll(connections);
+ qDeleteAll(accessPoints);
+ qDeleteAll(wirelessDevices);
+ qDeleteAll(activeConnections);
+}
+
+void QNetworkManagerEngine::initialize()
+{
+ QMutexLocker locker(&mutex);
+
+ // Get current list of access points.
+ foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
+ locker.unlock();
+ deviceAdded(devicePath);
+ locker.relock();
+ }
+
+ // Get connections.
+ foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) {
+ locker.unlock();
+ newConnection(settingsPath, systemSettings);
+ locker.relock();
+ }
+ foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) {
+ locker.unlock();
+ newConnection(settingsPath, userSettings);
+ locker.relock();
+ }
+
+ // Get active connections.
+ foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ QNetworkManagerConnectionActive *activeConnection =
+ new QNetworkManagerConnectionActive(acPath.path());
+ activeConnections.insert(acPath.path(), activeConnection);
+
+ activeConnection->setConnections();
+ connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
+ this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>)));
+ }
+}
+
+bool QNetworkManagerEngine::networkManagerAvailable() const
+{
+ QMutexLocker locker(&mutex);
+
+ return interface->isValid();
+}
+
+QString QNetworkManagerEngine::getInterfaceFromId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ QNetworkManagerConnectionActive activeConnection(acPath.path());
+
+ const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' +
+ activeConnection.connection().path()));
+
+ if (id == identifier) {
+ QList<QDBusObjectPath> devices = activeConnection.devices();
+
+ if (devices.isEmpty())
+ continue;
+
+ QNetworkManagerInterfaceDevice device(devices.at(0).path());
+ return device.networkInterface();
+ }
+ }
+
+ return QString();
+}
+
+bool QNetworkManagerEngine::hasIdentifier(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ if (connectionFromId(id))
+ return true;
+
+ for (int i = 0; i < accessPoints.count(); ++i) {
+ QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
+
+ const QString identifier =
+ QString::number(qHash(accessPoint->connectionInterface()->path()));
+
+ if (id == identifier)
+ return true;
+ }
+
+ return false;
+}
+
+void QNetworkManagerEngine::connectToId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ QNetworkManagerSettingsConnection *connection = connectionFromId(id);
+
+ if (!connection)
+ return;
+
+ QNmSettingsMap map = connection->getSettings();
+ const QString connectionType = map.value("connection").value("type").toString();
+
+ QString dbusDevicePath;
+ foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
+ QNetworkManagerInterfaceDevice device(devicePath.path());
+ if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET &&
+ connectionType == QLatin1String("802-3-ethernet")) {
+ dbusDevicePath = devicePath.path();
+ break;
+ } else if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS &&
+ connectionType == QLatin1String("802-11-wireless")) {
+ dbusDevicePath = devicePath.path();
+ break;
+ }
+ else if (device.deviceType() == DEVICE_TYPE_GSM &&
+ connectionType == QLatin1String("gsm")) {
+ dbusDevicePath = devicePath.path();
+ break;
+ }
+ }
+
+ const QString service = connection->connectionInterface()->service();
+ const QString settingsPath = connection->connectionInterface()->path();
+
+ interface->activateConnection(service, QDBusObjectPath(settingsPath),
+ QDBusObjectPath(dbusDevicePath), QDBusObjectPath("/"));
+}
+
+void QNetworkManagerEngine::disconnectFromId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ QNetworkManagerConnectionActive activeConnection(acPath.path());
+
+ const QString identifier = QString::number(qHash(activeConnection.serviceName() + ' ' +
+ activeConnection.connection().path()));
+
+ if (id == identifier && accessPointConfigurations.contains(id)) {
+ interface->deactivateConnection(acPath);
+ break;
+ }
+ }
+}
+
+void QNetworkManagerEngine::requestUpdate()
+{
+ QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
+}
+
+void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
+ const QMap<QString, QVariant> &properties)
+{
+ QMutexLocker locker(&mutex);
+
+ Q_UNUSED(path)
+
+ QMapIterator<QString, QVariant> i(properties);
+ while (i.hasNext()) {
+ i.next();
+
+ if (i.key() == QLatin1String("ActiveConnections")) {
+ // Active connections changed, update configurations.
+
+ QList<QDBusObjectPath> activeConnections =
+ qdbus_cast<QList<QDBusObjectPath> >(i.value().value<QDBusArgument>());
+
+ QStringList identifiers = accessPointConfigurations.keys();
+ foreach (const QString &id, identifiers)
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ QStringList priorActiveConnections = this->activeConnections.keys();
+
+ foreach (const QDBusObjectPath &acPath, activeConnections) {
+ priorActiveConnections.removeOne(acPath.path());
+ QNetworkManagerConnectionActive *activeConnection =
+ this->activeConnections.value(acPath.path());
+ if (!activeConnection) {
+ activeConnection = new QNetworkManagerConnectionActive(acPath.path());
+ this->activeConnections.insert(acPath.path(), activeConnection);
+
+ activeConnection->setConnections();
+ connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
+ this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>)));
+ }
+
+ const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' +
+ activeConnection->connection().path()));
+
+ identifiers.removeOne(id);
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+ if (ptr) {
+ ptr->mutex.lock();
+ if (activeConnection->state() == 2 &&
+ ptr->state != QNetworkConfiguration::Active) {
+ ptr->state = QNetworkConfiguration::Active;
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ } else {
+ ptr->mutex.unlock();
+ }
+ }
+ }
+
+ while (!priorActiveConnections.isEmpty())
+ delete this->activeConnections.take(priorActiveConnections.takeFirst());
+
+ while (!identifiers.isEmpty()) {
+ // These configurations are not active
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.value(identifiers.takeFirst());
+
+ ptr->mutex.lock();
+ if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ ptr->state = QNetworkConfiguration::Discovered;
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ } else {
+ ptr->mutex.unlock();
+ }
+ }
+ }
+ }
+}
+
+void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &path,
+ const QMap<QString, QVariant> &properties)
+{
+ QMutexLocker locker(&mutex);
+
+ Q_UNUSED(properties)
+
+ QNetworkManagerConnectionActive *activeConnection = activeConnections.value(path);
+
+ if (!activeConnection)
+ return;
+
+ const QString id = QString::number(qHash(activeConnection->serviceName() + ' ' +
+ activeConnection->connection().path()));
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+ if (ptr) {
+ ptr->mutex.lock();
+ if (activeConnection->state() == 2 &&
+ ptr->state != QNetworkConfiguration::Active) {
+ ptr->state = QNetworkConfiguration::Active;
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ } else {
+ ptr->mutex.unlock();
+ }
+ }
+}
+
+void QNetworkManagerEngine::devicePropertiesChanged(const QString &path,
+ const QMap<QString, QVariant> &properties)
+{
+ Q_UNUSED(path);
+ Q_UNUSED(properties);
+}
+
+void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path)
+{
+ QNetworkManagerInterfaceDevice device(path.path());
+ if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
+ QNetworkManagerInterfaceDeviceWireless *wirelessDevice =
+ new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path());
+
+ wirelessDevice->setConnections();
+ connect(wirelessDevice, SIGNAL(accessPointAdded(QString,QDBusObjectPath)),
+ this, SLOT(newAccessPoint(QString,QDBusObjectPath)));
+ connect(wirelessDevice, SIGNAL(accessPointRemoved(QString,QDBusObjectPath)),
+ this, SLOT(removeAccessPoint(QString,QDBusObjectPath)));
+ connect(wirelessDevice, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
+ this, SLOT(devicePropertiesChanged(QString,QMap<QString,QVariant>)));
+
+ foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints())
+ newAccessPoint(QString(), apPath);
+
+ mutex.lock();
+ wirelessDevices.insert(path.path(), wirelessDevice);
+ mutex.unlock();
+ }
+}
+
+void QNetworkManagerEngine::deviceRemoved(const QDBusObjectPath &path)
+{
+ QMutexLocker locker(&mutex);
+
+ delete wirelessDevices.take(path.path());
+}
+
+void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
+ QNetworkManagerSettings *settings)
+{
+ QMutexLocker locker(&mutex);
+
+ if (!settings)
+ settings = qobject_cast<QNetworkManagerSettings *>(sender());
+
+ if (!settings)
+ return;
+
+ QNetworkManagerSettingsConnection *connection =
+ new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(),
+ path.path());
+ connections.append(connection);
+
+ connect(connection, SIGNAL(removed(QString)), this, SLOT(removeConnection(QString)));
+ connect(connection, SIGNAL(updated(const QNmSettingsMap&)),
+ this, SLOT(updateConnection(const QNmSettingsMap&)));
+
+ const QString service = connection->connectionInterface()->service();
+ const QString settingsPath = connection->connectionInterface()->path();
+
+ QNetworkConfigurationPrivate *cpPriv =
+ parseConnection(service, settingsPath, connection->getSettings());
+
+ // Check if connection is active.
+ foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ QNetworkManagerConnectionActive activeConnection(acPath.path());
+
+ if (activeConnection.serviceName() == service &&
+ activeConnection.connection().path() == settingsPath &&
+ activeConnection.state() == 2) {
+ cpPriv->state |= QNetworkConfiguration::Active;
+ break;
+ }
+ }
+
+ QNetworkConfigurationPrivatePointer ptr(cpPriv);
+ accessPointConfigurations.insert(ptr->id, ptr);
+
+ locker.unlock();
+ emit configurationAdded(ptr);
+}
+
+void QNetworkManagerEngine::removeConnection(const QString &path)
+{
+ QMutexLocker locker(&mutex);
+
+ Q_UNUSED(path)
+
+ QNetworkManagerSettingsConnection *connection =
+ qobject_cast<QNetworkManagerSettingsConnection *>(sender());
+ if (!connection)
+ return;
+
+ connections.removeAll(connection);
+
+ const QString id = QString::number(qHash(connection->connectionInterface()->service() + ' ' +
+ connection->connectionInterface()->path()));
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
+
+ connection->deleteLater();
+
+ locker.unlock();
+ emit configurationRemoved(ptr);
+}
+
+void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
+{
+ QMutexLocker locker(&mutex);
+
+ QNetworkManagerSettingsConnection *connection =
+ qobject_cast<QNetworkManagerSettingsConnection *>(sender());
+ if (!connection)
+ return;
+
+ const QString service = connection->connectionInterface()->service();
+ const QString settingsPath = connection->connectionInterface()->path();
+
+ QNetworkConfigurationPrivate *cpPriv = parseConnection(service, settingsPath, settings);
+
+ // Check if connection is active.
+ foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
+ QNetworkManagerConnectionActive activeConnection(acPath.path());
+
+ if (activeConnection.serviceName() == service &&
+ activeConnection.connection().path() == settingsPath &&
+ activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
+ cpPriv->state |= QNetworkConfiguration::Active;
+ break;
+ }
+ }
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
+
+ ptr->mutex.lock();
+
+ ptr->isValid = cpPriv->isValid;
+ ptr->name = cpPriv->name;
+ ptr->id = cpPriv->id;
+ ptr->state = cpPriv->state;
+
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ delete cpPriv;
+}
+
+void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher)
+{
+ QMutexLocker locker(&mutex);
+
+ QDBusPendingReply<QDBusObjectPath> reply = *watcher;
+ if (!reply.isError()) {
+ QDBusObjectPath result = reply.value();
+
+ QNetworkManagerConnectionActive activeConnection(result.path());
+
+ const QString id = QString::number(qHash(activeConnection.serviceName() + ' ' +
+ activeConnection.connection().path()));
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+ if (ptr) {
+ ptr->mutex.lock();
+ if (activeConnection.state() == 2 &&
+ ptr->state != QNetworkConfiguration::Active) {
+ ptr->state = QNetworkConfiguration::Active;
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ } else {
+ ptr->mutex.unlock();
+ }
+ }
+ }
+}
+
+void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjectPath &objectPath)
+{
+ QMutexLocker locker(&mutex);
+
+ Q_UNUSED(path)
+
+ QNetworkManagerInterfaceAccessPoint *accessPoint =
+ new QNetworkManagerInterfaceAccessPoint(objectPath.path());
+ accessPoints.append(accessPoint);
+
+ accessPoint->setConnections();
+ connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
+ this, SLOT(updateAccessPoint(QMap<QString,QVariant>)));
+
+ // Check if configuration for this SSID already exists.
+ for (int i = 0; i < accessPoints.count(); ++i) {
+ if (accessPoint != accessPoints.at(i) &&
+ accessPoint->ssid() == accessPoints.at(i)->ssid()) {
+ return;
+ }
+ }
+
+ // Check if configuration exists for connection.
+ if (!accessPoint->ssid().isEmpty()) {
+ for (int i = 0; i < connections.count(); ++i) {
+ QNetworkManagerSettingsConnection *connection = connections.at(i);
+
+ if (accessPoint->ssid() == connection->getSsid()) {
+ const QString service = connection->connectionInterface()->service();
+ const QString settingsPath = connection->connectionInterface()->path();
+ const QString connectionId = QString::number(qHash(service + ' ' + settingsPath));
+
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.value(connectionId);
+ ptr->mutex.lock();
+ ptr->state = QNetworkConfiguration::Discovered;
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ return;
+ }
+ }
+ }
+
+ // New access point.
+ QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);
+
+ ptr->name = accessPoint->ssid();
+ ptr->isValid = true;
+ ptr->id = QString::number(qHash(objectPath.path()));
+ ptr->type = QNetworkConfiguration::InternetAccessPoint;
+ if(accessPoint->flags() == NM_802_11_AP_FLAGS_PRIVACY) {
+ ptr->purpose = QNetworkConfiguration::PrivatePurpose;
+ } else {
+ ptr->purpose = QNetworkConfiguration::PublicPurpose;
+ }
+ ptr->state = QNetworkConfiguration::Undefined;
+ ptr->bearerType = QNetworkConfiguration::BearerWLAN;
+
+ accessPointConfigurations.insert(ptr->id, ptr);
+
+ locker.unlock();
+ emit configurationAdded(ptr);
+}
+
+void QNetworkManagerEngine::removeAccessPoint(const QString &path,
+ const QDBusObjectPath &objectPath)
+{
+ QMutexLocker locker(&mutex);
+
+ Q_UNUSED(path)
+
+ for (int i = 0; i < accessPoints.count(); ++i) {
+ QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
+
+ if (accessPoint->connectionInterface()->path() == objectPath.path()) {
+ accessPoints.removeOne(accessPoint);
+
+ if (configuredAccessPoints.contains(accessPoint)) {
+ // find connection and change state to Defined
+ configuredAccessPoints.removeOne(accessPoint);
+ for (int i = 0; i < connections.count(); ++i) {
+ QNetworkManagerSettingsConnection *connection = connections.at(i);
+
+ if (accessPoint->ssid() == connection->getSsid()) {
+ const QString service = connection->connectionInterface()->service();
+ const QString settingsPath = connection->connectionInterface()->path();
+ const QString connectionId =
+ QString::number(qHash(service + ' ' + settingsPath));
+
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.value(connectionId);
+ ptr->mutex.lock();
+ ptr->state = QNetworkConfiguration::Defined;
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ locker.relock();
+ break;
+ }
+ }
+ } else {
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.take(QString::number(qHash(objectPath.path())));
+
+ if (ptr) {
+ locker.unlock();
+ emit configurationRemoved(ptr);
+ locker.relock();
+ }
+ }
+
+ delete accessPoint;
+
+ break;
+ }
+ }
+}
+
+void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map)
+{
+ QMutexLocker locker(&mutex);
+
+ Q_UNUSED(map)
+
+ QNetworkManagerInterfaceAccessPoint *accessPoint =
+ qobject_cast<QNetworkManagerInterfaceAccessPoint *>(sender());
+ if (!accessPoint)
+ return;
+
+ for (int i = 0; i < connections.count(); ++i) {
+ QNetworkManagerSettingsConnection *connection = connections.at(i);
+
+ if (accessPoint->ssid() == connection->getSsid()) {
+ const QString service = connection->connectionInterface()->service();
+ const QString settingsPath = connection->connectionInterface()->path();
+ const QString connectionId = QString::number(qHash(service + ' ' + settingsPath));
+
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.value(connectionId);
+ ptr->mutex.lock();
+ ptr->state = QNetworkConfiguration::Discovered;
+ ptr->mutex.unlock();
+
+ locker.unlock();
+ emit configurationChanged(ptr);
+ return;
+ }
+ }
+}
+
+QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &service,
+ const QString &settingsPath,
+ const QNmSettingsMap &map)
+{
+ QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
+ cpPriv->name = map.value("connection").value("id").toString();
+ cpPriv->isValid = true;
+ cpPriv->id = QString::number(qHash(service + ' ' + settingsPath));
+ cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
+
+ cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
+
+ cpPriv->state = QNetworkConfiguration::Defined;
+
+ const QString connectionType = map.value("connection").value("type").toString();
+
+ if (connectionType == QLatin1String("802-3-ethernet")) {
+ cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
+ cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
+
+ foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
+ QNetworkManagerInterfaceDevice device(devicePath.path());
+ if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
+ QNetworkManagerInterfaceDeviceWired wiredDevice(device.connectionInterface()->path());
+ if (wiredDevice.carrier()) {
+ cpPriv->state |= QNetworkConfiguration::Discovered;
+ break;
+ }
+
+ }
+ }
+ } else if (connectionType == QLatin1String("802-11-wireless")) {
+ cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
+
+ const QString connectionSsid = map.value("802-11-wireless").value("ssid").toString();
+ const QString connectionSecurity = map.value("802-11-wireless").value("security").toString();
+ if(!connectionSecurity.isEmpty()) {
+ cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
+ } else {
+ cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
+ }
+ for (int i = 0; i < accessPoints.count(); ++i) {
+ if (connectionSsid == accessPoints.at(i)->ssid()) {
+ cpPriv->state |= QNetworkConfiguration::Discovered;
+ if (!configuredAccessPoints.contains(accessPoints.at(i))) {
+ configuredAccessPoints.append(accessPoints.at(i));
+
+ const QString accessPointId =
+ QString::number(qHash(accessPoints.at(i)->connectionInterface()->path()));
+ QNetworkConfigurationPrivatePointer ptr =
+ accessPointConfigurations.take(accessPointId);
+
+ if (ptr) {
+ mutex.unlock();
+ emit configurationRemoved(ptr);
+ mutex.lock();
+ }
+ }
+ break;
+ }
+ }
+ } else if (connectionType == "gsm") {
+ cpPriv->bearerType = QNetworkConfiguration::Bearer2G;
+ } else if (connectionType == "cdma") {
+ cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000;
+ }
+
+ return cpPriv;
+}
+
+QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const QString &id) const
+{
+ for (int i = 0; i < connections.count(); ++i) {
+ QNetworkManagerSettingsConnection *connection = connections.at(i);
+ const QString service = connection->connectionInterface()->service();
+ const QString settingsPath = connection->connectionInterface()->path();
+
+ const QString identifier = QString::number(qHash(service + ' ' + settingsPath));
+
+ if (id == identifier)
+ return connection;
+ }
+
+ return 0;
+}
+
+QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+
+ if (!ptr)
+ return QNetworkSession::Invalid;
+
+ if (!ptr->isValid)
+ return QNetworkSession::Invalid;
+
+ foreach (const QString &acPath, activeConnections.keys()) {
+ QNetworkManagerConnectionActive *activeConnection = activeConnections.value(acPath);
+
+ const QString identifier = QString::number(qHash(activeConnection->serviceName() + ' ' +
+ activeConnection->connection().path()));
+
+ if (id == identifier) {
+ switch (activeConnection->state()) {
+ case 0:
+ return QNetworkSession::Disconnected;
+ case 1:
+ return QNetworkSession::Connecting;
+ case 2:
+ return QNetworkSession::Connected;
+ }
+ }
+ }
+
+ if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
+ return QNetworkSession::Disconnected;
+ else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined)
+ return QNetworkSession::NotAvailable;
+ else if ((ptr->state & QNetworkConfiguration::Undefined) == QNetworkConfiguration::Undefined)
+ return QNetworkSession::NotAvailable;
+
+ return QNetworkSession::Invalid;
+}
+
+quint64 QNetworkManagerEngine::bytesWritten(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+ if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ const QString networkInterface = getInterfaceFromId(id);
+ if (!networkInterface.isEmpty()) {
+ const QString devFile = QLatin1String("/sys/class/net/") +
+ networkInterface +
+ QLatin1String("/statistics/tx_bytes");
+
+ quint64 result = Q_UINT64_C(0);
+
+ QFile tx(devFile);
+ if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&tx);
+ in >> result;
+ tx.close();
+ }
+
+ return result;
+ }
+ }
+
+ return Q_UINT64_C(0);
+}
+
+quint64 QNetworkManagerEngine::bytesReceived(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
+ if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
+ const QString networkInterface = getInterfaceFromId(id);
+ if (!networkInterface.isEmpty()) {
+ const QString devFile = QLatin1String("/sys/class/net/") +
+ networkInterface +
+ QLatin1String("/statistics/rx_bytes");
+
+ quint64 result = Q_UINT64_C(0);
+
+ QFile tx(devFile);
+ if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&tx);
+ in >> result;
+ tx.close();
+ }
+
+ return result;
+ }
+ }
+
+ return Q_UINT64_C(0);
+}
+
+quint64 QNetworkManagerEngine::startTime(const QString &id)
+{
+ QMutexLocker locker(&mutex);
+
+ QNetworkManagerSettingsConnection *connection = connectionFromId(id);
+ if (connection)
+ return connection->getTimestamp();
+ else
+ return Q_UINT64_C(0);
+}
+
+QNetworkConfigurationManager::Capabilities QNetworkManagerEngine::capabilities() const
+{
+ return QNetworkConfigurationManager::ForcedRoaming |
+ QNetworkConfigurationManager::CanStartAndStopInterfaces;
+}
+
+QNetworkSessionPrivate *QNetworkManagerEngine::createSessionBackend()
+{
+ return new QNetworkSessionPrivateImpl;
+}
+
+QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration()
+{
+ return QNetworkConfigurationPrivatePointer();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
new file mode 100644
index 0000000000..f9d1b9f752
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.h
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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$
+**
+****************************************************************************/
+
+#ifndef QNETWORKMANAGERENGINE_P_H
+#define QNETWORKMANAGERENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QLibrary class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "../qbearerengine_impl.h"
+
+#include "qnetworkmanagerservice.h"
+
+#include <QMap>
+#include <QVariant>
+
+#ifndef QT_NO_BEARERMANAGEMENT
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+class QNetworkManagerEngine : public QBearerEngineImpl
+{
+ Q_OBJECT
+
+public:
+ QNetworkManagerEngine(QObject *parent = 0);
+ ~QNetworkManagerEngine();
+
+ bool networkManagerAvailable() const;
+
+ QString getInterfaceFromId(const QString &id);
+ bool hasIdentifier(const QString &id);
+
+ void connectToId(const QString &id);
+ void disconnectFromId(const QString &id);
+
+ Q_INVOKABLE void initialize();
+ Q_INVOKABLE void requestUpdate();
+
+ QNetworkSession::State sessionStateForId(const QString &id);
+
+ quint64 bytesWritten(const QString &id);
+ quint64 bytesReceived(const QString &id);
+ quint64 startTime(const QString &id);
+
+ QNetworkConfigurationManager::Capabilities capabilities() const;
+
+ QNetworkSessionPrivate *createSessionBackend();
+
+ QNetworkConfigurationPrivatePointer defaultConfiguration();
+
+private Q_SLOTS:
+ void interfacePropertiesChanged(const QString &path,
+ const QMap<QString, QVariant> &properties);
+ void activeConnectionPropertiesChanged(const QString &path,
+ const QMap<QString, QVariant> &properties);
+ void devicePropertiesChanged(const QString &path,
+ const QMap<QString, QVariant> &properties);
+
+ void deviceAdded(const QDBusObjectPath &path);
+ void deviceRemoved(const QDBusObjectPath &path);
+
+ void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0);
+ void removeConnection(const QString &path);
+ void updateConnection(const QNmSettingsMap &settings);
+ void activationFinished(QDBusPendingCallWatcher *watcher);
+
+ void newAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
+ void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
+ void updateAccessPoint(const QMap<QString, QVariant> &map);
+
+private:
+ QNetworkConfigurationPrivate *parseConnection(const QString &service,
+ const QString &settingsPath,
+ const QNmSettingsMap &map);
+ QNetworkManagerSettingsConnection *connectionFromId(const QString &id) const;
+
+private:
+ QNetworkManagerInterface *interface;
+ QNetworkManagerSettings *systemSettings;
+ QNetworkManagerSettings *userSettings;
+ QHash<QString, QNetworkManagerInterfaceDeviceWireless *> wirelessDevices;
+ QHash<QString, QNetworkManagerConnectionActive *> activeConnections;
+ QList<QNetworkManagerSettingsConnection *> connections;
+ QList<QNetworkManagerInterfaceAccessPoint *> accessPoints;
+ QList<QNetworkManagerInterfaceAccessPoint *> configuredAccessPoints;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif // QT_NO_BEARERMANAGEMENT
+
+#endif
+
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
new file mode 100644
index 0000000000..cb6385100a
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
@@ -0,0 +1,931 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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 <QObject>
+#include <QList>
+#include <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusError>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
+#include <QtDBus/QDBusPendingCallWatcher>
+#include <QtDBus/QDBusObjectPath>
+#include <QtDBus/QDBusPendingCall>
+
+#include "qnetworkmanagerservice.h"
+#include "qnmdbushelper.h"
+
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+static QDBusConnection dbusConnection = QDBusConnection::systemBus();
+
+class QNetworkManagerInterfacePrivate
+{
+public:
+ QDBusInterface *connectionInterface;
+ bool valid;
+};
+
+QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
+ : QObject(parent)
+{
+ d = new QNetworkManagerInterfacePrivate();
+ d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
+ QLatin1String(NM_DBUS_PATH),
+ QLatin1String(NM_DBUS_INTERFACE),
+ dbusConnection);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ return;
+ }
+ d->valid = true;
+ nmDBusHelper = new QNmDBusHelper(this);
+ 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()
+{
+ delete d->connectionInterface;
+ delete d;
+}
+
+bool QNetworkManagerInterface::isValid()
+{
+ return d->valid;
+}
+
+bool QNetworkManagerInterface::setConnections()
+{
+ if(!isValid() )
+ return false;
+ bool allOk = false;
+ if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ QLatin1String(NM_DBUS_PATH),
+ QLatin1String(NM_DBUS_INTERFACE),
+ QLatin1String("PropertiesChanged"),
+ nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>)))) {
+ allOk = true;
+ }
+ if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ QLatin1String(NM_DBUS_PATH),
+ QLatin1String(NM_DBUS_INTERFACE),
+ QLatin1String("DeviceAdded"),
+ this,SIGNAL(deviceAdded(QDBusObjectPath)))) {
+ allOk = true;
+ }
+ if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ QLatin1String(NM_DBUS_PATH),
+ QLatin1String(NM_DBUS_INTERFACE),
+ QLatin1String("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(QLatin1String("GetDevices"));
+ return reply.value();
+}
+
+void QNetworkManagerInterface::activateConnection( const QString &serviceName,
+ QDBusObjectPath connectionPath,
+ QDBusObjectPath devicePath,
+ QDBusObjectPath specificObject)
+{
+ QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("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(QLatin1String("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(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
+ dbusConnection);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ return;
+ }
+ d->valid = true;
+
+}
+
+QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint()
+{
+ delete d->connectionInterface;
+ delete d;
+}
+
+bool QNetworkManagerInterfaceAccessPoint::isValid()
+{
+ return d->valid;
+}
+
+bool QNetworkManagerInterfaceAccessPoint::setConnections()
+{
+ if(!isValid() )
+ return false;
+
+ bool allOk = false;
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
+ connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
+ this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
+
+ if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
+ QLatin1String("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(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE),
+ dbusConnection);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ return;
+ }
+ d->valid = true;
+}
+
+QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice()
+{
+ delete d->connectionInterface;
+ delete d;
+}
+
+bool QNetworkManagerInterfaceDevice::isValid()
+{
+ return d->valid;
+}
+
+bool QNetworkManagerInterfaceDevice::setConnections()
+{
+ if(!isValid() )
+ return false;
+
+ bool allOk = false;
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
+ connect(nmDBusHelper,SIGNAL(pathForStateChanged(const QString &, quint32)),
+ this, SIGNAL(stateChanged(const QString&, quint32)));
+ if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE),
+ QLatin1String("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();
+}
+
+QString QNetworkManagerInterfaceDevice::networkInterface() const
+{
+ return 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(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
+ dbusConnection, parent);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ return;
+ }
+ d->valid = true;
+}
+
+QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired()
+{
+ delete d->connectionInterface;
+ delete d;
+}
+
+bool QNetworkManagerInterfaceDeviceWired::isValid()
+{
+
+ return d->valid;
+}
+
+bool QNetworkManagerInterfaceDeviceWired::setConnections()
+{
+ if(!isValid() )
+ return false;
+
+ bool allOk = false;
+
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
+ connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
+ this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
+ if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
+ QLatin1String("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(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ dbusConnection, parent);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ return;
+ }
+ d->valid = true;
+}
+
+QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless()
+{
+ delete d->connectionInterface;
+ delete d;
+}
+
+bool QNetworkManagerInterfaceDeviceWireless::isValid()
+{
+ return d->valid;
+}
+
+bool QNetworkManagerInterfaceDeviceWireless::setConnections()
+{
+ if(!isValid() )
+ return false;
+
+ bool allOk = false;
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
+ 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(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ QLatin1String("AccessPointAdded"),
+ nmDBusHelper, SLOT(slotAccessPointAdded( QDBusObjectPath )))) {
+ allOk = true;
+ }
+
+
+ if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ QLatin1String("AccessPointRemoved"),
+ nmDBusHelper, SLOT(slotAccessPointRemoved( QDBusObjectPath )))) {
+ allOk = true;
+ }
+
+
+ if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ QLatin1String("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(QLatin1String("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,
+ QLatin1String(NM_DBUS_PATH_SETTINGS),
+ QLatin1String(NM_DBUS_IFACE_SETTINGS),
+ dbusConnection);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ 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, QLatin1String(NM_DBUS_PATH_SETTINGS),
+ QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"),
+ this, SIGNAL(newConnection(QDBusObjectPath)))) {
+ allOk = true;
+ }
+
+ return allOk;
+}
+
+QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
+{
+ QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("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,
+ QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
+ dbusConnection, parent);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ return;
+ }
+ d->valid = true;
+ QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings"));
+ d->settingsMap = rep.value();
+}
+
+QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection()
+{
+ 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,
+ QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"),
+ this, SIGNAL(updated(QNmSettingsMap)))) {
+ allOk = true;
+ } else {
+ QDBusError error = dbusConnection.lastError();
+ }
+
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
+ connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(const QString &)),
+ this,SIGNAL(removed( const QString &)));
+
+ if (!dbusConnection.connect(d->service, d->path,
+ QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"),
+ nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
+ allOk = true;
+ }
+
+ return allOk;
+}
+
+QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const
+{
+ return d->connectionInterface;
+}
+
+QNmSettingsMap QNetworkManagerSettingsConnection::getSettings()
+{
+ QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings"));
+ d->settingsMap = rep.value();
+ return d->settingsMap;
+}
+
+NMDeviceType QNetworkManagerSettingsConnection::getType()
+{
+ const QString devType =
+ d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
+
+ if (devType == QLatin1String("802-3-ethernet"))
+ return DEVICE_TYPE_802_3_ETHERNET;
+ else if (devType == QLatin1String("802-11-wireless"))
+ return DEVICE_TYPE_802_11_WIRELESS;
+ else
+ return DEVICE_TYPE_UNKNOWN;
+}
+
+bool QNetworkManagerSettingsConnection::isAutoConnect()
+{
+ const QVariant autoConnect =
+ d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect"));
+
+ // NetworkManager default is to auto connect
+ if (!autoConnect.isValid())
+ return true;
+
+ return autoConnect.toBool();
+}
+
+quint64 QNetworkManagerSettingsConnection::getTimestamp()
+{
+ return d->settingsMap.value(QLatin1String("connection"))
+ .value(QLatin1String("timestamp")).toUInt();
+}
+
+QString QNetworkManagerSettingsConnection::getId()
+{
+ return d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString();
+}
+
+QString QNetworkManagerSettingsConnection::getUuid()
+{
+ const QString id = d->settingsMap.value(QLatin1String("connection"))
+ .value(QLatin1String("uuid")).toString();
+
+ // is no uuid, return the connection path
+ return id.isEmpty() ? d->connectionInterface->path() : id;
+}
+
+QString QNetworkManagerSettingsConnection::getSsid()
+{
+ return d->settingsMap.value(QLatin1String("802-11-wireless"))
+ .value(QLatin1String("ssid")).toString();
+}
+
+QString QNetworkManagerSettingsConnection::getMacAddress()
+{
+ NMDeviceType type = getType();
+
+ if (type == DEVICE_TYPE_802_3_ETHERNET) {
+ return d->settingsMap.value(QLatin1String("802-3-ethernet"))
+ .value(QLatin1String("mac-address")).toString();
+ } else if (type == DEVICE_TYPE_802_11_WIRELESS) {
+ return d->settingsMap.value(QLatin1String("802-11-wireless"))
+ .value(QLatin1String("mac-address")).toString();
+ } else {
+ return QString();
+ }
+}
+
+QStringList QNetworkManagerSettingsConnection::getSeenBssids()
+{
+ if (getType() == DEVICE_TYPE_802_11_WIRELESS) {
+ return d->settingsMap.value(QLatin1String("802-11-wireless"))
+ .value(QLatin1String("seen-bssids")).toStringList();
+ } else {
+ 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(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
+ dbusConnection, parent);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ return;
+ }
+ d->valid = true;
+}
+
+QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive()
+{
+ delete d->connectionInterface;
+ delete d;
+}
+
+bool QNetworkManagerConnectionActive::isValid()
+{
+ return d->valid;
+}
+
+bool QNetworkManagerConnectionActive::setConnections()
+{
+ if(!isValid() )
+ return false;
+
+ bool allOk = false;
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
+ connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
+ this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
+ if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
+ QLatin1String("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(QLatin1String(NM_DBUS_SERVICE),
+ d->path,
+ QLatin1String(NM_DBUS_INTERFACE_IP4_CONFIG),
+ dbusConnection, parent);
+ if (!d->connectionInterface->isValid()) {
+ d->valid = false;
+ 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();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
new file mode 100644
index 0000000000..6fea2ba286
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
@@ -0,0 +1,448 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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$
+**
+****************************************************************************/
+
+#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 <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusError>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
+
+#include <QtDBus/QDBusPendingCallWatcher>
+#include <QtDBus/QDBusObjectPath>
+#include <QtDBus/QDBusContext>
+#include <QMap>
+#include "qnmdbushelper.h"
+
+#ifndef QT_NO_DBUS
+
+#ifndef NETWORK_MANAGER_H
+typedef enum NMDeviceType
+{
+ DEVICE_TYPE_UNKNOWN = 0,
+ DEVICE_TYPE_802_3_ETHERNET,
+ DEVICE_TYPE_802_11_WIRELESS,
+ DEVICE_TYPE_GSM,
+ DEVICE_TYPE_CDMA
+} NMDeviceType;
+
+typedef enum
+{
+ NM_DEVICE_STATE_UNKNOWN = 0,
+ NM_DEVICE_STATE_UNMANAGED,
+ NM_DEVICE_STATE_UNAVAILABLE,
+ NM_DEVICE_STATE_DISCONNECTED,
+ NM_DEVICE_STATE_PREPARE,
+ NM_DEVICE_STATE_CONFIG,
+ NM_DEVICE_STATE_NEED_AUTH,
+ NM_DEVICE_STATE_IP_CONFIG,
+ NM_DEVICE_STATE_ACTIVATED,
+ NM_DEVICE_STATE_FAILED
+} NMDeviceState;
+
+typedef enum
+{
+ NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
+ NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
+ NM_ACTIVE_CONNECTION_STATE_ACTIVATED
+} NMActiveConnectionState;
+
+#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
+
+#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
+#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
+#define NM_DBUS_INTERFACE_DEVICE NM_DBUS_INTERFACE ".Device"
+#define NM_DBUS_INTERFACE_DEVICE_WIRED NM_DBUS_INTERFACE_DEVICE ".Wired"
+#define NM_DBUS_INTERFACE_DEVICE_WIRELESS NM_DBUS_INTERFACE_DEVICE ".Wireless"
+#define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint"
+#define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint"
+
+#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManagerSettings"
+
+#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManagerSettings.Connection"
+#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManagerSettings"
+#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
+#define NM_DBUS_INTERFACE_IP4_CONFIG NM_DBUS_INTERFACE ".IP4Config"
+
+#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings"
+#define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings"
+
+#define NM_802_11_AP_FLAGS_NONE 0x00000000
+#define NM_802_11_AP_FLAGS_PRIVACY 0x00000001
+#endif
+
+QT_BEGIN_NAMESPACE
+
+typedef QMap< QString, QMap<QString,QVariant> > QNmSettingsMap;
+typedef QList<quint32> ServerThing;
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QNmSettingsMap))
+Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ServerThing))
+
+QT_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:
+ QNetworkManagerInterfacePrivate *d;
+ QNmDBusHelper *nmDBusHelper;
+};
+
+class QNetworkManagerInterfaceAccessPointPrivate;
+class QNetworkManagerInterfaceAccessPoint : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ 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);
+
+ explicit 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;
+
+};
+
+class QNetworkManagerInterfaceDevicePrivate;
+class QNetworkManagerInterfaceDevice : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = 0);
+ ~QNetworkManagerInterfaceDevice();
+
+ QString udi() const;
+ QString networkInterface() 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;
+};
+
+class QNetworkManagerInterfaceDeviceWiredPrivate;
+class QNetworkManagerInterfaceDeviceWired : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ explicit 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;
+};
+
+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
+ };
+
+ explicit 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;
+};
+
+class QNetworkManagerSettingsPrivate;
+class QNetworkManagerSettings : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ explicit 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;
+};
+
+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();
+ bool setConnections();
+ NMDeviceType getType();
+ bool isAutoConnect();
+ quint64 getTimestamp();
+ QString getId();
+ QString getUuid();
+ QString getSsid();
+ QString getMacAddress();
+ QStringList getSeenBssids();
+ bool isValid();
+
+Q_SIGNALS:
+
+ void updated(const QNmSettingsMap &settings);
+ void removed(const QString &path);
+
+private:
+ QNmDBusHelper *nmDBusHelper;
+ QNetworkManagerSettingsConnectionPrivate *d;
+};
+
+class QNetworkManagerConnectionActivePrivate;
+class QNetworkManagerConnectionActive : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ enum ActiveConnectionState {
+ Unknown = 0,
+ Activating = 1,
+ Activated = 2
+ };
+
+ explicit 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;
+};
+
+class QNetworkManagerIp4ConfigPrivate;
+class QNetworkManagerIp4Config : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0);
+ ~QNetworkManagerIp4Config();
+
+ QStringList domains() const;
+ bool isValid();
+
+ private:
+ QNetworkManagerIp4ConfigPrivate *d;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+#endif //QNETWORKMANAGERSERVICE_H
diff --git a/src/plugins/bearer/networkmanager/qnmdbushelper.cpp b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
new file mode 100644
index 0000000000..53b1c7cb4c
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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$
+**
+****************************************************************************/
+
+// this class is for helping qdbus get stuff
+
+#include "qnmdbushelper.h"
+
+#include "qnetworkmanagerservice.h"
+
+#include <QDBusError>
+#include <QDBusInterface>
+#include <QDBusMessage>
+#include <QDBusReply>
+
+#include <QDebug>
+
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+QNmDBusHelper::QNmDBusHelper(QObject * parent)
+ : QObject(parent)
+{
+}
+
+QNmDBusHelper::~QNmDBusHelper()
+{
+}
+
+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") {
+ emit pathForPropertiesChanged(msg.path(), map);
+ // 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();
+ } else if (i.key() == "ActiveConnections") {
+ emit pathForPropertiesChanged(msg.path(), map);
+ }
+ }
+}
+
+void QNmDBusHelper::slotSettingsRemoved()
+{
+ QDBusMessage msg = this->message();
+ emit pathForSettingsRemoved(msg.path());
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/networkmanager/qnmdbushelper.h b/src/plugins/bearer/networkmanager/qnmdbushelper.h
new file mode 100644
index 0000000000..6f3484a797
--- /dev/null
+++ b/src/plugins/bearer/networkmanager/qnmdbushelper.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 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$
+**
+****************************************************************************/
+
+#ifndef QNMDBUSHELPERPRIVATE_H
+#define QNMDBUSHELPERPRIVATE_H
+
+#include <QDBusObjectPath>
+#include <QDBusContext>
+#include <QMap>
+
+#ifndef QT_NO_DBUS
+
+QT_BEGIN_NAMESPACE
+
+class QNmDBusHelper: public QObject, protected QDBusContext
+ {
+ Q_OBJECT
+ public:
+ QNmDBusHelper(QObject *parent = 0);
+ ~QNmDBusHelper();
+
+ 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 &);
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DBUS
+
+#endif// QNMDBUSHELPERPRIVATE_H