2 * This file is part of ofono-qt
4 * Copyright (C) 2011 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 <QtDBus/QtDBus>
25 #include <QtCore/QObject>
27 #include "ofonointerface.h"
28 #include "ofonovoicecall.h"
30 #define VOICECALL_TIMEOUT 30000
32 OfonoVoiceCall::OfonoVoiceCall(const QString& callId, QObject *parent)
35 m_if = new OfonoInterface(callId, "org.ofono.VoiceCall", OfonoGetAllOnStartup, this);
37 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
38 this, SLOT(propertyChanged(const QString&, const QVariant&)));
40 QDBusConnection::systemBus().connect("org.ofono",path(),m_if->ifname(),
41 "DisconnectReason", this,
42 SIGNAL(disconnectReason(const QString&)));
46 OfonoVoiceCall::OfonoVoiceCall(const OfonoVoiceCall& call)
47 : QObject(call.parent())
49 m_if = new OfonoInterface(call.path(), "org.ofono.VoiceCall", OfonoGetAllOnStartup, this);
51 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
52 this, SLOT(propertyChanged(const QString&, const QVariant&)));
54 QDBusConnection::systemBus().connect("org.ofono",path(),m_if->ifname(),
55 "DisconnectReason", this,
56 SIGNAL(disconnectReason(const QString&)));
59 bool OfonoVoiceCall::operator==(const OfonoVoiceCall &call)
61 return path() == call.path();
64 OfonoVoiceCall::~OfonoVoiceCall()
68 void OfonoVoiceCall::answer()
72 request = QDBusMessage::createMethodCall("org.ofono",
73 path(), m_if->ifname(),
76 QDBusConnection::systemBus().callWithCallback(request, this,
78 SLOT(answerErr(const QDBusError&)),
82 void OfonoVoiceCall::hangup()
86 request = QDBusMessage::createMethodCall("org.ofono",
87 path(), m_if->ifname(),
90 QDBusConnection::systemBus().callWithCallback(request, this,
92 SLOT(hangupErr(const QDBusError&)),
96 void OfonoVoiceCall::deflect(const QString &number)
100 request = QDBusMessage::createMethodCall("org.ofono",
101 path(), m_if->ifname(),
104 arg.append(QVariant(number));
105 request.setArguments(arg);
107 QDBusConnection::systemBus().callWithCallback(request, this,
109 SLOT(deflectErr(const QDBusError&)),
113 void OfonoVoiceCall::answerResp()
115 emit answerComplete(TRUE);
118 void OfonoVoiceCall::answerErr(const QDBusError &error)
120 m_if->setError(error.name(), error.message());
121 emit answerComplete(FALSE);
124 void OfonoVoiceCall::hangupResp()
126 emit hangupComplete(TRUE);
129 void OfonoVoiceCall::hangupErr(const QDBusError &error)
131 m_if->setError(error.name(), error.message());
132 emit hangupComplete(FALSE);
135 void OfonoVoiceCall::deflectResp()
137 emit deflectComplete(TRUE);
140 void OfonoVoiceCall::deflectErr(const QDBusError &error)
142 m_if->setError(error.name(), error.message());
143 emit deflectComplete(FALSE);
146 QString OfonoVoiceCall::incomingLine() const
148 return m_if->properties()["IncomingLine"].value<QString>();
151 QString OfonoVoiceCall::lineIdentification() const
153 return m_if->properties()["LineIdentification"].value<QString>();
156 QString OfonoVoiceCall::name() const
158 return m_if->properties()["Name"].value<QString>();
161 QString OfonoVoiceCall::state() const
163 return m_if->properties()["State"].value<QString>();
166 QString OfonoVoiceCall::startTime() const
168 return m_if->properties()["StartTime"].value<QString>();
171 QString OfonoVoiceCall::information() const
173 return m_if->properties()["Information"].value<QString>();
176 bool OfonoVoiceCall::multiparty() const
178 return m_if->properties()["Multiparty"].value<bool>();
181 bool OfonoVoiceCall::emergency() const
183 return m_if->properties()["Emergency"].value<bool>();
186 void OfonoVoiceCall::propertyChanged(const QString &property, const QVariant &value)
188 if (property == "LineIdentification") {
189 emit lineIdentificationChanged(value.value<QString>());
190 } else if (property == "Name") {
191 emit nameChanged(value.value<QString>());
192 } else if (property == "State") {
193 emit stateChanged(value.value<QString>());
194 } else if (property == "Information") {
195 emit informationChanged(value.value<QString>());
196 } else if (property == "IncomingLine") {
197 emit incomingLineChanged(value.value<QString>());
198 } else if (property == "Multiparty") {
199 emit multipartyChanged(value.value<bool>());
200 } else if (property == "Emergency") {
201 emit emergencyChanged(value.value<bool>());
202 } else if (property == "StartTime") {
203 emit startTimeChanged(value.value<QString>());
204 } else if (property == "Icon") {
205 emit iconChanged(value.value<quint8>());
209 QString OfonoVoiceCall::path() const
214 QString OfonoVoiceCall::errorName() const
216 return m_if->errorName();
219 QString OfonoVoiceCall::errorMessage() const
221 return m_if->errorMessage();