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