phoneapp/phoneuicontrol/src/cphonecallheadermanager.cpp
changeset 77 2be0b271d017
parent 72 c76a0b1755b9
equal deleted inserted replaced
72:c76a0b1755b9 77:2be0b271d017
     1 /*
       
     2 * Copyright (c) 2008 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:  Bubble manager wrapper.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <mpeengineinfo.h>
       
    19 #include <StringLoader.h>
       
    20 #include "cphonecallheadermanager.h"
       
    21 #include "tphonecallheaderparam.h"
       
    22 #include "tphonecmdparamboolean.h"
       
    23 #include "tphonecmdparaminteger.h"
       
    24 #include "tphonecmdparamcallheaderdata.h"
       
    25 #include "cphonemainresourceresolver.h"
       
    26 #include "phonerssbase.h"
       
    27 #include "phoneui.pan"
       
    28 #include "phoneviewcommanddefinitions.h"
       
    29 #include "phonelogger.h"
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 
       
    33 // ---------------------------------------------------------------------------
       
    34 // CPhoneCallHeaderManager::CPhoneCallHeaderManager
       
    35 // ---------------------------------------------------------------------------
       
    36 //
       
    37 CPhoneCallHeaderManager::CPhoneCallHeaderManager(
       
    38          MPhoneViewCommandHandle& aViewCommandHandle,
       
    39          MPhoneStateMachine& aStateMachine,
       
    40          MPhoneCustomization* aCustomization )
       
    41    : iViewCommandHandle ( aViewCommandHandle ),
       
    42      iStateMachine ( aStateMachine ),
       
    43      iCustomization ( aCustomization )
       
    44     {
       
    45     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::CPhoneCallHeaderManager() ");
       
    46     }
       
    47 
       
    48  // ---------------------------------------------------------------------------
       
    49  // CPhoneCallHeaderManager::NewL
       
    50  // ---------------------------------------------------------------------------
       
    51  //
       
    52 CPhoneCallHeaderManager* CPhoneCallHeaderManager::NewL( 
       
    53         MPhoneViewCommandHandle& aViewCommandHandle,
       
    54         MPhoneStateMachine& aStateMachine,
       
    55         MPhoneCustomization* aCustomization )
       
    56      {
       
    57      __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::NewL() ");
       
    58      CPhoneCallHeaderManager* self = new (ELeave) CPhoneCallHeaderManager(
       
    59              aViewCommandHandle,
       
    60              aStateMachine,
       
    61              aCustomization );
       
    62      
       
    63      CleanupStack::PushL( self );
       
    64      self->ConstructL();
       
    65      CleanupStack::Pop( self );
       
    66      
       
    67      return self;
       
    68      }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CPhoneCallHeaderManager::ConstructL
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CPhoneCallHeaderManager::ConstructL()
       
    75     {
       
    76     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::ConstructL() ");
       
    77     if ( !iCallHeaderParam )
       
    78         {
       
    79         iCallHeaderParam = new (ELeave) TPhoneCallHeaderParam ( *this, iStateMachine );
       
    80         }
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 //  CPhoneCallHeaderManager::~CPhoneCallHeaderManager
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 CPhoneCallHeaderManager::~CPhoneCallHeaderManager()
       
    88      {
       
    89      __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::~CPhoneCallHeaderManager() ");
       
    90      delete iCallHeaderParam;
       
    91      }
       
    92  
       
    93 // ======== LOCAL FUNCTIONS ========
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CPhoneCallHeaderManager::LoadResource
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CPhoneCallHeaderManager::LoadResource( TDes& aData, const TInt aResource )
       
   100     {
       
   101     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::LoadResource() ");
       
   102     __PHONELOG1( EBasic, EPhoneControl, "CPhoneCallHeaderManager::LoadResource - aResource: %d", aResource );
       
   103     StringLoader::Load(  
       
   104             aData, CPhoneMainResourceResolver::Instance()->ResolveResourceID( aResource ), 
       
   105             CCoeEnv::Static() );
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 //  CPhoneCallHeaderManager::UpdateCallHeaderInfoL
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 TPhoneCmdParamCallHeaderData CPhoneCallHeaderManager::UpdateCallHeaderInfoL( 
       
   113         const TInt aCallId )
       
   114     {
       
   115     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::UpdateCallHeaderInfoL() ");
       
   116     __ASSERT_DEBUG( iStateMachine.PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
       
   117     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   118     iCallHeaderParam->UpdateCallHeaderInfoL( 
       
   119                 aCallId, 
       
   120                 IsWaitingCallL( aCallId ), 
       
   121                 IsVideoCall( aCallId ), 
       
   122                 &callHeaderParam );
       
   123 
       
   124     callHeaderParam.SetCiphering(
       
   125         iStateMachine.PhoneEngineInfo()->IsSecureCall( aCallId ) );
       
   126     
       
   127     callHeaderParam.SetCipheringIndicatorAllowed(
       
   128         iStateMachine.PhoneEngineInfo()->SecureSpecified() );
       
   129 
       
   130     return callHeaderParam;    
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 //  TPhoneCallHeaderParam::GetRemoteInfoDataL
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 void CPhoneCallHeaderManager::GetRemoteInfoDataL( 
       
   138         const TInt aCallId, 
       
   139         TDes& aData ) const 
       
   140     {
       
   141     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::GetRemoteInfoDataL() ");
       
   142     iCallHeaderParam->GetRemoteInfoDataL( aCallId, aData);
       
   143     }
       
   144 
       
   145 // ---------------------------------------------------------------------------
       
   146 //  CPhoneCallHeaderManager::SetCallHeaderTextsForCallComingIn
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CPhoneCallHeaderManager::SetCallHeaderTextsForCallComingIn(
       
   150         const TInt aCallId, 
       
   151         const TBool aWaitingCall,
       
   152         TPhoneCmdParamCallHeaderData* aCallHeaderData )
       
   153     {
       
   154     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneCallHeaderManager::SetCallHeaderTextsForCallComingIn() ");
       
   155     __ASSERT_DEBUG( iStateMachine.PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
       
   156      
       
   157     iCallHeaderParam->SetCallHeaderTexts( 
       
   158             aCallId, 
       
   159             aWaitingCall, 
       
   160             IsVideoCall( aCallId ), 
       
   161             aCallHeaderData );
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 //  CPhoneCallHeaderManager::DisplayHeaderForCallComingInL
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 void CPhoneCallHeaderManager::DisplayHeaderForCallComingInL(
       
   169         const TInt aCallId, 
       
   170         const TBool aWaitingCall )
       
   171     {
       
   172     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneCallHeaderManager::DisplayHeaderForCallComingInL() ");
       
   173     __ASSERT_DEBUG( iStateMachine.PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
       
   174     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   175     iCallHeaderParam->SetIncomingCallHeaderParamsL( 
       
   176             aCallId, 
       
   177             aWaitingCall, 
       
   178             IsVideoCall( aCallId ), 
       
   179             &callHeaderParam );
       
   180 
       
   181     if( iCustomization )
       
   182         {
       
   183         // to do modifications to call header parameters
       
   184         // if VoIP call in question
       
   185         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
       
   186             KNullDesC );
       
   187         }
       
   188 
       
   189     // Display call header
       
   190     iViewCommandHandle.ExecuteCommandL( 
       
   191             EPhoneViewCreateCallHeader, 
       
   192             aCallId, 
       
   193             &callHeaderParam );    
       
   194     }
       
   195 
       
   196 // ---------------------------------------------------------------------------
       
   197 //  CPhoneCallHeaderManager::DisplayHeaderForOutgoingCallL
       
   198 // ---------------------------------------------------------------------------
       
   199 //
       
   200 void CPhoneCallHeaderManager::DisplayHeaderForOutgoingCallL( const TInt aCallId )
       
   201     {
       
   202     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::DisplayHeaderForOutgoingCallL() ");
       
   203     __ASSERT_DEBUG( iStateMachine.PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
       
   204     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   205     
       
   206     iCallHeaderParam->SetOutgoingCallHeaderParamsL( 
       
   207             aCallId,
       
   208             &callHeaderParam );
       
   209             
       
   210     if( iCustomization )
       
   211         {
       
   212         // to do modifications to call header parameters
       
   213         // if VoIP call in question
       
   214         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
       
   215             KNullDesC );
       
   216         }
       
   217     
       
   218     // Display call header for outgoing call
       
   219     iViewCommandHandle.ExecuteCommandL( 
       
   220             EPhoneViewCreateCallHeader, 
       
   221             aCallId, 
       
   222             &callHeaderParam );
       
   223     }
       
   224 
       
   225 // ---------------------------------------------------------------------------
       
   226 //  CPhoneCallHeaderManager::IsWaitingCallL
       
   227 // ---------------------------------------------------------------------------
       
   228 //
       
   229 TBool CPhoneCallHeaderManager::IsWaitingCallL( const TInt aCallId  ) const
       
   230     {
       
   231     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneCallHeaderManager::IsWaitingCallL() ");
       
   232     TBool waiting( EFalse );
       
   233     if ( iStateMachine.PhoneEngineInfo()->CallState( aCallId ) == EPEStateRinging )
       
   234         {
       
   235         TPhoneCmdParamInteger activeCallCount;
       
   236         iViewCommandHandle.ExecuteCommandL( 
       
   237                 EPhoneViewGetCountOfActiveCalls, 
       
   238                 &activeCallCount );
       
   239         // if there is other calls then ringing call is waiting call.
       
   240         if( activeCallCount.Integer() > 0 )
       
   241             {
       
   242             waiting = ETrue;
       
   243             }
       
   244         }
       
   245     __PHONELOG1( EBasic, EPhoneControl, "CPhoneCallHeaderManager::IsWaitingCallL - waiting: %d", waiting );
       
   246     return waiting;
       
   247     }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 //  CPhoneCallHeaderManager::IsVideoCall
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 TBool CPhoneCallHeaderManager::IsVideoCall( const TInt aCallId ) const
       
   254     {
       
   255     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::IsVideoCall() ");
       
   256     if( aCallId < 0 )
       
   257         {
       
   258         // Illegal call id, check call type command
       
   259         return ( iStateMachine.PhoneEngineInfo()->CallTypeCommand()
       
   260             == EPECallTypeVideo );  
       
   261         }
       
   262     return ( iStateMachine.PhoneEngineInfo()->CallType( aCallId )
       
   263             == EPECallTypeVideo );
       
   264     }
       
   265 
       
   266 // ---------------------------------------------------------------------------
       
   267 //  CPhoneCallHeaderManager::SetCallHeaderType
       
   268 // ---------------------------------------------------------------------------
       
   269 //
       
   270 void CPhoneCallHeaderManager::SetCallHeaderType( 
       
   271     TInt aCallHeaderType )
       
   272     {
       
   273     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::SetCallHeaderType() ");
       
   274     iCallHeaderParam->SetCallHeaderType( aCallHeaderType ); 
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 //  CPhoneCallHeaderManager::~CPhoneCallHeaderManager
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 TInt CPhoneCallHeaderManager::CallHeaderType() const
       
   282     {
       
   283     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::CallHeaderType() ");
       
   284     return iCallHeaderParam->CallHeaderType();            
       
   285     }
       
   286 
       
   287 // ---------------------------------------------------------------------------
       
   288 //  CPhoneCallHeaderManager::SetDivertIndication
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 void CPhoneCallHeaderManager::SetDivertIndication( const TBool aDivertIndication )
       
   292     {
       
   293     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::SetDivertIndication()");
       
   294     iCallHeaderParam->SetDivertIndication( aDivertIndication );
       
   295     }
       
   296 
       
   297 // -----------------------------------------------------------
       
   298 // CPhoneCallHeaderManager::LoadCallHeaderTexts
       
   299 // -----------------------------------------------------------
       
   300 //
       
   301 void CPhoneCallHeaderManager::LoadCallHeaderTexts(
       
   302     const TInt aLabelId, 
       
   303     const TInt aShortLabelId,
       
   304     TPhoneCmdParamCallHeaderData* aCallHeaderData ) 
       
   305     {
       
   306     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneCallHeaderManager::LoadCallHeaderTexts( ) ");
       
   307     if ( aLabelId != EPhoneStringList )
       
   308         {
       
   309         TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
       
   310         LoadResource( labelText, aLabelId );
       
   311         aCallHeaderData->SetLabelText( labelText );
       
   312 
       
   313         if ( aShortLabelId != EPhoneStringList )
       
   314             {
       
   315             TBuf<KPhoneCallHeaderLabelMaxLength> shortLabelText( KNullDesC );
       
   316             LoadResource( shortLabelText, aShortLabelId );       
       
   317             aCallHeaderData->SetShortLabelText( shortLabelText );        
       
   318             }
       
   319         }
       
   320     }
       
   321