summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/networkmanager
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-01 07:45:35 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-03-02 05:42:32 (GMT)
commitd042a00b5828961e1e1fa82017717b5f72dde9ef (patch)
tree600353f03174c0bfe80d964c5a6d2500e5df235d /src/plugins/bearer/networkmanager
parentef30a6f336d55c813423bf139d8363f50181179f (diff)
downloadQt-d042a00b5828961e1e1fa82017717b5f72dde9ef.zip
Qt-d042a00b5828961e1e1fa82017717b5f72dde9ef.tar.gz
Qt-d042a00b5828961e1e1fa82017717b5f72dde9ef.tar.bz2
Bearer management changes from Qt Mobility (fca9891).
fca98911b75ce12e70d93cfc2932a9759758a605
Diffstat (limited to 'src/plugins/bearer/networkmanager')
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp3
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp293
-rw-r--r--src/plugins/bearer/networkmanager/qnetworkmanagerservice.h112
-rw-r--r--src/plugins/bearer/networkmanager/qnmdbushelper.cpp11
-rw-r--r--src/plugins/bearer/networkmanager/qnmdbushelper.h2
5 files changed, 218 insertions, 203 deletions
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
index 5c6efe3..0fa8f3c 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp
@@ -49,7 +49,6 @@
#include <QtCore/qdebug.h>
-#include <NetworkManager/NetworkManager.h>
#include <QtDBus>
#include <QDBusConnection>
#include <QDBusError>
@@ -147,7 +146,7 @@ QString QNetworkManagerEngine::getInterfaceFromId(const QString &id)
continue;
QNetworkManagerInterfaceDevice device(devices.at(0).path());
- return device.interface().name();
+ return device.networkInterface().name();
}
}
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
index 5dc0ea4..c780fbc 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp
@@ -41,26 +41,22 @@
#include <QObject>
#include <QList>
-#include <QtDBus>
-#include <QDBusConnection>
-#include <QDBusError>
-#include <QDBusInterface>
-#include <QDBusMessage>
-#include <QDBusReply>
-#include <QDBusPendingCallWatcher>
-#include <QDBusObjectPath>
-#include <QDBusPendingCall>
-
-#include <NetworkManager/NetworkManager.h>
+#include <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 "qnmdbushelper.h"
#include "qnetworkmanagerservice.h"
+#include "qnmdbushelper.h"
-//Q_DECLARE_METATYPE(QList<uint>)
QT_BEGIN_NAMESPACE
static QDBusConnection dbusConnection = QDBusConnection::systemBus();
-//static QDBusInterface iface(NM_DBUS_SERVICE, NM_DBUS_PATH, NM_DBUS_INTERFACE, dbusConnection);
class QNetworkManagerInterfacePrivate
{
@@ -70,19 +66,19 @@ public:
};
QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
- : QObject(parent), nmDBusHelper(0)
+ : QObject(parent)
{
d = new QNetworkManagerInterfacePrivate();
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- NM_DBUS_INTERFACE,
+ 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;
+ 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)),
@@ -92,8 +88,6 @@ QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
QNetworkManagerInterface::~QNetworkManagerInterface()
{
- if (nmDBusHelper)
- delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -108,24 +102,24 @@ bool QNetworkManagerInterface::setConnections()
if(!isValid() )
return false;
bool allOk = false;
- if (!dbusConnection.connect(NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- NM_DBUS_INTERFACE,
- "PropertiesChanged",
+ 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(NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- NM_DBUS_INTERFACE,
- "DeviceAdded",
+ 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(NM_DBUS_SERVICE,
- NM_DBUS_PATH,
- NM_DBUS_INTERFACE,
- "DeviceRemoved",
+ if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
+ QLatin1String(NM_DBUS_PATH),
+ QLatin1String(NM_DBUS_INTERFACE),
+ QLatin1String("DeviceRemoved"),
this,SIGNAL(deviceRemoved(QDBusObjectPath)))) {
allOk = true;
}
@@ -140,7 +134,7 @@ QDBusInterface *QNetworkManagerInterface::connectionInterface() const
QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() const
{
- QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call("GetDevices");
+ QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetDevices"));
return reply.value();
}
@@ -149,7 +143,7 @@ void QNetworkManagerInterface::activateConnection( const QString &serviceName,
QDBusObjectPath devicePath,
QDBusObjectPath specificObject)
{
- QDBusPendingCall pendingCall = d->connectionInterface->asyncCall("ActivateConnection",
+ QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("ActivateConnection"),
QVariant(serviceName),
QVariant::fromValue(connectionPath),
QVariant::fromValue(devicePath),
@@ -162,7 +156,7 @@ void QNetworkManagerInterface::activateConnection( const QString &serviceName,
void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) const
{
- d->connectionInterface->call("DeactivateConnection", QVariant::fromValue(connectionPath));
+ d->connectionInterface->call(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath));
}
bool QNetworkManagerInterface::wirelessEnabled() const
@@ -186,7 +180,6 @@ quint32 QNetworkManagerInterface::state()
return d->connectionInterface->property("State").toUInt();
}
-/////////////
class QNetworkManagerInterfaceAccessPointPrivate
{
public:
@@ -200,9 +193,9 @@ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const Q
{
d = new QNetworkManagerInterfaceAccessPointPrivate();
d->path = dbusPathName;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
+ d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_ACCESS_POINT,
+ QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
dbusConnection);
if (!d->connectionInterface->isValid()) {
d->valid = false;
@@ -215,8 +208,6 @@ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const Q
QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint()
{
- if (nmDBusHelper)
- delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -232,17 +223,15 @@ bool QNetworkManagerInterfaceAccessPoint::setConnections()
return false;
bool allOk = false;
- if (nmDBusHelper)
- delete nmDBusHelper;
- nmDBusHelper = 0;
- nmDBusHelper = new QNmDBusHelper;
+ 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(NM_DBUS_SERVICE,
+ if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_ACCESS_POINT,
- "PropertiesChanged",
+ QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
+ QLatin1String("PropertiesChanged"),
nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>))) ) {
allOk = true;
@@ -300,7 +289,6 @@ quint32 QNetworkManagerInterfaceAccessPoint::strength() const
return d->connectionInterface->property("Strength").toUInt();
}
-/////////////
class QNetworkManagerInterfaceDevicePrivate
{
public:
@@ -314,9 +302,9 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de
{
d = new QNetworkManagerInterfaceDevicePrivate();
d->path = deviceObjectPath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
+ d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_DEVICE,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE),
dbusConnection);
if (!d->connectionInterface->isValid()) {
d->valid = false;
@@ -328,8 +316,6 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de
QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice()
{
- if (nmDBusHelper)
- delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -345,16 +331,14 @@ bool QNetworkManagerInterfaceDevice::setConnections()
return false;
bool allOk = false;
- if (nmDBusHelper)
- delete nmDBusHelper;
- nmDBusHelper = 0;
- nmDBusHelper = new QNmDBusHelper;
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper,SIGNAL(pathForStateChanged(const QString &, quint32)),
this, SIGNAL(stateChanged(const QString&, quint32)));
- if(dbusConnection.connect(NM_DBUS_SERVICE,
+ if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_DEVICE,
- "StateChanged",
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE),
+ QLatin1String("StateChanged"),
nmDBusHelper,SLOT(deviceStateChanged(quint32)))) {
allOk = true;
}
@@ -371,7 +355,7 @@ QString QNetworkManagerInterfaceDevice::udi() const
return d->connectionInterface->property("Udi").toString();
}
-QNetworkInterface QNetworkManagerInterfaceDevice::interface() const
+QNetworkInterface QNetworkManagerInterfaceDevice::networkInterface() const
{
return QNetworkInterface::interfaceFromName(d->connectionInterface->property("Interface").toString());
}
@@ -397,7 +381,6 @@ QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const
return prop.value<QDBusObjectPath>();
}
-/////////////
class QNetworkManagerInterfaceDeviceWiredPrivate
{
public:
@@ -411,9 +394,9 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q
{
d = new QNetworkManagerInterfaceDeviceWiredPrivate();
d->path = ifaceDevicePath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
+ d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRED,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
@@ -425,8 +408,6 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q
QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired()
{
- if (nmDBusHelper)
- delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -444,16 +425,14 @@ bool QNetworkManagerInterfaceDeviceWired::setConnections()
bool allOk = false;
- if (nmDBusHelper)
- delete nmDBusHelper;
- nmDBusHelper = 0;
- nmDBusHelper = new QNmDBusHelper;
+ 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(NM_DBUS_SERVICE,
+ if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRED,
- "PropertiesChanged",
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
+ QLatin1String("PropertiesChanged"),
nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>))) ) {
allOk = true;
}
@@ -480,7 +459,6 @@ bool QNetworkManagerInterfaceDeviceWired::carrier() const
return d->connectionInterface->property("Carrier").toBool();
}
-/////////////
class QNetworkManagerInterfaceDeviceWirelessPrivate
{
public:
@@ -494,9 +472,9 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c
{
d = new QNetworkManagerInterfaceDeviceWirelessPrivate();
d->path = ifaceDevicePath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
+ d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
@@ -508,8 +486,6 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c
QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless()
{
- if (nmDBusHelper)
- delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -525,10 +501,8 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
return false;
bool allOk = false;
- if (nmDBusHelper)
- delete nmDBusHelper;
- nmDBusHelper = 0;
- nmDBusHelper = new QNmDBusHelper;
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(const QString &,QMap<QString,QVariant>)),
this,SIGNAL(propertiesChanged( const QString &, QMap<QString,QVariant>)));
@@ -538,28 +512,28 @@ bool QNetworkManagerInterfaceDeviceWireless::setConnections()
connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(const QString &,QDBusObjectPath)),
this,SIGNAL(accessPointRemoved(const QString &,QDBusObjectPath)));
- if(!dbusConnection.connect(NM_DBUS_SERVICE,
+ if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- "AccessPointAdded",
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ QLatin1String("AccessPointAdded"),
nmDBusHelper, SLOT(slotAccessPointAdded( QDBusObjectPath )))) {
allOk = true;
}
- if(!dbusConnection.connect(NM_DBUS_SERVICE,
+ if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- "AccessPointRemoved",
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ QLatin1String("AccessPointRemoved"),
nmDBusHelper, SLOT(slotAccessPointRemoved( QDBusObjectPath )))) {
allOk = true;
}
- if(!dbusConnection.connect(NM_DBUS_SERVICE,
+ if(!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_DEVICE_WIRELESS,
- "PropertiesChanged",
+ QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
+ QLatin1String("PropertiesChanged"),
nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>)))) {
allOk = true;
}
@@ -574,7 +548,7 @@ QDBusInterface *QNetworkManagerInterfaceDeviceWireless::connectionInterface() co
QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints()
{
- QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call("GetAccessPoints");
+ QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetAccessPoints"));
return reply.value();
}
@@ -603,7 +577,6 @@ quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const
return d->connectionInterface->property("WirelelessCapabilities").toUInt();
}
-/////////////
class QNetworkManagerSettingsPrivate
{
public:
@@ -618,8 +591,8 @@ QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService,
d = new QNetworkManagerSettingsPrivate();
d->path = settingsService;
d->connectionInterface = new QDBusInterface(settingsService,
- NM_DBUS_PATH_SETTINGS,
- NM_DBUS_IFACE_SETTINGS,
+ QLatin1String(NM_DBUS_PATH_SETTINGS),
+ QLatin1String(NM_DBUS_IFACE_SETTINGS),
dbusConnection);
if (!d->connectionInterface->isValid()) {
d->valid = false;
@@ -644,8 +617,8 @@ bool QNetworkManagerSettings::setConnections()
{
bool allOk = false;
- if (!dbusConnection.connect(d->path, NM_DBUS_PATH_SETTINGS,
- NM_DBUS_IFACE_SETTINGS, "NewConnection",
+ if (!dbusConnection.connect(d->path, QLatin1String(NM_DBUS_PATH_SETTINGS),
+ QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"),
this, SIGNAL(newConnection(QDBusObjectPath)))) {
allOk = true;
}
@@ -655,7 +628,7 @@ bool QNetworkManagerSettings::setConnections()
QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
{
- QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call("ListConnections");
+ QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("ListConnections"));
return reply.value();
}
@@ -665,7 +638,6 @@ QDBusInterface *QNetworkManagerSettings::connectionInterface() const
}
-/////////////
class QNetworkManagerSettingsConnectionPrivate
{
public:
@@ -685,7 +657,7 @@ QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QStri
d->service = settingsService;
d->connectionInterface = new QDBusInterface(settingsService,
d->path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION,
+ QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
//qWarning() << "Could not find NetworkManagerSettingsConnection";
@@ -693,14 +665,12 @@ QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QStri
return;
}
d->valid = true;
- QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call("GetSettings");
+ QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings"));
d->settingsMap = rep.value();
}
QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection()
{
- if (nmDBusHelper)
- delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -717,32 +687,26 @@ bool QNetworkManagerSettingsConnection::setConnections()
bool allOk = false;
if(!dbusConnection.connect(d->service, d->path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION, "Updated",
+ QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"),
this, SIGNAL(updated(QNmSettingsMap)))) {
allOk = true;
} else {
QDBusError error = dbusConnection.lastError();
}
- if (nmDBusHelper)
- delete nmDBusHelper;
- nmDBusHelper = 0;
- nmDBusHelper = new QNmDBusHelper;
+ delete nmDBusHelper;
+ nmDBusHelper = new QNmDBusHelper(this);
connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(const QString &)),
this,SIGNAL(removed( const QString &)));
if (!dbusConnection.connect(d->service, d->path,
- NM_DBUS_IFACE_SETTINGS_CONNECTION, "Removed",
+ QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"),
nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
allOk = true;
}
return allOk;
}
-//QNetworkManagerSettingsConnection::update(QNmSettingsMap map)
-//{
-// d->connectionInterface->call("Update", QVariant::fromValue(map));
-//}
QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const
{
@@ -751,23 +715,23 @@ QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const
QNmSettingsMap QNetworkManagerSettingsConnection::getSettings()
{
- QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call("GetSettings");
+ QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings"));
d->settingsMap = rep.value();
return d->settingsMap;
}
NMDeviceType QNetworkManagerSettingsConnection::getType()
{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("type");
- while (ii != innerMap.end() && ii.key() == "type") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("type"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("type")) {
QString devType = ii.value().toString();
- if (devType == "802-3-ethernet") {
+ if (devType == QLatin1String("802-3-ethernet")) {
return DEVICE_TYPE_802_3_ETHERNET;
}
- if (devType == "802-11-wireless") {
+ if (devType == QLatin1String("802-11-wireless")) {
return DEVICE_TYPE_802_11_WIRELESS;
}
ii++;
@@ -779,11 +743,11 @@ NMDeviceType QNetworkManagerSettingsConnection::getType()
bool QNetworkManagerSettingsConnection::isAutoConnect()
{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("autoconnect");
- while (ii != innerMap.end() && ii.key() == "autoconnect") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("autoconnect"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("autoconnect")) {
return ii.value().toBool();
ii++;
}
@@ -794,11 +758,11 @@ bool QNetworkManagerSettingsConnection::isAutoConnect()
quint64 QNetworkManagerSettingsConnection::getTimestamp()
{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("timestamp");
- while (ii != innerMap.end() && ii.key() == "timestamp") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("timestamp"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("timestamp")) {
return ii.value().toUInt();
ii++;
}
@@ -809,11 +773,11 @@ quint64 QNetworkManagerSettingsConnection::getTimestamp()
QString QNetworkManagerSettingsConnection::getId()
{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("id");
- while (ii != innerMap.end() && ii.key() == "id") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("id"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("id")) {
return ii.value().toString();
ii++;
}
@@ -824,11 +788,11 @@ QString QNetworkManagerSettingsConnection::getId()
QString QNetworkManagerSettingsConnection::getUuid()
{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("connection");
- while (i != d->settingsMap.end() && i.key() == "connection") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("connection"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("connection")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("uuid");
- while (ii != innerMap.end() && ii.key() == "uuid") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("uuid"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("uuid")) {
return ii.value().toString();
ii++;
}
@@ -840,11 +804,11 @@ QString QNetworkManagerSettingsConnection::getUuid()
QString QNetworkManagerSettingsConnection::getSsid()
{
- QNmSettingsMap::const_iterator i = d->settingsMap.find("802-11-wireless");
- while (i != d->settingsMap.end() && i.key() == "802-11-wireless") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("802-11-wireless"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("802-11-wireless")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("ssid");
- while (ii != innerMap.end() && ii.key() == "ssid") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("ssid"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("ssid")) {
return ii.value().toString();
ii++;
}
@@ -856,11 +820,11 @@ QString QNetworkManagerSettingsConnection::getSsid()
QString QNetworkManagerSettingsConnection::getMacAddress()
{
if(getType() == DEVICE_TYPE_802_3_ETHERNET) {
- QNmSettingsMap::const_iterator i = d->settingsMap.find("802-3-ethernet");
- while (i != d->settingsMap.end() && i.key() == "802-3-ethernet") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("802-3-ethernet"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("802-3-ethernet")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("mac-address");
- while (ii != innerMap.end() && ii.key() == "mac-address") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("mac-address"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("mac-address")) {
return ii.value().toString();
ii++;
}
@@ -869,11 +833,11 @@ QString QNetworkManagerSettingsConnection::getMacAddress()
}
else if(getType() == DEVICE_TYPE_802_11_WIRELESS) {
- QNmSettingsMap::const_iterator i = d->settingsMap.find("802-11-wireless");
- while (i != d->settingsMap.end() && i.key() == "802-11-wireless") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("802-11-wireless"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("802-11-wireless")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("mac-address");
- while (ii != innerMap.end() && ii.key() == "mac-address") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("mac-address"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("mac-address")) {
return ii.value().toString();
ii++;
}
@@ -886,11 +850,11 @@ QString QNetworkManagerSettingsConnection::getMacAddress()
QStringList QNetworkManagerSettingsConnection::getSeenBssids()
{
if(getType() == DEVICE_TYPE_802_11_WIRELESS) {
- QNmSettingsMap::const_iterator i = d->settingsMap.find("802-11-wireless");
- while (i != d->settingsMap.end() && i.key() == "802-11-wireless") {
+ QNmSettingsMap::const_iterator i = d->settingsMap.find(QLatin1String("802-11-wireless"));
+ while (i != d->settingsMap.end() && i.key() == QLatin1String("802-11-wireless")) {
QMap<QString,QVariant> innerMap = i.value();
- QMap<QString,QVariant>::const_iterator ii = innerMap.find("seen-bssids");
- while (ii != innerMap.end() && ii.key() == "seen-bssids") {
+ QMap<QString,QVariant>::const_iterator ii = innerMap.find(QLatin1String("seen-bssids"));
+ while (ii != innerMap.end() && ii.key() == QLatin1String("seen-bssids")) {
return ii.value().toStringList();
ii++;
}
@@ -900,7 +864,6 @@ QStringList QNetworkManagerSettingsConnection::getSeenBssids()
return QStringList();
}
-/////////////
class QNetworkManagerConnectionActivePrivate
{
public:
@@ -914,9 +877,9 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString
{
d = new QNetworkManagerConnectionActivePrivate();
d->path = activeConnectionObjectPath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
+ d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
+ QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
@@ -928,8 +891,6 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString
QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive()
{
- if (nmDBusHelper)
- delete nmDBusHelper;
delete d->connectionInterface;
delete d;
}
@@ -945,16 +906,14 @@ bool QNetworkManagerConnectionActive::setConnections()
return false;
bool allOk = false;
- if (nmDBusHelper)
- delete nmDBusHelper;
- nmDBusHelper = 0;
- nmDBusHelper = new QNmDBusHelper;
+ 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(NM_DBUS_SERVICE,
+ if(dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_ACTIVE_CONNECTION,
- "PropertiesChanged",
+ QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
+ QLatin1String("PropertiesChanged"),
nmDBusHelper,SLOT(slotPropertiesChanged( QMap<QString,QVariant>))) ) {
allOk = true;
}
@@ -1000,8 +959,6 @@ bool QNetworkManagerConnectionActive::defaultRoute() const
return d->connectionInterface->property("Default").toBool();
}
-
-////
class QNetworkManagerIp4ConfigPrivate
{
public:
@@ -1015,9 +972,9 @@ QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectP
{
d = new QNetworkManagerIp4ConfigPrivate();
d->path = deviceObjectPath;
- d->connectionInterface = new QDBusInterface(NM_DBUS_SERVICE,
+ d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
d->path,
- NM_DBUS_INTERFACE_IP4_CONFIG,
+ QLatin1String(NM_DBUS_INTERFACE_IP4_CONFIG),
dbusConnection, parent);
if (!d->connectionInterface->isValid()) {
d->valid = false;
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
index 81903ec..048f628 100644
--- a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
+++ b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.h
@@ -53,26 +53,87 @@
// We mean it.
//
-#include <NetworkManager/NetworkManager.h>
-#include <QtDBus>
-#include <QDBusConnection>
-#include <QDBusError>
-#include <QDBusInterface>
-#include <QDBusMessage>
-#include <QDBusReply>
+#include <QtDBus/QtDBus>
+#include <QtDBus/QDBusConnection>
+#include <QtDBus/QDBusError>
+#include <QtDBus/QDBusInterface>
+#include <QtDBus/QDBusMessage>
+#include <QtDBus/QDBusReply>
#include <QNetworkInterface>
-#include <QDBusPendingCallWatcher>
+#include <QtDBus/QDBusPendingCallWatcher>
+#include <QtDBus/QDBusObjectPath>
+#include <QtDBus/QDBusContext>
+#include <QMap>
#include "qnmdbushelper.h"
+#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;
-Q_DECLARE_METATYPE(QNmSettingsMap)
-Q_DECLARE_METATYPE(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
@@ -107,12 +168,10 @@ Q_SIGNALS:
private Q_SLOTS:
private:
-// Q_DISABLE_COPY(QNetworkManagerInterface); ??
QNetworkManagerInterfacePrivate *d;
QNmDBusHelper *nmDBusHelper;
-}; //end QNetworkManagerInterface
+};
-////////
class QNetworkManagerInterfaceAccessPointPrivate;
class QNetworkManagerInterfaceAccessPoint : public QObject
{
@@ -120,7 +179,6 @@ class QNetworkManagerInterfaceAccessPoint : public QObject
public:
- // NM_DEVICE_STATE
enum DeviceState {
Unknown = 0,
Unmanaged,
@@ -181,9 +239,8 @@ private:
QNetworkManagerInterfaceAccessPointPrivate *d;
QNmDBusHelper *nmDBusHelper;
-}; //end QNetworkManagerInterfaceAccessPoint
+};
-////////
class QNetworkManagerInterfaceDevicePrivate;
class QNetworkManagerInterfaceDevice : public QObject
{
@@ -195,7 +252,7 @@ public:
~QNetworkManagerInterfaceDevice();
QString udi() const;
- QNetworkInterface interface() const;
+ QNetworkInterface networkInterface() const;
QDBusInterface *connectionInterface() const;
quint32 ip4Address() const;
quint32 state() const;
@@ -211,9 +268,8 @@ Q_SIGNALS:
private:
QNetworkManagerInterfaceDevicePrivate *d;
QNmDBusHelper *nmDBusHelper;
-}; //end QNetworkManagerInterfaceDevice
+};
-////////
class QNetworkManagerInterfaceDeviceWiredPrivate;
class QNetworkManagerInterfaceDeviceWired : public QObject
{
@@ -236,9 +292,8 @@ Q_SIGNALS:
private:
QNetworkManagerInterfaceDeviceWiredPrivate *d;
QNmDBusHelper *nmDBusHelper;
-}; // end QNetworkManagerInterfaceDeviceWired
+};
-////
class QNetworkManagerInterfaceDeviceWirelessPrivate;
class QNetworkManagerInterfaceDeviceWireless : public QObject
{
@@ -278,9 +333,8 @@ Q_SIGNALS:
private:
QNetworkManagerInterfaceDeviceWirelessPrivate *d;
QNmDBusHelper *nmDBusHelper;
-}; // end QNetworkManagerInterfaceDeviceWireless
+};
-////
class QNetworkManagerSettingsPrivate;
class QNetworkManagerSettings : public QObject
{
@@ -300,9 +354,8 @@ Q_SIGNALS:
void newConnection(QDBusObjectPath);
private:
QNetworkManagerSettingsPrivate *d;
-}; //end QNetworkManagerSettings
+};
-////
class QNetworkManagerSettingsConnectionPrivate;
class QNetworkManagerSettingsConnection : public QObject
{
@@ -315,7 +368,6 @@ public:
QDBusInterface *connectionInterface() const;
QNmSettingsMap getSettings();
- // void update(QNmSettingsMap map);
bool setConnections();
NMDeviceType getType();
bool isAutoConnect();
@@ -335,9 +387,8 @@ Q_SIGNALS:
private:
QNmDBusHelper *nmDBusHelper;
QNetworkManagerSettingsConnectionPrivate *d;
-}; //end QNetworkManagerSettingsConnection
+};
-////
class QNetworkManagerConnectionActivePrivate;
class QNetworkManagerConnectionActive : public QObject
{
@@ -371,9 +422,8 @@ Q_SIGNALS:
private:
QNetworkManagerConnectionActivePrivate *d;
QNmDBusHelper *nmDBusHelper;
-}; //QNetworkManagerConnectionActive
+};
-////
class QNetworkManagerIp4ConfigPrivate;
class QNetworkManagerIp4Config : public QObject
{
@@ -383,14 +433,12 @@ public:
QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = 0);
~QNetworkManagerIp4Config();
- // QList<quint32> nameservers();
QStringList domains() const;
bool isValid();
private:
QNetworkManagerIp4ConfigPrivate *d;
};
-////
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/networkmanager/qnmdbushelper.cpp b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
index d5e20f3..e195eeb 100644
--- a/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
+++ b/src/plugins/bearer/networkmanager/qnmdbushelper.cpp
@@ -43,7 +43,7 @@
#include "qnmdbushelper.h"
-#include <NetworkManager/NetworkManager.h>
+#include "qnetworkmanagerservice.h"
#include <QDBusError>
#include <QDBusInterface>
@@ -54,6 +54,15 @@
QT_BEGIN_NAMESPACE
+QNmDBusHelper::QNmDBusHelper(QObject * parent)
+ : QObject(parent)
+{
+}
+
+QNmDBusHelper::~QNmDBusHelper()
+{
+}
+
void QNmDBusHelper::deviceStateChanged(quint32 state)
{
QDBusMessage msg = this->message();
diff --git a/src/plugins/bearer/networkmanager/qnmdbushelper.h b/src/plugins/bearer/networkmanager/qnmdbushelper.h
index 862290c..933d55a 100644
--- a/src/plugins/bearer/networkmanager/qnmdbushelper.h
+++ b/src/plugins/bearer/networkmanager/qnmdbushelper.h
@@ -52,6 +52,8 @@ class QNmDBusHelper: public QObject, protected QDBusContext
{
Q_OBJECT
public:
+ QNmDBusHelper(QObject *parent = 0);
+ ~QNmDBusHelper();
public slots:
void deviceStateChanged(quint32);