37
|
1 |
/*!
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Bubble Wrapper.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include <pevirtualengine.h>
|
|
19 |
|
|
20 |
#include "bubblemanagerif.h"
|
|
21 |
#include "phonebubblewrapper.h"
|
|
22 |
#include "phoneconstants.h"
|
|
23 |
#include "qtphonelog.h"
|
|
24 |
|
|
25 |
PhoneBubbleWrapper::PhoneBubbleWrapper (BubbleManagerIF& bubble, QObject *parent) :
|
|
26 |
QObject (parent), m_bubbleManager (bubble)
|
|
27 |
{
|
|
28 |
}
|
|
29 |
|
|
30 |
PhoneBubbleWrapper::~PhoneBubbleWrapper ()
|
|
31 |
{
|
|
32 |
|
|
33 |
}
|
|
34 |
|
|
35 |
void PhoneBubbleWrapper::updateCallState (int callId, int newState)
|
|
36 |
{
|
|
37 |
// TODO: +1 callId because value 0 causes problems
|
|
38 |
// when using QMap. Bug in S60 Qt?
|
|
39 |
m_callStates [callId] = newState;
|
|
40 |
}
|
|
41 |
|
|
42 |
int PhoneBubbleWrapper::callId (int state)
|
|
43 |
{
|
|
44 |
// Returns call id or -1 if not found
|
|
45 |
// TODO: callId -1 because we +1 callId when inserted
|
|
46 |
// This is because callId 0 causes problems in QMap.
|
|
47 |
int callId = m_callStates.key (state, -1);
|
|
48 |
return callId;
|
|
49 |
}
|
|
50 |
|
|
51 |
int PhoneBubbleWrapper::createCallHeader (int callId)
|
|
52 |
{
|
76
|
53 |
PHONE_TRACE
|
37
|
54 |
int bubble;
|
|
55 |
|
|
56 |
if (!m_bubbles.contains (callId)) {
|
|
57 |
bubble = m_bubbleManager.createCallHeader ();
|
|
58 |
m_bubbles.insert (callId, bubble);
|
|
59 |
}
|
|
60 |
else {
|
|
61 |
bubble = m_bubbles [callId];
|
|
62 |
}
|
|
63 |
|
|
64 |
return bubble;
|
|
65 |
}
|
|
66 |
|
|
67 |
void PhoneBubbleWrapper::removeCallHeader (int callId)
|
|
68 |
{
|
76
|
69 |
PHONE_TRACE
|
37
|
70 |
if (m_bubbles.contains (callId)) {
|
|
71 |
m_bubbleManager.removeCallHeader (m_bubbles [callId]);
|
|
72 |
m_bubbles.remove (callId);
|
|
73 |
}
|
|
74 |
}
|
|
75 |
|
|
76 |
BubbleManagerIF& PhoneBubbleWrapper::bubbleManager ()
|
|
77 |
{
|
|
78 |
return m_bubbleManager;
|
|
79 |
}
|
|
80 |
|
|
81 |
void PhoneBubbleWrapper::setState (int callId, int bubble, int callState)
|
|
82 |
{
|
|
83 |
BubbleManagerIF::PhoneCallState state = BubbleManagerIF::None;
|
|
84 |
|
|
85 |
switch (callState) {
|
|
86 |
case EPEStateIdle:
|
|
87 |
state = BubbleManagerIF::Disconnected;
|
|
88 |
break;
|
|
89 |
case EPEStateDialing:
|
|
90 |
state = BubbleManagerIF::Outgoing;
|
|
91 |
break;
|
|
92 |
case EPEStateRinging:
|
|
93 |
if ( m_bubbles.count() > 1 ) {
|
|
94 |
state = BubbleManagerIF::Waiting;
|
|
95 |
}
|
|
96 |
else {
|
|
97 |
state = BubbleManagerIF::Incoming;
|
|
98 |
}
|
|
99 |
break;
|
|
100 |
case EPEStateConnecting:
|
|
101 |
state = BubbleManagerIF::Alerting;
|
|
102 |
break;
|
|
103 |
case EPEStateConnected:
|
|
104 |
state = BubbleManagerIF::Active;
|
|
105 |
break;
|
|
106 |
case EPEStateHeld:
|
|
107 |
state = BubbleManagerIF::OnHold;
|
|
108 |
break;
|
|
109 |
case EPEStateDisconnecting:
|
|
110 |
state = BubbleManagerIF::Disconnected;
|
|
111 |
break;
|
|
112 |
case EPEStateConferenceIdle:
|
|
113 |
state = BubbleManagerIF::Disconnected;
|
|
114 |
break;
|
|
115 |
case EPEStateConnectedConference:
|
|
116 |
state = BubbleManagerIF::Active;
|
|
117 |
break;
|
|
118 |
case EPEStateHeldConference:
|
|
119 |
state = BubbleManagerIF::OnHold;
|
|
120 |
break;
|
|
121 |
case EPEStateUnknown:
|
|
122 |
state = BubbleManagerIF::None;
|
|
123 |
break;
|
|
124 |
default:
|
|
125 |
break;
|
|
126 |
}
|
|
127 |
|
|
128 |
updateCallState (callId, callState);
|
|
129 |
m_bubbleManager.setState (bubble, state);
|
|
130 |
|
|
131 |
}
|
|
132 |
|
|
133 |
void PhoneBubbleWrapper::setLabel (int bubble, const TDesC &text)
|
|
134 |
{
|
|
135 |
QString labelText = QString::fromUtf16 (text.Ptr (), text.Length ());
|
|
136 |
PHONE_DEBUG2("PhoneBubbleWrapper::setLabel, label:", labelText);
|
|
137 |
m_bubbleManager.setLabel (bubble, labelText, Qt::ElideRight);
|
|
138 |
}
|
|
139 |
|
50
|
140 |
void PhoneBubbleWrapper::setCli (int bubble, const TDesC &cliText,
|
|
141 |
Qt::TextElideMode elide)
|
37
|
142 |
{
|
|
143 |
QString text = QString::fromUtf16 (cliText.Ptr (), cliText.Length ());
|
|
144 |
PHONE_DEBUG2("PhoneBubbleWrapper::setCli, cli:", text);
|
50
|
145 |
m_bubbleManager.setCli (bubble, text, elide);
|
37
|
146 |
}
|
|
147 |
|
50
|
148 |
void PhoneBubbleWrapper::setSecondaryCli (int bubble, const TDesC &cliText,
|
|
149 |
Qt::TextElideMode elide)
|
37
|
150 |
{
|
|
151 |
QString text = QString::fromUtf16 (cliText.Ptr (), cliText.Length ());
|
|
152 |
PHONE_DEBUG2("PhoneBubbleWrapper::setSecondaryCli, SecondaryCli:", text);
|
50
|
153 |
m_bubbleManager.setSecondaryCli (bubble, text, elide);
|
37
|
154 |
}
|
|
155 |
|
|
156 |
void PhoneBubbleWrapper::setCallType (int bubble, int callType)
|
|
157 |
{
|
|
158 |
BubbleManagerIF::PhoneCallFlags callflag = BubbleManagerIF::Normal;
|
|
159 |
|
|
160 |
switch (callType) {
|
|
161 |
case EPECallTypeCSVoice:
|
|
162 |
callflag = BubbleManagerIF::Normal;
|
|
163 |
break;
|
|
164 |
case EPECallTypeVideo:
|
|
165 |
callflag = BubbleManagerIF::Video;
|
|
166 |
break;
|
|
167 |
case EPECallTypeVoIP:
|
|
168 |
callflag = BubbleManagerIF::VoIPCall;
|
|
169 |
break;
|
|
170 |
default:
|
|
171 |
break;
|
|
172 |
}
|
|
173 |
|
|
174 |
m_bubbleManager.setCallFlag (bubble, callflag, true);
|
|
175 |
}
|
|
176 |
|
|
177 |
int PhoneBubbleWrapper::bubbleId (int callId)
|
|
178 |
{
|
|
179 |
return m_bubbles.value (callId, -1);
|
|
180 |
}
|
|
181 |
|
|
182 |
void PhoneBubbleWrapper::setDivert (int bubble, bool enabled)
|
|
183 |
{
|
|
184 |
if (enabled) {
|
|
185 |
BubbleManagerIF::PhoneCallFlags divertedFlag = BubbleManagerIF::Diverted;
|
|
186 |
m_bubbleManager.setCallFlag (bubble, divertedFlag, true);
|
|
187 |
}
|
|
188 |
}
|
|
189 |
|
|
190 |
void PhoneBubbleWrapper::setCiphering(int bubble, bool indicatorAllowed, bool enabled)
|
|
191 |
{
|
|
192 |
if (indicatorAllowed && !enabled) {
|
|
193 |
m_bubbleManager.setCallFlag (bubble, BubbleManagerIF::NoCiphering, true);
|
|
194 |
} else {
|
|
195 |
m_bubbleManager.setCallFlag (bubble, BubbleManagerIF::NoCiphering, false);
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
int PhoneBubbleWrapper::activeCallCount()
|
|
200 |
{
|
76
|
201 |
PHONE_TRACE
|
37
|
202 |
int count(0);
|
|
203 |
QMap<int, int> callStateList = callStates();
|
|
204 |
|
|
205 |
for (int i=0; i<callStateList.size(); ++i) {
|
|
206 |
if ( callStateList.values().at(i) == EPEStateConnected ||
|
|
207 |
callStateList.values().at(i) == EPEStateConnectedConference ||
|
|
208 |
callStateList.values().at(i) == EPEStateDisconnecting ||
|
|
209 |
callStateList.values().at(i) == EPEStateHeld ||
|
|
210 |
callStateList.values().at(i) == EPEStateHeldConference ) {
|
|
211 |
count++;
|
|
212 |
}
|
|
213 |
}
|
|
214 |
|
|
215 |
return count;
|
|
216 |
}
|
|
217 |
|
|
218 |
QMap<int, int> PhoneBubbleWrapper::callStates() const
|
|
219 |
{
|
76
|
220 |
PHONE_TRACE
|
37
|
221 |
QMap<int, int> ret;
|
|
222 |
|
|
223 |
for (int i=0; i<m_callStates.size(); ++i) {
|
|
224 |
if ( false == m_conferenceList.contains(m_callStates.keys().at(i))
|
|
225 |
&& m_bubbles.keys().contains(m_callStates.keys().at(i)) ) {
|
|
226 |
ret.insert(m_callStates.keys().at(i),
|
|
227 |
m_callStates.value(m_callStates.keys().at(i)));
|
|
228 |
}
|
|
229 |
}
|
|
230 |
|
|
231 |
return ret;
|
|
232 |
}
|
|
233 |
|
|
234 |
QMap<int, int> PhoneBubbleWrapper::bubbles() const
|
|
235 |
{
|
76
|
236 |
PHONE_TRACE
|
37
|
237 |
QMap<int, int> ret;
|
|
238 |
|
|
239 |
for (int i=0; i<m_bubbles.size(); ++i) {
|
|
240 |
if ( false == m_conferenceList.contains(m_bubbles.keys().at(i)) ) {
|
|
241 |
ret.insert(m_bubbles.keys().at(i), m_bubbles.value(m_bubbles.keys().at(i)));
|
|
242 |
}
|
|
243 |
}
|
|
244 |
|
|
245 |
return ret;
|
|
246 |
}
|
|
247 |
|
|
248 |
int PhoneBubbleWrapper::createConferenceBubble(
|
|
249 |
int callId,
|
|
250 |
int callState,
|
|
251 |
const TDesC &labelText,
|
|
252 |
const TDesC &cliText)
|
|
253 |
{
|
76
|
254 |
PHONE_TRACE
|
37
|
255 |
int callId1;
|
|
256 |
int callId2;
|
|
257 |
int bubble = -1;
|
|
258 |
if (getCallIdsForConference(callId1, callId2)) {
|
|
259 |
m_bubbleManager.startChanges();
|
|
260 |
bubble = m_bubbleManager.createConference(
|
|
261 |
bubbleId(callId1),
|
|
262 |
bubbleId(callId2) );
|
|
263 |
|
|
264 |
setConferenceCallId(callId1);
|
|
265 |
setConferenceCallId(callId2);
|
|
266 |
|
|
267 |
m_bubbles.insert(callId,bubble);
|
|
268 |
setState(callId, bubble, callState );
|
|
269 |
setLabel(bubble, labelText);
|
50
|
270 |
setCli (bubble, cliText, Qt::ElideRight);
|
37
|
271 |
|
|
272 |
//Set conference bubble expanded if no other
|
|
273 |
//bubbles (like waiting bubble).
|
|
274 |
m_bubbleManager.setExpandedConferenceCallHeader(
|
|
275 |
(1==bubbles().size()));
|
|
276 |
|
|
277 |
m_bubbleManager.endChanges();
|
|
278 |
}
|
|
279 |
|
|
280 |
return bubble;
|
|
281 |
}
|
|
282 |
|
|
283 |
void PhoneBubbleWrapper::setConferenceCallId(int callId)
|
|
284 |
{
|
|
285 |
if ( false == m_conferenceList.contains(callId) ) {
|
|
286 |
m_conferenceList.append(callId);
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
void PhoneBubbleWrapper::removeConferenceCallId(int callId)
|
|
291 |
{
|
|
292 |
if ( m_conferenceList.contains(callId) ) {
|
|
293 |
m_conferenceList.removeOne(callId);
|
|
294 |
}
|
|
295 |
}
|
|
296 |
|
|
297 |
bool PhoneBubbleWrapper::conferenceCallId(int callId) const
|
|
298 |
{
|
|
299 |
return m_conferenceList.contains(callId);
|
|
300 |
}
|
|
301 |
|
|
302 |
void PhoneBubbleWrapper::removeCallFromConference(int callId)
|
|
303 |
{
|
76
|
304 |
PHONE_TRACE
|
37
|
305 |
if (m_conferenceList.contains(callId)) {
|
|
306 |
m_bubbleManager.startChanges();
|
|
307 |
if(1<m_conferenceList.size()) {
|
|
308 |
m_bubbleManager.removeRowFromConference(m_bubbles.value(callId));
|
|
309 |
m_conferenceList.removeOne(callId);
|
|
310 |
}
|
|
311 |
else {
|
|
312 |
m_bubbleManager.removeConference();
|
|
313 |
|
|
314 |
if (m_bubbles.contains(KConferenceCallId)) {
|
|
315 |
m_bubbles.remove(KConferenceCallId);
|
|
316 |
}
|
|
317 |
m_conferenceList.clear();
|
|
318 |
}
|
|
319 |
|
|
320 |
m_bubbleManager.endChanges();
|
|
321 |
}
|
|
322 |
}
|
|
323 |
|
|
324 |
QList<int> PhoneBubbleWrapper::conferenceCallList() const
|
|
325 |
{
|
|
326 |
return m_conferenceList;
|
|
327 |
}
|
|
328 |
|
|
329 |
void PhoneBubbleWrapper::removeConferenceBubble()
|
|
330 |
{
|
|
331 |
if (0 < m_conferenceList.size()) {
|
|
332 |
m_bubbleManager.removeConference();
|
|
333 |
m_bubbleManager.setExpandedConferenceCallHeader(false);
|
|
334 |
|
|
335 |
if (m_bubbles.contains(KConferenceCallId)) {
|
|
336 |
m_bubbles.remove(KConferenceCallId);
|
|
337 |
}
|
|
338 |
m_conferenceList.clear();
|
|
339 |
}
|
|
340 |
}
|
|
341 |
|
|
342 |
int PhoneBubbleWrapper::callIdByBubbleId(int bubbleId)
|
|
343 |
{
|
|
344 |
return m_bubbles.key(bubbleId, -1);
|
|
345 |
}
|
|
346 |
|
|
347 |
void PhoneBubbleWrapper::addToConferenceBubble()
|
|
348 |
{
|
|
349 |
if (m_conferenceList.size()) {
|
|
350 |
int callId = callIdForConference();
|
|
351 |
if (-1 != callId &&
|
|
352 |
false == m_conferenceList.contains(callId)) {
|
|
353 |
m_bubbleManager.startChanges();
|
|
354 |
setConferenceCallId(callId);
|
|
355 |
m_bubbleManager.addRowToConference(bubbleId(callId));
|
|
356 |
m_bubbleManager.endChanges();
|
|
357 |
}
|
|
358 |
}
|
|
359 |
}
|
|
360 |
|
|
361 |
int PhoneBubbleWrapper::callIdForConference()
|
|
362 |
{
|
|
363 |
int callId = -1;
|
|
364 |
QMap<int, int> bubblelist = bubbles();
|
|
365 |
for (int i=0; i<bubblelist.size() && callId == -1; ++i) {
|
|
366 |
if (KConferenceCallId != bubblelist.keys().at(i)) {
|
|
367 |
if ( bubblelist.size() > 2 ) {
|
|
368 |
if (EPEStateRinging !=
|
|
369 |
m_callStates.value(bubblelist.keys().at(i))) {
|
|
370 |
callId = bubblelist.keys().at(i);
|
|
371 |
}
|
|
372 |
} else {
|
|
373 |
callId = bubblelist.keys().at(i);
|
|
374 |
}
|
|
375 |
}
|
|
376 |
}
|
|
377 |
|
|
378 |
return callId;
|
|
379 |
}
|
|
380 |
|
|
381 |
bool PhoneBubbleWrapper::getCallIdsForConference(int &first, int &second)
|
|
382 |
{
|
|
383 |
first = -1;
|
|
384 |
second = -1;
|
|
385 |
|
|
386 |
if (2==m_bubbles.values().size()) {
|
|
387 |
first = m_bubbles.keys().first();
|
|
388 |
second = m_bubbles.keys().at(1);
|
|
389 |
} else if (2<=m_bubbles.values().size()) {
|
|
390 |
for (int i=0;i<m_callStates.values().size();++i) {
|
|
391 |
if ( m_callStates.values().at(i) != EPEStateRinging ) {
|
|
392 |
if (first==-1) {
|
|
393 |
first = m_callStates.keys().at(i);
|
|
394 |
} else {
|
|
395 |
second = m_callStates.keys().at(i);
|
|
396 |
break;
|
|
397 |
}
|
|
398 |
}
|
|
399 |
} // For
|
|
400 |
}
|
|
401 |
|
|
402 |
return (first!=-1 && second!=-1);
|
|
403 |
}
|
|
404 |
|
|
405 |
void PhoneBubbleWrapper::setServiceId(int callId, int serviceId)
|
|
406 |
{
|
|
407 |
m_services[callId] = serviceId;
|
|
408 |
}
|
|
409 |
|
|
410 |
int PhoneBubbleWrapper::serviceIdByCallId(int callId) const
|
|
411 |
{
|
|
412 |
return m_services.value(callId, -1);
|
|
413 |
}
|
|
414 |
|
|
415 |
QMap<int, int> PhoneBubbleWrapper::serviceIds() const
|
|
416 |
{
|
|
417 |
return m_services;
|
|
418 |
}
|
|
419 |
|