diff options
author | Lorn Potter <lorn.potter@jollamobile.com> | 2013-10-10 11:56:02 +1000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-11 03:30:44 +0100 |
commit | c28763d83c493a11da90295ec4bde016c53c0d70 (patch) | |
tree | fad7108a993726ef08060f6cf3208e6d7a5f7352 | |
parent | 67cf8bf9a8e6e583e9da02b153e8fdbe558637cb (diff) | |
download | qtbase-c28763d83c493a11da90295ec4bde016c53c0d70.tar.gz qtbase-c28763d83c493a11da90295ec4bde016c53c0d70.tar.bz2 qtbase-c28763d83c493a11da90295ec4bde016c53c0d70.zip |
update the network configuration list
when changes in the networks happen.
Task-number: QTBUG-34021
Change-Id: I2bd187e7d04d6876294f18d917c9a384afe5db35
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
-rw-r--r-- | src/plugins/bearer/connman/qconnmanengine.cpp | 22 | ||||
-rw-r--r-- | src/plugins/bearer/connman/qconnmanengine.h | 1 | ||||
-rw-r--r-- | src/plugins/bearer/connman/qconnmanservice_linux.cpp | 16 | ||||
-rw-r--r-- | src/plugins/bearer/connman/qconnmanservice_linux_p.h | 5 |
4 files changed, 44 insertions, 0 deletions
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<ConnmanMap>(); + qDBusRegisterMetaType<ConnmanMapList>(); + qRegisterMetaType<ConnmanMapList>("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<QDBusObjectPath>)), + this, SLOT(updateServices(ConnmanMapList, QList<QDBusObjectPath>))); + 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<QDBusObjectPath> &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<QDBusObjectPath> &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<QDBusObjectPath>)))) { + qWarning() << "servicesChanged not connected"; + } + } } +void QConnmanManagerInterface::onServicesChanged(const ConnmanMapList &changed, const QList<QDBusObjectPath> &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<QDBusObjectPath> &); protected: void connectNotify(const QMetaMethod &signal); void disconnectNotify(const QMetaMethod &signal); QVariant getProperty(const QString &); + +private slots: + void onServicesChanged(const ConnmanMapList&, const QList<QDBusObjectPath> &); + }; class QConnmanProfileInterfacePrivate; |