Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch to use newer signal-slot mechnanism
This commit also drop servicesChanged slot as it renders to
empty.
  • Loading branch information
rainemak committed Jun 19, 2017
1 parent af3feed commit 2590266
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
69 changes: 32 additions & 37 deletions connd/qconnectionagent.cpp
Expand Up @@ -57,14 +57,16 @@ QConnectionAgent::QConnectionAgent(QObject *parent) :
valid = false;
}

connect(this,SIGNAL(configurationNeeded(QString)),this,SLOT(openConnectionDialog(QString)));
connect(this, &QConnectionAgent::configurationNeeded, this, &QConnectionAgent::openConnectionDialog);

connect(netman,SIGNAL(availabilityChanged(bool)),this,SLOT(connmanAvailabilityChanged(bool)));
connect(netman,SIGNAL(servicesListChanged(QStringList)),this,SLOT(servicesListChanged(QStringList)));
connect(netman,SIGNAL(stateChanged(QString)),this,SLOT(networkStateChanged(QString)));
connect(netman,SIGNAL(offlineModeChanged(bool)),this,SLOT(offlineModeChanged(bool)));
connect(netman,SIGNAL(servicesChanged()),this,SLOT(servicesChanged()));
connect(netman,SIGNAL(technologiesChanged()),this,SLOT(techChanged()));
connect(netman, &NetworkManager::availabilityChanged, this, &QConnectionAgent::connmanAvailabilityChanged);
connect(netman, &NetworkManager::servicesListChanged, this, &QConnectionAgent::servicesListChanged);
connect(netman, &NetworkManager::stateChanged, this, &QConnectionAgent::networkStateChanged);
connect(netman, &NetworkManager::offlineModeChanged, this, &QConnectionAgent::offlineModeChanged);
connect(netman, &NetworkManager::servicesChanged, this, [=]() {
updateServices();
});
connect(netman, &NetworkManager::technologiesChanged, this, &QConnectionAgent::techChanged);

QFile connmanConf("/etc/connman/main.conf");
if (connmanConf.open(QIODevice::ReadOnly | QIODevice::Text)) {
Expand All @@ -85,7 +87,7 @@ QConnectionAgent::QConnectionAgent(QObject *parent) :
connmanAvailable = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman");

scanTimer = new QTimer(this);
connect(scanTimer,SIGNAL(timeout()),this,SLOT(scanTimeout()));
connect(scanTimer, &QTimer::timeout, this, &QConnectionAgent::scanTimeout);
scanTimer->setSingleShot(true);
if (connmanAvailable && valid)
setup();
Expand Down Expand Up @@ -325,16 +327,14 @@ void QConnectionAgent::updateServices()
//new!
qDebug() <<"new service"<< servicePath;

QObject::connect(serv, SIGNAL(stateChanged(QString)),
this,SLOT(serviceStateChanged(QString)), Qt::UniqueConnection);
QObject::connect(serv, SIGNAL(connectRequestFailed(QString)),
this,SLOT(serviceErrorChanged(QString)), Qt::UniqueConnection);

QObject::connect(serv, SIGNAL(errorChanged(QString)),
this,SLOT(servicesError(QString)), Qt::UniqueConnection);

QObject::connect(serv, SIGNAL(autoConnectChanged(bool)),
this,SLOT(serviceAutoconnectChanged(bool)), Qt::UniqueConnection);
QObject::connect(serv, &NetworkService::stateChanged,
this, &QConnectionAgent::serviceStateChanged, Qt::UniqueConnection);
QObject::connect(serv, &NetworkService::connectRequestFailed,
this, &QConnectionAgent::serviceErrorChanged, Qt::UniqueConnection);
QObject::connect(serv, &NetworkService::errorChanged,
this, &QConnectionAgent::servicesError, Qt::UniqueConnection);
QObject::connect(serv, &NetworkService::autoConnectChanged,
this, &QConnectionAgent::serviceAutoconnectChanged, Qt::UniqueConnection);
}
}
}
Expand Down Expand Up @@ -407,16 +407,16 @@ void QConnectionAgent::setup()
delete ua;
ua = new UserAgent(this);

connect(ua,SIGNAL(userInputRequested(QString,QVariantMap)),
this,SLOT(onUserInputRequested(QString,QVariantMap)));
connect(ua, &UserAgent::userInputRequested,
this, &QConnectionAgent::onUserInputRequested);

connect(ua,SIGNAL(connectionRequest()),this,SLOT(onConnectionRequest()));
connect(ua,SIGNAL(errorReported(QString, QString)),this,SLOT(onErrorReported(QString, QString)));
connect(ua,SIGNAL(userInputCanceled()),this,SLOT(onUserInputCanceled()));
connect(ua,SIGNAL(userInputRequested(QString,QVariantMap)),
this,SLOT(onUserInputRequested(QString,QVariantMap)), Qt::UniqueConnection);
connect(ua,SIGNAL(browserRequested(QString,QString)),
this,SLOT(browserRequest(QString,QString)), Qt::UniqueConnection);
connect(ua, &UserAgent::connectionRequest, this, &QConnectionAgent::onConnectionRequest);
connect(ua, &UserAgent::errorReported, this, &QConnectionAgent::onErrorReported);
connect(ua, &UserAgent::userInputCanceled, this, &QConnectionAgent::onUserInputCanceled);
connect(ua, &UserAgent::userInputRequested,
this, &QConnectionAgent::onUserInputRequested, Qt::UniqueConnection);
connect(ua, &UserAgent::browserRequested,
this, &QConnectionAgent::browserRequest, Qt::UniqueConnection);

updateServices();
offlineModeChanged(netman->offlineMode());
Expand Down Expand Up @@ -449,7 +449,7 @@ void QConnectionAgent::technologyPowerChanged(bool powered)

if (netman && powered && delayedTethering) {
// wifi tech might not be ready, so delay this
QTimer::singleShot(1000,this,SLOT(setWifiTetheringEnabled()));
QTimer::singleShot(1000, this, &QConnectionAgent::setWifiTetheringEnabled);
}
}

Expand All @@ -474,9 +474,9 @@ void QConnectionAgent::techChanged()
knownTechnologies << technology->path();
if (technology->type() == "wifi") {
tetheringWifiTech = technology;
connect(tetheringWifiTech,SIGNAL(poweredChanged(bool)),this,SLOT(technologyPowerChanged(bool)));
connect(tetheringWifiTech, SIGNAL(tetheringChanged(bool)),
this,SLOT(techTetheringChanged(bool)), Qt::UniqueConnection);
connect(tetheringWifiTech, &NetworkTechnology::poweredChanged, this, &QConnectionAgent::technologyPowerChanged);
connect(tetheringWifiTech, &NetworkTechnology::tetheringChanged,
this, &QConnectionAgent::techTetheringChanged, Qt::UniqueConnection);
}
} else {
knownTechnologies.removeOne(technology->path());
Expand Down Expand Up @@ -529,7 +529,7 @@ void QConnectionAgent::offlineModeChanged(bool b)
{
flightModeSuppression = b;
if (b) {
QTimer::singleShot(5 * 1000 * 60,this,SLOT(flightModeDialogSuppressionTimeout())); //5 minutes
QTimer::singleShot(5 * 1000 * 60, this, &QConnectionAgent::flightModeDialogSuppressionTimeout); //5 minutes
}
}

Expand Down Expand Up @@ -565,11 +565,6 @@ void QConnectionAgent::scanTimeout()
}
}

void QConnectionAgent::servicesChanged()
{
updateServices();
}

void QConnectionAgent::removeAllTypes(const QString &type)
{
Q_FOREACH (Service elem, orderedServicesList) {
Expand Down
1 change: 0 additions & 1 deletion connd/qconnectionagent.h
Expand Up @@ -146,7 +146,6 @@ private slots:
void serviceAutoconnectChanged(bool);
void scanTimeout();
void techTetheringChanged(bool b);
void servicesChanged();

void openConnectionDialog(const QString &type);
void setWifiTetheringEnabled();
Expand Down

0 comments on commit 2590266

Please sign in to comment.