phoneapp/phoneuistates/src/cphoneincoming.cpp
changeset 0 5f000ab63145
child 9 8871b09be73b
child 21 92ab7f8d0eab
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 CPhoneIncoming class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include <featmgr.h>
       
    21 #include <telephonyvariant.hrh>
       
    22 #include "cphoneincoming.h"
       
    23 #include "phonerssbase.h"
       
    24 #include "phonelogger.h"
       
    25 #include "cphonegeneralgsmmessageshandler.h"
       
    26 #include "phonestatedefinitionsgsm.h"
       
    27 #include "tphonecmdparaminteger.h"
       
    28 #include "tphonecmdparamboolean.h"
       
    29 #include "phoneui.hrh"
       
    30 #include "mphonestatemachine.h"
       
    31 #include "mphonestorage.h"
       
    32 #include "cphonecenrepproxy.h"
       
    33 #include "tphonecmdparamcallstatedata.h"
       
    34 
       
    35 // ================= MEMBER FUNCTIONS =======================
       
    36 
       
    37 // C++ default constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 //
       
    40 EXPORT_C CPhoneIncoming::CPhoneIncoming( 
       
    41     MPhoneStateMachine* aStateMachine, 
       
    42     MPhoneViewCommandHandle* aViewCommandHandle,
       
    43     MPhoneCustomization* aPhoneCustomization ) : 
       
    44     CPhoneStateIncoming( aStateMachine, aViewCommandHandle, aPhoneCustomization ),
       
    45     iWaitingCallId( KErrNotFound )
       
    46     {
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------
       
    50 // CPhoneIncoming::~CPhoneIncoming()
       
    51 // Destructor
       
    52 // (other items were commented in a header).
       
    53 // -----------------------------------------------------------
       
    54 //
       
    55 EXPORT_C CPhoneIncoming::~CPhoneIncoming()
       
    56     {
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------
       
    60 // CPhoneIncoming::ConstructL()
       
    61 // Constructor
       
    62 // (other items were commented in a header).
       
    63 // -----------------------------------------------------------
       
    64 //
       
    65 EXPORT_C void CPhoneIncoming::ConstructL()
       
    66     {
       
    67     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneIncoming::ConstructL()");
       
    68     CPhoneStateIncoming::ConstructL();
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------
       
    72 // CPhoneIncoming::NewL()
       
    73 // Constructor
       
    74 // (other items were commented in a header).
       
    75 // -----------------------------------------------------------
       
    76 //
       
    77 CPhoneIncoming* CPhoneIncoming::NewL( 
       
    78     MPhoneStateMachine* aStateMachine, 
       
    79     MPhoneViewCommandHandle* aViewCommandHandle,
       
    80     MPhoneCustomization* aPhoneCustomization )
       
    81     {
       
    82     CPhoneIncoming* self = new (ELeave) 
       
    83         CPhoneIncoming( aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
    84     
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL();
       
    87     CleanupStack::Pop( self );
       
    88     
       
    89     return self;
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------
       
    93 // CPhoneIncoming::HandlePhoneEngineMessageL
       
    94 // -----------------------------------------------------------
       
    95 //
       
    96 EXPORT_C void CPhoneIncoming::HandlePhoneEngineMessageL( 
       
    97     const TInt aMessage, 
       
    98     TInt aCallId )
       
    99     {
       
   100     __LOGMETHODSTARTEND(EPhoneUIStates, 
       
   101         "CPhoneIncoming::HandlePhoneEngineMessageL() ");
       
   102     switch ( aMessage )
       
   103         {
       
   104         case MEngineMonitor::EPEMessageIncoming:
       
   105             iWaitingCallId = aCallId;
       
   106             break;
       
   107 
       
   108         case MEngineMonitor::EPEMessageConnected:
       
   109             if( iWaitingCallId > KErrNotFound )
       
   110                 {
       
   111                 HandleIncomingL( iWaitingCallId );
       
   112                 }
       
   113             else
       
   114                 {
       
   115                 // There is no another incoming call
       
   116                 CPhoneStateIncoming::HandlePhoneEngineMessageL( 
       
   117                     aMessage, aCallId );
       
   118                 }
       
   119             break;
       
   120             
       
   121         case MEngineMonitor::EPEMessageRemoteHeld:
       
   122                 SendGlobalInfoNoteL( EPhoneInformationRemotePutOnHoldNote );
       
   123             break;
       
   124         
       
   125         case MEngineMonitor::EPEMessageRemoteResumed:
       
   126                 SendGlobalInfoNoteL( EPhoneInformationConnectedNote );
       
   127             break;
       
   128 
       
   129         // fall through.
       
   130         case MEngineMonitor::EPEMessageIssuingSSRequest:
       
   131         case MEngineMonitor::EPEMessageCallBarred:
       
   132         case MEngineMonitor::EPEMessageShowVersion:
       
   133         case MEngineMonitor::EPEMessageIssuedSSRequest:
       
   134         case MEngineMonitor::EPEMessageTempClirActivationUnsuccessful:
       
   135         case MEngineMonitor::EPEMessageIncCallIsForw:
       
   136         case MEngineMonitor::EPEMessageIncCallForwToC:
       
   137         case MEngineMonitor::EPEMessageOutCallForwToC:
       
   138         case MEngineMonitor::EPEMessageForwardUnconditionalModeActive:
       
   139         case MEngineMonitor::EPEMessageForwardConditionallyModeActive:
       
   140             {
       
   141             CPhoneGeneralGsmMessagesHandler* gsmMsgHandler =
       
   142                 CPhoneGeneralGsmMessagesHandler::NewL( *iStateMachine,
       
   143                                                        *iViewCommandHandle,
       
   144                                                        *this );
       
   145             CleanupStack::PushL( gsmMsgHandler );
       
   146             gsmMsgHandler->HandlePhoneEngineMessageL( aMessage, aCallId );
       
   147             CleanupStack::PopAndDestroy( gsmMsgHandler );
       
   148             }
       
   149             break;
       
   150             
       
   151         case MEngineMonitor::EPEMessageIdle:
       
   152            {
       
   153            // Check if there is another incoming call while the first one is
       
   154            // still disconnecting
       
   155            if ( iWaitingCallId > KErrNotFound && aCallId != iWaitingCallId )
       
   156                {
       
   157                HandleIncomingL( iWaitingCallId );
       
   158                
       
   159                // Prevent execution of CPhoneStateIncoming::HandleIdleL, only remove
       
   160                // the call bubble
       
   161                BeginUiUpdateLC();
       
   162                iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveCallHeader, aCallId );
       
   163                EndUiUpdate();
       
   164 
       
   165                iWaitingCallId = KErrNotFound;
       
   166                }
       
   167            else
       
   168                {
       
   169                CPhoneStateIncoming::HandlePhoneEngineMessageL( 
       
   170                    aMessage, aCallId );
       
   171                }
       
   172            }
       
   173            break;
       
   174 
       
   175         default:
       
   176             CPhoneStateIncoming::HandlePhoneEngineMessageL( 
       
   177                 aMessage, aCallId );
       
   178             break;
       
   179         }
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------
       
   183 //  CPhoneIncoming::HandleIncomingL
       
   184 // -----------------------------------------------------------
       
   185 void CPhoneIncoming::HandleIncomingL( TInt aCallId )
       
   186     {
       
   187     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   188         "CPhoneIncoming::HandleIncomingL()");
       
   189     
       
   190     TPhoneCmdParamCallStateData callState;
       
   191     callState.SetCallState( EPEStateConnected );
       
   192     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetCallIdByState, &callState );
       
   193     TInt connectedCall = callState.CallId(); 
       
   194     
       
   195     BeginUiUpdateLC();
       
   196     
       
   197     TPhoneCmdParamBoolean dialerParam;
       
   198     dialerParam.SetBoolean( ETrue );
       
   199     
       
   200     AllowShowingOfWaitingCallHeaderL( dialerParam );
       
   201       
       
   202     // Close fast swap window if it's displayed
       
   203     CEikonEnv::Static()->DismissTaskList();
       
   204     
       
   205     // If the 1st incoming call became Connected, this is waiting call
       
   206     // If the 1st incoming call went just Idle, this is a normal call
       
   207     if ( connectedCall > KErrNotFound )
       
   208         {
       
   209         SetTouchPaneButtons( EPhoneWaitingCallButtons );
       
   210         }
       
   211     else
       
   212         {
       
   213         SetTouchPaneButtons( EPhoneIncomingCallButtons );
       
   214         }
       
   215     
       
   216     if ( KErrNotFound == connectedCall )
       
   217         {
       
   218         dialerParam.SetBoolean( EFalse );
       
   219         }
       
   220     
       
   221     SetToolbarDimming( EFalse );
       
   222     // Display incoming call
       
   223     DisplayIncomingCallL( aCallId, dialerParam );
       
   224 
       
   225     if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) 
       
   226             && !CPhoneCenRepProxy::Instance()->
       
   227             IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) 
       
   228             && ( IsKeyLockOn() || IsAutoLockOn() ) )
       
   229         {
       
   230         DisableCallUIL();
       
   231         }
       
   232     else
       
   233         {
       
   234         // if keys have been locked, disable keylock without information note
       
   235         if ( IsKeyLockOn() )
       
   236             {
       
   237             iViewCommandHandle->ExecuteCommandL( EPhoneViewDisableKeyLockWithoutNote );
       
   238             }
       
   239         }
       
   240     
       
   241     if( CPhoneCenRepProxy::Instance()->
       
   242             IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) 
       
   243             && ( IsKeyLockOn() || IsAutoLockOn() ) )
       
   244         {
       
   245         DisableHWKeysL();
       
   246         }
       
   247     
       
   248     EndUiUpdate();
       
   249 
       
   250     if ( connectedCall > KErrNotFound )
       
   251         {
       
   252         // Go to incoming state
       
   253         iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
       
   254         iStateMachine->ChangeState( EPhoneStateWaitingInSingle );   
       
   255         }
       
   256     }
       
   257     
       
   258 // -----------------------------------------------------------
       
   259 // CPhoneIncoming::DisplayIncomingCallL
       
   260 // -----------------------------------------------------------
       
   261 //
       
   262 void CPhoneIncoming::DisplayIncomingCallL( 
       
   263     TInt aCallId, 
       
   264     const TPhoneCmdParamBoolean aCommandParam )
       
   265     {
       
   266     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   267         "CPhoneIncoming::DisplayIncomingCallL()");
       
   268  
       
   269     // Close menu bar, if it is displayed
       
   270     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   271 
       
   272     // Cannot delete active note, e.g. New call query, 
       
   273     // but show waiting note with or without caller name
       
   274     if ( IsAnyQueryActiveL() || 
       
   275         ( aCommandParam.Boolean() && iOnScreenDialer ) )
       
   276         {
       
   277         CallWaitingNoteL( aCallId );        
       
   278         }
       
   279     else
       
   280         {
       
   281         // Remove any phone dialogs if they are displayed
       
   282         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
   283         }
       
   284     
       
   285     // Indicate that the Phone needs to be sent to the background if
       
   286     // an application other than the top application is in the foreground
       
   287     TPhoneCmdParamBoolean booleanParam;
       
   288     booleanParam.SetBoolean( !TopAppIsDisplayedL() );
       
   289     iViewCommandHandle->ExecuteCommandL( 
       
   290         EPhoneViewSetNeedToSendToBackgroundStatus,
       
   291         &booleanParam );
       
   292 
       
   293     // Bring Phone app in the foreground
       
   294     TPhoneCmdParamInteger uidParam;
       
   295     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   296     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
   297         &uidParam );
       
   298 
       
   299     // Set Phone as the top application
       
   300     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
   301         &uidParam );
       
   302 
       
   303     DisplayHeaderForCallComingInL( aCallId, aCommandParam.Boolean() ); //waiting call 
       
   304     }    
       
   305 
       
   306 // -----------------------------------------------------------
       
   307 // CPhoneIncoming::AllowShowingOfWaitingCallHeaderL
       
   308 // -----------------------------------------------------------
       
   309 //
       
   310 void CPhoneIncoming::AllowShowingOfWaitingCallHeaderL( 
       
   311     TPhoneCmdParamBoolean& aCommandParam )
       
   312     {
       
   313     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneIncoming::AllowShowingOfWaitingCallHeaderL() ");
       
   314 
       
   315     iViewCommandHandle->ExecuteCommandL( 
       
   316         EPhoneViewAllowWaitingCallHeader, 
       
   317         &aCommandParam );
       
   318     
       
   319     // Non-touch :Hide number entry if it exists on 
       
   320     // Touch : an internal operation ongoing 
       
   321     // -> do not hide dialer
       
   322     if ( !iOnScreenDialer )
       
   323         {   
       
   324         SetNumberEntryVisibilityL(EFalse);
       
   325         }
       
   326     // If param is true and number entry is open only then
       
   327     // hide number entry.
       
   328     else if ( aCommandParam.Boolean() && IsNumberEntryUsedL() )
       
   329         {
       
   330         SetNumberEntryVisibilityL(EFalse);
       
   331         }
       
   332     }
       
   333 
       
   334 // -----------------------------------------------------------
       
   335 // CPhoneIncoming::HandleLongHashL
       
   336 // -----------------------------------------------------------
       
   337 //
       
   338  void CPhoneIncoming::HandleLongHashL()
       
   339     {
       
   340     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneIncoming::HandleLongHashL( ) ");
       
   341     }
       
   342 
       
   343  // -----------------------------------------------------------
       
   344  // CPhoneIncoming::HandleErrorL
       
   345  // -----------------------------------------------------------
       
   346  //
       
   347  EXPORT_C void CPhoneIncoming::HandleErrorL( 
       
   348          const TPEErrorInfo& aErrorInfo )
       
   349      {
       
   350      __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneIncoming::HandleErrorL()");
       
   351      
       
   352      if( aErrorInfo.iErrorCode == ECCPErrorCCUserAlertingNoAnswer )
       
   353          {
       
   354          // Should not shown "No Answer" note
       
   355          __PHONELOG1( EBasic, EPhoneUIStates,
       
   356         "PhoneUIControl: CPhoneIncoming::HandleErrorL - aErrorInfo.iErrorCode =%d ",
       
   357              aErrorInfo.iErrorCode);
       
   358          }
       
   359      else
       
   360          {
       
   361          CPhoneState::HandleErrorL( aErrorInfo );
       
   362          }
       
   363      }
       
   364  
       
   365 // End of File