summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/connman/qconnmanengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/bearer/connman/qconnmanengine.cpp')
-rw-r--r--src/plugins/bearer/connman/qconnmanengine.cpp83
1 files changed, 20 insertions, 63 deletions
diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp
index a8b8911176..184ceb49b2 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