From f1d884b6dad5a93d7a3077b6b05d3ec7fcd9a6ea Mon Sep 17 00:00:00 2001 From: Teemu Holappa Date: Thu, 11 Feb 2016 11:50:55 +0200 Subject: Refactored Qml plugins into modules. Separated C++ and Qml interfaces. All the UI's from plugins are moved to the settingsui folder. Change-Id: Id6a6623346b18321357bc42d24121c4d9cdfd098 Reviewed-by: Kimmo Ollila --- src/networksettings/connman/connman_manager.xml | 108 ++++++ src/networksettings/connman/connman_service.xml | 41 +++ src/networksettings/connman/connman_technology.xml | 23 ++ src/networksettings/connman/connmancommon.cpp | 97 +++++ src/networksettings/connman/connmancommon.h | 77 ++++ .../connman/qnetworksettingsinterface_p.cpp | 105 ++++++ .../connman/qnetworksettingsinterface_p.h | 92 +++++ .../connman/qnetworksettingsmanager_p.cpp | 171 +++++++++ .../connman/qnetworksettingsmanager_p.h | 72 ++++ .../connman/qnetworksettingsservice_p.cpp | 402 +++++++++++++++++++++ .../connman/qnetworksettingsservice_p.h | 84 +++++ .../connman/qnetworksettingsuseragent_p.cpp | 101 ++++++ .../connman/qnetworksettingsuseragent_p.h | 77 ++++ 13 files changed, 1450 insertions(+) create mode 100644 src/networksettings/connman/connman_manager.xml create mode 100644 src/networksettings/connman/connman_service.xml create mode 100644 src/networksettings/connman/connman_technology.xml create mode 100644 src/networksettings/connman/connmancommon.cpp create mode 100644 src/networksettings/connman/connmancommon.h create mode 100644 src/networksettings/connman/qnetworksettingsinterface_p.cpp create mode 100644 src/networksettings/connman/qnetworksettingsinterface_p.h create mode 100644 src/networksettings/connman/qnetworksettingsmanager_p.cpp create mode 100644 src/networksettings/connman/qnetworksettingsmanager_p.h create mode 100644 src/networksettings/connman/qnetworksettingsservice_p.cpp create mode 100644 src/networksettings/connman/qnetworksettingsservice_p.h create mode 100644 src/networksettings/connman/qnetworksettingsuseragent_p.cpp create mode 100644 src/networksettings/connman/qnetworksettingsuseragent_p.h (limited to 'src/networksettings/connman') diff --git a/src/networksettings/connman/connman_manager.xml b/src/networksettings/connman/connman_manager.xml new file mode 100644 index 0000000..5c52b27 --- /dev/null +++ b/src/networksettings/connman/connman_manager.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/networksettings/connman/connman_service.xml b/src/networksettings/connman/connman_service.xml new file mode 100644 index 0000000..c41aca4 --- /dev/null +++ b/src/networksettings/connman/connman_service.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/networksettings/connman/connman_technology.xml b/src/networksettings/connman/connman_technology.xml new file mode 100644 index 0000000..08d780f --- /dev/null +++ b/src/networksettings/connman/connman_technology.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/networksettings/connman/connmancommon.cpp b/src/networksettings/connman/connmancommon.cpp new file mode 100644 index 0000000..94a1fa1 --- /dev/null +++ b/src/networksettings/connman/connmancommon.cpp @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "connmancommon.h" + +//Conversion operations for datatypes +const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj) +{ + argument.beginStructure(); + argument >> obj.objectPath >> obj.propertyMap; + argument.endStructure(); + return argument; +} + +QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj) +{ + argument.beginStructure(); + argument << obj.objectPath << obj.propertyMap; + argument.endStructure(); + return argument; +} + +const QString &operator>>(const QString &argument, QNetworkSettingsType &obj) +{ + if (argument == AttributeEthernet) { + obj.setType(QNetworkSettingsType::Wired); + } + else if (argument == AttributeWifi) { + obj.setType(QNetworkSettingsType::Wifi); + } + else { + obj.setType(QNetworkSettingsType::Unknown); + } + + return argument; +} + +const QString &operator>>(const QString &argument, QNetworkSettingsState &obj) +{ + if (argument == AttributeIdle) { + obj.setState(QNetworkSettingsState::Idle); + } + else if (argument == AttributeFailure) { + obj.setState(QNetworkSettingsState::Failure); + } + else if (argument == AttributeAssociation) { + obj.setState(QNetworkSettingsState::Association); + } + else if (argument == AttributeConfiguration) { + obj.setState(QNetworkSettingsState::Configuration); + } + else if (argument == AttributeReady) { + obj.setState(QNetworkSettingsState::Ready); + } + else if (argument == AttributeDisconnect) { + obj.setState(QNetworkSettingsState::Disconnect); + } + else if (argument == AttributeOneline) { + obj.setState(QNetworkSettingsState::Online); + } + else { + obj.setState(QNetworkSettingsState::Undefined); + } + return argument; +} diff --git a/src/networksettings/connman/connmancommon.h b/src/networksettings/connman/connmancommon.h new file mode 100644 index 0000000..16850ea --- /dev/null +++ b/src/networksettings/connman/connmancommon.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CONNMANCOMMON_H +#define CONNMANCOMMON_H + +#include +#include +#include + +#define AgentPath "/ConnmanAgent" +#define PropertyState QStringLiteral("State") +#define PropertyName QStringLiteral("Name") +#define PropertyType QStringLiteral("Type") +#define PropertyConnected QStringLiteral("Connected") +#define PropertyPowered QStringLiteral("Powered") + +#define AttributeWifi QStringLiteral("wifi") +#define AttributeEthernet QStringLiteral("ethernet") +#define AttributeIdle QStringLiteral("idle") +#define AttributeFailure QStringLiteral("failure") +#define AttributeAssociation QStringLiteral("association") +#define AttributeConfiguration QStringLiteral("configuration") +#define AttributeReady QStringLiteral("ready") +#define AttributeDisconnect QStringLiteral("disconnect") +#define AttributeOneline QStringLiteral("online") + +struct ConnmanMap { + QDBusObjectPath objectPath; + QVariantMap propertyMap; +}; + +QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj); +const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj); + +const QString &operator>>(const QString &argument, QNetworkSettingsType &obj); +const QString &operator>>(const QString &argument, QNetworkSettingsState &obj); + +typedef QList ConnmanMapList; + +Q_DECLARE_METATYPE( ConnmanMap ) +Q_DECLARE_METATYPE( ConnmanMapList ) + + +#endif // CONNMANCOMMON_H diff --git a/src/networksettings/connman/qnetworksettingsinterface_p.cpp b/src/networksettings/connman/qnetworksettingsinterface_p.cpp new file mode 100644 index 0000000..dda05be --- /dev/null +++ b/src/networksettings/connman/qnetworksettingsinterface_p.cpp @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsinterface_p.h" +#include "qnetworksettingsinterface.h" +#include "connman_technology_interface.h" +#include "connmancommon.h" + +QNetworkSettingsInterfacePrivate::QNetworkSettingsInterfacePrivate(QNetworkSettingsInterface* parent) + : QObject(parent) + ,q_ptr(parent) +{ + +} + +void QNetworkSettingsInterfacePrivate::initialize(const QString& path, const QVariantMap& properties) +{ + m_technology = new NetConnmanTechnologyInterface(QStringLiteral("net.connman"), path, + QDBusConnection::systemBus(), this); + connect(m_technology, SIGNAL(PropertyChanged(QString,QDBusVariant)), + this, SLOT(updateProperty(QString,QDBusVariant))); + + updateProperty(PropertyName, properties[PropertyName]); + updateProperty(PropertyType, properties[PropertyType]); + updateProperty(PropertyConnected, properties[PropertyConnected]); + updateProperty(PropertyPowered, properties[PropertyPowered]); +} + +void QNetworkSettingsInterfacePrivate::updateProperty(const QString &name, const QDBusVariant &value) +{ + updateProperty(name, value.variant()); +} + +void QNetworkSettingsInterfacePrivate::updateProperty(const QString &name, const QVariant &value) +{ + Q_Q(QNetworkSettingsInterface); + if (name == PropertyName) { + m_name = qdbus_cast(value); + } + else if (name == PropertyType) { + qdbus_cast(value) >> m_type; + emit q->typeChanged(); + } + else if (name == PropertyConnected) { + bool connected = qdbus_cast(value); + if (connected) + m_state.setState(QNetworkSettingsState::Online); + else + m_state.setState(QNetworkSettingsState::Disconnect); + emit q->stateChanged(); + } + else if (name == PropertyPowered) { + m_powered = qdbus_cast(value); + emit q->poweredChanged(); + } +} + +void QNetworkSettingsInterfacePrivate::setState(QNetworkSettingsState::States aState) +{ + Q_Q(QNetworkSettingsInterface); + m_state.setState(aState); + emit q->stateChanged(); +} + +void QNetworkSettingsInterfacePrivate::setPowered(const bool aPowered) +{ + m_technology->SetProperty(PropertyPowered, QDBusVariant(QVariant(aPowered))); +} + +void QNetworkSettingsInterfacePrivate::scan() +{ + m_technology->Scan(); +} diff --git a/src/networksettings/connman/qnetworksettingsinterface_p.h b/src/networksettings/connman/qnetworksettingsinterface_p.h new file mode 100644 index 0000000..6e1d5ca --- /dev/null +++ b/src/networksettings/connman/qnetworksettingsinterface_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSINTERFACEPRIVATE_H +#define QNETWORKSETTINGSINTERFACEPRIVATE_H + +#include +#include +#include "qnetworksettings.h" +#include "qnetworksettingsinterface.h" + +class NetConnmanTechnologyInterface; + +class QNetworkSettingsInterfacePrivate : public QObject +{ + Q_OBJECT + Q_DECLARE_PUBLIC(QNetworkSettingsInterface) +public: + explicit QNetworkSettingsInterfacePrivate(QNetworkSettingsInterface* parent); + void initialize(const QString& path, const QVariantMap& properties); + void setPowered(const bool power); + void setState(QNetworkSettingsState::States aState); + void scan(); + +public slots: + void updateProperty(const QString &name, const QDBusVariant &value); +protected: + void updateProperty(const QString &name, const QVariant &value); + +protected: + NetConnmanTechnologyInterface *m_technology; + QString m_name; + QNetworkSettingsType m_type; + QNetworkSettingsState m_state; + bool m_powered; + QNetworkSettingsInterface *q_ptr; +}; + + +class ConnmanSettingsInterface : public QNetworkSettingsInterface +{ + Q_OBJECT +public: + ConnmanSettingsInterface(const QString& path, const QVariantMap& properties, QObject *parent=0) + :QNetworkSettingsInterface(parent) + { + if (d_ptr) + d_ptr->initialize(path, properties); + } + + void setState(QNetworkSettingsState::States aState) { + Q_D(QNetworkSettingsInterface); + d->setState(aState); + } + + virtual ~ConnmanSettingsInterface() { + + } +}; +#endif // QNETWORKSETTINGSINTERFACEPRIVATE_H diff --git a/src/networksettings/connman/qnetworksettingsmanager_p.cpp b/src/networksettings/connman/qnetworksettingsmanager_p.cpp new file mode 100644 index 0000000..64b4341 --- /dev/null +++ b/src/networksettings/connman/qnetworksettingsmanager_p.cpp @@ -0,0 +1,171 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsmanager_p.h" +#include "connman_manager_interface.cpp" +#include "moc_connman_manager_interface.cpp" +#include "qnetworksettingsinterface.h" +#include "qnetworksettingsinterface_p.h" +#include "qnetworksettingsservicemodel.h" + +QNetworkSettingsManagerPrivate::QNetworkSettingsManagerPrivate(QNetworkSettingsManager *parent) + :QObject(parent) + ,q_ptr(parent) +{ + m_serviceModel = new QNetworkSettingsServiceModel(this); + m_serviceFilter = new QNetworkSettingsServiceFilter(this); + m_serviceFilter->setSourceModel(m_serviceModel); + m_manager = new NetConnmanManagerInterface(QStringLiteral("net.connman"), QStringLiteral("/"), + QDBusConnection::systemBus(), this); + + if (m_manager->isValid()) { + //List technologies + QDBusPendingReply reply = m_manager->GetTechnologies(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + this, SLOT(getTechnologiesFinished(QDBusPendingCallWatcher*))); + + reply = m_manager->GetServices(); + watcher = new QDBusPendingCallWatcher(reply, this); + connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + this, SLOT(getServicesFinished(QDBusPendingCallWatcher*))); + + connect(m_manager, &NetConnmanManagerInterface::ServicesChanged, this, &QNetworkSettingsManagerPrivate::servicesChanged); + + m_manager->RegisterAgent(QDBusObjectPath(AgentPath)); + } + else { + delete m_manager; + m_manager = NULL; + } +} + +void QNetworkSettingsManagerPrivate::requestInput(const QString& service, const QString& type) +{ + Q_UNUSED(type); + foreach (QNetworkSettingsService* servicePtr, m_serviceModel->getModel()) { + if (servicePtr->id() == service) + emit servicePtr->showCrendentialInput(); + } +} + +void QNetworkSettingsManagerPrivate::getServicesFinished(QDBusPendingCallWatcher *watcher) +{ + Q_Q(QNetworkSettingsManager); + QDBusPendingReply reply = *watcher; + watcher->deleteLater(); + if (reply.isError()) + return; + + foreach (const ConnmanMap &object, reply.value()) { + const QString servicePath = object.objectPath.path(); + QNetworkSettingsService *service = new QNetworkSettingsService(servicePath, this); + m_serviceModel->append(service); + + //Update status property + QString n = qdbus_cast(object.propertyMap[PropertyName]); + QString t = qdbus_cast(object.propertyMap[PropertyType]); + QString s = qdbus_cast(object.propertyMap[PropertyState]); + + QNetworkSettingsType type; + t >> type; + QNetworkSettingsState state; + s >> state; + + foreach (QNetworkSettingsInterface* item, m_interfaceModel.getModel()) { + ConnmanSettingsInterface* technology = qobject_cast(item); + if (technology->name() == n && technology->type() == type.type()) { + technology->setState(state.state()); + } + } + } + emit q->servicesChanged(); +} + +void QNetworkSettingsManagerPrivate::getTechnologiesFinished(QDBusPendingCallWatcher *watcher) +{ + Q_Q(QNetworkSettingsManager); + + QDBusPendingReply reply = *watcher; + watcher->deleteLater(); + if (reply.isError()) + return; + + foreach (const ConnmanMap &object, reply.value()) { + ConnmanSettingsInterface *item = new ConnmanSettingsInterface(object.objectPath.path(), object.propertyMap, this); + + if (item->type() == QNetworkSettingsType::Wired) { + m_interfaceModel.insert(0, item); + } + else if (item->type() == QNetworkSettingsType::Wifi) { + m_interfaceModel.append(item); + } + emit q->interfacesChanged(); + } +} + +void QNetworkSettingsManagerPrivate::servicesChanged(ConnmanMapList changed, const QList &removed) +{ + foreach (QDBusObjectPath path, removed) { + QList serviceList = m_serviceModel->getModel(); + QMutableListIterator i(serviceList); + while (i.hasNext()) { + if (i.next()->id() == path.path()) + i.remove(); + } + } + + QStringList newServices; + foreach (ConnmanMap map, changed) { + bool found = false; + foreach (QNetworkSettingsService* service, m_serviceModel->getModel()) { + if (service->id() == map.objectPath.path()) { + found =true; + break; + } + } + if (!found) + newServices.append(map.objectPath.path()); + } + foreach (QString newService, newServices) { + QNetworkSettingsService *service = new QNetworkSettingsService(newService, this); + m_serviceModel->append(service); + } +} + +void QNetworkSettingsManagerPrivate::setUserAgent(QNetworkSettingsUserAgent *agent) +{ + Q_UNUSED(agent); +} diff --git a/src/networksettings/connman/qnetworksettingsmanager_p.h b/src/networksettings/connman/qnetworksettingsmanager_p.h new file mode 100644 index 0000000..3176c98 --- /dev/null +++ b/src/networksettings/connman/qnetworksettingsmanager_p.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSMANAGERPRIVATE_H +#define QNETWORKSETTINGSMANAGERPRIVATE_H + +#include +#include +#include "connmancommon.h" +#include "qnetworksettingsmanager.h" +#include "qnetworksettingsinterfacemodel.h" + +class NetConnmanManagerInterface; +class QNetworkSettingsServiceModel; +class QNetworkSettingsServiceFilter; + +class QNetworkSettingsManagerPrivate : public QObject +{ + Q_OBJECT + Q_DECLARE_PUBLIC(QNetworkSettingsManager) +public: + explicit QNetworkSettingsManagerPrivate(QNetworkSettingsManager *parent); + QNetworkSettingsManager *q_ptr; + void setUserAgent(QNetworkSettingsUserAgent *agent); + +public slots: + void getServicesFinished(QDBusPendingCallWatcher *watcher); + void getTechnologiesFinished(QDBusPendingCallWatcher *watcher); + void requestInput(const QString& service, const QString& type); + void servicesChanged(ConnmanMapList changed, const QList &removed); + +protected: + QNetworkSettingsInterfaceModel m_interfaceModel; + QNetworkSettingsServiceModel *m_serviceModel; + QNetworkSettingsServiceFilter *m_serviceFilter; +private: + NetConnmanManagerInterface *m_manager; +}; + +#endif // QNETWORKSETTINGSMANAGERPRIVATE_H diff --git a/src/networksettings/connman/qnetworksettingsservice_p.cpp b/src/networksettings/connman/qnetworksettingsservice_p.cpp new file mode 100644 index 0000000..b4e33a3 --- /dev/null +++ b/src/networksettings/connman/qnetworksettingsservice_p.cpp @@ -0,0 +1,402 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsservice_p.h" +#include "connman_service_interface.h" +#include "connmancommon.h" + +const QString PropertyIPv4(QStringLiteral("IPv4")); +const QString PropertyQNetworkSettingsIPv4(QStringLiteral("IPv4.Configuration")); +const QString PropertyIPv6(QStringLiteral("IPv6")); +const QString PropertyQNetworkSettingsIPv6(QStringLiteral("IPv6.Configuration")); +const QString PropertyNameservers(QStringLiteral("Nameservers")); +const QString PropertyNameserversConfig(QStringLiteral("Nameservers.Configuration")); +const QString PropertyDomains(QStringLiteral("Domains")); +const QString PropertyDomainsConfig(QStringLiteral("Domains.Configuration")); +const QString PropertyProxy(QStringLiteral("Proxy")); +const QString PropertyQNetworkSettingsProxy(QStringLiteral("Proxy.Configuration")); +const QString PropertyAddress(QStringLiteral("Address")); +const QString PropertyNetMask(QStringLiteral("Netmask")); +const QString PropertyGateway(QStringLiteral("Gateway")); +const QString PropertyPrefixLength(QStringLiteral("PrefixLength")); +const QString PropertyMethod(QStringLiteral("Method")); +const QString PropertyPrivacy(QStringLiteral("Privacy")); +const QString PropertyUrl(QStringLiteral("Url")); +const QString PropertyServers(QStringLiteral("Servers")); +const QString PropertyExcludes(QStringLiteral("Excludes")); +const QString PropertyStrength(QStringLiteral("Strength")); +const QString PropertySecurity(QStringLiteral("Security")); + +const QString AttributeAuto(QStringLiteral("auto")); +const QString AttributeDhcp(QStringLiteral("dhcp")); +const QString AttributeManual(QStringLiteral("manual")); +const QString AttributeOff(QStringLiteral("off")); +const QString AttributeDisabled(QStringLiteral("disabled")); +const QString AttributeEnabled(QStringLiteral("enabled")); +const QString AttributePreferred(QStringLiteral("preferred")); +const QString AttributeDirect(QStringLiteral("direct")); +const QString AttributeNone(QStringLiteral("none")); +const QString AttributeWep(QStringLiteral("wep")); +const QString AttributePsk(QStringLiteral("psk")); +const QString AttributeIeee(QStringLiteral("ieee8021x")); +const QString AttributeWps(QStringLiteral("wps")); +const QString AttributeInvalidKey(QStringLiteral("invalid-key")); + +const QVariantMap &operator>>(const QVariantMap &argument, QNetworkSettingsIPv4 &obj) +{ + obj.setAddress(argument[PropertyAddress].toString()); + obj.setMask(argument[PropertyNetMask].toString()); + obj.setGateway(argument[PropertyGateway].toString()); + + QString method = argument[PropertyMethod].toString(); + + if (method == AttributeDhcp) { + obj.setMethod(QNetworkSettingsIPv4::Dhcp); + } + else if (method == AttributeManual) { + obj.setMethod(QNetworkSettingsIPv4::Manual); + } + else if (method == AttributeOff) { + obj.setMethod(QNetworkSettingsIPv4::Off); + } + else { + obj.setMethod(QNetworkSettingsIPv4::Off); + } + return argument; +} + +const QVariantMap &operator<<(QVariantMap &argument, const QNetworkSettingsIPv4 &obj) +{ + argument.insert(PropertyAddress, QVariant::fromValue(obj.address())); + + argument.insert(PropertyNetMask, QVariant::fromValue(obj.mask())); + + argument.insert(PropertyGateway, QVariant::fromValue(obj.gateway())); + + QString method; + switch (obj.method()) { + case QNetworkSettingsIPv4::Dhcp: + method = AttributeDhcp; + break; + case QNetworkSettingsIPv4::Manual: + method = AttributeManual; + break; + case QNetworkSettingsIPv4::Off: + method = AttributeOff; + break; + default: + break; + } + argument.insert(PropertyMethod, QVariant::fromValue(method)); + return argument; +} + +const QVariantMap &operator>>(const QVariantMap &argument, QNetworkSettingsIPv6 &obj) +{ + obj.setAddress(argument[PropertyAddress].toString()); + obj.setGateway(argument[PropertyGateway].toString()); + obj.setPrefixLength(argument[PropertyPrefixLength].toInt()); + QString method = argument[PropertyMethod].toString(); + if (method == AttributeAuto) { + obj.setMethod(QNetworkSettingsIPv6::Auto); + } + else if (method == AttributeManual) { + obj.setMethod(QNetworkSettingsIPv6::Manual); + } + else if (method == AttributeOff) { + obj.setMethod(QNetworkSettingsIPv6::Off); + } + QString privacy = argument[PropertyPrivacy].toString(); + + if (privacy == AttributeDisabled) { + obj.setPrivacy(QNetworkSettingsIPv6::Disabled); + } + else if (privacy == AttributeEnabled) { + obj.setPrivacy(QNetworkSettingsIPv6::Enabled); + } + else if (privacy == AttributePreferred) { + obj.setPrivacy(QNetworkSettingsIPv6::Preferred); + } + return argument; +} + + +const QVariantMap &operator<<(QVariantMap &argument, const QNetworkSettingsIPv6 &obj) +{ + argument.insert(PropertyAddress, QVariant::fromValue(obj.address())); + argument.insert(PropertyGateway, QVariant::fromValue(obj.address())); + argument.insert(PropertyPrefixLength, QVariant::fromValue(obj.prefixLength())); + + QString method; + switch (obj.method()) { + case QNetworkSettingsIPv6::Auto: + method = AttributeAuto; + break; + case QNetworkSettingsIPv6::Manual: + method = AttributeManual; + break; + case QNetworkSettingsIPv6::Off: + method = AttributeOff; + break; + default: + break; + } + argument.insert(PropertyMethod, QVariant::fromValue(method)); + + QString privacy; + switch (obj.privacy()) { + case QNetworkSettingsIPv6::Disabled: + method = AttributeDisabled; + break; + case QNetworkSettingsIPv6::Enabled: + method = AttributeEnabled; + break; + case QNetworkSettingsIPv6::Preferred: + method = AttributePreferred; + break; + default: + break; + } + argument.insert(PropertyPrivacy, QVariant::fromValue(privacy)); + + return argument; +} + + +const QVariantMap &operator>>(const QVariantMap &argument, QNetworkSettingsProxy &obj) +{ + QString method = argument[PropertyMethod].toString(); + if (method == AttributeDirect) { + obj.setMethod(QNetworkSettingsProxy::Direct); + } + else if (method == AttributeAuto) { + obj.setMethod(QNetworkSettingsProxy::Auto); + } + else if (method == AttributeManual) { + obj.setMethod(QNetworkSettingsProxy::Manual); + } + + QString urlStr = argument[PropertyUrl].toString(); + obj.setUrl(QUrl(urlStr)); + + obj.setServers(argument[PropertyServers].toStringList()); + obj.setExcludes(argument[PropertyExcludes].toStringList()); + + return argument; +} + +const QVariantMap &operator<<(QVariantMap &argument, const QNetworkSettingsProxy &obj) +{ + QString method; + switch (obj.method()) { + case QNetworkSettingsProxy::Direct: + method = AttributeDirect; + break; + case QNetworkSettingsProxy::Auto: + method = AttributeAuto; + break; + case QNetworkSettingsProxy::Manual: + method = AttributeManual; + break; + default: + break; + } + argument.insert(PropertyMethod, QVariant::fromValue(method)); + argument.insert(PropertyUrl, QVariant::fromValue(obj.url().toString())); + argument.insert(PropertyServers, QVariant::fromValue(obj.servers())); + argument.insert(PropertyServers, QVariant::fromValue(obj.excludes())); + + return argument; +} + +QNetworkSettingsServicePrivate::QNetworkSettingsServicePrivate(const QString& id, QNetworkSettingsService *parent) : + QObject(parent) + ,q_ptr(parent) + ,m_id(id) +{ + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + + m_service = new NetConnmanServiceInterface(QStringLiteral("net.connman"), m_id, + QDBusConnection::systemBus(), this); + + connect(m_service, SIGNAL(PropertyChanged(QString,QDBusVariant)), + this, SLOT(updateProperty(QString,QDBusVariant))); + + QDBusPendingReply reply = m_service->GetProperties(); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); + + connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + this, SLOT(propertiesUpdated(QDBusPendingCallWatcher*))); +} + +void QNetworkSettingsServicePrivate::setupIpv6Config() +{ + QVariantMap param; + param << m_ipv6config; + if (m_service) + m_service->SetProperty(PropertyQNetworkSettingsIPv6, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::setupNameserversConfig() +{ + QVariant param = QVariant::fromValue(m_nameserverConfig.stringList()); + if (m_service) + m_service->SetProperty(PropertyNameserversConfig, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::setupDomainsConfig() +{ + QVariant param = QVariant::fromValue(m_domainsConfig.stringList()); + if (m_service) + m_service->SetProperty(PropertyDomainsConfig, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::setupQNetworkSettingsProxy() +{ + QVariantMap param; + param << m_proxyConfig; + if (m_service) + m_service->SetProperty(PropertyQNetworkSettingsProxy, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::setupIpv4Config() +{ + QVariantMap param; + param << m_ipv4config; + if (m_service) + m_service->SetProperty(PropertyQNetworkSettingsIPv4, QDBusVariant(QVariant(param))); +} + +void QNetworkSettingsServicePrivate::connectService() +{ + if (m_service) { + m_service->Connect(); + } +} + +void QNetworkSettingsServicePrivate::disconnectService() +{ + if (m_service) + m_service->Disconnect(); + +} + +void QNetworkSettingsServicePrivate::propertiesUpdated(QDBusPendingCallWatcher *call) +{ + QDBusPendingReply reply = *call; + call->deleteLater(); + + if (!reply.isError()) + setupConfiguration(reply.value()); +} + +void QNetworkSettingsServicePrivate::updateProperty(const QString &name, const QDBusVariant &value) +{ + updateProperty(name, value.variant()); +} + +void QNetworkSettingsServicePrivate::updateProperty(const QString& key, const QVariant& val) +{ + Q_Q(QNetworkSettingsService); + + if (key == PropertyIPv4) { + QVariantMap value = qdbus_cast(val); + value >> m_ipv4config; + emit q->ipv4Changed(); + } + else if (key == PropertyIPv6) { + QVariantMap value = qdbus_cast(val); + value >> m_ipv6config; + emit q->ipv6Changed(); + } + else if (key == PropertyNameservers) { + QStringList value = qdbus_cast(val); + m_nameserverConfig.setStringList(value); + emit q->nameserversChanged(); + } + else if (key == PropertyDomains) { + QStringList value = qdbus_cast(val); + m_domainsConfig.setStringList(value); + emit q->domainsChanged(); + } + else if (key == PropertyProxy) { + QVariantMap value = qdbus_cast(val); + value >> m_proxyConfig; + emit q->proxyChanged(); + } + else if (key == PropertyState) { + QString value = qdbus_cast(val); + value >> m_state; + emit q->stateChanged(); + } + else if (key == PropertyName) { + m_name = qdbus_cast(val); + emit q->nameChanged(); + } + else if (key == PropertyType) { + QString value = qdbus_cast(val); + value >> m_type; + } + else if (key == PropertyStrength) { + m_wifiConfig.setSignalStrength(val.toInt()); + } + else if (key == PropertySecurity) { + QStringList value = qdbus_cast(val); + foreach (const QString str, value) { + if (str == AttributeNone || str == AttributeWps) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::None); + } + else if (str == AttributeWep) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::WEP); + } + else if (str == AttributePsk) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::WPA); + } + else if (str == AttributeIeee) { + m_wifiConfig.setSecurity(QNetworkSettingsWireless::WPA2); + } + } + } +} + +void QNetworkSettingsServicePrivate::setupConfiguration(const QVariantMap &properties) +{ + QVariantMap::const_iterator it = properties.constBegin(), end = properties.constEnd(); + for ( ; it != end; ++it) { + updateProperty(it.key(), it.value()); + } +} + diff --git a/src/networksettings/connman/qnetworksettingsservice_p.h b/src/networksettings/connman/qnetworksettingsservice_p.h new file mode 100644 index 0000000..39a04bd --- /dev/null +++ b/src/networksettings/connman/qnetworksettingsservice_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSSERVICEPRIVATE_H +#define QNETWORKSETTINGSSERVICEPRIVATE_H + +#include +#include "qnetworksettingsservice.h" +#include "qnetworksettings.h" + +class NetConnmanServiceInterface; + +class QNetworkSettingsServicePrivate : public QObject +{ + Q_OBJECT + Q_DECLARE_PUBLIC(QNetworkSettingsService) +public: + QNetworkSettingsServicePrivate(const QString& aPath, QNetworkSettingsService *parent=0); + + QNetworkSettingsService *q_ptr; +private slots: + void propertiesUpdated(QDBusPendingCallWatcher *call); + void updateProperty(const QString &name, const QDBusVariant &value); + +private: + void setupConfiguration(const QVariantMap &properties); + void updateProperty(const QString& key, const QVariant& value); + +protected: + void setAutoConnect(const bool autoconnect); + void setupIpv4Config(); + void setupIpv6Config(); + void setupNameserversConfig(); + void setupDomainsConfig(); + void setupQNetworkSettingsProxy(); + void connectService(); + void disconnectService(); + + QString m_id; + QString m_name; + QNetworkSettingsState m_state; + QNetworkSettingsIPv4 m_ipv4config; + QNetworkSettingsIPv6 m_ipv6config; + QNetworkSettingsAddressModel m_domainsConfig; + QNetworkSettingsAddressModel m_nameserverConfig; + QNetworkSettingsProxy m_proxyConfig; + QNetworkSettingsWireless m_wifiConfig; + QNetworkSettingsType m_type; + NetConnmanServiceInterface *m_service; +}; + +#endif // QNETWORKSETTINGSSERVICEPRIVATE_H diff --git a/src/networksettings/connman/qnetworksettingsuseragent_p.cpp b/src/networksettings/connman/qnetworksettingsuseragent_p.cpp new file mode 100644 index 0000000..514745e --- /dev/null +++ b/src/networksettings/connman/qnetworksettingsuseragent_p.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qnetworksettingsuseragent_p.h" +#include "connmancommon.h" + +const QString PropertyPassphrase(QStringLiteral("Passphrase")); + +QNetworkSettingsUserAgentPrivate::QNetworkSettingsUserAgentPrivate(QNetworkSettingsUserAgent *parent) + :QDBusAbstractAdaptor(parent) + ,q_ptr(parent) + ,m_pendingReply(false) +{ + + setAutoRelaySignals(true); + QMetaObject::invokeMethod(this, "registerAgent", Qt::QueuedConnection); +} + +void QNetworkSettingsUserAgentPrivate::cancel() +{ + // handle method call net.connman.Agent.Cancel + m_pendingReply = false; + QMetaObject::invokeMethod(parent(), "Cancel"); +} + +void QNetworkSettingsUserAgentPrivate::release() +{ + // handle method call net.connman.Agent.Release + QMetaObject::invokeMethod(parent(), "Release"); +} + +void QNetworkSettingsUserAgentPrivate::ReportError(const QDBusObjectPath &path, const QString ¶m) +{ + Q_Q(QNetworkSettingsUserAgent); + Q_UNUSED(path); + Q_UNUSED(param); + emit q->error(); +} + +void QNetworkSettingsUserAgentPrivate::registerAgent() +{ + Q_Q(QNetworkSettingsUserAgent); + QDBusConnection::systemBus().registerObject(QStringLiteral(AgentPath), q); +} + +QVariantMap QNetworkSettingsUserAgentPrivate::RequestInput(const QDBusObjectPath &path, const QVariantMap ¶ms, const QDBusMessage &msg) +{ + Q_Q(QNetworkSettingsUserAgent); + Q_UNUSED(path); + Q_UNUSED(params); + msg.setDelayedReply(true); + m_reply = msg.createReply(); + m_pendingReply = true; + emit q->showUserCredentialsInput(); + return QVariantMap(); +} + +void QNetworkSettingsUserAgentPrivate::setUserCredentials(const QString& username, + const QString& password) +{ + m_username = username; + m_passphrase = password; + QVariantMap response; + response[PropertyName] = m_username; + response[PropertyPassphrase] = m_passphrase; + m_reply << response; + m_pendingReply = false; + QDBusConnection::systemBus().send(m_reply); +} diff --git a/src/networksettings/connman/qnetworksettingsuseragent_p.h b/src/networksettings/connman/qnetworksettingsuseragent_p.h new file mode 100644 index 0000000..efde5b5 --- /dev/null +++ b/src/networksettings/connman/qnetworksettingsuseragent_p.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt Device Utilities module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QNETWORKSETTINGSUSERAGENTPRIVATE_H +#define QNETWORKSETTINGSUSERAGENTPRIVATE_H + +#include +#include +#include "qnetworksettingsuseragent.h" + +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +const QString AgentPath(QStringLiteral("/ConnmanAgent")); + +class QNetworkSettingsUserAgentPrivate : public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "net.connman.Agent") + Q_DECLARE_PUBLIC(QNetworkSettingsUserAgent) +public: + QNetworkSettingsUserAgentPrivate(QNetworkSettingsUserAgent *parent=0); + void setUserCredentials(const QString& aUsername, const QString& aPassword); + void cancel(); + void release(); +public Q_SLOTS: // Dbus methods + void ReportError(const QDBusObjectPath &path, const QString ¶m); + QVariantMap RequestInput(const QDBusObjectPath &path, const QVariantMap ¶ms, + const QDBusMessage &message); + void registerAgent(); +private: + QNetworkSettingsUserAgent *q_ptr; + QDBusMessage m_reply; + bool m_pendingReply; + QString m_passphrase; + QString m_username; +}; + +#endif // QNETWORKSETTINGSUSERAGENTPRIVATE_H -- cgit v1.2.3