From 38be0d13830efd2d98281c645c3a60afe05ffece Mon Sep 17 00:00:00 2001 From: Qt by Nokia Date: Wed, 27 Apr 2011 12:05:43 +0200 Subject: Initial import from the monolithic Qt. This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12 --- src/plugins/bearer/connman/connman.pro | 21 + src/plugins/bearer/connman/main.cpp | 93 ++ src/plugins/bearer/connman/qconnmanengine.cpp | 594 +++++++++++++ src/plugins/bearer/connman/qconnmanengine.h | 142 ++++ .../bearer/connman/qconnmanservice_linux.cpp | 894 +++++++++++++++++++ .../bearer/connman/qconnmanservice_linux_p.h | 323 +++++++ src/plugins/bearer/connman/qofonoservice_linux.cpp | 945 +++++++++++++++++++++ src/plugins/bearer/connman/qofonoservice_linux_p.h | 340 ++++++++ 8 files changed, 3352 insertions(+) create mode 100644 src/plugins/bearer/connman/connman.pro create mode 100644 src/plugins/bearer/connman/main.cpp create mode 100644 src/plugins/bearer/connman/qconnmanengine.cpp create mode 100644 src/plugins/bearer/connman/qconnmanengine.h create mode 100644 src/plugins/bearer/connman/qconnmanservice_linux.cpp create mode 100644 src/plugins/bearer/connman/qconnmanservice_linux_p.h create mode 100644 src/plugins/bearer/connman/qofonoservice_linux.cpp create mode 100644 src/plugins/bearer/connman/qofonoservice_linux_p.h (limited to 'src/plugins/bearer/connman') diff --git a/src/plugins/bearer/connman/connman.pro b/src/plugins/bearer/connman/connman.pro new file mode 100644 index 0000000000..dec408c724 --- /dev/null +++ b/src/plugins/bearer/connman/connman.pro @@ -0,0 +1,21 @@ +TARGET = qconnmanbearer +include(../../qpluginbase.pri) + +QT = core network dbus + +HEADERS += qconnmanservice_linux_p.h \ + qofonoservice_linux_p.h \ + qconnmanengine.h \ + ../qnetworksession_impl.h \ + ../qbearerengine_impl.h + +SOURCES += main.cpp \ + qconnmanservice_linux.cpp \ + qofonoservice_linux.cpp \ + qconnmanengine.cpp \ + ../qnetworksession_impl.cpp + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/bearer +target.path += $$[QT_INSTALL_PLUGINS]/bearer +INSTALLS += target + diff --git a/src/plugins/bearer/connman/main.cpp b/src/plugins/bearer/connman/main.cpp new file mode 100644 index 0000000000..681b871479 --- /dev/null +++ b/src/plugins/bearer/connman/main.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qconnmanengine.h" + +#include + +#include + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +class QConnmanEnginePlugin : public QBearerEnginePlugin +{ +public: + QConnmanEnginePlugin(); + ~QConnmanEnginePlugin(); + + QStringList keys() const; + QBearerEngine *create(const QString &key) const; +}; + +QConnmanEnginePlugin::QConnmanEnginePlugin() +{ +} + +QConnmanEnginePlugin::~QConnmanEnginePlugin() +{ +} + +QStringList QConnmanEnginePlugin::keys() const +{ + return QStringList() << QLatin1String("connman"); +} + +QBearerEngine *QConnmanEnginePlugin::create(const QString &key) const +{ + if (key == QLatin1String("connman")) { + QConnmanEngine *engine = new QConnmanEngine; + if (engine->connmanAvailable()) + return engine; + else + delete engine; + } + return 0; +} + +Q_EXPORT_STATIC_PLUGIN(QConnmanEnginePlugin) +Q_EXPORT_PLUGIN2(qconnmanbearer, QConnmanEnginePlugin) + +QT_END_NAMESPACE + +#endif +#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/connman/qconnmanengine.cpp b/src/plugins/bearer/connman/qconnmanengine.cpp new file mode 100644 index 0000000000..53c9a7d431 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanengine.cpp @@ -0,0 +1,594 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qconnmanengine.h" +#include "qconnmanservice_linux_p.h" +#include "qofonoservice_linux_p.h" +#include "../qnetworksession_impl.h" + +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +QConnmanEngine::QConnmanEngine(QObject *parent) +: QBearerEngineImpl(parent), + connmanManager(new QConnmanManagerInterface(this)) +{ +} + +QConnmanEngine::~QConnmanEngine() +{ +} + +bool QConnmanEngine::connmanAvailable() const +{ + QMutexLocker locker(&mutex); + return connmanManager->isValid(); +} + +void QConnmanEngine::initialize() +{ + connect(connmanManager,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(propertyChangedContext(QString,QString,QDBusVariant))); + + foreach(const QString techPath, connmanManager->getTechnologies()) { + QConnmanTechnologyInterface *tech; + tech = new QConnmanTechnologyInterface(techPath, this); + + connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + } + + foreach(const QString servPath, connmanManager->getServices()) { + addServiceConfiguration(servPath); + } + + // Get current list of access points. + getConfigurations(); +} + +QList QConnmanEngine::getConfigurations() +{ + QMutexLocker locker(&mutex); + QList fetchedConfigurations; + QNetworkConfigurationPrivate* cpPriv = 0; + + for (int i = 0; i < foundConfigurations.count(); ++i) { + QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate; + cpPriv = foundConfigurations.at(i); + + config->name = cpPriv->name; + config->isValid = cpPriv->isValid; + config->id = cpPriv->id; + config->state = cpPriv->state; + config->type = cpPriv->type; + config->roamingSupported = cpPriv->roamingSupported; + config->purpose = cpPriv->purpose; + config->bearerType = cpPriv->bearerType; + + fetchedConfigurations.append(config); + delete config; + } + return fetchedConfigurations; +} + +void QConnmanEngine::doRequestUpdate() +{ + connmanManager->requestScan(""); + getConfigurations(); + emit updateCompleted(); +} + +QString QConnmanEngine::getInterfaceFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + return configInterfaces.value(id); +} + +bool QConnmanEngine::hasIdentifier(const QString &id) +{ + QMutexLocker locker(&mutex); + return accessPointConfigurations.contains(id); +} + +void QConnmanEngine::connectToId(const QString &id) +{ + QMutexLocker locker(&mutex); + QString servicePath = serviceFromId(id); + QConnmanServiceInterface serv(servicePath); + if(!serv.isValid()) { + emit connectionError(id, QBearerEngineImpl::InterfaceLookupError); + } else { + if(serv.getType() != "cellular") { + + serv.connect(); + } else { + QOfonoManagerInterface ofonoManager(0); + QString modemPath = ofonoManager.currentModem().path(); + QOfonoDataConnectionManagerInterface dc(modemPath,0); + foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) { + if(dcPath.path().contains(servicePath.section("_",-1))) { + QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0); + primaryContext.setActive(true); + } + } + } + } +} + +void QConnmanEngine::disconnectFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + QString servicePath = serviceFromId(id); + QConnmanServiceInterface serv(servicePath); + if(!serv.isValid()) { + emit connectionError(id, DisconnectionError); + } else { + if(serv.getType() != "cellular") { + serv.disconnect(); + } else { + QOfonoManagerInterface ofonoManager(0); + QString modemPath = ofonoManager.currentModem().path(); + QOfonoDataConnectionManagerInterface dc(modemPath,0); + foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) { + if(dcPath.path().contains(servicePath.section("_",-1))) { + QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0); + primaryContext.setActive(false); + } + } + } + } +} + +void QConnmanEngine::requestUpdate() +{ + QMutexLocker locker(&mutex); + QTimer::singleShot(0, this, SLOT(doRequestUpdate())); +} + +QString QConnmanEngine::serviceFromId(const QString &id) +{ + QMutexLocker locker(&mutex); + foreach(const QString service, serviceNetworks) { + if (id == QString::number(qHash(service))) + return service; + } + + return QString(); +} + +QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id) +{ + QMutexLocker locker(&mutex); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + if (!ptr) + return QNetworkSession::Invalid; + + if (!ptr->isValid) { + return QNetworkSession::Invalid; + + } + QString service = serviceFromId(id); + QConnmanServiceInterface serv(service); + QString servState = serv.getState(); + + if(serv.isFavorite() && (servState == "idle" || servState == "failure")) { + return QNetworkSession::Disconnected; + } + + if(servState == "association" || servState == "configuration" || servState == "login") { + return QNetworkSession::Connecting; + } + if(servState == "ready" || servState == "online") { + return QNetworkSession::Connected; + } + + if ((ptr->state & QNetworkConfiguration::Discovered) == + QNetworkConfiguration::Discovered) { + return QNetworkSession::Disconnected; + } else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) { + return QNetworkSession::NotAvailable; + } else if ((ptr->state & QNetworkConfiguration::Undefined) == + QNetworkConfiguration::Undefined) { + return QNetworkSession::NotAvailable; + } + + return QNetworkSession::Invalid; +} + +quint64 QConnmanEngine::bytesWritten(const QString &id) +{//TODO use connman counter API + QMutexLocker locker(&mutex); + quint64 result = 0; + QString devFile = getInterfaceFromId(id); + QFile tx("/sys/class/net/"+devFile+"/statistics/tx_bytes"); + if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&tx); + in >> result; + tx.close(); + } + + return result; +} + +quint64 QConnmanEngine::bytesReceived(const QString &id) +{//TODO use connman counter API + QMutexLocker locker(&mutex); + quint64 result = 0; + QString devFile = getInterfaceFromId(id); + QFile rx("/sys/class/net/"+devFile+"/statistics/rx_bytes"); + if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) { + QTextStream in(&rx); + in >> result; + rx.close(); + } + return result; +} + +quint64 QConnmanEngine::startTime(const QString &/*id*/) +{ + // TODO + QMutexLocker locker(&mutex); + if (activeTime.isNull()) { + return 0; + } + return activeTime.secsTo(QDateTime::currentDateTime()); +} + +QNetworkConfigurationManager::Capabilities QConnmanEngine::capabilities() const +{ + return QNetworkConfigurationManager::ForcedRoaming | + QNetworkConfigurationManager::DataStatistics | + QNetworkConfigurationManager::CanStartAndStopInterfaces; +} + +QNetworkSessionPrivate *QConnmanEngine::createSessionBackend() +{ + return new QNetworkSessionPrivateImpl; +} + +QNetworkConfigurationPrivatePointer QConnmanEngine::defaultConfiguration() +{ + return QNetworkConfigurationPrivatePointer(); +} + +void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) +{ + Q_UNUSED(path); + + QMutexLocker locker(&mutex); + if(item == "Services") { + QDBusArgument arg = qvariant_cast(value.variant()); + QStringList list = qdbus_cast(arg); + + if(list.count() > accessPointConfigurations.count()) { + foreach(const QString service, list) { + addServiceConfiguration(service); + } + } + } + + if(item == "Technologies") { + QDBusArgument arg = qvariant_cast(value.variant()); + QStringList newlist = qdbus_cast(arg); + if(newlist.count() > 0) { + QMap oldtech = technologies; + + foreach(const QString listPath, newlist) { + if(!oldtech.contains(listPath)) { + QConnmanTechnologyInterface *tech; + tech = new QConnmanTechnologyInterface(listPath,this); + connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + technologies.insert(listPath, tech); + } + } + } + } + if(item == "State") { +// qDebug() << value.variant(); + } +} + +void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value) +{ + QMutexLocker locker(&mutex); + if(item == "State") { + configurationChange(QString::number(qHash(path))); + + if(value.variant().toString() == "failure") { + QConnmanServiceInterface serv(path); + emit connectionError(QString::number(qHash(path)), ConnectError); + } + } +} + +void QConnmanEngine::technologyPropertyChangedContext(const QString & path, const QString &item, const QDBusVariant &value) +{ + if(item == "State") { + if(value.variant().toString() == "offline") { + QConnmanTechnologyInterface tech(path); + disconnect(&tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant))); + + technologies.remove(path); + } + } +} + +void QConnmanEngine::configurationChange(const QString &id) +{ + QMutexLocker locker(&mutex); + + if (accessPointConfigurations.contains(id)) { + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); + + QString servicePath = serviceFromId(id); + QConnmanServiceInterface *serv; + serv = new QConnmanServiceInterface(servicePath); + QString networkName = serv->getName(); + + QNetworkConfiguration::StateFlags curState = getStateForService(servicePath); + + ptr->mutex.lock(); + + if (!ptr->isValid) { + ptr->isValid = true; + } + + if (ptr->name != networkName) { + ptr->name = networkName; + } + + if (ptr->state != curState) { + ptr->state = curState; + } + + ptr->mutex.unlock(); + + locker.unlock(); + emit configurationChanged(ptr); + locker.relock(); + } + + locker.unlock(); + emit updateCompleted(); +} + +QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QString &service) +{ + QMutexLocker locker(&mutex); + QConnmanServiceInterface serv(service); + QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined; + if( serv.getType() == "cellular") { + if(serv.isSetupRequired()) { + flag = ( flag | QNetworkConfiguration::Defined); + } else { + flag = ( flag | QNetworkConfiguration::Discovered); + } + } else { + if(serv.isFavorite()) { + flag = ( flag | QNetworkConfiguration::Discovered); + } else { + flag = QNetworkConfiguration::Undefined; + } + } + + if(serv.getState() == "ready" || serv.getState() == "online") { + flag = ( flag | QNetworkConfiguration::Active); + } + + return flag; +} + +QNetworkConfiguration::BearerType QConnmanEngine::typeToBearer(const QString &type) +{ + if (type == "wifi") + return QNetworkConfiguration::BearerWLAN; + if (type == "ethernet") + return QNetworkConfiguration::BearerEthernet; + if (type == "bluetooth") + return QNetworkConfiguration::BearerBluetooth; + if (type == "cellular") { + return ofonoTechToBearerType(type); + } + if (type == "wimax") + return QNetworkConfiguration::BearerWiMAX; + +// if(type == "gps") +// if(type == "vpn") + + return QNetworkConfiguration::BearerUnknown; +} + +QNetworkConfiguration::BearerType QConnmanEngine::ofonoTechToBearerType(const QString &/*type*/) +{ + QOfonoManagerInterface ofonoManager(this); + QOfonoNetworkRegistrationInterface ofonoNetwork(ofonoManager.currentModem().path(),this); + + if(ofonoNetwork.isValid()) { + foreach(const QDBusObjectPath op,ofonoNetwork.getOperators() ) { + QOfonoNetworkOperatorInterface opIface(op.path(),this); + + foreach(const QString opTech, opIface.getTechnologies()) { + + if(opTech == "gsm") { + return QNetworkConfiguration::Bearer2G; + } + if(opTech == "edge"){ + return QNetworkConfiguration::BearerCDMA2000; //wrong, I know + } + if(opTech == "umts"){ + return QNetworkConfiguration::BearerWCDMA; + } + if(opTech == "hspa"){ + return QNetworkConfiguration::BearerHSPA; + } + if(opTech == "lte"){ + return QNetworkConfiguration::BearerWiMAX; //not exact + } + } + } + } + return QNetworkConfiguration::BearerUnknown; +} + +bool QConnmanEngine::isRoamingAllowed(const QString &context) +{ + QOfonoManagerInterface ofonoManager(this); + QString modemPath = ofonoManager.currentModem().path(); + QOfonoDataConnectionManagerInterface dc(modemPath,this); + foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) { + if(dcPath.path().contains(context.section("_",-1))) { + return dc.isRoamingAllowed(); + } + } + return false; +} + +void QConnmanEngine::removeConfiguration(const QString &id) +{ + QMutexLocker locker(&mutex); + + if (accessPointConfigurations.contains(id)) { + + QString service = serviceFromId(id); + QConnmanServiceInterface serv(service); + + disconnect(&serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + + serviceNetworks.removeOne(service); + + QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id); + locker.unlock(); + emit configurationRemoved(ptr); + locker.relock(); + } +} + +void QConnmanEngine::addServiceConfiguration(const QString &servicePath) +{ + QMutexLocker locker(&mutex); + QConnmanServiceInterface *serv; + serv = new QConnmanServiceInterface(servicePath); + + const QString id = QString::number(qHash(servicePath)); + + if (!accessPointConfigurations.contains(id)) { + serviceNetworks.append(servicePath); + + connect(serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), + this,SLOT(servicePropertyChangedContext(QString,QString, QDBusVariant))); + QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate(); + + QString networkName = serv->getName(); + + const QString connectionType = serv->getType(); + if (connectionType == "ethernet") { + cpPriv->bearerType = QNetworkConfiguration::BearerEthernet; + } else if (connectionType == "wifi") { + cpPriv->bearerType = QNetworkConfiguration::BearerWLAN; + } else if (connectionType == "cellular") { + cpPriv->bearerType = ofonoTechToBearerType("cellular"); + if(servicePath.isEmpty()) { + networkName = serv->getAPN(); + if(networkName.isEmpty()) { + networkName = serv->getName(); + } + } + cpPriv->roamingSupported = isRoamingAllowed(servicePath); + } else if (connectionType == "wimax") { + cpPriv->bearerType = QNetworkConfiguration::BearerWiMAX; + } else { + cpPriv->bearerType = QNetworkConfiguration::BearerUnknown; + } + + cpPriv->name = networkName; + cpPriv->isValid = true; + cpPriv->id = id; + cpPriv->type = QNetworkConfiguration::InternetAccessPoint; + + if(serv->getSecurity() == "none") { + cpPriv->purpose = QNetworkConfiguration::PublicPurpose; + } else { + cpPriv->purpose = QNetworkConfiguration::PrivatePurpose; + } + + cpPriv->state = getStateForService(servicePath); + + QNetworkConfigurationPrivatePointer ptr(cpPriv); + accessPointConfigurations.insert(ptr->id, ptr); + foundConfigurations.append(cpPriv); + configInterfaces[cpPriv->id] = serv->getInterface(); + + locker.unlock(); + emit configurationAdded(ptr); + locker.relock(); + emit updateCompleted(); + } +} + +bool QConnmanEngine::requiresPolling() const +{ + return false; +} + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/connman/qconnmanengine.h b/src/plugins/bearer/connman/qconnmanengine.h new file mode 100644 index 0000000000..8219c126c1 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanengine.h @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCONNMANENGINE_P_H +#define QCONNMANENGINE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of the QLibrary class. This header file may change from +// version to version without notice, or even be removed. +// +// We mean it. +// + +#include "../qbearerengine_impl.h" + +#include "qconnmanservice_linux_p.h" + +#include +#include + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE + +class QConnmanEngine : public QBearerEngineImpl +{ + Q_OBJECT + +public: + QConnmanEngine(QObject *parent = 0); + ~QConnmanEngine(); + + bool connmanAvailable() const; + + virtual QString getInterfaceFromId(const QString &id); + bool hasIdentifier(const QString &id); + + virtual void connectToId(const QString &id); + virtual void disconnectFromId(const QString &id); + + Q_INVOKABLE void initialize(); + Q_INVOKABLE void requestUpdate(); + + QNetworkSession::State sessionStateForId(const QString &id); + QNetworkSessionPrivate *createSessionBackend(); + + virtual quint64 bytesWritten(const QString &id); + virtual quint64 bytesReceived(const QString &id); + virtual quint64 startTime(const QString &id); + + + virtual QNetworkConfigurationManager::Capabilities capabilities() const; + virtual QNetworkConfigurationPrivatePointer defaultConfiguration(); + + void configurationChange(const QString &id); + QList getConfigurations(); + + +private Q_SLOTS: + + void doRequestUpdate(); + void servicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void technologyPropertyChangedContext(const QString &,const QString &, const QDBusVariant &); + +private: + QConnmanManagerInterface *connmanManager; + + QList foundConfigurations; + + QString serviceFromId(const QString &id); + QString networkFromId(const QString &id); + + QNetworkConfiguration::StateFlags getStateForService(const QString &service); + QNetworkConfiguration::BearerType typeToBearer(const QString &type); + + void removeConfiguration(const QString &servicePath); + void addServiceConfiguration(const QString &servicePath); + QDateTime activeTime; + + + QMap technologies; // techpath, tech interface + QMap configInterfaces; // id, interface name + QList serviceNetworks; //servpath + + QNetworkConfiguration::BearerType ofonoTechToBearerType(const QString &type); + bool isRoamingAllowed(const QString &context); +protected: + bool requiresPolling() const; +}; + + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT + +#endif + diff --git a/src/plugins/bearer/connman/qconnmanservice_linux.cpp b/src/plugins/bearer/connman/qconnmanservice_linux.cpp new file mode 100644 index 0000000000..02b5eb9661 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanservice_linux.cpp @@ -0,0 +1,894 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qconnmanservice_linux_p.h" + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE +static QDBusConnection dbusConnection = QDBusConnection::systemBus(); + + +QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + CONNMAN_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanManagerInterface::~QConnmanManagerInterface() +{ +} + +void QConnmanManagerInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(stateChanged(QString))) { + if (!connection().connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("StateChanged"), + this,SIGNAL(stateChanged(const QString&)))) { + qWarning() << "StateChanged not connected"; + + } + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + QLatin1String(CONNMAN_MANAGER_PATH), + QLatin1String(CONNMAN_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + } +} + +void QConnmanManagerInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QConnmanManagerInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << "does not contain" << property; + } + return var; +} + +QVariantMap QConnmanManagerInterface::getProperties() +{ + if(this->isValid()) { + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); + } else return QVariantMap(); +} + +QString QConnmanManagerInterface::getState() +{ + QDBusReply reply = this->call("GetState"); + return reply.value(); +} + +bool QConnmanManagerInterface::setProperty(const QString &name, const QDBusVariant &value) +{ + Q_UNUSED(name); + Q_UNUSED(value); + return false; +} + +QDBusObjectPath QConnmanManagerInterface::createProfile(const QString &/*name*/) +{ + return QDBusObjectPath(); +} + +bool QConnmanManagerInterface::removeProfile(QDBusObjectPath /*path*/) +{ + return false; +} + +bool QConnmanManagerInterface::requestScan(const QString &type) +{ + QDBusReply reply = this->call(QLatin1String("RequestScan"), QVariant::fromValue(type)); + + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +bool QConnmanManagerInterface::enableTechnology(const QString &type) +{ + QDBusReply > reply = this->call(QLatin1String("EnableTechnology"), QVariant::fromValue(type)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +bool QConnmanManagerInterface::disableTechnology(const QString &type) +{ + QDBusReply > reply = this->call(QLatin1String("DisableTechnology"), QVariant::fromValue(type)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } + return ok; +} + +QDBusObjectPath QConnmanManagerInterface::connectService(QVariantMap &map) +{ + QDBusReply reply = this->call(QLatin1String("ConnectService"), QVariant::fromValue(map)); + if(!reply.isValid()) { + qDebug() << reply.error().message(); + + } + return reply; +} + +void QConnmanManagerInterface::registerAgent(QDBusObjectPath &/*path*/) +{ +} + +void QConnmanManagerInterface::unregisterAgent(QDBusObjectPath /*path*/) +{ +} + +void QConnmanManagerInterface::registerCounter(const QString &path, quint32 interval) +{ QDBusReply > reply = this->call(QLatin1String("RegisterCounter"), + QVariant::fromValue(path), + QVariant::fromValue(interval)); + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + } +} + +void QConnmanManagerInterface::unregisterCounter(const QString &path) +{ QDBusReply > reply = this->call(QLatin1String("UnregisterCounter"), + QVariant::fromValue(path)); + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + } +} + +QString QConnmanManagerInterface::requestSession(const QString &bearerName) +{ + QDBusReply > reply = this->call(QLatin1String("RequestSession"), + QVariant::fromValue(bearerName)); + return QString(); +} + +void QConnmanManagerInterface::releaseSession() +{ + QDBusReply > reply = this->call(QLatin1String("ReleaseSession")); +} + + +QDBusObjectPath QConnmanManagerInterface::lookupService(const QString &service) +{ + QDBusReply reply = this->call(QLatin1String("LookupService"), QVariant::fromValue(service)); + if(!reply.isValid()) { + qDebug() << reply.error().message(); + } + return reply; +} + +// properties + +QStringList QConnmanManagerInterface::getAvailableTechnologies() +{ + QVariant var = getProperty("AvailableTechnologies"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getEnabledTechnologies() +{ + QVariant var = getProperty("EnabledTechnologies"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getConnectedTechnologies() +{ + QVariant var = getProperty("ConnectedTechnologies"); + return qdbus_cast(var); +} + +QString QConnmanManagerInterface::getDefaultTechnology() +{ + QVariant var = getProperty("DefaultTechnology"); + return qdbus_cast(var); +} + +bool QConnmanManagerInterface::getOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast(var); +} + +QString QConnmanManagerInterface::getActiveProfile() +{ + QVariant var = getProperty("ActiveProfile"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getProfiles() +{ + QVariant var = getProperty("Profiles"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getTechnologies() +{ + QVariant var = getProperty("Technologies"); + return qdbus_cast(var); +} + +QStringList QConnmanManagerInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast(var); +} + +QString QConnmanManagerInterface::getPathForTechnology(const QString &name) +{ + foreach(const QString path, getTechnologies()) { + if(path.contains(name)) { + return path; + } + } + return ""; +} + + +////////////////////////// +QConnmanProfileInterface::QConnmanProfileInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_PROFILE_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanProfileInterface::~QConnmanProfileInterface() +{ +} + +void QConnmanProfileInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_PROFILE_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } +} + +void QConnmanProfileInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QVariant))) { + + } +} + +QVariantMap QConnmanProfileInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanProfileInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +// properties +QString QConnmanProfileInterface::getName() +{ + + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +bool QConnmanProfileInterface::isOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast(var); +} + +QStringList QConnmanProfileInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast(var); +} + + +/////////////////////////// +QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_SERVICE_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanServiceInterface::~QConnmanServiceInterface() +{ +} + +void QConnmanServiceInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_SERVICE_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + } +} + +void QConnmanServiceInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QConnmanServiceInterface::getProperties() +{ + if(this->isValid()) { + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); + } + else + return QVariantMap(); +} + +QVariant QConnmanServiceInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +void QConnmanServiceInterface::connect() +{ + this->asyncCall(QLatin1String("Connect")); +} + +void QConnmanServiceInterface::disconnect() +{ + QDBusReply reply = this->call(QLatin1String("Disconnect")); +} + +void QConnmanServiceInterface::remove() +{ + QDBusReply reply = this->call(QLatin1String("Remove")); +} + +// void moveBefore(QDBusObjectPath &service); +// void moveAfter(QDBusObjectPath &service); + +// properties +QString QConnmanServiceInterface::getState() +{ + QVariant var = getProperty("State"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getError() +{ + QVariant var = getProperty("Error"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getMode() +{ + QVariant var = getProperty("Mode"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getSecurity() +{ + QVariant var = getProperty("Security"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getPassphrase() +{ + QVariant var = getProperty("Passphrase"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isPassphraseRequired() +{ + QVariant var = getProperty("PassphraseRequired"); + return qdbus_cast(var); +} + +quint8 QConnmanServiceInterface::getSignalStrength() +{ + QVariant var = getProperty("Strength"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isFavorite() +{ + QVariant var = getProperty("Favorite"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isImmutable() +{ + QVariant var = getProperty("Immutable"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isAutoConnect() +{ + QVariant var = getProperty("AutoConnect"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isSetupRequired() +{ + QVariant var = getProperty("SetupRequired"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getAPN() +{ + QVariant var = getProperty("APN"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getMCC() +{ + QVariant var = getProperty("MCC"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getMNC() +{ + QVariant var = getProperty("MNC"); + return qdbus_cast(var); +} + +bool QConnmanServiceInterface::isRoaming() +{ + QVariant var = getProperty("Roaming"); + return qdbus_cast(var); +} + +QStringList QConnmanServiceInterface::getNameservers() +{ + QVariant var = getProperty("NameServers"); + return qdbus_cast(var); +} + +QStringList QConnmanServiceInterface::getDomains() +{ + QVariant var = getProperty("Domains"); + return qdbus_cast(var); +} + +QVariantMap QConnmanServiceInterface::getIPv4() +{ + QVariant var = getProperty("IPv4"); + return qdbus_cast(var); +} + +QVariantMap QConnmanServiceInterface::getIPv4Configuration() +{ + QVariant var = getProperty("IPv4.Configuration"); + return qdbus_cast(var); +} + +QVariantMap QConnmanServiceInterface::getProxy() +{ + QVariant var = getProperty("Proxy"); + return qdbus_cast(var); +} + +QVariantMap QConnmanServiceInterface::getEthernet() +{ + QVariant var = getProperty("Ethernet"); + return qdbus_cast(var); +} + +QString QConnmanServiceInterface::getMethod() +{ + QVariant var; + QVariantMap map = getEthernet(); + QMapIterator it(map); + while(it.hasNext()) { + it.next(); + if(it.key() == "Method") { + return it.value().toString(); + } + } + return QString(); +} + +QString QConnmanServiceInterface::getInterface() +{ + QVariant var; + QVariantMap map = getEthernet(); + + QMapIterator it(map); + while(it.hasNext()) { + it.next(); + if(it.key() == "Interface") { + return it.value().toString(); + } + } + + return QString(); +} + +QString QConnmanServiceInterface::getMacAddress() +{ + QVariant var; + QVariantMap map = getEthernet(); + + QMapIterator it(map); + while(it.hasNext()) { + it.next(); + if(it.key() == "Address") { + return it.value().toString(); + } + } + return QString(); +} + +quint16 QConnmanServiceInterface::getMtu() +{ + quint16 mtu=0; + QVariant var; + QVariantMap map = getEthernet(); + + QMapIterator it(map); + while(it.hasNext()) { + it.next(); + if(it.key() == "MTU") { + return it.value().toUInt(); + } + } + return mtu; +} + +quint16 QConnmanServiceInterface::getSpeed() +{ + quint16 speed=0; + QVariant var; + QVariantMap map = getEthernet(); + + QMapIterator it(map); + while(it.hasNext()) { + it.next(); + if(it.key() == "Speed") { + return it.value().toUInt(); + } + } + return speed; +} + +QString QConnmanServiceInterface::getDuplex() +{ + QVariant var; + QVariantMap map = getEthernet(); + + QMapIterator it(map); + while(it.hasNext()) { + it.next(); + if(it.key() == "Duplex") { + return it.value().toString(); + } + } + return QString(); +} + + +bool QConnmanServiceInterface::isOfflineMode() +{ + QVariant var = getProperty("OfflineMode"); + return qdbus_cast(var); +} + +QStringList QConnmanServiceInterface::getServices() +{ + QVariant var = getProperty("Services"); + return qdbus_cast(var); +} + + +////////////////////////// +QConnmanTechnologyInterface::QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_TECHNOLOGY_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanTechnologyInterface::~QConnmanTechnologyInterface() +{ +} + +void QConnmanTechnologyInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(QString,QDBusVariant))); + } + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QConnmanDBusHelper *helper; + helper = new QConnmanDBusHelper(this); + + dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), + this->path(), + QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + } +} + +void QConnmanTechnologyInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QConnmanTechnologyInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QConnmanTechnologyInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } + return var; +} + +// properties +QString QConnmanTechnologyInterface::getState() +{ + QVariant var = getProperty("State"); + return qdbus_cast(var); +} + +QString QConnmanTechnologyInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +QString QConnmanTechnologyInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast(var); +} + + +////////////////////////////////// +QConnmanAgentInterface::QConnmanAgentInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_AGENT_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanAgentInterface::~QConnmanAgentInterface() +{ +} + +void QConnmanAgentInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { +// dbusConnection.connect(QLatin1String(CONNMAN_SERVICE), +// this->path(), +// QLatin1String(CONNMAN_NETWORK_INTERFACE), +// QLatin1String("PropertyChanged"), +// this,SIGNAL(propertyChanged(const QString &, QVariant &))); + } +} + +void QConnmanAgentInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString, QDBusVariant))) { + + } +} + + +void QConnmanAgentInterface::release() +{ +} + +void QConnmanAgentInterface::reportError(QDBusObjectPath &/*path*/, const QString &/*error*/) +{ +} + +//dict QConnmanAgentInterface::requestInput(QDBusObjectPath &path, dict fields) +//{ +//} + +void QConnmanAgentInterface::cancel() +{ +} + + +///////////////////////////////////////// +QConnmanCounterInterface::QConnmanCounterInterface(const QString &dbusPathName,QObject *parent) + : QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE), + dbusPathName, + CONNMAN_COUNTER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QConnmanCounterInterface::~QConnmanCounterInterface() +{ +} + +quint32 QConnmanCounterInterface::getReceivedByteCount() +{ + return 0; +} + +quint32 QConnmanCounterInterface::getTransmittedByteCount() +{ + return 0; +} + +quint64 QConnmanCounterInterface::getTimeOnline() +{ + return 0; +} + +///////////////////////////////////////// +QConnmanDBusHelper::QConnmanDBusHelper(QObject * parent) + : QObject(parent) +{ +} + +QConnmanDBusHelper::~QConnmanDBusHelper() +{ +} + +void QConnmanDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var) +{ + QDBusMessage msg = this->message(); + Q_EMIT propertyChangedContext(msg.path() ,item, var); +} + +///////////////// +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT + diff --git a/src/plugins/bearer/connman/qconnmanservice_linux_p.h b/src/plugins/bearer/connman/qconnmanservice_linux_p.h new file mode 100644 index 0000000000..d0ef6dc4f9 --- /dev/null +++ b/src/plugins/bearer/connman/qconnmanservice_linux_p.h @@ -0,0 +1,323 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QCONNMANSERVICE_H +#define QCONNMANSERVICE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +#ifndef __CONNMAN_DBUS_H + +#define CONNMAN_SERVICE "net.connman" +#define CONNMAN_PATH "/net/connman" + +#define CONNMAN_DEBUG_INTERFACE CONNMAN_SERVICE ".Debug" +#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error" +#define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent" +#define CONNMAN_COUNTER_INTERFACE CONNMAN_SERVICE ".Counter" + +#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager" +#define CONNMAN_MANAGER_PATH "/" + +#define CONNMAN_TASK_INTERFACE CONNMAN_SERVICE ".Task" +#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile" +#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service" +#define CONNMAN_PROVIDER_INTERFACE CONNMAN_SERVICE ".Provider" +#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology" +#endif + +QT_BEGIN_NAMESPACE + +QT_END_NAMESPACE + + +QT_BEGIN_NAMESPACE + +class QConnmanManagerInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanManagerInterface( QObject *parent = 0); + ~QConnmanManagerInterface(); + + QDBusObjectPath path() const; + + QVariantMap getProperties(); + bool setProperty(const QString &name, const QDBusVariant &value); + QDBusObjectPath createProfile(const QString &name); + bool removeProfile(QDBusObjectPath path); + bool requestScan(const QString &type); + bool enableTechnology(const QString &type); + bool disableTechnology(const QString &type); + QDBusObjectPath connectService(QVariantMap &map); + void registerAgent(QDBusObjectPath &path); + void unregisterAgent(QDBusObjectPath path); + void registerCounter(const QString &path, quint32 interval); + void unregisterCounter(const QString &path); + + QString requestSession(const QString &bearerName); + void releaseSession(); + + // properties + QString getState(); + QStringList getAvailableTechnologies(); + QStringList getEnabledTechnologies(); + QStringList getConnectedTechnologies(); + QString getDefaultTechnology(); + bool getOfflineMode(); + QString getActiveProfile(); + QStringList getProfiles(); + QStringList getTechnologies(); + QStringList getServices(); + QDBusObjectPath lookupService(const QString &); + + QString getPathForTechnology(const QString &tech); + + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void stateChanged(const QString &); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanProfileInterfacePrivate; +class QConnmanProfileInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanProfileInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanProfileInterface(); + + QVariantMap getProperties(); +// properties + QString getName(); + bool isOfflineMode(); + QStringList getServices(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); +private: + QConnmanProfileInterfacePrivate *d; + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanServiceInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanServiceInterface(); + + QVariantMap getProperties(); + // clearProperty + void connect(); + void disconnect(); + void remove(); + // void moveBefore(QDBusObjectPath &service); + // void moveAfter(QDBusObjectPath &service); + +// properties + QString getState(); + QString getError(); + QString getName(); + QString getType(); + QString getMode(); + QString getSecurity(); + QString getPassphrase(); + bool isPassphraseRequired(); + quint8 getSignalStrength(); + bool isFavorite(); + bool isImmutable(); + bool isAutoConnect(); + bool isSetupRequired(); + QString getAPN(); + QString getMCC(); + QString getMNC(); + bool isRoaming(); + QStringList getNameservers(); + QStringList getDomains(); + QVariantMap getIPv4(); + QVariantMap getIPv4Configuration(); + QVariantMap getProxy(); + QVariantMap getEthernet(); + + QString getMethod(); + QString getInterface(); + QString getMacAddress(); + quint16 getMtu(); + quint16 getSpeed(); + QString getDuplex(); + + bool isOfflineMode(); + QStringList getServices(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QConnmanTechnologyInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanTechnologyInterface(); + + QVariantMap getProperties(); +// properties + QString getState(); + QString getName(); + QString getType(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +}; + +class QConnmanAgentInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanAgentInterface(const QString &dbusPathName,QObject *parent = 0); + ~QConnmanAgentInterface(); + + void release(); + void reportError(QDBusObjectPath &path, const QString &error); +// dict requestInput(QDBusObjectPath &path, dict fields); + void cancel(); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); +}; + +class QConnmanCounterInterfacePrivate; +class QConnmanCounterInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QConnmanCounterInterface(const QString &dbusPathName, QObject *parent = 0); + ~QConnmanCounterInterface(); + +// void release(); + QString getInterface(); + quint32 getReceivedByteCount(); + quint32 getTransmittedByteCount(); + quint64 getTimeOnline(); + +private: + QConnmanCounterInterfacePrivate *d; +}; + +class QConnmanDBusHelper: public QObject, protected QDBusContext + { + Q_OBJECT + public: + QConnmanDBusHelper(QObject *parent = 0); + ~QConnmanDBusHelper(); + + public slots: + void propertyChanged(const QString &, const QDBusVariant &); + +Q_SIGNALS: + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +}; + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT + +#endif //QCONNMANSERVICE_H diff --git a/src/plugins/bearer/connman/qofonoservice_linux.cpp b/src/plugins/bearer/connman/qofonoservice_linux.cpp new file mode 100644 index 0000000000..e3fb2c6034 --- /dev/null +++ b/src/plugins/bearer/connman/qofonoservice_linux.cpp @@ -0,0 +1,945 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "qofonoservice_linux_p.h" + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +QT_BEGIN_NAMESPACE +static QDBusConnection dbusConnection = QDBusConnection::systemBus(); + + +QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), + OFONO_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoManagerInterface::~QOfonoManagerInterface() +{ +} + +QList QOfonoManagerInterface::getModems() +{ + QVariant var = getProperty("Modems"); + return qdbus_cast >(var); +} + +QDBusObjectPath QOfonoManagerInterface::currentModem() +{ + QList modems = getModems(); + foreach(const QDBusObjectPath modem, modems) { + QOfonoModemInterface device(modem.path()); + if(device.isPowered() && device.isOnline()) + return modem;; + } + return QDBusObjectPath(); +} + + +void QOfonoManagerInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), + QLatin1String(OFONO_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + QLatin1String(OFONO_MANAGER_PATH), + QLatin1String(OFONO_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } +} + +void QOfonoManagerInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoManagerInterface::getProperty(const QString &property) +{ + QVariantMap map = getProperties(); + if (map.contains(property)) { + return map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return QVariant(); +} + +QVariantMap QOfonoManagerInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + if(reply.isValid()) + return reply.value(); + else + return QVariantMap(); +} + +QOfonoDBusHelper::QOfonoDBusHelper(QObject * parent) + : QObject(parent) +{ +} + +QOfonoDBusHelper::~QOfonoDBusHelper() +{ +} + +void QOfonoDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var) +{ + QDBusMessage msg = this->message(); + Q_EMIT propertyChangedContext(msg.path() ,item, var); +} + + +QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_MODEM_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoModemInterface::~QOfonoModemInterface() +{ +} + +bool QOfonoModemInterface::isPowered() +{ + QVariant var = getProperty("Powered"); + return qdbus_cast(var); +} + +bool QOfonoModemInterface::isOnline() +{ + QVariant var = getProperty("Online"); + return qdbus_cast(var); +} + +QString QOfonoModemInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +QString QOfonoModemInterface::getManufacturer() +{ + QVariant var = getProperty("Manufacturer"); + return qdbus_cast(var); + +} + +QString QOfonoModemInterface::getModel() +{ + + QVariant var = getProperty("Model"); + return qdbus_cast(var); +} + +QString QOfonoModemInterface::getRevision() +{ + QVariant var = getProperty("Revision"); + return qdbus_cast(var); + +} +QString QOfonoModemInterface::getSerial() +{ + QVariant var = getProperty("Serial"); + return qdbus_cast(var); + +} + +QStringList QOfonoModemInterface::getFeatures() +{ + //sms, sim + QVariant var = getProperty("Features"); + return qdbus_cast(var); +} + +QStringList QOfonoModemInterface::getInterfaces() +{ + QVariant var = getProperty("Interfaces"); + return qdbus_cast(var); +} + +QString QOfonoModemInterface::defaultInterface() +{ + foreach(const QString &modem,getInterfaces()) { + return modem; + } + return QString(); +} + + +void QOfonoModemInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_MODEM_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_MODEM_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + }} + +void QOfonoModemInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariantMap QOfonoModemInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QVariant QOfonoModemInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + + +QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_NETWORK_REGISTRATION_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface() +{ +} + +QString QOfonoNetworkRegistrationInterface::getStatus() +{ + /* + "unregistered" Not registered to any network + "registered" Registered to home network + "searching" Not registered, but searching + "denied" Registration has been denied + "unknown" Status is unknown + "roaming" Registered, but roaming*/ + QVariant var = getProperty("Status"); + return qdbus_cast(var); +} + +quint16 QOfonoNetworkRegistrationInterface::getLac() +{ + QVariant var = getProperty("LocationAreaCode"); + return var.value(); +} + + +quint32 QOfonoNetworkRegistrationInterface::getCellId() +{ + QVariant var = getProperty("CellId"); + return var.value(); +} + +QString QOfonoNetworkRegistrationInterface::getTechnology() +{ + // "gsm", "edge", "umts", "hspa","lte" + QVariant var = getProperty("Technology"); + return qdbus_cast(var); +} + +QString QOfonoNetworkRegistrationInterface::getOperatorName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +int QOfonoNetworkRegistrationInterface::getSignalStrength() +{ + QVariant var = getProperty("Strength"); + return qdbus_cast(var); + +} + +QString QOfonoNetworkRegistrationInterface::getBaseStation() +{ + QVariant var = getProperty("BaseStation"); + return qdbus_cast(var); +} + +QList QOfonoNetworkRegistrationInterface::getOperators() +{ + QVariant var = getProperty("Operators"); + return qdbus_cast >(var); +} + +void QOfonoNetworkRegistrationInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + } +} + +void QOfonoNetworkRegistrationInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoNetworkRegistrationInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + + + +QOfonoNetworkOperatorInterface::QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_NETWORK_OPERATOR_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoNetworkOperatorInterface::~QOfonoNetworkOperatorInterface() +{ +} + +QString QOfonoNetworkOperatorInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +QString QOfonoNetworkOperatorInterface::getStatus() +{ + // "unknown", "available", "current" and "forbidden" + QVariant var = getProperty("Status"); + return qdbus_cast(var); +} + +QString QOfonoNetworkOperatorInterface::getMcc() +{ + QVariant var = getProperty("MobileCountryCode"); + return qdbus_cast(var); +} + +QString QOfonoNetworkOperatorInterface::getMnc() +{ + QVariant var = getProperty("MobileNetworkCode"); + return qdbus_cast(var); +} + +QStringList QOfonoNetworkOperatorInterface::getTechnologies() +{ + QVariant var = getProperty("Technologies"); + return qdbus_cast(var); +} + +void QOfonoNetworkOperatorInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + } +} + +void QOfonoNetworkOperatorInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoNetworkOperatorInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoNetworkOperatorInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QOfonoSimInterface::QOfonoSimInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_SIM_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoSimInterface::~QOfonoSimInterface() +{ +} + +bool QOfonoSimInterface::isPresent() +{ + QVariant var = getProperty("Present"); + return qdbus_cast(var); +} + +QString QOfonoSimInterface::getHomeMcc() +{ + QVariant var = getProperty("MobileCountryCode"); + return qdbus_cast(var); +} + +QString QOfonoSimInterface::getHomeMnc() +{ + QVariant var = getProperty("MobileNetworkCode"); + return qdbus_cast(var); +} + +// QStringList subscriberNumbers(); +// QMap serviceNumbers(); +QString QOfonoSimInterface::pinRequired() +{ + QVariant var = getProperty("PinRequired"); + return qdbus_cast(var); +} + +QString QOfonoSimInterface::lockedPins() +{ + QVariant var = getProperty("LockedPins"); + return qdbus_cast(var); +} + +QString QOfonoSimInterface::cardIdentifier() +{ + QVariant var = getProperty("CardIdentifier"); + return qdbus_cast(var); +} + +void QOfonoSimInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SIM_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SIM_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + } +} + +void QOfonoSimInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoSimInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoSimInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_DATA_CONNECTION_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface() +{ +} + +QList QOfonoDataConnectionManagerInterface::getPrimaryContexts() +{ + QVariant var = getProperty("PrimaryContexts"); + return qdbus_cast >(var); +} + +bool QOfonoDataConnectionManagerInterface::isAttached() +{ + QVariant var = getProperty("Attached"); + return qdbus_cast(var); +} + +bool QOfonoDataConnectionManagerInterface::isRoamingAllowed() +{ + QVariant var = getProperty("RoamingAllowed"); + return qdbus_cast(var); +} + +bool QOfonoDataConnectionManagerInterface::isPowered() +{ + QVariant var = getProperty("Powered"); + return qdbus_cast(var); +} + +void QOfonoDataConnectionManagerInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + } +} + +void QOfonoDataConnectionManagerInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoDataConnectionManagerInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +QOfonoPrimaryDataContextInterface::QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_DATA_CONTEXT_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoPrimaryDataContextInterface::~QOfonoPrimaryDataContextInterface() +{ +} + +bool QOfonoPrimaryDataContextInterface::isActive() +{ + QVariant var = getProperty("Active"); + return qdbus_cast(var); +} + +QString QOfonoPrimaryDataContextInterface::getApName() +{ + QVariant var = getProperty("AccessPointName"); + return qdbus_cast(var); +} + +QString QOfonoPrimaryDataContextInterface::getType() +{ + QVariant var = getProperty("Type"); + return qdbus_cast(var); +} + +QString QOfonoPrimaryDataContextInterface::getName() +{ + QVariant var = getProperty("Name"); + return qdbus_cast(var); +} + +QVariantMap QOfonoPrimaryDataContextInterface::getSettings() +{ + QVariant var = getProperty("Settings"); + return qdbus_cast(var); +} + +QString QOfonoPrimaryDataContextInterface::getInterface() +{ + QVariant var = getProperty("Interface"); + return qdbus_cast(var); +} + +QString QOfonoPrimaryDataContextInterface::getAddress() +{ + QVariant var = getProperty("Address"); + return qdbus_cast(var); +} + +bool QOfonoPrimaryDataContextInterface::setActive(bool on) +{ +// this->setProperty("Active", QVariant(on)); + + return setProp("Active", qVariantFromValue(on)); +} + +bool QOfonoPrimaryDataContextInterface::setApn(const QString &name) +{ + return setProp("AccessPointName", QVariant::fromValue(name)); +} + +void QOfonoPrimaryDataContextInterface::connectNotify(const char *signal) +{ +if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_DATA_CONTEXT_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_DATA_CONTEXT_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), Qt::UniqueConnection); + } +} + +void QOfonoPrimaryDataContextInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoPrimaryDataContextInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoPrimaryDataContextInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +bool QOfonoPrimaryDataContextInterface::setProp(const QString &property, const QVariant &var) +{ + QList args; + args << qVariantFromValue(property) << qVariantFromValue(QDBusVariant(var)); + + QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect, + QLatin1String("SetProperty"), + args); + bool ok = true; + if(reply.type() != QDBusMessage::ReplyMessage) { + qWarning() << reply.errorMessage(); + ok = false; + } + qWarning() << reply.errorMessage(); + return ok; +} + +QOfonoSmsInterface::QOfonoSmsInterface(const QString &dbusPathName, QObject *parent) + : QDBusAbstractInterface(QLatin1String(OFONO_SERVICE), + dbusPathName, + OFONO_SMS_MANAGER_INTERFACE, + QDBusConnection::systemBus(), parent) +{ +} + +QOfonoSmsInterface::~QOfonoSmsInterface() +{ +} + +void QOfonoSmsInterface::connectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QDBusVariant))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SMS_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + this,SIGNAL(propertyChanged(const QString &, const QDBusVariant & )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(propertyChangedContext(QString,QString,QDBusVariant))) { + QOfonoDBusHelper *helper; + helper = new QOfonoDBusHelper(this); + + dbusConnection.connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SMS_MANAGER_INTERFACE), + QLatin1String("PropertyChanged"), + helper,SLOT(propertyChanged(QString,QDBusVariant))); + + + QObject::connect(helper,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &)), + this,SIGNAL(propertyChangedContext(const QString &,const QString &,const QDBusVariant &))); + } + + if (QLatin1String(signal) == SIGNAL(immediateMessage(QString,QVariantMap))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SMS_MANAGER_INTERFACE), + QLatin1String("ImmediateMessage"), + this,SIGNAL(immediateMessage(QString,QVariantMap )))) { + qWarning() << "PropertyCHanged not connected"; + } + } + + if (QLatin1String(signal) == SIGNAL(incomingMessage(QString,QVariantMap))) { + if(!connection().connect(QLatin1String(OFONO_SERVICE), + this->path(), + QLatin1String(OFONO_SMS_MANAGER_INTERFACE), + QLatin1String("IncomingMessage"), + this,SIGNAL(incomingMessage(QString,QVariantMap)))) { + qWarning() << "PropertyCHanged not connected"; + } + } +} + +void QOfonoSmsInterface::disconnectNotify(const char *signal) +{ + if (QLatin1String(signal) == SIGNAL(propertyChanged(QString,QVariant))) { + + } +} + +QVariant QOfonoSmsInterface::getProperty(const QString &property) +{ + QVariant var; + QVariantMap map = getProperties(); + if (map.contains(property)) { + var = map.value(property); + } else { + qDebug() << Q_FUNC_INFO << "does not contain" << property; + } + return var; +} + +QVariantMap QOfonoSmsInterface::getProperties() +{ + QDBusReply reply = this->call(QLatin1String("GetProperties")); + return reply.value(); +} + +void QOfonoSmsInterface::sendMessage(const QString &to, const QString &message) +{ + QDBusReply reply = this->call(QLatin1String("SendMessage"), + QVariant::fromValue(to), + QVariant::fromValue(message)); + bool ok = true; + if(reply.error().type() == QDBusError::InvalidArgs) { + qWarning() << reply.error().message(); + ok = false; + } +} + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT diff --git a/src/plugins/bearer/connman/qofonoservice_linux_p.h b/src/plugins/bearer/connman/qofonoservice_linux_p.h new file mode 100644 index 0000000000..af54ba0613 --- /dev/null +++ b/src/plugins/bearer/connman/qofonoservice_linux_p.h @@ -0,0 +1,340 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QOFONOSERVICE_H +#define QOFONOSERVICE_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_DBUS + +#define OFONO_SERVICE "org.ofono" +#define OFONO_MANAGER_INTERFACE "org.ofono.Manager" +#define OFONO_MANAGER_PATH "/" +#define OFONO_MODEM_INTERFACE "org.ofono.Modem" +#define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration" +#define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator" +#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.DataConnectionManager" +#define OFONO_SIM_MANAGER_INTERFACE "org.ofono.SimManager" +#define OFONO_DATA_CONTEXT_INTERFACE "org.ofono.PrimaryDataContext" + +#define OFONO_SMS_MANAGER_INTERFACE "org.ofono.SmsManager" +#define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook" +#define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting" + + + +QT_BEGIN_NAMESPACE + +QT_END_NAMESPACE + + +QT_BEGIN_NAMESPACE + +class QOfonoManagerInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoManagerInterface( QObject *parent = 0); + ~QOfonoManagerInterface(); + + QDBusObjectPath path() const; + + QVariantMap getProperties(); + bool setProperty(const QString &name, const QDBusVariant &value); + QList getModems(); + QDBusObjectPath currentModem(); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +}; + + +class QOfonoDBusHelper: public QObject, protected QDBusContext + { + Q_OBJECT + public: + QOfonoDBusHelper(QObject *parent = 0); + ~QOfonoDBusHelper(); + + public slots: + void propertyChanged(const QString &, const QDBusVariant &); + Q_SIGNALS: + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +}; + +class QOfonoModemInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = 0); + ~QOfonoModemInterface(); + + QVariantMap getProperties(); + //properties + bool isPowered(); + bool isOnline(); + QString getName(); + QString getManufacturer(); + QString getModel(); + QString getRevision(); + QString getSerial(); + + QStringList getFeatures(); //sms, sim + QStringList getInterfaces(); + QString defaultInterface(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); +}; + + +class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = 0); + ~QOfonoNetworkRegistrationInterface(); + + QVariantMap getProperties(); + + //properties + QString getStatus(); + quint16 getLac(); + quint32 getCellId(); + QString getTechnology(); + QString getOperatorName(); + int getSignalStrength(); + QString getBaseStation(); + QList getOperators(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + +}; + +class QOfonoNetworkOperatorInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: +//modem or operator paths + QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent = 0); + ~QOfonoNetworkOperatorInterface(); + + QVariantMap getProperties(); + + //properties + QString getName(); + QString getStatus();// "unknown", "available", "current" and "forbidden" + QString getMcc(); + QString getMnc(); + QStringList getTechnologies(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + +class QOfonoSimInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoSimInterface(const QString &dbusModemPathName, QObject *parent = 0); + ~QOfonoSimInterface(); + + QVariantMap getProperties(); + + //properties + bool isPresent(); + QString getHomeMcc(); + QString getHomeMnc(); +// QStringList subscriberNumbers(); +// QMap serviceNumbers(); + QString pinRequired(); + QString lockedPins(); + QString cardIdentifier(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + + +class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = 0); + ~QOfonoDataConnectionManagerInterface(); + + QVariantMap getProperties(); + + //properties + QList getPrimaryContexts(); + bool isAttached(); + bool isRoamingAllowed(); + bool isPowered(); + + bool setPower(bool on); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); +}; + + +class QOfonoPrimaryDataContextInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent = 0); + ~QOfonoPrimaryDataContextInterface(); + + QVariantMap getProperties(); + + //properties + bool isActive(); + QString getApName(); + QString getType(); + QString getName(); + QVariantMap getSettings(); + QString getInterface(); + QString getAddress(); + + bool setActive(bool on); + bool setApn(const QString &name); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + bool setProp(const QString &, const QVariant &var); +}; + +class QOfonoSmsInterface : public QDBusAbstractInterface +{ + Q_OBJECT + +public: + + QOfonoSmsInterface(const QString &dbusModemPathName, QObject *parent = 0); + ~QOfonoSmsInterface(); + + QVariantMap getProperties(); + void sendMessage(const QString &to, const QString &message); + + //properties + QString serviceCenterAddress(); + bool useDeliveryReports(); + QString bearer(); + +protected: + void connectNotify(const char *signal); + void disconnectNotify(const char *signal); + QVariant getProperty(const QString &); + +Q_SIGNALS: + void propertyChanged(const QString &, const QDBusVariant &value); + void propertyChangedContext(const QString &,const QString &,const QDBusVariant &); + void immediateMessage(const QString &message, const QVariantMap &info); + void incomingMessage(const QString &message, const QVariantMap &info); +}; + +QT_END_NAMESPACE + +#endif // QT_NO_DBUS +#endif // QT_NO_BEARERMANAGEMENT + +#endif //QOFONOSERVICE_H -- cgit v1.2.3