author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 00:16:48 +0300 | |
changeset 77 | 2be0b271d017 |
parent 56 | 5bcb308bd24d |
child 76 | cfea66083b62 |
permissions | -rw-r--r-- |
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 |
{ |
|
53 |
int bubble; |
|
54 |
||
55 |
if (!m_bubbles.contains (callId)) { |
|
56 |
bubble = m_bubbleManager.createCallHeader (); |
|
57 |
m_bubbles.insert (callId, bubble); |
|
58 |
} |
|
59 |
else { |
|
60 |
bubble = m_bubbles [callId]; |
|
61 |
} |
|
62 |
||
63 |
return bubble; |
|
64 |
} |
|
65 |
||
66 |
void PhoneBubbleWrapper::removeCallHeader (int callId) |
|
67 |
{ |
|
68 |
if (m_bubbles.contains (callId)) { |
|
69 |
m_bubbleManager.removeCallHeader (m_bubbles [callId]); |
|
70 |
m_bubbles.remove (callId); |
|
71 |
} |
|
72 |
} |
|
73 |
||
74 |
BubbleManagerIF& PhoneBubbleWrapper::bubbleManager () |
|
75 |
{ |
|
76 |
return m_bubbleManager; |
|
77 |
} |
|
78 |
||
79 |
void PhoneBubbleWrapper::setState (int callId, int bubble, int callState) |
|
80 |
{ |
|
81 |
BubbleManagerIF::PhoneCallState state = BubbleManagerIF::None; |
|
82 |
||
83 |
switch (callState) { |
|
84 |
case EPEStateIdle: |
|
85 |
state = BubbleManagerIF::Disconnected; |
|
86 |
break; |
|
87 |
case EPEStateDialing: |
|
88 |
state = BubbleManagerIF::Outgoing; |
|
89 |
break; |
|
90 |
case EPEStateRinging: |
|
91 |
if ( m_bubbles.count() > 1 ) { |
|
92 |
state = BubbleManagerIF::Waiting; |
|
93 |
} |
|
94 |
else { |
|
95 |
state = BubbleManagerIF::Incoming; |
|
96 |
} |
|
97 |
break; |
|
98 |
case EPEStateConnecting: |
|
99 |
state = BubbleManagerIF::Alerting; |
|
100 |
break; |
|
101 |
case EPEStateConnected: |
|
102 |
state = BubbleManagerIF::Active; |
|
103 |
break; |
|
104 |
case EPEStateHeld: |
|
105 |
state = BubbleManagerIF::OnHold; |
|
106 |
break; |
|
107 |
case EPEStateDisconnecting: |
|
108 |
state = BubbleManagerIF::Disconnected; |
|
109 |
break; |
|
110 |
case EPEStateConferenceIdle: |
|
111 |
state = BubbleManagerIF::Disconnected; |
|
112 |
break; |
|
113 |
case EPEStateConnectedConference: |
|
114 |
state = BubbleManagerIF::Active; |
|
115 |
break; |
|
116 |
case EPEStateHeldConference: |
|
117 |
state = BubbleManagerIF::OnHold; |
|
118 |
break; |
|
119 |
case EPEStateUnknown: |
|
120 |
state = BubbleManagerIF::None; |
|
121 |
break; |
|
122 |
default: |
|
123 |
break; |
|
124 |
} |
|
125 |
||
126 |
updateCallState (callId, callState); |
|
127 |
m_bubbleManager.setState (bubble, state); |
|
128 |
||
129 |
} |
|
130 |
||
131 |
void PhoneBubbleWrapper::setLabel (int bubble, const TDesC &text) |
|
132 |
{ |
|
133 |
QString labelText = QString::fromUtf16 (text.Ptr (), text.Length ()); |
|
134 |
PHONE_DEBUG2("PhoneBubbleWrapper::setLabel, label:", labelText); |
|
135 |
m_bubbleManager.setLabel (bubble, labelText, Qt::ElideRight); |
|
136 |
} |
|
137 |
||
56
5bcb308bd24d
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
138 |
void PhoneBubbleWrapper::setCli (int bubble, const TDesC &cliText, |
5bcb308bd24d
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
139 |
Qt::TextElideMode elide) |
37 | 140 |
{ |
141 |
QString text = QString::fromUtf16 (cliText.Ptr (), cliText.Length ()); |
|
142 |
PHONE_DEBUG2("PhoneBubbleWrapper::setCli, cli:", text); |
|
56
5bcb308bd24d
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
143 |
m_bubbleManager.setCli (bubble, text, elide); |
37 | 144 |
} |
145 |
||
56
5bcb308bd24d
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
146 |
void PhoneBubbleWrapper::setSecondaryCli (int bubble, const TDesC &cliText, |
5bcb308bd24d
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
147 |
Qt::TextElideMode elide) |
37 | 148 |
{ |
149 |
QString text = QString::fromUtf16 (cliText.Ptr (), cliText.Length ()); |
|
150 |
PHONE_DEBUG2("PhoneBubbleWrapper::setSecondaryCli, SecondaryCli:", text); |
|
56
5bcb308bd24d
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
151 |
m_bubbleManager.setSecondaryCli (bubble, text, elide); |
37 | 152 |
} |
153 |
||
154 |
void PhoneBubbleWrapper::setCallType (int bubble, int callType) |
|
155 |
{ |
|
156 |
BubbleManagerIF::PhoneCallFlags callflag = BubbleManagerIF::Normal; |
|
157 |
||
158 |
switch (callType) { |
|
159 |
case EPECallTypeCSVoice: |
|
160 |
callflag = BubbleManagerIF::Normal; |
|
161 |
break; |
|
162 |
case EPECallTypeVideo: |
|
163 |
callflag = BubbleManagerIF::Video; |
|
164 |
break; |
|
165 |
case EPECallTypeVoIP: |
|
166 |
callflag = BubbleManagerIF::VoIPCall; |
|
167 |
break; |
|
168 |
default: |
|
169 |
break; |
|
170 |
} |
|
171 |
||
172 |
m_bubbleManager.setCallFlag (bubble, callflag, true); |
|
173 |
} |
|
174 |
||
175 |
int PhoneBubbleWrapper::bubbleId (int callId) |
|
176 |
{ |
|
177 |
return m_bubbles.value (callId, -1); |
|
178 |
} |
|
179 |
||
180 |
void PhoneBubbleWrapper::setDivert (int bubble, bool enabled) |
|
181 |
{ |
|
182 |
if (enabled) { |
|
183 |
BubbleManagerIF::PhoneCallFlags divertedFlag = BubbleManagerIF::Diverted; |
|
184 |
m_bubbleManager.setCallFlag (bubble, divertedFlag, true); |
|
185 |
} |
|
186 |
} |
|
187 |
||
188 |
void PhoneBubbleWrapper::setCiphering(int bubble, bool indicatorAllowed, bool enabled) |
|
189 |
{ |
|
190 |
if (indicatorAllowed && !enabled) { |
|
191 |
m_bubbleManager.setCallFlag (bubble, BubbleManagerIF::NoCiphering, true); |
|
192 |
} else { |
|
193 |
m_bubbleManager.setCallFlag (bubble, BubbleManagerIF::NoCiphering, false); |
|
194 |
} |
|
195 |
} |
|
196 |
||
197 |
int PhoneBubbleWrapper::activeCallCount() |
|
198 |
{ |
|
199 |
int count(0); |
|
200 |
QMap<int, int> callStateList = callStates(); |
|
201 |
||
202 |
for (int i=0; i<callStateList.size(); ++i) { |
|
203 |
if ( callStateList.values().at(i) == EPEStateConnected || |
|
204 |
callStateList.values().at(i) == EPEStateConnectedConference || |
|
205 |
callStateList.values().at(i) == EPEStateDisconnecting || |
|
206 |
callStateList.values().at(i) == EPEStateHeld || |
|
207 |
callStateList.values().at(i) == EPEStateHeldConference ) { |
|
208 |
count++; |
|
209 |
} |
|
210 |
} |
|
211 |
||
212 |
return count; |
|
213 |
} |
|
214 |
||
215 |
QMap<int, int> PhoneBubbleWrapper::callStates() const |
|
216 |
{ |
|
217 |
QMap<int, int> ret; |
|
218 |
||
219 |
for (int i=0; i<m_callStates.size(); ++i) { |
|
220 |
if ( false == m_conferenceList.contains(m_callStates.keys().at(i)) |
|
221 |
&& m_bubbles.keys().contains(m_callStates.keys().at(i)) ) { |
|
222 |
ret.insert(m_callStates.keys().at(i), |
|
223 |
m_callStates.value(m_callStates.keys().at(i))); |
|
224 |
} |
|
225 |
} |
|
226 |
||
227 |
return ret; |
|
228 |
} |
|
229 |
||
230 |
QMap<int, int> PhoneBubbleWrapper::bubbles() const |
|
231 |
{ |
|
232 |
QMap<int, int> ret; |
|
233 |
||
234 |
for (int i=0; i<m_bubbles.size(); ++i) { |
|
235 |
if ( false == m_conferenceList.contains(m_bubbles.keys().at(i)) ) { |
|
236 |
ret.insert(m_bubbles.keys().at(i), m_bubbles.value(m_bubbles.keys().at(i))); |
|
237 |
} |
|
238 |
} |
|
239 |
||
240 |
return ret; |
|
241 |
} |
|
242 |
||
243 |
int PhoneBubbleWrapper::createConferenceBubble( |
|
244 |
int callId, |
|
245 |
int callState, |
|
246 |
const TDesC &labelText, |
|
247 |
const TDesC &cliText) |
|
248 |
{ |
|
249 |
int callId1; |
|
250 |
int callId2; |
|
251 |
int bubble = -1; |
|
252 |
if (getCallIdsForConference(callId1, callId2)) { |
|
253 |
m_bubbleManager.startChanges(); |
|
254 |
bubble = m_bubbleManager.createConference( |
|
255 |
bubbleId(callId1), |
|
256 |
bubbleId(callId2) ); |
|
257 |
||
258 |
setConferenceCallId(callId1); |
|
259 |
setConferenceCallId(callId2); |
|
260 |
||
261 |
m_bubbles.insert(callId,bubble); |
|
262 |
setState(callId, bubble, callState ); |
|
263 |
setLabel(bubble, labelText); |
|
56
5bcb308bd24d
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
37
diff
changeset
|
264 |
setCli (bubble, cliText, Qt::ElideRight); |
37 | 265 |
|
266 |
//Set conference bubble expanded if no other |
|
267 |
//bubbles (like waiting bubble). |
|
268 |
m_bubbleManager.setExpandedConferenceCallHeader( |
|
269 |
(1==bubbles().size())); |
|
270 |
||
271 |
m_bubbleManager.endChanges(); |
|
272 |
} |
|
273 |
||
274 |
return bubble; |
|
275 |
} |
|
276 |
||
277 |
void PhoneBubbleWrapper::setConferenceCallId(int callId) |
|
278 |
{ |
|
279 |
if ( false == m_conferenceList.contains(callId) ) { |
|
280 |
m_conferenceList.append(callId); |
|
281 |
} |
|
282 |
} |
|
283 |
||
284 |
void PhoneBubbleWrapper::removeConferenceCallId(int callId) |
|
285 |
{ |
|
286 |
if ( m_conferenceList.contains(callId) ) { |
|
287 |
m_conferenceList.removeOne(callId); |
|
288 |
} |
|
289 |
} |
|
290 |
||
291 |
bool PhoneBubbleWrapper::conferenceCallId(int callId) const |
|
292 |
{ |
|
293 |
return m_conferenceList.contains(callId); |
|
294 |
} |
|
295 |
||
296 |
void PhoneBubbleWrapper::removeCallFromConference(int callId) |
|
297 |
{ |
|
298 |
if (m_conferenceList.contains(callId)) { |
|
299 |
m_bubbleManager.startChanges(); |
|
300 |
if(1<m_conferenceList.size()) { |
|
301 |
m_bubbleManager.removeRowFromConference(m_bubbles.value(callId)); |
|
302 |
m_conferenceList.removeOne(callId); |
|
303 |
} |
|
304 |
else { |
|
305 |
m_bubbleManager.removeConference(); |
|
306 |
||
307 |
if (m_bubbles.contains(KConferenceCallId)) { |
|
308 |
m_bubbles.remove(KConferenceCallId); |
|
309 |
} |
|
310 |
m_conferenceList.clear(); |
|
311 |
} |
|
312 |
||
313 |
m_bubbleManager.endChanges(); |
|
314 |
} |
|
315 |
} |
|
316 |
||
317 |
QList<int> PhoneBubbleWrapper::conferenceCallList() const |
|
318 |
{ |
|
319 |
return m_conferenceList; |
|
320 |
} |
|
321 |
||
322 |
void PhoneBubbleWrapper::removeConferenceBubble() |
|
323 |
{ |
|
324 |
if (0 < m_conferenceList.size()) { |
|
325 |
m_bubbleManager.removeConference(); |
|
326 |
m_bubbleManager.setExpandedConferenceCallHeader(false); |
|
327 |
||
328 |
if (m_bubbles.contains(KConferenceCallId)) { |
|
329 |
m_bubbles.remove(KConferenceCallId); |
|
330 |
} |
|
331 |
m_conferenceList.clear(); |
|
332 |
} |
|
333 |
} |
|
334 |
||
335 |
int PhoneBubbleWrapper::callIdByBubbleId(int bubbleId) |
|
336 |
{ |
|
337 |
return m_bubbles.key(bubbleId, -1); |
|
338 |
} |
|
339 |
||
340 |
void PhoneBubbleWrapper::addToConferenceBubble() |
|
341 |
{ |
|
342 |
if (m_conferenceList.size()) { |
|
343 |
int callId = callIdForConference(); |
|
344 |
if (-1 != callId && |
|
345 |
false == m_conferenceList.contains(callId)) { |
|
346 |
m_bubbleManager.startChanges(); |
|
347 |
setConferenceCallId(callId); |
|
348 |
m_bubbleManager.addRowToConference(bubbleId(callId)); |
|
349 |
m_bubbleManager.endChanges(); |
|
350 |
} |
|
351 |
} |
|
352 |
} |
|
353 |
||
354 |
int PhoneBubbleWrapper::callIdForConference() |
|
355 |
{ |
|
356 |
int callId = -1; |
|
357 |
QMap<int, int> bubblelist = bubbles(); |
|
358 |
for (int i=0; i<bubblelist.size() && callId == -1; ++i) { |
|
359 |
if (KConferenceCallId != bubblelist.keys().at(i)) { |
|
360 |
if ( bubblelist.size() > 2 ) { |
|
361 |
if (EPEStateRinging != |
|
362 |
m_callStates.value(bubblelist.keys().at(i))) { |
|
363 |
callId = bubblelist.keys().at(i); |
|
364 |
} |
|
365 |
} else { |
|
366 |
callId = bubblelist.keys().at(i); |
|
367 |
} |
|
368 |
} |
|
369 |
} |
|
370 |
||
371 |
return callId; |
|
372 |
} |
|
373 |
||
374 |
bool PhoneBubbleWrapper::getCallIdsForConference(int &first, int &second) |
|
375 |
{ |
|
376 |
first = -1; |
|
377 |
second = -1; |
|
378 |
||
379 |
if (2==m_bubbles.values().size()) { |
|
380 |
first = m_bubbles.keys().first(); |
|
381 |
second = m_bubbles.keys().at(1); |
|
382 |
} else if (2<=m_bubbles.values().size()) { |
|
383 |
for (int i=0;i<m_callStates.values().size();++i) { |
|
384 |
if ( m_callStates.values().at(i) != EPEStateRinging ) { |
|
385 |
if (first==-1) { |
|
386 |
first = m_callStates.keys().at(i); |
|
387 |
} else { |
|
388 |
second = m_callStates.keys().at(i); |
|
389 |
break; |
|
390 |
} |
|
391 |
} |
|
392 |
} // For |
|
393 |
} |
|
394 |
||
395 |
return (first!=-1 && second!=-1); |
|
396 |
} |
|
397 |
||
398 |
void PhoneBubbleWrapper::setServiceId(int callId, int serviceId) |
|
399 |
{ |
|
400 |
m_services[callId] = serviceId; |
|
401 |
} |
|
402 |
||
403 |
int PhoneBubbleWrapper::serviceIdByCallId(int callId) const |
|
404 |
{ |
|
405 |
return m_services.value(callId, -1); |
|
406 |
} |
|
407 |
||
408 |
QMap<int, int> PhoneBubbleWrapper::serviceIds() const |
|
409 |
{ |
|
410 |
return m_services; |
|
411 |
} |
|
412 |