2 * This file is part of ofono-qt
4 * Copyright (C) 2010-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 "ofonovoicecallmanager.h"
28 #include "ofonointerface.h"
30 #define DIAL_TIMEOUT 30000
31 #define TONE_TIMEOUT 10000
32 #define TRANSFER_TIMEOUT 20000
33 #define SWAP_TIMEOUT 20000
34 #define HANGUP_TIMEOUT 30000
35 #define HOLD_TIMEOUT 30000
37 QDBusArgument &operator<<(QDBusArgument &argument, const OfonoVoiceCallManagerStruct &call)
39 argument.beginStructure();
40 argument << call.path << call.properties;
41 argument.endStructure();
45 const QDBusArgument &operator>>(const QDBusArgument &argument, OfonoVoiceCallManagerStruct &call)
47 argument.beginStructure();
48 argument >> call.path >> call.properties;
49 argument.endStructure();
53 OfonoVoiceCallManager::OfonoVoiceCallManager(OfonoModem::SelectionSetting modemSetting, const QString &modemPath, QObject *parent)
54 : OfonoModemInterface(modemSetting, modemPath, "org.ofono.VoiceCallManager", OfonoGetAllOnStartup, parent)
56 QDBusReply<OfonoVoiceCallManagerList> reply;
57 OfonoVoiceCallManagerList calls;
61 qDBusRegisterMetaType<OfonoVoiceCallManagerStruct>();
62 qDBusRegisterMetaType<OfonoVoiceCallManagerStruct>();
64 request = QDBusMessage::createMethodCall("org.ofono",
65 path(), m_if->ifname(),
67 reply = QDBusConnection::systemBus().call(request);
70 foreach(OfonoVoiceCallManagerStruct call, calls) {
71 m_calllist<< call.path.path();
74 connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
75 this, SLOT(propertyChanged(const QString&, const QVariant&)));
77 QDBusConnection::systemBus().connect("org.ofono",path(),m_if->ifname(),
79 SLOT(callAddedChanged(const QDBusObjectPath&, const QVariantMap&)));
81 QDBusConnection::systemBus().connect("org.ofono",path(),m_if->ifname(),
83 SLOT(callRemovedChanged(const QDBusObjectPath&)));
86 OfonoVoiceCallManager::~OfonoVoiceCallManager()
90 void OfonoVoiceCallManager::dial(const QString &number, const QString &callerid_hide)
93 request = QDBusMessage::createMethodCall("org.ofono",
94 path(), m_if->ifname(),
97 arg.append(QVariant(number));
98 arg.append(QVariant(callerid_hide));
99 request.setArguments(arg);
100 QDBusConnection::systemBus().callWithCallback(request, this,
102 SLOT(dialErr(const QDBusError&)),
106 void OfonoVoiceCallManager::hangupAll()
108 QDBusMessage request;
109 request = QDBusMessage::createMethodCall("org.ofono",
110 path(), m_if->ifname(),
113 QDBusConnection::systemBus().callWithCallback(request, this,
114 SLOT(hangupAllResp()),
115 SLOT(hangupAllErr(const QDBusError&)),
119 void OfonoVoiceCallManager::sendTones(const QString &tonestring)
121 QDBusMessage request;
122 request = QDBusMessage::createMethodCall("org.ofono",
123 path(), m_if->ifname(),
126 arg.append(QVariant(tonestring));
127 request.setArguments(arg);
129 QDBusConnection::systemBus().callWithCallback(request, this,
130 SLOT(sendTonesResp()),
131 SLOT(sendTonesErr(const QDBusError&)),
132 (TONE_TIMEOUT*tonestring.length()));
135 void OfonoVoiceCallManager::transfer()
137 QDBusMessage request;
138 request = QDBusMessage::createMethodCall("org.ofono",
139 path(), m_if->ifname(),
142 QDBusConnection::systemBus().callWithCallback(request, this,
143 SLOT(transferResp()),
144 SLOT(transferErr(const QDBusError&)),
148 void OfonoVoiceCallManager::swapCalls()
150 QDBusMessage request;
151 request = QDBusMessage::createMethodCall("org.ofono",
152 path(), m_if->ifname(),
155 QDBusConnection::systemBus().callWithCallback(request, this,
156 SLOT(swapCallsResp()),
157 SLOT(swapCallsErr(const QDBusError&)),
161 void OfonoVoiceCallManager::releaseAndAnswer()
163 QDBusMessage request;
164 request = QDBusMessage::createMethodCall("org.ofono",
165 path(), m_if->ifname(),
168 QDBusConnection::systemBus().callWithCallback(request, this,
169 SLOT(releaseAndAnswerResp()),
170 SLOT(releaseAndAnswerErr(const QDBusError&)),
174 void OfonoVoiceCallManager::holdAndAnswer()
176 QDBusMessage request;
177 request = QDBusMessage::createMethodCall("org.ofono",
178 path(), m_if->ifname(),
181 QDBusConnection::systemBus().callWithCallback(request, this,
182 SLOT(holdAndAnswerResp()),
183 SLOT(holdAndAnswerErr(const QDBusError&)),
187 void OfonoVoiceCallManager::holdAndAnswerResp()
189 emit holdAndAnswerComplete(TRUE);
192 void OfonoVoiceCallManager::holdAndAnswerErr(const QDBusError &error)
194 qDebug() << "request failed" << error;
195 m_if->setError(error.name(), error.message());
196 emit holdAndAnswerComplete(FALSE);
199 void OfonoVoiceCallManager::releaseAndAnswerResp()
201 emit releaseAndAnswerComplete(TRUE);
204 void OfonoVoiceCallManager::releaseAndAnswerErr(const QDBusError &error)
206 qDebug() << "request failed" << error;
207 m_if->setError(error.name(), error.message());
208 emit releaseAndAnswerComplete(FALSE);
211 void OfonoVoiceCallManager::swapCallsResp()
213 emit swapCallsComplete(TRUE);
216 void OfonoVoiceCallManager::swapCallsErr(const QDBusError &error)
218 qDebug() << "request failed" << error;
219 m_if->setError(error.name(), error.message());
220 emit swapCallsComplete(FALSE);
223 void OfonoVoiceCallManager::dialResp()
225 emit dialComplete(TRUE);
228 void OfonoVoiceCallManager::dialErr(const QDBusError &error)
230 qDebug() << "request failed" << error;
231 m_if->setError(error.name(), error.message());
232 emit dialComplete(FALSE);
235 void OfonoVoiceCallManager::hangupAllResp()
237 emit hangupAllComplete(TRUE);
240 void OfonoVoiceCallManager::hangupAllErr(const QDBusError &error)
242 qDebug() << "request failed" << error;
243 m_if->setError(error.name(), error.message());
244 emit hangupAllComplete(FALSE);
246 void OfonoVoiceCallManager::sendTonesResp()
248 emit sendTonesComplete(TRUE);
251 void OfonoVoiceCallManager::sendTonesErr(const QDBusError &error)
253 qDebug() << "request failed" << error;
254 m_if->setError(error.name(), error.message());
255 emit sendTonesComplete(FALSE);
258 void OfonoVoiceCallManager::transferResp()
260 emit transferComplete(TRUE);
263 void OfonoVoiceCallManager::transferErr(const QDBusError &error)
265 qDebug() << "request failed" << error;
266 m_if->setError(error.name(), error.message());
267 emit transferComplete(FALSE);
270 QStringList OfonoVoiceCallManager::emergencyNumbers() const
272 return m_if->properties()["EmergencyNumbers"].value<QStringList>();
275 void OfonoVoiceCallManager::propertyChanged(const QString &property, const QVariant &value)
277 if (property == "EmergencyNumbers") {
278 emit emergencyNumbersChanged(value.value<QStringList>());
282 QStringList OfonoVoiceCallManager::getCalls() const
287 void OfonoVoiceCallManager::callAddedChanged(const QDBusObjectPath &path, const QVariantMap& /*values*/)
289 m_calllist << path.path();
290 emit callAdded(path.path());
293 void OfonoVoiceCallManager::callRemovedChanged(const QDBusObjectPath &path)
295 m_calllist.removeAll(path.path());
296 emit callRemoved(path.path());