INCLUDEPATH += ../
PUBLIC_HEADERS += libofono-qt_global.h
+PUBLIC_HEADERS += ofonopropertysetting.h
PUBLIC_HEADERS += ofonointerface.h
PUBLIC_HEADERS += ofonomodeminterface.h
PUBLIC_HEADERS += ofonomodemmanager.h
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
#include "ofonocallbarring.h"
+#include "ofonointerface.h"
#define SET_PROPERTY_TIMEOUT 300000
OfonoCallBarring::OfonoCallBarring(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallBarring", OfonoInterface::GetAllOnFirstRequest, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallBarring", OfonoGetAllOnFirstRequest, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- connect(this, SIGNAL(setPropertyFailed(const QString&)),
+ connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
this, SLOT(setPropertyFailed(const QString&)));
- connect(this, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
- QDBusConnection::systemBus().connect("org.ofono", path(), ifname(),
+ QDBusConnection::systemBus().connect("org.ofono", path(), m_if->ifname(),
"IncomingBarringInEffect",
this,
SIGNAL(incomingBarringInEffect()));
- QDBusConnection::systemBus().connect("org.ofono", path(), ifname(),
+ QDBusConnection::systemBus().connect("org.ofono", path(), m_if->ifname(),
"OutgoingBarringInEffect",
this,
SIGNAL(outgoingBarringInEffect()));
{
if (m_pendingProperty.length() > 0) {
// FIXME: should indicate that a setProperty is already in progress
- m_errorName = QString();
- m_errorMessage = QString("Operation already in progress");
+ m_if->setError(QString(), QString("Operation already in progress"));
emit setPropertyFailed(name);
return;
}
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"SetProperty");
request.setArguments(QList<QVariant>()
<< QVariant(name)
SET_PROPERTY_TIMEOUT);
if (!result) {
// FIXME: should indicate that sending a message failed
- m_errorName = QString();
- m_errorMessage = QString("DBUS sending failed");
+ m_if->setError(QString(), QString("DBUS sending failed"));
emit setPropertyFailed(name);
return;
}
void OfonoCallBarring::setPropertyErr(const QDBusError& error)
{
QString prop = m_pendingProperty;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
m_pendingProperty = QString();
emit setPropertyFailed(prop);
}
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"ChangePassword");
request << old_password << new_password;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"DisableAll");
request << password;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"DisableAllIncoming");
request << password;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"DisableAllOutgoing");
request << password;
void OfonoCallBarring::requestVoiceIncoming()
{
- requestProperty("VoiceIncoming");
+ m_if->requestProperty("VoiceIncoming");
}
void OfonoCallBarring::setVoiceIncoming(const QString &barrings, const QString &password)
void OfonoCallBarring::requestVoiceOutgoing()
{
- requestProperty("VoiceOutgoing");
+ m_if->requestProperty("VoiceOutgoing");
}
void OfonoCallBarring::setVoiceOutgoing(const QString &barrings, const QString &password)
void OfonoCallBarring::changePasswordErr(QDBusError error)
{
qDebug() << "ChangePassword failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit changePasswordComplete(FALSE);
}
void OfonoCallBarring::disableAllErr(QDBusError error)
{
qDebug() << "DisableAll failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit disableAllComplete(FALSE);
}
void OfonoCallBarring::disableAllIncomingErr(QDBusError error)
{
qDebug() << "DisableAllIncoming failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit disableAllIncomingComplete(FALSE);
}
void OfonoCallBarring::disableAllOutgoingErr(QDBusError error)
{
qDebug() << "DisableAllOutgoing failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit disableAllOutgoingComplete(FALSE);
}
#define OFONOCALLBARRING_H
#include <QtCore/QObject>
+#include <QDBusError>
#include "ofonomodeminterface.h"
#include "libofono-qt_global.h"
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
#include "ofonocallforwarding.h"
+#include "ofonointerface.h"
OfonoCallForwarding::OfonoCallForwarding(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallForwarding", OfonoInterface::GetAllOnFirstRequest, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallForwarding", OfonoGetAllOnFirstRequest, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- connect(this, SIGNAL(setPropertyFailed(const QString&)),
+ connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
this, SLOT(setPropertyFailed(const QString&)));
- connect(this, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
}
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"DisableAll");
request << type;
void OfonoCallForwarding::requestVoiceUnconditional()
{
- requestProperty("VoiceUnconditional");
+ m_if->requestProperty("VoiceUnconditional");
}
void OfonoCallForwarding::setVoiceUnconditional(const QString &property)
{
- setProperty("VoiceUnconditional", qVariantFromValue(property));
+ m_if->setProperty("VoiceUnconditional", qVariantFromValue(property));
}
void OfonoCallForwarding::requestVoiceBusy()
{
- requestProperty("VoiceBusy");
+ m_if->requestProperty("VoiceBusy");
}
void OfonoCallForwarding::setVoiceBusy(const QString &property)
{
- return setProperty("VoiceBusy", qVariantFromValue(property));
+ return m_if->setProperty("VoiceBusy", qVariantFromValue(property));
}
void OfonoCallForwarding::requestVoiceNoReply()
{
- requestProperty("VoiceNoReply");
+ m_if->requestProperty("VoiceNoReply");
}
void OfonoCallForwarding::setVoiceNoReply(const QString &property)
{
- return setProperty("VoiceNoReply", qVariantFromValue(property));
+ return m_if->setProperty("VoiceNoReply", qVariantFromValue(property));
}
void OfonoCallForwarding::requestVoiceNoReplyTimeout()
{
- requestProperty("VoiceNoReplyTimeout");
+ m_if->requestProperty("VoiceNoReplyTimeout");
}
void OfonoCallForwarding::setVoiceNoReplyTimeout(ushort timeout)
{
- return setProperty("VoiceNoReplyTimeout", qVariantFromValue(timeout));
+ return m_if->setProperty("VoiceNoReplyTimeout", qVariantFromValue(timeout));
}
void OfonoCallForwarding::requestVoiceNotReachable()
{
- requestProperty("VoiceNotReachable");
+ m_if->requestProperty("VoiceNotReachable");
}
void OfonoCallForwarding::setVoiceNotReachable(const QString &property)
{
- return setProperty("VoiceNotReachable", qVariantFromValue(property));
+ return m_if->setProperty("VoiceNotReachable", qVariantFromValue(property));
}
void OfonoCallForwarding::disableAllErr(QDBusError error)
{
qDebug() << "DisableAll failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit disableAllComplete(FALSE);
}
#define OFONOCALLFORWARDING_H
#include <QtCore/QObject>
+#include <QDBusError>
#include "ofonomodeminterface.h"
#include "libofono-qt_global.h"
#include <QtCore/QObject>
#include "ofonocallmeter.h"
+#include "ofonointerface.h"
OfonoCallMeter::OfonoCallMeter(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallMeter", OfonoInterface::GetAllOnFirstRequest, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallMeter", OfonoGetAllOnFirstRequest, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- connect(this, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
}
void OfonoCallMeter::requestCallMeter()
{
- requestProperty("CallMeter");
+ m_if->requestProperty("CallMeter");
}
void OfonoCallMeter::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
#include <QtCore/QObject>
#include "ofonocallsettings.h"
+#include "ofonointerface.h"
OfonoCallSettings::OfonoCallSettings(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallSettings", OfonoInterface::GetAllOnFirstRequest, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallSettings", OfonoGetAllOnFirstRequest, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- connect(this, SIGNAL(setPropertyFailed(const QString&)),
+ connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
this, SLOT(setPropertyFailed(const QString&)));
- connect(this, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
}
void OfonoCallSettings::requestCallingLinePresentation()
{
- requestProperty("CallingLinePresentation");
+ m_if->requestProperty("CallingLinePresentation");
}
void OfonoCallSettings::requestCalledLinePresentation()
{
- requestProperty("CalledLinePresentation");
+ m_if->requestProperty("CalledLinePresentation");
}
void OfonoCallSettings::requestCalledLineRestriction()
{
- requestProperty("CalledLineRestriction");
+ m_if->requestProperty("CalledLineRestriction");
}
void OfonoCallSettings::requestCallingLineRestriction()
{
- requestProperty("CallingLineRestriction");
+ m_if->requestProperty("CallingLineRestriction");
}
void OfonoCallSettings::requestHideCallerId()
{
- requestProperty("HideCallerId");
+ m_if->requestProperty("HideCallerId");
}
void OfonoCallSettings::requestVoiceCallWaiting()
{
- requestProperty("VoiceCallWaiting");
+ m_if->requestProperty("VoiceCallWaiting");
}
void OfonoCallSettings::setHideCallerId(const QString &preference)
{
- return setProperty("HideCallerId", qVariantFromValue(preference));
+ return m_if->setProperty("HideCallerId", qVariantFromValue(preference));
}
void OfonoCallSettings::setVoiceCallWaiting(const QString &preference)
{
- return setProperty("VoiceCallWaiting", qVariantFromValue(preference));
+ return m_if->setProperty("VoiceCallWaiting", qVariantFromValue(preference));
}
void OfonoCallSettings::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
#define GET_PROPERTIES_TIMEOUT 300000
#define SET_PROPERTY_TIMEOUT 300000
-OfonoInterface::OfonoInterface(const QString& path, const QString& ifname, GetPropertySetting setting, QObject *parent)
+OfonoInterface::OfonoInterface(const QString& path, const QString& ifname, OfonoGetPropertySetting setting, QObject *parent)
: QObject(parent) , m_path(path), m_ifname(ifname), m_getpropsetting(setting)
{
QDBusConnection::systemBus().connect("org.ofono", path, ifname,
"PropertyChanged",
this,
SLOT(onPropertyChanged(QString, QDBusVariant)));
- if (setting == GetAllOnStartup && path != "/")
+ if (setting == OfonoGetAllOnStartup && path != "/")
m_properties = getAllPropertiesSync();
}
this,
SLOT(onPropertyChanged(QString, QDBusVariant)));
- if (m_getpropsetting == GetAllOnStartup)
+ if (m_getpropsetting == OfonoGetAllOnStartup)
m_properties = getAllPropertiesSync();
else
resetProperties();
{
if (m_pendingProperty.length() > 0) {
// FIXME: should indicate that a get/setProperty is already in progress
- m_errorName = QString();
- m_errorMessage = QString("Already in progress");
+ setError(QString(), QString("Already in progress"));
emit requestPropertyComplete(false, name, QVariant());
return;
}
GET_PROPERTIES_TIMEOUT);
if (!result) {
// FIXME: should indicate that sending a message failed
- m_errorName = QString();
- m_errorMessage = QString("Sending a message failed");
+ setError(QString(), QString("Sending a message failed"));
emit requestPropertyComplete(false, name, QVariant());
return;
}
emit requestPropertyComplete(true, prop, m_properties[prop]);
} else {
// FIXME: should indicate that property is not available
- m_errorName = QString();
- m_errorMessage = QString("Property not available");
+ setError(QString(), QString("Property not available"));
emit requestPropertyComplete(false, prop, QVariant());
}
foreach (QString property, properties.keys()) {
void OfonoInterface::getPropertiesAsyncErr(const QDBusError& error)
{
QString prop = m_pendingProperty;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ setError(error.name(), error.message());
m_pendingProperty = QString();
emit requestPropertyComplete(false, prop, QVariant());
}
{
if (m_pendingProperty.length() > 0) {
// FIXME: should indicate that a get/setProperty is already in progress
- m_errorName = QString();
- m_errorMessage = QString("Already in progress");
+ setError(QString(), QString("Already in progress"));
emit setPropertyFailed(name);
return;
}
SET_PROPERTY_TIMEOUT);
if (!result) {
// FIXME: should indicate that sending a message failed
- m_errorName = QString();
- m_errorMessage = QString();
+ setError(QString(), QString("Sending a message failed"));
emit setPropertyFailed(name);
return;
}
void OfonoInterface::setPropertyErr(const QDBusError& error)
{
QString prop = m_pendingProperty;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ setError(error.name(), error.message());
m_pendingProperty = QString();
emit setPropertyFailed(prop);
}
+void OfonoInterface::setError(const QString& errorName, const QString& errorMessage)
+{
+ m_errorName = errorName;
+ m_errorMessage = errorMessage;
+}
#include <QVariant>
#include <QDBusVariant>
#include <QDBusError>
+#include "ofonopropertysetting.h"
#include "libofono-qt_global.h"
//! Basic oFono interface class
Q_OBJECT
public:
- //! How to handle getting the properties
- enum GetPropertySetting {
- GetAllOnStartup, /*!< Get all properties synchronously on startup;
- * they would be immediately available. */
- GetAllOnFirstRequest /*!< Do not get properties on startup;
- * get them in an asynhronous way when the first
- * property is requested. */
- };
-
/*!
* \param path D-Bus path to the interface
* \param ifname D-Bus name of the interface
* \param setting specifies how the object should handle oFono properties of the interface
*/
- OfonoInterface(const QString &path, const QString &ifname, GetPropertySetting setting, QObject *parent=0);
+ OfonoInterface(const QString &path, const QString &ifname, OfonoGetPropertySetting setting, QObject *parent=0);
~OfonoInterface();
//! Get all properties
* GetAllOnStartup or reset otherwise.
*/
void setPath(const QString &path);
+
+ //! Sets the last error explicitly
+ void setError(const QString &errorName, const QString &errorMessage);
signals:
//! Issued when a property has changed
QString m_ifname;
QVariantMap m_properties;
QString m_pendingProperty;
- GetPropertySetting m_getpropsetting;
+ OfonoGetPropertySetting m_getpropsetting;
};
#endif
#include <QtCore/QObject>
#include "ofonomessagemanager.h"
+#include "ofonointerface.h"
OfonoMessageManager::OfonoMessageManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.MessageManager", OfonoInterface::GetAllOnFirstRequest, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.MessageManager", OfonoGetAllOnFirstRequest, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- connect(this, SIGNAL(setPropertyFailed(const QString&)),
+ connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
this, SLOT(setPropertyFailed(const QString&)));
- connect(this, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
}
void OfonoMessageManager::requestServiceCenterAddress()
{
- requestProperty("ServiceCenterAddress");
+ m_if->requestProperty("ServiceCenterAddress");
}
void OfonoMessageManager::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
#include <QtCore/QObject>
#include "ofonomessagewaiting.h"
+#include "ofonointerface.h"
OfonoMessageWaiting::OfonoMessageWaiting(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.MessageWaiting", OfonoInterface::GetAllOnStartup, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.MessageWaiting", OfonoGetAllOnStartup, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- connect(this, SIGNAL(setPropertyFailed(const QString&)),
+ connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
this, SLOT(setPropertyFailed(const QString&)));
}
bool OfonoMessageWaiting::voicemailWaiting() const
{
- return properties()["VoicemailWaiting"].value<bool>();
+ return m_if->properties()["VoicemailWaiting"].value<bool>();
}
int OfonoMessageWaiting::voicemailMessageCount() const
{
- return properties()["VoicemailMessageCount"].value<int>();
+ return m_if->properties()["VoicemailMessageCount"].value<int>();
}
QString OfonoMessageWaiting::voicemailMailboxNumber() const
{
- return properties()["VoicemailMailboxNumber"].value<QString>();
+ return m_if->properties()["VoicemailMailboxNumber"].value<QString>();
}
void OfonoMessageWaiting::setVoicemailMailboxNumber(QString mailboxnumber)
{
- setProperty("VoicemailMailboxNumber", qVariantFromValue(mailboxnumber));
+ m_if->setProperty("VoicemailMailboxNumber", qVariantFromValue(mailboxnumber));
}
void OfonoMessageWaiting::setPropertyFailed(const QString& property)
if (finalModemPath.isEmpty()) {
finalModemPath = "/";
}
- m_if = new OfonoInterface(finalModemPath, "org.ofono.Modem", OfonoInterface::GetAllOnStartup, this);
+ m_if = new OfonoInterface(finalModemPath, "org.ofono.Modem", OfonoGetAllOnStartup, this);
connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
#include "ofonomodeminterface.h"
#include "ofonomodem.h"
+#include "ofonointerface.h"
-OfonoModemInterface::OfonoModemInterface(OfonoModem::SelectionSetting modemSetting, const QString& modemPath, const QString& ifname, GetPropertySetting propertySetting, QObject *parent)
- : OfonoInterface("/", ifname, propertySetting, parent)
+OfonoModemInterface::OfonoModemInterface(OfonoModem::SelectionSetting modemSetting, const QString& modemPath, const QString& ifname, OfonoGetPropertySetting propertySetting, QObject *parent)
+ : QObject(parent)
{
m_m = new OfonoModem(modemSetting, modemPath, this);
connect(m_m, SIGNAL(interfacesChanged(QStringList)), this, SLOT(interfacesChanged(QStringList)));
connect(m_m, SIGNAL(pathChanged(QString)), this, SLOT(setPath(QString)));
- setPath(m_m->path());
+ m_if = new OfonoInterface(m_m->path(), ifname, propertySetting, parent);
m_isValid = checkValidity();
}
bool OfonoModemInterface::checkValidity()
{
- return (m_m->isValid() && m_m->interfaces().contains(ifname()));
+ return (m_m->isValid() && m_m->interfaces().contains(m_if->ifname()));
}
void OfonoModemInterface::updateValidity()
updateValidity();
}
+QString OfonoModemInterface::path() const
+{
+ return m_if->path();
+}
+
+QString OfonoModemInterface::errorName() const
+{
+ return m_if->errorName();
+}
+
+QString OfonoModemInterface::errorMessage() const
+{
+ return m_if->errorMessage();
+}
+
#include <QtCore/QObject>
#include <QStringList>
-#include "ofonointerface.h"
#include "ofonomodem.h"
+#include "ofonopropertysetting.h"
#include "libofono-qt_global.h"
+class OfonoInterface;
+
//! This class implements a generic modem interface object
/*!
- * It adds validity checking and modem binding to OfonoInterface class.
+ * It provides validity checking and modem binding.
* It should not be instantiated directly; instead you should instantiate
* interface-specific subclasses.
*/
-class OFONO_QT_EXPORT OfonoModemInterface : public OfonoInterface
+class OFONO_QT_EXPORT OfonoModemInterface : public QObject
{
Q_OBJECT
public:
* \param ifname d-bus interface name
* \param propertySetting oFono d-bus properties setting
*/
- OfonoModemInterface(OfonoModem::SelectionSetting modemSetting, const QString& modemPath, const QString& ifname, GetPropertySetting propertySetting, QObject *parent=0);
+ OfonoModemInterface(OfonoModem::SelectionSetting modemSetting, const QString& modemPath, const QString& ifname, OfonoGetPropertySetting propertySetting, QObject *parent=0);
~OfonoModemInterface();
//! Check that the modem interface object is valid
//! Get the modem object that this interface belongs to
OfonoModem *modem() const;
+
+ //! Returns the D-Bus object path of the interface
+ QString path() const;
+
+ //! Get the D-Bus error name of the last operation.
+ /*!
+ * Returns the D-Bus error name of the last operation (setting a property
+ * or calling a method) if it has failed
+ */
+ QString errorName() const;
+
+ //! Get the D-Bus error message of the last operation.
+ /*!
+ * Returns the D-Bus error message of the last operation (setting a property
+ * or calling a method) if it has failed
+ */
+ QString errorMessage() const;
signals:
//! Interface validity has changed
void modemValidityChanged(bool validity);
void interfacesChanged(const QStringList &interfaces);
+protected:
+ OfonoInterface *m_if;
+
private:
OfonoModem *m_m;
bool m_isValid;
#define REGISTER_TIMEOUT 300000
OfonoNetworkOperator::OfonoNetworkOperator(const QString& operatorId, QObject *parent)
- : OfonoInterface(operatorId, "org.ofono.NetworkOperator", OfonoInterface::GetAllOnStartup, parent)
+ : OfonoInterface(operatorId, "org.ofono.NetworkOperator", OfonoGetAllOnStartup, parent)
{
connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
#include <QtCore/QObject>
#include "ofononetworkregistration.h"
+#include "ofonointerface.h"
#define REGISTER_TIMEOUT 300000
#define SCAN_TIMEOUT 300000
OfonoNetworkRegistration::OfonoNetworkRegistration(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.NetworkRegistration", OfonoInterface::GetAllOnStartup, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.NetworkRegistration", OfonoGetAllOnStartup, parent)
{
qDBusRegisterMetaType<OfonoOperatorStruct>();
qDBusRegisterMetaType<OfonoOperatorList>();
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
}
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"Register");
QDBusConnection::systemBus().callWithCallback(request, this,
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"Deregister");
QDBusConnection::systemBus().callWithCallback(request, this,
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"Scan");
QDBusConnection::systemBus().callWithCallback(request, this,
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"GetOperators");
QDBusConnection::systemBus().callWithCallback(request, this,
QString OfonoNetworkRegistration::mode() const
{
- return properties()["Mode"].value<QString>();
+ return m_if->properties()["Mode"].value<QString>();
}
QString OfonoNetworkRegistration::status() const
{
- return properties()["Status"].value<QString>();
+ return m_if->properties()["Status"].value<QString>();
}
uint OfonoNetworkRegistration::locationAreaCode() const
{
- return properties()["LocationAreaCode"].value<uint>();
+ return m_if->properties()["LocationAreaCode"].value<uint>();
}
uint OfonoNetworkRegistration::cellId() const
{
- return properties()["CellId"].value<uint>();
+ return m_if->properties()["CellId"].value<uint>();
}
QString OfonoNetworkRegistration::mcc() const
{
- return properties()["MobileCountryCode"].value<QString>();
+ return m_if->properties()["MobileCountryCode"].value<QString>();
}
QString OfonoNetworkRegistration::mnc() const
{
- return properties()["MobileNetworkCode"].value<QString>();
+ return m_if->properties()["MobileNetworkCode"].value<QString>();
}
QString OfonoNetworkRegistration::technology() const
{
- return properties()["Technology"].value<QString>();
+ return m_if->properties()["Technology"].value<QString>();
}
QString OfonoNetworkRegistration::name() const
{
- return properties()["Name"].value<QString>();
+ return m_if->properties()["Name"].value<QString>();
}
uint OfonoNetworkRegistration::strength() const
{
- return properties()["Strength"].value<uint>();
+ return m_if->properties()["Strength"].value<uint>();
}
QString OfonoNetworkRegistration::baseStation() const
{
- return properties()["BaseStation"].value<QString>();
+ return m_if->properties()["BaseStation"].value<QString>();
}
void OfonoNetworkRegistration::propertyChanged(const QString& property, const QVariant& value)
void OfonoNetworkRegistration::registerErr(QDBusError error)
{
qDebug() << "Register failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit registerComplete(FALSE);
}
void OfonoNetworkRegistration::deregisterErr(QDBusError error)
{
qDebug() << "Deregister failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit deregisterComplete(FALSE);
}
void OfonoNetworkRegistration::getOperatorsErr(QDBusError error)
{
qDebug() << "GetOperators failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit getOperatorsComplete(FALSE, QStringList());
}
void OfonoNetworkRegistration::scanErr(QDBusError error)
{
qDebug() << "Scan failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit scanComplete(FALSE, QStringList());
}
#include <QtCore/QObject>
#include <QStringList>
#include <QDBusError>
+#include <QDBusObjectPath>
#include "ofonomodeminterface.h"
#include "libofono-qt_global.h"
#include <QtCore/QObject>
#include "ofonophonebook.h"
+#include "ofonointerface.h"
#define IMPORT_TIMEOUT 300000
OfonoPhonebook::OfonoPhonebook(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.Phonebook", OfonoInterface::GetAllOnFirstRequest, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.Phonebook", OfonoGetAllOnFirstRequest, parent)
{
}
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"Import");
request.setArguments(QList<QVariant>());
void OfonoPhonebook::importErr(const QDBusError& error)
{
- m_errorName = error.name();
- m_errorMessage = error.message();
-
+ m_if->setError(error.name(), error.message());
emit importComplete(false, QString());
}
#define OFONOPHONEBOOK_H
#include <QtCore/QObject>
+#include <QDBusError>
#include "ofonomodeminterface.h"
#include "libofono-qt_global.h"
--- /dev/null
+/*
+ * This file is part of ofono-qt
+ *
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
+ *
+ * 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
+ *
+ */
+
+#ifndef OFONOPROPERTYSETTING_H
+#define OFONOPROPERTYSETTING_H
+
+//! How to handle getting the properties
+enum OfonoGetPropertySetting {
+ OfonoGetAllOnStartup, /*!< Get all properties synchronously on startup;
+ * they would be immediately available. */
+ OfonoGetAllOnFirstRequest /*!< Do not get properties on startup;
+ * get them in an asynhronous way when the first
+ * property is requested. */
+ };
+
+#endif
#include <QtCore/QObject>
#include "ofonoradiosettings.h"
+#include "ofonointerface.h"
OfonoRadioSettings::OfonoRadioSettings(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.RadioSettings", OfonoInterface::GetAllOnStartup, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.RadioSettings", OfonoGetAllOnStartup, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- connect(this, SIGNAL(setPropertyFailed(const QString&)),
+ connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
this, SLOT(setPropertyFailed(const QString&)));}
OfonoRadioSettings::~OfonoRadioSettings()
QString OfonoRadioSettings::technologyPreference() const
{
- return properties()["TechnologyPreference"].value<QString>();
+ return m_if->properties()["TechnologyPreference"].value<QString>();
}
void OfonoRadioSettings::setTechnologyPreference(QString preference)
{
- setProperty("TechnologyPreference", qVariantFromValue(preference));
+ m_if->setProperty("TechnologyPreference", qVariantFromValue(preference));
}
void OfonoRadioSettings::setPropertyFailed(const QString& property)
#include <QtCore/QObject>
#include "ofonosimmanager.h"
+#include "ofonointerface.h"
OfonoSimManager::OfonoSimManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SimManager", OfonoInterface::GetAllOnStartup, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SimManager", OfonoGetAllOnStartup, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- connect(this, SIGNAL(setPropertyFailed(const QString&)),
+ connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
this, SLOT(setPropertyFailed(const QString&)));
}
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"ChangePin");
request << pintype << oldpin << newpin;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"EnterPin");
request << pintype << pin;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"ResetPin");
request << pintype << puk << newpin;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"LockPin");
request << pintype << pin;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"UnlockPin");
request << pintype << pin;
void OfonoSimManager::setSubscriberNumbers(const QStringList &numbers)
{
- setProperty("SubscriberNumbers", qVariantFromValue(numbers));
+ m_if->setProperty("SubscriberNumbers", qVariantFromValue(numbers));
}
bool OfonoSimManager::present() const
{
- return properties()["Present"].value<bool>();
+ return m_if->properties()["Present"].value<bool>();
}
QString OfonoSimManager::subscriberIdentity() const
{
- return properties()["SubscriberIdentity"].value<QString>();
+ return m_if->properties()["SubscriberIdentity"].value<QString>();
}
QString OfonoSimManager::mobileCountryCode() const
{
- return properties()["MobileCountryCode"].value<QString>();
+ return m_if->properties()["MobileCountryCode"].value<QString>();
}
QString OfonoSimManager::mobileNetworkCode() const
{
- return properties()["MobileNetworkCode"].value<QString>();
+ return m_if->properties()["MobileNetworkCode"].value<QString>();
}
QStringList OfonoSimManager::subscriberNumbers() const
{
- return properties()["SubscriberNumbers"].value<QStringList>();
+ return m_if->properties()["SubscriberNumbers"].value<QStringList>();
}
QMap<QString, QString> OfonoSimManager::serviceNumbers() const
{
QMap<QString, QString> map;
- properties()["ServiceNumbers"].value<QDBusArgument>() >> map;
+ m_if->properties()["ServiceNumbers"].value<QDBusArgument>() >> map;
return map;
}
QString OfonoSimManager::pinRequired() const
{
- return properties()["PinRequired"].value<QString>();
+ return m_if->properties()["PinRequired"].value<QString>();
}
QStringList OfonoSimManager::lockedPins() const
{
- return properties()["LockedPins"].value<QStringList>();
+ return m_if->properties()["LockedPins"].value<QStringList>();
}
QString OfonoSimManager::cardIdentifier() const
{
- return properties()["CardIdentifier"].value<QString>();
+ return m_if->properties()["CardIdentifier"].value<QString>();
}
QStringList OfonoSimManager::preferredLanguages() const
{
- return properties()["PreferredLanguages"].value<QStringList>();
+ return m_if->properties()["PreferredLanguages"].value<QStringList>();
}
void OfonoSimManager::changePinErr(QDBusError error)
{
qDebug() << "ChangePin failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit changePinComplete(FALSE);
}
void OfonoSimManager::enterPinErr(QDBusError error)
{
qDebug() << "EnterPin failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit enterPinComplete(FALSE);
}
void OfonoSimManager::resetPinErr(QDBusError error)
{
qDebug() << "ResetPin failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit resetPinComplete(FALSE);
}
void OfonoSimManager::lockPinErr(QDBusError error)
{
qDebug() << "LockPin failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit lockPinComplete(FALSE);
}
void OfonoSimManager::unlockPinErr(QDBusError error)
{
qDebug() << "UnlockPin failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit unlockPinComplete(FALSE);
}
#include <QtCore/QObject>
#include "ofonosupplementaryservices.h"
+#include "ofonointerface.h"
#define REQUEST_TIMEOUT 60000
OfonoSupplementaryServices::OfonoSupplementaryServices(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SupplementaryServices", OfonoInterface::GetAllOnStartup, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.SupplementaryServices", OfonoGetAllOnStartup, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
- QDBusConnection::systemBus().connect("org.ofono", path(), ifname(),
+ QDBusConnection::systemBus().connect("org.ofono", path(), m_if->ifname(),
"NotificationReceived",
this,
SIGNAL(notificationReceived(QString)));
- QDBusConnection::systemBus().connect("org.ofono", path(), ifname(),
+ QDBusConnection::systemBus().connect("org.ofono", path(), m_if->ifname(),
"RequestReceived",
this,
SIGNAL(requestReceived(QString)));
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"Initiate");
request << command;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"Respond");
request << reply;
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"Cancel");
QDBusConnection::systemBus().callWithCallback(request, this,
QString OfonoSupplementaryServices::state() const
{
- return properties()["State"].value<QString>();
+ return m_if->properties()["State"].value<QString>();
}
void OfonoSupplementaryServices::propertyChanged(const QString& property, const QVariant& value)
void OfonoSupplementaryServices::initiateErr(QDBusError error)
{
qDebug() << "Initiate failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit initiateFailed();
}
void OfonoSupplementaryServices::respondErr(QDBusError error)
{
qDebug() << "Respond failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit respondComplete(FALSE, QString());
}
void OfonoSupplementaryServices::cancelErr(QDBusError error)
{
qDebug() << "Cancel failed" << error;
- m_errorName = error.name();
- m_errorMessage = error.message();
+ m_if->setError(error.name(), error.message());
emit cancelComplete(FALSE);
}
#include <QtCore/QObject>
#include <QStringList>
#include <QDBusError>
+#include <QDBusVariant>
#include "ofonomodeminterface.h"
#include "libofono-qt_global.h"
#include <QtCore/QObject>
#include "ofonovoicecallmanager.h"
+#include "ofonointerface.h"
OfonoVoiceCallManager::OfonoVoiceCallManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
- : OfonoModemInterface(modemSetting, modemPath, "org.ofono.VoiceCallManager", OfonoInterface::GetAllOnStartup, parent)
+ : OfonoModemInterface(modemSetting, modemPath, "org.ofono.VoiceCallManager", OfonoGetAllOnStartup, parent)
{
- connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
+ connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
this, SLOT(propertyChanged(const QString&, const QVariant&)));
}
QStringList OfonoVoiceCallManager::emergencyNumbers() const
{
- return properties()["EmergencyNumbers"].value<QStringList>();
+ return m_if->properties()["EmergencyNumbers"].value<QStringList>();
}
void OfonoVoiceCallManager::propertyChanged(const QString& property, const QVariant& value)
void initTestCase()
{
- oi = new OfonoInterface("/phonesim", "org.ofono.Modem", OfonoInterface::GetAllOnStartup, this);
+ oi = new OfonoInterface("/phonesim", "org.ofono.Modem", OfonoGetAllOnStartup, this);
if (oi->properties()["Powered"].toBool() == false) {
oi->setProperty("Powered", qVariantFromValue(true));
{
QCOMPARE(oi->properties()["Manufacturer"].toString(), QString("MeeGo"));
- oi_async = new OfonoInterface("/phonesim", "org.ofono.Modem", OfonoInterface::GetAllOnFirstRequest, this);
+ oi_async = new OfonoInterface("/phonesim", "org.ofono.Modem", OfonoGetAllOnFirstRequest, this);
QCOMPARE(oi_async->properties().count(), 0);
QSignalSpy spy_request(oi_async, SIGNAL(requestPropertyComplete(bool, const QString &, const QVariant &)));
void initTestCase()
{
- mi = new OfonoModemInterface(OfonoModem::ManualSelect, "/phonesim", "org.ofono.NetworkRegistration", OfonoInterface::GetAllOnStartup, this);
+ mi = new OfonoModemInterface(OfonoModem::ManualSelect, "/phonesim", "org.ofono.NetworkRegistration", OfonoGetAllOnStartup, this);
if (!mi->modem()->powered()) {
mi->modem()->setPowered(true);
QSignalSpy validity(mi, SIGNAL(validityChanged(bool)));
QSignalSpy property(mi, SIGNAL(propertyChanged(QString, QVariant)));
QCOMPARE(mi->isValid(), true);
- QVERIFY(mi->properties()["Name"].toString().length() > 0);
mi->modem()->setOnline(false);
QTest::qWait(5000);
QCOMPARE(property.count(), 0);
delete mi;
- mi = new OfonoModemInterface(OfonoModem::ManualSelect, "/phonesim", "org.ofono.NetworkRegistration", OfonoInterface::GetAllOnStartup, this);
+ mi = new OfonoModemInterface(OfonoModem::ManualSelect, "/phonesim", "org.ofono.NetworkRegistration", OfonoGetAllOnStartup, this);
if (!mi->modem()->powered()) {
mi->modem()->setPowered(true);
QTest::qWait(5000);