Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add license files and make work
  • Loading branch information
Lorn Potter committed Mar 19, 2013
1 parent a871c7f commit 78b452f
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 96 deletions.
28 changes: 15 additions & 13 deletions connd/connadaptor.cpp
@@ -1,12 +1,18 @@
/*
* This file was generated by qdbusxml2cpp version 0.7
* Command line was: qdbusxml2cpp -c ConnAdaptor -a connadaptor.h:connadaptor.cpp com.jolla.Connectiond.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.
*/
/****************************************************************************
**
** 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 "connadaptor.h"
#include <QtCore/QMetaObject>
Expand All @@ -24,25 +30,21 @@
ConnAdaptor::ConnAdaptor(QObject *parent)
: QDBusAbstractAdaptor(parent)
{
// constructor
setAutoRelaySignals(true);
}

ConnAdaptor::~ConnAdaptor()
{
// destructor
}

void ConnAdaptor::sendConnectReply(const QString &in0, int in1)
{
qDebug() << Q_FUNC_INFO << in0 << in1;
// handle method call com.jolla.Connectiond.sendConnectReply
QMetaObject::invokeMethod(parent(), "sendConnectReply", Q_ARG(QString, in0), Q_ARG(int, in1));
}

void ConnAdaptor::sendUserReply(const QVariantMap &input)
{
qDebug() << Q_FUNC_INFO << input;
// handle method call com.jolla.Connectiond.sendUserReply
QMetaObject::invokeMethod(parent(), "sendUserReply", Q_ARG(QVariantMap, input));
}
Expand Down
15 changes: 15 additions & 0 deletions connd/main.cpp
@@ -1,3 +1,18 @@
/****************************************************************************
**
** 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 <QtCore/QCoreApplication>
#include <QTimer>
Expand Down
39 changes: 3 additions & 36 deletions connd/qconnectionmanager.cpp
@@ -1,42 +1,17 @@
/****************************************************************************
**
** Copyright (C) 2012 Jolla Ltd.
** Copyright (C) 2013 Jolla Ltd
** Contact: lorn.potter@gmail.com
**
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qconnectionmanager.h"
Expand Down Expand Up @@ -109,31 +84,26 @@ void QConnectionManager::onUserInputRequested(const QString &servicePath, const
{
// gets called when a connman service gets called to connect and needs more configurations.

qDebug() << Q_FUNC_INFO;// << servicePath << fields;
Q_EMIT userInputRequested(servicePath, fields);
}

// from useragent
void QConnectionManager::onUserInputCanceled()
{
qDebug() << Q_FUNC_INFO;
Q_EMIT userInputCanceled();
}

// from useragent
void QConnectionManager::onErrorReported(const QString &error)
{
qDebug() << Q_FUNC_INFO << error;
Q_EMIT errorReported(error);
}

// from useragent
void QConnectionManager::onConnectionRequest()
{
qDebug() << Q_FUNC_INFO;
// if (!autoConnect()) {
Q_EMIT connectionRequest();

// }
}

Expand All @@ -144,13 +114,11 @@ void QConnectionManager::sendMessage()

void QConnectionManager::sendConnectReply(const QString &in0, int in1)
{
qDebug() << Q_FUNC_INFO << in0 << in1;
ua->sendConnectReply(in0, in1);
}

void QConnectionManager::sendUserReply(const QVariantMap &input)
{
qDebug() << Q_FUNC_INFO;
ua->sendUserReply(input);
}

Expand Down Expand Up @@ -197,12 +165,11 @@ void QConnectionManager::serviceErrorChanged(const QString &error)

void QConnectionManager::stateChanged(const QString &state)
{
qDebug() << Q_FUNC_INFO << state;
Q_UNUSED(state)
}

bool QConnectionManager::autoConnect()
{
qDebug() << Q_FUNC_INFO;
QStringList techList = netman->technologiesList();
Q_FOREACH (const QString &tech, techList) {

Expand Down
39 changes: 26 additions & 13 deletions connectionagentplugin/connectionagentplugin.cpp
@@ -1,3 +1,18 @@
/****************************************************************************
**
** 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.h"
#include "connectionamanagerinterface.h"

Expand All @@ -9,8 +24,6 @@
ConnectionAgentPlugin::ConnectionAgentPlugin(QObject *parent):
QObject(parent)
{
qDebug() << Q_FUNC_INFO << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" << this;

connectiondWatcher = new QDBusServiceWatcher(CONND_SERVICE,QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration |
QDBusServiceWatcher::WatchForUnregistration, this);
Expand All @@ -20,14 +33,7 @@ ConnectionAgentPlugin::ConnectionAgentPlugin(QObject *parent):
connect(connectiondWatcher, SIGNAL(serviceUnregistered(QString)),
this, SLOT(connectiondUnregistered(QString)));

bool available = QDBusConnection::sessionBus().interface()->isServiceRegistered(CONND_SERVICE);

if(available) {
connectToConnectiond();
qDebug() << Q_FUNC_INFO << CONND_SERVICE << "success!!";
} else {
qDebug() << Q_FUNC_INFO << CONND_SERVICE << "not available";
}
}

ConnectionAgentPlugin::~ConnectionAgentPlugin()
Expand All @@ -36,7 +42,6 @@ ConnectionAgentPlugin::~ConnectionAgentPlugin()

void ConnectionAgentPlugin::sendUserReply(const QVariantMap &input)
{
qDebug() << Q_FUNC_INFO << this << sender();
QDBusPendingReply<> reply = connManagerInterface->sendUserReply(input);
if (reply.isError()) {
qDebug() << Q_FUNC_INFO << reply.error().message();
Expand All @@ -45,13 +50,11 @@ void ConnectionAgentPlugin::sendUserReply(const QVariantMap &input)

void ConnectionAgentPlugin::sendConnectReply(const QString &replyMessage, int timeout)
{
qDebug() << Q_FUNC_INFO << replyMessage << timeout;
connManagerInterface->sendConnectReply(replyMessage,timeout);
}

void ConnectionAgentPlugin::onErrorReported(const QString &error)
{
qDebug() << Q_FUNC_INFO << error;
Q_EMIT errorReported(error);
}

Expand All @@ -78,7 +81,6 @@ void ConnectionAgentPlugin::onUserInputRequested(const QString &service, const Q

void ConnectionAgentPlugin::onConnectionRequested()
{
qDebug() << Q_FUNC_INFO;
Q_EMIT connectionRequest();
}

Expand All @@ -88,6 +90,17 @@ void ConnectionAgentPlugin::connectToConnectiond(QString)
delete connManagerInterface;
connManagerInterface = 0;
}

bool available = QDBusConnection::sessionBus().interface()->isServiceRegistered(CONND_SERVICE);

if(!available) {
QDBusReply<void> reply = QDBusConnection::sessionBus().interface()->startService(CONND_SERVICE);
if (!reply.isValid()) {
qDebug() << Q_FUNC_INFO << reply.error().message();
return;
}
}

connManagerInterface = new com::jolla::Connectiond(CONND_SERVICE, CONND_PATH, QDBusConnection::sessionBus(), this);

connect(connManagerInterface,SIGNAL(connectionRequest()),
Expand Down
21 changes: 18 additions & 3 deletions connectionagentplugin/connectionagentplugin.h
@@ -1,3 +1,19 @@
/****************************************************************************
**
** 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.
**
****************************************************************************/

