diff options
Diffstat (limited to 'src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp')
-rw-r--r-- | src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp | 301 |
1 files changed, 125 insertions, 176 deletions
diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerservice.cpp index 5dc0ea4..d23bb0d 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,13 +193,12 @@ 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; - qWarning() << "Could not find InterfaceAccessPoint"; return; } d->valid = true; @@ -215,8 +207,6 @@ QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const Q QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint() { - if (nmDBusHelper) - delete nmDBusHelper; delete d->connectionInterface; delete d; } @@ -232,17 +222,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 +288,6 @@ quint32 QNetworkManagerInterfaceAccessPoint::strength() const return d->connectionInterface->property("Strength").toUInt(); } -///////////// class QNetworkManagerInterfaceDevicePrivate { public: @@ -314,13 +301,12 @@ 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; - qWarning() << "Could not find NetworkManagerInterfaceDevice"; return; } d->valid = true; @@ -328,8 +314,6 @@ QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &de QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice() { - if (nmDBusHelper) - delete nmDBusHelper; delete d->connectionInterface; delete d; } @@ -345,16 +329,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 +353,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 +379,6 @@ QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const return prop.value<QDBusObjectPath>(); } -///////////// class QNetworkManagerInterfaceDeviceWiredPrivate { public: @@ -411,13 +392,12 @@ 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; - qWarning() << "Could not find InterfaceDeviceWired"; return; } d->valid = true; @@ -425,8 +405,6 @@ QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const Q QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired() { - if (nmDBusHelper) - delete nmDBusHelper; delete d->connectionInterface; delete d; } @@ -444,16 +422,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 +456,6 @@ bool QNetworkManagerInterfaceDeviceWired::carrier() const return d->connectionInterface->property("Carrier").toBool(); } -///////////// class QNetworkManagerInterfaceDeviceWirelessPrivate { public: @@ -494,13 +469,12 @@ 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; - qWarning() << "Could not find InterfaceDeviceWireless"; return; } d->valid = true; @@ -508,8 +482,6 @@ QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(c QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless() { - if (nmDBusHelper) - delete nmDBusHelper; delete d->connectionInterface; delete d; } @@ -525,10 +497,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 +508,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 +544,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 +573,6 @@ quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const return d->connectionInterface->property("WirelelessCapabilities").toUInt(); } -///////////// class QNetworkManagerSettingsPrivate { public: @@ -618,12 +587,11 @@ 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; - //qWarning() << "Could not find NetworkManagerSettings"; return; } d->valid = true; @@ -644,8 +612,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 +623,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 +633,6 @@ QDBusInterface *QNetworkManagerSettings::connectionInterface() const } -///////////// class QNetworkManagerSettingsConnectionPrivate { public: @@ -685,22 +652,19 @@ 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"; d->valid = false; 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 +681,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 +709,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 +737,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 +752,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 +767,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 +782,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 +798,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 +814,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 +827,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 +844,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 +858,6 @@ QStringList QNetworkManagerSettingsConnection::getSeenBssids() return QStringList(); } -///////////// class QNetworkManagerConnectionActivePrivate { public: @@ -914,13 +871,12 @@ 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; - //qWarning() << "Could not find NetworkManagerSettingsConnection"; return; } d->valid = true; @@ -928,8 +884,6 @@ QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive() { - if (nmDBusHelper) - delete nmDBusHelper; delete d->connectionInterface; delete d; } @@ -945,16 +899,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 +952,6 @@ bool QNetworkManagerConnectionActive::defaultRoute() const return d->connectionInterface->property("Default").toBool(); } - -//// class QNetworkManagerIp4ConfigPrivate { public: @@ -1015,13 +965,12 @@ 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; - //qWarning() << "Could not find NetworkManagerIp4Config"; return; } d->valid = true; |