From c28763d83c493a11da90295ec4bde016c53c0d70 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Thu, 10 Oct 2013 11:56:02 +1000 Subject: update the network configuration list when changes in the networks happen. Task-number: QTBUG-34021 Change-Id: I2bd187e7d04d6876294f18d917c9a384afe5db35 Reviewed-by: Robin Burchell --- src/plugins/bearer/connman/qconnmanengine.cpp | 22 ++++++++++++++++++++++ src/plugins/bearer/connman/qconnmanengine.h | 1 + .../bearer/connman/qconnmanservice_linux.cpp | 16 ++++++++++++++++ .../bearer/connman/qconnmanservice_linux_p.h | 5 +++++ 4 files changed, 44 insertions(+) diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index 6ea34b17f5..be50ba9935 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -65,6 +65,9 @@ QConnmanEngine::QConnmanEngine(QObject *parent) : QBearerEngineImpl(parent), connmanManager(new QConnmanManagerInterface(this)) { + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qRegisterMetaType("ConnmanMapList"); } QConnmanEngine::~QConnmanEngine() @@ -82,6 +85,9 @@ void QConnmanEngine::initialize() connect(connmanManager,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SLOT(propertyChangedContext(QString,QString,QDBusVariant))); + connect(connmanManager,SIGNAL(servicesChanged(ConnmanMapList, QList)), + this, SLOT(updateServices(ConnmanMapList, QList))); + foreach (const QString &techPath, connmanManager->getTechnologies()) { QConnmanTechnologyInterface *tech; tech = new QConnmanTechnologyInterface(techPath, this); @@ -172,6 +178,22 @@ void QConnmanEngine::requestUpdate() QTimer::singleShot(0, this, SLOT(doRequestUpdate())); } +void QConnmanEngine::updateServices(const ConnmanMapList &changed, const QList &removed) +{ + foreach (const QDBusObjectPath &objectPath, removed) { + removeConfiguration(QString::number(qHash(objectPath.path()))); + } + + foreach (const ConnmanMap &connmanMap, changed) { + const QString id = QString::number(qHash(connmanMap.objectPath.path())); + if (accessPointConfigurations.contains(id)) { + configurationChange(id); + } else { + addServiceConfiguration(connmanMap.objectPath.path()); + } + } +} + QString QConnmanEngine::serviceFromId(const QString &id) { QMutexLocker locker(&mutex); diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h index 9b6a271011..c2a820997e 100644 --- a/src/plugins/bearer/connman/qconnmanengine.h +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -105,6 +105,7 @@ private Q_SLOTS: void servicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &); void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); void technologyPropertyChangedContext(const QString &,const QString &, const QDBusVariant &); + void updateServices(const ConnmanMapList &changed, const QList &removed); private: QConnmanManagerInterface *connmanManager; diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp index 380cf92a24..6d9ee265c6 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -127,8 +127,24 @@ void QConnmanManagerInterface::connectNotify(const QMetaMethod &signal) QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection); } + static const QMetaMethod servicesChangedSignal = QMetaMethod::fromSignal(&QConnmanManagerInterface::servicesChanged); + if (signal == servicesChangedSignal) { + if (!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("ServicesChanged"), + this,SLOT(onServicesChanged(ConnmanMapList, QList)))) { + qWarning() << "servicesChanged not connected"; + } + } } +void QConnmanManagerInterface::onServicesChanged(const ConnmanMapList &changed, const QList &removed) +{ + emit servicesChanged(changed, removed); +} + + void QConnmanManagerInterface::disconnectNotify(const QMetaMethod &signal) { static const QMetaMethod propertyChangedSignal = QMetaMethod::fromSignal(&QConnmanManagerInterface::propertyChanged); diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h index a437c6609c..dd3f847cfd 100644 --- a/src/plugins/bearer/connman/qconnmanservice_linux_p.h +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -155,11 +155,16 @@ Q_SIGNALS: void propertyChanged(const QString &, const QDBusVariant &value); void stateChanged(const QString &); void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void servicesChanged(const ConnmanMapList&, const QList &); protected: void connectNotify(const QMetaMethod &signal); void disconnectNotify(const QMetaMethod &signal); QVariant getProperty(const QString &); + +private slots: + void onServicesChanged(const ConnmanMapList&, const QList &); + }; class QConnmanProfileInterfacePrivate; -- cgit v1.2.3