~ubuntu-branches/ubuntu/vivid/ofono-qt/vivid

« back to all changes in this revision

Viewing changes to .pc/01-update_code_compatible_qt5.patch/lib/ofonovoicecall.cpp

  • Committer: Package Import Robot
  • Author(s): Ricardo Salveti de Araujo
  • Date: 2013-06-04 06:39:51 UTC
  • Revision ID: package-import@ubuntu.com-20130604063951-2v4g0yyx0pey2sg5
Tags: 1.5+git20120419+bcf0c04-0ubuntu1
Initial release for Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of ofono-qt
 
3
 *
 
4
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 
5
 *
 
6
 * Contact: Alexander Kanavin <alex.kanavin@gmail.com>
 
7
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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
 
20
 * 02110-1301 USA
 
21
 *
 
22
 */
 
23
 
 
24
#include <QtDBus/QtDBus>
 
25
#include <QtCore/QObject>
 
26
 
 
27
#include "ofonointerface.h"
 
28
#include "ofonovoicecall.h"
 
29
 
 
30
#define VOICECALL_TIMEOUT 30000
 
31
 
 
32
OfonoVoiceCall::OfonoVoiceCall(const QString& callId, QObject *parent)
 
33
    : QObject(parent)
 
34
{
 
35
    m_if = new OfonoInterface(callId, "org.ofono.VoiceCall", OfonoGetAllOnStartup, this);
 
36
 
 
37
    connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
 
38
            this, SLOT(propertyChanged(const QString&, const QVariant&)));
 
39
 
 
40
    QDBusConnection::systemBus().connect("org.ofono",path(),m_if->ifname(),
 
41
                                         "DisconnectReason", this,
 
42
                                         SIGNAL(disconnectReason(const QString&)));
 
43
 
 
44
}
 
45
 
 
46
OfonoVoiceCall::OfonoVoiceCall(const OfonoVoiceCall& call)
 
47
    : QObject(call.parent())
 
48
{
 
49
    m_if = new OfonoInterface(call.path(), "org.ofono.VoiceCall", OfonoGetAllOnStartup, this);
 
50
 
 
51
    connect(m_if, SIGNAL(propertyChanged(const QString&, const QVariant&)),
 
52
            this, SLOT(propertyChanged(const QString&, const QVariant&)));
 
53
 
 
54
    QDBusConnection::systemBus().connect("org.ofono",path(),m_if->ifname(),
 
55
                                         "DisconnectReason", this,
 
56
                                         SIGNAL(disconnectReason(const QString&)));
 
57
}
 
58
 
 
59
bool OfonoVoiceCall::operator==(const OfonoVoiceCall &call)
 
60
{
 
61
    return path() == call.path();
 
62
}
 
63
 
 
64
OfonoVoiceCall::~OfonoVoiceCall()
 
65
{
 
66
}
 
67
 
 
68
void OfonoVoiceCall::answer()
 
69
{
 
70
    QDBusMessage request;
 
71
 
 
72
    request = QDBusMessage::createMethodCall("org.ofono",
 
73
                                             path(), m_if->ifname(),
 
74
                                             "Answer");
 
75
 
 
76
    QDBusConnection::systemBus().callWithCallback(request, this,
 
77
                                        SLOT(answerResp()),
 
78
                                        SLOT(answerErr(const QDBusError&)),
 
79
                                        VOICECALL_TIMEOUT);
 
80
}
 
81
 
 
82
void OfonoVoiceCall::hangup()
 
83
{
 
84
    QDBusMessage request;
 
85
 
 
86
    request = QDBusMessage::createMethodCall("org.ofono",
 
87
                                             path(), m_if->ifname(),
 
88
                                             "Hangup");
 
89
 
 
90
    QDBusConnection::systemBus().callWithCallback(request, this,
 
91
                                        SLOT(hangupResp()),
 
92
                                        SLOT(hangupErr(const QDBusError&)),
 
93
                                        VOICECALL_TIMEOUT);
 
94
}
 
95
 
 
96
void OfonoVoiceCall::deflect(const QString &number)
 
97
{
 
98
    QDBusMessage request;
 
99
 
 
100
    request = QDBusMessage::createMethodCall("org.ofono",
 
101
                                             path(), m_if->ifname(),
 
102
                                             "Deflect");
 
103
    QList<QVariant>arg;
 
104
    arg.append(QVariant(number));
 
105
    request.setArguments(arg);
 
106
 
 
107
    QDBusConnection::systemBus().callWithCallback(request, this,
 
108
                                        SLOT(deflectResp()),
 
109
                                        SLOT(deflectErr(const QDBusError&)),
 
110
                                        VOICECALL_TIMEOUT);
 
111
}
 
112
 
 
113
void OfonoVoiceCall::answerResp()
 
