summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2010-10-29 00:13:28 (GMT)
committerLorn Potter <lorn.potter@nokia.com>2010-10-29 00:13:28 (GMT)
commit9129a27f733169c9a4baf46b1be1c749dabdfdd8 (patch)
tree2b7c522eede960a5b626a1ff587165fbf153f9ad /src/plugins/bearer
parent746f4b50e9c13c720162f3bcc8795b7ef772fbba (diff)
downloadQt-9129a27f733169c9a4baf46b1be1c749dabdfdd8.zip
Qt-9129a27f733169c9a4baf46b1be1c749dabdfdd8.tar.gz
Qt-9129a27f733169c9a4baf46b1be1c749dabdfdd8.tar.bz2
remove the connecting thread, and use async call to dbus instead.
This fixes the case where the connection threads are never stopped until desctuctor. Task-number: QTBUG-14836 Reviewed-by: trust me
Diffstat (limited to 'src/plugins/bearer')
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.cpp83
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.h27
-rw-r--r--src/plugins/bearer/connman/qconnmanservice_linux.cpp21
-rw-r--r--src/plugins/bearer/connman/qofonoservice_linux.cpp12
4 files changed, 36 insertions, 107 deletions
diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp
index a8b8911..184ceb4 100644
--- a/src/plugins/bearer/connman/qconnmanengine.cpp
+++ b/src/plugins/bearer/connman/qconnmanengine.cpp
@@ -170,13 +170,26 @@ bool QConnmanEngine::hasIdentifier(const QString &id)
void QConnmanEngine::connectToId(const QString &id)
{
QMutexLocker locker(&mutex);
- QConnmanConnectThread *thread;
- thread = new QConnmanConnectThread(this);
- thread->setServicePath(serviceFromId(id));
- thread->setIdentifier(id);
- connect(thread,SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
- this,SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)));
- thread->start();
+ QString servicePath = serviceFromId(id);
+ QConnmanServiceInterface serv(servicePath);
+ if(!serv.isValid()) {
+ emit connectionError(id, QBearerEngineImpl::InterfaceLookupError);
+ } else {
+ if(serv.getType() != "cellular") {
+
+ serv.connect();
+ } else {
+ QOfonoManagerInterface ofonoManager(0);
+ QString modemPath = ofonoManager.currentModem().path();
+ QOfonoDataConnectionManagerInterface dc(modemPath,0);
+ foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
+ if(dcPath.path().contains(servicePath.section("_",-1))) {
+ QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0);
+ primaryContext.setActive(true);
+ }
+ }
+ }
+ }
}
void QConnmanEngine::disconnectFromId(const QString &id)
@@ -791,62 +804,6 @@ bool QConnmanEngine::requiresPolling() const
return false;
}
-
-QConnmanConnectThread::QConnmanConnectThread(QObject *parent)
- :QThread(parent),
- servicePath(), identifier()
-{
-}
-
-QConnmanConnectThread::~QConnmanConnectThread()
-{
-}
-
-void QConnmanConnectThread::stop()
-{
- if(currentThread() != this) {
- QMetaObject::invokeMethod(this, "quit",
- Qt::QueuedConnection);
- } else {
- quit();
- }
- wait();
-}
-
-void QConnmanConnectThread::run()
-{
- QConnmanServiceInterface serv(servicePath);
- if(!serv.isValid()) {
- emit connectionError(identifier, QBearerEngineImpl::InterfaceLookupError);
- } else {
- if(serv.getType() != "cellular") {
- serv.connect();
- } else {
- QOfonoManagerInterface ofonoManager(0);
- QString modemPath = ofonoManager.currentModem().path();
- QOfonoDataConnectionManagerInterface dc(modemPath,0);
- foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
- if(dcPath.path().contains(servicePath.section("_",-1))) {
- QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0);
- primaryContext.setActive(true);
- }
- }
- }
- }
-}
-
-void QConnmanConnectThread::setServicePath(const QString &path)
-{
- QMutexLocker locker(&mutex);
- servicePath = path;
-}
-
-void QConnmanConnectThread::setIdentifier(const QString &id)
-{
- QMutexLocker locker(&mutex);
- identifier = id;
-}
-
QT_END_NAMESPACE
#endif // QT_NO_DBUS
diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h
index 569bbc7..2a2308f 100644
--- a/src/plugins/bearer/connman/qconnmanengine.h
+++ b/src/plugins/bearer/connman/qconnmanengine.h
@@ -59,14 +59,12 @@
#include <QMap>
#include <QVariant>
-#include <QtCore/qthread.h>
#ifndef QT_NO_BEARERMANAGEMENT
#ifndef QT_NO_DBUS
QT_BEGIN_NAMESPACE
-class QConnmanConnectThread;
class QConnmanEngine : public QBearerEngineImpl
{
Q_OBJECT
@@ -141,33 +139,8 @@ private:
bool isRoamingAllowed(const QString &context);
protected:
bool requiresPolling() const;
- QConnmanConnectThread *connThread;
};
-class QConnmanConnectThread : public QThread
-{
- Q_OBJECT
-
-public:
- QConnmanConnectThread(QObject *parent = 0);
- ~QConnmanConnectThread();
- bool keepRunning;
- void stop();
- void setServicePath(const QString &path);
- void setIdentifier(const QString &id);
-
-Q_SIGNALS:
- void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error);
-
-protected:
- void run();
- QString servicePath;
- QString identifier;
-
-private:
- QMutex mutex;
-
-};
QT_END_NAMESPACE
diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
index 549a07a..46b6e80 100644
--- a/src/plugins/bearer/connman/qconnmanservice_linux.cpp
+++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp
@@ -79,7 +79,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
QLatin1String(CONNMAN_MANAGER_PATH),
QLatin1String(CONNMAN_MANAGER_INTERFACE),
QLatin1String("PropertyChanged"),
- this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) {
+ this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & ))), Qt::UniqueConnection) {
qWarning() << "PropertyCHanged not connected";
}
}
@@ -89,7 +89,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
QLatin1String(CONNMAN_MANAGER_PATH),
QLatin1String(CONNMAN_MANAGER_INTERFACE),
QLatin1String("StateChanged"),
- this,SIGNAL(stateChanged(const QString&)))) {
+ this,SIGNAL(stateChanged(const QString&))), Qt::UniqueConnection) {
qWarning() << "StateChanged not connected";
}
@@ -106,7 +106,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
@@ -338,7 +338,7 @@ void QConnmanNetworkInterface::connectNotify(const char *signal)
this->path(),
QLatin1String(CONNMAN_NETWORK_INTERFACE),
QLatin1String("PropertyChanged"),
- this,SIGNAL(propertyChanged(QString,QDBusVariant))) ) {
+ this,SIGNAL(propertyChanged(QString,QDBusVariant))), Qt::UniqueConnection) {
qWarning() << "network properties not connected";
}
}
@@ -350,10 +350,10 @@ void QConnmanNetworkInterface::connectNotify(const char *signal)
this->path(),
QLatin1String(CONNMAN_NETWORK_INTERFACE),
QLatin1String("PropertyChanged"),
- helper,SLOT(propertyChanged(QString,QDBusVariant)));
+ helper,SLOT(propertyChanged(QString,QDBusVariant))), Qt::UniqueConnection;
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
@@ -538,7 +538,7 @@ void QConnmanServiceInterface::connectNotify(const char *signal)
helper,SLOT(propertyChanged(QString,QDBusVariant)));
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
@@ -569,10 +569,9 @@ QVariant QConnmanServiceInterface::getProperty(const QString &property)
return var;
}
-// clearProperty
void QConnmanServiceInterface::connect()
{
- QDBusReply<QVariantMap> reply = this->call(QLatin1String("Connect"));
+ this->asyncCall(QLatin1String("Connect"));
}
void QConnmanServiceInterface::disconnect()
@@ -866,7 +865,7 @@ void QConnmanTechnologyInterface::connectNotify(const char *signal)
helper,SLOT(propertyChanged(QString,QDBusVariant)));
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
@@ -1031,7 +1030,7 @@ void QConnmanDeviceInterface::connectNotify(const char *signal)
helper,SLOT(propertyChanged(QString,QDBusVariant)));
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
diff --git a/src/plugins/bearer/connman/qofonoservice_linux.cpp b/src/plugins/bearer/connman/qofonoservice_linux.cpp
index 955f4b1..52f596b 100644
--- a/src/plugins/bearer/connman/qofonoservice_linux.cpp
+++ b/src/plugins/bearer/connman/qofonoservice_linux.cpp
@@ -262,7 +262,7 @@ void QOfonoModemInterface::connectNotify(const char *signal)
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}}
void QOfonoModemInterface::disconnectNotify(const char *signal)
@@ -385,7 +385,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
@@ -483,7 +483,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
@@ -586,7 +586,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
@@ -675,7 +675,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}
@@ -794,7 +794,7 @@ if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) {
QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)),
- this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)));
+ this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection);
}
}