2 * This file is part of ofono-qt
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include <QtCore/QObject>
25 #include <QtDBus/QtDBus>
26 #include "ofonocallbarring.h"
27 #include "ofonointerface.h"
29 #define SET_PROPERTY_TIMEOUT 300000
31 OfonoCallBarring::OfonoCallBarring(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
32 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallBarring", OfonoGetAllOnFirstRequest, parent)
34 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
35 this, SLOT(propertyChanged(const QString&, const QVariant&)));
36 connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
37 this, SLOT(setPropertyFailed(const QString&)));
38 connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
39 this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
41 connect(modem(), SIGNAL(pathChanged(QString)), this, SLOT(pathChanged(const QString&)));
43 connectDbusSignals(path());
46 OfonoCallBarring::~OfonoCallBarring()
50 void OfonoCallBarring::pathChanged(const QString& path)
52 connectDbusSignals(path);
55 void OfonoCallBarring::connectDbusSignals(const QString& /*path*/)
59 void OfonoCallBarring::changePassword(const QString &old_password,
60 const QString &new_password)
64 request = QDBusMessage::createMethodCall("org.ofono",
65 path(), m_if->ifname(),
67 request << old_password << new_password;
69 QDBusConnection::systemBus().callWithCallback(request, this,
70 SLOT(changePasswordResp()),
71 SLOT(changePasswordErr(const QDBusError&)));
74 void OfonoCallBarring::disableAll(const QString &password)
78 request = QDBusMessage::createMethodCall("org.ofono",
79 path(), m_if->ifname(),
83 QDBusConnection::systemBus().callWithCallback(request, this,
84 SLOT(disableAllResp()),
85 SLOT(disableAllErr(const QDBusError&)));
88 void OfonoCallBarring::disableAllIncoming(const QString &password)
92 request = QDBusMessage::createMethodCall("org.ofono",
93 path(), m_if->ifname(),
94 "DisableAllIncoming");
97 QDBusConnection::systemBus().callWithCallback(request, this,
98 SLOT(disableAllIncomingResp()),
99 SLOT(disableAllIncomingErr(const QDBusError&)));
102 void OfonoCallBarring::disableAllOutgoing(const QString &password)
104 QDBusMessage request;
106 request = QDBusMessage::createMethodCall("org.ofono",
107 path(), m_if->ifname(),
108 "DisableAllOutgoing");
111 QDBusConnection::systemBus().callWithCallback(request, this,
112 SLOT(disableAllOutgoingResp()),
113 SLOT(disableAllOutgoingErr(const QDBusError&)));
117 void OfonoCallBarring::requestVoiceIncoming()
119 m_if->requestProperty("VoiceIncoming");
122 void OfonoCallBarring::setVoiceIncoming(const QString &barrings, const QString &password)
124 m_if->setProperty("VoiceIncoming", qVariantFromValue(barrings), password);
127 void OfonoCallBarring::requestVoiceOutgoing()
129 m_if->requestProperty("VoiceOutgoing");
132 void OfonoCallBarring::setVoiceOutgoing(const QString &barrings, const QString &password)
134 m_if->setProperty("VoiceOutgoing", qVariantFromValue(barrings), password);
137 void OfonoCallBarring::propertyChanged(const QString& property, const QVariant& value)
139 if (property == "VoiceIncoming") {
140 emit voiceIncomingChanged(value.value<QString>());
141 } else if (property == "VoiceOutgoing") {
142 emit voiceOutgoingChanged(value.value<QString>());
146 void OfonoCallBarring::setPropertyFailed(const QString& property)
148 if (property == "VoiceIncoming") {
149 emit setVoiceIncomingFailed();
150 } else if (property == "VoiceOutgoing") {
151 emit setVoiceOutgoingFailed();
155 void OfonoCallBarring::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
157 if (property == "VoiceIncoming") {
158 emit voiceIncomingComplete(success, value.value<QString>());
159 } else if (property == "VoiceOutgoing") {
160 emit voiceOutgoingComplete(success, value.value<QString>());
164 void OfonoCallBarring::changePasswordResp()
166 emit changePasswordComplete(TRUE);
169 void OfonoCallBarring::changePasswordErr(QDBusError error)
171 m_if->setError(error.name(), error.message());
172 emit changePasswordComplete(FALSE);
175 void OfonoCallBarring::disableAllResp()
177 emit disableAllComplete(TRUE);
180 void OfonoCallBarring::disableAllErr(QDBusError error)
182 m_if->setError(error.name(), error.message());
183 emit disableAllComplete(FALSE);
186 void OfonoCallBarring::disableAllIncomingResp()
188 emit disableAllIncomingComplete(TRUE);
191 void OfonoCallBarring::disableAllIncomingErr(QDBusError error)
193 m_if->setError(error.name(), error.message());
194 emit disableAllIncomingComplete(FALSE);
197 void OfonoCallBarring::disableAllOutgoingResp()
199 emit disableAllOutgoingComplete(TRUE);
202 void OfonoCallBarring::disableAllOutgoingErr(QDBusError error)
204 m_if->setError(error.name(), error.message());
205 emit disableAllOutgoingComplete(FALSE);