diff -Nru libqofono-0.53/debian/changelog libqofono-0.70~rtm/debian/changelog --- libqofono-0.53/debian/changelog 2014-08-20 18:26:13.000000000 +0000 +++ libqofono-0.70~rtm/debian/changelog 2015-02-06 15:22:29.000000000 +0000 @@ -1,3 +1,27 @@ +libqofono (0.70~rtm-0ubuntu2) 14.09; urgency=medium + + * debian/control + - fixed typo in breaks + + -- Ken VanDine Wed, 14 Jan 2015 09:36:03 -0500 + +libqofono (0.70-0ubuntu1) vivid; urgency=medium + + * New upstream release. + * Dropped patches applied upstream, service_numbers.patch and + fix_multiarch.patch + * Refreshed expose_modem_tech.patch and mtk_settings_binding.patch + + -- Ken VanDine Mon, 12 Jan 2015 11:32:24 -0500 + +libqofono (0.53-0ubuntu3) vivid; urgency=medium + + * debian/patches/mtk_settings_binding.patch + - add mtk (mediatek) settings binding which allows consumer + to set which modem to allow 3G communication (LP: #1373388) + + -- Ken VanDine Fri, 21 Nov 2014 10:07:54 -0500 + libqofono (0.53-0ubuntu2) utopic; urgency=medium * debian/patches/expose_modem_tech.patch diff -Nru libqofono-0.53/debian/control libqofono-0.70~rtm/debian/control --- libqofono-0.53/debian/control 2014-08-20 15:16:43.000000000 +0000 +++ libqofono-0.70~rtm/debian/control 2015-01-14 14:35:30.000000000 +0000 @@ -37,6 +37,7 @@ Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends}, +Breaks: ubuntu-system-settings (<< 0.3+15.04.20150114) Description: QML bindings for libqofono A library for accessing the ofono daemon, and a declarative plugin for it. This allows accessing ofono in qtquick and friends. diff -Nru libqofono-0.53/debian/patches/expose_modem_tech.patch libqofono-0.70~rtm/debian/patches/expose_modem_tech.patch --- libqofono-0.53/debian/patches/expose_modem_tech.patch 2014-08-20 15:16:13.000000000 +0000 +++ libqofono-0.70~rtm/debian/patches/expose_modem_tech.patch 2015-01-12 18:25:35.000000000 +0000 @@ -4,12 +4,12 @@ radiosettings: expose modemtechnologies -diff --git a/src/qofonoradiosettings.cpp b/src/qofonoradiosettings.cpp -index f1d2159..99073be 100644 ---- a/src/qofonoradiosettings.cpp -+++ b/src/qofonoradiosettings.cpp -@@ -97,6 +97,8 @@ void QOfonoRadioSettings::updateProperty(const QString &property, const QVariant - +Index: libqofono-0.70/src/qofonoradiosettings.cpp +=================================================================== +--- libqofono-0.70.orig/src/qofonoradiosettings.cpp ++++ libqofono-0.70/src/qofonoradiosettings.cpp +@@ -47,6 +47,8 @@ void QOfonoRadioSettings::propertyChange + SUPER::propertyChanged(property, value); if (property == QLatin1String("TechnologyPreference")) { Q_EMIT technologyPreferenceChanged(value.value()); + } else if (property == QLatin1String("ModemTechnologies")) { @@ -17,31 +17,31 @@ } else if (property == QLatin1String("GsmBand")) { Q_EMIT gsmBandChanged(value.value()); } else if (property == QLatin1String("UtmsBand")) { -@@ -117,6 +119,11 @@ void QOfonoRadioSettings::setTechnologyPreference(const QString &preference) - d_ptr->radioSettings->SetProperty("TechnologyPreference", QDBusVariant(preference)); +@@ -66,6 +68,11 @@ void QOfonoRadioSettings::setTechnologyP + setProperty("TechnologyPreference", preference); } +QStringList QOfonoRadioSettings::modemTechnologies() const +{ -+ return d_ptr->properties["ModemTechnologies"].value(); ++ return getStringList("ModemTechnologies"); +} + QString QOfonoRadioSettings::gsmBand() const { - return d_ptr->properties["GsmBand"].value(); -diff --git a/src/qofonoradiosettings.h b/src/qofonoradiosettings.h -index d260c3d..90263c4 100644 ---- a/src/qofonoradiosettings.h -+++ b/src/qofonoradiosettings.h -@@ -33,6 +33,7 @@ class QOFONOSHARED_EXPORT QOfonoRadioSettings : public QObject + return getString("GsmBand"); +Index: libqofono-0.70/src/qofonoradiosettings.h +=================================================================== +--- libqofono-0.70.orig/src/qofonoradiosettings.h ++++ libqofono-0.70/src/qofonoradiosettings.h +@@ -29,6 +29,7 @@ class QOFONOSHARED_EXPORT QOfonoRadioSet + Q_OBJECT Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) - Q_PROPERTY(QString technologyPreference READ technologyPreference WRITE setTechnologyPreference NOTIFY technologyPreferenceChanged) + Q_PROPERTY(QStringList modemTechnologies READ modemTechnologies NOTIFY modemTechnologiesChanged) Q_PROPERTY(QString gsmBand READ gsmBand WRITE setGsmBand NOTIFY gsmBandChanged) Q_PROPERTY(QString umtsBand READ umtsBand WRITE setUmtsBand NOTIFY umtsBandChanged) Q_PROPERTY(bool fastDormancy READ fastDormancy WRITE setFastDormancy NOTIFY fastDormancyChanged) -@@ -47,6 +48,8 @@ public: +@@ -43,6 +44,8 @@ public: QString technologyPreference() const; void setTechnologyPreference(const QString &preference); @@ -50,19 +50,11 @@ QString gsmBand() const; void setGsmBand(const QString &gsmBand); -@@ -59,13 +62,14 @@ public: - bool isValid() const; +@@ -56,6 +59,7 @@ public: + Q_SIGNALS: void technologyPreferenceChanged(const QString &preference); + void modemTechnologiesChanged(const QStringList &technologies); void gsmBandChanged(const QString &gsmBand); void umtsBandChanged(const QString &umtsBand); void fastDormancyChanged(bool fastDormancy); - void modemPathChanged(const QString &path); - - public slots: -- -+ - private: - void updateProperty(const QString &property, const QVariant &value); - diff -Nru libqofono-0.53/debian/patches/fix_multiarch.patch libqofono-0.70~rtm/debian/patches/fix_multiarch.patch --- libqofono-0.53/debian/patches/fix_multiarch.patch 2014-08-20 15:16:43.000000000 +0000 +++ libqofono-0.70~rtm/debian/patches/fix_multiarch.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,28 +0,0 @@ -Index: libqofono-0.53/src/src.pro -=================================================================== ---- libqofono-0.53.orig/src/src.pro 2014-06-23 15:32:16.082380000 +0200 -+++ libqofono-0.53/src/src.pro 2014-06-23 15:33:47.301292315 +0200 -@@ -10,12 +10,12 @@ - - equals(QT_MAJOR_VERSION, 4): { - TARGET = qofono -- pkgconfig.path = $$INSTALL_ROOT$$PREFIX/lib/pkgconfig -+ pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig - } - - equals(QT_MAJOR_VERSION, 5): { - TARGET = qofono-qt5 -- pkgconfig.path = $$INSTALL_ROOT$$PREFIX/lib/pkgconfig-qt5 -+ pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig-qt5 - } - - TEMPLATE = lib -@@ -203,7 +203,7 @@ - xmlfiles.path = $$INSTALL_ROOT$$PREFIX/include/qofono-qt5/dbus - } - --target.path = $$INSTALL_ROOT$$PREFIX/lib -+target.path = $$[QT_INSTALL_LIBS] - headers.files = $$PUBLIC_HEADERS - - dbusheaders.files = $$DBUS_HEADERS diff -Nru libqofono-0.53/debian/patches/mtk_settings_binding.patch libqofono-0.70~rtm/debian/patches/mtk_settings_binding.patch --- libqofono-0.53/debian/patches/mtk_settings_binding.patch 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/debian/patches/mtk_settings_binding.patch 2015-01-12 16:37:36.000000000 +0000 @@ -0,0 +1,455 @@ +commit 8f71ba98d1ac5dcbdb0f7e191f8bf8f72a925898 +Author: Jonas G. Drange +Date: Thu Nov 20 17:01:17 CET 2014 + + add mtk (mediatek) settings binding which allows consumer + to set which modem to allow 3G communication + +Index: libqofono-0.70/plugin/qofonodeclarativeplugin.cpp +=================================================================== +--- libqofono-0.70.orig/plugin/qofonodeclarativeplugin.cpp ++++ libqofono-0.70/plugin/qofonodeclarativeplugin.cpp +@@ -34,6 +34,7 @@ + #include "qofonomessage.h" + #include "qofonomessagemanager.h" + #include "qofonomessagewaiting.h" ++#include "qofonomtksettings.h" + + #include "qofonosimmanager.h" + +@@ -86,6 +87,7 @@ void QOfonoDeclarativePlugin::registerTy + qmlRegisterType(uri,major,minor,"OfonoMessage"); + qmlRegisterType(uri,major,minor,"OfonoMessageManager"); + qmlRegisterType(uri,major,minor,"OfonoMessageWaiting"); ++ qmlRegisterType(uri,0,2,"OfonoMtkSettings"); + + qmlRegisterType(uri,major,minor,"OfonoSimManager"); + +Index: libqofono-0.70/src/dbus/ofono_mtk_settings.xml +=================================================================== +--- /dev/null ++++ libqofono-0.70/src/dbus/ofono_mtk_settings.xml +@@ -0,0 +1,18 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +Index: libqofono-0.70/src/dbus/ofonomtksettings.cpp +=================================================================== +--- /dev/null ++++ libqofono-0.70/src/dbus/ofonomtksettings.cpp +@@ -0,0 +1,26 @@ ++/* ++ * This file was generated by qdbusxml2cpp version 0.8 ++ * Command line was: qdbusxml2cpp -c OfonoMtkSettings -p ofonomtksettings -N ofono_mtk_settings.xml ++ * ++ * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ++ * ++ * This is an auto-generated file. ++ * This file may have been hand-edited. Look for HAND-EDIT comments ++ * before re-generating it. ++ */ ++ ++#include "ofonomtksettings.h" ++ ++/* ++ * Implementation of interface class OfonoMtkSettings ++ */ ++ ++OfonoMtkSettings::OfonoMtkSettings(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) ++ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) ++{ ++} ++ ++OfonoMtkSettings::~OfonoMtkSettings() ++{ ++} ++ +Index: libqofono-0.70/src/dbus/ofonomtksettings.h +=================================================================== +--- /dev/null ++++ libqofono-0.70/src/dbus/ofonomtksettings.h +@@ -0,0 +1,56 @@ ++/* ++ * This file was generated by qdbusxml2cpp version 0.8 ++ * Command line was: qdbusxml2cpp -c OfonoMtkSettings -p ofonomtksettings -N ofono_mtk_settings.xml ++ * ++ * qdbusxml2cpp is Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ++ * ++ * This is an auto-generated file. ++ * Do not edit! All changes made to it will be lost. ++ */ ++ ++#ifndef OFONOMTKSETTINGS_H_1416404986 ++#define OFONOMTKSETTINGS_H_1416404986 ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++/* ++ * Proxy class for interface org.ofono.MtkSettings ++ */ ++class OfonoMtkSettings: public QDBusAbstractInterface ++{ ++ Q_OBJECT ++public: ++ static inline const char *staticInterfaceName() ++ { return "org.ofono.MtkSettings"; } ++ ++public: ++ OfonoMtkSettings(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ++ ++ ~OfonoMtkSettings(); ++ ++public Q_SLOTS: // METHODS ++ inline QDBusPendingReply GetProperties() ++ { ++ QList argumentList; ++ return asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); ++ } ++ ++ inline QDBusPendingReply<> SetProperty(const QString &in0, const QDBusVariant &in1) ++ { ++ QList argumentList; ++ argumentList << QVariant::fromValue(in0) << QVariant::fromValue(in1); ++ return asyncCallWithArgumentList(QLatin1String("SetProperty"), argumentList); ++ } ++ ++Q_SIGNALS: // SIGNALS ++ void PropertyChanged(const QString &in0, const QDBusVariant &in1); ++}; ++ ++#endif +Index: libqofono-0.70/src/qofonomtksettings.cpp +=================================================================== +--- /dev/null ++++ libqofono-0.70/src/qofonomtksettings.cpp +@@ -0,0 +1,121 @@ ++/**************************************************************************** ++** ++** Copyright (C) 2014 Canonical Ltd. ++** Contact: jonas.drange@canonical.com ++** ++** 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. ++** ++****************************************************************************/ ++ ++#include "qofonomtksettings.h" ++#include "dbus/ofonomtksettings.h" ++ ++class QOfonoMtkSettingsPrivate ++{ ++public: ++ QOfonoMtkSettingsPrivate(); ++ QString modemPath; ++ OfonoMtkSettings *mtkSettings; ++ QVariantMap properties; ++ ++}; ++ ++QOfonoMtkSettingsPrivate::QOfonoMtkSettingsPrivate() : ++ modemPath(QString()) ++ , mtkSettings(0) ++{ ++} ++ ++QOfonoMtkSettings::QOfonoMtkSettings(QObject *parent) : ++ QObject(parent) ++ , d_ptr(new QOfonoMtkSettingsPrivate) ++{ ++} ++ ++QOfonoMtkSettings::~QOfonoMtkSettings() ++{ ++ delete d_ptr; ++} ++ ++void QOfonoMtkSettings::setModemPath(const QString &path) ++{ ++ if (path == d_ptr->modemPath || ++ path.isEmpty()) ++ return; ++ ++ QStringList removedProperties = d_ptr->properties.keys(); ++ ++ delete d_ptr->mtkSettings; ++ d_ptr->mtkSettings = new OfonoMtkSettings("org.ofono", path, QDBusConnection::systemBus(),this); ++ ++ if (d_ptr->mtkSettings->isValid()) { ++ d_ptr->modemPath = path; ++ ++ connect(d_ptr->mtkSettings,SIGNAL(PropertyChanged(QString,QDBusVariant)), ++ this,SLOT(propertyChanged(QString,QDBusVariant))); ++ ++ QVariantMap properties = d_ptr->mtkSettings->GetProperties().value(); ++ for (QVariantMap::ConstIterator it = properties.constBegin(); ++ it != properties.constEnd(); ++it) { ++ updateProperty(it.key(), it.value()); ++ removedProperties.removeOne(it.key()); ++ } ++ ++ Q_EMIT modemPathChanged(path); ++ } ++ ++ foreach (const QString &p, removedProperties) ++ updateProperty(p, QVariant()); ++} ++ ++QString QOfonoMtkSettings::modemPath() const ++{ ++ return d_ptr->modemPath; ++} ++ ++ ++void QOfonoMtkSettings::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) ++{ ++ updateProperty(property, dbusvalue.variant()); ++} ++ ++void QOfonoMtkSettings::updateProperty(const QString &property, const QVariant &value) ++{ ++ if (d_ptr->properties.value(property) == value) ++ return; ++ ++ if (value.isValid()) ++ d_ptr->properties.insert(property, value); ++ else ++ d_ptr->properties.remove(property); ++ ++ if (property == QLatin1String("Has3G")) { ++ Q_EMIT has3GChanged(value.value()); ++ } ++} ++ ++bool QOfonoMtkSettings::has3G() const ++{ ++ return d_ptr->properties["Has3G"].value(); ++} ++ ++void QOfonoMtkSettings::setHas3G(bool has3G) ++{ ++ // We do not allow this property to be set to false ++ if (!has3G) ++ return; ++ ++ if (d_ptr->mtkSettings) ++ d_ptr->mtkSettings->SetProperty("Has3G", QDBusVariant(has3G)); ++} ++ ++bool QOfonoMtkSettings::isValid() const ++{ ++ return d_ptr->mtkSettings->isValid(); ++} +Index: libqofono-0.70/src/qofonomtksettings.h +=================================================================== +--- /dev/null ++++ libqofono-0.70/src/qofonomtksettings.h +@@ -0,0 +1,61 @@ ++/**************************************************************************** ++** ++** Copyright (C) 2014 Canonical Ltd. ++** Contact: jonas.drange@canonical.com ++** ++** 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. ++** ++****************************************************************************/ ++ ++#ifndef QOFONOMtkSettings_H ++#define QOFONOMtkSettings_H ++ ++#include ++#include ++ ++#include "qofono_global.h" ++//! This class is used to access ofono mtk (MediaTek) settings API ++/*! ++ * The API is documented in ++ * https://github.com/rilmodem/ofono/blob/master/doc/mtk-settings-api.txt ++ */ ++ ++class QOfonoMtkSettingsPrivate; ++class QOFONOSHARED_EXPORT QOfonoMtkSettings : public QObject ++{ ++ Q_OBJECT ++ Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) ++ Q_PROPERTY(bool has3G READ has3G WRITE setHas3G NOTIFY has3GChanged) ++ ++public: ++ explicit QOfonoMtkSettings(QObject *parent = 0); ++ ~QOfonoMtkSettings(); ++ ++ QString modemPath() const; ++ void setModemPath(const QString &path); ++ ++ bool has3G() const; ++ void setHas3G(bool has3G); ++ ++ bool isValid() const; ++Q_SIGNALS: ++ void has3GChanged(bool has3G); ++ void modemPathChanged(const QString &path); ++ ++public slots: ++ ++private: ++ void updateProperty(const QString &property, const QVariant &value); ++ ++ QOfonoMtkSettingsPrivate *d_ptr; ++private slots: ++ void propertyChanged(const QString &property,const QDBusVariant &value); ++}; ++ ++#endif // QOFONOMtkSettings_H +Index: libqofono-0.70/src/src.pro +=================================================================== +--- libqofono-0.70.orig/src/src.pro ++++ libqofono-0.70/src/src.pro +@@ -49,6 +49,7 @@ XML_FILES += \ + dbus/ofono_message_manager.xml \ + dbus/ofono_messagewaiting.xml \ + dbus/ofono_modem.xml \ ++ dbus/ofono_mtk_settings.xml \ + dbus/ofono_network_operator.xml \ + dbus/ofono_network_registration.xml \ + dbus/ofono_phonebook.xml \ +@@ -91,6 +92,7 @@ DBUS_FILES +=\ + dbus/ofonomessagemanager\ + dbus/ofonomessagewaiting\ + dbus/ofonomodem\ ++ dbus/ofonomtksettings\ + dbus/ofononetworkoperator\ + dbus/ofononetworkregistration\ + dbus/ofonophonebook\ +@@ -137,6 +139,7 @@ SOURCES += $$DBUS_SOURCES\ + qofonomessage.cpp \ + qofonomessagemanager.cpp \ + qofonomessagewaiting.cpp \ ++ qofonomtksettings.cpp \ + qofonosimmanager.cpp \ + qofonophonebook.cpp \ + qofonopositioningrequestagent.cpp \ +@@ -176,6 +179,7 @@ PUBLIC_HEADERS += \ + qofonomessage.h \ + qofonomessagemanager.h \ + qofonomessagewaiting.h \ ++ qofonomtksettings.h \ + qofonosimmanager.h \ + qofonophonebook.h \ + qofonopositioningrequestagent.h \ +Index: libqofono-0.70/test/auto/tests/tests.pro +=================================================================== +--- libqofono-0.70.orig/test/auto/tests/tests.pro ++++ libqofono-0.70/test/auto/tests/tests.pro +@@ -11,6 +11,7 @@ SUBDIRS += \ + tst_qofonosimmanager.pro \ + tst_qofonomessagewaiting.pro \ + tst_qofonomessagemanager.pro \ ++ tst_qofonomtksettings.pro \ + tst_qofonoradiosettings.pro \ + tst_qofonocallbarring.pro \ + tst_qofonocallforwarding.pro \ +Index: libqofono-0.70/test/auto/tests/tst_qofonomtksettings.cpp +=================================================================== +--- /dev/null ++++ libqofono-0.70/test/auto/tests/tst_qofonomtksettings.cpp +@@ -0,0 +1,61 @@ ++/* ++ * ++ * Copyright (C) 2014 Canonical Ltd. ++ * Contact: Jonas G. Drange ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public License ++ * version 2.1 as published by the Free Software Foundation. ++ * ++ * This library is distributed in the hope that it will be useful, but ++ * WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ * ++ */ ++ ++#include ++#include ++ ++#include "../../../src/qofonomtksettings.h" ++ ++#include ++ ++class TestQOfonoMtkSettings : public QObject ++{ ++ Q_OBJECT ++ ++private slots: ++ void initTestCase() ++ { ++ m = new QOfonoMtkSettings(this); ++ m->setModemPath("/phonesim"); ++ QCOMPARE(m->isValid(), true); ++ ++ QEXPECT_FAIL("", "mtk settings is not supported by phonesim", Abort); ++ QVERIFY(false); ++ } ++ ++ void testQOfonoMtkSettings() ++ { ++ QSignalSpy has3G(m, SIGNAL(has3GChanged(bool))); ++ ++ qDebug() << "has3G():" << m->has3G(); ++ } ++ ++ void cleanupTestCase() ++ { ++ ++ } ++ ++private: ++ QOfonoMtkSettings *m; ++}; ++ ++QTEST_MAIN(TestQOfonoMtkSettings) ++#include "tst_qofonomtksettings.moc" +Index: libqofono-0.70/test/auto/tests/tst_qofonomtksettings.pro +=================================================================== +--- /dev/null ++++ libqofono-0.70/test/auto/tests/tst_qofonomtksettings.pro +@@ -0,0 +1,2 @@ ++include(testcase.pri) ++SOURCES += tst_qofonomtksettings.cpp diff -Nru libqofono-0.53/debian/patches/series libqofono-0.70~rtm/debian/patches/series --- libqofono-0.53/debian/patches/series 2014-08-20 15:17:46.000000000 +0000 +++ libqofono-0.70~rtm/debian/patches/series 2015-01-12 16:34:10.000000000 +0000 @@ -1,3 +1,2 @@ -service_numbers.patch -fix_multiarch.patch expose_modem_tech.patch +mtk_settings_binding.patch diff -Nru libqofono-0.53/debian/patches/service_numbers.patch libqofono-0.70~rtm/debian/patches/service_numbers.patch --- libqofono-0.53/debian/patches/service_numbers.patch 2014-08-20 15:16:43.000000000 +0000 +++ libqofono-0.70~rtm/debian/patches/service_numbers.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,12 +0,0 @@ -=== modified file 'src/qofonosimmanager.h' ---- old/src/qofonosimmanager.h 2014-06-10 02:16:00 +0000 -+++ new/src/qofonosimmanager.h 2014-06-18 17:16:51 +0000 -@@ -41,6 +41,7 @@ - Q_PROPERTY(QString mobileCountryCode READ mobileCountryCode NOTIFY mobileCountryCodeChanged) - Q_PROPERTY(QString mobileNetworkCode READ mobileNetworkCode NOTIFY mobileNetworkCodeChanged) - Q_PROPERTY(QStringList subscriberNumbers READ subscriberNumbers WRITE setSubscriberNumbers NOTIFY subscriberNumbersChanged) -+ Q_PROPERTY(QVariantMap serviceNumbers READ serviceNumbers NOTIFY serviceNumbersChanged) - Q_PROPERTY(PinType pinRequired READ pinRequired NOTIFY pinRequiredChanged) - Q_PROPERTY(QVariantList lockedPins READ lockedPins NOTIFY lockedPinsChanged) - Q_PROPERTY(QString cardIdentifier READ cardIdentifier NOTIFY cardIdentifierChanged) - diff -Nru libqofono-0.53/plugin/plugin.pro libqofono-0.70~rtm/plugin/plugin.pro --- libqofono-0.53/plugin/plugin.pro 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/plugin/plugin.pro 2015-01-09 08:20:12.000000000 +0000 @@ -13,15 +13,17 @@ equals(QT_MAJOR_VERSION, 5): { QT += qml -QT-=gui + QT -= gui LIBS += -L../src -lqofono-qt5 } SOURCES = \ - qofonodeclarativeplugin.cpp + qofonodeclarativeplugin.cpp \ + qofononetworkoperatorlistmodel.cpp HEADERS = \ - qofonodeclarativeplugin.h + qofonodeclarativeplugin.h \ + qofononetworkoperatorlistmodel.h INCLUDEPATH += ../src diff -Nru libqofono-0.53/plugin/qofonodeclarativeplugin.cpp libqofono-0.70~rtm/plugin/qofonodeclarativeplugin.cpp --- libqofono-0.53/plugin/qofonodeclarativeplugin.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/plugin/qofonodeclarativeplugin.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -60,55 +60,62 @@ #include "qofonopositioningrequestagent.h" #include "qofonolocationreporting.h" +#include "qofononetworkoperatorlistmodel.h" -void QOfonoDeclarativePlugin::registerTypes(const char *uri) +void QOfonoDeclarativePlugin::registerTypes(const char *uri, int major, int minor) { Q_ASSERT(QLatin1String(uri) == QLatin1String("MeeGo.QOfono")); - qmlRegisterType(uri,0,2,"OfonoManager"); - qmlRegisterType(uri,0,2,"OfonoModem"); + qmlRegisterType(uri,major,minor,"OfonoManager"); + qmlRegisterType(uri,major,minor,"OfonoModem"); + + qmlRegisterType(uri,major,minor,"OfonoConnMan"); + qmlRegisterType(uri,major,minor,"OfonoContextConnection"); - qmlRegisterType(uri,0,2,"OfonoConnMan"); - qmlRegisterType(uri,0,2,"OfonoContextConnection"); + qmlRegisterType(uri,major,minor,"OfonoNetworkRegistration"); + qmlRegisterType(uri,major,minor,"OfonoNetworkOperator"); - qmlRegisterType(uri,0,2,"OfonoNetworkRegistration"); - qmlRegisterType(uri,0,2,"OfonoNetworkOperator"); + qmlRegisterType(uri,major,minor,"OfonoCellBroadcast"); - qmlRegisterType(uri,0,2,"OfonoCellBroadcast"); + qmlRegisterType(uri,major,minor,"OfonoCallBarring"); + qmlRegisterType(uri,major,minor,"OfonoCallForwarding"); - qmlRegisterType(uri,0,2,"OfonoCallBarring"); - qmlRegisterType(uri,0,2,"OfonoCallForwarding"); + qmlRegisterType(uri,major,minor,"OfonoCallSettings"); + qmlRegisterType(uri,major,minor,"OfonoCallMeter"); - qmlRegisterType(uri,0,2,"OfonoCallSettings"); - qmlRegisterType(uri,0,2,"OfonoCallMeter"); + qmlRegisterType(uri,major,minor,"OfonoMessage"); + qmlRegisterType(uri,major,minor,"OfonoMessageManager"); + qmlRegisterType(uri,major,minor,"OfonoMessageWaiting"); - qmlRegisterType(uri,0,2,"OfonoMessage"); - qmlRegisterType(uri,0,2,"OfonoMessageManager"); - qmlRegisterType(uri,0,2,"OfonoMessageWaiting"); + qmlRegisterType(uri,major,minor,"OfonoSimManager"); - qmlRegisterType(uri,0,2,"OfonoSimManager"); + qmlRegisterType(uri,major,minor,"OfonoSmartMessaging"); + qmlRegisterType(uri,major,minor,"OfonoSmartMessagingAgent"); - qmlRegisterType(uri,0,2,"OfonoSmartMessaging"); - qmlRegisterType(uri,0,2,"OfonoSmartMessagingAgent"); + qmlRegisterType(uri,major,minor,"OfonoVoiceCall"); + qmlRegisterType(uri,major,minor,"OfonoVoiceCallManager"); - qmlRegisterType(uri,0,2,"OfonoVoiceCall"); - qmlRegisterType(uri,0,2,"OfonoVoiceCallManager"); + qmlRegisterType(uri,major,minor,"OfonoRadioSettings"); + qmlRegisterType(uri,major,minor,"OfonoSupplementaryServices"); - qmlRegisterType(uri,0,2,"OfonoRadioSettings"); - qmlRegisterType(uri,0,2,"OfonoSupplementaryServices"); + qmlRegisterType(uri,major,minor,"OfonoPhonebook"); + qmlRegisterType(uri,major,minor,"OfonoTextTelephony"); - qmlRegisterType(uri,0,2,"OfonoPhonebook"); - qmlRegisterType(uri,0,2,"OfonoTextTelephony"); + qmlRegisterType(uri,major,minor,"OfonoHandsfree"); + qmlRegisterType(uri,major,minor,"OfonoHandsfreeAudioAgent"); + qmlRegisterType(uri,major,minor,"OfonoHandsfreeAudioCard"); + qmlRegisterType(uri,major,minor,"OfonoHandsfreeAudioManager"); - qmlRegisterType(uri,0,2,"OfonoHandsfree"); - qmlRegisterType(uri,0,2,"OfonoHandsfreeAudioAgent"); - qmlRegisterType(uri,0,2,"OfonoHandsfreeAudioCard"); - qmlRegisterType(uri,0,2,"OfonoHandsfreeAudioManager"); + qmlRegisterType(uri,major,minor,"OfonoAssistedSatelliteNavigation"); + qmlRegisterType(uri,major,minor,"OfonoPositioningRequestAgent"); + qmlRegisterType(uri,major,minor,"OfonoLocationReporting"); - qmlRegisterType(uri,0,2,"OfonoAssistedSatelliteNavigation"); - qmlRegisterType(uri,0,2,"OfonoPositioningRequestAgent"); - qmlRegisterType(uri,0,2,"OfonoLocationReporting"); + qmlRegisterType(uri,major,minor,"OfonoNetworkOperatorListModel"); +} +void QOfonoDeclarativePlugin::registerTypes(const char *uri) +{ + registerTypes(uri, 0, 2); } #if QT_VERSION < 0x050000 diff -Nru libqofono-0.53/plugin/qofonodeclarativeplugin.h libqofono-0.70~rtm/plugin/qofonodeclarativeplugin.h --- libqofono-0.53/plugin/qofonodeclarativeplugin.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/plugin/qofonodeclarativeplugin.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -34,6 +34,7 @@ #endif public: void registerTypes(const char *uri); + static void registerTypes(const char *uri, int major, int minor); #if QT_VERSION < 0x050000 void initializeEngine(QDeclarativeEngine *engine, const char *uri); #endif diff -Nru libqofono-0.53/plugin/qofononetworkoperatorlistmodel.cpp libqofono-0.70~rtm/plugin/qofononetworkoperatorlistmodel.cpp --- libqofono-0.53/plugin/qofononetworkoperatorlistmodel.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/plugin/qofononetworkoperatorlistmodel.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,165 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#include "qofononetworkoperatorlistmodel.h" + +QOfonoNetworkOperatorListModel::QOfonoNetworkOperatorListModel(QObject *parent) : + QAbstractListModel(parent) +{ + netreg = new QOfonoNetworkRegistration(this); + onNetworkOperatorsChanged(netreg->networkOperators()); + connect(netreg, + SIGNAL(validChanged(bool)), + SIGNAL(validChanged(bool))); + connect(netreg, + SIGNAL(modemPathChanged(QString)), + SIGNAL(modemPathChanged(QString))); + connect(netreg, + SIGNAL(networkOperatorsChanged(QStringList)), + SLOT(onNetworkOperatorsChanged(QStringList))); +} + +QString QOfonoNetworkOperatorListModel::modemPath() const +{ + return netreg->modemPath(); +} + +void QOfonoNetworkOperatorListModel::setModemPath(const QString &path) +{ + netreg->setModemPath(path); +} + +bool QOfonoNetworkOperatorListModel::isValid() const +{ + return netreg->isValid(); +} + +int QOfonoNetworkOperatorListModel::rowCount(const QModelIndex &) const +{ + return operators.count(); +} + +int QOfonoNetworkOperatorListModel::count() const +{ + return operators.count(); +} + +QVariant QOfonoNetworkOperatorListModel::data(const QModelIndex &index, int role) const +{ + int row = index.row(); + if (row >= 0 && row < operators.count()) { + QOfonoNetworkOperator* op = netreg->networkOperator(operators[row]); + if (op) { + switch (role) { + case PathRole: return op->operatorPath(); + case NameRole: return op->name(); + case StatusRole: return op->status(); + case MccRole: return op->mcc(); + case MncRole: return op->mnc(); + case TechRole: return op->technologies(); + case InfoRole: return op->additionalInfo(); + } + } + } + qWarning() << index << role; + return QVariant(); +} + +QHash QOfonoNetworkOperatorListModel::roleNames() const +{ + QHash roles; + roles[PathRole] = "operatorPath"; + roles[NameRole] = "name"; + roles[StatusRole] = "status"; + roles[MccRole] = "mcc"; + roles[MncRole] = "mnc"; + roles[TechRole] = "technologies"; + roles[InfoRole] = "additionalInfo"; + return roles; +} + +void QOfonoNetworkOperatorListModel::operatorPropertyChanged(OperatorRole role) +{ + QOfonoNetworkOperator* op = (QOfonoNetworkOperator*)sender(); + if (op) { + int row = operators.indexOf(op->operatorPath()); + if (row >= 0) { + QModelIndex modelIndex = index(row); + QVector roles; + roles.append(role); + Q_EMIT dataChanged(modelIndex, modelIndex, roles); + } + } +} + +void QOfonoNetworkOperatorListModel::onNetworkOperatorsChanged(const QStringList &list) +{ + beginResetModel(); + const int oldCount = operators.count(); + const int n = list.count(); + operators = list; + for (int i=0; inetworkOperator(list[i]); + if (op) { + op->disconnect(this); + connect(op, SIGNAL(operatorPathChanged(QString)), SLOT(onOperatorPathChanged(QString))); + connect(op, SIGNAL(nameChanged(QString)), SLOT(onOperatorNameChanged(QString))); + connect(op, SIGNAL(statusChanged(QString)), SLOT(onOperatorStatusChanged(QString))); + connect(op, SIGNAL(mccChanged(QString)), SLOT(onOperatorMccChanged(QString))); + connect(op, SIGNAL(mncChanged(QString)), SLOT(onOperatorMncChanged(QString))); + connect(op, SIGNAL(technologiesChanged(QStringList)), SLOT(onOperatorTechChanged(QStringList))); + connect(op, SIGNAL(additionalInfoChanged(QString)), SLOT(onOperatorInfoChanged(QString))); + } + } + if (oldCount != n) { + Q_EMIT countChanged(n); + } + endResetModel(); +} + +void QOfonoNetworkOperatorListModel::onOperatorPathChanged(const QString &) +{ + operatorPropertyChanged(PathRole); +} + +void QOfonoNetworkOperatorListModel::onOperatorNameChanged(const QString &) +{ + operatorPropertyChanged(NameRole); +} + +void QOfonoNetworkOperatorListModel::onOperatorStatusChanged(const QString &) +{ + operatorPropertyChanged(StatusRole); +} + +void QOfonoNetworkOperatorListModel::onOperatorMccChanged(const QString &) +{ + operatorPropertyChanged(MccRole); +} + +void QOfonoNetworkOperatorListModel::onOperatorMncChanged(const QString &) +{ + operatorPropertyChanged(MncRole); +} + +void QOfonoNetworkOperatorListModel::onOperatorTechChanged(const QStringList &) +{ + operatorPropertyChanged(TechRole); +} + +void QOfonoNetworkOperatorListModel::onOperatorInfoChanged(const QString &) +{ + operatorPropertyChanged(InfoRole); +} diff -Nru libqofono-0.53/plugin/qofononetworkoperatorlistmodel.h libqofono-0.70~rtm/plugin/qofononetworkoperatorlistmodel.h --- libqofono-0.53/plugin/qofononetworkoperatorlistmodel.h 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/plugin/qofononetworkoperatorlistmodel.h 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#ifndef QOFONONETWORKOPERATORLISTMODEL_H +#define QOFONONETWORKOPERATORLISTMODEL_H + +#include "qofononetworkregistration.h" + +class QOfonoNetworkOperatorListModel : public QAbstractListModel { + Q_OBJECT + Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) + Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) + Q_PROPERTY(int count READ count NOTIFY countChanged) + +public: + enum OperatorRole { + PathRole = Qt::UserRole + 1, + NameRole, + StatusRole, + MccRole, + MncRole, + TechRole, + InfoRole + }; + + explicit QOfonoNetworkOperatorListModel(QObject* parent = NULL); + + QString modemPath() const; + void setModemPath(const QString &path); + bool isValid() const; + int count() const; + + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + +protected: + QHash roleNames() const; + +Q_SIGNALS: + void modemPathChanged(const QString &value); + void validChanged(bool value); + void countChanged(int value); + +private Q_SLOTS: + void onNetworkOperatorsChanged(const QStringList &list); + void onOperatorNameChanged(const QString &value); + void onOperatorStatusChanged(const QString &value); + void onOperatorMccChanged(const QString &value); + void onOperatorMncChanged(const QString &value); + void onOperatorTechChanged(const QStringList &value); + void onOperatorInfoChanged(const QString &value); + void onOperatorPathChanged(const QString &value); + +private: + void operatorPropertyChanged(OperatorRole role); + +private: + QOfonoNetworkRegistration *netreg; + QStringList operators; +}; + +#endif // QOFONONETWORKOPERATORLISTMODEL_H diff -Nru libqofono-0.53/rpm/libqofono-qt5.spec libqofono-0.70~rtm/rpm/libqofono-qt5.spec --- libqofono-0.53/rpm/libqofono-qt5.spec 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/rpm/libqofono-qt5.spec 2015-01-09 08:20:12.000000000 +0000 @@ -1,21 +1,12 @@ -# -# Do NOT Edit the Auto-generated Part! -# Generated by: spectacle version 0.27 -# - Name: libqofono-qt5 -# >> macros -# << macros - Summary: A library of Qt 5 bindings for ofono -Version: 0.53 +Version: 0.70 Release: 1 Group: System/Libraries License: LGPLv2.1 URL: https://github.com/nemomobile/libqofono Source0: %{name}-%{version}.tar.bz2 -Source100: libqofono-qt5.yaml Requires: qt5-qtcore Requires: mobile-broadband-provider-info Requires(post): /sbin/ldconfig @@ -30,7 +21,6 @@ This package contains Qt bindings for ofono cellular service interfaces. - %package declarative Summary: Declarative plugin for libqofono Group: Development/Tools @@ -54,6 +44,8 @@ Group: Development/Tools Requires: %{name} = %{version}-%{release} Requires: blts-tools +Requires: phonesim +Requires: mce-tools %description tests This package contains qml test for ofono Qt bindings. @@ -61,31 +53,16 @@ %prep %setup -q -n %{name}-%{version} -# >> setup -# << setup - %build -# >> build pre export QT_SELECT=5 -# << build pre - %qmake5 - make %{?jobs:-j%jobs} -# >> build post -# << build post - %install rm -rf %{buildroot} -# >> install pre export QT_SELECT=5 -# << install pre %qmake5_install -# >> install post -# << install post - %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -93,14 +70,10 @@ %files %defattr(-,root,root,-) %{_libdir}/%{name}.so.* -# >> files -# << files %files declarative %defattr(-,root,root,-) %{_libdir}/qt5/qml/MeeGo/QOfono/* -# >> files declarative -# << files declarative %files devel %defattr(-,root,root,-) @@ -111,12 +84,8 @@ %{_includedir}/qofono-qt5/dbus/ofono*.h %{_includedir}/qofono-qt5/dbus/ofono*.xml %{_datadir}/qt5/mkspecs/features/qofono-qt5.prf -# >> files devel -# << files devel %files tests %defattr(-,root,root,-) %{_libdir}/%{name}/tests/* /opt/tests/%{name}/* -# >> files tests -# << files tests diff -Nru libqofono-0.53/rpm/libqofono-qt5.yaml libqofono-0.70~rtm/rpm/libqofono-qt5.yaml --- libqofono-0.53/rpm/libqofono-qt5.yaml 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/rpm/libqofono-qt5.yaml 1970-01-01 00:00:00.000000000 +0000 @@ -1,67 +0,0 @@ -Name: libqofono-qt5 -Summary: A library of Qt 5 bindings for ofono -Version: 0.53 -Release: 1 -Group: System/Libraries -License: LGPLv2.1 -URL: https://github.com/nemomobile/libqofono - -Sources: - - "%{name}-%{version}.tar.bz2" - -Requires: - - qt5-qtcore - - mobile-broadband-provider-info - -Description: | - This package contains Qt bindings for ofono cellular service - interfaces. - -PkgConfigBR: - - Qt5Core - - Qt5DBus - - Qt5Quick - - Qt5Test - - Qt5XmlPatterns - -Configure: none -Builder: qmake5 -SetupOptions: "-q -n %{name}-%{version}" -Files: - - "%{_libdir}/%{name}.so.*" - -SubPackages: - - Name: declarative - Summary: Declarative plugin for libqofono - Group: Development/Tools - Description: This package contains declarative plugin for libofono. - Requires: - - "%{name} = %{version}" - - mobile-broadband-provider-info - Files: - - "%{_libdir}/qt5/qml/MeeGo/QOfono/*" - - - Name: devel - Summary: Development files for ofono Qt bindings - Group: Development/Libraries - Description: This package contains the development header files for the ofono Qt bindings. - Requires: - - "%{name} = %{version}" - Files: - - "%{_libdir}/%{name}.prl" - - "%{_libdir}/%{name}.so" - - "%{_libdir}/pkgconfig/qofono-qt5.pc" - - "%{_includedir}/qofono-qt5/*.h" - - "%{_includedir}/qofono-qt5/dbus/ofono*.h" - - "%{_includedir}/qofono-qt5/dbus/ofono*.xml" - - "%{_datadir}/qt5/mkspecs/features/qofono-qt5.prf" - - - Name: tests - Summary: qml test app for the ofono Qt bindings - Group: Development/Tools - Description: This package contains qml test for ofono Qt bindings. - Requires: - - blts-tools - Files: - - "%{_libdir}/%{name}/tests/*" - - "/opt/tests/%{name}/*" diff -Nru libqofono-0.53/rpm/libqofono.spec libqofono-0.70~rtm/rpm/libqofono.spec --- libqofono-0.53/rpm/libqofono.spec 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/rpm/libqofono.spec 2015-01-09 08:20:12.000000000 +0000 @@ -1,21 +1,12 @@ -# -# Do NOT Edit the Auto-generated Part! -# Generated by: spectacle version 0.26 -# - Name: libqofono -# >> macros -# << macros - Summary: A library of Qt bindings for ofono -Version: 0.53 +Version: 0.59 Release: 1 Group: System/Libraries License: LGPLv2.1 URL: https://github.com/nemomobile/libqofono Source0: libqofono-%{version}.tar.bz2 -Source100: libqofono.yaml Requires: mobile-broadband-provider-info Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -27,7 +18,6 @@ This package contains Qt bindings for ofono cellular service interfaces. - %package declarative Summary: Declarative plugin for libqofono Group: Development/Tools @@ -57,29 +47,14 @@ %prep %setup -q -n libqofono-%{version} -# >> setup -# << setup - %build -# >> build pre -# << build pre - %qmake - make %{?jobs:-j%jobs} -# >> build post -# << build post - %install rm -rf %{buildroot} -# >> install pre -# << install pre %qmake_install -# >> install post -# << install post - %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -87,14 +62,10 @@ %files %defattr(-,root,root,-) %{_libdir}/%{name}.so.* -# >> files -# << files %files declarative %defattr(-,root,root,-) %{_libdir}/qt4/imports/MeeGo/QOfono/* -# >> files declarative -# << files declarative %files devel %defattr(-,root,root,-) @@ -105,13 +76,9 @@ %{_includedir}/qofono/dbus/ofono*.h %{_includedir}/qofono/dbus/ofono*.xml %{_datadir}/qt4/mkspecs/features/qofono.prf -# >> files devel -# << files devel %files tests %defattr(-,root,root,-) /opt/ofonotest/bin/ofonotest /opt/ofonotest/qml/ofonotest/*.qml %{_libdir}/%{name}/tests/* -# >> files tests -# << files tests diff -Nru libqofono-0.53/rpm/libqofono.yaml libqofono-0.70~rtm/rpm/libqofono.yaml --- libqofono-0.53/rpm/libqofono.yaml 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/rpm/libqofono.yaml 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -Name: libqofono -Summary: A library of Qt bindings for ofono -Version: 0.53 -Release: 1 -Group: System/Libraries -License: LGPLv2.1 -URL: https://github.com/nemomobile/libqofono -Sources: - - "libqofono-%{version}.tar.bz2" -Description: | - This package contains Qt bindings for ofono cellular service - interfaces. -PkgConfigBR: - - QtCore - - QtDBus - - QtXmlPatterns -Configure: none -Builder: qmake - -SetupOptions: "-q -n libqofono-%{version}" -Files: - - "%{_libdir}/%{name}.so.*" - -SubPackages: - - Name: declarative - Summary: Declarative plugin for libqofono - Group: Development/Tools - Description: This package contains declarative plugin for libofono. - Requires: - - "%{name} = %{version}" - - mobile-broadband-provider-info - - Files: - - "%{_libdir}/qt4/imports/MeeGo/QOfono/*" - - - Name: devel - Summary: Development files for ofono Qt bindings - Group: Development/Libraries - Description: This package contains the development header files for the ofono Qt bindings. - Requires: - - "%{name} = %{version}" - Files: - - "%{_libdir}/%{name}.prl" - - "%{_libdir}/%{name}.so" - - "%{_libdir}/pkgconfig/qofono.pc" - - "%{_includedir}/qofono/*.h" - - "%{_includedir}/qofono/dbus/ofono*.h" - - "%{_includedir}/qofono/dbus/ofono*.xml" - - "%{_datadir}/qt4/mkspecs/features/qofono.prf" - - - Name: tests - Summary: qml test app for the ofono Qt bindings - Group: Development/Tools - Description: This package contains qml test for ofono Qt bindings. - Files: - - "/opt/ofonotest/bin/ofonotest" - - "/opt/ofonotest/qml/ofonotest/*.qml" - - "%{_libdir}/%{name}/tests/*" diff -Nru libqofono-0.53/src/dbus/ofononetworkregistration.cpp libqofono-0.70~rtm/src/dbus/ofononetworkregistration.cpp --- libqofono-0.53/src/dbus/ofononetworkregistration.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/dbus/ofononetworkregistration.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,8 +1,8 @@ /* - * This file was generated by qdbusxml2cpp version 0.7 + * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -c OfonoNetworkRegistration -p ofononetworkregistration -N ofono_network_registration.xml * - * qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). + * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * * This is an auto-generated file. * This file may have been hand-edited. Look for HAND-EDIT comments diff -Nru libqofono-0.53/src/dbus/ofononetworkregistration.h libqofono-0.70~rtm/src/dbus/ofononetworkregistration.h --- libqofono-0.53/src/dbus/ofononetworkregistration.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/dbus/ofononetworkregistration.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,15 +1,15 @@ /* - * This file was generated by qdbusxml2cpp version 0.7 + * This file was generated by qdbusxml2cpp version 0.8 * Command line was: qdbusxml2cpp -c OfonoNetworkRegistration -p ofononetworkregistration -N ofono_network_registration.xml * - * qdbusxml2cpp is Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). + * qdbusxml2cpp is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). * * This is an auto-generated file. * Do not edit! All changes made to it will be lost. */ -#ifndef OFONONETWORKREGISTRATION_H_1357881754 -#define OFONONETWORKREGISTRATION_H_1357881754 +#ifndef OFONONETWORKREGISTRATION_H_1418934619 +#define OFONONETWORKREGISTRATION_H_1418934619 #include #include @@ -68,6 +68,7 @@ } Q_SIGNALS: // SIGNALS + void OperatorsChanged(ObjectPathPropertiesList in0); void PropertyChanged(const QString &in0, const QDBusVariant &in1); }; diff -Nru libqofono-0.53/src/dbus/ofono_network_registration.xml libqofono-0.70~rtm/src/dbus/ofono_network_registration.xml --- libqofono-0.53/src/dbus/ofono_network_registration.xml 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/dbus/ofono_network_registration.xml 2015-01-09 08:20:12.000000000 +0000 @@ -10,16 +10,19 @@ - + - + + + + + - diff -Nru libqofono-0.53/src/dbustypes.h libqofono-0.70~rtm/src/dbustypes.h --- libqofono-0.53/src/dbustypes.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/dbustypes.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -15,6 +15,7 @@ #ifndef DBUSTYPES_H #define DBUSTYPES_H + #include #include @@ -23,8 +24,25 @@ QDBusObjectPath path; QVariantMap properties; }; + +typedef QList ObjectPathList; typedef QList ObjectPathPropertiesList; Q_DECLARE_METATYPE(ObjectPathProperties) Q_DECLARE_METATYPE(ObjectPathPropertiesList) +QDBusArgument &operator<<(QDBusArgument &, const ObjectPathProperties &); +const QDBusArgument &operator>>(const QDBusArgument &, ObjectPathProperties &); + +namespace QOfonoDbusTypes { + void registerObjectPathProperties(); +} + +// Deprecated, left in for ABI compatibility +struct OfonoPathProps { QDBusObjectPath path; QVariantMap properties; }; +typedef QList QArrayOfPathProps; +Q_DECLARE_METATYPE(OfonoPathProps) +Q_DECLARE_METATYPE (QArrayOfPathProps) +QDBusArgument &operator<<(QDBusArgument &, const OfonoPathProps &); +const QDBusArgument &operator>>(const QDBusArgument &, OfonoPathProps &); + #endif // DBUSTYPES_H diff -Nru libqofono-0.53/src/qofonocallbarring.cpp libqofono-0.70~rtm/src/qofonocallbarring.cpp --- libqofono-0.53/src/qofonocallbarring.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallbarring.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -15,195 +15,120 @@ #include "qofonocallbarring.h" #include "dbus/ofonocallbarring.h" -#include "qofonomodem.h" -class QOfonoCallBarringPrivate -{ -public: - QOfonoCallBarringPrivate(); - QString modemPath; - OfonoCallBarring *callBarring; - QVariantMap properties; - bool propertiesPending; - QSharedPointer modem; -}; - -QOfonoCallBarringPrivate::QOfonoCallBarringPrivate() : - modemPath(QString()) - , callBarring(0) - , propertiesPending(false) -{ -} +#define SUPER QOfonoModemInterface QOfonoCallBarring::QOfonoCallBarring(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoCallBarringPrivate) + SUPER(OfonoCallBarring::staticInterfaceName(), parent) { } QOfonoCallBarring::~QOfonoCallBarring() { - delete d_ptr; -} - -void QOfonoCallBarring::setModemPath(const QString &path) -{ - if (path == d_ptr->modemPath || path.isEmpty()) - return; - - if (!d_ptr->modem.isNull()) - disconnect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - - d_ptr->modemPath = path; - connectOfono(); - - d_ptr->modem = QOfonoModem::instance(path); - connect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - - Q_EMIT modemPathChanged(path); } -void QOfonoCallBarring::modemInterfacesChanged(const QStringList &interfaces) +QDBusAbstractInterface *QOfonoCallBarring::createDbusInterface(const QString &path) { - bool haveIface = interfaces.contains("org.ofono.CallBarring"); - if (haveIface != (isValid() && (isReady() || d_ptr->propertiesPending))) - connectOfono(); + return new OfonoCallBarring("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoCallBarring::connectOfono() { - if (d_ptr->callBarring) { - bool wasReady = isReady(); - delete d_ptr->callBarring; - d_ptr->callBarring = 0; - d_ptr->properties.clear(); - d_ptr->propertiesPending = false; - if (wasReady != isReady()) - Q_EMIT readyChanged(); - } - - d_ptr->callBarring = new OfonoCallBarring("org.ofono", d_ptr->modemPath, QDBusConnection::systemBus(),this); - - if (d_ptr->callBarring->isValid()) { - connect(d_ptr->callBarring,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - d_ptr->propertiesPending = true; - QDBusPendingReply reply = d_ptr->callBarring->GetProperties(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(getPropertiesComplete(QDBusPendingCallWatcher*))); - } -} - -QString QOfonoCallBarring::modemPath() const -{ - return d_ptr->modemPath; + resetDbusInterface(); } - -void QOfonoCallBarring::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +void QOfonoCallBarring::propertyChanged(const QString &property, const QVariant &value) { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("VoiceIncoming")) { - Q_EMIT voiceIncomingChanged(value.value()); + Q_EMIT voiceIncomingChanged(value.toString()); } else if (property == QLatin1String("VoiceOutgoing")) { - Q_EMIT voiceOutgoingChanged(value.value()); + Q_EMIT voiceOutgoingChanged(value.toString()); } } QString QOfonoCallBarring::voiceIncoming() { - if (d_ptr->callBarring) - return d_ptr->properties.value("VoiceIncoming").value(); - else - return QString(); + return getString("VoiceIncoming"); } void QOfonoCallBarring::setVoiceIncoming(const QString &barrings, const QString &password) { - if (d_ptr->callBarring) { - QDBusPendingReply<> reply = d_ptr->callBarring->SetProperty("VoiceIncoming",QDBusVariant(barrings), password); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoiceIncomingComplete(QDBusPendingCallWatcher*))); + OfonoCallBarring *iface = (OfonoCallBarring*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->SetProperty("VoiceIncoming", QDBusVariant(barrings), password), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(setVoiceIncomingComplete(QDBusPendingCallWatcher*))); } } QString QOfonoCallBarring::voiceOutgoing() { - if (d_ptr->callBarring) - return d_ptr->properties.value("VoiceOutgoing").value(); - else - return QString(); + return getString("VoiceOutgoing"); } void QOfonoCallBarring::setVoiceOutgoing(const QString &barrings, const QString &password) { - - if (d_ptr->callBarring) { - QDBusPendingReply<> reply = d_ptr->callBarring->SetProperty("VoiceOutgoing",QDBusVariant(barrings),password); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoiceOutgoingComplete(QDBusPendingCallWatcher*))); + OfonoCallBarring *iface = (OfonoCallBarring*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->SetProperty("VoiceOutgoing", QDBusVariant(barrings), password), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(setVoiceOutgoingComplete(QDBusPendingCallWatcher*))); } } void QOfonoCallBarring::changePassword(const QString &oldPassword, const QString &newPassword) { - - if (d_ptr->callBarring) { - QDBusPendingReply<> reply = d_ptr->callBarring->ChangePassword(oldPassword, newPassword); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(changePasswordCallComplete(QDBusPendingCallWatcher*))); + OfonoCallBarring *iface = (OfonoCallBarring*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->ChangePassword(oldPassword, newPassword), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(changePasswordCallComplete(QDBusPendingCallWatcher*))); } } void QOfonoCallBarring::disableAll(const QString &password) { - if (d_ptr->callBarring) - d_ptr->callBarring->DisableAll(password); + OfonoCallBarring *iface = (OfonoCallBarring*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->DisableAll(password), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(disableAllCallComplete(QDBusPendingCallWatcher*))); + } } void QOfonoCallBarring::disableAllIncoming(const QString &password) { - if (d_ptr->callBarring) - d_ptr->callBarring->DisableAllIncoming(password); + OfonoCallBarring *iface = (OfonoCallBarring*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->DisableAllIncoming(password), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(disableAllIncomingCallComplete(QDBusPendingCallWatcher*))); + } } void QOfonoCallBarring::disableAllOutgoing(const QString &password) { - if (d_ptr->callBarring) - d_ptr->callBarring->DisableAllOutgoing(password); -} - -bool QOfonoCallBarring::isValid() const -{ - return d_ptr->callBarring->isValid(); -} - -bool QOfonoCallBarring::isReady() const -{ - return !d_ptr->properties.isEmpty(); + OfonoCallBarring *iface = (OfonoCallBarring*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->DisableAllOutgoing(password), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(disableAllOutgoingCallComplete(QDBusPendingCallWatcher*))); + } } -void QOfonoCallBarring::getPropertiesComplete(QDBusPendingCallWatcher *call) +void QOfonoCallBarring::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) { - call->deleteLater(); - QDBusPendingReply reply = *call; - if (!reply.isError()) { - d_ptr->properties = reply.value(); - Q_EMIT voiceIncomingChanged(voiceIncoming()); - Q_EMIT voiceOutgoingChanged(voiceOutgoing()); - Q_EMIT readyChanged(); - } else { + SUPER::getPropertiesFinished(properties, error); + if (error) { Q_EMIT getPropertiesFailed(); } - d_ptr->propertiesPending = false; } void QOfonoCallBarring::setVoiceIncomingComplete(QDBusPendingCallWatcher *call) @@ -226,3 +151,44 @@ QDBusPendingReply<> reply = *call; Q_EMIT changePasswordComplete(!reply.isError()); } + +void QOfonoCallBarring::disableAllCallComplete(QDBusPendingCallWatcher *call) +{ + call->deleteLater(); + QDBusPendingReply<> reply = *call; + Q_EMIT disableAllComplete(!reply.isError()); +} + +void QOfonoCallBarring::disableAllIncomingCallComplete(QDBusPendingCallWatcher *call) +{ + call->deleteLater(); + QDBusPendingReply<> reply = *call; + Q_EMIT disableAllIncomingComplete(!reply.isError()); +} + +void QOfonoCallBarring::disableAllOutgoingCallComplete(QDBusPendingCallWatcher *call) +{ + call->deleteLater(); + QDBusPendingReply<> reply = *call; + Q_EMIT disableAllOutgoingComplete(!reply.isError()); +} + +QString QOfonoCallBarring::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoCallBarring::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); +} + +bool QOfonoCallBarring::isValid() const +{ + return SUPER::isValid(); +} + +bool QOfonoCallBarring::isReady() const +{ + return SUPER::isReady(); +} diff -Nru libqofono-0.53/src/qofonocallbarring.h libqofono-0.70~rtm/src/qofonocallbarring.h --- libqofono-0.53/src/qofonocallbarring.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallbarring.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,25 +16,19 @@ #ifndef QOFONOCALLBARRING_H #define QOFONOCALLBARRING_H -#include -#include - +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono call barring API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/call-barring-api.txt */ - -class QOfonoCallBarringPrivate; -class QOFONOSHARED_EXPORT QOfonoCallBarring : public QObject +class QOFONOSHARED_EXPORT QOfonoCallBarring : public QOfonoModemInterface { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) - Q_PROPERTY(QString voiceIncoming READ voiceIncoming NOTIFY voiceIncomingChanged) Q_PROPERTY(QString voiceOutgoing READ voiceOutgoing NOTIFY voiceOutgoingChanged) - Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) public: explicit QOfonoCallBarring(QObject *parent = 0); @@ -43,46 +37,47 @@ QString modemPath() const; void setModemPath(const QString &path); - QString voiceIncoming(); - Q_INVOKABLE void setVoiceIncoming(const QString &barrings, const QString &password); + QString voiceIncoming(); + Q_INVOKABLE void setVoiceIncoming(const QString &barrings, const QString &password); - QString voiceOutgoing(); - Q_INVOKABLE void setVoiceOutgoing(const QString &barrings, const QString &password); + QString voiceOutgoing(); + Q_INVOKABLE void setVoiceOutgoing(const QString &barrings, const QString &password); - bool isValid() const; - bool isReady() const; + bool isValid() const; + bool isReady() const; - void connectOfono(); + void connectOfono(); Q_SIGNALS: - void voiceIncomingChanged(const QString &barrings); - void voiceOutgoingChanged(const QString &barrings); - void voiceIncomingComplete(bool success); - void voiceOutgoingComplete(bool success); - void modemPathChanged(const QString &path); - void getPropertiesFailed(); - void readyChanged(); - - void changePasswordComplete(bool success); -// void disableAllComplete(bool success); -// void disableAllIncomingComplete(bool success); -// void disableAllOutgoingComplete(bool success); + void voiceIncomingChanged(const QString &barrings); + void voiceOutgoingChanged(const QString &barrings); + void voiceIncomingComplete(bool success); + void voiceOutgoingComplete(bool success); + void getPropertiesFailed(); + + void changePasswordComplete(bool success); + void disableAllComplete(bool success); + void disableAllIncomingComplete(bool success); + void disableAllOutgoingComplete(bool success); public slots: - void changePassword(const QString &oldPassword, const QString &newPassword); - void disableAll(const QString &password); - void disableAllIncoming(const QString &password); - void disableAllOutgoing(const QString &password); + void changePassword(const QString &oldPassword, const QString &newPassword); + void disableAll(const QString &password); + void disableAllIncoming(const QString &password); + void disableAllOutgoing(const QString &password); -private: - QOfonoCallBarringPrivate *d_ptr; private slots: - void modemInterfacesChanged(const QStringList &interfaces); - void propertyChanged(const QString &property,const QDBusVariant &value); - void getPropertiesComplete(QDBusPendingCallWatcher *); void setVoiceIncomingComplete(QDBusPendingCallWatcher *); void setVoiceOutgoingComplete(QDBusPendingCallWatcher *); void changePasswordCallComplete(QDBusPendingCallWatcher *); + void disableAllCallComplete(QDBusPendingCallWatcher *); + void disableAllIncomingCallComplete(QDBusPendingCallWatcher *); + void disableAllOutgoingCallComplete(QDBusPendingCallWatcher *); + +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &property, const QVariant &value); + void getPropertiesFinished(const QVariantMap &properties, const QDBusError *error); }; #endif // QOFONOCALLBARRING_H diff -Nru libqofono-0.53/src/qofonocallforwarding.cpp libqofono-0.70~rtm/src/qofonocallforwarding.cpp --- libqofono-0.53/src/qofonocallforwarding.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallforwarding.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -15,279 +15,149 @@ #include "qofonocallforwarding.h" #include "dbus/ofonocallforwarding.h" -#include "qofonomodem.h" -class QOfonoCallForwardingPrivate -{ -public: - QOfonoCallForwardingPrivate(); - QString modemPath; - OfonoCallForwarding *callForward; - QVariantMap properties; - bool propertiesPending; - QSharedPointer modem; -}; - -QOfonoCallForwardingPrivate::QOfonoCallForwardingPrivate() : - modemPath(QString()) - , callForward(0) - , propertiesPending(false) -{ -} +#define SUPER QOfonoModemInterface QOfonoCallForwarding::QOfonoCallForwarding(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoCallForwardingPrivate) + SUPER(OfonoCallForwarding::staticInterfaceName(), parent) { } QOfonoCallForwarding::~QOfonoCallForwarding() { - delete d_ptr; } -void QOfonoCallForwarding::setModemPath(const QString &path) +QDBusAbstractInterface *QOfonoCallForwarding::createDbusInterface(const QString &path) { - if (path == d_ptr->modemPath || path.isEmpty()) - return; - - if (!d_ptr->modem.isNull()) - disconnect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - - d_ptr->modemPath = path; - connectOfono(); - - d_ptr->modem = QOfonoModem::instance(path); - connect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - - Q_EMIT modemPathChanged(path); -} - -QString QOfonoCallForwarding::modemPath() const -{ - return d_ptr->modemPath; -} - -void QOfonoCallForwarding::modemInterfacesChanged(const QStringList &interfaces) -{ - bool haveIface = interfaces.contains("org.ofono.CallForwarding"); - if (haveIface != (isValid() && (isReady() || d_ptr->propertiesPending))) - connectOfono(); + return new OfonoCallForwarding("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoCallForwarding::connectOfono() { - if (d_ptr->callForward) { - bool wasReady = isReady(); - delete d_ptr->callForward; - d_ptr->callForward = 0; - d_ptr->properties.clear(); - d_ptr->propertiesPending = false; - if (wasReady != isReady()) - Q_EMIT readyChanged(); - } - d_ptr->callForward = new OfonoCallForwarding("org.ofono", d_ptr->modemPath, QDBusConnection::systemBus(),this); - - if (d_ptr->callForward->isValid()) { - connect(d_ptr->callForward,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - d_ptr->propertiesPending = true; - QDBusPendingReply reply = d_ptr->callForward->GetProperties(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(getPropertiesComplete(QDBusPendingCallWatcher*))); - } + resetDbusInterface(); } -void QOfonoCallForwarding::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +void QOfonoCallForwarding::propertyChanged(const QString &property, const QVariant &value) { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("VoiceUnconditional")) { - Q_EMIT voiceUnconditionalChanged(value.value()); + Q_EMIT voiceUnconditionalChanged(value.toString()); } else if (property == QLatin1String("VoiceBusy")) { - Q_EMIT voiceBusyChanged(value.value()); + Q_EMIT voiceBusyChanged(value.toString()); } else if (property == QLatin1String("VoiceNoReply")) { - Q_EMIT voiceNoReplyChanged(value.value()); + Q_EMIT voiceNoReplyChanged(value.toString()); } else if (property == QLatin1String("VoiceNoReplyTimeout")) { Q_EMIT voiceNoReplyTimeoutChanged(value.value()); } else if (property == QLatin1String("VoiceNotReachable")) { - Q_EMIT voiceNotReachableChanged(value.value()); + Q_EMIT voiceNotReachableChanged(value.toString()); } else if (property == QLatin1String("ForwardingFlagOnSim")) { - Q_EMIT forwardingFlagOnSimChanged(value.value()); + Q_EMIT forwardingFlagOnSimChanged(value.toBool()); } } QString QOfonoCallForwarding::voiceUnconditional() { - if (d_ptr->callForward) - return d_ptr->properties.value("VoiceUnconditional").value(); - else - return QString(); + return getString("VoiceUnconditional"); } void QOfonoCallForwarding::setVoiceUnconditional(const QString &property) { - if (d_ptr->callForward) { - QDBusPendingReply<> reply = d_ptr->callForward->SetProperty("VoiceUnconditional",QDBusVariant(property)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoiceUnconditionalComplete(QDBusPendingCallWatcher*))); - } + setProperty("VoiceUnconditional", property); } QString QOfonoCallForwarding::voiceBusy() { - if (d_ptr->callForward) - return d_ptr->properties.value("VoiceBusy").value(); - else - return QString(); + return getString("VoiceBusy"); } void QOfonoCallForwarding::setVoiceBusy(const QString &property) { - if (d_ptr->callForward) { - QDBusPendingReply<> reply = d_ptr->callForward->SetProperty("VoiceBusy",QDBusVariant(property)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoiceBusyComplete(QDBusPendingCallWatcher*))); - } + setProperty("VoiceBusy", property); } QString QOfonoCallForwarding::voiceNoReply() { - if (d_ptr->callForward) - return d_ptr->properties.value("VoiceNoReply").value(); - else - return QString(); + return getString("VoiceNoReply"); } void QOfonoCallForwarding::setVoiceNoReply(const QString &property) { - if (d_ptr->callForward) { - QDBusPendingReply<> reply = d_ptr->callForward->SetProperty("VoiceNoReply",QDBusVariant(property)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoiceNoReplyComplete(QDBusPendingCallWatcher*))); - } + setProperty("VoiceNoReply", property); } quint16 QOfonoCallForwarding::voiceNoReplyTimeout() { - if (d_ptr->callForward) - return d_ptr->properties.value("VoiceNoReplyTimeout").value(); - else - return 0; + return getProperty("VoiceNoReplyTimeout").value(); } void QOfonoCallForwarding::setVoiceNoReplyTimeout(ushort timeout) { - if (d_ptr->callForward) { - QDBusPendingReply<> reply = d_ptr->callForward->SetProperty("VoiceNoReplyTimeout",QDBusVariant(QVariant::fromValue((quint16)timeout))); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoiceNoReplyTimeoutComplete(QDBusPendingCallWatcher*))); - } + setProperty("VoiceNoReplyTimeout", QVariant::fromValue((quint16)timeout)); } - QString QOfonoCallForwarding::voiceNotReachable() { - if (d_ptr->callForward) - return d_ptr->properties.value("VoiceNotReachable").value(); - else - return QString(); + return getString("VoiceNotReachable"); } void QOfonoCallForwarding::setVoiceNotReachable(const QString &property) { - if (d_ptr->callForward) { - QDBusPendingReply<> reply = d_ptr->callForward->SetProperty("VoiceNotReachable",QDBusVariant(property)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoiceNotReachableComplete(QDBusPendingCallWatcher*))); - } + setProperty("VoiceNotReachable", property); } - bool QOfonoCallForwarding::forwardingFlagOnSim() { - if (d_ptr->callForward) - return d_ptr->properties.value("ForwardingFlagOnSim").value(); - else - return false; + return getBool("ForwardingFlagOnSim"); } - void QOfonoCallForwarding::disableAll(const QString &type) { - if (d_ptr->callForward) - d_ptr->callForward->DisableAll(type); -} - -bool QOfonoCallForwarding::isValid() const -{ - return d_ptr->callForward->isValid(); -} - -bool QOfonoCallForwarding::isReady() const -{ - return !d_ptr->properties.isEmpty(); + OfonoCallForwarding *iface = (OfonoCallForwarding*)dbusInterface(); + if (iface) { + iface->DisableAll(type); + } } -void QOfonoCallForwarding::getPropertiesComplete(QDBusPendingCallWatcher *call) +void QOfonoCallForwarding::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) { - call->deleteLater(); - QDBusPendingReply reply = *call; - if (!reply.isError()) { - d_ptr->properties = reply.value(); - Q_EMIT voiceUnconditionalChanged(voiceUnconditional()); - Q_EMIT voiceBusyChanged(voiceBusy()); - Q_EMIT voiceNoReplyChanged(voiceNoReply()); - Q_EMIT voiceNoReplyTimeoutChanged(voiceNoReplyTimeout()); - Q_EMIT voiceNotReachableChanged(voiceNotReachable()); - Q_EMIT forwardingFlagOnSimChanged(forwardingFlagOnSim()); - Q_EMIT readyChanged(); - } else { + SUPER::getPropertiesFinished(properties, error); + if (error) { Q_EMIT getPropertiesFailed(); } - d_ptr->propertiesPending = false; } -void QOfonoCallForwarding::setVoiceUnconditionalComplete(QDBusPendingCallWatcher *call) +void QOfonoCallForwarding::setPropertyFinished(const QString &property, const QDBusError *error) { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT voiceUnconditionalComplete(!reply.isError()); + SUPER::setPropertyFinished(property, error); + if (property == "VoiceUnconditional") { + Q_EMIT voiceUnconditionalComplete(!error); + } else if (property == "VoiceBusy") { + Q_EMIT voiceBusyComplete(!error); + } else if (property == "VoiceNoReply") { + Q_EMIT voiceNoReplyComplete(!error); + } else if (property == "VoiceNoReplyTimeout") { + Q_EMIT voiceNoReplyTimeoutComplete(!error); + } else if (property == "VoiceNotReachable") { + Q_EMIT voiceNotReachableComplete(!error); + } } -void QOfonoCallForwarding::setVoiceBusyComplete(QDBusPendingCallWatcher *call) +QString QOfonoCallForwarding::modemPath() const { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT voiceBusyComplete(!reply.isError()); + return SUPER::modemPath(); } -void QOfonoCallForwarding::setVoiceNoReplyComplete(QDBusPendingCallWatcher *call) +void QOfonoCallForwarding::setModemPath(const QString &path) { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT voiceNoReplyComplete(!reply.isError()); + SUPER::setModemPath(path); } -void QOfonoCallForwarding::setVoiceNoReplyTimeoutComplete(QDBusPendingCallWatcher *call) +bool QOfonoCallForwarding::isValid() const { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT voiceNoReplyTimeoutComplete(!reply.isError()); + return SUPER::isValid(); } -void QOfonoCallForwarding::setVoiceNotReachableComplete(QDBusPendingCallWatcher *call) +bool QOfonoCallForwarding::isReady() const { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT voiceNotReachableComplete(!reply.isError()); + return SUPER::isReady(); } diff -Nru libqofono-0.53/src/qofonocallforwarding.h libqofono-0.70~rtm/src/qofonocallforwarding.h --- libqofono-0.53/src/qofonocallforwarding.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallforwarding.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,28 +16,23 @@ #ifndef QOFONOCallForwarding_H #define QOFONOCallForwarding_H -#include -#include - +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono call forwarding API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/call-forwarding-api.txt */ - -class QOfonoCallForwardingPrivate; -class QOFONOSHARED_EXPORT QOfonoCallForwarding : public QObject +class QOFONOSHARED_EXPORT QOfonoCallForwarding : public QOfonoModemInterface { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QString voiceUnconditional READ voiceUnconditional WRITE setVoiceUnconditional NOTIFY voiceUnconditionalChanged) Q_PROPERTY(QString voiceBusy READ voiceBusy WRITE setVoiceBusy NOTIFY voiceBusyChanged) Q_PROPERTY(QString voiceNoReply READ voiceNoReply WRITE setVoiceNoReply NOTIFY voiceNoReplyChanged) Q_PROPERTY(quint16 voiceNoReplyTimeout READ voiceNoReplyTimeout WRITE setVoiceNoReplyTimeout NOTIFY voiceNoReplyTimeoutChanged) Q_PROPERTY(QString voiceNotReachable READ voiceNotReachable WRITE setVoiceNotReachable NOTIFY voiceNotReachableChanged) Q_PROPERTY(bool forwardingFlagOnSim READ forwardingFlagOnSim NOTIFY forwardingFlagOnSimChanged) - Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) public: explicit QOfonoCallForwarding(QObject *parent = 0); @@ -79,8 +74,6 @@ void voiceNoReplyTimeoutChanged(ushort timeout); void voiceNotReachableChanged(const QString &property); void forwardingFlagOnSimChanged(bool property); - void modemPathChanged(const QString &path); - void readyChanged(); void getPropertiesFailed(); void voiceUnconditionalComplete(bool success); void voiceBusyComplete(bool success); @@ -88,18 +81,11 @@ void voiceNoReplyTimeoutComplete(bool success); void voiceNotReachableComplete(bool success); -private: - QOfonoCallForwardingPrivate *d_ptr; - -private slots: - void modemInterfacesChanged(const QStringList &interfaces); - void propertyChanged(const QString &property,const QDBusVariant &value); - void getPropertiesComplete(QDBusPendingCallWatcher *call); - void setVoiceUnconditionalComplete(QDBusPendingCallWatcher *call); - void setVoiceBusyComplete(QDBusPendingCallWatcher *call); - void setVoiceNoReplyComplete(QDBusPendingCallWatcher *call); - void setVoiceNoReplyTimeoutComplete(QDBusPendingCallWatcher *call); - void setVoiceNotReachableComplete(QDBusPendingCallWatcher *call); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &property, const QVariant &value); + void getPropertiesFinished(const QVariantMap &properties, const QDBusError *error); + void setPropertyFinished(const QString &property, const QDBusError *error); }; #endif // QOFONOCallForwarding_H diff -Nru libqofono-0.53/src/qofonocallmeter.cpp libqofono-0.70~rtm/src/qofonocallmeter.cpp --- libqofono-0.53/src/qofonocallmeter.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallmeter.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,73 +16,27 @@ #include "qofonocallmeter.h" #include "dbus/ofonocallmeter.h" -class QOfonoCallMeterPrivate -{ -public: - QOfonoCallMeterPrivate(); - QString modemPath; - OfonoCallMeter *callMeter; - QVariantMap properties; - -}; - -QOfonoCallMeterPrivate::QOfonoCallMeterPrivate() : - modemPath(QString()) - , callMeter(0) -{ -} +#define SUPER QOfonoModemInterface QOfonoCallMeter::QOfonoCallMeter(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoCallMeterPrivate) + SUPER(OfonoCallMeter::staticInterfaceName(), parent) { } QOfonoCallMeter::~QOfonoCallMeter() { - delete d_ptr; } -void QOfonoCallMeter::setModemPath(const QString &path) +QDBusAbstractInterface *QOfonoCallMeter::createDbusInterface(const QString &path) { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - if (path != modemPath()) { - if (d_ptr->callMeter) { - delete d_ptr->callMeter; - d_ptr->callMeter = 0; - d_ptr->properties.clear(); - } - d_ptr->callMeter = new OfonoCallMeter("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->callMeter->isValid()) { - d_ptr->modemPath = path; - connect(d_ptr->callMeter,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - connect(d_ptr->callMeter,SIGNAL(NearMaximumWarning()),this,SIGNAL(nearMaximumWarning())); - QDBusPendingReply reply; - reply = d_ptr->callMeter->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - Q_EMIT modemPathChanged(path); - } - } + OfonoCallMeter *iface = new OfonoCallMeter("org.ofono", path, QDBusConnection::systemBus(), this); + connect(iface, SIGNAL(NearMaximumWarning()), SIGNAL(nearMaximumWarning())); + return iface; } -QString QOfonoCallMeter::modemPath() const +void QOfonoCallMeter::propertyChanged(const QString &property, const QVariant &value) { - return d_ptr->modemPath; -} - - -void QOfonoCallMeter::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) -{ - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("AccumulatedCallMeterMaximum")) { Q_EMIT accumulatedCallMeterMaximumChanged(value.value()); } else if (property == QLatin1String("PricePerUnit")) { @@ -92,90 +46,69 @@ quint32 QOfonoCallMeter::callMeter() const { - if (d_ptr->callMeter) - return d_ptr->properties["CallMeter"].value(); - else - return 0; + return getProperty("CallMeter").value(); } quint32 QOfonoCallMeter::accumulatedCallMeter() const { - if (d_ptr->callMeter) - return d_ptr->properties["AccumulatedCallMeter"].value(); - else - return 0; + return getProperty("AccumulatedCallMeter").value(); } quint32 QOfonoCallMeter::accumulatedCallMeterMaximum() const { - if (d_ptr->callMeter) - return d_ptr->properties["AccumulatedCallMeterMaximum"].value(); - else - return 0; + return getProperty("AccumulatedCallMeterMaximum").value(); } void QOfonoCallMeter::setAccumulatedCallMeterMaximum(quint32 max, const QString &password) { - if (d_ptr->callMeter) { + OfonoCallMeter *iface = (OfonoCallMeter*)dbusInterface(); + if (iface) { QVariantList arguments; arguments << QVariant(max); - d_ptr->callMeter->SetProperty("AccumulatedCallMeterMaximum",QDBusVariant(arguments), password); + iface->SetProperty("AccumulatedCallMeterMaximum", QDBusVariant(arguments), password); } } - qreal QOfonoCallMeter::pricePerUnit() const { - if (d_ptr->callMeter) - return d_ptr->properties["PricePerUnit"].value(); - else - return 0; + return getProperty("PricePerUnit").value(); } void QOfonoCallMeter::setPricePerUnit(qreal unit, const QString &password) { - if (d_ptr->callMeter) { + OfonoCallMeter *iface = (OfonoCallMeter*)dbusInterface(); + if (iface) { QVariantList arguments; arguments << QVariant(unit); - d_ptr->callMeter->SetProperty("PricePerUnit",QDBusVariant(arguments), password); + iface->SetProperty("PricePerUnit", QDBusVariant(arguments), password); } } QString QOfonoCallMeter:: currency() const { - if (d_ptr->callMeter) - return d_ptr->properties["Currency"].value(); - else - return QString(); + return getString("Currency"); } void QOfonoCallMeter::reset(const QString &password) { - if (d_ptr->callMeter) { - QDBusPendingReply<> result = d_ptr->callMeter->Reset(password); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(resetFinished(QDBusPendingCallWatcher*))); + OfonoCallMeter *iface = (OfonoCallMeter*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher(iface->Reset(password), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onResetFinished(QDBusPendingCallWatcher*))); } } -bool QOfonoCallMeter::isValid() const -{ - return d_ptr->callMeter->isValid(); -} - -void QOfonoCallMeter::resetFinished(QDBusPendingCallWatcher *call) +void QOfonoCallMeter::onResetFinished(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; QOfonoCallMeter::Error error = NoError; - QString errorString; - if (reply.isError()) { qWarning() << "QOfonoCallMeter::reset() failed:" << reply.error(); - error = errorNameToEnum(reply.error().name()); - errorString = reply.error().name() + " " + reply.error().message(); - Q_EMIT resetComplete(error,errorString); + QString errorName(reply.error().name()); + error = errorNameToEnum(errorName); + Q_EMIT resetComplete(error, errorName + " " + reply.error().message()); } } @@ -196,3 +129,18 @@ else return UnknownError; } + +QString QOfonoCallMeter::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoCallMeter::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); +} + +bool QOfonoCallMeter::isValid() const +{ + return SUPER::isValid(); +} diff -Nru libqofono-0.53/src/qofonocallmeter.h libqofono-0.70~rtm/src/qofonocallmeter.h --- libqofono-0.53/src/qofonocallmeter.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallmeter.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,22 +16,18 @@ #ifndef QOFONOCallMeter_H #define QOFONOCallMeter_H -#include -#include - +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono call meter API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/call-meter-api.txt */ - -class QOfonoCallMeterPrivate; -class QOFONOSHARED_EXPORT QOfonoCallMeter : public QObject +class QOFONOSHARED_EXPORT QOfonoCallMeter : public QOfonoModemInterface { Q_OBJECT Q_ENUMS(Error) - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(quint32 callMeter READ callMeter CONSTANT) Q_PROPERTY(quint32 accumulatedCallMeter READ accumulatedCallMeter CONSTANT) Q_PROPERTY(quint32 accumulatedCallMeterMaximum READ accumulatedCallMeterMaximum NOTIFY accumulatedCallMeterMaximumChanged) @@ -69,23 +65,22 @@ Q_INVOKABLE void reset(const QString &password); bool isValid() const; + Q_SIGNALS: void nearMaximumWarning(); void accumulatedCallMeterMaximumChanged(quint32); void pricePerUnitChanged(qreal); - void modemPathChanged(const QString &path); void resetComplete(QOfonoCallMeter::Error error,const QString &errorString); -public slots: - private: - QOfonoCallMeterPrivate *d_ptr; - Error errorNameToEnum(const QString &errorName); + static Error errorNameToEnum(const QString &errorName); private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); - void resetFinished(QDBusPendingCallWatcher *call); + void onResetFinished(QDBusPendingCallWatcher *call); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &property, const QVariant &value); }; #endif // QOFONOCallMeter_H diff -Nru libqofono-0.53/src/qofonocallsettings.cpp libqofono-0.70~rtm/src/qofonocallsettings.cpp --- libqofono-0.53/src/qofonocallsettings.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallsettings.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -15,99 +15,31 @@ #include "qofonocallsettings.h" #include "dbus/ofonocallsettings.h" -#include "qofonomodem.h" -class QOfonoCallSettingsPrivate -{ -public: - QOfonoCallSettingsPrivate(); - QString modemPath; - OfonoCallSettings *callSettings; - QVariantMap properties; - bool propertiesPending; - QSharedPointer modem; -}; - -QOfonoCallSettingsPrivate::QOfonoCallSettingsPrivate() : - modemPath(QString()) - , callSettings(0) - , propertiesPending(false) -{ -} +#define SUPER QOfonoModemInterface QOfonoCallSettings::QOfonoCallSettings(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoCallSettingsPrivate) + SUPER(OfonoCallSettings::staticInterfaceName(), parent) { } QOfonoCallSettings::~QOfonoCallSettings() { - delete d_ptr; } -void QOfonoCallSettings::setModemPath(const QString &path) -{ - if (path == d_ptr->modemPath || path.isEmpty()) - return; - - if (!d_ptr->modem.isNull()) - disconnect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - - d_ptr->modemPath = path; - connectOfono(); - - d_ptr->modem = QOfonoModem::instance(path); - connect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - - Q_EMIT modemPathChanged(path); -} - -QString QOfonoCallSettings::modemPath() const +void QOfonoCallSettings::connectOfono() { - return d_ptr->modemPath; + resetDbusInterface(); } -void QOfonoCallSettings::modemInterfacesChanged(const QStringList &interfaces) +QDBusAbstractInterface *QOfonoCallSettings::createDbusInterface(const QString &path) { - bool haveIface = interfaces.contains("org.ofono.CallSettings"); - if (haveIface != (isValid() && (isReady() || d_ptr->propertiesPending))) - connectOfono(); + return new OfonoCallSettings("org.ofono", path, QDBusConnection::systemBus(), this); } -void QOfonoCallSettings::connectOfono() +void QOfonoCallSettings::propertyChanged(const QString &property, const QVariant &value) { - if (d_ptr->callSettings) { - bool wasReady = isReady(); - delete d_ptr->callSettings; - d_ptr->callSettings = 0; - d_ptr->properties.clear(); - d_ptr->propertiesPending = false; - if (wasReady != isReady()) - Q_EMIT readyChanged(); - } - - d_ptr->callSettings = new OfonoCallSettings("org.ofono", d_ptr->modemPath, QDBusConnection::systemBus(),this); - - if (d_ptr->callSettings->isValid()) { - connect(d_ptr->callSettings,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - d_ptr->propertiesPending = true; - QDBusPendingReply reply = d_ptr->callSettings->GetProperties(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(getPropertiesComplete(QDBusPendingCallWatcher*))); - } -} - - -void QOfonoCallSettings::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) -{ - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("CallingLinePresentation")) { Q_EMIT callingLinePresentationChanged(value.value()); } else if (property == QLatin1String("CalledLinePresentation")) { @@ -129,129 +61,88 @@ QString QOfonoCallSettings::callingLinePresentation() { - if (d_ptr->callSettings) - return d_ptr->properties.value("CallingLinePresentation").value(); - else - return QString(); + return getString("CallingLinePresentation"); } QString QOfonoCallSettings::calledLinePresentation() { - if (d_ptr->callSettings) - return d_ptr->properties.value("CalledLinePresentation").value(); - else - return QString(); + return getString("CalledLinePresentation"); } QString QOfonoCallSettings::callingNamePresentation() { - if (d_ptr->callSettings) - return d_ptr->properties.value("CallingNamePresentation").value(); - else - return QString(); + return getString("CallingNamePresentation"); } QString QOfonoCallSettings::connectedLinePresentation() { - if (d_ptr->callSettings) - return d_ptr->properties.value("ConnectedLinePresentation").value(); - else - return QString(); + return getString("ConnectedLinePresentation"); } QString QOfonoCallSettings::connectedLineRestriction() { - if (d_ptr->callSettings) - return d_ptr->properties.value("ConnectedLineRestriction").value(); - else - return QString(); + return getString("ConnectedLineRestriction"); } QString QOfonoCallSettings::callingLineRestriction() { - if (d_ptr->callSettings) - return d_ptr->properties.value("CallingLineRestriction").value(); - else - return QString(); + return getString("CallingLineRestriction"); } QString QOfonoCallSettings::hideCallerId() { - if (d_ptr->callSettings) - return d_ptr->properties.value("HideCallerId").value(); - else - return QString(); + return getString("HideCallerId"); } void QOfonoCallSettings::setHideCallerId(const QString &setting) { - if (d_ptr->callSettings) { - QDBusPendingReply<> reply = d_ptr->callSettings->SetProperty("HideCallerId", QDBusVariant(setting)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setHideCallerIdComplete(QDBusPendingCallWatcher*))); - } + setProperty("HideCallerId", setting); } QString QOfonoCallSettings::voiceCallWaiting() { - if (d_ptr->callSettings) - return d_ptr->properties.value("VoiceCallWaiting").value(); - else - return QString(); + return getString("VoiceCallWaiting"); } void QOfonoCallSettings::setVoiceCallWaiting(const QString &setting) { - if (d_ptr->callSettings) { - QDBusPendingReply<> reply = d_ptr->callSettings->SetProperty("VoiceCallWaiting", QDBusVariant(setting)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoiceCallWaitingComplete(QDBusPendingCallWatcher*))); + setProperty("VoiceCallWaiting", setting); +} + +void QOfonoCallSettings::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) +{ + SUPER::getPropertiesFinished(properties, error); + if (error) { + Q_EMIT getPropertiesFailed(); } } -bool QOfonoCallSettings::isValid() const +void QOfonoCallSettings::setPropertyFinished(const QString &property, const QDBusError *error) { - return d_ptr->callSettings->isValid(); + SUPER::setPropertyFinished(property, error); + if (property == "HideCallerId") { + Q_EMIT hideCallerIdComplete(!error); + } else if (property == "VoiceCallWaiting") { + Q_EMIT voiceCallWaitingComplete(!error); + } } -bool QOfonoCallSettings::isReady() const +QString QOfonoCallSettings::modemPath() const { - return !d_ptr->properties.isEmpty(); + return SUPER::modemPath(); } -void QOfonoCallSettings::getPropertiesComplete(QDBusPendingCallWatcher *call) +void QOfonoCallSettings::setModemPath(const QString &path) { - call->deleteLater(); - QDBusPendingReply reply = *call; - if (!reply.isError()) { - d_ptr->properties = reply.value(); - Q_EMIT callingLinePresentationChanged(callingLinePresentation()); - Q_EMIT calledLinePresentationChanged(calledLinePresentation()); - Q_EMIT callingNamePresentationChanged(callingNamePresentation()); - Q_EMIT connectedLinePresentationChanged(connectedLinePresentation()); - Q_EMIT connectedLineRestrictionChanged(connectedLineRestriction()); - Q_EMIT callingLineRestrictionChanged(callingLineRestriction()); - Q_EMIT hideCallerIdChanged(hideCallerId()); - Q_EMIT voiceCallWaitingChanged(voiceCallWaiting()); - Q_EMIT readyChanged(); - } else { - Q_EMIT getPropertiesFailed(); - } - d_ptr->propertiesPending = false; + SUPER::setModemPath(path); } -void QOfonoCallSettings::setHideCallerIdComplete(QDBusPendingCallWatcher *call) +bool QOfonoCallSettings::isValid() const { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT hideCallerIdComplete(!reply.isError()); + return SUPER::isValid(); } -void QOfonoCallSettings::setVoiceCallWaitingComplete(QDBusPendingCallWatcher *call) +bool QOfonoCallSettings::isReady() const { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT voiceCallWaitingComplete(!reply.isError()); + return SUPER::isReady(); } diff -Nru libqofono-0.53/src/qofonocallsettings.h libqofono-0.70~rtm/src/qofonocallsettings.h --- libqofono-0.53/src/qofonocallsettings.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallsettings.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,21 +16,17 @@ #ifndef QOFONOCallSettings_H #define QOFONOCallSettings_H -#include -#include - +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono call settings API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/call-settings-api.txt */ - -class QOfonoCallSettingsPrivate; -class QOFONOSHARED_EXPORT QOfonoCallSettings : public QObject +class QOFONOSHARED_EXPORT QOfonoCallSettings : public QOfonoModemInterface { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QString hideCallerId READ hideCallerId WRITE setHideCallerId NOTIFY hideCallerIdChanged) Q_PROPERTY(QString voiceCallWaiting READ voiceCallWaiting WRITE setVoiceCallWaiting NOTIFY voiceCallWaitingChanged) Q_PROPERTY(QString callingLinePresentation READ callingLinePresentation NOTIFY callingLinePresentationChanged) @@ -39,7 +35,6 @@ Q_PROPERTY(QString connectedLinePresentation READ connectedLinePresentation NOTIFY connectedLinePresentationChanged) Q_PROPERTY(QString connectedLineRestriction READ connectedLineRestriction NOTIFY connectedLineRestrictionChanged) Q_PROPERTY(QString callingLineRestriction READ callingLineRestriction NOTIFY callingLineRestrictionChanged) - Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) public: explicit QOfonoCallSettings(QObject *parent = 0); @@ -75,21 +70,15 @@ void callingLineRestrictionChanged(const QString &setting); void hideCallerIdChanged(const QString &setting); void voiceCallWaitingChanged(const QString &setting); - void modemPathChanged(const QString &path); - void readyChanged(); void getPropertiesFailed(); void hideCallerIdComplete(bool success); void voiceCallWaitingComplete(bool success); -private: - QOfonoCallSettingsPrivate *d_ptr; - -private slots: - void modemInterfacesChanged(const QStringList &interfaces); - void propertyChanged(const QString &property,const QDBusVariant &value); - void getPropertiesComplete(QDBusPendingCallWatcher*); - void setHideCallerIdComplete(QDBusPendingCallWatcher *call); - void setVoiceCallWaitingComplete(QDBusPendingCallWatcher *call); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void getPropertiesFinished(const QVariantMap &properties, const QDBusError *error); + void setPropertyFinished(const QString &property, const QDBusError *error); + void propertyChanged(const QString &key, const QVariant &value); }; #endif // QOFONOCallSettings_H diff -Nru libqofono-0.53/src/qofonocallvolume.cpp libqofono-0.70~rtm/src/qofonocallvolume.cpp --- libqofono-0.53/src/qofonocallvolume.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallvolume.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,72 +16,25 @@ #include "qofonocallvolume.h" #include "dbus/ofonocallvolume.h" -class QOfonoCallVolumePrivate -{ -public: - QOfonoCallVolumePrivate(); - QString modemPath; - OfonoCallVolume *callVolume; - QVariantMap properties; - -}; - -QOfonoCallVolumePrivate::QOfonoCallVolumePrivate() : - modemPath(QString()) - , callVolume(0) -{ -} +#define SUPER QOfonoModemInterface QOfonoCallVolume::QOfonoCallVolume(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoCallVolumePrivate) + SUPER(OfonoCallVolume::staticInterfaceName(), parent) { } QOfonoCallVolume::~QOfonoCallVolume() { - delete d_ptr; -} - -void QOfonoCallVolume::setModemPath(const QString &path) -{ - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - if (path != modemPath()) { - if (d_ptr->callVolume) { - delete d_ptr->callVolume; - d_ptr->callVolume= 0; - d_ptr->properties.clear(); - } - d_ptr->callVolume = new OfonoCallVolume("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->callVolume->isValid()) { - d_ptr->modemPath = path; - connect(d_ptr->callVolume,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - QDBusPendingReply reply; - reply = d_ptr->callVolume->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - Q_EMIT modemPathChanged(path); - } - } } -QString QOfonoCallVolume::modemPath() const +QDBusAbstractInterface *QOfonoCallVolume::createDbusInterface(const QString &path) { - return d_ptr->modemPath; + return new OfonoCallVolume("org.ofono", path, QDBusConnection::systemBus(),this); } - -void QOfonoCallVolume::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +void QOfonoCallVolume::propertyChanged(const QString &property, const QVariant &value) { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("Muted")) { Q_EMIT mutedChanged(value.value()); } else if (property == QLatin1String("SpeakerVolume")) { @@ -93,48 +46,46 @@ bool QOfonoCallVolume::muted() const { - if ( d_ptr->callVolume) - return d_ptr->properties["Muted"].value(); - else - return false; + return getBool("Muted"); } void QOfonoCallVolume::setMuted(bool mute) { - if ( d_ptr->callVolume) - d_ptr->callVolume->SetProperty("Muted",QDBusVariant(mute)); - + setProperty("Muted", mute); } quint8 QOfonoCallVolume::speakerVolume() const { - if (d_ptr->callVolume) - return d_ptr->properties["SpeakerVolume"].value(); - else - return 0; + return getProperty("SpeakerVolume").value(); } +// Passing one byte by reference is such a great idea! void QOfonoCallVolume::setSpeakerVolume(const quint8 &volume) { - if ( d_ptr->callVolume) - d_ptr->callVolume->SetProperty("SpeakerVolume",QDBusVariant(QVariant::fromValue(volume))); + setProperty("SpeakerVolume", QVariant::fromValue(volume)); } quint8 QOfonoCallVolume::microphoneVolume()const { - if ( d_ptr->callVolume) - return d_ptr->properties["MicrophoneVolume"].value(); - else - return 0; + return getProperty("microphoneVolume").value(); } void QOfonoCallVolume::setMicrophoneVolume(const quint8 &volume) { - if ( d_ptr->callVolume) - d_ptr->callVolume->SetProperty("MicrophoneVolume",QDBusVariant(volume)); + setProperty("MicrophoneVolume", QVariant::fromValue(volume)); +} + +QString QOfonoCallVolume::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoCallVolume::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); } bool QOfonoCallVolume::isValid() const { - return d_ptr->callVolume->isValid(); + return SUPER::isValid(); } diff -Nru libqofono-0.53/src/qofonocallvolume.h libqofono-0.70~rtm/src/qofonocallvolume.h --- libqofono-0.53/src/qofonocallvolume.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocallvolume.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,22 +16,18 @@ #ifndef QOFONOCallVolume_H #define QOFONOCallVolume_H -#include -#include +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono call volume API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/call-volume-api.txt */ - -class QOfonoCallVolumePrivate; -class QOFONOSHARED_EXPORT QOfonoCallVolume : public QObject +class QOFONOSHARED_EXPORT QOfonoCallVolume : public QOfonoModemInterface { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged) - Q_PROPERTY(quint8 speakerVolume READ speakerVolume WRITE setSpeakerVolume NOTIFY speakerVolumeChanged) Q_PROPERTY(quint8 microphoneVolume READ microphoneVolume WRITE setMicrophoneVolume NOTIFY microphoneVolumeChanged) @@ -52,19 +48,15 @@ void setMicrophoneVolume(const quint8 &mpvolume); bool isValid() const; + Q_SIGNALS: void mutedChanged(bool muted); void speakerVolumeChanged(const quint8 &volume); void microphoneVolumeChanged(const quint8 &mvolume); - void modemPathChanged(const QString &path); - -public slots: - -private: - QOfonoCallVolumePrivate *d_ptr; -private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &property, const QVariant &value); }; #endif // QOFONOCallVolume_H diff -Nru libqofono-0.53/src/qofonocellbroadcast.cpp libqofono-0.70~rtm/src/qofonocellbroadcast.cpp --- libqofono-0.53/src/qofonocellbroadcast.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocellbroadcast.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,111 +16,78 @@ #include "qofonocellbroadcast.h" #include "dbus/ofonocellbroadcast.h" -class QOfonoCellBroadcastPrivate +#define SUPER QOfonoObject + +QOfonoCellBroadcast::QOfonoCellBroadcast(QObject *parent) : + SUPER(parent) { -public: - QOfonoCellBroadcastPrivate(); - QString modemPath; - OfonoCellBroadcast *cellBroadcast; - QVariantMap properties; - -}; - -QOfonoCellBroadcastPrivate::QOfonoCellBroadcastPrivate() : - modemPath(QString()) - , cellBroadcast(0) +} + +QOfonoCellBroadcast::~QOfonoCellBroadcast() { } -QOfonoCellBroadcast::QOfonoCellBroadcast(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoCellBroadcastPrivate) +QDBusAbstractInterface *QOfonoCellBroadcast::createDbusInterface(const QString &path) { + OfonoCellBroadcast *iface = new OfonoCellBroadcast("org.ofono", path, QDBusConnection::systemBus(), this); + connect(iface, + SIGNAL(IncomingBroadcast(QString,quint16)), + SIGNAL(incomingBroadcast(QString,quint16))); + connect(iface, + SIGNAL(EmergencyBroadcast(QString,QVariantMap)), + SIGNAL(emergencyBroadcast(QString,QVariantMap))); + return iface; } -QOfonoCellBroadcast::~QOfonoCellBroadcast() +void QOfonoCellBroadcast::objectPathChanged(const QString &path, const QVariantMap *properties) { - delete d_ptr; + SUPER::objectPathChanged(path, properties); + Q_EMIT modemPathChanged(path); } void QOfonoCellBroadcast::setModemPath(const QString &path) { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - if (path != modemPath()) { - if (d_ptr->cellBroadcast) { - delete d_ptr->cellBroadcast; - d_ptr->cellBroadcast = 0; - d_ptr->properties.clear(); - } - d_ptr->cellBroadcast = new OfonoCellBroadcast("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->cellBroadcast->isValid()) { - d_ptr->modemPath = path; - connect(d_ptr->cellBroadcast,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - connect(d_ptr->cellBroadcast,SIGNAL(IncomingBroadcast(QString,quint16)), - this,SIGNAL(incomingBroadcast(QString,quint16))); - connect(d_ptr->cellBroadcast,SIGNAL(EmergencyBroadcast(QString,QVariantMap)), - this,SIGNAL(emergencyBroadcast(QString,QVariantMap))); - - QDBusPendingReply reply; - reply = d_ptr->cellBroadcast->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - Q_EMIT modemPathChanged(path); - } - } + setObjectPath(path); } QString QOfonoCellBroadcast::modemPath() const { - return d_ptr->modemPath; + return objectPath(); +} + +void QOfonoCellBroadcast::propertyChanged(const QString &property, const QVariant &value) +{ + SUPER::propertyChanged(property, value); + if (property == QLatin1String("Powered")) { + Q_EMIT enabledChanged(value.toBool()); + } else if (property == QLatin1String("Topics")) { + Q_EMIT topicsChanged(value.toString()); + } } bool QOfonoCellBroadcast::enabled() const { - if ( d_ptr->cellBroadcast) - return d_ptr->properties["Powered"].value(); - else - return false; + return getBool("Powered"); } void QOfonoCellBroadcast::setEnabled(bool b) { - if ( d_ptr->cellBroadcast) - d_ptr->cellBroadcast->SetProperty("Powered",QDBusVariant(b)); + setProperty("Powered", b); } QString QOfonoCellBroadcast::topics() const { - if ( d_ptr->cellBroadcast) - return d_ptr->properties["Topics"].value(); - else - return QString(); + return getString("Topics"); } void QOfonoCellBroadcast::setTopics(const QString &topics) const { - if ( d_ptr->cellBroadcast) - d_ptr->cellBroadcast->SetProperty("Topics",QDBusVariant(topics)); -} - -void QOfonoCellBroadcast::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) -{ - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); - - if (property == QLatin1String("Powered")) { - Q_EMIT enabledChanged(value.value()); - } else if (property == QLatin1String("Topics")) { - Q_EMIT topicsChanged(value.value()); - } + // It's not clear why this method is const (probably, copy/paste artifact) + // but it has to remain const to maintain ABI + ((QOfonoCellBroadcast*)this)->setProperty("Topics", topics); } bool QOfonoCellBroadcast::isValid() const { - return d_ptr->cellBroadcast->isValid(); + return SUPER::isValid(); } diff -Nru libqofono-0.53/src/qofonocellbroadcast.h libqofono-0.70~rtm/src/qofonocellbroadcast.h --- libqofono-0.53/src/qofonocellbroadcast.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonocellbroadcast.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,22 +16,18 @@ #ifndef QOFONOCELLBROADCAST_H #define QOFONOCELLBROADCAST_H -#include -#include - +#include "qofonoobject.h" #include "qofono_global.h" + //! This class is used to access ofono cell broadcast API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/cell-broadcast-api.txt */ - -class QOfonoCellBroadcastPrivate; -class QOFONOSHARED_EXPORT QOfonoCellBroadcast : public QObject +class QOFONOSHARED_EXPORT QOfonoCellBroadcast : public QOfonoObject { Q_OBJECT Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) Q_PROPERTY(QString topics READ topics NOTIFY topicsChanged) @@ -46,9 +42,10 @@ void setEnabled(bool b); QString topics() const; - void setTopics(const QString &) const; + void setTopics(const QString &) const; // to maintain ABI bool isValid() const; + Q_SIGNALS: void enabledChanged(bool); void topicsChanged(const QString &); @@ -56,12 +53,10 @@ void emergencyBroadcast(const QString &, const QVariantMap &); void modemPathChanged(const QString &path); -public slots: - -private: - QOfonoCellBroadcastPrivate *d_ptr; -private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &key, const QVariant &value); + void objectPathChanged(const QString &path, const QVariantMap *properties); }; #endif // QOFONOCELLBROADCAST_H diff -Nru libqofono-0.53/src/qofonoconnectioncontext.cpp libqofono-0.70~rtm/src/qofonoconnectioncontext.cpp --- libqofono-0.53/src/qofonoconnectioncontext.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonoconnectioncontext.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,107 +16,71 @@ #include #include "qofonoconnectioncontext.h" +#include "qofononetworkregistration.h" #include "dbus/ofonoconnectioncontext.h" -#include "qofonomanager.h" -#include "qofonoconnectionmanager.h" -#include "qofononetworkregistration.h" +#define SUPER QOfonoObject -class QOfonoConnectionContextPrivate -{ -public: - QOfonoConnectionContextPrivate(); - OfonoConnectionContext *context; - QString contextPath; - QVariantMap properties; - QString modemPath; - -}; - -QOfonoConnectionContextPrivate::QOfonoConnectionContextPrivate() : - context(0) - , contextPath(QString()) +QOfonoConnectionContext::QOfonoConnectionContext(QObject *parent) : + SUPER(parent) { } -QOfonoConnectionContext::QOfonoConnectionContext(QObject *parent) : - QObject(parent), - d_ptr(new QOfonoConnectionContextPrivate) +QOfonoConnectionContext::~QOfonoConnectionContext() { - qDebug() << Q_FUNC_INFO; } -QOfonoConnectionContext::~QOfonoConnectionContext() +QDBusAbstractInterface *QOfonoConnectionContext::createDbusInterface(const QString &path) { - delete d_ptr; + return new OfonoConnectionContext("org.ofono", path, QDBusConnection::systemBus(),this); } +void QOfonoConnectionContext::objectPathChanged(const QString &path, const QVariantMap *properties) +{ + SUPER::objectPathChanged(path, properties); + Q_EMIT contextPathChanged(path); +} QString QOfonoConnectionContext::contextPath() const { - return d_ptr->contextPath; + return objectPath(); } QString QOfonoConnectionContext::modemPath() const { - return d_ptr->modemPath; + QString path = objectPath(); + int lastSlash = path.lastIndexOf('/'); + return (lastSlash > 0) ? path.left(lastSlash) : QString(); } -void QOfonoConnectionContext::setContextPath(const QString &idPath) +void QOfonoConnectionContext::setContextPath(const QString &path) { - - if (idPath != contextPath()) { - if(d_ptr->context) { - delete d_ptr->context; - d_ptr->context = 0; - d_ptr->properties.clear(); + if (path != objectPath()) { + // Modem path is redundant but supported for historical reasons + QString oldModemPath(modemPath()); + setObjectPath(path); + QString newModemPath(modemPath()); + if (oldModemPath != newModemPath) { + Q_EMIT modemPathChanged(newModemPath); } + } +} -qDebug() << Q_FUNC_INFO; - d_ptr->context = new OfonoConnectionContext("org.ofono", idPath, QDBusConnection::systemBus(),this); - if (d_ptr->context->isValid()) { - d_ptr->contextPath = idPath; - connect(d_ptr->context,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - QDBusPendingReply reply; - reply = d_ptr->context->GetProperties(); - reply.waitForFinished(); - if (reply.isError()) - Q_EMIT reportError(reply.error().message()); - - d_ptr->properties = reply.value(); - Q_EMIT contextPathChanged(idPath); - - } else { - Q_EMIT reportError("Context is not valid"); - qDebug() << Q_FUNC_INFO << "error Context is not valid"; - } - QOfonoManager manager; - if (manager.modems().count() > 0) { - QOfonoConnectionManager connManager; - Q_FOREACH (const QString &path, manager.modems()) { - connManager.setModemPath(path); - if (connManager.contexts().contains(idPath)) { - d_ptr->modemPath = path; - Q_EMIT modemPathChanged(path); - break; - } - } - } -/* if (!validateProvisioning()) { - provisionForCurrentNetwork(this->type()); - } else { - Q_EMIT reportError("Context provision is not valid"); - qDebug() << Q_FUNC_INFO << "error Context provision is not valid"; - } -*/ +QVariant QOfonoConnectionContext::convertProperty(const QString &key, const QVariant &value) +{ + if (key == QLatin1String("Settings") || + key == QLatin1String("IPv6.Settings")) { + QVariantMap map; + value.value() >> map; + return map; + } else { + return SUPER::convertProperty(key, value); } } -void QOfonoConnectionContext::propertyChanged(const QString &property, const QDBusVariant &dbusvalue) +void QOfonoConnectionContext::propertyChanged(const QString &property, const QVariant &value) { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property, value); + SUPER::propertyChanged(property, value); if (property == QLatin1String("Active")) { Q_EMIT activeChanged(value.value()); } else if (property == QLatin1String("Name")) { @@ -136,203 +100,125 @@ } else if (property == QLatin1String("MessageCenter")) { Q_EMIT messageCenterChanged(value.value()); } else if (property == QLatin1String("Settings")) { - QVariantMap map; - value.value()>>map; - Q_EMIT settingsChanged(map); + Q_EMIT settingsChanged(getVariantMap("Settings")); } else if (property == QLatin1String("IPv6.Settings")) { - QVariantMap map; - value.value()>>map; - Q_EMIT IPv6SettingsChanged(map); + Q_EMIT IPv6SettingsChanged(getVariantMap("IPv6.Settings")); } } bool QOfonoConnectionContext::active() const { - if (d_ptr->context) - return d_ptr->properties["Active"].value(); - else - return false; + return getBool("Active"); } QString QOfonoConnectionContext::accessPointName() const { - if (d_ptr->context) - return d_ptr->properties["AccessPointName"].value(); - else - return QString(); + return getString("AccessPointName"); } QString QOfonoConnectionContext::type() const { - if (d_ptr->context) - return d_ptr->properties["Type"].value(); - else - return QString(); + return getString("Type"); } QString QOfonoConnectionContext::username() const { - if (d_ptr->context) - return d_ptr->properties["Username"].value(); - else - return QString(); + return getString("Username"); } QString QOfonoConnectionContext::password() const { - if (d_ptr->context) - return d_ptr->properties["Password"].value(); - else - return QString(); + return getString("Password"); } QString QOfonoConnectionContext::protocol() const { - if (d_ptr->context) - return d_ptr->properties["Protocol"].value(); - else - return QString(); + return getString("Protocol"); } QString QOfonoConnectionContext::name() const { - if (d_ptr->context) - return d_ptr->properties["Name"].value(); - else - return QString(); + return getString("Name"); } QString QOfonoConnectionContext::messageProxy() const { - if (d_ptr->context) - return d_ptr->properties["MessageProxy"].value(); - else - return QString(); + return getString("MessageProxy"); } QString QOfonoConnectionContext::messageCenter() const { - if (d_ptr->context) - return d_ptr->properties["MessageCenter"].value(); - else - return QString(); + return getString("MessageCenter"); } QVariantMap QOfonoConnectionContext::settings() const { - QVariantMap map; - if (d_ptr->context) - d_ptr->properties["Settings"].value()>>map; - - return map; + return getVariantMap("Settings"); } QVariantMap QOfonoConnectionContext::IPv6Settings() const { - QVariantMap map; - if (d_ptr->context) - d_ptr->properties["IPv6.Settings"].value()>>map; - - return map; + return getVariantMap("IPv6.Settings"); } void QOfonoConnectionContext::setActive(const bool value) { // need someway to tell ui that someone wants to disconnect - if (!value) + if (!value) { Q_EMIT disconnectRequested(); - QString str("Active"); - QDBusVariant var(value); - setOneProperty(str,var); + } + setProperty("Active", value); } void QOfonoConnectionContext::setAccessPointName(const QString &value) { - if (!active()) { - QString str("AccessPointName"); - QDBusVariant var(value); - setOneProperty(str,var); - } else { - qDebug() << Q_FUNC_INFO << "is active cannot set APN"; - Q_EMIT reportError("Context active"); - } + setProperty("AccessPointName", value); } void QOfonoConnectionContext::setType(const QString &value) { - QString str("Type"); - QDBusVariant var(value); - setOneProperty(str,var); + setProperty("Type", value); } void QOfonoConnectionContext::setUsername(const QString &value) { - QString str("Username"); - QDBusVariant var(value); - setOneProperty(str,var); + setProperty("Username", value); } void QOfonoConnectionContext::setPassword(const QString &value) { - QString str("Password"); - QDBusVariant var(value); - setOneProperty(str,var); + setProperty("Password", value); } void QOfonoConnectionContext::setProtocol(const QString &value) { - QString str("Protocol"); - QDBusVariant var(value); - setOneProperty(str,var); + setProperty("Protocol", value); } void QOfonoConnectionContext::setName(const QString &value) { - QString str("Name"); - QDBusVariant var(value); - setOneProperty(str,var); + setProperty("Name", value); } void QOfonoConnectionContext::setMessageProxy(const QString &value) { - QString str("MessageProxy"); - QDBusVariant var(value); - setOneProperty(str,var); + setProperty("MessageProxy", value); } void QOfonoConnectionContext::setMessageCenter(const QString &value) { - QString str("MessageCenter"); - QDBusVariant var(value); - setOneProperty(str,var); -} - -bool QOfonoConnectionContext::isValid() const -{ - return d_ptr->context->isValid(); + setProperty("MessageCenter", value); } -void QOfonoConnectionContext::setOneProperty(const QString &prop, const QDBusVariant &var) +void QOfonoConnectionContext::disconnect() { - if (d_ptr->context) { - QDBusPendingReply <> reply = d_ptr->context->SetProperty(prop,var); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setPropertyFinished(QDBusPendingCallWatcher*))); - } + Q_EMIT disconnectRequested(); + setPropertySync("Active", false); } -void QOfonoConnectionContext::setPropertyFinished(QDBusPendingCallWatcher *watch) +bool QOfonoConnectionContext::isValid() const { - watch->deleteLater(); - QDBusPendingReply<> reply = *watch; - - if(reply.isError()) { - qDebug() << Q_FUNC_INFO << reply.error().message(); - Q_EMIT reportError(reply.error().message()); - } - Q_EMIT setPropertyFinished(); - + return SUPER::isValid(); } /* @@ -347,16 +233,13 @@ //check provision against mbpi bool QOfonoConnectionContext::validateProvisioning() { - qDebug() << Q_FUNC_INFO << d_ptr->modemPath; - if (d_ptr->modemPath.isEmpty()) + QString modem(modemPath()); + qDebug() << modem; + if (modem.isEmpty()) return false; - QString provider; - QString mcc; - QString mnc; - QOfonoNetworkRegistration netReg; - netReg.setModemPath(d_ptr->modemPath); + netReg.setModemPath(modem); if (netReg.status() == "registered") return validateProvisioning(netReg.networkOperators().at(0),netReg.mcc(),netReg.mnc()); return false; @@ -368,7 +251,7 @@ //check provision against mbpi bool QOfonoConnectionContext::validateProvisioning(const QString &providerString, const QString &mcc, const QString &mnc) { - qDebug() << Q_FUNC_INFO << providerString; + qDebug() << providerString; QXmlQuery query; QString provider = providerString; @@ -454,11 +337,12 @@ void QOfonoConnectionContext::provisionForCurrentNetwork(const QString &type) { - if (d_ptr->modemPath.isEmpty()) + QString modem(modemPath()); + if (modem.isEmpty()) return; QOfonoNetworkRegistration netReg; - netReg.setModemPath(d_ptr->modemPath); + netReg.setModemPath(modem); if (netReg.status() == "registered") provision(netReg.name(), netReg.mcc(),netReg.mnc(), type); @@ -484,7 +368,7 @@ providerStr.replace("\'", "'"); } - //provider + // provider query.setQuery("/serviceproviders/country/provider[ name = '"+providerStr+"']/string()"); QString providerName; query.evaluateTo(&providerName); @@ -514,11 +398,9 @@ Q_FOREACH( const QString &apn, accessPointNameList) { -// qDebug() << "For APN" << apn; - QString queryString("/serviceproviders/country/provider[ name = '"+providerStr+"']//gsm[ network-id[@mcc = '"+mcc+"' and @mnc = '"+mnc+"']]/apn [ @value = '"+apn+ "']/"); - //type + // type query.setQuery(queryString+"usage/@type/string()"); QString typeStr; query.evaluateTo(&typeStr); @@ -531,21 +413,21 @@ continue; } - //name - query.setQuery(queryString+"name/string()"); + // name + query.setQuery(queryString+"name/string()"); QString nameStr; query.evaluateTo(&nameStr); nameStr = nameStr.simplified(); if (nameStr.isEmpty()) nameStr = providerStr; - //username + // username query.setQuery(queryString+"username/string()"); QString usernameStr; query.evaluateTo(&usernameStr); usernameStr = usernameStr.simplified(); - //password + // password query.setQuery(queryString+"password/string()"); QString passwordStr; query.evaluateTo(&passwordStr); @@ -553,36 +435,25 @@ passwordStr = passwordStr.simplified(); if (!nameStr.isEmpty()) { - QDBusPendingReply <> reply = d_ptr->context->SetProperty("Name",QDBusVariant(nameStr)); - reply.waitForFinished(); - d_ptr->properties["Name"] = nameStr; + setPropertySync("Name", nameStr); } if (!type.isEmpty()) { - QDBusPendingReply <> reply = d_ptr->context->SetProperty("Type",QDBusVariant(type)); - reply.waitForFinished(); - d_ptr->properties["Type"] = type; + setPropertySync("Type", type); } if (!apn.isEmpty()) { - QDBusPendingReply <> reply = d_ptr->context->SetProperty("AccessPointName",QDBusVariant(apn)); - reply.waitForFinished(); - d_ptr->properties["AccessPointName"] = apn; + setPropertySync("AccessPointName", apn); } if (!passwordStr.isEmpty()) { - QDBusPendingReply <> reply = d_ptr->context->SetProperty("Password",QDBusVariant(passwordStr)); - reply.waitForFinished(); - d_ptr->properties["Password"] = passwordStr; + setPropertySync("Password", passwordStr); } + if (!usernameStr.isEmpty()) { - QDBusPendingReply <> reply = d_ptr->context->SetProperty("Username",QDBusVariant(usernameStr)); - reply.waitForFinished(); - d_ptr->properties["Username"] = usernameStr; + setPropertySync("Username", usernameStr); } break; } - Q_EMIT setPropertyFinished(); Q_EMIT provisioningFinished(); } - diff -Nru libqofono-0.53/src/qofonoconnectioncontext.h libqofono-0.70~rtm/src/qofonoconnectioncontext.h --- libqofono-0.53/src/qofonoconnectioncontext.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonoconnectioncontext.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,23 +16,20 @@ #ifndef QOFONOCONNECTIONCONTEXT_H #define QOFONOCONNECTIONCONTEXT_H -#include -#include "dbustypes.h" +#include "qofonoobject.h" #include "qofono_global.h" + //! This class is used to access ofono connman context API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob;f=doc/connman-api.txt */ - -class QOfonoConnectionContextPrivate; - -class QOFONOSHARED_EXPORT QOfonoConnectionContext : public QObject +class QOFONOSHARED_EXPORT QOfonoConnectionContext : public QOfonoObject { Q_OBJECT Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) Q_PROPERTY(QString accessPointName READ accessPointName WRITE setAccessPointName NOTIFY accessPointNameChanged) - Q_PROPERTY(QString type READ type WRITE setType NOTIFY nameChanged) + Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged) Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged) Q_PROPERTY(QString protocol READ protocol WRITE setProtocol NOTIFY protocolChanged) @@ -83,7 +80,6 @@ QVariantMap IPv6Settings() const; bool isValid() const; - QString modemPath() const; Q_INVOKABLE bool validateProvisioning(); //check provision against mbpi @@ -94,6 +90,7 @@ Q_INVOKABLE void provision(const QString &provider, const QString &mcc, const QString &mnc, const QString &type=QStringLiteral("internet")); // provision context against mbpi #endif Q_INVOKABLE void provisionForCurrentNetwork(const QString &type); + Q_INVOKABLE void disconnect(); Q_SIGNALS: void disconnectRequested(); @@ -108,25 +105,15 @@ void messageCenterChanged(const QString &msc); void settingsChanged(const QVariantMap &settingsMap); void IPv6SettingsChanged(const QVariantMap &ipv6SettingsMap); - void contextPathChanged(const QString &contextPath); - - void reportError(const QString &errorString); - void setPropertyFinished(); void provisioningFinished(); void modemPathChanged(const QString &path); - protected: - void setOneProperty(const QString &prop,const QDBusVariant &var); -protected slots: - void setPropertyFinished(QDBusPendingCallWatcher *watch); - -private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); - -private: - QOfonoConnectionContextPrivate *d_ptr; + QDBusAbstractInterface *createDbusInterface(const QString &path); + QVariant convertProperty(const QString &key, const QVariant &value); + void propertyChanged(const QString &key, const QVariant &value); + void objectPathChanged(const QString &path, const QVariantMap *properties); }; #endif // QOFONOCONNECTIONCONTEXT_H diff -Nru libqofono-0.53/src/qofonoconnectionmanager.cpp libqofono-0.70~rtm/src/qofonoconnectionmanager.cpp --- libqofono-0.53/src/qofonoconnectionmanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonoconnectionmanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -15,44 +15,25 @@ #include "qofonoconnectionmanager.h" #include "dbus/ofonoconnectionmanager.h" -#include "dbustypes.h" -class QOfonoConnectionManagerPrivate +#define SUPER QOfonoModemInterface + +class QOfonoConnectionManager::Private : public QOfonoObject::ExtData { public: - QOfonoConnectionManagerPrivate(); - QString modemPath; - OfonoConnectionManager *connman; - QVariantMap properties; + bool initialized; QStringList contexts; QHash contextTypes; QString filter; - void getContexts(); + Private() : initialized(false) {} void filterContexts(); }; -QOfonoConnectionManagerPrivate::QOfonoConnectionManagerPrivate() : - modemPath(QString()) - , connman(0) - ,contexts(QStringList()) -{ -} - -void QOfonoConnectionManagerPrivate::getContexts() -{ - contextTypes.clear(); - QDBusReply reply2 = connman->GetContexts(); - foreach(ObjectPathProperties context, reply2.value()) { - contextTypes.insert(context.path.path(), context.properties.value("Type").toString()); - } - filterContexts(); -} - // FILTER = [!]NAMES // NAMES = NAME [,NAMES] // Spaces and tabs are ignored -void QOfonoConnectionManagerPrivate::filterContexts() +void QOfonoConnectionManager::Private::filterContexts() { if (contextTypes.isEmpty()) { contexts.clear(); @@ -82,183 +63,120 @@ } QOfonoConnectionManager::QOfonoConnectionManager(QObject *parent) : - QObject(parent), - d_ptr(new QOfonoConnectionManagerPrivate) + SUPER(OfonoConnectionManager::staticInterfaceName(), new Private, parent) { + QOfonoDbusTypes::registerObjectPathProperties(); } QOfonoConnectionManager::~QOfonoConnectionManager() { - delete d_ptr; } -void QOfonoConnectionManager::setModemPath(const QString &path) +bool QOfonoConnectionManager::isValid() const { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - QStringList removedProperties = d_ptr->properties.keys(); - - delete d_ptr->connman; - d_ptr->connman = new OfonoConnectionManager("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->connman->isValid()) { - d_ptr->modemPath = path; - - connect(d_ptr->connman,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - connect(d_ptr->connman,SIGNAL(ContextAdded(QDBusObjectPath,QVariantMap)), - this,SLOT(onContextAdd(QDBusObjectPath,QVariantMap))); - connect(d_ptr->connman,SIGNAL(ContextRemoved(QDBusObjectPath)), - this,SLOT(onContextRemove(QDBusObjectPath))); - - QVariantMap properties = d_ptr->connman->GetProperties().value(); - for (QVariantMap::ConstIterator it = properties.constBegin(); - it != properties.constEnd(); ++it) { - updateProperty(it.key(), it.value()); - removedProperties.removeOne(it.key()); - } - - d_ptr->getContexts(); - Q_EMIT modemPathChanged(path); - Q_EMIT contextsChanged(d_ptr->contexts); - } - - foreach (const QString &p, removedProperties) - updateProperty(p, QVariant()); + return privateData()->initialized && SUPER::isValid(); } -QString QOfonoConnectionManager::modemPath() const +QDBusAbstractInterface *QOfonoConnectionManager::createDbusInterface(const QString &path) { - return d_ptr->modemPath; + OfonoConnectionManager* iface = new OfonoConnectionManager("org.ofono", path, QDBusConnection::systemBus(), this); + connect(new QDBusPendingCallWatcher(iface->GetContexts(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onGetContextsFinished(QDBusPendingCallWatcher*))); + connect(iface, + SIGNAL(ContextAdded(QDBusObjectPath,QVariantMap)), + SLOT(onContextAdded(QDBusObjectPath,QVariantMap))); + connect(iface, + SIGNAL(ContextRemoved(QDBusObjectPath)), + SLOT(onContextRemoved(QDBusObjectPath))); + return iface; +} + +void QOfonoConnectionManager::dbusInterfaceDropped() +{ + QOfonoModemInterface::dbusInterfaceDropped(); + Private *d_ptr = privateData(); + d_ptr->initialized = false; + if (!d_ptr->contexts.isEmpty()) { + QStringList list = d_ptr->contexts; + d_ptr->contexts.clear(); + d_ptr->contextTypes.clear(); + for (int i=0; iconnman) - return; - d_ptr->connman->DeactivateAll(); + OfonoConnectionManager *iface = (OfonoConnectionManager*)dbusInterface(); + if (iface) { + iface->DeactivateAll(); + } } void QOfonoConnectionManager::addContext(const QString &type) { - if (!d_ptr->connman) - return; - - QStringList allowedTypes; - allowedTypes << "internet"; - allowedTypes << "mms"; - allowedTypes << "wap"; - allowedTypes << "ims"; - - if(!allowedTypes.contains(type)) { - Q_EMIT reportError("Type not allowed"); - return; - } - QDBusPendingReply reply = d_ptr->connman->AddContext(type); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(addContextFinished(QDBusPendingCallWatcher*))); + OfonoConnectionManager *iface = (OfonoConnectionManager*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->AddContext(type), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onAddContextFinished(QDBusPendingCallWatcher*))); + } } void QOfonoConnectionManager::removeContext(const QString &path) { - if (!d_ptr->connman) - return; - QDBusPendingReply<> reply = d_ptr->connman->RemoveContext(QDBusObjectPath(path)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(removeContextFinished(QDBusPendingCallWatcher*))); + OfonoConnectionManager *iface = (OfonoConnectionManager*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->RemoveContext(QDBusObjectPath(path)), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onRemoveContextFinished(QDBusPendingCallWatcher*))); + } } bool QOfonoConnectionManager::attached() const { - if (d_ptr->connman) - return d_ptr->properties["Attached"].value(); - else - return false; + return getBool("Attached"); } QString QOfonoConnectionManager::bearer() const { - if (d_ptr->connman) - return d_ptr->properties["Bearer"].value(); - else - return QString(); + return getString("Bearer"); } bool QOfonoConnectionManager::suspended() const { - if (d_ptr->connman) - return d_ptr->properties["Suspended"].value(); - else - return false; + return getBool("Suspended"); } bool QOfonoConnectionManager::roamingAllowed() const { - if (d_ptr->connman) - return d_ptr->properties["RoamingAllowed"].value(); - else - return false; + return getBool("RoamingAllowed"); } void QOfonoConnectionManager::setRoamingAllowed(bool value) { - if (roamingAllowed() == value) - return; - - QString str("RoamingAllowed"); - QDBusVariant var(value); - setOneProperty(str,var); + setProperty("RoamingAllowed", value); } bool QOfonoConnectionManager::powered() const { - if (d_ptr->connman) - return d_ptr->properties["Powered"].value(); - else - return false; + return getBool("Powered"); } void QOfonoConnectionManager::setPowered(bool value) { - if (powered() == value) - return; - - QString str("Powered"); - QDBusVariant var(value); - setOneProperty(str,var); + setProperty("Powered", value); } -void QOfonoConnectionManager::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +void QOfonoConnectionManager::propertyChanged(const QString &property, const QVariant &value) { - updateProperty(property, dbusvalue.variant()); -} - -void QOfonoConnectionManager::updateProperty(const QString &property, const QVariant &value) -{ - if (d_ptr->properties.value(property) == value) - return; - - if (value.isValid()) - d_ptr->properties.insert(property, value); - else - d_ptr->properties.remove(property); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("Attached")) { - if (value.value()) { - if (d_ptr->contextTypes.isEmpty()) { - d_ptr->getContexts(); - Q_EMIT contextsChanged(d_ptr->contexts); - } - } else { - d_ptr->contextTypes.clear(); - d_ptr->contexts.clear(); - Q_EMIT contextsChanged(d_ptr->contexts); - } Q_EMIT attachedChanged(value.value()); } else if (property == QLatin1String("Bearer")) { Q_EMIT bearerChanged(value.value()); @@ -273,33 +191,40 @@ QStringList QOfonoConnectionManager::contexts() { - return d_ptr->contexts; + return privateData()->contexts; } -void QOfonoConnectionManager::onContextAdd(const QDBusObjectPath &path, const QVariantMap &propertyMap) +void QOfonoConnectionManager::onContextAdded(const QDBusObjectPath &path, const QVariantMap &properties) { - Q_UNUSED(propertyMap); - d_ptr->contextTypes.insert(path.path(), propertyMap.value("Type").toString()); + QString contextPath(path.path()); + Private *d_ptr = privateData(); + d_ptr->contextTypes.insert(contextPath, properties.value("Type").toString()); d_ptr->filterContexts(); - Q_EMIT contextAdded(path.path()); - Q_EMIT contextsChanged(d_ptr->contexts); + if (d_ptr->contexts.contains(contextPath)) { + Q_EMIT contextAdded(contextPath); + Q_EMIT contextsChanged(d_ptr->contexts); + } } -void QOfonoConnectionManager::onContextRemove(const QDBusObjectPath &path) +void QOfonoConnectionManager::onContextRemoved(const QDBusObjectPath &path) { - d_ptr->contextTypes.remove(path.path()); - d_ptr->filterContexts(); - Q_EMIT contextRemoved(path.path()); - Q_EMIT contextsChanged(d_ptr->contexts); + Private *d_ptr = privateData(); + QString contextPath(path.path()); + d_ptr->contextTypes.remove(contextPath); + if (d_ptr->contexts.removeOne(contextPath)) { + Q_EMIT contextRemoved(contextPath); + Q_EMIT contextsChanged(d_ptr->contexts); + } } QString QOfonoConnectionManager::filter() const { - return d_ptr->filter; + return privateData()->filter; } void QOfonoConnectionManager::setFilter(const QString &filter) { + Private *d_ptr = privateData(); if (d_ptr->filter != filter) { d_ptr->filter = filter; d_ptr->filterContexts(); @@ -308,48 +233,67 @@ } } -bool QOfonoConnectionManager::isValid() const -{ - return d_ptr->connman->isValid(); -} - -void QOfonoConnectionManager::setOneProperty(const QString &prop, const QDBusVariant &var) -{ - if (d_ptr->connman) { - QDBusPendingReply <> reply = d_ptr->connman->SetProperty(prop,var); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setPropertyFinished(QDBusPendingCallWatcher*))); - } -} - -void QOfonoConnectionManager::addContextFinished(QDBusPendingCallWatcher *watch) +void QOfonoConnectionManager::onGetContextsFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); - QDBusPendingReply reply = *watch; + QDBusPendingReply reply(*watch); if (reply.isError()) { - qDebug() << Q_FUNC_INFO << reply.error(); + qDebug() << reply.error(); Q_EMIT reportError(reply.error().message()); + } else { + Private *d_ptr = privateData(); + QStringList old = d_ptr->contexts; + d_ptr->contextTypes.clear(); + foreach (ObjectPathProperties context, reply.value()) { + QString contextPath(context.path.path()); + bool contextWasThere = d_ptr->contexts.contains(contextPath); + d_ptr->contextTypes.insert(contextPath, context.properties.value("Type").toString()); + d_ptr->filterContexts(); + bool contextIsThere = d_ptr->contexts.contains(contextPath); + if (contextWasThere && !contextIsThere) { + Q_EMIT contextRemoved(contextPath); + } else if (!contextWasThere && contextIsThere) { + Q_EMIT contextAdded(contextPath); + } + } + d_ptr->initialized = true; + if (d_ptr->contexts != old) { + Q_EMIT contextsChanged(d_ptr->contexts); + } } } -void QOfonoConnectionManager::removeContextFinished(QDBusPendingCallWatcher *watch) +void QOfonoConnectionManager::onAddContextFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); - QDBusPendingReply<> reply = *watch; + QDBusPendingReply reply(*watch); if (reply.isError()) { - qDebug() << Q_FUNC_INFO << reply.error(); + qDebug() << reply.error(); Q_EMIT reportError(reply.error().message()); } } -void QOfonoConnectionManager::setPropertyFinished(QDBusPendingCallWatcher *watch) +void QOfonoConnectionManager::onRemoveContextFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); - QDBusPendingReply<> reply = *watch; + QDBusPendingReply<> reply(*watch); if (reply.isError()) { - qDebug() << Q_FUNC_INFO << reply.error(); + qDebug() << reply.error(); Q_EMIT reportError(reply.error().message()); } } +QString QOfonoConnectionManager::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoConnectionManager::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); +} + +QOfonoConnectionManager::Private *QOfonoConnectionManager::privateData() const +{ + return (QOfonoConnectionManager::Private*)SUPER::extData(); +} diff -Nru libqofono-0.53/src/qofonoconnectionmanager.h libqofono-0.70~rtm/src/qofonoconnectionmanager.h --- libqofono-0.53/src/qofonoconnectionmanager.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonoconnectionmanager.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,18 +16,15 @@ #ifndef QOFONOCONNECTIONMANAGER_H #define QOFONOCONNECTIONMANAGER_H -#include -#include "dbustypes.h" +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono connman context API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob;f=doc/connman-api.txt */ - -class QOfonoConnectionManagerPrivate; - -class QOFONOSHARED_EXPORT QOfonoConnectionManager : public QObject +class QOFONOSHARED_EXPORT QOfonoConnectionManager : public QOfonoModemInterface { Q_OBJECT Q_PROPERTY(bool attached READ attached NOTIFY attachedChanged) @@ -36,7 +33,6 @@ Q_PROPERTY(bool roamingAllowed READ roamingAllowed WRITE setRoamingAllowed NOTIFY roamingAllowedChanged) Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged) - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QStringList contexts READ contexts NOTIFY contextsChanged) Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) @@ -73,33 +69,28 @@ void contextAdded(const QString &path); void contextRemoved(const QString &path); void contextsChanged(const QStringList &contexts); - void modemPathChanged(const QString &path); void filterChanged(const QString &filter); - void messagesFinished(); - void reportError(const QString &errorMessage); - public slots: void deactivateAll(); void addContext(const QString &type); void removeContext(const QString &path); -protected slots: - void addContextFinished(QDBusPendingCallWatcher *watch); - void removeContextFinished(QDBusPendingCallWatcher *watch); - void setPropertyFinished(QDBusPendingCallWatcher *watch); -protected: - void setOneProperty(const QString &prop,const QDBusVariant &var); - private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); - void onContextAdd(const QDBusObjectPath &path, const QVariantMap &propertyMap); - void onContextRemove(const QDBusObjectPath &path); + void onAddContextFinished(QDBusPendingCallWatcher *watch); + void onRemoveContextFinished(QDBusPendingCallWatcher *watch); + void onGetContextsFinished(QDBusPendingCallWatcher *watch); + void onContextAdded(const QDBusObjectPath &path, const QVariantMap &propertyMap); + void onContextRemoved(const QDBusObjectPath &path); -private: - void updateProperty(const QString &property, const QVariant &value); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void dbusInterfaceDropped(); + void propertyChanged(const QString &property, const QVariant &value); - QOfonoConnectionManagerPrivate *d_ptr; +private: + class Private; + Private *privateData() const; }; #endif // QOFONOCONNECTIONMANAGER_H diff -Nru libqofono-0.53/src/qofonodbustypes.cpp libqofono-0.70~rtm/src/qofonodbustypes.cpp --- libqofono-0.53/src/qofonodbustypes.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonodbustypes.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#include "dbustypes.h" + +QDBusArgument &operator<<(QDBusArgument &arg, const ObjectPathProperties &props) +{ + arg.beginStructure(); + arg << props.path << props.properties; + arg.endStructure(); + return arg; +} + +const QDBusArgument &operator>>(const QDBusArgument &arg, ObjectPathProperties &props) +{ + arg.beginStructure(); + arg >> props.path >> props.properties; + arg.endStructure(); + return arg; +} + +QDBusArgument &operator<<(QDBusArgument &arg, const OfonoPathProps &props) +{ + arg.beginStructure(); + arg << props.path << props.properties; + arg.endStructure(); + return arg; +} + +const QDBusArgument &operator>>(const QDBusArgument &arg, OfonoPathProps &props) +{ + arg.beginStructure(); + arg >> props.path >> props.properties; + arg.endStructure(); + return arg; +} + +void QOfonoDbusTypes::registerObjectPathProperties() +{ + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qRegisterMetaType("ObjectPathProperties"); + qRegisterMetaType("ObjectPathPropertiesList"); + + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); +} diff -Nru libqofono-0.53/src/qofono.h libqofono-0.70~rtm/src/qofono.h --- libqofono-0.53/src/qofono.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofono.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -46,6 +46,7 @@ QOfono(); static QString mobileCountryCodeToAlpha2CountryCode(int mcc); + static void registerObjectPathPropertiesType(); }; #endif // QOFONO_H diff -Nru libqofono-0.53/src/qofonomanager.cpp libqofono-0.70~rtm/src/qofonomanager.cpp --- libqofono-0.53/src/qofonomanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -14,57 +14,26 @@ ****************************************************************************/ #include "qofonomanager.h" -#include "qofonomodem.h" #include "dbus/ofonomanager.h" -#include -#include -#include "dbustypes.h" -QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &modem) -{ - argument.beginStructure(); - argument << modem.path << modem.properties; - argument.endStructure(); - return argument; -} - -const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathProperties &modem) -{ - argument.beginStructure(); - argument >> modem.path >> modem.properties; - argument.endStructure(); - return argument; -} - - -class QOfonoManagerPrivate +class QOfonoManager::Private { public: - QOfonoManagerPrivate(); OfonoManager *ofonoManager; QStringList modems; bool available; QDBusServiceWatcher *ofonoWatcher; -}; -QOfonoManagerPrivate::QOfonoManagerPrivate() : - ofonoManager(0) -, modems(QStringList()) -, available(0) -, ofonoWatcher(0) -{ - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); - qRegisterMetaType("ObjectPathProperties"); - qRegisterMetaType("ObjectPathPropertiesList"); -} + Private() : ofonoManager(NULL), available(false), ofonoWatcher(NULL) {} +}; QOfonoManager::QOfonoManager(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoManagerPrivate) + QObject(parent), + d_ptr(new Private) { - - d_ptr->ofonoWatcher = new QDBusServiceWatcher("org.ofono",QDBusConnection::systemBus(), + QOfonoDbusTypes::registerObjectPathProperties(); + QDBusConnection systemBus(QDBusConnection::systemBus()); + d_ptr->ofonoWatcher = new QDBusServiceWatcher("org.ofono", systemBus, QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); @@ -73,8 +42,8 @@ connect(d_ptr->ofonoWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(ofonoUnregistered(QString))); - d_ptr->available = QDBusConnection::systemBus().interface()->isServiceRegistered("org.ofono"); - if(d_ptr->available) { + d_ptr->available = systemBus.interface()->isServiceRegistered("org.ofono"); + if (d_ptr->available) { connectToOfono(QString()); } } @@ -89,77 +58,119 @@ return d_ptr->modems; } -void QOfonoManager::onModemAdd(const QDBusObjectPath& path, const QVariantMap& var) +QString QOfonoManager::defaultModem() +{ + return d_ptr->modems.isEmpty() ? QString() : d_ptr->modems[0]; +} + +bool QOfonoManager::available() const +{ + return d_ptr->available; +} + +bool QOfonoManager::isValid() const +{ + return d_ptr->ofonoManager && d_ptr->ofonoManager->isValid(); +} + +void QOfonoManager::onModemAdded(const QDBusObjectPath& path, const QVariantMap&) { QString pathStr = path.path(); if (!d_ptr->modems.contains(pathStr)) { + QString prevDefault = defaultModem(); d_ptr->modems.append(pathStr); Q_EMIT modemAdded(pathStr); Q_EMIT modemsChanged(d_ptr->modems); + QString newDefault = defaultModem(); + if (newDefault != prevDefault) { + Q_EMIT defaultModemChanged(newDefault); + } } } -void QOfonoManager::onModemRemove(const QDBusObjectPath& path) +void QOfonoManager::onModemRemoved(const QDBusObjectPath& path) { QString pathStr = path.path(); - /* we need to send out modem removed signal, since we decided to turn modem off directly */ - Q_EMIT modemRemoved(pathStr); - if (d_ptr->modems.contains(pathStr)) { - d_ptr->modems.removeOne(pathStr); + QString prevDefault = defaultModem(); + if (d_ptr->modems.removeOne(pathStr)) { + Q_EMIT modemRemoved(pathStr); Q_EMIT modemsChanged(d_ptr->modems); + QString newDefault = defaultModem(); + if (newDefault != prevDefault) { + Q_EMIT defaultModemChanged(newDefault); + } } } -bool QOfonoManager::available() const +void QOfonoManager::onGetModemsFinished(QDBusPendingCallWatcher* watcher) { - return d_ptr->available; -} - -void QOfonoManager::connectToOfono(const QString &) -{ - d_ptr->ofonoManager = new OfonoManager("org.ofono","/",QDBusConnection::systemBus(),this); - if (d_ptr->ofonoManager->isValid()) { - QDBusPendingReply reply = d_ptr->ofonoManager->GetModems(); - reply.waitForFinished(); + QDBusPendingReply reply(*watcher); + if (reply.isValid() && !reply.isError()) { // fugly I know... but we need sorted modems // with hardware listed first - QOfonoModem oModem; - foreach(ObjectPathProperties modem, reply.value()) { + QString prevDefault = defaultModem(); + d_ptr->modems.clear(); + foreach (ObjectPathProperties modem, reply.value()) { QString modemPath = modem.path.path(); - oModem.setModemPath(modemPath); - if (oModem.type() == "hardware" - && !modemPath.contains("phonesim")) { - // running phonesim from desktop - // presents phonesim as hardware + QString modemType = modem.properties["Type"].value(); + if (modemType == "hardware" && !modemPath.contains("phonesim")) { + // running phonesim from desktop presents phonesim as hardware d_ptr->modems.prepend(modemPath); } else { d_ptr->modems.append(modemPath); } - Q_EMIT modemAdded(modemPath); } Q_EMIT modemsChanged(d_ptr->modems); + QString newDefault = defaultModem(); + if (newDefault != prevDefault) { + Q_EMIT defaultModemChanged(newDefault); + } } - d_ptr->available = true; - Q_EMIT availableChanged(true); - connect(d_ptr->ofonoManager, SIGNAL(ModemAdded(QDBusObjectPath,QVariantMap)), this, SLOT(onModemAdd(QDBusObjectPath,QVariantMap))); - connect(d_ptr->ofonoManager, SIGNAL(ModemRemoved(QDBusObjectPath)), this, SLOT(onModemRemove(QDBusObjectPath))); + watcher->deleteLater(); } -void QOfonoManager::ofonoUnregistered(const QString &) +void QOfonoManager::connectToOfono(const QString &) { - d_ptr->available = false; - delete d_ptr->ofonoManager; - Q_FOREACH(const QString &modem, d_ptr->modems) { - Q_EMIT modemRemoved(modem); - } - d_ptr->modems.clear(); - Q_EMIT modemsChanged(d_ptr->modems); - Q_EMIT availableChanged(false); + if (!d_ptr->available) { + d_ptr->available = true; + Q_EMIT availableChanged(true); + } + if (!d_ptr->ofonoManager) { + OfonoManager* mgr = new OfonoManager("org.ofono", "/", QDBusConnection::systemBus(), this); + if (mgr->isValid()) { + d_ptr->ofonoManager = mgr; + connect(new QDBusPendingCallWatcher(mgr->GetModems(), mgr), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onGetModemsFinished(QDBusPendingCallWatcher*))); + connect(mgr, + SIGNAL(ModemAdded(QDBusObjectPath,QVariantMap)), + SLOT(onModemAdded(QDBusObjectPath,QVariantMap))); + connect(mgr, + SIGNAL(ModemRemoved(QDBusObjectPath)), + SLOT(onModemRemoved(QDBusObjectPath))); + } else { + delete mgr; + } + } } - -bool QOfonoManager::isValid() const +void QOfonoManager::ofonoUnregistered(const QString &) { - return d_ptr->ofonoManager->isValid(); + if (d_ptr->available) { + d_ptr->available = false; + Q_EMIT availableChanged(false); + } + if (d_ptr->ofonoManager) { + delete d_ptr->ofonoManager; + d_ptr->ofonoManager = NULL; + if (!d_ptr->modems.isEmpty()) { + Q_FOREACH(QString modem, d_ptr->modems) { + Q_EMIT modemRemoved(modem); + } + d_ptr->modems.clear(); + Q_EMIT modemsChanged(d_ptr->modems); + Q_EMIT defaultModemChanged(QString()); + } + } } diff -Nru libqofono-0.53/src/qofonomanager.h libqofono-0.70~rtm/src/qofonomanager.h --- libqofono-0.53/src/qofonomanager.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomanager.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,45 +16,47 @@ #ifndef QOFONOMANAGER_H #define QOFONOMANAGER_H -#include -#include #include "dbustypes.h" - #include "qofono_global.h" + //! This class is used to access ofono connman context API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob;f=doc/manager-api.txt */ - -class QOfonoManagerPrivate; class QOFONOSHARED_EXPORT QOfonoManager : public QObject { Q_OBJECT - Q_PROPERTY(QStringList modems READ modems NOTIFY modemsChanged) + Q_PROPERTY(QString defaultModem READ defaultModem NOTIFY defaultModemChanged) Q_PROPERTY(bool available READ available NOTIFY availableChanged) + public: explicit QOfonoManager(QObject *parent = 0); ~QOfonoManager(); QStringList modems(); + QString defaultModem(); bool available() const; - bool isValid() const; + Q_SIGNALS: // SIGNALS void modemAdded(const QString &modem); void modemRemoved(const QString &modem); void availableChanged(bool available); void modemsChanged(const QStringList &modems); + void defaultModemChanged(const QString &modem); private slots: - void onModemAdd(const QDBusObjectPath &path, const QVariantMap &var); - void onModemRemove(const QDBusObjectPath &path); + void onModemAdded(const QDBusObjectPath &path, const QVariantMap &var); + void onModemRemoved(const QDBusObjectPath &path); + void onGetModemsFinished(QDBusPendingCallWatcher*); void connectToOfono(const QString &); void ofonoUnregistered(const QString &); + private: - QOfonoManagerPrivate *d_ptr; + class Private; + Private *d_ptr; }; #endif // QOFONOMANAGER_H diff -Nru libqofono-0.53/src/qofonomessage.cpp libqofono-0.70~rtm/src/qofonomessage.cpp --- libqofono-0.53/src/qofonomessage.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomessage.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,87 +16,58 @@ #include "qofonomessage.h" #include "dbus/ofonomessage.h" -class QOfonoMessagePrivate -{ -public: - QOfonoMessagePrivate(); - QString messagePath; - OfonoMessage *oMessage; - QVariantMap properties; - -}; - -QOfonoMessagePrivate::QOfonoMessagePrivate() : - messagePath(QString()) - , oMessage(0) +QOfonoMessage::QOfonoMessage(QObject *parent) : + QOfonoObject(parent) { } -QOfonoMessage::QOfonoMessage(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoMessagePrivate) +QOfonoMessage::~QOfonoMessage() { } -QOfonoMessage::~QOfonoMessage() +QString QOfonoMessage::messagePath() const { - delete d_ptr; + return objectPath(); } void QOfonoMessage::setMessagePath(const QString &path) { - if (path != messagePath()) { - if (d_ptr->oMessage) { - delete d_ptr->oMessage; - d_ptr->oMessage = 0; - d_ptr->properties.clear(); - } - d_ptr->oMessage = new OfonoMessage("org.ofono", path, QDBusConnection::systemBus(),this); - d_ptr->messagePath = path; - - if (d_ptr->oMessage) { - connect(d_ptr->oMessage,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - QDBusPendingReply reply; - reply = d_ptr->oMessage->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - Q_EMIT messagePathChanged(path); - } - } + setObjectPath(path); } -QString QOfonoMessage::messagePath() const +void QOfonoMessage::objectPathChanged(const QString &path, const QVariantMap *properties) { - return d_ptr->messagePath; + QOfonoObject::objectPathChanged(path, properties); + Q_EMIT messagePathChanged(path); } -void QOfonoMessage::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +QDBusAbstractInterface *QOfonoMessage::createDbusInterface(const QString &path) { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); + return new OfonoMessage("org.ofono", path, QDBusConnection::systemBus(), this); +} +void QOfonoMessage::propertyChanged(const QString &property, const QVariant &value) +{ + QOfonoObject::propertyChanged(property, value); if (property == QLatin1String("State")) { Q_EMIT stateChanged(value.value()); - } + } } QString QOfonoMessage::state() const { - if (d_ptr->oMessage) - return d_ptr->properties["State"].value(); - else - return QString(); + return getString("State"); } void QOfonoMessage::cancel() { - if (d_ptr->oMessage) - d_ptr->oMessage->Cancel(); + QDBusAbstractInterface *dbus = dbusInterface(); + if (dbus) { + ((OfonoMessage*)dbus)->Cancel(); + } } bool QOfonoMessage::isValid() const { - return d_ptr->oMessage->isValid(); + return QOfonoObject::isValid(); } diff -Nru libqofono-0.53/src/qofonomessage.h libqofono-0.70~rtm/src/qofonomessage.h --- libqofono-0.53/src/qofonomessage.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomessage.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,18 +16,15 @@ #ifndef QOFONOMessage_H #define QOFONOMessage_H -#include -#include - +#include "qofonoobject.h" #include "qofono_global.h" + //! This class is used to access ofono message API /*! * oFono message API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/message-api.txt */ - -class QOfonoMessagePrivate; -class QOFONOSHARED_EXPORT QOfonoMessage : public QObject +class QOFONOSHARED_EXPORT QOfonoMessage : public QOfonoObject { Q_OBJECT Q_PROPERTY(QString messagePath READ messagePath WRITE setMessagePath NOTIFY messagePathChanged) @@ -44,16 +41,15 @@ Q_INVOKABLE void cancel(); bool isValid() const; -Q_SIGNALS: +Q_SIGNALS: void stateChanged(const QString &state); void messagePathChanged(const QString &path); -public slots: - -private: - QOfonoMessagePrivate *d_ptr; -private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); + +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &key, const QVariant &value); + void objectPathChanged(const QString &path, const QVariantMap *properties); }; #endif // QOFONOMessage_H diff -Nru libqofono-0.53/src/qofonomessagemanager.cpp libqofono-0.70~rtm/src/qofonomessagemanager.cpp --- libqofono-0.53/src/qofonomessagemanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomessagemanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -13,278 +13,215 @@ ** ****************************************************************************/ -#include "dbustypes.h" #include "qofonomessagemanager.h" #include "dbus/ofonomessagemanager.h" -class QOfonoMessageManagerPrivate +#define SUPER QOfonoModemInterface + +class QOfonoMessageManager::Private : public QOfonoObject::ExtData { public: - QOfonoMessageManagerPrivate(); - QString modemPath; - OfonoMessageManager *messageManager; - QVariantMap properties; + bool initialized; QStringList messageList; - QString errorMessage; + Private() : initialized(false) {} }; -QOfonoMessageManagerPrivate::QOfonoMessageManagerPrivate() : - modemPath(QString()) - , messageManager(0) - , messageList(QStringList()) -{ -} - QOfonoMessageManager::QOfonoMessageManager(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoMessageManagerPrivate) + SUPER(OfonoMessageManager::staticInterfaceName(), new Private, parent) { + QOfonoDbusTypes::registerObjectPathProperties(); } QOfonoMessageManager::~QOfonoMessageManager() { - delete d_ptr; } -void QOfonoMessageManager::setModemPath(const QString &path) +bool QOfonoMessageManager::isValid() const { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - if (path != modemPath()) { - if (d_ptr->messageManager) { - delete d_ptr->messageManager; - d_ptr->messageManager = 0; - d_ptr->properties.clear(); - } - d_ptr->messageManager = new OfonoMessageManager("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->messageManager->isValid()) { - d_ptr->modemPath = path; - connect(d_ptr->messageManager,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - connect(d_ptr->messageManager,SIGNAL(ImmediateMessage(QString,QVariantMap)), - this,SIGNAL(immediateMessage(QString,QVariantMap))); - connect(d_ptr->messageManager,SIGNAL(IncomingMessage(QString,QVariantMap)), - this,SIGNAL(incomingMessage(QString,QVariantMap))); - connect(d_ptr->messageManager,SIGNAL(MessageAdded(QDBusObjectPath,QVariantMap)), - this,SLOT(onMessageAdded(QDBusObjectPath,QVariantMap))); - connect(d_ptr->messageManager,SIGNAL(MessageRemoved(QDBusObjectPath)), - this,SLOT(onMessageRemoved(QDBusObjectPath))); - - QDBusPendingReply reply; - reply = d_ptr->messageManager->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - - QDBusMessage request = QDBusMessage::createMethodCall("org.ofono", - path, - "org.ofono.MessageManager", - "GetMessages"); - - QDBusConnection::systemBus().callWithCallback(request, - this, - SLOT(getMessagesFinished(ObjectPathPropertiesList)), - SLOT(messagesError(QDBusError))); - } - } + return privateData()->initialized && SUPER::isValid(); } -QString QOfonoMessageManager::modemPath() const +QDBusAbstractInterface *QOfonoMessageManager::createDbusInterface(const QString &path) { - return d_ptr->modemPath; + OfonoMessageManager* iface = new OfonoMessageManager("org.ofono", path, QDBusConnection::systemBus(), this); + connect(new QDBusPendingCallWatcher(iface->GetMessages(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onGetMessagesFinished(QDBusPendingCallWatcher*))); + connect(iface, + SIGNAL(ImmediateMessage(QString,QVariantMap)), + SIGNAL(immediateMessage(QString,QVariantMap))); + connect(iface, + SIGNAL(IncomingMessage(QString,QVariantMap)), + SIGNAL(incomingMessage(QString,QVariantMap))); + connect(iface, + SIGNAL(MessageAdded(QDBusObjectPath,QVariantMap)), + SLOT(onMessageAdded(QDBusObjectPath,QVariantMap))); + connect(iface, + SIGNAL(MessageRemoved(QDBusObjectPath)), + SLOT(onMessageRemoved(QDBusObjectPath))); + return iface; +} + +void QOfonoMessageManager::dbusInterfaceDropped() +{ + SUPER::dbusInterfaceDropped(); + Private *d_ptr = privateData(); + d_ptr->initialized = false; + if (!d_ptr->messageList.isEmpty()) { + QStringList list = d_ptr->messageList; + d_ptr->messageList.clear(); + for (int i=0; iproperties.insert(property,value); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("ServiceCenterAddress")) { - Q_EMIT serviceCenterAddressChanged(value.value()); + Q_EMIT serviceCenterAddressChanged(value.toString()); } else if (property == QLatin1String("UseDeliveryReports")) { - Q_EMIT useDeliveryReportsChanged(value.value()); + Q_EMIT useDeliveryReportsChanged(value.toBool()); } else if (property == QLatin1String("Bearer")) { - Q_EMIT bearerChanged(value.value()); + Q_EMIT bearerChanged(value.toString()); } else if (property == QLatin1String("Alphabet")) { - Q_EMIT alphabetChanged(value.value()); + Q_EMIT alphabetChanged(value.toString()); } } QString QOfonoMessageManager::serviceCenterAddress() { - if (d_ptr->messageManager) - return d_ptr->properties["ServiceCenterAddress"].value(); - else - return QString(); + return getString("ServiceCenterAddress"); } void QOfonoMessageManager::setServiceCenterAddress(const QString &address) { - if (d_ptr->messageManager) { - QDBusPendingReply<> result = d_ptr->messageManager->SetProperty("ServiceCenterAddress",QDBusVariant(address)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setServiceCenterAddressFinished(QDBusPendingCallWatcher*))); - } + setProperty("ServiceCenterAddress", address); } bool QOfonoMessageManager::useDeliveryReports() { - if (d_ptr->messageManager) - return d_ptr->properties["UseDeliveryReports"].value(); - else - return false; + return getBool("UseDeliveryReports"); } void QOfonoMessageManager::setUseDeliveryReports(bool useDeliveryReports) { - if (d_ptr->messageManager) { - QDBusPendingReply<> result = d_ptr->messageManager->SetProperty("UseDeliveryReports",QDBusVariant(useDeliveryReports)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setUseDeliveryReportsFinished(QDBusPendingCallWatcher*))); - } + setProperty("UseDeliveryReports", useDeliveryReports); } QString QOfonoMessageManager::bearer() { - if (d_ptr->messageManager) - return d_ptr->properties["Bearer"].value(); - else - return QString(); + return getString("Bearer"); } void QOfonoMessageManager::setBearer(const QString &bearer) { - if (d_ptr->messageManager) { - QDBusPendingReply<> result = d_ptr->messageManager->SetProperty("Bearer",QDBusVariant(bearer)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setBearerFinished(QDBusPendingCallWatcher*))); - } + setProperty("Bearer", bearer); } QString QOfonoMessageManager::alphabet() { - if (d_ptr->messageManager) - return d_ptr->properties["Alphabet"].value(); - else - return QString(); + return getString("Alphabet"); } void QOfonoMessageManager::setAlphabet(const QString &alphabet) { - if (d_ptr->messageManager) { - QDBusPendingReply<> result = d_ptr->messageManager->SetProperty("Alphabet",QDBusVariant(alphabet)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setAlphabetFinished(QDBusPendingCallWatcher*))); - } + setProperty("Alphabet", alphabet); } void QOfonoMessageManager::sendMessage(const QString &numberTo, const QString &message) { - if (d_ptr->messageManager) { - QDBusPendingReply result = d_ptr->messageManager->SendMessage(numberTo,message); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(sendMessageFinished(QDBusPendingCallWatcher*))); + OfonoMessageManager *iface = (OfonoMessageManager*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher(iface->SendMessage(numberTo, message), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onSendMessageFinished(QDBusPendingCallWatcher*))); } } QStringList QOfonoMessageManager::messages() { - if (d_ptr->messageManager) - return d_ptr->messageList; - return QStringList(); + return privateData()->messageList; } - -void QOfonoMessageManager::onMessageAdded(const QDBusObjectPath &path, - const QVariantMap &properties) +void QOfonoMessageManager::onMessageAdded(const QDBusObjectPath &path, const QVariantMap &) { - Q_UNUSED(properties); - - if (d_ptr->messageManager) { - if (!d_ptr->messageList.contains(path.path())) { - d_ptr->messageList.append(path.path()); - Q_EMIT messageAdded(path.path()); - } - } + addMessage(path.path()); } void QOfonoMessageManager::onMessageRemoved(const QDBusObjectPath &path) { - if (d_ptr->messageManager) { - if (d_ptr->messageList.contains(path.path())) { - d_ptr->messageList.removeOne(path.path()); - Q_EMIT messageRemoved(path.path()); - } + QString messagePath = path.path(); + if (privateData()->messageList.removeOne(messagePath)) { + Q_EMIT messageRemoved(messagePath); } } -bool QOfonoMessageManager::isValid() const -{ - return d_ptr->messageManager->isValid(); -} - -void QOfonoMessageManager::getMessagesFinished(const ObjectPathPropertiesList &list) +void QOfonoMessageManager::onGetMessagesFinished(QDBusPendingCallWatcher *watch) { - qDebug() << Q_FUNC_INFO << list.count(); -// messages = reply2.value(); - foreach(ObjectPathProperties message, list) { - d_ptr->messageList << message.path.path(); - Q_EMIT messageAdded(message.path.path()); + watch->deleteLater(); + QDBusPendingReply reply(*watch); + if (reply.isError()) { + qDebug() << reply.error(); + Q_EMIT reportError(reply.error().message()); + } else { + ObjectPathPropertiesList list = reply.value(); + privateData()->initialized = true; + for (int i=0; imessageList.contains(messagePath)) { + d_ptr->messageList.append(messagePath); + Q_EMIT messageAdded(messagePath); + } } -void QOfonoMessageManager::sendMessageFinished(QDBusPendingCallWatcher *call) +void QOfonoMessageManager::onSendMessageFinished(QDBusPendingCallWatcher *watch) { - call->deleteLater(); - QDBusPendingReply reply = *call; - bool ok = true; + watch->deleteLater(); + QDBusPendingReply reply = *watch; if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; + qWarning() << reply.error(); + Q_EMIT sendMessageComplete(false, QString()); + } else { + Q_EMIT sendMessageComplete(true, reply.value().path()); } - Q_EMIT sendMessageComplete(ok, reply.value().path()); } -void QOfonoMessageManager::setServiceCenterAddressFinished(QDBusPendingCallWatcher *call) -{ - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT setServiceCenterAddressComplete(!reply.isError()); +void QOfonoMessageManager::setPropertyFinished(const QString &property, const QDBusError *error) +{ + SUPER::setPropertyFinished(property, error); + if (property == "ServiceCenterAddress") { + Q_EMIT setServiceCenterAddressComplete(!error); + } else if (property == "UseDeliveryReports") { + Q_EMIT setUseDeliveryReportsComplete(!error); + } else if (property == "Bearer") { + Q_EMIT setBearerComplete(!error); + } else if (property == "Alphabet") { + Q_EMIT setAlphabetComplete(!error); + } } -void QOfonoMessageManager::setUseDeliveryReportsFinished(QDBusPendingCallWatcher *call) +QString QOfonoMessageManager::modemPath() const { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT setUseDeliveryReportsComplete(!reply.isError()); + return SUPER::modemPath(); } -void QOfonoMessageManager::setBearerFinished(QDBusPendingCallWatcher *call) +void QOfonoMessageManager::setModemPath(const QString &path) { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT setBearerComplete(!reply.isError()); + SUPER::setModemPath(path); } -void QOfonoMessageManager::setAlphabetFinished(QDBusPendingCallWatcher *call) +QOfonoMessageManager::Private *QOfonoMessageManager::privateData() const { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT setAlphabetComplete(!reply.isError()); + return (QOfonoMessageManager::Private*)SUPER::extData(); } - diff -Nru libqofono-0.53/src/qofonomessagemanager.h libqofono-0.70~rtm/src/qofonomessagemanager.h --- libqofono-0.53/src/qofonomessagemanager.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomessagemanager.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,21 +16,17 @@ #ifndef QOFONOMessageManager_H #define QOFONOMessageManager_H -#include -#include -#include +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono message manager API /*! * oFono message manager API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/messagemanager-api.txt */ - -class QOfonoMessageManagerPrivate; -class QOFONOSHARED_EXPORT QOfonoMessageManager : public QObject +class QOFONOSHARED_EXPORT QOfonoMessageManager : public QOfonoModemInterface { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QString serviceCenterAddress READ serviceCenterAddress WRITE setServiceCenterAddress NOTIFY serviceCenterAddressChanged) Q_PROPERTY(bool useDeliveryReports READ useDeliveryReports WRITE setUseDeliveryReports NOTIFY useDeliveryReportsChanged) Q_PROPERTY(QString bearer READ bearer WRITE setBearer NOTIFY bearerChanged) @@ -59,6 +55,7 @@ Q_INVOKABLE QStringList messages(); bool isValid() const; + Q_SIGNALS: void serviceCenterAddressChanged(const QString &address); void useDeliveryReportsChanged(const bool &useDeliveryReports); @@ -70,7 +67,6 @@ void messageAdded(const QString &message); void messageRemoved(const QString &message); - void modemPathChanged(const QString &path); void messagesFinished(); @@ -80,21 +76,24 @@ void setBearerComplete(bool success); void setAlphabetComplete(bool success); -private: - QOfonoMessageManagerPrivate *d_ptr; private slots: void onMessageAdded(const QDBusObjectPath &path, const QVariantMap &properties); void onMessageRemoved(const QDBusObjectPath &path); + void onGetMessagesFinished(QDBusPendingCallWatcher *watch); + void onSendMessageFinished(QDBusPendingCallWatcher *watch); - void propertyChanged(const QString &property,const QDBusVariant &value); - void getMessagesFinished(const ObjectPathPropertiesList &list); - void messagesError(const QDBusError &error); - - void sendMessageFinished(QDBusPendingCallWatcher *call); - void setServiceCenterAddressFinished(QDBusPendingCallWatcher*); - void setUseDeliveryReportsFinished(QDBusPendingCallWatcher*); - void setBearerFinished(QDBusPendingCallWatcher*); - void setAlphabetFinished(QDBusPendingCallWatcher*); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void dbusInterfaceDropped(); + void propertyChanged(const QString &property, const QVariant &value); + void setPropertyFinished(const QString &property, const QDBusError *error); + +private: + void addMessage(const QString &messagePath); + +private: + class Private; + Private* privateData() const; }; #endif // QOFONOMessageManager_H diff -Nru libqofono-0.53/src/qofonomessagewaiting.cpp libqofono-0.70~rtm/src/qofonomessagewaiting.cpp --- libqofono-0.53/src/qofonomessagewaiting.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomessagewaiting.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -15,174 +15,92 @@ #include "qofonomessagewaiting.h" #include "dbus/ofonomessagewaiting.h" -#include "qofonomodem.h" -#include "qofonoutils_p.h" -class QOfonoMessageWaitingPrivate -{ -public: - QOfonoMessageWaitingPrivate(); - QString modemPath; - OfonoMessageWaiting *messageWaiting; - QVariantMap properties; - QSharedPointer modem; -}; - -QOfonoMessageWaitingPrivate::QOfonoMessageWaitingPrivate() : - modemPath(QString()) - , messageWaiting(0) -{ -} +#define SUPER QOfonoModemInterface QOfonoMessageWaiting::QOfonoMessageWaiting(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoMessageWaitingPrivate) + SUPER(OfonoMessageWaiting::staticInterfaceName(), parent) { } QOfonoMessageWaiting::~QOfonoMessageWaiting() { - delete d_ptr; -} - -void QOfonoMessageWaiting::setModemPath(const QString &path) -{ - if (path == d_ptr->modemPath || path.isEmpty()) - return; - - if (!d_ptr->modem.isNull()) - disconnect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - - d_ptr->modemPath = path; - connectOfono(); - - d_ptr->modem = QOfonoModem::instance(path); - connect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - - Q_EMIT modemPathChanged(path); -} - -QString QOfonoMessageWaiting::modemPath() const -{ - return d_ptr->modemPath; } -void QOfonoMessageWaiting::modemInterfacesChanged(const QStringList &interfaces) +QDBusAbstractInterface *QOfonoMessageWaiting::createDbusInterface(const QString &path) { - bool haveIface = interfaces.contains("org.ofono.MessageWaiting"); - if (haveIface != (isValid() && isReady())) - connectOfono(); + return new OfonoMessageWaiting("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoMessageWaiting::connectOfono() { - bool wasReady = isReady(); - // FIXME: Clearing properties here results in false *Changed signal - // emissions. Ideally ready() should not be derived from - // properties.isEmpty(). Also compare with QOfonoSimManager. - if (d_ptr->messageWaiting) { - delete d_ptr->messageWaiting; - d_ptr->messageWaiting = 0; - d_ptr->properties.clear(); - } - - d_ptr->messageWaiting = new OfonoMessageWaiting("org.ofono", d_ptr->modemPath, QDBusConnection::systemBus(),this); - - if (d_ptr->messageWaiting->isValid()) { - connect(d_ptr->messageWaiting,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - QDBusPendingReply reply; - reply = d_ptr->messageWaiting->GetProperties(); - reply.waitForFinished(); - if (reply.isError()) { - Q_EMIT getPropertiesFailed(); - } else { - QVariantMap properties = reply.value(); - for (QVariantMap::ConstIterator it = properties.constBegin(); - it != properties.constEnd(); ++it) { - updateProperty(it.key(), it.value()); - } - } - } - - if (wasReady != isReady()) - Q_EMIT readyChanged(); + resetDbusInterface(); } -void QOfonoMessageWaiting::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +void QOfonoMessageWaiting::propertyChanged(const QString &property, const QVariant &value) { - updateProperty(property, dbusvalue.variant()); -} - -void QOfonoMessageWaiting::updateProperty(const QString& property, const QVariant& value) -{ - QVariant old = d_ptr->properties.value(property); - - d_ptr->properties.insert(property,value); - - if (qofono::safeVariantEq(old, value)) - return; - + SUPER::propertyChanged(property, value); if (property == QLatin1String("VoicemailWaiting")) { - Q_EMIT voicemailWaitingChanged(value.value()); + Q_EMIT voicemailWaitingChanged(value.toBool()); } else if (property == QLatin1String("VoicemailMessageCount")) { - Q_EMIT voicemailMessageCountChanged(value.value()); + Q_EMIT voicemailMessageCountChanged(value.toInt()); } else if (property == QLatin1String("VoicemailMailboxNumber")) { - Q_EMIT voicemailMailboxNumberChanged(value.value()); + Q_EMIT voicemailMailboxNumberChanged(value.toString()); } } - bool QOfonoMessageWaiting::voicemailWaiting() const { - if ( d_ptr->messageWaiting) - return d_ptr->properties.value("VoicemailWaiting").value(); - else - return false; + return getBool("VoicemailWaiting"); } int QOfonoMessageWaiting::voicemailMessageCount() const { - if ( d_ptr->messageWaiting) - return d_ptr->properties.value("VoicemailMessageCount").value(); - else - return false; + return getInt("VoicemailMessageCount"); } QString QOfonoMessageWaiting::voicemailMailboxNumber() const { - if (d_ptr->messageWaiting) - return d_ptr->properties.value("VoicemailMailboxNumber").value(); - else - return QString(); + return getString("VoicemailMailboxNumber"); } void QOfonoMessageWaiting::setVoicemailMailboxNumber(const QString &mailboxnumber) { - if (d_ptr->messageWaiting) { - QDBusPendingReply<> reply = d_ptr->messageWaiting->SetProperty(QLatin1String("VoicemailMailboxNumber"),QDBusVariant(mailboxnumber)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setVoicemailMailboxNumberComplete(QDBusPendingCallWatcher*))); + setProperty("VoicemailMailboxNumber", mailboxnumber); +} + +void QOfonoMessageWaiting::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) +{ + SUPER::getPropertiesFinished(properties, error); + if (error) { + Q_EMIT getPropertiesFailed(); } } -bool QOfonoMessageWaiting::isValid() const +void QOfonoMessageWaiting::setPropertyFinished(const QString &property, const QDBusError *error) { - return d_ptr->messageWaiting && d_ptr->messageWaiting->isValid(); + SUPER::setPropertyFinished(property, error); + if (property == "VoicemailMailboxNumber") { + Q_EMIT voicemailMailboxComplete(!error); + } } -bool QOfonoMessageWaiting::isReady() const +QString QOfonoMessageWaiting::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoMessageWaiting::setModemPath(const QString &path) { - return !d_ptr->properties.isEmpty(); + SUPER::setModemPath(path); } -void QOfonoMessageWaiting::setVoicemailMailboxNumberComplete(QDBusPendingCallWatcher *call) +bool QOfonoMessageWaiting::isValid() const +{ + return SUPER::isValid(); +} + +bool QOfonoMessageWaiting::isReady() const { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - Q_EMIT voicemailMailboxComplete(!reply.isError()); + return SUPER::isReady(); } diff -Nru libqofono-0.53/src/qofonomessagewaiting.h libqofono-0.70~rtm/src/qofonomessagewaiting.h --- libqofono-0.53/src/qofonomessagewaiting.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomessagewaiting.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,24 +16,19 @@ #ifndef QOFONOMessageWaiting_H #define QOFONOMessageWaiting_H -#include -#include +#include "qofonomodeminterface.h" #include "qofono_global.h" -//! This class is used to access ofono message waiting API + /*! * oFono message manager API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/message-waiting-api.txt */ - -class QOfonoMessageWaitingPrivate; -class QOFONOSHARED_EXPORT QOfonoMessageWaiting : public QObject +class QOFONOSHARED_EXPORT QOfonoMessageWaiting : public QOfonoModemInterface { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(bool voicemailWaiting READ voicemailWaiting NOTIFY voicemailWaitingChanged) Q_PROPERTY(int voicemailMessageCount READ voicemailMessageCount NOTIFY voicemailMessageCountChanged) Q_PROPERTY(QString voicemailMailboxNumber READ voicemailMailboxNumber WRITE setVoicemailMailboxNumber NOTIFY voicemailMailboxNumberChanged) - Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) public: explicit QOfonoMessageWaiting(QObject *parent = 0); @@ -56,22 +51,15 @@ void voicemailWaitingChanged(bool waiting); void voicemailMessageCountChanged(int count); void voicemailMailboxNumberChanged(const QString &mailboxnumber); - void modemPathChanged(const QString &path); void voicemailMailboxComplete(bool success); void getPropertiesFailed(); - void readyChanged(); - -private: - QOfonoMessageWaitingPrivate *d_ptr; - -private slots: - void modemInterfacesChanged(const QStringList &interfaces); - void propertyChanged(const QString &property,const QDBusVariant &value); - void setVoicemailMailboxNumberComplete(QDBusPendingCallWatcher*); -private: - void updateProperty(const QString& property, const QVariant& value); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void getPropertiesFinished(const QVariantMap &properties, const QDBusError *error); + void setPropertyFinished(const QString &property, const QDBusError *error); + void propertyChanged(const QString &key, const QVariant &value); }; #endif // QOFONOMessageWaiting_H diff -Nru libqofono-0.53/src/qofonomodem.cpp libqofono-0.70~rtm/src/qofonomodem.cpp --- libqofono-0.53/src/qofonomodem.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomodem.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -23,222 +23,141 @@ typedef QMap > ModemMap; Q_GLOBAL_STATIC(ModemMap, modemMap) -class QOfonoModemPrivate -{ -public: - QOfonoModemPrivate(); - QString modemPath; - OfonoModem *modem; - QVariantMap properties; -}; - -QOfonoModemPrivate::QOfonoModemPrivate() : - modemPath(QString()) - , modem(0) -{ -} +#define SUPER QOfonoObject QOfonoModem::QOfonoModem(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoModemPrivate) + SUPER(parent) { } QOfonoModem::~QOfonoModem() { - delete d_ptr; } -void QOfonoModem::setModemPath(const QString &path) +QDBusAbstractInterface *QOfonoModem::createDbusInterface(const QString &path) { - if (path != modemPath()) { - d_ptr->modemPath = path; - connectOfono(); - Q_EMIT modemPathChanged(path); - } + return new OfonoModem("org.ofono", path, QDBusConnection::systemBus(), this); } -QString QOfonoModem::modemPath() const +void QOfonoModem::objectPathChanged(const QString &path, const QVariantMap *properties) { - return d_ptr->modemPath; + SUPER::objectPathChanged(path, properties); + Q_EMIT modemPathChanged(path); } -void QOfonoModem::connectOfono() +void QOfonoModem::setModemPath(const QString &path) { - bool wasValid = isValid(); - if (d_ptr->modem) { - delete d_ptr->modem; - d_ptr->modem = 0; - d_ptr->properties.clear(); - } - - d_ptr->modem = new OfonoModem("org.ofono", d_ptr->modemPath, QDBusConnection::systemBus(),this); - - if (d_ptr->modem->isValid()) { - connect(d_ptr->modem,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - QDBusPendingReply reply; - reply = d_ptr->modem->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - } + setObjectPath(path); +} - if (wasValid != isValid()) - Q_EMIT validChanged(isValid()); +QString QOfonoModem::modemPath() const +{ + return objectPath(); } bool QOfonoModem::powered() const { - if (d_ptr->modem) { - return d_ptr->properties["Powered"].value(); - } - return false; + return getBool("Powered"); } bool QOfonoModem::online() const { - if (d_ptr->modem) { - return d_ptr->properties["Online"].value(); - } - return false; + return getBool("Online"); } bool QOfonoModem::lockdown() const { - if (d_ptr->modem) { - return d_ptr->properties["Lockdown"].value(); - } - return false; + return getBool("Lockdown"); } bool QOfonoModem::emergency() const { - if (d_ptr->modem) { - return d_ptr->properties["Emergency"].value(); - } - return false; + return getBool("Emergency"); } QString QOfonoModem::name() const { - if (d_ptr->modem) { - return d_ptr->properties["Name"].value(); - } - return QString(); + return getString("Name"); } QString QOfonoModem::manufacturer() const { - if (d_ptr->modem) { - return d_ptr->properties["Manufacturer"].value(); - } - return QString(); + return getString("Manufacturer"); } QString QOfonoModem::model() const { - if (d_ptr->modem) { - return d_ptr->properties["Model"].value(); - } - return QString(); + return getString("Model"); } QString QOfonoModem::revision() const { - if (d_ptr->modem) { - return d_ptr->properties["Revision"].value(); - } - return QString(); + return getString("Revision"); } QString QOfonoModem::serial() const { - if (d_ptr->modem) { - return d_ptr->properties["Serial"].value(); - } - return QString(); + return getString("Serial"); } QString QOfonoModem::type() const { - if (d_ptr->modem) { - return d_ptr->properties["Type"].value(); - } - return QString(); + return getString("Type"); } QStringList QOfonoModem::features() const { - if (d_ptr->modem) { - return d_ptr->properties["Features"].value(); - } - return QStringList(); + return getStringList("Features"); } QStringList QOfonoModem::interfaces() const { - if (d_ptr->modem) { - return d_ptr->properties["Interfaces"].value(); - } - return QStringList(); + return getStringList("Interfaces"); } void QOfonoModem::setPowered(bool powered) { - QString str("Powered"); - QDBusVariant var(powered); - setOneProperty(str,var); + setProperty("Powered", powered); } void QOfonoModem::setOnline(bool online) { - QString str("Online"); - QDBusVariant var(online); - setOneProperty(str,var); + setProperty("Online", online); } void QOfonoModem::setLockdown(bool lockdown) { - QString str = "Lockdown"; - QDBusVariant var(lockdown); - setOneProperty(str,var); + setProperty("Lockdown", lockdown); } -void QOfonoModem::propertyChanged(const QString& property, const QDBusVariant& dbusValue) +void QOfonoModem::propertyChanged(const QString &property, const QVariant &value) { - QVariant value = dbusValue.variant(); - d_ptr->properties.insert(property,value); - if (property == QLatin1String("Online")) + SUPER::propertyChanged(property, value); + if (property == QLatin1String("Online")) { Q_EMIT onlineChanged(value.value()); - else if (property == QLatin1String("Powered")) + } else if (property == QLatin1String("Powered")) { Q_EMIT poweredChanged(value.value()); - else if (property == QLatin1String("Lockdown")) + } else if (property == QLatin1String("Lockdown")) { Q_EMIT lockdownChanged(value.value()); - else if (property == QLatin1String("Emergency")) + } else if (property == QLatin1String("Emergency")) { Q_EMIT emergencyChanged(value.value()); - else if (property == QLatin1String("Name")) + } else if (property == QLatin1String("Name")) { Q_EMIT nameChanged(value.value()); - else if (property == QLatin1String("Manufacturer")) + } else if (property == QLatin1String("Manufacturer")) { Q_EMIT manufacturerChanged(value.value()); - else if (property == QLatin1String("Model")) + } else if (property == QLatin1String("Model")) { Q_EMIT modelChanged(value.value()); - else if (property == QLatin1String("Revision")) + } else if (property == QLatin1String("Revision")) { Q_EMIT revisionChanged(value.value()); - else if (property == QLatin1String("Serial")) + } else if (property == QLatin1String("Serial")) { Q_EMIT serialChanged(value.value()); - else if (property == QLatin1String("Type")) + } else if (property == QLatin1String("Type")) { Q_EMIT typeChanged(value.value()); - else if (property == QLatin1String("Features")) + } else if (property == QLatin1String("Features")) { Q_EMIT featuresChanged(value.value()); - else if (property == QLatin1String("Interfaces")) + } else if (property == QLatin1String("Interfaces")) { Q_EMIT interfacesChanged(value.value()); - -} - -bool QOfonoModem::isValid() const -{ - return d_ptr->modem && d_ptr->modem->isValid(); + } } QSharedPointer QOfonoModem::instance(const QString &modemPath) @@ -249,29 +168,12 @@ modem->setModemPath(modemPath); modemMap()->insert(modemPath, QWeakPointer(modem)); } else if (!modem->isValid()) { - modem->connectOfono(); + modem->resetDbusInterface(); } - return modem; } -void QOfonoModem::setOneProperty(const QString &prop, const QDBusVariant &var) -{ - if (d_ptr->modem) { - QDBusPendingReply <> reply = d_ptr->modem->SetProperty(prop,var); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(setPropertyFinished(QDBusPendingCallWatcher*))); - } -} - -void QOfonoModem::setPropertyFinished(QDBusPendingCallWatcher *watch) +bool QOfonoModem::isValid() const { - watch->deleteLater(); - QDBusPendingReply<> reply = *watch; - if(reply.isError()) { - qDebug() << Q_FUNC_INFO << reply.error().message(); - Q_EMIT reportError(reply.error().message()); - } + return SUPER::isValid(); } - diff -Nru libqofono-0.53/src/qofonomodem.h libqofono-0.70~rtm/src/qofonomodem.h --- libqofono-0.53/src/qofonomodem.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomodem.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,20 +16,15 @@ #ifndef QOFONOMODEM_H #define QOFONOMODEM_H -#include -#include -#include "dbustypes.h" - +#include "qofonoobject.h" #include "qofono_global.h" + //! This class is used to access an oFono modem object and its properties /*! * oFono modem properties are documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/modem-api.txt */ - -class QOfonoModemPrivate; - -class QOFONOSHARED_EXPORT QOfonoModem : public QObject +class QOFONOSHARED_EXPORT QOfonoModem : public QOfonoObject { Q_OBJECT @@ -49,7 +44,6 @@ Q_PROPERTY(QStringList interfaces READ interfaces NOTIFY interfacesChanged) Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) - Q_PROPERTY(QString valid READ isValid NOTIFY validChanged) public: explicit QOfonoModem(QObject *parent = 0); @@ -95,24 +89,14 @@ void revisionChanged(const QString &revision); void serialChanged(const QString &serial); void typeChanged(const QString &type); - void featuresChanged(const QStringList &features); void interfacesChanged(const QStringList &interfaces); void modemPathChanged(const QString &path); - void reportError(const QString &errorMessage); - void validChanged(bool); protected: - void setOneProperty(const QString &prop,const QDBusVariant &var); -protected slots: - void setPropertyFinished(QDBusPendingCallWatcher *watch); - -private slots: - void connectOfono(); - void propertyChanged(const QString &property,const QDBusVariant &value); - -private: - QOfonoModemPrivate *d_ptr; + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &key, const QVariant &value); + void objectPathChanged(const QString &path, const QVariantMap *properties); }; #endif // QOFONOMODEM_H diff -Nru libqofono-0.53/src/qofonomodeminterface2.cpp libqofono-0.70~rtm/src/qofonomodeminterface2.cpp --- libqofono-0.53/src/qofonomodeminterface2.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomodeminterface2.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#include "qofonomodeminterface2.h" +#include "qofonomodem.h" + +class QOfonoModemInterface2::Private +{ +public: + QString modemPath; + QString interfaceName; + QSharedPointer modem; + QDBusAbstractInterface *interface; + QOfonoModemInterface2::ExtData *ext; + + Private(const QString &iname, QOfonoModemInterface2::ExtData *data) : + interfaceName(iname), interface(NULL), ext(data) {} + ~Private() { delete ext; } +}; + +QOfonoModemInterface2::ExtData::~ExtData() +{ +} + +QOfonoModemInterface2::QOfonoModemInterface2(const QString &iname, ExtData *ext, QObject *parent) : + QObject(parent), + d_ptr(new Private(iname, ext)) +{ +} + +QOfonoModemInterface2::QOfonoModemInterface2(const QString &iname, QObject *parent) : + QObject(parent), + d_ptr(new Private(iname, NULL)) +{ +} + +QOfonoModemInterface2::~QOfonoModemInterface2() +{ + delete d_ptr; +} + +QOfonoModemInterface2::ExtData* QOfonoModemInterface2::extData() const +{ + return d_ptr->ext; +} + +QString QOfonoModemInterface2::modemPath() const +{ + return d_ptr->modemPath; +} + +void QOfonoModemInterface2::setModemPath(const QString &path) +{ + if (d_ptr->modemPath != path) { + bool wasValid = isValid(); + d_ptr->modemPath = path; + + if (!d_ptr->modem.isNull()) { + disconnect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), + this, SLOT(onModemInterfacesChanged(QStringList))); + d_ptr->modem.reset(); + } + if (d_ptr->interface) { + delete d_ptr->interface; + d_ptr->interface = NULL; + dbusInterfaceDropped(); + } + + d_ptr->modem = QOfonoModem::instance(d_ptr->modemPath); + connect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), + this, SLOT(onModemInterfacesChanged(QStringList))); + + QStringList interfaces = d_ptr->modem->interfaces(); + if (interfaces.contains(d_ptr->interfaceName)) { + d_ptr->interface = createDbusInterface(d_ptr->modemPath); + } + + Q_EMIT modemPathChanged(d_ptr->modemPath); + + bool valid = isValid(); + if (valid != wasValid) { + Q_EMIT validChanged(valid); + } + } +} + +void QOfonoModemInterface2::dbusInterfaceDropped() +{ +} + +void QOfonoModemInterface2::onModemInterfacesChanged(const QStringList &interfaces) +{ + bool wasValid = isValid(); + if (interfaces.contains(d_ptr->interfaceName)) { + if (!d_ptr->interface) { + d_ptr->interface = createDbusInterface(d_ptr->modemPath); + } + } else if (d_ptr->interface) { + delete d_ptr->interface; + d_ptr->interface = NULL; + dbusInterfaceDropped(); + } + bool valid = isValid(); + if (valid != wasValid) { + Q_EMIT validChanged(valid); + } +} + +bool QOfonoModemInterface2::isValid() const +{ + return d_ptr->interface && d_ptr->interface->isValid(); +} + +QDBusAbstractInterface *QOfonoModemInterface2::dbusInterface() const +{ + return d_ptr->interface; +} diff -Nru libqofono-0.53/src/qofonomodeminterface2.h libqofono-0.70~rtm/src/qofonomodeminterface2.h --- libqofono-0.53/src/qofonomodeminterface2.h 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomodeminterface2.h 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#ifndef QOFONOMODEMINTERFACE2_H +#define QOFONOMODEMINTERFACE2_H + +#include "dbustypes.h" + +/** + * Modem interface without properties. + */ +class QOfonoModemInterface2 : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) + Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) + +public: + class ExtData { + public: + virtual ~ExtData(); + }; + +protected: + QOfonoModemInterface2(const QString &iface, ExtData *ext, QObject *parent = NULL); + QOfonoModemInterface2(const QString &iface, QObject *parent = NULL); + ~QOfonoModemInterface2(); + + ExtData* extData() const; + + QString modemPath() const; + void setModemPath(const QString &path); + + bool isValid() const; + +Q_SIGNALS: + void modemPathChanged(const QString &path); + void validChanged(bool valid); + +protected: + virtual QDBusAbstractInterface *createDbusInterface(const QString &path) = 0; + virtual void dbusInterfaceDropped(); + QDBusAbstractInterface *dbusInterface() const; + +private slots: + void onModemInterfacesChanged(const QStringList &interfaces); + +private: + class Private; + Private* d_ptr; +}; + +#endif // QOFONOMODEMINTERFACE2_H diff -Nru libqofono-0.53/src/qofonomodeminterface.cpp libqofono-0.70~rtm/src/qofonomodeminterface.cpp --- libqofono-0.53/src/qofonomodeminterface.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomodeminterface.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,130 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#include "qofonomodeminterface.h" +#include "qofonomodem.h" + +#define SUPER QOfonoObject + +class QOfonoModemInterface::Private : public QOfonoObject::ExtData +{ +public: + QString interfaceName; + QSharedPointer modem; + QOfonoModem::ExtData *ext; + + Private(const QString &iface, QOfonoModem::ExtData *data) : + interfaceName(iface), ext(data) {} + ~Private() { delete ext; } +}; + +QOfonoModemInterface::QOfonoModemInterface(const QString &iface, ExtData *ext, QObject *parent) : + SUPER(new Private(iface, ext), parent) +{ +} + +QOfonoModemInterface::QOfonoModemInterface(const QString &iface, QObject *parent) : + SUPER(new Private(iface, NULL), parent) +{ +} + +QOfonoModemInterface::~QOfonoModemInterface() +{ +} + +QOfonoModemInterface::Private* QOfonoModemInterface::privateData() const +{ + return (Private*)SUPER::extData(); +} + +QOfonoObject::ExtData* QOfonoModemInterface::extData() const +{ + return privateData()->ext; +} + +QString QOfonoModemInterface::modemPath() const +{ + return objectPath(); +} + +void QOfonoModemInterface::setModemPath(const QString &path) +{ + setObjectPath(path); +} + +void QOfonoModemInterface::objectPathChanged(const QString &path, const QVariantMap *) +{ + // The base implementation would immediately create the D-Bus interface + // object. However we need to check if our interface is actually available + // and postpone creation of the D-Bus interface object if our interface + // isn't there (see onModemInterfacesChanged below) + bool wasReady = isReady(); + + Private *d_ptr = privateData(); + if (!d_ptr->modem.isNull()) { + disconnect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), + this, SLOT(onModemInterfacesChanged(QStringList))); + d_ptr->modem.reset(); + } + + setDbusInterface(NULL, NULL); + + d_ptr->modem = QOfonoModem::instance(objectPath()); + connect(d_ptr->modem.data(), SIGNAL(interfacesChanged(QStringList)), + this, SLOT(onModemInterfacesChanged(QStringList))); + + Q_EMIT modemPathChanged(path); + onModemInterfacesChanged(d_ptr->modem->interfaces()); + if (wasReady != isReady()) { + Q_EMIT readyChanged(); + } +} + +void QOfonoModemInterface::onModemInterfacesChanged(const QStringList &interfaces) +{ + if (interfaces.contains(privateData()->interfaceName)) { + Q_ASSERT(!objectPath().isEmpty()); + if (!dbusInterface()) { + setDbusInterface(createDbusInterface(objectPath()), NULL); + } + } else { + setDbusInterface(NULL, NULL); + } +} + +// The usefullness if the 'ready' property is questionable but it has to exist +// for backward compatibility. +bool QOfonoModemInterface::isReady() const +{ + return isValid() && !getProperties().isEmpty(); +} + +void QOfonoModemInterface::updateProperty(const QString &key, const QVariant &value) +{ + bool wasReady = isReady(); + SUPER::updateProperty(key, value); + if (wasReady != isReady()) { + Q_EMIT readyChanged(); + } +} + +void QOfonoModemInterface::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) +{ + bool wasReady = isReady(); + SUPER::getPropertiesFinished(properties, error); + if (wasReady != isReady()) { + Q_EMIT readyChanged(); + } +} diff -Nru libqofono-0.53/src/qofonomodeminterface.h libqofono-0.70~rtm/src/qofonomodeminterface.h --- libqofono-0.53/src/qofonomodeminterface.h 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonomodeminterface.h 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#ifndef QOFONOMODEMINTERFACE_H +#define QOFONOMODEMINTERFACE_H + +#include "qofonoobject.h" + +/** + * Modem interface with properties. + */ +class QOfonoModemInterface : public QOfonoObject +{ + Q_OBJECT + Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) + Q_PROPERTY(bool ready READ isReady NOTIFY readyChanged) + +protected: + QOfonoModemInterface(const QString &iface, ExtData *ext, QObject *parent = NULL); + QOfonoModemInterface(const QString &iface, QObject *parent = NULL); + ~QOfonoModemInterface(); + + virtual ExtData* extData() const; + + QString modemPath() const; + void setModemPath(const QString &path); + + bool isReady() const; + +Q_SIGNALS: + void modemPathChanged(const QString &path); + void readyChanged(/* No parameter for historical reasons */); + +protected: + void getPropertiesFinished(const QVariantMap &properties, const QDBusError *error); + void updateProperty(const QString &key, const QVariant &value); + void objectPathChanged(const QString &path, const QVariantMap *properties); + +private slots: + void onModemInterfacesChanged(const QStringList &interfaces); + +private: + class Private; + Private* privateData() const; +}; + +#endif // QOFONOMODEMINTERFACE_H diff -Nru libqofono-0.53/src/qofononetworkoperator.cpp libqofono-0.70~rtm/src/qofononetworkoperator.cpp --- libqofono-0.53/src/qofononetworkoperator.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofononetworkoperator.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,73 +16,85 @@ #include "qofononetworkoperator.h" #include "dbus/ofononetworkoperator.h" -class QOfonoNetworkOperatorPrivate +#define SUPER QOfonoObject + +class QOfonoNetworkOperator::Private : public SUPER::ExtData { public: - QOfonoNetworkOperatorPrivate(); - QString modemPath; - OfonoNetworkOperator *networkOperator; - QVariantMap properties; + bool registering; + Private() : registering(false) {} }; -QOfonoNetworkOperatorPrivate::QOfonoNetworkOperatorPrivate() : - modemPath(QString()) - , networkOperator(0) +QOfonoNetworkOperator::QOfonoNetworkOperator(QObject *parent) : + SUPER(new Private, parent) { } -QOfonoNetworkOperator::QOfonoNetworkOperator(QObject *parent) : - QObject(parent), - d_ptr(new QOfonoNetworkOperatorPrivate) +// Constructs the object with known set of properties, saves a roundtrip +// via D-Bus and makes the object valid immediately +QOfonoNetworkOperator::QOfonoNetworkOperator(const QString &path, + const QVariantMap &properties, QObject *parent) : + SUPER(new Private, parent) { + setObjectPath(path, &properties); } QOfonoNetworkOperator::~QOfonoNetworkOperator() { - delete d_ptr; +} + +QString QOfonoNetworkOperator::operatorPath() const +{ + return objectPath(); } void QOfonoNetworkOperator::setOperatorPath(const QString &path) { - if (path != operatorPath()) { - if (d_ptr->networkOperator) { - delete d_ptr->networkOperator; - d_ptr->networkOperator = 0; - } - d_ptr->networkOperator = new OfonoNetworkOperator("org.ofono", path, QDBusConnection::systemBus(),this); - if (d_ptr->networkOperator->isValid()) { - d_ptr->modemPath = path; - - connect(d_ptr->networkOperator,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - QDBusPendingReply reply; - reply = d_ptr->networkOperator->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - Q_EMIT operatorPathChanged(path); - } - } + setObjectPath(path); } -QString QOfonoNetworkOperator::operatorPath() const +void QOfonoNetworkOperator::objectPathChanged(const QString &path, const QVariantMap *properties) { - return d_ptr->modemPath; + SUPER::objectPathChanged(path, properties); + Q_EMIT operatorPathChanged(path); } -void QOfonoNetworkOperator::registerOperator() +QDBusAbstractInterface *QOfonoNetworkOperator::createDbusInterface(const QString &path) { - QDBusPendingReply result = d_ptr->networkOperator->Register(); + OfonoNetworkOperator *iface = new OfonoNetworkOperator("org.ofono", path, QDBusConnection::systemBus(), this); + iface->setTimeout(120*1000); //increase dbus timeout as registration can take a long time + return iface; +} - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(registerFinished(QDBusPendingCallWatcher*))); +void QOfonoNetworkOperator::dbusInterfaceDropped() +{ + SUPER::dbusInterfaceDropped(); + Private *d_ptr = privateData(); + if (d_ptr->registering) { + d_ptr->registering = false; + Q_EMIT registeringChanged(d_ptr->registering); + } } -void QOfonoNetworkOperator::registerFinished(QDBusPendingCallWatcher *call) +void QOfonoNetworkOperator::registerOperator() { - call->deleteLater(); - QDBusPendingReply<> reply = *call; + Private *d_ptr = privateData(); + if (!d_ptr->registering) { + OfonoNetworkOperator *iface = (OfonoNetworkOperator*)dbusInterface(); + if (iface) { + d_ptr->registering = true; + Q_EMIT registeringChanged(d_ptr->registering); + connect(new QDBusPendingCallWatcher(iface->Register(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onRegisterFinished(QDBusPendingCallWatcher*))); + } + } +} + +void QOfonoNetworkOperator::onRegisterFinished(QDBusPendingCallWatcher *watch) +{ + watch->deleteLater(); + QDBusPendingReply<> reply(*watch); QOfonoNetworkOperator::Error error = NoError; QString errorString; @@ -91,64 +103,61 @@ error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } - Q_EMIT registerComplete(error,errorString); + + Private *d_ptr = privateData(); + d_ptr->registering = false; + Q_EMIT registerComplete(error, errorString); + Q_EMIT registeringChanged(d_ptr->registering); +} + +bool QOfonoNetworkOperator::registering() const +{ + return privateData()->registering; } QString QOfonoNetworkOperator::name() const { - if (d_ptr->networkOperator) - return d_ptr->properties["Name"].value(); - else - return QString(); + return getString("Name"); } QString QOfonoNetworkOperator::status() const { - if (d_ptr->networkOperator) - return d_ptr->properties["Status"].value(); - else - return QString(); + return getString("Status"); } QString QOfonoNetworkOperator::mcc() const { - if (d_ptr->networkOperator) - return d_ptr->properties["MobileCountryCode"].value(); - else - return QString(); + return getString("MobileCountryCode"); } QString QOfonoNetworkOperator::mnc() const { - if (d_ptr->networkOperator) - return d_ptr->properties["MobileNetworkCode"].value(); - else - return QString(); + return getString("MobileNetworkCode"); } QStringList QOfonoNetworkOperator::technologies() const { - if (d_ptr->networkOperator) { - return d_ptr->properties["Technologies"].value(); - } else { - return QStringList(); - } + return getStringList("Technologies"); } QString QOfonoNetworkOperator::additionalInfo() const { - if (d_ptr->networkOperator) - return d_ptr->properties["AdditionalInformation"].value(); - else - return QString(); + return getString("AdditionalInformation"); } +bool QOfonoNetworkOperator::isValid() const +{ + return SUPER::isValid(); +} -void QOfonoNetworkOperator::propertyChanged(const QString &property, const QDBusVariant &dbusvalue) +QOfonoNetworkOperator::Private *QOfonoNetworkOperator::privateData() const { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); + return (QOfonoNetworkOperator::Private*)SUPER::extData(); +} +void QOfonoNetworkOperator::propertyChanged(const QString &property, const QVariant &value) +{ + SUPER::propertyChanged(property, value); if (property == QLatin1String("Name")) { Q_EMIT nameChanged(value.value()); } else if (property == QLatin1String("Status")) { @@ -164,11 +173,6 @@ } } -bool QOfonoNetworkOperator::isValid() const -{ - return d_ptr->networkOperator->isValid(); -} - QOfonoNetworkOperator::Error QOfonoNetworkOperator::errorNameToEnum(const QString &errorName) { if (errorName == "") diff -Nru libqofono-0.53/src/qofononetworkoperator.h libqofono-0.70~rtm/src/qofononetworkoperator.h --- libqofono-0.53/src/qofononetworkoperator.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofononetworkoperator.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,29 +16,26 @@ #ifndef QOFONONETWORKOPERATOR_H #define QOFONONETWORKOPERATOR_H -#include -#include -#include +#include "qofonoobject.h" #include "qofono_global.h" + //! This class is used to access ofono network operator API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/network-api.txt */ - -class QOfonoNetworkOperatorPrivate; -class QOFONOSHARED_EXPORT QOfonoNetworkOperator : public QObject +class QOFONOSHARED_EXPORT QOfonoNetworkOperator : public QOfonoObject { Q_OBJECT Q_ENUMS(Error) Q_PROPERTY(QString operatorPath READ operatorPath WRITE setOperatorPath NOTIFY operatorPathChanged) - Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString status READ status NOTIFY statusChanged) Q_PROPERTY(QString mcc READ mcc NOTIFY mccChanged) Q_PROPERTY(QString mnc READ mnc NOTIFY mncChanged) Q_PROPERTY(QStringList technologies READ technologies NOTIFY technologiesChanged) Q_PROPERTY(QString additionalInfo READ additionalInfo NOTIFY additionalInfoChanged) + Q_PROPERTY(bool registering READ registering NOTIFY registeringChanged) public: enum Error { @@ -52,6 +49,7 @@ }; explicit QOfonoNetworkOperator(QObject *parent = 0); + QOfonoNetworkOperator(const QString &path, const QVariantMap &properties, QObject *parent = 0); ~QOfonoNetworkOperator(); QString operatorPath() const; @@ -65,6 +63,7 @@ QString additionalInfo() const; Q_INVOKABLE void registerOperator(); + bool registering() const; bool isValid() const; Q_SIGNALS: @@ -76,18 +75,25 @@ void technologiesChanged(const QStringList &technologies); void additionalInfoChanged(const QString &additionalInfo); void operatorPathChanged(const QString &path); + void registeringChanged(bool value); void registerComplete(QOfonoNetworkOperator::Error error, const QString &errorString); -public slots: - private: - QOfonoNetworkOperatorPrivate *d_ptr; - Error errorNameToEnum(const QString &errorName); + static Error errorNameToEnum(const QString &errorName); private slots: - void propertyChanged(const QString &property, const QDBusVariant &value); - void registerFinished(QDBusPendingCallWatcher *call); + void onRegisterFinished(QDBusPendingCallWatcher *call); + +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void dbusInterfaceDropped(); + void propertyChanged(const QString &key, const QVariant &value); + void objectPathChanged(const QString &path, const QVariantMap *properties); + +private: + class Private; + Private *privateData() const; }; #endif // QOFONONETWORKOPERATOR_H diff -Nru libqofono-0.53/src/qofononetworkregistration.cpp libqofono-0.70~rtm/src/qofononetworkregistration.cpp --- libqofono-0.53/src/qofononetworkregistration.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofononetworkregistration.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -13,295 +13,330 @@ ** ****************************************************************************/ -#include - #include "qofononetworkregistration.h" +#include "qofononetworkoperator.h" #include "dbus/ofononetworkregistration.h" +#define SUPER QOfonoModemInterface -QDBusArgument &operator<<(QDBusArgument &argument, const OfonoPathProps &op) +class QOfonoNetworkRegistration::Private : public QOfonoObject::ExtData { - argument.beginStructure(); - argument << op.path << op.properties; - argument.endStructure(); - return argument; -} +public: + bool initialized; + bool scanning; + QOfonoNetworkOperator* currentOperator; + QHash networkOperators; + QStringList operatorPaths; + + Private() : initialized(false), scanning(false), currentOperator(NULL) {} + ~Private() { qDeleteAll(networkOperators.values()); } +}; -const QDBusArgument &operator>>(const QDBusArgument &argument, OfonoPathProps &op) +QOfonoNetworkRegistration::QOfonoNetworkRegistration(QObject *parent) : + SUPER(OfonoNetworkRegistration::staticInterfaceName(), new Private, parent) { - argument.beginStructure(); - argument >> op.path >> op.properties; - argument.endStructure(); - return argument; + QOfonoDbusTypes::registerObjectPathProperties(); } +QOfonoNetworkRegistration::~QOfonoNetworkRegistration() +{ +} - -class QOfonoNetworkRegistrationPrivate +bool QOfonoNetworkRegistration::isValid() const { -public: - QOfonoNetworkRegistrationPrivate(); - OfonoNetworkRegistration *networkRegistration; - QString modemPath; - QVariantMap properties; - QStringList networkOperators; - QArrayOfPathProps operatorArray; -}; + return privateData()->initialized && SUPER::isValid(); +} -QOfonoNetworkRegistrationPrivate::QOfonoNetworkRegistrationPrivate() : - networkRegistration(0) - , modemPath(QString()) - , networkOperators(QStringList()) +bool QOfonoNetworkRegistration::scanning() const { - qDBusRegisterMetaType(); - qDBusRegisterMetaType(); + return privateData()->scanning; } -QOfonoNetworkRegistration::QOfonoNetworkRegistration(QObject *parent) : - QObject(parent), - d_ptr(new QOfonoNetworkRegistrationPrivate) +QDBusAbstractInterface *QOfonoNetworkRegistration::createDbusInterface(const QString &path) { + OfonoNetworkRegistration* iface = new OfonoNetworkRegistration("org.ofono", path, QDBusConnection::systemBus(), this); + iface->setTimeout(120*1000); //increase dbus timeout as scanning can take a long time + connect(iface, + SIGNAL(OperatorsChanged(ObjectPathPropertiesList)), + SLOT(onOperatorsChanged(ObjectPathPropertiesList))); + connect(new QDBusPendingCallWatcher(iface->GetOperators(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onGetOperatorsFinished(QDBusPendingCallWatcher*))); + return iface; } -QOfonoNetworkRegistration::~QOfonoNetworkRegistration() +void QOfonoNetworkRegistration::dbusInterfaceDropped() { - delete d_ptr; + SUPER::dbusInterfaceDropped(); + Private *d_ptr = privateData(); + d_ptr->initialized = false; + if (d_ptr->scanning) { + d_ptr->scanning = false; + scanningChanged(false); + } + if (!d_ptr->networkOperators.isEmpty()) { + qDeleteAll(d_ptr->networkOperators.values()); + d_ptr->operatorPaths.clear(); + d_ptr->networkOperators.clear(); + d_ptr->currentOperator = NULL; + Q_EMIT networkOperatorsChanged(d_ptr->operatorPaths); + } } -void QOfonoNetworkRegistration::setModemPath(const QString &path) +void QOfonoNetworkRegistration::registration() { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - QStringList removedProperties = d_ptr->properties.keys(); - - delete d_ptr->networkRegistration; - d_ptr->networkRegistration = new OfonoNetworkRegistration("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->networkRegistration->isValid()) { - d_ptr->modemPath = path; - d_ptr->networkRegistration->setTimeout(1000 * 120); //increase dbus timeout as scanning can take a long time - - connect(d_ptr->networkRegistration,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - QDBusPendingReply reply; - reply = d_ptr->networkRegistration->GetProperties(); - reply.waitForFinished(); - if (!reply.isError()) { - QVariantMap properties = reply.value(); - for (QVariantMap::ConstIterator it = properties.constBegin(); - it != properties.constEnd(); ++it) { - updateProperty(it.key(), it.value()); - removedProperties.removeOne(it.key()); - } - } + OfonoNetworkRegistration *iface = (OfonoNetworkRegistration*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher(iface->Register(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onRegistrationFinished(QDBusPendingCallWatcher*))); + } else { + Q_EMIT registrationError(QStringLiteral("Error.ServiceUnknown")); + } +} - Q_EMIT modemPathChanged(path); +void QOfonoNetworkRegistration::onRegistrationFinished(QDBusPendingCallWatcher *watch) +{ + watch->deleteLater(); + QDBusPendingReply<> reply(*watch); + if (!reply.isError()) { + Q_EMIT registrationFinished(); + } else { + Q_EMIT registrationError(reply.error().message()); } +} - foreach (const QString &p, removedProperties) - updateProperty(p, QVariant()); +QStringList QOfonoNetworkRegistration::networkOperators() const +{ + return privateData()->operatorPaths; } -QString QOfonoNetworkRegistration::modemPath() const +QStringList QOfonoNetworkRegistration::networkOperators() { - return d_ptr->modemPath; + return privateData()->operatorPaths; } -void QOfonoNetworkRegistration::registration() +QOfonoNetworkOperator* QOfonoNetworkRegistration::networkOperator(const QString &path) const { - if (d_ptr->networkRegistration) - d_ptr->networkRegistration->Register(); + return privateData()->networkOperators[path]; } -QStringList QOfonoNetworkRegistration::networkOperators() +QString QOfonoNetworkRegistration::currentOperatorPath() { - if (d_ptr->networkRegistration) { - QDBusPendingReply pending = d_ptr->networkRegistration->GetOperators(); - pending.waitForFinished(); - - if (!pending.isError()) { - scanFinish(pending.value()); - } else { - qDebug() << Q_FUNC_INFO << pending.error().message(); - } - } - return d_ptr->networkOperators; + Private *d_ptr = privateData(); + return d_ptr->currentOperator ? d_ptr->currentOperator->operatorPath() : QString(); } void QOfonoNetworkRegistration::scan() { - if (d_ptr->networkRegistration) { - QList arguments; - if (!d_ptr->networkRegistration->callWithCallback(QLatin1String("Scan"), - arguments, - this, - SLOT(scanFinish(QArrayOfPathProps)), - SLOT(scanError(const QDBusError&)))) { - qDebug() << "Failed to queue scan call"; + Private *d_ptr = privateData(); + if (!d_ptr->scanning) { + OfonoNetworkRegistration *iface = (OfonoNetworkRegistration*)dbusInterface(); + if (iface) { + d_ptr->scanning = true; + scanningChanged(true); + connect(new QDBusPendingCallWatcher(iface->Scan(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onScanFinished(QDBusPendingCallWatcher*))); } } } QString QOfonoNetworkRegistration::mode() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["Mode"].value(); - else - return QString(); + return getString("Mode"); } QString QOfonoNetworkRegistration::status() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["Status"].value(); - else - return QString(); + return getString("Status"); } uint QOfonoNetworkRegistration::locationAreaCode() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["LocalAreaCode"].value(); - else - return 0; + return getUInt("LocalAreaCode"); } uint QOfonoNetworkRegistration::cellId() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["CellId"].value(); - else - return 0; + return getUInt("CellId"); } QString QOfonoNetworkRegistration::mcc() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["MobileCountryCode"].value(); - else - return QString(); - + return getString("MobileCountryCode"); } QString QOfonoNetworkRegistration::mnc() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["MobileNetworkCode"].value(); - else - return QString(); - + return getString("MobileNetworkCode"); } QString QOfonoNetworkRegistration::technology() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["Technology"].value(); - else - return QString(); + return getString("Technology"); } QString QOfonoNetworkRegistration::name() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["Name"].value(); - else - return QString(); + return getString("Name"); } uint QOfonoNetworkRegistration::strength() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["Strength"].value(); - else - return 0; + return getUInt("Strength"); } QString QOfonoNetworkRegistration::baseStation() const { - if ( d_ptr->networkRegistration) - return d_ptr->properties["BaseStation"].value(); - else - return QString(); -} - -void QOfonoNetworkRegistration::propertyChanged(const QString &property, const QDBusVariant &dbusvalue) -{ - updateProperty(property, dbusvalue.variant()); + return getString("BaseStation"); } -void QOfonoNetworkRegistration::updateProperty(const QString &property, const QVariant &value) +void QOfonoNetworkRegistration::propertyChanged(const QString &property, const QVariant &value) { - if (d_ptr->properties.value(property) == value) - return; - - if (value.isValid()) - d_ptr->properties.insert(property, value); - else - d_ptr->properties.remove(property); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("Mode")) { - Q_EMIT modeChanged(value.value()); + Q_EMIT modeChanged(value.toString()); } else if (property == QLatin1String("Status")) { - Q_EMIT statusChanged(value.value()); + Q_EMIT statusChanged(value.toString()); } else if (property == QLatin1String("LocationAreaCode")) { - Q_EMIT locationAreaCodeChanged(value.value()); + Q_EMIT locationAreaCodeChanged(value.toUInt()); } else if (property == QLatin1String("CellId")) { - Q_EMIT cellIdChanged(value.value()); + Q_EMIT cellIdChanged(value.toUInt()); } else if (property == QLatin1String("MobileCountryCode")) { - Q_EMIT mccChanged(value.value()); + Q_EMIT mccChanged(value.toString()); } else if (property == QLatin1String("MobileNetworkCode")) { - Q_EMIT mncChanged(value.value()); + Q_EMIT mncChanged(value.toString()); } else if (property == QLatin1String("Technology")) { - Q_EMIT technologyChanged(value.value()); + Q_EMIT technologyChanged(value.toString()); } else if (property == QLatin1String("Name")) { - Q_EMIT nameChanged(value.value()); + Q_EMIT nameChanged(value.toString()); } else if (property == QLatin1String("Strength")) { - Q_EMIT strengthChanged(value.value()); + Q_EMIT strengthChanged(value.toUInt()); } else if (property == QLatin1String("BaseStation")) { - Q_EMIT baseStationChanged(value.value()); + Q_EMIT baseStationChanged(value.toString()); } } -void QOfonoNetworkRegistration::scanFinish(const QArrayOfPathProps &list) +void QOfonoNetworkRegistration::onOperatorsChanged(const ObjectPathPropertiesList &list) { - bool changed = false; - d_ptr->operatorArray = list; - QString current; - foreach(OfonoPathProps netop, list) { - if (!d_ptr->networkOperators.contains(netop.path.path())) { - d_ptr->networkOperators.append(netop.path.path()); - current == netop.path.path(); - changed = true; + QString oldPath = currentOperatorPath(); + + QStringList paths; + QList newOperators; + QOfonoNetworkOperator* currentOperator = NULL; + Private *d_ptr = privateData(); + bool listChanged = false; + int i; + + // Find new operators + for (i=0; inetworkOperators.contains(path)) { + // No need to query the properties as we already have the. + // The object becomes valid immediately. + QOfonoNetworkOperator* op = new QOfonoNetworkOperator(path, + list[i].properties, this); + newOperators.append(op); + connect(op, SIGNAL(statusChanged(QString)), + SLOT(onOperatorStatusChanged(QString))); + if (op->status() == "current") { + currentOperator = op; + } + listChanged = true; } } - if (changed) { - Q_EMIT networkOperatorsChanged(d_ptr->networkOperators); - Q_EMIT currentOperatorPathChanged(current); + + // Remove operators that are no longer on the list + for (i=d_ptr->operatorPaths.count()-1; i>=0; i--) { + QString path = d_ptr->operatorPaths[i]; + if (!paths.contains(path)) { + QOfonoNetworkOperator* op = d_ptr->networkOperators[path]; + if (op == d_ptr->currentOperator) d_ptr->currentOperator = NULL; + d_ptr->operatorPaths.removeAt(i); + d_ptr->networkOperators.remove(path); + delete op; + listChanged = true; + } + } + + // Append new operators to the end of the list + for (i=0; ioperatorPaths.append(op->operatorPath()); + d_ptr->networkOperators.insert(op->operatorPath(), op); + } + + // Replace the current operator if it has changed + if (currentOperator) d_ptr->currentOperator = currentOperator; + + // Fire necessary events + if (listChanged) { + Q_EMIT networkOperatorsChanged(d_ptr->operatorPaths); + } + QString currentPath = currentOperatorPath(); + if (currentPath != oldPath) { + Q_EMIT currentOperatorPathChanged(currentPath); } - Q_EMIT scanFinished(); } -void QOfonoNetworkRegistration::scanError(QDBusError error) +void QOfonoNetworkRegistration::onGetOperatorsFinished(QDBusPendingCallWatcher *watch) { - qDebug() << Q_FUNC_INFO << error.message(); - Q_EMIT scanError(error.message()); - Q_EMIT scanFinished(); + watch->deleteLater(); + QDBusPendingReply reply(*watch); + if (reply.isError()) { + qDebug() << reply.error(); + Q_EMIT reportError(reply.error().message()); + } else { + privateData()->initialized = true; + onOperatorsChanged(reply.value()); + if (isValid()) validChanged(true); + } } -QString QOfonoNetworkRegistration::currentOperatorPath() +void QOfonoNetworkRegistration::onScanFinished(QDBusPendingCallWatcher *watch) { + watch->deleteLater(); + QDBusPendingReply reply(*watch); + if (reply.isError()) { + qDebug() << reply.error(); + Q_EMIT scanError(reply.error().message()); + } else { + onOperatorsChanged(reply.value()); + Q_EMIT scanFinished(); + } + privateData()->scanning = false; + scanningChanged(false); +} - foreach(OfonoPathProps netop, d_ptr->operatorArray) { - if (netop.properties["Status"].toString() == QLatin1String("current")) { - return netop.path.path(); - } +void QOfonoNetworkRegistration::onOperatorStatusChanged(const QString &status) +{ + QString oldPath = currentOperatorPath(); + QOfonoNetworkOperator *op = (QOfonoNetworkOperator*)sender(); + Private *d_ptr = privateData(); + if (status == "current") { + d_ptr->currentOperator = op; + } else if (d_ptr->currentOperator == op) { + d_ptr->currentOperator = NULL; + } + QString currentPath = currentOperatorPath(); + if (currentPath != oldPath) { + Q_EMIT currentOperatorPathChanged(currentPath); } - return QString(); } -bool QOfonoNetworkRegistration::isValid() const +QString QOfonoNetworkRegistration::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoNetworkRegistration::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); +} + +QOfonoNetworkRegistration::Private *QOfonoNetworkRegistration::privateData() const { - return d_ptr->networkRegistration->isValid(); + return (QOfonoNetworkRegistration::Private*)SUPER::extData(); } diff -Nru libqofono-0.53/src/qofononetworkregistration.h libqofono-0.70~rtm/src/qofononetworkregistration.h --- libqofono-0.53/src/qofononetworkregistration.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofononetworkregistration.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,31 +16,19 @@ #ifndef QOFONONETWORKREGISTRATION_H #define QOFONONETWORKREGISTRATION_H -#include -#include "dbustypes.h" - +#include "qofonomodeminterface.h" +#include "qofononetworkoperator.h" #include "qofono_global.h" + //! This class is used to access ofono network operator API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/network-api.txt */ - -class QOfonoNetworkRegistrationPrivate; - -struct OfonoPathProps -{ - QDBusObjectPath path; - QVariantMap properties; -}; -typedef QList QArrayOfPathProps; -Q_DECLARE_METATYPE(OfonoPathProps) -Q_DECLARE_METATYPE (QArrayOfPathProps) - -class QOFONOSHARED_EXPORT QOfonoNetworkRegistration : public QObject +class QOFONOSHARED_EXPORT QOfonoNetworkRegistration : public QOfonoModemInterface { Q_OBJECT - + Q_PROPERTY(bool scanning READ scanning NOTIFY scanningChanged) Q_PROPERTY(QString mode READ mode NOTIFY modeChanged) Q_PROPERTY(QString status READ status NOTIFY statusChanged) Q_PROPERTY(uint locationAreaCode READ locationAreaCode NOTIFY locationAreaCodeChanged) @@ -55,8 +43,6 @@ Q_PROPERTY(QStringList networkOperators READ networkOperators NOTIFY networkOperatorsChanged) Q_PROPERTY(QString currentOperatorPath READ currentOperatorPath NOTIFY currentOperatorPathChanged) - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath) - public: explicit QOfonoNetworkRegistration(QObject *parent = 0); ~QOfonoNetworkRegistration(); @@ -75,7 +61,9 @@ uint strength() const; QString baseStation() const; - QStringList networkOperators(); + QStringList networkOperators(); // For ABI compatibility + QStringList networkOperators() const; + QOfonoNetworkOperator* networkOperator(const QString &path) const; Q_INVOKABLE void registration(); Q_INVOKABLE void scan(); @@ -83,6 +71,8 @@ QString currentOperatorPath(); bool isValid() const; + bool scanning() const; + Q_SIGNALS: void modeChanged(const QString &mode); void statusChanged(const QString &status); @@ -99,19 +89,26 @@ void currentOperatorPathChanged(const QString &); void scanFinished(); void scanError(const QString &message); - void modemPathChanged(const QString &path); + void scanningChanged(bool value); -public slots: - -private: - void updateProperty(const QString &property, const QVariant &value); - - QOfonoNetworkRegistrationPrivate *d_ptr; + void registrationFinished(); + void registrationError(const QString &errorMessage); private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); - void scanError(QDBusError error); - void scanFinish(const QArrayOfPathProps &list); + void onOperatorsChanged(const ObjectPathPropertiesList &operators); + void onOperatorStatusChanged(const QString &status); + void onScanFinished(QDBusPendingCallWatcher *watch); + void onGetOperatorsFinished(QDBusPendingCallWatcher *watch); + void onRegistrationFinished(QDBusPendingCallWatcher *watch); + +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void dbusInterfaceDropped(); + void propertyChanged(const QString &property, const QVariant &value); + +private: + class Private; + Private *privateData() const; }; #endif // QOFONONETWORKREGISTRATION_H diff -Nru libqofono-0.53/src/qofonoobject.cpp libqofono-0.70~rtm/src/qofonoobject.cpp --- libqofono-0.53/src/qofonoobject.cpp 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonoobject.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,271 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#include "qofonoobject.h" +#include "qofonoutils_p.h" + +class QOfonoObject::Private +{ +public: + QOfonoObject::ExtData *ext; + QDBusAbstractInterface *interface; + bool initialized; + QString objectPath; + QVariantMap properties; + + Private(QOfonoObject::ExtData *data) : ext(data), + interface(NULL), initialized(false) {} + ~Private() { delete ext; } + + QDBusPendingCall setProperty(const QString &key, const QVariant &value); + + class SetPropertyWatcher : public QDBusPendingCallWatcher { + public: + QString property; + SetPropertyWatcher(QDBusAbstractInterface *parent, const QString &name, + const QDBusPendingCall &call) : QDBusPendingCallWatcher(call, parent), + property(name) {} + }; +}; + +QOfonoObject::ExtData::~ExtData() +{ +} + +QDBusPendingCall QOfonoObject::Private::setProperty(const QString &key, const QVariant &value) +{ + // Caller checks interface for NULL + QVariantList args; + args << QVariant(key) << QVariant::fromValue(QDBusVariant(value)); + return interface->asyncCallWithArgumentList("SetProperty", args); +} + + +QOfonoObject::QOfonoObject(QObject *parent) : + QObject(parent), + d_ptr(new QOfonoObject::Private(NULL)) +{ +} + +QOfonoObject::QOfonoObject(QOfonoObject::ExtData *ext, QObject *parent) : + QObject(parent), + d_ptr(new QOfonoObject::Private(ext)) +{ +} + +QOfonoObject::~QOfonoObject() +{ + delete d_ptr; +} + +QOfonoObject::ExtData* QOfonoObject::extData() const +{ + return d_ptr->ext; +} + +QString QOfonoObject::objectPath() const +{ + return d_ptr->objectPath; +} + +void QOfonoObject::setObjectPath(const QString &path, const QVariantMap *properties) +{ + if (d_ptr->objectPath != path) { + d_ptr->objectPath = path; + objectPathChanged(path, properties); + } +} + +void QOfonoObject::objectPathChanged(const QString &, const QVariantMap *properties) +{ + resetDbusInterface(properties); +} + +bool QOfonoObject::isValid() const +{ + return d_ptr->interface && d_ptr->interface->isValid() && d_ptr->initialized; +} + +QDBusAbstractInterface *QOfonoObject::dbusInterface() const +{ + return d_ptr->interface; +} + +void QOfonoObject::resetDbusInterface(const QVariantMap *properties) +{ + setDbusInterface(d_ptr->objectPath.isEmpty() ? NULL : + createDbusInterface(d_ptr->objectPath), properties); +} + +void QOfonoObject::setDbusInterface(QDBusAbstractInterface *iface, const QVariantMap *properties) +{ + bool wasValid = isValid(); + d_ptr->initialized = false; + if (d_ptr->interface) { + delete d_ptr->interface; + d_ptr->interface = NULL; + dbusInterfaceDropped(); + } + if (iface) { + d_ptr->interface = iface; + if (properties) { + d_ptr->initialized = true; + // Ofono objects have fixed sets of properties, there's no need to check + // for disappearance or reappearance of individual properties. + for (QVariantMap::ConstIterator it = properties->constBegin(); + it != properties->constEnd(); ++it) { + updateProperty(it.key(), it.value()); + } + } else { + d_ptr->initialized = false; + connect(new QDBusPendingCallWatcher( + iface->asyncCall("GetProperties"), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onGetPropertiesFinished(QDBusPendingCallWatcher*))); + } + connect(iface, + SIGNAL(PropertyChanged(QString,QDBusVariant)), + SLOT(onPropertyChanged(QString,QDBusVariant))); + } + bool valid = isValid(); + if (valid != wasValid) { + Q_EMIT validChanged(valid); + } +} + +void QOfonoObject::dbusInterfaceDropped() +{ + if (!d_ptr->properties.isEmpty()) { + QStringList keys = d_ptr->properties.keys(); + for (int i=0; ideleteLater(); + QDBusPendingReply reply(*watch); + if (!reply.isError()) { + getPropertiesFinished(reply.value(), NULL); + } else { + QDBusError error = reply.error(); + getPropertiesFinished(QVariantMap(), &error); + } +} + +void QOfonoObject::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) +{ + if (!error) { + for (QVariantMap::ConstIterator it = properties.constBegin(); + it != properties.constEnd(); ++it) { + updateProperty(it.key(), it.value()); + } + d_ptr->initialized = true; + if (isValid()) { + Q_EMIT validChanged(true); + } + } else { + qDebug() << *error; + Q_EMIT reportError(error->message()); + } +} + +QVariantMap QOfonoObject::getProperties() const +{ + return d_ptr->properties; +} + +QVariant QOfonoObject::getProperty(const QString &key) const +{ + return d_ptr->properties[key]; +} + +QVariant QOfonoObject::convertProperty(const QString &key, const QVariant &value) +{ + return value; +} + +void QOfonoObject::propertyChanged(const QString &key, const QVariant &value) +{ +} + +void QOfonoObject::updateProperty(const QString &key, const QVariant &value) +{ + QVariant oldValue = getProperty(key); + QVariant newValue; + if (value.isValid()) { + newValue = convertProperty(key, value); + } + if (!qofono::safeVariantEq(oldValue, newValue)) { + if (newValue.isValid()) { + d_ptr->properties.insert(key, newValue); + } else { + d_ptr->properties.remove(key); + } + propertyChanged(key, newValue); + } +} + +void QOfonoObject::onPropertyChanged(const QString &key, const QDBusVariant &value) +{ + updateProperty(key, value.variant()); +} + +bool QOfonoObject::setPropertySync(const QString &key, const QVariant &value) +{ + if (d_ptr->interface) { + QDBusPendingReply<> reply = d_ptr->setProperty(key, value); + reply.waitForFinished(); + return reply.isValid() && !reply.isError(); + } else { + return false; + } +} + +void QOfonoObject::setProperty(const QString &key, const QVariant &value) +{ + if (d_ptr->interface) { + connect(new Private::SetPropertyWatcher(d_ptr->interface, + key, d_ptr->setProperty(key, value)), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onSetPropertyFinished(QDBusPendingCallWatcher*))); + } +} + +void QOfonoObject::onSetPropertyFinished(QDBusPendingCallWatcher *watch) +{ + watch->deleteLater(); + QDBusPendingReply<> reply(*watch); + QDBusError dbusError; + const QDBusError *error; + if (!reply.isError()) { + error = NULL; + } else { + dbusError = reply.error(); + error = &dbusError; + } + setPropertyFinished(((Private::SetPropertyWatcher*)watch)->property, error); +} + +void QOfonoObject::setPropertyFinished(const QString &property, const QDBusError *error) +{ + if (error) { + qDebug() << qPrintable(property) << ": " << *error; + Q_EMIT reportError(error->message()); + } + Q_EMIT setPropertyFinished(); +} diff -Nru libqofono-0.53/src/qofonoobject.h libqofono-0.70~rtm/src/qofonoobject.h --- libqofono-0.53/src/qofonoobject.h 1970-01-01 00:00:00.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonoobject.h 2015-01-09 08:20:12.000000000 +0000 @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd. +** Contact: slava.monich@jolla.com +** +** 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. +** +****************************************************************************/ + +#ifndef QOFONOOBJECT_H +#define QOFONOOBJECT_H + +#include "dbustypes.h" + +class QOfonoObject : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) + +public: + class ExtData { + public: + virtual ~ExtData(); + }; + +protected: + QOfonoObject(ExtData *ext, QObject *parent = NULL); + QOfonoObject(QObject *parent = NULL); + ~QOfonoObject(); + + virtual ExtData* extData() const; + +public: + QString objectPath() const; + void setObjectPath(const QString &path, const QVariantMap *properties = NULL); + virtual bool isValid() const; + +Q_SIGNALS: + void validChanged(bool valid); + void setPropertyFinished(); + void reportError(const QString &message); + +protected: + virtual void objectPathChanged(const QString &path, const QVariantMap *properties) = 0; + virtual QDBusAbstractInterface *createDbusInterface(const QString &path) = 0; + virtual void dbusInterfaceDropped(); + + virtual QVariant convertProperty(const QString &key, const QVariant &value); + virtual void updateProperty(const QString &key, const QVariant &value); + virtual void propertyChanged(const QString &key, const QVariant &value); + virtual void getPropertiesFinished(const QVariantMap &properties, const QDBusError *error); + virtual void setPropertyFinished(const QString &property, const QDBusError *error); + + void setProperty(const QString &key, const QVariant &value); + bool setPropertySync(const QString &key, const QVariant &value); + + QVariantMap getProperties() const; + QVariant getProperty(const QString &key) const; + QString getString(const QString &key) const; + QStringList getStringList(const QString &key) const; + QVariantMap getVariantMap(const QString &key) const; + QVariantList getVariantList(const QString &key) const; + bool getBool(const QString &key) const; + uint getUInt(const QString &key) const; + int getInt(const QString &key) const; + + QDBusAbstractInterface *dbusInterface() const; + void setDbusInterface(QDBusAbstractInterface *dbus, const QVariantMap *properties = NULL); + void resetDbusInterface(const QVariantMap *properties = NULL); + +private slots: + void onGetPropertiesFinished(QDBusPendingCallWatcher *watch); + void onSetPropertyFinished(QDBusPendingCallWatcher *watch); + void onPropertyChanged(const QString &key, const QDBusVariant &value); + +private: + class Private; + Private *d_ptr; +}; + +inline QString QOfonoObject::getString(const QString &key) const + { return getProperty(key).toString(); } +inline QStringList QOfonoObject::getStringList(const QString &key) const + { return getProperty(key).toStringList(); } +inline QVariantMap QOfonoObject::getVariantMap(const QString &key) const + { return getProperty(key).value(); } +inline QVariantList QOfonoObject::getVariantList(const QString &key) const + { return getProperty(key).value(); } +inline bool QOfonoObject::getBool(const QString &key) const + { return getProperty(key).toBool(); } +inline uint QOfonoObject::getUInt(const QString &key) const + { return getProperty(key).toUInt(); } +inline int QOfonoObject::getInt(const QString &key) const + { return getProperty(key).toInt(); } + +#endif // QOFONOOBJECT_H diff -Nru libqofono-0.53/src/qofonophonebook.cpp libqofono-0.70~rtm/src/qofonophonebook.cpp --- libqofono-0.53/src/qofonophonebook.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonophonebook.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,90 +16,88 @@ #include "qofonophonebook.h" #include "dbus/ofonophonebook.h" -class QOfonoPhonebookPrivate +#define SUPER QOfonoModemInterface2 + +class QOfonoPhonebook::Private : public SUPER::ExtData { public: - QOfonoPhonebookPrivate(); - QString modemPath; - OfonoPhonebook *phonebook; bool importing; + Private() : importing(false) {} }; -QOfonoPhonebookPrivate::QOfonoPhonebookPrivate() : - modemPath(QString()) - , phonebook(0) - , importing(false) -{ -} - QOfonoPhonebook::QOfonoPhonebook(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoPhonebookPrivate) + SUPER(OfonoPhonebook::staticInterfaceName(), new Private, parent) { } QOfonoPhonebook::~QOfonoPhonebook() { - delete d_ptr; } -void QOfonoPhonebook::setModemPath(const QString &path) +QDBusAbstractInterface *QOfonoPhonebook::createDbusInterface(const QString &path) { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - if (path != modemPath()) { - if (d_ptr->phonebook) { - delete d_ptr->phonebook; - d_ptr->phonebook = 0; - } - d_ptr->phonebook = new OfonoPhonebook("org.ofono", path, QDBusConnection::systemBus(),this); - if (d_ptr->phonebook->isValid()) { - d_ptr->modemPath = path; - Q_EMIT modemPathChanged(path); - } - } + return new OfonoPhonebook("org.ofono", path, QDBusConnection::systemBus(), this); } -QString QOfonoPhonebook::modemPath() const +void QOfonoPhonebook::dbusInterfaceDropped() { - return d_ptr->modemPath; + SUPER::dbusInterfaceDropped(); + Private *d_ptr = privateData(); + if (d_ptr->importing) { + d_ptr->importing = false; + Q_EMIT importingChanged(); + } } bool QOfonoPhonebook::importing() const { - return d_ptr->importing; + return privateData()->importing; } void QOfonoPhonebook::beginImport() { - if (d_ptr->phonebook) { - QDBusPendingReply result = d_ptr->phonebook->Import(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(importComplete(QDBusPendingCallWatcher*))); - d_ptr->importing = true; - emit importingChanged(); + Private *d_ptr = privateData(); + if (!d_ptr->importing) { + OfonoPhonebook *iface = (OfonoPhonebook*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher(iface->Import(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onImportFinished(QDBusPendingCallWatcher*))); + d_ptr->importing = true; + Q_EMIT importingChanged(); + } } } -void QOfonoPhonebook::importComplete(QDBusPendingCallWatcher *call) +void QOfonoPhonebook::onImportFinished(QDBusPendingCallWatcher *watch) { - call->deleteLater(); - QDBusPendingReply reply = *call; + watch->deleteLater(); + QDBusPendingReply reply(*watch); if (!reply.isError()) { - QString data = reply.value(); - emit importReady(data); + Q_EMIT importReady(reply.value()); } else { - emit importFailed(); + Q_EMIT importFailed(); } - d_ptr->importing = false; - emit importingChanged(); + privateData()->importing = false; + Q_EMIT importingChanged(); +} + +QString QOfonoPhonebook::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoPhonebook::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); } bool QOfonoPhonebook::isValid() const { - return d_ptr->phonebook->isValid(); + return SUPER::isValid(); } +QOfonoPhonebook::Private *QOfonoPhonebook::privateData() const +{ + return (QOfonoPhonebook::Private*)SUPER::extData(); +} diff -Nru libqofono-0.53/src/qofonophonebook.h libqofono-0.70~rtm/src/qofonophonebook.h --- libqofono-0.53/src/qofonophonebook.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonophonebook.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,20 +16,17 @@ #ifndef QOFONOPhonebook_H #define QOFONOPhonebook_H -#include -#include +#include "qofonomodeminterface2.h" #include "qofono_global.h" + //! This class is used to access ofono phonebook API /*! * oFono phonebook API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/phonebook-api.txt */ - -class QOfonoPhonebookPrivate; -class QOFONOSHARED_EXPORT QOfonoPhonebook : public QObject +class QOFONOSHARED_EXPORT QOfonoPhonebook : public QOfonoModemInterface2 { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(bool importing READ importing NOTIFY importingChanged) public: @@ -40,10 +37,9 @@ void setModemPath(const QString &path); bool importing() const; - bool isValid() const; + Q_SIGNALS: - void modemPathChanged(const QString &path); void importReady(const QString &vcardData); void importFailed(); void importingChanged(); @@ -52,11 +48,15 @@ void beginImport(); private slots: - void importComplete(QDBusPendingCallWatcher *call); + void onImportFinished(QDBusPendingCallWatcher *watch); -private: - QOfonoPhonebookPrivate *d_ptr; +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void dbusInterfaceDropped(); +private: + class Private; + Private *privateData() const; }; #endif // QOFONOPhonebook_H diff -Nru libqofono-0.53/src/qofonoradiosettings.cpp libqofono-0.70~rtm/src/qofonoradiosettings.cpp --- libqofono-0.53/src/qofonoradiosettings.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonoradiosettings.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,85 +16,35 @@ #include "qofonoradiosettings.h" #include "dbus/ofonoradiosettings.h" -class QOfonoRadioSettingsPrivate -{ -public: - QOfonoRadioSettingsPrivate(); - QString modemPath; - OfonoRadioSettings *radioSettings; - QVariantMap properties; - -}; - -QOfonoRadioSettingsPrivate::QOfonoRadioSettingsPrivate() : - modemPath(QString()) - , radioSettings(0) -{ -} +#define SUPER QOfonoModemInterface QOfonoRadioSettings::QOfonoRadioSettings(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoRadioSettingsPrivate) + SUPER(OfonoRadioSettings::staticInterfaceName(), parent) { } QOfonoRadioSettings::~QOfonoRadioSettings() { - delete d_ptr; } -void QOfonoRadioSettings::setModemPath(const QString &path) +QDBusAbstractInterface *QOfonoRadioSettings::createDbusInterface(const QString &path) { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - QStringList removedProperties = d_ptr->properties.keys(); - - delete d_ptr->radioSettings; - d_ptr->radioSettings = new OfonoRadioSettings("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->radioSettings->isValid()) { - d_ptr->modemPath = path; - - connect(d_ptr->radioSettings,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - QVariantMap properties = d_ptr->radioSettings->GetProperties().value(); - for (QVariantMap::ConstIterator it = properties.constBegin(); - it != properties.constEnd(); ++it) { - updateProperty(it.key(), it.value()); - removedProperties.removeOne(it.key()); - } - - Q_EMIT modemPathChanged(path); - } - - foreach (const QString &p, removedProperties) - updateProperty(p, QVariant()); + return new OfonoRadioSettings("org.ofono", path, QDBusConnection::systemBus(), this); } -QString QOfonoRadioSettings::modemPath() const +void QOfonoRadioSettings::setModemPath(const QString &path) { - return d_ptr->modemPath; + SUPER::setModemPath(path); } - -void QOfonoRadioSettings::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +QString QOfonoRadioSettings::modemPath() const { - updateProperty(property, dbusvalue.variant()); + return SUPER::modemPath(); } -void QOfonoRadioSettings::updateProperty(const QString &property, const QVariant &value) +void QOfonoRadioSettings::propertyChanged(const QString &property, const QVariant &value) { - if (d_ptr->properties.value(property) == value) - return; - - if (value.isValid()) - d_ptr->properties.insert(property, value); - else - d_ptr->properties.remove(property); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("TechnologyPreference")) { Q_EMIT technologyPreferenceChanged(value.value()); } else if (property == QLatin1String("GsmBand")) { @@ -108,49 +58,45 @@ QString QOfonoRadioSettings::technologyPreference() const { - return d_ptr->properties["TechnologyPreference"].value(); + return getString("TechnologyPreference"); } void QOfonoRadioSettings::setTechnologyPreference(const QString &preference) { - if( d_ptr->radioSettings) - d_ptr->radioSettings->SetProperty("TechnologyPreference", QDBusVariant(preference)); + setProperty("TechnologyPreference", preference); } QString QOfonoRadioSettings::gsmBand() const { - return d_ptr->properties["GsmBand"].value(); + return getString("GsmBand"); } void QOfonoRadioSettings::setGsmBand(const QString &gsmBand) { - if( d_ptr->radioSettings) - d_ptr->radioSettings->SetProperty("GsmBand", QDBusVariant(gsmBand)); + setProperty("GsmBand", gsmBand); } QString QOfonoRadioSettings::umtsBand() const { - return d_ptr->properties["UmtsBand"].value(); + return getString("UmtsBand"); } void QOfonoRadioSettings::setUmtsBand(const QString &umtsBand) { - if( d_ptr->radioSettings) - d_ptr->radioSettings->SetProperty("UmtsBand", QDBusVariant(umtsBand)); + setProperty("UmtsBand", umtsBand); } bool QOfonoRadioSettings::fastDormancy() const { - return d_ptr->properties["FastDormancy"].value(); + return getBool("FastDormancy"); } void QOfonoRadioSettings::setFastDormancy(bool fastDormancy) { - if( d_ptr->radioSettings) - d_ptr->radioSettings->SetProperty("FastDormancy", QDBusVariant(fastDormancy)); + setProperty("FastDormancy", fastDormancy); } bool QOfonoRadioSettings::isValid() const { - return d_ptr->radioSettings->isValid(); + return SUPER::isValid(); } diff -Nru libqofono-0.53/src/qofonoradiosettings.h libqofono-0.70~rtm/src/qofonoradiosettings.h --- libqofono-0.53/src/qofonoradiosettings.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonoradiosettings.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,22 +16,18 @@ #ifndef QOFONORadioSettings_H #define QOFONORadioSettings_H -#include -#include - +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono radio settings API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/radio-settings-api.txt */ - -class QOfonoRadioSettingsPrivate; -class QOFONOSHARED_EXPORT QOfonoRadioSettings : public QObject +class QOFONOSHARED_EXPORT QOfonoRadioSettings : public QOfonoModemInterface { Q_OBJECT Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) - Q_PROPERTY(QString technologyPreference READ technologyPreference WRITE setTechnologyPreference NOTIFY technologyPreferenceChanged) Q_PROPERTY(QString gsmBand READ gsmBand WRITE setGsmBand NOTIFY gsmBandChanged) Q_PROPERTY(QString umtsBand READ umtsBand WRITE setUmtsBand NOTIFY umtsBandChanged) @@ -57,6 +53,7 @@ void setFastDormancy(bool fastDormancy); bool isValid() const; + Q_SIGNALS: void technologyPreferenceChanged(const QString &preference); void gsmBandChanged(const QString &gsmBand); @@ -64,14 +61,9 @@ void fastDormancyChanged(bool fastDormancy); void modemPathChanged(const QString &path); -public slots: - -private: - void updateProperty(const QString &property, const QVariant &value); - - QOfonoRadioSettingsPrivate *d_ptr; -private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &key, const QVariant &value); }; #endif // QOFONORadioSettings_H diff -Nru libqofono-0.53/src/qofonosimmanager.cpp libqofono-0.70~rtm/src/qofonosimmanager.cpp --- libqofono-0.53/src/qofonosimmanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonosimmanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -13,147 +13,51 @@ ** ****************************************************************************/ -#include - #include "qofonosimmanager.h" -#include "qofonomodem.h" -#include "qofonoutils_p.h" #include "dbus/ofonosimmanager.h" -static const int qofonosimmanager_pinRetries = 3; -static const int qofonosimmanager_pukRetries = 10; +#define SUPER QOfonoModemInterface -static QHash qofonosimmanager_pinTypes() -{ - QHash types; - types[QOfonoSimManager::NoPin] = "none"; - types[QOfonoSimManager::SimPin] = "pin"; - types[QOfonoSimManager::SimPin2] = "pin2"; - types[QOfonoSimManager::PhoneToSimPin] = "phone"; - types[QOfonoSimManager::PhoneToFirstSimPin] = "firstphone"; - types[QOfonoSimManager::NetworkPersonalizationPin] = "network"; - types[QOfonoSimManager::NetworkSubsetPersonalizationPin] = "netsub"; - types[QOfonoSimManager::ServiceProviderPersonalizationPin] = "service"; - types[QOfonoSimManager::CorporatePersonalizationPin] = "corp"; - types[QOfonoSimManager::SimPuk] = "puk"; - types[QOfonoSimManager::SimPuk2] = "puk2"; - types[QOfonoSimManager::PhoneToFirstSimPuk] = "firstphonepuk"; - types[QOfonoSimManager::NetworkPersonalizationPuk] = "networkpuk"; - types[QOfonoSimManager::NetworkSubsetPersonalizationPuk] = "netsubpuk"; - types[QOfonoSimManager::CorporatePersonalizationPuk] = "corppuk"; - return types; -} - -class QOfonoSimManagerPrivate -{ -public: - QOfonoSimManagerPrivate(); - QString modemPath; - OfonoSimManager *simManager; - QVariantMap properties; - QOfonoModem *oModem; - static QHash allPinTypes; -}; - -QHash QOfonoSimManagerPrivate::allPinTypes = qofonosimmanager_pinTypes(); - -QOfonoSimManagerPrivate::QOfonoSimManagerPrivate() : - modemPath(QString()), - simManager(0), - oModem(0) +namespace QOfonoSimManagerPrivate { + static QHash pinTypes() + { + QHash types; + types[QOfonoSimManager::NoPin] = "none"; + types[QOfonoSimManager::SimPin] = "pin"; + types[QOfonoSimManager::SimPin2] = "pin2"; + types[QOfonoSimManager::PhoneToSimPin] = "phone"; + types[QOfonoSimManager::PhoneToFirstSimPin] = "firstphone"; + types[QOfonoSimManager::NetworkPersonalizationPin] = "network"; + types[QOfonoSimManager::NetworkSubsetPersonalizationPin] = "netsub"; + types[QOfonoSimManager::ServiceProviderPersonalizationPin] = "service"; + types[QOfonoSimManager::CorporatePersonalizationPin] = "corp"; + types[QOfonoSimManager::SimPuk] = "puk"; + types[QOfonoSimManager::SimPuk2] = "puk2"; + types[QOfonoSimManager::PhoneToFirstSimPuk] = "firstphonepuk"; + types[QOfonoSimManager::NetworkPersonalizationPuk] = "networkpuk"; + types[QOfonoSimManager::NetworkSubsetPersonalizationPuk] = "netsubpuk"; + types[QOfonoSimManager::CorporatePersonalizationPuk] = "corppuk"; + return types; + } + static QHash allPinTypes = pinTypes(); } QOfonoSimManager::QOfonoSimManager(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoSimManagerPrivate) + SUPER(OfonoSimManager::staticInterfaceName(), parent) { - d_ptr->oModem = new QOfonoModem(this); } QOfonoSimManager::~QOfonoSimManager() { - delete d_ptr; -} - -void QOfonoSimManager::setModemPath(const QString &path) -{ - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - d_ptr->modemPath = path; - Q_EMIT modemPathChanged(path); - - d_ptr->oModem->setModemPath(path); - - connect(d_ptr->oModem, SIGNAL(interfacesChanged(QStringList)), - this, SLOT(modemInterfacesChanged(QStringList))); - modemInterfacesChanged(d_ptr->oModem->interfaces()); -} - -void QOfonoSimManager::initialize() -{ - if (d_ptr->modemPath.isEmpty()) - return; - - delete d_ptr->simManager; - d_ptr->simManager = new OfonoSimManager("org.ofono", d_ptr->modemPath, QDBusConnection::systemBus(), this); - - if (d_ptr->simManager->isValid()) { - - connect(d_ptr->simManager,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - getAllProperties(); - } } -void QOfonoSimManager::modemInterfacesChanged(const QStringList &list) +QDBusAbstractInterface *QOfonoSimManager::createDbusInterface(const QString &path) { - if (list.contains(QLatin1String("org.ofono.SimManager"))) { - // FIXME: must also handle !simMan->isValid and maybe - // properties.isEmpty - if (!d_ptr->simManager) - initialize(); - } else { - if (d_ptr->simManager) { - delete d_ptr->simManager; - d_ptr->simManager = 0; - foreach (const QString &p, d_ptr->properties.keys()) - updateProperty(p, QVariant()); - } - } + return new OfonoSimManager("org.ofono", path, QDBusConnection::systemBus(), this); } -void QOfonoSimManager::getAllProperties() -{ - QStringList removedProperties = d_ptr->properties.keys(); - - QDBusPendingReply reply = d_ptr->simManager->GetProperties(); - reply.waitForFinished(); - QVariantMap properties = reply.value(); - - for (QVariantMap::ConstIterator it = properties.constBegin(); - it != properties.constEnd(); ++it) { - updateProperty(it.key(), it.value()); - removedProperties.removeOne(it.key()); - } - foreach (const QString &p, removedProperties) - updateProperty(p, QVariant()); - -} - -QString QOfonoSimManager::modemPath() const -{ - return d_ptr->modemPath; -} - -void QOfonoSimManager::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) -{ - updateProperty(property, dbusvalue.variant()); -} - -void QOfonoSimManager::updateProperty(const QString& property, const QVariant& value_) +QVariant QOfonoSimManager::convertProperty(const QString &property, const QVariant &value) { // Perform necessary type conversions // This serve two purposes: @@ -161,60 +65,53 @@ // (2) Possibility to compare with QVariant::operator== (comparing variants // of user type is NOT supported with Qt < 5.2 and with Qt >= 5.2 it // relies on QVariant::registerComparisonOperators) - QVariant value = value_; - if (value.isValid()) { - if (property == QLatin1String("ServiceNumbers")) { - QVariantMap convertedNumbers; - if (value.userType() == qMetaTypeId()) { - QMap numbers; - value.value() >> numbers; - Q_FOREACH(const QString &key, numbers.keys()) { - convertedNumbers.insert(key, numbers.value(key)); - } + if (property == QLatin1String("ServiceNumbers")) { + QVariantMap convertedNumbers; + if (value.userType() == qMetaTypeId()) { + QMap numbers; + value.value() >> numbers; + Q_FOREACH(const QString &key, numbers.keys()) { + convertedNumbers.insert(key, numbers.value(key)); } - value = convertedNumbers; - } else if (property == QLatin1String("LockedPins")) { - QVariantList convertedPins; - if (value.userType() == qMetaTypeId()) { - QStringList pins = value.value(); - Q_FOREACH(QString type, pins) { - convertedPins << (int)pinTypeFromString(type); - } + } + return convertedNumbers; + } else if (property == QLatin1String("LockedPins")) { + QVariantList convertedPins; + if (value.userType() == qMetaTypeId()) { + QStringList pins = value.value(); + Q_FOREACH(QString type, pins) { + convertedPins << (int)pinTypeFromString(type); } - value = convertedPins; - } else if (property == QLatin1String("PinRequired")) { - // Use int instead of QString so that default value can be - // default-constructed (NoPin corresponds to "none") (Also not - // using PinType for above mentioned reason) - value = (int)pinTypeFromString(value.value()); - } else if (property == QLatin1String("Retries")) { - QVariantMap convertedRetries; - if (value.userType() == qMetaTypeId()) { - QMap retries; - value.value() >> retries; - Q_FOREACH(const QString &type, retries.keys()) { - QVariant retryCountVariant = retries[type]; - bool ok = false; - int retryCount = retryCountVariant.toInt(&ok); - if (ok) { - convertedRetries[QString::number(pinTypeFromString(type))] = retryCount; - } + } + return convertedPins; + } else if (property == QLatin1String("PinRequired")) { + // Use int instead of QString so that default value can be + // default-constructed (NoPin corresponds to "none") (Also not + // using PinType for above mentioned reason) + return (int)pinTypeFromString(value.value()); + } else if (property == QLatin1String("Retries")) { + QVariantMap convertedRetries; + if (value.userType() == qMetaTypeId()) { + QMap retries; + value.value() >> retries; + Q_FOREACH(const QString &type, retries.keys()) { + QVariant retryCountVariant = retries[type]; + bool ok = false; + int retryCount = retryCountVariant.toInt(&ok); + if (ok) { + convertedRetries[QString::number(pinTypeFromString(type))] = retryCount; } } - value = convertedRetries; } + return convertedRetries; + } else { + return SUPER::convertProperty(property, value); } +} - QVariant old = d_ptr->properties.value(property); - - if (value.isValid()) - d_ptr->properties.insert(property, value); - else - d_ptr->properties.remove(property); - - if (qofono::safeVariantEq(old, value)) - return; - +void QOfonoSimManager::propertyChanged(const QString &property, const QVariant &value) +{ + SUPER::propertyChanged(property, value); if (property == QLatin1String("Present")) { Q_EMIT presenceChanged(value.value()); } else if (property == QLatin1String("SubscriberIdentity")) { @@ -226,17 +123,17 @@ } else if (property == QLatin1String("SubscriberNumbers")) { Q_EMIT subscriberNumbersChanged(value.value()); } else if (property == QLatin1String("ServiceNumbers")) { - Q_EMIT serviceNumbersChanged(value.value()); + Q_EMIT serviceNumbersChanged(getVariantMap("ServiceNumbers")); } else if (property == QLatin1String("PinRequired")) { - Q_EMIT pinRequiredChanged((PinType)value.value()); + Q_EMIT pinRequiredChanged((PinType)getInt("PinRequired")); } else if (property == QLatin1String("LockedPins")) { - Q_EMIT lockedPinsChanged(value.value()); + Q_EMIT lockedPinsChanged(getVariantList("LockedPins")); } else if (property == QLatin1String("CardIdentifier")) { Q_EMIT cardIdentifierChanged(value.value()); } else if (property == QLatin1String("PreferredLanguages")) { Q_EMIT preferredLanguagesChanged(value.value()); } else if (property == QLatin1String("Retries")) { - Q_EMIT pinRetriesChanged(value.value()); + Q_EMIT pinRetriesChanged(getVariantMap("Retries")); } else if (property == QLatin1String("FixedDialing")) { Q_EMIT fixedDialingChanged(value.value()); } else if (property == QLatin1String("BarredDialing")) { @@ -246,176 +143,142 @@ bool QOfonoSimManager::present() const { - if (d_ptr->simManager) - return d_ptr->properties["Present"].value(); - else - return false; + return getBool("Present"); } QString QOfonoSimManager::subscriberIdentity() const { - if (d_ptr->simManager) - return d_ptr->properties["SubscriberIdentity"].value(); - else - return QString(); + return getString("SubscriberIdentity"); } QString QOfonoSimManager::mobileCountryCode() const { - if (d_ptr->simManager) - return d_ptr->properties["MobileCountryCode"].value(); - else - return QString(); + return getString("MobileCountryCode"); } QString QOfonoSimManager::mobileNetworkCode() const { - if (d_ptr->simManager) - return d_ptr->properties["MobileNetworkCode"].value(); - else - return QString(); + return getString("MobileNetworkCode"); } QStringList QOfonoSimManager::subscriberNumbers() const { - if (d_ptr->simManager) - return d_ptr->properties["SubscriberNumbers"].value(); - else - return QStringList(); + return getStringList("SubscriberNumbers"); } QVariantMap QOfonoSimManager::serviceNumbers() const // { - if (d_ptr->simManager) - return d_ptr->properties["ServiceNumbers"].value(); - else - return QVariantMap(); + return getVariantMap("ServiceNumbers"); } QOfonoSimManager::PinType QOfonoSimManager::pinRequired() const { - if (d_ptr->simManager) - return (PinType)d_ptr->properties["PinRequired"].value(); - else - return QOfonoSimManager::NoPin; + return (PinType)getInt("PinRequired"); } QVariantList QOfonoSimManager::lockedPins() const { - if (d_ptr->simManager) - return d_ptr->properties["LockedPins"].value(); - else - return QVariantList(); + return getVariantList("LockedPins"); } QString QOfonoSimManager::cardIdentifier() const { - if (d_ptr->simManager) - return d_ptr->properties["CardIdentifier"].value(); - else - return QString(); + return getString("CardIdentifier"); } QStringList QOfonoSimManager::preferredLanguages() const { - if (d_ptr->simManager) - return d_ptr->properties["PreferredLanguages"].value(); - else - return QStringList(); + return getStringList("PreferredLanguages"); } QVariantMap QOfonoSimManager::pinRetries() const { - if (d_ptr->simManager) - return d_ptr->properties["Retries"].value(); - else - return QVariantMap(); + return getVariantMap("Retries"); } bool QOfonoSimManager::fixedDialing() const { - if (d_ptr->simManager) - return d_ptr->properties["FixedDialing"].value(); - else - return false; + return getBool("FixedDialing"); } bool QOfonoSimManager::barredDialing() const { - if (d_ptr->simManager) - return d_ptr->properties["BarredDialing"].value(); - else - return false; + return getBool("BarredDialing"); +} + +void QOfonoSimManager::setSubscriberNumbers(const QStringList &numbers) +{ + setProperty("SubscriberNumbers", numbers); } void QOfonoSimManager::changePin(QOfonoSimManager::PinType pinType, const QString &oldpin, const QString &newpin) { - if (d_ptr->simManager) { - QDBusPendingReply<> result = d_ptr->simManager->ChangePin(pinTypeToString(pinType), oldpin, newpin); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(changePinCallFinished(QDBusPendingCallWatcher*))); + OfonoSimManager *iface = (OfonoSimManager*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->ChangePin(pinTypeToString(pinType), oldpin, newpin), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(changePinCallFinished(QDBusPendingCallWatcher*))); } } void QOfonoSimManager::enterPin(QOfonoSimManager::PinType pinType, const QString &pin) { - if (d_ptr->simManager) { - QDBusPendingReply<> result = d_ptr->simManager->EnterPin(pinTypeToString(pinType), pin); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(enterPinCallFinished(QDBusPendingCallWatcher*))); + OfonoSimManager *iface = (OfonoSimManager*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->EnterPin(pinTypeToString(pinType), pin), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(enterPinCallFinished(QDBusPendingCallWatcher*))); } } void QOfonoSimManager::resetPin(QOfonoSimManager::PinType pinType, const QString &puk, const QString &newpin) { - if (d_ptr->simManager) { - QDBusPendingReply<> result = d_ptr->simManager->ResetPin(pinTypeToString(pinType), puk, newpin); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(resetPinCallFinished(QDBusPendingCallWatcher*))); + OfonoSimManager *iface = (OfonoSimManager*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->ResetPin(pinTypeToString(pinType), puk, newpin), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(resetPinCallFinished(QDBusPendingCallWatcher*))); } } void QOfonoSimManager::lockPin(QOfonoSimManager::PinType pinType, const QString &pin) { - if (d_ptr->simManager) { - QDBusPendingReply<> result = d_ptr->simManager->LockPin(pinTypeToString(pinType), pin); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(lockPinCallFinished(QDBusPendingCallWatcher*))); + OfonoSimManager *iface = (OfonoSimManager*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->LockPin(pinTypeToString(pinType), pin), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(lockPinCallFinished(QDBusPendingCallWatcher*))); } } void QOfonoSimManager::unlockPin(QOfonoSimManager::PinType pinType, const QString &pin) { - if (d_ptr->simManager) { - QDBusPendingReply<> result = d_ptr->simManager->UnlockPin(pinTypeToString(pinType), pin); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(unlockPinCallFinished(QDBusPendingCallWatcher*))); + OfonoSimManager *iface = (OfonoSimManager*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher( + iface->UnlockPin(pinTypeToString(pinType), pin), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(unlockPinCallFinished(QDBusPendingCallWatcher*))); } } QByteArray QOfonoSimManager::getIcon(quint8 id) { - QDBusMessage request = QDBusMessage::createMethodCall("org.ofono", - d_ptr->simManager->path(), - "org.ofono.SimManager", - "GetIcon"); - request.setArguments(QList() << QVariant::fromValue(id)); - - QDBusReply reply2 = QDBusConnection::systemBus().call(request); - - return reply2.value(); -} - - -void QOfonoSimManager::setSubscriberNumbers(const QStringList &numbers) -{ - if (d_ptr->simManager) - d_ptr->simManager->SetProperty("SubscriberNumbers",QDBusVariant(numbers)); + OfonoSimManager *iface = (OfonoSimManager*)dbusInterface(); + if (iface) { + // BLOCKING CALL! + QDBusPendingReply reply = iface->GetIcon(id); + reply.waitForFinished(); + if (!reply.isError()) { + return reply.value(); + } + qDebug() << reply.error().message(); + } + return QByteArray(); } void QOfonoSimManager::changePinCallFinished(QDBusPendingCallWatcher *call) @@ -600,7 +463,17 @@ } } +QString QOfonoSimManager::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoSimManager::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); +} + bool QOfonoSimManager::isValid() const { - return d_ptr->simManager && d_ptr->simManager->isValid(); + return SUPER::isValid(); } diff -Nru libqofono-0.53/src/qofonosimmanager.h libqofono-0.70~rtm/src/qofonosimmanager.h --- libqofono-0.53/src/qofonosimmanager.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonosimmanager.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,31 +16,25 @@ #ifndef QOFONOSimManager_H #define QOFONOSimManager_H -#include -#include -#include - +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono SIM API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/sim-api.txt */ - -class QOfonoSimManagerPrivate; -class QDBusPendingCallWatcher; - -class QOFONOSHARED_EXPORT QOfonoSimManager : public QObject +class QOFONOSHARED_EXPORT QOfonoSimManager : public QOfonoModemInterface { Q_OBJECT Q_ENUMS(Error) Q_ENUMS(PinType) - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(bool present READ present NOTIFY presenceChanged) Q_PROPERTY(QString subscriberIdentity READ subscriberIdentity NOTIFY subscriberIdentityChanged) Q_PROPERTY(QString mobileCountryCode READ mobileCountryCode NOTIFY mobileCountryCodeChanged) Q_PROPERTY(QString mobileNetworkCode READ mobileNetworkCode NOTIFY mobileNetworkCodeChanged) Q_PROPERTY(QStringList subscriberNumbers READ subscriberNumbers WRITE setSubscriberNumbers NOTIFY subscriberNumbersChanged) + Q_PROPERTY(QVariantMap serviceNumbers READ serviceNumbers NOTIFY serviceNumbersChanged) Q_PROPERTY(PinType pinRequired READ pinRequired NOTIFY pinRequiredChanged) Q_PROPERTY(QVariantList lockedPins READ lockedPins NOTIFY lockedPinsChanged) Q_PROPERTY(QString cardIdentifier READ cardIdentifier NOTIFY cardIdentifierChanged) @@ -100,63 +94,57 @@ bool isValid() const; Q_SIGNALS: - void modemPathChanged(const QString &modemPath); - void presenceChanged(bool ispresent); - void subscriberIdentityChanged(const QString &imsi); - void mobileCountryCodeChanged(const QString &mcc); - void mobileNetworkCodeChanged(const QString &mnc); - void subscriberNumbersChanged(const QStringList &msisdns); - void serviceNumbersChanged(const QVariantMap &sdns); - void pinRequiredChanged(int pinType); - void lockedPinsChanged(const QVariantList &pins); - void cardIdentifierChanged(const QString &iccid); - void preferredLanguagesChanged(const QStringList &languages); - void pinRetriesChanged(const QVariantMap &pinRetries); - void fixedDialingChanged(bool fixedDialing); - void barredDialingChanged(bool barredDialing); - - void enterPinComplete(QOfonoSimManager::Error error, const QString &errorString); - void resetPinComplete(QOfonoSimManager::Error error, const QString &errorString); - void changePinComplete(QOfonoSimManager::Error error, const QString &errorString); - void lockPinComplete(QOfonoSimManager::Error error, const QString &errorString); - void unlockPinComplete(QOfonoSimManager::Error error, const QString &errorString); + void presenceChanged(bool ispresent); + void subscriberIdentityChanged(const QString &imsi); + void mobileCountryCodeChanged(const QString &mcc); + void mobileNetworkCodeChanged(const QString &mnc); + void subscriberNumbersChanged(const QStringList &msisdns); + void serviceNumbersChanged(const QVariantMap &sdns); + void pinRequiredChanged(int pinType); + void lockedPinsChanged(const QVariantList &pins); + void cardIdentifierChanged(const QString &iccid); + void preferredLanguagesChanged(const QStringList &languages); + void pinRetriesChanged(const QVariantMap &pinRetries); + void fixedDialingChanged(bool fixedDialing); + void barredDialingChanged(bool barredDialing); + + void enterPinComplete(QOfonoSimManager::Error error, const QString &errorString); + void resetPinComplete(QOfonoSimManager::Error error, const QString &errorString); + void changePinComplete(QOfonoSimManager::Error error, const QString &errorString); + void lockPinComplete(QOfonoSimManager::Error error, const QString &errorString); + void unlockPinComplete(QOfonoSimManager::Error error, const QString &errorString); public slots: - void changePin(QOfonoSimManager::PinType pinType, const QString &oldpin, const QString &newpin); - void enterPin(QOfonoSimManager::PinType pinType, const QString &pin); - void resetPin(QOfonoSimManager::PinType pinType, const QString &puk, const QString &newpin); - void lockPin(QOfonoSimManager::PinType pinType, const QString &pin); - void unlockPin(QOfonoSimManager::PinType pinType, const QString &pin); - QByteArray getIcon(quint8 id); - - void setSubscriberNumbers(const QStringList &numbers); - - static int minimumPinLength(QOfonoSimManager::PinType pinType); - static int maximumPinLength(QOfonoSimManager::PinType pinType); - static QString pinTypeToString(QOfonoSimManager::PinType pinType); - static int pinTypeFromString(const QString &s); - static bool isPukType(QOfonoSimManager::PinType pinType); - static int pukToPin(QOfonoSimManager::PinType puk); + void changePin(QOfonoSimManager::PinType pinType, const QString &oldpin, const QString &newpin); + void enterPin(QOfonoSimManager::PinType pinType, const QString &pin); + void resetPin(QOfonoSimManager::PinType pinType, const QString &puk, const QString &newpin); + void lockPin(QOfonoSimManager::PinType pinType, const QString &pin); + void unlockPin(QOfonoSimManager::PinType pinType, const QString &pin); + QByteArray getIcon(quint8 id); + + void setSubscriberNumbers(const QStringList &numbers); + + static int minimumPinLength(QOfonoSimManager::PinType pinType); + static int maximumPinLength(QOfonoSimManager::PinType pinType); + static QString pinTypeToString(QOfonoSimManager::PinType pinType); + static int pinTypeFromString(const QString &s); + static bool isPukType(QOfonoSimManager::PinType pinType); + static int pukToPin(QOfonoSimManager::PinType puk); private: - void updateProperty(const QString& property, const QVariant& value); - Error errorNameToEnum(const QString &errorName); - - QOfonoSimManagerPrivate *d_ptr; + Error errorNameToEnum(const QString &errorName); +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + QVariant convertProperty(const QString &property, const QVariant &value); + void propertyChanged(const QString &property, const QVariant &value); private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); void changePinCallFinished(QDBusPendingCallWatcher *call); void enterPinCallFinished(QDBusPendingCallWatcher *call); void resetPinCallFinished(QDBusPendingCallWatcher *call); void lockPinCallFinished(QDBusPendingCallWatcher *call); void unlockPinCallFinished(QDBusPendingCallWatcher *call); - - void getAllProperties(); - void initialize(); - void modemInterfacesChanged(const QStringList &); - }; #endif // QOFONOSimManager_H diff -Nru libqofono-0.53/src/qofonosmartmessaging.cpp libqofono-0.70~rtm/src/qofonosmartmessaging.cpp --- libqofono-0.53/src/qofonosmartmessaging.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonosmartmessaging.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,87 +16,73 @@ #include "qofonosmartmessaging.h" #include "dbus/ofonosmartmessaging.h" -class QOfonoSmartMessagingPrivate -{ -public: - QOfonoSmartMessagingPrivate(); - QString modemPath; - OfonoSmartMessaging *smartMessaging; -}; - -QOfonoSmartMessagingPrivate::QOfonoSmartMessagingPrivate() : - modemPath(QString()) - , smartMessaging(0) -{ -} +#define SUPER QOfonoModemInterface2 QOfonoSmartMessaging::QOfonoSmartMessaging(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoSmartMessagingPrivate) + SUPER(OfonoSmartMessaging::staticInterfaceName(), parent) { } QOfonoSmartMessaging::~QOfonoSmartMessaging() { - delete d_ptr; -} - -void QOfonoSmartMessaging::setModemPath(const QString &path) -{ - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - if (path != modemPath()) { - if (d_ptr->smartMessaging) { - delete d_ptr->smartMessaging; - d_ptr->smartMessaging = 0; - } - d_ptr->smartMessaging = new OfonoSmartMessaging("org.ofono", path, QDBusConnection::systemBus(),this); - if (d_ptr->smartMessaging->isValid()) { - d_ptr->modemPath = path; - Q_EMIT modemPathChanged(path); - } - } - } -QString QOfonoSmartMessaging::modemPath() const +QDBusAbstractInterface *QOfonoSmartMessaging::createDbusInterface(const QString &path) { - return d_ptr->modemPath; + return new OfonoSmartMessaging("org.ofono", path, QDBusConnection::systemBus(), this); } QDBusObjectPath QOfonoSmartMessaging::sendAppointment(const QString &toPhoneNumber, const QByteArray &appointment) { - if (d_ptr->smartMessaging) { - QDBusPendingReply returnPath = d_ptr->smartMessaging->SendAppointment(toPhoneNumber, appointment); - return returnPath; + OfonoSmartMessaging *iface = (OfonoSmartMessaging*)dbusInterface(); + if (iface) { + // BLOCKING CALL! + QDBusPendingReply returnPath = iface->SendAppointment(toPhoneNumber, appointment); + returnPath.waitForFinished(); + return returnPath.value(); } return QDBusObjectPath(); } QDBusObjectPath QOfonoSmartMessaging::sendBusinessCard(const QString &toPhoneNumber, const QByteArray &card) { - if (d_ptr->smartMessaging) { - QDBusPendingReply returnPath = d_ptr->smartMessaging->SendBusinessCard(toPhoneNumber,card); - return returnPath; + OfonoSmartMessaging *iface = (OfonoSmartMessaging*)dbusInterface(); + if (iface) { + // BLOCKING CALL! + QDBusPendingReply returnPath = iface->SendBusinessCard(toPhoneNumber,card); + returnPath.waitForFinished(); + return returnPath.value(); } return QDBusObjectPath(); } void QOfonoSmartMessaging::registerAgent(const QString &objectPath) { - if (d_ptr->smartMessaging) - d_ptr->smartMessaging->RegisterAgent(QDBusObjectPath(objectPath)); + OfonoSmartMessaging *iface = (OfonoSmartMessaging*)dbusInterface(); + if (iface) { + iface->RegisterAgent(QDBusObjectPath(objectPath)); + } } void QOfonoSmartMessaging::unregisterAgent(const QString &objectPath) { - if (d_ptr->smartMessaging) - d_ptr->smartMessaging->UnregisterAgent(QDBusObjectPath(objectPath)); + OfonoSmartMessaging *iface = (OfonoSmartMessaging*)dbusInterface(); + if (iface) { + iface->UnregisterAgent(QDBusObjectPath(objectPath)); + } +} + +QString QOfonoSmartMessaging::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoSmartMessaging::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); } bool QOfonoSmartMessaging::isValid() const { - return d_ptr->smartMessaging->isValid(); + return SUPER::isValid(); } diff -Nru libqofono-0.53/src/qofonosmartmessaging.h libqofono-0.70~rtm/src/qofonosmartmessaging.h --- libqofono-0.53/src/qofonosmartmessaging.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonosmartmessaging.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,21 +16,17 @@ #ifndef QOFONOSMARTMESSAGING_H #define QOFONOSMARTMESSAGING_H -#include -#include - +#include "qofonomodeminterface2.h" #include "qofono_global.h" + //! This class is used to access ofono cell broadcast API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/smartmessaging-api.txt */ - -class QOfonoSmartMessagingPrivate; -class QOFONOSHARED_EXPORT QOfonoSmartMessaging : public QObject +class QOFONOSHARED_EXPORT QOfonoSmartMessaging : public QOfonoModemInterface2 { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) public: explicit QOfonoSmartMessaging(QObject *parent = 0); @@ -39,18 +35,16 @@ QString modemPath() const; void setModemPath(const QString &path); bool isValid() const; -public slots: +public slots: QDBusObjectPath sendAppointment(const QString &toPhoneNumber, const QByteArray &appointment); QDBusObjectPath sendBusinessCard(const QString &toPhoneNumber, const QByteArray &card); void registerAgent(const QString &objectPath); void unregisterAgent(const QString &objectPath); -Q_SIGNALS: - void modemPathChanged(const QString &path); -private: - QOfonoSmartMessagingPrivate *d_ptr; +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); }; #endif // QOFONOSMARTMESSAGING_H diff -Nru libqofono-0.53/src/qofonosupplementaryservices.cpp libqofono-0.70~rtm/src/qofonosupplementaryservices.cpp --- libqofono-0.53/src/qofonosupplementaryservices.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonosupplementaryservices.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,117 +16,63 @@ #include "qofonosupplementaryservices.h" #include "dbus/ofonosupplementaryservices.h" -class QOfonoSupplementaryServicesPrivate -{ -public: - QOfonoSupplementaryServicesPrivate(); - QString modemPath; - OfonoSupplementaryServices *supplementaryServices; - QVariantMap properties; - -}; - -QOfonoSupplementaryServicesPrivate::QOfonoSupplementaryServicesPrivate() : - modemPath(QString()) - , supplementaryServices(0) -{ -} +#define SUPER QOfonoModemInterface QOfonoSupplementaryServices::QOfonoSupplementaryServices(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoSupplementaryServicesPrivate) + SUPER(OfonoSupplementaryServices::staticInterfaceName(), parent) { } QOfonoSupplementaryServices::~QOfonoSupplementaryServices() { - delete d_ptr; } -void QOfonoSupplementaryServices::setModemPath(const QString &path) +QDBusAbstractInterface *QOfonoSupplementaryServices::createDbusInterface(const QString &path) { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - if (path != modemPath()) { - if (d_ptr->supplementaryServices) { - delete d_ptr->supplementaryServices; - d_ptr->supplementaryServices = 0; - d_ptr->properties.clear(); - } - d_ptr->supplementaryServices = new OfonoSupplementaryServices("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->supplementaryServices->isValid()) { - d_ptr->modemPath = path; - - connect(d_ptr->supplementaryServices,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - connect(d_ptr->supplementaryServices,SIGNAL(NotificationReceived(QString)), - this,SIGNAL(notificationReceived(QString))); - connect(d_ptr->supplementaryServices,SIGNAL(RequestReceived(QString)), - this,SIGNAL(requestReceived(QString))); - QDBusPendingReply reply; - reply = d_ptr->supplementaryServices->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - Q_EMIT modemPathChanged(path); - } - } -} - -QString QOfonoSupplementaryServices::modemPath() const -{ - return d_ptr->modemPath; + return new OfonoSupplementaryServices("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoSupplementaryServices::initiate(const QString &command) { - QDBusPendingReply result = d_ptr->supplementaryServices->Initiate(command); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + OfonoSupplementaryServices *iface = (OfonoSupplementaryServices*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher(iface->Initiate(command), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(initiateResponseReceived(QDBusPendingCallWatcher*))); + } } void QOfonoSupplementaryServices::respond(const QString &command) { - QDBusPendingReply result = d_ptr->supplementaryServices->Respond(command); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + OfonoSupplementaryServices *iface = (OfonoSupplementaryServices*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher(iface->Respond(command), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(respondResponseReceived(QDBusPendingCallWatcher*))); + } } void QOfonoSupplementaryServices::cancel() { - QDBusPendingReply<> result = d_ptr->supplementaryServices->Cancel(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + OfonoSupplementaryServices *iface = (OfonoSupplementaryServices*)dbusInterface(); + if (iface) { + connect(new QDBusPendingCallWatcher(iface->Cancel(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(cancelResponseReceived(QDBusPendingCallWatcher*))); + } } -void QOfonoSupplementaryServices::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +void QOfonoSupplementaryServices::propertyChanged(const QString &property, const QVariant &value) { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); - + SUPER::propertyChanged(property, value); if (property == QLatin1String("State")) { Q_EMIT stateChanged(value.value()); } } - QString QOfonoSupplementaryServices::state() const { - if (d_ptr->supplementaryServices) - return d_ptr->properties["State"].value(); - else - return QString(); -} - -bool QOfonoSupplementaryServices::isValid() const -{ - return d_ptr->supplementaryServices->isValid(); + return getString("State"); } void QOfonoSupplementaryServices::initiateResponseReceived(QDBusPendingCallWatcher *call) @@ -216,3 +162,18 @@ QDBusPendingReply<> reply = *call; Q_EMIT cancelComplete(!reply.isError()); } + +QString QOfonoSupplementaryServices::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoSupplementaryServices::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); +} + +bool QOfonoSupplementaryServices::isValid() const +{ + return SUPER::isValid(); +} diff -Nru libqofono-0.53/src/qofonosupplementaryservices.h libqofono-0.70~rtm/src/qofonosupplementaryservices.h --- libqofono-0.53/src/qofonosupplementaryservices.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonosupplementaryservices.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,20 +16,17 @@ #ifndef QOFONOSupplimentaryServices_H #define QOFONOSupplimentaryServices_H -#include -#include +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono supplementary services API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/supplementaryservices-api.txt */ - -class QOfonoSupplementaryServicesPrivate; -class QOFONOSHARED_EXPORT QOfonoSupplementaryServices : public QObject +class QOFONOSHARED_EXPORT QOfonoSupplementaryServices : public QOfonoModemInterface { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QString state READ state NOTIFY stateChanged) public: @@ -65,11 +62,11 @@ void stateChanged(const QString &state); void modemPathChanged(const QString &path); -private: - QOfonoSupplementaryServicesPrivate *d_ptr; +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &key, const QVariant &value); private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); void initiateResponseReceived(QDBusPendingCallWatcher*); void respondResponseReceived(QDBusPendingCallWatcher*); void cancelResponseReceived(QDBusPendingCallWatcher*); diff -Nru libqofono-0.53/src/qofonovoicecall.cpp libqofono-0.70~rtm/src/qofonovoicecall.cpp --- libqofono-0.53/src/qofonovoicecall.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonovoicecall.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,273 +16,179 @@ #include "qofonovoicecall.h" #include "dbus/ofonovoicecall.h" -class QOfonoVoiceCallPrivate -{ -public: - QOfonoVoiceCallPrivate(); - QString voiceCallPath; - OfonoVoiceCall *voiceCall; - QVariantMap properties; +#define SUPER QOfonoObject +class QOfonoVoiceCallWatcher : public QDBusPendingCallWatcher { +public: + typedef void (QOfonoVoiceCall::*Signal)(QOfonoVoiceCall::Error,const QString&); + const char* name; + Signal signal; + QOfonoVoiceCallWatcher(QOfonoVoiceCall* target, OfonoVoiceCall *parent, + const char* callName, const QDBusPendingCall &call, Signal complete) : + QDBusPendingCallWatcher(call, parent), + name(callName), signal(complete) + { + connect(this, SIGNAL(finished(QDBusPendingCallWatcher*)), + target, SLOT(onDbusCallFinished(QDBusPendingCallWatcher*))); + } }; -QOfonoVoiceCallPrivate::QOfonoVoiceCallPrivate() : - voiceCallPath(QString()) - , voiceCall(0) -{ -} - QOfonoVoiceCall::QOfonoVoiceCall(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoVoiceCallPrivate) + SUPER(parent) { } QOfonoVoiceCall::~QOfonoVoiceCall() { - delete d_ptr; } void QOfonoVoiceCall::setVoiceCallPath(const QString &path) { - if (path != voiceCallPath()) { - if (d_ptr->voiceCall) { - delete d_ptr->voiceCall; - d_ptr->voiceCall = 0; - d_ptr->properties.clear(); - } - d_ptr->voiceCall = new OfonoVoiceCall("org.ofono", path, QDBusConnection::systemBus(),this); - - if (d_ptr->voiceCall->isValid()) { - d_ptr->voiceCallPath = path; - - connect(d_ptr->voiceCall,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - - QDBusPendingReply reply; - reply = d_ptr->voiceCall->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - Q_EMIT voiceCallPathChanged(path); - } - } + setObjectPath(path); } QString QOfonoVoiceCall::voiceCallPath() const { - return d_ptr->voiceCallPath; + return objectPath(); } -void QOfonoVoiceCall::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +void QOfonoVoiceCall::objectPathChanged(const QString &path, const QVariantMap *properties) { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); + SUPER::objectPathChanged(path, properties); + Q_EMIT voiceCallPathChanged(path); +} - if (property == QLatin1String("LineIdentification")) { - Q_EMIT lineIdentificationChanged(value.value()); +QDBusAbstractInterface *QOfonoVoiceCall::createDbusInterface(const QString &path) +{ + return new OfonoVoiceCall("org.ofono", path, QDBusConnection::systemBus(), this); +} +void QOfonoVoiceCall::propertyChanged(const QString &property, const QVariant &value) +{ + SUPER::propertyChanged(property, value); + if (property == QLatin1String("LineIdentification")) { + Q_EMIT lineIdentificationChanged(value.toString()); } else if (property == QLatin1String("DisconnectReason")) { - Q_EMIT disconnectReason(value.value()); - - + Q_EMIT disconnectReason(value.toString()); } else if (property == QLatin1String("Name")) { - Q_EMIT nameChanged(value.value()); - + Q_EMIT nameChanged(value.toString()); } else if (property == QLatin1String("State")) { - Q_EMIT stateChanged(value.value()); - + Q_EMIT stateChanged(value.toString()); } else if (property == QLatin1String("StartTime")) { - Q_EMIT startTimeChanged(value.value()); - + Q_EMIT startTimeChanged(value.toString()); } else if (property == QLatin1String("Information")) { - Q_EMIT informationChanged(value.value()); - + Q_EMIT informationChanged(value.toString()); } else if (property == QLatin1String("IncomingLine")) { - Q_EMIT incomingLineChanged(value.value()); - + Q_EMIT incomingLineChanged(value.toString()); } else if (property == QLatin1String("Multiparty")) { - Q_EMIT multipartyChanged(value.value()); - + Q_EMIT multipartyChanged(value.toBool()); } else if (property == QLatin1String("Icon")) { Q_EMIT iconChanged(value.value()); - } else if (property == QLatin1String("Emergency")) { - Q_EMIT emergencyChanged(value.value()); - + Q_EMIT emergencyChanged(value.toBool()); } else if (property == QLatin1String("RemoteHeld")) { - Q_EMIT remoteHeldChanged(value.value()); - + Q_EMIT remoteHeldChanged(value.toBool()); } else if (property == QLatin1String("RemoteMultiparty")) { - Q_EMIT remoteMultipartyChanged(value.value()); + Q_EMIT remoteMultipartyChanged(value.toBool()); } } QString QOfonoVoiceCall::lineIdentification() const { - if (d_ptr->voiceCall) - return d_ptr->properties["LineIdentification"].value(); - else - return QString(); + return getString("LineIdentification"); } QString QOfonoVoiceCall::incomingLine() const { - if (d_ptr->voiceCall) - return d_ptr->properties["IncomingLine"].value(); - else - return QString(); + return getString("IncomingLine"); } QString QOfonoVoiceCall::name() const { - if (d_ptr->voiceCall) - return d_ptr->properties["Name"].value(); - else - return QString(); + return getString("Name"); } QString QOfonoVoiceCall::state() const { - if (d_ptr->voiceCall) - return d_ptr->properties["State"].value(); - else - return QString(); + return getString("State"); } QString QOfonoVoiceCall::startTime() const { - if (d_ptr->voiceCall) - return d_ptr->properties["StartTime"].value(); - else - return QString(); + return getString("StartTime"); } QString QOfonoVoiceCall::information() const { - if (d_ptr->voiceCall) - return d_ptr->properties["Information"].value(); - else - return QString(); + return getString("Information"); } bool QOfonoVoiceCall::multiparty() const { - if (d_ptr->voiceCall) - return d_ptr->properties["Multiparty"].value(); - else - return false; + return getBool("Multiparty"); } bool QOfonoVoiceCall::emergency() const { - if (d_ptr->voiceCall) - return d_ptr->properties["Emergency"].value(); - else - return false; + return getBool("Emergency"); } quint8 QOfonoVoiceCall::icon() const { - if (d_ptr->voiceCall) - return d_ptr->properties["Icon"].value(); - else - return 0; + return getProperty("Icon").value(); } bool QOfonoVoiceCall::remoteHeld() const { - if (d_ptr->voiceCall) - return d_ptr->properties["RemoteHeld"].value(); - else - return false; + return getBool("RemoteHeld"); } bool QOfonoVoiceCall::remoteMultiparty() const { - if (d_ptr->voiceCall) - return d_ptr->properties["RemoteMultiparty"].value(); - else - return false; + return getBool("RemoteMultiparty"); } void QOfonoVoiceCall::answer() { - if (d_ptr->voiceCall) { - QDBusPendingReply<> result = d_ptr->voiceCall->Answer(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(answerFinished(QDBusPendingCallWatcher*))); + OfonoVoiceCall *iface = (OfonoVoiceCall*)dbusInterface(); + if (iface) { + new QOfonoVoiceCallWatcher(this, iface, "Answer", + iface->Answer(), &QOfonoVoiceCall::answerComplete); } } void QOfonoVoiceCall::hangup() { - if (d_ptr->voiceCall) { - QDBusPendingReply<> result = d_ptr->voiceCall->Hangup(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(hangupFinished(QDBusPendingCallWatcher*))); + OfonoVoiceCall *iface = (OfonoVoiceCall*)dbusInterface(); + if (iface) { + new QOfonoVoiceCallWatcher(this, iface, "Hangup", + iface->Hangup(), &QOfonoVoiceCall::hangupComplete); } } void QOfonoVoiceCall::deflect(const QString &number) { - if (d_ptr->voiceCall) { - QDBusPendingReply<> result = d_ptr->voiceCall->Deflect(number); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(deflectFinished(QDBusPendingCallWatcher*))); - } -} - -bool QOfonoVoiceCall::isValid() const -{ - return d_ptr->voiceCall->isValid(); -} - -void QOfonoVoiceCall::answerFinished(QDBusPendingCallWatcher *call) -{ - call->deleteLater(); - QDBusPendingReply<> reply = *call; - QOfonoVoiceCall::Error error = NoError; - QString errorString; - - if (reply.isError()) { - qWarning() << "QOfonoVoiceCall::answer() failed:" << reply.error(); - error = errorNameToEnum(reply.error().name()); - errorString = reply.error().name() + " " + reply.error().message(); - } - Q_EMIT answerComplete(error, errorString); -} - -void QOfonoVoiceCall::hangupFinished(QDBusPendingCallWatcher *call) -{ - call->deleteLater(); - QDBusPendingReply<> reply = *call; - QOfonoVoiceCall::Error error = NoError; - QString errorString; - - if (reply.isError()) { - qWarning() << "QOfonoVoiceCall::hangup() failed:" << reply.error(); - error = errorNameToEnum(reply.error().name()); - errorString = reply.error().name() + " " + reply.error().message(); + OfonoVoiceCall *iface = (OfonoVoiceCall*)dbusInterface(); + if (iface) { + new QOfonoVoiceCallWatcher(this, iface, "Deflect", + iface->Deflect(number), &QOfonoVoiceCall::deflectComplete); } - Q_EMIT hangupComplete(error, errorString); } -void QOfonoVoiceCall::deflectFinished(QDBusPendingCallWatcher *call) +void QOfonoVoiceCall::onDbusCallFinished(QDBusPendingCallWatcher *watch) { - call->deleteLater(); - QDBusPendingReply<> reply = *call; + watch->deleteLater(); + QDBusPendingReply<> reply(*watch); + QOfonoVoiceCallWatcher* call = (QOfonoVoiceCallWatcher*)watch; QOfonoVoiceCall::Error error = NoError; QString errorString; if (reply.isError()) { - qWarning() << "QOfonoVoiceCall::deflect() failed:" << reply.error(); + qWarning() << call->name << " failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } - Q_EMIT deflectComplete(error, errorString); + (this->*call->signal)(error, errorString); } QOfonoVoiceCall::Error QOfonoVoiceCall::errorNameToEnum(const QString &errorName) @@ -302,3 +208,8 @@ else return UnknownError; } + +bool QOfonoVoiceCall::isValid() const +{ + return SUPER::isValid(); +} diff -Nru libqofono-0.53/src/qofonovoicecall.h libqofono-0.70~rtm/src/qofonovoicecall.h --- libqofono-0.53/src/qofonovoicecall.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonovoicecall.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,17 +16,15 @@ #ifndef QOFONOVoiceCall_H #define QOFONOVoiceCall_H -#include -#include +#include "qofonoobject.h" #include "qofono_global.h" + //! This class is used to access ofono voice call API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob;f=doc/voicecall-api.txt */ - -class QOfonoVoiceCallPrivate; -class QOFONOSHARED_EXPORT QOfonoVoiceCall : public QObject +class QOFONOSHARED_EXPORT QOfonoVoiceCall : public QOfonoObject { Q_OBJECT Q_ENUMS(Error) @@ -72,6 +70,7 @@ bool remoteMultiparty() const; bool isValid() const; + Q_SIGNALS: void lineIdentificationChanged(const QString &name); void nameChanged(const QString &name); @@ -98,14 +97,15 @@ void deflect(const QString &number); private: - QOfonoVoiceCallPrivate *d_ptr; - Error errorNameToEnum(const QString &errorName); + static Error errorNameToEnum(const QString &errorName); private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); - void answerFinished(QDBusPendingCallWatcher *call); - void hangupFinished(QDBusPendingCallWatcher *call); - void deflectFinished(QDBusPendingCallWatcher *call); + void onDbusCallFinished(QDBusPendingCallWatcher *watch); + +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void propertyChanged(const QString &key, const QVariant &value); + void objectPathChanged(const QString &path, const QVariantMap *properties); }; #endif // QOFONOVoiceCall_H diff -Nru libqofono-0.53/src/qofonovoicecallmanager.cpp libqofono-0.70~rtm/src/qofonovoicecallmanager.cpp --- libqofono-0.53/src/qofonovoicecallmanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonovoicecallmanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /***************************************************`************************* ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,378 +16,295 @@ #include "qofonovoicecallmanager.h" #include "dbus/ofonovoicecallmanager.h" -class QOfonoVoiceCallManagerPrivate +#define SUPER QOfonoModemInterface + +class QOfonoVoiceCallManager::Private : public SUPER::ExtData { public: - QOfonoVoiceCallManagerPrivate(); - QString modemPath; - OfonoVoiceCallManager *voiceCallManager; - QVariantMap properties; + bool initialized; QStringList callList; QString errorMessage; + Private() : initialized(false) {} + + class Watcher : public QDBusPendingCallWatcher { + public: + typedef void (QOfonoVoiceCallManager::*Signal)(bool); + const char* name; + Signal signal; + Watcher(QOfonoVoiceCallManager* target, OfonoVoiceCallManager *parent, + const char* callName, const QDBusPendingCall &call, Signal complete) : + QDBusPendingCallWatcher(call, parent), + name(callName), signal(complete) + { + connect(this, SIGNAL(finished(QDBusPendingCallWatcher*)), + target, SLOT(onVoidCallFinished(QDBusPendingCallWatcher*))); + } + }; + + class ObjectPathListWatcher : public QDBusPendingCallWatcher { + public: + typedef void (QOfonoVoiceCallManager::*Signal)(bool, const QStringList&); + const char* name; + Signal signal; + ObjectPathListWatcher(QOfonoVoiceCallManager* target, OfonoVoiceCallManager *parent, + const char* callName, const QDBusPendingCall &call, Signal complete) : + QDBusPendingCallWatcher(call, parent), + name(callName), signal(complete) + { + connect(this, SIGNAL(finished(QDBusPendingCallWatcher*)), + target, SLOT(onObjectPathListCallFinished(QDBusPendingCallWatcher*))); + } + }; }; -QOfonoVoiceCallManagerPrivate::QOfonoVoiceCallManagerPrivate() : - modemPath(QString()) - , voiceCallManager(0) - , callList(QStringList()) +QOfonoVoiceCallManager::QOfonoVoiceCallManager(QObject *parent) : + SUPER(OfonoVoiceCallManager::staticInterfaceName(), new Private, parent) { + QOfonoDbusTypes::registerObjectPathProperties(); } -QOfonoVoiceCallManager::QOfonoVoiceCallManager(QObject *parent) : - QObject(parent) - , d_ptr(new QOfonoVoiceCallManagerPrivate) +QOfonoVoiceCallManager::~QOfonoVoiceCallManager() { } -QOfonoVoiceCallManager::~QOfonoVoiceCallManager() +bool QOfonoVoiceCallManager::isValid() const { - delete d_ptr; + return privateData()->initialized && SUPER::isValid(); } -void QOfonoVoiceCallManager::setModemPath(const QString &path) +QDBusAbstractInterface *QOfonoVoiceCallManager::createDbusInterface(const QString &path) { - if (path == d_ptr->modemPath || - path.isEmpty()) - return; - - if (path != modemPath()) { - if (d_ptr->voiceCallManager) { - delete d_ptr->voiceCallManager; - d_ptr->voiceCallManager = 0; - d_ptr->properties.clear(); - } - d_ptr->voiceCallManager = new OfonoVoiceCallManager("org.ofono", path, QDBusConnection::systemBus(),this); + OfonoVoiceCallManager* iface = new OfonoVoiceCallManager("org.ofono", path, QDBusConnection::systemBus(), this); + connect(new QDBusPendingCallWatcher(iface->GetCalls(), iface), + SIGNAL(finished(QDBusPendingCallWatcher*)), + SLOT(onGetCallsFinished(QDBusPendingCallWatcher*))); + connect(iface, + SIGNAL(CallAdded(QDBusObjectPath,QVariantMap)), + SLOT(onCallAdded(QDBusObjectPath,QVariantMap))); + connect(iface, + SIGNAL(CallRemoved(QDBusObjectPath)), + SLOT(onCallRemoved(QDBusObjectPath))); + connect(iface, SIGNAL(BarringActive(QString)), SIGNAL(barringActive(QString))); + connect(iface, SIGNAL(Forwarded(QString)), SIGNAL(forwarded(QString))); + return iface; +} - if (d_ptr->voiceCallManager->isValid()) { - d_ptr->modemPath = path; +void QOfonoVoiceCallManager::dbusInterfaceDropped() +{ + SUPER::dbusInterfaceDropped(); - connect(d_ptr->voiceCallManager,SIGNAL(PropertyChanged(QString,QDBusVariant)), - this,SLOT(propertyChanged(QString,QDBusVariant))); - connectSignals(); - QDBusPendingReply reply; - reply = d_ptr->voiceCallManager->GetProperties(); - reply.waitForFinished(); - d_ptr->properties = reply.value(); - Q_EMIT emergencyNumbersChanged(emergencyNumbers()); - Q_EMIT modemPathChanged(path); + Private *d_ptr = privateData(); + d_ptr->initialized = false; + if (!d_ptr->callList.isEmpty()) { + QStringList list = d_ptr->callList; + d_ptr->callList.clear(); + for (int i=0; imodemPath; + return getStringList("EmergencyNumbers"); } -void QOfonoVoiceCallManager::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) +QStringList QOfonoVoiceCallManager::getCalls() const { - QVariant value = dbusvalue.variant(); - d_ptr->properties.insert(property,value); + return privateData()->callList; +} - if (property == QLatin1String("EmergencyNumbers")) { - Q_EMIT emergencyNumbersChanged(value.value()); +QString QOfonoVoiceCallManager::errorMessage() const +{ + return privateData()->errorMessage; +} + +void QOfonoVoiceCallManager::dial(const QString &number, const QString &calleridHide) +{ + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::Watcher(this, iface, "Dial", + iface->Dial(number, calleridHide), &QOfonoVoiceCallManager::dialComplete); } } -QStringList QOfonoVoiceCallManager::emergencyNumbers() const +void QOfonoVoiceCallManager::hangupAll() { - if(d_ptr->voiceCallManager) - return d_ptr->properties["EmergencyNumbers"].toStringList(); + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::Watcher(this, iface, "HangupAll", + iface->HangupAll(), &QOfonoVoiceCallManager::hangupAllComplete); + } +} - return QStringList(); +void QOfonoVoiceCallManager::sendTones(const QString &tonestring) +{ + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::Watcher(this, iface, "SendTones", + iface->SendTones(tonestring), &QOfonoVoiceCallManager::sendTonesComplete); + } } -QStringList QOfonoVoiceCallManager::getCalls() const +void QOfonoVoiceCallManager::transfer() { - if(d_ptr->voiceCallManager) { - d_ptr->callList.clear(); - QDBusReply reply = d_ptr->voiceCallManager->GetCalls(); - foreach(ObjectPathProperties calls, reply.value()) { - d_ptr->callList << calls.path.path(); + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::Watcher(this, iface, "Transfer", + iface->Transfer(), &QOfonoVoiceCallManager::transferComplete); + } +} + +void QOfonoVoiceCallManager::swapCalls() +{ + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::Watcher(this, iface, "SwapCalls", + iface->SwapCalls(), &QOfonoVoiceCallManager::swapCallsComplete); + } +} + +void QOfonoVoiceCallManager::releaseAndAnswer() +{ + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::Watcher(this, iface, "ReleaseAndAnswer", + iface->ReleaseAndAnswer(), &QOfonoVoiceCallManager::releaseAndAnswerComplete); + } +} + +void QOfonoVoiceCallManager::holdAndAnswer() +{ + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::Watcher(this, iface, "HoldAndAnswer", + iface->HoldAndAnswer(), &QOfonoVoiceCallManager::holdAndAnswerComplete); + } +} + +void QOfonoVoiceCallManager::createMultiparty() +{ + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::ObjectPathListWatcher(this, iface, "CreateMultiparty", + iface->CreateMultiparty(), &QOfonoVoiceCallManager::createMultipartyComplete); + } +} + +void QOfonoVoiceCallManager::hangupMultiparty() +{ + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::Watcher(this, iface, "HangupMultiparty", + iface->HangupMultiparty(), &QOfonoVoiceCallManager::hangupMultipartyComplete); + } +} + +void QOfonoVoiceCallManager::privateChat(const QString &path) +{ + OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); + if (iface) { + new Private::ObjectPathListWatcher(this, iface, "PrivateChat", + iface->PrivateChat(QDBusObjectPath(path)), &QOfonoVoiceCallManager::privateChatComplete); + } +} + +void QOfonoVoiceCallManager::onVoidCallFinished(QDBusPendingCallWatcher *watch) +{ + watch->deleteLater(); + Private::Watcher* call = (Private::Watcher*)watch; + QDBusPendingReply<> reply(*watch); + bool ok = true; + if (reply.isError()) { + Private *d_ptr = privateData(); + d_ptr->errorMessage = QString("%1: %2 %3").arg(call->name). + arg(reply.error().name()).arg(reply.error().message()); + qWarning() << d_ptr->errorMessage; + ok = false; + } + (this->*call->signal)(ok); +} + +void QOfonoVoiceCallManager::onObjectPathListCallFinished(QDBusPendingCallWatcher *watch) +{ + watch->deleteLater(); + QDBusPendingReply reply(*watch); + Private::ObjectPathListWatcher* call = (Private::ObjectPathListWatcher*)watch; + QStringList list; + bool ok = true; + if (reply.isError()) { + Private *d_ptr = privateData(); + d_ptr->errorMessage = QString("%1: %2 %3").arg(call->name). + arg(reply.error().name()).arg(reply.error().message()); + qWarning() << d_ptr->errorMessage; + ok = false; + } else { + Q_FOREACH(const QDBusObjectPath &path, reply.value()) { + list << path.path(); + } + } + (this->*call->signal)(ok, list); +} + +void QOfonoVoiceCallManager::addCall(const QString &callPath) +{ + Private *d_ptr = privateData(); + if (!d_ptr->callList.contains(callPath)) { + d_ptr->callList.append(callPath); + Q_EMIT callAdded(callPath); + } +} + +void QOfonoVoiceCallManager::onGetCallsFinished(QDBusPendingCallWatcher *watch) +{ + watch->deleteLater(); + QDBusPendingReply reply(*watch); + if (reply.isError()) { + qDebug() << reply.error(); + Q_EMIT reportError(reply.error().message()); + } else { + ObjectPathPropertiesList list = reply.value(); + privateData()->initialized = true; + for (int i=0; icallList; } - void QOfonoVoiceCallManager::connectSignals() - { - disconnect(d_ptr->voiceCallManager,SIGNAL(CallAdded(QDBusObjectPath,QVariantMap)), - this,SLOT(onCallAdded(QDBusObjectPath,QVariantMap))); - disconnect(d_ptr->voiceCallManager,SIGNAL(CallRemoved(QDBusObjectPath)), - this,SLOT(onCallRemoved(QDBusObjectPath))); - - disconnect(d_ptr->voiceCallManager,SIGNAL(BarringActive(QString)), - this,SIGNAL(barringActive(QString))); - disconnect(d_ptr->voiceCallManager,SIGNAL(Forwarded(QString)), - this,SIGNAL(forwarded(QString))); - - connect(d_ptr->voiceCallManager,SIGNAL(CallAdded(QDBusObjectPath,QVariantMap)), - this,SLOT(onCallAdded(QDBusObjectPath,QVariantMap))); - connect(d_ptr->voiceCallManager,SIGNAL(CallRemoved(QDBusObjectPath)), - this,SLOT(onCallRemoved(QDBusObjectPath))); - - connect(d_ptr->voiceCallManager,SIGNAL(BarringActive(QString)), - this,SIGNAL(barringActive(QString))); - connect(d_ptr->voiceCallManager,SIGNAL(Forwarded(QString)), - this,SIGNAL(forwarded(QString))); - - } - - void QOfonoVoiceCallManager::dial(const QString &number, const QString &calleridHide) - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply<> result = d_ptr->voiceCallManager->Dial(number,calleridHide); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(dialFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::hangupAll() - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply<> result = d_ptr->voiceCallManager->HangupAll(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(hangupAllFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::sendTones(const QString &tonestring) - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply<> result = d_ptr->voiceCallManager->SendTones(tonestring); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(sendTonesFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::transfer() - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply<> result = d_ptr->voiceCallManager->Transfer(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(transferFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::swapCalls() - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply<> result = d_ptr->voiceCallManager->SwapCalls(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(swapCallsFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::releaseAndAnswer() - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply<> result = d_ptr->voiceCallManager->ReleaseAndAnswer(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(releaseAndAnswerFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::holdAndAnswer() - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply<> result = d_ptr->voiceCallManager->HoldAndAnswer(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(holdAndAnswerFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::privateChat(const QString &path) - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply > result = d_ptr->voiceCallManager->PrivateChat(QDBusObjectPath(path)); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(privateChatFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::createMultiparty() - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply > result = d_ptr->voiceCallManager->CreateMultiparty(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(createMultipartyFinished(QDBusPendingCallWatcher*))); - } - } - - void QOfonoVoiceCallManager::hangupMultiparty() - { - if(d_ptr->voiceCallManager) { - QDBusPendingReply<> result = d_ptr->voiceCallManager->HangupMultiparty(); - QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); - connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), - SLOT(hangupMultipartyFinished(QDBusPendingCallWatcher*))); - } - } - - bool QOfonoVoiceCallManager::isValid() const - { - return d_ptr->voiceCallManager->isValid(); - } - - void QOfonoVoiceCallManager::dialFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } - Q_EMIT dialComplete(ok); - - } - - void QOfonoVoiceCallManager::hangupAllFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } - Q_EMIT hangupAllComplete(ok); - } - - void QOfonoVoiceCallManager::sendTonesFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; -// bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); -// ok = false; - } - // Q_EMIT sendTonesComplete(ok); - } - - void QOfonoVoiceCallManager::transferFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } - Q_EMIT transferComplete(ok); - } - - void QOfonoVoiceCallManager::swapCallsFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } - Q_EMIT swapCallsComplete(ok); - } - - void QOfonoVoiceCallManager::releaseAndAnswerFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } - Q_EMIT releaseAndAnswerComplete(ok); - } - - void QOfonoVoiceCallManager::holdAndAnswerFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } - Q_EMIT holdAndAnswerComplete(ok); - } - - void QOfonoVoiceCallManager::privateChatFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply > reply = *call; - QStringList calls; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } else { - Q_FOREACH(const QDBusObjectPath &path, reply.value()) - calls << path.path(); - - } - Q_EMIT privateChatComplete(ok, calls); - } - - void QOfonoVoiceCallManager::createMultipartyFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } - Q_EMIT createMultipartyComplete(ok, QStringList()); - } - - void QOfonoVoiceCallManager::hangupMultipartyFinished(QDBusPendingCallWatcher *call) - { - call->deleteLater(); - QDBusPendingReply<> reply = *call; - bool ok = true; - if (reply.isError()) { - qWarning() << Q_FUNC_INFO << "failed:" << reply.error(); - d_ptr->errorMessage = reply.error().name() + " " + reply.error().message(); - ok = false; - } - Q_EMIT hangupMultipartyComplete(ok); - } - - - QString QOfonoVoiceCallManager::errorMessage() const - { - return d_ptr->errorMessage; - } - - void QOfonoVoiceCallManager::onCallRemoved(const QDBusObjectPath &path) - { - Q_EMIT callRemoved(path.path()); - } - - void QOfonoVoiceCallManager::onCallAdded(const QDBusObjectPath &path, const QVariantMap &) - { - Q_EMIT callAdded(path.path()); - } +void QOfonoVoiceCallManager::onCallRemoved(const QDBusObjectPath &path) +{ + QString callPath = path.path(); + if (privateData()->callList.removeOne(callPath)) { + Q_EMIT callRemoved(callPath); + } +} + +void QOfonoVoiceCallManager::onCallAdded(const QDBusObjectPath &path, const QVariantMap &) +{ + addCall(path.path()); +} + +QString QOfonoVoiceCallManager::modemPath() const +{ + return SUPER::modemPath(); +} + +void QOfonoVoiceCallManager::setModemPath(const QString &path) +{ + SUPER::setModemPath(path); +} + +QOfonoVoiceCallManager::Private *QOfonoVoiceCallManager::privateData() const +{ + return (QOfonoVoiceCallManager::Private*)SUPER::extData(); +} diff -Nru libqofono-0.53/src/qofonovoicecallmanager.h libqofono-0.70~rtm/src/qofonovoicecallmanager.h --- libqofono-0.53/src/qofonovoicecallmanager.h 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/qofonovoicecallmanager.h 2015-01-09 08:20:12.000000000 +0000 @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Jolla Ltd. +** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.com ** ** GNU Lesser General Public License Usage @@ -16,21 +16,17 @@ #ifndef QOFONOVoiceCallManager_H #define QOFONOVoiceCallManager_H -#include -#include -#include +#include "qofonomodeminterface.h" #include "qofono_global.h" + //! This class is used to access ofono voice call manager API /*! * The API is documented in * http://git.kernel.org/?p=network/ofono/ofono.git;a=blob_plain;f=doc/voicecallmanager-api.txt */ - -class QOfonoVoiceCallManagerPrivate; -class QOFONOSHARED_EXPORT QOfonoVoiceCallManager : public QObject +class QOFONOSHARED_EXPORT QOfonoVoiceCallManager : public QOfonoModemInterface { Q_OBJECT - Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QStringList emergencyNumbers READ emergencyNumbers NOTIFY emergencyNumbersChanged) Q_PROPERTY(QString errorMessage READ errorMessage) @@ -57,6 +53,7 @@ void dialComplete(bool status); void hangupAllComplete(bool status); + void sendTonesComplete(bool status); void transferComplete(bool status); void swapCallsComplete(bool status); void releaseAndAnswerComplete(bool status); @@ -67,41 +64,37 @@ void barringActive(const QString &type); void forwarded(const QString &type); - void modemPathChanged(const QString &path); public slots: void dial(const QString &number, const QString &calleridHide); - void hangupAll(); - void sendTones(const QString &tonestring); - void transfer(); - void swapCalls(); - void releaseAndAnswer(); - void holdAndAnswer(); - void privateChat(const QString &path); - void createMultiparty(); - void hangupMultiparty(); - -private: - QOfonoVoiceCallManagerPrivate *d_ptr; - void connectSignals(); + void hangupAll(); + void sendTones(const QString &tonestring); + void transfer(); + void swapCalls(); + void releaseAndAnswer(); + void holdAndAnswer(); + void privateChat(const QString &path); + void createMultiparty(); + void hangupMultiparty(); private slots: - void propertyChanged(const QString &property,const QDBusVariant &value); - - void dialFinished(QDBusPendingCallWatcher *call); - void hangupAllFinished(QDBusPendingCallWatcher *call); - void sendTonesFinished(QDBusPendingCallWatcher *call); - void transferFinished(QDBusPendingCallWatcher *call); - void swapCallsFinished(QDBusPendingCallWatcher *call); - void releaseAndAnswerFinished(QDBusPendingCallWatcher *call); - void holdAndAnswerFinished(QDBusPendingCallWatcher *call); - void privateChatFinished(QDBusPendingCallWatcher *call); - void createMultipartyFinished(QDBusPendingCallWatcher *call); - void hangupMultipartyFinished(QDBusPendingCallWatcher *call); - + void onGetCallsFinished(QDBusPendingCallWatcher *watch); + void onVoidCallFinished(QDBusPendingCallWatcher *watch); + void onObjectPathListCallFinished(QDBusPendingCallWatcher *watch); void onCallAdded(const QDBusObjectPath &, const QVariantMap &map); void onCallRemoved(const QDBusObjectPath &); +private: + void addCall(const QString &callPath); + +protected: + QDBusAbstractInterface *createDbusInterface(const QString &path); + void dbusInterfaceDropped(); + void propertyChanged(const QString &property, const QVariant &value); + +private: + class Private; + Private *privateData() const; }; #endif // QOFONOVoiceCallManager_H diff -Nru libqofono-0.53/src/src.pro libqofono-0.70~rtm/src/src.pro --- libqofono-0.53/src/src.pro 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/src.pro 2015-01-09 08:20:12.000000000 +0000 @@ -4,18 +4,19 @@ # #------------------------------------------------- -QT += dbus xmlpatterns +QT += dbus xmlpatterns +QMAKE_CXXFLAGS += -Wno-unused-parameter include(version.pri) equals(QT_MAJOR_VERSION, 4): { TARGET = qofono - pkgconfig.path = $$INSTALL_ROOT$$PREFIX/lib/pkgconfig + pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig } equals(QT_MAJOR_VERSION, 5): { TARGET = qofono-qt5 - pkgconfig.path = $$INSTALL_ROOT$$PREFIX/lib/pkgconfig-qt5 + pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig-qt5 } TEMPLATE = lib @@ -110,9 +111,13 @@ } SOURCES += $$DBUS_SOURCES\ - qofono.cpp \ + qofono.cpp \ + qofonodbustypes.cpp \ + qofonoobject.cpp \ qofonomanager.cpp \ qofonomodem.cpp \ + qofonomodeminterface.cpp \ + qofonomodeminterface2.cpp \ qofonoassistedsatellitenavigation.cpp \ qofonoconnectionmanager.cpp \ qofonoconnectioncontext.cpp \ @@ -146,9 +151,12 @@ PUBLIC_HEADERS += \ qofono.h \ qofono_global.h \ + qofonoobject.h \ qofonomanager.h \ dbustypes.h \ qofonomodem.h \ + qofonomodeminterface.h \ + qofonomodeminterface2.h \ qofonoassistedsatellitenavigation.h \ qofonoconnectionmanager.h \ qofonoconnectioncontext.h \ @@ -203,7 +211,7 @@ xmlfiles.path = $$INSTALL_ROOT$$PREFIX/include/qofono-qt5/dbus } -target.path = $$INSTALL_ROOT$$PREFIX/lib +target.path = $$[QT_INSTALL_LIBS] headers.files = $$PUBLIC_HEADERS dbusheaders.files = $$DBUS_HEADERS diff -Nru libqofono-0.53/src/version.pri libqofono-0.70~rtm/src/version.pri --- libqofono-0.53/src/version.pri 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/src/version.pri 2015-01-09 08:20:12.000000000 +0000 @@ -1 +1 @@ -VERSION = 0.49 +VERSION = 0.70 diff -Nru libqofono-0.53/test/auto/tests/runtest.sh libqofono-0.70~rtm/test/auto/tests/runtest.sh --- libqofono-0.53/test/auto/tests/runtest.sh 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/runtest.sh 2015-01-09 08:20:12.000000000 +0000 @@ -1,5 +1,5 @@ #!/bin/sh -e systemctl --user restart phonesim -sleep 10 +sleep 15 exec "/usr/lib/libqofono-qt5/tests/${1?Test executable expected}" diff -Nru libqofono-0.53/test/auto/tests/testcase.pri libqofono-0.70~rtm/test/auto/tests/testcase.pri --- libqofono-0.53/test/auto/tests/testcase.pri 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/testcase.pri 2015-01-09 08:20:12.000000000 +0000 @@ -1,15 +1,16 @@ CONFIG += testcase QT = core testlib dbus -INCLUDEPATH += ../lib ../ +QOFONO_DIR = ../../../src/ +INCLUDEPATH += ../lib ../ $$QOFONO_DIR equals(QT_MAJOR_VERSION, 4): { - LIBS += -L../../../src -lqofono - target.path = $$INSTALL_ROOT$$PREFIX/lib/libqofono/tests + LIBS += -L$$QOFONO_DIR -lqofono + target.path = $$[QT_INSTALL_LIBS]/libqofono/tests } equals(QT_MAJOR_VERSION, 5): { - LIBS += -L../../../src -lqofono-qt5 - target.path = $$INSTALL_ROOT$$PREFIX/lib/libqofono-qt5/tests + LIBS += -L$$QOFONO_DIR -lqofono-qt5 + target.path = $$[QT_INSTALL_LIBS]/libqofono-qt5/tests } INSTALLS += target diff -Nru libqofono-0.53/test/auto/tests/tests.xml libqofono-0.70~rtm/test/auto/tests/tests.xml --- libqofono-0.53/test/auto/tests/tests.xml 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tests.xml 2015-01-09 08:20:12.000000000 +0000 @@ -4,10 +4,19 @@ Ofono test set with manual, automatic and semi-automatic case. - run-blts-root systemctl stop connman.service + /usr/sbin/mcetool --set-never-blank=disabled --set-demo-mode=off --block=1 --set-never-blank=enabled --unblank-screen --block=1 --set-tklock-mode=unlocked + /usr/sbin/run-blts-root /bin/mv /var/lib/environment/ofono/noplugin.conf /var/lib/environment/ofono/noplugin.conf_LIBQOFONO_TESTS_DISABLED || true + /usr/sbin/run-blts-root /bin/sh -c "/bin/echo OFONO_ARGS=--noplugin=ril > /var/lib/environment/ofono/LIBQOFONO_TESTS_noplugin.conf" || true + /usr/sbin/run-blts-root /bin/systemctl restart ofono.service + /usr/sbin/run-blts-root /bin/systemctl stop connman.service - run-blts-root systemctl start connman.service + /bin/systemctl --user stop phonesim.service + /usr/sbin/run-blts-root /bin/rm /var/lib/environment/ofono/LIBQOFONO_TESTS_noplugin.conf || true + /usr/sbin/run-blts-root /bin/mv /var/lib/environment/ofono/noplugin.conf_LIBQOFONO_TESTS_DISABLED /var/lib/environment/ofono/noplugin.conf || true + /usr/sbin/run-blts-root /bin/systemctl restart ofono.service + /usr/sbin/run-blts-root /bin/systemctl start connman.service + /usr/sbin/mcetool --set-never-blank=disabled --set-demo-mode=off /opt/tests/libqofono-qt5/runtest.sh tst_qofonocallbarring diff -Nru libqofono-0.53/test/auto/tests/tst_qofonocallbarring.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonocallbarring.cpp --- libqofono-0.53/test/auto/tests/tst_qofonocallbarring.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonocallbarring.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,11 +22,9 @@ */ #include -#include -#include "../../../src/qofonocallbarring.h" +#include "qofonocallbarring.h" -#include class TestQOfonoCallBarring : public QObject { @@ -37,11 +35,11 @@ { m = new QOfonoCallBarring(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); QSignalSpy ready(m, SIGNAL(readyChanged())); - QTRY_COMPARE(ready.count(), 1); - QCOMPARE(m->isReady(), true); + QTRY_VERIFY(m->isValid()); + QTRY_VERIFY(m->isReady()); + QCOMPARE(ready.count(), 1); } void testQOfonoCallBarring() diff -Nru libqofono-0.53/test/auto/tests/tst_qofonocallforwarding.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonocallforwarding.cpp --- libqofono-0.53/test/auto/tests/tst_qofonocallforwarding.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonocallforwarding.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,10 +22,8 @@ */ #include -#include -#include "../../../src/qofonocallforwarding.h" -#include +#include "qofonocallforwarding.h" class TestQOfonoCallForwarding : public QObject { @@ -36,11 +34,11 @@ { m = new QOfonoCallForwarding(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); QSignalSpy ready(m, SIGNAL(readyChanged())); - QTRY_COMPARE(ready.count(), 1); - QCOMPARE(m->isReady(), true); + QTRY_VERIFY(m->isValid()); + QTRY_VERIFY(m->isReady()); + QCOMPARE(ready.count(), 1); } void testQOfonoCallForwarding() @@ -101,6 +99,14 @@ QCOMPARE(voiceNotReachableComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceNotReachableChanged.count(), 1); QCOMPARE(voiceNotReachableChanged.takeFirst().at(0).toString(), QString("12345678")); + + QCOMPARE(m->voiceBusy(), QString("12345678")); + QCOMPARE(m->voiceNoReply(), QString("12345678")); + QCOMPARE(m->voiceNoReplyTimeout(), quint16(30)); + QCOMPARE(m->voiceNotReachable(), QString("12345678")); + QCOMPARE(m->voiceUnconditional(), QString("")); + QCOMPARE(m->forwardingFlagOnSim(), false); + m->setVoiceUnconditional("12345678"); QTRY_COMPARE(voiceUnconditionalComplete.count(), 1); QCOMPARE(voiceUnconditionalComplete.takeFirst().at(0).toBool(), true); @@ -110,16 +116,45 @@ QTRY_COMPARE(forwardingFlagOnSimChanged.count(), 1); QCOMPARE(forwardingFlagOnSimChanged.takeFirst().at(0).toBool(), true); - QCOMPARE(m->voiceBusy(), QString("12345678")); - QCOMPARE(m->voiceNoReply(), QString("12345678")); - QCOMPARE(m->voiceNoReplyTimeout(), quint16(30)); - QCOMPARE(m->voiceNotReachable(), QString("12345678")); + // When VoiceUnconditional is active, all other CF is cleared and enabled again when + // VoiceUnconditional is deactivated + QTRY_COMPARE(voiceBusyChanged.count(), 1); + QCOMPARE(voiceBusyChanged.takeFirst().at(0).toString(), QString("")); + QTRY_COMPARE(voiceNoReplyChanged.count(), 1); + QCOMPARE(voiceNoReplyChanged.takeFirst().at(0).toString(), QString("")); + QTRY_COMPARE(voiceNotReachableChanged.count(), 1); + QCOMPARE(voiceNotReachableChanged.takeFirst().at(0).toString(), QString("")); + + QCOMPARE(m->voiceBusy(), QString("")); + QCOMPARE(m->voiceNoReply(), QString("")); + QCOMPARE(m->voiceNotReachable(), QString("")); QCOMPARE(m->voiceUnconditional(), QString("12345678")); QCOMPARE(m->forwardingFlagOnSim(), true); - m->disableAll("all"); + m->setVoiceUnconditional(""); + QTRY_COMPARE(voiceUnconditionalComplete.count(), 1); + QCOMPARE(voiceUnconditionalComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceUnconditionalChanged.count(), 1); QCOMPARE(voiceUnconditionalChanged.takeFirst().at(0).toString(), QString("")); + + QTRY_COMPARE(forwardingFlagOnSimChanged.count(), 1); + QCOMPARE(forwardingFlagOnSimChanged.takeFirst().at(0).toBool(), false); + + QTRY_COMPARE(voiceBusyChanged.count(), 1); + QCOMPARE(voiceBusyChanged.takeFirst().at(0).toString(), QString("12345678")); + QTRY_COMPARE(voiceNoReplyChanged.count(), 1); + QCOMPARE(voiceNoReplyChanged.takeFirst().at(0).toString(), QString("12345678")); + QTRY_COMPARE(voiceNotReachableChanged.count(), 1); + QCOMPARE(voiceNotReachableChanged.takeFirst().at(0).toString(), QString("12345678")); + + QCOMPARE(m->voiceBusy(), QString("12345678")); + QCOMPARE(m->voiceNoReply(), QString("12345678")); + QCOMPARE(m->voiceNotReachable(), QString("12345678")); + QCOMPARE(m->voiceUnconditional(), QString("")); + QCOMPARE(m->forwardingFlagOnSim(), false); + + m->disableAll("all"); + QTRY_COMPARE(voiceUnconditionalChanged.count(), 0); QTRY_COMPARE(voiceBusyChanged.count(), 1); QCOMPARE(voiceBusyChanged.takeFirst().at(0).toString(), QString("")); QTRY_COMPARE(voiceNoReplyChanged.count(), 1); @@ -128,8 +163,7 @@ QCOMPARE(voiceNoReplyTimeoutChanged.takeFirst().at(0).toUInt(), uint(20)); QTRY_COMPARE(voiceNotReachableChanged.count(), 1); QCOMPARE(voiceNotReachableChanged.takeFirst().at(0).toString(), QString("")); - QTRY_COMPARE(forwardingFlagOnSimChanged.count(), 1); - QCOMPARE(forwardingFlagOnSimChanged.takeFirst().at(0).toBool(), false); + QTRY_COMPARE(forwardingFlagOnSimChanged.count(), 0); QCOMPARE(m->voiceUnconditional(), QString("")); QCOMPARE(m->voiceBusy(), QString("")); diff -Nru libqofono-0.53/test/auto/tests/tst_qofonocallmeter.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonocallmeter.cpp --- libqofono-0.53/test/auto/tests/tst_qofonocallmeter.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonocallmeter.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,11 +22,8 @@ */ #include -#include -#include "../../../src/qofonocallmeter.h" - -#include +#include "qofonocallmeter.h" class TestQOfonoCallMeter : public QObject { @@ -37,7 +34,7 @@ { m = new QOfonoCallMeter(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoCallMeter() @@ -48,7 +45,6 @@ void cleanupTestCase() { - } private: diff -Nru libqofono-0.53/test/auto/tests/tst_qofonocallsettings.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonocallsettings.cpp --- libqofono-0.53/test/auto/tests/tst_qofonocallsettings.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonocallsettings.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,11 +22,8 @@ */ #include -#include -#include "../../../src/qofonocallsettings.h" - -#include +#include "qofonocallsettings.h" class TestQOfonoCallSettings : public QObject { @@ -37,11 +34,11 @@ { m = new QOfonoCallSettings(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); - QSignalSpy ready(m, SIGNAL(readyChanged())); + + QTRY_VERIFY(m->isValid()); + QTRY_VERIFY(m->isReady()); QTRY_COMPARE(ready.count(), 1); - QCOMPARE(m->isReady(), true); } void testQOfonoCallSettings() diff -Nru libqofono-0.53/test/auto/tests/tst_qofonocallvolume.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonocallvolume.cpp --- libqofono-0.53/test/auto/tests/tst_qofonocallvolume.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonocallvolume.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -23,12 +23,8 @@ */ #include -#include -#include "../../../src/qofonocallvolume.h" -#include "../../../src/qofonomodem.h" - -#include +#include "qofonocallvolume.h" class TestQOfonoCallVolume : public QObject { @@ -42,7 +38,7 @@ { m = new QOfonoCallVolume(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoCallVolume() @@ -75,7 +71,6 @@ void cleanupTestCase() { - } private: diff -Nru libqofono-0.53/test/auto/tests/tst_qofonocellbroadcast.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonocellbroadcast.cpp --- libqofono-0.53/test/auto/tests/tst_qofonocellbroadcast.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonocellbroadcast.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,12 +22,8 @@ */ #include -#include -#include "../../../src/qofonocellbroadcast.h" -#include "../../../src/qofonomodem.h" - -#include +#include "qofonocellbroadcast.h" class TestQOfonoCellBroadcast : public QObject { @@ -40,8 +36,7 @@ { m = new QOfonoCellBroadcast( this); m->setModemPath("/phonesim"); - - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoCellBroadcast() diff -Nru libqofono-0.53/test/auto/tests/tst_qofonoconnmancontext.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonoconnmancontext.cpp --- libqofono-0.53/test/auto/tests/tst_qofonoconnmancontext.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonoconnmancontext.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,11 +22,10 @@ */ #include -#include -#include "../../../src/qofonomanager.h" -#include "../../../src/qofonoconnectionmanager.h" -#include "../../../src/qofonoconnectioncontext.h" +#include "qofonomanager.h" +#include "qofonoconnectionmanager.h" +#include "qofonoconnectioncontext.h" #include @@ -43,8 +42,8 @@ QOfonoManager manager; m = new QOfonoConnectionManager(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); - QCOMPARE(m->powered(), true); + QTRY_VERIFY(m->isValid()); + QTRY_VERIFY(m->powered()); } void testQOfonoConnectionManagerContext () @@ -59,6 +58,7 @@ QOfonoConnectionContext* context = new QOfonoConnectionContext(this); context->setContextPath(contextid); + QTRY_COMPARE(context->isValid(), true); QSignalSpy active(context, SIGNAL(activeChanged(bool))); QSignalSpy apn(context,SIGNAL(accessPointNameChanged(QString))); @@ -142,8 +142,9 @@ QOfonoConnectionContext* context = new QOfonoConnectionContext(this); context->setContextPath(contextid); - QSignalSpy apn(context, SIGNAL(accessPointNameChanged(QString))); + QTRY_VERIFY(context->isValid()); + QSignalSpy apn(context, SIGNAL(accessPointNameChanged(QString))); context->setAccessPointName("internet"); QTRY_COMPARE(apn.count(), 1); QCOMPARE(apn.takeFirst().at(0).toString(), QString("internet")); diff -Nru libqofono-0.53/test/auto/tests/tst_qofonoconnman.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonoconnman.cpp --- libqofono-0.53/test/auto/tests/tst_qofonoconnman.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonoconnman.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,13 +22,9 @@ */ #include -#include -#include "../../../src/qofonoconnectioncontext.h" -#include "../../../src/qofonoconnectionmanager.h" -#include "../../../src/qofonomanager.h" - -#include +#include "qofonoconnectioncontext.h" +#include "qofonoconnectionmanager.h" class TestOfonoConnMan : public QObject { @@ -37,21 +33,24 @@ private slots: void initTestCase() { - QOfonoManager manager; m = new QOfonoConnectionManager(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); - QCOMPARE(m->powered(), true); + QTRY_VERIFY(m->isValid()); + QTRY_VERIFY(m->powered()); } void testOfonoConnMan() { - QSignalSpy attch(m, SIGNAL(attachedChanged(bool))); - QSignalSpy sus(m,SIGNAL(suspendedChanged(bool))); - QSignalSpy ber(m, SIGNAL(bearerChanged(QString))); + m->setRoamingAllowed(true); + QTRY_COMPARE(m->roamingAllowed(), true); + Q_FOREACH (QString context, m->contexts()) { + m->removeContext(context); + } + QTRY_VERIFY(m->contexts().isEmpty()); + QSignalSpy roam(m,SIGNAL(roamingAllowedChanged(bool))); - QSignalSpy pow(m,SIGNAL(poweredChanged(bool))); + QSignalSpy pow(m, SIGNAL(poweredChanged(bool))); QSignalSpy add(m, SIGNAL(contextAdded(QString))); QSignalSpy rem(m, SIGNAL(contextRemoved(QString))); @@ -63,6 +62,7 @@ QTRY_COMPARE(pow.count(), 1); QCOMPARE(pow.takeFirst().at(0).toBool(), true); QCOMPARE(m->powered(), true); + m->setRoamingAllowed(false); QTRY_COMPARE(roam.count(), 1); QCOMPARE(roam.takeFirst().at(0).toBool(), false); @@ -71,6 +71,7 @@ QTRY_COMPARE(roam.count(), 1); QCOMPARE(roam.takeFirst().at(0).toBool(), true); QCOMPARE(m->roamingAllowed(), true); + m->addContext(QString("internet")); QTRY_COMPARE(add.count(), 1); @@ -108,7 +109,6 @@ void cleanupTestCase() { - } private: diff -Nru libqofono-0.53/test/auto/tests/tst_qofonomanager.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonomanager.cpp --- libqofono-0.53/test/auto/tests/tst_qofonomanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonomanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -24,8 +24,8 @@ #include #include -#include "../../../src/qofonomanager.h" -#include "../../../src/qofonomodem.h" +#include "qofonomanager.h" +#include "qofonomodem.h" #include @@ -39,6 +39,9 @@ void initTestCase() { mm = new QOfonoManager(this); + QCOMPARE(mm->modems(), QStringList()); + QSignalSpy defaultModem(mm, SIGNAL(defaultModemChanged(QString))); + QTRY_COMPARE(defaultModem.count(), 1); } void testQOfonoManager() diff -Nru libqofono-0.53/test/auto/tests/tst_qofonomessagemanager.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonomessagemanager.cpp --- libqofono-0.53/test/auto/tests/tst_qofonomessagemanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonomessagemanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,14 +22,9 @@ */ #include -#include -#include -#include "../../../src/qofonomanager.h" -#include "../../../src/qofonomessagemanager.h" -#include "../../../src/qofonomessage.h" - -#include +#include "qofonomessagemanager.h" +#include "qofonomessage.h" class TestQOfonoMessageManager : public QObject { @@ -41,10 +36,9 @@ private slots: void initTestCase() { - QOfonoManager manager; m = new QOfonoMessageManager(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoMessageManager() @@ -55,7 +49,6 @@ QSignalSpy immediateMessage(m, SIGNAL(immediateMessage(QString, QVariantMap))); QSignalSpy incomingMessage(m, SIGNAL(incomingMessage(QString, QVariantMap))); - QStringList messages = m->messages(); QVERIFY(messages.count() == 0); diff -Nru libqofono-0.53/test/auto/tests/tst_qofonomessagewaiting.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonomessagewaiting.cpp --- libqofono-0.53/test/auto/tests/tst_qofonomessagewaiting.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonomessagewaiting.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,12 +22,9 @@ */ #include -#include -#include "../../../src/qofonomessagewaiting.h" -#include "../../../src/qofonomodem.h" - -#include +#include "qofonomessagewaiting.h" +#include "qofonomodem.h" class TestQOfonoMessageWaiting : public QObject { @@ -41,7 +38,7 @@ { m = new QOfonoMessageWaiting(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoMessageWaiting() @@ -54,6 +51,10 @@ QSignalSpy mailboxNumber(m, SIGNAL(voicemailMailboxNumberChanged(QString))); QSignalSpy setNumberComplete(m, SIGNAL(voicemailMailboxComplete(bool))); + // Wait for modem to become ready + QTRY_COMPARE(modemOnline.count(), 1); + QCOMPARE(modemOnline.takeFirst().at(0).toBool(), true); + QCOMPARE(m->voicemailWaiting(), true); QCOMPARE(m->voicemailMessageCount(), 1); QCOMPARE(m->voicemailMailboxNumber(), QString("6789")); @@ -63,10 +64,13 @@ QCOMPARE(modemOnline.takeFirst().at(0).toBool(), false); QTest::qWait(REASONABLE_TIMEOUT); - QCOMPARE(waiting.count(), 0); - QCOMPARE(messageCount.count(), 0); - QCOMPARE(mailboxNumber.count(), 0); + QTRY_COMPARE(waiting.count(), 1); + QTRY_COMPARE(messageCount.count(), 1); + QTRY_COMPARE(mailboxNumber.count(), 1); QCOMPARE(setNumberComplete.count(), 0); + QCOMPARE(waiting.takeFirst().at(0).toInt(), 0); + QCOMPARE(messageCount.takeFirst().at(0).toInt(), 0); + QCOMPARE(mailboxNumber.takeFirst().at(0).toString(), QString("")); modem.setOnline(true); QTRY_COMPARE(modemOnline.count(), 1); @@ -115,7 +119,6 @@ void cleanupTestCase() { - } private: diff -Nru libqofono-0.53/test/auto/tests/tst_qofononetworkoperator.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofononetworkoperator.cpp --- libqofono-0.53/test/auto/tests/tst_qofononetworkoperator.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofononetworkoperator.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,12 +22,9 @@ */ #include -#include -#include "../../../src/qofononetworkregistration.h" -#include "../../../src/qofononetworkoperator.h" - -#include +#include "qofononetworkregistration.h" +#include "qofononetworkoperator.h" // Do it here to not break API compatibility - also see qRegisterMetaType below Q_DECLARE_METATYPE(QOfonoNetworkOperator::Error) @@ -47,8 +44,7 @@ { m = new QOfonoNetworkRegistration(this); m->setModemPath("/phonesim"); - - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoNetworkOperator() @@ -69,6 +65,7 @@ { QOfonoNetworkOperator *op = new QOfonoNetworkOperator(this); op->setOperatorPath(opId); + QTRY_VERIFY(op->isValid()); opList << op; if (op1 == -1 && op->status() == "current") op1 = opIdList.indexOf(opId); diff -Nru libqofono-0.53/test/auto/tests/tst_qofononetworkregistration.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofononetworkregistration.cpp --- libqofono-0.53/test/auto/tests/tst_qofononetworkregistration.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofononetworkregistration.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,13 +22,10 @@ */ #include -#include -#include "../../../src/qofononetworkregistration.h" -#include "../../../src/qofonomanager.h" -#include "../../../src/qofonomodem.h" +#include "qofononetworkregistration.h" +#include "qofonomodem.h" -#include class TestQOfonoNetworkRegistration : public QObject { @@ -37,10 +34,9 @@ private slots: void initTestCase() { - QOfonoManager manager; m = new QOfonoNetworkRegistration(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoNetworkRegistration() @@ -79,24 +75,30 @@ modem.setOnline(true); QTRY_COMPARE(modem.online(), true); - QEXPECT_FAIL("", "Network registration status does not change when modem goes offline", - Abort); - QTRY_COMPARE(status.count(), 1); + QTRY_COMPARE(status.count(), 3); + QCOMPARE(status.takeFirst().at(0).toString(), QString("")); + QCOMPARE(status.takeFirst().at(0).toString(), QString("unknown")); QCOMPARE(status.takeFirst().at(0).toString(), QString("registered")); - QCOMPARE(mcc.count(), 1); + + QTRY_COMPARE(mcc.count(), 2); + QCOMPARE(mcc.takeFirst().at(0).toString(), QString("")); QCOMPARE(mcc.takeFirst().at(0).toString(), QString("234")); - QCOMPARE(mnc.count(), 1); + + QTRY_COMPARE(mnc.count(), 2); + QCOMPARE(mnc.takeFirst().at(0).toString(), QString("")); QCOMPARE(mnc.takeFirst().at(0).toString(), QString("01")); - QCOMPARE(name.count(), 2); - QVERIFY(name.takeFirst().at(0).toString().length() > 0); + + QTRY_COMPARE(name.count(), 2); + QVERIFY(name.takeFirst().at(0).toString().isEmpty()); QVERIFY(name.takeFirst().at(0).toString().length() > 0); - QCOMPARE(strength.count(), 1); + + QTRY_COMPARE(strength.count(), 2); + QCOMPARE(strength.takeFirst().at(0).toUInt(), uint(0)); QCOMPARE(strength.takeFirst().at(0).toUInt(), uint(100)); } void cleanupTestCase() { - } private: diff -Nru libqofono-0.53/test/auto/tests/tst_qofonophonebook.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonophonebook.cpp --- libqofono-0.53/test/auto/tests/tst_qofonophonebook.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonophonebook.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,11 +22,8 @@ */ #include -#include -#include "../../../src/qofonophonebook.h" - -#include +#include "qofonophonebook.h" class TestQOfonoPhonebook : public QObject { @@ -37,6 +34,7 @@ { m = new QOfonoPhonebook(this); m->setModemPath("/phonesim"); + QTRY_VERIFY(m->isValid()); } void testQOfonoPhonebook() @@ -60,7 +58,6 @@ void cleanupTestCase() { - } private: diff -Nru libqofono-0.53/test/auto/tests/tst_qofonoradiosettings.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonoradiosettings.cpp --- libqofono-0.53/test/auto/tests/tst_qofonoradiosettings.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonoradiosettings.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,9 +22,8 @@ */ #include -#include -#include "../../../src/qofonoradiosettings.h" +#include "qofonoradiosettings.h" #include @@ -37,11 +36,10 @@ { m = new QOfonoRadioSettings(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); QEXPECT_FAIL("", "FIXME: radio settings interface is not supported by AT modems, " "and consequently, phonesim", Abort); - QVERIFY(false); + QTRY_VERIFY(m->isValid()); } void testQOfonoRadioSettings() diff -Nru libqofono-0.53/test/auto/tests/tst_qofonosimmanager.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonosimmanager.cpp --- libqofono-0.53/test/auto/tests/tst_qofonosimmanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonosimmanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -52,7 +52,7 @@ m = new QOfonoSimManager(this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); + QTRY_COMPARE(m->isValid(), true); } void testQOfonoSimManager() @@ -131,6 +131,12 @@ QSignalSpy modemOnline(&modem, SIGNAL(onlineChanged(bool))); QSignalSpy modemPowered(&modem, SIGNAL(poweredChanged(bool))); + // Wait for modem to become ready + QTRY_COMPARE(modemOnline.count(), 1); + QCOMPARE(modemOnline.takeFirst().at(0).toBool(), true); + QTRY_COMPARE(modemPowered.count(), 1); + QCOMPARE(modemPowered.takeFirst().at(0).toBool(), true); + //SIM hotswap is not testable with phonesim, so we simulate a modem reset modem.setOnline(false); QTRY_COMPARE(modemOnline.count(), 1); diff -Nru libqofono-0.53/test/auto/tests/tst_qofonosupplementaryservices.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonosupplementaryservices.cpp --- libqofono-0.53/test/auto/tests/tst_qofonosupplementaryservices.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonosupplementaryservices.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,11 +22,8 @@ */ #include -#include -#include "../../../src/qofonosupplementaryservices.h" - -#include +#include "qofonosupplementaryservices.h" class TestQOfonoSupplementaryServices : public QObject { @@ -37,7 +34,7 @@ { m = new QOfonoSupplementaryServices( this); m->setModemPath("/phonesim"); - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoSupplementaryServices() @@ -141,7 +138,6 @@ void cleanupTestCase() { - } private: diff -Nru libqofono-0.53/test/auto/tests/tst_qofonovoicecall.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonovoicecall.cpp --- libqofono-0.53/test/auto/tests/tst_qofonovoicecall.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonovoicecall.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -22,11 +22,9 @@ */ #include -#include -#include "../../../src/qofonovoicecallmanager.h" -#include "../../../src/qofonovoicecall.h" -#include +#include "qofonovoicecallmanager.h" +#include "qofonovoicecall.h" // FIXME: Not aligned with the current API class TestQOfonoVoiceCall : public QObject @@ -38,8 +36,7 @@ { m = new QOfonoVoiceCallManager( this); m->setModemPath("/phonesim"); - - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoVoiceCall() @@ -58,6 +55,7 @@ QOfonoVoiceCall* call = new QOfonoVoiceCall(this); call->setVoiceCallPath(callid); + QTRY_VERIFY(call->isValid()); QSignalSpy state(call, SIGNAL(stateChanged(QString))); QSignalSpy discreason(call,SIGNAL(disconnectReason(QString))); @@ -176,6 +174,7 @@ delete call; } + void testQOfonoVoiceCallStep4() { //Deflect @@ -202,12 +201,11 @@ delete call; } + void cleanupTestCase() { - } - private: QOfonoVoiceCallManager *m; }; diff -Nru libqofono-0.53/test/auto/tests/tst_qofonovoicecallmanager.cpp libqofono-0.70~rtm/test/auto/tests/tst_qofonovoicecallmanager.cpp --- libqofono-0.53/test/auto/tests/tst_qofonovoicecallmanager.cpp 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tests/tst_qofonovoicecallmanager.cpp 2015-01-09 08:20:12.000000000 +0000 @@ -24,8 +24,8 @@ #include #include -#include "../../../src/qofonovoicecallmanager.h" -#include "../../../src/qofonomodem.h" +#include "qofonovoicecallmanager.h" +#include "qofonomodem.h" #include @@ -39,8 +39,7 @@ { m = new QOfonoVoiceCallManager(this); m->setModemPath("/phonesim"); - - QCOMPARE(m->isValid(), true); + QTRY_VERIFY(m->isValid()); } void testQOfonoVoiceCallManager() @@ -57,14 +56,17 @@ QOfonoModem modem; modem.setModemPath(m->modemPath()); modem.setPowered(false); - QTest::qWait(5000); + QTRY_VERIFY(!modem.powered()); modem.setPowered(true); - QTest::qWait(5000); + QTRY_VERIFY(modem.powered()); modem.setOnline(true); - QTest::qWait(5000); + QTRY_VERIFY(modem.online()); + + QTRY_COMPARE(emergencyNumbers.count(), 3); + QVERIFY(emergencyNumbers.takeFirst().at(0).toStringList().isEmpty()); + QVERIFY(!emergencyNumbers.takeFirst().at(0).toStringList().isEmpty()); + QVERIFY(!emergencyNumbers.takeFirst().at(0).toStringList().isEmpty()); - QCOMPARE(emergencyNumbers.count(), 1); - QVERIFY(emergencyNumbers.takeFirst().at(0).toStringList().count() > 0); //Dial testing m->dial("123",""); qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button"; @@ -114,12 +116,10 @@ QTest::qWait(10000); QCOMPARE(hspy.count(), 1); - } void cleanupTestCase() { - } diff -Nru libqofono-0.53/test/auto/tst_qofono/tst_qofono.pro libqofono-0.70~rtm/test/auto/tst_qofono/tst_qofono.pro --- libqofono-0.53/test/auto/tst_qofono/tst_qofono.pro 2014-06-10 07:12:07.000000000 +0000 +++ libqofono-0.70~rtm/test/auto/tst_qofono/tst_qofono.pro 2015-01-09 08:20:12.000000000 +0000 @@ -10,12 +10,12 @@ equals(QT_MAJOR_VERSION, 4): { LIBS += -lqofono TARGET = tst_qofonotest - target.path = $$INSTALL_ROOT$$PREFIX/lib/libqofono/tests + target.path = $$[QT_INSTALL_LIBS]/libqofono/tests } equals(QT_MAJOR_VERSION, 5): { LIBS += -lqofono-qt5 TARGET = tst_qofonotest-qt5 - target.path = $$INSTALL_ROOT$$PREFIX/lib/libqofono-qt5/tests + target.path = $$[QT_INSTALL_LIBS]/libqofono-qt5/tests } CONFIG += console