Commit aa869b24 authored by Lorn Potter's avatar Lorn Potter

move libconnman-qt stuff here from liblipstick

parent f11e5cdd
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="com.jolla.Connectiond">
<method name="sendUserReply">
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In0"/>
<arg type="a{sv}" name="input"/>
</method>
<method name="sendConnectReply">
<arg direction="in" type="s"/>
<arg direction="in" type="i"/>
</method>
<signal name="userInputRequested">
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In1"/>
<arg type="s" name="service"/>
<arg type="a{sv}" name="fields"/>
</signal>
<signal name="userInputCanceled"/>
<signal name="connectionRequest"/>
<signal name="configurationNeeded"/>
<signal name="errorReported">
<arg type="s" name="error"/>
<arg direction="out" type="s" name="error"/>
</signal>
<signal name="requestBrowser">
<arg type="s" name="url"/>
<arg direction="out" type="s" name="url"/>
</signal>
<signal name="connectionRequest"/>
<signal name="userInputCanceled"/>
<signal name="userInputRequested">
<arg direction="out" type="s" name="service"/>
<arg direction="out" type="a{sv}" name="fields"/>
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In1"/>
</signal>
<method name="sendConnectReply">
<arg direction="in" type="s" name="in0"/>
<arg direction="in" type="i" name="in1"/>
</method>
<method name="sendUserReply">
<arg direction="in" type="a{sv}" name="input"/>
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In0"/>
</method>
<method name="connectToType">
<arg direction="in" type="s" name="in0"/>
</method>
</interface>
</node>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="com.jolla.Connectiond">
<method name="sendUserReply">
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In0"/>
<arg type="a{sv}" name="input"/>
</method>
<method name="sendConnectReply">
<arg direction="in" type="s"/>
<arg direction="in" type="i"/>
</method>
<signal name="userInputRequested">
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In1"/>
<arg type="s" name="service"/>
<arg type="a{sv}" name="fields "/>
</signal>
<signal name="userInputCanceled"/>
<signal name="connectionRequest"/>
<signal name="wlanConfigurationNeeded"/>
<signal name="errorReported">
<arg type="s" name="service"/>
<arg type="s" name="error"/>
<arg direction="out" type="s" name="error"/>
</signal>
<signal name="requestBrowser">
<arg type="s" name="service"/>
<arg type="s" name="url"/>
<arg direction="out" type="s" name="url"/>
</signal>
<signal name="connectionRequest"/>
<signal name="userInputCanceled"/>
<signal name="userInputRequested">
<arg direction="out" type="s" name="service"/>
<arg direction="out" type="a{sv}" name="fields"/>
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In1"/>
</signal>
<method name="sendConnectReply">
<arg direction="in" type="s" name="in0"/>
<arg direction="in" type="i" name="in1"/>
</method>
<method name="sendUserReply">
<arg direction="in" type="a{sv}" name="input"/>
<annotation value="QVariantMap" name="org.qtproject.QtDBus.QtTypeName.In0"/>
</method>
<method name="connectToType">
<arg direction="in" type="s" name="in0"/>
</method>
</interface>
</node>
/****************************************************************************
**
** 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.
**
****************************************************************************/
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -v -c ConnAdaptor -a connadaptor.h:connadaptor.cpp conn.xml
*
* qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#include "connadaptor.h"
#include <QtCore/QMetaObject>
......@@ -30,11 +24,19 @@
ConnAdaptor::ConnAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
// constructor
setAutoRelaySignals(true);
}
ConnAdaptor::~ConnAdaptor()
{
// destructor
}
void ConnAdaptor::connectToType(const QString &in0)
{
// handle method call com.jolla.Connectiond.connectToType
QMetaObject::invokeMethod(parent(), "connectToType", Q_ARG(QString, in0));
}
void ConnAdaptor::sendConnectReply(const QString &in0, int in1)
......
/****************************************************************************
**
** 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.
**
****************************************************************************/
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -v -c ConnAdaptor -a connadaptor.h:connadaptor.cpp conn.xml
*
* qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#ifndef CONNADAPTOR_H_1363412350
#define CONNADAPTOR_H_1363412350
#ifndef CONNADAPTOR_H_1363743442
#define CONNADAPTOR_H_1363743442
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
......@@ -35,27 +30,31 @@ class ConnAdaptor: public QDBusAbstractAdaptor
Q_CLASSINFO("D-Bus Interface", "com.jolla.Connectiond")
Q_CLASSINFO("D-Bus Introspection", ""
" <interface name=\"com.jolla.Connectiond\">\n"
" <method name=\"sendUserReply\">\n"
" <annotation value=\"QVariantMap\" name=\"org.qtproject.QtDBus.QtTypeName.In0\"/>\n"
" <arg type=\"a{sv}\" name=\"input\"/>\n"
" </method>\n"
" <method name=\"sendConnectReply\">\n"
" <arg direction=\"in\" type=\"s\"/>\n"
" <arg direction=\"in\" type=\"i\"/>\n"
" </method>\n"
" <signal name=\"userInputRequested\">\n"
" <annotation value=\"QVariantMap\" name=\"org.qtproject.QtDBus.QtTypeName.In1\"/>\n"
" <arg type=\"s\" name=\"service\"/>\n"
" <arg type=\"a{sv}\" name=\"fields \"/>\n"
" </signal>\n"
" <signal name=\"userInputCanceled\"/>\n"
" <signal name=\"connectionRequest\"/>\n"
" <signal name=\"wlanConfigurationNeeded\"/>\n"
" <signal name=\"errorReported\">\n"
" <arg type=\"s\" name=\"error\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"error\"/>\n"
" </signal>\n"
" <signal name=\"requestBrowser\">\n"
" <arg type=\"s\" name=\"url\"/>\n"
" <arg direction=\"out\" type=\"s\" name=\"url\"/>\n"
" </signal>\n"
" <signal name=\"connectionRequest\"/>\n"
" <signal name=\"userInputCanceled\"/>\n"
" <signal name=\"userInputRequested\">\n"
" <arg direction=\"out\" type=\"s\" name=\"service\"/>\n"
" <arg direction=\"out\" type=\"a{sv}\" name=\"fields\"/>\n"
" <annotation value=\"QVariantMap\" name=\"org.qtproject.QtDBus.QtTypeName.In1\"/>\n"
" </signal>\n"
" <method name=\"sendConnectReply\">\n"
" <arg direction=\"in\" type=\"s\" name=\"in0\"/>\n"
" <arg direction=\"in\" type=\"i\" name=\"in1\"/>\n"
" </method>\n"
" <method name=\"sendUserReply\">\n"
" <arg direction=\"in\" type=\"a{sv}\" name=\"input\"/>\n"
" <annotation value=\"QVariantMap\" name=\"org.qtproject.QtDBus.QtTypeName.In0\"/>\n"
" </method>\n"
" <method name=\"connectToType\">\n"
" <arg direction=\"in\" type=\"s\" name=\"in0\"/>\n"
" </method>\n"
" </interface>\n"
"")
public:
......@@ -64,6 +63,7 @@ public:
public: // PROPERTIES
public Q_SLOTS: // METHODS
void connectToType(const QString &in0);
void sendConnectReply(const QString &in0, int in1);
void sendUserReply(const QVariantMap &input);
Q_SIGNALS: // SIGNALS
......@@ -72,6 +72,7 @@ Q_SIGNALS: // SIGNALS
void requestBrowser(const QString &url);
void userInputCanceled();
void userInputRequested(const QString &service, const QVariantMap &fields);
void wlanConfigurationNeeded();
};
#endif
......@@ -3,7 +3,7 @@ QT += core network dbus gui
QT -= gui
TARGET = connectionagent
CONFIG += console
CONFIG += console link_pkgconfig
CONFIG -= app_bundle
TEMPLATE = app
......
......@@ -35,7 +35,10 @@ QConnectionManager* QConnectionManager::self = NULL;
QConnectionManager::QConnectionManager(QObject *parent) :
QObject(parent),
netman(NetworkManagerFactory::createInstance())
netman(NetworkManagerFactory::createInstance()),
okToConnect(0),
currentNetworkState(QString()),
currentType(QString())
{
connectionAdaptor = new ConnAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus();
......@@ -102,9 +105,12 @@ void QConnectionManager::onErrorReported(const QString &error)
// from useragent
void QConnectionManager::onConnectionRequest()
{
// if (!autoConnect()) {
qDebug() << Q_FUNC_INFO;
if (!autoConnect()) {
qDebug() << Q_FUNC_INFO << "emit connectionRequest";
Q_EMIT connectionRequest();
// }
}
}
void QConnectionManager::sendMessage()
......@@ -150,6 +156,18 @@ void QConnectionManager::networkStateChanged(const QString &state)
void QConnectionManager::onServiceAdded(const QString &servicePath)
{
// qDebug() << Q_FUNC_INFO << servicePath;
if (okToConnect) {
NetworkService *netService;
netService = new NetworkService(this);
netService->setPath(servicePath);
if (netService->favorite()) {
QObject::connect(netService, SIGNAL(stateChanged(QString)),
this,SLOT(stateChanged(QString)));
QObject::connect(netService, SIGNAL(connectRequestFailed(QString)),
this,SLOT(serviceErrorChanged(QString)));
netService->requestConnect();
}
}
}
void QConnectionManager::serviceErrorChanged(const QString &error)
......@@ -166,6 +184,27 @@ void QConnectionManager::serviceErrorChanged(const QString &error)
void QConnectionManager::stateChanged(const QString &state)
{
Q_UNUSED(state)
// QString msg;
// if (currentNetworkState == "idle" && state == "association") {
// msg = "Connecting...";
// } else if (currentNetworkState == "ready" && state == "online") {
// msg = "Connected";
// } else if (state == "offline") {
// msg = "Offline";
// }
// qDebug() << Q_FUNC_INFO << currentNetworkState << state << msg;
//// NotificationManager *manager = NotificationManager::instance();
//// QVariantHash hints;
//// hints.insert(NotificationManager::HINT_URGENCY, 2);
//// hints.insert(NotificationManager::HINT_CATEGORY, "device.error");
//// hints.insert(NotificationManager::HINT_PREVIEW_BODY, msg);
//// manager->Notify(qApp->applicationName(), 0, QString(), QString(), QString(), QStringList(), hints, -1);
// if (!msg.isEmpty()) {
// emit serviceStateChanged(msg);
// }
// currentNetworkState = state;
}
bool QConnectionManager::autoConnect()
......@@ -184,10 +223,78 @@ bool QConnectionManager::autoConnect()
this,SLOT(serviceErrorChanged(QString)));
service->requestConnect();
qDebug() << Q_FUNC_INFO << true;
return true;
}
}
}
qDebug() << Q_FUNC_INFO << false;
return false;
}
void QConnectionManager::connectToType(const QString &type)
{
qDebug() << Q_FUNC_INFO << type;
currentType = type;
QString techPath = netman->technologyPathForType(type);
NetworkTechnology netTech;
netTech.setPath(techPath);
if (!netTech.powered()) {
netTech.setPowered(true);
}
QStringList servicesList = netman->servicesList(type);
qDebug() << servicesList;
if (servicesList.isEmpty()) {
if (type == "wifi") {
QObject::connect(&netTech,SIGNAL(scanFinished()),this,SLOT(onScanFinished()));
netTech.scan();
} else {
onScanFinished();
}
} else {
NetworkService *netService;
netService = new NetworkService(this);
bool needConfig = false;
Q_FOREACH (const QString path, servicesList) {
netService->setPath(path);
if (netService->favorite()) {
qDebug() << "power on, fav";
needConfig = false;
QObject::connect(netService, SIGNAL(stateChanged(QString)),
this,SLOT(stateChanged(QString)));
QObject::connect(netService, SIGNAL(connectRequestFailed(QString)),
this,SLOT(serviceErrorChanged(QString)));
qDebug() << Q_FUNC_INFO << "just connect to this thing";
//window->rootContext()->setContextProperty("connecting", QVariant(true));
// NetworkTechnology *tech = netman->getTechnology(netService->type());
// tech->setIdleTimeout(120);
netService->requestConnect();
okToConnect = false;
return;
} else {
needConfig = true;
}
}
if (needConfig) {
qDebug() << Q_FUNC_INFO << "no favorite service found. Configuration needed";
Q_EMIT wlanConfigurationNeeded();
}
}
}
void QConnectionManager::onScanFinished()
{
qDebug() << Q_FUNC_INFO;
}
......@@ -47,6 +47,7 @@ Q_SIGNALS:
void userInputCanceled();
void errorReported(const QString &error);
void connectionRequest();
void wlanConfigurationNeeded();
public Q_SLOTS:
......@@ -66,14 +67,23 @@ public Q_SLOTS:
void serviceErrorChanged(const QString &error);
void stateChanged(const QString &state);
void connectToType(const QString &type);
private:
explicit QConnectionManager(QObject *parent = 0);
static QConnectionManager *self;
ConnAdaptor *connectionAdaptor;
UserAgent *ua;
NetworkManager *netman;
bool autoConnect();
NetworkManager *netman;
bool okToConnect;
QString currentNetworkState;
QString currentType;
private slots:
void onScanFinished();
};
#endif // QCONNECTIONMANAGER_H
......@@ -17,6 +17,12 @@
#include "connectionagentplugin.h"
#include "connectionamanagerinterface.h"
#include <connman-qt/networkmanager.h>
#include <connman-qt/networktechnology.h>
#include <connman-qt/networkservice.h>
//#include "notifications/notificationmanager.h"
#include <qobject.h>
#define CONND_SERVICE "com.jolla.Connectiond"
......@@ -54,6 +60,12 @@ void ConnectionAgentPlugin::sendConnectReply(const QString &replyMessage, int ti
connManagerInterface->sendConnectReply(replyMessage,timeout);
}
void ConnectionAgentPlugin::connectToType(const QString &type)
{
qDebug() << Q_FUNC_INFO << type;;
connManagerInterface->connectToType(type);
}
void ConnectionAgentPlugin::onErrorReported(const QString &error)
{
Q_EMIT errorReported(error);
......@@ -106,6 +118,9 @@ void ConnectionAgentPlugin::connectToConnectiond(QString)
connect(connManagerInterface,SIGNAL(connectionRequest()),
this,SLOT(onConnectionRequested()));
connect(connManagerInterface,SIGNAL(wlanConfigurationNeeded()),
this,SIGNAL(wlanConfigurationNeeded()));
connect(connManagerInterface,SIGNAL(userInputCanceled()),
this,SIGNAL(userInputCanceled()));
......@@ -126,3 +141,9 @@ void ConnectionAgentPlugin::connectiondUnregistered(QString)
connManagerInterface = 0;
}
}
void ConnectionAgentPlugin::onWlanConfigurationNeeded()
{
qDebug() << Q_FUNC_INFO;
Q_EMIT wlanConfigurationNeeded();
}
......@@ -21,6 +21,7 @@
#include "connectionagentplugin.h"
#include "connectionamanagerinterface.h"
class NetworkManager;
class ConnectionAgentPlugin : public QObject
{
Q_OBJECT
......@@ -33,12 +34,14 @@ public:
public slots:
void sendUserReply(const QVariantMap &input);
void sendConnectReply(const QString &replyMessage, int timeout = 120);
void connectToType(const QString &type);
signals:
void userInputRequested(const QString &servicePath, const QVariantMap &fields);
void userInputCanceled();
void errorReported(const QString &error);
void connectionRequest();
void wlanConfigurationNeeded();
private:
com::jolla::Connectiond *connManagerInterface;
......@@ -49,6 +52,7 @@ private slots:
void onRequestBrowser(const QString &url);
void onUserInputRequested(const QString &service, const QVariantMap &fields);
void onConnectionRequested();
void onWlanConfigurationNeeded();
void connectToConnectiond(const QString = QString());
void connectiondUnregistered(const QString = QString());
......
......@@ -6,7 +6,7 @@ CONFIG += qt plugin
uri = com.jolla.connection
#create client
#system(qdbusxml2cpp ../connd/com.jolla.Connectiond.xml -c ConnectionManagerInterface -p connectionamanagerinterface)
system(qdbusxml2cpp ../connd/com.jolla.Connectiond.xml -c ConnectionManagerInterface -p connectionamanagerinterface)
SOURCES += \
connectionagentplugin_plugin.cpp \
......
/****************************************************************************
**
** 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.
**
****************************************************************************/
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp ../connd/conn.xml -c ConnectionManagerInterface -p connectionamanagerinterface
*
* qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
*
* This is an auto-generated file.
* This file may have been hand-edited. Look for HAND-EDIT comments
* before re-generating it.
*/
#include "connectionamanagerinterface.h"
......
/****************************************************************************
**
** 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.
**
****************************************************************************/
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp ../connd/conn.xml -c ConnectionManagerInterface -p connectionamanagerinterface
*
* qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
*
* This is an auto-generated file.
* Do not edit! All changes made to it will be lost.
*/
#ifndef CONNECTIONAMANAGERINTERFACE_H_1363426405
#define CONNECTIONAMANAGERINTERFACE_H_1363426405
#ifndef CONNECTIONAMANAGERINTERFACE_H_1363743454
#define CONNECTIONAMANAGERINTERFACE_H_1363743454
#include <QtCore/QObject>
#include <QtCore/QByteArray>
......@@ -43,6 +36,13 @@ public:
~ConnectionManagerInterface();
public Q_SLOTS: // METHODS
inline QDBusPendingReply<> connectToType(const QString &in0)
{
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(in0);
return asyncCallWithArgumentList(QLatin1String("connectToType"), argumentList);
}
inline QDBusPendingReply<> sendConnectReply(const QString &in0, int in1)
{
QList<QVariant> argumentList;
......@@ -52,7 +52,6 @@ public Q_SLOTS: // METHODS
inline QDBusPendingReply<> sendUserReply(const QVariantMap &input)
{
qDebug() << Q_FUNC_INFO;
QList<QVariant> argumentList;
argumentList << QVariant::fromValue(input);
return asyncCallWithArgumentList(QLatin1String("sendUserReply"), argumentList);
......@@ -64,6 +63,7 @@ Q_SIGNALS: // SIGNALS
void requestBrowser(const QString &url);
void userInputCanceled();
void userInputRequested(const QString &service, const QVariantMap &fields);
void wlanConfigurationNeeded();
};
namespace com {
......
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