2 * hfdialer - Hands Free Voice Call Manager
3 * Copyright (c) 2012, Intel Corporation.
5 * This program is licensed under the terms and conditions of the
6 * Apache License, version 2.0. The full text of the Apache License is at
7 * http://www.apache.org/licenses/LICENSE-2.0
13 #include "dialerapplication.h"
14 #include "pacontrol.h"
15 #include <QGraphicsItem>
16 #include <QGraphicsWidget>
19 #define DEFAULT_RINGTONE "ring-1.wav"
21 CallItem::CallItem(const QString path, QObject *parent)
24 m_rtKey(new MGConfItem("/apps/dialer/defaultRingtone")),
28 QString l_ringtoneFile = QString("/usr/share/hfdialer/sounds/%1").arg(DEFAULT_RINGTONE);
29 QString l_rtKeyValue = m_rtKey->value(QVariant(l_ringtoneFile)).toString();
31 if (!QFileInfo(l_rtKeyValue).exists()) {
32 qWarning() << QString("CallItem: %1 ringtone not found: %2")
45 PAControl::instance()->unrouteAudio();
52 // delete the callproxy object
60 if (!m_path.isEmpty()) {
61 m_call = new CallProxy(m_path);
62 if (m_call->isValid()) {
63 // dynamic_cast<CallItemModel*>(model())->setCall(call);
64 connect(m_call,SIGNAL(stateChanged()),this,SLOT(callStateChanged()));
65 connect(m_call,SIGNAL(dataChanged()),this,SLOT(callDataChanged()));
66 connect(m_call,SIGNAL(multipartyChanged()),this,SLOT(callMultipartyChanged()));
68 qCritical("Invalid CallProxy instance!");
71 qCritical("Empty call path. Can not create CallProxy!");
75 bool CallItem::isValid()
78 return (!path().isEmpty());
81 bool CallItem::isValid() const
84 return (!path().isEmpty());
87 QString CallItem::path() const
93 bool CallItem::setPath(QString path)
96 if (!m_path.isEmpty()) {
97 qCritical("Path already set and can not be changed once it is set");
99 } else if (path.isEmpty()) {
100 qCritical("It makes no sense to set Path to an empty string!?!?");
111 void CallItem::setDirection(CallDirection direction)
116 QString CallItem::lineID() const
119 return m_call->lineID();
122 QString CallItem::name() const
125 return m_call->name();
128 CallState CallItem::state() const
131 CallState cs = STATE_NONE;
132 QString state = m_call->state();
134 if (state == "active")
137 else if (state == "held")
139 else if (state == "dialing")
141 else if (state == "alerting")
143 else if (state == "incoming")
145 else if (state == "waiting")
147 else if (state == "disconnected")
148 cs = STATE_DISCONNECTED;
153 CallDirection CallItem::direction() const
156 return DIRECTION_NONE;
159 CallDisconnectReason CallItem::reason() const
162 return DISCONNECT_NONE;
165 int CallItem::duration() const
168 return m_call->duration();
171 QDateTime CallItem::startTime() const
174 return m_call->startTime();
177 CallProxy* CallItem::callProxy() const
183 void CallItem::click()
190 void CallItem::silenceRingtone()
195 void CallItem::callStateChanged()
201 void CallItem::callDataChanged()
206 void CallItem::callDisconnected(const QString &reason)
213 bool CallItem::multiparty()
219 void CallItem::callMultipartyChanged()
222 emit multipartyChanged();
225 /* Local Variables: */
227 /* c-basic-offset:4 */
228 /* indent-tabs-mode: nil */