diff options
Diffstat (limited to 'src/plugins/bearer/connman/qconnmanengine.cpp')
-rw-r--r-- | src/plugins/bearer/connman/qconnmanengine.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp index ee219f00ac..3d7daedeb0 100644 --- a/src/plugins/bearer/connman/qconnmanengine.cpp +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -168,10 +168,19 @@ void QConnmanEngine::connectToId(const QString &id) QConnmanServiceInterface *serv = connmanServiceInterfaces.value(id); - if (!serv->isValid()) { + if (!serv || !serv->isValid()) { emit connectionError(id, QBearerEngineImpl::InterfaceLookupError); } else { - serv->connect(); + if (serv->type() == QLatin1String("cellular")) { + if (serv->roaming()) { + if (!isRoamingAllowed(serv->path())) { + emit connectionError(id, QBearerEngineImpl::OperationNotSupported); + return; + } + } + } + if (serv->autoConnect()) + serv->connect(); } } @@ -180,7 +189,7 @@ void QConnmanEngine::disconnectFromId(const QString &id) QMutexLocker locker(&mutex); QConnmanServiceInterface *serv = connmanServiceInterfaces.value(id); - if (!serv->isValid()) { + if (!serv || !serv->isValid()) { emit connectionError(id, DisconnectionError); } else { serv->disconnect(); @@ -232,6 +241,8 @@ QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id) QString service = id; QConnmanServiceInterface *serv = connmanServiceInterfaces.value(service); + if (!serv) + return QNetworkSession::Invalid; QString servState = serv->state(); @@ -336,6 +347,8 @@ void QConnmanEngine::serviceStateChanged(const QString &state) void QConnmanEngine::configurationChange(QConnmanServiceInterface *serv) { + if (!serv) + return; QMutexLocker locker(&mutex); QString id = serv->path(); @@ -377,8 +390,10 @@ QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QStri { QMutexLocker locker(&mutex); QConnmanServiceInterface *serv = connmanServiceInterfaces.value(service); - QString state = serv->state(); + if (!serv) + return QNetworkConfiguration::Undefined; + QString state = serv->state(); QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; if (serv->type() == QLatin1String("cellular")) { @@ -474,7 +489,7 @@ void QConnmanEngine::addServiceConfiguration(const QString &servicePath) { QMutexLocker locker(&mutex); if (!connmanServiceInterfaces.contains(servicePath)) { - QConnmanServiceInterface *serv = new QConnmanServiceInterface(servicePath); + QConnmanServiceInterface *serv = new QConnmanServiceInterface(servicePath, this); connmanServiceInterfaces.insert(serv->path(),serv); } |