Skip to content

Commit

Permalink
[connectionagent] make connectToType work correctly.
Browse files Browse the repository at this point in the history
If type is already connected, don't popup dialog.
  • Loading branch information
Lorn Potter committed Apr 17, 2014
1 parent 446cbab commit 9673507
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions connd/qconnectionagent.cpp
Expand Up @@ -248,42 +248,28 @@ void QConnectionAgent::serviceStateChanged(const QString &state)
// from plugin/qml
void QConnectionAgent::connectToType(const QString &type)
{
qDebug() << type;
QString techPath = netman->technologyPathForType(type);
if (!netman)
return;

if (techPath.isEmpty()) {
if (netman->technologyPathForType(type).isEmpty()) {
Q_EMIT errorReported("","Type not valid");
return;
}

NetworkTechnology netTech;
netTech.setPath(techPath);

QStringList servicesList = netman->servicesList(type);
bool needConfig = true;

if (servicesList.isEmpty()) {
if (type == "wifi") {
needConfig = false;
QObject::connect(&netTech,SIGNAL(scanFinished()),this,SLOT(onScanFinished()));
netTech.scan();
}
} else {
Q_FOREACH (const QString path, servicesList) {
NetworkService *service = servicesMap.value(path);
if (service) {
if (service->favorite() && service->autoConnect()) {
needConfig = false;
qDebug() << "<<<<<<<<<<< requestConnect() >>>>>>>>>>>>";
service->requestConnect();
break;
Q_FOREACH (const QString &path, servicesMap.keys()) {
if (path.contains(type)) {
if (!isStateOnline(servicesMap.value(path)->state())) {
if (servicesMap.value(path)->autoConnect()) {
servicesMap.value(path)->requestConnect();
return;
}
} else {
return;
}
}
}
if (needConfig) {
Q_EMIT configurationNeeded(type);
}

Q_EMIT configurationNeeded(type);
}

void QConnectionAgent::onScanFinished()
Expand Down

0 comments on commit 9673507

Please sign in to comment.