Commit 544a5272 authored by Lamarque Souza's avatar Lamarque Souza
Browse files

Use asynchronous DBus API in plasmoid and kded module communication.

CCBUG: 287002
CCBUG: 282022
CCBUG: 286424
parent edc95686
......@@ -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;
}
......
/*
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);
}
/*
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;
};
......
/*
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()
......
/*
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
/*
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
/*
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;
}
......
/*
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:
......
......@@ -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
......@@ -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)
};
......
......@@ -29,6 +29,8 @@ class RemoteGsmInterfaceConnectionPrivate : public RemoteInterfaceConnectionPriv
{
public:
GsmInterfaceConnectionInterface * gsmInterfaceConnectionIface;
int signalQuality;
int accessTechnology;
};
#endif // REMOTEGSMINTERFACECONNECTION_P_H
/*
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()) {