phoneapp/phoneuiqtviewadapter/src/phoneuiqtviewadapter.cpp
changeset 74 d1c62c765e48
parent 65 2a5d4ab426d3
child 76 cfea66083b62
equal deleted inserted replaced
65:2a5d4ab426d3 74:d1c62c765e48
    42 #include "phoneindicatorcontroller.h"
    42 #include "phoneindicatorcontroller.h"
    43 #include "qtphonelog.h"
    43 #include "qtphonelog.h"
    44 #include "phonevisibilityhandler.h"
    44 #include "phonevisibilityhandler.h"
    45 #include "phoneapplauncher.h"
    45 #include "phoneapplauncher.h"
    46 #include "cphonecenrepproxy.h"
    46 #include "cphonecenrepproxy.h"
    47 
    47 #include "phonecallheadermanager.h"
    48 #include <UikonInternalPSKeys.h>
    48 
    49 #include <bubblemanagerif.h>
    49 #include <bubblemanagerif.h>
    50 #include <hbaction.h>
    50 #include <hbaction.h>
    51 #include <pevirtualengine.h>
    51 #include <pevirtualengine.h>
    52 #include <QtGlobal>
    52 #include <QtGlobal>
    53 #include <xqserviceutil.h>
    53 #include <xqserviceutil.h>
    56 #include <hbextendedlocale.h>
    56 #include <hbextendedlocale.h>
    57 #include <hbi18ndef.h>
    57 #include <hbi18ndef.h>
    58 #include <eikenv.h>
    58 #include <eikenv.h>
    59 #include <w32std.h>
    59 #include <w32std.h>
    60 #include <hbstringutil.h>
    60 #include <hbstringutil.h>
    61 #include <AknSgcc.h>
       
    62 #include <AknCapServerClient.h>
       
    63 #include <xqaiwdecl.h>
    61 #include <xqaiwdecl.h>
       
    62 #include <mpeengineinfo.h>
    64 
    63 
    65 
    64 
    66 //CONSTANTS
    65 //CONSTANTS
    67 static const int PHONE_CALL_NOT_FOUND = -1;
    66 static const int PHONE_CALL_NOT_FOUND = -1;
    68 
    67 
    78     }
    77     }
    79 
    78 
    80 PhoneUIQtViewAdapter::PhoneUIQtViewAdapter (PhoneUIQtViewIF &view, QObject *parent) :
    79 PhoneUIQtViewAdapter::PhoneUIQtViewAdapter (PhoneUIQtViewIF &view, QObject *parent) :
    81     QObject (parent),
    80     QObject (parent),
    82     m_view (view),
    81     m_view (view),
    83     m_idleUid(-1),
       
    84     m_bubbleWrapper(0),
    82     m_bubbleWrapper(0),
    85     m_ringingtonecontroller(0),
    83     m_ringingtonecontroller(0),
    86     m_resourceAdapter(0),
    84     m_resourceAdapter(0),
    87     m_noteController(0),
    85     m_noteController(0),
    88     m_telephonyService(0),
    86     m_telephonyService(0),
    89     m_uiCommandController(0),
    87     m_uiCommandController(0),
    90     m_messageController(0),
    88     m_messageController(0),
    91     m_indicatorController(0),
    89     m_indicatorController(0),
       
    90     m_phoneCallHeaderManager(0),
    92     m_dialpadAboutToClose(false),
    91     m_dialpadAboutToClose(false),
    93     m_homeScreenToForeground(false),
    92     m_homeScreenToForeground(false),
    94     m_visibilityHandler(0),
    93     m_visibilityHandler(0),
    95     m_appLauncher(0),
    94     m_appLauncher(0),
    96     m_clearDialpadOnClose(true),
    95     m_clearDialpadOnClose(true),
    97     m_speakerAsDefaultButton(false)
    96     m_speakerAsDefaultButton(false),
    98 {
    97     m_ringingTonePlaying(false)
    99     m_bubbleWrapper = new PhoneBubbleWrapper(m_view.bubbleManager (), this);
    98 {
       
    99     m_bubbleWrapper = new PhoneBubbleWrapper(m_view.bubbleManager(), this);
   100     m_noteController = new PhoneNoteController(this);
   100     m_noteController = new PhoneNoteController(this);
   101     m_uiCommandController = new PhoneUiCommandController(view, this);
   101     m_uiCommandController = new PhoneUiCommandController(view, this);
       
   102     m_phoneCallHeaderManager = new PhoneCallHeaderManager(*m_bubbleWrapper, m_view, this);
   102 
   103 
   103     TRAPD( error, m_ringingtonecontroller = CPhoneRingingToneController::NewL () );
   104     TRAPD( error, m_ringingtonecontroller = CPhoneRingingToneController::NewL () );
   104     qt_symbian_throwIfError(error);
   105     qt_symbian_throwIfError(error);
   105     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
   106     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
   106 
   107 
   139         {
   140         {
   140         m_view.shutdownPhoneApp();
   141         m_view.shutdownPhoneApp();
   141         }
   142         }
   142         break;
   143         break;
   143 
   144 
   144     case EPhoneViewSetIdleTopApplication:
   145     case EPhoneViewBringPhoneAppToForeground:
   145         {
   146         bringToForeground();
   146             TPhoneCmdParamInteger uidParam;
   147         break;
   147             uidParam.SetInteger (idleAppUid());
   148         
   148             setTopApplication (&uidParam);
       
   149         }
       
   150         break;
       
   151 
       
   152     case EPhoneViewMuteRingToneOnAnswer:
   149     case EPhoneViewMuteRingToneOnAnswer:
   153         m_ringingtonecontroller->MuteRingingToneOnAnswer();
   150         m_ringingtonecontroller->MuteRingingToneOnAnswer();
   154         break;
   151         break;
   155 
   152 
   156     case EPhoneViewStopRingTone:
   153     case EPhoneViewStopRingTone:
       
   154         m_ringingTonePlaying = false;
   157         m_ringingtonecontroller->StopPlaying();
   155         m_ringingtonecontroller->StopPlaying();
   158         break;
   156         break;
   159 
   157 
   160     case EPhoneViewMuteRingTone:
   158     case EPhoneViewMuteRingTone:
       
   159         m_ringingTonePlaying = false;
   161         m_ringingtonecontroller->MuteRingingTone();
   160         m_ringingtonecontroller->MuteRingingTone();
   162         break;
   161         break;
   163 
   162 
   164     case EPhoneViewHideNaviPaneAudioVolume:
   163     case EPhoneViewHideNaviPaneAudioVolume:
   165         m_view.removeVolumeSlider ();
   164         m_view.removeVolumeSlider ();
   219 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TInt aCallId)
   218 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TInt aCallId)
   220 {
   219 {
   221     switch (aCmdId) {
   220     switch (aCmdId) {
   222     case EPhoneViewRemoveCallHeader:
   221     case EPhoneViewRemoveCallHeader:
   223         {
   222         {
   224         m_bubbleWrapper->bubbleManager().startChanges();
   223 	        m_phoneCallHeaderManager->removeCallHeader(aCallId);
   225         int bubble = m_bubbleWrapper->bubbles().value(aCallId);
       
   226         m_view.clearBubbleCommands(bubble);
       
   227         m_view.removeExpandAction(bubble);
       
   228         m_bubbleWrapper->removeCallHeader (aCallId);
       
   229         m_bubbleWrapper->bubbleManager().endChanges();
       
   230         
   224         
   231         if (!m_bubbleWrapper->bubbles().count()) {
   225 	        if (!m_bubbleWrapper->bubbles().count()) {
   232             m_indicatorController->clearActiveCallData();
   226 	            m_indicatorController->clearActiveCallData();
   233         }
   227 	        }
   234         }
   228         }
   235         break;
   229         break;
   236     case EPhoneViewRemoveFromConference:
   230     case EPhoneViewRemoveFromConference:
   237         removeCallFromConference(aCallId);
   231         removeCallFromConference(aCallId);
   238         break;
   232         break;
   239     case EPhoneViewPrivateFromConference:
   233     case EPhoneViewPrivateFromConference:
   240         setPrivateFromConference(aCallId);
   234         setPrivateFromConference(aCallId);
   241         break;
   235         break;
       
   236     case EPhoneViewCreateCallHeader:
       
   237         createCallHeader(aCallId);
       
   238         break;
       
   239     case EPhoneViewUpdateBubble:
       
   240         updateCallHeaderState(aCallId);
       
   241         setExpandActions();
       
   242         break;
       
   243     case EPhoneViewUpdateCallHeaderRemoteInfoData:
       
   244         updateCallHeaderRemoteInfo(aCallId);
       
   245         break;
       
   246     case EPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel:
       
   247         updateCallHeaderRemoteInfoAndLabel(aCallId);
       
   248         break;
       
   249     case EPhoneViewCreateConference:
       
   250         createConferenceBubble(aCallId);
       
   251         break;
       
   252     case EPhoneViewCipheringInfoChange:
       
   253         handleCipheringInfoChange(aCallId);
       
   254         break;
       
   255     case EPhoneViewCreateEmergencyCallHeader:
       
   256         createEmergencyCallHeader(aCallId);
       
   257         break;
   242     default:
   258     default:
   243         break;
   259         break;
   244     }
   260     }
   245    CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId, aCallId );
   261    CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId, aCallId );
   246 }
   262 }
   247 
   263 
   248 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TPhoneCommandParam* aCommandParam)
   264 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TPhoneCommandParam* aCommandParam)
   249 {
   265 {
   250     switch (aCmdId) {
   266     switch (aCmdId) {
   251     case EPhoneViewSetTopApplication:
       
   252         setTopApplication (aCommandParam);
       
   253         break;
       
   254     case EPhoneViewPlayRingTone:
   267     case EPhoneViewPlayRingTone:
       
   268         m_ringingTonePlaying = true;
   255         m_ringingtonecontroller->PlayRingToneL( aCommandParam );
   269         m_ringingtonecontroller->PlayRingToneL( aCommandParam );
   256         break;
       
   257     case EPhoneViewSetTouchPaneButtons:
       
   258         setTouchButtons (aCommandParam);
       
   259         setExpandActions();
       
   260         break;
       
   261     case EPhoneViewUpdateCba:
       
   262         setToolbarButtons (aCommandParam);
       
   263         break;
       
   264     case EPhoneViewSetHoldFlag:
       
   265         setCallHoldFlag (aCommandParam);
       
   266         break;
       
   267     case EPhoneViewGetHoldFlag:
       
   268         callHoldFlag (aCommandParam);
       
   269         break;
   270         break;
   270     case EPhoneViewSetNaviPaneAudioVolume:
   271     case EPhoneViewSetNaviPaneAudioVolume:
   271         setAudioVolumeSliderValue (aCommandParam);
   272         setAudioVolumeSliderValue (aCommandParam);
   272         break;
   273         break;
   273     case EPhoneViewActivateMuteUIChanges:
   274     case EPhoneViewActivateMuteUIChanges:
   277         activeCallCount(aCommandParam);
   278         activeCallCount(aCommandParam);
   278         break;
   279         break;
   279     case EPhoneViewActivateAudioPathUIChanges:
   280     case EPhoneViewActivateAudioPathUIChanges:
   280         setAudioPath(aCommandParam);
   281         setAudioPath(aCommandParam);
   281         break;
   282         break;
   282     case EPhoneViewGetExpandedBubbleCallId:
       
   283         expandedBubbleCallId(aCommandParam);
       
   284         break;
       
   285     case EPhoneViewGetIsConference:
   283     case EPhoneViewGetIsConference:
   286         isConference(aCommandParam);
   284         isConference(aCommandParam);
   287         break;
   285         break;    
   288     case EPhoneViewBringAppToForeground:
       
   289         bringToForeground();
       
   290         break;
       
   291     case EPhoneViewShowGlobalNote:
   286     case EPhoneViewShowGlobalNote:
   292         showGlobalNote(aCommandParam);
   287         showGlobalNote(aCommandParam);
   293         break;
   288         break;
   294     case EPhoneViewSetNumberEntryVisible:
   289     case EPhoneViewSetNumberEntryVisible:
   295         setDialpadVisibility(aCommandParam);
   290         setDialpadVisibility(aCommandParam);
   324 
   319 
   325 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TInt aCallId,
   320 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TInt aCallId,
   326     TPhoneCommandParam *aCommandParam)
   321     TPhoneCommandParam *aCommandParam)
   327 {
   322 {
   328     switch (aCmdId) {
   323     switch (aCmdId) {
   329     case EPhoneViewCreateCallHeader:
       
   330         createCallHeader (aCallId, aCommandParam);
       
   331         break;
       
   332     case EPhoneViewCreateEmergencyCallHeader:
       
   333         createEmergencyCallHeader (aCallId, aCommandParam);
       
   334         break;
       
   335     case EPhoneViewUpdateBubble:
       
   336         updateCallHeaderState (aCallId, aCommandParam);
       
   337         setExpandActions();
       
   338         break;
       
   339     case EPhoneViewUpdateCallHeaderRemoteInfoData:
       
   340         updateCallHeaderRemoteInfo (aCallId, aCommandParam);
       
   341         break;
       
   342     case EPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel:
       
   343         updateCallHeaderRemoteInfoAndLabel(aCallId, aCommandParam);
       
   344         break;
       
   345     case EPhoneViewCreateConference:
       
   346         createConferenceBubble(aCallId, aCommandParam);
       
   347         break;
       
   348     case EPhoneViewGetCallExistsInConference:
   324     case EPhoneViewGetCallExistsInConference:
   349         conferenceCallId(aCallId, aCommandParam);
   325         conferenceCallId(aCallId, aCommandParam);
   350         break;
   326         break;
   351     case EPhoneViewUpdateCallHeaderCallDuration:
   327     case EPhoneViewUpdateCallHeaderCallDuration:
   352     {
   328     {
   359             m_bubbleWrapper->bubbleManager().updateCallTime(bubbleId, duration);
   335             m_bubbleWrapper->bubbleManager().updateCallTime(bubbleId, duration);
   360         }
   336         }
   361         break;
   337         break;
   362     }
   338     }
   363 
   339 
   364     case EPhoneViewCipheringInfoChange:
       
   365     {
       
   366         handleCipheringInfoChange(aCallId, aCommandParam);
       
   367         break;
       
   368     }
       
   369 
       
   370     default:
   340     default:
   371         break;
   341         break;
   372     }
   342     }
   373     CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId, aCallId, *aCommandParam );
   343     CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId, aCallId, *aCommandParam );
   374 }
   344 }
   389     TPhoneViewResponseId response = EPhoneViewResponseSuccess;
   359     TPhoneViewResponseId response = EPhoneViewResponseSuccess;
   390 
   360 
   391     switch (aCmdId) {
   361     switch (aCmdId) {
   392     case EPhoneIsDTMFDialerVisible:
   362     case EPhoneIsDTMFDialerVisible:
   393     case EPhoneIsCustomizedDialerVisible:
   363     case EPhoneIsCustomizedDialerVisible:
   394     case EPhoneViewGetNeedToSendToBackgroundStatus:
       
   395         // TODO: currently not supported
   364         // TODO: currently not supported
   396         response = EPhoneViewResponseFailed;
   365         response = EPhoneViewResponseFailed;
   397         break;
   366         break;
   398     case EPhoneViewGetNumberEntryIsVisibleStatus:
   367     case EPhoneViewGetNumberEntryIsVisibleStatus:
   399     case EPhoneViewGetNumberEntryIsUsedStatus: // Fall through
   368     case EPhoneViewGetNumberEntryIsUsedStatus: // Fall through
   529         if (convertKey(captureParam->KeyCode(), qtKey)) {
   498         if (convertKey(captureParam->KeyCode(), qtKey)) {
   530             m_view.captureKey(qtKey, false);
   499             m_view.captureKey(qtKey, false);
   531         }
   500         }
   532     }
   501     }
   533     break;
   502     break;
       
   503     case EPhoneViewIsRingingTonePlaying: {
       
   504         TPhoneCmdParamBoolean *param = static_cast<TPhoneCmdParamBoolean *>(aCommandParam);
       
   505         param->SetBoolean(m_ringingTonePlaying);
       
   506         }
       
   507     break;
       
   508     case EPhoneViewUpdateCba:
       
   509         setToolbarButtons(aCommandParam);
       
   510         break;
       
   511     case EPhoneViewGetExpandedBubbleCallId:
       
   512         expandedBubbleCallId(aCommandParam);
       
   513         break;
       
   514     case EPhoneViewSetTouchPaneButtons:
       
   515         setTouchButtons (aCommandParam);
       
   516         setExpandActions();
       
   517         break;
   534     default:
   518     default:
   535         break;
   519         break;
   536     }
   520     }
   537 }
   521 }
   538 
   522 
   539 const TDesC& PhoneUIQtViewAdapter::FetchContent ()
   523 const TDesC& PhoneUIQtViewAdapter::FetchContent()
   540 {
   524 {
   541     return KNullDesC;
   525     return KNullDesC;
       
   526 }
       
   527 
       
   528 void PhoneUIQtViewAdapter::setEngineInfo(MPEEngineInfo* engineInfo)
       
   529 {
       
   530     m_phoneCallHeaderManager->setEngineInfo(engineInfo);
       
   531     m_engineInfo = engineInfo;
   542 }
   532 }
   543 
   533 
   544 void PhoneUIQtViewAdapter::dialpadClosed()
   534 void PhoneUIQtViewAdapter::dialpadClosed()
   545 {
   535 {
   546     if (m_clearDialpadOnClose) {
   536     if (m_clearDialpadOnClose) {
   564     }
   554     }
   565 }
   555 }
   566 
   556 
   567 void PhoneUIQtViewAdapter::handleWindowActivated()
   557 void PhoneUIQtViewAdapter::handleWindowActivated()
   568 {
   558 {
       
   559     m_view.captureKey(Qt::Key_Yes, true);
       
   560 }
       
   561 
       
   562 void PhoneUIQtViewAdapter::handleWindowDeactivated()
       
   563 {
       
   564     m_view.captureKey(Qt::Key_Yes, false);
       
   565 }
       
   566 
       
   567 void PhoneUIQtViewAdapter::onFocusLost()
       
   568 {
       
   569     m_indicatorController->enableActiveCallIndicator();
       
   570 }
       
   571 
       
   572 void PhoneUIQtViewAdapter::onFocusGained()
       
   573 {
   569     m_indicatorController->disableActiveCallIndicator();
   574     m_indicatorController->disableActiveCallIndicator();
   570     m_view.captureKey(Qt::Key_Yes, true);
       
   571 }
       
   572 
       
   573 void PhoneUIQtViewAdapter::handleWindowDeactivated()
       
   574 {
       
   575     m_indicatorController->enableActiveCallIndicator();
       
   576     m_view.captureKey(Qt::Key_Yes, false);
       
   577 }
       
   578 
       
   579 void PhoneUIQtViewAdapter::setTopApplication (TPhoneCommandParam *commandParam)
       
   580 {
       
   581     TPhoneCmdParamInteger *integerParam = static_cast<TPhoneCmdParamInteger *> (commandParam);
       
   582     CPhonePubSubProxy::Instance()->ChangePropertyValue(
       
   583         KPSUidUikon,
       
   584         KUikVideoCallTopApp,
       
   585         integerParam->Integer() );
       
   586 
       
   587     // Hide the Phone icon if it is not the top application
       
   588     // TODO: how to do this?
       
   589 }
       
   590 
       
   591 int PhoneUIQtViewAdapter::idleAppUid ()
       
   592 {
       
   593 // <-- QT HS START -->
       
   594    /* if ( m_idleUid == -1 ) {
       
   595         // Get Idle's UID from PubSub.
       
   596         m_idleUid = CPhonePubSubProxy::Instance()->Value (KPSUidAiInformation,
       
   597             KActiveIdleUid );
       
   598     }*/
       
   599     m_idleUid=0x20022F35;
       
   600 // <-- QT HS END -->
       
   601     return m_idleUid;
       
   602 }
   575 }
   603 
   576 
   604 void PhoneUIQtViewAdapter::createCallHeader(
   577 void PhoneUIQtViewAdapter::createCallHeader(
   605     int callId,
   578     int callId )
   606     TPhoneCommandParam *commandParam )
   579 {
   607 {
   580     m_phoneCallHeaderManager->createCallHeader(callId);
   608     PHONE_DEBUG("PhoneUIQtViewAdapter::createCallHeader");
       
   609     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
       
   610 
       
   611     TPhoneCmdParamCallHeaderData &data =
       
   612         static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
       
   613 
       
   614     m_bubbleWrapper->bubbleManager ().startChanges ();
       
   615 
       
   616     if (m_bubbleWrapper->bubbleManager().isConferenceExpanded())
       
   617         {
       
   618         m_bubbleWrapper->bubbleManager().setExpandedConferenceCallHeader(false);
       
   619         }
       
   620 
       
   621     int bubble = m_bubbleWrapper->createCallHeader (callId);
       
   622     m_bubbleWrapper->setState (callId, bubble, data.CallState ());        
       
   623     m_bubbleWrapper->setCli (bubble, data.CLIText (), clipToElide(data.CLITextClippingDirection()));
       
   624     m_bubbleWrapper->setServiceId(callId, data.ServiceId());
       
   625     m_bubbleWrapper->setSecondaryCli (bubble, data.CNAPText (), clipToElide(data.CNAPTextClippingDirection()));
       
   626     m_bubbleWrapper->setLabel (bubble, data.LabelText ());
       
   627     m_bubbleWrapper->setCallType (bubble, data.CallType ());
       
   628     m_bubbleWrapper->setDivert (bubble, data.Diverted ());
       
   629     m_bubbleWrapper->setCiphering(bubble, data.CipheringIndicatorAllowed(), data.Ciphering());
       
   630 
       
   631     if (data.Picture().Length()) {
       
   632         QString imagePath =
       
   633             QString::fromUtf16(data.Picture().Ptr(),data.Picture().Length());
       
   634         m_bubbleWrapper->bubbleManager().setCallObjectImage(bubble,imagePath);
       
   635     } else {
       
   636         m_bubbleWrapper->bubbleManager().setCallObjectFromTheme(bubble);
       
   637     }
       
   638     m_bubbleWrapper->bubbleManager ().endChanges ();
       
   639     
   581     
   640     if (1 == m_bubbleWrapper->bubbles().keys().count()) {
   582     if (1 == m_bubbleWrapper->bubbles().keys().count()) {
   641         setHidden(false);
   583         setHidden(false);
   642     }
   584     }
   643     if( EPECallTypeVideo != data.CallType() ){
   585 
       
   586     if( m_phoneCallHeaderManager->isVoiceCall(callId) ){
   644         m_indicatorController->setActiveCallData();
   587         m_indicatorController->setActiveCallData();
   645     }
   588     }
   646     
   589 
   647 }
   590 }
   648 
   591 
   649 void PhoneUIQtViewAdapter::createEmergencyCallHeader(
   592 void PhoneUIQtViewAdapter::createEmergencyCallHeader(int callId)
   650     int callId,
   593 {
   651     TPhoneCommandParam *commandParam)
   594     m_phoneCallHeaderManager->createEmergencyCallHeader(callId);    
   652 {
       
   653     PHONE_DEBUG("PhoneUIQtViewAdapter::createEmergencyCallHeader");
       
   654     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdEmergencyCallHeaderData);
       
   655 
       
   656     TPhoneCmdParamEmergencyCallHeaderData &data =
       
   657         static_cast<TPhoneCmdParamEmergencyCallHeaderData &> (*commandParam);
       
   658 
       
   659     m_bubbleWrapper->bubbleManager ().startChanges ();
       
   660     int bubble = m_bubbleWrapper->createCallHeader (callId);
       
   661     m_bubbleWrapper->setLabel (bubble, data.LabelText ());
       
   662     m_bubbleWrapper->setCli (bubble, data.HeaderText (), Qt::ElideRight);
       
   663     m_bubbleWrapper->setCiphering(bubble, data.CipheringIndicatorAllowed(), data.Ciphering());
       
   664     m_bubbleWrapper->bubbleManager ().endChanges ();
       
   665     
       
   666     m_indicatorController->setActiveCallData();
   595     m_indicatorController->setActiveCallData();
   667 }
   596 }
   668 
   597 
   669 void PhoneUIQtViewAdapter::updateCallHeaderState (
   598 void PhoneUIQtViewAdapter::updateCallHeaderState(int callId)
   670     int callId,
       
   671     TPhoneCommandParam *commandParam)
       
   672 {
   599 {
   673     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderState");
   600     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderState");
   674     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
   601 
   675 
   602     m_phoneCallHeaderManager->updateCallHeaderState(callId);
   676     TPhoneCmdParamCallHeaderData &data =
   603 }
   677             static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
   604 
   678 
   605 void PhoneUIQtViewAdapter::updateCallHeaderRemoteInfo(int callId)
   679     int bubble = m_bubbleWrapper->bubbleId (callId);
       
   680     if ( -1 != bubble ) {
       
   681         m_bubbleWrapper->bubbleManager ().startChanges ();
       
   682         m_bubbleWrapper->setState (callId, bubble, data.CallState ());
       
   683         m_bubbleWrapper->setLabel (bubble, data.LabelText ());
       
   684         m_bubbleWrapper->setDivert (bubble, data.Diverted ());
       
   685         m_bubbleWrapper->bubbleManager ().endChanges ();
       
   686     }
       
   687 }
       
   688 
       
   689 void PhoneUIQtViewAdapter::updateCallHeaderRemoteInfo (int callId, TPhoneCommandParam *commandParam)
       
   690 {
   606 {
   691     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderRemoteInfo");
   607     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderRemoteInfo");
   692     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
   608     m_phoneCallHeaderManager->updateCallHeaderRemoteInfo(callId);
   693 
   609     
   694     TPhoneCmdParamCallHeaderData &data =
   610     if ( m_phoneCallHeaderManager->isVoiceCall(callId) ) {
   695          static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
       
   696 
       
   697 
       
   698      int bubble = m_bubbleWrapper->bubbleId (callId);
       
   699      if ( -1 != bubble ) {
       
   700          m_bubbleWrapper->bubbleManager ().startChanges ();
       
   701          m_bubbleWrapper->setCli (bubble, data.CLIText (),
       
   702              clipToElide(data.CLITextClippingDirection()));
       
   703          m_bubbleWrapper->setSecondaryCli (bubble, data.CNAPText (),
       
   704              clipToElide(data.CNAPTextClippingDirection()));
       
   705          m_bubbleWrapper->setDivert (bubble, data.Diverted ());
       
   706          m_bubbleWrapper->bubbleManager ().endChanges ();
       
   707      }
       
   708      if ( EPECallTypeVideo != data.CallType() ) {
       
   709          m_indicatorController->setActiveCallData();
   611          m_indicatorController->setActiveCallData();
   710      }
   612     }
   711 }
   613 }
   712 
   614 
   713 void PhoneUIQtViewAdapter::updateCallHeaderRemoteInfoAndLabel (int callId, TPhoneCommandParam *commandParam)
   615 void PhoneUIQtViewAdapter::updateCallHeaderRemoteInfoAndLabel(int callId)
   714 {
   616 {
   715     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderRemoteInfoAndLabel");
   617     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderRemoteInfoAndLabel");
   716     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
   618     m_phoneCallHeaderManager->updateCallHeaderRemoteInfoAndLabel(callId);
   717 
   619 }
   718     TPhoneCmdParamCallHeaderData &data =
   620 
   719          static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
   621 void PhoneUIQtViewAdapter::handleCipheringInfoChange(int callId)
   720 
   622 {
   721      int bubble = m_bubbleWrapper->bubbleId (callId);
   623     m_phoneCallHeaderManager->handleCipheringInfoChange(callId);
   722      if ( -1 != bubble ) {
       
   723          m_bubbleWrapper->bubbleManager ().startChanges ();
       
   724          m_bubbleWrapper->setCli (bubble, data.CLIText (),
       
   725              clipToElide(data.CLITextClippingDirection()));
       
   726          m_bubbleWrapper->setSecondaryCli (bubble, data.CNAPText (),
       
   727              clipToElide(data.CNAPTextClippingDirection()));
       
   728          m_bubbleWrapper->setLabel (bubble, data.LabelText ());
       
   729          m_bubbleWrapper->setDivert (bubble, data.Diverted ());
       
   730          m_bubbleWrapper->bubbleManager ().endChanges ();
       
   731      }
       
   732 }
       
   733 
       
   734 void PhoneUIQtViewAdapter::handleCipheringInfoChange(int callId, TPhoneCommandParam *commandParam)
       
   735 {
       
   736     TPhoneCmdParamCallHeaderData *param =
       
   737         static_cast<TPhoneCmdParamCallHeaderData*>(commandParam);
       
   738 
       
   739     int bubble = m_bubbleWrapper->bubbleId(callId);        
       
   740     if ( -1 != bubble ) {        
       
   741         m_bubbleWrapper->bubbleManager().startChanges();
       
   742         m_bubbleWrapper->setCiphering(m_bubbleWrapper->bubbleId(callId),
       
   743                                       param->CipheringIndicatorAllowed(),
       
   744                                       param->Ciphering());
       
   745         m_bubbleWrapper->bubbleManager().endChanges();
       
   746     }
       
   747 }
   624 }
   748 
   625 
   749 TPhoneViewResponseId PhoneUIQtViewAdapter::callIdByState (TPhoneCommandParam *commandParam)
   626 TPhoneViewResponseId PhoneUIQtViewAdapter::callIdByState (TPhoneCommandParam *commandParam)
   750 {
   627 {
   751     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallStateData);
   628     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallStateData);
   835     }
   712     }
   836 
   713 
   837     qDeleteAll(actions);
   714     qDeleteAll(actions);
   838 }
   715 }
   839 
   716 
   840 void PhoneUIQtViewAdapter::setCallHoldFlag (TPhoneCommandParam *commandParam)
       
   841 {
       
   842     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
   843 
       
   844     TPhoneCmdParamBoolean &boolParam =
       
   845         static_cast<TPhoneCmdParamBoolean &>(*commandParam);
       
   846 
       
   847     m_resourceAdapter->buttonsController()->setButtonFlags(PhoneUIQtButtonsController::Hold,
       
   848                                                            boolParam.Boolean ());
       
   849 }
       
   850 
       
   851 void PhoneUIQtViewAdapter::callHoldFlag (TPhoneCommandParam *commandParam)
       
   852 {
       
   853     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
   854 
       
   855     TPhoneCmdParamBoolean &boolParam =
       
   856         static_cast<TPhoneCmdParamBoolean &>(*commandParam);
       
   857     boolParam.SetBoolean (m_resourceAdapter->buttonsController()->getButtonFlags(PhoneUIQtButtonsController::Hold));
       
   858 }
       
   859 
       
   860 void PhoneUIQtViewAdapter::writeAudioVolumeLevel (TPhoneCommandParam *commandParam)
   717 void PhoneUIQtViewAdapter::writeAudioVolumeLevel (TPhoneCommandParam *commandParam)
   861 {
   718 {
   862     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdInteger);
   719     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdInteger);
   863 
   720 
   864     TPhoneCmdParamInteger &intParam =
   721     TPhoneCmdParamInteger &intParam =
   932     m_dialpadAboutToClose = false;
   789     m_dialpadAboutToClose = false;
   933     m_view.showDialpad();
   790     m_view.showDialpad();
   934     setDialpadMenu();
   791     setDialpadMenu();
   935     }
   792     }
   936 
   793 
   937 void PhoneUIQtViewAdapter::createConferenceBubble(int callId, TPhoneCommandParam *commandParam)
   794 void PhoneUIQtViewAdapter::createConferenceBubble(int callId)
   938 {
   795 {
   939     PHONE_DEBUG("PhoneUIQtViewAdapter::createConferenceBubble");
   796     m_bubbleWrapper->bubbleManager().startChanges();
   940     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
   797     m_phoneCallHeaderManager->createConferenceBubble(callId);
   941 
       
   942     TPhoneCmdParamCallHeaderData &data =
       
   943          static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
       
   944 
       
   945     int bubble = m_bubbleWrapper->createConferenceBubble(
       
   946             callId, data.CallState(), data.LabelText(), data.CLIText());
       
   947 
       
   948     m_bubbleWrapper->setServiceId(callId,data.ServiceId());
       
   949     m_bubbleWrapper->setCiphering(bubble, data.CipheringIndicatorAllowed(), data.Ciphering());
       
   950     
       
   951     setParticipantListActions();
   798     setParticipantListActions();
       
   799     m_bubbleWrapper->bubbleManager().endChanges();
   952 }
   800 }
   953 
   801 
   954 void PhoneUIQtViewAdapter::conferenceCallId(int callId, TPhoneCommandParam *commandParam)
   802 void PhoneUIQtViewAdapter::conferenceCallId(int callId, TPhoneCommandParam *commandParam)
   955 {
   803 {
   956     PHONE_DEBUG("PhoneUIQtViewAdapter::conferenceCallId");
   804     PHONE_DEBUG("PhoneUIQtViewAdapter::conferenceCallId");
   963     conferenceDataValue->SetBoolean(m_bubbleWrapper->conferenceCallId(callId));
   811     conferenceDataValue->SetBoolean(m_bubbleWrapper->conferenceCallId(callId));
   964 }
   812 }
   965 
   813 
   966 void PhoneUIQtViewAdapter::removeConferenceBubble()
   814 void PhoneUIQtViewAdapter::removeConferenceBubble()
   967 {
   815 {
   968     m_bubbleWrapper->bubbleManager().startChanges();
   816     m_phoneCallHeaderManager->removeConferenceBubble();
   969     m_view.removeExpandAction(m_bubbleWrapper->bubbleId(KConferenceCallId));
       
   970     m_view.clearParticipantListActions();
       
   971     m_bubbleWrapper->removeConferenceBubble();
       
   972     m_bubbleWrapper->bubbleManager().endChanges();
       
   973     if (!m_bubbleWrapper->bubbles().count()) {
   817     if (!m_bubbleWrapper->bubbles().count()) {
   974         m_indicatorController->clearActiveCallData();
   818         m_indicatorController->clearActiveCallData();
   975     }
   819     }
   976 
   820 
   977 }
   821 }
   987     conferenceDataValue->SetBoolean(0<m_bubbleWrapper->conferenceCallList().size());
   831     conferenceDataValue->SetBoolean(0<m_bubbleWrapper->conferenceCallList().size());
   988 }
   832 }
   989 
   833 
   990 void PhoneUIQtViewAdapter::removeCallFromConference(int callId)
   834 void PhoneUIQtViewAdapter::removeCallFromConference(int callId)
   991 {
   835 {
   992     m_bubbleWrapper->bubbleManager().startChanges();
   836     m_phoneCallHeaderManager->removeCallFromConference(callId);
   993     m_bubbleWrapper->removeCallFromConference(callId);
       
   994     int bubbleId = m_bubbleWrapper->bubbles().value(callId);
       
   995     m_view.clearBubbleCommands(bubbleId);
       
   996     m_view.removeExpandAction(bubbleId);
       
   997     m_bubbleWrapper->removeCallHeader(callId);
       
   998     m_bubbleWrapper->bubbleManager().endChanges();
       
   999 }
   837 }
  1000 
   838 
  1001 TPhoneViewResponseId PhoneUIQtViewAdapter::getSelectedConferenceMember(
   839 TPhoneViewResponseId PhoneUIQtViewAdapter::getSelectedConferenceMember(
  1002         TPhoneCommandParam *commandParam)
   840         TPhoneCommandParam *commandParam)
  1003 {
   841 {
  1019     return ret;
   857     return ret;
  1020 }
   858 }
  1021 
   859 
  1022 void PhoneUIQtViewAdapter::setPrivateFromConference(int callId)
   860 void PhoneUIQtViewAdapter::setPrivateFromConference(int callId)
  1023 {
   861 {
  1024     m_bubbleWrapper->bubbleManager().startChanges();
   862     m_phoneCallHeaderManager->setPrivateFromConference(callId);
  1025     m_bubbleWrapper->bubbleManager().setExpandedConferenceCallHeader(false);
       
  1026     m_bubbleWrapper->removeCallFromConference(callId);
       
  1027     m_view.clearBubbleCommands(m_bubbleWrapper->bubbles().value(callId));
       
  1028     m_bubbleWrapper->bubbleManager().endChanges();
       
  1029 }
   863 }
  1030 
   864 
  1031 void PhoneUIQtViewAdapter::setExpandActions()
   865 void PhoneUIQtViewAdapter::setExpandActions()
  1032 {
   866 {
  1033     /* If there is 2 or more calls ongoing then we should
   867     /* If there is 2 or more calls ongoing then we should
  1083     }
   917     }
  1084 }
   918 }
  1085 
   919 
  1086 void PhoneUIQtViewAdapter::setExpandedConferenceCallHeader()
   920 void PhoneUIQtViewAdapter::setExpandedConferenceCallHeader()
  1087 {
   921 {
  1088     int callId = PHONE_CALL_NOT_FOUND;
   922     m_phoneCallHeaderManager->setExpandedConferenceCallHeader();
  1089 
       
  1090     if ( 1==m_bubbleWrapper->bubbles().keys().size()
       
  1091          || (1<m_bubbleWrapper->bubbles().keys().size()
       
  1092          && false == m_bubbleWrapper->callStates().values().contains(EPEStateRinging)
       
  1093          && false == m_bubbleWrapper->callStates().values().contains(EPEStateDialing)
       
  1094          && false == m_bubbleWrapper->callStates().values().contains(EPEStateConnecting)
       
  1095          && false == m_bubbleWrapper->callStates().values().contains(EPEStateHeldConference))) {
       
  1096 
       
  1097         int bubbleId = m_bubbleWrapper->bubbleManager().expandedBubble();
       
  1098         callId = m_bubbleWrapper->callIdByBubbleId(bubbleId);
       
  1099     }
       
  1100 
       
  1101     m_bubbleWrapper->bubbleManager().setExpandedConferenceCallHeader(
       
  1102             (KConferenceCallId == callId));
       
  1103 }
   923 }
  1104 
   924 
  1105 void PhoneUIQtViewAdapter::bringToForeground()
   925 void PhoneUIQtViewAdapter::bringToForeground()
  1106 {
   926 {
  1107     m_visibilityHandler->bringToForeground();
   927     m_visibilityHandler->bringToForeground();
  1137     }
   957     }
  1138 }
   958 }
  1139 
   959 
  1140 void PhoneUIQtViewAdapter::removeAllCallHeaders()
   960 void PhoneUIQtViewAdapter::removeAllCallHeaders()
  1141 {
   961 {
  1142     if (m_bubbleWrapper->conferenceCallList().size()) {
   962     m_phoneCallHeaderManager->removeAllCallHeaders();
  1143         removeConferenceBubble();
       
  1144     }
       
  1145 
       
  1146     QList<int> callIds = m_bubbleWrapper->bubbles().keys();
       
  1147 
       
  1148     for (int i=0; i<callIds.size(); ++i) {
       
  1149         int callId = callIds.at(i);
       
  1150         if (KEmergencyCallId != callId) {
       
  1151             m_bubbleWrapper->bubbleManager().startChanges();
       
  1152             int bubble = m_bubbleWrapper->bubbles().value(callId);
       
  1153             m_view.clearBubbleCommands(bubble);
       
  1154             m_view.removeExpandAction(bubble);
       
  1155             m_bubbleWrapper->removeCallHeader (callId);
       
  1156             m_bubbleWrapper->bubbleManager().endChanges();
       
  1157         }
       
  1158     }
       
  1159     if (!m_bubbleWrapper->bubbles().count()) {
   963     if (!m_bubbleWrapper->bubbles().count()) {
  1160         m_indicatorController->clearActiveCallData();
   964         m_indicatorController->clearActiveCallData();
  1161     }
   965     }
  1162 
   966 
  1163 }
   967 }
  1279         User::LeaveIfError(
  1083         User::LeaveIfError(
  1280                 windowGroupName->SetWindowGroupName(
  1084                 windowGroupName->SetWindowGroupName(
  1281                         env->RootWin() ) );
  1085                         env->RootWin() ) );
  1282         
  1086         
  1283         CleanupStack::PopAndDestroy( windowGroupName );
  1087         CleanupStack::PopAndDestroy( windowGroupName );
  1284 
  1088         
  1285         CAknSgcClient::AknSrv()->UpdateTaskList();
  1089         // Avkon removal
  1286     }
  1090     }
  1287 }
  1091 }
  1288 void PhoneUIQtViewAdapter::openContacts()
  1092 void PhoneUIQtViewAdapter::openContacts()
  1289 {
  1093 {
  1290     m_appLauncher->launchContacts();
  1094     m_appLauncher->launchContacts();