2 * This file is part of ofono-qt
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Kanavin <alexander.kanavin@nokia.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));
112 void OfonoCallForwarding::propertyChanged(const QString& property, const QVariant& value)
114 if (property == "VoiceUnconditional") {
115 emit voiceUnconditionalChanged(value.value<QString>());
116 } else if (property == "VoiceBusy") {
117 emit voiceBusyChanged(value.value<QString>());
118 } else if (property == "VoiceNoReply") {
119 emit voiceNoReplyChanged(value.value<QString>());
120 } else if (property == "VoiceNoReplyTimeout") {
121 emit voiceNoReplyTimeoutChanged(value.value<ushort>());
122 } else if (property == "VoiceNotReachable") {
123 emit voiceNotReachableChanged(value.value<QString>());
127 void OfonoCallForwarding::setPropertyFailed(const QString& property)
129 if (property == "VoiceUnconditional") {
130 emit setVoiceUnconditionalFailed();
131 } else if (property == "VoiceBusy") {
132 emit setVoiceBusyFailed();
133 } else if (property == "VoiceNoReply") {
134 emit setVoiceNoReplyFailed();
135 } else if (property == "VoiceNoReplyTimeout") {
136 emit setVoiceNoReplyTimeoutFailed();
137 } else if (property == "VoiceNotReachable") {
138 emit setVoiceNotReachableFailed();
142 void OfonoCallForwarding::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
144 if (property == "VoiceUnconditional") {
145 success ? emit voiceUnconditionalComplete(true, value.value<QString>()) : emit voiceUnconditionalComplete(false, QString());
146 } else if (property == "VoiceBusy") {
147 success ? emit voiceBusyComplete(true, value.value<QString>()) : emit voiceBusyComplete(false, QString());
148 } else if (property == "VoiceNoReply") {
149 success ? emit voiceNoReplyComplete(true, value.value<QString>()) : emit voiceNoReplyComplete(false, QString());
150 } else if (property == "VoiceNoReplyTimeout") {
151 success ? emit voiceNoReplyTimeoutComplete(true, value.value<ushort>()) : emit voiceNoReplyTimeoutComplete(false, 0);
152 } else if (property == "VoiceNotReachable") {
153 success ? emit voiceNotReachableComplete(true, value.value<QString>()) : emit voiceNotReachableComplete(false, QString());
157 void OfonoCallForwarding::disableAllResp()
159 emit disableAllComplete(TRUE);
162 void OfonoCallForwarding::disableAllErr(QDBusError error)
164 m_if->setError(error.name(), error.message());
165 emit disableAllComplete(FALSE);