Do not subclass OfonoModemInterface from OfonoInterface
authorAlexander Kanavin <alexander.kanavin@nokia.com>
Thu, 2 Dec 2010 20:14:26 +0000 (22:14 +0200)
committerAlexander Kanavin <alexander.kanavin@nokia.com>
Thu, 2 Dec 2010 20:14:26 +0000 (22:14 +0200)
This took more effort than anticipated

27 files changed:
lib/lib.pro
lib/ofonocallbarring.cpp
lib/ofonocallbarring.h
lib/ofonocallforwarding.cpp
lib/ofonocallforwarding.h
lib/ofonocallmeter.cpp
lib/ofonocallsettings.cpp
lib/ofonointerface.cpp
lib/ofonointerface.h
lib/ofonomessagemanager.cpp
lib/ofonomessagewaiting.cpp
lib/ofonomodem.cpp
lib/ofonomodeminterface.cpp
lib/ofonomodeminterface.h
lib/ofononetworkoperator.cpp
lib/ofononetworkregistration.cpp
lib/ofononetworkregistration.h
lib/ofonophonebook.cpp
lib/ofonophonebook.h
lib/ofonopropertysetting.h [new file with mode: 0644]
lib/ofonoradiosettings.cpp
lib/ofonosimmanager.cpp
lib/ofonosupplementaryservices.cpp
lib/ofonosupplementaryservices.h
lib/ofonovoicecallmanager.cpp
tests/test_ofonointerface.cpp
tests/test_ofonomodeminterface.cpp

index 1d27b63..4ef2287 100644 (file)
@@ -11,6 +11,7 @@ QT -= gui
 INCLUDEPATH += ../
 
 PUBLIC_HEADERS += libofono-qt_global.h
+PUBLIC_HEADERS += ofonopropertysetting.h 
 PUBLIC_HEADERS += ofonointerface.h 
 PUBLIC_HEADERS += ofonomodeminterface.h 
 PUBLIC_HEADERS += ofonomodemmanager.h
index f205111..02333d8 100644 (file)
 #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()));
@@ -57,8 +58,7 @@ void OfonoCallBarring::setProperty(const QString& name,
 {
     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;
     }
@@ -67,7 +67,7 @@ void OfonoCallBarring::setProperty(const QString& name,
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "SetProperty");
     request.setArguments(QList<QVariant>() 
                         << QVariant(name) 
@@ -80,8 +80,7 @@ void OfonoCallBarring::setProperty(const QString& 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;
     }
@@ -99,8 +98,7 @@ void OfonoCallBarring::setPropertyResp()
 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);
 }
@@ -112,7 +110,7 @@ void OfonoCallBarring::requestChangePassword(const QString &old_password,
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "ChangePassword");
     request << old_password << new_password;
 
@@ -126,7 +124,7 @@ void OfonoCallBarring::requestDisableAll(const QString &password)
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "DisableAll");
     request << password;
 
@@ -140,7 +138,7 @@ void OfonoCallBarring::requestDisableAllIncoming(const QString &password)
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "DisableAllIncoming");
     request << password;
 
@@ -154,7 +152,7 @@ void OfonoCallBarring::requestDisableAllOutgoing(const QString &password)
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "DisableAllOutgoing");
     request << password;
 
@@ -166,7 +164,7 @@ void OfonoCallBarring::requestDisableAllOutgoing(const QString &password)
 
 void OfonoCallBarring::requestVoiceIncoming()
 {
-    requestProperty("VoiceIncoming");
+    m_if->requestProperty("VoiceIncoming");
 }
 
 void OfonoCallBarring::setVoiceIncoming(const QString &barrings, const QString &password)
@@ -176,7 +174,7 @@ void OfonoCallBarring::setVoiceIncoming(const QString &barrings, const QString &
 
 void OfonoCallBarring::requestVoiceOutgoing()
 {
-    requestProperty("VoiceOutgoing");
+    m_if->requestProperty("VoiceOutgoing");
 }
 
 void OfonoCallBarring::setVoiceOutgoing(const QString &barrings, const QString &password)
@@ -219,8 +217,7 @@ void OfonoCallBarring::changePasswordResp()
 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);
 }
 
@@ -232,8 +229,7 @@ void OfonoCallBarring::disableAllResp()
 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);
 }
 
