diff --git a/connectionagentplugin/connectionagentplugin.pro b/connectionagentplugin/connectionagentplugin.pro index 348bf0d..385b3f4 100644 --- a/connectionagentplugin/connectionagentplugin.pro +++ b/connectionagentplugin/connectionagentplugin.pro @@ -7,11 +7,11 @@ uri = com.jolla.connection SOURCES += \ connectionagentplugin_plugin.cpp \ - connectionagentplugin.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 index 2bb15f0..7f265b5 100644 --- a/connectionagentplugin/connectionagentplugin_plugin.cpp +++ b/connectionagentplugin/connectionagentplugin_plugin.cpp @@ -15,45 +15,10 @@ ****************************************************************************/ #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); - * } - * } - * - **/ +#include "declarativeconnectionagent.h" void ConnectionagentpluginPlugin::registerTypes(const char *uri) { // @uri com.jolla.connection - qmlRegisterType(uri, 1, 0, "ConnectionAgent"); + 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/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugin.pro b/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugin.pro index 6d91b9b..59b4649 100644 --- a/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugin.pro +++ b/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugin.pro @@ -16,10 +16,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 diff --git a/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugintest.cpp b/test/auto/tst_connectionagent_plugin/tst_connectionagent_plugintest.cpp index 743aa87..082c536 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); }