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: ...@@ -38,7 +38,6 @@ public:
bool isValid() const; bool isValid() const;
Q_SIGNALS: Q_SIGNALS:
void userInputRequested(const QString &servicePath, const QVariantMap &fields); void userInputRequested(const QString &servicePath, const QVariantMap &fields);
void userInputCanceled(); void userInputCanceled();
void errorReported(const QString &servicePath, const QString &error); void errorReported(const QString &servicePath, const QString &error);
...@@ -51,9 +50,6 @@ Q_SIGNALS: ...@@ -51,9 +50,6 @@ Q_SIGNALS:
void tetheringFinished(bool); void tetheringFinished(bool);
public Q_SLOTS: public Q_SLOTS:
void onUserInputRequested(const QString &servicePath, const QVariantMap &fields);
void onUserInputCanceled();
void onErrorReported(const QString &servicePath, const QString &error); void onErrorReported(const QString &servicePath, const QString &error);
void onConnectionRequest(); void onConnectionRequest();
...@@ -106,10 +102,10 @@ private: ...@@ -106,10 +102,10 @@ private:
void setup(); void setup();
void updateServices(); void updateServices();
bool isStateOnline(const QString &state); bool isStateOnline(const QString &state);
bool isBestService(NetworkService *service);
QString findBestConnectableService();
void removeAllTypes(const QString &type); void removeAllTypes(const QString &type);
bool shouldSuppressError(const QString &error, bool cellular) const;
UserAgent *ua; UserAgent *ua;
NetworkManager *netman; NetworkManager *netman;
QString currentNetworkState; QString currentNetworkState;
...@@ -129,8 +125,6 @@ private: ...@@ -129,8 +125,6 @@ private:
bool valid; bool valid;
private slots: private slots:
void onScanFinished();
void serviceErrorChanged(const QString &error); void serviceErrorChanged(const QString &error);
void serviceStateChanged(const QString &state); void serviceStateChanged(const QString &state);
void networkStateChanged(const QString &state); void networkStateChanged(const QString &state);
...@@ -138,7 +132,6 @@ private slots: ...@@ -138,7 +132,6 @@ private slots:
void connmanAvailabilityChanged(bool b); void connmanAvailabilityChanged(bool b);
void servicesError(const QString &); void servicesError(const QString &);
void technologyPowerChanged(bool); void technologyPowerChanged(bool);
void browserRequest(const QString &servicePath, const QString &url);
void techChanged(); void techChanged();
void servicesListChanged(const QStringList &); void servicesListChanged(const QStringList &);
...@@ -148,7 +141,6 @@ private slots: ...@@ -148,7 +141,6 @@ private slots:
void serviceAutoconnectChanged(bool); void serviceAutoconnectChanged(bool);
void scanTimeout(); void scanTimeout();
void techTetheringChanged(bool b); void techTetheringChanged(bool b);
void servicesChanged();
void openConnectionDialog(const QString &type); void openConnectionDialog(const QString &type);
void setWifiTetheringEnabled(); void setWifiTetheringEnabled();
......
...@@ -28,16 +28,16 @@ ...@@ -28,16 +28,16 @@
DeclarativeConnectionAgent::DeclarativeConnectionAgent(QObject *parent): DeclarativeConnectionAgent::DeclarativeConnectionAgent(QObject *parent):
QObject(parent), QObject(parent),
connManagerInterface(0) connManagerInterface(nullptr)
{ {
connectiondWatcher = new QDBusServiceWatcher(CONND_SERVICE,QDBusConnection::sessionBus(), connectiondWatcher = new QDBusServiceWatcher(CONND_SERVICE,QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForRegistration |
QDBusServiceWatcher::WatchForUnregistration, this); QDBusServiceWatcher::WatchForUnregistration, this);
connect(connectiondWatcher, SIGNAL(serviceRegistered(QString)), connect(connectiondWatcher, &QDBusServiceWatcher::serviceRegistered,
this, SLOT(connectToConnectiond(QString))); this, &DeclarativeConnectionAgent::connectToConnectiond);
connect(connectiondWatcher, SIGNAL(serviceUnregistered(QString)), connect(connectiondWatcher, &QDBusServiceWatcher::serviceUnregistered,
this, SLOT(connectiondUnregistered(QString))); this, &DeclarativeConnectionAgent::connectiondUnregistered);
connectToConnectiond(); connectToConnectiond();
} }
...@@ -46,12 +46,10 @@ DeclarativeConnectionAgent::~DeclarativeConnectionAgent() ...@@ -46,12 +46,10 @@ DeclarativeConnectionAgent::~DeclarativeConnectionAgent()
{ {
} }
void DeclarativeConnectionAgent::connectToConnectiond(QString) void DeclarativeConnectionAgent::connectToConnectiond()
{ {
if (connManagerInterface) { delete connManagerInterface;
delete connManagerInterface; connManagerInterface = nullptr;
connManagerInterface = 0;
}
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(CONND_SERVICE)) { if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(CONND_SERVICE)) {
qDebug() << Q_FUNC_INFO << QString("connection service not available").arg(CONND_SERVICE); qDebug() << Q_FUNC_INFO << QString("connection service not available").arg(CONND_SERVICE);
...@@ -68,28 +66,22 @@ void DeclarativeConnectionAgent::connectToConnectiond(QString) ...@@ -68,28 +66,22 @@ void DeclarativeConnectionAgent::connectToConnectiond(QString)
if (!connManagerInterface->isValid()) { if (!connManagerInterface->isValid()) {
qDebug() << Q_FUNC_INFO << "is not valid interface"; qDebug() << Q_FUNC_INFO << "is not valid interface";
} }
connect(connManagerInterface,SIGNAL(connectionRequest()), connect(connManagerInterface, &com::jolla::Connectiond::connectionRequest,
this,SLOT(onConnectionRequested())); this, &DeclarativeConnectionAgent::connectionRequest);
connect(connManagerInterface,SIGNAL(configurationNeeded(QString)), connect(connManagerInterface, &com::jolla::Connectiond::configurationNeeded,
this,SIGNAL(configurationNeeded(QString))); this, &DeclarativeConnectionAgent::configurationNeeded);
connect(connManagerInterface, &com::jolla::Connectiond::userInputCanceled,
connect(connManagerInterface,SIGNAL(userInputCanceled()), this, &DeclarativeConnectionAgent::userInputCanceled);
this,SIGNAL(userInputCanceled())); connect(connManagerInterface, &com::jolla::Connectiond::errorReported,
this, &DeclarativeConnectionAgent::errorReported);
connect(connManagerInterface, SIGNAL(errorReported(QString, QString)), connect(connManagerInterface, &com::jolla::Connectiond::connectionState,
this, SLOT(onErrorReported(QString, QString))); this, &DeclarativeConnectionAgent::connectionState);
connect(connManagerInterface, &com::jolla::Connectiond::requestBrowser,
connect(connManagerInterface,SIGNAL(connectionState(QString, QString)), this, &DeclarativeConnectionAgent::browserRequested);
this,SLOT(onConnectionState(QString, QString))); connect(connManagerInterface, &com::jolla::Connectiond::userInputRequested,
this, &DeclarativeConnectionAgent::onUserInputRequested, Qt::UniqueConnection);
connect(connManagerInterface,SIGNAL(requestBrowser(QString)), connect(connManagerInterface, &com::jolla::Connectiond::tetheringFinished,
this,SLOT(onRequestBrowser(QString))); this, &DeclarativeConnectionAgent::tetheringFinished);
connect(connManagerInterface,SIGNAL(userInputRequested(QString,QVariantMap)),
this,SLOT(onUserInputRequested(QString,QVariantMap)), Qt::UniqueConnection);
connect(connManagerInterface,SIGNAL(tetheringFinished(bool)),
this,SLOT(onTetheringFinished(bool)));
} }
void DeclarativeConnectionAgent::sendUserReply(const QVariantMap &input) void DeclarativeConnectionAgent::sendUserReply(const QVariantMap &input)
...@@ -125,17 +117,6 @@ void DeclarativeConnectionAgent::connectToType(const QString &type) ...@@ -125,17 +117,6 @@ void DeclarativeConnectionAgent::connectToType(const QString &type)
connManagerInterface->connectToType(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) void DeclarativeConnectionAgent::onUserInputRequested(const QString &service, const QVariantMap &fields)
{ {
// we do this as qtdbus does not understand QVariantMap very well. // we do this as qtdbus does not understand QVariantMap very well.
...@@ -152,24 +133,10 @@ void DeclarativeConnectionAgent::onUserInputRequested(const QString &service, co ...@@ -152,24 +133,10 @@ void DeclarativeConnectionAgent::onUserInputRequested(const QString &service, co
Q_EMIT userInputRequested(service, map); Q_EMIT userInputRequested(service, map);
} }
void DeclarativeConnectionAgent::onConnectionRequested() void DeclarativeConnectionAgent::connectiondUnregistered()
{
qDebug() << Q_FUNC_INFO;
Q_EMIT connectionRequest();
}
void DeclarativeConnectionAgent::connectiondUnregistered(QString)
{ {
if (connManagerInterface) { delete connManagerInterface;
delete connManagerInterface; connManagerInterface = nullptr;
connManagerInterface = 0;
}
}
void DeclarativeConnectionAgent::onConnectionState(const QString &state, const QString &type)
{
qDebug() << Q_FUNC_INFO << state;
Q_EMIT connectionState(state, type);
} }
void DeclarativeConnectionAgent::startTethering(const QString &type) void DeclarativeConnectionAgent::startTethering(const QString &type)
...@@ -177,11 +144,6 @@ void DeclarativeConnectionAgent::startTethering(const QString &type) ...@@ -177,11 +144,6 @@ void DeclarativeConnectionAgent::startTethering(const QString &type)
connManagerInterface->startTethering(type); connManagerInterface->startTethering(type);
} }
void DeclarativeConnectionAgent::onTetheringFinished(bool success)
{
Q_EMIT tetheringFinished(success);
}
void DeclarativeConnectionAgent::stopTethering(bool keepPowered) void DeclarativeConnectionAgent::stopTethering(bool keepPowered)
{ {
connManagerInterface->stopTethering(keepPowered); connManagerInterface->stopTethering(keepPowered);
......
...@@ -87,15 +87,10 @@ private: ...@@ -87,15 +87,10 @@ private:
QDBusServiceWatcher *connectiondWatcher; QDBusServiceWatcher *connectiondWatcher;
private slots: private slots:
void onErrorReported(const QString &servicePath, const QString &error);
void onRequestBrowser(const QString &url);
void onUserInputRequested(const QString &service, const QVariantMap &fields); 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 connectToConnectiond();
void connectiondUnregistered(const QString = QString()); void connectiondUnregistered();
}; };
#endif #endif
......
...@@ -34,8 +34,6 @@ class Tst_connectionagent : public QObject ...@@ -34,8 +34,6 @@ class Tst_connectionagent : public QObject
Q_OBJECT Q_OBJECT
private Q_SLOTS: private Q_SLOTS:
void tst_onUserInputRequested();
void tst_onUserInputCanceled();
void tst_onErrorReported(); void tst_onErrorReported();
void tst_onConnectionRequest(); void tst_onConnectionRequest();
...@@ -43,29 +41,6 @@ private: ...@@ -43,29 +41,6 @@ private:
QConnectionAgent agent; 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() void Tst_connectionagent::tst_onErrorReported()
{ {
QSignalSpy spy(&agent, SIGNAL(errorReported(QString,QString))); 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