phoneapp/phoneuistates/src/cphoneincoming.cpp
changeset 37 ba76fc04e6c2
child 45 6b911d05207e
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     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     
       
   223     // Display incoming call
       
   224     DisplayIncomingCallL( aCallId, dialerParam );
       
   225     
       
   226     SetTouchPaneButtons( EPhoneWaitingCallButtons );
       
   227 
       
   228     if( FeatureManager::FeatureSupported( KFeatureIdFfTouchUnlockStroke ) 
       
   229             && !CPhoneCenRepProxy::Instance()->
       
   230             IsTelephonyFeatureSupported( KTelephonyLVFlagAllowUnlockOnIncoming ) 
       
   231             && ( IsKeyLockOn() || IsAutoLockOn() ) )
       
   232         {
       
   233         DisableCallUIL();
       
   234         }
       
   235     else
       
   236         {
       
   237         // if keys have been locked, disable keylock without information note
       
   238         if ( IsKeyLockOn() )
       
   239             {
       
   240             iViewCommandHandle->ExecuteCommandL( EPhoneViewDisableKeyLockWithoutNote );
       
   241             }
       
   242         }
       
   243         
       
   244     if( CPhoneCenRepProxy::Instance()->
       
   245             IsTelephonyFeatureSupported( KTelephonyLVFlagDisableCallControlHardKeysWhileLocked ) 
       
   246             && ( IsKeyLockOn() || IsAutoLockOn() ) )
       
   247         {
       
   248         DisableHWKeysL();
       
   249         }
       
   250         
       
   251     EndUiUpdate();
       
   252 
       
   253     if ( connectedCall > KErrNotFound )
       
   254         {
       
   255         // Go to incoming state
       
   256         iCbaManager->UpdateCbaL( EPhoneCallHandlingCallWaitingCBA );
       
   257         iStateMachine->ChangeState( EPhoneStateWaitingInSingle );   
       
   258         }
       
   259     }
       
   260     
       
   261 // -----------------------------------------------------------
       
   262 // CPhoneIncoming::DisplayIncomingCallL
       
   263 // -----------------------------------------------------------
       
   264 //
       
   265 void CPhoneIncoming::DisplayIncomingCallL( 
       
   266     TInt aCallId, 
       
   267     const TPhoneCmdParamBoolean aCommandParam )
       
   268     {
       
   269     __LOGMETHODSTARTEND( EPhoneUIStates, 
       
   270         "CPhoneIncoming::DisplayIncomingCallL()");
       
   271  
       
   272     // Close menu bar, if it is displayed
       
   273     iViewCommandHandle->ExecuteCommandL( EPhoneViewMenuBarClose );
       
   274 
       
   275     // Cannot delete active note, e.g. New call query, 
       
   276     // but show waiting note with or without caller name
       
   277     if ( IsAnyQueryActiveL() || 
       
   278         ( aCommandParam.Boolean() && iOnScreenDialer ) )
       
   279         {
       
   280         CallWaitingNoteL( aCallId );        
       
   281         }
       
   282     else
       
   283         {
       
   284         // Remove any phone dialogs if they are displayed
       
   285         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemovePhoneDialogs );
       
   286         }
       
   287     
       
   288     // Indicate that the Phone needs to be sent to the background if
       
   289     // an application other than the top application is in the foreground
       
   290     TPhoneCmdParamBoolean booleanParam;
       
   291     booleanParam.SetBoolean( !TopAppIsDisplayedL() );
       
   292     iViewCommandHandle->ExecuteCommandL( 
       
   293         EPhoneViewSetNeedToSendToBackgroundStatus,
       
   294         &booleanParam );
       
   295 
       
   296     // Bring Phone app in the foreground
       
   297     TPhoneCmdParamInteger uidParam;
       
   298     uidParam.SetInteger( KUidPhoneApplication.iUid );
       
   299     iViewCommandHandle->ExecuteCommandL( EPhoneViewBringAppToForeground,
       
   300         &uidParam );
       
   301 
       
   302     // Set Phone as the top application
       
   303     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetTopApplication,
       
   304         &uidParam );
       
   305 
       
   306     DisplayHeaderForCallComingInL( aCallId, ETrue ); //waiting call 
       
   307     }    
       
   308 
       
   309 // -----------------------------------------------------------
       
   310 // CPhoneIncoming::AllowShowingOfWaitingCallHeaderL
       
   311 // -----------------------------------------------------------
       
   312 //
       
   313 void CPhoneIncoming::AllowShowingOfWaitingCallHeaderL( 
       
   314     TPhoneCmdParamBoolean& aCommandParam )
       
   315     {
       
   316     __LOGMETHODSTARTEND(EPhoneUIStates, "CPhoneIncoming::AllowShowingOfWaitingCallHeaderL() ");
       
   317 
       
   318     iViewCommandHandle->ExecuteCommandL( 
       
   319         EPhoneViewAllowWaitingCallHeader, 
       
   320         &aCommandParam );
       
   321     
       
   322     // Non-touch :Hide number entry if it exists on 
       
   323     // Touch : an internal operation ongoing 
       
   324     // -> do not hide dialer
       
   325     if ( !iOnScreenDialer )
       
   326         {   
       
   327         SetNumberEntryVisibilityL(EFalse);
       
   328         }
       
   329     // If param is true and number entry is open only then
       
   330     // hide number entry.
       
   331     else if ( aCommandParam.Boolean() && IsNumberEntryUsedL() )
       
   332         {
       
   333         SetNumberEntryVisibilityL(EFalse);
       
   334         }
       
   335     }
       
   336 
       
   337 // -----------------------------------------------------------
       
   338 // CPhoneIncoming::HandleLongHashL
       
   339 // -----------------------------------------------------------
       
   340 //
       
   341  void CPhoneIncoming::HandleLongHashL()
       
   342     {
       
   343     __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneIncoming::HandleLongHashL( ) ");
       
   344     }
       
   345 
       
   346  // -----------------------------------------------------------
       
   347  // CPhoneIncoming::HandleErrorL
       
   348  // -----------------------------------------------------------
       
   349  //
       
   350  EXPORT_C void CPhoneIncoming::HandleErrorL( 
       
   351          const TPEErrorInfo& aErrorInfo )
       
   352      {
       
   353      __LOGMETHODSTARTEND( EPhoneUIStates, "CPhoneIncoming::HandleErrorL()");
       
   354      
       
   355      if( aErrorInfo.iErrorCode == ECCPErrorCCUserAlertingNoAnswer )
       
   356          {
       
   357          // Should not shown "No Answer" note
       
   358          __PHONELOG1( EBasic, EPhoneUIStates,
       
   359         "PhoneUIControl: CPhoneIncoming::HandleErrorL - aErrorInfo.iErrorCode =%d ",
       
   360              aErrorInfo.iErrorCode);
       
   361          }
       
   362      else
       
   363          {
       
   364          CPhoneState::HandleErrorL( aErrorInfo );
       
   365          }
       
   366      }
       
   367  
       
   368 // End of File