phoneapp/phoneuiqtviewadapter/src/phoneuiqtviewadapter.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     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:  Phone UI's symbian adapter for Qt view.
       
    15 *
       
    16 */
       
    17 
       
    18 #include "phoneuiqtviewadapter.h"
       
    19 #include "phoneuiqtviewif.h"
       
    20 #include "phonebubblewrapper.h"
       
    21 #include "tphonecmdparaminteger.h"
       
    22 #include "tphonecmdparamboolean.h"
       
    23 #include "tphonecmdparamaudioavailability.h"
       
    24 #include "tphonecmdparamaudiooutput.h"
       
    25 #include "tphonecmdparamcallstatedata.h"
       
    26 #include "tphonecmdparamcallheaderdata.h"
       
    27 #include "tphonecmdparamemergencycallheaderdata.h"
       
    28 #include "tphonecmdparamstring.h"
       
    29 #include "cphonepubsubproxy.h"
       
    30 #include "pevirtualengine.h"
       
    31 #include "cphonepubsubproxy.h"
       
    32 #include "cphoneringingtonecontroller.h"
       
    33 #include "phoneresourceadapter.h"
       
    34 #include "phoneui.hrh"
       
    35 #include "cphonemediatorfactory.h"
       
    36 #include "phoneuiqtbuttonscontroller.h"
       
    37 #include "phoneconstants.h"
       
    38 #include "phonenotecontroller.h"
       
    39 #include "telephonyservice.h"
       
    40 #include "phoneuicommandcontroller.h"
       
    41 #include "phonemessagecontroller.h"
       
    42 #include "phoneindicatorcontroller.h"
       
    43 #include "qtphonelog.h"
       
    44 #include <UikonInternalPSKeys.h>
       
    45 #include <bubblemanagerif.h>
       
    46 #include <hbaction.h>
       
    47 #include <pevirtualengine.h>
       
    48 #include <xqservicerequest.h>
       
    49 #include <QtGlobal>
       
    50 #include <xqserviceutil.h>
       
    51 #include <hbinstance.h>
       
    52 #include <QKeyEvent>
       
    53 #include <hbextendedlocale.h>
       
    54 #include <hbi18ndef.h>
       
    55 #include <eikenv.h>
       
    56 #include <w32std.h>
       
    57 #include <apgtask.h>
       
    58 #include <hbstringutil.h>
       
    59 #include <telinformationpskeys.h>
       
    60 #include <AknSgcc.h>
       
    61 #include <AknCapServerClient.h>
       
    62 
       
    63 
       
    64 //CONSTANTS
       
    65 static const int PHONE_CALL_NOT_FOUND = -1;
       
    66 
       
    67 PhoneUIQtViewAdapter::PhoneUIQtViewAdapter (PhoneUIQtViewIF &view, QObject *parent) :
       
    68     QObject (parent), m_view (view), m_idleUid(-1),
       
    69     m_dialpadAboutToClose(false), m_homeScreenToForeground(false),
       
    70     m_carModeEnabled(false)
       
    71 {
       
    72     m_bubbleWrapper = new PhoneBubbleWrapper(m_view.bubbleManager (), this);
       
    73     m_noteController = new PhoneNoteController(this);
       
    74     m_uiCommandController = new PhoneUiCommandController(view, this);
       
    75     m_messageController = new PhoneMessageController(this);
       
    76 
       
    77     TRAPD( error, m_ringingtonecontroller = CPhoneRingingToneController::NewL () );
       
    78     qt_symbian_throwIfError(error);
       
    79     m_resourceAdapter = PhoneResourceAdapter::Instance(this);
       
    80 
       
    81     // display initial toolbar to make client area size correct
       
    82     TPhoneCmdParamInteger intParam;
       
    83     intParam.SetInteger(m_resourceAdapter->defaultToolbarResourceId());
       
    84     setToolbarButtons(&intParam);
       
    85 
       
    86     m_telephonyService = new TelephonyService (this, this);
       
    87 	m_indicatorController = new PhoneIndicatorController(this);
       
    88 
       
    89     // Define car mode pub sub key
       
    90     int err = RProperty::Define(
       
    91         KPSUidTelCarMode,
       
    92         KTelCarMode,
       
    93         RProperty::EInt,
       
    94         KPhoneReadPolicy,
       
    95         KPhoneWritePolicy);
       
    96     
       
    97     // Start listening to car mode changes
       
    98     if(err == KErrNone) {
       
    99         CPhonePubSubProxy::Instance()->NotifyChangeL(KPSUidTelCarMode,
       
   100             KTelCarMode, this);
       
   101     }
       
   102 }
       
   103 
       
   104 PhoneUIQtViewAdapter::~PhoneUIQtViewAdapter ()
       
   105 {
       
   106     delete m_ringingtonecontroller;
       
   107 }
       
   108 
       
   109 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId)
       
   110 {
       
   111     switch (aCmdId) {
       
   112     case EPhoneAppShutDown:
       
   113         {
       
   114         m_view.shutdownPhoneApp();
       
   115         }
       
   116         break;
       
   117 
       
   118     case EPhoneViewSetIdleTopApplication:
       
   119         {
       
   120             TPhoneCmdParamInteger uidParam;
       
   121             uidParam.SetInteger (idleAppUid());
       
   122             setTopApplication (&uidParam);
       
   123         }
       
   124         break;
       
   125 
       
   126     case EPhoneViewMuteRingToneOnAnswer:
       
   127         m_ringingtonecontroller->MuteRingingToneOnAnswer();
       
   128         break;
       
   129 
       
   130     case EPhoneViewStopRingTone:
       
   131         m_ringingtonecontroller->StopPlaying();
       
   132         break;
       
   133 
       
   134     case EPhoneViewMuteRingTone:
       
   135         m_ringingtonecontroller->MuteRingingTone();
       
   136         break;
       
   137 
       
   138     case EPhoneViewHideNaviPaneAudioVolume:
       
   139         m_view.removeVolumeSlider ();
       
   140         break;
       
   141 
       
   142     case EPhoneViewOpenDialer:
       
   143         openDialpad();
       
   144         break;
       
   145 
       
   146     case EPhoneViewRemoveConferenceBubble:
       
   147         removeConferenceBubble();
       
   148         break;
       
   149 
       
   150     case EPhoneViewSendToBackground:
       
   151     case EPhoneViewBringIdleToForeground:
       
   152         if (m_homeScreenToForeground) {
       
   153             RWsSession& wsSession = CEikonEnv::Static()->WsSession();
       
   154 
       
   155             TApaTaskList taskList( wsSession );
       
   156             _LIT(KPhoneHsAppName,"hsapplication");
       
   157             TApaTask task = taskList.FindApp(KPhoneHsAppName);
       
   158             task.BringToForeground();
       
   159         } else {
       
   160             XQServiceUtil::toBackground(true);
       
   161         }
       
   162 
       
   163         m_homeScreenToForeground = false;
       
   164         break;
       
   165     case EPhoneViewRemoveAllCallHeaders:
       
   166         removeAllCallHeaders();
       
   167         break;
       
   168     case EPhoneViewRemoveNumberEntry:
       
   169     case EPhoneViewClearNumberEntryContent: // Fall through
       
   170         removeDialpad();
       
   171         break;
       
   172     case EPhoneViewAddToConference:
       
   173         addToConference();
       
   174         break;
       
   175     case EPhoneViewRemoveDtmfNote:
       
   176         m_noteController->removeDtmfNote();
       
   177         break;
       
   178     case EPhoneViewRemoveNote:
       
   179         m_noteController->removeNote();
       
   180         break;
       
   181     case EPhoneViewRemoveQuery:
       
   182         m_noteController->removeQuery();
       
   183         break;
       
   184     case EPhoneViewRemovePhoneDialogs:
       
   185         m_noteController->removeNote();
       
   186         m_noteController->removeQuery();
       
   187         break;
       
   188     case EPhoneViewRemoveGlobalNote:
       
   189     case EPhoneViewRemoveGlobalWaitNote:
       
   190         m_noteController->removeGlobalWaitNote();
       
   191         break;
       
   192     case EPhoneViewUpdateFSW:
       
   193         setHidden(true);
       
   194         break;
       
   195     default:
       
   196         break;
       
   197     }
       
   198  CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId );
       
   199 }
       
   200 
       
   201 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TInt aCallId)
       
   202 {
       
   203     switch (aCmdId) {
       
   204     case EPhoneViewRemoveCallHeader:
       
   205         {
       
   206         m_bubbleWrapper->bubbleManager().startChanges();
       
   207         int bubble = m_bubbleWrapper->bubbles().value(aCallId);
       
   208         m_view.clearBubbleCommands(bubble);
       
   209         m_view.removeExpandAction(bubble);
       
   210         m_bubbleWrapper->removeCallHeader (aCallId);
       
   211         m_bubbleWrapper->bubbleManager().endChanges();
       
   212         m_indicatorController->clearActiveCallData();
       
   213         }
       
   214         break;
       
   215     case EPhoneViewRemoveFromConference:
       
   216         removeCallFromConference(aCallId);
       
   217         break;
       
   218     case EPhoneViewPrivateFromConference:
       
   219         setPrivateFromConference(aCallId);
       
   220         break;
       
   221     default:
       
   222         break;
       
   223     }
       
   224    CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId, aCallId );
       
   225 }
       
   226 
       
   227 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TPhoneCommandParam* aCommandParam)
       
   228 {
       
   229     switch (aCmdId) {
       
   230     case EPhoneViewSetTopApplication:
       
   231         setTopApplication (aCommandParam);
       
   232         break;
       
   233     case EPhoneViewPlayRingTone:
       
   234         m_ringingtonecontroller->PlayRingToneL( aCommandParam );
       
   235         break;
       
   236     case EPhoneViewSetTouchPaneButtons:
       
   237         setTouchButtons (aCommandParam);
       
   238         setExpandActions();
       
   239         break;
       
   240     case EPhoneViewUpdateCba:
       
   241         setToolbarButtons (aCommandParam);
       
   242         break;
       
   243     case EPhoneViewSetHoldFlag:
       
   244         setCallHoldFlag (aCommandParam);
       
   245         break;
       
   246     case EPhoneViewGetHoldFlag:
       
   247         callHoldFlag (aCommandParam);
       
   248         break;
       
   249     case EPhoneViewSetNaviPaneAudioVolume:
       
   250         setAudioVolumeSliderValue (aCommandParam);
       
   251         break;
       
   252     case EPhoneViewActivateMuteUIChanges:
       
   253         setMuteIndication(aCommandParam);
       
   254         break;
       
   255     case EPhoneViewGetCountOfActiveCalls:
       
   256         activeCallCount(aCommandParam);
       
   257         break;
       
   258     case EPhoneViewActivateAudioPathUIChanges:
       
   259         setAudioPath(aCommandParam);
       
   260         break;
       
   261     case EPhoneViewGetExpandedBubbleCallId:
       
   262         expandedBubbleCallId(aCommandParam);
       
   263         break;
       
   264     case EPhoneViewGetIsConference:
       
   265         isConference(aCommandParam);
       
   266         break;
       
   267     case EPhoneViewBringAppToForeground:
       
   268         bringToForeground();
       
   269         break;
       
   270     case EPhoneViewShowGlobalNote:
       
   271         showGlobalNote(aCommandParam);
       
   272         break;
       
   273     case EPhoneViewSetNumberEntryVisible:
       
   274         setDialpadVisibility(aCommandParam);
       
   275         break;
       
   276     case EPhoneViewGetNumberEntryCount:
       
   277         getDialpadStringLength(aCommandParam);
       
   278         break;
       
   279     case EPhoneViewGetNumberFromEntry:
       
   280         getNumberFromDialpad(aCommandParam);
       
   281         break;
       
   282     case EPhoneViewShowNote:
       
   283         showNote(aCommandParam);
       
   284         break;
       
   285     case EPhoneViewShowQuery:
       
   286         m_noteController->showQuery(aCommandParam);
       
   287         break;
       
   288     case EPhoneViewOpenSoftRejectEditor:
       
   289         m_messageController->openSoftRejectMessageEditor(aCommandParam);
       
   290         break;
       
   291     default:
       
   292         break;
       
   293     }
       
   294     CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId, *aCommandParam );
       
   295 }
       
   296 
       
   297 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TInt aCallId,
       
   298     TPhoneCommandParam *aCommandParam)
       
   299 {
       
   300     switch (aCmdId) {
       
   301     case EPhoneViewCreateCallHeader:
       
   302         createCallHeader (aCallId, aCommandParam);
       
   303         break;
       
   304     case EPhoneViewCreateEmergencyCallHeader:
       
   305         createEmergencyCallHeader (aCallId, aCommandParam);
       
   306         break;
       
   307     case EPhoneViewUpdateBubble:
       
   308         updateCallHeaderState (aCallId, aCommandParam);
       
   309         setExpandActions();
       
   310         break;
       
   311     case EPhoneViewUpdateCallHeaderRemoteInfoData:
       
   312         updateCallHeaderRemoteInfo (aCallId, aCommandParam);
       
   313         break;
       
   314     case EPhoneViewUpdateCallHeaderRemoteInfoDataAndLabel:
       
   315         updateCallHeaderRemoteInfoAndLabel(aCallId, aCommandParam);
       
   316         break;
       
   317     case EPhoneViewCreateConference:
       
   318         createConferenceBubble(aCallId, aCommandParam);
       
   319         break;
       
   320     case EPhoneViewGetCallExistsInConference:
       
   321         conferenceCallId(aCallId, aCommandParam);
       
   322         break;
       
   323     case EPhoneViewUpdateCallHeaderCallDuration:
       
   324     {
       
   325         TPhoneCmdParamInteger *time = static_cast<TPhoneCmdParamInteger *>(aCommandParam);
       
   326         QString duration = convertDuration(time->Integer());
       
   327         PHONE_DEBUG2("call duration:", duration);
       
   328         int bubbleId = m_bubbleWrapper->bubbleId(aCallId);
       
   329         
       
   330         if (-1 != bubbleId) {
       
   331             m_bubbleWrapper->bubbleManager().updateCallTime(bubbleId, duration);
       
   332         }
       
   333         break;
       
   334     }
       
   335 
       
   336     case EPhoneViewCipheringInfoChange:
       
   337     {
       
   338         handleCipheringInfoChange(aCallId, aCommandParam);
       
   339         break;
       
   340     }
       
   341 
       
   342     default:
       
   343         break;
       
   344     }
       
   345     CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId, aCallId, *aCommandParam );
       
   346 }
       
   347 
       
   348 void PhoneUIQtViewAdapter::ExecuteCommandL (TPhoneViewCommandId aCmdId, TInt aCallId,
       
   349     TDesC &aMessage)
       
   350 {
       
   351     switch (aCmdId) {
       
   352 
       
   353     default:
       
   354         break;
       
   355     }
       
   356     CPhoneMediatorFactory::Instance()->Sender()->SendEvent( aCmdId, aCallId, &aMessage );
       
   357 }
       
   358 
       
   359 TPhoneViewResponseId PhoneUIQtViewAdapter::HandleCommandL (TPhoneViewCommandId aCmdId)
       
   360 {
       
   361     TPhoneViewResponseId response = EPhoneViewResponseSuccess;
       
   362 
       
   363     switch (aCmdId) {
       
   364     case EPhoneIsDTMFDialerVisible:
       
   365     case EPhoneViewIsDTMFEditorVisible: //TODO
       
   366     case EPhoneIsCustomizedDialerVisible:
       
   367     case EPhoneViewGetNeedToSendToBackgroundStatus:
       
   368         // TODO: currently not supported
       
   369         response = EPhoneViewResponseFailed;
       
   370         break;
       
   371     case EPhoneViewIsMenuBarVisible:
       
   372         {
       
   373         //TODO
       
   374         response = EPhoneViewResponseFailed;
       
   375         break;
       
   376         }
       
   377     case EPhoneViewGetNumberEntryIsVisibleStatus:
       
   378     case EPhoneViewGetNumberEntryIsUsedStatus: // Fall through
       
   379         {
       
   380         response = (m_view.isDialpadVisible() && !m_dialpadAboutToClose) ?
       
   381                         EPhoneViewResponseSuccess :
       
   382                         EPhoneViewResponseFailed;
       
   383         break;
       
   384         }
       
   385     default:
       
   386         break;
       
   387     }
       
   388 
       
   389     return response;
       
   390 }
       
   391 
       
   392 TPhoneViewResponseId PhoneUIQtViewAdapter::HandleCommandL (TPhoneViewCommandId aCmdId,
       
   393     TPhoneCommandParam *aCommandParam)
       
   394 {
       
   395     TPhoneViewResponseId viewResponse = EPhoneViewResponseSuccess;
       
   396 
       
   397     switch (aCmdId) {
       
   398     case EPhoneViewGetCallIdByState:
       
   399         viewResponse = callIdByState (aCommandParam);
       
   400         break;
       
   401     case EPhoneViewSelectedConfMember:
       
   402         viewResponse = getSelectedConferenceMember (aCommandParam);
       
   403         break;
       
   404     default:
       
   405         break;
       
   406     }
       
   407 
       
   408     return viewResponse;
       
   409 }
       
   410 
       
   411 void PhoneUIQtViewAdapter::ExecuteCommand (TPhoneViewCommandId aCmdId)
       
   412 {
       
   413     switch (aCmdId) {
       
   414     case EPhoneSetConferenceExpanded:
       
   415         m_bubbleWrapper->bubbleManager ().startChanges ();
       
   416         m_bubbleWrapper->bubbleManager().setExpandedConferenceCallHeader(
       
   417                 m_bubbleWrapper->conferenceCallList().size());
       
   418         m_bubbleWrapper->bubbleManager ().endChanges ();
       
   419         break;
       
   420     case EPhoneViewBeginUpdate:
       
   421         m_bubbleWrapper->bubbleManager ().startChanges ();
       
   422         break;
       
   423     case EPhoneViewEndUpdate:
       
   424         m_bubbleWrapper->bubbleManager ().endChanges ();
       
   425         break;
       
   426     case EPhoneViewOpenContacts:
       
   427         openContacts();
       
   428         break;
       
   429     default:
       
   430         break;
       
   431     }
       
   432 }
       
   433 
       
   434 void PhoneUIQtViewAdapter::ExecuteCommand (TPhoneViewCommandId aCmdId, TPhoneCommandParam *aCommandParam)
       
   435 {
       
   436     switch (aCmdId) {
       
   437     case EPhoneViewGetAudioVolumeLevel:
       
   438         writeAudioVolumeLevel (aCommandParam);
       
   439         break;
       
   440     case EPhoneViewGetNumberFromEntry:
       
   441         getNumberFromDialpad(aCommandParam);
       
   442         break;
       
   443     case EPhoneViewSetDtmfOptionsFlag:
       
   444         //TODO
       
   445         break;
       
   446     case EPhoneViewSetVideoCallDTMFVisibilityFlag:
       
   447         //TODO
       
   448         break;
       
   449     case EPhoneViewBackButtonActive: {
       
   450         TPhoneCmdParamBoolean *param = static_cast<TPhoneCmdParamBoolean *>(aCommandParam);
       
   451         m_view.setBackButtonVisible(param->Boolean());
       
   452 		}
       
   453         break;
       
   454     case EPhoneViewHsToForegroundAfterCall: {
       
   455         TPhoneCmdParamBoolean *param = static_cast<TPhoneCmdParamBoolean *>(aCommandParam);
       
   456         m_homeScreenToForeground = param->Boolean();
       
   457         }
       
   458         break;
       
   459     default:
       
   460         break;
       
   461     }
       
   462 }
       
   463 
       
   464 const TDesC& PhoneUIQtViewAdapter::FetchContent ()
       
   465 {
       
   466     return KNullDesC;
       
   467 }
       
   468 
       
   469 void PhoneUIQtViewAdapter::dialpadClosed()
       
   470 {
       
   471     m_dialpadAboutToClose = true;
       
   472     setCallMenu();
       
   473 }
       
   474 
       
   475 PhoneNoteController* PhoneUIQtViewAdapter::noteController() const
       
   476 {
       
   477     return m_noteController;
       
   478 }
       
   479 
       
   480 void PhoneUIQtViewAdapter::keyReleased(QKeyEvent */*event*/)
       
   481 {
       
   482     if (m_view.isDialpadVisible() &&
       
   483         false == m_dialpadAboutToClose ) {
       
   484         setDialpadMenu();
       
   485     }
       
   486 }
       
   487 
       
   488 void PhoneUIQtViewAdapter::handleWindowActivated()
       
   489 {
       
   490     m_indicatorController->disableActiveCallIndicator();
       
   491 }
       
   492 
       
   493 void PhoneUIQtViewAdapter::handleWindowDeactivated()
       
   494 {
       
   495     m_indicatorController->enableActiveCallIndicator();
       
   496 }
       
   497 
       
   498 void PhoneUIQtViewAdapter::setTopApplication (TPhoneCommandParam *commandParam)
       
   499 {
       
   500     TPhoneCmdParamInteger *integerParam = static_cast<TPhoneCmdParamInteger *> (commandParam);
       
   501     CPhonePubSubProxy::Instance()->ChangePropertyValue(
       
   502         KPSUidUikon,
       
   503         KUikVideoCallTopApp,
       
   504         integerParam->Integer() );
       
   505 
       
   506     // Hide the Phone icon if it is not the top application
       
   507     // TODO: how to do this?
       
   508 }
       
   509 
       
   510 int PhoneUIQtViewAdapter::idleAppUid ()
       
   511 {
       
   512 // <-- QT HS START -->
       
   513    /* if ( m_idleUid == -1 ) {
       
   514         // Get Idle's UID from PubSub.
       
   515         m_idleUid = CPhonePubSubProxy::Instance()->Value (KPSUidAiInformation,
       
   516             KActiveIdleUid );
       
   517     }*/
       
   518     m_idleUid=0x20022F35;
       
   519 // <-- QT HS END -->
       
   520     return m_idleUid;
       
   521 }
       
   522 
       
   523 void PhoneUIQtViewAdapter::createCallHeader(
       
   524     int callId,
       
   525     TPhoneCommandParam *commandParam )
       
   526 {
       
   527     PHONE_DEBUG("PhoneUIQtViewAdapter::createCallHeader");
       
   528     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
       
   529 
       
   530     TPhoneCmdParamCallHeaderData &data =
       
   531         static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
       
   532 
       
   533     m_bubbleWrapper->bubbleManager ().startChanges ();
       
   534 
       
   535     if (m_bubbleWrapper->bubbleManager().isConferenceExpanded())
       
   536         {
       
   537         m_bubbleWrapper->bubbleManager().setExpandedConferenceCallHeader(false);
       
   538         }
       
   539 
       
   540     int bubble = m_bubbleWrapper->createCallHeader (callId);
       
   541     m_bubbleWrapper->setState (callId, bubble, data.CallState ());
       
   542     m_bubbleWrapper->setCli (bubble, data.CLIText ());
       
   543     m_bubbleWrapper->setServiceId(callId, data.ServiceId());
       
   544     m_bubbleWrapper->setSecondaryCli (bubble, data.CNAPText ());
       
   545     m_bubbleWrapper->setLabel (bubble, data.LabelText ());
       
   546     m_bubbleWrapper->setCallType (bubble, data.CallType ());
       
   547     m_bubbleWrapper->setDivert (bubble, data.Diverted ());
       
   548     m_bubbleWrapper->setCiphering(bubble, data.CipheringIndicatorAllowed(), data.Ciphering());
       
   549 
       
   550     if (data.Picture().Length()) {
       
   551         QString imagePath =
       
   552             QString::fromUtf16(data.Picture().Ptr(),data.Picture().Length());
       
   553         m_bubbleWrapper->bubbleManager().setCallObjectImage(bubble,imagePath);
       
   554     } else {
       
   555         m_bubbleWrapper->bubbleManager().setCallObjectFromTheme(bubble);
       
   556     }
       
   557     m_bubbleWrapper->bubbleManager ().endChanges ();
       
   558     
       
   559     if (1 == m_bubbleWrapper->bubbles().keys().count()) {
       
   560         setHidden(false);
       
   561     }
       
   562     m_indicatorController->setActiveCallData( data.CLIText(), KNullDesC );
       
   563 }
       
   564 
       
   565 void PhoneUIQtViewAdapter::createEmergencyCallHeader(
       
   566     int callId,
       
   567     TPhoneCommandParam *commandParam)
       
   568 {
       
   569     PHONE_DEBUG("PhoneUIQtViewAdapter::createEmergencyCallHeader");
       
   570     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdEmergencyCallHeaderData);
       
   571 
       
   572     TPhoneCmdParamEmergencyCallHeaderData &data =
       
   573         static_cast<TPhoneCmdParamEmergencyCallHeaderData &> (*commandParam);
       
   574 
       
   575     m_bubbleWrapper->bubbleManager ().startChanges ();
       
   576     int bubble = m_bubbleWrapper->createCallHeader (callId);
       
   577     m_bubbleWrapper->setLabel (bubble, data.LabelText ());
       
   578     m_bubbleWrapper->setCli (bubble, data.HeaderText ());
       
   579     m_bubbleWrapper->setCiphering(bubble, data.CipheringIndicatorAllowed(), data.Ciphering());
       
   580     m_bubbleWrapper->bubbleManager ().endChanges ();
       
   581 }
       
   582 
       
   583 void PhoneUIQtViewAdapter::updateCallHeaderState (
       
   584     int callId,
       
   585     TPhoneCommandParam *commandParam)
       
   586 {
       
   587     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderState");
       
   588     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
       
   589 
       
   590     TPhoneCmdParamCallHeaderData &data =
       
   591             static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
       
   592 
       
   593     int bubble = m_bubbleWrapper->bubbleId (callId);
       
   594     if ( -1 != bubble ) {
       
   595         m_bubbleWrapper->bubbleManager ().startChanges ();
       
   596         m_bubbleWrapper->setState (callId, bubble, data.CallState ());
       
   597         m_bubbleWrapper->setLabel (bubble, data.LabelText ());
       
   598         m_bubbleWrapper->setDivert (bubble, data.Diverted ());
       
   599         m_bubbleWrapper->bubbleManager ().endChanges ();
       
   600     }
       
   601 }
       
   602 
       
   603 void PhoneUIQtViewAdapter::updateCallHeaderRemoteInfo (int callId, TPhoneCommandParam *commandParam)
       
   604 {
       
   605     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderRemoteInfo");
       
   606     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
       
   607 
       
   608     TPhoneCmdParamCallHeaderData &data =
       
   609          static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
       
   610 
       
   611 
       
   612      int bubble = m_bubbleWrapper->bubbleId (callId);
       
   613      if ( -1 != bubble ) {
       
   614          m_bubbleWrapper->bubbleManager ().startChanges ();
       
   615          m_bubbleWrapper->setCli (bubble, data.CLIText ());
       
   616          m_bubbleWrapper->setSecondaryCli (bubble, data.CNAPText ());
       
   617          m_bubbleWrapper->setDivert (bubble, data.Diverted ());
       
   618          m_bubbleWrapper->bubbleManager ().endChanges ();
       
   619      }
       
   620 
       
   621 }
       
   622 
       
   623 void PhoneUIQtViewAdapter::updateCallHeaderRemoteInfoAndLabel (int callId, TPhoneCommandParam *commandParam)
       
   624 {
       
   625     PHONE_DEBUG("PhoneUIQtViewAdapter::updateCallHeaderRemoteInfoAndLabel");
       
   626     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
       
   627 
       
   628     TPhoneCmdParamCallHeaderData &data =
       
   629          static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
       
   630 
       
   631      int bubble = m_bubbleWrapper->bubbleId (callId);
       
   632      if ( -1 != bubble ) {
       
   633          m_bubbleWrapper->bubbleManager ().startChanges ();
       
   634          m_bubbleWrapper->setCli (bubble, data.CLIText ());
       
   635          m_bubbleWrapper->setSecondaryCli (bubble, data.CNAPText ());
       
   636          m_bubbleWrapper->setLabel (bubble, data.LabelText ());
       
   637          m_bubbleWrapper->setDivert (bubble, data.Diverted ());
       
   638          m_bubbleWrapper->bubbleManager ().endChanges ();
       
   639      }
       
   640 }
       
   641 
       
   642 void PhoneUIQtViewAdapter::handleCipheringInfoChange(int callId, TPhoneCommandParam *commandParam)
       
   643 {
       
   644     TPhoneCmdParamCallHeaderData *param =
       
   645         static_cast<TPhoneCmdParamCallHeaderData*>(commandParam);
       
   646 
       
   647     int bubble = m_bubbleWrapper->bubbleId(callId);        
       
   648     if ( -1 != bubble ) {        
       
   649         m_bubbleWrapper->bubbleManager().startChanges();
       
   650         m_bubbleWrapper->setCiphering(m_bubbleWrapper->bubbleId(callId),
       
   651                                       param->CipheringIndicatorAllowed(),
       
   652                                       param->Ciphering());
       
   653         m_bubbleWrapper->bubbleManager().endChanges();
       
   654     }
       
   655 }
       
   656 
       
   657 TPhoneViewResponseId PhoneUIQtViewAdapter::callIdByState (TPhoneCommandParam *commandParam)
       
   658 {
       
   659     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallStateData);
       
   660 
       
   661     TPhoneCmdParamCallStateData &stateParam =
       
   662         static_cast<TPhoneCmdParamCallStateData &>(*commandParam);
       
   663 
       
   664     stateParam.SetCallId (m_bubbleWrapper->callId (stateParam.CallState ()));
       
   665     return EPhoneViewResponseSuccess;
       
   666 }
       
   667 
       
   668 void PhoneUIQtViewAdapter::setTouchButtons (TPhoneCommandParam *commandParam)
       
   669 {
       
   670     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
   671 
       
   672     TPhoneCmdParamBoolean &param =
       
   673         static_cast<TPhoneCmdParamBoolean &>(*commandParam);
       
   674     bool emergencyCall = param.Boolean();
       
   675 
       
   676     m_bubbleWrapper->bubbleManager ().startChanges ();
       
   677     m_view.clearParticipantListActions();
       
   678 
       
   679     QList<int> bubbles = m_bubbleWrapper->bubbles().keys();
       
   680 
       
   681     m_resourceAdapter->buttonsController()->setButtonFlags(
       
   682             PhoneUIQtButtonsController::DisableJoin,
       
   683             (5 <= m_bubbleWrapper->conferenceCallList().count()));
       
   684 
       
   685     for (int j = 0; j < bubbles.size(); ++j){
       
   686         int callId = bubbles.at(j);
       
   687         // Clear bubble
       
   688         m_view.clearBubbleCommands(m_bubbleWrapper->bubbles().value(callId));
       
   689 
       
   690 		// Get bubble actions by call type
       
   691         QMap<PhoneAction::ActionType, PhoneAction *> actions =
       
   692             m_uiCommandController->pushButtonActionsForCall(
       
   693                                m_bubbleWrapper->callStates().value(callId),
       
   694                                emergencyCall,
       
   695                                m_bubbleWrapper->callStates(),
       
   696                                m_bubbleWrapper->serviceIds(),
       
   697                                m_bubbleWrapper->serviceIdByCallId(callId),
       
   698                                callId);
       
   699 
       
   700         QList<PhoneAction *> values = actions.values();
       
   701         for (int i = 0; i < values.size (); ++i) {
       
   702             PhoneAction *action = values.at (i);
       
   703             m_view.addBubbleCommand(m_bubbleWrapper->bubbles().value(callId),
       
   704                                     *action);
       
   705             delete action;
       
   706         }
       
   707     }
       
   708 
       
   709     setParticipantListActions();
       
   710     setExpandedConferenceCallHeader();
       
   711     setBubbleSelectionFlag();
       
   712     setMenu();
       
   713 
       
   714     m_bubbleWrapper->bubbleManager ().endChanges ();
       
   715 }
       
   716 
       
   717 void PhoneUIQtViewAdapter::setToolbarButtons (TPhoneCommandParam *commandParam)
       
   718 {
       
   719     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdInteger);
       
   720 
       
   721     TPhoneCmdParamInteger &intParam =
       
   722         static_cast<TPhoneCmdParamInteger &>(*commandParam);
       
   723 
       
   724     m_resourceAdapter->buttonsController()->setButtonFlags(
       
   725             PhoneUIQtButtonsController::DisableJoin,
       
   726             (5 <= m_bubbleWrapper->conferenceCallList().count()));
       
   727 
       
   728     QMap<PhoneAction::ActionType, PhoneAction *> actions = m_resourceAdapter->convert (intParam.Integer ());
       
   729     QList<PhoneAction*> values = actions.values();
       
   730 
       
   731     if (actions.count()) {
       
   732         m_view.setToolbarActions(values);
       
   733     }
       
   734 
       
   735     qDeleteAll(actions);
       
   736 }
       
   737 
       
   738 void PhoneUIQtViewAdapter::setCallHoldFlag (TPhoneCommandParam *commandParam)
       
   739 {
       
   740     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
   741 
       
   742     TPhoneCmdParamBoolean &boolParam =
       
   743         static_cast<TPhoneCmdParamBoolean &>(*commandParam);
       
   744 
       
   745     m_resourceAdapter->buttonsController()->setButtonFlags(PhoneUIQtButtonsController::Hold,
       
   746                                                            boolParam.Boolean ());
       
   747 }
       
   748 
       
   749 void PhoneUIQtViewAdapter::callHoldFlag (TPhoneCommandParam *commandParam)
       
   750 {
       
   751     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
   752 
       
   753     TPhoneCmdParamBoolean &boolParam =
       
   754         static_cast<TPhoneCmdParamBoolean &>(*commandParam);
       
   755     boolParam.SetBoolean (m_resourceAdapter->buttonsController()->getButtonFlags(PhoneUIQtButtonsController::Hold));
       
   756 }
       
   757 
       
   758 void PhoneUIQtViewAdapter::writeAudioVolumeLevel (TPhoneCommandParam *commandParam)
       
   759 {
       
   760     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdInteger);
       
   761 
       
   762     TPhoneCmdParamInteger &intParam =
       
   763         static_cast<TPhoneCmdParamInteger &>(*commandParam);
       
   764     intParam.SetInteger (m_view.volumeSliderValue ());
       
   765 }
       
   766 
       
   767 void PhoneUIQtViewAdapter::setAudioVolumeSliderValue (TPhoneCommandParam *commandParam)
       
   768 {
       
   769     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdInteger);
       
   770 
       
   771     TPhoneCmdParamInteger &intParam =
       
   772         static_cast<TPhoneCmdParamInteger &>(*commandParam);
       
   773 
       
   774     m_view.setVolumeSliderValue(intParam.Integer(),
       
   775                                 EPhoneInCallCmdSetVolumeLevel,
       
   776                                 KPhoneVolumeMaxValue,
       
   777                                 KPhoneVolumeMinValue );
       
   778 }
       
   779 
       
   780 void PhoneUIQtViewAdapter::setMuteIndication (TPhoneCommandParam *commandParam)
       
   781 {
       
   782     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
   783     TPhoneCmdParamBoolean &boolParam =
       
   784             static_cast<TPhoneCmdParamBoolean &>(*commandParam);
       
   785     m_bubbleWrapper->bubbleManager().setPhoneMuted(boolParam.Boolean());
       
   786 }
       
   787 
       
   788 void PhoneUIQtViewAdapter::activeCallCount (TPhoneCommandParam *commandParam)
       
   789 {
       
   790     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdInteger);
       
   791 
       
   792     TPhoneCmdParamInteger &integerParam =
       
   793         static_cast<TPhoneCmdParamInteger&>(*commandParam);
       
   794     integerParam.SetInteger (m_bubbleWrapper->activeCallCount());
       
   795 }
       
   796 
       
   797 void PhoneUIQtViewAdapter::setAudioPath (TPhoneCommandParam *commandParam)
       
   798     {
       
   799     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdAudioOutput);
       
   800 
       
   801     TPhoneCmdParamAudioOutput &outputParam =
       
   802         static_cast<TPhoneCmdParamAudioOutput &>(*commandParam);
       
   803 
       
   804     m_resourceAdapter->buttonsController()->setButtonFlags(PhoneUIQtButtonsController::Ihf,
       
   805                               outputParam.AudioOutput() == EPELoudspeaker);
       
   806     m_resourceAdapter->buttonsController()->setButtonFlags(PhoneUIQtButtonsController::Wired,
       
   807                               outputParam.AudioOutput() == EPEWiredAudioAccessory);
       
   808     m_resourceAdapter->buttonsController()->setButtonFlags(PhoneUIQtButtonsController::Btaa,
       
   809                               outputParam.AudioOutput() == EPEBTAudioAccessory);
       
   810     }
       
   811 
       
   812 void PhoneUIQtViewAdapter::expandedBubbleCallId(TPhoneCommandParam *commandParam)
       
   813     {
       
   814     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdInteger);
       
   815 
       
   816     TPhoneCmdParamInteger &outputParam =
       
   817             static_cast<TPhoneCmdParamInteger &>(*commandParam);
       
   818     int callId = PHONE_CALL_NOT_FOUND;
       
   819 
       
   820     if ( 0<m_bubbleWrapper->callStates().keys().size() ) {
       
   821         int bubbleId = m_bubbleWrapper->bubbleManager().expandedBubble();
       
   822         callId = m_bubbleWrapper->callIdByBubbleId(bubbleId);
       
   823     }
       
   824 
       
   825     outputParam.SetInteger( callId );
       
   826     }
       
   827 
       
   828 void PhoneUIQtViewAdapter::openDialpad()
       
   829     {
       
   830     m_dialpadAboutToClose = false;
       
   831     m_view.showDialpad();
       
   832     setDialpadMenu();
       
   833     }
       
   834 
       
   835 void PhoneUIQtViewAdapter::createConferenceBubble(int callId, TPhoneCommandParam *commandParam)
       
   836 {
       
   837     PHONE_DEBUG("PhoneUIQtViewAdapter::createConferenceBubble");
       
   838     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdCallHeaderData);
       
   839 
       
   840     TPhoneCmdParamCallHeaderData &data =
       
   841          static_cast<TPhoneCmdParamCallHeaderData &> (*commandParam);
       
   842 
       
   843     int bubble = m_bubbleWrapper->createConferenceBubble(
       
   844             callId, data.CallState(), data.LabelText(), data.CLIText());
       
   845 
       
   846     m_bubbleWrapper->setServiceId(callId,data.ServiceId());
       
   847     m_bubbleWrapper->setCiphering(bubble, data.CipheringIndicatorAllowed(), data.Ciphering());
       
   848 }
       
   849 
       
   850 void PhoneUIQtViewAdapter::conferenceCallId(int callId, TPhoneCommandParam *commandParam)
       
   851 {
       
   852     PHONE_DEBUG("PhoneUIQtViewAdapter::conferenceCallId");
       
   853     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
   854 
       
   855     TPhoneCmdParamBoolean*  conferenceDataValue =
       
   856         static_cast<TPhoneCmdParamBoolean*>(
       
   857                 commandParam );
       
   858 
       
   859     conferenceDataValue->SetBoolean(m_bubbleWrapper->conferenceCallId(callId));
       
   860 }
       
   861 
       
   862 void PhoneUIQtViewAdapter::removeConferenceBubble()
       
   863 {
       
   864     m_bubbleWrapper->bubbleManager().startChanges();
       
   865     m_view.removeExpandAction(m_bubbleWrapper->bubbleId(KConferenceCallId));
       
   866     m_bubbleWrapper->removeConferenceBubble();
       
   867     m_bubbleWrapper->bubbleManager().endChanges();
       
   868 }
       
   869 
       
   870 void PhoneUIQtViewAdapter::isConference(TPhoneCommandParam *commandParam)
       
   871 {
       
   872     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
   873 
       
   874     TPhoneCmdParamBoolean*  conferenceDataValue =
       
   875         static_cast<TPhoneCmdParamBoolean*>(
       
   876                 commandParam );
       
   877 
       
   878     conferenceDataValue->SetBoolean(0<m_bubbleWrapper->conferenceCallList().size());
       
   879 }
       
   880 
       
   881 void PhoneUIQtViewAdapter::removeCallFromConference(int callId)
       
   882 {
       
   883     m_bubbleWrapper->bubbleManager().startChanges();
       
   884     m_bubbleWrapper->removeCallFromConference(callId);
       
   885     int bubbleId = m_bubbleWrapper->bubbles().value(callId);
       
   886     m_view.clearBubbleCommands(bubbleId);
       
   887     m_view.removeExpandAction(bubbleId);
       
   888     m_bubbleWrapper->removeCallHeader(callId);
       
   889     m_bubbleWrapper->bubbleManager().endChanges();
       
   890 }
       
   891 
       
   892 TPhoneViewResponseId PhoneUIQtViewAdapter::getSelectedConferenceMember(
       
   893         TPhoneCommandParam *commandParam)
       
   894 {
       
   895     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdInteger);
       
   896     TPhoneViewResponseId ret = EPhoneViewResponseSuccess;
       
   897     TPhoneCmdParamInteger*  integerValue =
       
   898         static_cast<TPhoneCmdParamInteger*>(
       
   899                 commandParam );
       
   900 
       
   901     int bubbleId = m_bubbleWrapper->bubbleManager().selectionIdInConference();
       
   902     int callId = m_bubbleWrapper->callIdByBubbleId(bubbleId);
       
   903 
       
   904     if (callId == -1) {
       
   905         ret = EPhoneViewResponseFailed;
       
   906     } else {
       
   907         integerValue->SetInteger(callId);
       
   908     }
       
   909 
       
   910     return ret;
       
   911 }
       
   912 
       
   913 void PhoneUIQtViewAdapter::setPrivateFromConference(int callId)
       
   914 {
       
   915     m_bubbleWrapper->bubbleManager().startChanges();
       
   916     m_bubbleWrapper->bubbleManager().setExpandedConferenceCallHeader(false);
       
   917     m_bubbleWrapper->removeCallFromConference(callId);
       
   918     m_view.clearBubbleCommands(m_bubbleWrapper->bubbles().value(callId));
       
   919     m_bubbleWrapper->bubbleManager().endChanges();
       
   920 }
       
   921 
       
   922 void PhoneUIQtViewAdapter::setExpandActions()
       
   923 {
       
   924     /* If there is 2 or more calls ongoing then we should
       
   925      * enable expancion swap*/
       
   926     int heldBubble = -1;
       
   927 
       
   928     if ( 2 <= m_bubbleWrapper->callStates().values().size() ) {
       
   929         if (callsExists(EPEStateConnected,EPEStateHeld)) {
       
   930             heldBubble =
       
   931                 m_bubbleWrapper->bubbleId(m_bubbleWrapper->callId(EPEStateHeld));
       
   932             m_view.setExpandAction(heldBubble, EPhoneInCallCmdSwap);
       
   933         } else if (callsExists(EPEStateConnected,EPEStateHeldConference)) {
       
   934             heldBubble =
       
   935                 m_bubbleWrapper->bubbleId(m_bubbleWrapper->callId(EPEStateHeldConference));
       
   936             m_view.setExpandAction(heldBubble, EPhoneInCallCmdSwap);
       
   937         } else if (callsExists(EPEStateRinging,EPEStateHeld)) {
       
   938             heldBubble =
       
   939                 m_bubbleWrapper->bubbleId(m_bubbleWrapper->callId(EPEStateHeld));
       
   940             m_view.setExpandAction(heldBubble, EPhoneInCallCmdUnhold);
       
   941         }
       
   942 
       
   943         QList<int> calls = m_bubbleWrapper->bubbles().keys();
       
   944         foreach (int call, calls) {
       
   945             int bubbleId = m_bubbleWrapper->bubbleId(call);
       
   946             if ( bubbleId != heldBubble ) {
       
   947                  m_view.setExpandAction(bubbleId, EPhoneCmdUpdateUiControls);
       
   948             }
       
   949         }
       
   950     }
       
   951 }
       
   952 
       
   953 bool PhoneUIQtViewAdapter::callsExists(int call1State, int call2State)
       
   954 {
       
   955     bool callsExist(false);
       
   956     if ( m_bubbleWrapper->callStates().values().contains(call1State) &&
       
   957          m_bubbleWrapper->callStates().values().contains(call2State) ) {
       
   958         callsExist = true;
       
   959     }
       
   960     return callsExist;
       
   961 }
       
   962 
       
   963 void PhoneUIQtViewAdapter::setParticipantListActions()
       
   964 {
       
   965     if ( 0<m_bubbleWrapper->conferenceCallList().size() ) {
       
   966         m_view.addParticipantListAction(
       
   967                 EPhoneInCallCmdPrivate,
       
   968                 hbTrId("txt_phone_button_private"),
       
   969                 HbIcon("qtg_mono_private_call"));
       
   970         m_view.addParticipantListAction(
       
   971                 EPhoneInCallCmdDrop,
       
   972                 hbTrId("txt_phone_button_drop"),
       
   973                 HbIcon("qtg_mono_drop_call"));
       
   974     }
       
   975 }
       
   976 
       
   977 void PhoneUIQtViewAdapter::setExpandedConferenceCallHeader()
       
   978 {
       
   979     int callId = PHONE_CALL_NOT_FOUND;
       
   980 
       
   981     if ( 1==m_bubbleWrapper->bubbles().keys().size()
       
   982          || (1<m_bubbleWrapper->bubbles().keys().size()
       
   983          && false == m_bubbleWrapper->callStates().values().contains(EPEStateRinging)
       
   984          && false == m_bubbleWrapper->callStates().values().contains(EPEStateDialing)
       
   985          && false == m_bubbleWrapper->callStates().values().contains(EPEStateConnecting)
       
   986          && false == m_bubbleWrapper->callStates().values().contains(EPEStateHeldConference))) {
       
   987 
       
   988         int bubbleId = m_bubbleWrapper->bubbleManager().expandedBubble();
       
   989         callId = m_bubbleWrapper->callIdByBubbleId(bubbleId);
       
   990     }
       
   991 
       
   992     m_bubbleWrapper->bubbleManager().setExpandedConferenceCallHeader(
       
   993             (KConferenceCallId == callId));
       
   994 }
       
   995 
       
   996 void PhoneUIQtViewAdapter::bringToForeground()
       
   997 {
       
   998     if(!m_carModeEnabled) {
       
   999         m_view.bringToForeground();
       
  1000     }
       
  1001 }
       
  1002 
       
  1003 void PhoneUIQtViewAdapter::showGlobalNote(
       
  1004         TPhoneCommandParam *commandParam)
       
  1005 {
       
  1006     m_noteController->showGlobalNote(commandParam);
       
  1007 }
       
  1008 
       
  1009 void PhoneUIQtViewAdapter::setDialpadVisibility(
       
  1010         TPhoneCommandParam *commandParam)
       
  1011 {
       
  1012     Q_ASSERT (commandParam->ParamId () == TPhoneCommandParam::EPhoneParamIdBoolean);
       
  1013     TPhoneCmdParamBoolean* booleanParam =
       
  1014         static_cast<TPhoneCmdParamBoolean*>(commandParam);
       
  1015 
       
  1016     if (booleanParam->Boolean()) {
       
  1017         m_dialpadAboutToClose = false;
       
  1018         m_view.showDialpad();
       
  1019     } else {
       
  1020         m_view.hideDialpad();
       
  1021     }
       
  1022 }
       
  1023 
       
  1024 void PhoneUIQtViewAdapter::removeAllCallHeaders()
       
  1025 {
       
  1026     if (m_bubbleWrapper->conferenceCallList().size()) {
       
  1027         removeConferenceBubble();
       
  1028     }
       
  1029 
       
  1030     QList<int> callIds = m_bubbleWrapper->bubbles().keys();
       
  1031 
       
  1032     for (int i=0; i<callIds.size(); ++i) {
       
  1033         int callId = callIds.at(i);
       
  1034         if (KEmergencyCallId != callId) {
       
  1035             m_bubbleWrapper->bubbleManager().startChanges();
       
  1036             int bubble = m_bubbleWrapper->bubbles().value(callId);
       
  1037             m_view.clearBubbleCommands(bubble);
       
  1038             m_view.removeExpandAction(bubble);
       
  1039             m_bubbleWrapper->removeCallHeader (callId);
       
  1040             m_bubbleWrapper->bubbleManager().endChanges();
       
  1041         }
       
  1042     }
       
  1043     m_indicatorController->clearActiveCallData();
       
  1044 }
       
  1045 
       
  1046 void PhoneUIQtViewAdapter::getNumberFromDialpad(
       
  1047         TPhoneCommandParam *commandParam)
       
  1048 {
       
  1049 
       
  1050     TPhoneCmdParamString* entryContent =
       
  1051         static_cast<TPhoneCmdParamString*>(commandParam);
       
  1052     
       
  1053     QString westernNumber = 
       
  1054         HbStringUtil::convertDigitsTo(m_view.dialpadText(), WesternDigit);
       
  1055     
       
  1056     (*entryContent->String()).Copy(westernNumber.utf16());         
       
  1057 }
       
  1058 
       
  1059 void PhoneUIQtViewAdapter::getDialpadStringLength(
       
  1060         TPhoneCommandParam *commandParam)
       
  1061 {
       
  1062 
       
  1063     TPhoneCmdParamInteger* integerParam =
       
  1064         static_cast<TPhoneCmdParamInteger*>(commandParam);
       
  1065 
       
  1066     integerParam->SetInteger(m_view.dialpadText().length());
       
  1067 }
       
  1068 
       
  1069 void PhoneUIQtViewAdapter::removeDialpad()
       
  1070 {
       
  1071     m_view.clearAndHideDialpad();
       
  1072 }
       
  1073 
       
  1074 void PhoneUIQtViewAdapter::addToConference()
       
  1075 {
       
  1076     m_bubbleWrapper->addToConferenceBubble();
       
  1077 }
       
  1078 
       
  1079 void PhoneUIQtViewAdapter::setMenu()
       
  1080 {
       
  1081     if (m_view.isDialpadVisible() && false == m_dialpadAboutToClose) {
       
  1082         setDialpadMenu();
       
  1083     } else {
       
  1084         setCallMenu();
       
  1085     }
       
  1086 }
       
  1087 
       
  1088 void PhoneUIQtViewAdapter::setCallMenu()
       
  1089 {
       
  1090     if ( 0<m_bubbleWrapper->callStates().keys().size() ) {
       
  1091         int bubbleId = m_bubbleWrapper->bubbleManager().expandedBubble();
       
  1092         int callId = m_bubbleWrapper->callIdByBubbleId(bubbleId);
       
  1093         m_uiCommandController->setCallMenuActions(
       
  1094                 m_bubbleWrapper->callStates(),
       
  1095                 m_bubbleWrapper->serviceIds(),
       
  1096                 m_bubbleWrapper->serviceIdByCallId(callId),
       
  1097                 callId );
       
  1098     }
       
  1099 
       
  1100 }
       
  1101 
       
  1102 void PhoneUIQtViewAdapter::setDialpadMenu()
       
  1103 {
       
  1104     m_uiCommandController->setDialpadMenuActions();
       
  1105 }
       
  1106 
       
  1107 void PhoneUIQtViewAdapter::showNote(TPhoneCommandParam *commandParam)
       
  1108 {
       
  1109     m_noteController->showNote(commandParam);
       
  1110 }
       
  1111 
       
  1112 QString PhoneUIQtViewAdapter::convertDuration(TInt secs)
       
  1113     {
       
  1114     QTime init(0,0,0);
       
  1115     QTime duration = init.addSecs(secs);
       
  1116     HbExtendedLocale locale = HbExtendedLocale::system();
       
  1117     QString durationString = locale.format(duration, QString(r_qtn_time_durat_long));
       
  1118     return HbStringUtil::convertDigits(durationString); 
       
  1119 } 
       
  1120 
       
  1121 void PhoneUIQtViewAdapter::setBubbleSelectionFlag()
       
  1122 {
       
  1123     bool selectionFlag = ((m_bubbleWrapper->callStates().
       
  1124                               values().contains(EPEStateRinging) &&
       
  1125                            m_bubbleWrapper->conferenceCallList().count())||
       
  1126                           m_bubbleWrapper->callStates().
       
  1127                               values().contains(EPEStateDialing) ||
       
  1128                           m_bubbleWrapper->callStates().
       
  1129                               values().contains(EPEStateConnecting));
       
  1130 
       
  1131     m_bubbleWrapper->bubbleManager().setBubbleSelectionDisabled(selectionFlag);
       
  1132 }
       
  1133 
       
  1134 void PhoneUIQtViewAdapter::HandlePropertyChangedL(const TUid& aCategory, 
       
  1135     const TUint aKey, const TInt aValue)
       
  1136 {
       
  1137     if((aCategory == KPSUidTelCarMode) && (aKey == KTelCarMode)) {
       
  1138         if(aValue == EPSCarModeOff) {
       
  1139             m_carModeEnabled = false;
       
  1140         } else if(aValue == EPSCarModeOn) {
       
  1141             m_carModeEnabled = true;
       
  1142         } else {
       
  1143             Q_ASSERT(false);
       
  1144         }
       
  1145     }
       
  1146 }
       
  1147 
       
  1148 void PhoneUIQtViewAdapter::setHidden(bool hidden)
       
  1149 {
       
  1150     TRAP_IGNORE(SetHiddenL(hidden));
       
  1151 }
       
  1152 
       
  1153 void PhoneUIQtViewAdapter::SetHiddenL(bool hidden)
       
  1154 {
       
  1155     CEikonEnv* env = CEikonEnv::Static();
       
  1156     
       
  1157     if (env) {
       
  1158         CApaWindowGroupName* windowGroupName =
       
  1159             CApaWindowGroupName::NewLC(
       
  1160                     env->WsSession(),
       
  1161                     env->RootWin().Identifier() );
       
  1162         
       
  1163         windowGroupName->SetHidden( hidden );
       
  1164         User::LeaveIfError(
       
  1165                 windowGroupName->SetWindowGroupName(
       
  1166                         env->RootWin() ) );
       
  1167         
       
  1168         CleanupStack::PopAndDestroy( windowGroupName );
       
  1169 
       
  1170         CAknSgcClient::AknSrv()->UpdateTaskList();
       
  1171     }
       
  1172 }
       
  1173 
       
  1174 void PhoneUIQtViewAdapter::openContacts()
       
  1175 {
       
  1176     XQServiceRequest snd("com.nokia.services.phonebookappservices.Launch","launch()", false);
       
  1177     int retValue;
       
  1178     snd.send(retValue);
       
  1179 }
       
  1180 
       
  1181