@@ -245,8 +241,7 @@ void OfonoCallBarring::disableAllIncomingResp()
 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);
 }
 
@@ -258,7 +253,6 @@ void OfonoCallBarring::disableAllOutgoingResp()
 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);
 }
index a620821..6c0d3b6 100644 (file)
@@ -25,6 +25,7 @@
 #define OFONOCALLBARRING_H
 
 #include <QtCore/QObject>
+#include <QDBusError>
 #include "ofonomodeminterface.h"
 #include "libofono-qt_global.h"
 
index 0d2e85c..2e15799 100644 (file)
 #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&)));
 }
 
@@ -47,7 +48,7 @@ void OfonoCallForwarding::requestDisableAll(const QString &type)
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "DisableAll");
     request << type;
 
@@ -59,52 +60,52 @@ void OfonoCallForwarding::requestDisableAll(const QString &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));
 }
 
 
@@ -161,8 +162,7 @@ void OfonoCallForwarding::disableAllResp()
 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);
 }
 
index 1e94e71..ae1770b 100644 (file)
@@ -25,6 +25,7 @@
 #define OFONOCALLFORWARDING_H
  
 #include <QtCore/QObject>
+#include <QDBusError>
 #include "ofonomodeminterface.h"
 #include "libofono-qt_global.h"
 
index 8b49307..a8b05d6 100644 (file)
 #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&)));
 }
 
@@ -41,7 +42,7 @@ OfonoCallMeter::~OfonoCallMeter()
 
 void OfonoCallMeter::requestCallMeter()
 {
-    requestProperty("CallMeter");
+    m_if->requestProperty("CallMeter");
 }
 
 void OfonoCallMeter::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
index ee09f3f..fed9f62 100644 (file)
 #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&)));
 }
 
@@ -43,42 +44,42 @@ OfonoCallSettings::~OfonoCallSettings()
 
 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)
index fecbd4f..684d201 100644 (file)
 #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();
 }
 
@@ -57,7 +57,7 @@ void OfonoInterface::setPath(const QString& path)
                                             this,
                                             SLOT(onPropertyChanged(QString, QDBusVariant)));
 
-    if (m_getpropsetting == GetAllOnStartup)
+    if (m_getpropsetting == OfonoGetAllOnStartup)
         m_properties = getAllPropertiesSync();
     else
        resetProperties();
@@ -94,8 +94,7 @@ void OfonoInterface::requestProperty(const QString& name)
 {
     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;
     }
@@ -117,8 +116,7 @@ void OfonoInterface::requestProperty(const QString& name)
                                        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;
     }
@@ -134,8 +132,7 @@ void OfonoInterface::getPropertiesAsyncResp(QVariantMap properties)
         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()) {
@@ -146,8 +143,7 @@ void OfonoInterface::getPropertiesAsyncResp(QVariantMap properties)
 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());
 }
@@ -162,8 +158,7 @@ void OfonoInterface::setProperty(const QString& name, const QVariant& property)
 {
     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;
     }
@@ -182,8 +177,7 @@ void OfonoInterface::setProperty(const QString& name, const QVariant& property)
                                        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;
     }
@@ -199,9 +193,13 @@ void OfonoInterface::setPropertyResp()
 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;
+}
index effee0b..2de0956 100644 (file)
@@ -28,6 +28,7 @@
 #include <QVariant>
 #include <QDBusVariant>
 #include <QDBusError>
+#include "ofonopropertysetting.h"
 #include "libofono-qt_global.h"
 
 //! Basic oFono interface class
@@ -41,21 +42,12 @@ class OFONO_QT_EXPORT OfonoInterface : public QObject
     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
@@ -109,6 +101,9 @@ public:
      * 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
@@ -151,7 +146,7 @@ private:
    QString m_ifname;
    QVariantMap m_properties;
    QString m_pendingProperty;
-   GetPropertySetting m_getpropsetting;
+   OfonoGetPropertySetting m_getpropsetting;
 };
 
 #endif
index 765b1a5..322960c 100644 (file)
 #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&)));
 }
 
@@ -43,7 +44,7 @@ OfonoMessageManager::~OfonoMessageManager()
 
 void OfonoMessageManager::requestServiceCenterAddress()
 {
-    requestProperty("ServiceCenterAddress");
+    m_if->requestProperty("ServiceCenterAddress");
 }
 
 void OfonoMessageManager::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
