|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QtGui> |
|
19 #include <QDebug> |
|
20 #include <hbaction.h> |
|
21 #include <hbtoolbar.h> |
|
22 #include <bubblemanager2.h> |
|
23 #include <hbmenu.h> |
|
24 #include <hbmainwindow.h> |
|
25 #include "bubbletestview.h" |
|
26 #include <hbeffect.h> |
|
27 |
|
28 BubbleTestView::BubbleTestView(HbMainWindow& window, QGraphicsItem *parent) : |
|
29 HbView (parent), mMainWindow(window), mMuted(0), mConfBubbleId(-1), |
|
30 mProvideJoin(false) |
|
31 { |
|
32 setFlags (QGraphicsItem::ItemIsFocusable); |
|
33 setFocusPolicy (Qt::StrongFocus); |
|
34 setTitle("BubbleTest2"); |
|
35 |
|
36 // the widget under the test |
|
37 mBubbleManager = new BubbleManager (this); |
|
38 setWidget(mBubbleManager); |
|
39 |
|
40 // init toolbar |
|
41 createToolBarActions(); |
|
42 //toolBar()->setOrientation(mMainWindow.orientation()); |
|
43 connect( &mMainWindow,SIGNAL(orientationChanged(Qt::Orientation)), |
|
44 this,SLOT(handleOrientationChange(Qt::Orientation))); |
|
45 |
|
46 // init menu |
|
47 createMenuActions(); |
|
48 |
|
49 // create actions for push buttons |
|
50 createBubbleActions(); |
|
51 |
|
52 // disable toolbar effects |
|
53 HbEffect::disable(toolBar()); |
|
54 } |
|
55 |
|
56 BubbleTestView::~BubbleTestView() |
|
57 { |
|
58 toolBar()->clearActions(); |
|
59 } |
|
60 |
|
61 void BubbleTestView::keyPressEvent(QKeyEvent *event) |
|
62 { |
|
63 switch( event->key() ) |
|
64 { |
|
65 case '1': // create incoming call |
|
66 { |
|
67 if ( mEmergencyCall->isChecked() ) { |
|
68 return; // not supported |
|
69 } |
|
70 |
|
71 if ( mCalls.count() == 0 ) { |
|
72 bubbleManager().startChanges(); |
|
73 int bubbleId = bubbleManager().createCallHeader(); |
|
74 setBubbleData(bubbleId, BubbleManager::Incoming); |
|
75 setBubbleActions(bubbleId, BubbleManager::Incoming); |
|
76 bubbleManager().endChanges(); |
|
77 |
|
78 // store this call |
|
79 TestCall call; |
|
80 call.bubbleId = bubbleId; |
|
81 call.callState = BubbleManager::Incoming; |
|
82 mCalls.append( call ); |
|
83 |
|
84 updateToolBarActions(); |
|
85 |
|
86 } else if ( !initializingCallExists() ) { |
|
87 // waiting call |
|
88 bubbleManager().startChanges(); |
|
89 int bubbleId = bubbleManager().createCallHeader(); |
|
90 setBubbleData(bubbleId, BubbleManager::Waiting); |
|
91 setBubbleActions( bubbleId, BubbleManager::Waiting ); |
|
92 bubbleManager().setExpandedConferenceCallHeader(false); |
|
93 bubbleManager().endChanges(); |
|
94 |
|
95 // store this call |
|
96 TestCall call; |
|
97 call.bubbleId = bubbleId; |
|
98 call.callState = BubbleManager::Waiting; |
|
99 mCalls.append( call ); |
|
100 |
|
101 setExpandActions(); |
|
102 updateToolBarActions(); |
|
103 } |
|
104 break; |
|
105 } |
|
106 |
|
107 case '2': // create outgoing call |
|
108 { |
|
109 if ( !initializingCallExists() && (callCount()<3) ) { |
|
110 bubbleManager().startChanges(); |
|
111 int bubbleId = bubbleManager().createCallHeader(); |
|
112 setBubbleData(bubbleId, BubbleManager::Outgoing); |
|
113 setBubbleActions( bubbleId, BubbleManager::Outgoing ); |
|
114 bubbleManager().endChanges(); |
|
115 |
|
116 // store this call |
|
117 TestCall call; |
|
118 call.bubbleId = bubbleId; |
|
119 call.callState = BubbleManager::Outgoing; |
|
120 mCalls.append( call ); |
|
121 |
|
122 bubbleManager().setBubbleSelectionDisabled(false); |
|
123 updateToolBarActions(); |
|
124 } |
|
125 break; |
|
126 } |
|
127 |
|
128 case '3': // connect |
|
129 { |
|
130 int i,j; |
|
131 |
|
132 if (callIndexByState(BubbleManagerIF::Outgoing, i)) { |
|
133 // outgoing to alerting |
|
134 bubbleManager().startChanges(); |
|
135 setBubbleData(mCalls[i].bubbleId, BubbleManager::Alerting); |
|
136 bubbleManager().endChanges(); |
|
137 mCalls[i].callState = BubbleManager::Alerting; |
|
138 return; |
|
139 } |
|
140 |
|
141 if (callCount()==3) { |
|
142 // replace active call |
|
143 bubbleManager().startChanges(); |
|
144 Q_ASSERT(callIndexByState(BubbleManagerIF::Active, j)); |
|
145 bubbleManager().removeCallHeader(mCalls[j].bubbleId); |
|
146 mCalls.removeAt(j); |
|
147 Q_ASSERT(callIndexByState(BubbleManagerIF::Waiting, i)); |
|
148 setBubbleData(mCalls[i].bubbleId, BubbleManager::Active); |
|
149 setBubbleActions(mCalls[i].bubbleId, BubbleManager::Active); |
|
150 bubbleManager().endChanges(); |
|
151 mCalls[i].callState = BubbleManager::Active; |
|
152 setExpandActions(); |
|
153 updateToolBarActions(); |
|
154 bubbleManager().setBubbleSelectionDisabled(false); |
|
155 } else if (callIndexByState(BubbleManagerIF::Incoming, i)|| |
|
156 callIndexByState(BubbleManagerIF::Alerting, i)|| |
|
157 callIndexByState(BubbleManagerIF::Waiting, i)) { |
|
158 bubbleManager().startChanges(); |
|
159 setBubbleData(mCalls[i].bubbleId, BubbleManager::Active); |
|
160 mProvideJoin = true; // bit hackish |
|
161 setBubbleActions(mCalls[i].bubbleId, BubbleManager::Active); |
|
162 mProvideJoin = false; |
|
163 if (callIndexByState(BubbleManagerIF::Active, j)) { |
|
164 setBubbleData(mCalls[j].bubbleId, BubbleManager::OnHold); |
|
165 setBubbleActions(mCalls[j].bubbleId, BubbleManager::OnHold); |
|
166 mCalls[j].callState = BubbleManager::OnHold; |
|
167 } |
|
168 bubbleManager().endChanges(); |
|
169 mCalls[i].callState = BubbleManager::Active; |
|
170 setExpandActions(); |
|
171 updateToolBarActions(); |
|
172 bubbleManager().setBubbleSelectionDisabled(false); |
|
173 } |
|
174 break; |
|
175 } |
|
176 |
|
177 case '4': // hold |
|
178 { |
|
179 int i,j; |
|
180 |
|
181 if (bubbleManager().isConferenceExpanded()) { |
|
182 toggleHoldConference(); |
|
183 } else if (callCount()==1) { |
|
184 // toggle hold |
|
185 bubbleManager().startChanges(); |
|
186 if (callIndexByState(BubbleManagerIF::Active, i)|| |
|
187 callIndexByState(BubbleManagerIF::OnHold, i)) { |
|
188 BubbleManagerIF::PhoneCallState state = |
|
189 mCalls[i].callState == BubbleManagerIF::Active ? |
|
190 BubbleManagerIF::OnHold : BubbleManagerIF::Active; |
|
191 |
|
192 setBubbleData(mCalls[i].bubbleId, state); |
|
193 setBubbleActions(mCalls[i].bubbleId, state ); |
|
194 mCalls[i].callState=state; |
|
195 } |
|
196 bubbleManager().endChanges(); |
|
197 updateToolBarActions(); |
|
198 } else if (callIndexByState(BubbleManagerIF::Active, i)) { |
|
199 // swap calls |
|
200 bubbleManager().startChanges(); |
|
201 if (callIndexByState(BubbleManagerIF::OnHold, j)) { |
|
202 setBubbleData(mCalls[j].bubbleId, BubbleManager::Active); |
|
203 setBubbleActions(mCalls[j].bubbleId, BubbleManager::Active ); |
|
204 mCalls[j].callState=BubbleManager::Active; |
|
205 } |
|
206 setBubbleData(mCalls[i].bubbleId, BubbleManager::OnHold); |
|
207 setBubbleActions(mCalls[i].bubbleId, BubbleManager::OnHold ); |
|
208 mCalls[i].callState=BubbleManager::OnHold; |
|
209 if (conferenceCallExists()) { |
|
210 bubbleManager().setExpandedConferenceCallHeader( |
|
211 bubbleIdByState(BubbleManager::Active)==mConfBubbleId); |
|
212 } |
|
213 bubbleManager().endChanges(); |
|
214 setExpandActions(); |
|
215 updateToolBarActions(); |
|
216 } else if (callIndexByState(BubbleManagerIF::Waiting, i)) { |
|
217 // activate held call |
|
218 bubbleManager().startChanges(); |
|
219 if (callIndexByState(BubbleManagerIF::OnHold, j)) { |
|
220 setBubbleData(mCalls[j].bubbleId, BubbleManager::Active); |
|
221 setBubbleActions(mCalls[j].bubbleId, BubbleManager::Active ); |
|
222 mCalls[j].callState=BubbleManager::Active; |
|
223 } |
|
224 bubbleManager().endChanges(); |
|
225 setExpandActions(); |
|
226 updateToolBarActions(); |
|
227 } |
|
228 break; |
|
229 } |
|
230 |
|
231 case '5': // disconnect |
|
232 { |
|
233 int i,j; |
|
234 |
|
235 if (callIndexByState(BubbleManagerIF::Disconnected, i)) { |
|
236 bubbleManager().startChanges(); |
|
237 bubbleManager().removeCallHeader(mCalls[i].bubbleId); |
|
238 // remove call |
|
239 mCalls.removeAt(i); |
|
240 |
|
241 if (mMuted) { |
|
242 setMuted(); // unmute |
|
243 } |
|
244 |
|
245 bool expand = true; |
|
246 QListIterator<TestCall> calls(mCalls); |
|
247 while(calls.hasNext()) { |
|
248 TestCall call = calls.next(); |
|
249 if (!call.isConf && !call.isInConf) { |
|
250 expand = false; |
|
251 } |
|
252 } |
|
253 bubbleManager().setExpandedConferenceCallHeader(expand); |
|
254 bubbleManager().endChanges(); |
|
255 |
|
256 updateToolBarActions(); |
|
257 return; |
|
258 } |
|
259 |
|
260 if (callCount()) { |
|
261 int expanded = bubbleManager().expandedBubble(); |
|
262 callIndexByBubbleId(expanded,i); |
|
263 bubbleManager().startChanges(); |
|
264 |
|
265 if (mCalls.at(i).isConf) { |
|
266 bubbleManager().removeConference(); |
|
267 mConfBubbleId = -1; |
|
268 mCalls.removeAt(i); |
|
269 |
|
270 QMutableListIterator<TestCall> calls(mCalls); |
|
271 j=0; |
|
272 while(calls.hasNext()) { |
|
273 if (mCalls[j].isInConf) { |
|
274 bubbleManager().removeCallHeader(mCalls[j].bubbleId); |
|
275 mCalls.removeAt(j); |
|
276 } else { |
|
277 j++; |
|
278 } |
|
279 calls.next(); |
|
280 } |
|
281 } else { |
|
282 setBubbleData(mCalls[i].bubbleId, BubbleManager::Disconnected); |
|
283 setBubbleActions(mCalls[i].bubbleId, BubbleManager::Disconnected); |
|
284 mCalls[i].callState=BubbleManager::Disconnected; |
|
285 } |
|
286 bubbleManager().endChanges(); |
|
287 updateToolBarActions(); |
|
288 } |
|
289 break; |
|
290 } |
|
291 |
|
292 case '7': // create/join conference |
|
293 { |
|
294 int activeCallId = bubbleIdByState(BubbleManagerIF::Active); |
|
295 int heldCallId = bubbleIdByState(BubbleManagerIF::OnHold); |
|
296 int i; |
|
297 |
|
298 if (conferenceCallExists()&&(activeCallId!=-1)) { |
|
299 int j; |
|
300 callIndexByBubbleId(mConfBubbleId,j); |
|
301 callIndexByBubbleId(activeCallId,i); |
|
302 mCalls[i].isInConf = true; |
|
303 mCalls[i].callState = BubbleManagerIF::Active; |
|
304 mCalls[j].callState = BubbleManagerIF::Active; |
|
305 bubbleManager().startChanges(); |
|
306 bubbleManager().addRowToConference(activeCallId); |
|
307 bubbleManager().setExpandedConferenceCallHeader(true); |
|
308 bubbleManager().setState(mConfBubbleId,BubbleManagerIF::Active); |
|
309 setBubbleActions(mConfBubbleId,BubbleManagerIF::Active); |
|
310 bubbleManager().endChanges(); |
|
311 } else if (activeCallId!=-1 && heldCallId!=-1) { |
|
312 bubbleManager().startChanges(); |
|
313 mConfBubbleId = bubbleManager().createConference(heldCallId, activeCallId); |
|
314 bubbleManager().setExpandedConferenceCallHeader(true); |
|
315 bubbleManager().setState(mConfBubbleId,BubbleManagerIF::Active); |
|
316 bubbleManager().setCli(mConfBubbleId,"Conference call",Qt::ElideRight); |
|
317 if (mCallTimer->isChecked()) { |
|
318 bubbleManager().setCallTime( mConfBubbleId, "00:00:00" ); |
|
319 } |
|
320 bubbleManager().addAction(mConfBubbleId, mMute); |
|
321 bubbleManager().addAction(mConfBubbleId, mEndConference); |
|
322 bubbleManager().clearParticipantListActions(); |
|
323 bubbleManager().addParticipantListAction(mPrivate); |
|
324 bubbleManager().addParticipantListAction(mDrop); |
|
325 bubbleManager().setState(heldCallId,BubbleManagerIF::Active); |
|
326 bubbleManager().setCallFlag(mConfBubbleId, BubbleManager::NoCiphering, |
|
327 mCipheringOff->isChecked()); |
|
328 bubbleManager().endChanges(); |
|
329 |
|
330 callIndexByBubbleId(activeCallId,i); |
|
331 mCalls[i].isInConf = true; |
|
332 mCalls[i].callState = BubbleManagerIF::Active; |
|
333 callIndexByBubbleId(heldCallId,i); |
|
334 mCalls[i].isInConf = true; |
|
335 mCalls[i].callState = BubbleManagerIF::Active; |
|
336 |
|
337 // store the call |
|
338 TestCall call; |
|
339 call.bubbleId = mConfBubbleId; |
|
340 call.callState = BubbleManagerIF::Active; |
|
341 call.isConf = true; |
|
342 call.isInConf = false; |
|
343 mCalls.append(call); |
|
344 } |
|
345 break; |
|
346 } |
|
347 |
|
348 case '9': // conference shortcut |
|
349 { |
|
350 conferenceWizard(); |
|
351 break; |
|
352 } |
|
353 |
|
354 case '0': // updates |
|
355 case Qt::Key_Space: // updates |
|
356 { |
|
357 if (mCallTimer->isChecked()) { |
|
358 foreach (TestCall call, mCalls) { |
|
359 if ( call.callState == BubbleManager::Active || |
|
360 call.callState == BubbleManager::OnHold ) { |
|
361 bubbleManager().updateCallTime(call.bubbleId,"00:00:01"); |
|
362 } |
|
363 } |
|
364 } |
|
365 } |
|
366 |
|
367 default: |
|
368 break; |
|
369 } |
|
370 } |
|
371 |
|
372 bool BubbleTestView::initializingCallExists() const |
|
373 { |
|
374 bool result = false; |
|
375 foreach(TestCall call, mCalls) { |
|
376 if (call.callState>=BubbleManagerIF::Incoming) { |
|
377 result = true; |
|
378 break; |
|
379 } |
|
380 } |
|
381 |
|
382 return result; |
|
383 } |
|
384 |
|
385 bool BubbleTestView::conferenceCallExists() const |
|
386 { |
|
387 bool result = false; |
|
388 QListIterator<TestCall> i(mCalls); |
|
389 while (i.hasNext()) { |
|
390 if (i.next().isConf) { |
|
391 result = true; |
|
392 break; |
|
393 } |
|
394 } |
|
395 return result; |
|
396 } |
|
397 |
|
398 int BubbleTestView::callCount() const |
|
399 { |
|
400 int count = 0; |
|
401 foreach(TestCall call, mCalls) { |
|
402 if (!call.isInConf) { |
|
403 count++; |
|
404 } |
|
405 } |
|
406 |
|
407 return count; |
|
408 } |
|
409 |
|
410 bool BubbleTestView::callIndexByState( |
|
411 BubbleManagerIF::PhoneCallState state, int& index) |
|
412 { |
|
413 bool result = false; |
|
414 int i = 0; |
|
415 foreach(TestCall call, mCalls) { |
|
416 if (call.callState==state && !call.isInConf) { |
|
417 result = true; |
|
418 index = i; |
|
419 break; |
|
420 } |
|
421 i++; |
|
422 } |
|
423 |
|
424 return result; |
|
425 } |
|
426 |
|
427 bool BubbleTestView::callIndexByBubbleId(int bubbleId, int& index) |
|
428 { |
|
429 bool result = false; |
|
430 int i = 0; |
|
431 foreach(TestCall call, mCalls) { |
|
432 if (call.bubbleId==bubbleId) { |
|
433 result = true; |
|
434 index = i; |
|
435 break; |
|
436 } |
|
437 i++; |
|
438 } |
|
439 |
|
440 return result; |
|
441 } |
|
442 |
|
443 BubbleManagerIF& BubbleTestView::bubbleManager() |
|
444 { |
|
445 return *mBubbleManager; |
|
446 } |
|
447 |
|
448 void BubbleTestView::setBubbleData(int bubble, BubbleManagerIF::PhoneCallState state) |
|
449 { |
|
450 bubbleManager().setState(bubble, state); |
|
451 |
|
452 switch (state) { |
|
453 case BubbleManager::Incoming: |
|
454 { |
|
455 if ( mContactName->isChecked() ) { |
|
456 bubbleManager().setCli(bubble, "Gloria Andersson", Qt::ElideRight); |
|
457 bubbleManager().setSecondaryCli( bubble, "+35850123456789" ); |
|
458 } else { |
|
459 bubbleManager().setCli(bubble, "+35850123456789", Qt::ElideLeft); |
|
460 } |
|
461 |
|
462 setCallObject(bubble, ":resources/contactpic.jpg"); |
|
463 bubbleManager().setNumberType(bubble, BubbleManager::Mobile); |
|
464 bubbleManager().setCallFlag(bubble, BubbleManager::Diverted, mCallDivert->isChecked()); |
|
465 bubbleManager().setCallFlag(bubble, BubbleManager::NoCiphering, mCipheringOff->isChecked()); |
|
466 bubbleManager().setLabel(bubble, "calling", Qt::ElideRight); |
|
467 break; |
|
468 } |
|
469 |
|
470 case BubbleManager::Waiting: |
|
471 { |
|
472 if ( mContactName->isChecked() ) { |
|
473 if (callCount()==2) { |
|
474 bubbleManager().setCli(bubble, "Mary Poppins", Qt::ElideRight); |
|
475 bubbleManager().setSecondaryCli(bubble, "+35840987654321"); |
|
476 } else { |
|
477 bubbleManager().setCli(bubble, "John Doe", Qt::ElideRight); |
|
478 bubbleManager().setSecondaryCli(bubble, "+35840987654321"); |
|
479 } |
|
480 } else { |
|
481 if (callCount()==2) { |
|
482 bubbleManager().setCli(bubble, "+35850232323232", Qt::ElideLeft); |
|
483 } else { |
|
484 bubbleManager().setCli(bubble, "+35840987654321", Qt::ElideLeft); |
|
485 } |
|
486 |
|
487 } |
|
488 setCallObject(bubble, ":resources/contactpic3.png"); |
|
489 bubbleManager().setNumberType(bubble, BubbleManager::Mobile); |
|
490 bubbleManager().setCallFlag(bubble, BubbleManager::Diverted, mCallDivert->isChecked()); |
|
491 bubbleManager().setCallFlag(bubble, BubbleManager::NoCiphering, mCipheringOff->isChecked()); |
|
492 bubbleManager().setLabel(bubble, "waiting", Qt::ElideRight); |
|
493 break; |
|
494 } |
|
495 |
|
496 case BubbleManager::Outgoing: |
|
497 { |
|
498 bubbleManager().setCallFlag(bubble, BubbleManager::NoCiphering, mCipheringOff->isChecked()); |
|
499 |
|
500 if (mEmergencyCall->isChecked()) { |
|
501 bubbleManager().setCli( bubble, "emergency call", Qt::ElideRight ); |
|
502 bubbleManager().setLabel( bubble, "Attempting", Qt::ElideRight ); |
|
503 } else { |
|
504 if ( mContactName->isChecked() ) { |
|
505 bubbleManager().setCli( bubble, "Bart Simpson", Qt::ElideRight ); |
|
506 bubbleManager().setSecondaryCli( bubble, "+35890987654321" ); |
|
507 } else { |
|
508 bubbleManager().setCli( bubble, "+35890987654321", Qt::ElideRight ); |
|
509 } |
|
510 setCallObject(bubble, ":resources/contactpic2.jpg"); |
|
511 bubbleManager().setLabel( bubble, "Calling", Qt::ElideRight ); |
|
512 } |
|
513 break; |
|
514 } |
|
515 |
|
516 case BubbleManager::Alerting: |
|
517 { |
|
518 if ( mEmergencyCall->isChecked() ) { |
|
519 bubbleManager().setCli( bubble, "Emergency call", Qt::ElideRight ); |
|
520 } |
|
521 break; |
|
522 } |
|
523 |
|
524 case BubbleManager::Active: |
|
525 { |
|
526 if ( mCallTimer->isChecked() ) { |
|
527 bubbleManager().setCallTime( bubble, "00:00:00" ); |
|
528 } |
|
529 break; |
|
530 } |
|
531 |
|
532 case BubbleManager::OnHold: |
|
533 { |
|
534 bubbleManager().setLabel( bubble, "on hold", Qt::ElideRight ); |
|
535 break; |
|
536 } |
|
537 |
|
538 case BubbleManager::Disconnected: |
|
539 { |
|
540 bubbleManager().setLabel( bubble, "disconnected", Qt::ElideRight ); |
|
541 break; |
|
542 } |
|
543 |
|
544 default: |
|
545 { |
|
546 break; |
|
547 } |
|
548 } |
|
549 } |
|
550 |
|
551 void BubbleTestView::setCallObject(int bubble, const QString& filename) |
|
552 { |
|
553 if (mContactPicture->isChecked()) { |
|
554 bubbleManager().setCallObjectImage(bubble, filename); |
|
555 } else { |
|
556 bubbleManager().setCallObjectFromTheme(bubble); |
|
557 } |
|
558 } |
|
559 |
|
560 void BubbleTestView::setBubbleActions(int bubble, BubbleManagerIF::PhoneCallState state ) |
|
561 { |
|
562 if (bubble==mConfBubbleId) { |
|
563 bubbleManager().clearActions(bubble); |
|
564 bubbleManager().addAction(bubble, mMute); |
|
565 bubbleManager().addAction(bubble, mEndConference); |
|
566 return; |
|
567 } |
|
568 |
|
569 bubbleManager().clearActions(bubble); |
|
570 |
|
571 switch (state) { |
|
572 case BubbleManager::Incoming: |
|
573 case BubbleManager::Waiting: |
|
574 { |
|
575 if (callCount()==2) { |
|
576 bubbleManager().addAction( bubble, mReplace ); |
|
577 } else { |
|
578 bubbleManager().addAction( bubble, mAnswer ); |
|
579 bubbleManager().addAction( bubble, mReject ); |
|
580 } |
|
581 break; |
|
582 } |
|
583 case BubbleManager::Outgoing: |
|
584 case BubbleManager::Alerting: // flow through |
|
585 { |
|
586 bubbleManager().addAction( bubble, mMute ); |
|
587 bubbleManager().addAction( bubble, mEndCall ); |
|
588 break; |
|
589 } |
|
590 case BubbleManager::OnHold: |
|
591 { |
|
592 if (mMuted) { |
|
593 bubbleManager().addAction( bubble, mUnmute ); |
|
594 } else { |
|
595 bubbleManager().addAction( bubble, mMute ); |
|
596 } |
|
597 bubbleManager().addAction( bubble, mEndCall ); |
|
598 } |
|
599 break; |
|
600 default: // Active call |
|
601 { |
|
602 if (mMuted) { |
|
603 bubbleManager().addAction( bubble, mUnmute ); |
|
604 } else { |
|
605 bubbleManager().addAction( bubble, mMute ); |
|
606 } |
|
607 bubbleManager().addAction( bubble, mEndCall ); |
|
608 break; |
|
609 } |
|
610 } |
|
611 } |
|
612 |
|
613 void BubbleTestView::setExpandActions() |
|
614 { |
|
615 if (callCount() >= 2) { |
|
616 int i; |
|
617 int j; |
|
618 int heldBubble = -1; |
|
619 if (callIndexByState(BubbleManagerIF::Active,i) && |
|
620 callIndexByState(BubbleManagerIF::OnHold,j)) { |
|
621 heldBubble = mCalls[j].bubbleId; |
|
622 bubbleManager().setExpandAction(heldBubble, mSwap); |
|
623 } else if (callIndexByState(BubbleManagerIF::Waiting,i) && |
|
624 callIndexByState(BubbleManagerIF::OnHold,j)) { |
|
625 heldBubble = mCalls[j].bubbleId; |
|
626 bubbleManager().setExpandAction(heldBubble, mUnhold); |
|
627 } |
|
628 |
|
629 // for rest set update toolbar action |
|
630 QListIterator<TestCall> calls(mCalls); |
|
631 while (calls.hasNext()) { |
|
632 TestCall call = calls.next(); |
|
633 if (!call.isInConf && call.bubbleId!=heldBubble) { |
|
634 bubbleManager().setExpandAction(call.bubbleId, mUpdateUiControls); |
|
635 } |
|
636 } |
|
637 } |
|
638 } |
|
639 |
|
640 void BubbleTestView::answerCall() |
|
641 { |
|
642 QKeyEvent event( QEvent::KeyPress, '3', 0 ); |
|
643 keyPressEvent(&event); |
|
644 } |
|
645 |
|
646 void BubbleTestView::endCall() |
|
647 { |
|
648 QKeyEvent event( QEvent::KeyPress, '5', 0 ); |
|
649 keyPressEvent(&event); |
|
650 keyPressEvent(&event); |
|
651 } |
|
652 |
|
653 void BubbleTestView::endConferenceCall() |
|
654 { |
|
655 QKeyEvent event( QEvent::KeyPress, '5', 0 ); |
|
656 keyPressEvent(&event); |
|
657 } |
|
658 |
|
659 void BubbleTestView::rejectCall() |
|
660 { |
|
661 QKeyEvent event( QEvent::KeyPress, '5', 0 ); |
|
662 keyPressEvent(&event); |
|
663 keyPressEvent(&event); |
|
664 } |
|
665 |
|
666 void BubbleTestView::toggleHold() |
|
667 { |
|
668 if (callCount() > 1) { |
|
669 QTimer::singleShot(1000, this, SLOT(toggleHoldDelayed())); |
|
670 } else { |
|
671 QKeyEvent event( QEvent::KeyPress, '4', 0 ); |
|
672 keyPressEvent(&event); |
|
673 } |
|
674 } |
|
675 |
|
676 void BubbleTestView::toggleHoldDelayed() |
|
677 { |
|
678 QKeyEvent event( QEvent::KeyPress, '4', 0 ); |
|
679 keyPressEvent(&event); |
|
680 } |
|
681 |
|
682 void BubbleTestView::createIncomingCall() |
|
683 { |
|
684 QKeyEvent event( QEvent::KeyPress, '1', 0 ); |
|
685 keyPressEvent(&event); |
|
686 setFocus(); // hack because toolbar steals the focus |
|
687 } |
|
688 |
|
689 void BubbleTestView::createOutgoingCall() |
|
690 { |
|
691 QKeyEvent event( QEvent::KeyPress, '2', 0 ); |
|
692 keyPressEvent(&event); |
|
693 setFocus(); // hack because toolbar steals the focus |
|
694 } |
|
695 |
|
696 void BubbleTestView::setMuted() |
|
697 { |
|
698 mMuted = !mMuted; |
|
699 int bubble = bubbleManager().expandedBubble(); |
|
700 QListIterator<TestCall> calls(mCalls); |
|
701 while (calls.hasNext()) { |
|
702 TestCall call = calls.next(); |
|
703 if (call.bubbleId==bubble) { |
|
704 bubbleManager().startChanges(); |
|
705 setBubbleActions(bubble, (BubbleManagerIF::PhoneCallState)call.callState); |
|
706 bubbleManager().endChanges(); |
|
707 } |
|
708 } |
|
709 |
|
710 bubbleManager().setPhoneMuted( mMuted ); |
|
711 setFocus(); // hack because toolbar steals the focus |
|
712 } |
|
713 |
|
714 void BubbleTestView::joinToConference() |
|
715 { |
|
716 QKeyEvent event( QEvent::KeyPress, '7', 0 ); |
|
717 keyPressEvent(&event); |
|
718 } |
|
719 |
|
720 void BubbleTestView::handlePrivate() |
|
721 { |
|
722 int i; |
|
723 qDebug() << "Handle private"; |
|
724 int selection = bubbleManager().selectionIdInConference(); |
|
725 qDebug() << "bubble:" << selection; |
|
726 bubbleManager().startChanges(); |
|
727 if (bubbleManager().conferenceRowCount()>2) { |
|
728 bubbleManager().removeRowFromConference(selection); |
|
729 bubbleManager().setExpandedConferenceCallHeader(false); |
|
730 callIndexByBubbleId(selection,i); |
|
731 mCalls[i].isInConf = false; |
|
732 setBubbleActions(mCalls[i].bubbleId,BubbleManagerIF::Active); |
|
733 setBubbleData(mConfBubbleId,BubbleManagerIF::OnHold); |
|
734 setExpandActions(); |
|
735 } else { |
|
736 bubbleManager().removeConference(); |
|
737 callIndexByBubbleId(mConfBubbleId,i); |
|
738 mCalls.removeAt(i); |
|
739 mConfBubbleId = -1; |
|
740 callIndexByBubbleId(selection,i); |
|
741 int held = (i==0) ? 1 : 0; // ?? |
|
742 setBubbleActions(selection,BubbleManagerIF::Active); |
|
743 setBubbleData(selection,BubbleManagerIF::Active); |
|
744 setBubbleActions(held,BubbleManagerIF::OnHold); |
|
745 setBubbleData(held,BubbleManagerIF::OnHold); |
|
746 mCalls[i].isInConf = false; |
|
747 mCalls[i].callState = BubbleManagerIF::Active; |
|
748 int callId; |
|
749 callIndexByBubbleId(held, callId); |
|
750 mCalls[callId].callState = BubbleManagerIF::OnHold; |
|
751 mCalls[callId].isInConf = false; |
|
752 setExpandActions(); |
|
753 } |
|
754 bubbleManager().endChanges(); |
|
755 } |
|
756 |
|
757 void BubbleTestView::handleDrop() |
|
758 { |
|
759 int i; |
|
760 qDebug() << "Handle drop"; |
|
761 int selection = bubbleManager().selectionIdInConference(); |
|
762 qDebug() << "bubble:" << selection; |
|
763 bubbleManager().startChanges(); |
|
764 if (bubbleManager().conferenceRowCount()>2) { |
|
765 bubbleManager().removeRowFromConference(selection); |
|
766 bubbleManager().removeCallHeader(selection); |
|
767 callIndexByBubbleId(selection,i); |
|
768 mCalls.removeAt(i); |
|
769 } else { |
|
770 bubbleManager().removeConference(); |
|
771 callIndexByBubbleId(mConfBubbleId,i); |
|
772 mCalls.removeAt(i); |
|
773 mConfBubbleId = -1; |
|
774 bubbleManager().removeCallHeader(selection); |
|
775 callIndexByBubbleId(selection,i); |
|
776 mCalls.removeAt(i); |
|
777 mCalls[0].isInConf = false; |
|
778 setBubbleActions(mCalls[0].bubbleId,BubbleManagerIF::Active); |
|
779 setExpandActions(); |
|
780 } |
|
781 bubbleManager().endChanges(); |
|
782 } |
|
783 |
|
784 void BubbleTestView::replaceActiveCall() |
|
785 { |
|
786 QKeyEvent event( QEvent::KeyPress, '3', 0 ); |
|
787 keyPressEvent(&event); |
|
788 } |
|
789 |
|
790 void BubbleTestView::updateUiControls() |
|
791 { |
|
792 if (conferenceCallExists()) { |
|
793 bubbleManager().startChanges(); |
|
794 bubbleManager().setExpandedConferenceCallHeader( |
|
795 bubbleManager().expandedBubble()==mConfBubbleId ); |
|
796 bubbleManager().endChanges(); |
|
797 } |
|
798 |
|
799 updateToolBarActions(); |
|
800 } |
|
801 |
|
802 void BubbleTestView::createToolBarActions() |
|
803 { |
|
804 mCallIn = new HbAction("Call in", this); |
|
805 connect( mCallIn, SIGNAL(triggered()), this, SLOT(createIncomingCall()), Qt::QueuedConnection ); |
|
806 |
|
807 mCallOut = new HbAction("Call out", this); |
|
808 connect( mCallOut, SIGNAL(triggered()), this, SLOT(createOutgoingCall()), Qt::QueuedConnection ); |
|
809 |
|
810 mMute = new HbAction(HbIcon("qtg_mono_mic_mute"), "", this); |
|
811 connect( mMute, SIGNAL(triggered()), this, SLOT(setMuted()), Qt::QueuedConnection ); |
|
812 |
|
813 mUnmute = new HbAction(HbIcon("qtg_mono_mic_unmute"), "", this); |
|
814 connect( mUnmute, SIGNAL(triggered()), this, SLOT(setMuted()), Qt::QueuedConnection ); |
|
815 |
|
816 // not connected to anywhere |
|
817 mActivateLoudspeaker = new HbAction(HbIcon("qtg_mono_speaker"), "", this); |
|
818 connect( mActivateLoudspeaker, SIGNAL(triggered()), this, SLOT(createIncomingCall()), Qt::QueuedConnection ); |
|
819 mActivateHandset = new HbAction(HbIcon("qtg_mono_mobile"), "", this); |
|
820 mSendMessage = new HbAction(HbIcon("qtg_mono_send"), "", this); |
|
821 mSilence = new HbAction(HbIcon("qtg_mono_speaker_off"), "", this); |
|
822 mOpenDialer = new HbAction(HbIcon("qtg_mono_dialer"), "", this); |
|
823 mOpenContacts = new HbAction(HbIcon("qtg_mono_contacts"), "", this); |
|
824 |
|
825 updateToolBarActions(); |
|
826 } |
|
827 |
|
828 void BubbleTestView::createMenuActions() |
|
829 { |
|
830 // HbMenu* typeMenu = menu()->addMenu("Call type"); current submenu layout sucks |
|
831 menu()->addAction("Switch orientation",this,SLOT(switchOrientation())); |
|
832 mCallDivert = menu()->addAction("Diverted call"); |
|
833 mCallTimer = menu()->addAction("Call timer"); |
|
834 mContactName = menu()->addAction("Contact name"); |
|
835 mContactPicture = menu()->addAction("Contact picture"); |
|
836 mCipheringOff = menu()->addAction("Ciphering off"); |
|
837 mEmergencyCall = menu()->addAction( "Emergency call" ); |
|
838 HbAction* exit = menu()->addAction( "Exit" ); |
|
839 mCallDivert->setCheckable(true); |
|
840 mCallTimer->setCheckable(true); |
|
841 mContactPicture->setCheckable(true); |
|
842 mContactName->setCheckable(true); |
|
843 mCipheringOff->setCheckable(true); |
|
844 mEmergencyCall->setCheckable(true); |
|
845 connect( exit, SIGNAL(triggered()), qApp, SLOT(quit()) ); |
|
846 } |
|
847 |
|
848 void BubbleTestView::updateToolBarActions() |
|
849 { |
|
850 toolBar()->clearActions(); |
|
851 |
|
852 if (!mCalls.count()) { |
|
853 toolBar()->addAction(mCallIn); |
|
854 toolBar()->addAction(mCallOut); |
|
855 return; |
|
856 } |
|
857 |
|
858 int bubble = bubbleManager().expandedBubble(); |
|
859 int i; |
|
860 callIndexByBubbleId(bubble,i); |
|
861 int state = mCalls[i].callState; |
|
862 |
|
863 if ( state == BubbleManagerIF::Incoming || |
|
864 state == BubbleManagerIF::Waiting ) { |
|
865 toolBar()->addAction(mSendMessage); |
|
866 toolBar()->addAction(mSilence); |
|
867 } else { |
|
868 toolBar()->addAction(mActivateLoudspeaker); |
|
869 |
|
870 if (callCount()==1) { |
|
871 toolBar()->addAction(mHold); |
|
872 } else { |
|
873 toolBar()->addAction(mSwap); |
|
874 } |
|
875 |
|
876 if (callCount()==1) { |
|
877 toolBar()->addAction(mOpenContacts); |
|
878 } else { |
|
879 toolBar()->addAction(mJoin); |
|
880 } |
|
881 |
|
882 toolBar()->addAction(mOpenDialer); |
|
883 } |
|
884 } |
|
885 |
|
886 void BubbleTestView::createBubbleActions() |
|
887 { |
|
888 mAnswer = new HbAction( HbIcon("qtg_mono_call"),QString(), this); |
|
889 mAnswer->setSoftKeyRole(QAction::PositiveSoftKey); |
|
890 connect( mAnswer, SIGNAL( triggered() ), this, SLOT( answerCall() ) ); |
|
891 |
|
892 mReject= new HbAction( HbIcon("qtg_mono_reject_call"),QString(), this); |
|
893 mReject->setSoftKeyRole(QAction::NegativeSoftKey); |
|
894 connect( mReject, SIGNAL( triggered() ), this, SLOT( rejectCall() ) ); |
|
895 |
|
896 mHold = new HbAction( HbIcon("qtg_mono_hold_call"),QString(), this); |
|
897 connect( mHold, SIGNAL( triggered() ), this, SLOT( toggleHold() ) ); |
|
898 |
|
899 mUnhold = new HbAction( HbIcon("qtg_mono_call"),QString(), this); |
|
900 connect( mUnhold, SIGNAL( triggered() ), this, SLOT( toggleHold() ) ); |
|
901 |
|
902 mSwap = new HbAction( HbIcon("qtg_mono_hold_call"),QString(), this); |
|
903 connect( mSwap, SIGNAL( triggered() ), this, SLOT( toggleHold() ) ); |
|
904 |
|
905 mEndCall = new HbAction(HbIcon("qtg_mono_end_call"),QString(), this); |
|
906 mEndCall->setSoftKeyRole(QAction::NegativeSoftKey); |
|
907 connect( mEndCall, SIGNAL( triggered() ), this, SLOT( endCall() ) ); |
|
908 |
|
909 mEndConference = new HbAction(HbIcon("qtg_mono_end_call"),QString(), this); |
|
910 mEndConference->setSoftKeyRole(QAction::NegativeSoftKey); |
|
911 connect( mEndConference, SIGNAL( triggered() ), this, SLOT( endConferenceCall() ) ); |
|
912 |
|
913 mJoin = new HbAction(HbIcon("qtg_mono_join_call"),QString(), this); |
|
914 connect( mJoin, SIGNAL( triggered() ), this, SLOT(joinToConference()) ); |
|
915 |
|
916 mPrivate = new HbAction(HbIcon("qtg_mono_private_call"),QString(), this); |
|
917 connect( mPrivate, SIGNAL( triggered() ), this, SLOT(handlePrivate()) ); |
|
918 |
|
919 mDrop = new HbAction(HbIcon("qtg_mono_drop_call"),QString(), this); |
|
920 connect( mDrop, SIGNAL( triggered() ), this, SLOT(handleDrop()) ); |
|
921 |
|
922 mReplace = new HbAction(HbIcon("qtg_mono_replace_call"),QString(), this); |
|
923 connect( mReplace, SIGNAL( triggered() ), this, SLOT(replaceActiveCall()) ); |
|
924 |
|
925 mUpdateUiControls = new HbAction(QString(), this); |
|
926 connect( mUpdateUiControls, SIGNAL(triggered()), this, SLOT(updateUiControls()) ); |
|
927 } |
|
928 |
|
929 int BubbleTestView::bubbleIdByState(BubbleManagerIF::PhoneCallState state) |
|
930 { |
|
931 int bubbleId=-1; |
|
932 foreach(TestCall call, mCalls) { |
|
933 if ((call.callState==state) && !call.isInConf) { |
|
934 bubbleId = call.bubbleId; |
|
935 break; |
|
936 } |
|
937 } |
|
938 |
|
939 return bubbleId; |
|
940 } |
|
941 |
|
942 void BubbleTestView::conferenceWizard() { |
|
943 bubbleManager().startChanges(); |
|
944 |
|
945 for (int i=0; i<5; i++) { |
|
946 sendKeyEvent('1'); |
|
947 sendKeyEvent('3'); |
|
948 sendKeyEvent('7'); |
|
949 } |
|
950 |
|
951 bubbleManager().endChanges(); |
|
952 } |
|
953 |
|
954 void BubbleTestView::sendKeyEvent(int key) |
|
955 { |
|
956 QKeyEvent event( QEvent::KeyPress, key, 0 ); |
|
957 keyPressEvent(&event); |
|
958 } |
|
959 |
|
960 void BubbleTestView::switchOrientation() |
|
961 { |
|
962 if (mMainWindow.orientation()==Qt::Vertical) { |
|
963 mMainWindow.setOrientation(Qt::Horizontal); |
|
964 |
|
965 } else { |
|
966 mMainWindow.setOrientation(Qt::Vertical); |
|
967 } |
|
968 } |
|
969 |
|
970 void BubbleTestView::handleOrientationChange(Qt::Orientation orientation) |
|
971 { |
|
972 if (orientation==Qt::Horizontal) { |
|
973 toolBar()->setOrientation(Qt::Horizontal); |
|
974 } |
|
975 |
|
976 mBubbleManager->handleOrientationChange(orientation); |
|
977 } |
|
978 |
|
979 void BubbleTestView::toggleHoldConference() |
|
980 { |
|
981 int i; |
|
982 if (callIndexByBubbleId(mConfBubbleId, i) ) { |
|
983 BubbleManagerIF::PhoneCallState state = |
|
984 (mCalls[i].callState == BubbleManagerIF::Active) ? |
|
985 BubbleManagerIF::OnHold : BubbleManagerIF::Active; |
|
986 bubbleManager().startChanges(); |
|
987 setBubbleData(mCalls[i].bubbleId, state); |
|
988 setBubbleActions(mCalls[i].bubbleId, state ); |
|
989 qDebug() << "toggleHoldConference:" << state; |
|
990 mCalls[i].callState=state; |
|
991 bubbleManager().endChanges(); |
|
992 // update participants |
|
993 QTimer::singleShot(500, this, SLOT(toggleConferenceHoldDelayed())); |
|
994 } |
|
995 } |
|
996 |
|
997 void BubbleTestView::toggleConferenceHoldDelayed() |
|
998 { |
|
999 int i; |
|
1000 callIndexByBubbleId(mConfBubbleId, i); |
|
1001 BubbleManagerIF::PhoneCallState confState = |
|
1002 (BubbleManagerIF::PhoneCallState)mCalls[i].callState; |
|
1003 // qDebug() << "toggleConferenceHoldDelayed state:" << confState; |
|
1004 |
|
1005 QListIterator<TestCall> calls(mCalls); |
|
1006 int j=0; |
|
1007 while(calls.hasNext()) { |
|
1008 TestCall call = calls.next(); |
|
1009 // qDebug() << "toggleConferenceHoldDelayed callState:" << call.callState; |
|
1010 if (call.isInConf && call.callState!=confState) { |
|
1011 bubbleManager().startChanges(); |
|
1012 setBubbleData(call.bubbleId, confState); |
|
1013 setBubbleActions(call.bubbleId, confState); |
|
1014 mCalls[j].callState=confState; |
|
1015 bubbleManager().endChanges(); |
|
1016 // next |
|
1017 QTimer::singleShot(500, this, SLOT(toggleConferenceHoldDelayed())); |
|
1018 break; |
|
1019 } |
|
1020 j++; |
|
1021 } |
|
1022 } |
|
1023 |