diff --git a/connd/connd.pro b/connd/connd.pro index ef5cc33..75777b0 100644 --- a/connd/connd.pro +++ b/connd/connd.pro @@ -2,7 +2,7 @@ QT = core network dbus TARGET = connectionagent -PKGCONFIG += connman-qt5 qofono-qt5 +PKGCONFIG += connman-qt5 packagesExist(qt5-boostable) { DEFINES += HAS_BOOSTER @@ -30,15 +30,15 @@ SOURCES += main.cpp \ qconnectionagent.cpp \ wakeupwatcher.cpp -HEADERS+= \ +HEADERS += \ qconnectionagent.h \ wakeupwatcher.h target.path = /usr/bin INSTALLS += target -MOC_DIR=.moc -OBJECTS_DIR=.obj +MOC_DIR = .moc +OBJECTS_DIR = .obj diff --git a/connd/main.cpp b/connd/main.cpp index f5a0f03..869d337 100644 --- a/connd/main.cpp +++ b/connd/main.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -79,13 +78,13 @@ static void daemonize(void) } static QtMessageHandler previousMessageHandler; -bool toggleDebug; +static bool toggleDebug; void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &str) - { +{ if (toggleDebug) previousMessageHandler(type,context,str); - } +} Q_DECL_EXPORT int main(int argc, char *argv[]) { @@ -104,13 +103,13 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) QCoreApplication::setApplicationVersion("1.0"); QCoreApplication a(argc, argv); - if (QDBusConnection::sessionBus().interface()->isServiceRegistered("com.jolla.Connectiond")) { - qDebug() << "Connectionagent service is already running. Exiting now"; + + QConnectionAgent agent; + if (!agent.isValid()) { + qDebug() << "Connectionagent service failed to register. Exiting now"; return 1; } - QConnectionAgent::instance(); - return a.exec(); } diff --git a/connd/notes.txt b/connd/notes.txt deleted file mode 100644 index e69de29..0000000 diff --git a/connd/qconnectionagent.cpp b/connd/qconnectionagent.cpp index 9aed019..26bd016 100644 --- a/connd/qconnectionagent.cpp +++ b/connd/qconnectionagent.cpp @@ -23,20 +23,12 @@ #include #include #include -#include -#include -#include -#include #include #include #include -#define CONNMAN_1_21 - -QConnectionAgent* QConnectionAgent::self = NULL; - #define CONND_SERVICE "com.jolla.Connectiond" #define CONND_PATH "/Connectiond" #define CONND_SESSION_PATH = "/ConnectionSession" @@ -48,30 +40,31 @@ QConnectionAgent::QConnectionAgent(QObject *parent) : currentNetworkState(QString()), isEthernet(false), connmanAvailable(false), - oContext(0), tetheringWifiTech(0), tetheringEnabled(false), flightModeSuppression(false), scanTimeoutInterval(1), - delayedTethering(false) + delayedTethering(false), + valid(true) { qDebug() << Q_FUNC_INFO; - connect(netman,SIGNAL(availabilityChanged(bool)),this,SLOT(connmanAvailabilityChanged(bool))); - - connectionAdaptor = new ConnAdaptor(this); + new ConnAdaptor(this); QDBusConnection dbus = QDBusConnection::sessionBus(); if (!dbus.registerService(CONND_SERVICE)) { qDebug() << "XXXXXXXXXXX could not register service XXXXXXXXXXXXXXXXXX"; + valid = false; } if (!dbus.registerObject(CONND_PATH, this)) { qDebug() << "XXXXXXXXXXX could not register object XXXXXXXXXXXXXXXXXX"; + valid = false; } connect(this,SIGNAL(configurationNeeded(QString)),this,SLOT(openConnectionDialog(QString))); + 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))); @@ -102,23 +95,17 @@ QConnectionAgent::QConnectionAgent(QObject *parent) : scanTimer = new QTimer(this); connect(scanTimer,SIGNAL(timeout()),this,SLOT(scanTimeout())); scanTimer->setSingleShot(true); - if (connmanAvailable) + if (connmanAvailable && valid) setup(); } QConnectionAgent::~QConnectionAgent() { - delete self; } -QConnectionAgent & QConnectionAgent::instance() +bool QConnectionAgent::isValid() const { - qDebug() << Q_FUNC_INFO; - if (!self) { - self = new QConnectionAgent; - } - - return *self; + return valid; } // from useragent @@ -387,20 +374,6 @@ void QConnectionAgent::servicesError(const QString &errorMessage) Q_EMIT onErrorReported(serv->path(), errorMessage); } -void QConnectionAgent::ofonoServicesError(const QString &errorMessage) -{ - QOfonoConnectionContext *context = static_cast(sender()); - QVector services = netman->getServices("cellular"); - Q_FOREACH (NetworkService *serv, services) { - if (context->contextPath().contains(serv->path().section("_",2,2))) { - Q_EMIT onErrorReported(serv->path(), errorMessage); - qDebug() << serv->name() << errorMessage; - return; - } - } - qWarning() << "ofono error but could not discover connman service"; -} - void QConnectionAgent::networkStateChanged(const QString &state) { qDebug() << state; @@ -448,12 +421,6 @@ void QConnectionAgent::connmanAvailabilityChanged(bool b) } } -void QConnectionAgent::serviceAdded(const QString &srv) -{ - qDebug() << Q_FUNC_INFO << "<<<<"<< srv; - updateServices(); -} - void QConnectionAgent::setup() { qDebug() << Q_FUNC_INFO @@ -462,9 +429,7 @@ void QConnectionAgent::setup() if (connmanAvailable) { qDebug() << Q_FUNC_INFO << netman->state(); - if (ua) - delete ua; - + delete ua; ua = new UserAgent(this); connect(ua,SIGNAL(userInputRequested(QString,QVariantMap)), @@ -595,8 +560,7 @@ void QConnectionAgent::offlineModeChanged(bool b) void QConnectionAgent::flightModeDialogSuppressionTimeout() { - if (flightModeSuppression) - flightModeSuppression = false; + flightModeSuppression = false; } void QConnectionAgent::displayStateChanged(const QString &state) @@ -641,7 +605,7 @@ bool QConnectionAgent::isBestService(NetworkService *service) void QConnectionAgent::scanTimeout() { if (!tetheringWifiTech || tetheringWifiTech->tethering()) - return; + return; if (tetheringWifiTech->powered() && !tetheringWifiTech->connected() && netman->defaultRoute()->type() != "wifi" ) { tetheringWifiTech->scan(); diff --git a/connd/qconnectionagent.h b/connd/qconnectionagent.h index 142eaf1..3dfc605 100644 --- a/connd/qconnectionagent.h +++ b/connd/qconnectionagent.h @@ -31,10 +31,8 @@ class UserAgent; class SessionAgent; -class ConnAdaptor; class NetworkManager; class NetworkService; -class QOfonoConnectionContext; class NetworkTechnology; class WakeupWatcher; class QTimer; @@ -44,9 +42,10 @@ class QConnectionAgent : public QObject Q_OBJECT public: + explicit QConnectionAgent(QObject *parent = 0); ~QConnectionAgent(); - static QConnectionAgent &instance(); + bool isValid() const; Q_SIGNALS: @@ -82,41 +81,45 @@ public Q_SLOTS: class Service { public: - QString path; - NetworkService *service; + QString path; + NetworkService *service; - bool operator==(const Service &other) const { - return other.path == path; - } + bool operator==(const Service &other) const { + return other.path == path; + } }; class ServiceList : public QVector { public: - int indexOf(const QString &path, int from = 0) const { - Service key; - key.path = path; - return QVector::indexOf(key, from); - } - - bool contains(const QString &path) const { - Service key; - key.path = path; - return QVector::indexOf(key) >= 0; - } - - void remove(const QString &path) { - Service key; - key.path = path; - int pos = QVector::indexOf(key); - if (pos >= 0) - QVector::remove(pos); - } + int indexOf(const QString &path, int from = 0) const { + Service key; + key.path = path; + return QVector::indexOf(key, from); + } + + bool contains(const QString &path) const { + Service key; + key.path = path; + return QVector::indexOf(key) >= 0; + } + + void remove(const QString &path) { + Service key; + key.path = path; + int pos = QVector::indexOf(key); + if (pos >= 0) + QVector::remove(pos); + } }; - explicit QConnectionAgent(QObject *parent = 0); - static QConnectionAgent *self; - ConnAdaptor *connectionAdaptor; + void setup(); + void updateServices(); + bool isStateOnline(const QString &state); + bool isBestService(NetworkService *service); + QString findBestConnectableService(); + void removeAllTypes(const QString &type); + UserAgent *ua; NetworkManager *netman; @@ -130,8 +133,6 @@ public Q_SLOTS: bool isEthernet; bool connmanAvailable; - bool isStateOnline(const QString &state); - QOfonoConnectionContext *oContext; NetworkTechnology *tetheringWifiTech; bool tetheringEnabled; bool flightModeSuppression; @@ -140,29 +141,23 @@ public Q_SLOTS: QTimer *scanTimer; QStringList knownTechnologies; - bool isBestService(NetworkService *service); - QString findBestConnectableService(); - void removeAllTypes(const QString &type); bool tetheringStarted; bool delayedTethering; + bool valid; private slots: void onScanFinished(); - void updateServices(); void serviceErrorChanged(const QString &error); void serviceStateChanged(const QString &state); void networkStateChanged(const QString &state); void connmanAvailabilityChanged(bool b); - void setup(); void servicesError(const QString &); - void ofonoServicesError(const QString &); void technologyPowerChanged(bool); void browserRequest(const QString &servicePath, const QString &url); void techChanged(); - void serviceAdded(const QString &); void servicesListChanged(const QStringList &); void offlineModeChanged(bool); void flightModeDialogSuppressionTimeout(); diff --git a/connd/wakeupwatcher.cpp b/connd/wakeupwatcher.cpp index 755688d..9f6cef8 100644 --- a/connd/wakeupwatcher.cpp +++ b/connd/wakeupwatcher.cpp @@ -19,6 +19,18 @@ #include "wakeupwatcher.h" +#define MCE_SERVICE "com.nokia.mce" +#define MCE_SIGNAL_PATH "/com/nokia/mce/signal" +#define MCE_SIGNAL_INTERFACE "com.nokia.mce.signal" +#define MCE_PSM_STATE_IND "psm_state_ind" +#define MCE_DISPLAY_IND "display_status_ind" + +#define MCE_REQUEST_PATH "/com/nokia/mce/request" +#define MCE_REQUEST_INTERFACE "com.nokia.mce.request" +#define MCE_DISPLAY_STATUS_GET "get_display_status" +#define MCE_PSM_STATE_GET "get_psm_state" + + WakeupWatcher::WakeupWatcher(QObject *parent) : QObject(parent), currentPowerSave(false) diff --git a/connd/wakeupwatcher.h b/connd/wakeupwatcher.h index a5386df..5fca3cf 100644 --- a/connd/wakeupwatcher.h +++ b/connd/wakeupwatcher.h @@ -20,17 +20,6 @@ #include #include -#define MCE_SERVICE "com.nokia.mce" -#define MCE_SIGNAL_PATH "/com/nokia/mce/signal" -#define MCE_SIGNAL_INTERFACE "com.nokia.mce.signal" -#define MCE_PSM_STATE_IND "psm_state_ind" -#define MCE_DISPLAY_IND "display_status_ind" - -#define MCE_REQUEST_PATH "/com/nokia/mce/request" -#define MCE_REQUEST_INTERFACE "com.nokia.mce.request" -#define MCE_DISPLAY_STATUS_GET "get_display_status" -#define MCE_PSM_STATE_GET "get_psm_state" - class WakeupWatcher : public QObject { Q_OBJECT @@ -40,11 +29,11 @@ class WakeupWatcher : public QObject signals: void displayStateChanged(const QString&); void sleepStateChanged(bool); -public slots: private slots: void mceDisplayStateChanged(const QString &state); void mceSleepStateChanged(bool mode); + private: QDBusInterface *mceInterface; QString currentDisplayState; diff --git a/connectionagent.pro b/connectionagent.pro index 0c86b8e..5a21766 100644 --- a/connectionagent.pro +++ b/connectionagent.pro @@ -8,7 +8,4 @@ SUBDIRS = \ test.depends = connd # xml interface -OTHER_FILES += rpm/connectionagent-qt5.spec \ - rpm/connectionagent-qt5.yaml \ - rpm/connectionagent.tracing - +OTHER_FILES += rpm/connectionagent-qt5.spec diff --git a/connectionagentplugin/connectionagentplugin.pro b/connectionagentplugin/connectionagentplugin.pro index 348bf0d..638ca90 100644 --- a/connectionagentplugin/connectionagentplugin.pro +++ b/connectionagentplugin/connectionagentplugin.pro @@ -6,12 +6,11 @@ CONFIG += qt plugin uri = com.jolla.connection SOURCES += \ - connectionagentplugin_plugin.cpp \ - connectionagentplugin.cpp + plugin.cpp \ + declarativeconnectionagent.cpp HEADERS += \ - connectionagentplugin_plugin.h \ - connectionagentplugin.h + declarativeconnectionagent.h DBUS_INTERFACES = connectiond_interface connectiond_interface.files = ../connd/com.jollamobile.Connectiond.xml diff --git a/connectionagentplugin/connectionagentplugin_plugin.cpp b/connectionagentplugin/connectionagentplugin_plugin.cpp deleted file mode 100644 index 2bb15f0..0000000 --- a/connectionagentplugin/connectionagentplugin_plugin.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Jolla Ltd -** Contact: lorn.potter@gmail.com -** -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -****************************************************************************/ - -#include "connectionagentplugin_plugin.h" -#include "connectionagentplugin.h" - -/* - *This class is for accessing connman's UserAgent from multiple sources. - *This is because currently, there can only be one UserAgent per system. - * - *It also makes use of a patch to connman, that allows the UserAgent - *to get signaled when a connection is needed. This is the real reason - *this daemon is needed. An InputRequest is short lived, and thus, may - *not clash with other apps that need to use UserAgent. - * - *When you are trying to intercept a connection request, you need a long - *living process to wait until such time. This will immediately clash if - *a wlan needs user Input signal from connman, and the configure will never - *get the proper signal. - * - *This qml type can be used as such: - * - *import com.jolla.connection 1.0 - * - * ConnectionAgent { - * id: userAgent - * onUserInputRequested: { - * console.log(" onUserInputRequested:") - * } - * - * onConnectionRequest: { - * console.log("onConnectionRequest ") - * sendSuppress() - * } - * onErrorReported: { - * console.log("Got error from connman: " + error); - * } - * } - * - **/ - -void ConnectionagentpluginPlugin::registerTypes(const char *uri) -{ - // @uri com.jolla.connection - qmlRegisterType(uri, 1, 0, "ConnectionAgent"); -} diff --git a/connectionagentplugin/connectionagentplugin.cpp b/connectionagentplugin/declarativeconnectionagent.cpp similarity index 82% rename from connectionagentplugin/connectionagentplugin.cpp rename to connectionagentplugin/declarativeconnectionagent.cpp index caa5b05..be0a18c 100644 --- a/connectionagentplugin/connectionagentplugin.cpp +++ b/connectionagentplugin/declarativeconnectionagent.cpp @@ -14,7 +14,7 @@ ** ****************************************************************************/ -#include "connectionagentplugin.h" +#include "declarativeconnectionagent.h" #include "connectiond_interface.h" #include @@ -26,7 +26,7 @@ #define CONND_SERVICE "com.jolla.Connectiond" #define CONND_PATH "/Connectiond" -ConnectionAgentPlugin::ConnectionAgentPlugin(QObject *parent): +DeclarativeConnectionAgent::DeclarativeConnectionAgent(QObject *parent): QObject(parent), connManagerInterface(0) { @@ -42,11 +42,11 @@ ConnectionAgentPlugin::ConnectionAgentPlugin(QObject *parent): connectToConnectiond(); } -ConnectionAgentPlugin::~ConnectionAgentPlugin() +DeclarativeConnectionAgent::~DeclarativeConnectionAgent() { } -void ConnectionAgentPlugin::connectToConnectiond(QString) +void DeclarativeConnectionAgent::connectToConnectiond(QString) { if (connManagerInterface) { delete connManagerInterface; @@ -92,7 +92,7 @@ void ConnectionAgentPlugin::connectToConnectiond(QString) this,SLOT(onTetheringFinished(bool))); } -void ConnectionAgentPlugin::sendUserReply(const QVariantMap &input) +void DeclarativeConnectionAgent::sendUserReply(const QVariantMap &input) { if (!connManagerInterface || !connManagerInterface->isValid()) { Q_EMIT errorReported("","ConnectionAgent not available"); @@ -106,7 +106,7 @@ void ConnectionAgentPlugin::sendUserReply(const QVariantMap &input) } } -void ConnectionAgentPlugin::sendConnectReply(const QString &replyMessage, int timeout) +void DeclarativeConnectionAgent::sendConnectReply(const QString &replyMessage, int timeout) { if (!connManagerInterface || !connManagerInterface->isValid()) { Q_EMIT errorReported("","ConnectionAgent not available"); @@ -115,7 +115,7 @@ void ConnectionAgentPlugin::sendConnectReply(const QString &replyMessage, int ti connManagerInterface->sendConnectReply(replyMessage,timeout); } -void ConnectionAgentPlugin::connectToType(const QString &type) +void DeclarativeConnectionAgent::connectToType(const QString &type) { if (!connManagerInterface || !connManagerInterface->isValid()) { Q_EMIT errorReported("","ConnectionAgent not available"); @@ -125,18 +125,18 @@ void ConnectionAgentPlugin::connectToType(const QString &type) connManagerInterface->connectToType(type); } -void ConnectionAgentPlugin::onErrorReported(const QString &servicePath, const QString &error) +void DeclarativeConnectionAgent::onErrorReported(const QString &servicePath, const QString &error) { Q_EMIT errorReported(servicePath, error); } -void ConnectionAgentPlugin::onRequestBrowser(const QString &url) +void DeclarativeConnectionAgent::onRequestBrowser(const QString &url) { qDebug() << Q_FUNC_INFO <startTethering(type); } -void ConnectionAgentPlugin::onTetheringFinished(bool success) +void DeclarativeConnectionAgent::onTetheringFinished(bool success) { Q_EMIT tetheringFinished(success); } -void ConnectionAgentPlugin::stopTethering(bool keepPowered) +void DeclarativeConnectionAgent::stopTethering(bool keepPowered) { connManagerInterface->stopTethering(keepPowered); } diff --git a/connectionagentplugin/connectionagentplugin.h b/connectionagentplugin/declarativeconnectionagent.h similarity index 58% rename from connectionagentplugin/connectionagentplugin.h rename to connectionagentplugin/declarativeconnectionagent.h index 8e32a0f..befc985 100644 --- a/connectionagentplugin/connectionagentplugin.h +++ b/connectionagentplugin/declarativeconnectionagent.h @@ -14,22 +14,56 @@ ** ****************************************************************************/ -#ifndef CONNECTIONAGENTPLUGIN_H -#define CONNECTIONAGENTPLUGIN_H +#ifndef DECLARATIVECONNECTIONAGENT_H +#define DECLARATIVECONNECTIONAGENT_H -#include "connectionagentplugin.h" +#include "declarativeconnectionagent.h" #include "connectiond_interface.h" -class NetworkManager; -class ConnectionAgentPlugin : public QObject +/* + *This class is for accessing connman's UserAgent from multiple sources. + *This is because currently, there can only be one UserAgent per system. + * + *It also makes use of a patch to connman, that allows the UserAgent + *to get signaled when a connection is needed. This is the real reason + *this daemon is needed. An InputRequest is short lived, and thus, may + *not clash with other apps that need to use UserAgent. + * + *When you are trying to intercept a connection request, you need a long + *living process to wait until such time. This will immediately clash if + *a wlan needs user Input signal from connman, and the configure will never + *get the proper signal. + * + *This qml type can be used as such: + * + *import com.jolla.connection 1.0 + * + * ConnectionAgent { + * id: userAgent + * onUserInputRequested: { + * console.log(" onUserInputRequested:") + * } + * + * onConnectionRequest: { + * console.log("onConnectionRequest ") + * sendSuppress() + * } + * onErrorReported: { + * console.log("Got error from connman: " + error); + * } + * } + * + **/ + +class DeclarativeConnectionAgent : public QObject { Q_OBJECT - Q_DISABLE_COPY(ConnectionAgentPlugin) + Q_DISABLE_COPY(DeclarativeConnectionAgent) public: - explicit ConnectionAgentPlugin(QObject *parent = 0); - ~ConnectionAgentPlugin(); + explicit DeclarativeConnectionAgent(QObject *parent = 0); + ~DeclarativeConnectionAgent(); public slots: void sendUserReply(const QVariantMap &input); @@ -64,5 +98,5 @@ private slots: void connectiondUnregistered(const QString = QString()); }; -#endif // CONNECTIONAGENTPLUGIN_H +#endif diff --git a/connectionagentplugin/connectionagentplugin_plugin.h b/connectionagentplugin/plugin.cpp similarity index 75% rename from connectionagentplugin/connectionagentplugin_plugin.h rename to connectionagentplugin/plugin.cpp index bfba5c1..6cf85f8 100644 --- a/connectionagentplugin/connectionagentplugin_plugin.h +++ b/connectionagentplugin/plugin.cpp @@ -14,15 +14,15 @@ ** ****************************************************************************/ -#ifndef CONNECTIONAGENTPLUGIN_PLUGIN_H -#define CONNECTIONAGENTPLUGIN_PLUGIN_H +#include "declarativeconnectionagent.h" + #include #include #include #include -class ConnectionagentpluginPlugin : public QQmlExtensionPlugin +class ConnectionagentPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") @@ -32,5 +32,10 @@ class ConnectionagentpluginPlugin : public QQmlExtensionPlugin }; -#endif // CONNECTIONAGENTPLUGIN_PLUGIN_H +void ConnectionagentPlugin::registerTypes(const char *uri) +{ + // @uri com.jolla.connection + qmlRegisterType(uri, 1, 0, "ConnectionAgent"); +} +#include "plugin.moc" diff --git a/rpm/connectionagent-qt5.spec b/rpm/connectionagent-qt5.spec index e210afa..90ce421 100644 --- a/rpm/connectionagent-qt5.spec +++ b/rpm/connectionagent-qt5.spec @@ -14,7 +14,6 @@ Requires: connman >= 1.21 BuildRequires: pkgconfig(Qt5Core) BuildRequires: pkgconfig(Qt5DBus) BuildRequires: pkgconfig(connman-qt5) -BuildRequires: pkgconfig(qofono-qt5) BuildRequires: pkgconfig(Qt5Network) BuildRequires: pkgconfig(Qt5Test) BuildRequires: pkgconfig(Qt5Qml) @@ -98,7 +97,7 @@ fi %files test %defattr(-,root,root,-) -%{_prefix}/opt/tests/libqofono/* +%{_prefix}/opt/tests/connectionagent/* %files tracing %defattr(-,root,root,-) diff --git a/test/auto/tst_connectionagent/tst_connectionagent.cpp b/test/auto/tst_connectionagent/tst_connectionagent.cpp index 4da5767..96b9092 100644 --- a/test/auto/tst_connectionagent/tst_connectionagent.cpp +++ b/test/auto/tst_connectionagent/tst_connectionagent.cpp @@ -33,45 +33,23 @@ class Tst_connectionagent : public QObject { Q_OBJECT -public: - Tst_connectionagent(); - private Q_SLOTS: - void tst_networkInstance(); - void tst_restartconnman(); - void tst_onUserInputRequested(); void tst_onUserInputCanceled(); void tst_onErrorReported(); void tst_onConnectionRequest(); - void tst_sendConnectReply(); - void tst_sendUserReply(); - void tst_connectToType(); -}; - -Tst_connectionagent::Tst_connectionagent() -{ -} -void Tst_connectionagent::tst_networkInstance() -{ - NetworkManager *netman = NetworkManagerFactory::createInstance(); - QString currentState = netman->state(); - QConnectionAgent::instance(); - QVERIFY(currentState == netman->state()); -} - -void Tst_connectionagent::tst_restartconnman() -{ -} +private: + QConnectionAgent agent; +}; void Tst_connectionagent::tst_onUserInputRequested() { - QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(userInputRequested(QString,QVariantMap))); + QSignalSpy spy(&agent, SIGNAL(userInputRequested(QString,QVariantMap))); QVariantMap map; map.insert("test",true); - QConnectionAgent::instance().onUserInputRequested(QLatin1String("test_path"), map); + agent.onUserInputRequested(QLatin1String("test_path"), map); QCOMPARE(spy.count(),1); QList arguments; arguments = spy.takeFirst(); @@ -83,15 +61,15 @@ void Tst_connectionagent::tst_onUserInputRequested() void Tst_connectionagent::tst_onUserInputCanceled() { - QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(userInputCanceled())); - QConnectionAgent::instance().onUserInputCanceled(); + QSignalSpy spy(&agent, SIGNAL(userInputCanceled())); + agent.onUserInputCanceled(); QCOMPARE(spy.count(),1); } void Tst_connectionagent::tst_onErrorReported() { - QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(errorReported(QString,QString))); - QConnectionAgent::instance().onErrorReported("test_path","Test error"); + QSignalSpy spy(&agent, SIGNAL(errorReported(QString,QString))); + agent.onErrorReported("test_path","Test error"); QCOMPARE(spy.count(),1); QList arguments; @@ -99,7 +77,7 @@ void Tst_connectionagent::tst_onErrorReported() QCOMPARE(arguments.at(0).toString(), QString("test_path")); QCOMPARE(arguments.at(1).toString(), QString("Test error")); - QConnectionAgent::instance().connectToType("test"); + agent.connectToType("test"); QCOMPARE(spy.count(),1); arguments = spy.takeFirst(); QCOMPARE(arguments.at(0).toString(), QString("")); @@ -116,8 +94,8 @@ void Tst_connectionagent::tst_onConnectionRequest() service->requestDisconnect(); // service->requestConnect(); } - QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(connectionRequest())); - QConnectionAgent::instance().onConnectionRequest(); + QSignalSpy spy(&agent, SIGNAL(connectionRequest())); + agent.onConnectionRequest(); if (currentState == "online") QCOMPARE(spy.count(),0); @@ -126,19 +104,6 @@ void Tst_connectionagent::tst_onConnectionRequest() } -void Tst_connectionagent::tst_sendConnectReply() -{ -} - -void Tst_connectionagent::tst_sendUserReply() -{ -} - -void Tst_connectionagent::tst_connectToType() -{ -} - - QTEST_APPLESS_MAIN(Tst_connectionagent) #include "tst_connectionagent.moc" diff --git a/test/auto/tst_connectionagent/tst_connectionagent.pro b/test/auto/tst_connectionagent/tst_connectionagent.pro index 18599a8..a228fad 100644 --- a/test/auto/tst_connectionagent/tst_connectionagent.pro +++ b/test/auto/tst_connectionagent/tst_connectionagent.pro @@ -21,5 +21,5 @@ HEADERS += \ INCLUDEPATH += $$OUT_PWD/../../../connd CONFIG += link_pkgconfig -PKGCONFIG += connman-qt5 qofono-qt5 +PKGCONFIG += connman-qt5 diff --git a/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugin.pro b/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugin.pro index 6d91b9b..d8f2e04 100644 --- a/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugin.pro +++ b/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugin.pro @@ -1,11 +1,4 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-05-28T05:39:06 -# -#------------------------------------------------- - QT += testlib dbus network - QT -= gui TARGET = tst_connectionagent_plugintest @@ -16,10 +9,10 @@ TEMPLATE = app SOURCES += tst_connectionagent_plugintest.cpp \ - ../../../connectionagentplugin/connectionagentplugin.cpp + ../../../connectionagentplugin/declarativeconnectionagent.cpp HEADERS += \ - ../../../connectionagentplugin/connectionagentplugin.h + ../../../connectionagentplugin/declarativeconnectionagent.h DBUS_INTERFACES = connectiond_interface connectiond_interface.files = ../../../connd/com.jollamobile.Connectiond.xml @@ -28,10 +21,8 @@ connectiond_interface.source_flags = "-c ConnectionManagerInterface" DEFINES += SRCDIR=\\\"$$PWD/\\\" -INCLUDEPATH += ../../../connectiongentplugin - CONFIG += link_pkgconfig PKGCONFIG += connman-qt5 -target.path = $$[QT_INSTALL_PREFIX]/opt/tests/libqofono/ +target.path = $$[QT_INSTALL_PREFIX]/opt/tests/connectionagent/ INSTALLS += target diff --git a/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugintest.cpp b/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugintest.cpp index 743aa87..0246823 100644 --- a/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugintest.cpp +++ b/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugintest.cpp @@ -20,7 +20,7 @@ #include #include -#include "../../../connectionagentplugin/connectionagentplugin.h" +#include "../../../connectionagentplugin/declarativeconnectionagent.h" #include #include @@ -49,13 +49,13 @@ private Q_SLOTS: void tst_tethering(); private: - ConnectionAgentPlugin *plugin; - NetworkManager *netman; + DeclarativeConnectionAgent *plugin; + NetworkManager *netman; }; Tst_connectionagent_pluginTest::Tst_connectionagent_pluginTest() { - plugin = new ConnectionAgentPlugin(this); + plugin = new DeclarativeConnectionAgent(this); netman = NetworkManagerFactory::createInstance(); QTest::qWait(5000); } @@ -154,7 +154,7 @@ void Tst_connectionagent_pluginTest::testUserInputRequested() void Tst_connectionagent_pluginTest::tst_tethering() { - NetworkService *wlanService; + NetworkService *wlanService = 0; NetworkService *mobiledataService; QVector wifiServices = netman->getServices("wifi");