114
{
 
115
    emit answerComplete(TRUE);
 
116
}
 
117
 
 
118
void OfonoVoiceCall::answerErr(const QDBusError &error)
 
119
{
 
120
    m_if->setError(error.name(), error.message());
 
121
    emit answerComplete(FALSE);
 
122
}
 
123
 
 
124
void OfonoVoiceCall::hangupResp()
 
125
{
 
126
    emit hangupComplete(TRUE);
 
127
}
 
128
 
 
129
void OfonoVoiceCall::hangupErr(const QDBusError &error)
 
130
{
 
131
    m_if->setError(error.name(), error.message());
 
132
    emit hangupComplete(FALSE);
 
133
}
 
134
 
 
135
void OfonoVoiceCall::deflectResp()
 
136
{
 
137
    emit deflectComplete(TRUE);
 
138
}
 
139
 
 
140
void OfonoVoiceCall::deflectErr(const QDBusError &error)
 
141
{
 
142
    m_if->setError(error.name(), error.message());
 
143
    emit deflectComplete(FALSE);
 
144
}
 
145
 
 
146
QString OfonoVoiceCall::incomingLine() const
 
147
{
 
148
    return m_if->properties()["IncomingLine"].value<QString>();
 
149
}
 
150
 
 
151
QString OfonoVoiceCall::lineIdentification() const
 
152
{
 
153
    return m_if->properties()["LineIdentification"].value<QString>();
 
154
}
 
155
 
 
156
QString OfonoVoiceCall::name() const
 
157
{
 
158
    return m_if->properties()["Name"].value<QString>();
 
159
}
 
160
 
 
161
QString OfonoVoiceCall::state() const
 
162
{
 
163
    return m_if->properties()["State"].value<QString>();
 
164
}
 
165
 
 
166
QString OfonoVoiceCall::startTime() const
 
167
{
 
168
    return m_if->properties()["StartTime"].value<QString>();
 
169
}
 
170
 
 
171
QString OfonoVoiceCall::information() const
 
172
{
 
173
    return m_if->properties()["Information"].value<QString>();
 
174
}
 
175
 
 
176
bool OfonoVoiceCall::multiparty() const
 
177
{
 
178
    return m_if->properties()["Multiparty"].value<bool>();
 
179
}
 
180
 
 
181
bool OfonoVoiceCall::emergency() const
 
182
{
 
183
    return m_if->properties()["Emergency"].value<bool>();
 
184
}
 
185
 
 
186
quint8 OfonoVoiceCall::icon() const
 
187
{
 
188
    return m_if->properties()["Icon"].value<quint8>();
 
189
}
 
190
 
 
191
bool OfonoVoiceCall::remoteHeld() const
 
192
{
 
193
    return m_if->properties()["RemoteHeld"].value<bool>();
 
194
}
 
195
 
 
196
bool OfonoVoiceCall::remoteMultiparty() const
 
197
{
 
198
    return m_if->properties()["RemoteMultiparty"].value<bool>();
 
199
}
 
200
 
 
201
void OfonoVoiceCall::propertyChanged(const QString &property, const QVariant &value)
 
202
{
 
203
    if (property == "LineIdentification") {
 
204
        emit lineIdentificationChanged(value.value<QString>());
 
205
    } else if (property == "Name") {
 
206
        emit nameChanged(value.value<QString>());
 
207
    } else if (property == "State") {
 
208
        emit stateChanged(value.value<QString>());
 
209
    } else if (property == "Information") {
 
210
        emit informationChanged(value.value<QString>());
 
211
    } else if (property == "IncomingLine") {
 
212
        emit incomingLineChanged(value.value<QString>());
 
213
    } else if (property == "Multiparty") {
 
214
        emit multipartyChanged(value.value<bool>());
 
215
    } else if (property == "Emergency") {
 
216
        emit emergencyChanged(value.value<bool>());
 
217
    } else if (property == "StartTime") {
 
218
        emit startTimeChanged(value.value<QString>());
 
219
    } else if (property == "Icon") {
 
220
        emit iconChanged(value.value<quint8>());
 
221
    } else if (property == "RemoteHeld") {
 
222
        emit remoteHeldChanged(value.value<bool>());
 
223
    } else if (property == "RemoteMultiparty") {
 
224
        emit remoteMultipartyChanged(value.value<bool>());
 
225
    }
 
226
}
 
227
 
 
228
QString OfonoVoiceCall::path() const
 
229
{
 
230
    return m_if->path();
 
231
}
 
232
 
 
233
QString OfonoVoiceCall::errorName() const
 
234
{
 
235
    return m_if->errorName();
 
236
}
 
237
 
 
238
QString OfonoVoiceCall::errorMessage() const
 
239
{
 
240
    return m_if->errorMessage();
 
241
}