#ifndef CONNECTIONAGENTPLUGIN_H
#define CONNECTIONAGENTPLUGIN_H

Expand All @@ -8,10 +24,10 @@
class ConnectionAgentPlugin : public QObject
{
Q_OBJECT
// Q_DISABLE_COPY(ConnectionAgentPlugin)
Q_DISABLE_COPY(ConnectionAgentPlugin)

public:
ConnectionAgentPlugin(QObject *parent = 0);
explicit ConnectionAgentPlugin(QObject *parent = 0);
~ConnectionAgentPlugin();

public slots:
Expand All @@ -24,7 +40,6 @@ public slots:
void errorReported(const QString &error);
void connectionRequest();

// void userConnectRequested(const QDBusMessage &message);
private:
com::jolla::Connectiond *connManagerInterface;
QDBusServiceWatcher *connectiondWatcher;
Expand Down
51 changes: 51 additions & 0 deletions connectionagentplugin/connectionagentplugin_plugin.cpp
@@ -1,8 +1,59 @@
/****************************************************************************
**
** 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"

#include <qdeclarative.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 deamon 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)
{
qDebug() << Q_FUNC_INFO << uri;
Expand Down
16 changes: 16 additions & 0 deletions connectionagentplugin/connectionagentplugin_plugin.h
@@ -1,3 +1,19 @@
/****************************************************************************
**
** 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.
**
****************************************************************************/

#ifndef CONNECTIONAGENTPLUGIN_PLUGIN_H
#define CONNECTIONAGENTPLUGIN_PLUGIN_H

Expand Down

0 comments on commit 78b452f

Please sign in to comment.