index d6ba1c7..25ebaf6 100644 (file)
 #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&)));
 
 }
@@ -43,22 +44,22 @@ OfonoMessageWaiting::~OfonoMessageWaiting()
 
 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)
index 2e1b823..dfe7e67 100644 (file)
@@ -47,7 +47,7 @@ OfonoModem::OfonoModem(SelectionSetting setting, const QString &modemPath, QObje
     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&)), 
index c875398..305ca00 100644 (file)
 
 #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);
@@ -37,7 +38,7 @@ OfonoModemInterface::OfonoModemInterface(OfonoModem::SelectionSetting modemSetti
     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();
 }
 
@@ -57,7 +58,7 @@ OfonoModem* OfonoModemInterface::modem() const
 
 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()
@@ -78,3 +79,18 @@ void OfonoModemInterface::interfacesChanged(const QStringList& /*interfaces*/)
     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();
+}
+
index e135eb7..a3324bd 100644 (file)
 
 #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:
@@ -48,7 +50,7 @@ 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
@@ -60,6 +62,23 @@ public:
     
     //! 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
@@ -78,6 +97,9 @@ private slots:
     void modemValidityChanged(bool validity);
     void interfacesChanged(const QStringList &interfaces);
 
+protected:
+    OfonoInterface *m_if;
+
 private:
     OfonoModem *m_m;
     bool m_isValid;
index 5c7fa81..1f81dd6 100644 (file)
@@ -30,7 +30,7 @@
 #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&)));
index f2228f6..f3a1a7d 100644 (file)
@@ -25,6 +25,7 @@
 #include <QtCore/QObject>
 
 #include "ofononetworkregistration.h"
+#include "ofonointerface.h"
 
 #define REGISTER_TIMEOUT 300000
 #define SCAN_TIMEOUT 300000
@@ -47,12 +48,12 @@ const QDBusArgument &operator>>(const QDBusArgument &argument, OfonoOperatorStru
 
 
 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&)));
 }
 
@@ -65,7 +66,7 @@ void OfonoNetworkRegistration::requestRegister()
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "Register");
 
     QDBusConnection::systemBus().callWithCallback(request, this,
@@ -79,7 +80,7 @@ void OfonoNetworkRegistration::requestDeregister()
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "Deregister");
 
     QDBusConnection::systemBus().callWithCallback(request, this,
@@ -93,7 +94,7 @@ void OfonoNetworkRegistration::requestScan()
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "Scan");
 
     QDBusConnection::systemBus().callWithCallback(request, this,
@@ -107,7 +108,7 @@ void OfonoNetworkRegistration::requestGetOperators()
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "GetOperators");
 
     QDBusConnection::systemBus().callWithCallback(request, this,
@@ -118,52 +119,52 @@ void OfonoNetworkRegistration::requestGetOperators()
 
 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)
@@ -199,8 +200,7 @@ void OfonoNetworkRegistration::registerResp()
 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);
 }
 
@@ -212,8 +212,7 @@ void OfonoNetworkRegistration::deregisterResp()
 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);
 }
 
@@ -229,8 +228,7 @@ void OfonoNetworkRegistration::getOperatorsResp(OfonoOperatorList list)
 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());
 }
 
@@ -246,8 +244,7 @@ void OfonoNetworkRegistration::scanResp(OfonoOperatorList list)
 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());
 }
 
index 93c5257..9e9b525 100644 (file)
@@ -27,6 +27,7 @@
 #include <QtCore/QObject>
 #include <QStringList>
 #include <QDBusError>
+#include <QDBusObjectPath>
 #include "ofonomodeminterface.h"
 #include "libofono-qt_global.h"
 
index 95c1da3..24dafac 100644 (file)
 #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)
 {
 
 }
@@ -43,7 +44,7 @@ void OfonoPhonebook::requestImport()
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "Import");
     request.setArguments(QList<QVariant>());
 
@@ -60,9 +61,7 @@ void OfonoPhonebook::importResp(const QString &entries)
 
 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());
 }
 
index 34eb359..3d549b2 100644 (file)
@@ -25,6 +25,7 @@
 #define OFONOPHONEBOOK_H
 
 #include <QtCore/QObject>
