*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
- * Contact: Alexander Kanavin <alexander.kanavin@nokia.com>
+ * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
#include <QtCore/QObject>
#include <QtDBus/QtDBus>
#include "ofonocallbarring.h"
+#include "ofonointerface.h"
#define SET_PROPERTY_TIMEOUT 300000
-OfonoCallBarring::OfonoCallBarring(QString modemId, QObject *parent)
- : OfonoModemInterface(modemId, "org.ofono.CallBarring", OfonoInterface::GetAllOnFirstRequest, parent)
+OfonoCallBarring::OfonoCallBarring(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *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()));
- m_pendingProperty = QString();
}
OfonoCallBarring::~OfonoCallBarring()
{
}
-void OfonoCallBarring::setProperty(const QString& name,
- const QVariant& property,
- const QString& password)
-{
- 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");
- emit setPropertyFailed(name);
- return;
- }
-
-
- QDBusMessage request;
-
- request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
- "SetProperty");
- request.setArguments(QList<QVariant>()
- << QVariant(name)
- << QVariant::fromValue(QDBusVariant(property))
- << QVariant(password));
-
- bool result = QDBusConnection::systemBus().callWithCallback(request, this,
- SLOT(setPropertyResp()),
- SLOT(setPropertyErr(const QDBusError&)),
- SET_PROPERTY_TIMEOUT);
- if (!result) {
- // FIXME: should indicate that sending a message failed
- m_errorName = QString();
- m_errorMessage = QString("DBUS sending failed");
- emit setPropertyFailed(name);
- return;
- }
- m_pendingProperty = name;
-
-
-}
-
-void OfonoCallBarring::setPropertyResp()
-{
- m_pendingProperty = QString();
- // emit nothing; we will get a PropertyChanged signal
-}
-
-void OfonoCallBarring::setPropertyErr(const QDBusError& error)
-{
- QString prop = m_pendingProperty;
- m_errorName = error.name();
- m_errorMessage = error.message();
- m_pendingProperty = QString();
- emit setPropertyFailed(prop);
-}
-
-
-void OfonoCallBarring::requestChangePassword(QString old_password,
- QString new_password)
+void OfonoCallBarring::changePassword(const QString &old_password,
+ const QString &new_password)
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"ChangePassword");
request << old_password << new_password;
SLOT(changePasswordErr(const QDBusError&)));
}
-void OfonoCallBarring::requestDisableAll(QString password)
+void OfonoCallBarring::disableAll(const QString &password)
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"DisableAll");
request << password;
SLOT(disableAllErr(const QDBusError&)));
}
-void OfonoCallBarring::requestDisableAllIncoming(QString password)
+void OfonoCallBarring::disableAllIncoming(const QString &password)
{
QDBusMessage request;
request = QDBusMessage::createMethodCall("org.ofono",
- path(), ifname(),
+ path(), m_if->ifname(),
"DisableAllIncoming");
request << password;
SLOT(disableAllIncomingErr(const QDBusError&)));
}
-void OfonoCallBarring::requestDisableAllOutgoing(QString password)
+void OfonoCallBarring::disableAllOutgoing(const QString &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(QString barrings, QString password)
+void OfonoCallBarring::setVoiceIncoming(const QString &barrings, const QString &password)
{
- setProperty("VoiceIncoming", qVariantFromValue(barrings), password);
+ m_if->setProperty("VoiceIncoming", qVariantFromValue(barrings), password);
}
void OfonoCallBarring::requestVoiceOutgoing()
{
- requestProperty("VoiceOutgoing");
+ m_if->requestProperty("VoiceOutgoing");
}
-void OfonoCallBarring::setVoiceOutgoing(QString barrings, QString password)
+void OfonoCallBarring::setVoiceOutgoing(const QString &barrings, const QString &password)
{
- setProperty("VoiceOutgoing", qVariantFromValue(barrings), password);
+ m_if->setProperty("VoiceOutgoing", qVariantFromValue(barrings), password);
}
void OfonoCallBarring::propertyChanged(const QString& property, const QVariant& value)
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);
}