Commit c7a25125 authored by Pekka Vuorela's avatar Pekka Vuorela

Rename ConnectionAgentPlugin as DeclarativeConnectionAgent

Qml type is not a plugin really.
parent 4f608a33
......@@ -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
......
......@@ -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<ConnectionAgentPlugin>(uri, 1, 0, "ConnectionAgent");
qmlRegisterType<DeclarativeConnectionAgent>(uri, 1, 0, "ConnectionAgent");
}
......@@ -14,7 +14,7 @@
**
****************************************************************************/
#include "connectionagentplugin.h"
#include "declarativeconnectionagent.h"
#include "connectiond_interface.h"
#include <connman-qt5/networkmanager.h>
......@@ -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 <<url;
Q_EMIT browserRequested(url);
}
void ConnectionAgentPlugin::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 need to manually demarshall
......@@ -152,13 +152,13 @@ void ConnectionAgentPlugin::onUserInputRequested(const QString &service, const Q
Q_EMIT userInputRequested(service, map);
}
void ConnectionAgentPlugin::onConnectionRequested()
void DeclarativeConnectionAgent::onConnectionRequested()
{
qDebug() << Q_FUNC_INFO;
Q_EMIT connectionRequest();
}
void ConnectionAgentPlugin::connectiondUnregistered(QString)
void DeclarativeConnectionAgent::connectiondUnregistered(QString)
{
if (connManagerInterface) {
delete connManagerInterface;
......@@ -166,23 +166,23 @@ void ConnectionAgentPlugin::connectiondUnregistered(QString)
}
}
void ConnectionAgentPlugin::onConnectionState(const QString &state, const QString &type)
void DeclarativeConnectionAgent::onConnectionState(const QString &state, const QString &type)
{
qDebug() << Q_FUNC_INFO << state;
Q_EMIT connectionState(state, type);
}
void ConnectionAgentPlugin::startTethering(const QString &type)
void DeclarativeConnectionAgent::startTethering(const QString &type)
{
connManagerInterface->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);
}
......@@ -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
......@@ -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
......
......@@ -20,7 +20,7 @@
#include <QString>
#include <QtTest>
#include "../../../connectionagentplugin/connectionagentplugin.h"
#include "../../../connectionagentplugin/declarativeconnectionagent.h"
#include <networkmanager.h>
#include <networktechnology.h>
......@@ -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);
}
......
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