phoneapp/phoneuicontrol/src/cphonecallheadermanager.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     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     
       
   176     iCallHeaderParam->SetIncomingCallHeaderParamsL( 
       
   177             aCallId, 
       
   178             aWaitingCall, 
       
   179             IsVideoCall( aCallId ), 
       
   180             &callHeaderParam );
       
   181 
       
   182     if( iCustomization )
       
   183         {
       
   184         // to do modifications to call header parameters
       
   185         // if VoIP call in question
       
   186         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
       
   187             KNullDesC );
       
   188         }
       
   189 
       
   190     // Display call header
       
   191     iViewCommandHandle.ExecuteCommandL( 
       
   192             EPhoneViewCreateCallHeader, 
       
   193             aCallId, 
       
   194             &callHeaderParam );    
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 //  CPhoneCallHeaderManager::DisplayHeaderForOutgoingCallL
       
   199 // ---------------------------------------------------------------------------
       
   200 //
       
   201 void CPhoneCallHeaderManager::DisplayHeaderForOutgoingCallL( const TInt aCallId )
       
   202     {
       
   203     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::DisplayHeaderForOutgoingCallL() ");
       
   204     __ASSERT_DEBUG( iStateMachine.PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
       
   205     TPhoneCmdParamCallHeaderData callHeaderParam;
       
   206     
       
   207     iCallHeaderParam->SetOutgoingCallHeaderParamsL( 
       
   208             aCallId,
       
   209             &callHeaderParam );
       
   210             
       
   211     if( iCustomization )
       
   212         {
       
   213         // to do modifications to call header parameters
       
   214         // if VoIP call in question
       
   215         iCustomization->ModifyCallHeaderTexts( aCallId, &callHeaderParam,
       
   216             KNullDesC );
       
   217         }
       
   218     
       
   219     // Display call header for outgoing call
       
   220     iViewCommandHandle.ExecuteCommandL( 
       
   221             EPhoneViewCreateCallHeader, 
       
   222             aCallId, 
       
   223             &callHeaderParam );
       
   224     }
       
   225 
       
   226 // ---------------------------------------------------------------------------
       
   227 //  CPhoneCallHeaderManager::IsWaitingCallL
       
   228 // ---------------------------------------------------------------------------
       
   229 //
       
   230 TBool CPhoneCallHeaderManager::IsWaitingCallL( const TInt aCallId  ) const
       
   231     {
       
   232     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneCallHeaderManager::IsWaitingCallL() ");
       
   233     TBool waiting( EFalse );
       
   234     if ( iStateMachine.PhoneEngineInfo()->CallState( aCallId ) == EPEStateRinging )
       
   235         {
       
   236         TPhoneCmdParamInteger activeCallCount;
       
   237         iViewCommandHandle.ExecuteCommandL( 
       
   238                 EPhoneViewGetCountOfActiveCalls, 
       
   239                 &activeCallCount );
       
   240         // if there is other calls then ringing call is waiting call.
       
   241         if( activeCallCount.Integer() > 0 )
       
   242             {
       
   243             waiting = ETrue;
       
   244             }
       
   245         }
       
   246     __PHONELOG1( EBasic, EPhoneControl, "CPhoneCallHeaderManager::IsWaitingCallL - waiting: %d", waiting );
       
   247     return waiting;
       
   248     }
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 //  CPhoneCallHeaderManager::IsVideoCall
       
   252 // ---------------------------------------------------------------------------
       
   253 //
       
   254 TBool CPhoneCallHeaderManager::IsVideoCall( const TInt aCallId ) const
       
   255     {
       
   256     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::IsVideoCall() ");
       
   257     if( aCallId < 0 )
       
   258         {
       
   259         // Illegal call id, check call type command
       
   260         return ( iStateMachine.PhoneEngineInfo()->CallTypeCommand()
       
   261             == EPECallTypeVideo );  
       
   262         }
       
   263     return ( iStateMachine.PhoneEngineInfo()->CallType( aCallId )
       
   264             == EPECallTypeVideo );
       
   265     }
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 //  CPhoneCallHeaderManager::SetCallHeaderType
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 void CPhoneCallHeaderManager::SetCallHeaderType( 
       
   272     TInt aCallHeaderType )
       
   273     {
       
   274     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::SetCallHeaderType() ");
       
   275     iCallHeaderParam->SetCallHeaderType( aCallHeaderType ); 
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------------------------
       
   279 //  CPhoneCallHeaderManager::~CPhoneCallHeaderManager
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 TInt CPhoneCallHeaderManager::CallHeaderType() const
       
   283     {
       
   284     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::CallHeaderType() ");
       
   285     return iCallHeaderParam->CallHeaderType();            
       
   286     }
       
   287 
       
   288 // ---------------------------------------------------------------------------
       
   289 //  CPhoneCallHeaderManager::SetDivertIndication
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 void CPhoneCallHeaderManager::SetDivertIndication( const TBool aDivertIndication )
       
   293     {
       
   294     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneCallHeaderManager::SetDivertIndication()");
       
   295     iCallHeaderParam->SetDivertIndication( aDivertIndication );           
       
   296     }
       
   297 
       
   298 // ---------------------------------------------------------------------------
       
   299 // CPhoneCallHeaderManager::SetPhoneNumberAvailabilityL
       
   300 // ---------------------------------------------------------------------------
       
   301 //
       
   302 void CPhoneCallHeaderManager::SetPhoneNumberAvailabilityL( 
       
   303         const TInt aNumberLength,
       
   304         const TBool aContactInfoAvailable )
       
   305     {
       
   306     __LOGMETHODSTARTEND( 
       
   307             EPhoneControl, 
       
   308             "CPhoneCallHeaderManager::SetPhoneNumberAvailabilityL() ");
       
   309     TPhoneCmdParamBoolean phoneNumberAvailable;
       
   310     if( aNumberLength || aContactInfoAvailable )
       
   311         {
       
   312         // Phone number is available straight or via contact info
       
   313         // so switch to video/voice call is possible
       
   314         __PHONELOG( EBasic, 
       
   315                 EPhoneControl, 
       
   316                 "CPhoneCallHeaderManager::SetPhoneNumberAvailabilityL - Phonenumber is available" );
       
   317         phoneNumberAvailable.SetBoolean( ETrue );
       
   318         }
       
   319     else
       
   320         {
       
   321         __PHONELOG( EBasic, 
       
   322                 EPhoneControl, 
       
   323                 "CPhoneCallHeaderManager::SetPhoneNumberAvailabilityL - Phonenumber is not available" );
       
   324         phoneNumberAvailable.SetBoolean( EFalse );              
       
   325         }
       
   326     iViewCommandHandle.ExecuteCommandL( 
       
   327             EPhoneViewSetPhoneNumberAvailableInPhoneEngine, 
       
   328             &phoneNumberAvailable );        
       
   329     }
       
   330 
       
   331 // -----------------------------------------------------------
       
   332 // CPhoneCallHeaderManager::LoadCallHeaderTexts
       
   333 // -----------------------------------------------------------
       
   334 //
       
   335 void CPhoneCallHeaderManager::LoadCallHeaderTexts(
       
   336     const TInt aLabelId, 
       
   337     const TInt aShortLabelId,
       
   338     TPhoneCmdParamCallHeaderData* aCallHeaderData ) 
       
   339     {
       
   340     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneCallHeaderManager::LoadCallHeaderTexts( ) ");
       
   341     if ( aLabelId != EPhoneStringList )
       
   342         {
       
   343         TBuf<KPhoneCallHeaderLabelMaxLength> labelText( KNullDesC );
       
   344         LoadResource( labelText, aLabelId );
       
   345         aCallHeaderData->SetLabelText( labelText );
       
   346 
       
   347         if ( aShortLabelId != EPhoneStringList )
       
   348             {
       
   349             TBuf<KPhoneCallHeaderLabelMaxLength> shortLabelText( KNullDesC );
       
   350             LoadResource( shortLabelText, aShortLabelId );       
       
   351             aCallHeaderData->SetShortLabelText( shortLabelText );        
       
   352             }
       
   353         }
       
   354     }
       
   355 
       
   356 // -----------------------------------------------------------
       
   357 // CPhoneCallHeaderManager::GetInCallNumberTextL
       
   358 // -----------------------------------------------------------
       
   359 //
       
   360 void CPhoneCallHeaderManager::GetInCallNumberTextL( 
       
   361         TInt aCallId, 
       
   362         TDes& aData ) const
       
   363     {
       
   364     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneCallHeaderManager::GetInCallNumberTextL( ) ");    
       
   365     // Display "Call n", n = callId-8 for video and callId+1 for voice call
       
   366     HBufC* tmp = StringLoader::LoadL( 
       
   367         CPhoneMainResourceResolver::Instance()->
       
   368         ResolveResourceID( EPhoneInCallNumberText ), 
       
   369         aCallId + ( IsVideoCall( aCallId ) ? -8 : 1 ), 
       
   370         CCoeEnv::Static() );
       
   371     
       
   372     aData = *tmp;
       
   373     delete tmp;
       
   374     }
       
   375