./0000755000004100000410000000000012762041045011244 5ustar www-datawww-data./rpm/0000755000004100000410000000000012762041064012043 5ustar www-datawww-data./rpm/libqofono.spec0000644000004100000410000000364612762041045014717 0ustar www-datawww-dataName: libqofono Summary: A library of Qt bindings for ofono Version: 0.59 Release: 1 Group: System/Libraries License: LGPLv2.1 URL: https://github.com/nemomobile/libqofono Source0: libqofono-%{version}.tar.bz2 Requires: mobile-broadband-provider-info Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(QtCore) BuildRequires: pkgconfig(QtDBus) BuildRequires: pkgconfig(QtXmlPatterns) %description This package contains Qt bindings for ofono cellular service interfaces. %package declarative Summary: Declarative plugin for libqofono Group: Development/Tools Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version} %description declarative This package contains declarative plugin for libofono. %package devel Summary: Development files for ofono Qt bindings Group: Development/Libraries Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version} %description devel This package contains the development header files for the ofono Qt bindings. %package tests Summary: qml test app for the ofono Qt bindings Group: Development/Tools Requires: %{name} = %{version}-%{release} %description tests This package contains qml test for ofono Qt bindings. %prep %setup -q -n libqofono-%{version} %build %qmake make %{?jobs:-j%jobs} %install rm -rf %{buildroot} %qmake_install %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr(-,root,root,-) %{_libdir}/%{name}.so.* %files declarative %defattr(-,root,root,-) %{_libdir}/qt4/imports/MeeGo/QOfono/* %files devel %defattr(-,root,root,-) %{_libdir}/%{name}.prl %{_libdir}/%{name}.so %{_libdir}/pkgconfig/qofono.pc %{_includedir}/qofono/*.h %{_includedir}/qofono/dbus/ofono*.xml %{_datadir}/qt4/mkspecs/features/qofono.prf %files tests %defattr(-,root,root,-) /opt/ofonotest/bin/ofonotest /opt/ofonotest/qml/ofonotest/*.qml %{_libdir}/%{name}/tests/* ./rpm/libqofono-qt5.spec0000644000004100000410000000413212762041064015416 0ustar www-datawww-dataName: libqofono-qt5 Summary: A library of Qt 5 bindings for ofono Version: 0.90 Release: 1 Group: System/Libraries License: LGPLv2.1 URL: https://git.merproject.org/mer-core/libqofono Source0: %{name}-%{version}.tar.bz2 Requires: qt5-qtcore Requires: mobile-broadband-provider-info Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(Qt5Core) BuildRequires: pkgconfig(Qt5DBus) BuildRequires: pkgconfig(Qt5Quick) BuildRequires: pkgconfig(Qt5Test) BuildRequires: pkgconfig(Qt5XmlPatterns) %description This package contains Qt bindings for ofono cellular service interfaces. %package declarative Summary: Declarative plugin for libqofono Group: Development/Tools Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version} %description declarative This package contains declarative plugin for libofono. %package devel Summary: Development files for ofono Qt bindings Group: Development/Libraries Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version} %description devel This package contains the development header files for the ofono Qt bindings. %package tests Summary: qml test app for the ofono Qt bindings 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. %prep %setup -q -n %{name}-%{version} %build export QT_SELECT=5 %qmake5 make %{?jobs:-j%jobs} %install rm -rf %{buildroot} export QT_SELECT=5 %qmake5_install %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %files %defattr(-,root,root,-) %{_libdir}/%{name}.so.* %files declarative %defattr(-,root,root,-) %{_libdir}/qt5/qml/MeeGo/QOfono/* %files devel %defattr(-,root,root,-) %{_libdir}/%{name}.prl %{_libdir}/%{name}.so %{_libdir}/pkgconfig/qofono-qt5.pc %{_includedir}/qofono-qt5/*.h %{_includedir}/qofono-qt5/dbus/ofono*.xml %{_datadir}/qt5/mkspecs/features/qofono-qt5.prf %files tests %defattr(-,root,root,-) %{_libdir}/%{name}/tests/* /opt/tests/%{name}/* ./rpm/libqofono.changes0000644000004100000410000000121612762041045015364 0ustar www-datawww-data* Wed May 22 2013 Lorn Potter - 0.10 - fix pkgconfig version. * Mon May 20 2013 Lorn Potter - 0.9 - add assisted satellite navigation, location reporting * Thu May 9 2013 Lorn Potter - 0.6 - [libqofono] add some compatible signals to modem and simmanager * Wed Apr 17 2013 Lorn Potter - 0.3 - change lib name and declarative install dir for qt5 * Wed Apr 10 2013 Lorn Potter - 0.2 - fixed removeContext function * Sat Feb 2 2013 Lorn Potter - 0.1 - initial obs commit ./src/0000755000004100000410000000000012762041064012034 5ustar www-datawww-data./src/qofonotexttelephony.h0000644000004100000410000000347112762041045016347 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOTextTelephony_H #define QOFONOTextTelephony_H #include "qofonomodeminterface.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/text-telephony-api.txt */ class QOFONOSHARED_EXPORT QOfonoTextTelephony : public QOfonoModemInterface { Q_OBJECT Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(bool ttyEnabled READ ttyEnabled WRITE setTtyEnabled NOTIFY ttyEnabledChanged) public: explicit QOfonoTextTelephony(QObject *parent = 0); ~QOfonoTextTelephony(); QString modemPath() const; void setModemPath(const QString &path); bool ttyEnabled() const; void setTtyEnabled(bool enabled); bool isValid() const; Q_SIGNALS: void ttyEnabledChanged(bool); void modemPathChanged(const QString &path); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); void propertyChanged(const QString &key, const QVariant &value); }; #endif // QOFONOTextTelephony_H ./src/qofonoradiosettings.h0000644000004100000410000000543412762041045016313 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONORadioSettings_H #define QOFONORadioSettings_H #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 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(QStringList availableTechnologies READ availableTechnologies NOTIFY availableTechnologiesChanged) 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) public: explicit QOfonoRadioSettings(QObject *parent = 0); ~QOfonoRadioSettings(); QString modemPath() const; void setModemPath(const QString &path); QString technologyPreference() const; void setTechnologyPreference(const QString &preference); QStringList availableTechnologies() const; QString gsmBand() const; void setGsmBand(const QString &gsmBand); QString umtsBand() const; void setUmtsBand(const QString &umtsBand); bool fastDormancy() const; void setFastDormancy(bool fastDormancy); bool isValid() const; Q_SIGNALS: void technologyPreferenceChanged(const QString &preference); void availableTechnologiesChanged(const QStringList &technologies); void gsmBandChanged(const QString &gsmBand); void umtsBandChanged(const QString &umtsBand); void fastDormancyChanged(bool fastDormancy); void modemPathChanged(const QString &path); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); void propertyChanged(const QString &key, const QVariant &value); }; #endif // QOFONORadioSettings_H ./src/qofono_global.h0000644000004100000410000000171212762041045015026 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONO_GLOBAL_H #define QOFONO_GLOBAL_H #include #include "dbustypes.h" #if defined(QOFONO_LIBRARY) # define QOFONOSHARED_EXPORT Q_DECL_EXPORT #else # define QOFONOSHARED_EXPORT Q_DECL_IMPORT #endif #endif // QOFONO_GLOBAL_H ./src/qofonomessage.h0000644000004100000410000000350112762041045015051 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOMessage_H #define QOFONOMessage_H #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 QOFONOSHARED_EXPORT QOfonoMessage : public QOfonoObject { Q_OBJECT Q_PROPERTY(QString messagePath READ messagePath WRITE setMessagePath NOTIFY messagePathChanged) Q_PROPERTY(QString state READ state NOTIFY stateChanged) public: explicit QOfonoMessage(QObject *parent = 0); ~QOfonoMessage(); QString messagePath() const; void setMessagePath(const QString &path); QString state() const; Q_INVOKABLE void cancel(); bool isValid() const; Q_SIGNALS: void stateChanged(const QString &state); void messagePathChanged(const QString &path); 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 ./src/qofonoassistedsatellitenavigation.cpp0000644000004100000410000000603312762041045021571 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonoassistedsatellitenavigation.h" #include "ofono_assisted_satellite_navigation_interface.h" class QOfonoAssistedSatelliteNavigationPrivate { public: QOfonoAssistedSatelliteNavigationPrivate(); QString modemPath; OfonoAssistedSatelliteNavigation *ofonoAssistedSatelliteNav; }; QOfonoAssistedSatelliteNavigationPrivate::QOfonoAssistedSatelliteNavigationPrivate() : modemPath(QString()) , ofonoAssistedSatelliteNav(0) { } QOfonoAssistedSatelliteNavigation::QOfonoAssistedSatelliteNavigation(QObject *parent) : QObject(parent) , d_ptr(new QOfonoAssistedSatelliteNavigationPrivate) { } QOfonoAssistedSatelliteNavigation::~QOfonoAssistedSatelliteNavigation() { delete d_ptr; } void QOfonoAssistedSatelliteNavigation::setModemPath(const QString &path) { if (path == d_ptr->modemPath || path.isEmpty()) return; if (path != modemPath()) { if (d_ptr->ofonoAssistedSatelliteNav) { delete d_ptr->ofonoAssistedSatelliteNav; d_ptr->ofonoAssistedSatelliteNav = 0; } d_ptr->ofonoAssistedSatelliteNav = new OfonoAssistedSatelliteNavigation("org.ofono", path, QDBusConnection::systemBus(),this); if (d_ptr->ofonoAssistedSatelliteNav->isValid()) { d_ptr->modemPath = path; Q_EMIT modemPathChanged(path); } } } QString QOfonoAssistedSatelliteNavigation::modemPath() const { return d_ptr->modemPath; } void QOfonoAssistedSatelliteNavigation::registerPositioningRequestAgent(const QString &path) { if (d_ptr->ofonoAssistedSatelliteNav) { QDBusPendingReply <> reply = d_ptr->ofonoAssistedSatelliteNav->RegisterPositioningRequestAgent(QDBusObjectPath(path)); if (reply.isError()) qDebug() << reply.error().message(); } } void QOfonoAssistedSatelliteNavigation::sendPositioningElement(const QString &xmlElement) { if (d_ptr->ofonoAssistedSatelliteNav) d_ptr->ofonoAssistedSatelliteNav->SendPositioningElement(xmlElement); } void QOfonoAssistedSatelliteNavigation::unregisterPositioningRequestAgent(const QString &path) { if (d_ptr->ofonoAssistedSatelliteNav) d_ptr->ofonoAssistedSatelliteNav->UnregisterPositioningRequestAgent(QDBusObjectPath(path)); } bool QOfonoAssistedSatelliteNavigation::isValid() const { return d_ptr->ofonoAssistedSatelliteNav->isValid(); } ./src/qofonocallforwarding.cpp0000644000004100000410000001120212762041045016753 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonocallforwarding.h" #include "ofono_call_forwarding_interface.h" #define SUPER QOfonoModemInterface QOfonoCallForwarding::QOfonoCallForwarding(QObject *parent) : SUPER(OfonoCallForwarding::staticInterfaceName(), parent) { } QOfonoCallForwarding::~QOfonoCallForwarding() { } QDBusAbstractInterface *QOfonoCallForwarding::createDbusInterface(const QString &path) { return new OfonoCallForwarding("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoCallForwarding::connectOfono() { resetDbusInterface(); } void QOfonoCallForwarding::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("VoiceUnconditional")) { Q_EMIT voiceUnconditionalChanged(value.toString()); } else if (property == QLatin1String("VoiceBusy")) { Q_EMIT voiceBusyChanged(value.toString()); } else if (property == QLatin1String("VoiceNoReply")) { Q_EMIT voiceNoReplyChanged(value.toString()); } else if (property == QLatin1String("VoiceNoReplyTimeout")) { Q_EMIT voiceNoReplyTimeoutChanged(value.value()); } else if (property == QLatin1String("VoiceNotReachable")) { Q_EMIT voiceNotReachableChanged(value.toString()); } else if (property == QLatin1String("ForwardingFlagOnSim")) { Q_EMIT forwardingFlagOnSimChanged(value.toBool()); } } QString QOfonoCallForwarding::voiceUnconditional() { return getString("VoiceUnconditional"); } void QOfonoCallForwarding::setVoiceUnconditional(const QString &property) { setProperty("VoiceUnconditional", property); } QString QOfonoCallForwarding::voiceBusy() { return getString("VoiceBusy"); } void QOfonoCallForwarding::setVoiceBusy(const QString &property) { setProperty("VoiceBusy", property); } QString QOfonoCallForwarding::voiceNoReply() { return getString("VoiceNoReply"); } void QOfonoCallForwarding::setVoiceNoReply(const QString &property) { setProperty("VoiceNoReply", property); } quint16 QOfonoCallForwarding::voiceNoReplyTimeout() { return getProperty("VoiceNoReplyTimeout").value(); } void QOfonoCallForwarding::setVoiceNoReplyTimeout(ushort timeout) { setProperty("VoiceNoReplyTimeout", QVariant::fromValue((quint16)timeout)); } QString QOfonoCallForwarding::voiceNotReachable() { return getString("VoiceNotReachable"); } void QOfonoCallForwarding::setVoiceNotReachable(const QString &property) { setProperty("VoiceNotReachable", property); } bool QOfonoCallForwarding::forwardingFlagOnSim() { return getBool("ForwardingFlagOnSim"); } void QOfonoCallForwarding::disableAll(const QString &type) { OfonoCallForwarding *iface = (OfonoCallForwarding*)dbusInterface(); if (iface) { iface->DisableAll(type); } } void QOfonoCallForwarding::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) { SUPER::getPropertiesFinished(properties, error); if (error) { Q_EMIT getPropertiesFailed(); } } void QOfonoCallForwarding::setPropertyFinished(const QString &property, const QDBusError *error) { 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); } } QString QOfonoCallForwarding::modemPath() const { return SUPER::modemPath(); } void QOfonoCallForwarding::setModemPath(const QString &path) { SUPER::setModemPath(path); } bool QOfonoCallForwarding::isValid() const { return SUPER::isValid(); } bool QOfonoCallForwarding::isReady() const { return SUPER::isReady(); } ./src/qofonocallmeter.h0000644000004100000410000000542212762041045015401 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOCallMeter_H #define QOFONOCallMeter_H #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 QOFONOSHARED_EXPORT QOfonoCallMeter : public QOfonoModemInterface { Q_OBJECT Q_ENUMS(Error) Q_PROPERTY(quint32 callMeter READ callMeter CONSTANT) Q_PROPERTY(quint32 accumulatedCallMeter READ accumulatedCallMeter CONSTANT) Q_PROPERTY(quint32 accumulatedCallMeterMaximum READ accumulatedCallMeterMaximum NOTIFY accumulatedCallMeterMaximumChanged) Q_PROPERTY(qreal pricePerUnit READ pricePerUnit NOTIFY pricePerUnitChanged) Q_PROPERTY(QString currency READ currency CONSTANT) public: enum Error { NoError, NotImplementedError, InProgressError, InvalidArgumentsError, InvalidFormatError, FailedError, UnknownError }; explicit QOfonoCallMeter(QObject *parent = 0); ~QOfonoCallMeter(); QString modemPath() const; void setModemPath(const QString &path); quint32 callMeter() const; quint32 accumulatedCallMeter() const; quint32 accumulatedCallMeterMaximum() const; void setAccumulatedCallMeterMaximum(quint32 max, const QString &password); qreal pricePerUnit() const; void setPricePerUnit(qreal unit, const QString &password); QString currency() const; Q_INVOKABLE void reset(const QString &password); bool isValid() const; Q_SIGNALS: void nearMaximumWarning(); void accumulatedCallMeterMaximumChanged(quint32); void pricePerUnitChanged(qreal); void resetComplete(QOfonoCallMeter::Error error,const QString &errorString); private: static Error errorNameToEnum(const QString &errorName); private slots: void onResetFinished(QDBusPendingCallWatcher *call); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); void propertyChanged(const QString &property, const QVariant &value); }; #endif // QOFONOCallMeter_H ./src/qofonomessagewaiting.h0000644000004100000410000000465412762041045016446 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOMessageWaiting_H #define QOFONOMessageWaiting_H #include "qofonomodeminterface.h" #include "qofono_global.h" /*! * 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 QOFONOSHARED_EXPORT QOfonoMessageWaiting : public QOfonoModemInterface { Q_OBJECT 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) public: explicit QOfonoMessageWaiting(QObject *parent = 0); ~QOfonoMessageWaiting(); QString modemPath() const; void setModemPath(const QString &path); bool voicemailWaiting() const; int voicemailMessageCount() const; QString voicemailMailboxNumber() const; void setVoicemailMailboxNumber(const QString &mailboxnumber); bool isValid() const; bool isReady() const; void connectOfono(); Q_SIGNALS: void voicemailWaitingChanged(bool waiting); void voicemailMessageCountChanged(int count); void voicemailMailboxNumberChanged(const QString &mailboxnumber); void voicemailMailboxComplete(bool success); void getPropertiesFailed(); 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 ./src/qofonosimwatcher.h0000644000004100000410000000304212762041064015574 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2015 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 QOFONOSIMWATCHER_H #define QOFONOSIMWATCHER_H #include "qofono_global.h" #include "qofonosimmanager.h" // Watches present SIM cards class QOFONOSHARED_EXPORT QOfonoSimWatcher : public QObject { Q_OBJECT Q_PROPERTY(bool valid READ isValid NOTIFY validChanged) Q_PROPERTY(int presentSimCount READ presentSimCount NOTIFY presentSimCountChanged) public: explicit QOfonoSimWatcher(QObject *parent = 0); ~QOfonoSimWatcher(); bool isValid() const; bool requireSubscriberIdentity() const; void setRequireSubscriberIdentity(bool require); int presentSimCount() const; QList presentSimList() const; Q_SIGNALS: void validChanged(); void presentSimCountChanged(); void presentSimListChanged(); private: class Private; Private* d_ptr; }; #endif // QOFONOSIMWATCHER_H ./src/qofonohandsfree.cpp0000644000004100000410000000774512762041045015735 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonohandsfree.h" #include "ofono_handsfree_interface.h" class QOfonoHandsfreePrivate { public: QOfonoHandsfreePrivate(); QString modemPath; OfonoHandsfree *ofonoHandsFree; QVariantMap properties; }; QOfonoHandsfreePrivate::QOfonoHandsfreePrivate() : modemPath(QString()) , ofonoHandsFree(0) { } QOfonoHandsfree::QOfonoHandsfree(QObject *parent) : QObject(parent) , d_ptr(new QOfonoHandsfreePrivate) { } QOfonoHandsfree::~QOfonoHandsfree() { delete d_ptr; } void QOfonoHandsfree::setModemPath(const QString &path) { if (path == d_ptr->modemPath || path.isEmpty()) return; if (path != modemPath()) { if (d_ptr->ofonoHandsFree) { delete d_ptr->ofonoHandsFree; d_ptr->ofonoHandsFree = 0; d_ptr->properties.clear(); } d_ptr->ofonoHandsFree = new OfonoHandsfree("org.ofono", path, QDBusConnection::systemBus(),this); if (d_ptr->ofonoHandsFree) { d_ptr->modemPath = path; connect(d_ptr->ofonoHandsFree,SIGNAL(PropertyChanged(QString,QDBusVariant)), this,SLOT(propertyChanged(QString,QDBusVariant))); QDBusPendingReply reply; reply = d_ptr->ofonoHandsFree->GetProperties(); reply.waitForFinished(); d_ptr->properties = reply.value(); Q_EMIT modemPathChanged(path); } } } QString QOfonoHandsfree::modemPath() const { return d_ptr->modemPath; } void QOfonoHandsfree::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) { QVariant value = dbusvalue.variant(); d_ptr->properties.insert(property,value); if (property == QLatin1String("VoiceRecognition")) { Q_EMIT voiceRecognitionChanged(value.value()); } else if (property == QLatin1String("EchoCancelingNoiseReduction")) { Q_EMIT echoCancelingNoiseReductionChanged(value.value()); } } QStringList QOfonoHandsfree::features() const { if (d_ptr->ofonoHandsFree) { return d_ptr->properties["Features"].value(); } return QStringList(); } bool QOfonoHandsfree::inbandRinging() const { if (d_ptr->ofonoHandsFree) { return d_ptr->properties["InbandRinging"].value(); } return false; } bool QOfonoHandsfree::voiceRecognition() const { if (d_ptr->ofonoHandsFree) { return d_ptr->properties["VoiceRecognition"].value(); } return false; } void QOfonoHandsfree::setVoiceRecognition(bool on) { if (d_ptr->ofonoHandsFree) { d_ptr->ofonoHandsFree->SetProperty("VoiceRecognition",QDBusVariant(on)); } } bool QOfonoHandsfree::echoCancelingNoiseReduction() const { if (d_ptr->ofonoHandsFree) { return d_ptr->properties["EchoCancelingNoiseReduction"].value(); } return false; } void QOfonoHandsfree::setEchoCancelingNoiseReduction(bool on) { if (d_ptr->ofonoHandsFree) { d_ptr->ofonoHandsFree->SetProperty("EchoCancelingNoiseReduction",QDBusVariant(on)); } } uchar QOfonoHandsfree::batteryChargeLevel() const { if (d_ptr->ofonoHandsFree) { return d_ptr->properties["BatteryChargeLevel"].value(); } return 0; } bool QOfonoHandsfree::isValid() const { return d_ptr->ofonoHandsFree->isValid(); } ./src/qofonohandsfreeaudioagent.cpp0000644000004100000410000000476612762041045017776 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonohandsfreeaudioagent.h" #include "ofono_handsfree_audio_agent_interface.h" class QOfonoHandsfreeAudioAgentPrivate { public: QOfonoHandsfreeAudioAgentPrivate(); QString audioAgentPath; OfonoHandsfreeAudioAgent *ofonoHandsfreeAudioAgent; }; QOfonoHandsfreeAudioAgentPrivate::QOfonoHandsfreeAudioAgentPrivate() : ofonoHandsfreeAudioAgent(0) { } QOfonoHandsfreeAudioAgent::QOfonoHandsfreeAudioAgent(QObject *parent) : QObject(parent) , d_ptr(new QOfonoHandsfreeAudioAgentPrivate) { } QOfonoHandsfreeAudioAgent::~QOfonoHandsfreeAudioAgent() { delete d_ptr; } void QOfonoHandsfreeAudioAgent::setAgentPath(const QString &path) { if (!d_ptr->ofonoHandsfreeAudioAgent) { d_ptr->audioAgentPath = path; d_ptr->ofonoHandsfreeAudioAgent = new OfonoHandsfreeAudioAgent("org.ofono", path, QDBusConnection::systemBus(),this); } } QString QOfonoHandsfreeAudioAgent::agentPath() const { return d_ptr->audioAgentPath; } void QOfonoHandsfreeAudioAgent::NewConnection(const QString &card, QDBusUnixFileDescriptor sco, const QByteArray &codec) { Q_EMIT newConnection(card, sco, codec); } void QOfonoHandsfreeAudioAgent::Release() { Q_EMIT release(); } bool QOfonoHandsfreeAudioAgent::isValid() const { return d_ptr->ofonoHandsfreeAudioAgent->isValid(); } QOfonoHandsfreeAudioAgentAdaptor::QOfonoHandsfreeAudioAgentAdaptor(QOfonoHandsfreeAudioAgent *parent) : QDBusAbstractAdaptor(parent), audioAgent(parent) { } QOfonoHandsfreeAudioAgentAdaptor::~QOfonoHandsfreeAudioAgentAdaptor() { } void QOfonoHandsfreeAudioAgentAdaptor::NewConnection(const QString &card, QDBusUnixFileDescriptor sco, const QByteArray & codec) { audioAgent->NewConnection(card, sco, codec); } void QOfonoHandsfreeAudioAgentAdaptor::Release() { audioAgent->Release(); } ./src/qofonohandsfree.h0000644000004100000410000000432712762041045015373 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOQOFONOHANDSFREE_H #define QOFONOQOFONOHANDSFREE_H #include #include #include class QOfonoHandsfreePrivate; class QOfonoHandsfree : public QObject { Q_OBJECT Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QStringList features READ features) Q_PROPERTY(bool inbandRinging READ inbandRinging) Q_PROPERTY(bool voiceRecognition READ voiceRecognition WRITE setVoiceRecognition WRITE voiceRecognitionChanged) Q_PROPERTY(bool echoCancelingNoiseReduction READ echoCancelingNoiseReduction WRITE setEchoCancelingNoiseReduction NOTIFY echoCancelingNoiseReductionChanged) Q_PROPERTY(uchar batteryChargeLevel READ batteryChargeLevel) public: explicit QOfonoHandsfree(QObject *parent = 0); ~QOfonoHandsfree(); QString modemPath() const; void setModemPath(const QString &path); QStringList features() const; bool inbandRinging() const; bool voiceRecognition() const; void setVoiceRecognition(bool on); bool echoCancelingNoiseReduction() const; void setEchoCancelingNoiseReduction(bool on); uchar batteryChargeLevel() const; bool isValid() const; Q_SIGNALS: void voiceRecognitionChanged(bool on); void echoCancelingNoiseReductionChanged(bool on); void modemPathChanged(const QString &path); private: QOfonoHandsfreePrivate *d_ptr; private slots: void propertyChanged(const QString &property,const QDBusVariant &value); }; #endif // QOFONOQOFONOHANDSFREE_H ./src/qofonocallvolume.cpp0000644000004100000410000000503212762041045016124 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonocallvolume.h" #include "ofono_callvolume_interface.h" #define SUPER QOfonoModemInterface QOfonoCallVolume::QOfonoCallVolume(QObject *parent) : SUPER(OfonoCallVolume::staticInterfaceName(), parent) { } QOfonoCallVolume::~QOfonoCallVolume() { } QDBusAbstractInterface *QOfonoCallVolume::createDbusInterface(const QString &path) { return new OfonoCallVolume("org.ofono", path, QDBusConnection::systemBus(),this); } void QOfonoCallVolume::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("Muted")) { Q_EMIT mutedChanged(value.value()); } else if (property == QLatin1String("SpeakerVolume")) { Q_EMIT speakerVolumeChanged(value.value()); } else if (property == QLatin1String("MicrophoneVolume")) { Q_EMIT microphoneVolumeChanged(value.value()); } } bool QOfonoCallVolume::muted() const { return getBool("Muted"); } void QOfonoCallVolume::setMuted(bool mute) { setProperty("Muted", mute); } quint8 QOfonoCallVolume::speakerVolume() const { return getProperty("SpeakerVolume").value(); } // Passing one byte by reference is such a great idea! void QOfonoCallVolume::setSpeakerVolume(const quint8 &volume) { setProperty("SpeakerVolume", QVariant::fromValue(volume)); } quint8 QOfonoCallVolume::microphoneVolume()const { return getProperty("microphoneVolume").value(); } void QOfonoCallVolume::setMicrophoneVolume(const quint8 &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 SUPER::isValid(); } ./src/qofonomodem.cpp0000644000004100000410000001420012762041064015060 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonomodem.h" #include "qofonomanager.h" #include "ofono_modem_interface.h" #include #include typedef QMap > ModemMap; Q_GLOBAL_STATIC(ModemMap, modemMap) #define SUPER QOfonoObject class QOfonoModem::Private : public SUPER::ExtData { public: bool modemPathValid; QSharedPointer mgr; Private() : modemPathValid(false), mgr(QOfonoManager::instance()) {} }; QOfonoModem::QOfonoModem(QObject *parent) : SUPER(new Private, parent) { QOfonoManager* mgr = privateData()->mgr.data(); connect(mgr, SIGNAL(availableChanged(bool)), SLOT(checkModemPathValidity())); connect(mgr, SIGNAL(modemsChanged(QStringList)), SLOT(checkModemPathValidity())); checkModemPathValidity(); } QOfonoModem::~QOfonoModem() { } QDBusAbstractInterface *QOfonoModem::createDbusInterface(const QString &path) { return new OfonoModem("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoModem::objectPathChanged(const QString &path, const QVariantMap *properties) { Q_EMIT modemPathChanged(path); if (!checkModemPathValidity()) { // checkModemPathValidity() didn't do anything because modemPathValid // flag hasn't changed. If the modem path has changed from one valid // path to another, D-Bus interface has to be re-initialized. if (privateData()->modemPathValid) { resetDbusInterface(properties); } } } void QOfonoModem::setModemPath(const QString &path) { setObjectPath(path); } QString QOfonoModem::modemPath() const { return objectPath(); } bool QOfonoModem::powered() const { return getBool("Powered"); } bool QOfonoModem::online() const { return getBool("Online"); } bool QOfonoModem::lockdown() const { return getBool("Lockdown"); } bool QOfonoModem::emergency() const { return getBool("Emergency"); } QString QOfonoModem::name() const { return getString("Name"); } QString QOfonoModem::manufacturer() const { return getString("Manufacturer"); } QString QOfonoModem::model() const { return getString("Model"); } QString QOfonoModem::revision() const { return getString("Revision"); } QString QOfonoModem::serial() const { return getString("Serial"); } QString QOfonoModem::type() const { return getString("Type"); } QStringList QOfonoModem::features() const { return getStringList("Features"); } QStringList QOfonoModem::interfaces() const { return getStringList("Interfaces"); } void QOfonoModem::setPowered(bool powered) { setProperty("Powered", powered); } void QOfonoModem::setOnline(bool online) { setProperty("Online", online); } void QOfonoModem::setLockdown(bool lockdown) { setProperty("Lockdown", lockdown); } void QOfonoModem::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("Online")) { Q_EMIT onlineChanged(value.value()); } else if (property == QLatin1String("Powered")) { Q_EMIT poweredChanged(value.value()); } else if (property == QLatin1String("Lockdown")) { Q_EMIT lockdownChanged(value.value()); } else if (property == QLatin1String("Emergency")) { Q_EMIT emergencyChanged(value.value()); } else if (property == QLatin1String("Name")) { Q_EMIT nameChanged(value.value()); } else if (property == QLatin1String("Manufacturer")) { Q_EMIT manufacturerChanged(value.value()); } else if (property == QLatin1String("Model")) { Q_EMIT modelChanged(value.value()); } else if (property == QLatin1String("Revision")) { Q_EMIT revisionChanged(value.value()); } else if (property == QLatin1String("Serial")) { Q_EMIT serialChanged(value.value()); } else if (property == QLatin1String("Type")) { Q_EMIT typeChanged(value.value()); } else if (property == QLatin1String("Features")) { Q_EMIT featuresChanged(value.value()); } else if (property == QLatin1String("Interfaces")) { Q_EMIT interfacesChanged(value.value()); } } QSharedPointer QOfonoModem::instance(const QString &modemPath) { QSharedPointer modem = modemMap()->value(modemPath); if (modem.isNull()) { modem = QSharedPointer::create(); modem->fixObjectPath(modemPath); modemMap()->insert(modemPath, QWeakPointer(modem)); } return modem; } bool QOfonoModem::isValid() const { return SUPER::isValid() && privateData()->modemPathValid; } QOfonoModem::Private* QOfonoModem::privateData() const { return (Private*)SUPER::extData(); } bool QOfonoModem::checkModemPathValidity() { ValidTracker valid(this); bool modemPathValid; Private* priv = privateData(); if (priv->mgr->isValid()) { QString path = modemPath(); modemPathValid = !path.isEmpty() && priv->mgr->modems().contains(path); } else { modemPathValid = false; } if (priv->modemPathValid != modemPathValid) { priv->modemPathValid = modemPathValid; if (modemPathValid) { resetDbusInterface(); } else { setDbusInterface(NULL); } return true; } else { // Return false to indicate that this function didn't do anything // because modemPathValid hasn't changed return false; } } ./src/qofonopositioningrequestagent.h0000644000004100000410000000323012762041045020416 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOQOFONOPOSITIONINGREQUESTAGENT_H #define QOFONOQOFONOPOSITIONINGREQUESTAGENT_H #include "qofono_global.h" class QOfonoPositioningRequestAgentPrivate; class QOfonoPositioningRequestAgent : public QObject { Q_OBJECT Q_DISABLE_COPY(QOfonoPositioningRequestAgent) Q_PROPERTY(QString agentPath READ agentPath WRITE setAgentPath NOTIFY agentPathChanged) public: explicit QOfonoPositioningRequestAgent(QObject *parent = 0); ~QOfonoPositioningRequestAgent(); QString agentPath() const; void setAgentPath(const QString &path); bool isValid() const; Q_SIGNALS: void agentPathChanged(const QString &path); void request(const QString &xmlElement); void positioningRequest(); void release(); private: QOfonoPositioningRequestAgentPrivate *d_ptr; private Q_SLOTS: void Request(const QString &xmlElement); void PositioningRequest(); void Release(); }; #endif // QOFONOQOFONOPOSITIONINGREQUESTAGENT_H ./src/qofonosmartmessagingagent.h0000644000004100000410000000374112762041045017476 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOSmartMessagingAgent_H #define QOFONOSmartMessagingAgent_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 QOfonoSmartMessagingAgentPrivate; class QOFONOSHARED_EXPORT QOfonoSmartMessagingAgent : public QObject { Q_OBJECT Q_DISABLE_COPY(QOfonoSmartMessagingAgent) Q_PROPERTY(QString agentPath READ agentPath WRITE setAgentPath NOTIFY agentPathChanged) public: explicit QOfonoSmartMessagingAgent(QObject *parent = 0); ~QOfonoSmartMessagingAgent(); QString agentPath() const; void setAgentPath(const QString &path); Q_SIGNALS: void agentPathChanged(const QString &path); void receiveAppointment(const QByteArray &appointment, const QVariantMap &info); void receiveBusinessCard(const QByteArray &card, const QVariantMap &info); void release(); private: QOfonoSmartMessagingAgentPrivate *d_ptr; QString smAgentPath; private Q_SLOTS: void ReceiveAppointment(const QByteArray &appointment, const QVariantMap &info); void ReceiveBusinessCard(const QByteArray &card, const QVariantMap &info); void Release(); }; #endif // QOFONOSmartMessagingAgent_H ./src/qofonocallsettings.h0000644000004100000410000000713612762041045016131 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOCallSettings_H #define QOFONOCallSettings_H #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 QOFONOSHARED_EXPORT QOfonoCallSettings : public QOfonoModemInterface { Q_OBJECT 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) Q_PROPERTY(QString calledLinePresentation READ calledLinePresentation NOTIFY calledLinePresentationChanged) Q_PROPERTY(QString callingNamePresentation READ callingNamePresentation NOTIFY callingNamePresentationChanged) Q_PROPERTY(QString connectedLinePresentation READ connectedLinePresentation NOTIFY connectedLinePresentationChanged) Q_PROPERTY(QString connectedLineRestriction READ connectedLineRestriction NOTIFY connectedLineRestrictionChanged) Q_PROPERTY(QString callingLineRestriction READ callingLineRestriction NOTIFY callingLineRestrictionChanged) public: explicit QOfonoCallSettings(QObject *parent = 0); ~QOfonoCallSettings(); QString modemPath() const; void setModemPath(const QString &path); QString callingLinePresentation(); QString calledLinePresentation(); QString callingNamePresentation(); QString connectedLinePresentation(); QString connectedLineRestriction(); QString callingLineRestriction(); QString hideCallerId(); void setHideCallerId(const QString &setting); QString voiceCallWaiting(); void setVoiceCallWaiting(const QString &setting); bool isValid() const; bool isReady() const; void connectOfono(); Q_SIGNALS: void callingLinePresentationChanged(const QString &setting); void calledLinePresentationChanged(const QString &setting); void callingNamePresentationChanged(const QString &setting); void connectedLinePresentationChanged(const QString &setting); void connectedLineRestrictionChanged(const QString &setting); void callingLineRestrictionChanged(const QString &setting); void hideCallerIdChanged(const QString &setting); void voiceCallWaitingChanged(const QString &setting); void getPropertiesFailed(); void hideCallerIdComplete(bool success); void voiceCallWaitingComplete(bool success); 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 ./src/qofonoobject.h0000644000004100000410000001022612762041064014676 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2014-2015 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) protected: friend class ValidTracker; class ValidTracker { private: QOfonoObject* object; public: ValidTracker(QOfonoObject* object); ~ValidTracker(); }; 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 &errorString); 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); void removeProperty(const QString &key); 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); void fixObjectPath(const QString &path); 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 ./src/qofonocallvolume.h0000644000004100000410000000420212762041045015567 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOCallVolume_H #define QOFONOCallVolume_H #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 QOFONOSHARED_EXPORT QOfonoCallVolume : public QOfonoModemInterface { Q_OBJECT 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) public: explicit QOfonoCallVolume(QObject *parent = 0); ~QOfonoCallVolume(); QString modemPath() const; void setModemPath(const QString &path); bool muted() const; void setMuted(const bool mute); quint8 speakerVolume() const; void setSpeakerVolume(const quint8 &spvolume); quint8 microphoneVolume()const ; void setMicrophoneVolume(const quint8 &mpvolume); bool isValid() const; Q_SIGNALS: void mutedChanged(bool muted); void speakerVolumeChanged(const quint8 &volume); void microphoneVolumeChanged(const quint8 &mvolume); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); void propertyChanged(const QString &property, const QVariant &value); }; #endif // QOFONOCallVolume_H ./src/qofonohandsfreeaudiocard.cpp0000644000004100000410000001074212762041045017600 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonohandsfreeaudiocard.h" #include "ofono_handsfree_audio_card_interface.h" class QOfonoHandsfreeAudioCardPrivate { public: QOfonoHandsfreeAudioCardPrivate(); QString modemPath; OfonoHandsfreeAudioCard *ofonoHandsfreeAudioCard; QVariantMap properties; }; QOfonoHandsfreeAudioCardPrivate::QOfonoHandsfreeAudioCardPrivate() : modemPath(QString()) , ofonoHandsfreeAudioCard(0) { } QOfonoHandsfreeAudioCard::QOfonoHandsfreeAudioCard(QObject *parent) : QObject(parent) , d_ptr(new QOfonoHandsfreeAudioCardPrivate) { } QOfonoHandsfreeAudioCard::~QOfonoHandsfreeAudioCard() { delete d_ptr; } void QOfonoHandsfreeAudioCard::setModemPath(const QString &path) { if (path == d_ptr->modemPath || path.isEmpty()) return; if (path != modemPath()) { if (d_ptr->ofonoHandsfreeAudioCard) { delete d_ptr->ofonoHandsfreeAudioCard; d_ptr->ofonoHandsfreeAudioCard = 0; d_ptr->properties.clear(); } d_ptr->modemPath = path; d_ptr->ofonoHandsfreeAudioCard = new OfonoHandsfreeAudioCard("org.ofono", path, QDBusConnection::systemBus(),this); if (d_ptr->ofonoHandsfreeAudioCard) { QDBusPendingReply reply; reply = d_ptr->ofonoHandsfreeAudioCard->GetProperties(); reply.waitForFinished(); d_ptr->properties = reply.value(); Q_EMIT modemPathChanged(path); } } } QString QOfonoHandsfreeAudioCard::modemPath() const { return d_ptr->modemPath; } void QOfonoHandsfreeAudioCard::propertyChanged(const QString& property, const QDBusVariant& dbusvalue) { QVariant value = dbusvalue.variant(); d_ptr->properties.insert(property,value); } QString QOfonoHandsfreeAudioCard::remoteAddress() const { if (d_ptr->ofonoHandsfreeAudioCard) { return d_ptr->properties["RemoteAddress"].value(); } return QString(); } QString QOfonoHandsfreeAudioCard::localAddress() const { if (d_ptr->ofonoHandsfreeAudioCard) { return d_ptr->properties["LocalAddress"].value(); } return QString(); } void QOfonoHandsfreeAudioCard::connectAudio() { if (d_ptr->ofonoHandsfreeAudioCard) { QDBusPendingReply<> result = d_ptr->ofonoHandsfreeAudioCard->Connect(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(result, this); connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(connectAudioFinished(QDBusPendingCallWatcher*))); } } bool QOfonoHandsfreeAudioCard::isValid() const { return d_ptr->ofonoHandsfreeAudioCard->isValid(); } void QOfonoHandsfreeAudioCard::connectAudioFinished(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; QOfonoHandsfreeAudioCard::Error error = NoError; QString errorString; if (reply.isError()) { qWarning() << "QOfonoHandsfreeAudioCard::connectAudio() failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } emit connectAudioComplete(error, errorString); } QOfonoHandsfreeAudioCard::Error QOfonoHandsfreeAudioCard::errorNameToEnum(const QString &errorName) { if (errorName == "") return NoError; else if (errorName == "org.ofono.Error.NotImplemented") return NotImplementedError; else if (errorName == "org.ofono.Error.InProgress") return InProgressError; else if (errorName == "org.ofono.Error.InvalidArguments") return InvalidArgumentsError; else if (errorName == "org.ofono.Error.InvalidFormat") return InvalidFormatError; else if (errorName == "org.ofono.Error.Failed") return FailedError; else return UnknownError; } ./src/qofonocellbroadcast.cpp0000644000004100000410000000522312762041045016565 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonocellbroadcast.h" #include "ofono_cell_broadcast_interface.h" #define SUPER QOfonoObject QOfonoCellBroadcast::QOfonoCellBroadcast(QObject *parent) : SUPER(parent) { } QOfonoCellBroadcast::~QOfonoCellBroadcast() { } 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; } void QOfonoCellBroadcast::objectPathChanged(const QString &path, const QVariantMap *properties) { SUPER::objectPathChanged(path, properties); Q_EMIT modemPathChanged(path); } void QOfonoCellBroadcast::setModemPath(const QString &path) { setObjectPath(path); } QString QOfonoCellBroadcast::modemPath() const { 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 { return getBool("Powered"); } void QOfonoCellBroadcast::setEnabled(bool b) { setProperty("Powered", b); } QString QOfonoCellBroadcast::topics() const { return getString("Topics"); } void QOfonoCellBroadcast::setTopics(const QString &topics) const { // 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 SUPER::isValid(); } ./src/qofonosimwatcher.cpp0000644000004100000410000001327612762041064016141 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2015 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 "qofonosimwatcher.h" #include "qofonomanager.h" class QOfonoSimWatcher::Private : public QObject { Q_OBJECT public: Private(QOfonoSimWatcher *parent); QOfonoSimWatcher *watcher; QSharedPointer ofono; QHash allSims; QList presentSims; bool requireSubscriberIdentity; bool valid; public Q_SLOTS: void onOfonoAvailableChanged(); void updateValid(); void updateModems(); void updateSims(); }; QOfonoSimWatcher::Private::Private(QOfonoSimWatcher *parent) : watcher(parent), ofono(QOfonoManager::instance()), requireSubscriberIdentity(false), valid(false) { connect(ofono.data(), SIGNAL(availableChanged(bool)), SLOT(onOfonoAvailableChanged())); connect(ofono.data(), SIGNAL(modemsChanged(QStringList)), SLOT(updateModems())); if (ofono->available()) { onOfonoAvailableChanged(); } } void QOfonoSimWatcher::Private::onOfonoAvailableChanged() { if (ofono->available()) { updateModems(); updateValid(); } else { updateValid(); allSims.clear(); if (!presentSims.isEmpty()) { presentSims.clear(); if (watcher) { Q_EMIT watcher->presentSimListChanged(); } if (watcher) { Q_EMIT watcher->presentSimCountChanged(); } } } } void QOfonoSimWatcher::Private::updateModems() { QStringList oldModems = allSims.keys(); QStringList newModems = ofono->modems(); oldModems.sort(); newModems.sort(); if (oldModems != newModems) { const int oldCount = oldModems.count(); const int newCount = newModems.count(); int i; for (i=0; idisconnect(this); } } for (i=0; ifixModemPath(path); connect(sim, SIGNAL(validChanged(bool)), SLOT(updateSims())); connect(sim, SIGNAL(presenceChanged(bool)), SLOT(updateSims())); connect(sim, SIGNAL(subscriberIdentityChanged(QString)), SLOT(updateSims())); allSims.insert(path, QOfonoSimManager::SharedPointer(sim)); } } updateSims(); } } void QOfonoSimWatcher::Private::updateSims() { QList sims; QStringList modems = allSims.keys(); modems.sort(); int i, n = modems.count(); for (i=0; iisValid() && sim->present() && (!requireSubscriberIdentity || !sim->subscriberIdentity().isEmpty())) { sims.append(sim); } } if (sims.count() != presentSims.count()) { presentSims = sims; if (watcher) { Q_EMIT watcher->presentSimListChanged(); } if (watcher) { Q_EMIT watcher->presentSimCountChanged(); } } else { n = sims.count(); for (i=0; ipresentSimListChanged(); } break; } } } updateValid(); } void QOfonoSimWatcher::Private::updateValid() { // This object is valid if QOfonoManager and all SIM managers are valid. bool isValid = ofono->available(); if (isValid) { QList sims = allSims.values(); const int n = sims.count(); for (int i=0; iisValid(); } } if (valid != isValid) { valid = isValid; if (watcher) { Q_EMIT watcher->validChanged(); } } } QOfonoSimWatcher::QOfonoSimWatcher(QObject *parent) : QObject(parent), d_ptr(new Private(this)) { } QOfonoSimWatcher::~QOfonoSimWatcher() { d_ptr->watcher = NULL; d_ptr->deleteLater(); } bool QOfonoSimWatcher::isValid() const { return d_ptr->valid; } int QOfonoSimWatcher::presentSimCount() const { return d_ptr->presentSims.count(); } QList QOfonoSimWatcher::presentSimList() const { return d_ptr->presentSims; } bool QOfonoSimWatcher::requireSubscriberIdentity() const { return d_ptr->requireSubscriberIdentity; } void QOfonoSimWatcher::setRequireSubscriberIdentity(bool require) { if (d_ptr->requireSubscriberIdentity != require) { d_ptr->requireSubscriberIdentity = require; d_ptr->updateSims(); } } #include "qofonosimwatcher.moc" ./src/qofonovoicecall.h0000644000004100000410000000772712762041045015404 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOVoiceCall_H #define QOFONOVoiceCall_H #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 QOFONOSHARED_EXPORT QOfonoVoiceCall : public QOfonoObject { Q_OBJECT Q_ENUMS(Error) Q_PROPERTY(QString voiceCallPath READ voiceCallPath WRITE setVoiceCallPath NOTIFY voiceCallPathChanged) Q_PROPERTY(QString lineIdentification READ lineIdentification NOTIFY lineIdentificationChanged) Q_PROPERTY(QString incomingLine READ incomingLine NOTIFY incomingLineChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString state READ state NOTIFY stateChanged) Q_PROPERTY(QString startTime READ startTime NOTIFY startTimeChanged) Q_PROPERTY(QString information READ information NOTIFY informationChanged) Q_PROPERTY(bool multiparty READ multiparty NOTIFY multipartyChanged) Q_PROPERTY(bool emergency READ emergency NOTIFY emergencyChanged) Q_PROPERTY(bool remoteHeld READ remoteHeld NOTIFY remoteHeldChanged) Q_PROPERTY(quint8 icon READ icon NOTIFY iconChanged) public: enum Error { NoError, NotImplementedError, InProgressError, InvalidArgumentsError, InvalidFormatError, FailedError, UnknownError }; explicit QOfonoVoiceCall(QObject *parent = 0); ~QOfonoVoiceCall(); QString voiceCallPath() const; void setVoiceCallPath(const QString &path); QString lineIdentification() const; QString incomingLine() const; QString name() const; QString state() const; QString startTime() const; QString information() const; bool multiparty() const; bool emergency() const; quint8 icon() const; bool remoteHeld() const; bool remoteMultiparty() const; bool isValid() const; Q_SIGNALS: void lineIdentificationChanged(const QString &name); void nameChanged(const QString &name); void stateChanged(const QString &state); void startTimeChanged(const QString &time); void informationChanged(const QString &mcc); void incomingLineChanged(const QString &line); void disconnectReason(const QString &reason); void multipartyChanged(bool multiparty); void iconChanged(const quint8 &icon); void emergencyChanged(bool emergency); void remoteHeldChanged(bool remoteHeld); void remoteMultipartyChanged(bool remoteMultiparty); void voiceCallPathChanged(const QString &path); void answerComplete(QOfonoVoiceCall::Error error, const QString &errorString); void hangupComplete(QOfonoVoiceCall::Error error, const QString &errorString); void deflectComplete(QOfonoVoiceCall::Error error, const QString &errorString); public slots: void answer(); void hangup(); void deflect(const QString &number); private: static Error errorNameToEnum(const QString &errorName); private slots: 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 ./src/qofonosimmanager.h0000644000004100000410000001533112762041064015555 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2016 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOSimManager_H #define QOFONOSimManager_H #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 QOFONOSHARED_EXPORT QOfonoSimManager : public QOfonoModemInterface { Q_OBJECT Q_ENUMS(Error) Q_ENUMS(PinType) 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(QString serviceProviderName READ serviceProviderName NOTIFY serviceProviderNameChanged) 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) Q_PROPERTY(QStringList preferredLanguages READ preferredLanguages NOTIFY preferredLanguagesChanged) Q_PROPERTY(QVariantMap pinRetries READ pinRetries NOTIFY pinRetriesChanged) Q_PROPERTY(bool fixedDialing READ fixedDialing NOTIFY fixedDialingChanged) Q_PROPERTY(bool barredDialing READ barredDialing NOTIFY barredDialingChanged) public: class SharedPointer; enum Error { NoError, NotImplementedError, InProgressError, InvalidArgumentsError, InvalidFormatError, FailedError, UnknownError }; enum PinType { NoPin, SimPin, SimPin2, PhoneToSimPin, PhoneToFirstSimPin, NetworkPersonalizationPin, NetworkSubsetPersonalizationPin, ServiceProviderPersonalizationPin, CorporatePersonalizationPin, SimPuk, SimPuk2, PhoneToFirstSimPuk, NetworkPersonalizationPuk, NetworkSubsetPersonalizationPuk, CorporatePersonalizationPuk }; explicit QOfonoSimManager(QObject *parent = 0); ~QOfonoSimManager(); QString modemPath() const; void setModemPath(const QString &path); bool present() const; QString subscriberIdentity() const; QString mobileCountryCode() const; QString mobileNetworkCode() const; QString serviceProviderName() const; QStringList subscriberNumbers() const; QVariantMap serviceNumbers() const; // PinType pinRequired() const; QVariantList lockedPins() const; QString cardIdentifier() const; QStringList preferredLanguages() const; QVariantMap pinRetries() const; // bool fixedDialing() const; bool barredDialing() const; bool isValid() const; Q_SIGNALS: void presenceChanged(bool ispresent); void subscriberIdentityChanged(const QString &imsi); void mobileCountryCodeChanged(const QString &mcc); void mobileNetworkCodeChanged(const QString &mnc); void serviceProviderNameChanged(const QString &spn); 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); private: 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 changePinCallFinished(QDBusPendingCallWatcher *call); void enterPinCallFinished(QDBusPendingCallWatcher *call); void resetPinCallFinished(QDBusPendingCallWatcher *call); void lockPinCallFinished(QDBusPendingCallWatcher *call); void unlockPinCallFinished(QDBusPendingCallWatcher *call); }; // Unlike the default QSharedPointer, deletes QOfonoSimManager with deleteLater class QOFONOSHARED_EXPORT QOfonoSimManager::SharedPointer : public QSharedPointer { public: SharedPointer(QOfonoSimManager * ptr = NULL) : QSharedPointer(ptr, &QObject::deleteLater) {} }; #endif // QOFONOSimManager_H ./src/qofonomanager.h0000644000004100000410000000415212762041064015043 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOMANAGER_H #define QOFONOMANAGER_H #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 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; static QSharedPointer instance(); 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 onModemAdded(const QDBusObjectPath &path, const QVariantMap &var); void onModemRemoved(const QDBusObjectPath &path); void onGetModemsFinished(QDBusPendingCallWatcher*); void connectToOfono(const QString &); void ofonoUnregistered(const QString &); private: class Private; Private *d_ptr; }; #endif // QOFONOMANAGER_H ./src/qofonocallbarring.cpp0000644000004100000410000001363712762041045016253 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonocallbarring.h" #include "ofono_call_barring_interface.h" #define SUPER QOfonoModemInterface QOfonoCallBarring::QOfonoCallBarring(QObject *parent) : SUPER(OfonoCallBarring::staticInterfaceName(), parent) { } QOfonoCallBarring::~QOfonoCallBarring() { } QDBusAbstractInterface *QOfonoCallBarring::createDbusInterface(const QString &path) { return new OfonoCallBarring("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoCallBarring::connectOfono() { resetDbusInterface(); } void QOfonoCallBarring::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("VoiceIncoming")) { Q_EMIT voiceIncomingChanged(value.toString()); } else if (property == QLatin1String("VoiceOutgoing")) { Q_EMIT voiceOutgoingChanged(value.toString()); } } QString QOfonoCallBarring::voiceIncoming() { return getString("VoiceIncoming"); } void QOfonoCallBarring::setVoiceIncoming(const QString &barrings, const QString &password) { 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() { return getString("VoiceOutgoing"); } void QOfonoCallBarring::setVoiceOutgoing(const QString &barrings, const QString &password) { 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) { 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) { 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) { 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) { OfonoCallBarring *iface = (OfonoCallBarring*)dbusInterface(); if (iface) { connect(new QDBusPendingCallWatcher( iface->DisableAllOutgoing(password), iface), SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(disableAllOutgoingCallComplete(QDBusPendingCallWatcher*))); } } void QOfonoCallBarring::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) { SUPER::getPropertiesFinished(properties, error); if (error) { Q_EMIT getPropertiesFailed(); } } void QOfonoCallBarring::setVoiceIncomingComplete(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; Q_EMIT voiceIncomingComplete(!reply.isError()); } void QOfonoCallBarring::setVoiceOutgoingComplete(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; Q_EMIT voiceOutgoingComplete(!reply.isError()); } void QOfonoCallBarring::changePasswordCallComplete(QDBusPendingCallWatcher *call) { call->deleteLater(); 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(); } ./src/qofonohandsfreeaudiomanager.cpp0000644000004100000410000000721412762041045020301 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonohandsfreeaudiomanager.h" #include "ofono_handsfree_audio_manager_interface.h" class QOfonoHandsfreeAudioManagerPrivate { public: QOfonoHandsfreeAudioManagerPrivate(); QString modemPath; OfonoHandsfreeAudioManager *ofonoHandsfreeAudioManager; QStringList audioCards; }; QOfonoHandsfreeAudioManagerPrivate::QOfonoHandsfreeAudioManagerPrivate() : modemPath(QString()) , ofonoHandsfreeAudioManager(0), audioCards(QStringList()) { } QOfonoHandsfreeAudioManager::QOfonoHandsfreeAudioManager(QObject *parent) : QObject(parent) , d_ptr(new QOfonoHandsfreeAudioManagerPrivate) { } QOfonoHandsfreeAudioManager::~QOfonoHandsfreeAudioManager() { delete d_ptr; } void QOfonoHandsfreeAudioManager::setModemPath(const QString &path) { if (path == d_ptr->modemPath || path.isEmpty()) return; // if (path != modemPath()) { // if (d_ptr->ofonoHandsfreeAudioManager) { // delete d_ptr->ofonoHandsfreeAudioManager; // d_ptr->ofonoHandsfreeAudioManager = 0; // d_ptr->audioCards.clear(); // } // d_ptr->ofonoHandsfreeAudioManager = new OfonoHandsfreeAudioManager("org.ofono", path, QDBusConnection::systemBus(),this); // d_ptr->modemPath = path; // QDBusPendingReply reply2 = d_ptr->ofonoHandsfreeAudioManager->GetCards(); // reply2.waitForFinished(); // foreach(ObjectPathProperties card, reply2.value()) { // d_ptr->audioCards << card.path.path(); // Q_EMIT cardAdded(card.path.path()); // } // Q_EMIT modemPathChanged(path); // } if (!d_ptr->ofonoHandsfreeAudioManager) { if (path != modemPath()) { d_ptr->ofonoHandsfreeAudioManager = new OfonoHandsfreeAudioManager("org.ofono", path, QDBusConnection::systemBus(),this); if (d_ptr->ofonoHandsfreeAudioManager) { d_ptr->modemPath = path; QDBusReply reply2 = d_ptr->ofonoHandsfreeAudioManager->GetCards(); foreach(ObjectPathProperties card, reply2.value()) { d_ptr->audioCards << card.path.path(); Q_EMIT cardAdded(card.path.path()); } Q_EMIT modemPathChanged(path); } } } } QString QOfonoHandsfreeAudioManager::modemPath() const { return d_ptr->modemPath; } QStringList QOfonoHandsfreeAudioManager::cards() const { if (d_ptr->ofonoHandsfreeAudioManager) { return d_ptr->audioCards; } return QStringList(); } void QOfonoHandsfreeAudioManager::registerAgent(const QString &path, CodecTypeFlags codecs) { QByteArray ba; if (codecs & CVSD) ba += CVSD; if (codecs & mSBC) ba += mSBC; d_ptr->ofonoHandsfreeAudioManager->Register(QDBusObjectPath(path),ba); } bool QOfonoHandsfreeAudioManager::isValid() const { return d_ptr->ofonoHandsfreeAudioManager->isValid(); } ./src/qofonohandsfreeaudiomanager.h0000644000004100000410000000343612762041045017750 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOQOFONOHANDSFREEAUDIOMANAGER_H #define QOFONOQOFONOHANDSFREEAUDIOMANAGER_H #include #include #include class QOfonoHandsfreeAudioManagerPrivate; class QOfonoHandsfreeAudioManager : public QObject { Q_OBJECT Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_ENUMS(CodecType) Q_FLAGS(CodecType CodecTypeFlags) public: enum CodecType { CVSD = 0x01, mSBC = 0x02 }; Q_DECLARE_FLAGS(CodecTypeFlags, CodecType) explicit QOfonoHandsfreeAudioManager(QObject *parent = 0); ~QOfonoHandsfreeAudioManager(); QString modemPath() const; void setModemPath(const QString &path); bool isValid() const; Q_SIGNALS: void cardAdded(const QString &card); void cardRemoved(const QString &card); void modemPathChanged(const QString &path); public slots: QStringList cards() const; void registerAgent(const QString &path, CodecTypeFlags codecs); private: QOfonoHandsfreeAudioManagerPrivate *d_ptr; }; #endif // QOFONOQOFONOHANDSFREEAUDIOMANAGER_H ./src/qofonohandsfreeaudioagent.h0000644000004100000410000000435412762041045017434 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOQOFONOHANDSFREEAUDIOAGENT_H #define QOFONOQOFONOHANDSFREEAUDIOAGENT_H #include #include #include #include class QOfonoHandsfreeAudioAgentPrivate; class QOfonoHandsfreeAudioAgent : public QObject { Q_OBJECT Q_DISABLE_COPY(QOfonoHandsfreeAudioAgent) Q_PROPERTY(QString agentPath READ agentPath WRITE setAgentPath) public: explicit QOfonoHandsfreeAudioAgent(QObject *parent = 0); ~QOfonoHandsfreeAudioAgent(); QString agentPath() const; void setAgentPath(const QString &path); bool isValid() const; Q_SIGNALS: void newConnection(const QString &card, QDBusUnixFileDescriptor sco, const QByteArray &codec); void release(); public slots: private: QOfonoHandsfreeAudioAgentPrivate *d_ptr; friend class QOfonoHandsfreeAudioAgentAdaptor; private Q_SLOTS: void NewConnection(const QString &card, QDBusUnixFileDescriptor sco, const QByteArray &codec); void Release(); }; class QOfonoHandsfreeAudioAgentAdaptor : public QDBusAbstractAdaptor { Q_OBJECT Q_CLASSINFO ("D-Bus Interface", "org.ofono.HandsfreeAudioAgent") public: explicit QOfonoHandsfreeAudioAgentAdaptor(QOfonoHandsfreeAudioAgent *parent = 0); virtual ~QOfonoHandsfreeAudioAgentAdaptor(); public Q_SLOTS: Q_NOREPLY void NewConnection(const QString &card, QDBusUnixFileDescriptor sco, const QByteArray &codec); Q_NOREPLY void Release(); private: QOfonoHandsfreeAudioAgent* audioAgent; }; #endif // QOFONOQOFONOHANDSFREEAUDIOAGENT_H ./src/qofonoradiosettings.cpp0000644000004100000410000000610512762041045016642 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonoradiosettings.h" #include "ofono_radio_settings_interface.h" #define SUPER QOfonoModemInterface QOfonoRadioSettings::QOfonoRadioSettings(QObject *parent) : SUPER(OfonoRadioSettings::staticInterfaceName(), parent) { } QOfonoRadioSettings::~QOfonoRadioSettings() { } QDBusAbstractInterface *QOfonoRadioSettings::createDbusInterface(const QString &path) { return new OfonoRadioSettings("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoRadioSettings::setModemPath(const QString &path) { SUPER::setModemPath(path); } QString QOfonoRadioSettings::modemPath() const { return SUPER::modemPath(); } void QOfonoRadioSettings::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("TechnologyPreference")) { Q_EMIT technologyPreferenceChanged(value.value()); } else if (property == QLatin1String("AvailableTechnologies")) { Q_EMIT availableTechnologiesChanged(value.value()); } else if (property == QLatin1String("GsmBand")) { Q_EMIT gsmBandChanged(value.value()); } else if (property == QLatin1String("UtmsBand")) { Q_EMIT umtsBandChanged(value.value()); } else if (property == QLatin1String("FastDormancy")) { Q_EMIT fastDormancyChanged(value.value()); } } QString QOfonoRadioSettings::technologyPreference() const { return getString("TechnologyPreference"); } void QOfonoRadioSettings::setTechnologyPreference(const QString &preference) { setProperty("TechnologyPreference", preference); } QStringList QOfonoRadioSettings::availableTechnologies() const { return getStringList("AvailableTechnologies"); } QString QOfonoRadioSettings::gsmBand() const { return getString("GsmBand"); } void QOfonoRadioSettings::setGsmBand(const QString &gsmBand) { setProperty("GsmBand", gsmBand); } QString QOfonoRadioSettings::umtsBand() const { return getString("UmtsBand"); } void QOfonoRadioSettings::setUmtsBand(const QString &umtsBand) { setProperty("UmtsBand", umtsBand); } bool QOfonoRadioSettings::fastDormancy() const { return getBool("FastDormancy"); } void QOfonoRadioSettings::setFastDormancy(bool fastDormancy) { setProperty("FastDormancy", fastDormancy); } bool QOfonoRadioSettings::isValid() const { return SUPER::isValid(); } ./src/qofonomessagemanager.cpp0000644000004100000410000001552312762041064016747 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonomessagemanager.h" #include "ofono_message_manager_interface.h" #define SUPER QOfonoModemInterface class QOfonoMessageManager::Private : public QOfonoObject::ExtData { public: bool initialized; QStringList messageList; Private() : initialized(false) {} }; QOfonoMessageManager::QOfonoMessageManager(QObject *parent) : SUPER(OfonoMessageManager::staticInterfaceName(), new Private, parent) { QOfonoDbusTypes::registerObjectPathProperties(); } QOfonoMessageManager::~QOfonoMessageManager() { } bool QOfonoMessageManager::isValid() const { return privateData()->initialized && SUPER::isValid(); } QDBusAbstractInterface *QOfonoMessageManager::createDbusInterface(const QString &path) { 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; iSendMessage(numberTo, message), iface), SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onSendMessageFinished(QDBusPendingCallWatcher*))); } } QStringList QOfonoMessageManager::messages() { return privateData()->messageList; } void QOfonoMessageManager::onMessageAdded(const QDBusObjectPath &path, const QVariantMap &) { addMessage(path.path()); } void QOfonoMessageManager::onMessageRemoved(const QDBusObjectPath &path) { QString messagePath = path.path(); if (privateData()->messageList.removeOne(messagePath)) { Q_EMIT messageRemoved(messagePath); } } void QOfonoMessageManager::onGetMessagesFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply reply(*watch); if (reply.isError()) { qDebug() << reply.error(); Q_EMIT reportError(reply.error().message()); } else { ValidTracker valid(this); 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::onSendMessageFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply reply = *watch; if (reply.isError()) { qWarning() << reply.error(); Q_EMIT sendMessageComplete(false, QString()); } else { Q_EMIT sendMessageComplete(true, reply.value().path()); } } 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); } } QString QOfonoMessageManager::modemPath() const { return SUPER::modemPath(); } void QOfonoMessageManager::setModemPath(const QString &path) { SUPER::setModemPath(path); } QOfonoMessageManager::Private *QOfonoMessageManager::privateData() const { return (QOfonoMessageManager::Private*)SUPER::extData(); } ./src/qofonocallsettings.cpp0000644000004100000410000001052412762041045016457 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonocallsettings.h" #include "ofono_call_settings_interface.h" #define SUPER QOfonoModemInterface QOfonoCallSettings::QOfonoCallSettings(QObject *parent) : SUPER(OfonoCallSettings::staticInterfaceName(), parent) { } QOfonoCallSettings::~QOfonoCallSettings() { } void QOfonoCallSettings::connectOfono() { resetDbusInterface(); } QDBusAbstractInterface *QOfonoCallSettings::createDbusInterface(const QString &path) { return new OfonoCallSettings("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoCallSettings::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("CallingLinePresentation")) { Q_EMIT callingLinePresentationChanged(value.value()); } else if (property == QLatin1String("CalledLinePresentation")) { Q_EMIT calledLinePresentationChanged(value.value()); } else if (property == QLatin1String("CallingNamePresentation")) { Q_EMIT callingNamePresentationChanged(value.value()); } else if (property == QLatin1String("ConnectedLinePresentation")) { Q_EMIT connectedLinePresentationChanged(value.value()); } else if (property == QLatin1String("ConnectedLineRestriction")) { Q_EMIT connectedLineRestrictionChanged(value.value()); } else if (property == QLatin1String("CallingLineRestriction")) { Q_EMIT callingLineRestrictionChanged(value.value()); } else if (property == QLatin1String("HideCallerId")) { Q_EMIT hideCallerIdChanged(value.value()); } else if (property == QLatin1String("VoiceCallWaiting")) { Q_EMIT voiceCallWaitingChanged(value.value()); } } QString QOfonoCallSettings::callingLinePresentation() { return getString("CallingLinePresentation"); } QString QOfonoCallSettings::calledLinePresentation() { return getString("CalledLinePresentation"); } QString QOfonoCallSettings::callingNamePresentation() { return getString("CallingNamePresentation"); } QString QOfonoCallSettings::connectedLinePresentation() { return getString("ConnectedLinePresentation"); } QString QOfonoCallSettings::connectedLineRestriction() { return getString("ConnectedLineRestriction"); } QString QOfonoCallSettings::callingLineRestriction() { return getString("CallingLineRestriction"); } QString QOfonoCallSettings::hideCallerId() { return getString("HideCallerId"); } void QOfonoCallSettings::setHideCallerId(const QString &setting) { setProperty("HideCallerId", setting); } QString QOfonoCallSettings::voiceCallWaiting() { return getString("VoiceCallWaiting"); } void QOfonoCallSettings::setVoiceCallWaiting(const QString &setting) { setProperty("VoiceCallWaiting", setting); } void QOfonoCallSettings::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) { SUPER::getPropertiesFinished(properties, error); if (error) { Q_EMIT getPropertiesFailed(); } } void QOfonoCallSettings::setPropertyFinished(const QString &property, const QDBusError *error) { SUPER::setPropertyFinished(property, error); if (property == "HideCallerId") { Q_EMIT hideCallerIdComplete(!error); } else if (property == "VoiceCallWaiting") { Q_EMIT voiceCallWaitingComplete(!error); } } QString QOfonoCallSettings::modemPath() const { return SUPER::modemPath(); } void QOfonoCallSettings::setModemPath(const QString &path) { SUPER::setModemPath(path); } bool QOfonoCallSettings::isValid() const { return SUPER::isValid(); } bool QOfonoCallSettings::isReady() const { return SUPER::isReady(); } ./src/qofonolocationreporting.cpp0000644000004100000410000000634112762041045017527 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonolocationreporting.h" #include "ofono_location_reporting_interface.h" #include class QOfonoLocationReportingPrivate { public: QOfonoLocationReportingPrivate(); QString modemPath; OfonoLocationReporting *ofonoLocationReporting; QVariantMap properties; }; QOfonoLocationReportingPrivate::QOfonoLocationReportingPrivate() : modemPath(QString()) , ofonoLocationReporting(0) { } QOfonoLocationReporting::QOfonoLocationReporting(QObject *parent) : QObject(parent) , d_ptr(new QOfonoLocationReportingPrivate) { } QOfonoLocationReporting::~QOfonoLocationReporting() { delete d_ptr; } void QOfonoLocationReporting::setModemPath(const QString &path) { if (path == d_ptr->modemPath || path.isEmpty()) return; if (path != modemPath()) { if (d_ptr->ofonoLocationReporting) { delete d_ptr->ofonoLocationReporting; d_ptr->ofonoLocationReporting = 0; d_ptr->properties.clear(); } d_ptr->ofonoLocationReporting = new OfonoLocationReporting("org.ofono", path, QDBusConnection::systemBus(),this); if (d_ptr->ofonoLocationReporting) { d_ptr->modemPath = path; QDBusPendingReply reply; reply = d_ptr->ofonoLocationReporting->GetProperties(); reply.waitForFinished(); d_ptr->properties = reply.value(); Q_EMIT modemPathChanged(path); } } } QString QOfonoLocationReporting::modemPath() const { return d_ptr->modemPath; } QString QOfonoLocationReporting::type() const { if (d_ptr->ofonoLocationReporting) { return d_ptr->properties["Type"].value(); } return QString(); } bool QOfonoLocationReporting::enabled() const { if (d_ptr->ofonoLocationReporting) { return d_ptr->properties["Enabled"].value(); } return false; } void QOfonoLocationReporting::release() { if (d_ptr->ofonoLocationReporting) d_ptr->ofonoLocationReporting->Release(); } int QOfonoLocationReporting::request() { if (d_ptr->ofonoLocationReporting) { QDBusPendingReply reply = d_ptr->ofonoLocationReporting->Request(); if (!reply.isError() && reply.value().isValid()) { return dup(reply.value().fileDescriptor()); //pass on fd } else { qDebug() << Q_FUNC_INFO << reply.error().message(); } } return 0; } bool QOfonoLocationReporting::isValid() const { return d_ptr->ofonoLocationReporting->isValid(); } ./src/qofonomessagewaiting.cpp0000644000004100000410000000577212762041045017003 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonomessagewaiting.h" #include "ofono_messagewaiting_interface.h" #define SUPER QOfonoModemInterface QOfonoMessageWaiting::QOfonoMessageWaiting(QObject *parent) : SUPER(OfonoMessageWaiting::staticInterfaceName(), parent) { } QOfonoMessageWaiting::~QOfonoMessageWaiting() { } QDBusAbstractInterface *QOfonoMessageWaiting::createDbusInterface(const QString &path) { return new OfonoMessageWaiting("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoMessageWaiting::connectOfono() { resetDbusInterface(); } void QOfonoMessageWaiting::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("VoicemailWaiting")) { Q_EMIT voicemailWaitingChanged(value.toBool()); } else if (property == QLatin1String("VoicemailMessageCount")) { Q_EMIT voicemailMessageCountChanged(value.toInt()); } else if (property == QLatin1String("VoicemailMailboxNumber")) { Q_EMIT voicemailMailboxNumberChanged(value.toString()); } } bool QOfonoMessageWaiting::voicemailWaiting() const { return getBool("VoicemailWaiting"); } int QOfonoMessageWaiting::voicemailMessageCount() const { return getInt("VoicemailMessageCount"); } QString QOfonoMessageWaiting::voicemailMailboxNumber() const { return getString("VoicemailMailboxNumber"); } void QOfonoMessageWaiting::setVoicemailMailboxNumber(const QString &mailboxnumber) { setProperty("VoicemailMailboxNumber", mailboxnumber); } void QOfonoMessageWaiting::getPropertiesFinished(const QVariantMap &properties, const QDBusError *error) { SUPER::getPropertiesFinished(properties, error); if (error) { Q_EMIT getPropertiesFailed(); } } void QOfonoMessageWaiting::setPropertyFinished(const QString &property, const QDBusError *error) { SUPER::setPropertyFinished(property, error); if (property == "VoicemailMailboxNumber") { Q_EMIT voicemailMailboxComplete(!error); } } QString QOfonoMessageWaiting::modemPath() const { return SUPER::modemPath(); } void QOfonoMessageWaiting::setModemPath(const QString &path) { SUPER::setModemPath(path); } bool QOfonoMessageWaiting::isValid() const { return SUPER::isValid(); } bool QOfonoMessageWaiting::isReady() const { return SUPER::isReady(); } ./src/qofonomanager.cpp0000644000004100000410000001366212762041064015404 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2016 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonomanager.h" #include "qofonoutils_p.h" #include "ofono_manager_interface.h" class QOfonoManager::Private { public: OfonoManager *ofonoManager; QStringList modems; bool available; Private() : ofonoManager(NULL), available(false) {} void getModems(QOfonoManager *manager); }; void QOfonoManager::Private::getModems(QOfonoManager *manager) { if (ofonoManager) { connect(new QDBusPendingCallWatcher( ofonoManager->GetModems(), ofonoManager), SIGNAL(finished(QDBusPendingCallWatcher*)), manager, SLOT(onGetModemsFinished(QDBusPendingCallWatcher*))); } } QOfonoManager::QOfonoManager(QObject *parent) : QObject(parent), d_ptr(new Private) { QOfonoDbusTypes::registerObjectPathProperties(); QDBusConnection systemBus(QDBusConnection::systemBus()); QDBusServiceWatcher *ofonoWatcher = new QDBusServiceWatcher("org.ofono", systemBus, QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(ofonoWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectToOfono(QString))); connect(ofonoWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(ofonoUnregistered(QString))); if (systemBus.interface()->isServiceRegistered("org.ofono")) { connectToOfono(QString()); } } QOfonoManager::~QOfonoManager() { delete d_ptr; } QStringList QOfonoManager::modems() { return d_ptr->modems; } 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 { // isValid() is essentially the same as available(), keeping it around for // backward compatibility return d_ptr->available; } 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); qSort(d_ptr->modems); Q_EMIT modemAdded(pathStr); Q_EMIT modemsChanged(d_ptr->modems); QString newDefault = defaultModem(); if (newDefault != prevDefault) { Q_EMIT defaultModemChanged(newDefault); } } } void QOfonoManager::onModemRemoved(const QDBusObjectPath& path) { QString pathStr = path.path(); 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); } } } void QOfonoManager::onGetModemsFinished(QDBusPendingCallWatcher* watcher) { QDBusPendingReply reply(*watcher); watcher->deleteLater(); if (reply.isError()) { if (qofono::isTimeout(reply.error())) { qDebug() << "Retrying GetModems..."; d_ptr->getModems(this); } else { qWarning() << reply.error(); } } else { QString prevDefault = defaultModem(); QStringList newModems; Q_FOREACH(ObjectPathProperties modem, reply.value()) { newModems.append(modem.path.path()); } qSort(newModems); if (d_ptr->modems != newModems) { d_ptr->modems = newModems; Q_EMIT modemsChanged(d_ptr->modems); } QString newDefault = defaultModem(); if (newDefault != prevDefault) { Q_EMIT defaultModemChanged(newDefault); } d_ptr->available = true; Q_EMIT availableChanged(true); } } void QOfonoManager::connectToOfono(const QString &) { if (!d_ptr->ofonoManager) { OfonoManager* mgr = new OfonoManager("org.ofono", "/", QDBusConnection::systemBus(), this); if (mgr->isValid()) { d_ptr->ofonoManager = mgr; connect(mgr, SIGNAL(ModemAdded(QDBusObjectPath,QVariantMap)), SLOT(onModemAdded(QDBusObjectPath,QVariantMap))); connect(mgr, SIGNAL(ModemRemoved(QDBusObjectPath)), SLOT(onModemRemoved(QDBusObjectPath))); d_ptr->getModems(this); } else { delete mgr; } } } void QOfonoManager::ofonoUnregistered(const QString &) { 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()); } } } QSharedPointer QOfonoManager::instance() { static QWeakPointer sharedInstance; QSharedPointer mgr = sharedInstance; if (mgr.isNull()) { mgr = QSharedPointer::create(); sharedInstance = mgr; } return mgr; } ./src/qofonocallforwarding.h0000644000004100000410000000707312762041045016433 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOCallForwarding_H #define QOFONOCallForwarding_H #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 QOFONOSHARED_EXPORT QOfonoCallForwarding : public QOfonoModemInterface { Q_OBJECT 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) public: explicit QOfonoCallForwarding(QObject *parent = 0); ~QOfonoCallForwarding(); QString modemPath() const; void setModemPath(const QString &path); QString voiceUnconditional(); void setVoiceUnconditional(const QString &property); QString voiceBusy(); void setVoiceBusy(const QString &property); QString voiceNoReply(); void setVoiceNoReply(const QString &property); quint16 voiceNoReplyTimeout(); // TODO: Fix argument type - should be quint16 void setVoiceNoReplyTimeout(ushort timeout); QString voiceNotReachable(); void setVoiceNotReachable(const QString &property); bool forwardingFlagOnSim(); Q_INVOKABLE void disableAll(const QString &type); bool isValid() const; bool isReady() const; void connectOfono(); Q_SIGNALS: void voiceUnconditionalChanged(const QString &property); void voiceBusyChanged(const QString &property); void voiceNoReplyChanged(const QString &property); // TODO: Fix argument type - should be quint16 void voiceNoReplyTimeoutChanged(ushort timeout); void voiceNotReachableChanged(const QString &property); void forwardingFlagOnSimChanged(bool property); void getPropertiesFailed(); void voiceUnconditionalComplete(bool success); void voiceBusyComplete(bool success); void voiceNoReplyComplete(bool success); void voiceNoReplyTimeoutComplete(bool success); void voiceNotReachableComplete(bool success); 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 ./src/qofonophonebook.h0000644000004100000410000000345312762041045015417 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOPhonebook_H #define QOFONOPhonebook_H #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 QOFONOSHARED_EXPORT QOfonoPhonebook : public QOfonoModemInterface2 { Q_OBJECT Q_PROPERTY(bool importing READ importing NOTIFY importingChanged) public: explicit QOfonoPhonebook(QObject *parent = 0); ~QOfonoPhonebook(); QString modemPath() const; void setModemPath(const QString &path); bool importing() const; bool isValid() const; Q_SIGNALS: void importReady(const QString &vcardData); void importFailed(); void importingChanged(); public slots: void beginImport(); private slots: void onImportFinished(QDBusPendingCallWatcher *watch); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); void dbusInterfaceDropped(); private: class Private; Private *privateData() const; }; #endif // QOFONOPhonebook_H ./src/qofonocellbroadcast.h0000644000004100000410000000423312762041045016232 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOCELLBROADCAST_H #define QOFONOCELLBROADCAST_H #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 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) public: explicit QOfonoCellBroadcast(QObject *parent = 0); ~QOfonoCellBroadcast(); QString modemPath() const; void setModemPath(const QString &path); bool enabled() const; void setEnabled(bool b); QString topics() const; void setTopics(const QString &) const; // to maintain ABI bool isValid() const; Q_SIGNALS: void enabledChanged(bool); void topicsChanged(const QString &); void incomingBroadcast(const QString &, quint16); void emergencyBroadcast(const QString &, const QVariantMap &); void modemPathChanged(const QString &path); 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 ./src/qofonovoicecallmanager.h0000644000004100000410000000644712762041045016735 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOVoiceCallManager_H #define QOFONOVoiceCallManager_H #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 QOFONOSHARED_EXPORT QOfonoVoiceCallManager : public QOfonoModemInterface { Q_OBJECT Q_PROPERTY(QStringList emergencyNumbers READ emergencyNumbers NOTIFY emergencyNumbersChanged) Q_PROPERTY(QString errorMessage READ errorMessage) public: explicit QOfonoVoiceCallManager(QObject *parent = 0); ~QOfonoVoiceCallManager(); QString modemPath() const; void setModemPath(const QString &path); QStringList emergencyNumbers() const; Q_INVOKABLE QStringList getCalls() const; bool isValid() const; QString errorMessage() const; Q_SIGNALS: void emergencyNumbersChanged(const QStringList &numbers); void callAdded(const QString &call); void callRemoved(const QString &call); void dialComplete(bool status); void hangupAllComplete(bool status); void sendTonesComplete(bool status); void transferComplete(bool status); void swapCallsComplete(bool status); void releaseAndAnswerComplete(bool status); void holdAndAnswerComplete(bool status); void privateChatComplete(bool status, const QStringList& calls); void createMultipartyComplete(bool status, const QStringList& calls); void hangupMultipartyComplete(bool status); void barringActive(const QString &type); void forwarded(const QString &type); 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 slots: 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 ./src/qofonoconnectioncontext.h0000644000004100000410000001261012762041045017172 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOCONNECTIONCONTEXT_H #define QOFONOCONNECTIONCONTEXT_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 QOFONOSHARED_EXPORT QOfonoConnectionContext : public QOfonoObject { Q_OBJECT Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) Q_PROPERTY(bool provisioning READ provisioning NOTIFY provisioningChanged) Q_PROPERTY(QString accessPointName READ accessPointName WRITE setAccessPointName NOTIFY accessPointNameChanged) Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged) Q_PROPERTY(QString authMethod READ authMethod WRITE setAuthMethod NOTIFY authMethodChanged) 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) Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString messageProxy READ messageProxy WRITE setMessageProxy NOTIFY messageProxyChanged) Q_PROPERTY(QString messageCenter READ messageCenter WRITE setMessageCenter NOTIFY messageCenterChanged) Q_PROPERTY(QVariantMap settings READ settings NOTIFY settingsChanged) Q_PROPERTY(QVariantMap IPv6Settings READ IPv6Settings NOTIFY IPv6SettingsChanged) Q_PROPERTY(QString contextPath READ contextPath WRITE setContextPath NOTIFY contextPathChanged) Q_PROPERTY(QString modemPath READ modemPath NOTIFY modemPathChanged) public: explicit QOfonoConnectionContext(QObject *parent = 0); ~QOfonoConnectionContext(); void setContextPath(const QString &idPath); QString contextPath() const; bool active() const; void setActive(bool); bool provisioning() const; QString accessPointName() const; void setAccessPointName(const QString &); QString type() const; void setType(const QString &); QString authMethod() const; void setAuthMethod(const QString &); QString username() const; void setUsername(const QString &); QString password() const; void setPassword(const QString &); QString protocol() const; void setProtocol(const QString &); QString name() const; void setName(const QString &); QString messageProxy() const; void setMessageProxy(const QString &); QString messageCenter() const; void setMessageCenter(const QString &); QVariantMap settings() const; QVariantMap IPv6Settings() const; bool isValid() const; QString modemPath() const; bool validateProvisioning(); //check provision against mbpi bool validateProvisioning(const QString &provider, const QString &mcc, const QString &mnc); //check provision against mbpi #if QT_VERSION < 0x050000 void provision(const QString &provider, const QString &mcc, const QString &mnc, const QString &type="internet"); #else void provision(const QString &provider, const QString &mcc, const QString &mnc, const QString &type=QStringLiteral("internet")); // provision context against mbpi #endif void provisionForCurrentNetwork(const QString &type); Q_INVOKABLE void disconnect(); Q_INVOKABLE bool provision(); Q_SIGNALS: void disconnectRequested(); void activeChanged(bool active); void provisioningChanged(bool provisioning); void accessPointNameChanged(const QString &apn); void nameChanged(const QString &name); void typeChanged(const QString &type); void authMethodChanged(const QString &method); void usernameChanged(const QString &uname); void passwordChanged(const QString &pw); void protocolChanged(const QString &proto); void messageProxyChanged(const QString &proxy); void messageCenterChanged(const QString &msc); void settingsChanged(const QVariantMap &settingsMap); void IPv6SettingsChanged(const QVariantMap &ipv6SettingsMap); void contextPathChanged(const QString &contextPath); void provisioningFinished(const QString &error); void modemPathChanged(const QString &path); private Q_SLOTS: void onProvisionContextFinished(QDBusPendingCallWatcher *watch); void onManagerValidChanged(bool valid); protected: 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); private: class Private; Private *privateData() const; }; #endif // QOFONOCONNECTIONCONTEXT_H ./src/qofonomessagemanager.h0000644000004100000410000000717412762041045016416 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOMessageManager_H #define QOFONOMessageManager_H #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 QOFONOSHARED_EXPORT QOfonoMessageManager : public QOfonoModemInterface { Q_OBJECT 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) Q_PROPERTY(QString alphabet READ alphabet WRITE setAlphabet NOTIFY alphabetChanged) public: explicit QOfonoMessageManager(QObject *parent = 0); ~QOfonoMessageManager(); QString modemPath() const; void setModemPath(const QString &path); QString serviceCenterAddress(); void setServiceCenterAddress(const QString &address); bool useDeliveryReports(); void setUseDeliveryReports(bool useDeliveryReports); QString bearer(); void setBearer(const QString &bearer); QString alphabet(); void setAlphabet(const QString &alphabet); Q_INVOKABLE void sendMessage(const QString &numberTo, const QString &message); Q_INVOKABLE QStringList messages(); bool isValid() const; Q_SIGNALS: void serviceCenterAddressChanged(const QString &address); void useDeliveryReportsChanged(const bool &useDeliveryReports); void bearerChanged(const QString &bearer); void alphabetChanged(const QString &alphabet); void immediateMessage(const QString &message, const QVariantMap &info); void incomingMessage(const QString &message, const QVariantMap &info); void messageAdded(const QString &message); void messageRemoved(const QString &message); void messagesFinished(); void sendMessageComplete(bool success, const QString& path); void setServiceCenterAddressComplete(bool success); void setUseDeliveryReportsComplete(bool success); void setBearerComplete(bool success); void setAlphabetComplete(bool success); private slots: void onMessageAdded(const QDBusObjectPath &path, const QVariantMap &properties); void onMessageRemoved(const QDBusObjectPath &path); void onGetMessagesFinished(QDBusPendingCallWatcher *watch); void onSendMessageFinished(QDBusPendingCallWatcher *watch); 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 ./src/qofonocallmeter.cpp0000644000004100000410000001070512762041045015734 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonocallmeter.h" #include "ofono_callmeter_interface.h" #define SUPER QOfonoModemInterface QOfonoCallMeter::QOfonoCallMeter(QObject *parent) : SUPER(OfonoCallMeter::staticInterfaceName(), parent) { } QOfonoCallMeter::~QOfonoCallMeter() { } QDBusAbstractInterface *QOfonoCallMeter::createDbusInterface(const QString &path) { OfonoCallMeter *iface = new OfonoCallMeter("org.ofono", path, QDBusConnection::systemBus(), this); connect(iface, SIGNAL(NearMaximumWarning()), SIGNAL(nearMaximumWarning())); return iface; } void QOfonoCallMeter::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("AccumulatedCallMeterMaximum")) { Q_EMIT accumulatedCallMeterMaximumChanged(value.value()); } else if (property == QLatin1String("PricePerUnit")) { Q_EMIT pricePerUnitChanged(value.value()); } } quint32 QOfonoCallMeter::callMeter() const { return getProperty("CallMeter").value(); } quint32 QOfonoCallMeter::accumulatedCallMeter() const { return getProperty("AccumulatedCallMeter").value(); } quint32 QOfonoCallMeter::accumulatedCallMeterMaximum() const { return getProperty("AccumulatedCallMeterMaximum").value(); } void QOfonoCallMeter::setAccumulatedCallMeterMaximum(quint32 max, const QString &password) { OfonoCallMeter *iface = (OfonoCallMeter*)dbusInterface(); if (iface) { QVariantList arguments; arguments << QVariant(max); iface->SetProperty("AccumulatedCallMeterMaximum", QDBusVariant(arguments), password); } } qreal QOfonoCallMeter::pricePerUnit() const { return getProperty("PricePerUnit").value(); } void QOfonoCallMeter::setPricePerUnit(qreal unit, const QString &password) { OfonoCallMeter *iface = (OfonoCallMeter*)dbusInterface(); if (iface) { QVariantList arguments; arguments << QVariant(unit); iface->SetProperty("PricePerUnit", QDBusVariant(arguments), password); } } QString QOfonoCallMeter:: currency() const { return getString("Currency"); } void QOfonoCallMeter::reset(const QString &password) { OfonoCallMeter *iface = (OfonoCallMeter*)dbusInterface(); if (iface) { connect(new QDBusPendingCallWatcher(iface->Reset(password), iface), SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onResetFinished(QDBusPendingCallWatcher*))); } } void QOfonoCallMeter::onResetFinished(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; QOfonoCallMeter::Error error = NoError; if (reply.isError()) { qWarning() << "QOfonoCallMeter::reset() failed:" << reply.error(); QString errorName(reply.error().name()); error = errorNameToEnum(errorName); Q_EMIT resetComplete(error, errorName + " " + reply.error().message()); } } QOfonoCallMeter::Error QOfonoCallMeter::errorNameToEnum(const QString &errorName) { if (errorName == "") return NoError; else if (errorName == "org.ofono.Error.NotImplemented") return NotImplementedError; else if (errorName == "org.ofono.Error.InProgress") return InProgressError; else if (errorName == "org.ofono.Error.InvalidArguments") return InvalidArgumentsError; else if (errorName == "org.ofono.Error.InvalidFormat") return InvalidFormatError; else if (errorName == "org.ofono.Error.Failed") return FailedError; 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(); } ./src/qofonomodeminterface.cpp0000644000004100000410000001112412762041064016743 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2014-2015 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; bool modemValid; Private(const QString &iface, QOfonoModem::ExtData *data) : interfaceName(iface), ext(data), modemValid(false) {} ~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::fixModemPath(const QString &path) { fixObjectPath(path); } bool QOfonoModemInterface::isValid() const { return privateData()->modemValid && SUPER::isValid(); } 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(); ValidTracker track(this); Private *d_ptr = privateData(); if (!d_ptr->modem.isNull()) { QOfonoModem *modem = d_ptr->modem.data(); disconnect(modem, SIGNAL(interfacesChanged(QStringList)), this, SLOT(onModemInterfacesChanged(QStringList))); disconnect(modem, SIGNAL(validChanged(bool)), this, SLOT(onModemValidChanged(bool))); d_ptr->modemValid = false; d_ptr->modem.reset(); } setDbusInterface(NULL, NULL); d_ptr->modem = QOfonoModem::instance(objectPath()); QOfonoModem *modem = d_ptr->modem.data(); connect(modem, SIGNAL(interfacesChanged(QStringList)), this, SLOT(onModemInterfacesChanged(QStringList))); connect(modem, SIGNAL(validChanged(bool)), this, SLOT(onModemValidChanged(bool))); d_ptr->modemValid = modem->isValid(); Q_EMIT modemPathChanged(path); onModemInterfacesChanged(d_ptr->modem->interfaces()); if (wasReady != isReady()) { Q_EMIT readyChanged(); } } void QOfonoModemInterface::onModemValidChanged(bool valid) { ValidTracker track(this); privateData()->modemValid = valid; } 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(); } } ./src/dbustypes.h0000644000004100000410000000326312762041045014232 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 DBUSTYPES_H #define DBUSTYPES_H #include #include struct ObjectPathProperties { 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 ./src/qofonosmartmessagingagent.cpp0000644000004100000410000000461012762041045020025 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonosmartmessagingagent.h" #include "ofono_smart_messaging_agent_adaptor.h" class QOfonoSmartMessagingAgentPrivate { public: QOfonoSmartMessagingAgentPrivate(); bool registered; }; QOfonoSmartMessagingAgentPrivate::QOfonoSmartMessagingAgentPrivate() : registered(false) { } QOfonoSmartMessagingAgent::QOfonoSmartMessagingAgent(QObject *parent) : QObject(parent) , d_ptr(new QOfonoSmartMessagingAgentPrivate) { new QOfonoSmartMessagingAgentAdaptor(this); } QOfonoSmartMessagingAgent::~QOfonoSmartMessagingAgent() { if (d_ptr->registered) QDBusConnection::systemBus().unregisterObject(smAgentPath); delete d_ptr; } void QOfonoSmartMessagingAgent::setAgentPath(const QString &path) { if (smAgentPath != path) { QDBusConnection dbus = QDBusConnection::systemBus(); if (d_ptr->registered) { dbus.unregisterObject(smAgentPath); d_ptr->registered = false; } smAgentPath = path; if (!path.isEmpty()) { if (!dbus.registerObject(path, this)) { qWarning() << "Object registration failed:" << dbus.lastError(); } d_ptr->registered = true; } Q_EMIT agentPathChanged(path); } } QString QOfonoSmartMessagingAgent::agentPath() const { return smAgentPath; } void QOfonoSmartMessagingAgent::ReceiveAppointment(const QByteArray &appointment, const QVariantMap &info) { Q_EMIT receiveAppointment(appointment, info); } void QOfonoSmartMessagingAgent::ReceiveBusinessCard(const QByteArray &card, const QVariantMap &info) { Q_EMIT receiveBusinessCard(card, info); } void QOfonoSmartMessagingAgent::Release() { Q_EMIT release(); } ./src/qofonotexttelephony.cpp0000644000004100000410000000350312762041045016676 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonotexttelephony.h" #include "ofono_text_telephony_interface.h" #define SUPER QOfonoModemInterface QOfonoTextTelephony::QOfonoTextTelephony(QObject *parent) : SUPER(OfonoTextTelephony::staticInterfaceName(), parent) { } QOfonoTextTelephony::~QOfonoTextTelephony() { } QDBusAbstractInterface *QOfonoTextTelephony::createDbusInterface(const QString &path) { return new OfonoTextTelephony("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoTextTelephony::setModemPath(const QString &path) { SUPER::setModemPath(path); } QString QOfonoTextTelephony::modemPath() const { return SUPER::modemPath(); } void QOfonoTextTelephony::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("Enabled")) { Q_EMIT setTtyEnabled(value.toBool()); } } bool QOfonoTextTelephony::ttyEnabled() const { return getBool("Enabled"); } void QOfonoTextTelephony::setTtyEnabled(bool enabled) { setProperty("Enabled", enabled); } bool QOfonoTextTelephony::isValid() const { return SUPER::isValid(); } ./src/qofono.prf0000644000004100000410000000023612762041045014046 0ustar www-datawww-dataprefix=/usr exec_prefix=$${prefix} DEPENDPATH += $${prefix}/include/qofono INCLUDEPATH += $${prefix}/include/qofono LIBS += -L $${exec_prefix}/lib -lqofono ./src/qofono.cpp0000644000004100000410000023272312762041045014051 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofono.h" typedef struct _QOfonoMccListEntry { int mcc; char mnc[4]; char cc[4]; } QOfonoMccListEntry; // Updated from Wikipedia on October 09, 2014 // http://en.wikipedia.org/wiki/Mobile_country_code static const QOfonoMccListEntry qofonoMccList[] = { {202, "01", "GR"}, /* Greece */ {202, "02", "GR"}, /* Greece */ {202, "03", "GR"}, /* Greece */ {202, "04", "GR"}, /* Greece */ {202, "05", "GR"}, /* Greece */ {202, "06", "GR"}, /* Greece */ {202, "07", "GR"}, /* Greece */ {202, "09", "GR"}, /* Greece */ {202, "10", "GR"}, /* Greece */ {204, "01", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "02", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "03", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "04", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "05", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "06", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "07", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "08", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "09", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "10", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "11", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "12", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "13", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "14", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "15", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "16", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "17", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "18", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "19", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "20", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "21", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "22", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "23", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "24", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "25", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "26", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "27", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "28", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "29", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "60", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "61", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "62", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "64", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "65", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "66", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "67", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "68", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {204, "69", "NL"}, /* Netherlands (Kingdom of the Netherlands) */ {206, "01", "BE"}, /* Belgium */ {206, "02", "BE"}, /* Belgium */ {206, "05", "BE"}, /* Belgium */ {206, "06", "BE"}, /* Belgium */ {206, "07", "BE"}, /* Belgium */ {206, "09", "BE"}, /* Belgium */ {206, "10", "BE"}, /* Belgium */ {206, "15", "BE"}, /* Belgium */ {206, "20", "BE"}, /* Belgium */ {208, "01", "FR"}, /* France */ {208, "02", "FR"}, /* France */ {208, "03", "FR"}, /* France */ {208, "04", "FR"}, /* France */ {208, "05", "FR"}, /* France */ {208, "06", "FR"}, /* France */ {208, "07", "FR"}, /* France */ {208, "08", "FR"}, /* France */ {208, "09", "FR"}, /* France */ {208, "10", "FR"}, /* France */ {208, "11", "FR"}, /* France */ {208, "13", "FR"}, /* France */ {208, "14", "FR"}, /* France */ {208, "15", "FR"}, /* France */ {208, "16", "FR"}, /* France */ {208, "17", "FR"}, /* France */ {208, "18", "FR"}, /* France */ {208, "20", "FR"}, /* France */ {208, "21", "FR"}, /* France */ {208, "22", "FR"}, /* France */ {208, "23", "FR"}, /* France */ {208, "24", "FR"}, /* France */ {208, "25", "FR"}, /* France */ {208, "26", "FR"}, /* France */ {208, "27", "FR"}, /* France */ {208, "28", "FR"}, /* France */ {208, "29", "FR"}, /* France */ {208, "30", "FR"}, /* France */ {208, "31", "FR"}, /* France */ {208, "88", "FR"}, /* France */ {208, "89", "FR"}, /* France */ {208, "90", "FR"}, /* France */ {208, "91", "FR"}, /* France */ {208, "92", "FR"}, /* France */ {208, "93", "FR"}, /* France */ {212, "01", "MC"}, /* Monaco */ {212, "01", "RKS"}, /* Kosovo */ {213, "03", "AD"}, /* Andorra */ {214, "01", "ES"}, /* Spain */ {214, "03", "ES"}, /* Spain */ {214, "04", "ES"}, /* Spain */ {214, "05", "ES"}, /* Spain */ {214, "06", "ES"}, /* Spain */ {214, "07", "ES"}, /* Spain */ {214, "08", "ES"}, /* Spain */ {214, "09", "ES"}, /* Spain */ {214, "15", "ES"}, /* Spain */ {214, "16", "ES"}, /* Spain */ {214, "17", "ES"}, /* Spain */ {214, "18", "ES"}, /* Spain */ {214, "19", "ES"}, /* Spain */ {214, "20", "ES"}, /* Spain */ {214, "21", "ES"}, /* Spain */ {214, "22", "ES"}, /* Spain */ {214, "23", "ES"}, /* Spain */ {214, "24", "ES"}, /* Spain */ {214, "25", "ES"}, /* Spain */ {214, "28", "ES"}, /* Spain */ {214, "29", "ES"}, /* Spain */ {214, "30", "ES"}, /* Spain */ {214, "31", "ES"}, /* Spain */ {214, "32", "ES"}, /* Spain */ {216, "01", "HU"}, /* Hungary */ {216, "20", "HU"}, /* Hungary */ {216, "30", "HU"}, /* Hungary */ {216, "70", "HU"}, /* Hungary */ {216, "71", "HU"}, /* Hungary */ {216, "99", "HU"}, /* Hungary */ {218, "03", "BA"}, /* Bosnia and Herzegovina */ {218, "05", "BA"}, /* Bosnia and Herzegovina */ {218, "90", "BA"}, /* Bosnia and Herzegovina */ {219, "01", "HR"}, /* Croatia */ {219, "02", "HR"}, /* Croatia */ {219, "10", "HR"}, /* Croatia */ {220, "01", "RS"}, /* Serbia */ {220, "02", "RS"}, /* Serbia */ {220, "03", "RS"}, /* Serbia */ {220, "05", "RS"}, /* Serbia */ {222, "01", "IT"}, /* Italy */ {222, "02", "IT"}, /* Italy */ {222, "04", "IT"}, /* Italy */ {222, "05", "IT"}, /* Italy */ {222, "07", "IT"}, /* Italy */ {222, "10", "IT"}, /* Italy */ {222, "30", "IT"}, /* Italy */ {222, "34", "IT"}, /* Italy */ {222, "35", "IT"}, /* Italy */ {222, "77", "IT"}, /* Italy */ {222, "88", "IT"}, /* Italy */ {222, "98", "IT"}, /* Italy */ {222, "99", "IT"}, /* Italy */ {226, "01", "RO"}, /* Romania */ {226, "02", "RO"}, /* Romania */ {226, "03", "RO"}, /* Romania */ {226, "04", "RO"}, /* Romania */ {226, "05", "RO"}, /* Romania */ {226, "06", "RO"}, /* Romania */ {226, "10", "RO"}, /* Romania */ {226, "11", "RO"}, /* Romania */ {226, "15", "RO"}, /* Romania */ {228, "01", "CH"}, /* Switzerland */ {228, "02", "CH"}, /* Switzerland */ {228, "03", "CH"}, /* Switzerland */ {228, "05", "CH"}, /* Switzerland */ {228, "06", "CH"}, /* Switzerland */ {228, "07", "CH"}, /* Switzerland */ {228, "08", "CH"}, /* Switzerland */ {228, "09", "CH"}, /* Switzerland */ {228, "12", "CH"}, /* Switzerland */ {228, "50", "CH"}, /* Switzerland */ {228, "51", "CH"}, /* Switzerland */ {228, "52", "CH"}, /* Switzerland */ {228, "53", "CH"}, /* Switzerland */ {228, "54", "CH"}, /* Switzerland */ {228, "99", "CH"}, /* Switzerland */ {230, "01", "CZ"}, /* Czech Republic */ {230, "02", "CZ"}, /* Czech Republic */ {230, "03", "CZ"}, /* Czech Republic */ {230, "04", "CZ"}, /* Czech Republic */ {230, "05", "CZ"}, /* Czech Republic */ {230, "06", "CZ"}, /* Czech Republic */ {230, "07", "CZ"}, /* Czech Republic */ {230, "08", "CZ"}, /* Czech Republic */ {230, "98", "CZ"}, /* Czech Republic */ {230, "99", "CZ"}, /* Czech Republic */ {231, "01", "SK"}, /* Slovakia */ {231, "02", "SK"}, /* Slovakia */ {231, "03", "SK"}, /* Slovakia */ {231, "04", "SK"}, /* Slovakia */ {231, "06", "SK"}, /* Slovakia */ {231, "99", "SK"}, /* Slovakia */ {232, "01", "AT"}, /* Austria */ {232, "02", "AT"}, /* Austria */ {232, "03", "AT"}, /* Austria */ {232, "04", "AT"}, /* Austria */ {232, "05", "AT"}, /* Austria */ {232, "06", "AT"}, /* Austria */ {232, "07", "AT"}, /* Austria */ {232, "08", "AT"}, /* Austria */ {232, "09", "AT"}, /* Austria */ {232, "10", "AT"}, /* Austria */ {232, "11", "AT"}, /* Austria */ {232, "12", "AT"}, /* Austria */ {232, "13", "AT"}, /* Austria */ {232, "14", "AT"}, /* Austria */ {232, "15", "AT"}, /* Austria */ {232, "16", "AT"}, /* Austria */ {232, "91", "AT"}, /* Austria */ {234, "00", "GB"}, /* United Kingdom */ {234, "01", "GB"}, /* United Kingdom */ {234, "02", "GB"}, /* United Kingdom */ {234, "03", "GG"}, /* Guernsey (United Kingdom) */ {234, "03", "JE"}, /* Jersey (United Kingdom) */ {234, "03", "GB"}, /* United Kingdom */ {234, "04", "GB"}, /* United Kingdom */ {234, "05", "GB"}, /* United Kingdom */ {234, "06", "GB"}, /* United Kingdom */ {234, "07", "GB"}, /* United Kingdom */ {234, "08", "GB"}, /* United Kingdom */ {234, "09", "IM"}, /* Isle of Man (United Kingdom) */ {234, "09", "GB"}, /* United Kingdom */ {234, "10", "GB"}, /* United Kingdom */ {234, "11", "GB"}, /* United Kingdom */ {234, "12", "GB"}, /* United Kingdom */ {234, "13", "GB"}, /* United Kingdom */ {234, "14", "GB"}, /* United Kingdom */ {234, "15", "GB"}, /* United Kingdom */ {234, "16", "GB"}, /* United Kingdom */ {234, "17", "GB"}, /* United Kingdom */ {234, "18", "GB"}, /* United Kingdom */ {234, "19", "GB"}, /* United Kingdom */ {234, "20", "GB"}, /* United Kingdom */ {234, "22", "GB"}, /* United Kingdom */ {234, "23", "GB"}, /* United Kingdom */ {234, "24", "GB"}, /* United Kingdom */ {234, "25", "GB"}, /* United Kingdom */ {234, "26", "GB"}, /* United Kingdom */ {234, "27", "GB"}, /* United Kingdom */ {234, "28", "GB"}, /* United Kingdom */ {234, "29", "GB"}, /* United Kingdom */ {234, "30", "GB"}, /* United Kingdom */ {234, "31", "GB"}, /* United Kingdom */ {234, "32", "GB"}, /* United Kingdom */ {234, "33", "GB"}, /* United Kingdom */ {234, "34", "GB"}, /* United Kingdom */ {234, "35", "GB"}, /* United Kingdom */ {234, "36", "GB"}, /* United Kingdom */ {234, "37", "GB"}, /* United Kingdom */ {234, "38", "GB"}, /* United Kingdom */ {234, "39", "GB"}, /* United Kingdom */ {234, "50", "GG"}, /* Guernsey (United Kingdom) */ {234, "50", "JE"}, /* Jersey (United Kingdom) */ {234, "50", "GB"}, /* United Kingdom */ {234, "51", "GB"}, /* United Kingdom */ {234, "52", "GB"}, /* United Kingdom */ {234, "53", "GB"}, /* United Kingdom */ {234, "55", "GG"}, /* Guernsey (United Kingdom) */ {234, "55", "JE"}, /* Jersey (United Kingdom) */ {234, "55", "GB"}, /* United Kingdom */ {234, "58", "IM"}, /* Isle of Man (United Kingdom) */ {234, "58", "GB"}, /* United Kingdom */ {234, "76", "GB"}, /* United Kingdom */ {234, "78", "GB"}, /* United Kingdom */ {234, "86", "GB"}, /* United Kingdom */ {235, "00", "GB"}, /* United Kingdom */ {235, "01", "GB"}, /* United Kingdom */ {235, "02", "GB"}, /* United Kingdom */ {235, "03", "GB"}, /* United Kingdom */ {235, "77", "GB"}, /* United Kingdom */ {235, "91", "GB"}, /* United Kingdom */ {235, "92", "GB"}, /* United Kingdom */ {235, "94", "GB"}, /* United Kingdom */ {235, "95", "GB"}, /* United Kingdom */ {238, "01", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "02", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "04", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "05", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "06", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "07", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "08", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "09", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "10", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "11", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "12", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "13", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "20", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "23", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "28", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "30", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "40", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "43", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "66", "DK"}, /* Denmark (Kingdom of Denmark) */ {238, "77", "DK"}, /* Denmark (Kingdom of Denmark) */ {240, "01", "SE"}, /* Sweden */ {240, "02", "SE"}, /* Sweden */ {240, "03", "SE"}, /* Sweden */ {240, "04", "SE"}, /* Sweden */ {240, "05", "SE"}, /* Sweden */ {240, "06", "SE"}, /* Sweden */ {240, "07", "SE"}, /* Sweden */ {240, "08", "SE"}, /* Sweden */ {240, "09", "SE"}, /* Sweden */ {240, "10", "SE"}, /* Sweden */ {240, "11", "SE"}, /* Sweden */ {240, "12", "SE"}, /* Sweden */ {240, "13", "SE"}, /* Sweden */ {240, "14", "SE"}, /* Sweden */ {240, "15", "SE"}, /* Sweden */ {240, "16", "SE"}, /* Sweden */ {240, "17", "SE"}, /* Sweden */ {240, "18", "SE"}, /* Sweden */ {240, "19", "SE"}, /* Sweden */ {240, "20", "SE"}, /* Sweden */ {240, "21", "SE"}, /* Sweden */ {240, "22", "SE"}, /* Sweden */ {240, "23", "SE"}, /* Sweden */ {240, "24", "SE"}, /* Sweden */ {240, "25", "SE"}, /* Sweden */ {240, "26", "SE"}, /* Sweden */ {240, "27", "SE"}, /* Sweden */ {240, "28", "SE"}, /* Sweden */ {240, "29", "SE"}, /* Sweden */ {240, "30", "SE"}, /* Sweden */ {240, "31", "SE"}, /* Sweden */ {240, "32", "SE"}, /* Sweden */ {240, "33", "SE"}, /* Sweden */ {240, "34", "SE"}, /* Sweden */ {240, "35", "SE"}, /* Sweden */ {240, "36", "SE"}, /* Sweden */ {240, "37", "SE"}, /* Sweden */ {240, "38", "SE"}, /* Sweden */ {240, "39", "SE"}, /* Sweden */ {240, "40", "SE"}, /* Sweden */ {240, "41", "SE"}, /* Sweden */ {240, "42", "SE"}, /* Sweden */ {240, "43", "SE"}, /* Sweden */ {240, "44", "SE"}, /* Sweden */ {242, "01", "NO"}, /* Norway */ {242, "02", "NO"}, /* Norway */ {242, "03", "NO"}, /* Norway */ {242, "04", "NO"}, /* Norway */ {242, "05", "NO"}, /* Norway */ {242, "06", "NO"}, /* Norway */ {242, "07", "NO"}, /* Norway */ {242, "08", "NO"}, /* Norway */ {242, "09", "NO"}, /* Norway */ {242, "11", "NO"}, /* Norway */ {242, "12", "NO"}, /* Norway */ {242, "20", "NO"}, /* Norway */ {242, "21", "NO"}, /* Norway */ {242, "23", "NO"}, /* Norway */ {242, "24", "NO"}, /* Norway */ {242, "25", "NO"}, /* Norway */ {244, "03", "FI"}, /* Finland */ {244, "04", "FI"}, /* Finland */ {244, "05", "FI"}, /* Finland */ {244, "07", "FI"}, /* Finland */ {244, "08", "FI"}, /* Finland */ {244, "09", "FI"}, /* Finland */ {244, "10", "FI"}, /* Finland */ {244, "11", "FI"}, /* Finland */ {244, "12", "FI"}, /* Finland */ {244, "13", "FI"}, /* Finland */ {244, "14", "FI"}, /* Finland */ {244, "16", "FI"}, /* Finland */ {244, "21", "FI"}, /* Finland */ {244, "25", "FI"}, /* Finland */ {244, "26", "FI"}, /* Finland */ {244, "29", "FI"}, /* Finland */ {244, "30", "FI"}, /* Finland */ {244, "31", "FI"}, /* Finland */ {244, "32", "FI"}, /* Finland */ {244, "33", "FI"}, /* Finland */ {244, "34", "FI"}, /* Finland */ {244, "35", "FI"}, /* Finland */ {244, "91", "FI"}, /* Finland */ {246, "01", "LT"}, /* Lithuania */ {246, "02", "LT"}, /* Lithuania */ {246, "03", "LT"}, /* Lithuania */ {246, "05", "LT"}, /* Lithuania */ {246, "06", "LT"}, /* Lithuania */ {247, "01", "LV"}, /* Latvia */ {247, "02", "LV"}, /* Latvia */ {247, "03", "LV"}, /* Latvia */ {247, "04", "LV"}, /* Latvia */ {247, "05", "LV"}, /* Latvia */ {247, "06", "LV"}, /* Latvia */ {247, "07", "LV"}, /* Latvia */ {247, "08", "LV"}, /* Latvia */ {247, "09", "LV"}, /* Latvia */ {248, "01", "EE"}, /* Estonia */ {248, "02", "EE"}, /* Estonia */ {248, "03", "EE"}, /* Estonia */ {248, "04", "EE"}, /* Estonia */ {248, "05", "EE"}, /* Estonia */ {248, "06", "EE"}, /* Estonia */ {248, "07", "EE"}, /* Estonia */ {248, "08", "EE"}, /* Estonia */ {248, "09", "EE"}, /* Estonia */ {248, "71", "EE"}, /* Estonia */ {250, "01", "RU"}, /* Russian Federation */ {250, "02", "RU"}, /* Russian Federation */ {250, "03", "RU"}, /* Russian Federation */ {250, "04", "RU"}, /* Russian Federation */ {250, "05", "RU"}, /* Russian Federation */ {250, "06", "RU"}, /* Russian Federation */ {250, "07", "RU"}, /* Russian Federation */ {250, "09", "RU"}, /* Russian Federation */ {250, "10", "RU"}, /* Russian Federation */ {250, "11", "RU"}, /* Russian Federation */ {250, "12", "RU"}, /* Russian Federation */ {250, "13", "RU"}, /* Russian Federation */ {250, "14", "RU"}, /* Russian Federation */ {250, "15", "RU"}, /* Russian Federation */ {250, "16", "RU"}, /* Russian Federation */ {250, "17", "RU"}, /* Russian Federation */ {250, "18", "RU"}, /* Russian Federation */ {250, "19", "RU"}, /* Russian Federation */ {250, "20", "RU"}, /* Russian Federation */ {250, "23", "RU"}, /* Russian Federation */ {250, "28", "RU"}, /* Russian Federation */ {250, "32", "RU"}, /* Russian Federation */ {250, "35", "RU"}, /* Russian Federation */ {250, "38", "RU"}, /* Russian Federation */ {250, "39", "RU"}, /* Russian Federation */ {250, "44", "RU"}, /* Russian Federation */ {250, "50", "RU"}, /* Russian Federation */ {250, "91", "RU"}, /* Russian Federation */ {250, "92", "RU"}, /* Russian Federation */ {250, "93", "RU"}, /* Russian Federation */ {250, "99", "RU"}, /* Russian Federation */ {255, "01", "UA"}, /* Ukraine */ {255, "02", "UA"}, /* Ukraine */ {255, "03", "UA"}, /* Ukraine */ {255, "04", "UA"}, /* Ukraine */ {255, "05", "UA"}, /* Ukraine */ {255, "06", "UA"}, /* Ukraine */ {255, "07", "UA"}, /* Ukraine */ {255, "21", "UA"}, /* Ukraine */ {255, "23", "UA"}, /* Ukraine */ {255, "25", "UA"}, /* Ukraine */ {257, "01", "BY"}, /* Belarus */ {257, "02", "BY"}, /* Belarus */ {257, "03", "BY"}, /* Belarus */ {257, "04", "BY"}, /* Belarus */ {257, "05", "BY"}, /* Belarus */ {257, "06", "BY"}, /* Belarus */ {257, "501", "BY"}, /* Belarus */ {259, "01", "MD"}, /* Moldova */ {259, "02", "MD"}, /* Moldova */ {259, "03", "MD"}, /* Moldova */ {259, "04", "MD"}, /* Moldova */ {259, "05", "MD"}, /* Moldova */ {259, "99", "MD"}, /* Moldova */ {260, "01", "PL"}, /* Poland */ {260, "02", "PL"}, /* Poland */ {260, "03", "PL"}, /* Poland */ {260, "04", "PL"}, /* Poland */ {260, "05", "PL"}, /* Poland */ {260, "06", "PL"}, /* Poland */ {260, "07", "PL"}, /* Poland */ {260, "08", "PL"}, /* Poland */ {260, "09", "PL"}, /* Poland */ {260, "10", "PL"}, /* Poland */ {260, "11", "PL"}, /* Poland */ {260, "12", "PL"}, /* Poland */ {260, "13", "PL"}, /* Poland */ {260, "14", "PL"}, /* Poland */ {260, "15", "PL"}, /* Poland */ {260, "16", "PL"}, /* Poland */ {260, "17", "PL"}, /* Poland */ {260, "18", "PL"}, /* Poland */ {260, "19", "PL"}, /* Poland */ {260, "20", "PL"}, /* Poland */ {260, "21", "PL"}, /* Poland */ {260, "22", "PL"}, /* Poland */ {260, "23", "PL"}, /* Poland */ {260, "24", "PL"}, /* Poland */ {260, "25", "PL"}, /* Poland */ {260, "26", "PL"}, /* Poland */ {260, "27", "PL"}, /* Poland */ {260, "28", "PL"}, /* Poland */ {260, "29", "PL"}, /* Poland */ {260, "30", "PL"}, /* Poland */ {260, "31", "PL"}, /* Poland */ {260, "32", "PL"}, /* Poland */ {260, "33", "PL"}, /* Poland */ {260, "34", "PL"}, /* Poland */ {260, "98", "PL"}, /* Poland */ {262, "01", "DE"}, /* Germany */ {262, "02", "DE"}, /* Germany */ {262, "03", "DE"}, /* Germany */ {262, "04", "DE"}, /* Germany */ {262, "05", "DE"}, /* Germany */ {262, "06", "DE"}, /* Germany */ {262, "07", "DE"}, /* Germany */ {262, "08", "DE"}, /* Germany */ {262, "09", "DE"}, /* Germany */ {262, "10", "DE"}, /* Germany */ {262, "11", "DE"}, /* Germany */ {262, "12", "DE"}, /* Germany */ {262, "13", "DE"}, /* Germany */ {262, "14", "DE"}, /* Germany */ {262, "15", "DE"}, /* Germany */ {262, "16", "DE"}, /* Germany */ {262, "17", "DE"}, /* Germany */ {262, "18", "DE"}, /* Germany */ {262, "19", "DE"}, /* Germany */ {262, "20", "DE"}, /* Germany */ {262, "33", "DE"}, /* Germany */ {262, "41", "DE"}, /* Germany */ {262, "42", "DE"}, /* Germany */ {262, "43", "DE"}, /* Germany */ {262, "60", "DE"}, /* Germany */ {262, "76", "DE"}, /* Germany */ {262, "77", "DE"}, /* Germany */ {262, "78", "DE"}, /* Germany */ {262, "79", "DE"}, /* Germany */ {262, "901", "DE"}, /* Germany */ {262, "92", "DE"}, /* Germany */ {266, "01", "GI"}, /* Gibraltar (United Kingdom) */ {266, "06", "GI"}, /* Gibraltar (United Kingdom) */ {266, "09", "GI"}, /* Gibraltar (United Kingdom) */ {268, "01", "PT"}, /* Portugal */ {268, "03", "PT"}, /* Portugal */ {268, "04", "PT"}, /* Portugal */ {268, "05", "PT"}, /* Portugal */ {268, "06", "PT"}, /* Portugal */ {268, "07", "PT"}, /* Portugal */ {268, "21", "PT"}, /* Portugal */ {270, "01", "LU"}, /* Luxembourg */ {270, "02", "LU"}, /* Luxembourg */ {270, "10", "LU"}, /* Luxembourg */ {270, "77", "LU"}, /* Luxembourg */ {270, "78", "LU"}, /* Luxembourg */ {270, "99", "LU"}, /* Luxembourg */ {272, "01", "IE"}, /* Republic of Ireland|Ireland */ {272, "02", "IE"}, /* Republic of Ireland|Ireland */ {272, "03", "IE"}, /* Republic of Ireland|Ireland */ {272, "04", "IE"}, /* Republic of Ireland|Ireland */ {272, "05", "IE"}, /* Republic of Ireland|Ireland */ {272, "07", "IE"}, /* Republic of Ireland|Ireland */ {272, "09", "IE"}, /* Republic of Ireland|Ireland */ {272, "11", "IE"}, /* Republic of Ireland|Ireland */ {272, "13", "IE"}, /* Republic of Ireland|Ireland */ {274, "01", "IS"}, /* Iceland */ {274, "02", "IS"}, /* Iceland */ {274, "03", "IS"}, /* Iceland */ {274, "04", "IS"}, /* Iceland */ {274, "06", "IS"}, /* Iceland */ {274, "07", "IS"}, /* Iceland */ {274, "08", "IS"}, /* Iceland */ {274, "11", "IS"}, /* Iceland */ {274, "12", "IS"}, /* Iceland */ {276, "01", "AL"}, /* Albania */ {276, "02", "AL"}, /* Albania */ {276, "03", "AL"}, /* Albania */ {276, "04", "AL"}, /* Albania */ {278, "01", "MT"}, /* Malta */ {278, "21", "MT"}, /* Malta */ {278, "77", "MT"}, /* Malta */ {280, "01", "CY"}, /* Cyprus */ {280, "10", "CY"}, /* Cyprus */ {280, "20", "CY"}, /* Cyprus */ {280, "22", "CY"}, /* Cyprus */ {282, "01", "GE"}, /* Georgia (country)|Georgia */ {282, "02", "GE"}, /* Georgia (country)|Georgia */ {282, "03", "GE"}, /* Georgia (country)|Georgia */ {282, "04", "GE"}, /* Georgia (country)|Georgia */ {282, "05", "GE"}, /* Georgia (country)|Georgia */ {282, "06", "GE"}, /* Georgia (country)|Georgia */ {282, "07", "GE"}, /* Georgia (country)|Georgia */ {283, "01", "AM"}, /* Armenia */ {283, "04", "AM"}, /* Armenia */ {283, "05", "AM"}, /* Armenia */ {283, "10", "AM"}, /* Armenia */ {284, "01", "BG"}, /* Bulgaria */ {284, "03", "BG"}, /* Bulgaria */ {284, "05", "BG"}, /* Bulgaria */ {284, "07", "BG"}, /* Bulgaria */ {284, "09", "BG"}, /* Bulgaria */ {284, "11", "BG"}, /* Bulgaria */ {284, "13", "BG"}, /* Bulgaria */ {286, "01", "TR"}, /* Turkey */ {286, "02", "TR"}, /* Turkey */ {286, "03", "TR"}, /* Turkey */ {286, "04", "TR"}, /* Turkey */ {288, "01", "FO"}, /* Faroe Islands (Kingdom of Denmark) */ {288, "02", "FO"}, /* Faroe Islands (Kingdom of Denmark) */ {288, "03", "FO"}, /* Faroe Islands (Kingdom of Denmark) */ {289, "67", "GE"}, /* Abkhazia */ {289, "88", "GE"}, /* Abkhazia */ {290, "01", "GL"}, /* Greenland (Kingdom of Denmark) */ {292, "01", "SM"}, /* San Marino */ {293, "31", "SI"}, /* Slovenia */ {293, "40", "SI"}, /* Slovenia */ {293, "41", "RKS"}, /* Kosovo */ {293, "41", "SI"}, /* Slovenia */ {293, "51", "SI"}, /* Slovenia */ {293, "64", "SI"}, /* Slovenia */ {293, "70", "SI"}, /* Slovenia */ {294, "01", "MK"}, /* Republic of Macedonia|Macedonia */ {294, "02", "MK"}, /* Republic of Macedonia|Macedonia */ {294, "03", "MK"}, /* Republic of Macedonia|Macedonia */ {295, "01", "LI"}, /* Liechtenstein */ {295, "02", "LI"}, /* Liechtenstein */ {295, "05", "LI"}, /* Liechtenstein */ {295, "06", "LI"}, /* Liechtenstein */ {295, "77", "LI"}, /* Liechtenstein */ {297, "01", "ME"}, /* Montenegro */ {297, "02", "ME"}, /* Montenegro */ {297, "03", "ME"}, /* Montenegro */ {297, "04", "ME"}, /* Montenegro */ {302, "220", "CA"}, /* Canada */ {302, "221", "CA"}, /* Canada */ {302, "222", "CA"}, /* Canada */ {302, "250", "CA"}, /* Canada */ {302, "270", "CA"}, /* Canada */ {302, "290", "CA"}, /* Canada */ {302, "320", "CA"}, /* Canada */ {302, "340", "CA"}, /* Canada */ {302, "350", "CA"}, /* Canada */ {302, "360", "CA"}, /* Canada */ {302, "361", "CA"}, /* Canada */ {302, "370", "CA"}, /* Canada */ {302, "380", "CA"}, /* Canada */ {302, "390", "CA"}, /* Canada */ {302, "480", "CA"}, /* Canada */ {302, "490", "CA"}, /* Canada */ {302, "500", "CA"}, /* Canada */ {302, "510", "CA"}, /* Canada */ {302, "520", "CA"}, /* Canada */ {302, "530", "CA"}, /* Canada */ {302, "560", "CA"}, /* Canada */ {302, "570", "CA"}, /* Canada */ {302, "590", "CA"}, /* Canada */ {302, "610", "CA"}, /* Canada */ {302, "620", "CA"}, /* Canada */ {302, "630", "CA"}, /* Canada */ {302, "640", "CA"}, /* Canada */ {302, "652", "CA"}, /* Canada */ {302, "653", "CA"}, /* Canada */ {302, "655", "CA"}, /* Canada */ {302, "656", "CA"}, /* Canada */ {302, "657", "CA"}, /* Canada */ {302, "660", "CA"}, /* Canada */ {302, "670", "CA"}, /* Canada */ {302, "680", "CA"}, /* Canada */ {302, "690", "CA"}, /* Canada */ {302, "701", "CA"}, /* Canada */ {302, "702", "CA"}, /* Canada */ {302, "703", "CA"}, /* Canada */ {302, "710", "CA"}, /* Canada */ {302, "720", "CA"}, /* Canada */ {302, "730", "CA"}, /* Canada */ {302, "740", "CA"}, /* Canada */ {302, "750", "CA"}, /* Canada */ {302, "760", "CA"}, /* Canada */ {302, "770", "CA"}, /* Canada */ {302, "780", "CA"}, /* Canada */ {302, "790", "CA"}, /* Canada */ {302, "860", "CA"}, /* Canada */ {302, "880", "CA"}, /* Canada */ {302, "940", "CA"}, /* Canada */ {308, "01", "PM"}, /* Saint Pierre and Miquelon (France) */ {308, "02", "PM"}, /* Saint Pierre and Miquelon (France) */ {310, "004", "US"}, /* United States of America */ {310, "005", "US"}, /* United States of America */ {310, "010", "US"}, /* United States of America */ {310, "013", "US"}, /* United States of America */ {310, "014", "US"}, /* United States of America */ {310, "016", "US"}, /* United States of America */ {310, "017", "US"}, /* United States of America */ {310, "020", "US"}, /* United States of America */ {310, "026", "US"}, /* United States of America */ {310, "030", "US"}, /* United States of America */ {310, "032", "GU"}, /* Guam (United States of America) */ {310, "033", "GU"}, /* Guam (United States of America) */ {310, "034", "US"}, /* United States of America */ {310, "040", "US"}, /* United States of America */ {310, "046", "US"}, /* United States of America */ {310, "053", "US"}, /* United States of America */ {310, "054", "US"}, /* United States of America */ {310, "060", "US"}, /* United States of America */ {310, "066", "US"}, /* United States of America */ {310, "070", "US"}, /* United States of America */ {310, "080", "US"}, /* United States of America */ {310, "090", "US"}, /* United States of America */ {310, "100", "US"}, /* United States of America */ {310, "110", "US"}, /* United States of America */ {310, "120", "US"}, /* United States of America */ {310, "140", "GU"}, /* Guam (United States of America) */ {310, "150", "US"}, /* United States of America */ {310, "160", "US"}, /* United States of America */ {310, "170", "US"}, /* United States of America */ {310, "180", "US"}, /* United States of America */ {310, "190", "US"}, /* United States of America */ {310, "200", "US"}, /* United States of America */ {310, "210", "US"}, /* United States of America */ {310, "220", "US"}, /* United States of America */ {310, "230", "US"}, /* United States of America */ {310, "240", "US"}, /* United States of America */ {310, "250", "US"}, /* United States of America */ {310, "260", "US"}, /* United States of America */ {310, "270", "US"}, /* United States of America */ {310, "280", "US"}, /* United States of America */ {310, "290", "US"}, /* United States of America */ {310, "300", "US"}, /* United States of America */ {310, "310", "US"}, /* United States of America */ {310, "311", "US"}, /* United States of America */ {310, "320", "US"}, /* United States of America */ {310, "330", "US"}, /* United States of America */ {310, "340", "US"}, /* United States of America */ {310, "350", "US"}, /* United States of America */ {310, "370", "GU"}, /* Guam (United States of America) */ {310, "380", "US"}, /* United States of America */ {310, "390", "US"}, /* United States of America */ {310, "400", "US"}, /* United States of America */ {310, "410", "US"}, /* United States of America */ {310, "420", "US"}, /* United States of America */ {310, "430", "US"}, /* United States of America */ {310, "440", "US"}, /* United States of America */ {310, "450", "US"}, /* United States of America */ {310, "460", "US"}, /* United States of America */ {310, "470", "US"}, /* United States of America */ {310, "480", "US"}, /* United States of America */ {310, "490", "US"}, /* United States of America */ {310, "500", "US"}, /* United States of America */ {310, "510", "US"}, /* United States of America */ {310, "520", "US"}, /* United States of America */ {310, "530", "US"}, /* United States of America */ {310, "540", "US"}, /* United States of America */ {310, "560", "US"}, /* United States of America */ {310, "570", "US"}, /* United States of America */ {310, "580", "US"}, /* United States of America */ {310, "590", "US"}, /* United States of America */ {310, "59", "BM"}, /* Bermuda */ {310, "610", "US"}, /* United States of America */ {310, "620", "US"}, /* United States of America */ {310, "630", "US"}, /* United States of America */ {310, "640", "US"}, /* United States of America */ {310, "650", "US"}, /* United States of America */ {310, "660", "US"}, /* United States of America */ {310, "670", "US"}, /* United States of America */ {310, "680", "US"}, /* United States of America */ {310, "690", "US"}, /* United States of America */ {310, "730", "US"}, /* United States of America */ {310, "740", "US"}, /* United States of America */ {310, "750", "US"}, /* United States of America */ {310, "760", "US"}, /* United States of America */ {310, "770", "US"}, /* United States of America */ {310, "780", "US"}, /* United States of America */ {310, "790", "US"}, /* United States of America */ {310, "800", "US"}, /* United States of America */ {310, "830", "US"}, /* United States of America */ {310, "840", "US"}, /* United States of America */ {310, "850", "US"}, /* United States of America */ {310, "870", "US"}, /* United States of America */ {310, "880", "US"}, /* United States of America */ {310, "890", "US"}, /* United States of America */ {310, "900", "US"}, /* United States of America */ {310, "910", "US"}, /* United States of America */ {310, "940", "US"}, /* United States of America */ {310, "950", "US"}, /* United States of America */ {310, "960", "US"}, /* United States of America */ {310, "970", "US"}, /* United States of America */ {310, "980", "US"}, /* United States of America */ {310, "990", "US"}, /* United States of America */ {311, "000", "US"}, /* United States of America */ {311, "010", "US"}, /* United States of America */ {311, "012", "US"}, /* United States of America */ {311, "020", "US"}, /* United States of America */ {311, "030", "US"}, /* United States of America */ {311, "040", "US"}, /* United States of America */ {311, "050", "US"}, /* United States of America */ {311, "060", "US"}, /* United States of America */ {311, "070", "US"}, /* United States of America */ {311, "080", "US"}, /* United States of America */ {311, "090", "US"}, /* United States of America */ {311, "100", "US"}, /* United States of America */ {311, "110", "US"}, /* United States of America */ {311, "120", "US"}, /* United States of America */ {311, "130", "US"}, /* United States of America */ {311, "140", "US"}, /* United States of America */ {311, "150", "US"}, /* United States of America */ {311, "160", "US"}, /* United States of America */ {311, "170", "US"}, /* United States of America */ {311, "180", "US"}, /* United States of America */ {311, "190", "US"}, /* United States of America */ {311, "210", "US"}, /* United States of America */ {311, "220", "US"}, /* United States of America */ {311, "230", "US"}, /* United States of America */ {311, "250", "GU"}, /* Guam (United States of America) */ {311, "330", "US"}, /* United States of America */ {311, "480", "US"}, /* United States of America */ {311, "481", "US"}, /* United States of America */ {311, "490", "US"}, /* United States of America */ {311, "580", "US"}, /* United States of America */ {311, "660", "US"}, /* United States of America */ {311, "870", "US"}, /* United States of America */ {311, "960", "US"}, /* United States of America */ {311, "970", "US"}, /* United States of America */ {312, "590", "US"}, /* United States of America */ {313, "100", "US"}, /* United States of America */ {313, "101", "US"}, /* United States of America */ {316, "010", "US"}, /* United States of America */ {316, "011", "US"}, /* United States of America */ {330, "00", "PR"}, /* Puerto Rico */ {330, "110", "PR"}, /* Puerto Rico */ {330, "120", "PR"}, /* Puerto Rico */ {334, "001", "MX"}, /* Mexico */ {334, "010", "MX"}, /* Mexico */ {334, "020", "MX"}, /* Mexico */ {334, "030", "MX"}, /* Mexico */ {334, "040", "MX"}, /* Mexico */ {334, "050", "MX"}, /* Mexico */ {334, "060", "MX"}, /* Mexico */ {334, "066", "MX"}, /* Mexico */ {334, "070", "MX"}, /* Mexico */ {334, "080", "MX"}, /* Mexico */ {334, "090", "MX"}, /* Mexico */ {338, "020", "JM"}, /* Jamaica */ {338, "050", "BM"}, /* Bermuda */ {338, "050", "JM"}, /* Jamaica */ {338, "050", "TC"}, /* Turks and Caicos Islands */ {338, "110", "JM"}, /* Jamaica */ {338, "180", "JM"}, /* Jamaica */ {340, "01", "GP"}, /* Guadeloupe (France) */ {340, "01", "MQ"}, /* Martinique (France) */ {340, "02", "GP"}, /* Guadeloupe (France) */ {340, "02", "MQ"}, /* Martinique (France) */ {340, "03", "GP"}, /* Guadeloupe (France) */ {340, "08", "GP"}, /* Guadeloupe (France) */ {340, "10", "GP"}, /* Guadeloupe (France) */ {340, "11", "GF"}, /* French Guiana (France) */ {340, "12", "MQ"}, /* Martinique (France) */ {340, "20", "GP"}, /* Guadeloupe (France) */ {340, "20", "MQ"}, /* Martinique (France) */ {342, "600", "BB"}, /* Barbados */ {342, "750", "BB"}, /* Barbados */ {342, "820", "BB"}, /* Barbados */ {344, "030", "AG"}, /* Antigua and Barbuda */ {344, "050", "AG"}, /* Antigua and Barbuda */ {344, "920", "AG"}, /* Antigua and Barbuda */ {344, "930", "AG"}, /* Antigua and Barbuda */ {346, "050", "KY"}, /* Cayman Islands (United Kingdom) */ {346, "140", "KY"}, /* Cayman Islands (United Kingdom) */ {348, "170", "VG"}, /* British Virgin Islands (United Kingdom) */ {348, "370", "VG"}, /* British Virgin Islands (United Kingdom) */ {348, "570", "VG"}, /* British Virgin Islands (United Kingdom) */ {348, "770", "VG"}, /* British Virgin Islands (United Kingdom) */ {350, "00", "BM"}, /* Bermuda */ {350, "01", "BM"}, /* Bermuda */ {350, "02", "BM"}, /* Bermuda */ {352, "030", "GD"}, /* Grenada */ {352, "110", "GD"}, /* Grenada */ {354, "860", "MS"}, /* Montserrat (United Kingdom) */ {356, "050", "KN"}, /* Saint Kitts and Nevis */ {356, "070", "KN"}, /* Saint Kitts and Nevis */ {356, "110", "KN"}, /* Saint Kitts and Nevis */ {358, "050", "LC"}, /* Saint Lucia */ {358, "110", "LC"}, /* Saint Lucia */ {360, "070", "VC"}, /* Saint Vincent and the Grenadines */ {360, "100", "VC"}, /* Saint Vincent and the Grenadines */ {360, "110", "VC"}, /* Saint Vincent and the Grenadines */ {362, "51", "AN"}, /* Former Netherlands Antilles (Kingdom of the Netherlands) */ {362, "69", "AN"}, /* Former Netherlands Antilles (Kingdom of the Netherlands) */ {362, "91", "AN"}, /* Former Netherlands Antilles (Kingdom of the Netherlands) */ {362, "94", "AN"}, /* Former Netherlands Antilles (Kingdom of the Netherlands) */ {362, "95", "AN"}, /* Former Netherlands Antilles (Kingdom of the Netherlands) */ {363, "01", "AW"}, /* Aruba (Kingdom of the Netherlands) */ {363, "02", "AW"}, /* Aruba (Kingdom of the Netherlands) */ {364, "39", "BS"}, /* Bahamas */ {365, "010", "AI"}, /* Anguilla (United Kingdom) */ {365, "840", "AI"}, /* Anguilla (United Kingdom) */ {366, "020", "DM"}, /* Dominica */ {366, "110", "DM"}, /* Dominica */ {368, "01", "CU"}, /* Cuba */ {370, "01", "DO"}, /* Dominican Republic */ {370, "02", "DO"}, /* Dominican Republic */ {370, "03", "DO"}, /* Dominican Republic */ {370, "04", "DO"}, /* Dominican Republic */ {372, "01", "HT"}, /* Haiti */ {372, "02", "HT"}, /* Haiti */ {372, "03", "HT"}, /* Haiti */ {374, "12", "TT"}, /* Trinidad and Tobago */ {374, "130", "TT"}, /* Trinidad and Tobago */ {376, "350", "TC"}, /* Turks and Caicos Islands */ {376, "352", "TC"}, /* Turks and Caicos Islands */ {400, "01", "AZ"}, /* Azerbaijan */ {400, "02", "AZ"}, /* Azerbaijan */ {400, "03", "AZ"}, /* Azerbaijan */ {400, "04", "AZ"}, /* Azerbaijan */ {401, "01", "KZ"}, /* Kazakhstan */ {401, "02", "KZ"}, /* Kazakhstan */ {401, "07", "KZ"}, /* Kazakhstan */ {401, "08", "KZ"}, /* Kazakhstan */ {401, "77", "KZ"}, /* Kazakhstan */ {402, "11", "BT"}, /* Bhutan */ {402, "77", "BT"}, /* Bhutan */ {404, "01", "IN"}, /* India */ {404, "02", "IN"}, /* India */ {404, "03", "IN"}, /* India */ {404, "04", "IN"}, /* India */ {404, "05", "IN"}, /* India */ {404, "07", "IN"}, /* India */ {404, "09", "IN"}, /* India */ {404, "10", "IN"}, /* India */ {404, "11", "IN"}, /* India */ {404, "12", "IN"}, /* India */ {404, "13", "IN"}, /* India */ {404, "14", "IN"}, /* India */ {404, "15", "IN"}, /* India */ {404, "16", "IN"}, /* India */ {404, "17", "IN"}, /* India */ {404, "18", "IN"}, /* India */ {404, "19", "IN"}, /* India */ {404, "20", "IN"}, /* India */ {404, "21", "IN"}, /* India */ {404, "22", "IN"}, /* India */ {404, "24", "IN"}, /* India */ {404, "25", "IN"}, /* India */ {404, "27", "IN"}, /* India */ {404, "28", "IN"}, /* India */ {404, "29", "IN"}, /* India */ {404, "30", "IN"}, /* India */ {404, "31", "IN"}, /* India */ {404, "34", "IN"}, /* India */ {404, "36", "IN"}, /* India */ {404, "37", "IN"}, /* India */ {404, "38", "IN"}, /* India */ {404, "40", "IN"}, /* India */ {404, "41", "IN"}, /* India */ {404, "42", "IN"}, /* India */ {404, "43", "IN"}, /* India */ {404, "44", "IN"}, /* India */ {404, "45", "IN"}, /* India */ {404, "46", "IN"}, /* India */ {404, "48", "IN"}, /* India */ {404, "49", "IN"}, /* India */ {404, "50", "IN"}, /* India */ {404, "51", "IN"}, /* India */ {404, "52", "IN"}, /* India */ {404, "53", "IN"}, /* India */ {404, "54", "IN"}, /* India */ {404, "55", "IN"}, /* India */ {404, "56", "IN"}, /* India */ {404, "57", "IN"}, /* India */ {404, "58", "IN"}, /* India */ {404, "59", "IN"}, /* India */ {404, "60", "IN"}, /* India */ {404, "62", "IN"}, /* India */ {404, "64", "IN"}, /* India */ {404, "66", "IN"}, /* India */ {404, "67", "IN"}, /* India */ {404, "68", "IN"}, /* India */ {404, "69", "IN"}, /* India */ {404, "70", "IN"}, /* India */ {404, "71", "IN"}, /* India */ {404, "72", "IN"}, /* India */ {404, "73", "IN"}, /* India */ {404, "74", "IN"}, /* India */ {404, "75", "IN"}, /* India */ {404, "76", "IN"}, /* India */ {404, "77", "IN"}, /* India */ {404, "78", "IN"}, /* India */ {404, "79", "IN"}, /* India */ {404, "80", "IN"}, /* India */ {404, "81", "IN"}, /* India */ {404, "82", "IN"}, /* India */ {404, "83", "IN"}, /* India */ {404, "84", "IN"}, /* India */ {404, "85", "IN"}, /* India */ {404, "86", "IN"}, /* India */ {404, "87", "IN"}, /* India */ {404, "88", "IN"}, /* India */ {404, "89", "IN"}, /* India */ {404, "90", "IN"}, /* India */ {404, "91", "IN"}, /* India */ {404, "92", "IN"}, /* India */ {404, "93", "IN"}, /* India */ {404, "94", "IN"}, /* India */ {404, "95", "IN"}, /* India */ {404, "96", "IN"}, /* India */ {404, "97", "IN"}, /* India */ {404, "98", "IN"}, /* India */ {405, "01", "IN"}, /* India */ {405, "025", "IN"}, /* India */ {405, "026", "IN"}, /* India */ {405, "027", "IN"}, /* India */ {405, "028", "IN"}, /* India */ {405, "029", "IN"}, /* India */ {405, "030", "IN"}, /* India */ {405, "031", "IN"}, /* India */ {405, "032", "IN"}, /* India */ {405, "033", "IN"}, /* India */ {405, "034", "IN"}, /* India */ {405, "035", "IN"}, /* India */ {405, "036", "IN"}, /* India */ {405, "037", "IN"}, /* India */ {405, "038", "IN"}, /* India */ {405, "039", "IN"}, /* India */ {405, "03", "IN"}, /* India */ {405, "041", "IN"}, /* India */ {405, "042", "IN"}, /* India */ {405, "043", "IN"}, /* India */ {405, "044", "IN"}, /* India */ {405, "045", "IN"}, /* India */ {405, "046", "IN"}, /* India */ {405, "047", "IN"}, /* India */ {405, "04", "IN"}, /* India */ {405, "05", "IN"}, /* India */ {405, "06", "IN"}, /* India */ {405, "07", "IN"}, /* India */ {405, "08", "IN"}, /* India */ {405, "09", "IN"}, /* India */ {405, "10", "IN"}, /* India */ {405, "11", "IN"}, /* India */ {405, "12", "IN"}, /* India */ {405, "13", "IN"}, /* India */ {405, "14", "IN"}, /* India */ {405, "15", "IN"}, /* India */ {405, "17", "IN"}, /* India */ {405, "18", "IN"}, /* India */ {405, "19", "IN"}, /* India */ {405, "20", "IN"}, /* India */ {405, "21", "IN"}, /* India */ {405, "22", "IN"}, /* India */ {405, "23", "IN"}, /* India */ {405, "51", "IN"}, /* India */ {405, "52", "IN"}, /* India */ {405, "53", "IN"}, /* India */ {405, "54", "IN"}, /* India */ {405, "55", "IN"}, /* India */ {405, "56", "IN"}, /* India */ {405, "66", "IN"}, /* India */ {405, "67", "IN"}, /* India */ {405, "70", "IN"}, /* India */ {405, "750", "IN"}, /* India */ {405, "751", "IN"}, /* India */ {405, "752", "IN"}, /* India */ {405, "753", "IN"}, /* India */ {405, "754", "IN"}, /* India */ {405, "755", "IN"}, /* India */ {405, "756", "IN"}, /* India */ {405, "799", "IN"}, /* India */ {405, "800", "IN"}, /* India */ {405, "801", "IN"}, /* India */ {405, "802", "IN"}, /* India */ {405, "803", "IN"}, /* India */ {405, "804", "IN"}, /* India */ {405, "805", "IN"}, /* India */ {405, "806", "IN"}, /* India */ {405, "807", "IN"}, /* India */ {405, "808", "IN"}, /* India */ {405, "809", "IN"}, /* India */ {405, "810", "IN"}, /* India */ {405, "811", "IN"}, /* India */ {405, "812", "IN"}, /* India */ {405, "818", "IN"}, /* India */ {405, "819", "IN"}, /* India */ {405, "820", "IN"}, /* India */ {405, "821", "IN"}, /* India */ {405, "822", "IN"}, /* India */ {405, "824", "IN"}, /* India */ {405, "827", "IN"}, /* India */ {405, "834", "IN"}, /* India */ {405, "840", "IN"}, /* India */ {405, "844", "IN"}, /* India */ {405, "845", "IN"}, /* India */ {405, "846", "IN"}, /* India */ {405, "847", "IN"}, /* India */ {405, "848", "IN"}, /* India */ {405, "849", "IN"}, /* India */ {405, "850", "IN"}, /* India */ {405, "851", "IN"}, /* India */ {405, "852", "IN"}, /* India */ {405, "853", "IN"}, /* India */ {405, "854", "IN"}, /* India */ {405, "855", "IN"}, /* India */ {405, "856", "IN"}, /* India */ {405, "857", "IN"}, /* India */ {405, "858", "IN"}, /* India */ {405, "859", "IN"}, /* India */ {405, "860", "IN"}, /* India */ {405, "861", "IN"}, /* India */ {405, "862", "IN"}, /* India */ {405, "863", "IN"}, /* India */ {405, "864", "IN"}, /* India */ {405, "865", "IN"}, /* India */ {405, "866", "IN"}, /* India */ {405, "867", "IN"}, /* India */ {405, "868", "IN"}, /* India */ {405, "869", "IN"}, /* India */ {405, "870", "IN"}, /* India */ {405, "871", "IN"}, /* India */ {405, "872", "IN"}, /* India */ {405, "873", "IN"}, /* India */ {405, "874", "IN"}, /* India */ {405, "875", "IN"}, /* India */ {405, "880", "IN"}, /* India */ {405, "881", "IN"}, /* India */ {405, "908", "IN"}, /* India */ {405, "909", "IN"}, /* India */ {405, "910", "IN"}, /* India */ {405, "911", "IN"}, /* India */ {405, "912", "IN"}, /* India */ {405, "913", "IN"}, /* India */ {405, "914", "IN"}, /* India */ {405, "917", "IN"}, /* India */ {405, "927", "IN"}, /* India */ {405, "929", "IN"}, /* India */ {410, "01", "PK"}, /* Pakistan */ {410, "02", "PK"}, /* Pakistan */ {410, "03", "PK"}, /* Pakistan */ {410, "04", "PK"}, /* Pakistan */ {410, "05", "PK"}, /* Pakistan */ {410, "06", "PK"}, /* Pakistan */ {410, "07", "PK"}, /* Pakistan */ {412, "01", "AF"}, /* Afghanistan */ {412, "20", "AF"}, /* Afghanistan */ {412, "40", "AF"}, /* Afghanistan */ {412, "50", "AF"}, /* Afghanistan */ {412, "55", "AF"}, /* Afghanistan */ {412, "80", "AF"}, /* Afghanistan */ {412, "88", "AF"}, /* Afghanistan */ {413, "01", "LK"}, /* Sri Lanka */ {413, "02", "LK"}, /* Sri Lanka */ {413, "03", "LK"}, /* Sri Lanka */ {413, "05", "LK"}, /* Sri Lanka */ {413, "08", "LK"}, /* Sri Lanka */ {414, "01", "MM"}, /* Myanmar */ {414, "05", "MM"}, /* Myanmar */ {414, "06", "MM"}, /* Myanmar */ {415, "01", "LB"}, /* Lebanon */ {415, "03", "LB"}, /* Lebanon */ {415, "05", "LB"}, /* Lebanon */ {416, "01", "JO"}, /* Jordan */ {416, "02", "JO"}, /* Jordan */ {416, "03", "JO"}, /* Jordan */ {416, "77", "JO"}, /* Jordan */ {417, "01", "SY"}, /* Syria */ {417, "02", "SY"}, /* Syria */ {418, "05", "IQ"}, /* Iraq */ {418, "08", "IQ"}, /* Iraq */ {418, "20", "IQ"}, /* Iraq */ {418, "30", "IQ"}, /* Iraq */ {418, "40", "IQ"}, /* Iraq */ {418, "45", "IQ"}, /* Iraq */ {418, "62", "IQ"}, /* Iraq */ {418, "92", "IQ"}, /* Iraq */ {419, "02", "KW"}, /* Kuwait */ {419, "03", "KW"}, /* Kuwait */ {419, "04", "KW"}, /* Kuwait */ {420, "01", "SA"}, /* Saudi Arabia */ {420, "03", "SA"}, /* Saudi Arabia */ {420, "04", "SA"}, /* Saudi Arabia */ {420, "21", "SA"}, /* Saudi Arabia */ {421, "01", "YE"}, /* Yemen */ {421, "02", "YE"}, /* Yemen */ {421, "03", "YE"}, /* Yemen */ {421, "04", "YE"}, /* Yemen */ {422, "02", "OM"}, /* Oman */ {422, "03", "OM"}, /* Oman */ {422, "04", "OM"}, /* Oman */ {424, "02", "AE"}, /* United Arab Emirates */ {424, "03", "AE"}, /* United Arab Emirates */ {425, "01", "IL"}, /* Israel */ {425, "02", "IL"}, /* Israel */ {425, "03", "IL"}, /* Israel */ {425, "04", "IL"}, /* Israel */ {425, "05", "PW"}, /* Palau */ {425, "06", "PW"}, /* Palau */ {425, "07", "IL"}, /* Israel */ {425, "08", "IL"}, /* Israel */ {425, "11", "IL"}, /* Israel */ {425, "12", "IL"}, /* Israel */ {425, "13", "IL"}, /* Israel */ {425, "14", "IL"}, /* Israel */ {425, "15", "IL"}, /* Israel */ {425, "16", "IL"}, /* Israel */ {425, "17", "IL"}, /* Israel */ {425, "18", "IL"}, /* Israel */ {425, "19", "IL"}, /* Israel */ {425, "20", "IL"}, /* Israel */ {425, "21", "IL"}, /* Israel */ {426, "01", "BH"}, /* Bahrain */ {426, "02", "BH"}, /* Bahrain */ {426, "03", "BH"}, /* Bahrain */ {426, "04", "BH"}, /* Bahrain */ {426, "05", "BH"}, /* Bahrain */ {427, "01", "QA"}, /* Qatar */ {427, "02", "QA"}, /* Qatar */ {427, "05", "QA"}, /* Qatar */ {427, "06", "QA"}, /* Qatar */ {428, "88", "MN"}, /* Mongolia */ {428, "91", "MN"}, /* Mongolia */ {428, "98", "MN"}, /* Mongolia */ {428, "99", "MN"}, /* Mongolia */ {429, "01", "NP"}, /* Nepal */ {429, "02", "NP"}, /* Nepal */ {429, "03", "NP"}, /* Nepal */ {429, "04", "NP"}, /* Nepal */ {432, "11", "IR"}, /* Iran */ {432, "14", "IR"}, /* Iran */ {432, "19", "IR"}, /* Iran */ {432, "20", "IR"}, /* Iran */ {432, "32", "IR"}, /* Iran */ {432, "35", "IR"}, /* Iran */ {432, "70", "IR"}, /* Iran */ {432, "93", "IR"}, /* Iran */ {434, "01", "UZ"}, /* Uzbekistan */ {434, "02", "UZ"}, /* Uzbekistan */ {434, "03", "UZ"}, /* Uzbekistan */ {434, "04", "UZ"}, /* Uzbekistan */ {434, "05", "UZ"}, /* Uzbekistan */ {434, "06", "UZ"}, /* Uzbekistan */ {434, "07", "UZ"}, /* Uzbekistan */ {436, "01", "TJ"}, /* Tajikistan */ {436, "02", "TJ"}, /* Tajikistan */ {436, "03", "TJ"}, /* Tajikistan */ {436, "04", "TJ"}, /* Tajikistan */ {436, "05", "TJ"}, /* Tajikistan */ {436, "12", "TJ"}, /* Tajikistan */ {437, "01", "KG"}, /* Kyrgyzstan */ {437, "03", "KG"}, /* Kyrgyzstan */ {437, "05", "KG"}, /* Kyrgyzstan */ {437, "09", "KG"}, /* Kyrgyzstan */ {438, "01", "TM"}, /* Turkmenistan */ {438, "02", "TM"}, /* Turkmenistan */ {440, "00", "JP"}, /* Japan */ {440, "01", "JP"}, /* Japan */ {440, "02", "JP"}, /* Japan */ {440, "03", "JP"}, /* Japan */ {440, "04", "JP"}, /* Japan */ {440, "06", "JP"}, /* Japan */ {440, "07", "JP"}, /* Japan */ {440, "08", "JP"}, /* Japan */ {440, "09", "JP"}, /* Japan */ {440, "10", "JP"}, /* Japan */ {440, "11", "JP"}, /* Japan */ {440, "12", "JP"}, /* Japan */ {440, "13", "JP"}, /* Japan */ {440, "14", "JP"}, /* Japan */ {440, "15", "JP"}, /* Japan */ {440, "16", "JP"}, /* Japan */ {440, "17", "JP"}, /* Japan */ {440, "18", "JP"}, /* Japan */ {440, "19", "JP"}, /* Japan */ {440, "20", "JP"}, /* Japan */ {440, "21", "JP"}, /* Japan */ {440, "22", "JP"}, /* Japan */ {440, "23", "JP"}, /* Japan */ {440, "24", "JP"}, /* Japan */ {440, "25", "JP"}, /* Japan */ {440, "26", "JP"}, /* Japan */ {440, "27", "JP"}, /* Japan */ {440, "28", "JP"}, /* Japan */ {440, "29", "JP"}, /* Japan */ {440, "30", "JP"}, /* Japan */ {440, "31", "JP"}, /* Japan */ {440, "32", "JP"}, /* Japan */ {440, "33", "JP"}, /* Japan */ {440, "34", "JP"}, /* Japan */ {440, "35", "JP"}, /* Japan */ {440, "36", "JP"}, /* Japan */ {440, "37", "JP"}, /* Japan */ {440, "38", "JP"}, /* Japan */ {440, "39", "JP"}, /* Japan */ {440, "40", "JP"}, /* Japan */ {440, "41", "JP"}, /* Japan */ {440, "42", "JP"}, /* Japan */ {440, "43", "JP"}, /* Japan */ {440, "44", "JP"}, /* Japan */ {440, "45", "JP"}, /* Japan */ {440, "46", "JP"}, /* Japan */ {440, "47", "JP"}, /* Japan */ {440, "48", "JP"}, /* Japan */ {440, "49", "JP"}, /* Japan */ {440, "50", "JP"}, /* Japan */ {440, "51", "JP"}, /* Japan */ {440, "52", "JP"}, /* Japan */ {440, "53", "JP"}, /* Japan */ {440, "54", "JP"}, /* Japan */ {440, "55", "JP"}, /* Japan */ {440, "56", "JP"}, /* Japan */ {440, "58", "JP"}, /* Japan */ {440, "60", "JP"}, /* Japan */ {440, "61", "JP"}, /* Japan */ {440, "62", "JP"}, /* Japan */ {440, "63", "JP"}, /* Japan */ {440, "64", "JP"}, /* Japan */ {440, "65", "JP"}, /* Japan */ {440, "66", "JP"}, /* Japan */ {440, "67", "JP"}, /* Japan */ {440, "68", "JP"}, /* Japan */ {440, "69", "JP"}, /* Japan */ {440, "70", "JP"}, /* Japan */ {440, "71", "JP"}, /* Japan */ {440, "72", "JP"}, /* Japan */ {440, "73", "JP"}, /* Japan */ {440, "74", "JP"}, /* Japan */ {440, "75", "JP"}, /* Japan */ {440, "76", "JP"}, /* Japan */ {440, "77", "JP"}, /* Japan */ {440, "78", "JP"}, /* Japan */ {440, "79", "JP"}, /* Japan */ {440, "80", "JP"}, /* Japan */ {440, "81", "JP"}, /* Japan */ {440, "82", "JP"}, /* Japan */ {440, "83", "JP"}, /* Japan */ {440, "84", "JP"}, /* Japan */ {440, "85", "JP"}, /* Japan */ {440, "86", "JP"}, /* Japan */ {440, "87", "JP"}, /* Japan */ {440, "88", "JP"}, /* Japan */ {440, "89", "JP"}, /* Japan */ {440, "90", "JP"}, /* Japan */ {440, "92", "JP"}, /* Japan */ {440, "93", "JP"}, /* Japan */ {440, "94", "JP"}, /* Japan */ {440, "95", "JP"}, /* Japan */ {440, "96", "JP"}, /* Japan */ {440, "97", "JP"}, /* Japan */ {440, "98", "JP"}, /* Japan */ {440, "99", "JP"}, /* Japan */ {450, "02", "KR"}, /* South Korea */ {450, "03", "KR"}, /* South Korea */ {450, "04", "KR"}, /* South Korea */ {450, "05", "KR"}, /* South Korea */ {450, "06", "KR"}, /* South Korea */ {450, "08", "KR"}, /* South Korea */ {450, "11", "KR"}, /* South Korea */ {452, "01", "VN"}, /* Vietnam */ {452, "02", "VN"}, /* Vietnam */ {452, "03", "VN"}, /* Vietnam */ {452, "04", "VN"}, /* Vietnam */ {452, "05", "VN"}, /* Vietnam */ {452, "06", "VN"}, /* Vietnam */ {452, "07", "VN"}, /* Vietnam */ {452, "08", "VN"}, /* Vietnam */ {454, "00", "HK"}, /* Hong Kong */ {454, "01", "HK"}, /* Hong Kong */ {454, "02", "HK"}, /* Hong Kong */ {454, "03", "HK"}, /* Hong Kong */ {454, "04", "HK"}, /* Hong Kong */ {454, "05", "HK"}, /* Hong Kong */ {454, "06", "HK"}, /* Hong Kong */ {454, "07", "HK"}, /* Hong Kong */ {454, "08", "HK"}, /* Hong Kong */ {454, "09", "HK"}, /* Hong Kong */ {454, "10", "HK"}, /* Hong Kong */ {454, "11", "HK"}, /* Hong Kong */ {454, "12", "HK"}, /* Hong Kong */ {454, "13", "HK"}, /* Hong Kong */ {454, "14", "HK"}, /* Hong Kong */ {454, "15", "HK"}, /* Hong Kong */ {454, "16", "HK"}, /* Hong Kong */ {454, "17", "HK"}, /* Hong Kong */ {454, "18", "HK"}, /* Hong Kong */ {454, "19", "HK"}, /* Hong Kong */ {454, "22", "HK"}, /* Hong Kong */ {454, "29", "HK"}, /* Hong Kong */ {455, "00", "MO"}, /* Macau (People's Republic of China) */ {455, "01", "MO"}, /* Macau (People's Republic of China) */ {455, "02", "MO"}, /* Macau (People's Republic of China) */ {455, "03", "MO"}, /* Macau (People's Republic of China) */ {455, "04", "MO"}, /* Macau (People's Republic of China) */ {455, "05", "MO"}, /* Macau (People's Republic of China) */ {455, "06", "MO"}, /* Macau (People's Republic of China) */ {456, "01", "KH"}, /* Cambodia */ {456, "02", "KH"}, /* Cambodia */ {456, "03", "KH"}, /* Cambodia */ {456, "04", "KH"}, /* Cambodia */ {456, "05", "KH"}, /* Cambodia */ {456, "06", "KH"}, /* Cambodia */ {456, "08", "KH"}, /* Cambodia */ {456, "09", "KH"}, /* Cambodia */ {456, "11", "KH"}, /* Cambodia */ {456, "18", "KH"}, /* Cambodia */ {457, "01", "LA"}, /* Laos */ {457, "02", "LA"}, /* Laos */ {457, "03", "LA"}, /* Laos */ {457, "08", "LA"}, /* Laos */ {460, "00", "CN"}, /* China */ {460, "01", "CN"}, /* China */ {460, "02", "CN"}, /* China */ {460, "03", "CN"}, /* China */ {460, "04", "CN"}, /* China */ {460, "05", "CN"}, /* China */ {460, "06", "CN"}, /* China */ {460, "07", "CN"}, /* China */ {460, "20", "CN"}, /* China */ {466, "01", "TW"}, /* Taiwan */ {466, "05", "TW"}, /* Taiwan */ {466, "06", "TW"}, /* Taiwan */ {466, "11", "TW"}, /* Taiwan */ {466, "88", "TW"}, /* Taiwan */ {466, "89", "TW"}, /* Taiwan */ {466, "92", "TW"}, /* Taiwan */ {466, "93", "TW"}, /* Taiwan */ {466, "97", "TW"}, /* Taiwan */ {466, "99", "TW"}, /* Taiwan */ {467, "05", "KP"}, /* North Korea */ {467, "193", "KP"}, /* North Korea */ {470, "01", "BD"}, /* Bangladesh */ {470, "02", "BD"}, /* Bangladesh */ {470, "03", "BD"}, /* Bangladesh */ {470, "04", "BD"}, /* Bangladesh */ {470, "05", "BD"}, /* Bangladesh */ {470, "06", "BD"}, /* Bangladesh */ {470, "07", "BD"}, /* Bangladesh */ {472, "01", "MV"}, /* Maldives */ {472, "02", "MV"}, /* Maldives */ {502, "01", "MY"}, /* Malaysia */ {502, "10", "MY"}, /* Malaysia */ {502, "11", "MY"}, /* Malaysia */ {502, "12", "MY"}, /* Malaysia */ {502, "13", "MY"}, /* Malaysia */ {502, "14", "MY"}, /* Malaysia */ {502, "150", "MY"}, /* Malaysia */ {502, "151", "MY"}, /* Malaysia */ {502, "152", "MY"}, /* Malaysia */ {502, "156", "MY"}, /* Malaysia */ {502, "16", "MY"}, /* Malaysia */ {502, "17", "MY"}, /* Malaysia */ {502, "18", "MY"}, /* Malaysia */ {502, "19", "MY"}, /* Malaysia */ {502, "20", "MY"}, /* Malaysia */ {505, "01", "AU"}, /* Australia */ {505, "02", "AU"}, /* Australia */ {505, "03", "AU"}, /* Australia */ {505, "04", "AU"}, /* Australia */ {505, "05", "AU"}, /* Australia */ {505, "06", "AU"}, /* Australia */ {505, "07", "AU"}, /* Australia */ {505, "08", "AU"}, /* Australia */ {505, "09", "AU"}, /* Australia */ {505, "10", "AU"}, /* Australia */ {505, "10", "NF"}, /* Norfolk Island */ {505, "11", "AU"}, /* Australia */ {505, "12", "AU"}, /* Australia */ {505, "13", "AU"}, /* Australia */ {505, "14", "AU"}, /* Australia */ {505, "15", "AU"}, /* Australia */ {505, "16", "AU"}, /* Australia */ {505, "17", "AU"}, /* Australia */ {505, "18", "AU"}, /* Australia */ {505, "19", "AU"}, /* Australia */ {505, "20", "AU"}, /* Australia */ {505, "21", "AU"}, /* Australia */ {505, "22", "AU"}, /* Australia */ {505, "23", "AU"}, /* Australia */ {505, "24", "AU"}, /* Australia */ {505, "25", "AU"}, /* Australia */ {505, "26", "AU"}, /* Australia */ {505, "27", "AU"}, /* Australia */ {505, "28", "AU"}, /* Australia */ {505, "30", "AU"}, /* Australia */ {505, "31", "AU"}, /* Australia */ {505, "38", "AU"}, /* Australia */ {505, "62", "AU"}, /* Australia */ {505, "68", "AU"}, /* Australia */ {505, "71", "AU"}, /* Australia */ {505, "72", "AU"}, /* Australia */ {505, "88", "AU"}, /* Australia */ {505, "90", "AU"}, /* Australia */ {505, "99", "AU"}, /* Australia */ {510, "00", "ID"}, /* Indonesia */ {510, "01", "ID"}, /* Indonesia */ {510, "03", "ID"}, /* Indonesia */ {510, "07", "ID"}, /* Indonesia */ {510, "08", "ID"}, /* Indonesia */ {510, "09", "ID"}, /* Indonesia */ {510, "10", "ID"}, /* Indonesia */ {510, "11", "ID"}, /* Indonesia */ {510, "20", "ID"}, /* Indonesia */ {510, "21", "ID"}, /* Indonesia */ {510, "27", "ID"}, /* Indonesia */ {510, "28", "ID"}, /* Indonesia */ {510, "89", "ID"}, /* Indonesia */ {510, "995", "ID"}, /* Indonesia */ {510, "996", "ID"}, /* Indonesia */ {510, "99", "ID"}, /* Indonesia */ {514, "01", "TL"}, /* East Timor */ {514, "02", "TL"}, /* East Timor */ {514, "03", "TL"}, /* East Timor */ {515, "01", "PH"}, /* Philippines */ {515, "02", "PH"}, /* Philippines */ {515, "03", "PH"}, /* Philippines */ {515, "05", "PH"}, /* Philippines */ {515, "11", "PH"}, /* Philippines */ {515, "18", "PH"}, /* Philippines */ {515, "24", "PH"}, /* Philippines */ {515, "88", "PH"}, /* Philippines */ {520, "00", "TH"}, /* Thailand */ {520, "01", "TH"}, /* Thailand */ {520, "02", "TH"}, /* Thailand */ {520, "03", "TH"}, /* Thailand */ {520, "04", "TH"}, /* Thailand */ {520, "05", "TH"}, /* Thailand */ {520, "15", "TH"}, /* Thailand */ {520, "18", "TH"}, /* Thailand */ {520, "23", "TH"}, /* Thailand */ {520, "25", "TH"}, /* Thailand */ {520, "47", "TH"}, /* Thailand */ {520, "99", "TH"}, /* Thailand */ {525, "01", "SG"}, /* Singapore */ {525, "02", "SG"}, /* Singapore */ {525, "03", "SG"}, /* Singapore */ {525, "05", "SG"}, /* Singapore */ {525, "06", "SG"}, /* Singapore */ {525, "07", "SG"}, /* Singapore */ {525, "12", "SG"}, /* Singapore */ {528, "01", "BN"}, /* Brunei */ {528, "02", "BN"}, /* Brunei */ {528, "11", "BN"}, /* Brunei */ {530, "00", "NZ"}, /* New Zealand */ {530, "01", "NZ"}, /* New Zealand */ {530, "02", "NZ"}, /* New Zealand */ {530, "03", "NZ"}, /* New Zealand */ {530, "04", "NZ"}, /* New Zealand */ {530, "05", "NZ"}, /* New Zealand */ {530, "06", "NZ"}, /* New Zealand */ {530, "07", "NZ"}, /* New Zealand */ {530, "24", "NZ"}, /* New Zealand */ {536, "02", "NR"}, /* Nauru */ {537, "01", "PG"}, /* Papua New Guinea */ {537, "02", "PG"}, /* Papua New Guinea */ {537, "03", "PG"}, /* Papua New Guinea */ {539, "01", "TO"}, /* Tonga */ {539, "43", "TO"}, /* Tonga */ {539, "88", "TO"}, /* Tonga */ {540, "01", "SB"}, /* Solomon Islands */ {540, "02", "SB"}, /* Solomon Islands */ {541, "00", "VU"}, /* Vanuatu */ {541, "01", "VU"}, /* Vanuatu */ {541, "05", "VU"}, /* Vanuatu */ {541, "07", "VU"}, /* Vanuatu */ {542, "01", "FJ"}, /* Fiji */ {542, "02", "FJ"}, /* Fiji */ {542, "03", "FJ"}, /* Fiji */ {544, "11", "AS"}, /* American Samoa (United States of America) */ {545, "01", "KI"}, /* Kiribati */ {545, "09", "KI"}, /* Kiribati */ {546, "01", "NC"}, /* New Caledonia (France) */ {547, "10", "PF"}, /* French Polynesia (France) */ {547, "15", "PF"}, /* French Polynesia (France) */ {547, "20", "PF"}, /* French Polynesia (France) */ {548, "01", "CK"}, /* Cook Islands (New Zealand) */ {549, "01", "WS"}, /* Samoa */ {549, "27", "WS"}, /* Samoa */ {550, "01", "FM"}, /* Federated States of Micronesia */ {551, "01", "MH"}, /* Marshall Islands */ {552, "01", "PW"}, /* Palau */ {552, "80", "PW"}, /* Palau */ {553, "01", "TV"}, /* Tuvalu */ {555, "01", "NU"}, /* Niue */ {602, "01", "EG"}, /* Egypt */ {602, "02", "EG"}, /* Egypt */ {602, "03", "EG"}, /* Egypt */ {603, "01", "DZ"}, /* Algeria */ {603, "02", "DZ"}, /* Algeria */ {603, "03", "DZ"}, /* Algeria */ {604, "00", "MA"}, /* Morocco */ {604, "01", "MA"}, /* Morocco */ {604, "02", "MA"}, /* Morocco */ {604, "05", "MA"}, /* Morocco */ {605, "01", "TN"}, /* Tunisia */ {605, "02", "TN"}, /* Tunisia */ {605, "03", "TN"}, /* Tunisia */ {606, "00", "LY"}, /* Libya */ {606, "01", "LY"}, /* Libya */ {606, "02", "LY"}, /* Libya */ {606, "03", "LY"}, /* Libya */ {606, "06", "LY"}, /* Libya */ {607, "01", "GM"}, /* Gambia */ {607, "02", "GM"}, /* Gambia */ {607, "03", "GM"}, /* Gambia */ {607, "04", "GM"}, /* Gambia */ {608, "01", "SN"}, /* Senegal */ {608, "02", "SN"}, /* Senegal */ {608, "03", "SN"}, /* Senegal */ {608, "04", "SN"}, /* Senegal */ {609, "01", "MR"}, /* Mauritania */ {609, "02", "MR"}, /* Mauritania */ {609, "10", "MR"}, /* Mauritania */ {610, "01", "ML"}, /* Mali */ {610, "02", "ML"}, /* Mali */ {611, "01", "GN"}, /* Guinea */ {611, "02", "GN"}, /* Guinea */ {611, "03", "GN"}, /* Guinea */ {611, "04", "GN"}, /* Guinea */ {611, "05", "GN"}, /* Guinea */ {612, "01", "CI"}, /* Ivory Coast */ {612, "02", "CI"}, /* Ivory Coast */ {612, "03", "CI"}, /* Ivory Coast */ {612, "04", "CI"}, /* Ivory Coast */ {612, "05", "CI"}, /* Ivory Coast */ {612, "06", "CI"}, /* Ivory Coast */ {612, "07", "CI"}, /* Ivory Coast */ {613, "01", "BF"}, /* Burkina Faso */ {613, "02", "BF"}, /* Burkina Faso */ {613, "03", "BF"}, /* Burkina Faso */ {614, "01", "NE"}, /* Niger */ {614, "02", "NE"}, /* Niger */ {614, "03", "NE"}, /* Niger */ {614, "04", "NE"}, /* Niger */ {615, "01", "TG"}, /* Togo */ {615, "03", "TG"}, /* Togo */ {616, "01", "BJ"}, /* Benin */ {616, "02", "BJ"}, /* Benin */ {616, "03", "BJ"}, /* Benin */ {616, "04", "BJ"}, /* Benin */ {616, "05", "BJ"}, /* Benin */ {617, "01", "MU"}, /* Mauritius */ {617, "02", "MU"}, /* Mauritius */ {617, "03", "MU"}, /* Mauritius */ {617, "10", "MU"}, /* Mauritius */ {618, "01", "LR"}, /* Liberia */ {618, "02", "LR"}, /* Liberia */ {618, "04", "LR"}, /* Liberia */ {618, "07", "LR"}, /* Liberia */ {618, "20", "LR"}, /* Liberia */ {619, "01", "SL"}, /* Sierra Leone */ {619, "03", "SL"}, /* Sierra Leone */ {619, "04", "SL"}, /* Sierra Leone */ {619, "05", "SL"}, /* Sierra Leone */ {619, "06", "SL"}, /* Sierra Leone */ {619, "25", "SL"}, /* Sierra Leone */ {620, "01", "GH"}, /* Ghana */ {620, "02", "GH"}, /* Ghana */ {620, "03", "GH"}, /* Ghana */ {620, "04", "GH"}, /* Ghana */ {620, "06", "GH"}, /* Ghana */ {620, "07", "GH"}, /* Ghana */ {620, "11", "GH"}, /* Ghana */ {621, "20", "NG"}, /* Nigeria */ {621, "25", "NG"}, /* Nigeria */ {621, "30", "NG"}, /* Nigeria */ {621, "40", "NG"}, /* Nigeria */ {621, "50", "NG"}, /* Nigeria */ {621, "60", "NG"}, /* Nigeria */ {622, "01", "TD"}, /* Chad */ {622, "02", "TD"}, /* Chad */ {622, "03", "TD"}, /* Chad */ {622, "07", "TD"}, /* Chad */ {623, "01", "CF"}, /* Central African Republic */ {623, "02", "CF"}, /* Central African Republic */ {623, "03", "CF"}, /* Central African Republic */ {623, "04", "CF"}, /* Central African Republic */ {624, "01", "CM"}, /* Cameroon */ {624, "02", "CM"}, /* Cameroon */ {625, "01", "CV"}, /* Cape Verde */ {625, "02", "CV"}, /* Cape Verde */ {626, "01", "ST"}, /* Sao Tome and Principe */ {627, "01", "GQ"}, /* Equatorial Guinea */ {627, "03", "GQ"}, /* Equatorial Guinea */ {628, "01", "GA"}, /* Gabon */ {628, "02", "GA"}, /* Gabon */ {628, "03", "GA"}, /* Gabon */ {628, "04", "GA"}, /* Gabon */ {628, "05", "GA"}, /* Gabon */ {629, "01", "CG"}, /* Republic of the Congo */ {629, "07", "CG"}, /* Republic of the Congo */ {629, "10", "CG"}, /* Republic of the Congo */ {630, "01", "CD"}, /* Democratic Republic of the Congo */ {630, "02", "CD"}, /* Democratic Republic of the Congo */ {630, "04", "CD"}, /* Democratic Republic of the Congo */ {630, "05", "CD"}, /* Democratic Republic of the Congo */ {630, "10", "CD"}, /* Democratic Republic of the Congo */ {630, "86", "CD"}, /* Democratic Republic of the Congo */ {630, "88", "CD"}, /* Democratic Republic of the Congo */ {630, "89", "CD"}, /* Democratic Republic of the Congo */ {630, "90", "CD"}, /* Democratic Republic of the Congo */ {631, "02", "AO"}, /* Angola */ {631, "04", "AO"}, /* Angola */ {632, "01", "GW"}, /* Guinea-Bissau */ {632, "02", "GW"}, /* Guinea-Bissau */ {632, "03", "GW"}, /* Guinea-Bissau */ {632, "07", "GW"}, /* Guinea-Bissau */ {633, "01", "SC"}, /* Seychelles */ {633, "02", "SC"}, /* Seychelles */ {633, "10", "SC"}, /* Seychelles */ {634, "01", "SD"}, /* Sudan */ {634, "02", "SD"}, /* Sudan */ {634, "05", "SD"}, /* Sudan */ {634, "07", "SD"}, /* Sudan */ {634, "09", "SD"}, /* Sudan */ {635, "10", "RW"}, /* Rwanda */ {635, "13", "RW"}, /* Rwanda */ {635, "14", "RW"}, /* Rwanda */ {635, "17", "RW"}, /* Rwanda */ {636, "01", "ET"}, /* Ethiopia */ {637, "01", "SO"}, /* Somalia */ {637, "04", "SO"}, /* Somalia */ {637, "10", "SO"}, /* Somalia */ {637, "30", "SO"}, /* Somalia */ {637, "50", "SO"}, /* Somalia */ {637, "57", "SO"}, /* Somalia */ {637, "60", "SO"}, /* Somalia */ {637, "70", "SO"}, /* Somalia */ {637, "71", "SO"}, /* Somalia */ {637, "82", "SO"}, /* Somalia */ {638, "01", "DJ"}, /* Djibouti */ {639, "02", "KE"}, /* Kenya */ {639, "03", "KE"}, /* Kenya */ {639, "05", "KE"}, /* Kenya */ {639, "07", "KE"}, /* Kenya */ {640, "02", "TZ"}, /* Tanzania */ {640, "03", "TZ"}, /* Tanzania */ {640, "04", "TZ"}, /* Tanzania */ {640, "05", "TZ"}, /* Tanzania */ {640, "06", "TZ"}, /* Tanzania */ {640, "07", "TZ"}, /* Tanzania */ {640, "08", "TZ"}, /* Tanzania */ {640, "11", "TZ"}, /* Tanzania */ {641, "01", "UG"}, /* Uganda */ {641, "10", "UG"}, /* Uganda */ {641, "11", "UG"}, /* Uganda */ {641, "14", "UG"}, /* Uganda */ {641, "22", "UG"}, /* Uganda */ {641, "33", "UG"}, /* Uganda */ {641, "44", "UG"}, /* Uganda */ {641, "66", "UG"}, /* Uganda */ {642, "01", "BI"}, /* Burundi */ {642, "02", "BI"}, /* Burundi */ {642, "03", "BI"}, /* Burundi */ {642, "07", "BI"}, /* Burundi */ {642, "08", "BI"}, /* Burundi */ {642, "82", "BI"}, /* Burundi */ {643, "01", "MZ"}, /* Mozambique */ {643, "03", "MZ"}, /* Mozambique */ {643, "04", "MZ"}, /* Mozambique */ {645, "01", "ZM"}, /* Zambia */ {645, "02", "ZM"}, /* Zambia */ {645, "03", "ZM"}, /* Zambia */ {646, "01", "MG"}, /* Madagascar */ {646, "02", "MG"}, /* Madagascar */ {646, "03", "MG"}, /* Madagascar */ {646, "04", "MG"}, /* Madagascar */ {647, "00", "RE"}, /* Réunion (France) */ {647, "01", "RE"}, /* Réunion (France) */ {647, "02", "RE"}, /* Réunion (France) */ {647, "10", "RE"}, /* Réunion (France) */ {648, "01", "ZW"}, /* Zimbabwe */ {648, "03", "ZW"}, /* Zimbabwe */ {648, "04", "ZW"}, /* Zimbabwe */ {649, "01", "NA"}, /* Namibia */ {649, "02", "NA"}, /* Namibia */ {649, "03", "NA"}, /* Namibia */ {650, "01", "MW"}, /* Malawi */ {650, "10", "MW"}, /* Malawi */ {651, "01", "LS"}, /* Lesotho */ {651, "02", "LS"}, /* Lesotho */ {652, "01", "BW"}, /* Botswana */ {652, "02", "BW"}, /* Botswana */ {652, "04", "BW"}, /* Botswana */ {653, "10", "SZ"}, /* Swaziland */ {654, "01", "KM"}, /* Comoros */ {655, "01", "ZA"}, /* South Africa */ {655, "02", "ZA"}, /* South Africa */ {655, "06", "ZA"}, /* South Africa */ {655, "07", "ZA"}, /* South Africa */ {655, "10", "ZA"}, /* South Africa */ {655, "11", "ZA"}, /* South Africa */ {655, "13", "ZA"}, /* South Africa */ {655, "14", "ZA"}, /* South Africa */ {655, "19", "ZA"}, /* South Africa */ {655, "21", "ZA"}, /* South Africa */ {655, "30", "ZA"}, /* South Africa */ {655, "31", "ZA"}, /* South Africa */ {655, "32", "ZA"}, /* South Africa */ {655, "33", "ZA"}, /* South Africa */ {655, "50", "ZA"}, /* South Africa */ {655, "51", "ZA"}, /* South Africa */ {657, "01", "ER"}, /* Eritrea */ {659, "02", "SS"}, /* South Sudan */ {659, "03", "SS"}, /* South Sudan */ {659, "04", "SS"}, /* South Sudan */ {659, "06", "SS"}, /* South Sudan */ {659, "07", "SS"}, /* South Sudan */ {702, "67", "BZ"}, /* Belize */ {702, "68", "BZ"}, /* Belize */ {702, "99", "BZ"}, /* Belize */ {704, "01", "GT"}, /* Guatemala */ {704, "02", "GT"}, /* Guatemala */ {704, "03", "GT"}, /* Guatemala */ {706, "01", "SV"}, /* El Salvador */ {706, "02", "SV"}, /* El Salvador */ {706, "03", "SV"}, /* El Salvador */ {706, "04", "SV"}, /* El Salvador */ {708, "001", "HN"}, /* Honduras */ {708, "002", "HN"}, /* Honduras */ {708, "030", "HN"}, /* Honduras */ {708, "040", "HN"}, /* Honduras */ {710, "21", "NI"}, /* Nicaragua */ {710, "30", "NI"}, /* Nicaragua */ {710, "73", "NI"}, /* Nicaragua */ {712, "01", "CR"}, /* Costa Rica */ {712, "02", "CR"}, /* Costa Rica */ {712, "03", "CR"}, /* Costa Rica */ {712, "04", "CR"}, /* Costa Rica */ {712, "20", "CR"}, /* Costa Rica */ {714, "01", "PA"}, /* Panama */ {714, "02", "PA"}, /* Panama */ {714, "03", "PA"}, /* Panama */ {714, "04", "PA"}, /* Panama */ {716, "06", "PE"}, /* Peru */ {716, "07", "PE"}, /* Peru */ {716, "10", "PE"}, /* Peru */ {716, "15", "PE"}, /* Peru */ {716, "17", "PE"}, /* Peru */ {722, "010", "AR"}, /* Argentina */ {722, "020", "AR"}, /* Argentina */ {722, "040", "AR"}, /* Argentina */ {722, "070", "AR"}, /* Argentina */ {722, "310", "AR"}, /* Argentina */ {722, "320", "AR"}, /* Argentina */ {722, "330", "AR"}, /* Argentina */ {722, "340", "AR"}, /* Argentina */ {722, "350", "AR"}, /* Argentina */ {724, "00", "BR"}, /* Brazil */ {724, "01", "BR"}, /* Brazil */ {724, "02", "BR"}, /* Brazil */ {724, "03", "BR"}, /* Brazil */ {724, "04", "BR"}, /* Brazil */ {724, "05", "BR"}, /* Brazil */ {724, "06", "BR"}, /* Brazil */ {724, "10", "BR"}, /* Brazil */ {724, "11", "BR"}, /* Brazil */ {724, "15", "BR"}, /* Brazil */ {724, "16", "BR"}, /* Brazil */ {724, "18", "BR"}, /* Brazil */ {724, "23", "BR"}, /* Brazil */ {724, "24", "BR"}, /* Brazil */ {724, "30", "BR"}, /* Brazil */ {724, "31", "BR"}, /* Brazil */ {724, "32", "BR"}, /* Brazil */ {724, "33", "BR"}, /* Brazil */ {724, "34", "BR"}, /* Brazil */ {724, "35", "BR"}, /* Brazil */ {724, "36", "BR"}, /* Brazil */ {724, "37", "BR"}, /* Brazil */ {724, "38", "BR"}, /* Brazil */ {724, "39", "BR"}, /* Brazil */ {724, "54", "BR"}, /* Brazil */ {730, "01", "CL"}, /* Chile */ {730, "02", "CL"}, /* Chile */ {730, "03", "CL"}, /* Chile */ {730, "04", "CL"}, /* Chile */ {730, "05", "CL"}, /* Chile */ {730, "06", "CL"}, /* Chile */ {730, "07", "CL"}, /* Chile */ {730, "08", "CL"}, /* Chile */ {730, "09", "CL"}, /* Chile */ {730, "10", "CL"}, /* Chile */ {730, "11", "CL"}, /* Chile */ {730, "12", "CL"}, /* Chile */ {730, "13", "CL"}, /* Chile */ {730, "14", "CL"}, /* Chile */ {730, "15", "CL"}, /* Chile */ {730, "99", "CL"}, /* Chile */ {732, "001", "CO"}, /* Colombia */ {732, "002", "CO"}, /* Colombia */ {732, "020", "CO"}, /* Colombia */ {732, "099", "CO"}, /* Colombia */ {732, "101", "CO"}, /* Colombia */ {732, "102", "CO"}, /* Colombia */ {732, "103", "CO"}, /* Colombia */ {732, "111", "CO"}, /* Colombia */ {732, "123", "CO"}, /* Colombia */ {732, "130", "CO"}, /* Colombia */ {734, "01", "VE"}, /* Venezuela */ {734, "02", "VE"}, /* Venezuela */ {734, "03", "VE"}, /* Venezuela */ {734, "04", "VE"}, /* Venezuela */ {734, "06", "VE"}, /* Venezuela */ {736, "01", "BO"}, /* Bolivia */ {736, "02", "BO"}, /* Bolivia */ {736, "03", "BO"}, /* Bolivia */ {738, "01", "GY"}, /* Guyana */ {738, "02", "GY"}, /* Guyana */ {740, "00", "EC"}, /* Ecuador */ {740, "01", "EC"}, /* Ecuador */ {740, "02", "EC"}, /* Ecuador */ {744, "01", "PY"}, /* Paraguay */ {744, "02", "PY"}, /* Paraguay */ {744, "03", "PY"}, /* Paraguay */ {744, "04", "PY"}, /* Paraguay */ {744, "05", "PY"}, /* Paraguay */ {744, "06", "PY"}, /* Paraguay */ {746, "02", "SR"}, /* Suriname */ {746, "03", "SR"}, /* Suriname */ {746, "04", "SR"}, /* Suriname */ {748, "01", "UY"}, /* Uruguay */ {748, "07", "UY"}, /* Uruguay */ {748, "10", "UY"}, /* Uruguay */ {750, "001", "FK"}, /* Falkland Islands (United Kingdom) */ }; QOfono::QOfono() { qDebug() << Q_FUNC_INFO; } QString QOfono::mobileCountryCodeToAlpha2CountryCode(int mcc) { const int n = sizeof(qofonoMccList)/sizeof(qofonoMccList[0]); int low = 0; int high = n; while (low < high) { const int mid = (low + high)/2; if (qofonoMccList[mid].mcc >= mcc) { high = mid; } else { low = mid + 1; } } if (high < n && qofonoMccList[high].mcc == mcc) { return QString(qofonoMccList[high].cc); } else { qWarning() << "Unknown Mobile Country Code:" << mcc; return QString(); } } ./src/qofonosupplementaryservices.cpp0000644000004100000410000001452512762041045020444 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonosupplementaryservices.h" #include "ofono_supplementary_services_interface.h" #define SUPER QOfonoModemInterface QOfonoSupplementaryServices::QOfonoSupplementaryServices(QObject *parent) : SUPER(OfonoSupplementaryServices::staticInterfaceName(), parent) { } QOfonoSupplementaryServices::~QOfonoSupplementaryServices() { } QDBusAbstractInterface *QOfonoSupplementaryServices::createDbusInterface(const QString &path) { QDBusAbstractInterface *iface = new OfonoSupplementaryServices("org.ofono", path, QDBusConnection::systemBus(), this); connect(iface, SIGNAL(NotificationReceived(QString)), this, SIGNAL(notificationReceived(QString))); connect(iface, SIGNAL(RequestReceived(QString)), this, SIGNAL(requestReceived(QString))); return iface; } void QOfonoSupplementaryServices::initiate(const QString &command) { 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) { OfonoSupplementaryServices *iface = (OfonoSupplementaryServices*)dbusInterface(); if (iface) { connect(new QDBusPendingCallWatcher(iface->Respond(command), iface), SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(respondResponseReceived(QDBusPendingCallWatcher*))); } } void QOfonoSupplementaryServices::cancel() { 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 QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("State")) { Q_EMIT stateChanged(value.value()); } } QString QOfonoSupplementaryServices::state() const { return getString("State"); } void QOfonoSupplementaryServices::initiateResponseReceived(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply reply = *call; if (reply.isError()) { emit initiateFailed(); return; } QString type = reply.value(); if (type == QLatin1String("USSD")) { QString resp = qvariant_cast(reply.argumentAt(1)).variant().toString(); emit ussdResponse(resp); } else { QVariant val = qvariant_cast(reply.argumentAt(1)).variant(); const QDBusArgument arg = qvariant_cast(val); if (type == QLatin1String("CallBarring")) { QString ss_op; QString cb_service; QVariantMap cb_dict; arg.beginStructure(); arg >> ss_op >> cb_service >> cb_dict; arg.endStructure(); emit callBarringResponse(ss_op, cb_service, cb_dict); } else if (type == QLatin1String("CallForwarding")) { QString ss_op; QString cf_service; QVariantMap cf_dict; arg.beginStructure(); arg >> ss_op >> cf_service >> cf_dict; arg.endStructure(); emit callForwardingResponse(ss_op, cf_service, cf_dict); } else if (type == QLatin1String("CallWaiting")) { QString ss_op; QVariantMap cw_dict; arg.beginStructure(); arg >> ss_op >> cw_dict; arg.endStructure(); emit callWaitingResponse(ss_op, cw_dict); } else if (type == QLatin1String("CallingLinePresentation")) { QString ss_op; QString status; arg.beginStructure(); arg >> ss_op >> status; arg.endStructure(); emit callingLinePresentationResponse(ss_op, status); } else if (type == QLatin1String("ConnectedLinePresentation")) { QString ss_op; QString status; arg.beginStructure(); arg >> ss_op >> status; arg.endStructure(); emit connectedLinePresentationResponse(ss_op, status); } else if (type == QLatin1String("CallingLineRestriction")) { QString ss_op; QString status; arg.beginStructure(); arg >> ss_op >> status; arg.endStructure(); emit callingLineRestrictionResponse(ss_op, status); } else if (type == QLatin1String("ConnectedLineRestriction")) { QString ss_op; QString status; arg.beginStructure(); arg >> ss_op >> status; arg.endStructure(); emit connectedLineRestrictionResponse(ss_op, status); } else { emit initiateFailed(); } } } void QOfonoSupplementaryServices::respondResponseReceived(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply reply = *call; Q_EMIT respondComplete(!reply.isError(), reply.value()); } void QOfonoSupplementaryServices::cancelResponseReceived(QDBusPendingCallWatcher *call) { call->deleteLater(); 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(); } ./src/qofonoassistedsatellitenavigation.h0000644000004100000410000000322112762041045021232 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOASSISTEDSATELLITENAVIGATION_H #define QOFONOASSISTEDSATELLITENAVIGATION_H #include #include #include class QOfonoAssistedSatelliteNavigationPrivate; class QOfonoAssistedSatelliteNavigation : public QObject { Q_OBJECT Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) public: explicit QOfonoAssistedSatelliteNavigation(QObject *parent = 0); ~QOfonoAssistedSatelliteNavigation(); QString modemPath() const; void setModemPath(const QString &path); bool isValid() const; Q_SIGNALS: void modemPathChanged(const QString &path); public slots: void registerPositioningRequestAgent(const QString &path); void sendPositioningElement(const QString &xmlElement); void unregisterPositioningRequestAgent(const QString &path); private: QOfonoAssistedSatelliteNavigationPrivate *d_ptr; }; #endif // QOFONOASSISTEDSATELLITENAVIGATION_H ./src/qofonodbustypes.cpp0000644000004100000410000000357312762041045016013 0ustar www-datawww-data/**************************************************************************** ** ** 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(); } ./src/version.pri0000644000004100000410000000001712762041064014233 0ustar www-datawww-dataVERSION = 0.90 ./src/qofonoobject.cpp0000644000004100000410000002233612762041064015236 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2014-2016 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; bool fixedPath; bool validMark; int validMarkCount; QString objectPath; QVariantMap properties; Private(QOfonoObject::ExtData *data) : ext(data), interface(NULL), initialized(false), fixedPath(false), validMark(false), validMarkCount(0) {} ~Private() { delete ext; } QDBusPendingCall setProperty(const QString &key, const QVariant &value); void getProperties(QOfonoObject *obj); class SetPropertyWatcher : public QDBusPendingCallWatcher { public: QString property; SetPropertyWatcher(QDBusAbstractInterface *parent, const QString &name, const QDBusPendingCall &call) : QDBusPendingCallWatcher(call, parent), property(name) {} }; }; QOfonoObject::ExtData::~ExtData() { } QOfonoObject::ValidTracker::ValidTracker(QOfonoObject* obj) : object(obj) { if (!(object->d_ptr->validMarkCount++)) { object->d_ptr->validMark = obj->isValid(); } } QOfonoObject::ValidTracker::~ValidTracker() { if (!(--object->d_ptr->validMarkCount)) { const bool valid = object->isValid(); if (object->d_ptr->validMark != valid) { Q_EMIT object->validChanged(valid); } } } 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); } void QOfonoObject::Private::getProperties(QOfonoObject *obj) { QObject::connect(new QDBusPendingCallWatcher( interface->asyncCall("GetProperties"), interface), SIGNAL(finished(QDBusPendingCallWatcher*)), obj, SLOT(onGetPropertiesFinished(QDBusPendingCallWatcher*))); } 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->fixedPath) { if (d_ptr->objectPath != path) { qWarning() << "Attempt to change a fixed path"; } } else if (d_ptr->objectPath != path) { d_ptr->objectPath = path; objectPathChanged(path, properties); } } void QOfonoObject::fixObjectPath(const QString &path) { if (d_ptr->fixedPath) { qWarning() << "Attempt to fix object path more than once"; } else if (d_ptr->objectPath != path) { d_ptr->objectPath = path; d_ptr->fixedPath = true; objectPathChanged(path, NULL); } } 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) { ValidTracker valid(this); 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; d_ptr->getProperties(this); } connect(iface, SIGNAL(PropertyChanged(QString,QDBusVariant)), SLOT(onPropertyChanged(QString,QDBusVariant))); } } void QOfonoObject::dbusInterfaceDropped() { if (!d_ptr->properties.isEmpty()) { const 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) { ValidTracker valid(this); for (QVariantMap::ConstIterator it = properties.constBegin(); it != properties.constEnd(); ++it) { updateProperty(it.key(), it.value()); } d_ptr->initialized = true; } else if (qofono::isTimeout(*error)) { // Retry GetProperties call if it times out qDebug() << "Retrying" << qPrintable(d_ptr->interface->interface() + ".GetProperties") << d_ptr->interface->path(); d_ptr->getProperties(this); } else { qWarning() << *error; Q_EMIT reportError(error->message()); } } void QOfonoObject::removeProperty(const QString &key) { if (d_ptr->properties.remove(key) > 0) { propertyChanged(key, QVariant()); } } QVariantMap QOfonoObject::getProperties() const { return d_ptr->properties; } QVariant QOfonoObject::getProperty(const QString &key) const { return d_ptr->properties.value(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); } else if (!oldValue.isValid() && newValue.isValid()) { // Not a change, but we need to insert the new value to make isReady() work. d_ptr->properties.insert(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(); } ./src/qofonomodeminterface2.h0000644000004100000410000000357612762041045016505 0ustar www-datawww-data/**************************************************************************** ** ** 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 ./src/qofonoconnectionmanager.cpp0000644000004100000410000002346512762041045017465 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonoconnectionmanager.h" #include "ofono_connection_manager_interface.h" typedef QWeakPointer QOfonoConnectionManagerWeakPtr; typedef QSharedPointer QOfonoConnectionManagerRef; typedef QMap QOfonoConnectionManagerMap; Q_GLOBAL_STATIC(QOfonoConnectionManagerMap, ofonoConnectionManagerList) #define SUPER QOfonoModemInterface class QOfonoConnectionManager::Private : public QOfonoObject::ExtData { public: bool initialized; QStringList contexts; QHash contextTypes; QString modemPath; QString filter; Private() : initialized(false) {} void filterContexts(); }; // FILTER = [!]NAMES // NAMES = NAME [,NAMES] // Spaces and tabs are ignored void QOfonoConnectionManager::Private::filterContexts() { if (contextTypes.isEmpty()) { contexts.clear(); } else { QStringList contextList = contextTypes.keys(); if (filter.isEmpty()) { contexts = contextList; } else { contexts.clear(); QString f(filter); f.remove(' ').remove('\t'); if (f[0] == '!') { QStringList blackList = f.remove(0,1).split(',', QString::SkipEmptyParts); foreach (QString path, contextList) { if (!blackList.contains(contextTypes.value(path))) contexts.append(path); } } else { QStringList whiteList = f.split(',', QString::SkipEmptyParts); foreach (QString path, contextList) { if (whiteList.contains(contextTypes.value(path))) contexts.append(path); } } } } } QOfonoConnectionManager::QOfonoConnectionManager(QObject *parent) : SUPER(OfonoConnectionManager::staticInterfaceName(), new Private, parent) { QOfonoDbusTypes::registerObjectPathProperties(); } QOfonoConnectionManager::~QOfonoConnectionManager() { } bool QOfonoConnectionManager::isValid() const { return privateData()->initialized && SUPER::isValid(); } QDBusAbstractInterface *QOfonoConnectionManager::createDbusInterface(const QString &path) { 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; iDeactivateAll(); } } void QOfonoConnectionManager::addContext(const QString &type) { 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) { OfonoConnectionManager *iface = (OfonoConnectionManager*)dbusInterface(); if (iface) { connect(new QDBusPendingCallWatcher( iface->RemoveContext(QDBusObjectPath(path)), iface), SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onRemoveContextFinished(QDBusPendingCallWatcher*))); } } bool QOfonoConnectionManager::attached() const { return getBool("Attached"); } QString QOfonoConnectionManager::bearer() const { return getString("Bearer"); } bool QOfonoConnectionManager::suspended() const { return getBool("Suspended"); } bool QOfonoConnectionManager::roamingAllowed() const { return getBool("RoamingAllowed"); } void QOfonoConnectionManager::setRoamingAllowed(bool value) { setProperty("RoamingAllowed", value); } bool QOfonoConnectionManager::powered() const { return getBool("Powered"); } void QOfonoConnectionManager::setPowered(bool value) { setProperty("Powered", value); } void QOfonoConnectionManager::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("Attached")) { Q_EMIT attachedChanged(value.value()); } else if (property == QLatin1String("Bearer")) { Q_EMIT bearerChanged(value.value()); } else if (property == QLatin1String("Suspended")) { Q_EMIT suspendedChanged(value.value()); } else if (property == QLatin1String("RoamingAllowed")) { Q_EMIT roamingAllowedChanged(value.value()); } else if (property == QLatin1String("Powered")) { Q_EMIT poweredChanged(value.value()); } } QStringList QOfonoConnectionManager::contexts() { return privateData()->contexts; } void QOfonoConnectionManager::onContextAdded(const QDBusObjectPath &path, const QVariantMap &properties) { QString contextPath(path.path()); Private *d_ptr = privateData(); d_ptr->contextTypes.insert(contextPath, properties.value("Type").toString()); d_ptr->filterContexts(); if (d_ptr->contexts.contains(contextPath)) { Q_EMIT contextAdded(contextPath); Q_EMIT contextsChanged(d_ptr->contexts); } } void QOfonoConnectionManager::onContextRemoved(const QDBusObjectPath &path) { 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 privateData()->filter; } void QOfonoConnectionManager::setFilter(const QString &filter) { Private *d_ptr = privateData(); if (d_ptr->filter != filter) { d_ptr->filter = filter; d_ptr->filterContexts(); Q_EMIT filterChanged(filter); Q_EMIT contextsChanged(d_ptr->contexts); } } void QOfonoConnectionManager::onGetContextsFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply reply(*watch); if (reply.isError()) { 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::onAddContextFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply reply(*watch); if (reply.isError()) { qDebug() << reply.error(); Q_EMIT reportError(reply.error().message()); } } void QOfonoConnectionManager::onRemoveContextFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply<> reply(*watch); if (reply.isError()) { 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(); } QSharedPointer QOfonoConnectionManager::instance(const QString &path) { QOfonoConnectionManagerRef mgr = ofonoConnectionManagerList()->value(path); if (mgr.isNull()) { mgr = QOfonoConnectionManagerRef::create(); mgr->fixObjectPath(path); ofonoConnectionManagerList()->insert(path, mgr); } return mgr; } ./src/qofonocallbarring.h0000644000004100000410000000607212762041045015713 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOCALLBARRING_H #define QOFONOCALLBARRING_H #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 QOFONOSHARED_EXPORT QOfonoCallBarring : public QOfonoModemInterface { Q_OBJECT Q_PROPERTY(QString voiceIncoming READ voiceIncoming NOTIFY voiceIncomingChanged) Q_PROPERTY(QString voiceOutgoing READ voiceOutgoing NOTIFY voiceOutgoingChanged) public: explicit QOfonoCallBarring(QObject *parent = 0); ~QOfonoCallBarring(); QString modemPath() const; void setModemPath(const QString &path); QString voiceIncoming(); Q_INVOKABLE void setVoiceIncoming(const QString &barrings, const QString &password); QString voiceOutgoing(); Q_INVOKABLE void setVoiceOutgoing(const QString &barrings, const QString &password); bool isValid() const; bool isReady() const; void connectOfono(); Q_SIGNALS: 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); private slots: 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 ./src/qofonoconnectioncontext.cpp0000644000004100000410000003741512762041064017540 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 #include "qofonoconnectioncontext.h" #include "qofonoconnectionmanager.h" #include "qofononetworkregistration.h" #include "ofono_connection_context_interface.h" #define SUPER QOfonoObject class QOfonoConnectionContext::Private : public SUPER::ExtData { public: bool provisioning; bool mgrValid; QSharedPointer mgr; Private() : provisioning(false), mgrValid(false) {} ~Private() {} }; QOfonoConnectionContext::QOfonoConnectionContext(QObject *parent) : SUPER(new Private, parent) { } QOfonoConnectionContext::~QOfonoConnectionContext() { } QDBusAbstractInterface *QOfonoConnectionContext::createDbusInterface(const QString &path) { 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 objectPath(); } QString QOfonoConnectionContext::modemPath() const { QString path = objectPath(); int lastSlash = path.lastIndexOf('/'); return (lastSlash > 0) ? path.left(lastSlash) : QString(); } void QOfonoConnectionContext::setContextPath(const QString &path) { if (path != objectPath()) { ValidTracker valid(this); QString oldModemPath(modemPath()); setObjectPath(path); QString newModemPath(modemPath()); if (oldModemPath != newModemPath) { Private *priv = privateData(); if (!priv->mgr.isNull()) { priv->mgr->disconnect(this); priv->mgr.reset(); priv->mgrValid = false; } if (!newModemPath.isEmpty()) { priv->mgr = QOfonoConnectionManager::instance(newModemPath); priv->mgrValid = priv->mgr.data()->isValid(); connect(priv->mgr.data(), SIGNAL(validChanged(bool)), this, SLOT(onManagerValidChanged(bool))); } Q_EMIT modemPathChanged(newModemPath); } } } void QOfonoConnectionContext::onManagerValidChanged(bool valid) { ValidTracker track(this); privateData()->mgrValid = valid; if (valid) { resetDbusInterface(); } else { setDbusInterface(NULL); } } 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 QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("Active")) { Q_EMIT activeChanged(value.value()); } else if (property == QLatin1String("Name")) { Q_EMIT nameChanged(value.value()); } else if (property == QLatin1String("AccessPointName")) { Q_EMIT accessPointNameChanged(value.value()); } else if (property == QLatin1String("Type")) { Q_EMIT typeChanged(value.value()); } else if (property == QLatin1String("AuthenticationMethod")) { Q_EMIT authMethodChanged(value.value()); } else if (property == QLatin1String("Username")) { Q_EMIT usernameChanged(value.value()); } else if (property == QLatin1String("Password")) { Q_EMIT passwordChanged(value.value()); } else if (property == QLatin1String("Protocol")) { Q_EMIT protocolChanged(value.value()); } else if (property == QLatin1String("MessageProxy")) { Q_EMIT messageProxyChanged(value.value()); } else if (property == QLatin1String("MessageCenter")) { Q_EMIT messageCenterChanged(value.value()); } else if (property == QLatin1String("Settings")) { Q_EMIT settingsChanged(getVariantMap("Settings")); } else if (property == QLatin1String("IPv6.Settings")) { Q_EMIT IPv6SettingsChanged(getVariantMap("IPv6.Settings")); } } bool QOfonoConnectionContext::active() const { return getBool("Active"); } QString QOfonoConnectionContext::accessPointName() const { return getString("AccessPointName"); } QString QOfonoConnectionContext::type() const { return getString("Type"); } QString QOfonoConnectionContext::authMethod() const { return getString("AuthenticationMethod"); } QString QOfonoConnectionContext::username() const { return getString("Username"); } QString QOfonoConnectionContext::password() const { return getString("Password"); } QString QOfonoConnectionContext::protocol() const { return getString("Protocol"); } QString QOfonoConnectionContext::name() const { return getString("Name"); } QString QOfonoConnectionContext::messageProxy() const { return getString("MessageProxy"); } QString QOfonoConnectionContext::messageCenter() const { return getString("MessageCenter"); } QVariantMap QOfonoConnectionContext::settings() const { return getVariantMap("Settings"); } QVariantMap QOfonoConnectionContext::IPv6Settings() const { return getVariantMap("IPv6.Settings"); } void QOfonoConnectionContext::setActive(const bool value) { // need someway to tell ui that someone wants to disconnect if (!value) { Q_EMIT disconnectRequested(); } setProperty("Active", value); } void QOfonoConnectionContext::setAccessPointName(const QString &value) { setProperty("AccessPointName", value); } void QOfonoConnectionContext::setType(const QString &value) { setProperty("Type", value); } void QOfonoConnectionContext::setAuthMethod(const QString &value) { setProperty("AuthenticationMethod", value); } void QOfonoConnectionContext::setUsername(const QString &value) { setProperty("Username", value); } void QOfonoConnectionContext::setPassword(const QString &value) { setProperty("Password", value); } void QOfonoConnectionContext::setProtocol(const QString &value) { setProperty("Protocol", value); } void QOfonoConnectionContext::setName(const QString &value) { setProperty("Name", value); } void QOfonoConnectionContext::setMessageProxy(const QString &value) { setProperty("MessageProxy", value); } void QOfonoConnectionContext::setMessageCenter(const QString &value) { setProperty("MessageCenter", value); } void QOfonoConnectionContext::disconnect() { Q_EMIT disconnectRequested(); setPropertySync("Active", false); } bool QOfonoConnectionContext::isValid() const { return privateData()->mgrValid && SUPER::isValid(); } bool QOfonoConnectionContext::provisioning() const { return privateData()->provisioning; } QOfonoConnectionContext::Private *QOfonoConnectionContext::privateData() const { return (QOfonoConnectionContext::Private*)SUPER::extData(); } bool QOfonoConnectionContext::provision() { Private *priv = privateData(); if (!priv->provisioning) { OfonoConnectionContext *iface = (OfonoConnectionContext*)dbusInterface(); if (iface) { priv->provisioning = true; Q_EMIT provisioningChanged(true); connect(new QDBusPendingCallWatcher(iface->ProvisionContext(), iface), SIGNAL(finished(QDBusPendingCallWatcher*)), SLOT(onProvisionContextFinished(QDBusPendingCallWatcher*))); return true; } } return false; } void QOfonoConnectionContext::onProvisionContextFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply<> reply(*watch); QString error; if (reply.isError()) { qWarning() << "Provisioning failed:" << reply.error(); error = reply.error().name(); } privateData()->provisioning = false; Q_EMIT provisioningChanged(false); Q_EMIT provisioningFinished(error); } /* * These provisioning functions use the mobile broadband provider info database available from this url: * https://git.gnome.org/browse/mobile-broadband-provider-info/ * **/ /* * Tries to validate the context against the current registered network **/ //check provision against mbpi bool QOfonoConnectionContext::validateProvisioning() { QString modem(modemPath()); qDebug() << modem; if (modem.isEmpty()) return false; QOfonoNetworkRegistration netReg; netReg.setModemPath(modem); // This won't work because ofono queries are asynchronous: if (netReg.status() == "registered") return validateProvisioning(netReg.networkOperators().at(0),netReg.mcc(),netReg.mnc()); return false; } /* * Tries to validate the context using the provider, mcc and mnc arguments **/ //check provision against mbpi bool QOfonoConnectionContext::validateProvisioning(const QString &providerString, const QString &mcc, const QString &mnc) { qDebug() << providerString; QXmlQuery query; QString provider = providerString; query.setFocus(QUrl("/usr/share/mobile-broadband-provider-info/serviceproviders.xml")); if (provider.contains("\'")) { provider = provider.replace("\'", "'"); } //provider query.setQuery("/serviceproviders/country/provider[ name = '"+provider+"']/string()"); QString providerName; query.evaluateTo(&providerName); providerName = providerName.simplified(); if (providerName.isEmpty() && provider.at(1).isLower() ) { //try with uppercase provider[0] = provider.at(0).toUpper(); query.setQuery("/serviceproviders/country/provider[ name = '"+provider+"']/string()"); query.evaluateTo(&providerName); if (providerName.isEmpty()) { qDebug() << "provider not found"; return false; } } // apn query.setQuery("/serviceproviders/country/provider[ name = '"+provider+"']/gsm[ network-id [ @mcc = '"+mcc+"' and @mnc = '"+mnc+"' ] ]/apn/@value/string()"); QStringList accessPointNameList; query.evaluateTo(&accessPointNameList); if (accessPointNameList.isEmpty()) { qDebug() << "APN not found"; return false; } QString apn = accessPointName(); if (!accessPointNameList.contains(apn)) { qDebug() << "APN not valid"<< accessPointName(); return false; } QString queryString("/serviceproviders/country/provider[ name = '"+provider+"']//gsm[ network-id[@mcc = '"+mcc+"' and @mnc = '"+mnc+"']]/apn [ @value = '"+apn+ "']/"); //type query.setQuery(queryString+"usage/@type/string()"); QString typeStr; query.evaluateTo(&typeStr); typeStr = typeStr.simplified(); if (!typeStr.isEmpty() && !typeStr.contains(type())) { qDebug() << "type is not the same" << typeStr << type(); return false; } //dns // ofono dns properties are read only //username query.setQuery(queryString+"username/string()"); QString usernameStr; query.evaluateTo(&usernameStr); if (!usernameStr.contains(username())) { qDebug() << "username is not the same"; return false; } //password query.setQuery(queryString+"password/string()"); QString passwordStr; query.evaluateTo(&passwordStr); if (!passwordStr.contains(password())) { qDebug() << "password is not the same"; return false; } //we got here, must be ok return true; } void QOfonoConnectionContext::provisionForCurrentNetwork(const QString &type) { QString modem(modemPath()); if (modem.isEmpty()) return; QOfonoNetworkRegistration netReg; netReg.setModemPath(modem); if (netReg.status() == "registered") provision(netReg.name(), netReg.mcc(),netReg.mnc(), type); } /* * Tries to provision the context using the provider, mcc and mnc given. * * In the case of multiple apn's for given provider and type, this will provision the context * using the first available apn. * * The only way to see if this is a working context is to try to activate the context. * **/ // provision context against mbpi void QOfonoConnectionContext::provision(const QString &provider, const QString &mcc, const QString &mnc, const QString &type) { QXmlQuery query; query.setFocus(QUrl("/usr/share/mobile-broadband-provider-info/serviceproviders.xml")); QString providerStr = provider; if (providerStr.contains("\'")) { providerStr.replace("\'", "'"); } // provider query.setQuery("/serviceproviders/country/provider[ name = '"+providerStr+"']/string()"); QString providerName; query.evaluateTo(&providerName); providerName = providerName.simplified(); if (providerName.isEmpty() && providerStr.at(0).isLower() ) { //try with uppercase first letter providerStr[0] = providerStr.at(0).toUpper(); query.setQuery("/serviceproviders/country/provider [ name = '"+providerStr+"']/string()"); query.evaluateTo(&providerName); if (providerName.isEmpty()) { Q_EMIT reportError("Provider not found"); return; } } // apn query.setQuery("/serviceproviders/country/provider[ name = '"+providerStr+"']/gsm[ network-id [ @mcc = '"+mcc+"' and @mnc = '"+mnc+"' ] ]/apn/@value/string()"); QStringList accessPointNameList; query.evaluateTo(&accessPointNameList); if (accessPointNameList.isEmpty()) { Q_EMIT reportError("APN not found"); return; } Q_FOREACH( const QString &apn, accessPointNameList) { QString queryString("/serviceproviders/country/provider[ name = '"+providerStr+"']//gsm[ network-id[@mcc = '"+mcc+"' and @mnc = '"+mnc+"']]/apn [ @value = '"+apn+ "']/"); // type query.setQuery(queryString+"usage/@type/string()"); QString typeStr; query.evaluateTo(&typeStr); typeStr = typeStr.simplified(); if (typeStr.isEmpty()) { typeStr = "internet"; } if (typeStr != type) { qDebug() << typeStr << "continue"; continue; } // name query.setQuery(queryString+"name/string()"); QString nameStr; query.evaluateTo(&nameStr); nameStr = nameStr.simplified(); if (nameStr.isEmpty()) nameStr = providerStr; // username query.setQuery(queryString+"username/string()"); QString usernameStr; query.evaluateTo(&usernameStr); usernameStr = usernameStr.simplified(); // password query.setQuery(queryString+"password/string()"); QString passwordStr; query.evaluateTo(&passwordStr); passwordStr = passwordStr.simplified(); if (!nameStr.isEmpty()) { setPropertySync("Name", nameStr); } if (!type.isEmpty()) { setPropertySync("Type", type); } if (!apn.isEmpty()) { setPropertySync("AccessPointName", apn); } if (!passwordStr.isEmpty()) { setPropertySync("Password", passwordStr); } if (!usernameStr.isEmpty()) { setPropertySync("Username", usernameStr); } break; } } ./src/qofonovoicecallmanager.cpp0000644000004100000410000002453412762041064017266 0ustar www-datawww-data/***************************************************`************************* ** ** Copyright (C) 2013-2016 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonovoicecallmanager.h" #include "qofonoutils_p.h" #include "ofono_voicecallmanager_interface.h" #define SUPER QOfonoModemInterface class QOfonoVoiceCallManager::Private : public SUPER::ExtData { public: bool initialized; QStringList callList; QString errorMessage; Private() : initialized(false) {} static void getCalls(QOfonoVoiceCallManager *parent, OfonoVoiceCallManager* iface) { connect(new QDBusPendingCallWatcher(iface->GetCalls(), iface), SIGNAL(finished(QDBusPendingCallWatcher*)), parent, SLOT(onGetCallsFinished(QDBusPendingCallWatcher*))); } 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*))); } }; }; QOfonoVoiceCallManager::QOfonoVoiceCallManager(QObject *parent) : SUPER(OfonoVoiceCallManager::staticInterfaceName(), new Private, parent) { QOfonoDbusTypes::registerObjectPathProperties(); } QOfonoVoiceCallManager::~QOfonoVoiceCallManager() { } bool QOfonoVoiceCallManager::isValid() const { return privateData()->initialized && SUPER::isValid(); } QDBusAbstractInterface *QOfonoVoiceCallManager::createDbusInterface(const QString &path) { OfonoVoiceCallManager* iface = new OfonoVoiceCallManager("org.ofono", path, QDBusConnection::systemBus(), this); 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))); Private::getCalls(this, iface); return iface; } void QOfonoVoiceCallManager::dbusInterfaceDropped() { SUPER::dbusInterfaceDropped(); 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; icallList; } 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); } } void QOfonoVoiceCallManager::hangupAll() { OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); if (iface) { new Private::Watcher(this, iface, "HangupAll", iface->HangupAll(), &QOfonoVoiceCallManager::hangupAllComplete); } } void QOfonoVoiceCallManager::sendTones(const QString &tonestring) { OfonoVoiceCallManager *iface = (OfonoVoiceCallManager*)dbusInterface(); if (iface) { new Private::Watcher(this, iface, "SendTones", iface->SendTones(tonestring), &QOfonoVoiceCallManager::sendTonesComplete); } } void QOfonoVoiceCallManager::transfer() { 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()) { if (qofono::isTimeout(reply.error())) { // Retry GetCalls call if it times out qDebug() << "Retrying GetCalls..."; Private::getCalls(this, (OfonoVoiceCallManager*)dbusInterface()); } else { qDebug() << reply.error(); Q_EMIT reportError(reply.error().message()); } } else { ValidTracker valid(this); ObjectPathPropertiesList list = reply.value(); privateData()->initialized = true; for (int i=0; icallList.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(); } ./src/qofono.h0000644000004100000410000000172412762041045013511 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONO_H #define QOFONO_H #include "qofono_global.h" class QOFONOSHARED_EXPORT QOfono { public: QOfono(); static QString mobileCountryCodeToAlpha2CountryCode(int mcc); static void registerObjectPathPropertiesType(); }; #endif // QOFONO_H ./src/qofonolocationreporting.h0000644000004100000410000000310212762041045017164 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOQLOCATIONREPORTING_H #define QOFONOQLOCATIONREPORTING_H #include #include #include class QOfonoLocationReportingPrivate; class QOfonoLocationReporting : public QObject { Q_OBJECT Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QString type READ type) Q_PROPERTY(bool enabled READ enabled) public: explicit QOfonoLocationReporting(QObject *parent = 0); ~QOfonoLocationReporting(); QString modemPath() const; void setModemPath(const QString &path); QString type() const; bool enabled() const; bool isValid() const; public slots: void release(); int request(); Q_SIGNALS: void modemPathChanged(const QString &path); private: QOfonoLocationReportingPrivate *d_ptr; private slots: }; #endif // QOFONOQLOCATIONREPORTING_H ./src/dbus/0000755000004100000410000000000012762041045012770 5ustar www-datawww-data./src/dbus/ofono_voice_call.xml0000644000004100000410000000141112762041045017007 0ustar www-datawww-data ./src/dbus/ofono_voicecallmanager.xml0000644000004100000410000000307312762041045020211 0ustar www-datawww-data ./src/dbus/ofono_supplementary_services.xml0000644000004100000410000000157412762041045021534 0ustar www-datawww-data ./src/dbus/ofono_positioning_request_agent.xml0000644000004100000410000000100412762041045022175 0ustar www-datawww-data ./src/dbus/ofono_modem.xml0000644000004100000410000000110012762041045016003 0ustar www-datawww-data ./src/dbus/ofono_sim_toolkit.xml0000644000004100000410000000134012762041045017245 0ustar www-datawww-data ./src/dbus/ofono_location_reporting.xml0000644000004100000410000000123212762041045020611 0ustar www-datawww-data ./src/dbus/ofono_messagewaiting.xml0000644000004100000410000000111012762041045017712 0ustar www-datawww-data ./src/dbus/ofono_smart_messaging.xml0000644000004100000410000000125512762041045020100 0ustar www-datawww-data ./src/dbus/ofono_simmanager.xml0000644000004100000410000000241412762041045017036 0ustar www-datawww-data ./src/dbus/ofono_message.xml0000644000004100000410000000113512762041045016336 0ustar www-datawww-data ./src/dbus/ofono_network_registration.xml0000644000004100000410000000203712762041045021177 0ustar www-datawww-data ./src/dbus/ofono_handsfree_audio_agent.xml0000644000004100000410000000064712762041045021217 0ustar www-datawww-data ./src/dbus/ofono_connection_context.xml0000644000004100000410000000115612762041045020620 0ustar www-datawww-data ./src/dbus/ofono_smart_messaging_agent.xml0000644000004100000410000000122612762041045021254 0ustar www-datawww-data ./src/dbus/ofono_sim_toolkit_agent.xml0000644000004100000410000001116512762041045020431 0ustar www-datawww-data ./src/dbus/ofono_cell_broadcast.xml0000644000004100000410000000151012762041045017650 0ustar www-datawww-data ./src/dbus/ofono_callmeter.xml0000644000004100000410000000132112762041045016657 0ustar www-datawww-data ./src/dbus/ofono_manager.xml0000644000004100000410000000117112762041045016324 0ustar www-datawww-data ./src/dbus/ofono_call_forwarding.xml0000644000004100000410000000123412762041045020047 0ustar www-datawww-data ./src/dbus/ofono_push_notification.xml0000644000004100000410000000060312762041045020436 0ustar www-datawww-data ./src/dbus/ofono_assisted_satellite_navigation.xml0000644000004100000410000000101512762041045023013 0ustar www-datawww-data ./src/dbus/ofono_call_settings.xml0000644000004100000410000000110612762041045017543 0ustar www-datawww-data ./src/dbus/ofono_call_barring.xml0000644000004100000410000000203612762041045017332 0ustar www-datawww-data ./src/dbus/ofono_network_operator.xml0000644000004100000410000000076712762041045020330 0ustar www-datawww-data ./src/dbus/ofono_push_notification_agent.xml0000644000004100000410000000060012762041045021611 0ustar www-datawww-data ./src/dbus/ofono_text_telephony.xml0000644000004100000410000000111612762041045017764 0ustar www-datawww-data ./src/dbus/ofono_handsfree_audio_card.xml0000644000004100000410000000100312762041045021015 0ustar www-datawww-data ./src/dbus/ofono_handsfree_audio_manager.xml0000644000004100000410000000177712762041045021540 0ustar www-datawww-data ./src/dbus/ofono_audio_settings.xml0000644000004100000410000000074012762041045017734 0ustar www-datawww-data ./src/dbus/ofono_connection_manager.xml0000644000004100000410000000227712762041045020553 0ustar www-datawww-data ./src/dbus/ofono_callvolume.xml0000644000004100000410000000110412762041045017051 0ustar www-datawww-data ./src/dbus/ofono_phonebook.xml0000644000004100000410000000044512762041045016701 0ustar www-datawww-data ./src/dbus/ofono_radio_settings.xml0000644000004100000410000000111612762041045017727 0ustar www-datawww-data ./src/dbus/ofono_message_manager.xml0000644000004100000410000000270212762041045020031 0ustar www-datawww-data ./src/dbus/ofono_handsfree.xml0000644000004100000410000000127312762041045016654 0ustar www-datawww-data ./src/src.pro0000644000004100000410000002767112762041064013362 0ustar www-datawww-data#------------------------------------------------- # # Project created by QtCreator 2013-01-11T09:22:23 # #------------------------------------------------- QT += dbus xmlpatterns QT -= gui QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-psabi include(version.pri) equals(QT_MAJOR_VERSION, 4): { TARGET = qofono pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig } equals(QT_MAJOR_VERSION, 5): { TARGET = qofono-qt5 pkgconfig.path = $$[QT_INSTALL_LIBS]/pkgconfig-qt5 } TEMPLATE = lib DEFINES += QOFONO_LIBRARY isEmpty(PREFIX) { PREFIX=/usr } XML_FILES += \ dbus/ofono_assisted_satellite_navigation.xml \ dbus/ofono_audio_settings.xml \ dbus/ofono_call_barring.xml \ dbus/ofono_call_forwarding.xml \ dbus/ofono_callmeter.xml \ dbus/ofono_call_settings.xml \ dbus/ofono_callvolume.xml \ dbus/ofono_cell_broadcast.xml \ dbus/ofono_connection_context.xml \ dbus/ofono_connection_manager.xml \ dbus/ofono_handsfree.xml \ dbus/ofono_handsfree_audio_agent.xml \ dbus/ofono_handsfree_audio_card.xml \ dbus/ofono_handsfree_audio_manager.xml \ dbus/ofono_manager.xml \ dbus/ofono_message.xml \ dbus/ofono_message_manager.xml \ dbus/ofono_messagewaiting.xml \ dbus/ofono_modem.xml \ dbus/ofono_network_operator.xml \ dbus/ofono_network_registration.xml \ dbus/ofono_phonebook.xml \ dbus/ofono_push_notification.xml \ dbus/ofono_radio_settings.xml \ dbus/ofono_simmanager.xml \ dbus/ofono_smart_messaging.xml \ dbus/ofono_smart_messaging_agent.xml \ dbus/ofono_supplementary_services.xml \ dbus/ofono_text_telephony.xml \ dbus/ofono_voice_call.xml \ dbus/ofono_voicecallmanager.xml OTHER_FILES += $$XML_FILES\ version.pri \ qofono.prf \ qofono-qt5.prf SOURCES += \ qofono.cpp \ qofonodbustypes.cpp \ qofonoobject.cpp \ qofonomanager.cpp \ qofonomodem.cpp \ qofonomodeminterface.cpp \ qofonomodeminterface2.cpp \ qofonoassistedsatellitenavigation.cpp \ qofonoconnectionmanager.cpp \ qofonoconnectioncontext.cpp \ qofononetworkregistration.cpp \ qofononetworkoperator.cpp \ qofonocellbroadcast.cpp \ qofonocallbarring.cpp \ qofonocallforwarding.cpp \ qofonocallmeter.cpp \ qofonocallsettings.cpp \ qofonocallvolume.cpp \ qofonohandsfree.cpp \ qofonohandsfreeaudioagent.cpp \ qofonohandsfreeaudiocard.cpp \ qofonohandsfreeaudiomanager.cpp\ qofonolocationreporting.cpp \ qofonomessage.cpp \ qofonomessagemanager.cpp \ qofonomessagewaiting.cpp \ qofonosimmanager.cpp \ qofonosimwatcher.cpp \ qofonophonebook.cpp \ qofonopositioningrequestagent.cpp \ qofonosmartmessaging.cpp \ qofonosmartmessagingagent.cpp \ qofonovoicecall.cpp \ qofonovoicecallmanager.cpp \ qofonoradiosettings.cpp \ qofonosupplementaryservices.cpp \ qofonotexttelephony.cpp 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 \ qofononetworkregistration.h \ qofononetworkoperator.h \ qofonocellbroadcast.h \ qofonocallbarring.h \ qofonocallforwarding.h \ qofonolocationreporting.h \ qofonocallmeter.h \ qofonocallsettings.h \ qofonocallvolume.h \ qofonohandsfree.h \ qofonohandsfreeaudioagent.h \ qofonohandsfreeaudiocard.h \ qofonohandsfreeaudiomanager.h\ qofonomessage.h \ qofonomessagemanager.h \ qofonomessagewaiting.h \ qofonosimmanager.h \ qofonosimwatcher.h \ qofonophonebook.h \ qofonopositioningrequestagent.h \ qofonosmartmessaging.h \ qofonosmartmessagingagent.h \ qofonovoicecall.h \ qofonovoicecallmanager.h \ qofonoradiosettings.h \ qofonosupplementaryservices.h \ qofonotexttelephony.h HEADERS += \ $$DBUS_HEADERS \ $$PUBLIC_HEADERS \ qofonoutils_p.h equals(QT_MAJOR_VERSION, 4): { headers.path = $$INSTALL_ROOT$$PREFIX/include/qofono qtconfig.path = $$[QT_INSTALL_PREFIX]/share/qt4/mkspecs/features qtconfig.files = qofono.prf pkgconfig.files = qofono.pc xmlfiles.path = $$INSTALL_ROOT$$PREFIX/include/qofono/dbus } equals(QT_MAJOR_VERSION, 5): { headers.path = $$INSTALL_ROOT$$PREFIX/include/qofono-qt5 qtconfig.path = $$[QT_INSTALL_PREFIX]/share/qt5/mkspecs/features qtconfig.files = qofono-qt5.prf pkgconfig.files = qofono-qt5.pc xmlfiles.path = $$INSTALL_ROOT$$PREFIX/include/qofono-qt5/dbus } DBUS_INTERFACES += ofono_assisted_satellite_navigation ofono_assisted_satellite_navigation.files = dbus/ofono_assisted_satellite_navigation.xml ofono_assisted_satellite_navigation.header_flags = -N -c OfonoAssistedSatelliteNavigation ofono_assisted_satellite_navigation.source_flags = -N -c OfonoAssistedSatelliteNavigation DBUS_INTERFACES += ofono_call_barring ofono_call_barring.files = dbus/ofono_call_barring.xml ofono_call_barring.header_flags = -N -c OfonoCallBarring ofono_call_barring.source_flags = -N -c OfonoCallBarring DBUS_INTERFACES += ofono_call_forwarding ofono_call_forwarding.files = dbus/ofono_call_forwarding.xml ofono_call_forwarding.header_flags = -N -c OfonoCallForwarding ofono_call_forwarding.source_flags = -N -c OfonoCallForwarding DBUS_INTERFACES += ofono_callmeter ofono_callmeter.files = dbus/ofono_callmeter.xml ofono_callmeter.header_flags = -N -c OfonoCallMeter ofono_callmeter.source_flags = -N -c OfonoCallMeter DBUS_INTERFACES += ofono_call_settings ofono_call_settings.files = dbus/ofono_call_settings.xml ofono_call_settings.header_flags = -N -c OfonoCallSettings ofono_call_settings.source_flags = -N -c OfonoCallSettings DBUS_INTERFACES += ofono_callvolume ofono_callvolume.files = dbus/ofono_callvolume.xml ofono_callvolume.header_flags = -N -c OfonoCallVolume ofono_callvolume.source_flags = -N -c OfonoCallVolume DBUS_INTERFACES += ofono_cell_broadcast ofono_cell_broadcast.files = dbus/ofono_cell_broadcast.xml ofono_cell_broadcast.header_flags = -N -c OfonoCellBroadcast ofono_cell_broadcast.source_flags = -N -c OfonoCellBroadcast DBUS_INTERFACES += ofono_handsfree ofono_handsfree.files = dbus/ofono_handsfree.xml ofono_handsfree.header_flags = -N -c OfonoHandsfree ofono_handsfree.source_flags = -N -c OfonoHandsfree DBUS_INTERFACES += ofono_handsfree_audio_agent ofono_handsfree_audio_agent.files = dbus/ofono_handsfree_audio_agent.xml ofono_handsfree_audio_agent.header_flags = -N -c OfonoHandsfreeAudioAgent ofono_handsfree_audio_agent.source_flags = -N -c OfonoHandsfreeAudioAgent DBUS_INTERFACES += ofono_handsfree_audio_card ofono_handsfree_audio_card.files = dbus/ofono_handsfree_audio_card.xml ofono_handsfree_audio_card.header_flags = -N -c OfonoHandsfreeAudioCard ofono_handsfree_audio_card.source_flags = -N -c OfonoHandsfreeAudioCard DBUS_INTERFACES += ofono_handsfree_audio_manager ofono_handsfree_audio_manager.files = dbus/ofono_handsfree_audio_manager.xml ofono_handsfree_audio_manager.header_flags = -N -c OfonoHandsfreeAudioManager -i dbustypes.h ofono_handsfree_audio_manager.source_flags = -N -c OfonoHandsfreeAudioManager DBUS_INTERFACES += ofono_connection_context ofono_connection_context.files = dbus/ofono_connection_context.xml ofono_connection_context.header_flags = -N -c OfonoConnectionContext ofono_connection_context.source_flags = -N -c OfonoConnectionContext DBUS_INTERFACES += ofono_connection_manager ofono_connection_manager.files = dbus/ofono_connection_manager.xml ofono_connection_manager.header_flags = -N -c OfonoConnectionManager -i dbustypes.h ofono_connection_manager.source_flags = -N -c OfonoConnectionManager DBUS_INTERFACES += ofono_location_reporting ofono_location_reporting.files = dbus/ofono_location_reporting.xml ofono_location_reporting.header_flags = -N -c OfonoLocationReporting ofono_location_reporting.source_flags = -N -c OfonoLocationReporting DBUS_INTERFACES += ofono_manager ofono_manager.files = dbus/ofono_manager.xml ofono_manager.header_flags = -N -c OfonoManager -i dbustypes.h ofono_manager.source_flags = -N -c OfonoManager DBUS_INTERFACES += ofono_message ofono_message.files = dbus/ofono_message.xml ofono_message.header_flags = -N -c OfonoMessage ofono_message.source_flags = -N -c OfonoMessage DBUS_INTERFACES += ofono_message_manager ofono_message_manager.files = dbus/ofono_message_manager.xml ofono_message_manager.header_flags = -N -c OfonoMessageManager -i dbustypes.h ofono_message_manager.source_flags = -N -c OfonoMessageManager DBUS_INTERFACES += ofono_messagewaiting ofono_messagewaiting.files = dbus/ofono_messagewaiting.xml ofono_messagewaiting.header_flags = -N -c OfonoMessageWaiting ofono_messagewaiting.source_flags = -N -c OfonoMessageWaiting DBUS_INTERFACES += ofono_modem ofono_modem.files = dbus/ofono_modem.xml ofono_modem.header_flags = -N -c OfonoModem ofono_modem.source_flags = -N -c OfonoModem DBUS_INTERFACES += ofono_network_operator ofono_network_operator.files = dbus/ofono_network_operator.xml ofono_network_operator.header_flags = -N -c OfonoNetworkOperator ofono_network_operator.source_flags = -N -c OfonoNetworkOperator DBUS_INTERFACES += ofono_network_registration ofono_network_registration.files = dbus/ofono_network_registration.xml ofono_network_registration.header_flags = -N -c OfonoNetworkRegistration -i dbustypes.h ofono_network_registration.source_flags = -N -c OfonoNetworkRegistration DBUS_INTERFACES += ofono_phonebook ofono_phonebook.files = dbus/ofono_phonebook.xml ofono_phonebook.header_flags = -N -c OfonoPhonebook ofono_phonebook.source_flags = -N -c OfonoPhonebook DBUS_ADAPTORS += ofono_positioning_request_agent ofono_positioning_request_agent.files = dbus/ofono_positioning_request_agent.xml ofono_positioning_request_agent.header_flags = -N -c QOfonoPositioningRequestAgentAdaptor ofono_positioning_request_agent.source_flags = -N -c QOfonoPositioningRequestAgentAdaptor DBUS_INTERFACES += ofono_radio_settings ofono_radio_settings.files = dbus/ofono_radio_settings.xml ofono_radio_settings.header_flags = -N -c OfonoRadioSettings ofono_radio_settings.source_flags = -N -c OfonoRadioSettings DBUS_INTERFACES += ofono_simmanager ofono_simmanager.files = dbus/ofono_simmanager.xml ofono_simmanager.header_flags = -N -c OfonoSimManager ofono_simmanager.source_flags = -N -c OfonoSimManager DBUS_INTERFACES += ofono_smart_messaging ofono_smart_messaging.files = dbus/ofono_smart_messaging.xml ofono_smart_messaging.header_flags = -N -c OfonoSmartMessaging ofono_smart_messaging.source_flags = -N -c OfonoSmartMessaging DBUS_ADAPTORS += ofono_smart_messaging_agent ofono_smart_messaging_agent.files = dbus/ofono_smart_messaging_agent.xml ofono_smart_messaging_agent.header_flags = -N -c QOfonoSmartMessagingAgentAdaptor ofono_smart_messaging_agent.source_flags = -N -c QOfonoSmartMessagingAgentAdaptor DBUS_INTERFACES += ofono_supplementary_services ofono_supplementary_services.files = dbus/ofono_supplementary_services.xml ofono_supplementary_services.header_flags = -N -c OfonoSupplementaryServices ofono_supplementary_services.source_flags = -N -c OfonoSupplementaryServices DBUS_INTERFACES += ofono_text_telephony ofono_text_telephony.files = dbus/ofono_text_telephony.xml ofono_text_telephony.header_flags = -N -c OfonoTextTelephony ofono_text_telephony.source_flags = -N -c OfonoTextTelephony DBUS_INTERFACES += ofono_voice_call ofono_voice_call.files = dbus/ofono_voice_call.xml ofono_voice_call.header_flags = -N -c OfonoVoiceCall ofono_voice_call.source_flags = -N -c OfonoVoiceCall DBUS_INTERFACES += ofono_voicecallmanager ofono_voicecallmanager.files = dbus/ofono_voicecallmanager.xml ofono_voicecallmanager.header_flags = -N -c OfonoVoiceCallManager -i dbustypes.h ofono_voicecallmanager.source_flags = -N -c OfonoVoiceCallManager target.path = $$[QT_INSTALL_LIBS] headers.files = $$PUBLIC_HEADERS xmlfiles.files = $$XML_FILES CONFIG += create_pc create_prl link_pkgconfig QMAKE_PKGCONFIG_DESTDIR = pkgconfig QMAKE_PKGCONFIG_INCDIR = $$headers.path INSTALLS += target headers qtconfig xmlfiles pkgconfig ./src/qofononetworkregistration.cpp0000644000004100000410000002514512762041064020115 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofononetworkregistration.h" #include "qofononetworkoperator.h" #include "ofono_network_registration_interface.h" #define SUPER QOfonoModemInterface class QOfonoNetworkRegistration::Private : public QOfonoObject::ExtData { public: bool initialized; bool scanning; QOfonoNetworkOperator* currentOperator; QHash networkOperators; QStringList operatorPaths; Private() : initialized(false), scanning(false), currentOperator(NULL) {} ~Private() { qDeleteAll(networkOperators.values()); } }; QOfonoNetworkRegistration::QOfonoNetworkRegistration(QObject *parent) : SUPER(OfonoNetworkRegistration::staticInterfaceName(), new Private, parent) { QOfonoDbusTypes::registerObjectPathProperties(); } QOfonoNetworkRegistration::~QOfonoNetworkRegistration() { } bool QOfonoNetworkRegistration::isValid() const { return privateData()->initialized && SUPER::isValid(); } bool QOfonoNetworkRegistration::scanning() const { return privateData()->scanning; } 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; } void QOfonoNetworkRegistration::dbusInterfaceDropped() { 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::registration() { 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")); } } void QOfonoNetworkRegistration::onRegistrationFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply<> reply(*watch); if (!reply.isError()) { Q_EMIT registrationFinished(); } else { Q_EMIT registrationError(reply.error().message()); } } QStringList QOfonoNetworkRegistration::networkOperators() const { return privateData()->operatorPaths; } QStringList QOfonoNetworkRegistration::networkOperators() { return privateData()->operatorPaths; } QOfonoNetworkOperator* QOfonoNetworkRegistration::networkOperator(const QString &path) const { return privateData()->networkOperators[path]; } QString QOfonoNetworkRegistration::currentOperatorPath() { Private *d_ptr = privateData(); return d_ptr->currentOperator ? d_ptr->currentOperator->operatorPath() : QString(); } void QOfonoNetworkRegistration::scan() { 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 { return getString("Mode"); } QString QOfonoNetworkRegistration::status() const { return getString("Status"); } uint QOfonoNetworkRegistration::locationAreaCode() const { return getUInt("LocalAreaCode"); } uint QOfonoNetworkRegistration::cellId() const { return getUInt("CellId"); } QString QOfonoNetworkRegistration::mcc() const { return getString("MobileCountryCode"); } QString QOfonoNetworkRegistration::mnc() const { return getString("MobileNetworkCode"); } QString QOfonoNetworkRegistration::technology() const { return getString("Technology"); } QString QOfonoNetworkRegistration::name() const { return getString("Name"); } uint QOfonoNetworkRegistration::strength() const { return getUInt("Strength"); } QString QOfonoNetworkRegistration::baseStation() const { return getString("BaseStation"); } void QOfonoNetworkRegistration::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == QLatin1String("Mode")) { Q_EMIT modeChanged(value.toString()); } else if (property == QLatin1String("Status")) { Q_EMIT statusChanged(value.toString()); } else if (property == QLatin1String("LocationAreaCode")) { Q_EMIT locationAreaCodeChanged(value.toUInt()); } else if (property == QLatin1String("CellId")) { Q_EMIT cellIdChanged(value.toUInt()); } else if (property == QLatin1String("MobileCountryCode")) { Q_EMIT mccChanged(value.toString()); } else if (property == QLatin1String("MobileNetworkCode")) { Q_EMIT mncChanged(value.toString()); } else if (property == QLatin1String("Technology")) { Q_EMIT technologyChanged(value.toString()); } else if (property == QLatin1String("Name")) { Q_EMIT nameChanged(value.toString()); } else if (property == QLatin1String("Strength")) { Q_EMIT strengthChanged(value.toUInt()); } else if (property == QLatin1String("BaseStation")) { Q_EMIT baseStationChanged(value.toString()); } } void QOfonoNetworkRegistration::onOperatorsChanged(const ObjectPathPropertiesList &list) { 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; } } // 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); } } void QOfonoNetworkRegistration::onGetOperatorsFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply reply(*watch); if (reply.isError()) { qDebug() << reply.error(); Q_EMIT reportError(reply.error().message()); } else { ValidTracker valid(this); privateData()->initialized = true; onOperatorsChanged(reply.value()); } } 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); } 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); } } QString QOfonoNetworkRegistration::modemPath() const { return SUPER::modemPath(); } void QOfonoNetworkRegistration::setModemPath(const QString &path) { SUPER::setModemPath(path); } QOfonoNetworkRegistration::Private *QOfonoNetworkRegistration::privateData() const { return (QOfonoNetworkRegistration::Private*)SUPER::extData(); } ./src/qofononetworkoperator.h0000644000004100000410000000661412762041045016702 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONONETWORKOPERATOR_H #define QOFONONETWORKOPERATOR_H #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 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 { NoError, NotImplementedError, InProgressError, InvalidArgumentsError, InvalidFormatError, FailedError, UnknownError }; explicit QOfonoNetworkOperator(QObject *parent = 0); QOfonoNetworkOperator(const QString &path, const QVariantMap &properties, QObject *parent = 0); ~QOfonoNetworkOperator(); QString operatorPath() const; void setOperatorPath(const QString &path); QString name() const; QString status() const; QString mcc() const; QString mnc() const; QStringList technologies() const; QString additionalInfo() const; Q_INVOKABLE void registerOperator(); bool registering() const; bool isValid() const; Q_SIGNALS: void nameChanged(const QString &name); void statusChanged(const QString &status); void mccChanged(const QString &mcc); void mncChanged(const QString &mnc); 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); private: static Error errorNameToEnum(const QString &errorName); private slots: 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 ./src/qofonovoicecall.cpp0000644000004100000410000001446612762041045015735 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonovoicecall.h" #include "ofono_voice_call_interface.h" #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*))); } }; QOfonoVoiceCall::QOfonoVoiceCall(QObject *parent) : SUPER(parent) { } QOfonoVoiceCall::~QOfonoVoiceCall() { } void QOfonoVoiceCall::setVoiceCallPath(const QString &path) { setObjectPath(path); } QString QOfonoVoiceCall::voiceCallPath() const { return objectPath(); } void QOfonoVoiceCall::objectPathChanged(const QString &path, const QVariantMap *properties) { SUPER::objectPathChanged(path, properties); Q_EMIT voiceCallPathChanged(path); } 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.toString()); } else if (property == QLatin1String("Name")) { Q_EMIT nameChanged(value.toString()); } else if (property == QLatin1String("State")) { Q_EMIT stateChanged(value.toString()); } else if (property == QLatin1String("StartTime")) { Q_EMIT startTimeChanged(value.toString()); } else if (property == QLatin1String("Information")) { Q_EMIT informationChanged(value.toString()); } else if (property == QLatin1String("IncomingLine")) { Q_EMIT incomingLineChanged(value.toString()); } else if (property == QLatin1String("Multiparty")) { Q_EMIT multipartyChanged(value.toBool()); } else if (property == QLatin1String("Icon")) { Q_EMIT iconChanged(value.value()); } else if (property == QLatin1String("Emergency")) { Q_EMIT emergencyChanged(value.toBool()); } else if (property == QLatin1String("RemoteHeld")) { Q_EMIT remoteHeldChanged(value.toBool()); } else if (property == QLatin1String("RemoteMultiparty")) { Q_EMIT remoteMultipartyChanged(value.toBool()); } } QString QOfonoVoiceCall::lineIdentification() const { return getString("LineIdentification"); } QString QOfonoVoiceCall::incomingLine() const { return getString("IncomingLine"); } QString QOfonoVoiceCall::name() const { return getString("Name"); } QString QOfonoVoiceCall::state() const { return getString("State"); } QString QOfonoVoiceCall::startTime() const { return getString("StartTime"); } QString QOfonoVoiceCall::information() const { return getString("Information"); } bool QOfonoVoiceCall::multiparty() const { return getBool("Multiparty"); } bool QOfonoVoiceCall::emergency() const { return getBool("Emergency"); } quint8 QOfonoVoiceCall::icon() const { return getProperty("Icon").value(); } bool QOfonoVoiceCall::remoteHeld() const { return getBool("RemoteHeld"); } bool QOfonoVoiceCall::remoteMultiparty() const { return getBool("RemoteMultiparty"); } void QOfonoVoiceCall::answer() { OfonoVoiceCall *iface = (OfonoVoiceCall*)dbusInterface(); if (iface) { new QOfonoVoiceCallWatcher(this, iface, "Answer", iface->Answer(), &QOfonoVoiceCall::answerComplete); } } void QOfonoVoiceCall::hangup() { OfonoVoiceCall *iface = (OfonoVoiceCall*)dbusInterface(); if (iface) { new QOfonoVoiceCallWatcher(this, iface, "Hangup", iface->Hangup(), &QOfonoVoiceCall::hangupComplete); } } void QOfonoVoiceCall::deflect(const QString &number) { OfonoVoiceCall *iface = (OfonoVoiceCall*)dbusInterface(); if (iface) { new QOfonoVoiceCallWatcher(this, iface, "Deflect", iface->Deflect(number), &QOfonoVoiceCall::deflectComplete); } } void QOfonoVoiceCall::onDbusCallFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply<> reply(*watch); QOfonoVoiceCallWatcher* call = (QOfonoVoiceCallWatcher*)watch; QOfonoVoiceCall::Error error = NoError; QString errorString; if (reply.isError()) { qWarning() << call->name << " failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } (this->*call->signal)(error, errorString); } QOfonoVoiceCall::Error QOfonoVoiceCall::errorNameToEnum(const QString &errorName) { if (errorName == "") return NoError; else if (errorName == "org.ofono.Error.NotImplemented") return NotImplementedError; else if (errorName == "org.ofono.Error.InProgress") return InProgressError; else if (errorName == "org.ofono.Error.InvalidArguments") return InvalidArgumentsError; else if (errorName == "org.ofono.Error.InvalidFormat") return InvalidFormatError; else if (errorName == "org.ofono.Error.Failed") return FailedError; else return UnknownError; } bool QOfonoVoiceCall::isValid() const { return SUPER::isValid(); } ./src/qofonomessage.cpp0000644000004100000410000000364512762041045015415 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonomessage.h" #include "ofono_message_interface.h" QOfonoMessage::QOfonoMessage(QObject *parent) : QOfonoObject(parent) { } QOfonoMessage::~QOfonoMessage() { } QString QOfonoMessage::messagePath() const { return objectPath(); } void QOfonoMessage::setMessagePath(const QString &path) { setObjectPath(path); } void QOfonoMessage::objectPathChanged(const QString &path, const QVariantMap *properties) { QOfonoObject::objectPathChanged(path, properties); Q_EMIT messagePathChanged(path); } QDBusAbstractInterface *QOfonoMessage::createDbusInterface(const QString &path) { 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 { return getString("State"); } void QOfonoMessage::cancel() { QDBusAbstractInterface *dbus = dbusInterface(); if (dbus) { ((OfonoMessage*)dbus)->Cancel(); } } bool QOfonoMessage::isValid() const { return QOfonoObject::isValid(); } ./src/qofonosmartmessaging.h0000644000004100000410000000405312762041045016454 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOSMARTMESSAGING_H #define QOFONOSMARTMESSAGING_H #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 QOFONOSHARED_EXPORT QOfonoSmartMessaging : public QOfonoModemInterface2 { Q_OBJECT public: explicit QOfonoSmartMessaging(QObject *parent = 0); ~QOfonoSmartMessaging(); QString modemPath() const; void setModemPath(const QString &path); bool isValid() const; public Q_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 registered(const QString &objectPath); void unregistered(const QString &objectPath); void registerFailed(const QString &objectPath, const QString &error); void unregisterFailed(const QString &objectPath, const QString &error); private Q_SLOTS: void onDbusCallFinished(QDBusPendingCallWatcher *watch); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); }; #endif // QOFONOSMARTMESSAGING_H ./src/qofonomodem.h0000644000004100000410000000745212762041064014540 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOMODEM_H #define QOFONOMODEM_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 QOFONOSHARED_EXPORT QOfonoModem : public QOfonoObject { Q_OBJECT Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged) Q_PROPERTY(bool online READ online WRITE setOnline NOTIFY onlineChanged) //flightmode Q_PROPERTY(bool lockdown READ lockdown WRITE setLockdown NOTIFY lockdownChanged) Q_PROPERTY(bool emergency READ emergency NOTIFY emergencyChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString manufacturer READ manufacturer NOTIFY manufacturerChanged) Q_PROPERTY(QString model READ model NOTIFY modelChanged) Q_PROPERTY(QString revision READ revision NOTIFY revisionChanged) Q_PROPERTY(QString serial READ serial NOTIFY serialChanged) Q_PROPERTY(QString type READ type NOTIFY typeChanged) Q_PROPERTY(QStringList features READ features NOTIFY featuresChanged) Q_PROPERTY(QStringList interfaces READ interfaces NOTIFY interfacesChanged) Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) public: explicit QOfonoModem(QObject *parent = 0); ~QOfonoModem(); QString modemPath() const; void setModemPath(const QString &path); bool powered() const; void setPowered(bool powered); bool online() const; void setOnline(bool online); bool lockdown() const; void setLockdown(bool lockdown); bool emergency() const; QString name() const; QString manufacturer() const; QString model() const; QString revision() const; QString serial() const; QString type() const; QStringList features() const; QStringList interfaces() const; bool isValid() const; // If you use this, remember to keep a QSharedPointer to it, otherwise it may be destroyed. static QSharedPointer instance(const QString &modemPath); Q_SIGNALS: void poweredChanged(bool powered); void onlineChanged(bool online); void lockdownChanged(bool lockdown); void emergencyChanged(bool emergency); void nameChanged(const QString &name); void manufacturerChanged(const QString &manufacturer); void modelChanged(const QString &model); 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); private Q_SLOTS: bool checkModemPathValidity(); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); void propertyChanged(const QString &key, const QVariant &value); void objectPathChanged(const QString &path, const QVariantMap *properties); private: class Private; Private* privateData() const; }; #endif // QOFONOMODEM_H ./src/qofonoconnectionmanager.h0000644000004100000410000000673712762041045017135 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOCONNECTIONMANAGER_H #define QOFONOCONNECTIONMANAGER_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 QOFONOSHARED_EXPORT QOfonoConnectionManager : public QOfonoModemInterface { Q_OBJECT Q_PROPERTY(bool attached READ attached NOTIFY attachedChanged) Q_PROPERTY(QString bearer READ bearer NOTIFY bearerChanged) Q_PROPERTY(bool suspended READ suspended NOTIFY suspendedChanged) Q_PROPERTY(bool roamingAllowed READ roamingAllowed WRITE setRoamingAllowed NOTIFY roamingAllowedChanged) Q_PROPERTY(bool powered READ powered WRITE setPowered NOTIFY poweredChanged) Q_PROPERTY(QStringList contexts READ contexts NOTIFY contextsChanged) Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged) public: explicit QOfonoConnectionManager(QObject *parent = 0); ~QOfonoConnectionManager(); QString modemPath() const; void setModemPath(const QString &path); bool attached() const; QString bearer() const; bool suspended() const; bool roamingAllowed() const; void setRoamingAllowed(bool); bool powered() const; void setPowered(bool); QStringList contexts(); bool isValid() const; QString filter() const; void setFilter(const QString &filter); // Remember to keep a QSharedPointer to QOfonoConnectionManager, otherwise // it may be destroyed. static QSharedPointer instance(const QString &path); Q_SIGNALS: void attachedChanged(bool value); void bearerChanged(const QString &bearer); void suspendedChanged(bool suspnd); void roamingAllowedChanged(bool roaming); void poweredChanged(bool powered); void contextAdded(const QString &path); void contextRemoved(const QString &path); void contextsChanged(const QStringList &contexts); void filterChanged(const QString &filter); public slots: void deactivateAll(); void addContext(const QString &type); void removeContext(const QString &path); private slots: 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); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); void dbusInterfaceDropped(); void propertyChanged(const QString &property, const QVariant &value); private: class Private; Private *privateData() const; }; #endif // QOFONOCONNECTIONMANAGER_H ./src/qofononetworkregistration.h0000644000004100000410000001034412762041045017554 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONONETWORKREGISTRATION_H #define QOFONONETWORKREGISTRATION_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 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) Q_PROPERTY(uint cellId READ cellId NOTIFY cellIdChanged) Q_PROPERTY(QString mcc READ mcc NOTIFY mccChanged) Q_PROPERTY(QString mnc READ mnc NOTIFY mncChanged) Q_PROPERTY(QString technology READ technology NOTIFY technologyChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(uint strength READ strength NOTIFY strengthChanged) Q_PROPERTY(QString baseStation READ baseStation NOTIFY baseStationChanged) Q_PROPERTY(QStringList networkOperators READ networkOperators NOTIFY networkOperatorsChanged) Q_PROPERTY(QString currentOperatorPath READ currentOperatorPath NOTIFY currentOperatorPathChanged) public: explicit QOfonoNetworkRegistration(QObject *parent = 0); ~QOfonoNetworkRegistration(); QString modemPath() const; void setModemPath(const QString &path); QString mode() const; QString status() const; uint locationAreaCode() const; uint cellId() const; QString mcc() const; QString mnc() const; QString technology() const; QString name() const; uint strength() const; QString baseStation() const; QStringList networkOperators(); // For ABI compatibility QStringList networkOperators() const; QOfonoNetworkOperator* networkOperator(const QString &path) const; Q_INVOKABLE void registration(); Q_INVOKABLE void scan(); QString currentOperatorPath(); bool isValid() const; bool scanning() const; Q_SIGNALS: void modeChanged(const QString &mode); void statusChanged(const QString &status); void locationAreaCodeChanged(uint locationAreaCode); void cellIdChanged(uint cellId); void mccChanged(const QString &mcc); void mncChanged(const QString &mnc); void technologyChanged(const QString &technology); void nameChanged(const QString &name); void strengthChanged(uint strength); void baseStationChanged(const QString &baseStation); void networkOperatorsChanged(const QStringList &networkOperators); void currentOperatorPathChanged(const QString &); void scanFinished(); void scanError(const QString &message); void scanningChanged(bool value); void registrationFinished(); void registrationError(const QString &errorMessage); private slots: 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 ./src/qofonopositioningrequestagent.cpp0000644000004100000410000000530012762041045020751 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonopositioningrequestagent.h" #include "qofonoassistedsatellitenavigation.h" #include "ofono_positioning_request_agent_adaptor.h" class QOfonoPositioningRequestAgentPrivate { public: QOfonoPositioningRequestAgentPrivate(); ~QOfonoPositioningRequestAgentPrivate(); QString positioningAgentPath; bool registered; }; QOfonoPositioningRequestAgentPrivate::QOfonoPositioningRequestAgentPrivate() : registered(false) { } QOfonoPositioningRequestAgentPrivate::~QOfonoPositioningRequestAgentPrivate() { if (registered) QDBusConnection::systemBus().unregisterObject(positioningAgentPath); } QOfonoPositioningRequestAgent::QOfonoPositioningRequestAgent(QObject *parent) : QObject(parent) , d_ptr(new QOfonoPositioningRequestAgentPrivate) { new QOfonoPositioningRequestAgentAdaptor(this); } QOfonoPositioningRequestAgent::~QOfonoPositioningRequestAgent() { delete d_ptr; } void QOfonoPositioningRequestAgent::setAgentPath(const QString &path) { if (d_ptr->positioningAgentPath != path) { QDBusConnection dbus = QDBusConnection::systemBus(); if (d_ptr->registered) { dbus.unregisterObject(d_ptr->positioningAgentPath); d_ptr->registered = false; } d_ptr->positioningAgentPath = path; if (!path.isEmpty()) { if (!dbus.registerObject(path, this)) { qWarning() << "Object registration failed:" << dbus.lastError(); } d_ptr->registered = true; } Q_EMIT agentPathChanged(path); } } QString QOfonoPositioningRequestAgent::agentPath() const { return d_ptr->positioningAgentPath; } void QOfonoPositioningRequestAgent::Release() { Q_EMIT release(); } void QOfonoPositioningRequestAgent::PositioningRequest() { Q_EMIT positioningRequest(); } void QOfonoPositioningRequestAgent::Request(const QString &xmlElement) { Q_EMIT request(xmlElement); } bool QOfonoPositioningRequestAgent::isValid() const { return d_ptr->registered; } ./src/qofonohandsfreeaudiocard.h0000644000004100000410000000420112762041045017236 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOQOfonoHandsfreeAudioCard_H #define QOFONOQOfonoHandsfreeAudioCard_H #include #include #include class QOfonoHandsfreeAudioCardPrivate; class QOfonoHandsfreeAudioCard : public QObject { Q_OBJECT Q_ENUMS(Error) Q_PROPERTY(QString modemPath READ modemPath WRITE setModemPath NOTIFY modemPathChanged) Q_PROPERTY(QString remoteAddress READ remoteAddress) Q_PROPERTY(QString localAddress READ localAddress) public: enum Error { NoError, NotImplementedError, InProgressError, InvalidArgumentsError, InvalidFormatError, FailedError, UnknownError }; explicit QOfonoHandsfreeAudioCard(QObject *parent = 0); ~QOfonoHandsfreeAudioCard(); QString modemPath() const; void setModemPath(const QString &path); QString remoteAddress() const; QString localAddress() const; bool isValid() const; Q_SIGNALS: void modemPathChanged(const QString &path); void connectAudioComplete(QOfonoHandsfreeAudioCard::Error error, const QString &errorString); public slots: void connectAudio(); private: QOfonoHandsfreeAudioCardPrivate *d_ptr; Error errorNameToEnum(const QString &errorName); private slots: void propertyChanged(const QString &property,const QDBusVariant &value); void connectAudioFinished(QDBusPendingCallWatcher *call); }; #endif // QOFONOQOfonoHandsfreeAudioCard_H ./src/qofonosmartmessaging.cpp0000644000004100000410000001060312762041045017005 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonosmartmessaging.h" #include "ofono_smart_messaging_interface.h" #define SUPER QOfonoModemInterface2 class QOfonoSmartMessagingCallWatcher : public QDBusPendingCallWatcher { public: typedef void (QOfonoSmartMessaging::*SignalSuccess)(const QString&); typedef void (QOfonoSmartMessaging::*SignalError)(const QString&, const QString&); const char* name; QString objectPath; SignalSuccess success; SignalError error; QOfonoSmartMessagingCallWatcher(QOfonoSmartMessaging* target, OfonoSmartMessaging *parent, const char* callName, const QString &path, const QDBusPendingCall &call, SignalSuccess ok, SignalError err) : QDBusPendingCallWatcher(call, parent), name(callName), objectPath(path), success(ok), error(err) { connect(this, SIGNAL(finished(QDBusPendingCallWatcher*)), target, SLOT(onDbusCallFinished(QDBusPendingCallWatcher*))); } }; QOfonoSmartMessaging::QOfonoSmartMessaging(QObject *parent) : SUPER(OfonoSmartMessaging::staticInterfaceName(), parent) { } QOfonoSmartMessaging::~QOfonoSmartMessaging() { } QDBusAbstractInterface *QOfonoSmartMessaging::createDbusInterface(const QString &path) { return new OfonoSmartMessaging("org.ofono", path, QDBusConnection::systemBus(), this); } QDBusObjectPath QOfonoSmartMessaging::sendAppointment(const QString &toPhoneNumber, const QByteArray &appointment) { 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) { 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) { OfonoSmartMessaging *iface = (OfonoSmartMessaging*)dbusInterface(); if (iface) { new QOfonoSmartMessagingCallWatcher(this, iface, "RegisterAgent", objectPath, iface->RegisterAgent(QDBusObjectPath(objectPath)), &QOfonoSmartMessaging::registered, &QOfonoSmartMessaging::registerFailed); } } void QOfonoSmartMessaging::unregisterAgent(const QString &objectPath) { OfonoSmartMessaging *iface = (OfonoSmartMessaging*)dbusInterface(); if (iface) { new QOfonoSmartMessagingCallWatcher(this, iface, "UnregisterAgent", objectPath, iface->UnregisterAgent(QDBusObjectPath(objectPath)), &QOfonoSmartMessaging::unregistered, &QOfonoSmartMessaging::unregisterFailed); } } QString QOfonoSmartMessaging::modemPath() const { return SUPER::modemPath(); } void QOfonoSmartMessaging::setModemPath(const QString &path) { SUPER::setModemPath(path); } bool QOfonoSmartMessaging::isValid() const { return SUPER::isValid(); } void QOfonoSmartMessaging::onDbusCallFinished(QDBusPendingCallWatcher *watch) { QOfonoSmartMessagingCallWatcher* call = (QOfonoSmartMessagingCallWatcher*)watch; QDBusPendingReply<> reply(*call); if (reply.isError()) { qWarning() << call->name << "failed:" << reply.error(); (this->*call->error)(call->objectPath, reply.error().name()); } else { (this->*call->success)(call->objectPath); } call->deleteLater(); } ./src/qofononetworkoperator.cpp0000644000004100000410000001343012762041045017227 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofononetworkoperator.h" #include "ofono_network_operator_interface.h" #define SUPER QOfonoObject class QOfonoNetworkOperator::Private : public SUPER::ExtData { public: bool registering; Private() : registering(false) {} }; QOfonoNetworkOperator::QOfonoNetworkOperator(QObject *parent) : SUPER(new Private, parent) { } // 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() { } QString QOfonoNetworkOperator::operatorPath() const { return objectPath(); } void QOfonoNetworkOperator::setOperatorPath(const QString &path) { setObjectPath(path); } void QOfonoNetworkOperator::objectPathChanged(const QString &path, const QVariantMap *properties) { SUPER::objectPathChanged(path, properties); Q_EMIT operatorPathChanged(path); } QDBusAbstractInterface *QOfonoNetworkOperator::createDbusInterface(const QString &path) { 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; } 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::registerOperator() { 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; if (reply.isError()) { qWarning() << "QOfonoNetworkOperator::registerOperator() failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } 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 { return getString("Name"); } QString QOfonoNetworkOperator::status() const { return getString("Status"); } QString QOfonoNetworkOperator::mcc() const { return getString("MobileCountryCode"); } QString QOfonoNetworkOperator::mnc() const { return getString("MobileNetworkCode"); } QStringList QOfonoNetworkOperator::technologies() const { return getStringList("Technologies"); } QString QOfonoNetworkOperator::additionalInfo() const { return getString("AdditionalInformation"); } bool QOfonoNetworkOperator::isValid() const { return SUPER::isValid(); } QOfonoNetworkOperator::Private *QOfonoNetworkOperator::privateData() const { 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")) { Q_EMIT statusChanged(value.value()); } else if (property == QLatin1String("MobileCountryCode")) { Q_EMIT mccChanged(value.value()); } else if (property == QLatin1String("MobileNetworkCode")) { Q_EMIT mncChanged(value.value()); } else if (property == QLatin1String("Technologies")) { Q_EMIT technologiesChanged(value.value()); } else if (property == QLatin1String("AdditionalInformation")) { Q_EMIT additionalInfoChanged(value.value()); } } QOfonoNetworkOperator::Error QOfonoNetworkOperator::errorNameToEnum(const QString &errorName) { if (errorName == "") return NoError; else if (errorName == "org.ofono.Error.NotImplemented") return NotImplementedError; else if (errorName == "org.ofono.Error.InProgress") return InProgressError; else if (errorName == "org.ofono.Error.InvalidArguments") return InvalidArgumentsError; else if (errorName == "org.ofono.Error.InvalidFormat") return InvalidFormatError; else if (errorName == "org.ofono.Error.Failed") return FailedError; else return UnknownError; } ./src/qofonomodeminterface2.cpp0000644000004100000410000000715512762041045017035 0ustar www-datawww-data/**************************************************************************** ** ** 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; } ./src/qofonosimmanager.cpp0000644000004100000410000004114312762041064016110 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonosimmanager.h" #include "ofono_simmanager_interface.h" #define SUPER QOfonoModemInterface static const QString kPresent(QLatin1String("Present")); static const QString kSubscriberIdentity(QLatin1String("SubscriberIdentity")); static const QString kMobileCountryCode(QLatin1String("MobileCountryCode")); static const QString kMobileNetworkCode(QLatin1String("MobileNetworkCode")); static const QString kServiceProviderName(QLatin1String("ServiceProviderName")); static const QString kSubscriberNumbers(QLatin1String("SubscriberNumbers")); static const QString kServiceNumbers(QLatin1String("ServiceNumbers")); static const QString kPinRequired(QLatin1String("PinRequired")); static const QString kLockedPins(QLatin1String("LockedPins")); static const QString kCardIdentifier(QLatin1String("CardIdentifier")); static const QString kPreferredLanguages(QLatin1String("PreferredLanguages")); static const QString kRetries(QLatin1String("Retries")); static const QString kFixedDialing(QLatin1String("FixedDialing")); static const QString kBarredDialing(QLatin1String("BarredDialing")); 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) : SUPER(OfonoSimManager::staticInterfaceName(), parent) { } QOfonoSimManager::~QOfonoSimManager() { } QDBusAbstractInterface *QOfonoSimManager::createDbusInterface(const QString &path) { return new OfonoSimManager("org.ofono", path, QDBusConnection::systemBus(), this); } QVariant QOfonoSimManager::convertProperty(const QString &property, const QVariant &value) { // Perform necessary type conversions // This serve two purposes: // (1) Usability from QML side // (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) if (property == kServiceNumbers) { QVariantMap convertedNumbers; if (value.userType() == qMetaTypeId()) { QMap numbers; value.value() >> numbers; Q_FOREACH(const QString &key, numbers.keys()) { convertedNumbers.insert(key, numbers.value(key)); } } return convertedNumbers; } else if (property == kLockedPins) { QVariantList convertedPins; if (value.userType() == qMetaTypeId()) { QStringList pins = value.value(); Q_FOREACH(QString type, pins) { convertedPins << (int)pinTypeFromString(type); } } return convertedPins; } else if (property == kPinRequired) { // 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 == kRetries) { 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 convertedRetries; } else { return SUPER::convertProperty(property, value); } } void QOfonoSimManager::propertyChanged(const QString &property, const QVariant &value) { SUPER::propertyChanged(property, value); if (property == kPresent) { Q_EMIT presenceChanged(value.toBool()); } else if (property == kSubscriberIdentity) { Q_EMIT subscriberIdentityChanged(value.value()); } else if (property == kMobileCountryCode) { Q_EMIT mobileCountryCodeChanged(value.value()); } else if (property == kMobileNetworkCode) { Q_EMIT mobileNetworkCodeChanged(value.value()); } else if (property == kServiceProviderName) { Q_EMIT serviceProviderNameChanged(value.value()); } else if (property == kSubscriberNumbers) { Q_EMIT subscriberNumbersChanged(value.value()); } else if (property == kServiceNumbers) { Q_EMIT serviceNumbersChanged(getVariantMap(kServiceNumbers)); } else if (property == kPinRequired) { Q_EMIT pinRequiredChanged((PinType)getInt(kPinRequired)); } else if (property == kLockedPins) { Q_EMIT lockedPinsChanged(getVariantList(kLockedPins)); } else if (property == kCardIdentifier) { Q_EMIT cardIdentifierChanged(value.value()); } else if (property == kPreferredLanguages) { Q_EMIT preferredLanguagesChanged(value.value()); } else if (property == kRetries) { Q_EMIT pinRetriesChanged(getVariantMap(kRetries)); } else if (property == kFixedDialing) { Q_EMIT fixedDialingChanged(value.value()); } else if (property == kBarredDialing) { Q_EMIT barredDialingChanged(value.value()); } } bool QOfonoSimManager::present() const { return getBool(kPresent); } QString QOfonoSimManager::subscriberIdentity() const { return getString(kSubscriberIdentity); } QString QOfonoSimManager::mobileCountryCode() const { return getString(kMobileCountryCode); } QString QOfonoSimManager::mobileNetworkCode() const { return getString(kMobileNetworkCode); } QString QOfonoSimManager::serviceProviderName() const { return getString(kServiceProviderName); } QStringList QOfonoSimManager::subscriberNumbers() const { return getStringList(kSubscriberNumbers); } QVariantMap QOfonoSimManager::serviceNumbers() const // { return getVariantMap(kServiceNumbers); } QOfonoSimManager::PinType QOfonoSimManager::pinRequired() const { return (PinType)getInt(kPinRequired); } QVariantList QOfonoSimManager::lockedPins() const { return getVariantList(kLockedPins); } QString QOfonoSimManager::cardIdentifier() const { return getString(kCardIdentifier); } QStringList QOfonoSimManager::preferredLanguages() const { return getStringList(kPreferredLanguages); } QVariantMap QOfonoSimManager::pinRetries() const { return getVariantMap(kRetries); } bool QOfonoSimManager::fixedDialing() const { return getBool(kFixedDialing); } bool QOfonoSimManager::barredDialing() const { return getBool(kBarredDialing); } void QOfonoSimManager::setSubscriberNumbers(const QStringList &numbers) { setProperty(kSubscriberNumbers, numbers); } void QOfonoSimManager::changePin(QOfonoSimManager::PinType pinType, const QString &oldpin, const QString &newpin) { 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) { 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) { 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) { 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) { 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) { 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) { call->deleteLater(); QDBusPendingReply<> reply = *call; QOfonoSimManager::Error error = NoError; QString errorString; if (reply.isError()) { qWarning() << "QOfonoSimManager::changePin() failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } emit changePinComplete(error, errorString); } void QOfonoSimManager::enterPinCallFinished(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; QOfonoSimManager::Error error = NoError; QString errorString; if (reply.isError()) { qWarning() << "QOfonoSimManager::enterPin() failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } emit enterPinComplete(error, errorString); } void QOfonoSimManager::resetPinCallFinished(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; QOfonoSimManager::Error error = NoError; QString errorString; if (reply.isError()) { qWarning() << "QOfonoSimManager::resetPin() failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } emit resetPinComplete(error, errorString); } void QOfonoSimManager::lockPinCallFinished(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; QOfonoSimManager::Error error = NoError; QString errorString; if (reply.isError()) { qWarning() << "QOfonoSimManager::lockPin() failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } emit lockPinComplete(error, errorString); } void QOfonoSimManager::unlockPinCallFinished(QDBusPendingCallWatcher *call) { call->deleteLater(); QDBusPendingReply<> reply = *call; QOfonoSimManager::Error error = NoError; QString errorString; if (reply.isError()) { qWarning() << "QOfonoSimManager::unlockPin() failed:" << reply.error(); error = errorNameToEnum(reply.error().name()); errorString = reply.error().name() + " " + reply.error().message(); } emit unlockPinComplete(error, errorString); } QOfonoSimManager::Error QOfonoSimManager::errorNameToEnum(const QString &errorName) { if (errorName == "") return NoError; else if (errorName == "org.ofono.Error.NotImplemented") return NotImplementedError; else if (errorName == "org.ofono.Error.InProgress") return InProgressError; else if (errorName == "org.ofono.Error.InvalidArguments") return InvalidArgumentsError; else if (errorName == "org.ofono.Error.InvalidFormat") return InvalidFormatError; else if (errorName == "org.ofono.Error.Failed") return FailedError; else return UnknownError; } int QOfonoSimManager::minimumPinLength(QOfonoSimManager::PinType pinType) { if (isPukType(pinType)) return 8; switch (pinType) { case SimPin: case SimPin2: case PhoneToSimPin: case PhoneToFirstSimPin: case NetworkPersonalizationPin: case NetworkSubsetPersonalizationPin: case CorporatePersonalizationPin: return 4; default: return -1; } } int QOfonoSimManager::maximumPinLength(QOfonoSimManager::PinType pinType) { if (isPukType(pinType)) return 8; switch (pinType) { case SimPin: case SimPin2: return 8; case PhoneToSimPin: case PhoneToFirstSimPin: case NetworkPersonalizationPin: case NetworkSubsetPersonalizationPin: case CorporatePersonalizationPin: return 16; default: return -1; } } QString QOfonoSimManager::pinTypeToString(QOfonoSimManager::PinType pinType) { return QOfonoSimManagerPrivate::allPinTypes.value(pinType); } int QOfonoSimManager::pinTypeFromString(const QString &s) { return (int)QOfonoSimManagerPrivate::allPinTypes.key(s); } bool QOfonoSimManager::isPukType(QOfonoSimManager::PinType pinType) { switch (pinType) { case SimPuk: case SimPuk2: case PhoneToFirstSimPuk: case NetworkPersonalizationPuk: case NetworkSubsetPersonalizationPuk: case CorporatePersonalizationPuk: return true; default: return false; } } int QOfonoSimManager::pukToPin(QOfonoSimManager::PinType puk) { switch (puk) { case QOfonoSimManager::SimPuk: return (int)QOfonoSimManager::SimPin; case QOfonoSimManager::PhoneToFirstSimPuk: return (int)QOfonoSimManager::PhoneToFirstSimPin; case QOfonoSimManager::SimPuk2: return (int)QOfonoSimManager::SimPin2; case QOfonoSimManager::NetworkPersonalizationPuk: return (int)QOfonoSimManager::NetworkPersonalizationPin; case QOfonoSimManager::NetworkSubsetPersonalizationPuk: return (int)QOfonoSimManager::NetworkSubsetPersonalizationPin; case QOfonoSimManager::CorporatePersonalizationPuk: return (int)QOfonoSimManager::CorporatePersonalizationPin; default: return (int)QOfonoSimManager::NoPin; } } QString QOfonoSimManager::modemPath() const { return SUPER::modemPath(); } void QOfonoSimManager::setModemPath(const QString &path) { SUPER::setModemPath(path); } bool QOfonoSimManager::isValid() const { return SUPER::isValid(); } ./src/qofono-qt5.prf0000644000004100000410000000025212762041045014553 0ustar www-datawww-dataprefix=/usr exec_prefix=$${prefix} DEPENDPATH += $${prefix}/include/qofono-qt5 INCLUDEPATH += $${prefix}/include/qofono-qt5 LIBS += -L $${exec_prefix}/lib -lqofono-qt5 ./src/qofonomodeminterface.h0000644000004100000410000000404312762041064016412 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2014-2015 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; public: bool isValid() const; void fixModemPath(const QString &path); 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 Q_SLOTS: void onModemInterfacesChanged(const QStringList &interfaces); void onModemValidChanged(bool valid); private: class Private; Private* privateData() const; }; #endif // QOFONOMODEMINTERFACE_H ./src/qofonosupplementaryservices.h0000644000004100000410000000570612762041045020112 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOSupplimentaryServices_H #define QOFONOSupplimentaryServices_H #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 QOFONOSHARED_EXPORT QOfonoSupplementaryServices : public QOfonoModemInterface { Q_OBJECT Q_PROPERTY(QString state READ state NOTIFY stateChanged) public: explicit QOfonoSupplementaryServices(QObject *parent = 0); ~QOfonoSupplementaryServices(); QString modemPath() const; void setModemPath(const QString &path); QString state() const; bool isValid() const; Q_INVOKABLE void initiate(const QString &command); Q_INVOKABLE void respond(const QString &reply); Q_INVOKABLE void cancel(); Q_SIGNALS: void notificationReceived(const QString &message); void requestReceived(const QString &message); void ussdResponse(const QString &response); void callBarringResponse(const QString &ssOp, const QString &cbService, const QVariantMap &cbMap); void callForwardingResponse(const QString &ssOp, const QString &cfService, const QVariantMap &cfMap); void callWaitingResponse(const QString &ssOp, const QVariantMap &cwMap); void callingLinePresentationResponse(const QString &ssOp, const QString &status); void connectedLinePresentationResponse(const QString &ssOp, const QString &status); void callingLineRestrictionResponse(const QString &ssOp, const QString &status); void connectedLineRestrictionResponse(const QString &ssOp, const QString &status); void initiateFailed(); void respondComplete(bool success, const QString &message); void cancelComplete(bool success); void stateChanged(const QString &state); void modemPathChanged(const QString &path); protected: QDBusAbstractInterface *createDbusInterface(const QString &path); void propertyChanged(const QString &key, const QVariant &value); private slots: void initiateResponseReceived(QDBusPendingCallWatcher*); void respondResponseReceived(QDBusPendingCallWatcher*); void cancelResponseReceived(QDBusPendingCallWatcher*); }; #endif // QOFONOSupplimentaryServices_H ./src/qofonoutils_p.h0000644000004100000410000000313112762041064015104 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2014-2016 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONOUTILS_P_H #define QOFONOUTILS_P_H #include "qofono_global.h" namespace qofono { /* Carefully compare variant values, handling invalid and null values properly. * Intentionally not using isNull() as its semantic is not optimal for our use * case. E.g.: * QVariant(QString("")).isNull() != QVariant(QString()).isNull() */ inline bool safeVariantEq(const QVariant &v1, const QVariant &v2) { if (!v1.isValid() && !v2.isValid()) return true; if (!v1.isValid() && v2 == QVariant(v2.type())) return true; if (!v2.isValid() && v1 == QVariant(v1.type())) return true; return v1 == v2; } inline bool isTimeout(const QDBusError &error) { switch (error.type()) { case QDBusError::NoReply: case QDBusError::Timeout: case QDBusError::TimedOut: return true; default: return false; } } } #endif // QOFONOUTILS_P_H ./src/qofonophonebook.cpp0000644000004100000410000000534112762041045015750 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonophonebook.h" #include "ofono_phonebook_interface.h" #define SUPER QOfonoModemInterface2 class QOfonoPhonebook::Private : public SUPER::ExtData { public: bool importing; Private() : importing(false) {} }; QOfonoPhonebook::QOfonoPhonebook(QObject *parent) : SUPER(OfonoPhonebook::staticInterfaceName(), new Private, parent) { } QOfonoPhonebook::~QOfonoPhonebook() { } QDBusAbstractInterface *QOfonoPhonebook::createDbusInterface(const QString &path) { return new OfonoPhonebook("org.ofono", path, QDBusConnection::systemBus(), this); } void QOfonoPhonebook::dbusInterfaceDropped() { SUPER::dbusInterfaceDropped(); Private *d_ptr = privateData(); if (d_ptr->importing) { d_ptr->importing = false; Q_EMIT importingChanged(); } } bool QOfonoPhonebook::importing() const { return privateData()->importing; } void QOfonoPhonebook::beginImport() { 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::onImportFinished(QDBusPendingCallWatcher *watch) { watch->deleteLater(); QDBusPendingReply reply(*watch); if (!reply.isError()) { Q_EMIT importReady(reply.value()); } else { Q_EMIT importFailed(); } 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 SUPER::isValid(); } QOfonoPhonebook::Private *QOfonoPhonebook::privateData() const { return (QOfonoPhonebook::Private*)SUPER::extData(); } ./README0000644000004100000410000000021612762041045012123 0ustar www-datawww-dataqofono ====== A library for accessing the ofono daemon, and a declarative plugin for it. This allows accessing ofono in qtquick and friends. ./COPYING0000644000004100000410000006364212762041045012312 0ustar www-datawww-data GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. 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 Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! ./test/0000755000004100000410000000000012762041045012223 5ustar www-datawww-data./test/test.pro0000644000004100000410000000017212762041045013724 0ustar www-datawww-dataTEMPLATE = subdirs CONFIG += ordered SUBDIRS += auto/tst_qofono SUBDIRS += auto/tests #SUBDIRS += auto/tst_location ./test/auto/0000755000004100000410000000000012762041045013173 5ustar www-datawww-data./test/auto/tests/0000755000004100000410000000000012762041045014335 5ustar www-datawww-data./test/auto/tests/tst_qofonomanager.pro0000644000004100000410000000011512762041045020602 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonomanager.cpp ./test/auto/tests/tst_qofonomultipartycall.pro0000644000004100000410000000007612762041045022244 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonomultipartycall.cpp ./test/auto/tests/tst_qofonocallvolume.pro0000644000004100000410000000007212762041045021335 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonocallvolume.cpp ./test/auto/tests/tst_qofonocallforwarding.cpp0000644000004100000410000002104612762041045022156 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonocallforwarding.h" class TestQOfonoCallForwarding : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoCallForwarding(this); m->setModemPath("/phonesim"); QSignalSpy ready(m, SIGNAL(readyChanged())); QTRY_VERIFY(m->isValid()); QTRY_VERIFY(m->isReady()); QCOMPARE(ready.count(), 1); } void testQOfonoCallForwarding() { QSignalSpy voiceUnconditionalComplete(m, SIGNAL(voiceUnconditionalComplete(bool))); QSignalSpy voiceBusyComplete(m, SIGNAL(voiceBusyComplete(bool))); QSignalSpy voiceNoReplyComplete(m, SIGNAL(voiceNoReplyComplete(bool))); QSignalSpy voiceNoReplyTimeoutComplete(m, SIGNAL(voiceNoReplyTimeoutComplete(bool))); QSignalSpy voiceNotReachableComplete(m, SIGNAL(voiceNotReachableComplete(bool))); QSignalSpy voiceUnconditionalChanged(m, SIGNAL(voiceUnconditionalChanged(QString))); QSignalSpy voiceBusyChanged(m, SIGNAL(voiceBusyChanged(QString))); QSignalSpy voiceNoReplyChanged(m, SIGNAL(voiceNoReplyChanged(QString))); QSignalSpy voiceNoReplyTimeoutChanged(m, SIGNAL(voiceNoReplyTimeoutChanged(ushort))); QSignalSpy voiceNotReachableChanged(m, SIGNAL(voiceNotReachableChanged(QString))); QSignalSpy forwardingFlagOnSimChanged(m, SIGNAL(forwardingFlagOnSimChanged(bool))); QCOMPARE(m->voiceUnconditional(), QString("")); QCOMPARE(m->voiceBusy(), QString("")); QCOMPARE(m->voiceNoReply(), QString("")); QCOMPARE(m->voiceNoReplyTimeout(), quint16(20)); QCOMPARE(m->voiceNotReachable(), QString("")); QCOMPARE(m->forwardingFlagOnSim(), false); m->setVoiceUnconditional("abc"); QTRY_COMPARE(voiceUnconditionalComplete.count(), 1); QCOMPARE(voiceUnconditionalComplete.takeFirst().at(0).toBool(), false); m->setVoiceBusy("abc"); QTRY_COMPARE(voiceBusyComplete.count(), 1); QCOMPARE(voiceBusyComplete.takeFirst().at(0).toBool(), false); m->setVoiceNoReply("abc"); QTRY_COMPARE(voiceNoReplyComplete.count(), 1); QCOMPARE(voiceNoReplyComplete.takeFirst().at(0).toBool(), false); m->setVoiceNoReplyTimeout(-30); QTRY_COMPARE(voiceNoReplyTimeoutComplete.count(), 1); QCOMPARE(voiceNoReplyTimeoutComplete.takeFirst().at(0).toBool(), false); m->setVoiceNotReachable("abc"); QTRY_COMPARE(voiceNotReachableComplete.count(), 1); QCOMPARE(voiceNotReachableComplete.takeFirst().at(0).toBool(), false); m->setVoiceBusy("12345678"); QTRY_COMPARE(voiceBusyComplete.count(), 1); QCOMPARE(voiceBusyComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceBusyChanged.count(), 1); QCOMPARE(voiceBusyChanged.takeFirst().at(0).toString(), QString("12345678")); m->setVoiceNoReply("12345678"); QTRY_COMPARE(voiceNoReplyComplete.count(), 1); QCOMPARE(voiceNoReplyComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceNoReplyChanged.count(), 1); QCOMPARE(voiceNoReplyChanged.takeFirst().at(0).toString(), QString("12345678")); m->setVoiceNoReplyTimeout(30); QTRY_COMPARE(voiceNoReplyTimeoutComplete.count(), 1); QCOMPARE(voiceNoReplyTimeoutComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceNoReplyTimeoutChanged.count(), 1); QCOMPARE(voiceNoReplyTimeoutChanged.takeFirst().at(0).value(), quint16(30)); m->setVoiceNotReachable("12345678"); QTRY_COMPARE(voiceNotReachableComplete.count(), 1); 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); QTRY_COMPARE(voiceUnconditionalChanged.count(), 1); QCOMPARE(voiceUnconditionalChanged.takeFirst().at(0).toString(), QString("12345678")); QTRY_COMPARE(forwardingFlagOnSimChanged.count(), 1); QCOMPARE(forwardingFlagOnSimChanged.takeFirst().at(0).toBool(), true); // 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->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); QCOMPARE(voiceNoReplyChanged.takeFirst().at(0).toString(), QString("")); QTRY_COMPARE(voiceNoReplyTimeoutChanged.count(), 1); QCOMPARE(voiceNoReplyTimeoutChanged.takeFirst().at(0).toUInt(), uint(20)); QTRY_COMPARE(voiceNotReachableChanged.count(), 1); QCOMPARE(voiceNotReachableChanged.takeFirst().at(0).toString(), QString("")); QTRY_COMPARE(forwardingFlagOnSimChanged.count(), 0); QCOMPARE(m->voiceUnconditional(), QString("")); QCOMPARE(m->voiceBusy(), QString("")); QCOMPARE(m->voiceNoReply(), QString("")); QCOMPARE(m->voiceNoReplyTimeout(), quint16(20)); QCOMPARE(m->voiceNotReachable(), QString("")); QCOMPARE(m->forwardingFlagOnSim(), false); } void cleanupTestCase() { } private: QOfonoCallForwarding *m; }; QTEST_MAIN(TestQOfonoCallForwarding) #include "tst_qofonocallforwarding.moc" ./test/auto/tests/tst_qofonophonebook.cpp0000644000004100000410000000354612762041045021151 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonophonebook.h" class TestQOfonoPhonebook : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoPhonebook(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoPhonebook() { QSignalSpy importingChanged(m, SIGNAL(importingChanged())); QSignalSpy importReady(m, SIGNAL(importReady(QString))); QCOMPARE(m->importing(), false); m->beginImport(); QTRY_COMPARE(importingChanged.count(), 1); importingChanged.takeFirst(); QCOMPARE(m->importing(), true); QTRY_COMPARE(importingChanged.count(), 1); importingChanged.takeFirst(); QCOMPARE(m->importing(), false); QTRY_COMPARE(importReady.count(), 1); QVERIFY(!importReady.takeFirst().at(0).toString().isEmpty()); } void cleanupTestCase() { } private: QOfonoPhonebook *m; }; QTEST_MAIN(TestQOfonoPhonebook) #include "tst_qofonophonebook.moc" ./test/auto/tests/tst_qofonomodem.cpp0000644000004100000410000002065712762041045020270 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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/qofonomanager.h" #include "../../../src/qofonomodem.h" #include class TestQOfonoModem : public QObject { Q_OBJECT static const int INTERACTIVE_STEP_TIMEOUT = 30000; // The same as the QTRY_* macros use static const int REASONABLE_TIMEOUT = 5000; static const int REASONABLE_TIMEOUT_AFTER_RESTART = 10000; public: TestQOfonoModem() : mm(0) { } private slots: void init() { delete mm; mm = new QOfonoModem(this); mm->setModemPath("/phonesim"); mm->setPowered(true); QTRY_VERIFY(mm->powered()); mm->setOnline(true); QTRY_VERIFY(mm->online()); } void testQOfonoModem() { QVERIFY(mm->isValid()); QVERIFY(mm->powered()); QVERIFY(mm->online()); QVERIFY(!mm->lockdown()); QVERIFY(!mm->emergency()); QVERIFY(mm->features().count() > 0); QVERIFY(mm->interfaces().count() > 0); QCOMPARE(mm->modemPath(), QString("/phonesim")); QCOMPARE(mm->name(), QString()); QCOMPARE(mm->manufacturer(), QString("MeeGo")); QCOMPARE(mm->model(), QString("Synthetic Device")); QCOMPARE(mm->revision(), QString("REV1")); QCOMPARE(mm->serial(), QString("1234567890")); QCOMPARE(mm->type(), QString("hardware")); } void testQOfonoModemAddRemove() { QSignalSpy valid(mm, SIGNAL(validChanged(bool))); QSignalSpy modemPath(mm, SIGNAL(modemPathChanged(QString))); QVERIFY(mm->isValid()); QOfonoManager *manager = new QOfonoManager(this); QSignalSpy availableChanged(manager, SIGNAL(availableChanged(bool))); qDebug() << "Please stop oFono and then start it again"; QTRY_COMPARE_WITH_TIMEOUT(availableChanged.count(), 2, INTERACTIVE_STEP_TIMEOUT); QCOMPARE(availableChanged.takeFirst().at(0).toBool(), false); QCOMPARE(availableChanged.takeFirst().at(0).toBool(), true); QTRY_VERIFY(manager->modems().contains("/phonesim")); QTest::qWait(REASONABLE_TIMEOUT); QEXPECT_FAIL("", "Modem not invalidated when oFono is stopped", Continue); QCOMPARE(valid.count(), 1); // Uncomment when above is fixed //QCOMPARE(valid.takeFirst().at(0).toBool(), false); //QVERIFY(!mm->isValid()); } void testQOfonoModemPowercycle() { // TODO: Workaround. Find a way to detect oFono is fully up. Without this // the QCOMPARE(manufacturer.count(), 0) test below fails. QTest::qWait(REASONABLE_TIMEOUT_AFTER_RESTART); QSignalSpy powered(mm, SIGNAL(poweredChanged(bool))); QSignalSpy online(mm, SIGNAL(onlineChanged(bool))); QSignalSpy lockdown(mm, SIGNAL(lockdownChanged(bool))); QSignalSpy emergency(mm, SIGNAL(emergencyChanged(bool))); QSignalSpy name(mm, SIGNAL(nameChanged(QString))); QSignalSpy manufacturer(mm, SIGNAL(manufacturerChanged(QString))); QSignalSpy model(mm, SIGNAL(modelChanged(QString))); QSignalSpy revision(mm, SIGNAL(revisionChanged(QString))); QSignalSpy serial(mm, SIGNAL(serialChanged(QString))); QSignalSpy type(mm, SIGNAL(typeChanged(QString))); QSignalSpy features(mm, SIGNAL(featuresChanged(QStringList))); QSignalSpy interfaces(mm, SIGNAL(interfacesChanged(QStringList))); mm->setOnline(false); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(powered.count(), 0); QCOMPARE(online.count(), 1); QCOMPARE(online.takeFirst().at(0).toBool(), false); QCOMPARE(emergency.count(), 0); QCOMPARE(name.count(), 0); QCOMPARE(manufacturer.count(), 0); QCOMPARE(model.count(), 0); QCOMPARE(revision.count(), 0); QCOMPARE(serial.count(), 0); QCOMPARE(type.count(), 0); QVERIFY(features.count() > 0); QVERIFY(features.takeLast().at(0).toStringList().count() > 0); features.clear(); QVERIFY(interfaces.count() > 0); QVERIFY(interfaces.takeLast().at(0).toStringList().count() > 0); interfaces.clear(); mm->setPowered(false); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(powered.count(), 1); QCOMPARE(powered.takeFirst().at(0).toBool(), false); QCOMPARE(online.count(), 0); QCOMPARE(emergency.count(), 0); QCOMPARE(name.count(), 0); QCOMPARE(manufacturer.count(), 0); QCOMPARE(model.count(), 0); QCOMPARE(revision.count(), 0); QCOMPARE(serial.count(), 0); QCOMPARE(type.count(), 0); QVERIFY(features.count() > 0); QCOMPARE(features.takeLast().at(0).toStringList().count(), 0); features.clear(); QVERIFY(interfaces.count() > 0); QEXPECT_FAIL("", "org.ofono.SmsHistory remains available even when poweroff - ok?", Continue); qDebug() << "interfaces: " << interfaces.last().at(0).toStringList(); QCOMPARE(interfaces.takeLast().at(0).toStringList().count(), 0); interfaces.clear(); mm->setLockdown(true); QTRY_COMPARE(lockdown.count(), 1); QCOMPARE(lockdown.takeFirst().at(0).toBool(), true); mm->setLockdown(false); QTRY_COMPARE(lockdown.count(), 1); QCOMPARE(lockdown.takeFirst().at(0).toBool(), false); mm->setOnline(true); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(powered.count(), 0); QCOMPARE(online.count(), 0); QCOMPARE(emergency.count(), 0); QCOMPARE(name.count(), 0); QCOMPARE(manufacturer.count(), 0); QCOMPARE(model.count(), 0); QCOMPARE(revision.count(), 0); QCOMPARE(serial.count(), 0); QCOMPARE(type.count(), 0); QCOMPARE(features.count(), 0); QCOMPARE(interfaces.count(), 0); // FIXME: This does not seem to be valid - These properties actually // do not change. mm->setPowered(true); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(powered.count(), 1); QCOMPARE(powered.takeFirst().at(0).toBool(), true); QCOMPARE(online.count(), 0); QCOMPARE(emergency.count(), 0); QCOMPARE(name.count(), 0); QCOMPARE(manufacturer.count(), 1); manufacturer.takeFirst(); QCOMPARE(model.count(), 1); model.takeFirst(); QCOMPARE(revision.count(), 1); revision.takeFirst(); QCOMPARE(serial.count(), 1); serial.takeFirst(); QCOMPARE(type.count(), 0); QVERIFY(features.count() > 0); QVERIFY(features.takeLast().at(0).toStringList().count() > 0); features.clear(); QVERIFY(interfaces.count() > 0); QVERIFY(interfaces.takeLast().at(0).toStringList().count() > 0); interfaces.clear(); mm->setOnline(true); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(powered.count(), 0); QCOMPARE(online.count(), 1); QCOMPARE(online.takeFirst().at(0).toBool(), true); QCOMPARE(emergency.count(), 0); QCOMPARE(name.count(), 0); QCOMPARE(manufacturer.count(), 0); QCOMPARE(model.count(), 0); QCOMPARE(revision.count(), 0); QCOMPARE(serial.count(), 0); QCOMPARE(type.count(), 0); QVERIFY(features.count() > 0); QVERIFY(features.takeLast().at(0).toStringList().count() > 0); features.clear(); QVERIFY(interfaces.count() > 0); QVERIFY(interfaces.takeLast().at(0).toStringList().count() > 0); interfaces.clear(); } void cleanupTestCase() { } private: QOfonoModem *mm; }; QTEST_MAIN(TestQOfonoModem) #include "tst_qofonomodem.moc" ./test/auto/tests/tst_qofononetworkregistration.cpp0000644000004100000410000000727412762041045023313 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofononetworkregistration.h" #include "qofonomodem.h" class TestQOfonoNetworkRegistration : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoNetworkRegistration(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoNetworkRegistration() { QOfonoModem modem; modem.setModemPath(m->modemPath()); QSignalSpy mode(m, SIGNAL(modeChanged(QString))); QSignalSpy status(m, SIGNAL(statusChanged(QString))); QSignalSpy lac(m, SIGNAL(locationAreaCodeChanged(uint))); QSignalSpy cellId(m, SIGNAL(cellIdChanged(uint))); QSignalSpy mcc(m, SIGNAL(mccChanged(QString))); QSignalSpy mnc(m, SIGNAL(mncChanged(QString))); QSignalSpy tech(m, SIGNAL(technologyChanged(QString))); QSignalSpy name(m, SIGNAL(nameChanged(QString))); QSignalSpy strength(m, SIGNAL(strengthChanged(uint))); QSignalSpy base(m, SIGNAL(baseStationChanged(QString))); QSignalSpy scanFinished(m, SIGNAL(scanFinished())); QSignalSpy scanError(m, SIGNAL(scanError(QString))); QVERIFY(m->mode().length() > 0); QCOMPARE(m->status(), QString("registered")); QCOMPARE(m->mcc(), QString("234")); QCOMPARE(m->mnc(), QString("01")); QVERIFY(m->name().length() > 0); QCOMPARE(m->strength(), uint(100)); m->scan(); QTRY_COMPARE(scanFinished.count(), 1); scanFinished.clear(); QVERIFY(scanError.isEmpty()); QVERIFY(m->networkOperators().count() > 0); modem.setOnline(false); QTRY_COMPARE(modem.online(), false); modem.setOnline(true); QTRY_COMPARE(modem.online(), true); 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")); QTRY_COMPARE(mcc.count(), 2); QCOMPARE(mcc.takeFirst().at(0).toString(), QString("")); QCOMPARE(mcc.takeFirst().at(0).toString(), QString("234")); QTRY_COMPARE(mnc.count(), 2); QCOMPARE(mnc.takeFirst().at(0).toString(), QString("")); QCOMPARE(mnc.takeFirst().at(0).toString(), QString("01")); QTRY_COMPARE(name.count(), 2); QVERIFY(name.takeFirst().at(0).toString().isEmpty()); QVERIFY(name.takeFirst().at(0).toString().length() > 0); QTRY_COMPARE(strength.count(), 2); QCOMPARE(strength.takeFirst().at(0).toUInt(), uint(0)); QCOMPARE(strength.takeFirst().at(0).toUInt(), uint(100)); } void cleanupTestCase() { } private: QOfonoNetworkRegistration *m; }; QTEST_MAIN(TestQOfonoNetworkRegistration) #include "tst_qofononetworkregistration.moc" ./test/auto/tests/tst_qofonosimmanager.pro0000644000004100000410000000012012762041045021307 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonosimmanager.cpp ./test/auto/tests/tests.pro0000644000004100000410000000135312762041045016223 0ustar www-datawww-dataTEMPLATE = subdirs SUBDIRS += \ tests.xml.pro \ tst_qofonomanager.pro \ tst_qofonomodem.pro \ tst_qofonoconnman.pro \ tst_qofonoconnmancontext.pro \ tst_qofononetworkoperator.pro \ tst_qofonophonebook.pro \ tst_qofononetworkregistration.pro \ tst_qofonosimmanager.pro \ tst_qofonomessagewaiting.pro \ tst_qofonomessagemanager.pro \ tst_qofonoradiosettings.pro \ tst_qofonocallbarring.pro \ tst_qofonocallforwarding.pro \ tst_qofonocallmeter.pro \ tst_qofonocallsettings.pro \ tst_qofonosupplementaryservices.pro \ tst_qofonovoicecallmanager.pro \ tst_qofonovoicecall.pro \ tst_qofonocallvolume.pro \ tst_qofonomultipartycall.pro \ tst_qofonocellbroadcast.pro ./test/auto/tests/tst_qofonovoicecall.pro0000644000004100000410000000007112762041045021132 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonovoicecall.cpp ./test/auto/tests/testcase.pri0000644000004100000410000000060012762041045016660 0ustar www-datawww-dataCONFIG += testcase QT = core testlib dbus QOFONO_DIR = ../../../src/ INCLUDEPATH += ../lib ../ $$QOFONO_DIR equals(QT_MAJOR_VERSION, 4): { LIBS += -L$$QOFONO_DIR -lqofono target.path = $$[QT_INSTALL_LIBS]/libqofono/tests } equals(QT_MAJOR_VERSION, 5): { LIBS += -L$$QOFONO_DIR -lqofono-qt5 target.path = $$[QT_INSTALL_LIBS]/libqofono-qt5/tests } INSTALLS += target ./test/auto/tests/tst_qofonoconnman.cpp0000644000004100000410000000734312762041045020615 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonoconnectioncontext.h" #include "qofonoconnectionmanager.h" class TestOfonoConnMan : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoConnectionManager(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); QTRY_VERIFY(m->powered()); } void testOfonoConnMan() { 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 add(m, SIGNAL(contextAdded(QString))); QSignalSpy rem(m, SIGNAL(contextRemoved(QString))); m->setPowered(false); QTRY_COMPARE(pow.count(), 1); QCOMPARE(pow.takeFirst().at(0).toBool(), false); QCOMPARE(m->powered(), false); m->setPowered(true); 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); QCOMPARE(m->roamingAllowed(), false); m->setRoamingAllowed(true); 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); QCOMPARE(m->powered(),true); QCOMPARE(m->attached(),true); QCOMPARE(m->suspended(),false); QCOMPARE(m->roamingAllowed(),true); QString path = add.takeFirst().at(0).toString(); m->removeContext(path); QTRY_COMPARE(rem.count(), 1); QCOMPARE(rem.takeFirst().at(0).toString(), path); m->addContext(QString("internet")); QTRY_COMPARE(add.count(), 1); path = add.takeFirst().at(0).toString(); QOfonoConnectionContext* contextInternet = new QOfonoConnectionContext(this); contextInternet->setContextPath(path); m->addContext(QString("mms")); QTRY_COMPARE(add.count(), 1); path = add.takeFirst().at(0).toString(); QOfonoConnectionContext* contextMms = new QOfonoConnectionContext(this); contextMms->setContextPath(path); contextInternet->setActive(true); contextMms->setActive(true); QTRY_VERIFY(contextInternet->active() && contextMms->active()); m->deactivateAll(); QTRY_VERIFY(!contextInternet->active()); QTRY_VERIFY(!contextMms->active()); QCOMPARE(rem.count(), 0); } void cleanupTestCase() { } private: QOfonoConnectionManager *m; }; QTEST_MAIN(TestOfonoConnMan) #include "tst_qofonoconnman.moc" ./test/auto/tests/tst_qofononetworkoperator.pro0000644000004100000410000000012512762041045022436 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofononetworkoperator.cpp ./test/auto/tests/tst_qofonovoicecall.cpp0000644000004100000410000001615212762041045021123 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonovoicecallmanager.h" #include "qofonovoicecall.h" // FIXME: Not aligned with the current API class TestQOfonoVoiceCall : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoVoiceCallManager( this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoVoiceCall() { QSignalSpy dialreg(m,SIGNAL(dialComplete(bool))); QSignalSpy dspy(m, SIGNAL(callAdded(QString))); // Dial and hangup m->dial("123",""); QTest::qWait(1000); QCOMPARE(dialreg.count(), 1); QCOMPARE(dialreg.takeFirst().at(0).toBool(),true); QCOMPARE(dspy.count(), 1); QString callid = dspy.takeFirst().at(0).toString(); QOfonoVoiceCall* call = new QOfonoVoiceCall(this); call->setVoiceCallPath(callid); QTRY_VERIFY(call->isValid()); QSignalSpy state(call, SIGNAL(stateChanged(QString))); QSignalSpy discreason(call,SIGNAL(disconnectReason(QString))); QSignalSpy hspy(call, SIGNAL(hangupComplete(bool))); QSignalSpy li (call, SIGNAL(lineIdentificationChanged(QString))); QSignalSpy name (call, SIGNAL(nameChanged(QString))); QSignalSpy info (call, SIGNAL(informationChanged(QString))); QSignalSpy mp (call, SIGNAL(multipartyChanged(bool))); QSignalSpy em (call, SIGNAL(emergencyChanged(bool))); QSignalSpy st (call, SIGNAL(startTimeChanged(QString))); QSignalSpy ic (call, SIGNAL(iconChanged(quint8))); qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button"; QTest::qWait(15000); QVERIFY(state.count()>0); QVERIFY(st.count()>0); QVERIFY(ic.count()==0); QVERIFY(em.count()==0); QVERIFY(mp.count()==0); QVERIFY(info.count()==0); QVERIFY(name.count()==0); QVERIFY(li.count()==0); QCOMPARE(call->state(),QString("active")); QCOMPARE(call->lineIdentification(),QString("123")); QCOMPARE(call->emergency(),false); QCOMPARE(call->multiparty(),false); QCOMPARE(call->name(),QString("")); QCOMPARE(call->information(),QString("")); call->hangup(); QTest::qWait(5000); QCOMPARE(hspy.count(), 1); QCOMPARE(hspy.takeFirst().at(0).toBool(),true); QCOMPARE(discreason.count(), 1); QCOMPARE(discreason.takeFirst().at(0).toString(), QString("local")); delete call; } void testQOfonoVoiceCallStep2() { //Dial failure, incoming, answer and local hangup QSignalSpy callsignal(m, SIGNAL(callAdded(QString))); m->dial("199",""); QTest::qWait(8000); QCOMPARE(callsignal.count(),1); QString callid = callsignal.takeFirst().at(0).toString(); QOfonoVoiceCall* call = new QOfonoVoiceCall(this); call->setVoiceCallPath(callid); QSignalSpy state(call, SIGNAL(stateChanged(QString))); QSignalSpy time(call,SIGNAL(startTimeChanged(QString))); QSignalSpy discreason(call,SIGNAL(disconnectReason(QString))); QSignalSpy hspy(call, SIGNAL(hangupComplete(bool))); QSignalSpy aspy(call, SIGNAL(answerComplete(bool))); QSignalSpy li (call, SIGNAL(lineIdentificationChanged(QString))); QSignalSpy name (call, SIGNAL(nameChanged(QString))); QSignalSpy info (call, SIGNAL(informationChanged(QString))); QSignalSpy mp (call, SIGNAL(multipartyChanged(bool))); QSignalSpy em (call, SIGNAL(emergencyChanged(bool))); QSignalSpy ic (call, SIGNAL(iconChanged(quint8))); QTest::qWait(8000); QCOMPARE(call->state(),QString("incoming")); call->answer(); QTest::qWait(10000); QVERIFY(state.count()>0); QCOMPARE(call->lineIdentification(),QString("1234567")); //PhoneSim specific value QVERIFY(time.count()>0); QCOMPARE(aspy.count(), 1); QCOMPARE(aspy.takeFirst().at(0).toBool(),true); QVERIFY(ic.count()==0); QVERIFY(em.count()==0); QVERIFY(mp.count()==0); QVERIFY(info.count()==0); QVERIFY(name.count()==0); QVERIFY(li.count()==0); call->hangup(); QTest::qWait(5000); QCOMPARE(hspy.count(), 1); QCOMPARE(hspy.takeFirst().at(0).toBool(), true); QCOMPARE(discreason.count(), 1); QCOMPARE(discreason.takeFirst().at(0).toString(), QString("local")); delete call; } void testQOfonoVoiceCallStep3() { //Dial failed, incoming, no answer and state change to disconnect QSignalSpy callsignal(m, SIGNAL(callAdded(QString))); m->dial("177",""); QTest::qWait(3000); QCOMPARE(callsignal.count(),1); QString callid = callsignal.takeFirst().at(0).toString(); QOfonoVoiceCall* call = new QOfonoVoiceCall(this); call->setVoiceCallPath(callid); QSignalSpy state(call, SIGNAL(stateChanged(QString))); QSignalSpy discreason(call,SIGNAL(disconnectReason(QString))); QTest::qWait(1000); QCOMPARE(call->state(),QString("incoming")); QTest::qWait(8000); QVERIFY(state.count()>0); QCOMPARE(discreason.count(), 1); QCOMPARE(discreason.takeFirst().at(0).toString(), QString("remote")); delete call; } void testQOfonoVoiceCallStep4() { //Deflect QSignalSpy callsignal(m, SIGNAL(callAdded(QString))); m->dial("199",""); QTest::qWait(8000); QCOMPARE(callsignal.count(),1); QString callid = callsignal.takeFirst().at(0).toString(); QOfonoVoiceCall* call = new QOfonoVoiceCall(this); call->setVoiceCallPath(callid); QSignalSpy dfspy(call, SIGNAL(deflectComplete(bool))); QTest::qWait(8000); QCOMPARE(call->state(),QString("incoming")); QCOMPARE(call->lineIdentification(),QString("1234567")); //PhoneSim specific value call->deflect("2345"); QTest::qWait(8000); QCOMPARE(dfspy.count(), 1); QCOMPARE(dfspy.takeFirst().at(0).toBool(), true); QTest::qWait(10000); delete call; } void cleanupTestCase() { } private: QOfonoVoiceCallManager *m; }; QTEST_MAIN(TestQOfonoVoiceCall) #include "tst_qofonovoicecall.moc" ./test/auto/tests/tst_qofonoconnmancontext.cpp0000644000004100000410000001512312762041045022215 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonomanager.h" #include "qofonoconnectionmanager.h" #include "qofonoconnectioncontext.h" #include class TestQOfonoConnectionManagerContext : public QObject { Q_OBJECT // The same as the QTRY_* macros use static const int REASONABLE_TIMEOUT = 5000; private slots: void initTestCase() { QOfonoManager manager; m = new QOfonoConnectionManager(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); QTRY_VERIFY(m->powered()); } void testQOfonoConnectionManagerContext () { QSignalSpy conadd(m, SIGNAL(contextAdded(QString))); QSignalSpy conrem(m, SIGNAL(contextRemoved(QString))); m->addContext("internet"); QTRY_COMPARE(conadd.count(), 1); QString contextid = conadd.takeFirst().at(0).toString(); QVERIFY(m->contexts().contains(contextid)); 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))); QSignalSpy name(context, SIGNAL(nameChanged(QString))); QSignalSpy type (context, SIGNAL(typeChanged(QString))); QSignalSpy uname (context, SIGNAL(usernameChanged(QString))); QSignalSpy pw (context, SIGNAL(passwordChanged(QString))); QSignalSpy proto (context, SIGNAL(protocolChanged(QString))); QSignalSpy sett (context, SIGNAL(settingsChanged(QVariantMap))); QSignalSpy sett6 (context, SIGNAL(IPv6SettingsChanged(QVariantMap))); context->setAccessPointName("hyva"); QTRY_COMPARE(apn.count(), 1); QCOMPARE(apn.takeFirst().at(0).toString(), QString("hyva")); context->setUsername("huomenta"); QTRY_COMPARE(uname.count(), 1); QCOMPARE(uname.takeFirst().at(0).toString(), QString("huomenta")); context->setPassword("HYVA"); QTRY_COMPARE(pw.count(), 1); QCOMPARE(pw.takeFirst().at(0).toString(), QString("HYVA")); context->setName("yota"); QTRY_COMPARE(name.count(), 1); QCOMPARE(name.takeFirst().at(0).toString(), QString("yota")); context->setType("mms"); QTRY_COMPARE(type.count(), 1); QCOMPARE(type.takeFirst().at(0).toString(), QString("mms")); context->setProtocol("ipv6"); QTRY_COMPARE(proto.count(), 1); QCOMPARE(proto.takeFirst().at(0).toString(), QString("ipv6")); context->setActive(true); QTRY_COMPARE(active.count(), 1); QCOMPARE(active.takeFirst().at(0).toBool(), true); QTRY_COMPARE(sett6.count(), 1); QCOMPARE(sett6.takeFirst().at(0).toMap()["Interface"].value().left(5), QString("dummy")); // "dummy" plus number QVariantMap settings = context->IPv6Settings(); QCOMPARE(settings["Interface"].value().left(5),QString("dummy")); // "dummy" plus number QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(apn.count(), 0); QCOMPARE(uname.count(), 0); QCOMPARE(pw.count(), 0); QCOMPARE(name.count(), 0); QCOMPARE(type.count(), 0); QCOMPARE(sett.count(), 0); QCOMPARE(proto.count(), 0); QCOMPARE(active.count(), 0); context->setActive(false); QTRY_COMPARE(active.count(), 1); QCOMPARE(active.takeFirst().at(0).toBool(), false); delete context; m->removeContext(contextid); QTRY_COMPARE(conrem.count(), 1); QCOMPARE(conrem.takeFirst().at(0).toString(), contextid); } void cleanupTestCase() { } void tst_provisioning() { QSignalSpy conadd(m, SIGNAL(contextAdded(QString))); Q_FOREACH (const QString con, m->contexts()) { m->removeContext(con); } QTRY_COMPARE(m->contexts(), QStringList()); m->addContext("internet"); QTRY_COMPARE(conadd.count(), 1); QString contextid = conadd.takeFirst().at(0).toString(); QVERIFY(m->contexts().contains(contextid)); QOfonoConnectionContext* context = new QOfonoConnectionContext(this); context->setContextPath(contextid); 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")); QString operatorString = "Optus"; QString mcc = "505"; QString mnc = "02"; QCOMPARE(context->validateProvisioning(operatorString, mcc, mnc),true); context->setAccessPointName("yesinternet"); QTRY_COMPARE(apn.count(), 1); QCOMPARE(apn.takeFirst().at(0).toString(), QString("yesinternet")); QCOMPARE(context->validateProvisioning(operatorString, mcc, mnc),true); context->setAccessPointName("connect"); QTRY_COMPARE(apn.count(), 1); QCOMPARE(apn.takeFirst().at(0).toString(), QString("connect")); QCOMPARE(context->validateProvisioning(operatorString, mcc, mnc),true); context->setAccessPointName("connectcap"); QTRY_COMPARE(apn.count(), 1); QCOMPARE(apn.takeFirst().at(0).toString(), QString("connectcap")); QCOMPARE(context->validateProvisioning(operatorString, mcc, mnc),true); context->setAccessPointName("test"); QTRY_COMPARE(apn.count(), 1); QCOMPARE(apn.takeFirst().at(0).toString(), QString("test")); QCOMPARE(context->validateProvisioning(operatorString, mcc, mnc),false); } private: QOfonoConnectionManager *m; }; QTEST_MAIN(TestQOfonoConnectionManagerContext) #include "tst_qofonoconnmancontext.moc" ./test/auto/tests/tests.xml.pro0000644000004100000410000000017512762041045017023 0ustar www-datawww-dataTEMPLATE = subdirs tests.xml.files = tests.xml runtest.sh tests.xml.path = /opt/tests/libqofono-qt5/ INSTALLS += tests.xml ./test/auto/tests/tst_qofonomodem.pro0000644000004100000410000000006512762041045020275 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonomodem.cpp ./test/auto/tests/tst_qofonomultipartycall.cpp0000644000004100000410000003152512762041045022231 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * Portions of this file are Copyright (C) 2011 Intel Corporation * Contact: Shane Bryan * * 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/qofonovoicecallmanager.h" #include "../../../src/qofonovoicecall.h" #include // FIXME: Not aligned with the current API class TestOfonoMultipartyCall : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoVoiceCallManager(this); m->setModemPath("/phonesim"); QCOMPARE(m->isValid(), true); } void testOfonoMultipartyCalls() { // Test for hangupMultiparty(): // 1. Dial a call // 2. Receive a call (dial "199" to trigger phonesim callback) // 3. Combine into multiparty call (2 participants) // 4. Verify createMultiparty() works as expected // 5. Put multiparty call on hold // 6. Dial a 3rd call // 7. Combine into multiparty call (3 participants) // 8. Split one call off to "private chat" // 9. Verify privateChat() works as expected // 10. Hangup multiparty call // 11. Verify hangupMultiparty() works as expected // 12. Hangup all calls QVariantList variantList; // VoiceCallManager Spy's QSignalSpy dialreg(m,SIGNAL(dialComplete(bool))); QSignalSpy dspy(m, SIGNAL(callAdded(QString))); QSignalSpy rspy(m, SIGNAL(callRemoved(QString))); QSignalSpy haspy(m, SIGNAL(hangupAllComplete(bool))); QSignalSpy haaspy(m, SIGNAL(holdAndAnswerComplete(bool))); QSignalSpy cmspy(m, SIGNAL(createMultipartyComplete(bool, QStringList))); QSignalSpy hmspy(m, SIGNAL(hangupMultipartyComplete(bool))); QSignalSpy scspy(m, SIGNAL(swapCallsComplete(bool))); QSignalSpy pcspy(m, SIGNAL(privateChatComplete(bool, QStringList))); // 1. Dial a call (outgoing) m->dial("123",""); QTest::qWait(1000); QCOMPARE(dialreg.count(), 1); QCOMPARE(dialreg.takeFirst().at(0).toBool(),true); QCOMPARE(dspy.count(), 1); QString c1id = dspy.takeFirst().at(0).toString(); QOfonoVoiceCall* c1 = new QOfonoVoiceCall(); c1->setVoiceCallPath(c1id); QSignalSpy c1state(c1, SIGNAL(stateChanged(QString))); QSignalSpy c1discreason(c1,SIGNAL(disconnectReason(QString))); QSignalSpy c1li (c1, SIGNAL(lineIdentificationChanged(QString))); QSignalSpy c1name (c1, SIGNAL(nameChanged(QString))); QSignalSpy c1info (c1, SIGNAL(informationChanged(QString))); QSignalSpy c1mp (c1, SIGNAL(multipartyChanged(bool))); QSignalSpy c1em (c1, SIGNAL(emergencyChanged(bool))); QSignalSpy c1st (c1, SIGNAL(startTimeChanged(QString))); QSignalSpy c1ic (c1, SIGNAL(iconChanged(quint8))); qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button"; QTest::qWait(15000); // - new call should have a state change, and be in "active" state QVERIFY(c1state.count()>0); QVERIFY(c1st.count()>0); QVERIFY(c1ic.count()==0); QVERIFY(c1em.count()==0); QVERIFY(c1mp.count()==0); QVERIFY(c1info.count()==0); QVERIFY(c1name.count()==0); QVERIFY(c1li.count()==0); QCOMPARE(c1->state(),QString("active")); QCOMPARE(c1->lineIdentification(),QString("123")); QCOMPARE(c1->emergency(),false); QCOMPARE(c1->multiparty(),false); QCOMPARE(c1->name(),QString("")); QCOMPARE(c1->information(),QString("")); // 2. Receive a call // - dial "199" to trigger phonesim callback m->dial("199",""); QTest::qWait(8000); QCOMPARE(dialreg.count(), 1); QCOMPARE(dialreg.takeFirst().at(0).toBool(),false); QCOMPARE(dspy.count(),1); QString c2id = dspy.takeFirst().at(0).toString(); QOfonoVoiceCall* c2 = new QOfonoVoiceCall(); c2->setVoiceCallPath(c2id); QSignalSpy c2state(c2, SIGNAL(stateChanged(QString))); QSignalSpy c2time(c2,SIGNAL(startTimeChanged(QString))); QSignalSpy c2discreason(c2,SIGNAL(disconnectReason(QString))); QSignalSpy c2li (c2, SIGNAL(lineIdentificationChanged(QString))); QSignalSpy c2name (c2, SIGNAL(nameChanged(QString))); QSignalSpy c2info (c2, SIGNAL(informationChanged(QString))); QSignalSpy c2mp (c2, SIGNAL(multipartyChanged(bool))); QSignalSpy c2em (c2, SIGNAL(emergencyChanged(bool))); QSignalSpy c2ic (c2, SIGNAL(iconChanged(quint8))); QTest::qWait(3000); QCOMPARE(c2->state(),QString("waiting")); // - accept incoming call, placing first call on hold m->holdAndAnswer(); QTest::qWait(1000); QCOMPARE(haaspy.count(),1); QCOMPARE(haaspy.takeFirst().at(0).toBool(),true); QTest::qWait(3000); // - call #1 should be in "held" state QVERIFY(c1state.count()>0); QCOMPARE(c1->state(),QString("held")); // - call #2 should be in "active" state QVERIFY(c2state.count()>0); QCOMPARE(c2->state(),QString("active")); QCOMPARE(c2->lineIdentification(),QString("1234567")); QVERIFY(c2time.count()>0); QVERIFY(c2ic.count()==0); QVERIFY(c2em.count()==0); QVERIFY(c2mp.count()==0); QVERIFY(c2info.count()==0); QVERIFY(c2name.count()==0); QVERIFY(c2li.count()==0); // 3. Combine into multiparty call (2 participants) m->createMultiparty(); QTest::qWait(1000); QCOMPARE(cmspy.count(),1); variantList = cmspy.takeFirst(); QCOMPARE(variantList.at(0).toBool(),true); QVERIFY(variantList.at(1).toStringList().length() > 0); QTest::qWait(3000); // 4. Verify createMultiparty() works as expected // - call #1 should have a stateChanged signal triggered QVERIFY(c1state.count()>0); // - both calls should have a multipartyChanged signal triggered, // be in "active" state and have multiparty property set to "true" QVERIFY(c1mp.count()>0); QVERIFY(c2mp.count()>0); QCOMPARE(c1->state(),QString("active")); QCOMPARE(c2->state(),QString("active")); QCOMPARE(c1->multiparty(),true); QCOMPARE(c2->multiparty(),true); // 5. Put multiparty call on hold m->swapCalls(); QTest::qWait(1000); QCOMPARE(scspy.count(),1); QCOMPARE(scspy.takeFirst().at(0).toBool(),true); QTest::qWait(3000); // - both calls should have a stateChanged signal triggered // and be in "held" state QVERIFY(c1state.count()>0); QVERIFY(c2state.count()>0); QCOMPARE(c1->state(),QString("held")); QCOMPARE(c2->state(),QString("held")); // 6. Dial a 3rd call m->dial("456",""); QTest::qWait(1000); QCOMPARE(dialreg.count(), 1); QCOMPARE(dialreg.takeFirst().at(0).toBool(),true); QCOMPARE(dspy.count(), 1); QString c3id = dspy.takeFirst().at(0).toString(); QOfonoVoiceCall* c3 = new QOfonoVoiceCall(); c3->setVoiceCallPath(c3id); QSignalSpy c3state(c3, SIGNAL(stateChanged(QString))); QSignalSpy c3discreason(c3,SIGNAL(disconnectReason(QString))); QSignalSpy c3li (c3, SIGNAL(lineIdentificationChanged(QString))); QSignalSpy c3name (c3, SIGNAL(nameChanged(QString))); QSignalSpy c3info (c3, SIGNAL(informationChanged(QString))); QSignalSpy c3mp (c3, SIGNAL(multipartyChanged(bool))); QSignalSpy c3em (c3, SIGNAL(emergencyChanged(bool))); QSignalSpy c3st (c3, SIGNAL(startTimeChanged(QString))); QSignalSpy c3ic (c3, SIGNAL(iconChanged(quint8))); qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button"; QTest::qWait(15000); // - 3rd call should have a state change, and be in "active" state QVERIFY(c3state.count()>0); QVERIFY(c3st.count()>0); QVERIFY(c3ic.count()==0); QVERIFY(c3em.count()==0); QVERIFY(c3mp.count()==0); QVERIFY(c3info.count()==0); QVERIFY(c3name.count()==0); QVERIFY(c3li.count()==0); QCOMPARE(c3->state(),QString("active")); QCOMPARE(c3->lineIdentification(),QString("456")); QCOMPARE(c3->emergency(),false); QCOMPARE(c3->multiparty(),false); QCOMPARE(c3->name(),QString("")); QCOMPARE(c3->information(),QString("")); // 7. Combine into multiparty call (3 participants) m->createMultiparty(); QTest::qWait(1000); QCOMPARE(cmspy.count(),1); variantList = cmspy.takeFirst(); QCOMPARE(variantList.at(0).toBool(),true); QVERIFY(variantList.at(1).toStringList().length() > 0); QTest::qWait(3000); // - calls #1 and #2 should have a stateChanged signal triggered QVERIFY(c1state.count()>0); QVERIFY(c2state.count()>0); // - all calls should have a multipartyChanged signal triggered, // be in "active" state and have multiparty property set to "true" QVERIFY(c1mp.count()>0); QVERIFY(c2mp.count()>0); QVERIFY(c3mp.count()>0); QCOMPARE(c1->state(),QString("active")); QCOMPARE(c2->state(),QString("active")); QCOMPARE(c3->state(),QString("active")); QCOMPARE(c1->multiparty(),true); QCOMPARE(c2->multiparty(),true); QCOMPARE(c3->multiparty(),true); // 8. Split call #1 off to "private chat" m->privateChat(c1id); QTest::qWait(1000); QCOMPARE(pcspy.count(),1); variantList = pcspy.takeFirst(); QCOMPARE(variantList.at(0).toBool(),true); QVERIFY(variantList.at(1).toStringList().length() > 0); QTest::qWait(3000); // 9. Verify privateChat() works as expected // - call #1 should have a multipartyChanged signal triggered, // it's multiparty property set to false and be in "active" state QVERIFY(c1mp.count()>0); QCOMPARE(c1->multiparty(),false); QCOMPARE(c1->state(),QString("active")); // - calls #2 and #3 should have a stateChanged signal triggered // and be back in "held" state QVERIFY(c2state.count()>0); QVERIFY(c3state.count()>0); QCOMPARE(c2->state(),QString("held")); QCOMPARE(c3->state(),QString("held")); // 10. Hangup multiparty call m->hangupMultiparty(); QTest::qWait(1000); QCOMPARE(hmspy.count(), 1); QCOMPARE(hmspy.takeFirst().at(0).toBool(),true); QTest::qWait(3000); // 11. Verify hangupMultiparty() works as expected // - two calls should have been removed QVERIFY(rspy.count()==2); QString r2id = rspy.takeFirst().at(0).toString(); QString r3id = rspy.takeFirst().at(0).toString(); QCOMPARE(r2id,c2id); QCOMPARE(r3id,c3id); // - call #1 should still be in "active" state QCOMPARE(c1->state(),QString("active")); // - calls #2 and #3 should have a stateChanged signal triggered // and have a disconnect reason of "local" QVERIFY(c2state.count()>0); QVERIFY(c3state.count()>0); QCOMPARE(c2discreason.count(), 1); QCOMPARE(c3discreason.count(), 1); QCOMPARE(c2discreason.takeFirst().at(0).toString(), QString("local")); QCOMPARE(c3discreason.takeFirst().at(0).toString(), QString("local")); // 12. Hangup all calls m->hangupAll(); QTest::qWait(1000); QCOMPARE(haspy.count(), 1); QCOMPARE(haspy.takeFirst().at(0).toBool(),true); QTest::qWait(3000); QCOMPARE(c1discreason.count(), 1); QCOMPARE(c1discreason.takeFirst().at(0).toString(), QString("local")); delete c1; delete c2; delete c3; } void cleanupTestCase() { } private: QOfonoVoiceCallManager *m; }; QTEST_MAIN(TestOfonoMultipartyCall) #include "tst_qofonomultipartycall.moc" ./test/auto/tests/tst_qofonocallvolume.cpp0000644000004100000410000000476412762041045021333 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * Author: Arun Ravindran * * 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 "qofonocallvolume.h" class TestQOfonoCallVolume : public QObject { Q_OBJECT // The same as the QTRY_* macros use static const int REASONABLE_TIMEOUT = 5000; private slots: void initTestCase() { m = new QOfonoCallVolume(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoCallVolume() { QSignalSpy mutedChanged(m, SIGNAL(mutedChanged(bool))); QSignalSpy speakerVolumeChanged(m, SIGNAL(speakerVolumeChanged(quint8))); QSignalSpy microphoneVolumeChanged(m, SIGNAL(microphoneVolumeChanged(quint8))); m->setMuted(true); QTRY_COMPARE(mutedChanged.count(), 1); QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(true)); QVERIFY(m->muted()==bool(true)); m->setMuted(false); QTRY_COMPARE(mutedChanged.count(), 1); QVERIFY(mutedChanged.takeFirst().at(0).toBool()==bool(false)); QVERIFY(m->muted()==bool(false)); m->setSpeakerVolume(quint8(15)); QTRY_COMPARE(speakerVolumeChanged.count(), 1); QCOMPARE(quint8(speakerVolumeChanged.takeFirst().at(0).toUInt()), quint8(15)); QCOMPARE(m->speakerVolume(),quint8(15)); m->setSpeakerVolume(quint8(250)); m->setMicrophoneVolume(quint8(10)); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(speakerVolumeChanged.count(), 0); QCOMPARE(microphoneVolumeChanged.count(), 0); } void cleanupTestCase() { } private: QOfonoCallVolume *m; }; QTEST_MAIN(TestQOfonoCallVolume) #include "tst_qofonocallvolume.moc" ./test/auto/tests/tst_qofonophonebook.pro0000644000004100000410000000011712762041045021156 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonophonebook.cpp ./test/auto/tests/tst_qofononetworkregistration.pro0000644000004100000410000000013112762041045023312 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofononetworkregistration.cpp ./test/auto/tests/tst_qofonocellbroadcast.cpp0000644000004100000410000000402612762041045021761 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2012 Jolla * * Contact: Lorn Potter * * 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 "qofonocellbroadcast.h" class TestQOfonoCellBroadcast : public QObject { Q_OBJECT static const int INTERACTIVE_STEP_TIMEOUT = 30000; private slots: void initTestCase() { m = new QOfonoCellBroadcast( this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoCellBroadcast() { QSignalSpy inBroadcast(m, SIGNAL(incomingBroadcast( QString ,quint16))); //QSignalSpy emBroadcast(m, SIGNAL(emergencyBroadcast( QString , QVariantMap))); QSignalSpy topicsSpy(m, SIGNAL(topicsChanged(QString))); qDebug() << "Please send CBM using phonesim"; //QCOMPARE(emBroadcast.count(), 1); QTRY_COMPARE_WITH_TIMEOUT(inBroadcast.count(), 1, INTERACTIVE_STEP_TIMEOUT); QString topicsList = "20,50-51,60"; m->setTopics(""); QTRY_COMPARE(topicsSpy.count(), 1); QCOMPARE(topicsSpy.takeFirst().at(0).toString(), QString()); m->setTopics(topicsList); QTRY_COMPARE(topicsSpy.count(), 1); QCOMPARE(topicsSpy.takeFirst().at(0).toString(), topicsList); } private: QOfonoCellBroadcast *m; }; QTEST_MAIN(TestQOfonoCellBroadcast) #include "tst_qofonocellbroadcast.moc" ./test/auto/tests/tst_qofonosupplementaryservices.pro0000644000004100000410000000013312762041045023644 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonosupplementaryservices.cpp ./test/auto/tests/tst_qofonosimmanager.cpp0000644000004100000410000003244012762041045021303 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2014-2015 Jolla Ltd. * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonosimmanager.h" #include "qofonomodem.h" #include // Do it here to not break API compatibility - also see qRegisterMetaType below Q_DECLARE_METATYPE(QOfonoSimManager::Error) class TestQOfonoSimManager : public QObject { Q_OBJECT // The same as the QTRY_* macros use static const int REASONABLE_TIMEOUT = 5000; public: TestQOfonoSimManager() { qRegisterMetaType(); } private slots: void initTestCase() { m = new QOfonoSimManager(this); m->setModemPath("/phonesim"); QTRY_COMPARE(m->isValid(), true); } void testQOfonoSimManager() { QSignalSpy presence(m, SIGNAL(presenceChanged(bool))); QSignalSpy subscriberIdentity(m, SIGNAL(subscriberIdentityChanged(QString))); QSignalSpy mcc(m, SIGNAL(mobileCountryCodeChanged(QString))); QSignalSpy mnc(m, SIGNAL(mobileNetworkCodeChanged(QString))); QSignalSpy subscriberNumbers(m, SIGNAL(subscriberNumbersChanged(QStringList))); QSignalSpy serviceNumbers(m, SIGNAL(serviceNumbersChanged(QVariantMap))); QSignalSpy pinRequired(m, SIGNAL(pinRequiredChanged(int))); QSignalSpy lockedPins(m, SIGNAL(lockedPinsChanged(QVariantList))); QSignalSpy cardIdentifier(m, SIGNAL(cardIdentifierChanged(QString))); QSignalSpy preferredLanguages(m, SIGNAL(preferredLanguagesChanged(QStringList))); QSignalSpy fixedDialing(m, SIGNAL(fixedDialingChanged(bool))); QSignalSpy barredDialing(m, SIGNAL(barredDialingChanged(bool))); QSignalSpy changePin(m, SIGNAL(changePinComplete(QOfonoSimManager::Error, QString))); QSignalSpy enterPin(m, SIGNAL(enterPinComplete(QOfonoSimManager::Error, QString))); QSignalSpy resetPin(m, SIGNAL(resetPinComplete(QOfonoSimManager::Error, QString))); QSignalSpy lockPin(m, SIGNAL(lockPinComplete(QOfonoSimManager::Error, QString))); QSignalSpy unlockPin(m, SIGNAL(unlockPinComplete(QOfonoSimManager::Error, QString))); QTRY_COMPARE(m->present(), true); QTRY_COMPARE(m->subscriberIdentity(), QString("246813579")); QTRY_COMPARE(m->mobileCountryCode(), QString("246")); QTRY_COMPARE(m->mobileNetworkCode(), QString("81")); QTRY_VERIFY(m->subscriberNumbers().count() > 0); QCOMPARE(m->subscriberNumbers()[0], QString("358501234567")); QTRY_VERIFY(m->serviceNumbers().count() > 0); QCOMPARE(m->serviceNumbers().value(".HELP DESK").toString(), QString("2601")); QCOMPARE(m->pinRequired(),QOfonoSimManager::NoPin); QCOMPARE(m->lockedPins().count(), 0); QTRY_COMPARE(m->cardIdentifier(), QString("8949222074451242066")); QTRY_VERIFY(m->preferredLanguages().count() > 0); QCOMPARE(m->preferredLanguages()[0], QString("de")); QCOMPARE(m->pinRetries().count(), 0); QCOMPARE(m->fixedDialing(), false); QCOMPARE(m->barredDialing(), false); QStringList numbers = m->subscriberNumbers(); QStringList newNumbers; newNumbers << "1234567"; m->setSubscriberNumbers(newNumbers); QTRY_COMPARE(subscriberNumbers.count(), 1); QStringList newNumbersSignal = subscriberNumbers.takeFirst().at(0).toStringList(); QCOMPARE(newNumbersSignal.count(), 1); QCOMPARE(newNumbersSignal, newNumbers); newNumbers.clear(); newNumbers << ""; m->setSubscriberNumbers(newNumbers); // previous call is expected to fail -> only one signal will be emitted m->setSubscriberNumbers(numbers); QTRY_COMPARE(subscriberNumbers.count(), 1); newNumbersSignal = subscriberNumbers.takeFirst().at(0).toStringList(); QCOMPARE(newNumbersSignal.count(), 1); QCOMPARE(newNumbersSignal, numbers); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(presence.count(), 0); QCOMPARE(subscriberIdentity.count(), 0); QCOMPARE(mcc.count(), 0); QCOMPARE(mnc.count(), 0); QCOMPARE(subscriberNumbers.count(), 0); QCOMPARE(serviceNumbers.count(), 0); QCOMPARE(cardIdentifier.count(), 0); QCOMPARE(preferredLanguages.count(), 0); QCOMPARE(pinRequired.count(), 0); QCOMPARE(lockedPins.count(), 0); QCOMPARE(fixedDialing.count(), 0); QCOMPARE(barredDialing.count(), 0); QOfonoModem modem; modem.setModemPath(m->modemPath()); 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); QCOMPARE(modemOnline.takeFirst().at(0).toBool(), false); modem.setPowered(false); QTRY_COMPARE(modemPowered.count(), 1); QCOMPARE(modemPowered.takeFirst().at(0).toBool(), false); QTRY_VERIFY(!m->isValid()); QTRY_COMPARE(presence.count(), 1); QCOMPARE(presence.takeFirst().at(0).toBool(), false); QTRY_COMPARE(subscriberIdentity.count(), 1); QCOMPARE(subscriberIdentity.takeFirst().at(0).toString(), QString("")); QTRY_COMPARE(mcc.count(), 1); QCOMPARE(mcc.takeFirst().at(0).toString(), QString("")); QTRY_COMPARE(mnc.count(), 1); QCOMPARE(mnc.takeFirst().at(0).toString(), QString("")); QTRY_COMPARE(subscriberNumbers.count(), 1); numbers = subscriberNumbers.takeFirst().at(0).toStringList(); QCOMPARE(numbers.count(), 0); QTRY_COMPARE(serviceNumbers.count(), 1); QVariantMap serviceNumbersMap = serviceNumbers.takeFirst().at(0).toMap(); QCOMPARE(serviceNumbersMap.count(), 0); QTRY_COMPARE(cardIdentifier.count(), 1); QCOMPARE(cardIdentifier.takeFirst().at(0).toString(), QString("")); QTRY_COMPARE(preferredLanguages.count(), 1); QStringList languages = preferredLanguages.takeFirst().at(0).toStringList(); QCOMPARE(languages.count(), 0); QCOMPARE(pinRequired.count(), 0); QCOMPARE(lockedPins.count(), 0); QCOMPARE(fixedDialing.count(), 0); QCOMPARE(barredDialing.count(), 0); QCOMPARE(presence.count(), 0); QCOMPARE(subscriberIdentity.count(), 0); QCOMPARE(mcc.count(), 0); QCOMPARE(mnc.count(), 0); QCOMPARE(subscriberNumbers.count(), 0); QCOMPARE(serviceNumbers.count(), 0); QCOMPARE(cardIdentifier.count(), 0); QCOMPARE(preferredLanguages.count(), 0); QCOMPARE(pinRequired.count(), 0); QCOMPARE(lockedPins.count(), 0); QCOMPARE(fixedDialing.count(), 0); QCOMPARE(barredDialing.count(), 0); modem.setPowered(true); QTRY_COMPARE(modemPowered.count(), 1); QCOMPARE(modemPowered.takeFirst().at(0).toBool(), true); modem.setOnline(true); QTRY_COMPARE(modemOnline.count(), 1); QCOMPARE(modemOnline.takeFirst().at(0).toBool(), true); QTRY_VERIFY(m->isValid()); QTRY_COMPARE(presence.count(), 1); QCOMPARE(presence.takeFirst().at(0).toBool(), true); QTRY_COMPARE(subscriberIdentity.count(), 1); QCOMPARE(subscriberIdentity.takeFirst().at(0).toString(), QString("246813579")); QTRY_COMPARE(mcc.count(), 1); QCOMPARE(mcc.takeFirst().at(0).toString(), QString("246")); QTRY_COMPARE(mnc.count(), 1); QCOMPARE(mnc.takeFirst().at(0).toString(), QString("81")); QTRY_COMPARE(subscriberNumbers.count(), 1); numbers = subscriberNumbers.takeFirst().at(0).toStringList(); QCOMPARE(numbers.count(), 1); QCOMPARE(numbers[0], QString("358501234567")); QTRY_COMPARE(serviceNumbers.count(), 1); serviceNumbersMap = serviceNumbers.takeFirst().at(0).toMap(); QVERIFY(serviceNumbersMap.count() > 0); QCOMPARE(serviceNumbersMap.value(".HELP DESK").toString(), QString("2601")); QTRY_COMPARE(cardIdentifier.count(), 1); QCOMPARE(cardIdentifier.takeFirst().at(0).toString(), QString("8949222074451242066")); QTRY_COMPARE(preferredLanguages.count(), 1); languages = preferredLanguages.takeFirst().at(0).toStringList(); QVERIFY(languages.count() > 0); QCOMPARE(languages[0], QString("de")); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(presence.count(), 0); QCOMPARE(subscriberIdentity.count(), 0); QCOMPARE(mcc.count(), 0); QCOMPARE(mnc.count(), 0); QCOMPARE(subscriberNumbers.count(), 0); QCOMPARE(serviceNumbers.count(), 0); QCOMPARE(cardIdentifier.count(), 0); QCOMPARE(preferredLanguages.count(), 0); QCOMPARE(pinRequired.count(), 0); QCOMPARE(lockedPins.count(), 0); QCOMPARE(fixedDialing.count(), 0); QCOMPARE(barredDialing.count(), 0); } void testQOfonoSimManagerPin() { QSignalSpy presence(m, SIGNAL(presenceChanged(bool))); QSignalSpy subscriberIdentity(m, SIGNAL(subscriberIdentityChanged(QString))); QSignalSpy mcc(m, SIGNAL(mobileCountryCodeChanged(QString))); QSignalSpy mnc(m, SIGNAL(mobileNetworkCodeChanged(QString))); QSignalSpy subscriberNumbers(m, SIGNAL(subscriberNumbersChanged(QStringList))); QSignalSpy serviceNumbers(m, SIGNAL(serviceNumbersChanged(QVariantMap))); QSignalSpy pinRequired(m, SIGNAL(pinRequiredChanged(int))); QSignalSpy lockedPins(m, SIGNAL(lockedPinsChanged(QVariantList))); QSignalSpy cardIdentifier(m, SIGNAL(cardIdentifierChanged(QString))); QSignalSpy preferredLanguages(m, SIGNAL(preferredLanguagesChanged(QStringList))); QSignalSpy pinRetries(m, SIGNAL(pinRetriesChanged(QVariantMap))); QSignalSpy changePin(m, SIGNAL(changePinComplete(QOfonoSimManager::Error, QString))); QSignalSpy enterPin(m, SIGNAL(enterPinComplete(QOfonoSimManager::Error, QString))); QSignalSpy resetPin(m, SIGNAL(resetPinComplete(QOfonoSimManager::Error, QString))); QSignalSpy lockPin(m, SIGNAL(lockPinComplete(QOfonoSimManager::Error, QString))); QSignalSpy unlockPin(m, SIGNAL(unlockPinComplete(QOfonoSimManager::Error, QString))); m->lockPin(QOfonoSimManager::SimPin, "2468"); QTRY_COMPARE(lockPin.count(), 1); QCOMPARE(lockPin.takeFirst().at(0).value(), QOfonoSimManager::NoError); QTRY_COMPARE(lockedPins.count(), 1); QCOMPARE(lockedPins.takeFirst().at(0).toList().count(), 1); m->changePin(QOfonoSimManager::SimPin, "2468", "1234"); QTRY_COMPARE(changePin.count(), 1); QCOMPARE(changePin.takeFirst().at(0).value(), QOfonoSimManager::NoError); m->changePin(QOfonoSimManager::SimPin, "1234", "2468"); QTRY_COMPARE(changePin.count(), 1); QCOMPARE(changePin.takeFirst().at(0).value(), QOfonoSimManager::NoError); // entering and resetting PIN is not possible with phonesim's default config m->enterPin(QOfonoSimManager::SimPin, "2468"); QTRY_COMPARE(enterPin.count(), 1); QCOMPARE(enterPin.takeFirst().at(0).value(), QOfonoSimManager::InvalidFormatError); m->resetPin(QOfonoSimManager::SimPuk, "13243546", "2468"); QTRY_COMPARE(resetPin.count(), 1); QCOMPARE(resetPin.takeFirst().at(0).value(), QOfonoSimManager::InvalidFormatError); m->unlockPin(QOfonoSimManager::SimPin, "2468"); QTRY_COMPARE(unlockPin.count(), 1); QCOMPARE(unlockPin.takeFirst().at(0).value(), QOfonoSimManager::NoError); QTRY_COMPARE(lockedPins.count(), 1); QCOMPARE(lockedPins.takeFirst().at(0).toList().count(), 0); // entering PIN is not possible with phonesim's default config QCOMPARE(pinRetries.count(), 0); } void testQOfonoSimManagerIcon() { QByteArray icon0 = m->getIcon(0); QVERIFY(icon0.isEmpty()); QByteArray icon1 = m->getIcon(1); QVERIFY(!icon1.isEmpty()); } void cleanupTestCase() { } private: QOfonoSimManager *m; }; QTEST_MAIN(TestQOfonoSimManager) #include "tst_qofonosimmanager.moc" ./test/auto/tests/tst_qofononetworkoperator.cpp0000644000004100000410000001165512762041045022432 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofononetworkregistration.h" #include "qofononetworkoperator.h" // Do it here to not break API compatibility - also see qRegisterMetaType below Q_DECLARE_METATYPE(QOfonoNetworkOperator::Error) class TestQOfonoNetworkOperator : public QObject { Q_OBJECT public: TestQOfonoNetworkOperator() { qRegisterMetaType(); } private slots: void initTestCase() { m = new QOfonoNetworkRegistration(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoNetworkOperator() { QSignalSpy scanFinished(m, SIGNAL(scanFinished())); QSignalSpy networkOperatorsChanged(m, SIGNAL(networkOperatorsChanged(QStringList))); m->scan(); QTRY_COMPARE(scanFinished.count(), 1); scanFinished.takeFirst(); QTRY_COMPARE(networkOperatorsChanged.count(), 1); QStringList opIdList = networkOperatorsChanged.takeFirst().at(0).toStringList(); QVERIFY(opIdList.count() > 0); int op1 = -1; int op2 = -1; QList opList; foreach(QString opId, opIdList) { QOfonoNetworkOperator *op = new QOfonoNetworkOperator(this); op->setOperatorPath(opId); QTRY_VERIFY(op->isValid()); opList << op; if (op1 == -1 && op->status() == "current") op1 = opIdList.indexOf(opId); if (op2 == -1 && op->status() == "available") op2 = opIdList.indexOf(opId); } QVERIFY(op1 != -1); QVERIFY(op2 != -1); QVERIFY(opList[op1]->name().length() > 0); QVERIFY(opList[op2]->name().length() > 0); QVERIFY(opList[op1]->mcc().length() > 0); QVERIFY(opList[op2]->mcc().length() > 0); QVERIFY(opList[op1]->mnc().length() > 0); QVERIFY(opList[op2]->mnc().length() > 0); QVERIFY(opList[op1]->technologies().count() > 0); QVERIFY(opList[op2]->technologies().count() > 0); QSignalSpy op1Register(opList[op1], SIGNAL(registerComplete(QOfonoNetworkOperator::Error, QString))); QSignalSpy op2Register(opList[op2], SIGNAL(registerComplete(QOfonoNetworkOperator::Error, QString))); QSignalSpy op1Status(opList[op1], SIGNAL(statusChanged(QString))); QSignalSpy op2Status(opList[op2], SIGNAL(statusChanged(QString))); //QSignalSpy mcc(m, SIGNAL(mccChanged(QString))); QSignalSpy mnc(m, SIGNAL(mncChanged(QString))); QSignalSpy name(m, SIGNAL(nameChanged(QString))); opList[op2]->registerOperator(); QTRY_COMPARE(op2Register.count(), 1); QCOMPARE(op2Register.takeFirst().at(0).value(), QOfonoNetworkOperator::NoError); QTRY_COMPARE(op1Status.count(), 1); QCOMPARE(op1Status.takeFirst().at(0).toString(), QString("available")); QTRY_COMPARE(op2Status.count(), 1); QCOMPARE(op2Status.takeFirst().at(0).toString(), QString("current")); //QTRY_COMPARE(mcc.count(), 1); // both OPs have the same MCC QTRY_COMPARE(mnc.count(), 1); mnc.takeFirst(); QTRY_COMPARE(name.count(), 1); name.takeFirst(); opList[op1]->registerOperator(); QTRY_COMPARE(op1Register.count(), 1); QCOMPARE(op1Register.takeFirst().at(0).value(), QOfonoNetworkOperator::NoError); QTRY_COMPARE(op1Status.count(), 1); QCOMPARE(op1Status.takeFirst().at(0).toString(), QString("current")); QTRY_COMPARE(op2Status.count(), 1); QCOMPARE(op2Status.takeFirst().at(0).toString(), QString("available")); //QTRY_COMPARE(mcc.count(), 1); // both OPs have the same MCC QTRY_COMPARE(mnc.count(), 1); mnc.takeFirst(); QTRY_COMPARE(name.count(), 1); name.takeFirst(); qDeleteAll(opList); } void cleanupTestCase() { } private: QOfonoNetworkRegistration *m; }; QTEST_MAIN(TestQOfonoNetworkOperator) #include "tst_qofononetworkoperator.moc" ./test/auto/tests/tst_qofonoconnman.pro0000644000004100000410000000006712762041045020627 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonoconnman.cpp ./test/auto/tests/tst_qofonocallmeter.cpp0000644000004100000410000000263712762041045021135 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonocallmeter.h" class TestQOfonoCallMeter : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoCallMeter(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoCallMeter() { QCOMPARE(m->callMeter(), quint32(0)); // TODO: should also test change in call meter as a result of voice call } void cleanupTestCase() { } private: QOfonoCallMeter *m; }; QTEST_MAIN(TestQOfonoCallMeter) #include "tst_qofonocallmeter.moc" ./test/auto/tests/tst_qofonocellbroadcast.pro0000644000004100000410000000007512762041045021777 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonocellbroadcast.cpp ./test/auto/tests/tst_qofonocallforwarding.pro0000644000004100000410000000012412762041045022166 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonocallforwarding.cpp ./test/auto/tests/runtest.sh0000755000004100000410000000017312762041045016401 0ustar www-datawww-data#!/bin/sh -e systemctl --user restart phonesim sleep 15 exec "/usr/lib/libqofono-qt5/tests/${1?Test executable expected}" ./test/auto/tests/tests.xml0000644000004100000410000001130212762041045016216 0ustar www-datawww-data Ofono test set with manual, automatic and semi-automatic case. /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 /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 /opt/tests/libqofono-qt5/runtest.sh tst_qofonocallforwarding /opt/tests/libqofono-qt5/runtest.sh tst_qofonocallmeter /opt/tests/libqofono-qt5/runtest.sh tst_qofonocallsettings /opt/tests/libqofono-qt5/runtest.sh tst_qofonocallvolume /opt/tests/libqofono-qt5/runtest.sh tst_qofonocellbroadcast /opt/tests/libqofono-qt5/runtest.sh tst_qofonoconnmancontext /opt/tests/libqofono-qt5/runtest.sh tst_qofonoconnman /opt/tests/libqofono-qt5/runtest.sh tst_qofonomanager /opt/tests/libqofono-qt5/runtest.sh tst_qofonomessagemanager /opt/tests/libqofono-qt5/runtest.sh tst_qofonomessagewaiting /opt/tests/libqofono-qt5/runtest.sh tst_qofonomodem /opt/tests/libqofono-qt5/runtest.sh tst_qofonomultipartycall /opt/tests/libqofono-qt5/runtest.sh tst_qofononetworkoperator /opt/tests/libqofono-qt5/runtest.sh tst_qofononetworkregistration /opt/tests/libqofono-qt5/runtest.sh tst_qofonophonebook /opt/tests/libqofono-qt5/runtest.sh tst_qofonoradiosettings /opt/tests/libqofono-qt5/runtest.sh tst_qofonosimmanager /opt/tests/libqofono-qt5/runtest.sh tst_qofonosupplementaryservices /opt/tests/libqofono-qt5/runtest.sh tst_qofonovoicecall /opt/tests/libqofono-qt5/runtest.sh tst_qofonovoicecallmanager ./test/auto/tests/tst_qofonomanager.cpp0000644000004100000410000000424612762041045020575 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonomanager.h" #include "qofonomodem.h" #include class TestQOfonoManager : public QObject { Q_OBJECT static const int INTERACTIVE_STEP_TIMEOUT = 30000; private slots: void initTestCase() { mm = new QOfonoManager(this); QCOMPARE(mm->modems(), QStringList()); QSignalSpy defaultModem(mm, SIGNAL(defaultModemChanged(QString))); QTRY_COMPARE(defaultModem.count(), 1); } void testQOfonoManager() { QVERIFY(mm->modems().contains("/phonesim") == true); } void testQOfonoManagerAddRemove() { QSignalSpy add(mm, SIGNAL(modemAdded(QString))); QSignalSpy remove(mm, SIGNAL(modemRemoved(QString))); qDebug() << "Please stop oFono and then start it again"; QTRY_VERIFY_WITH_TIMEOUT(add.count() > 0 && remove.count() > 0, INTERACTIVE_STEP_TIMEOUT); QVERIFY(mm->modems().contains("/phonesim") == true); QOfonoModem *m = new QOfonoModem(this); m->setModemPath("/phonesim"); m->setPowered(true); QTRY_VERIFY(m->powered()); m->setOnline(true); QTRY_VERIFY(m->online()); } void cleanupTestCase() { } private: QOfonoManager *mm; }; QTEST_MAIN(TestQOfonoManager) #include "tst_qofonomanager.moc" ./test/auto/tests/tst_qofonoradiosettings.pro0000644000004100000410000000012312762041045022046 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonoradiosettings.cpp ./test/auto/tests/tst_qofonocallmeter.pro0000644000004100000410000000011712762041045021142 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonocallmeter.cpp ./test/auto/tests/tst_qofonocallsettings.pro0000644000004100000410000000012212762041045021662 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonocallsettings.cpp ./test/auto/tests/tst_qofonoradiosettings.cpp0000644000004100000410000000264412762041045022042 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2014-2015 Jolla Ltd. * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonoradiosettings.h" class TestQOfonoRadioSettings : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoRadioSettings(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoRadioSettings() { QCOMPARE(m->technologyPreference(), QString("any")); } void cleanupTestCase() { } private: QOfonoRadioSettings *m; }; QTEST_MAIN(TestQOfonoRadioSettings) #include "tst_qofonoradiosettings.moc" ./test/auto/tests/tst_qofonocallbarring.pro0000644000004100000410000000012112762041045021445 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonocallbarring.cpp ./test/auto/tests/tst_qofonomessagemanager.pro0000644000004100000410000000012412762041045022147 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonomessagemanager.cpp ./test/auto/tests/tst_qofonosupplementaryservices.cpp0000644000004100000410000001352512762041045023637 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonosupplementaryservices.h" class TestQOfonoSupplementaryServices : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoSupplementaryServices( this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoSupplementaryServices() { QSignalSpy notification(m, SIGNAL(notificationReceived(QString))); QSignalSpy request(m, SIGNAL(requestReceived(QString))); QSignalSpy state(m, SIGNAL(stateChanged(QString))); QSignalSpy ussd(m, SIGNAL(ussdResponse(QString))); QSignalSpy barring(m, SIGNAL(callBarringResponse(QString, QString, QVariantMap))); QSignalSpy forwarding(m, SIGNAL(callForwardingResponse(QString, QString, QVariantMap))); QSignalSpy waiting(m, SIGNAL(callWaitingResponse(QString, QVariantMap))); QSignalSpy callingLinePresentation(m, SIGNAL(callingLinePresentationResponse(QString, QString))); QSignalSpy connectedLinePresentation(m, SIGNAL(connectedLinePresentationResponse(QString, QString))); QSignalSpy callingLineRestriction(m, SIGNAL(callingLineRestrictionResponse(QString, QString))); QSignalSpy connectedLineRestriction(m, SIGNAL(connectedLineRestrictionResponse(QString, QString))); QSignalSpy initiateFailed(m, SIGNAL(initiateFailed())); QSignalSpy respond(m, SIGNAL(respondComplete(bool, QString))); QSignalSpy cancel(m, SIGNAL(cancelComplete(bool))); QCOMPARE(m->state(), QString("idle")); m->initiate("*225#"); QTRY_COMPARE(state.count(), 2); QCOMPARE(state.takeFirst().at(0).toString(), QString("active")); QCOMPARE(state.takeFirst().at(0).toString(), QString("idle")); QTRY_COMPARE(ussd.count(), 1); QCOMPARE(ussd.takeFirst().at(0).toString(), QString("Thank you, your request is being processed. A message will be sent to your phone.")); m->cancel(); QTRY_COMPARE(cancel.count(), 1); QCOMPARE(cancel.takeFirst().at(0).toBool(), false); m->respond("*225#"); QTRY_COMPARE(respond.count(), 1); QCOMPARE(respond.takeFirst().at(0).toBool(), false); QEXPECT_FAIL("", "'*226#' case fails", Continue); QVERIFY(false); //m->initiate("*226#"); //QTRY_COMPARE(state.count(), 2); //QCOMPARE(state.takeFirst().at(0).toString(), QString("active")); //QCOMPARE(state.takeFirst().at(0).toString(), QString("idle")); //QTRY_COMPARE(initiateFailed.count(), 1); //initiateFailed.takeFirst(); m->initiate("*#331#"); QTRY_COMPARE(barring.count(), 1); QVariantList list = barring.takeFirst(); QCOMPARE(list.at(0).toString(), QString("interrogation")); QCOMPARE(list.at(1).toString(), QString("InternationalOutgoing")); QVariantMap map = list.at(2).toMap(); QCOMPARE(map.count(), 3); QCOMPARE(map["DataInternationalOutgoing"].toString(), QString("disabled")); QEXPECT_FAIL("", "'*#002**11#' case fails", Continue); QVERIFY(false); //m->initiate("*#002**11#"); //QTRY_COMPARE(forwarding.count(), 1); //list = forwarding.takeFirst(); //QCOMPARE(list.at(0).toString(), QString("interrogation")); //QCOMPARE(list.at(1).toString(), QString("All")); //map = list.at(2).toMap(); //QCOMPARE(map.count(), 5); //QCOMPARE(map["VoiceNoReplyTimeout"].toUInt(), uint(20)); m->initiate("*#43#"); QTRY_COMPARE(waiting.count(), 1); list = waiting.takeFirst(); QCOMPARE(list.at(0).toString(), QString("interrogation")); map = list.at(1).toMap(); QCOMPARE(map.count(), 5); QCOMPARE(map["DataAsyncCallWaiting"].toString(), QString("disabled")); m->initiate("*#31#"); QTRY_COMPARE(callingLineRestriction.count(), 1); list = callingLineRestriction.takeFirst(); QCOMPARE(list.at(0).toString(), QString("interrogation")); QCOMPARE(list.at(1).toString(), QString("disabled")); m->initiate("*#30#"); QTRY_COMPARE(callingLinePresentation.count(), 1); list = callingLinePresentation.takeFirst(); QCOMPARE(list.at(0).toString(), QString("interrogation")); QCOMPARE(list.at(1).toString(), QString("enabled")); m->initiate("*#76#"); QTRY_COMPARE(connectedLinePresentation.count(), 1); list = connectedLinePresentation.takeFirst(); QCOMPARE(list.at(0).toString(), QString("interrogation")); QCOMPARE(list.at(1).toString(), QString("enabled")); m->initiate("*#77#"); QTRY_COMPARE(connectedLineRestriction.count(), 1); list = connectedLineRestriction.takeFirst(); QCOMPARE(list.at(0).toString(), QString("interrogation")); QCOMPARE(list.at(1).toString(), QString("enabled")); } void cleanupTestCase() { } private: QOfonoSupplementaryServices *m; }; QTEST_MAIN(TestQOfonoSupplementaryServices) #include "tst_qofonosupplementaryservices.moc" ./test/auto/tests/tst_qofonoconnmancontext.pro0000644000004100000410000000007612762041045022234 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonoconnmancontext.cpp ./test/auto/tests/tst_qofonovoicecallmanager.pro0000644000004100000410000000012612762041045022466 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonovoicecallmanager.cpp ./test/auto/tests/tst_qofonomessagemanager.cpp0000644000004100000410000001640412762041045022141 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonomessagemanager.h" #include "qofonomessage.h" class TestQOfonoMessageManager : public QObject { Q_OBJECT // The same as the QTRY_* macros use static const int REASONABLE_TIMEOUT = 5000; private slots: void initTestCase() { m = new QOfonoMessageManager(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoMessageManager() { QSignalSpy sendMessage(m, SIGNAL(sendMessageComplete(bool, QString))); QSignalSpy messageAdded(m, SIGNAL(messageAdded(QString))); QSignalSpy messageRemoved(m, SIGNAL(messageRemoved(QString))); QSignalSpy immediateMessage(m, SIGNAL(immediateMessage(QString, QVariantMap))); QSignalSpy incomingMessage(m, SIGNAL(incomingMessage(QString, QVariantMap))); QStringList messages = m->messages(); QVERIFY(messages.count() == 0); m->sendMessage("99999", "success"); QTRY_COMPARE(sendMessage.count(), 1); QVariantList params = sendMessage.takeFirst(); QCOMPARE(params.at(0).toBool(), true); QString objectPath = params.at(1).value(); QVERIFY(objectPath.length() > 0); qDebug() << objectPath; QTRY_COMPARE(messageAdded.count(), 1); QString messageId = messageAdded.takeFirst().at(0).toString(); QCOMPARE(messageId, objectPath); QTRY_COMPARE(messageRemoved.count(), 1); QCOMPARE(messageRemoved.takeFirst().at(0).toString(), objectPath); QOfonoMessage* message = new QOfonoMessage(); message->setMessagePath(messageId); QSignalSpy state(message, SIGNAL(stateChanged(QString))); qDebug() << message->state(); m->sendMessage("abc", "fail"); QTRY_COMPARE(sendMessage.count(), 1); params = sendMessage.takeFirst(); QCOMPARE(params.at(0).toBool(), false); objectPath = params.at(1).value(); QVERIFY(objectPath.length() == 0); } void testQOfonoMessageManagerSca() { QString sca = m->serviceCenterAddress(); QVERIFY(sca.length() > 0); qDebug() << sca; QSignalSpy setScaComplete(m, SIGNAL(setServiceCenterAddressComplete(bool))); QSignalSpy scaChanged(m, SIGNAL(serviceCenterAddressChanged(QString))); m->setServiceCenterAddress("+12345678"); QTRY_COMPARE(setScaComplete.count(), 1); QCOMPARE(setScaComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(scaChanged.count(), 1); QCOMPARE(scaChanged.takeFirst().at(0).toString(), QString("+12345678")); QCOMPARE(m->serviceCenterAddress(), QString("+12345678")); m->setServiceCenterAddress(""); QTRY_COMPARE(setScaComplete.count(), 1); QCOMPARE(setScaComplete.takeFirst().at(0).toBool(), false); QCOMPARE(m->serviceCenterAddress(), QString("+12345678")); m->setServiceCenterAddress(sca); QTRY_COMPARE(setScaComplete.count(), 1); QCOMPARE(setScaComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(scaChanged.count(), 1); QCOMPARE(scaChanged.takeFirst().at(0).toString(), sca); QCOMPARE(m->serviceCenterAddress(), sca); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(scaChanged.count(), 0); } void testQOfonoMessageManagerUseDeliveryReports() { QSignalSpy setUseDeliveryReportsComplete(m, SIGNAL(setUseDeliveryReportsComplete(bool))); QSignalSpy useDeliveryReportsChanged(m, SIGNAL(useDeliveryReportsChanged(bool))); QCOMPARE(m->useDeliveryReports(), false); m->setUseDeliveryReports(true); QTRY_COMPARE(setUseDeliveryReportsComplete.count(), 1); QCOMPARE(setUseDeliveryReportsComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(useDeliveryReportsChanged.count(), 1); QCOMPARE(useDeliveryReportsChanged.takeFirst().at(0).toBool(), true); QCOMPARE(m->useDeliveryReports(), true); m->setUseDeliveryReports(false); QTRY_COMPARE(setUseDeliveryReportsComplete.count(), 1); QCOMPARE(setUseDeliveryReportsComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(useDeliveryReportsChanged.count(), 1); QCOMPARE(useDeliveryReportsChanged.takeFirst().at(0).toBool(), false); QCOMPARE(m->useDeliveryReports(), false); } void testQOfonoMessageManagerAlphabet() { QSignalSpy setAlphabetComplete(m, SIGNAL(setAlphabetComplete(bool))); QSignalSpy alphabetChanged(m, SIGNAL(alphabetChanged(QString))); QString alphabet = m->alphabet(); QVERIFY(alphabet.length() > 0); QCOMPARE(alphabet, QString("default")); m->setAlphabet("spanish"); QTRY_COMPARE(setAlphabetComplete.count(), 1); QCOMPARE(setAlphabetComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(alphabetChanged.count(), 1); QCOMPARE(alphabetChanged.takeFirst().at(0).toString(), QString("spanish")); QCOMPARE(m->alphabet(), QString("spanish")); m->setAlphabet(alphabet); QTRY_COMPARE(setAlphabetComplete.count(), 1); QCOMPARE(setAlphabetComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(alphabetChanged.count(), 1); QCOMPARE(alphabetChanged.takeFirst().at(0).toString(), alphabet); QCOMPARE(m->alphabet(), alphabet); } void testQOfonoMessageManagerBearer() { QSignalSpy setBearerComplete(m, SIGNAL(setBearerComplete(bool))); QSignalSpy bearerChanged(m, SIGNAL(bearerChanged(QString))); QString bearer = m->bearer(); QVERIFY(bearer.length() > 0); QCOMPARE(bearer, QString("cs-preferred")); m->setBearer("ps-preferred"); QTRY_COMPARE(setBearerComplete.count(), 1); QCOMPARE(setBearerComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(bearerChanged.count(), 1); QCOMPARE(bearerChanged.takeFirst().at(0).toString(), QString("ps-preferred")); QCOMPARE(m->bearer(), QString("ps-preferred")); m->setBearer(bearer); // change value QTRY_COMPARE(setBearerComplete.count(), 1); QCOMPARE(setBearerComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(bearerChanged.count(), 1); QCOMPARE(bearerChanged.takeFirst().at(0).toString(), bearer); QCOMPARE(m->bearer(), bearer); } void cleanupTestCase() { } private: QOfonoMessageManager *m; }; QTEST_MAIN(TestQOfonoMessageManager) #include "tst_qofonomessagemanager.moc" ./test/auto/tests/tst_qofonocallsettings.cpp0000644000004100000410000001073712762041045021661 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonocallsettings.h" class TestQOfonoCallSettings : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoCallSettings(this); m->setModemPath("/phonesim"); QSignalSpy ready(m, SIGNAL(readyChanged())); QTRY_VERIFY(m->isValid()); QTRY_VERIFY(m->isReady()); QTRY_COMPARE(ready.count(), 1); } void testQOfonoCallSettings() { QSignalSpy hideCallerIdComplete(m, SIGNAL(hideCallerIdComplete(bool))); QSignalSpy voiceCallWaitingComplete(m, SIGNAL(voiceCallWaitingComplete(bool))); QSignalSpy callingLinePresentationChanged(m, SIGNAL(callingLinePresentationChanged(QString))); QSignalSpy calledLinePresentationChanged(m, SIGNAL(calledLinePresentationChanged(QString))); QSignalSpy callingNamePresentationChanged(m, SIGNAL(callingNamePresentationChanged(QString))); QSignalSpy connectedLinePresentationChanged(m, SIGNAL(connectedLinePresentationChanged(QString))); QSignalSpy connectedLineRestrictionChanged(m, SIGNAL(connectedLineRestrictionChanged(QString))); QSignalSpy callingLineRestrictionChanged(m, SIGNAL(callingLineRestrictionChanged(QString))); QSignalSpy hideCallerIdChanged(m, SIGNAL(hideCallerIdChanged(QString))); QSignalSpy voiceCallWaitingChanged(m, SIGNAL(voiceCallWaitingChanged(QString))); QCOMPARE(m->callingLinePresentation(), QString("enabled")); QCOMPARE(m->calledLinePresentation(), QString("enabled")); QCOMPARE(m->callingNamePresentation(), QString("enabled")); QCOMPARE(m->connectedLinePresentation(), QString("enabled")); QCOMPARE(m->connectedLineRestriction(), QString("enabled")); QCOMPARE(m->callingLineRestriction(), QString("on")); QCOMPARE(m->hideCallerId(), QString("default")); QCOMPARE(m->voiceCallWaiting(), QString("enabled")); m->setHideCallerId("abc"); QTRY_COMPARE(hideCallerIdComplete.count(), 1); QCOMPARE(hideCallerIdComplete.takeFirst().at(0).toBool(), false); m->setVoiceCallWaiting("abc"); QTRY_COMPARE(voiceCallWaitingComplete.count(), 1); QCOMPARE(voiceCallWaitingComplete.takeFirst().at(0).toBool(), false); m->setHideCallerId("enabled"); QTRY_COMPARE(hideCallerIdComplete.count(), 1); QCOMPARE(hideCallerIdComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(hideCallerIdChanged.count(), 1); QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("enabled")); m->setHideCallerId("default"); QTRY_COMPARE(hideCallerIdComplete.count(), 1); QCOMPARE(hideCallerIdComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(hideCallerIdChanged.count(), 1); QCOMPARE(hideCallerIdChanged.takeFirst().at(0).toString(), QString("default")); m->setVoiceCallWaiting("disabled"); QTRY_COMPARE(voiceCallWaitingComplete.count(), 1); QCOMPARE(voiceCallWaitingComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceCallWaitingChanged.count(), 1); QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("disabled")); m->setVoiceCallWaiting("enabled"); QTRY_COMPARE(voiceCallWaitingComplete.count(), 1); QCOMPARE(voiceCallWaitingComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceCallWaitingChanged.count(), 1); QCOMPARE(voiceCallWaitingChanged.takeFirst().at(0).toString(), QString("enabled")); } void cleanupTestCase() { } private: QOfonoCallSettings *m; }; QTEST_MAIN(TestQOfonoCallSettings) #include "tst_qofonocallsettings.moc" ./test/auto/tests/tst_qofonomessagewaiting.cpp0000644000004100000410000001124512762041045022167 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonomessagewaiting.h" #include "qofonomodem.h" class TestQOfonoMessageWaiting : public QObject { Q_OBJECT // The same as the QTRY_* macros use static const int REASONABLE_TIMEOUT = 5000; private slots: void initTestCase() { m = new QOfonoMessageWaiting(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoMessageWaiting() { QOfonoModem modem; modem.setModemPath(m->modemPath()); QSignalSpy modemOnline(&modem, SIGNAL(onlineChanged(bool))); QSignalSpy waiting(m, SIGNAL(voicemailWaitingChanged(bool))); QSignalSpy messageCount(m, SIGNAL(voicemailMessageCountChanged(int))); 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")); modem.setOnline(false); QTRY_COMPARE(modemOnline.count(), 1); QCOMPARE(modemOnline.takeFirst().at(0).toBool(), false); QTest::qWait(REASONABLE_TIMEOUT); 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); QCOMPARE(modemOnline.takeFirst().at(0).toBool(), true); // FIXME: This does not seem to be correct. These properties actually // do not change. QTRY_COMPARE(waiting.count(), 1); QCOMPARE(waiting.takeFirst().at(0).toBool(), true); QTRY_COMPARE(messageCount.count(), 1); QCOMPARE(messageCount.takeFirst().at(0).toInt(), 1); QTRY_COMPARE(mailboxNumber.count(), 1); QCOMPARE(mailboxNumber.takeFirst().at(0).toString(), QString("6789")); QTRY_COMPARE(setNumberComplete.count(), 0); } void testQOfonoMessageWaitingSet() { QSignalSpy waiting(m, SIGNAL(voicemailWaitingChanged(bool))); QSignalSpy messageCount(m, SIGNAL(voicemailMessageCountChanged(int))); QSignalSpy mailboxNumber(m, SIGNAL(voicemailMailboxNumberChanged(QString))); QSignalSpy setNumberComplete(m, SIGNAL(voicemailMailboxComplete(bool))); QString number = m->voicemailMailboxNumber(); m->setVoicemailMailboxNumber(""); QTRY_COMPARE(setNumberComplete.count(), 1); QCOMPARE(setNumberComplete.takeFirst().at(0).toBool(), false); m->setVoicemailMailboxNumber("1234"); QTRY_COMPARE(mailboxNumber.count(), 1); QCOMPARE(mailboxNumber.takeFirst().at(0).toString(), QString("1234")); QTRY_COMPARE(setNumberComplete.count(), 1); QCOMPARE(setNumberComplete.takeFirst().at(0).toBool(), true); m->setVoicemailMailboxNumber(number); QTRY_COMPARE(mailboxNumber.count(), 1); QCOMPARE(mailboxNumber.takeFirst().at(0).toString(), number); QTRY_COMPARE(setNumberComplete.count(), 1); QCOMPARE(setNumberComplete.takeFirst().at(0).toBool(), true); QTest::qWait(REASONABLE_TIMEOUT); QCOMPARE(waiting.count(), 0); QCOMPARE(messageCount.count(), 0); QCOMPARE(mailboxNumber.count(), 0); } void cleanupTestCase() { } private: QOfonoMessageWaiting *m; }; QTEST_MAIN(TestQOfonoMessageWaiting) #include "tst_qofonomessagewaiting.moc" ./test/auto/tests/tst_qofonocallbarring.cpp0000644000004100000410000001151712762041045021442 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonocallbarring.h" class TestQOfonoCallBarring : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoCallBarring(this); m->setModemPath("/phonesim"); QSignalSpy ready(m, SIGNAL(readyChanged())); QTRY_VERIFY(m->isValid()); QTRY_VERIFY(m->isReady()); QCOMPARE(ready.count(), 1); } void testQOfonoCallBarring() { QSignalSpy voiceIncomingComplete(m, SIGNAL(voiceIncomingComplete(bool))); QSignalSpy voiceOutgoingComplete(m, SIGNAL(voiceOutgoingComplete(bool))); QSignalSpy voiceIncomingChanged(m, SIGNAL(voiceIncomingChanged(QString))); QSignalSpy voiceOutgoingChanged(m, SIGNAL(voiceOutgoingChanged(QString))); QSignalSpy changePasswordComplete(m, SIGNAL(changePasswordComplete(bool))); //QSignalSpy disableAllComplete(m, SIGNAL(disableAllComplete(bool))); //QSignalSpy disableAllIncomingComplete(m, SIGNAL(disableAllIncomingComplete(bool))); //QSignalSpy disableAllOutgoingComplete(m, SIGNAL(disableAllOutgoingComplete(bool))); QCOMPARE(m->voiceIncoming(), QString("disabled")); QCOMPARE(m->voiceOutgoing(), QString("disabled")); voiceIncomingChanged.clear(); voiceOutgoingChanged.clear(); m->setVoiceIncoming("always", "0000"); QTRY_COMPARE(voiceIncomingComplete.count(), 1); QCOMPARE(voiceIncomingComplete.takeFirst().at(0).toBool(), false); QCOMPARE(voiceIncomingChanged.count(), 0); m->setVoiceOutgoing("always", "0000"); QTRY_COMPARE(voiceOutgoingComplete.count(), 1); QCOMPARE(voiceOutgoingComplete.takeFirst().at(0).toBool(), false); QCOMPARE(voiceOutgoingChanged.count(), 0); m->setVoiceIncoming("always", "3579"); QTRY_COMPARE(voiceIncomingComplete.count(), 1); QCOMPARE(voiceIncomingComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceIncomingChanged.count(), 1); QCOMPARE(voiceIncomingChanged.takeFirst().at(0).toString(), QString("always")); m->setVoiceOutgoing("international", "3579"); QTRY_COMPARE(voiceOutgoingComplete.count(), 1); QCOMPARE(voiceOutgoingComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceOutgoingChanged.count(), 1); QCOMPARE(voiceOutgoingChanged.takeFirst().at(0).toString(), QString("international")); // QOfonoCallBarring API incomplete //m->disableAllIncoming("3579"); //QTRY_COMPARE(disableAllIncomingComplete.count(), 1); //QCOMPARE(disableAllIncomingComplete.takeFirst().at(0).toBool(), false); //QCOMPARE(m->errorName(), QString("org.ofono.Error.Failed")); //QCOMPARE(m->errorMessage(), QString("Operation failed")); //m->disableAllOutgoing("3579"); //QTRY_COMPARE(disableAllOutgoingComplete.count(), 1); //QCOMPARE(disableAllOutgoingComplete.takeFirst().at(0).toBool(), false); //QCOMPARE(m->errorName(), QString("org.ofono.Error.Failed")); //QCOMPARE(m->errorMessage(), QString("Operation failed")); m->disableAll("3579"); //QTRY_COMPARE(disableAllComplete.count(), 1); //QCOMPARE(disableAllComplete.takeFirst().at(0).toBool(), true); QTRY_COMPARE(voiceIncomingChanged.count(), 1); QCOMPARE(voiceIncomingChanged.takeFirst().at(0).toString(), QString("disabled")); QTRY_COMPARE(voiceOutgoingChanged.count(), 1); QCOMPARE(voiceOutgoingChanged.takeFirst().at(0).toString(), QString("disabled")); m->changePassword("3579", "1234"); QTRY_COMPARE(changePasswordComplete.count(), 1); QCOMPARE(changePasswordComplete.takeFirst().at(0).toBool(), true); m->changePassword("1234", "3579"); QTRY_COMPARE(changePasswordComplete.count(), 1); QCOMPARE(changePasswordComplete.takeFirst().at(0).toBool(), true); } void cleanupTestCase() { } private: QOfonoCallBarring *m; }; QTEST_MAIN(TestQOfonoCallBarring) #include "tst_qofonocallbarring.moc" ./test/auto/tests/tst_qofonovoicecallmanager.cpp0000644000004100000410000001006712762041045022455 0ustar www-datawww-data/* * This file is part of ofono-qt * * Copyright (C) 2010-2011 Nokia Corporation and/or its subsidiary(-ies). * * Contact: Alexander Kanavin * * 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 "qofonovoicecallmanager.h" #include "qofonomodem.h" #include // FIXME: Not aligned with the current API class TestQOfonoVoiceCallManager : public QObject { Q_OBJECT private slots: void initTestCase() { m = new QOfonoVoiceCallManager(this); m->setModemPath("/phonesim"); QTRY_VERIFY(m->isValid()); } void testQOfonoVoiceCallManager() { QVERIFY(m->emergencyNumbers().count() > 0); QSignalSpy emergencyNumbers(m, SIGNAL(emergencyNumbersChanged(QStringList))); QSignalSpy dialreg(m,SIGNAL(dialComplete(bool))); QSignalSpy dspy(m, SIGNAL(callAdded(QString))); QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool))); QSignalSpy tonereg(m,SIGNAL(sendTonesComplete(bool))); QSignalSpy hspy(m, SIGNAL(callRemoved(QString))); QOfonoModem modem; modem.setModemPath(m->modemPath()); modem.setPowered(false); QTRY_VERIFY(!modem.powered()); modem.setPowered(true); QTRY_VERIFY(modem.powered()); modem.setOnline(true); 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()); //Dial testing m->dial("123",""); qDebug() << "Please find a call in 'Dialing' state in phonesim window and press 'Active' button"; QTest::qWait(15000); QCOMPARE(dialreg.count(), 1); QCOMPARE(dialreg.takeFirst().at(0).toBool(),true); QCOMPARE(dspy.count(), 1); //Tones testing QTest::qWait(5000); m->sendTones("1234"); QTest::qWait(5000); QCOMPARE(tonereg.count(), 1); QCOMPARE(tonereg.takeFirst().at(0).toBool(),true); QTest::qWait(5000); QStringList calls = m->getCalls(); QVERIFY(calls.size()>0); //hangup testing m->hangupAll(); QTest::qWait(5000); QCOMPARE(hupreg.count(), 1); QCOMPARE(hupreg.takeFirst().at(0).toBool(),true); QCOMPARE(hspy.count(), 1); } void testQOfonoVoiceCallManagerStep2() { // test dial failure and hangup of incoming alerting call QSignalSpy dialreg(m,SIGNAL(dialComplete(bool))); QSignalSpy hupreg(m,SIGNAL(hangupAllComplete(bool))); QSignalSpy dspy(m, SIGNAL(callAdded(QString))); QSignalSpy hspy(m, SIGNAL(callRemoved(QString))); m->dial("199",""); QTest::qWait(5000); QCOMPARE(dialreg.count(), 1); QCOMPARE(dialreg.takeFirst().at(0).toBool(),false); QTest::qWait(10000); QCOMPARE(dspy.count(), 1); //hangup the alerting call m->hangupAll(); QTest::qWait(5000); QCOMPARE(hupreg.count(), 1); QCOMPARE(hupreg.takeFirst().at(0).toBool(),true); QTest::qWait(10000); QCOMPARE(hspy.count(), 1); } void cleanupTestCase() { } private: QOfonoVoiceCallManager *m; }; QTEST_MAIN(TestQOfonoVoiceCallManager) #include "tst_qofonovoicecallmanager.moc" ./test/auto/tests/tst_qofonomessagewaiting.pro0000644000004100000410000000012412762041045022177 0ustar www-datawww-datainclude(testcase.pri) SOURCES += tst_qofonomessagewaiting.cpp ./test/auto/tst_location/0000755000004100000410000000000012762041045015675 5ustar www-datawww-data./test/auto/tst_location/tst_location.pro0000644000004100000410000000064612762041045021127 0ustar www-datawww-data#------------------------------------------------- # # Project created by QtCreator 2013-05-21T10:46:43 # #------------------------------------------------- QT += testlib dbus QT -= gui TARGET = tst_locationtest CONFIG += console CONFIG -= app_bundle TEMPLATE = app INCLUDEPATH += ../../../src LIBS += -lqofono LIBS += -L../../../src SOURCES += tst_locationtest.cpp DEFINES += SRCDIR=\\\"$$PWD/\\\" ./test/auto/tst_location/tst_locationtest.cpp0000644000004100000410000000300012762041045021774 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd ** Contact: lorn.potter@jollamobile.com ** ** ** $QT_BEGIN_LICENSE:LGPL$ ** ** 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. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include #include #include "qofonomanager.h" #include "qofonomodem.h" #include "qofonoassistedsatellitenavigation.h" #include "qofonopositioningrequestagent.h" class Tst_locationTest : public QObject { Q_OBJECT public: Tst_locationTest(); private Q_SLOTS: void testCase1(); }; Tst_locationTest::Tst_locationTest() { QOfonoManager oMan; QOfonoAssistedSatelliteNavigation satNav; satNav.setModemPath(oMan.modems().at(0)); QOfonoPositioningRequestAgent posAgent; posAgent.setAgentPath("/QOfonoTest"); satNav.registerPositioningRequestAgent("/QOfonoTest"); } void Tst_locationTest::testCase1() { QVERIFY2(true, "Failure"); } QTEST_APPLESS_MAIN(Tst_locationTest) #include "tst_locationtest.moc" ./test/auto/tst_qofono/0000755000004100000410000000000012762041045015366 5ustar www-datawww-data./test/auto/tst_qofono/tst_qofono.pro0000644000004100000410000000132212762041045020301 0ustar www-datawww-data#------------------------------------------------- # # Project created by QtCreator 2013-01-15T03:55:39 # #------------------------------------------------- QT += testlib dbus xmlpatterns QT -= gui equals(QT_MAJOR_VERSION, 4): { LIBS += -lqofono TARGET = tst_qofonotest target.path = $$[QT_INSTALL_LIBS]/libqofono/tests } equals(QT_MAJOR_VERSION, 5): { LIBS += -lqofono-qt5 TARGET = tst_qofonotest-qt5 target.path = $$[QT_INSTALL_LIBS]/libqofono-qt5/tests } CONFIG += console CONFIG -= app_bundle TEMPLATE = app LIBS += -L../../../src INCLUDEPATH += ../../../src SOURCES += tst_qofonotest.cpp DEFINES += SRCDIR=\\\"$$PWD/\\\" isEmpty(PREFIX) { PREFIX=/usr } INSTALLS += target ./test/auto/tst_qofono/tst_qofonotest.cpp0000644000004100000410000003620112762041045021167 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013 Jolla Ltd ** Contact: lorn.potter@gmail.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 #include #include "qofonomanager.h" #include "qofonoconnectionmanager.h" #include "qofonoconnectioncontext.h" #include "qofonomodem.h" #include "qofononetworkregistration.h" #include "qofonohandsfree.h" #include "qofonohandsfreeaudiocard.h" #include "qofononetworkoperator.h" #include "qofononetworkregistration.h" #include "qofonomessagemanager.h" #include "qofonosimmanager.h" #include "qofonoconnectioncontext.h" #include "qofonoconnectionmanager.h" #include "qofonovoicecallmanager.h" // These auto tests require // phonesim or real modem static bool waitForSignal(QObject *obj, const char *signal, int timeout = 0) { QEventLoop loop; QObject::connect(obj, signal, &loop, SLOT(quit())); QTimer timer; QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); if (timeout > 0) { QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); timer.setSingleShot(true); timer.start(timeout); } loop.exec(); return timeoutSpy.isEmpty(); } class Tst_qofonoTest : public QObject { Q_OBJECT public: Tst_qofonoTest(); private Q_SLOTS: void testManager(); void testModem(); void testScan(); void testContextConnection(); void testConnectionManager(); void testNetworkRegistration(); void testNetworkOperator(); void testSimManager(); void testHandsfree(); void testHandsfreeAudioCard(); void testMessageManager(); void testVoiceCallManager(); void testprovisioning_data(); void testprovisioning(); }; Tst_qofonoTest::Tst_qofonoTest() { } void Tst_qofonoTest::testManager() { QOfonoManager manager; QStringList modems = manager.modems(); QVERIFY(!modems.isEmpty()); //TODO modemAdded, modemRemoved signals ? //testprovisioning(); } void Tst_qofonoTest::testModem() { // something controls the modem power. // TODO // QOfonoManager manager; // QOfonoModem modem; // QVERIFY(modem.modemPath().isEmpty()); // QStringList modemList = manager.modems(); // QSignalSpy spy(&modem, SIGNAL(modemPathChanged(QString))); // modem.setModemPath(modemList[0]); // QTest::qWait(2000); // QCOMPARE(spy.count(),1); // QVERIFY(!modem.modemPath().isEmpty()); // if (!modem.powered()) { // modem.setPowered(true); // QTest::qWait(2000); // QVERIFY(modem.powered()); // } else { // if (modemList[0] != "/phonesim") { // // power off phonesim modem doesnt work // modem.setPowered(false); // QTest::qWait(2000); // QVERIFY(!modem.powered()); // modem.setPowered(true); // QTest::qWait(2000); // QVERIFY(modem.powered()); // } // } // bool isOnline = modem.online(); // modem.setOnline(!isOnline); // QTest::qWait(3000); // QVERIFY(!isOnline); // modem.setOnline(true); } void Tst_qofonoTest::testScan() { QOfonoManager manager; QOfonoModem modem; modem.setModemPath(manager.modems()[0]); QOfonoNetworkRegistration netreg; netreg.setModemPath(manager.modems()[0]); QSignalSpy spy_scanFinished(&netreg, SIGNAL(scanFinished())); QSignalSpy spy_scanError(&netreg, SIGNAL(scanError(QString))); netreg.scan(); ::waitForSignal(&netreg, SIGNAL(scanFinished()), 1000 * 500); QCOMPARE(spy_scanError.count(),0); QCOMPARE(spy_scanFinished.count(),1); } void Tst_qofonoTest::testConnectionManager() { QOfonoManager manager; QOfonoConnectionManager connman; QOfonoModem modem; modem.setModemPath(manager.modems()[0]); if (!modem.online()) { modem.setOnline(true); } QVERIFY(modem.online()); connman.setModemPath(manager.modems()[0]); QVERIFY(!connman.modemPath().isEmpty()); QSignalSpy spy(&connman, SIGNAL(contextAdded(QString))); connman.addContext("internet"); ::waitForSignal(&connman,SIGNAL(contextAdded(QString)),1000); QCOMPARE(spy.count(),1); // QList arguments ; // arguments = spy.takeFirst(); // attached // bearer // suspended // roamingAllowed // QSignalSpy spy_roaming(&connman, SIGNAL(roamingAllowedChanged(bool))); // bool expected = !connman.roamingAllowed(); // connman.setRoamingAllowed(expected); // QTest::qWait(3000); // QCOMPARE(spy_roaming.count(),1); // QList argumentsspy_roaming; // argumentsspy_roaming = spy_roaming.takeFirst(); // QCOMPARE(argumentsspy_roaming[0].toBool(), expected); // connman.setRoamingAllowed(false); // QTest::qWait(3000); // QCOMPARE(spy_roaming.count(),1); // QList argumentsspy_roaming2; // argumentsspy_roaming2 = spy_roaming.takeFirst(); // if (manager.modems()[0].contains("phonesim")) // QEXPECT_FAIL("","seems to nt work on phonesim",Continue); // QCOMPARE(argumentsspy_roaming[0].toBool(), false); // // powered // QSignalSpy spy_powered(&connman, SIGNAL(poweredChanged(bool))); // QList argumentsspy_powered; // bool isPowered = connman.powered(); // qDebug() << Q_FUNC_INFO << "modem powered" << connman.powered(); // connman.setPowered(!isPowered); // QTest::qWait(3000); // QCOMPARE(spy_powered.count(),2); //powers itself back on // argumentsspy_powered = spy_powered.takeFirst(); // QCOMPARE(argumentsspy_powered[0].toBool(), !isPowered); // if(!connman.powered()) { // connman.setPowered(true); // QTest::qWait(3000); // QVERIFY(connman.powered()); // } //TODO other signals } void Tst_qofonoTest::testContextConnection() { QOfonoManager manager; QOfonoModem modem; QStringList modems = manager.modems(); modem.setModemPath(manager.modems()[0]); if (!modem.online()) { QSignalSpy spy_bogusContext(&modem, SIGNAL(onlineChanged(bool))); modem.setOnline(true); ::waitForSignal(&modem,SIGNAL(onlineChanged(bool)),3000); QCOMPARE(spy_bogusContext.count(),1); } QVERIFY(modem.online()); QVERIFY(modem.interfaces().contains("org.ofono.ConnectionManager")); QOfonoConnectionManager connman; connman.setModemPath(modems[0]); QVERIFY(connman.isValid()); if (!connman.powered()) { QSignalSpy spy_connPowered(&connman, SIGNAL(poweredChanged(bool))); connman.setPowered(true); ::waitForSignal(&connman,SIGNAL(poweredChanged(bool)),3000); QCOMPARE(spy_connPowered.count(),1); } QOfonoConnectionContext connContext; QStringList contextList = connman.contexts(); int contextCount = contextList.count(); QSignalSpy spy_bogusContext(&connman, SIGNAL(contextAdded(QString))); QSignalSpy spy_contextError(&connman, SIGNAL(reportError(QString))); connman.addContext(QString("test")); ::waitForSignal(&connman,SIGNAL(reportError(QString)),3000); QCOMPARE(spy_bogusContext.count(),0); QCOMPARE(spy_contextError.count(),1); QSignalSpy spy_realContext(&connman, SIGNAL(contextAdded(QString))); connman.addContext(QString("internet")); ::waitForSignal(&connman,SIGNAL(contextAdded(QString)),3000); QCOMPARE(spy_realContext.count(),1); contextList = connman.contexts(); QVERIFY(!contextList.isEmpty()); QVERIFY(contextList.count() == contextCount + 1); Q_FOREACH(const QString &path, connman.contexts()) { QSignalSpy spy2(&connContext, SIGNAL(contextPathChanged(QString))); connContext.setContextPath(path); ::waitForSignal(&connContext,SIGNAL(contextPathChanged(QString)),1000); QCOMPARE(spy2.count(),1); QVERIFY(!connContext.contextPath().isEmpty()); QSignalSpy spy1(&connContext, SIGNAL(accessPointNameChanged(QString))); connContext.setAccessPointName("Jolla"); ::waitForSignal(&connContext,SIGNAL(accessPointNameChanged(QString)),2000); QCOMPARE(spy1.count(),1); QList arguments1; arguments1 = spy1.takeFirst(); QCOMPARE(arguments1[0].toString(),QString("Jolla")); QVERIFY(!connContext.accessPointName().isEmpty()); QSignalSpy spy_name(&connContext, SIGNAL(nameChanged(QString))); connContext.setName("Test AP"); ::waitForSignal(&connContext,SIGNAL(nameChanged(QString)),2000); QTest::qWait(2000); QCOMPARE(spy_name.count(),1); QList arguments ; arguments = spy_name.takeFirst(); QCOMPARE(arguments[0].toString(), QString("Test AP")); } QVERIFY(!connContext.active()); QVERIFY(connContext.isValid()); if(!connContext.validateProvisioning()) { connContext.provisionForCurrentNetwork("internet"); ::waitForSignal(&connContext,SIGNAL(provisioningFinished()),3000); } QSignalSpy spy_active(&connContext, SIGNAL(activeChanged(bool))); connContext.setActive(true); ::waitForSignal(&connContext,SIGNAL(activeChanged(bool)),3000); QCOMPARE(spy_active.count(),1); QList arguments2 = spy_active.takeFirst(); QCOMPARE(arguments2[0].toBool(),true); } void Tst_qofonoTest::testNetworkRegistration() { QOfonoManager manager; QStringList modems = manager.modems(); QOfonoNetworkRegistration netreg; netreg.setModemPath(modems.at(0)); // qDebug() << Q_FUNC_INFO // <<"stat:"<< netreg.status() // << "lac:"<< netreg.locationAreaCode() // <<"cell id:"<< netreg.cellId() // <<"mcc:"<< netreg.mcc() // <<"mnc:"<< netreg.mnc() // <<"netreg"<< netreg.name() // <<"base:"<< netreg.baseStation(); // QOfonoNetworkOperator netop; // netop.setOperatorPath(netreg.currentOperatorPath()); // qDebug() << Q_FUNC_INFO // << netop.name(); QVERIFY(!netreg.name().isEmpty()); QVERIFY(!netreg.mode().isEmpty()); QVERIFY(!netreg.status().isEmpty()); QVERIFY(!netreg.locationAreaCode() != 0); QVERIFY(!netreg.mcc().isEmpty()); QVERIFY(!netreg.mnc().isEmpty()); QVERIFY(netreg.baseStation().isEmpty()); QVERIFY(netreg.cellId() > 0); netreg.scan(); ::waitForSignal(&netreg,SIGNAL(scanFinished()), 1000 * 500); QVERIFY(!netreg.currentOperatorPath().isEmpty()); QVERIFY(netreg.status() == "registered"); QVERIFY(netreg.locationAreaCode() == 0); QVERIFY(!netreg.mcc().isEmpty()); QVERIFY(!netreg.mnc().isEmpty()); QVERIFY(!netreg.technology().isEmpty()); QVERIFY(!netreg.networkOperators().isEmpty()); } void Tst_qofonoTest::testHandsfree() { QOfonoHandsfree handsfree; handsfree.setModemPath("/phonesim"); QVERIFY(handsfree.features().isEmpty()); QVERIFY(!handsfree.inbandRinging()); QVERIFY(!handsfree.voiceRecognition()); QVERIFY(!handsfree.echoCancelingNoiseReduction()); QVERIFY(handsfree.batteryChargeLevel() == 0); } void Tst_qofonoTest::testHandsfreeAudioCard() { QOfonoHandsfreeAudioCard handsfreeAudioCard; handsfreeAudioCard.setModemPath("/phonesim"); QVERIFY(handsfreeAudioCard.remoteAddress().isEmpty()); QVERIFY(handsfreeAudioCard.localAddress().isEmpty()); } void Tst_qofonoTest::testNetworkOperator() { QOfonoManager manager; QStringList modems = manager.modems(); QOfonoNetworkRegistration netreg; netreg.setModemPath(modems.at(0)); QStringList operators = netreg.networkOperators(); Q_FOREACH(const QString &onetopPath, operators) { QOfonoNetworkOperator netOp; netOp.setOperatorPath(onetopPath); // qDebug() << netOp.name() // << netOp.status() // << netOp.mcc() // << netOp.mnc() // << netOp.technologies() // << netOp.additionalInfo(); } } void Tst_qofonoTest::testMessageManager() { QOfonoManager manager; QStringList modems = manager.modems(); QOfonoMessageManager messageManager; messageManager.setModemPath(modems.at(0)); // QSignalSpy spy1(&messageManager, SIGNAL(messagesFinished())); } void Tst_qofonoTest::testSimManager() { QOfonoManager manager; QStringList modems = manager.modems(); QOfonoSimManager simManager; QSignalSpy spy(&simManager, SIGNAL(modemPathChanged(QString))); simManager.setModemPath(modems[0]); ::waitForSignal(&simManager,SIGNAL(modemPathChanged(QString)),1000); QCOMPARE(spy.count(),1); } void Tst_qofonoTest::testVoiceCallManager() { QOfonoManager manager; QStringList modems = manager.modems(); QOfonoVoiceCallManager callManager; callManager.setModemPath(modems.at(0)); } void Tst_qofonoTest::testprovisioning_data() { QTest::addColumn("op"); QTest::addColumn("mcc"); QTest::addColumn("mnc"); QTest::addColumn("apns"); QTest::newRow("Optus") << "Optus" << "505" <<"02" << (QStringList() << "internet" << "yesinternet" << "connect" << "connectcap"); QTest::newRow("Amaysim") << "amaysim" << "505" <<"02"<< (QStringList() << "internet"); QTest::newRow("Crazy") << "Crazy John's" << "505" <<"03"<< (QStringList() << "purtona.net"); QTest::newRow("Sonera") << "Sonera" << "244" <<"91"<< (QStringList() << "internet" << "prointernet"); } void Tst_qofonoTest::testprovisioning() { QOfonoManager manager; QOfonoConnectionManager connman; connman.setModemPath(manager.modems().at(0)); QStringList contextList = connman.contexts(); Q_FOREACH (const QString con, contextList) { connman.removeContext(con); } QSignalSpy spy(&connman, SIGNAL(contextAdded(QString))); connman.addContext("internet"); ::waitForSignal(&connman, SIGNAL(contextAdded(QString)), 1000 * 50); QCOMPARE(spy.count(),1); QList arguments ; arguments = spy.takeFirst(); QString contextid = arguments[0].toString(); QOfonoConnectionContext* context = new QOfonoConnectionContext(this); context->setContextPath(contextid); QSignalSpy provisionspy(context, SIGNAL(provisioningFinished())); QFETCH(QString, op); QFETCH(QString, mcc); QFETCH(QString, mnc); QFETCH(QStringList, apns); context->provision(op,mcc,mnc,"internet"); QCOMPARE(provisionspy.count(),1); QCOMPARE(context->validateProvisioning(op, mcc, mnc),true); Q_FOREACH (const QString &apn, apns) { context->setAccessPointName(apn); ::waitForSignal(context, SIGNAL(setPropertyFinished()), 1000 * 50); QCOMPARE(context->validateProvisioning(op, mcc, mnc),true); } context->setAccessPointName("test"); ::waitForSignal(context, SIGNAL(setPropertyFinished()), 1000 * 50); QCOMPARE(context->validateProvisioning(op, mcc, mnc),false); connman.removeContext(contextid); } QTEST_MAIN(Tst_qofonoTest) #include "tst_qofonotest.moc" ./makedist0000755000004100000410000000232712762041045012777 0ustar www-datawww-data#!/bin/bash # Determine project name based on current directory #PROJECT=$(basename $PWD) PROJECT=libqofono # NOTE: Don't like this? Then uncomment one of the following as appropriate # # Just set it explictly to whatever you like: # PROJECT=libseaside # # Parse it from any Qt *.pro or *.pri files in CWD: # PROJECT=$(grep -E "TARGET ?= ?" *.pr[io]|cut -d' ' -f3) while getopts qht: o do case $o in h) head=1;; t) TAG="$OPTARG";; q) PROJECT=libqofono-qt5;; ?) printf >&2 "Usage: $0 [-h] [-t TAG]\n" exit 2;; esac done # Grab most recent tag from git unless TAG is set if [ -z "$TAG" ] ; then TAG=$(git describe --tags --abbrev=0) fi # Parse out just the version number #PARTS=(${TAG//-/ }) #VERSION=${PARTS[1]} VERSION=${TAG} # Set name of toplevel directory for the archive PREFIX="${PROJECT}-${VERSION}/" # Set name of resulting release archive file ARCHIVE=${PROJECT}-${VERSION}.tar.bz2 [ -e ${ARCHIVE} ] && rm -rf ${ARCHIVE} && echo "Removed: ${ARCHIVE}" if [ ! -z "$head" ] ; then TAG="HEAD" fi git archive --format=tar --prefix=${PREFIX} $TAG | bzip2 -c -- > ${ARCHIVE} && { echo "Created: ${ARCHIVE}" } || { echo "Creation of release archive ${ARCHIVE} failed. Reason unknown." } ./TODO0000644000004100000410000000010312762041045011726 0ustar www-datawww-data - audio settings API - cdma* API - dundee API - simtoolkit API ./plugin/0000755000004100000410000000000012762041064012543 5ustar www-datawww-data./plugin/qofonosimlistmodel.cpp0000644000004100000410000002202312762041064017175 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2015 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 "qofonosimlistmodel.h" #include QOfonoSimListModel::QOfonoSimListModel(QObject *parent) : QAbstractListModel(parent), simWatcher(new QOfonoSimWatcher(this)) { simWatcher->setRequireSubscriberIdentity(true); simList = simWatcher->presentSimList(); connect(simWatcher, SIGNAL(validChanged()), SIGNAL(validChanged())); connect(simWatcher, SIGNAL(presentSimListChanged()), SLOT(onPresentSimListChanged())); } bool QOfonoSimListModel::valid() const { return simWatcher->isValid(); } int QOfonoSimListModel::count() const { return simList.count(); } bool QOfonoSimListModel::requireSubscriberIdentity() const { return simWatcher->requireSubscriberIdentity(); } void QOfonoSimListModel::setRequireSubscriberIdentity(bool require) { if (simWatcher->requireSubscriberIdentity() != require) { simWatcher->setRequireSubscriberIdentity(require); Q_EMIT requireSubscriberIdentityChanged(); } } QHash QOfonoSimListModel::roleNames() const { QHash roles; roles[PathRole] = "path"; roles[SubscriberIdentityRole] = "subscriberIdentity"; roles[MobileCountryCodeRole] = "mobileCountryCode"; roles[MobileNetworkCodeRole] = "mobileNetworkCode"; roles[ServiceProviderNameRole] = "serviceProviderName"; roles[SubscriberNumbersRole] = "subscriberNumbers"; roles[ServiceNumbersRole] = "serviceNumbers"; roles[PinRequiredRole] = "pinRequired"; roles[LockedPinsRole] = "lockedPins"; roles[CardIdentifierRole] = "cardIdentifier"; roles[PreferredLanguagesRole] = "preferredLanguages"; roles[PinRetriesRole] = "pinRetries"; roles[FixedDialingRole] = "fixedDialing"; roles[BarredDialingRole] = "barredDialing"; return roles; } int QOfonoSimListModel::rowCount(const QModelIndex&) const { return simList.count(); } QVariant QOfonoSimListModel::data(const QModelIndex& index, int role) const { const int row = index.row(); if (row >= 0 && row < simList.count()) { const QOfonoSimManager* sim = simList.at(row).data(); switch (role) { case PathRole: return sim->modemPath(); case SubscriberIdentityRole: return sim->subscriberIdentity(); case MobileCountryCodeRole: return sim->mobileCountryCode(); case MobileNetworkCodeRole: return sim->mobileNetworkCode(); case ServiceProviderNameRole: return sim->serviceProviderName(); case SubscriberNumbersRole: return sim->subscriberNumbers(); case ServiceNumbersRole: return sim->serviceNumbers(); case PinRequiredRole: return sim->pinRequired(); case LockedPinsRole: return sim->lockedPins(); case CardIdentifierRole: return sim->cardIdentifier(); case PreferredLanguagesRole: return sim->preferredLanguages(); case PinRetriesRole: return sim->pinRetries(); case FixedDialingRole: return sim->fixedDialing(); case BarredDialingRole: return sim->barredDialing(); } } else { qWarning() << index << role; } return QVariant(); } bool QOfonoSimListModel::setData(const QModelIndex& index, const QVariant& value, int role) { const int row = index.row(); if (row >= 0 && row < simList.count() && role == SubscriberNumbersRole) { simList.at(row)->setSubscriberNumbers(value.toStringList()); return true; } else { qWarning() << index << role; } return false; } int QOfonoSimListModel::indexOf(QOfonoSimManager* sim) { // We cann't just do simList.indexOf(sim) because that would create temporary // QOfonoSimManager::SharedPointer on stack, pass it to simList.indexOf, and // eventually destroy QOfonoSimManager. const int n = simList.count(); for (int i=0; i= 0) { QModelIndex modelIndex = index(row); QVector roles; roles.append(role); Q_EMIT dataChanged(modelIndex, modelIndex, roles); } } void QOfonoSimListModel::onPresentSimListChanged() { QList newList = simWatcher->presentSimList(); const bool countHasChanged = simList.count() != simWatcher->presentSimCount(); int i; for (i=simList.count()-1; i>=0; i--) { QOfonoSimManager::SharedPointer sim = simList.at(i); if (!newList.contains(sim)) { beginRemoveRows(QModelIndex(), i, i); sim->disconnect(this); simList.removeAt(i); endRemoveRows(); Q_EMIT simRemoved(sim.data()); } } QList oldList = simList; simList = newList; for (i=0; idisconnect(this); connect(sim, SIGNAL(subscriberIdentityChanged(QString)), SLOT(onSubscriberIdentityChanged())); connect(sim, SIGNAL(mobileCountryCodeChanged(QString)), SLOT(onMobileCountryCodeChanged())); connect(sim, SIGNAL(mobileNetworkCodeChanged(QString)), SLOT(onMobileNetworkCodeChanged())); connect(sim, SIGNAL(serviceProviderNameChanged(QString)), SLOT(onServiceProviderNameChanged())); connect(sim, SIGNAL(subscriberNumbersChanged(QStringList)), SLOT(onSubscriberNumbersChanged())); connect(sim, SIGNAL(serviceNumbersChanged(QVariantMap)), SLOT(onServiceNumbersChanged())); connect(sim, SIGNAL(pinRequiredChanged(int)), SLOT(onPinRequiredChanged())); connect(sim, SIGNAL(lockedPinsChanged(QVariantList)), SLOT(onLockedPinsChanged())); connect(sim, SIGNAL(cardIdentifierChanged(QString)), SLOT(onCardIdentifierChanged())); connect(sim, SIGNAL(preferredLanguagesChanged(QStringList)), SLOT(onPreferredLanguagesChanged())); connect(sim, SIGNAL(pinRetriesChanged(QVariantMap)), SLOT(onPinRetriesChanged())); connect(sim, SIGNAL(fixedDialingChanged(bool)), SLOT(onFixedDialingChanged())); connect(sim, SIGNAL(barredDialingChanged(bool)), SLOT(onBarredDialingChanged())); endInsertRows(); Q_EMIT simAdded(sim); } } if (countHasChanged) { Q_EMIT countChanged(); } } void QOfonoSimListModel::onSubscriberIdentityChanged() { simPropertyChanged(SubscriberIdentityRole); } void QOfonoSimListModel::onMobileCountryCodeChanged() { simPropertyChanged(MobileCountryCodeRole); } void QOfonoSimListModel::onMobileNetworkCodeChanged() { simPropertyChanged(MobileNetworkCodeRole); } void QOfonoSimListModel::onServiceProviderNameChanged() { simPropertyChanged(ServiceProviderNameRole); } void QOfonoSimListModel::onSubscriberNumbersChanged() { simPropertyChanged(SubscriberNumbersRole); } void QOfonoSimListModel::onServiceNumbersChanged() { simPropertyChanged(ServiceNumbersRole); } void QOfonoSimListModel::onPinRequiredChanged() { simPropertyChanged(PinRequiredRole); } void QOfonoSimListModel::onLockedPinsChanged() { simPropertyChanged(LockedPinsRole); } void QOfonoSimListModel::onCardIdentifierChanged() { simPropertyChanged(CardIdentifierRole); } void QOfonoSimListModel::onPreferredLanguagesChanged() { simPropertyChanged(PreferredLanguagesRole); } void QOfonoSimListModel::onPinRetriesChanged() { simPropertyChanged(PinRetriesRole); } void QOfonoSimListModel::onFixedDialingChanged() { simPropertyChanged(FixedDialingRole); } void QOfonoSimListModel::onBarredDialingChanged() { simPropertyChanged(BarredDialingRole); } ./plugin/qofonodeclarativeplugin.h0000644000004100000410000000305212762041045017637 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2014 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 QOFONODECLARATIVEPLUGIN_H #define QOFONODECLARATIVEPLUGIN_H #include "qofono_global.h" #if QT_VERSION < 0x050000 #include #include class QOFONOSHARED_EXPORT QOfonoDeclarativePlugin : public QDeclarativeExtensionPlugin #else #include #include class QOFONOSHARED_EXPORT QOfonoDeclarativePlugin : public QQmlExtensionPlugin #endif { Q_OBJECT #if QT_VERSION >= 0x050000 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface" FILE "plugin.json") #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 }; #endif // QOFONODECLARATIVEPLUGIN_H ./plugin/plugin.pro0000644000004100000410000000166012762041064014566 0ustar www-datawww-dataTARGET=QOfonoQtDeclarative TEMPLATE = lib QT += dbus CONFIG += plugin QT_VERSION=$$[QT_VERSION] equals(QT_MAJOR_VERSION, 4):{ QT += declarative PLUGIN_TYPE = declarative LIBS += -L../src -lqofono } equals(QT_MAJOR_VERSION, 5): { QT += qml QT -= gui LIBS += -L../src -lqofono-qt5 } SOURCES = \ qofonodeclarativeplugin.cpp \ qofononetworkoperatorlistmodel.cpp \ qofonosimlistmodel.cpp HEADERS = \ qofonodeclarativeplugin.h \ qofononetworkoperatorlistmodel.h \ qofonosimlistmodel.h INCLUDEPATH += ../src OTHER_FILES += \ plugin.json qmldir #plugins.qmltypes equals(QT_MAJOR_VERSION, 4): { qmldir.path = $$[QT_INSTALL_IMPORTS]/MeeGo/QOfono target.path = $$[QT_INSTALL_IMPORTS]/MeeGo/QOfono } equals(QT_MAJOR_VERSION, 5): { qmldir.path = $$[QT_INSTALL_QML]/MeeGo/QOfono target.path = $$[QT_INSTALL_QML]/MeeGo/QOfono } qmldir.files += qmldir INSTALLS += target qmldir ./plugin/plugin.json0000644000004100000410000000000312762041045014724 0ustar www-datawww-data{} ./plugin/qofononetworkoperatorlistmodel.cpp0000644000004100000410000001233512762041045021656 0ustar www-datawww-data/**************************************************************************** ** ** 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); } ./plugin/qofonodeclarativeplugin.cpp0000644000004100000410000001176012762041064020200 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2013-2015 Jolla Ltd. ** Contact: lorn.potter@jollamobile.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 "qofonodeclarativeplugin.h" #include "qofonomanager.h" #include "qofonomodem.h" #include "qofonoconnectionmanager.h" #include "qofonoconnectioncontext.h" #include "qofononetworkregistration.h" #include "qofononetworkoperator.h" #include "qofonocellbroadcast.h" #include "qofonocallbarring.h" #include "qofonocallforwarding.h" #include "qofonocallmeter.h" #include "qofonocallsettings.h" #include "qofonocallvolume.h" #include "qofonomessage.h" #include "qofonomessagemanager.h" #include "qofonomessagewaiting.h" #include "qofonosimmanager.h" #include "qofonophonebook.h" #include "qofonosmartmessaging.h" #include "qofonosmartmessagingagent.h" #include "qofonovoicecall.h" #include "qofonovoicecallmanager.h" #include "qofonoradiosettings.h" #include "qofonosupplementaryservices.h" #include "qofonophonebook.h" #include "qofonotexttelephony.h" #include "qofonohandsfree.h" #include "qofonohandsfreeaudioagent.h" #include "qofonohandsfreeaudiocard.h" #include "qofonohandsfreeaudiomanager.h" #include "qofonoassistedsatellitenavigation.h" #include "qofonopositioningrequestagent.h" #include "qofonolocationreporting.h" #include "qofononetworkoperatorlistmodel.h" #include "qofonosimlistmodel.h" void QOfonoDeclarativePlugin::registerTypes(const char *uri, int major, int minor) { Q_ASSERT(QLatin1String(uri) == QLatin1String("MeeGo.QOfono")); qmlRegisterType(uri,major,minor,"OfonoManager"); qmlRegisterType(uri,major,minor,"OfonoModem"); qmlRegisterType(uri,major,minor,"OfonoConnMan"); qmlRegisterType(uri,major,minor,"OfonoContextConnection"); qmlRegisterType(uri,major,minor,"OfonoNetworkRegistration"); qmlRegisterType(uri,major,minor,"OfonoNetworkOperator"); qmlRegisterType(uri,major,minor,"OfonoCellBroadcast"); qmlRegisterType(uri,major,minor,"OfonoCallBarring"); qmlRegisterType(uri,major,minor,"OfonoCallForwarding"); qmlRegisterType(uri,major,minor,"OfonoCallSettings"); qmlRegisterType(uri,major,minor,"OfonoCallMeter"); qmlRegisterType(uri,major,minor,"OfonoMessage"); qmlRegisterType(uri,major,minor,"OfonoMessageManager"); qmlRegisterType(uri,major,minor,"OfonoMessageWaiting"); qmlRegisterType(uri,major,minor,"OfonoSimManager"); qmlRegisterType(uri,major,minor,"OfonoSmartMessaging"); qmlRegisterType(uri,major,minor,"OfonoSmartMessagingAgent"); qmlRegisterType(uri,major,minor,"OfonoVoiceCall"); qmlRegisterType(uri,major,minor,"OfonoVoiceCallManager"); qmlRegisterType(uri,major,minor,"OfonoRadioSettings"); qmlRegisterType(uri,major,minor,"OfonoSupplementaryServices"); qmlRegisterType(uri,major,minor,"OfonoPhonebook"); qmlRegisterType(uri,major,minor,"OfonoTextTelephony"); qmlRegisterType(uri,major,minor,"OfonoHandsfree"); qmlRegisterType(uri,major,minor,"OfonoHandsfreeAudioAgent"); qmlRegisterType(uri,major,minor,"OfonoHandsfreeAudioCard"); qmlRegisterType(uri,major,minor,"OfonoHandsfreeAudioManager"); qmlRegisterType(uri,major,minor,"OfonoAssistedSatelliteNavigation"); qmlRegisterType(uri,major,minor,"OfonoPositioningRequestAgent"); qmlRegisterType(uri,major,minor,"OfonoLocationReporting"); qmlRegisterType(uri,major,minor,"OfonoNetworkOperatorListModel"); qmlRegisterType(uri,major,minor,"OfonoSimListModel"); } void QOfonoDeclarativePlugin::registerTypes(const char *uri) { registerTypes(uri, 0, 2); } #if QT_VERSION < 0x050000 void QOfonoDeclarativePlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) { Q_UNUSED(uri); Q_UNUSED(engine); } Q_EXPORT_PLUGIN2(ofonomodule, QT_PREPEND_NAMESPACE(QOfonoDeclarativePlugin)) #endif ./plugin/qmldir0000644000004100000410000000005712762041045013757 0ustar www-datawww-datamodule MeeGo.QOfono plugin QOfonoQtDeclarative ./plugin/qofonosimlistmodel.h0000644000004100000410000000564512762041064016655 0ustar www-datawww-data/**************************************************************************** ** ** Copyright (C) 2015 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 QOFONOSIMLISTMODEL_H #define QOFONOSIMLISTMODEL_H #include "qofonosimwatcher.h" class QOfonoSimListModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(bool valid READ valid NOTIFY validChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(bool requireSubscriberIdentity READ requireSubscriberIdentity WRITE setRequireSubscriberIdentity NOTIFY requireSubscriberIdentityChanged) public: enum Role { PathRole = Qt::UserRole + 1, SubscriberIdentityRole, MobileCountryCodeRole, MobileNetworkCodeRole, ServiceProviderNameRole, SubscriberNumbersRole, ServiceNumbersRole, PinRequiredRole, LockedPinsRole, CardIdentifierRole, PreferredLanguagesRole, PinRetriesRole, FixedDialingRole, BarredDialingRole }; explicit QOfonoSimListModel(QObject* parent = NULL); bool valid() const; int count() const; bool requireSubscriberIdentity() const; void setRequireSubscriberIdentity(bool require); protected: QHash roleNames() const; int rowCount(const QModelIndex& aParent) const; QVariant data(const QModelIndex& aIndex, int aRole) const; bool setData(const QModelIndex& aIndex, const QVariant& aValue, int aRole); Q_SIGNALS: void validChanged(); void countChanged(); void requireSubscriberIdentityChanged(); void simAdded(QOfonoSimManager* sim); void simRemoved(QOfonoSimManager* sim); private Q_SLOTS: void onPresentSimListChanged(); void onSubscriberIdentityChanged(); void onMobileCountryCodeChanged(); void onMobileNetworkCodeChanged(); void onServiceProviderNameChanged(); void onSubscriberNumbersChanged(); void onServiceNumbersChanged(); void onPinRequiredChanged(); void onLockedPinsChanged(); void onCardIdentifierChanged(); void onPreferredLanguagesChanged(); void onPinRetriesChanged(); void onFixedDialingChanged(); void onBarredDialingChanged(); private: void simPropertyChanged(Role role); int indexOf(QOfonoSimManager* sim); private: QOfonoSimWatcher *simWatcher; QList simList; }; #endif // QOFONOSIMLISTMODEL_H ./plugin/qofononetworkoperatorlistmodel.h0000644000004100000410000000461612762041045021326 0ustar www-datawww-data/**************************************************************************** ** ** 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 ./libqofono.pro0000644000004100000410000000065112762041045013760 0ustar www-datawww-dataTEMPLATE = subdirs CONFIG += ordered SUBDIRS += src \ plugin \ test equals(QT_MAJOR_VERSION, 4):{ SUBDIRS += ofonotest } equals(QT_MAJOR_VERSION, 4): { OTHER_FILES += rpm/libqofono.spec \ rpm/libqofono.yaml } equals(QT_MAJOR_VERSION, 5): { OTHER_FILES += rpm/libqofono-qt5.spec \ rpm/libqofono-qt5.yaml \ TODO \ README } ./ofonotest/0000755000004100000410000000000012762041045013264 5ustar www-datawww-data./ofonotest/ofonotest.pro0000644000004100000410000000140012762041045016021 0ustar www-datawww-data# Add more folders to ship with the application, here folder_01.source = qml/ofonotest folder_01.target = qml DEPLOYMENTFOLDERS = folder_01 # Additional import path used to resolve QML modules in Creator's code model QML_IMPORT_PATH = # If your application uses the Qt Mobility libraries, uncomment the following # lines and add the respective components to the MOBILITY variable. # CONFIG += mobility # MOBILITY += # Speed up launching on MeeGo/Harmattan when using applauncherd daemon CONFIG += qdeclarative-boostable # The .cpp file which was generated for your project. Feel free to hack it. SOURCES += main.cpp # Please do not modify the following two lines. Required for deployment. include(qmlapplicationviewer/qmlapplicationviewer.pri) qtcAddDeployment() ./ofonotest/rpm/0000755000004100000410000000000012762041045014062 5ustar www-datawww-data./ofonotest/rpm/ofonotest.yaml0000644000004100000410000000125012762041045016764 0ustar www-datawww-dataName: ofonotest Summary: A Mer application implemented in QML Version: 0.1 Release: 1 Group: Qt/Qt License: LICENSE Sources: - "%{name}-%{version}.tar.bz2" Description: | A short description Of the application. # Qt Applications generally don't use configure and do use qmake Configure: none Builder: qmake # pkgconfigs we depend on to build PkgConfigBR: - "" # Packages we depend on to build PkgBR: - "" # Packages we require to run Requires: - "" Files: - "/opt" # This is a spectacle file. # It is a yaml file that uses specify to manage the spec file used to package the application. # See https://wiki.merproject.org/wiki/Spectacle for more information ./ofonotest/main.cpp0000644000004100000410000000062512762041045014717 0ustar www-datawww-data#include #include "qmlapplicationviewer.h" Q_DECL_EXPORT int main(int argc, char *argv[]) { QScopedPointer app(createApplication(argc, argv)); QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setMainQmlFile(QLatin1String("qml/ofonotest/main.qml")); viewer.showExpanded(); return app->exec(); } ./ofonotest/qml/0000755000004100000410000000000012762041045014055 5ustar www-datawww-data./ofonotest/qml/ofonotest/0000755000004100000410000000000012762041045016075 5ustar www-datawww-data./ofonotest/qml/ofonotest/main.qml0000644000004100000410000000325212762041045017536 0ustar www-datawww-dataimport QtQuick 1.1 import MeeGo.QOfono 0.2 Rectangle { width: 480 height: 560 Text { id: textLine anchors.centerIn: parent } Text { id: textLine2 anchors.top: textLine.bottom text: manager.available ? netreg.name : "Ofono not available" } MouseArea { anchors.fill: parent onClicked: { context1.active = !context1.active } } OfonoManager { id: manager onAvailableChanged: { console.log("Ofono is " + available) textLine2.text = manager.available ? netreg.currentOperator["Name"].toString() :"Ofono not available" } onModemAdded: { console.log("modem added "+modem) } onModemRemoved: console.log("modem removed") } OfonoConnMan { id: ofono1 Component.onCompleted: { // console.log(manager.modems) } modemPath: manager.modems[0] } OfonoModem { id: modem1 modemPath: manager.modems[0] } OfonoContextConnection { id: context1 contextPath : ofono1.contexts[0] Component.onCompleted: { textLine.text = context1.active ? "online" : "offline" } onActiveChanged: { textLine.text = context1.active ? "online" : "offline" } } OfonoNetworkRegistration { modemPath: manager.modems[0] id: netreg Component.onCompleted: { netreg.scan() } onNetworkOperatorsChanged : { console.log("operators :"+netreg.currentOperator["Name"].toString()) } } OfonoNetworkOperator { id: netop } } ./ofonotest/ofonotest64.png0000644000004100000410000000651012762041045016166 0ustar www-datawww-dataPNG  IHDR@@iqbKGDԂ pHYs__]݋ vpAg@@` LIDATxkl\us7\>DDQ/z8ȒkǢlɱA]]$(*mShuCha(!p"A򩭋1(֕S'rb;ߏc{=p\Z?rܙssf̹b^tM Ӡfն4p?p8`-}NѼsp"LY~m/ЂY/M#ZtDjc '(A@-JnKXtyA0mԃtl͖e`)u  7I4;(޸e ج)xh¶%5\/àP07tjkGϬ< MD/U{]$ YcKn"ck#,Ft}%+yE-OQ O8 0LR LzCkU˕IV9 g@Cj<@LTJ#+u5X]JKB2o*ؔm47u/5 õT|.k iXNOmlkZ bQR7HdcΓJndZCXll@-?ƈx߾voBrVטˌW h y%4/T-Yjsbv_{3-_2>ן~R%  hh7{'Cĵ*oyz?U)h+]KpR=>Pf|6zBW>DIͻw>vDW5 kwx'?£*\Nr^??|2 unN8EF͑5miwuvj\5Z8u$n9N_:L~w_w.]Cos@X,G p+T} PK)'.t+hM.5m!I«btvء!,KHmg% XbK5C,ǷX͉3z[,cbt!Oz@.ߏ%sq^>,3vݦ@i'D,˦6۷V `9_)i L^Dz-}x4JP( ͇O0KbZeʙB,#A$@@.x EЧ19?C̹o߶ppczU53Llj%gbYTTڢsK~L2c%]SsY+Gs{p;OO5te? bk kXcT< %dL!lƨ຦d[C#MeS~~# glsL2AN\{p֎ebǖ-X*]] 41mU+TUL?9VC۠ B1Z+eT l.eMihVCJ[dGX[s^/ӺUQ +Ⱥf)ie Wx@۠)tMʦ RMK2?3e ,XXbrQ$. b5sxYP`(Z!QLS^ ݽv.|U^WP1 әJ̒1eR^=?rM׏p65oP ]LO3ݟNeYB:kh[rtgctAVN):ZR&CDQt?d%Pa<1f1Pˣ^<ΕI隇.ɢ-;>'ss/UdžE) [l,۬(";>޸pxdO݄DdbnZ}j4 + ]qGOSW?+6rd`{8{~l~]KL>blJ]~C:?]%$=Lg%2x{{r52K Y\\!N6[-T!/Pa$BiM;L{E~0we)Q,=E, Mz}CX$Ale/c`K':@SFK=Da5,Bථm+v}\1uBfn~qxz]^vm;?̨o4sAl<>#9Dc X#<0?'jFY,F^[AwZ| oD`kh|18({v q2 Ъs1 o\N!8ƈv/Oǫ?0~K2d-IՓTL"4v;X5E#D;tnxdeL&/JWڊƛ0 rEPF^/r7\]:#U IJQP1 Tݛ꽤TuZ%捼7t d! J}?X$  k?R#40 j(o䢡 O߫ e8k/ڪ?,GL8b1RCIQI޾v ȓ`"n6xLި!;2jT ^Z; R/|T;ܾ;mj0o4-29xV뽁 l`6Uejq %tEXtdate:create2010-08-31T10:37:54+02:00~%tEXtdate:modify2010-08-31T10:37:37+02:00g] tEXtSoftwareAdobe ImageReadyqe<IENDB`./ofonotest/ofonotest80.png0000644000004100000410000001152112762041045016162 0ustar www-datawww-dataPNG  IHDRPPgAMAOX2bKGD pHYs``kB vpAgPPEIDATxi\Wu{zf4$H,2cle!@ [E8JRI9|HH%"$7Lؖ-ɒHh6޻'G3hF W{ywq1E.U]\in55}>\X8#aE>'HBqsmD{fhNފ "|DUm 6U)ޒ^r>,\O"2eY)EBLݱkYmLTU< "l\E4j:c E->3ćښeFю'z)T MaBR@T:҃pDs:>|91xS&@D-rktj$&TǝwKJu a PzT$0 ˖IW]TQ QȒ;1Y5C 7Fٶz^U\hk㠝 = TѳֈFf? %ihۦ|X1u/:ZZM؛E8 ț^NYCNxY@'e4owmWG5@Å"EJVY(qD ok eԜ 9#*zH(,p96 o6G~bp ApxL? 3qY#`_zcٽ§pC%*՟cAXWo+ļMSE B)"LTw\uU!wq8>jk1Va,=p,7GeqUUNLzJ,#PEèKM3ع=>3&r xС$'NX۲/(],+UY]ۗ?gy ]XRt)"϶p5j! %6œxÞ= w]|C5[:>O}d \“ǿɑ]XBstu|SvL: F&鋟6L$'=#] Ɔ[E1H&]뗯oϭr d l;XݲL y? qUl`_)jVW?&r,j81x}]{ edq#}c,uf2o$4ԗ]}@^=J":8SRnq"lhCOrPEw]U?u~|j,KzU!EU&.{AyiCih{)V[y';*4ly0 L&=<ĪL+J?ɚ U% W^4jaYJ /J$c>mfJ᷂ ! Q*W*`/jBi!\QQA ˲3iʓISB%ݔ'%lQQ#|9ӧdӄ獕MkCKi\C>xDz 4&ԆʒxBSd_م/]p|/Z6 <4djRN ~Xr-+Ce6P DB#;97MKK rE ,bqjdȒCq Fh55r(赯"3W6 %Xmdy*e0FKd8Nkڶx@YƆˋߪ>ڪjjKhkr &wc, /cBɱ\tghZY,3$ʹ.n)*v $`X*rJ$ʿdTWN$gw"ͩL`Y6Dxf3G\/lʩCj.YDUs}i`Yڋbߟe2Pȝn-_F 3:9ȴ@A 7!4%V\ -Fm2v9ґd`0eCF}?ɱs'ojyhbd?a3|ɟsl7+8'b6+V-t/?UNc?; '[~hӏܗ<JC}?]p DCM=u`aCc`Ŋ0YΜ[!o۴eR|Wn?ˆQ,ڛXղd88x':?MMz'yg醴TxO<Y[}?pb1*J!Q~gm[C%1,Y<~le<|B8l3txO7`M xY sSl5 |cwrN{7ɑ<}[|lKij Jy$'=D}.$r°2z_maժ0E>tcoh(Rv f0< l;ب9ҝ8*CnU{Wn uu~s/wG6x{92w֥ OE˾9 ajj%O0/)EXZEh. [tgJ`$bn]晽gQnL+!U~&$жZreD:~rtߴu,߷Nҧi+y-ܺ뮋9t?ϳo?:L*qf\Q<Խg[YvovA8VUU6RM{{|[7Ć57Q12O<;ᡗ+zARýսeP 45M8LdIEqUXuO3K +A.E?0!"2v&cX66/#s' y/\'ȟP*:dD/2YD^C ,KIIOb`9 rʨzD$>iNsfyx9 =ރ6k}f$Wm\| 5I6Q )|-1 }ˢ32N"O #p/;AW丢3CBD&·_M|[ 9پkb_slhp%tEXtdate:create2011-04-28T14:17:50+02:00%tEXtdate:modify2011-04-28T14:17:50+02:00FotEXtSoftwareAdobe ImageReadyqe<IENDB`./ofonotest/ofonotest_harmattan.desktop0000644000004100000410000000044612762041045020742 0ustar www-datawww-data[Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Terminal=false Name=ofonotest Exec=/usr/bin/invoker --type=d -s /opt/ofonotest/bin/ofonotest Icon=/usr/share/icons/hicolor/80x80/apps/ofonotest80.png X-Window-Icon= X-HildonDesk-ShowInToolbar=true X-Osso-Type=application/x-executable ./ofonotest/ofonotest.desktop0000644000004100000410000000034112762041045016675 0ustar www-datawww-data[Desktop Entry] Encoding=UTF-8 Version=1.0 Type=Application Terminal=false Name=ofonotest Exec=/opt/ofonotest/bin/ofonotest Icon=ofonotest64 X-Window-Icon= X-HildonDesk-ShowInToolbar=true X-Osso-Type=application/x-executable ./ofonotest/qmlapplicationviewer/0000755000004100000410000000000012762041045017523 5ustar www-datawww-data./ofonotest/qmlapplicationviewer/qmlapplicationviewer.cpp0000644000004100000410000001161712762041045024474 0ustar www-datawww-data// checksum 0xbe90 version 0x90018 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific code such as screen orientation handling. Also QML paths and debugging are handled here. It is recommended not to modify this file, since newer versions of Qt Creator may offer an updated version of it. */ #include "qmlapplicationviewer.h" #include #include #include #include #include #include #include // MEEGO_EDITION_HARMATTAN #ifdef HARMATTAN_BOOSTER #include #endif #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 #include #if !defined(NO_JSDEBUGGER) #include #endif #if !defined(NO_QMLOBSERVER) #include #endif // Enable debugging before any QDeclarativeEngine is created struct QmlJsDebuggingEnabler { QmlJsDebuggingEnabler() { QDeclarativeDebugHelper::enableDebugging(); } }; // Execute code in constructor before first QDeclarativeEngine is instantiated static QmlJsDebuggingEnabler enableDebuggingHelper; #endif // QMLJSDEBUGGER class QmlApplicationViewerPrivate { QString mainQmlFile; friend class QmlApplicationViewer; static QString adjustPath(const QString &path); }; QString QmlApplicationViewerPrivate::adjustPath(const QString &path) { #ifdef Q_OS_MAC if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("%1/../Resources/%2") .arg(QCoreApplication::applicationDirPath(), path); #elif defined(Q_OS_BLACKBERRY) if (!QDir::isAbsolutePath(path)) return QString::fromLatin1("app/native/%1").arg(path); #elif !defined(Q_OS_ANDROID) QString pathInInstallDir = QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; pathInInstallDir = QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path); if (QFileInfo(pathInInstallDir).exists()) return pathInInstallDir; #endif return path; } QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) : QDeclarativeView(parent) , d(new QmlApplicationViewerPrivate()) { connect(engine(), SIGNAL(quit()), SLOT(close())); setResizeMode(QDeclarativeView::SizeRootObjectToView); // Qt versions prior to 4.8.0 don't have QML/JS debugging services built in #if defined(QMLJSDEBUGGER) && QT_VERSION < 0x040800 #if !defined(NO_JSDEBUGGER) new QmlJSDebugger::JSDebuggerAgent(engine()); #endif #if !defined(NO_QMLOBSERVER) new QmlJSDebugger::QDeclarativeViewObserver(this, this); #endif #endif } QmlApplicationViewer::~QmlApplicationViewer() { delete d; } QmlApplicationViewer *QmlApplicationViewer::create() { return new QmlApplicationViewer(); } void QmlApplicationViewer::setMainQmlFile(const QString &file) { d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); #ifdef Q_OS_ANDROID setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile)); #else setSource(QUrl::fromLocalFile(d->mainQmlFile)); #endif } void QmlApplicationViewer::addImportPath(const QString &path) { engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); } void QmlApplicationViewer::setOrientation(ScreenOrientation orientation) { #if QT_VERSION < 0x050000 Qt::WidgetAttribute attribute; switch (orientation) { #if QT_VERSION < 0x040702 // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes case ScreenOrientationLockPortrait: attribute = static_cast(128); break; case ScreenOrientationLockLandscape: attribute = static_cast(129); break; default: case ScreenOrientationAuto: attribute = static_cast(130); break; #else // QT_VERSION < 0x040702 case ScreenOrientationLockPortrait: attribute = Qt::WA_LockPortraitOrientation; break; case ScreenOrientationLockLandscape: attribute = Qt::WA_LockLandscapeOrientation; break; default: case ScreenOrientationAuto: attribute = Qt::WA_AutoOrientation; break; #endif // QT_VERSION < 0x040702 }; setAttribute(attribute, true); #else // QT_VERSION < 0x050000 Q_UNUSED(orientation) #endif // QT_VERSION < 0x050000 } void QmlApplicationViewer::showExpanded() { #if defined(MEEGO_EDITION_HARMATTAN) || defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX) showFullScreen(); #elif defined(Q_WS_MAEMO_5) showMaximized(); #else show(); #endif } QApplication *createApplication(int &argc, char **argv) { #ifdef HARMATTAN_BOOSTER return MDeclarativeCache::qApplication(argc, argv); #else return new QApplication(argc, argv); #endif } ./ofonotest/qmlapplicationviewer/qmlapplicationviewer.h0000644000004100000410000000233412762041045024135 0ustar www-datawww-data// checksum 0xc67a version 0x90018 /* This file was generated by the Qt Quick Application wizard of Qt Creator. QmlApplicationViewer is a convenience class containing mobile device specific code such as screen orientation handling. Also QML paths and debugging are handled here. It is recommended not to modify this file, since newer versions of Qt Creator may offer an updated version of it. */ #ifndef QMLAPPLICATIONVIEWER_H #define QMLAPPLICATIONVIEWER_H #include class QmlApplicationViewer : public QDeclarativeView { Q_OBJECT public: enum ScreenOrientation { ScreenOrientationLockPortrait, ScreenOrientationLockLandscape, ScreenOrientationAuto }; explicit QmlApplicationViewer(QWidget *parent = 0); virtual ~QmlApplicationViewer(); static QmlApplicationViewer *create(); void setMainQmlFile(const QString &file); void addImportPath(const QString &path); // Note that this will only have an effect on Fremantle. void setOrientation(ScreenOrientation orientation); void showExpanded(); private: class QmlApplicationViewerPrivate *d; }; QApplication *createApplication(int &argc, char **argv); #endif // QMLAPPLICATIONVIEWER_H ./ofonotest/qmlapplicationviewer/qmlapplicationviewer.pri0000644000004100000410000001477412762041045024513 0ustar www-datawww-data# checksum 0xf003 version 0x90018 # This file was generated by the Qt Quick Application wizard of Qt Creator. # The code below adds the QmlApplicationViewer to the project and handles the # activation of QML debugging. # It is recommended not to modify this file, since newer versions of Qt Creator # may offer an updated version of it. QT += declarative SOURCES += $$PWD/qmlapplicationviewer.cpp HEADERS += $$PWD/qmlapplicationviewer.h INCLUDEPATH += $$PWD # Include JS debugger library if QMLJSDEBUGGER_PATH is set !isEmpty(QMLJSDEBUGGER_PATH) { include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) } else { DEFINES -= QMLJSDEBUGGER } contains(CONFIG,qdeclarative-boostable):contains(MEEGO_EDITION,harmattan) { DEFINES += HARMATTAN_BOOSTER } # This file was generated by an application wizard of Qt Creator. # The code below handles deployment to Android and Maemo, aswell as copying # of the application data to shadow build directories on desktop. # It is recommended not to modify this file, since newer versions of Qt Creator # may offer an updated version of it. defineTest(qtcAddDeployment) { for(deploymentfolder, DEPLOYMENTFOLDERS) { item = item$${deploymentfolder} greaterThan(QT_MAJOR_VERSION, 4) { itemsources = $${item}.files } else { itemsources = $${item}.sources } $$itemsources = $$eval($${deploymentfolder}.source) itempath = $${item}.path $$itempath= $$eval($${deploymentfolder}.target) export($$itemsources) export($$itempath) DEPLOYMENT += $$item } MAINPROFILEPWD = $$PWD android-no-sdk { for(deploymentfolder, DEPLOYMENTFOLDERS) { item = item$${deploymentfolder} itemfiles = $${item}.files $$itemfiles = $$eval($${deploymentfolder}.source) itempath = $${item}.path $$itempath = /data/user/qt/$$eval($${deploymentfolder}.target) export($$itemfiles) export($$itempath) INSTALLS += $$item } target.path = /data/user/qt export(target.path) INSTALLS += target } else:android { for(deploymentfolder, DEPLOYMENTFOLDERS) { item = item$${deploymentfolder} itemfiles = $${item}.files $$itemfiles = $$eval($${deploymentfolder}.source) itempath = $${item}.path $$itempath = /assets/$$eval($${deploymentfolder}.target) export($$itemfiles) export($$itempath) INSTALLS += $$item } x86 { target.path = /libs/x86 } else: armeabi-v7a { target.path = /libs/armeabi-v7a } else { target.path = /libs/armeabi } export(target.path) INSTALLS += target } else:win32 { copyCommand = for(deploymentfolder, DEPLOYMENTFOLDERS) { source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) source = $$replace(source, /, \\) sourcePathSegments = $$split(source, \\) target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments) target = $$replace(target, /, \\) target ~= s,\\\\\\.?\\\\,\\, !isEqual(source,$$target) { !isEmpty(copyCommand):copyCommand += && isEqual(QMAKE_DIR_SEP, \\) { copyCommand += $(COPY_DIR) \"$$source\" \"$$target\" } else { source = $$replace(source, \\\\, /) target = $$OUT_PWD/$$eval($${deploymentfolder}.target) target = $$replace(target, \\\\, /) copyCommand += test -d \"$$target\" || mkdir -p \"$$target\" && cp -r \"$$source\" \"$$target\" } } } !isEmpty(copyCommand) { copyCommand = @echo Copying application data... && $$copyCommand copydeploymentfolders.commands = $$copyCommand first.depends = $(first) copydeploymentfolders export(first.depends) export(copydeploymentfolders.commands) QMAKE_EXTRA_TARGETS += first copydeploymentfolders } } else:unix { maemo5 { desktopfile.files = $${TARGET}.desktop desktopfile.path = /usr/share/applications/hildon icon.files = $${TARGET}64.png icon.path = /usr/share/icons/hicolor/64x64/apps } else:!isEmpty(MEEGO_VERSION_MAJOR) { desktopfile.files = $${TARGET}_harmattan.desktop desktopfile.path = /usr/share/applications icon.files = $${TARGET}80.png icon.path = /usr/share/icons/hicolor/80x80/apps } else { # Assumed to be a Desktop Unix copyCommand = for(deploymentfolder, DEPLOYMENTFOLDERS) { source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) source = $$replace(source, \\\\, /) macx { target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) } else { target = $$OUT_PWD/$$eval($${deploymentfolder}.target) } target = $$replace(target, \\\\, /) sourcePathSegments = $$split(source, /) targetFullPath = $$target/$$last(sourcePathSegments) targetFullPath ~= s,/\\.?/,/, !isEqual(source,$$targetFullPath) { !isEmpty(copyCommand):copyCommand += && copyCommand += $(MKDIR) \"$$target\" copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\" } } !isEmpty(copyCommand) { copyCommand = @echo Copying application data... && $$copyCommand copydeploymentfolders.commands = $$copyCommand first.depends = $(first) copydeploymentfolders export(first.depends) export(copydeploymentfolders.commands) QMAKE_EXTRA_TARGETS += first copydeploymentfolders } } !isEmpty(target.path) { installPrefix = $${target.path} } else { installPrefix = /opt/$${TARGET} } for(deploymentfolder, DEPLOYMENTFOLDERS) { item = item$${deploymentfolder} itemfiles = $${item}.files $$itemfiles = $$eval($${deploymentfolder}.source) itempath = $${item}.path $$itempath = $${installPrefix}/$$eval($${deploymentfolder}.target) export($$itemfiles) export($$itempath) INSTALLS += $$item } !isEmpty(desktopfile.path) { export(icon.files) export(icon.path) export(desktopfile.files) export(desktopfile.path) INSTALLS += icon desktopfile } isEmpty(target.path) { target.path = $${installPrefix}/bin export(target.path) } INSTALLS += target } export (ICON) export (INSTALLS) export (DEPLOYMENT) export (LIBS) export (QMAKE_EXTRA_TARGETS) }