phoneapp/phoneuistates/src/cphonegsmincall.cpp
changeset 0 5f000ab63145
child 1 838b0a10d15b
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2006 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: Implementation of CPhoneGsmInCall class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <mpeengineinfo.h>
       
    21 #include <pevirtualengine.h>
       
    22 #include <cpephonemodelif.h>
       
    23 #include <StringLoader.h>
       
    24 
       
    25 #include "cphonegsmincall.h"
       
    26 #include "phonerssbase.h"
       
    27 #include "phonelogger.h"
       
    28 #include "cphonegeneralgsmmessageshandler.h"
       
    29 #include "tphonecmdparamglobalnote.h"
       
    30 #include "tphonecmdparamboolean.h"
       
    31 #include "tphonecmdparaminteger.h"
       
    32 #include "mphonestatemachine.h"
       
    33 #include "cphonemainresourceresolver.h"
       
    34 #include "phoneui.hrh"
       
    35 
       
    36 #include "tphonecmdparamcallstatedata.h"
       
    37 #include "tphonecmdparamcallheaderdata.h"
       
    38 
       
    39 // ================= MEMBER FUNCTIONS =======================
       
    40 
       
    41 // C++ default constructor can NOT contain any code, that
       
    42 // might leave.
       
    43 //
       
    44 CPhoneGsmInCall::CPhoneGsmInCall( 
       
    45     MPhoneStateMachine* aStateMachine, 
       
    46     MPhoneViewCommandHandle* aViewCommandHandle,
       
    47     MPhoneCustomization* aPhoneCustomization ) : 
       
    48     CPhoneStateInCall( aStateMachine, aViewCommandHandle, aPhoneCustomization )
       
    49     {
       
    50     }
       
    51 
       
    52 // -----------------------------------------------------------
       
    53 // CPhoneGsmInCall::~CPhoneGsmInCall()
       
    54 // Destructor
       
    55 // (other items were commented in a header).
       
    56 // -----------------------------------------------------------
       
    57 
       
    58 CPhoneGsmInCall::~CPhoneGsmInCall()
       
    59     {
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------
       
    63 // CPhoneGsmInCall::ConstructL()
       
    64 // Constructor
       
    65 // (other items were commented in a header).
       
    66 // -----------------------------------------------------------
       
    67 //
       
    68 void CPhoneGsmInCall::ConstructL()
       
    69     {
       
    70     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneGsmInCall::ConstructL()");
       
    71     CPhoneStateInCall::ConstructL();
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------
       
    75 // CPhoneGsmInCall::NewL()
       
    76 // Constructor
       
    77 // (other items were commented in a header).
       
    78 // -----------------------------------------------------------
       
    79 //
       
    80 CPhoneGsmInCall* CPhoneGsmInCall::NewL( 
       
    81     MPhoneStateMachine* aStateMachine, 
       
    82     MPhoneViewCommandHandle* aViewCommandHandle,
       
    83     MPhoneCustomization* aPhoneCustomization )
       
    84     {
       
    85     CPhoneGsmInCall* self = new (ELeave) 
       
    86         CPhoneGsmInCall( aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
    87     
       
    88     CleanupStack::PushL( self );
       
    89     self->ConstructL();
       
    90     CleanupStack::Pop( self );
       
    91     
       
    92     return self;
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------
       
    96 // CPhoneGsmInCall::HandlePhoneEngineMessageL
       
    97 // -----------------------------------------------------------
       
    98 //
       
    99 void CPhoneGsmInCall::HandlePhoneEngineMessageL( 
       
   100     const TInt aMessage, 
       
   101     TInt aCallId )
       
   102     {
       
   103     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   104         "CPhoneGsmInCall::HandlePhoneEngineMessageL() ");
       
   105     switch ( aMessage )
       
   106         {
       
   107         case MEngineMonitor::EPEMessageRemoteHeld:
       
   108             CPhoneState::SendGlobalInfoNoteL( 
       
   109                 EPhoneInformationRemotePutOnHoldNote );
       
   110             break;
       
   111         
       
   112         case MEngineMonitor::EPEMessageRemoteResumed:
       
   113             CPhoneState::SendGlobalInfoNoteL( 
       
   114                 EPhoneInformationConnectedNote );
       
   115             break;
       
   116             
       
   117         case MEngineMonitor::EPEMessageRemoteCreatedConference:
       
   118             CPhoneState::SendGlobalInfoNoteL( 
       
   119                 EPhoneInformationRemoteCreateConferenceNote );
       
   120             break;        
       
   121         case MEngineMonitor::EPEMessageIncCallIsForw:  // fall through
       
   122         case MEngineMonitor::EPEMessageIssuingSSRequest: // fall through
       
   123         case MEngineMonitor::EPEMessageCallBarred: // fall through
       
   124         case MEngineMonitor::EPEMessageShowVersion: // fall through
       
   125         case MEngineMonitor::EPEMessageIssuedSSRequest: // fall through
       
   126         case MEngineMonitor::EPEMessageTempClirActivationUnsuccessful:
       
   127         case MEngineMonitor::EPEMessageIncCallForwToC: // fall through
       
   128         case MEngineMonitor::EPEMessageOutCallForwToC: // fall through
       
   129         case MEngineMonitor::EPEMessageForwardUnconditionalModeActive: // fall through
       
   130         case MEngineMonitor::EPEMessageForwardConditionallyModeActive:
       
   131 			{
       
   132 			CPhoneGeneralGsmMessagesHandler* gsmMsgHandler =
       
   133 				CPhoneGeneralGsmMessagesHandler::NewL( *iStateMachine,
       
   134 													   *iViewCommandHandle,
       
   135 													   *this );
       
   136 			CleanupStack::PushL( gsmMsgHandler );
       
   137 			gsmMsgHandler->HandlePhoneEngineMessageL( aMessage, aCallId );
       
   138 			CleanupStack::PopAndDestroy( gsmMsgHandler );
       
   139 			
       
   140             // Needed also in non-touch, if call waiting request (*43#) 
       
   141             // is sent during active call at least.
       
   142     	    UpdateCbaL( EPhoneCallHandlingInCallCBA );
       
   143 			}
       
   144 			break;
       
   145 
       
   146         default:
       
   147             CPhoneStateInCall::HandlePhoneEngineMessageL( 
       
   148                 aMessage, aCallId );
       
   149             break;
       
   150         }
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------
       
   154 // CPhoneGsmInCall:HandleCommandL
       
   155 // -----------------------------------------------------------
       
   156 //
       
   157 EXPORT_C TBool CPhoneGsmInCall::HandleCommandL( TInt aCommand )
       
   158     {
       
   159     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   160         "CPhoneGsmInCall::HandleCommandL() ");
       
   161     TBool commandStatus = ETrue;
       
   162 
       
   163     switch( aCommand )
       
   164         {                        
       
   165         case EPhoneCallComingCmdAnswer:
       
   166         case EPhoneInCallCmdAnswer:
       
   167             iStateMachine->SendPhoneEngineMessage(
       
   168                 CPEPhoneModelIF::EPEMessageAnswer );
       
   169             break;
       
   170         
       
   171         // 'Replace' from menu            
       
   172         case EPhoneInCallCmdReplace:
       
   173         	ReplaceCallL();
       
   174             break;
       
   175         
       
   176         case EPhoneInCallCmdSwap:
       
   177             iStateMachine->SendPhoneEngineMessage(
       
   178                 CPEPhoneModelIF::EPEMessageSwap ); 
       
   179             break;  
       
   180             
       
   181         case EPhoneInCallCmdEndAllCalls:
       
   182             iStateMachine->SendPhoneEngineMessage(
       
   183                 CPEPhoneModelIF::EPEMessageReleaseAll );        
       
   184             break;
       
   185             
       
   186         case EPhoneInCallCmdCreateConference:
       
   187             iStateMachine->SendPhoneEngineMessage(
       
   188                 CPEPhoneModelIF::EPEMessageCreateConference );
       
   189             break;
       
   190             
       
   191         case EPhoneInCallCmdTransfer:
       
   192             iStateMachine->SendPhoneEngineMessage( 
       
   193                 CPEPhoneModelIF::EPEMessageTransfer );                        
       
   194             break;   
       
   195             
       
   196        default:
       
   197             CPhoneStateInCall::HandleCommandL( aCommand );
       
   198             break;
       
   199         }
       
   200     return commandStatus;
       
   201     }
       
   202 
       
   203 
       
   204 // -----------------------------------------------------------
       
   205 // CPhoneGsmInCall::ReplaceCallL
       
   206 // -----------------------------------------------------------
       
   207 //
       
   208 void CPhoneGsmInCall::ReplaceCallL()
       
   209     {
       
   210     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   211         "CPhoneGsmInCall::ReplaceCallL() ");
       
   212           
       
   213     iStateMachine->SendPhoneEngineMessage( 
       
   214         MPEPhoneModel::EPEMessageReplaceActive );
       
   215     }
       
   216 
       
   217 // -----------------------------------------------------------
       
   218 // CPhoneGsmInCall::HandleColpNoteL
       
   219 // -----------------------------------------------------------
       
   220 //
       
   221 void CPhoneGsmInCall::HandleColpNoteL( 
       
   222     TInt aCallId )
       
   223     {
       
   224     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneGsmInCall::HandleColpNoteL() ");
       
   225 
       
   226     MPEEngineInfo* EngineInfo = CPhoneState::iStateMachine->PhoneEngineInfo();
       
   227 
       
   228     if ( EngineInfo->RemoteColpNumber( aCallId ).Length() )
       
   229         {
       
   230         TPhoneCmdParamGlobalNote globalNoteParam;
       
   231 	    globalNoteParam.SetText(  EngineInfo->RemoteColpNumber( aCallId ) ); 
       
   232 	    globalNoteParam.SetType( EAknGlobalInformationNote );
       
   233 	    globalNoteParam.SetTextResourceId( 
       
   234 	        CPhoneMainResourceResolver::Instance()->
       
   235 	        ResolveResourceID( EPhoneColpConnected ) );
       
   236 	    globalNoteParam.SetTone( EAvkonSIDInformationTone );
       
   237 	        
       
   238 	    iViewCommandHandle->ExecuteCommandL( 
       
   239 	            EPhoneViewShowGlobalNote, &globalNoteParam );
       
   240         }
       
   241     }
       
   242 
       
   243 // -----------------------------------------------------------
       
   244 // CPhoneGsmInCall::BringIncomingToForegroundL()
       
   245 // -----------------------------------------------------------
       
   246 //
       
   247 void CPhoneGsmInCall::BringIncomingToForegroundL()
       
   248     {
       
   249     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneGsmInCall::BringIncomingToForegroundL( ) ");
       
   250 
       
   251     // Close menu bar, if it is displayed
       
   252     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   253 
       
   254     // Remove any phone dialogs if they are displayed
       
   255     iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
   256 
       
   257     // Capture keys when there is an incoming call
       
   258     CaptureKeysDuringCallNotificationL( ETrue );
       
   259 
       
   260     // Bring Phone app in the foreground
       
   261     TPhoneCmdParamInteger uidParam;
       
   262     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   263     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
   264         &uidParam );
       
   265 
       
   266     // Set Phone as the top application
       
   267     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
   268         &uidParam );
       
   269     
       
   270     // Disable global notes when there is an incoming call
       
   271     TPhoneCmdParamBoolean globalNotifierParam;
       
   272     globalNotifierParam.SetBoolean( ETrue );
       
   273     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   274         &globalNotifierParam );
       
   275     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetEikonNotifiersDisabled,
       
   276         &globalNotifierParam );
       
   277     
       
   278     }
       
   279 
       
   280 // -----------------------------------------------------------
       
   281 // CPhoneGsmInCall::AllowShowingOfWaitingCallHeaderL
       
   282 // -----------------------------------------------------------
       
   283 //
       
   284 void CPhoneGsmInCall::AllowShowingOfWaitingCallHeaderL( 
       
   285     TPhoneCmdParamBoolean& aCommandParam )
       
   286     {
       
   287     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneGsmInCall::AllowShowingOfWaitingCallHeaderL() ");
       
   288 
       
   289     iViewCommandHandle->ExecuteCommandL( 
       
   290         EPhoneViewAllowWaitingCallHeader, 
       
   291         &aCommandParam );
       
   292     
       
   293     // Non-touch :Hide number entry if it exists on 
       
   294     // Touch : an internal operation ongoing 
       
   295     // -> do not hide dialer
       
   296     if ( !iOnScreenDialer )
       
   297         {   
       
   298         SetNumberEntryVisibilityL(EFalse);
       
   299         }
       
   300     // If param is true and number entry is open only then
       
   301     // hide number entry.
       
   302     else if ( aCommandParam.Boolean() && IsNumberEntryUsedL() )
       
   303         {
       
   304         SetNumberEntryVisibilityL(EFalse);
       
   305         }
       
   306     }
       
   307 
       
   308 // -----------------------------------------------------------
       
   309 // CPhoneGsmInCall::HandlePhoneForegroundEventL
       
   310 // -----------------------------------------------------------
       
   311 //
       
   312 EXPORT_C void CPhoneGsmInCall::HandlePhoneForegroundEventL()
       
   313     {
       
   314     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneGsmInCall::HandlePhoneForegroundEventL( ) ");
       
   315     if ( iOnScreenDialer && IsNumberEntryUsedL() )
       
   316         {
       
   317         // If numberentry is used then we need to call EPhoneViewSetDialerControlVisible 
       
   318         // to ensure that numberentry/dialler is drawn to UI.
       
   319         TPhoneViewResponseId respond = 
       
   320             iViewCommandHandle->HandleCommandL( EPhoneViewSetDialerControlVisible );
       
   321                 
       
   322         if ( respond && IsNumberEntryVisibleL() )
       
   323             {
       
   324             // Set Number Entry CBA
       
   325             iCbaManager->SetCbaL( EPhoneNumberAcqCBA );
       
   326             }
       
   327         }
       
   328      }
       
   329 
       
   330 // -----------------------------------------------------------
       
   331 // CPhoneGsmInCall::HandleHoldNoteL
       
   332 // -----------------------------------------------------------
       
   333 //
       
   334 void CPhoneGsmInCall::HandleHoldNoteL( 
       
   335     TInt aCallId, TBool aHold )
       
   336     {
       
   337     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneGsmInCall::HandleHoldNoteL( ) ");
       
   338     TBuf< KPhoneContactNameMaxLength > holdText( KNullDesC );
       
   339     TPhoneCmdParamGlobalNote globalNoteParam;
       
   340     TInt resourceId(0);
       
   341     
       
   342     if( iStateMachine->PhoneEngineInfo()->RemoteName( aCallId ).Length() ||
       
   343         iStateMachine->PhoneEngineInfo()->RemoteCompanyName( aCallId ).Length())
       
   344         {
       
   345         TInt resource( EPhoneInformationCallActivetedCli );
       
   346         if ( aHold )
       
   347             {
       
   348             resource = EPhoneInformationCallOnHoldCli;    
       
   349             }
       
   350         GetRemoteInfoDataL ( aCallId, holdText );
       
   351         resourceId = CPhoneMainResourceResolver::Instance()->
       
   352             ResolveResourceID( resource );
       
   353         globalNoteParam.SetTextResourceId( resourceId );    
       
   354         }
       
   355     else
       
   356         {
       
   357         TInt resource( EPhoneInformationCallActiveted );
       
   358         if ( aHold )
       
   359             {
       
   360             resource = EPhoneInformationCallOnHoldNoCli;    
       
   361             }
       
   362         resourceId = CPhoneMainResourceResolver::Instance()->
       
   363                 ResolveResourceID( resource );
       
   364                 
       
   365         HBufC* tmp = StringLoader::LoadL( resourceId, 
       
   366             aCallId + 1 , CCoeEnv::Static() );
       
   367 
       
   368         holdText = *tmp;
       
   369         delete tmp;
       
   370         tmp = NULL;  
       
   371         }
       
   372          
       
   373     globalNoteParam.SetText( holdText ); 
       
   374     globalNoteParam.SetType( EAknGlobalConfirmationNote );
       
   375     globalNoteParam.SetTone( EAvkonSIDInformationTone );
       
   376         
       
   377     iViewCommandHandle->ExecuteCommandL( 
       
   378             EPhoneViewShowGlobalNote, &globalNoteParam ); 
       
   379     }
       
   380 
       
   381 
       
   382 // ---------------------------------------------------------
       
   383 // CPhoneGsmInCall::SetDivertIndication
       
   384 // ---------------------------------------------------------
       
   385 //
       
   386 EXPORT_C void CPhoneGsmInCall::SetDivertIndication( const TBool aDivertIndication )
       
   387     {
       
   388     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneGsmInCall::SetDivertIndication()");
       
   389            
       
   390     CPhoneState::SetDivertIndication( aDivertIndication );    
       
   391     
       
   392     TRAP_IGNORE( HandeDivertIndicationL() );
       
   393 	}
       
   394 
       
   395 // ---------------------------------------------------------
       
   396 // CPhoneGsmInCall::HandeDivertIndicationL
       
   397 // ---------------------------------------------------------
       
   398 //
       
   399 void CPhoneGsmInCall::HandeDivertIndicationL()
       
   400     {
       
   401     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneGsmInCall::HandeDivertIndicationL()");
       
   402        
       
   403     TBuf< KPhoneContactNameMaxLength > remoteInfoText( KNullDesC );
       
   404     TInt ringingCallId ( KErrNotFound );
       
   405         
       
   406     ringingCallId = GetRingingCallL();
       
   407     
       
   408     if( ringingCallId > KErrNotFound )
       
   409        {
       
   410        TPhoneCmdParamCallHeaderData divertData;
       
   411     
       
   412        divertData.SetCallFlag( CBubbleManager::EDiverted );
       
   413        
       
   414        GetRemoteInfoDataL( ringingCallId, remoteInfoText );
       
   415        divertData.SetCLIText( 
       
   416                   remoteInfoText,
       
   417                   CBubbleManager::ERight );
       
   418        
       
   419        divertData.SetCiphering(
       
   420            iStateMachine->PhoneEngineInfo()->IsSecureCall( ringingCallId ) );
       
   421        divertData.SetCipheringIndicatorAllowed(
       
   422            iStateMachine->PhoneEngineInfo()->SecureSpecified() );
       
   423            
       
   424        iViewCommandHandle->ExecuteCommandL( 
       
   425            EPhoneViewUpdateCallHeaderRemoteInfoData, ringingCallId,
       
   426            &divertData );
       
   427         }
       
   428     }
       
   429 
       
   430 // End of File