summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamarque V. Souza <lamarque@kde.org>2012-01-23 00:31:42 (GMT)
committerLamarque V. Souza <lamarque@kde.org>2012-01-26 19:57:22 (GMT)
commit544a5272c2172882101469b01aa98248e336999a (patch)
tree4962ca620fdf4162d8903f20c1dea61e44bfcf4e
parentedc9568628f799e7b1faa9d0ddfa10e3b43b4af9 (diff)
Use asynchronous DBus API in plasmoid and kded module communication.
CCBUG: 287002 CCBUG: 282022 CCBUG: 286424
-rw-r--r--applet/networkmanager.cpp9
-rw-r--r--kded/service.cpp99
-rw-r--r--kded/service.h2
-rw-r--r--libs/client/remoteactivatable.cpp64
-rw-r--r--libs/client/remoteactivatable.h9
-rw-r--r--libs/client/remoteactivatable_p.h2
-rw-r--r--libs/client/remoteactivatablelist.cpp43
-rw-r--r--libs/client/remoteactivatablelist.h3
-rw-r--r--libs/client/remotegsminterfaceconnection.cpp45
-rw-r--r--libs/client/remotegsminterfaceconnection.h4
-rw-r--r--libs/client/remotegsminterfaceconnection_p.h2
-rw-r--r--libs/client/remoteinterfaceconnection.cpp105
-rw-r--r--libs/client/remoteinterfaceconnection.h8
-rw-r--r--libs/client/remoteinterfaceconnection_p.h8
-rw-r--r--libs/client/remoteunconfiguredinterface.cpp9
-rw-r--r--libs/client/remoteunconfiguredinterface.h7
-rw-r--r--libs/client/remotevpninterfaceconnection.cpp5
-rw-r--r--libs/client/remotevpninterfaceconnection.h3
-rw-r--r--libs/client/remotewirelessinterfaceconnection.cpp85
-rw-r--r--libs/client/remotewirelessinterfaceconnection.h5
-rw-r--r--libs/client/remotewirelessinterfaceconnection_p.h10
-rw-r--r--libs/client/remotewirelessnetwork.cpp86
-rw-r--r--libs/client/remotewirelessnetwork.h5
-rw-r--r--libs/client/remotewirelessnetwork_p.h11
-rw-r--r--libs/internals/activatable.cpp21
-rw-r--r--libs/internals/activatable.h4
-rw-r--r--libs/internals/gsminterfaceconnection.cpp42
-rw-r--r--libs/internals/gsminterfaceconnection.h4
-rw-r--r--libs/internals/interfaceconnection.cpp59
-rw-r--r--libs/internals/interfaceconnection.h3
-rw-r--r--libs/internals/wirelessinterfaceconnection.cpp24
-rw-r--r--libs/internals/wirelessinterfaceconnection.h3
-rw-r--r--libs/internals/wirelessnetwork.cpp24
-rw-r--r--libs/internals/wirelessnetwork.h3
-rw-r--r--libs/service/interfaces/org.kde.networkmanagement.activatable.xml8
-rw-r--r--libs/service/interfaces/org.kde.networkmanagement.gsminterfaceconnection.xml8
-rw-r--r--libs/service/interfaces/org.kde.networkmanagement.interfaceconnection.xml8
-rw-r--r--libs/service/interfaces/org.kde.networkmanagement.wirelessinterfaceconnection.xml8
-rw-r--r--libs/service/interfaces/org.kde.networkmanagement.wirelessnetwork.xml8
-rw-r--r--libs/service/interfaces/org.kde.networkmanagement.xml13
-rw-r--r--libs/service/sessionabstractedservice.cpp23
-rw-r--r--libs/service/sessionabstractedservice.h5
-rw-r--r--plasma_nm_version.h2
43 files changed, 660 insertions, 239 deletions
diff --git a/applet/networkmanager.cpp b/applet/networkmanager.cpp
index 50dd8a4..e537950 100644
--- a/applet/networkmanager.cpp
+++ b/applet/networkmanager.cpp
@@ -320,8 +320,12 @@ void NetworkManagerApplet::init()
Q_ARG(int, Solid::Control::NetworkInterfaceNm09::NoReason));
}
- connect(m_activatables, SIGNAL(appeared()), SLOT(finishInitialization()));
- finishInitialization();
+ QDBusConnection dbus = QDBusConnection::sessionBus();
+ dbus.connect("org.kde.kded", "/org/kde/networkmanagement", "org.kde.networkmanagement", "ModuleReady", this, SLOT(finishInitialization()));
+
+ if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.networkmanagement")) {
+ QTimer::singleShot(0, this, SLOT(finishInitialization()));
+ }
}
void NetworkManagerApplet::finishInitialization()
@@ -337,7 +341,6 @@ QGraphicsWidget* NetworkManagerApplet::graphicsWidget()
{
if (!m_popup) {
m_popup = new NMPopup(m_activatables, this);
- connect(m_popup, SIGNAL(configNeedsSaving()), this, SIGNAL(configNeedsSaving()));
}
return m_popup;
}
diff --git a/kded/service.cpp b/kded/service.cpp
index 3c20d1c..6fbdf23 100644
--- a/kded/service.cpp
+++ b/kded/service.cpp
@@ -1,6 +1,7 @@
/*
Copyright 2009 Dario Freddi <drf54321@gmail.com>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2011-2012 Lamarque V. Souza <lamarque@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -20,6 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "service.h"
+#include "paths.h"
+#include "knmserviceprefs.h"
#include <KCModuleInfo>
#include <KDebug>
@@ -84,30 +87,7 @@ NetworkManagementService::NetworkManagementService(QObject * parent, const QVari
: KDEDModule(parent), d_ptr(new NetworkManagementServicePrivate)
{
Q_D(NetworkManagementService);
- d->connectionList = new ConnectionList(this);
- d->secretStorage = new SecretStorage();
-
- d->activatableList = new ActivatableList(d->connectionList);
-
- d->configurationLauncher = new ConfigurationLauncher(this);
- d->connectionUsageMonitor = new ConnectionUsageMonitor(d->connectionList, d->activatableList, d->activatableList);
-
- d->vpnInterfaceConnectionProvider = new VpnInterfaceConnectionProvider(d->connectionList, d->activatableList, d->activatableList);
- d->connectionList->registerConnectionHandler(d->vpnInterfaceConnectionProvider);
-
- d->nmDBusConnectionProvider = new NMDBusSettingsConnectionProvider(d->connectionList, d->connectionList);
- d->nmDBusSecretAgent = new NMDBusSecretAgent(this);
- d->nmDBusSecretAgent->registerSecretsProvider(d->secretStorage);
-
- // generic observers
- d->activatableList->registerObserver(d->configurationLauncher);
- d->activatableList->registerObserver(d->connectionUsageMonitor);
-
- d->activatableList->registerObserver(d->nmDBusConnectionProvider);
-
- // debug activatable changes
- //ActivatableDebug debug;
- //activatableList->registerObserver(&debug);
+ KNetworkManagerServicePrefs::instance(Knm::NETWORKMANAGEMENT_RCFILE);
Solid::Control::NetworkInterfaceNm09::Types types =
(Solid::Control::NetworkInterfaceNm09::Ethernet
@@ -117,31 +97,15 @@ NetworkManagementService::NetworkManagementService(QObject * parent, const QVari
);
d->sortedList = new SortedActivatableList(types, this);
- d->activatableList->registerObserver(d->sortedList);
d->sessionAbstractedService = new SessionAbstractedService(d->sortedList, this);
d->sortedList->registerObserver(d->sessionAbstractedService);
- // there is a problem setting this as a child of connectionList or of activatableList since it has
- // references to both and NetworkInterfaceActivatableProvider touches the activatableList
- // in its dtor (needed so it cleans up when removed by the monitor)
- // ideally this will always be deleted before the other list
- d->networkInterfaceMonitor = new NetworkInterfaceMonitor(d->connectionList, d->activatableList, d->activatableList);
-
- // create ActiveConnectionMonitor after construction of NMDBusSettingsConnectionProvider and observer registrations
- // because, activatableList is filled in NetworkInterfaceMonitor and updated in registerObservers above. This is why "Auto eth0" connection created automatically by NM has
- // Unknown activationState in its /org/kde/networkmanagement/Activatable interface
- d->nmActiveConnectionMonitor = new NMDBusActiveConnectionMonitor(d->activatableList, d->nmDBusConnectionProvider);
-
- // register after nmSettingsService and nmDBusConnectionProvider because it relies on changes they
- // make to interfaceconnections
- d->activatableList->registerObserver(d->nmActiveConnectionMonitor);
-
d->notificationManager = 0;
connect(d->sessionAbstractedService, SIGNAL(DoFinishInitialization()), SLOT(finishInitialization()));
+ QTimer::singleShot(1000, d->sessionAbstractedService, SIGNAL(ModuleReady()));
}
-
NetworkManagementService::~NetworkManagementService()
{
}
@@ -149,16 +113,67 @@ NetworkManagementService::~NetworkManagementService()
void NetworkManagementService::finishInitialization()
{
Q_D(NetworkManagementService);
- QObject::disconnect(d->sessionAbstractedService, SIGNAL(DoFinishInitialization()), this, 0);
if (d->notificationManager) {
return;
}
+ QObject::disconnect(d->sessionAbstractedService, SIGNAL(DoFinishInitialization()), this, 0);
+
+ d->connectionList = new ConnectionList(this);
+
// watches events and creates KNotifications
d->notificationManager = new NotificationManager(d->connectionList, this);
+ d->activatableList = new ActivatableList(d->connectionList);
+
d->activatableList->registerObserver(d->notificationManager);
+ d->activatableList->registerObserver(d->sortedList);
+
+ // debug activatable changes
+ //ActivatableDebug debug;
+ //activatableList->registerObserver(&debug);
+
+ d->secretStorage = new SecretStorage();
+ d->configurationLauncher = new ConfigurationLauncher(this);
+ d->connectionUsageMonitor = new ConnectionUsageMonitor(d->connectionList, d->activatableList, d->activatableList);
+
+ d->vpnInterfaceConnectionProvider = new VpnInterfaceConnectionProvider(d->connectionList, d->activatableList, d->activatableList);
+ d->connectionList->registerConnectionHandler(d->vpnInterfaceConnectionProvider);
+
+ d->nmDBusConnectionProvider = new NMDBusSettingsConnectionProvider(d->connectionList, d->connectionList);
+ d->nmDBusSecretAgent = new NMDBusSecretAgent(this);
+ d->nmDBusSecretAgent->registerSecretsProvider(d->secretStorage);
+
+ // generic observers
+ d->activatableList->registerObserver(d->configurationLauncher);
+ d->activatableList->registerObserver(d->connectionUsageMonitor);
+
+ d->activatableList->registerObserver(d->nmDBusConnectionProvider);
+
+ // there is a problem setting this as a child of connectionList or of activatableList since it has
+ // references to both and NetworkInterfaceActivatableProvider touches the activatableList
+ // in its dtor (needed so it cleans up when removed by the monitor)
+ // ideally this will always be deleted before the other list
+ d->networkInterfaceMonitor = new NetworkInterfaceMonitor(d->connectionList, d->activatableList, d->activatableList);
d->nm08Connections = new Nm08Connections(d->secretStorage, d->nmDBusConnectionProvider);
d->nm08Connections->importNextNm08Connection();
+
+ // give some time for the ActivatableAdded signal be processed before we emit the activationStateChanged
+ // and hasDefaultRouteChanged signals from d->nmActiveConnectionMonitor.
+ QTimer::singleShot(1000, this, SLOT(delayedRegisterObservers()));
+}
+
+void NetworkManagementService::delayedRegisterObservers()
+{
+ Q_D(NetworkManagementService);
+
+ // create ActiveConnectionMonitor after construction of NMDBusSettingsConnectionProvider and observer registrations
+ // because, activatableList is filled in NetworkManager::DeviceMonitor and updated in registerObservers above. This is why "Auto eth0" connection created automatically by NM has
+ // Unknown activationState in its /org/kde/networkmanagement/Activatable interface
+ d->nmActiveConnectionMonitor = new NMDBusActiveConnectionMonitor(d->activatableList, d->nmDBusConnectionProvider);
+
+ // register after nmSettingsService and nmDBusConnectionProvider because it relies on changes they
+ // make to interfaceconnections
+ d->activatableList->registerObserver(d->nmActiveConnectionMonitor);
}
diff --git a/kded/service.h b/kded/service.h
index d4ebcf8..4d48ed9 100644
--- a/kded/service.h
+++ b/kded/service.h
@@ -1,6 +1,7 @@
/*
Copyright 2009 Dario Freddi <drf54321@gmail.com>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -37,6 +38,7 @@ public:
virtual ~NetworkManagementService();
private Q_SLOTS:
void finishInitialization();
+ void delayedRegisterObservers();
private:
NetworkManagementServicePrivate * d_ptr;
};
diff --git a/libs/client/remoteactivatable.cpp b/libs/client/remoteactivatable.cpp
index ed88aa4..9e84c3d 100644
--- a/libs/client/remoteactivatable.cpp
+++ b/libs/client/remoteactivatable.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -28,20 +29,16 @@ RemoteActivatablePrivate::~RemoteActivatablePrivate()
}
-RemoteActivatable::RemoteActivatable(RemoteActivatablePrivate & dd, const QString &dbusPath, QObject * parent)
+RemoteActivatable::RemoteActivatable(RemoteActivatablePrivate & dd, const QVariantMap &properties, QObject * parent)
: QObject(parent), d_ptr(&dd)
{
- Q_D(RemoteActivatable);
- d->activatableIface = new ActivatableInterface("org.kde.networkmanagement", dbusPath, QDBusConnection::sessionBus(), this);
- init();
+ init(properties);
}
-RemoteActivatable::RemoteActivatable(const QString &dbusPath, QObject * parent)
+RemoteActivatable::RemoteActivatable(const QVariantMap &properties, QObject * parent)
: QObject(parent), d_ptr(new RemoteActivatablePrivate)
{
- Q_D(RemoteActivatable);
- d->activatableIface = new ActivatableInterface("org.kde.networkmanagement", dbusPath, QDBusConnection::sessionBus(), this);
- init();
+ init(properties);
}
RemoteActivatable::~RemoteActivatable()
@@ -49,28 +46,44 @@ RemoteActivatable::~RemoteActivatable()
delete d_ptr;
}
-void RemoteActivatable::init()
+void RemoteActivatable::init(const QVariantMap & properties)
{
Q_D(RemoteActivatable);
+ d->activatableIface = new ActivatableInterface("org.kde.networkmanagement", properties["path"].toString(), QDBusConnection::sessionBus(), this);
//kDebug() << "ActivatableInterface is (" << d->activatableIface << ") on" << d_ptr;
connect(d->activatableIface, SIGNAL(activated()),
this, SIGNAL(activated()));
connect(d->activatableIface, SIGNAL(changed()),
this, SIGNAL(changed()));
+ connect(d->activatableIface, SIGNAL(propertiesChanged(QVariantMap)), SLOT(propertiesChanged(QVariantMap)));
- QDBusReply<QString> reply = d->activatableIface->deviceUni();
- if (reply.isValid()) {
- d->deviceUni = reply.value();
- } else {
- kDebug() << "deviceUni reply is invalid";
- }
+ propertiesChanged(properties);
+}
- QDBusReply<uint> reply2 = d->activatableIface->activatableType();
- if (reply2.isValid()) {
- d->activatableType = (Knm::Activatable::ActivatableType)reply2.value();
- } else {
- d->activatableType = Knm::Activatable::InterfaceConnection;
- kDebug() << "activatableType reply is invalid";
+void RemoteActivatable::propertiesChanged(const QVariantMap &changedProperties)
+{
+ Q_D(RemoteActivatable);
+ QStringList propKeys = changedProperties.keys();
+ QLatin1String deviceUniKey("deviceUni"),
+ activatableTypeKey("activatableType"),
+ sharedKey("shared");
+ QVariantMap::const_iterator it = changedProperties.find(deviceUniKey);
+ if (it != changedProperties.end()) {
+ d->deviceUni = it->toString();
+ propKeys.removeOne(deviceUniKey);
+ }
+ it = changedProperties.find(activatableTypeKey);
+ if (it != changedProperties.end()) {
+ d->activatableType = (Knm::Activatable::ActivatableType)it->toUInt();
+ propKeys.removeOne(activatableTypeKey);
+ }
+ it = changedProperties.find(sharedKey);
+ if (it != changedProperties.end()) {
+ d->shared = it->toBool();
+ propKeys.removeOne(sharedKey);
+ }
+ if (propKeys.count()) {
+ kDebug() << "Unhandled properties: " << propKeys;
}
}
@@ -89,14 +102,7 @@ QString RemoteActivatable::deviceUni() const
bool RemoteActivatable::isShared() const
{
Q_D(const RemoteActivatable);
- if (!d->activatableIface->isValid()) {
- return false;
- }
- QDBusReply<bool> reply = d->activatableIface->isShared();
- if (reply.isValid()) {
- return reply.value();
- }
- return false;
+ return d->shared;
}
void RemoteActivatable::activate()
diff --git a/libs/client/remoteactivatable.h b/libs/client/remoteactivatable.h
index ec41fa7..f621b64 100644
--- a/libs/client/remoteactivatable.h
+++ b/libs/client/remoteactivatable.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -51,13 +52,15 @@ public Q_SLOTS:
Q_SIGNALS:
void activated();
void changed();
+protected Q_SLOTS:
+ void propertiesChanged(const QVariantMap &properties);
protected:
Q_DECLARE_PRIVATE(RemoteActivatable)
- RemoteActivatable(const QString &dbusPath, QObject * parent);
- RemoteActivatable(RemoteActivatablePrivate & dd, const QString &dbusPath, QObject * parent);
+ RemoteActivatable(const QVariantMap &properties, QObject * parent);
+ RemoteActivatable(RemoteActivatablePrivate & dd, const QVariantMap &properties, QObject * parent);
RemoteActivatablePrivate * d_ptr;
private:
- void init();
+ void init(const QVariantMap & properties);
};
#endif // REMOTEACTIVATABLE_H
diff --git a/libs/client/remoteactivatable_p.h b/libs/client/remoteactivatable_p.h
index 5fb573b..dab03eb 100644
--- a/libs/client/remoteactivatable_p.h
+++ b/libs/client/remoteactivatable_p.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -30,6 +31,7 @@ public:
ActivatableInterface * activatableIface;
QString deviceUni;
Knm::Activatable::ActivatableType activatableType;
+ bool shared;
};
#endif // REMOTEACTIVATABLE_P_H
diff --git a/libs/client/remoteactivatablelist.cpp b/libs/client/remoteactivatablelist.cpp
index 1126d6c..ee788bc 100644
--- a/libs/client/remoteactivatablelist.cpp
+++ b/libs/client/remoteactivatablelist.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2011-2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -60,27 +61,13 @@ void RemoteActivatableList::init()
{
Q_D(RemoteActivatableList);
if (d->iface->isValid()) {
- connect(d->iface, SIGNAL(ActivatableAdded(const QString&,uint, int)),
- this, SLOT(handleActivatableAdded(const QString&,uint, int)));
- connect(d->iface, SIGNAL(ActivatableRemoved(const QString&)),
- this, SLOT(handleActivatableRemoved(const QString &)));
+ connect(d->iface, SIGNAL(ActivatableAdded(QVariantMap)),
+ this, SLOT(handleActivatableAdded(QVariantMap)));
+ connect(d->iface, SIGNAL(ActivatableRemoved(QString)),
+ this, SLOT(handleActivatableRemoved(QString)));
if (d->activatables.isEmpty()) {
- QDBusReply<QStringList> rv = d->iface->ListActivatables();
- if (rv.isValid()) {
- int i = 0;
- foreach (const QString &activatable, rv.value()) {
- // messy, I know, but making ListActivatables return a(si) is boring
- QDBusInterface iface(QLatin1String("org.kde.networkmanagement"),
- activatable, "org.kde.networkmanagement.Activatable", QDBusConnection::sessionBus());
- QDBusReply<uint> type = iface.call("activatableType");
- if (type.isValid())
- handleActivatableAdded(activatable, type.value(), i);
- i++;
- }
- }
- else
- kWarning() << "ListActivatables method of KDED module is not available!";
+ d->iface->ReEmitActivatableList();
}
}
}
@@ -138,8 +125,12 @@ QList<RemoteActivatable *> RemoteActivatableList::activatables() const
return d->sortedActivatables;
}
-void RemoteActivatableList::handleActivatableAdded(const QString &addedPath, uint type, int index)
+void RemoteActivatableList::handleActivatableAdded(const QVariantMap & properties)
{
+ QString addedPath = properties["path"].toString();
+ uint type = properties["activatableType"].toUInt();
+ int index = properties["activatableIndex"].toInt();
+
if (!addedPath.startsWith('/')) {
kDebug() << "Invalid path:" << addedPath << type;
return;
@@ -149,27 +140,27 @@ void RemoteActivatableList::handleActivatableAdded(const QString &addedPath, uin
RemoteActivatable * newActivatable = 0;
switch (type) {
case Knm::Activatable::InterfaceConnection:
- newActivatable = new RemoteInterfaceConnection(addedPath, this);
+ newActivatable = new RemoteInterfaceConnection(properties, this);
//kDebug() << "interfaceconnection at" << addedPath << "with type" << newActivatable->activatableType();
break;
case Knm::Activatable::WirelessInterfaceConnection:
- newActivatable = new RemoteWirelessInterfaceConnection(addedPath, this);
+ newActivatable = new RemoteWirelessInterfaceConnection(properties, this);
//kDebug() << "wirelessconnection at" << addedPath << "with type" << newActivatable->activatableType();
break;
case Knm::Activatable::WirelessNetwork:
- newActivatable = new RemoteWirelessNetwork(addedPath, this);
+ newActivatable = new RemoteWirelessNetwork(properties, this);
//kDebug() << "wirelessnetwork at" << addedPath << "with type" << newActivatable->activatableType();
break;
case Knm::Activatable::UnconfiguredInterface:
- newActivatable = new RemoteUnconfiguredInterface(addedPath, this);
+ newActivatable = new RemoteUnconfiguredInterface(properties, this);
//kDebug() << "unconfiguredinterface at" << addedPath << "with type" << newActivatable->activatableType();
break;
case Knm::Activatable::VpnInterfaceConnection:
- newActivatable = new RemoteVpnInterfaceConnection(addedPath, this);
+ newActivatable = new RemoteVpnInterfaceConnection(properties, this);
//kDebug() << "vpnconnection at" << addedPath << "with type" << newActivatable->activatableType();
break;
case Knm::Activatable::GsmInterfaceConnection:
- newActivatable = new RemoteGsmInterfaceConnection(addedPath, this);
+ newActivatable = new RemoteGsmInterfaceConnection(properties, this);
//kDebug() << "gsminterfaceconnection at" << addedPath << "with type" << newActivatable->activatableType();
break;
}
diff --git a/libs/client/remoteactivatablelist.h b/libs/client/remoteactivatablelist.h
index b4a12db..460ab55 100644
--- a/libs/client/remoteactivatablelist.h
+++ b/libs/client/remoteactivatablelist.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -53,7 +54,7 @@ Q_SIGNALS:
void appeared();
void disappeared();
protected Q_SLOTS:
- void handleActivatableAdded(const QString &, uint, int);
+ void handleActivatableAdded(const QVariantMap &properties);
void handleActivatableRemoved(const QString &);
void serviceOwnerChanged(const QString&, const QString&, const QString&);
private:
diff --git a/libs/client/remotegsminterfaceconnection.cpp b/libs/client/remotegsminterfaceconnection.cpp
index f178bc2..b6cbe5e 100644
--- a/libs/client/remotegsminterfaceconnection.cpp
+++ b/libs/client/remotegsminterfaceconnection.cpp
@@ -24,14 +24,15 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "remotegsminterfaceconnection.h"
#include "remotegsminterfaceconnection_p.h"
-RemoteGsmInterfaceConnection::RemoteGsmInterfaceConnection(const QString &dbusPath, QObject * parent)
-: RemoteInterfaceConnection(*new RemoteGsmInterfaceConnectionPrivate, dbusPath, parent)
+#include <KDebug>
+
+RemoteGsmInterfaceConnection::RemoteGsmInterfaceConnection(const QVariantMap &properties, QObject * parent)
+: RemoteInterfaceConnection(*new RemoteGsmInterfaceConnectionPrivate, properties, parent)
{
Q_D(RemoteGsmInterfaceConnection);
- d->gsmInterfaceConnectionIface = new GsmInterfaceConnectionInterface("org.kde.networkmanagement", dbusPath, QDBusConnection::sessionBus(), this);
- connect(d->gsmInterfaceConnectionIface, SIGNAL(signalQualityChanged(int)), this, SIGNAL(signalQualityChanged(int)));
-
- connect(d->gsmInterfaceConnectionIface, SIGNAL(accessTechnologyChanged(const int)), this, SIGNAL(accessTechnologyChanged(const int)));
+ d->gsmInterfaceConnectionIface = new GsmInterfaceConnectionInterface("org.kde.networkmanagement", properties["path"].toString(), QDBusConnection::sessionBus(), this);
+ connect(d->gsmInterfaceConnectionIface, SIGNAL(gsmPropertiesChanged(QVariantMap)), SLOT(gsmPropertiesChanged(QVariantMap)));
+ gsmPropertiesChanged(properties);
}
RemoteGsmInterfaceConnection::~RemoteGsmInterfaceConnection()
@@ -39,22 +40,38 @@ RemoteGsmInterfaceConnection::~RemoteGsmInterfaceConnection()
}
+void RemoteGsmInterfaceConnection::gsmPropertiesChanged(const QVariantMap &changedProperties)
+{
+ Q_D(RemoteGsmInterfaceConnection);
+ QStringList propKeys = changedProperties.keys();
+ QLatin1String signalQualityKey("signalQuality"),
+ accessTechnologyKey("accessTechnology");
+ QVariantMap::const_iterator it = changedProperties.find(signalQualityKey);
+ if (it != changedProperties.end()) {
+ d->signalQuality = it->toInt();
+ emit signalQualityChanged(d->signalQuality);
+ propKeys.removeOne(signalQualityKey);
+ }
+ it = changedProperties.find(accessTechnologyKey);
+ if (it != changedProperties.end()) {
+ d->accessTechnology = it->toInt();
+ emit accessTechnologyChanged(d->accessTechnology);
+ propKeys.removeOne(accessTechnologyKey);
+ }
+ if (propKeys.count()) {
+ kDebug() << "Unhandled properties: " << propKeys;
+ }
+}
int RemoteGsmInterfaceConnection::getAccessTechnology() const
{
Q_D(const RemoteGsmInterfaceConnection);
- QDBusReply<int> reply = d->gsmInterfaceConnectionIface->getAccessTechnology();
-
- if (reply.isValid()) {
- return reply.value();
- } else {
- return Solid::Control::ModemInterface::UnknownTechnology;
- }
+ return d->accessTechnology;
}
int RemoteGsmInterfaceConnection::getSignalQuality() const
{
Q_D(const RemoteGsmInterfaceConnection);
- return d->gsmInterfaceConnectionIface->getSignalQuality();
+ return d->signalQuality;
}
// vim: sw=4 sts=4 et tw=100
diff --git a/libs/client/remotegsminterfaceconnection.h b/libs/client/remotegsminterfaceconnection.h
index 6beac09..c8c7b8c 100644
--- a/libs/client/remotegsminterfaceconnection.h
+++ b/libs/client/remotegsminterfaceconnection.h
@@ -45,8 +45,10 @@ public:
Q_SIGNALS:
void signalQualityChanged(int);
void accessTechnologyChanged(const int);
+protected Q_SLOTS:
+ void gsmPropertiesChanged(const QVariantMap &properties);
protected:
- RemoteGsmInterfaceConnection(const QString & dbusPath, QObject * parent);
+ RemoteGsmInterfaceConnection(const QVariantMap & properties, QObject * parent);
Q_DECLARE_PRIVATE(RemoteGsmInterfaceConnection)
};
diff --git a/libs/client/remotegsminterfaceconnection_p.h b/libs/client/remotegsminterfaceconnection_p.h
index 3543017..2d72ad8 100644
--- a/libs/client/remotegsminterfaceconnection_p.h
+++ b/libs/client/remotegsminterfaceconnection_p.h
@@ -29,6 +29,8 @@ class RemoteGsmInterfaceConnectionPrivate : public RemoteInterfaceConnectionPriv
{
public:
GsmInterfaceConnectionInterface * gsmInterfaceConnectionIface;
+ int signalQuality;
+ int accessTechnology;
};
#endif // REMOTEGSMINTERFACECONNECTION_P_H
diff --git a/libs/client/remoteinterfaceconnection.cpp b/libs/client/remoteinterfaceconnection.cpp
index 645e25f..ccc0a28 100644
--- a/libs/client/remoteinterfaceconnection.cpp
+++ b/libs/client/remoteinterfaceconnection.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -21,84 +22,124 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "remoteinterfaceconnection.h"
#include "remoteinterfaceconnection_p.h"
-RemoteInterfaceConnection::RemoteInterfaceConnection(RemoteInterfaceConnectionPrivate &dd, const QString &dbusPath, QObject * parent)
-: RemoteActivatable(dd, dbusPath, parent)
+#include <KDebug>
+
+RemoteInterfaceConnection::RemoteInterfaceConnection(RemoteInterfaceConnectionPrivate &dd, const QVariantMap &properties, QObject * parent)
+: RemoteActivatable(dd, properties, parent)
{
- Q_D(RemoteInterfaceConnection);
- d->interfaceConnectionIface = new InterfaceConnectionInterface("org.kde.networkmanagement", dbusPath, QDBusConnection::sessionBus(), this);
- connect(d->interfaceConnectionIface, SIGNAL(activationStateChanged(uint, uint)),
- this, SLOT(handleActivationStateChange(uint, uint)));
- connect(d->interfaceConnectionIface, SIGNAL(hasDefaultRouteChanged(bool)),
- this, SIGNAL(hasDefaultRouteChanged(bool)));
+ init(properties);
}
-RemoteInterfaceConnection::RemoteInterfaceConnection(const QString &dbusPath, QObject * parent)
-: RemoteActivatable(*new RemoteInterfaceConnectionPrivate, dbusPath, parent)
+RemoteInterfaceConnection::RemoteInterfaceConnection(const QVariantMap &properties, QObject * parent)
+: RemoteActivatable(*new RemoteInterfaceConnectionPrivate, properties, parent)
+{
+ init(properties);
+}
+
+void RemoteInterfaceConnection::init(const QVariantMap &properties)
{
Q_D(RemoteInterfaceConnection);
- d->interfaceConnectionIface = new InterfaceConnectionInterface("org.kde.networkmanagement", dbusPath, QDBusConnection::sessionBus(), this);
- connect(d->interfaceConnectionIface, SIGNAL(activationStateChanged(uint, uint)),
- this, SLOT(handleActivationStateChange(uint, uint)));
- connect(d->interfaceConnectionIface, SIGNAL(hasDefaultRouteChanged(bool)),
- this, SIGNAL(hasDefaultRouteChanged(bool)));
+ d->interfaceConnectionIface = new InterfaceConnectionInterface("org.kde.networkmanagement", properties["path"].toString(), QDBusConnection::sessionBus(), this);
+ connect(d->interfaceConnectionIface, SIGNAL(icPropertiesChanged(QVariantMap)), SLOT(icPropertiesChanged(QVariantMap)));
+
+ d->activationState = Knm::InterfaceConnection::Unknown;
+ icPropertiesChanged(properties);
}
RemoteInterfaceConnection::~RemoteInterfaceConnection()
{
}
+void RemoteInterfaceConnection::icPropertiesChanged(const QVariantMap &changedProperties)
+{
+ Q_D(RemoteInterfaceConnection);
+ QStringList propKeys = changedProperties.keys();
+ QLatin1String connectionTypeKey("connectionType"),
+ uuidKey("uuid"),
+ nameKey("name"),
+ iconNameKey("iconName"),
+ activationStateKey("activationState"),
+ hasDefaultRouteKey("hasDefaultRoute");
+ QVariantMap::const_iterator it = changedProperties.find(connectionTypeKey);
+ if (it != changedProperties.end()) {
+ d->connectionType = (Knm::Connection::Type)it->toUInt();
+ propKeys.removeOne(connectionTypeKey);
+ }
+ it = changedProperties.find(uuidKey);
+ if (it != changedProperties.end()) {
+ d->uuid = it->toString();
+ propKeys.removeOne(uuidKey);
+ }
+ it = changedProperties.find(nameKey);
+ if (it != changedProperties.end()) {
+ d->name = it->toString();
+ propKeys.removeOne(nameKey);
+ }
+ it = changedProperties.find(iconNameKey);
+ if (it != changedProperties.end()) {
+ d->iconName = it->toString();
+ propKeys.removeOne(iconNameKey);
+ }
+ it = changedProperties.find(activationStateKey);
+ if (it != changedProperties.end()) {
+ d->oldActivationState = d->activationState;
+ d->activationState = (Knm::InterfaceConnection::ActivationState)it->toUInt();
+ emit activationStateChanged(d->oldActivationState, d->activationState);
+ propKeys.removeOne(activationStateKey);
+ }
+ it = changedProperties.find(hasDefaultRouteKey);
+ if (it != changedProperties.end()) {
+ d->hasDefaultRoute = it->toBool();
+ emit hasDefaultRouteChanged(d->hasDefaultRoute);
+ propKeys.removeOne(hasDefaultRouteKey);
+ }
+ if (propKeys.count()) {
+ kDebug() << "Unhandled properties: " << propKeys;
+ }
+}
+
Knm::Connection::Type RemoteInterfaceConnection::connectionType() const
{
Q_D(const RemoteInterfaceConnection);
- uint cType = d->interfaceConnectionIface->connectionType();
- return (Knm::Connection::Type)cType;
+ return d->connectionType;
}
QUuid RemoteInterfaceConnection::connectionUuid() const
{
Q_D(const RemoteInterfaceConnection);
- QString uuid = d->interfaceConnectionIface->connectionUuid();
- return QUuid(uuid);
+ return d->uuid;
}
QString RemoteInterfaceConnection::connectionName() const
{
Q_D(const RemoteInterfaceConnection);
- return d->interfaceConnectionIface->connectionName();
+ return d->name;
}
QString RemoteInterfaceConnection::iconName() const
{
Q_D(const RemoteInterfaceConnection);
- return d->interfaceConnectionIface->iconName();
+ return d->iconName;
}
Knm::InterfaceConnection::ActivationState RemoteInterfaceConnection::activationState() const
{
Q_D(const RemoteInterfaceConnection);
- uint aState = d->interfaceConnectionIface->activationState();
- return (Knm::InterfaceConnection::ActivationState)aState;
+ return d->activationState;
}
Knm::InterfaceConnection::ActivationState RemoteInterfaceConnection::oldActivationState() const
{
Q_D(const RemoteInterfaceConnection);
- uint aState = d->interfaceConnectionIface->oldActivationState();
- return (Knm::InterfaceConnection::ActivationState)aState;
+ return d->oldActivationState;
}
bool RemoteInterfaceConnection::hasDefaultRoute() const
{
Q_D(const RemoteInterfaceConnection);
- return d->interfaceConnectionIface->hasDefaultRoute();
+ return d->hasDefaultRoute;
}
-void RemoteInterfaceConnection::handleActivationStateChange(uint oldState, uint newState)
-{
- emit activationStateChanged((Knm::InterfaceConnection::ActivationState)oldState, (Knm::InterfaceConnection::ActivationState)newState);
-}
-
-
void RemoteInterfaceConnection::deactivate()
{
Q_D(RemoteInterfaceConnection);
diff --git a/libs/client/remoteinterfaceconnection.h b/libs/client/remoteinterfaceconnection.h
index 0732434..68ecf30 100644
--- a/libs/client/remoteinterfaceconnection.h
+++ b/libs/client/remoteinterfaceconnection.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -67,11 +68,12 @@ Q_SIGNALS:
void activationStateChanged(Knm::InterfaceConnection::ActivationState, Knm::InterfaceConnection::ActivationState);
void hasDefaultRouteChanged(bool);
protected Q_SLOTS:
- void handleActivationStateChange(uint, uint);
+ void icPropertiesChanged(const QVariantMap &properties);
protected:
- RemoteInterfaceConnection(const QString &dbusPath, QObject * parent);
- RemoteInterfaceConnection(RemoteInterfaceConnectionPrivate &dd, const QString &dbusPath, QObject * parent);
+ RemoteInterfaceConnection(const QVariantMap &properties, QObject * parent);
+ RemoteInterfaceConnection(RemoteInterfaceConnectionPrivate &dd, const QVariantMap &properties, QObject * parent);
private:
+ void init(const QVariantMap & properties);
Q_DECLARE_PRIVATE(RemoteInterfaceConnection)
};
diff --git a/libs/client/remoteinterfaceconnection_p.h b/libs/client/remoteinterfaceconnection_p.h
index 422352a..e2c7fe5 100644
--- a/libs/client/remoteinterfaceconnection_p.h
+++ b/libs/client/remoteinterfaceconnection_p.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -29,6 +30,13 @@ class RemoteInterfaceConnectionPrivate : public RemoteActivatablePrivate
{
public:
InterfaceConnectionInterface * interfaceConnectionIface;
+ Knm::Connection::Type connectionType;
+ QString uuid;
+ QString name;
+ QString iconName;
+ Knm::InterfaceConnection::ActivationState activationState;
+ Knm::InterfaceConnection::ActivationState oldActivationState;
+ bool hasDefaultRoute;
};
#endif // REMOTEINTERFACECONNECTION_P_H
diff --git a/libs/client/remoteunconfiguredinterface.cpp b/libs/client/remoteunconfiguredinterface.cpp
index 128bd32..513183b 100644
--- a/libs/client/remoteunconfiguredinterface.cpp
+++ b/libs/client/remoteunconfiguredinterface.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -21,13 +22,13 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "remoteunconfiguredinterface.h"
#include "remoteunconfiguredinterface_p.h"
-RemoteUnconfiguredInterface::RemoteUnconfiguredInterface(RemoteUnconfiguredInterfacePrivate &dd, const QString &dbusPath, QObject * parent)
-: RemoteActivatable(dd, dbusPath, parent)
+RemoteUnconfiguredInterface::RemoteUnconfiguredInterface(RemoteUnconfiguredInterfacePrivate &dd, const QVariantMap &properties, QObject * parent)
+: RemoteActivatable(dd, properties, parent)
{
}
-RemoteUnconfiguredInterface::RemoteUnconfiguredInterface(const QString &dbusPath, QObject * parent)
-: RemoteActivatable(*new RemoteUnconfiguredInterfacePrivate, dbusPath, parent)
+RemoteUnconfiguredInterface::RemoteUnconfiguredInterface(const QVariantMap &properties, QObject * parent)
+: RemoteActivatable(*new RemoteUnconfiguredInterfacePrivate, properties, parent)
{
}
diff --git a/libs/client/remoteunconfiguredinterface.h b/libs/client/remoteunconfiguredinterface.h
index f3a06bf..e9cc39c 100644
--- a/libs/client/remoteunconfiguredinterface.h
+++ b/libs/client/remoteunconfiguredinterface.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -18,6 +19,8 @@ You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+// TODO: check if this class is really used, remove it if not.
+
#ifndef REMOTEUNCONFIGUREDINTERFACE_H
#define REMOTEUNCONFIGUREDINTERFACE_H
@@ -38,11 +41,11 @@ Q_OBJECT
friend class RemoteActivatableList;
public:
- RemoteUnconfiguredInterface(const QString &dbusPath, QObject * parent);
+ RemoteUnconfiguredInterface(const QVariantMap &properties, QObject * parent);
virtual ~RemoteUnconfiguredInterface();
protected:
- RemoteUnconfiguredInterface(RemoteUnconfiguredInterfacePrivate &dd, const QString &dbusPath, QObject * parent);
+ RemoteUnconfiguredInterface(RemoteUnconfiguredInterfacePrivate &dd, const QVariantMap &properties, QObject * parent);
private:
Q_DECLARE_PRIVATE(RemoteUnconfiguredInterface)
};
diff --git a/libs/client/remotevpninterfaceconnection.cpp b/libs/client/remotevpninterfaceconnection.cpp
index d58506b..12372ad 100644
--- a/libs/client/remotevpninterfaceconnection.cpp
+++ b/libs/client/remotevpninterfaceconnection.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -21,8 +22,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "remotevpninterfaceconnection.h"
#include "remotevpninterfaceconnection_p.h"
-RemoteVpnInterfaceConnection::RemoteVpnInterfaceConnection(const QString &dbusPath, QObject * parent)
-: RemoteInterfaceConnection(*new RemoteVpnInterfaceConnectionPrivate, dbusPath, parent)
+RemoteVpnInterfaceConnection::RemoteVpnInterfaceConnection(const QVariantMap &properties, QObject * parent)
+: RemoteInterfaceConnection(*new RemoteVpnInterfaceConnectionPrivate, properties, parent)
{
}
diff --git a/libs/client/remotevpninterfaceconnection.h b/libs/client/remotevpninterfaceconnection.h
index a3c6238..6e9f78f 100644
--- a/libs/client/remotevpninterfaceconnection.h
+++ b/libs/client/remotevpninterfaceconnection.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -36,7 +37,7 @@ friend class RemoteActivatableList;
public:
virtual ~RemoteVpnInterfaceConnection();
protected:
- RemoteVpnInterfaceConnection(const QString & dbusPath, QObject * parent);
+ RemoteVpnInterfaceConnection(const QVariantMap & properties, QObject * parent);
Q_DECLARE_PRIVATE(RemoteVpnInterfaceConnection)
};
diff --git a/libs/client/remotewirelessinterfaceconnection.cpp b/libs/client/remotewirelessinterfaceconnection.cpp
index beb30ce..25d0a9c 100644
--- a/libs/client/remotewirelessinterfaceconnection.cpp
+++ b/libs/client/remotewirelessinterfaceconnection.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -21,12 +22,17 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "remotewirelessinterfaceconnection.h"
#include "remotewirelessinterfaceconnection_p.h"
-RemoteWirelessInterfaceConnection::RemoteWirelessInterfaceConnection(const QString &dbusPath, QObject * parent)
-: RemoteInterfaceConnection(*new RemoteWirelessInterfaceConnectionPrivate, dbusPath, parent)
+#include "solid/control/wirelessnetworkinterface.h"
+
+#include <KDebug>
+
+RemoteWirelessInterfaceConnection::RemoteWirelessInterfaceConnection(const QVariantMap &properties, QObject * parent)
+: RemoteInterfaceConnection(*new RemoteWirelessInterfaceConnectionPrivate, properties, parent)
{
Q_D(RemoteWirelessInterfaceConnection);
- d->wirelessInterfaceConnectionIface = new WirelessInterfaceConnectionInterface("org.kde.networkmanagement", dbusPath, QDBusConnection::sessionBus(), this);
- connect(d->wirelessInterfaceConnectionIface, SIGNAL(strengthChanged(int)), this, SIGNAL(strengthChanged(int)));
+ d->wirelessInterfaceConnectionIface = new WirelessInterfaceConnectionInterface("org.kde.networkmanagement", properties["path"].toString(), QDBusConnection::sessionBus(), this);
+ connect(d->wirelessInterfaceConnectionIface, SIGNAL(wicPropertiesChanged(QVariantMap)), SLOT(wicPropertiesChanged(QVariantMap)));
+ wicPropertiesChanged(properties);
}
RemoteWirelessInterfaceConnection::~RemoteWirelessInterfaceConnection()
@@ -34,51 +40,98 @@ RemoteWirelessInterfaceConnection::~RemoteWirelessInterfaceConnection()
}
+void RemoteWirelessInterfaceConnection::wicPropertiesChanged(const QVariantMap &changedProperties)
+{
+ Q_D(RemoteWirelessInterfaceConnection);
+ QStringList propKeys = changedProperties.keys();
+ QLatin1String ssidKey("ssid"),
+ signalStrengthKey("signalStrength"),
+ interfaceCapabilitiesKey("interfaceCapabilities"),
+ apCapabilitiesKey("apCapabilities"),
+ wpaFlagsKey("wpaFlags"),
+ rsnFlagsKey("rsnFlags"),
+ operationModeKey("operationMode");
+ QVariantMap::const_iterator it = changedProperties.find(ssidKey);
+ if (it != changedProperties.end()) {
+ d->ssid = it->toString();
+ propKeys.removeOne(ssidKey);
+ }
+ it = changedProperties.find(signalStrengthKey);
+ if (it != changedProperties.end()) {
+ d->signalStrength = it->toInt();
+ emit strengthChanged(d->signalStrength);
+ propKeys.removeOne(signalStrengthKey);
+ }
+ it = changedProperties.find(interfaceCapabilitiesKey);
+ if (it != changedProperties.end()) {
+ d->interfaceCapabilities = static_cast<Solid::Control::WirelessNetworkInterfaceNm09::Capabilities>(it->toUInt());
+ propKeys.removeOne(interfaceCapabilitiesKey);
+ }
+ it = changedProperties.find(apCapabilitiesKey);
+ if (it != changedProperties.end()) {
+ d->apCapabilities = static_cast<Solid::Control::AccessPointNm09::Capabilities>(it->toUInt());
+ propKeys.removeOne(apCapabilitiesKey);
+ }
+ it = changedProperties.find(wpaFlagsKey);
+ if (it != changedProperties.end()) {
+ d->wpaFlags = static_cast<Solid::Control::AccessPointNm09::WpaFlags>(it->toUInt());
+ propKeys.removeOne(wpaFlagsKey);
+ }
+ it = changedProperties.find(rsnFlagsKey);
+ if (it != changedProperties.end()) {
+ d->rsnFlags = static_cast<Solid::Control::AccessPointNm09::WpaFlags>(it->toUInt());
+ propKeys.removeOne(rsnFlagsKey);
+ }
+ it = changedProperties.find(operationModeKey);
+ if (it != changedProperties.end()) {
+ d->operationMode = static_cast<Solid::Control::WirelessNetworkInterfaceNm09::OperationMode>(it->toUInt());
+ propKeys.removeOne(operationModeKey);
+ }
+ if (propKeys.count()) {
+ kDebug() << "Unhandled properties: " << propKeys;
+ }
+}
+
QString RemoteWirelessInterfaceConnection::ssid() const
{
Q_D(const RemoteWirelessInterfaceConnection);
- return d->wirelessInterfaceConnectionIface->ssid();
+ return d->ssid;
}
int RemoteWirelessInterfaceConnection::strength() const
{
Q_D(const RemoteWirelessInterfaceConnection);
- return d->wirelessInterfaceConnectionIface->strength();
+ return d->signalStrength;
}
Solid::Control::WirelessNetworkInterfaceNm09::Capabilities RemoteWirelessInterfaceConnection::interfaceCapabilities() const
{
Q_D(const RemoteWirelessInterfaceConnection);
- uint caps = d->wirelessInterfaceConnectionIface->interfaceCapabilities();
- return (Solid::Control::WirelessNetworkInterfaceNm09::Capabilities)caps;
+ return d->interfaceCapabilities;
}
Solid::Control::AccessPointNm09::Capabilities RemoteWirelessInterfaceConnection::apCapabilities() const
{
Q_D(const RemoteWirelessInterfaceConnection);
- uint caps = d->wirelessInterfaceConnectionIface->apCapabilities();
- return (Solid::Control::AccessPointNm09::Capabilities)caps;
+ return d->apCapabilities;
}
Solid::Control::AccessPointNm09::WpaFlags RemoteWirelessInterfaceConnection::wpaFlags() const
{
Q_D(const RemoteWirelessInterfaceConnection);
- uint wpaflags = d->wirelessInterfaceConnectionIface->wpaFlags();
- return (Solid::Control::AccessPointNm09::WpaFlags)wpaflags;
+ return d->wpaFlags;
}
Solid::Control::AccessPointNm09::WpaFlags RemoteWirelessInterfaceConnection::rsnFlags() const
{
Q_D(const RemoteWirelessInterfaceConnection);
- uint rsnflags = d->wirelessInterfaceConnectionIface->rsnFlags();
- return (Solid::Control::AccessPointNm09::WpaFlags)rsnflags;
+ return d->rsnFlags;
}
Solid::Control::WirelessNetworkInterfaceNm09::OperationMode RemoteWirelessInterfaceConnection::operationMode() const
{
Q_D(const RemoteWirelessInterfaceConnection);
- uint rsnflags = d->wirelessInterfaceConnectionIface->operationMode();
- return (Solid::Control::WirelessNetworkInterfaceNm09::OperationMode)rsnflags;
+ return d->operationMode;
}
// vim: sw=4 sts=4 et tw=100
diff --git a/libs/client/remotewirelessinterfaceconnection.h b/libs/client/remotewirelessinterfaceconnection.h
index bbca576..38fae90 100644
--- a/libs/client/remotewirelessinterfaceconnection.h
+++ b/libs/client/remotewirelessinterfaceconnection.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -55,8 +56,10 @@ public:
Solid::Control::WirelessNetworkInterfaceNm09::OperationMode operationMode() const;
Q_SIGNALS:
void strengthChanged(int);
+protected Q_SLOTS:
+ void wicPropertiesChanged(const QVariantMap &properties);
protected:
- RemoteWirelessInterfaceConnection(const QString & dbusPath, QObject * parent);
+ RemoteWirelessInterfaceConnection(const QVariantMap & properties, QObject * parent);
Q_DECLARE_PRIVATE(RemoteWirelessInterfaceConnection)
};
diff --git a/libs/client/remotewirelessinterfaceconnection_p.h b/libs/client/remotewirelessinterfaceconnection_p.h
index 9a9b860..ddfa83c 100644
--- a/libs/client/remotewirelessinterfaceconnection_p.h
+++ b/libs/client/remotewirelessinterfaceconnection_p.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyrignt 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -24,10 +25,19 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "remoteinterfaceconnection_p.h"
#include "wirelessinterfaceconnectioninterface.h"
+#include "solid/control/wirelessnetworkinterface.h"
+
class RemoteWirelessInterfaceConnectionPrivate : public RemoteInterfaceConnectionPrivate
{
public:
WirelessInterfaceConnectionInterface * wirelessInterfaceConnectionIface;
+ QString ssid;
+ int signalStrength;
+ Solid::Control::WirelessNetworkInterfaceNm09::Capabilities interfaceCapabilities;
+ Solid::Control::AccessPointNm09::Capabilities apCapabilities;
+ Solid::Control::AccessPointNm09::WpaFlags wpaFlags;
+ Solid::Control::AccessPointNm09::WpaFlags rsnFlags;
+ Solid::Control::WirelessNetworkInterfaceNm09::OperationMode operationMode;
};
#endif // REMOTEWIRELESSINTERFACECONNECTION_P_H
diff --git a/libs/client/remotewirelessnetwork.cpp b/libs/client/remotewirelessnetwork.cpp
index abf128c..d1bba3c 100644
--- a/libs/client/remotewirelessnetwork.cpp
+++ b/libs/client/remotewirelessnetwork.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -21,12 +22,15 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "remotewirelessnetwork.h"
#include "remotewirelessnetwork_p.h"
-RemoteWirelessNetwork::RemoteWirelessNetwork(const QString & path, QObject * parent)
-: RemoteActivatable(*new RemoteWirelessNetworkPrivate, path, parent)
+#include <KDebug>
+
+RemoteWirelessNetwork::RemoteWirelessNetwork(const QVariantMap & properties, QObject * parent)
+: RemoteActivatable(*new RemoteWirelessNetworkPrivate, properties, parent)
{
Q_D(RemoteWirelessNetwork);
- d->wirelessNetworkItemInterface = new WirelessNetworkInterface("org.kde.networkmanagement", path, QDBusConnection::sessionBus(), this);
- connect(d->wirelessNetworkItemInterface, SIGNAL(strengthChanged(int)), this, SIGNAL(strengthChanged(int)));
+ d->wirelessNetworkItemInterface = new WirelessNetworkInterface("org.kde.networkmanagement", properties["path"].toString(), QDBusConnection::sessionBus(), this);
+ connect(d->wirelessNetworkItemInterface, SIGNAL(wnPropertiesChanged(QVariantMap)), SLOT(wnPropertiesChanged(QVariantMap)));
+ wnPropertiesChanged(properties);
}
RemoteWirelessNetwork::~RemoteWirelessNetwork()
@@ -34,54 +38,98 @@ RemoteWirelessNetwork::~RemoteWirelessNetwork()
}
+void RemoteWirelessNetwork::wnPropertiesChanged(const QVariantMap &changedProperties)
+{
+ Q_D(RemoteWirelessNetwork);
+ QStringList propKeys = changedProperties.keys();
+ QLatin1String ssidKey("ssid"),
+ signalStrengthKey("signalStrength"),
+ interfaceCapabilitiesKey("interfaceCapabilities"),
+ apCapabilitiesKey("apCapabilities"),
+ wpaFlagsKey("wpaFlags"),
+ rsnFlagsKey("rsnFlags"),
+ operationModeKey("operationMode");
+ QVariantMap::const_iterator it = changedProperties.find(ssidKey);
+ if (it != changedProperties.end()) {
+ d->ssid = it->toString();
+ propKeys.removeOne(ssidKey);
+ }
+ it = changedProperties.find(signalStrengthKey);
+ if (it != changedProperties.end()) {
+ d->signalStrength = it->toInt();
+ emit strengthChanged(d->signalStrength);
+ propKeys.removeOne(signalStrengthKey);
+ }
+ it = changedProperties.find(interfaceCapabilitiesKey);
+ if (it != changedProperties.end()) {
+ d->interfaceCapabilities = static_cast<Solid::Control::WirelessNetworkInterfaceNm09::Capabilities>(it->toUInt());
+ propKeys.removeOne(interfaceCapabilitiesKey);
+ }
+ it = changedProperties.find(apCapabilitiesKey);
+ if (it != changedProperties.end()) {
+ d->apCapabilities = static_cast<Solid::Control::AccessPointNm09::Capabilities>(it->toUInt());
+ propKeys.removeOne(apCapabilitiesKey);
+ }
+ it = changedProperties.find(wpaFlagsKey);
+ if (it != changedProperties.end()) {
+ d->wpaFlags = static_cast<Solid::Control::AccessPointNm09::WpaFlags>(it->toUInt());
+ propKeys.removeOne(wpaFlagsKey);
+ }
+ it = changedProperties.find(rsnFlagsKey);
+ if (it != changedProperties.end()) {
+ d->rsnFlags = static_cast<Solid::Control::AccessPointNm09::WpaFlags>(it->toUInt());
+ propKeys.removeOne(rsnFlagsKey);
+ }
+ it = changedProperties.find(operationModeKey);
+ if (it != changedProperties.end()) {
+ d->operationMode = static_cast<Solid::Control::WirelessNetworkInterfaceNm09::OperationMode>(it->toUInt());
+ propKeys.removeOne(operationModeKey);
+ }
+ if (propKeys.count()) {
+ kDebug() << "Unhandled properties: " << propKeys;
+ }
+}
+
QString RemoteWirelessNetwork::ssid() const
{
Q_D(const RemoteWirelessNetwork);
- return d->wirelessNetworkItemInterface->ssid();
+ return d->ssid;
}
int RemoteWirelessNetwork::strength() const
{
Q_D(const RemoteWirelessNetwork);
- return d->wirelessNetworkItemInterface->strength();
+ return d->signalStrength;
}
Solid::Control::WirelessNetworkInterfaceNm09::Capabilities RemoteWirelessNetwork::interfaceCapabilities() const
{
Q_D(const RemoteWirelessNetwork);
- uint wpaflags = d->wirelessNetworkItemInterface->interfaceCapabilities();
- return (Solid::Control::WirelessNetworkInterfaceNm09::Capabilities)wpaflags;
-
+ return d->interfaceCapabilities;
}
Solid::Control::AccessPointNm09::Capabilities RemoteWirelessNetwork::apCapabilities() const
{
Q_D(const RemoteWirelessNetwork);
- uint wpaflags = d->wirelessNetworkItemInterface->apCapabilities();
- return (Solid::Control::AccessPointNm09::Capabilities)wpaflags;
-
+ return d->apCapabilities;
}
Solid::Control::AccessPointNm09::WpaFlags RemoteWirelessNetwork::wpaFlags() const
{
Q_D(const RemoteWirelessNetwork);
- uint wpaflags = d->wirelessNetworkItemInterface->wpaFlags();
- return (Solid::Control::AccessPointNm09::WpaFlags)wpaflags;
-
+ return d->wpaFlags;
}
Solid::Control::AccessPointNm09::WpaFlags RemoteWirelessNetwork::rsnFlags() const
{
Q_D(const RemoteWirelessNetwork);
- uint rsnflags = d->wirelessNetworkItemInterface->rsnFlags();
- return (Solid::Control::AccessPointNm09::WpaFlags)rsnflags;
+ return d->rsnFlags;
}
Solid::Control::WirelessNetworkInterfaceNm09::OperationMode RemoteWirelessNetwork::operationMode() const
{
Q_D(const RemoteWirelessNetwork);
- uint rsnflags = d->wirelessNetworkItemInterface->operationMode();
- return (Solid::Control::WirelessNetworkInterfaceNm09::OperationMode)rsnflags;
+ return d->operationMode;
}
// vim: sw=4 sts=4 et tw=100
diff --git a/libs/client/remotewirelessnetwork.h b/libs/client/remotewirelessnetwork.h
index e109673..7b3260c 100644
--- a/libs/client/remotewirelessnetwork.h
+++ b/libs/client/remotewirelessnetwork.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -56,8 +57,10 @@ public:
Solid::Control::WirelessNetworkInterfaceNm09::OperationMode operationMode() const;
Q_SIGNALS:
void strengthChanged(int);
+protected Q_SLOTS:
+ void wnPropertiesChanged(const QVariantMap &properties);
protected:
- RemoteWirelessNetwork(const QString & path, QObject * parent);
+ RemoteWirelessNetwork(const QVariantMap & properties, QObject * parent);
Q_DECLARE_PRIVATE(RemoteWirelessNetwork)
};
diff --git a/libs/client/remotewirelessnetwork_p.h b/libs/client/remotewirelessnetwork_p.h
index 59a03c2..37cf25f 100644
--- a/libs/client/remotewirelessnetwork_p.h
+++ b/libs/client/remotewirelessnetwork_p.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyrignt 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -22,13 +23,21 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#define REMOTEWIRELESSNETWORKITEM_P_H
#include "remoteactivatable_p.h"
-
#include "wirelessnetworkinterface.h"
+#include "solid/control/wirelessnetworkinterface.h"
+
class RemoteWirelessNetworkPrivate : public RemoteActivatablePrivate
{
public:
WirelessNetworkInterface * wirelessNetworkItemInterface;
+ QString ssid;
+ int signalStrength;
+ Solid::Control::WirelessNetworkInterfaceNm09::Capabilities interfaceCapabilities;
+ Solid::Control::AccessPointNm09::Capabilities apCapabilities;
+ Solid::Control::AccessPointNm09::WpaFlags wpaFlags;
+ Solid::Control::AccessPointNm09::WpaFlags rsnFlags;
+ Solid::Control::WirelessNetworkInterfaceNm09::OperationMode operationMode;
};
#endif // REMOTEWIRELESSNETWORKITEM_P_H
diff --git a/libs/internals/activatable.cpp b/libs/internals/activatable.cpp
index 19538db..759de7c 100644
--- a/libs/internals/activatable.cpp
+++ b/libs/internals/activatable.cpp
@@ -1,6 +1,7 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -43,7 +44,13 @@ Activatable::ActivatableType Activatable::activatableType() const
void Activatable::setDeviceUni(const QString& deviceUni)
{
+ if (deviceUni == m_deviceUni) {
+ return;
+ }
m_deviceUni = deviceUni;
+ QVariantMap map;
+ map.insert("deviceUni", deviceUni);
+ emit propertiesChanged(map);
}
QString Activatable::deviceUni() const
@@ -58,7 +65,13 @@ bool Activatable::isShared() const
void Activatable::setShared(const bool shared)
{
+ if (shared == m_shared) {
+ return;
+ }
m_shared = shared;
+ QVariantMap map;
+ map.insert("shared", m_shared);
+ emit propertiesChanged(map);
}
void Activatable::activate()
@@ -67,3 +80,11 @@ void Activatable::activate()
emit activated();
}
+QVariantMap Activatable::toMap()
+{
+ QVariantMap map;
+ map.insert("activatableType", m_type);
+ map.insert("deviceUni", m_deviceUni);
+ map.insert("shared", m_shared);
+ return map;
+}
diff --git a/libs/internals/activatable.h b/libs/internals/activatable.h
index c8a795b..b084a41 100644
--- a/libs/internals/activatable.h
+++ b/libs/internals/activatable.h
@@ -1,6 +1,7 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -26,6 +27,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QtCore/QObject>
#include <QMetaType>
+#include <QVariantMap>
namespace Knm {
@@ -56,11 +58,13 @@ public:
QString deviceUni() const;
bool isShared() const;
void setShared(const bool);
+ virtual QVariantMap toMap();
public Q_SLOTS:
void activate();
Q_SIGNALS:
void activated();
void changed();
+ void propertiesChanged(const QVariantMap & properties);
protected:
Activatable(ActivatableType type, const QString &deviceUni, QObject * parent);
diff --git a/libs/internals/gsminterfaceconnection.cpp b/libs/internals/gsminterfaceconnection.cpp
index 42ac3cb..6df3a89 100644
--- a/libs/internals/gsminterfaceconnection.cpp
+++ b/libs/internals/gsminterfaceconnection.cpp
@@ -1,7 +1,7 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
-Copyright 2010-2011 Lamarque Souza <lamarque@gmail.com>
+Copyright 2010-2012 Lamarque Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -74,21 +74,29 @@ void GsmInterfaceConnection::connectMMSignals()
void GsmInterfaceConnection::setSignalQuality(uint signalQuality)
{
- if ((int)signalQuality != m_signalQuality) {
- m_signalQuality = (int)signalQuality;
- emit signalQualityChanged(m_signalQuality);
+ if ((int)signalQuality == m_signalQuality) {
+ return;
}
+ m_signalQuality = (int)signalQuality;
+ emit signalQualityChanged(m_signalQuality);
+ QVariantMap map;
+ map.insert("signalQuality", m_signalQuality);
+ emit gsmPropertiesChanged(map);
}
void GsmInterfaceConnection::setAccessTechnology(const Solid::Control::ModemInterface::AccessTechnology accessTechnology)
{
- int temp =accessTechnology;
+ int temp = accessTechnology;
- if (temp != m_accessTechnology) {
- setSignalQuality(0);
- m_accessTechnology = temp;
- emit accessTechnologyChanged(m_accessTechnology);
+ if (temp == m_accessTechnology) {
+ return;
}
+ setSignalQuality(0);
+ m_accessTechnology = temp;
+ emit accessTechnologyChanged(m_accessTechnology);
+ QVariantMap map;
+ map.insert("accessTechnology", m_accessTechnology);
+ emit gsmPropertiesChanged(map);
}
int GsmInterfaceConnection::getSignalQuality() const
@@ -103,10 +111,26 @@ int GsmInterfaceConnection::getAccessTechnology() const
void GsmInterfaceConnection::setEnabled(const bool enabled)
{
+ if (enabled == m_enabled) {
+ return;
+ }
m_enabled = enabled;
emit enabledChanged(m_enabled);
+ QVariantMap map;
+ map.insert("enabled", m_enabled);
+ emit gsmPropertiesChanged(map);
if (!enabled) {
setSignalQuality(0);
}
}
+
+
+QVariantMap GsmInterfaceConnection::toMap()
+{
+ QVariantMap map = InterfaceConnection::toMap();
+ map.insert("signalQuality", m_signalQuality);
+ map.insert("accessTechnology", m_accessTechnology);
+ map.insert("enabled", m_enabled);
+ return map;
+}
diff --git a/libs/internals/gsminterfaceconnection.h b/libs/internals/gsminterfaceconnection.h
index c7e171e..f4d0052 100644
--- a/libs/internals/gsminterfaceconnection.h
+++ b/libs/internals/gsminterfaceconnection.h
@@ -1,7 +1,7 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
-Copyright 2010-2011 Lamarque Souza <lamarque@gmail.com>
+Copyright 2010-2012 Lamarque Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -45,10 +45,12 @@ public:
virtual ~GsmInterfaceConnection();
int getSignalQuality() const;
int getAccessTechnology() const;
+ QVariantMap toMap();
Q_SIGNALS:
void signalQualityChanged(int);
void accessTechnologyChanged(const int);
void enabledChanged(const bool enabled);
+ void gsmPropertiesChanged(const QVariantMap & properties);
public Q_SLOTS:
void setSignalQuality(uint signalQuality);
void setAccessTechnology(const Solid::Control::ModemInterface::AccessTechnology accessTechnology);
diff --git a/libs/internals/interfaceconnection.cpp b/libs/internals/interfaceconnection.cpp
index 2fc3865..ad9cd26 100644
--- a/libs/internals/interfaceconnection.cpp
+++ b/libs/internals/interfaceconnection.cpp
@@ -1,6 +1,7 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -51,10 +52,14 @@ QUuid InterfaceConnection::connectionUuid() const
void InterfaceConnection::setConnectionName(const QString& name)
{
- if (name != m_name) {
- m_name = name;
- emit changed();
+ if (name == m_name) {
+ return;
}
+ m_name = name;
+ emit changed();
+ QVariantMap map;
+ map.insert("name", m_name);
+ emit icPropertiesChanged(map);
}
QString InterfaceConnection::connectionName() const
@@ -64,10 +69,14 @@ QString InterfaceConnection::connectionName() const
void InterfaceConnection::setIconName(const QString & iconName)
{
- if (iconName != m_iconName) {
- m_iconName = iconName;
- emit changed();
+ if (iconName == m_iconName) {
+ return;
}
+ m_iconName = iconName;
+ emit changed();
+ QVariantMap map;
+ map.insert("iconName", m_iconName);
+ emit icPropertiesChanged(map);
}
QString InterfaceConnection::iconName() const
@@ -77,13 +86,17 @@ QString InterfaceConnection::iconName() const
void InterfaceConnection::setActivationState(InterfaceConnection::ActivationState state)
{
- if (m_state != state) {
- m_oldState = m_state;
- m_state = state;
- emit changed();
- emit activationStateChanged(m_oldState, m_state);
- emit activationStateChanged((uint)m_oldState, (uint)m_state);
+ if (m_state == state) {
+ return;
}
+ m_oldState = m_state;
+ m_state = state;
+ emit changed();
+ emit activationStateChanged(m_oldState, m_state);
+ emit activationStateChanged((uint)m_oldState, (uint)m_state);
+ QVariantMap map;
+ map.insert("activationState", m_state);
+ emit icPropertiesChanged(map);
}
InterfaceConnection::ActivationState InterfaceConnection::activationState() const
@@ -98,10 +111,14 @@ InterfaceConnection::ActivationState InterfaceConnection::oldActivationState() c
void InterfaceConnection::setHasDefaultRoute(bool hasDefault)
{
- if (m_hasDefaultRoute != hasDefault) {
- m_hasDefaultRoute = hasDefault;
- emit hasDefaultRouteChanged(m_hasDefaultRoute);
+ if (m_hasDefaultRoute == hasDefault) {
+ return;
}
+ m_hasDefaultRoute = hasDefault;
+ emit hasDefaultRouteChanged(m_hasDefaultRoute);
+ QVariantMap map;
+ map.insert("hasDefaultRoute", m_hasDefaultRoute);
+ emit icPropertiesChanged(map);
}
bool InterfaceConnection::hasDefaultRoute() const
@@ -113,3 +130,15 @@ void InterfaceConnection::deactivate()
{
emit deactivated();
}
+
+QVariantMap InterfaceConnection::toMap()
+{
+ QVariantMap map = Activatable::toMap();
+ map.insert("connectionType", m_type);
+ map.insert("uuid", m_uuid.toString());
+ map.insert("name", m_name);
+ map.insert("iconName", m_iconName);
+ map.insert("activationState", m_state);
+ map.insert("hasDefaultRoute", m_hasDefaultRoute);
+ return map;
+}
diff --git a/libs/internals/interfaceconnection.h b/libs/internals/interfaceconnection.h
index 84bffb6..2909feb 100644
--- a/libs/internals/interfaceconnection.h
+++ b/libs/internals/interfaceconnection.h
@@ -1,6 +1,7 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -76,6 +77,7 @@ public:
void setHasDefaultRoute(bool hasDefault);
bool hasDefaultRoute() const;
void deactivate();
+ QVariantMap toMap();
Q_SIGNALS:
void activationStateChanged(Knm::InterfaceConnection::ActivationState oldState, Knm::InterfaceConnection::ActivationState newState);
@@ -83,6 +85,7 @@ Q_SIGNALS:
void activationStateChanged(uint, uint);
void hasDefaultRouteChanged(bool);
void deactivated();
+ void icPropertiesChanged(const QVariantMap & properties);
protected:
InterfaceConnection(ActivatableType type, const QString & deviceUni, QObject * parent);
diff --git a/libs/internals/wirelessinterfaceconnection.cpp b/libs/internals/wirelessinterfaceconnection.cpp
index 1b793a4..8f1b38b 100644
--- a/libs/internals/wirelessinterfaceconnection.cpp
+++ b/libs/internals/wirelessinterfaceconnection.cpp
@@ -1,6 +1,7 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -34,8 +35,25 @@ WirelessInterfaceConnection::~WirelessInterfaceConnection()
void WirelessInterfaceConnection::setStrength(int strength)
{
- if (strength != m_strength) {
- WirelessObject::setStrength(strength);
- emit strengthChanged(strength);
+ if (strength == m_strength) {
+ return;
}
+ WirelessObject::setStrength(strength);
+ emit strengthChanged(strength);
+ QVariantMap map;
+ map.insert("signalStrength", m_strength);
+ emit wicPropertiesChanged(map);
+}
+
+QVariantMap WirelessInterfaceConnection::toMap()
+{
+ QVariantMap map = InterfaceConnection::toMap();
+ map.insert("ssid", m_ssid);
+ map.insert("signalStrength", m_strength);
+ map.insert("interfaceCapabilities", (uint)m_interfaceCapabilities);
+ map.insert("apCapabilities", (uint)m_apCapabilities);
+ map.insert("wpaFlags", (uint)m_wpaFlags);
+ map.insert("rsnFlags", (uint)m_rsnFlags);
+ map.insert("operationMode", (uint)m_operationMode);
+ return map;
}
diff --git a/libs/internals/wirelessinterfaceconnection.h b/libs/internals/wirelessinterfaceconnection.h
index 1318bd4..c809786 100644
--- a/libs/internals/wirelessinterfaceconnection.h
+++ b/libs/internals/wirelessinterfaceconnection.h
@@ -1,6 +1,7 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -43,8 +44,10 @@ public:
// To create an object of WirelessInterfaceConnection class please use
// Knm::WirelessInterfaceConnectionHelpers::build(..) function.
virtual ~WirelessInterfaceConnection();
+ QVariantMap toMap();
signals:
void strengthChanged(int);
+ void wicPropertiesChanged(const QVariantMap & properties);
public Q_SLOTS:
void setStrength(int);
diff --git a/libs/internals/wirelessnetwork.cpp b/libs/internals/wirelessnetwork.cpp
index 693cf67..a7f5196 100644
--- a/libs/internals/wirelessnetwork.cpp
+++ b/libs/internals/wirelessnetwork.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -34,8 +35,25 @@ WirelessNetwork::~WirelessNetwork()
void WirelessNetwork::setStrength(int strength)
{
- if (strength != m_strength) {
- WirelessObject::setStrength(strength);
- emit strengthChanged(strength);
+ if (strength == m_strength) {
+ return;
}
+ WirelessObject::setStrength(strength);
+ emit strengthChanged(strength);
+ QVariantMap map;
+ map.insert("signalStrength", m_strength);
+ emit wnPropertiesChanged(map);
+}
+
+QVariantMap WirelessNetwork::toMap()
+{
+ QVariantMap map = Activatable::toMap();
+ map.insert("ssid", m_ssid);
+ map.insert("signalStrength", m_strength);
+ map.insert("interfaceCapabilities", (uint)m_interfaceCapabilities);
+ map.insert("apCapabilities", (uint)m_apCapabilities);
+ map.insert("wpaFlags", (uint)m_wpaFlags);
+ map.insert("rsnFlags", (uint)m_rsnFlags);
+ map.insert("operationMode", (uint)m_operationMode);
+ return map;
}
diff --git a/libs/internals/wirelessnetwork.h b/libs/internals/wirelessnetwork.h
index e68005e..e910046 100644
--- a/libs/internals/wirelessnetwork.h
+++ b/libs/internals/wirelessnetwork.h
@@ -1,5 +1,6 @@
/*
Copyright 2008 Frederik Gladhorn <gladhorn@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -41,8 +42,10 @@ Q_PROPERTY(uint rsnFlags READ rsnFlags)
public:
WirelessNetwork(const QString & ssid, int strength, Solid::Control::WirelessNetworkInterfaceNm09::Capabilities interfaceCapabilities, Solid::Control::AccessPointNm09::Capabilities apCapabilities, Solid::Control::AccessPointNm09::WpaFlags wpaFlags, Solid::Control::AccessPointNm09::WpaFlags rsnFlags, Solid::Control::WirelessNetworkInterfaceNm09::OperationMode mode, const QString & deviceUni, QObject * parent);
virtual ~WirelessNetwork();
+ QVariantMap toMap();
signals:
void strengthChanged(int);
+ void wnPropertiesChanged(const QVariantMap & properties);
public Q_SLOTS:
void setStrength(int);
};
diff --git a/libs/service/interfaces/org.kde.networkmanagement.activatable.xml b/libs/service/interfaces/org.kde.networkmanagement.activatable.xml
index fe2665c..a1457bc 100644
--- a/libs/service/interfaces/org.kde.networkmanagement.activatable.xml
+++ b/libs/service/interfaces/org.kde.networkmanagement.activatable.xml
@@ -16,5 +16,13 @@
<signal name="changed"/>
<property name="deviceUni" type="s" access="read"/>
<property name="type" type="u" access="read"/>
+ <signal name="propertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
</interface>
</node>
diff --git a/libs/service/interfaces/org.kde.networkmanagement.gsminterfaceconnection.xml b/libs/service/interfaces/org.kde.networkmanagement.gsminterfaceconnection.xml
index 07109a1..751cc48 100644
--- a/libs/service/interfaces/org.kde.networkmanagement.gsminterfaceconnection.xml
+++ b/libs/service/interfaces/org.kde.networkmanagement.gsminterfaceconnection.xml
@@ -16,5 +16,13 @@
<signal name="signalQualityChanged">
<arg name="quality" type="i" direction="out"/>
</signal>
+ <signal name="gsmPropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
</interface>
</node>
diff --git a/libs/service/interfaces/org.kde.networkmanagement.interfaceconnection.xml b/libs/service/interfaces/org.kde.networkmanagement.interfaceconnection.xml
index a67a5c7..2cfb7e3 100644
--- a/libs/service/interfaces/org.kde.networkmanagement.interfaceconnection.xml
+++ b/libs/service/interfaces/org.kde.networkmanagement.interfaceconnection.xml
@@ -34,5 +34,13 @@
<property name="iconName" type="s" access="read"/>
<property name="activationState" type="u" access="read"/>
<property name="hasDefaultRoute" type="b" access="read"/>
+ <signal name="icPropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
</interface>
</node>
diff --git a/libs/service/interfaces/org.kde.networkmanagement.wirelessinterfaceconnection.xml b/libs/service/interfaces/org.kde.networkmanagement.wirelessinterfaceconnection.xml
index cac2d8f..62d9f5f 100644
--- a/libs/service/interfaces/org.kde.networkmanagement.wirelessinterfaceconnection.xml
+++ b/libs/service/interfaces/org.kde.networkmanagement.wirelessinterfaceconnection.xml
@@ -33,5 +33,13 @@
<signal name="strengthChanged">
<arg name="strength" type="i" direction="out"/>
</signal>
+ <signal name="wicPropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
</interface>
</node>
diff --git a/libs/service/interfaces/org.kde.networkmanagement.wirelessnetwork.xml b/libs/service/interfaces/org.kde.networkmanagement.wirelessnetwork.xml
index af90776..2a8a7eb 100644
--- a/libs/service/interfaces/org.kde.networkmanagement.wirelessnetwork.xml
+++ b/libs/service/interfaces/org.kde.networkmanagement.wirelessnetwork.xml
@@ -33,5 +33,13 @@
<signal name="strengthChanged">
<arg name="strength" type="i" direction="out"/>
</signal>
+ <signal name="wnPropertiesChanged">
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
+ </signal>
</interface>
</node>
diff --git a/libs/service/interfaces/org.kde.networkmanagement.xml b/libs/service/interfaces/org.kde.networkmanagement.xml
index 2bc8685..bcef053 100644
--- a/libs/service/interfaces/org.kde.networkmanagement.xml
+++ b/libs/service/interfaces/org.kde.networkmanagement.xml
@@ -7,15 +7,20 @@
</method>
<method name="ReadConfig" />
<method name="FinishInitialization" />
+ <method name="ReEmitActivatableList" />
<signal name="ActivatableAdded">
- <arg name="added" type="s" direction="out" />
- <arg name="type" type="u" direction="out" />
- <arg name="index" type="i" direction="out" />
+ <arg name="properties" type="a{sv}" tp:type="String_Variant_Map">
+ <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+ <tp:docstring>
+ A dictionary mapping property names to variant boxed values
+ </tp:docstring>
+ </arg>
</signal>
<signal name="ActivatableRemoved">
- <arg name="removed" type="s" direction="out" />
+ <arg name="removed" type="s" direction="out" />
</signal>
<signal name="ReloadConfig" />
+ <signal name="ModuleReady" />
</interface>
</node>
diff --git a/libs/service/sessionabstractedservice.cpp b/libs/service/sessionabstractedservice.cpp
index 928467b..75fb769 100644
--- a/libs/service/sessionabstractedservice.cpp
+++ b/libs/service/sessionabstractedservice.cpp
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -62,11 +63,13 @@ void SessionAbstractedService::handleAdd(Knm::Activatable * added)
{
Q_D(SessionAbstractedService);
if (added) {
+ QVariantMap properties;
if (added->activatableType() == Knm::Activatable::InterfaceConnection
|| added->activatableType() == Knm::Activatable::VpnInterfaceConnection) {
Knm::InterfaceConnection * realObj = static_cast<Knm::InterfaceConnection*>(added);
new InterfaceConnectionAdaptor(realObj);
new ActivatableAdaptor(realObj);
+ properties = realObj->toMap();
} else if (added->activatableType() == Knm::Activatable::WirelessInterfaceConnection
|| added->activatableType() == Knm::Activatable::HiddenWirelessInterfaceConnection ) {
Knm::WirelessInterfaceConnection * realObj
@@ -74,16 +77,19 @@ void SessionAbstractedService::handleAdd(Knm::Activatable * added)
new WirelessInterfaceConnectionAdaptor(realObj);
new InterfaceConnectionAdaptor(realObj);
new ActivatableAdaptor(realObj);
+ properties = realObj->toMap();
} else if (added->activatableType() == Knm::Activatable::WirelessNetwork) {
Knm::WirelessNetwork * realObj
= static_cast<Knm::WirelessNetwork*>(added);
new WirelessNetworkAdaptor(realObj);
new ActivatableAdaptor(realObj);
+ properties = realObj->toMap();
} else if (added->activatableType() == Knm::Activatable::GsmInterfaceConnection) {
Knm::GsmInterfaceConnection * realObj = static_cast<Knm::GsmInterfaceConnection*>(added);
new GsmInterfaceConnectionAdaptor(realObj);
new InterfaceConnectionAdaptor(realObj);
new ActivatableAdaptor(realObj);
+ properties = realObj->toMap();
} else {
// do not put any other types on the bus
return;
@@ -93,7 +99,9 @@ void SessionAbstractedService::handleAdd(Knm::Activatable * added)
d->adaptors.insert(added, path);
QDBusConnection::sessionBus().registerObject(path, added);
//kDebug() << "registering object at " << path;
- emit ActivatableAdded(path, added->activatableType(), d->list->activatableIndex(added));
+ properties.insert("path", path);
+ properties.insert("activatableIndex", d->list->activatableIndex(added));
+ emit ActivatableAdded(properties);
}
}
@@ -134,6 +142,19 @@ QStringList SessionAbstractedService::ListActivatables() const
return sortedPaths;
}
+void SessionAbstractedService::ReEmitActivatableList()
+{
+ Q_D(const SessionAbstractedService);
+ foreach (Knm::Activatable * a, d->list->activatables()) {
+ if (d->adaptors.contains(a)) {
+ QVariantMap properties = a->toMap();
+ properties.insert("path", d->adaptors[a]);
+ properties.insert("activatableIndex", d->list->activatableIndex(a));
+ emit ActivatableAdded(properties);
+ }
+ }
+}
+
void SessionAbstractedService::ReadConfig()
{
emit ReloadConfig();
diff --git a/libs/service/sessionabstractedservice.h b/libs/service/sessionabstractedservice.h
index faba473..9ed6fd5 100644
--- a/libs/service/sessionabstractedservice.h
+++ b/libs/service/sessionabstractedservice.h
@@ -1,5 +1,6 @@
/*
Copyright 2009 Will Stephenson <wstephenson@kde.org>
+Copyright 2012 Lamarque V. Souza <lamarque@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -54,10 +55,12 @@ public slots:
Q_SCRIPTABLE QStringList ListActivatables() const;
Q_SCRIPTABLE void ReadConfig();
Q_SCRIPTABLE void FinishInitialization();
+ Q_SCRIPTABLE void ReEmitActivatableList();
signals:
- Q_SCRIPTABLE void ActivatableAdded(const QString & path, uint type, int index);
+ Q_SCRIPTABLE void ActivatableAdded(const QVariantMap & properties);
Q_SCRIPTABLE void ActivatableRemoved(const QString &);
Q_SCRIPTABLE void ReloadConfig();
+ Q_SCRIPTABLE void ModuleReady();
void DoFinishInitialization();
private:
Q_DECLARE_PRIVATE(SessionAbstractedService)
diff --git a/plasma_nm_version.h b/plasma_nm_version.h
index 891ad6a..2aa3623 100644
--- a/plasma_nm_version.h
+++ b/plasma_nm_version.h
@@ -1,4 +1,4 @@
#ifndef PLASMA_NM_VERSION_H
#define PLASMA_NM_VERSION_H
-static const char * plasmaNmVersion = "0.9.0_rc4 (nm09 20120121)";
+static const char * plasmaNmVersion = "0.9.0_rc4 (nm09 20120126)";
#endif