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 "ofonocallforwarding.h"
27 #include "ofonointerface.h"
30 OfonoCallForwarding::OfonoCallForwarding(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
31 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallForwarding", OfonoGetAllOnFirstRequest, parent)
33 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
34 this, SLOT(propertyChanged(const QString&, const QVariant&)));
35 connect(m_if, SIGNAL(setPropertyFailed(const QString&)),
36 this, SLOT(setPropertyFailed(const QString&)));
37 connect(m_if, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
38 this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
41 OfonoCallForwarding::~OfonoCallForwarding()
46 void OfonoCallForwarding::disableAll(const QString &type)
50 request = QDBusMessage::createMethodCall("org.ofono",
51 path(), m_if->ifname(),
55 QDBusConnection::systemBus().callWithCallback(request, this,
56 SLOT(disableAllResp()),
57 SLOT(disableAllErr(const QDBusError&)));
61 void OfonoCallForwarding::requestVoiceUnconditional()
63 m_if->requestProperty("VoiceUnconditional");
66 void OfonoCallForwarding::setVoiceUnconditional(const QString &property)
68 m_if->setProperty("VoiceUnconditional", qVariantFromValue(property));
71 void OfonoCallForwarding::requestVoiceBusy()
73 m_if->requestProperty("VoiceBusy");
76 void OfonoCallForwarding::setVoiceBusy(const QString &property)
78 return m_if->setProperty("VoiceBusy", qVariantFromValue(property));
81 void OfonoCallForwarding::requestVoiceNoReply()
83 m_if->requestProperty("VoiceNoReply");
86 void OfonoCallForwarding::setVoiceNoReply(const QString &property)
88 return m_if->setProperty("VoiceNoReply", qVariantFromValue(property));
91 void OfonoCallForwarding::requestVoiceNoReplyTimeout()
93 m_if->requestProperty("VoiceNoReplyTimeout");
96 void OfonoCallForwarding::setVoiceNoReplyTimeout(ushort timeout)
98 return m_if->setProperty("VoiceNoReplyTimeout", qVariantFromValue(timeout));
101 void OfonoCallForwarding::requestVoiceNotReachable()
103 m_if->requestProperty("VoiceNotReachable");
106 void OfonoCallForwarding::setVoiceNotReachable(const QString &property)
108 return m_if->setProperty("VoiceNotReachable", qVariantFromValue(property));
111 void OfonoCallForwarding::requestForwardingFlagOnSim()
113 m_if->requestProperty("ForwardingFlagOnSim");
116 void OfonoCallForwarding::propertyChanged(const QString& property, const QVariant& value)
118 if (property == "VoiceUnconditional") {
119 emit voiceUnconditionalChanged(value.value<QString>());
120 } else if (property == "VoiceBusy") {
121 emit voiceBusyChanged(value.value<QString>());
122 } else if (property == "VoiceNoReply") {
123 emit voiceNoReplyChanged(value.value<QString>());
124 } else if (property == "VoiceNoReplyTimeout") {
125 emit voiceNoReplyTimeoutChanged(value.value<ushort>());
126 } else if (property == "VoiceNotReachable") {
127 emit voiceNotReachableChanged(value.value<QString>());
128 } else if (property == "ForwardingFlagOnSim") {
129 emit forwardingFlagOnSimChanged(value.value<bool>());
133 void OfonoCallForwarding::setPropertyFailed(const QString& property)
135 if (property == "VoiceUnconditional") {
136 emit setVoiceUnconditionalFailed();
137 } else if (property == "VoiceBusy") {
138 emit setVoiceBusyFailed();
139 } else if (property == "VoiceNoReply") {
140 emit setVoiceNoReplyFailed();
141 } else if (property == "VoiceNoReplyTimeout") {
142 emit setVoiceNoReplyTimeoutFailed();
143 } else if (property == "VoiceNotReachable") {
144 emit setVoiceNotReachableFailed();
148 void OfonoCallForwarding::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
150 if (property == "VoiceUnconditional") {
151 emit voiceUnconditionalComplete(success, value.value<QString>());
152 } else if (property == "VoiceBusy") {
153 emit voiceBusyComplete(success, value.value<QString>());
154 } else if (property == "VoiceNoReply") {
155 emit voiceNoReplyComplete(success, value.value<QString>());
156 } else if (property == "VoiceNoReplyTimeout") {
157 emit voiceNoReplyTimeoutComplete(success, value.value<ushort>());
158 } else if (property == "VoiceNotReachable") {
159 emit voiceNotReachableComplete(success, value.value<QString>());
160 } else if (property == "ForwardingFlagOnSim") {
161 emit forwardingFlagOnSimComplete(success, value.value<bool>());
165 void OfonoCallForwarding::disableAllResp()
167 emit disableAllComplete(TRUE);
170 void OfonoCallForwarding::disableAllErr(QDBusError error)
172 m_if->setError(error.name(), error.message());
173 emit disableAllComplete(FALSE);