diff --git a/connd/connadaptor.cpp b/connd/connadaptor.cpp index 94a1d1e..7348d4d 100644 --- a/connd/connadaptor.cpp +++ b/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 @@ -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)); } diff --git a/connd/main.cpp b/connd/main.cpp index d7a3c6b..4f49b7d 100644 --- a/connd/main.cpp +++ b/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 #include diff --git a/connd/qconnectionmanager.cpp b/connd/qconnectionmanager.cpp index aaef575..cdad241 100644 --- a/connd/qconnectionmanager.cpp +++ b/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" @@ -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(); - // } } @@ -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); } @@ -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) { diff --git a/connectionagentplugin/connectionagentplugin.cpp b/connectionagentplugin/connectionagentplugin.cpp index 468c144..cb3caea 100644 --- a/connectionagentplugin/connectionagentplugin.cpp +++ b/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" @@ -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); @@ -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"; - } + connectToConnectiond(); } ConnectionAgentPlugin::~ConnectionAgentPlugin() @@ -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(); @@ -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); } @@ -78,7 +81,6 @@ void ConnectionAgentPlugin::onUserInputRequested(const QString &service, const Q void ConnectionAgentPlugin::onConnectionRequested() { - qDebug() << Q_FUNC_INFO; Q_EMIT connectionRequest(); } @@ -88,6 +90,17 @@ void ConnectionAgentPlugin::connectToConnectiond(QString) delete connManagerInterface; connManagerInterface = 0; } + + bool available = QDBusConnection::sessionBus().interface()->isServiceRegistered(CONND_SERVICE); + + if(!available) { + QDBusReply 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()), diff --git a/connectionagentplugin/connectionagentplugin.h b/connectionagentplugin/connectionagentplugin.h index 1bace44..25804f9 100644 --- a/connectionagentplugin/connectionagentplugin.h +++ b/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 @@ -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: @@ -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; diff --git a/connectionagentplugin/connectionagentplugin_plugin.cpp b/connectionagentplugin/connectionagentplugin_plugin.cpp index 2f9a327..a8a9d1a 100644 --- a/connectionagentplugin/connectionagentplugin_plugin.cpp +++ b/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 +/* + *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; diff --git a/connectionagentplugin/connectionagentplugin_plugin.h b/connectionagentplugin/connectionagentplugin_plugin.h index 90d8d6a..9d7de1f 100644 --- a/connectionagentplugin/connectionagentplugin_plugin.h +++ b/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 diff --git a/connectionagentplugin/connectionamanagerinterface.cpp b/connectionagentplugin/connectionamanagerinterface.cpp index e5909be..3fef0bd 100644 --- a/connectionagentplugin/connectionamanagerinterface.cpp +++ b/connectionagentplugin/connectionamanagerinterface.cpp @@ -1,13 +1,19 @@ -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp ../connd/com.jolla.Connectiond.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. - */ +/**************************************************************************** +** +** 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 "connectionamanagerinterface.h" diff --git a/connectionagentplugin/connectionamanagerinterface.h b/connectionagentplugin/connectionamanagerinterface.h index 24e0673..9a03ce1 100644 --- a/connectionagentplugin/connectionamanagerinterface.h +++ b/connectionagentplugin/connectionamanagerinterface.h @@ -1,12 +1,19 @@ -/* - * This file was generated by qdbusxml2cpp version 0.7 - * Command line was: qdbusxml2cpp ../connd/com.jolla.Connectiond.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. - */ +/**************************************************************************** +** +** 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 CONNECTIONAMANAGERINTERFACE_H_1363426405 #define CONNECTIONAMANAGERINTERFACE_H_1363426405 diff --git a/rpm/com.jolla.Connectiond.service b/rpm/com.jolla.Connectiond.service new file mode 100644 index 0000000..5f78dc3 --- /dev/null +++ b/rpm/com.jolla.Connectiond.service @@ -0,0 +1,6 @@ +# (Lines starting with hash marks are comments) + +# Fixed section header (do not change): +[D-BUS Service] +Name=com.jolla.Connectiond +Exec=/usr/bin/connectionagent diff --git a/rpm/connectionagent.service b/rpm/connectionagent.service deleted file mode 100644 index 8d7de29..0000000 --- a/rpm/connectionagent.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Connection daemon for connman UserAgent -Requires=dbus.socket dbus.service - -[Service] -ExecStart=/usr/bin/connectionagent -Restart=always -BusName=com.jolla.Connectiond -Type=dbus - -[Install] -WantedBy=jolla-middleware.target \ No newline at end of file