125 } |
124 } |
126 |
125 |
127 return translatedActions; |
126 return translatedActions; |
128 } |
127 } |
129 |
128 |
|
129 QList<PhoneAction *> PhoneUiCommandController::toolBarActions( |
|
130 int resourceId, |
|
131 QMap<int,int> callStates, |
|
132 QMap<int,int> serviceIds, |
|
133 int serviceId, |
|
134 int callId) |
|
135 { |
|
136 QList<PhoneAction *> actions; |
|
137 |
|
138 //Set tool bar button flags |
|
139 setJoinFlag(callStates, serviceIds); |
|
140 setConferenceFlag(callStates.values()); |
|
141 setHoldFlag(callStates.value(callId)); |
|
142 setMultiCallFlag(callStates.values()); |
|
143 setOutgoingFlag(callStates.values()); |
|
144 |
|
145 //Get tool bar item list by resource id. |
|
146 QList<PhoneAction::ToolBarItem> commands = PhoneResourceAdapter::Instance()-> |
|
147 convertToToolBarCommandList(resourceId); |
|
148 |
|
149 if (serviceId != -1) { |
|
150 PhoneCommandExtensionWrapper *extension = commandExtension(serviceId); |
|
151 |
|
152 if (extension) { |
|
153 QList<XQTelUiCommandExtension::CallInfo> callInfo; |
|
154 extension->getCallInfoList( |
|
155 callInfo,callStates,serviceIds,callId); |
|
156 |
|
157 QList<XQTelUiCommandExtension::ToolBarCommand> toolBarCmdList; |
|
158 |
|
159 mapToExtensionToolBarItems(commands,toolBarCmdList); |
|
160 //Modify tool bar command list by extension |
|
161 extension->modifyToolBarCommandList(callInfo,toolBarCmdList); |
|
162 // Map tool bar item list back to the phone action tool bar item list. |
|
163 mapToPhoneActionToolBarItems(toolBarCmdList,commands); |
|
164 } |
|
165 } |
|
166 |
|
167 for ( int i=0; i < commands.count(); ++i) { |
|
168 PhoneAction *action = mapCommandToAction( |
|
169 commands.at(i).mCommandId, !commands.at(i).mEnabled); |
|
170 if (action) { |
|
171 actions.append(action); |
|
172 } |
|
173 } |
|
174 |
|
175 return actions; |
|
176 } |
|
177 |
130 QList<int> PhoneUiCommandController::menuCommands( |
178 QList<int> PhoneUiCommandController::menuCommands( |
131 QMap<int,int> callStates, QMap<int,int> serviceIds ) |
179 QMap<int,int> callStates, QMap<int,int> serviceIds ) const |
132 { |
180 { |
133 PHONE_DEBUG("PhoneMenuController::menuCommands"); |
181 PHONE_DEBUG("PhoneMenuController::menuCommands"); |
134 QList<int> commands; |
182 QList<int> commands; |
135 bool sameServices = areServicesSame(callStates,serviceIds); |
183 bool sameServices = areServicesSame(callStates,serviceIds); |
136 |
184 |
300 m_lastCommandExtension = 0; |
342 m_lastCommandExtension = 0; |
301 } |
343 } |
302 } |
344 } |
303 |
345 |
304 bool PhoneUiCommandController::areServicesSame( |
346 bool PhoneUiCommandController::areServicesSame( |
305 QMap<int,int> callStates, QMap<int,int> serviceIds) |
347 QMap<int,int> callStates, QMap<int,int> serviceIds) const |
306 { |
348 { |
307 bool ret(true); |
349 bool ret(true); |
308 int serviceId(-1); |
350 int serviceId(-1); |
309 for(int i=0;i<callStates.count()&&ret;++i) { |
351 for(int i=0;i<callStates.count()&&ret;++i) { |
310 if (-1==serviceId) { |
352 if (-1==serviceId) { |
311 serviceId = serviceIds.value(callStates.keys().at(i)); |
353 serviceId = serviceIds.value(callStates.keys().at(i)); |
312 } else if (serviceId!=serviceIds.value(callStates.keys().at(i))) { |
354 } else if (serviceId != serviceIds.value(callStates.keys().at(i))) { |
313 ret = false; |
355 ret = false; |
314 } |
356 } |
315 } |
357 } |
316 |
358 |
317 return ret; |
359 return ret; |
|
360 } |
|
361 |
|
362 void PhoneUiCommandController::setJoinFlag( |
|
363 QMap<int,int> callStates, QMap<int,int> serviceIds) const |
|
364 { |
|
365 bool disable(PhoneResourceAdapter::Instance()->buttonsController()-> |
|
366 getButtonFlags(PhoneUIQtButtonsController::FullConference)); |
|
367 |
|
368 if (!disable) { |
|
369 disable = !areServicesSame(callStates, serviceIds); |
|
370 } |
|
371 |
|
372 PhoneResourceAdapter::Instance()->buttonsController()-> |
|
373 setButtonFlags(PhoneUIQtButtonsController::DisableJoin, disable); |
|
374 } |
|
375 |
|
376 void PhoneUiCommandController::setHoldFlag(int callState) const |
|
377 { |
|
378 bool hold = (callState == EPEStateHeldConference || |
|
379 callState == EPEStateHeld ); |
|
380 |
|
381 PhoneResourceAdapter::Instance()->buttonsController()-> |
|
382 setButtonFlags(PhoneUIQtButtonsController::Hold,hold); |
|
383 } |
|
384 |
|
385 void PhoneUiCommandController::setOutgoingFlag( |
|
386 QList<int> callStates) const |
|
387 { |
|
388 bool outgoing(callStates.contains(EPEStateDialing) || |
|
389 callStates.contains(EPEStateConnecting)); |
|
390 |
|
391 PhoneResourceAdapter::Instance()->buttonsController()-> |
|
392 setButtonFlags(PhoneUIQtButtonsController::Outgoing, outgoing); |
|
393 } |
|
394 |
|
395 void PhoneUiCommandController::setConferenceFlag( |
|
396 QList<int> callStates) const |
|
397 { |
|
398 bool conference(callStates.contains(EPEStateConnectedConference) || |
|
399 callStates.contains(EPEStateHeldConference)); |
|
400 |
|
401 PhoneResourceAdapter::Instance()->buttonsController()-> |
|
402 setButtonFlags(PhoneUIQtButtonsController::Conference, conference); |
|
403 } |
|
404 |
|
405 void PhoneUiCommandController::setMultiCallFlag( |
|
406 QList<int> callStates) const |
|
407 { |
|
408 bool multicall(false); |
|
409 |
|
410 if (1<callStates.count()) { |
|
411 if (callStates.count() == 2 && callStates.contains(EPEStateRinging)) { |
|
412 multicall = false; |
|
413 } else { |
|
414 multicall = true; |
|
415 } |
|
416 } |
|
417 |
|
418 PhoneResourceAdapter::Instance()->buttonsController()-> |
|
419 setButtonFlags(PhoneUIQtButtonsController::MultiCall, multicall); |
|
420 } |
|
421 |
|
422 void PhoneUiCommandController::mapToExtensionToolBarItems( |
|
423 const QList<PhoneAction::ToolBarItem> &sourceList, |
|
424 QList<XQTelUiCommandExtension::ToolBarCommand> &toolBarCmdList) const |
|
425 { |
|
426 toolBarCmdList.clear(); |
|
427 |
|
428 for (int i=0;i<sourceList.count();++i) { |
|
429 XQTelUiCommandExtension::ToolBarCommand command; |
|
430 command.mCommandId = sourceList.at(i).mCommandId; |
|
431 command.mIsEnabled = sourceList.at(i).mEnabled; |
|
432 toolBarCmdList.append(command); |
|
433 } |
|
434 } |
|
435 |
|
436 void PhoneUiCommandController::mapToPhoneActionToolBarItems( |
|
437 const QList<XQTelUiCommandExtension::ToolBarCommand> &sourceList, |
|
438 QList<PhoneAction::ToolBarItem> &commandList) const |
|
439 { |
|
440 commandList.clear(); |
|
441 |
|
442 for (int i=0;i<sourceList.count();++i) { |
|
443 PhoneAction::ToolBarItem command( |
|
444 sourceList.at(i).mCommandId, |
|
445 sourceList.at(i).mIsEnabled); |
|
446 commandList.append(command); |
|
447 } |
318 } |
448 } |
319 |
449 |
320 QList<int> PhoneUiCommandController::buttonCommandList( |
450 QList<int> PhoneUiCommandController::buttonCommandList( |
321 int callState, |
451 int callState, |
322 bool emergencyCall, |
452 bool emergencyCall, |
323 bool sameServices, |
453 QList<int> callStates) const |
324 QList<int> callStates) |
|
325 { |
454 { |
326 QList<int> ret; |
455 QList<int> ret; |
327 |
456 |
328 switch( callState ) { |
457 switch( callState ) { |
329 case EPEStateIdle: |
458 case EPEStateIdle: |
345 } |
482 } |
346 } |
483 } |
347 break; |
484 break; |
348 |
485 |
349 case EPEStateConnected: |
486 case EPEStateConnected: |
350 case EPEStateConnectedConference: { |
487 case EPEStateConnectedConference: |
351 if (!emergencyCall) { |
|
352 if ( 1 == callStates.size() || |
|
353 (2 == callStates.size() && |
|
354 callStates.contains(EPEStateRinging)) ) { |
|
355 ret.append(PhoneInCallCmdHold); |
|
356 } else { |
|
357 |
|
358 if (EPEStateConnectedConference == callState) { |
|
359 ret.append(PhoneInCallCmdSwap); |
|
360 } else if (sameServices && |
|
361 false == PhoneResourceAdapter::Instance()->buttonsController()-> |
|
362 getButtonFlags(PhoneUIQtButtonsController::DisableJoin)) { |
|
363 if ( callStates.contains(EPEStateHeldConference) ) { |
|
364 ret.append(PhoneInCallCmdJoinToConference); |
|
365 } else { |
|
366 ret.append(PhoneInCallCmdCreateConference); |
|
367 } |
|
368 } |
|
369 } |
|
370 } |
|
371 |
|
372 ret.append(PhoneInCallCmdEndActive); |
|
373 } |
|
374 break; |
|
375 |
|
376 case EPEStateHeld: |
488 case EPEStateHeld: |
377 case EPEStateHeldConference: { |
489 case EPEStateHeldConference: { |
378 if (1 == callStates.size() || |
490 if (!emergencyCall) { |
379 (2 == callStates.size() && |
491 if (PhoneResourceAdapter::Instance()->buttonsController()-> |
380 callStates.contains(EPEStateRinging))) { |
492 getButtonFlags(PhoneUIQtButtonsController::Mute)) { |
381 |
493 ret.append(PhoneInCallCmdUnmute); |
382 ret.append(PhoneInCallCmdUnhold); |
494 } else { |
383 } else { |
495 ret.append(PhoneInCallCmdMute); |
384 if (EPEStateHeldConference == callState) { |
|
385 ret.append(PhoneInCallCmdSwap); |
|
386 } else if (sameServices && |
|
387 false == PhoneResourceAdapter::Instance()->buttonsController()-> |
|
388 getButtonFlags(PhoneUIQtButtonsController::DisableJoin)) { |
|
389 if ( callStates.contains(EPEStateConnectedConference)) { |
|
390 ret.append(PhoneInCallCmdJoinToConference); |
|
391 } else { |
|
392 ret.append(PhoneInCallCmdCreateConference); |
|
393 } |
|
394 } |
496 } |
395 } |
497 } |
396 |
498 |
397 ret.append(PhoneInCallCmdEndActive); |
499 ret.append(PhoneInCallCmdEndActive); |
398 } |
500 } |
406 } |
508 } |
407 |
509 |
408 return ret; |
510 return ret; |
409 } |
511 } |
410 |
512 |
411 PhoneAction *PhoneUiCommandController::mapCommandToAction(int command) |
513 PhoneAction *PhoneUiCommandController::mapCommandToAction( |
|
514 int command, bool disabled) const |
412 { |
515 { |
413 PhoneAction *action=0; |
516 PhoneAction *action=0; |
414 |
517 |
415 switch( command ) { |
518 switch( command ) { |
416 case PhoneInCallCmdJoinToConference: { |
519 case PhoneInCallCmdJoinToConference: { |
417 action = new PhoneAction; |
520 action = new PhoneAction; |
418 action->setIcon(HbIcon("qtg_mono_join_call")); |
521 action->setIcon(HbIcon("qtg_mono_join_call")); |
|
522 action->setDisabled(disabled); |
419 action->setCommand(EPhoneInCallCmdJoin); |
523 action->setCommand(EPhoneInCallCmdJoin); |
420 } |
524 } |
421 break; |
525 break; |
422 |
526 |
423 case PhoneInCallCmdCreateConference: { |
527 case PhoneInCallCmdCreateConference: { |
424 action = new PhoneAction; |
528 action = new PhoneAction; |
425 action->setIcon(HbIcon("qtg_mono_join_call")); |
529 action->setIcon(HbIcon("qtg_mono_join_call")); |
|
530 action->setDisabled(disabled); |
426 action->setCommand(EPhoneInCallCmdCreateConference); |
531 action->setCommand(EPhoneInCallCmdCreateConference); |
427 } |
532 } |
428 break; |
533 break; |
429 |
534 |
430 case PhoneInCallCmdAnswer: { |
535 case PhoneInCallCmdAnswer: { |
431 action = new PhoneAction; |
536 action = new PhoneAction; |
432 action->setIcon(HbIcon("qtg_mono_call")); |
537 action->setIcon(HbIcon("qtg_mono_call")); |
433 action->setCommand (EPhoneCallComingCmdAnswer); |
538 action->setDisabled(disabled); |
|
539 action->setCommand (EPhoneCallComingCmdAnswer); |
434 action->setActionRole(PhoneAction::Accept); |
540 action->setActionRole(PhoneAction::Accept); |
435 } |
541 } |
436 break; |
542 break; |
437 |
543 |
438 case PhoneInCallCmdReject: { |
544 case PhoneInCallCmdReject: { |
439 action = new PhoneAction; |
545 action = new PhoneAction; |
440 action->setIcon(HbIcon("qtg_mono_reject_call")); |
546 action->setIcon(HbIcon("qtg_mono_reject_call")); |
|
547 action->setDisabled(disabled); |
441 action->setCommand (EPhoneCallComingCmdReject); |
548 action->setCommand (EPhoneCallComingCmdReject); |
442 action->setActionRole(PhoneAction::Decline); |
549 action->setActionRole(PhoneAction::Decline); |
443 } |
550 } |
444 break; |
551 break; |
445 |
552 |
446 case PhoneInCallCmdHold: { |
553 case PhoneInCallCmdHold: { |
447 action = new PhoneAction; |
554 action = new PhoneAction; |
448 action->setIcon(HbIcon("qtg_mono_hold_call")); |
555 action->setIcon(HbIcon("qtg_mono_hold_call")); |
|
556 action->setDisabled(disabled); |
449 action->setCommand(EPhoneInCallCmdHold); |
557 action->setCommand(EPhoneInCallCmdHold); |
450 } |
558 } |
451 break; |
559 break; |
452 |
560 |
453 case PhoneInCallCmdUnhold: { |
561 case PhoneInCallCmdUnhold: { |
454 action = new PhoneAction; |
562 action = new PhoneAction; |
455 action->setIcon(HbIcon("qtg_mono_call")); |
563 action->setIcon(HbIcon("qtg_mono_call")); |
|
564 action->setDisabled(disabled); |
456 action->setCommand(EPhoneInCallCmdUnhold); |
565 action->setCommand(EPhoneInCallCmdUnhold); |
457 } |
566 } |
458 break; |
567 break; |
459 |
568 |
460 case PhoneInCallCmdEndActive: { |
569 case PhoneInCallCmdEndActive: { |
461 action = new PhoneAction; |
570 action = new PhoneAction; |
462 action->setIcon(HbIcon("qtg_mono_end_call")); |
571 action->setIcon(HbIcon("qtg_mono_end_call")); |
|
572 action->setDisabled(disabled); |
463 action->setCommand(EPhoneInCallCmdEndThisActiveCall); |
573 action->setCommand(EPhoneInCallCmdEndThisActiveCall); |
464 action->setActionRole(PhoneAction::Decline); |
574 action->setActionRole(PhoneAction::Decline); |
465 } |
575 } |
466 break; |
576 break; |
467 |
577 |
468 case PhoneInCallCmdEndOutgoingCall: { |
578 case PhoneInCallCmdEndOutgoingCall: { |
469 action = new PhoneAction; |
579 action = new PhoneAction; |
470 action->setIcon(HbIcon("qtg_mono_end_call")); |
580 action->setIcon(HbIcon("qtg_mono_end_call")); |
|
581 action->setDisabled(disabled); |
471 action->setCommand(EPhoneInCallCmdEndThisOutgoingCall); |
582 action->setCommand(EPhoneInCallCmdEndThisOutgoingCall); |
472 action->setActionRole(PhoneAction::Decline); |
583 action->setActionRole(PhoneAction::Decline); |
473 } |
584 } |
474 break; |
585 break; |
475 |
586 |
476 case PhoneInCallCmdReplace: { |
587 case PhoneInCallCmdReplace: { |
477 action = new PhoneAction; |
588 action = new PhoneAction; |
478 action->setIcon(HbIcon("qtg_mono_replace_call")); |
589 action->setIcon(HbIcon("qtg_mono_replace_call")); |
|
590 action->setDisabled(disabled); |
479 action->setCommand(EPhoneInCallCmdReplace); |
591 action->setCommand(EPhoneInCallCmdReplace); |
480 action->setActionRole(PhoneAction::Accept); |
592 action->setActionRole(PhoneAction::Accept); |
481 } |
593 } |
482 break; |
594 break; |
483 |
595 |
484 case PhoneInCallCmdSwap: { |
596 case PhoneInCallCmdSwap: { |
485 action = new PhoneAction; |
597 action = new PhoneAction; |
486 action->setIcon(HbIcon("qtg_mono_swap")); |
598 action->setIcon(HbIcon("qtg_mono_replace_call")); |
|
599 action->setDisabled(disabled); |
487 action->setCommand(EPhoneInCallCmdSwap); |
600 action->setCommand(EPhoneInCallCmdSwap); |
488 } |
601 } |
489 break; |
602 break; |
490 |
603 case PhoneCallComingCmdSoftReject: { |
|
604 action = new PhoneAction; |
|
605 action->setIcon(HbIcon("qtg_mono_send")); |
|
606 action->setDisabled(disabled); |
|
607 action->setCommand(EPhoneCallComingCmdSoftReject); |
|
608 } |
|
609 break; |
|
610 case PhoneCallComingCmdSilent: { |
|
611 action = new PhoneAction; |
|
612 action->setIcon(HbIcon("qtg_mono_speaker_off")); |
|
613 action->setDisabled(disabled); |
|
614 action->setCommand(EPhoneCallComingCmdSilent); |
|
615 } |
|
616 break; |
|
617 case PhoneInCallCmdOpenDialer: { |
|
618 action = new PhoneAction; |
|
619 action->setIcon(HbIcon("qtg_mono_dialer")); |
|
620 action->setDisabled(disabled); |
|
621 action->setCommand(EPhoneInCallCmdDialer); |
|
622 } |
|
623 break; |
|
624 case PhoneInCallCmdMute: { |
|
625 action = new PhoneAction; |
|
626 action->setIcon(HbIcon("qtg_mono_mic_mute")); |
|
627 action->setDisabled(disabled); |
|
628 action->setCommand(EPhoneInCallCmdMute); |
|
629 } |
|
630 break; |
|
631 case PhoneInCallCmdUnmute: { |
|
632 action = new PhoneAction; |
|
633 action->setIcon(HbIcon("qtg_mono_mic_unmute")); |
|
634 action->setDisabled(disabled); |
|
635 action->setCommand(EPhoneInCallCmdUnmute); |
|
636 } |
|
637 break; |
|
638 case PhoneInCallCmdActivateIhf: { |
|
639 action = new PhoneAction; |
|
640 action->setIcon(HbIcon("qtg_mono_speaker")); |
|
641 action->setDisabled(disabled); |
|
642 action->setCommand(EPhoneInCallCmdActivateIhf); |
|
643 } |
|
644 break; |
|
645 case PhoneInCallCmdDeactivateIhf: { |
|
646 action = new PhoneAction; |
|
647 action->setIcon(HbIcon("qtg_mono_mobile")); |
|
648 action->setDisabled(disabled); |
|
649 action->setCommand(EPhoneInCallCmdDeactivateIhf); |
|
650 } |
|
651 break; |
|
652 case PhoneInCallCmdOpenContacts: { |
|
653 action = new PhoneAction; |
|
654 action->setIcon(HbIcon("qtg_mono_contacts")); |
|
655 action->setDisabled(disabled); |
|
656 action->setCommand(EPhoneInCallCmdContacts); |
|
657 } |
|
658 break; |
491 default: |
659 default: |
492 break; |
660 break; |
493 } |
661 } |
494 |
662 |
495 return action; |
663 return action; |