+#include <QDBusError>
 #include "ofonomodeminterface.h"
 #include "libofono-qt_global.h"
 
diff --git a/lib/ofonopropertysetting.h b/lib/ofonopropertysetting.h
new file mode 100644 (file)
index 0000000..4f4d4af
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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
index c7d47f7..924ac1d 100644 (file)
 #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()
@@ -40,12 +41,12 @@ 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)
index 654637c..326e250 100644 (file)
 #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&)));
 
 }
@@ -46,7 +47,7 @@ void OfonoSimManager::requestChangePin(const QString &pintype, const QString &ol
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "ChangePin");
     request << pintype << oldpin << newpin;
 
@@ -60,7 +61,7 @@ void OfonoSimManager::requestEnterPin(const QString &pintype, const QString &pin
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "EnterPin");
     request << pintype << pin;
 
@@ -74,7 +75,7 @@ void OfonoSimManager::requestResetPin(const QString &pintype, const QString &puk
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "ResetPin");
     request << pintype << puk << newpin;
 
@@ -88,7 +89,7 @@ void OfonoSimManager::requestLockPin(const QString &pintype, const QString &pin)
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "LockPin");
     request << pintype << pin;
 
@@ -102,7 +103,7 @@ void OfonoSimManager::requestUnlockPin(const QString &pintype, const QString &pi
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "UnlockPin");
     request << pintype << pin;
 
@@ -113,59 +114,59 @@ void OfonoSimManager::requestUnlockPin(const QString &pintype, const QString &pi
 
 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>();
 }
 
 
@@ -210,8 +211,7 @@ void OfonoSimManager::changePinResp()
 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);
 }
 
@@ -223,8 +223,7 @@ void OfonoSimManager::enterPinResp()
 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);
 }
 
@@ -236,8 +235,7 @@ void OfonoSimManager::resetPinResp()
 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);
 }
 
@@ -248,8 +246,7 @@ void OfonoSimManager::lockPinResp()
 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);
 }
 
@@ -260,7 +257,6 @@ void OfonoSimManager::unlockPinResp()
 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);
 }
index 9702ac4..92a50c5 100644 (file)
 #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)));
@@ -53,7 +54,7 @@ void OfonoSupplementaryServices::requestInitiate(const QString &command)
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "Initiate");
     request << command;
 
@@ -68,7 +69,7 @@ void OfonoSupplementaryServices::requestRespond(const QString &reply)
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "Respond");
     request << reply;
 
@@ -83,7 +84,7 @@ void OfonoSupplementaryServices::requestCancel()
     QDBusMessage request;
 
     request = QDBusMessage::createMethodCall("org.ofono",
-                                            path(), ifname(),
+                                            path(), m_if->ifname(),
                                             "Cancel");
 
     QDBusConnection::systemBus().callWithCallback(request, this,
@@ -94,7 +95,7 @@ void OfonoSupplementaryServices::requestCancel()
 
 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)
@@ -162,8 +163,7 @@ void OfonoSupplementaryServices::initiateResp(QString message, QDBusVariant deta
 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();
 }
 
@@ -176,8 +176,7 @@ void OfonoSupplementaryServices::respondResp(QString message)
 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());
 }
 
@@ -189,8 +188,7 @@ void OfonoSupplementaryServices::cancelResp()
 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);
 }
 
index 2ffd860..5fd5126 100644 (file)
@@ -27,6 +27,7 @@
 #include <QtCore/QObject>
 #include <QStringList>
 #include <QDBusError>
+#include <QDBusVariant>
 #include "ofonomodeminterface.h"
 #include "libofono-qt_global.h"
 
index 2d3209b..0bf209d 100644 (file)
 #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&)));
 }
 
@@ -39,7 +40,7 @@ OfonoVoiceCallManager::~OfonoVoiceCallManager()
 
 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)
index 63749fe..42acd2c 100644 (file)
@@ -36,7 +36,7 @@ private slots:
 
     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));
@@ -52,7 +52,7 @@ private slots:
     {
         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 &)));
index 4a0fba3..e851d44 100644 (file)
@@ -36,7 +36,7 @@ private slots:
 
     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);
@@ -54,7 +54,6 @@ private slots:
         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);
@@ -83,7 +82,7 @@ private slots:
         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);