Commit f489bacd authored by Raine Makelainen's avatar Raine Makelainen

Merge branch 'jb20091' into 'master'

Align error reporting code paths and cleanup

See merge request !6
parents 8e28532c 711111c2
This diff is collapsed.
......@@ -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();
......@@ -106,10 +102,10 @@ private:
void setup();
void updateServices();
bool isStateOnline(const QString &state);
bool isBestService(NetworkService *service);
QString findBestConnectableService();
void removeAllTypes(const QString &type);
bool shouldSuppressError(const QString &error, bool cellular) const;
UserAgent *ua;
NetworkManager *netman;
QString currentNetworkState;
......@@ -129,8 +125,6 @@ private:
bool valid;
private slots:
void onScanFinished();
void serviceErrorChanged(const QString &error);
void serviceStateChanged(const QString &state);
void networkStateChanged(const QString &state);
......@@ -138,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 &);
......@@ -148,7 +141,6 @@ private slots:
void serviceAutoconnectChanged(bool);
void scanTimeout();
void techTetheringChanged(bool b);
void servicesChanged();
void openConnectionDialog(const QString &type);
void setWifiTetheringEnabled();
......
......@@ -28,16 +28,16 @@
DeclarativeConnectionAgent::DeclarativeConnectionAgent(QObject *parent):
QObject(parent),
connManagerInterface(0)
connManagerInterface(nullptr)
{
connectiondWatcher = new QDBusServiceWatcher(CONND_SERVICE,QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration |
QDBusServiceWatcher::WatchForUnregistration, this);
connect(connectiondWatcher, SIGNAL(serviceRegistered(QString)),
this, SLOT(connectToConnectiond(QString)));
connect(connectiondWatcher, SIGNAL(serviceUnregistered(QString)),
this, SLOT(connectiondUnregistered(QString)));
connect(connectiondWatcher, &QDBusServiceWatcher::serviceRegistered,
this, &DeclarativeConnectionAgent::connectToConnectiond);
connect(connectiondWatcher, &QDBusServiceWatcher::serviceUnregistered,
this, &DeclarativeConnectionAgent::connectiondUnregistered);
connectToConnectiond();
}
......@@ -46,12 +46,10 @@ DeclarativeConnectionAgent::~DeclarativeConnectionAgent()
{
}
void DeclarativeConnectionAgent::connectToConnectiond(QString)
void DeclarativeConnectionAgent::connectToConnectiond()
{
if (connManagerInterface) {
delete connManagerInterface;
connManagerInterface = 0;
}
delete connManagerInterface;
connManagerInterface = nullptr;
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(CONND_SERVICE)) {
qDebug() << Q_FUNC_INFO << QString("connection service not available").arg(CONND_SERVICE);
......@@ -68,28 +66,22 @@ void DeclarativeConnectionAgent::connectToConnectiond(QString)
if (!connManagerInterface->isValid()) {
qDebug() << Q_FUNC_INFO << "is not valid interface";
}
connect(connManagerInterface,SIGNAL(connectionRequest()),
this,SLOT(onConnectionRequested()));
connect(connManagerInterface,SIGNAL(configurationNeeded(QString)),
this,SIGNAL(configurationNeeded(QString)));
connect(connManagerInterface,SIGNAL(userInputCanceled()),
this,SIGNAL(userInputCanceled()));
connect(connManagerInterface, SIGNAL(errorReported(QString, QString)),
this, SLOT(onErrorReported(QString, QString)));
connect(connManagerInterface,SIGNAL(connectionState(QString, QString)),
this,SLOT(onConnectionState(QString, QString)));
connect(connManagerInterface,SIGNAL(requestBrowser(QString)),
this,SLOT(onRequestBrowser(QString)));
connect(connManagerInterface,SIGNAL(userInputRequested(QString,QVariantMap)),
this,SLOT(onUserInputRequested(QString,QVariantMap)), Qt::UniqueConnection);
connect(connManagerInterface,SIGNAL(tetheringFinished(bool)),
this,SLOT(onTetheringFinished(bool)));
connect(connManagerInterface, &com::jolla::Connectiond::connectionRequest,
this, &DeclarativeConnectionAgent::connectionRequest);
connect(connManagerInterface, &com::jolla::Connectiond::configurationNeeded,
this, &DeclarativeConnectionAgent::configurationNeeded);
connect(connManagerInterface, &com::jolla::Connectiond::userInputCanceled,
this, &DeclarativeConnectionAgent::userInputCanceled);
connect(connManagerInterface, &com::jolla::Connectiond::errorReported,
this, &DeclarativeConnectionAgent::errorReported);
connect(connManagerInterface, &com::jolla::Connectiond::connectionState,
this, &DeclarativeConnectionAgent::connectionState);
connect(connManagerInterface, &com::jolla::Connectiond::requestBrowser,
this, &DeclarativeConnectionAgent::browserRequested);
connect(connManagerInterface, &com::jolla::Connectiond::userInputRequested,
this, &DeclarativeConnectionAgent::onUserInputRequested, Qt::UniqueConnection);
connect(connManagerInterface, &com::jolla::Connectiond::tetheringFinished,
this, &DeclarativeConnectionAgent::tetheringFinished);
}
void DeclarativeConnectionAgent::sendUserReply(const QVariantMap &input)
......@@ -125,17 +117,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,24 +133,10 @@ void DeclarativeConnectionAgent::onUserInputRequested(const QString &service, co
Q_EMIT userInputRequested(service, map);
}
void DeclarativeConnectionAgent::onConnectionRequested()
{
qDebug() << Q_FUNC_INFO;
Q_EMIT connectionRequest();
}
void DeclarativeConnectionAgent::connectiondUnregistered(QString)
void DeclarativeConnectionAgent::connectiondUnregistered()
{
if (connManagerInterface) {
delete connManagerInterface;
connManagerInterface = 0;
}
}
void DeclarativeConnectionAgent::onConnectionState(const QString &state, const QString &type)
{
qDebug() << Q_FUNC_INFO << state;
Q_EMIT connectionState(state, type);
delete connManagerInterface;
connManagerInterface = nullptr;
}
void DeclarativeConnectionAgent::startTethering(const QString &type)
......@@ -177,11 +144,6 @@ 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,15 +87,10 @@ 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());
void connectToConnectiond();
void connectiondUnregistered();
};
#endif
......
......@@ -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