Commit 8ad283ff authored by Raine Makelainen's avatar Raine Makelainen

Drop slots that emit matching signal.

This also removes duplicated userInputRequested
connection. Further, all UserAgent connections are unique
by nature as previous user agent is destroyed and new created
right before connecting signals and slots.
parent 25902661
......@@ -102,20 +102,6 @@ bool QConnectionAgent::isValid() const
return valid;
}
// from useragent
void QConnectionAgent::onUserInputRequested(const QString &servicePath, const QVariantMap &fields)
{
qDebug() << servicePath;
// gets called when a connman service gets called to connect and needs more configurations.
Q_EMIT userInputRequested(servicePath, fields);
}
// from useragent
void QConnectionAgent::onUserInputCanceled()
{
Q_EMIT userInputCanceled();
}
// from useragent
void QConnectionAgent::onErrorReported(const QString &servicePath, const QString &error)
{
......@@ -407,16 +393,15 @@ void QConnectionAgent::setup()
delete ua;
ua = new UserAgent(this);
connect(ua, &UserAgent::userInputRequested,
this, &QConnectionAgent::onUserInputRequested);
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::userInputCanceled, this, &QConnectionAgent::userInputCanceled);
connect(ua, &UserAgent::userInputRequested, this, &QConnectionAgent::userInputRequested);
connect(ua, &UserAgent::browserRequested,
this, &QConnectionAgent::browserRequest, Qt::UniqueConnection);
this, [=](const QString &servicePath, const QString &url) {
Q_UNUSED(servicePath);
Q_EMIT requestBrowser(url);
});
updateServices();
offlineModeChanged(netman->offlineMode());
......@@ -484,15 +469,6 @@ void QConnectionAgent::techChanged()
}
}
void QConnectionAgent::browserRequest(const QString &servicePath, const QString &url)
{
Q_UNUSED(servicePath)
qDebug() << servicePath;
qDebug() << url;
Q_EMIT requestBrowser(url);
}
bool QConnectionAgent::isStateOnline(const QString &state)
{
if (state == "online" || state == "ready")
......
......@@ -38,7 +38,6 @@ public:
bool isValid() const;
Q_SIGNALS:
void userInputRequested(const QString &servicePath, const QVariantMap &fields);
void userInputCanceled();
void errorReported(const QString &servicePath, const QString &error);
......@@ -51,9 +50,6 @@ Q_SIGNALS:
void tetheringFinished(bool);
public Q_SLOTS:
void onUserInputRequested(const QString &servicePath, const QVariantMap &fields);
void onUserInputCanceled();
void onErrorReported(const QString &servicePath, const QString &error);
void onConnectionRequest();
......@@ -136,7 +132,6 @@ private slots:
void connmanAvailabilityChanged(bool b);
void servicesError(const QString &);
void technologyPowerChanged(bool);
void browserRequest(const QString &servicePath, const QString &url);
void techChanged();
void servicesListChanged(const QStringList &);
......
......@@ -69,7 +69,7 @@ void DeclarativeConnectionAgent::connectToConnectiond(QString)
qDebug() << Q_FUNC_INFO << "is not valid interface";
}
connect(connManagerInterface,SIGNAL(connectionRequest()),
this,SLOT(onConnectionRequested()));
this, SIGNAL(connectionRequest()));
connect(connManagerInterface,SIGNAL(configurationNeeded(QString)),
this,SIGNAL(configurationNeeded(QString)));
......@@ -77,19 +77,19 @@ void DeclarativeConnectionAgent::connectToConnectiond(QString)
this,SIGNAL(userInputCanceled()));
connect(connManagerInterface, SIGNAL(errorReported(QString, QString)),
this, SLOT(onErrorReported(QString, QString)));
this, SIGNAL(errorReported(QString, QString)));
connect(connManagerInterface,SIGNAL(connectionState(QString, QString)),
this,SLOT(onConnectionState(QString, QString)));
this,SIGNAL(connectionState(QString, QString)));
connect(connManagerInterface,SIGNAL(requestBrowser(QString)),
this,SLOT(onRequestBrowser(QString)));
connect(connManagerInterface, SIGNAL(requestBrowser(QString)),
this, SIGNAL(browserRequested(QString)));
connect(connManagerInterface,SIGNAL(userInputRequested(QString,QVariantMap)),
this,SLOT(onUserInputRequested(QString,QVariantMap)), Qt::UniqueConnection);
connect(connManagerInterface,SIGNAL(tetheringFinished(bool)),
this,SLOT(onTetheringFinished(bool)));
this,SLOT(tetheringFinished(bool)));
}
void DeclarativeConnectionAgent::sendUserReply(const QVariantMap &input)
......@@ -125,17 +125,6 @@ void DeclarativeConnectionAgent::connectToType(const QString &type)
connManagerInterface->connectToType(type);
}
void DeclarativeConnectionAgent::onErrorReported(const QString &servicePath, const QString &error)
{
Q_EMIT errorReported(servicePath, error);
}
void DeclarativeConnectionAgent::onRequestBrowser(const QString &url)
{
qDebug() << Q_FUNC_INFO <<url;
Q_EMIT browserRequested(url);
}
void DeclarativeConnectionAgent::onUserInputRequested(const QString &service, const QVariantMap &fields)
{
// we do this as qtdbus does not understand QVariantMap very well.
......@@ -152,11 +141,6 @@ void DeclarativeConnectionAgent::onUserInputRequested(const QString &service, co
Q_EMIT userInputRequested(service, map);
}
void DeclarativeConnectionAgent::onConnectionRequested()
{
Q_EMIT connectionRequest();
}
void DeclarativeConnectionAgent::connectiondUnregistered(QString)
{
if (connManagerInterface) {
......@@ -165,21 +149,11 @@ void DeclarativeConnectionAgent::connectiondUnregistered(QString)
}
}
void DeclarativeConnectionAgent::onConnectionState(const QString &state, const QString &type)
{
Q_EMIT connectionState(state, type);
}
void DeclarativeConnectionAgent::startTethering(const QString &type)
{
connManagerInterface->startTethering(type);
}
void DeclarativeConnectionAgent::onTetheringFinished(bool success)
{
Q_EMIT tetheringFinished(success);
}
void DeclarativeConnectionAgent::stopTethering(bool keepPowered)
{
connManagerInterface->stopTethering(keepPowered);
......
......@@ -87,12 +87,7 @@ private:
QDBusServiceWatcher *connectiondWatcher;
private slots:
void onErrorReported(const QString &servicePath, const QString &error);
void onRequestBrowser(const QString &url);
void onUserInputRequested(const QString &service, const QVariantMap &fields);
void onConnectionRequested();
void onConnectionState(const QString &state, const QString &type);
void onTetheringFinished(bool);
void connectToConnectiond(const QString = QString());
void connectiondUnregistered(const QString = QString());
......
......@@ -34,8 +34,6 @@ class Tst_connectionagent : public QObject
Q_OBJECT
private Q_SLOTS:
void tst_onUserInputRequested();
void tst_onUserInputCanceled();
void tst_onErrorReported();
void tst_onConnectionRequest();
......@@ -43,29 +41,6 @@ private:
QConnectionAgent agent;
};
void Tst_connectionagent::tst_onUserInputRequested()
{
QSignalSpy spy(&agent, SIGNAL(userInputRequested(QString,QVariantMap)));
QVariantMap map;
map.insert("test",true);
agent.onUserInputRequested(QLatin1String("test_path"), map);
QCOMPARE(spy.count(),1);
QList<QVariant> arguments;
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), QString("test_path"));
QVariantMap map2 = arguments.at(1).toMap();
QCOMPARE(map2.keys().at(0), QString("test"));
}
void Tst_connectionagent::tst_onUserInputCanceled()
{
QSignalSpy spy(&agent, SIGNAL(userInputCanceled()));
agent.onUserInputCanceled();
QCOMPARE(spy.count(),1);
}
void Tst_connectionagent::tst_onErrorReported()
{
QSignalSpy spy(&agent, SIGNAL(errorReported(QString,QString)));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment