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"
29 OfonoCallForwarding::OfonoCallForwarding(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
30 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.CallForwarding", OfonoInterface::GetAllOnFirstRequest, parent)
32 connect(this, SIGNAL(propertyChanged(const QString&, const QVariant&)),
33 this, SLOT(propertyChanged(const QString&, const QVariant&)));
34 connect(this, SIGNAL(setPropertyFailed(const QString&)),
35 this, SLOT(setPropertyFailed(const QString&)));
36 connect(this, SIGNAL(requestPropertyComplete(bool, const QString&, const QVariant&)),
37 this, SLOT(requestPropertyComplete(bool, const QString&, const QVariant&)));
40 OfonoCallForwarding::~OfonoCallForwarding()
45 void OfonoCallForwarding::requestDisableAll(const QString &type)
49 request = QDBusMessage::createMethodCall("org.ofono",
54 QDBusConnection::systemBus().callWithCallback(request, this,
55 SLOT(disableAllResp()),
56 SLOT(disableAllErr(const QDBusError&)));
60 void OfonoCallForwarding::requestVoiceUnconditional()
62 requestProperty("VoiceUnconditional");
65 void OfonoCallForwarding::setVoiceUnconditional(const QString &property)
67 setProperty("VoiceUnconditional", qVariantFromValue(property));
70 void OfonoCallForwarding::requestVoiceBusy()
72 requestProperty("VoiceBusy");
75 void OfonoCallForwarding::setVoiceBusy(const QString &property)
77 return setProperty("VoiceBusy", qVariantFromValue(property));
80 void OfonoCallForwarding::requestVoiceNoReply()
82 requestProperty("VoiceNoReply");
85 void OfonoCallForwarding::setVoiceNoReply(const QString &property)
87 return setProperty("VoiceNoReply", qVariantFromValue(property));
90 void OfonoCallForwarding::requestVoiceNoReplyTimeout()
92 requestProperty("VoiceNoReplyTimeout");
95 void OfonoCallForwarding::setVoiceNoReplyTimeout(ushort timeout)
97 return setProperty("VoiceNoReplyTimeout", qVariantFromValue(timeout));
100 void OfonoCallForwarding::requestVoiceNotReachable()
102 requestProperty("VoiceNotReachable");
105 void OfonoCallForwarding::setVoiceNotReachable(const QString &property)
107 return setProperty("VoiceNotReachable", qVariantFromValue(property));
111 void OfonoCallForwarding::propertyChanged(const QString& property, const QVariant& value)
113 if (property == "VoiceUnconditional") {
114 emit voiceUnconditionalChanged(value.value<QString>());
115 } else if (property == "VoiceBusy") {
116 emit voiceBusyChanged(value.value<QString>());
117 } else if (property == "VoiceNoReply") {
118 emit voiceNoReplyChanged(value.value<QString>());
119 } else if (property == "VoiceNoReplyTimeout") {
120 emit voiceNoReplyTimeoutChanged(value.value<ushort>());
121 } else if (property == "VoiceNotReachable") {
122 emit voiceNotReachableChanged(value.value<QString>());
126 void OfonoCallForwarding::setPropertyFailed(const QString& property)
128 if (property == "VoiceUnconditional") {
129 emit setVoiceUnconditionalFailed();
130 } else if (property == "VoiceBusy") {
131 emit setVoiceBusyFailed();
132 } else if (property == "VoiceNoReply") {
133 emit setVoiceNoReplyFailed();
134 } else if (property == "VoiceNoReplyTimeout") {
135 emit setVoiceNoReplyTimeoutFailed();
136 } else if (property == "VoiceNotReachable") {
137 emit setVoiceNotReachableFailed();
141 void OfonoCallForwarding::requestPropertyComplete(bool success, const QString& property, const QVariant& value)
143 if (property == "VoiceUnconditional") {
144 success ? emit voiceUnconditionalComplete(true, value.value<QString>()) : emit voiceUnconditionalComplete(false, QString());
145 } else if (property == "VoiceBusy") {
146 success ? emit voiceBusyComplete(true, value.value<QString>()) : emit voiceBusyComplete(false, QString());
147 } else if (property == "VoiceNoReply") {
148 success ? emit voiceNoReplyComplete(true, value.value<QString>()) : emit voiceNoReplyComplete(false, QString());
149 } else if (property == "VoiceNoReplyTimeout") {
150 success ? emit voiceNoReplyTimeoutComplete(true, value.value<ushort>()) : emit voiceNoReplyTimeoutComplete(false, 0);
151 } else if (property == "VoiceNotReachable") {
152 success ? emit voiceNotReachableComplete(true, value.value<QString>()) : emit voiceNotReachableComplete(false, QString());
156 void OfonoCallForwarding::disableAllResp()
158 emit disableAllComplete(TRUE);
161 void OfonoCallForwarding::disableAllErr(QDBusError error)
163 qDebug() << "DisableAll failed" << error;
164 m_errorName = error.name();
165 m_errorMessage = error.message();
166 emit disableAllComplete(FALSE);