phoneapp/phoneuicontrol/src/cphonestatestartup.cpp
changeset 0 5f000ab63145
child 14 24062c24fe38
child 21 92ab7f8d0eab
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2005-2007 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 CPhoneStateStartup class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDES
       
    20 #include "cphonestatestartup.h"
       
    21 #include "phonestatedefinitions.h"
       
    22 #include "mphonestatemachine.h"
       
    23 #include "tphonecmdparamKeycapture.h"
       
    24 #include "tphonecmdparamboolean.h"
       
    25 #include "phonelogger.h"
       
    26 #include "phonerssbase.h"
       
    27 
       
    28 // ================= MEMBER FUNCTIONS =======================
       
    29 
       
    30 // C++ default constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 //
       
    33 EXPORT_C CPhoneStateStartup::CPhoneStateStartup( 
       
    34     MPhoneStateMachine* aStateMachine, 
       
    35     MPhoneViewCommandHandle* aViewCommandHandle,
       
    36     MPhoneCustomization* aPhoneCustomization
       
    37      ) : 
       
    38     CPhoneState( aStateMachine, aViewCommandHandle, aPhoneCustomization ),
       
    39     iPEReady( EFalse ),
       
    40     iPhoneReady( EFalse )
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------
       
    45 // CPhoneStateStartup::~CPhoneStateStartup()
       
    46 // Destructor
       
    47 // (other items were commented in a header).
       
    48 // -----------------------------------------------------------
       
    49 //
       
    50 EXPORT_C CPhoneStateStartup::~CPhoneStateStartup()
       
    51     {
       
    52     delete iCreateNote;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------
       
    56 // CPhoneStateStartup::ConstructL()
       
    57 // Constructor
       
    58 // (other items were commented in a header).
       
    59 // -----------------------------------------------------------
       
    60 //
       
    61 EXPORT_C void CPhoneStateStartup::ConstructL()
       
    62     {
       
    63     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateStartup::ConstructL() ");
       
    64     CPhoneState::BaseConstructL();
       
    65     
       
    66     // Set send key activation off.
       
    67     TPhoneCmdParamBoolean boolean;
       
    68     boolean.SetBoolean( EFalse );
       
    69     iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSendKeyDialerActivationFlag, 
       
    70             &boolean );
       
    71 
       
    72     // CAPTURE KEY EVENTS PERMANENTLY
       
    73         
       
    74     // Capture the up and down events for the No key
       
    75     TPhoneCmdParamKeyCapture noKeyCaptureParam;
       
    76     noKeyCaptureParam.SetKey( EStdKeyNo );
       
    77     noKeyCaptureParam.SetKeyCode( EKeyNo );
       
    78     noKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
    79     iViewCommandHandle->ExecuteCommandL( EPhoneViewStartCapturingKey, 
       
    80         &noKeyCaptureParam );
       
    81           
       
    82     // Capture the up and down events for the EStdKeyEnd key
       
    83     TPhoneCmdParamKeyCapture endKeyCaptureParam;
       
    84     endKeyCaptureParam.SetKey( EStdKeyEnd );
       
    85     endKeyCaptureParam.SetKeyCode( EKeyEnd );
       
    86     endKeyCaptureParam.SetCaptureType( EPhoneKeyAllEvents );
       
    87     iViewCommandHandle->ExecuteCommandL( EPhoneViewStartCapturingKey, 
       
    88         &endKeyCaptureParam );
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------
       
    92 // CPhoneStateStartup::NewL()
       
    93 // Constructor
       
    94 // (other items were commented in a header).
       
    95 // -----------------------------------------------------------
       
    96 //
       
    97 EXPORT_C CPhoneStateStartup* CPhoneStateStartup::NewL( 
       
    98     MPhoneStateMachine* aStateMachine, 
       
    99     MPhoneViewCommandHandle* aViewCommandHandle,
       
   100     MPhoneCustomization* aPhoneCustomization )
       
   101     {
       
   102     CPhoneStateStartup* self = new (ELeave) CPhoneStateStartup( 
       
   103         aStateMachine, aViewCommandHandle, aPhoneCustomization );
       
   104     
       
   105     CleanupStack::PushL( self );
       
   106     self->ConstructL();
       
   107     CleanupStack::Pop( self );
       
   108     
       
   109     return self;
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------
       
   113 // CPhoneStateStartup::HandlePhoneEngineMessageL
       
   114 // -----------------------------------------------------------
       
   115 //
       
   116 EXPORT_C void CPhoneStateStartup::HandlePhoneEngineMessageL( 
       
   117     const TInt aMessage, 
       
   118     TInt aCallId )
       
   119     {
       
   120     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateStartup::HandlePhoneEngineMessageL() ");
       
   121     switch ( aMessage )
       
   122         {
       
   123         case MEngineMonitor::EPEMessagePEConstructionReady:
       
   124             HandlePEConstructionReadyL( aCallId );
       
   125             break;
       
   126             
       
   127         default:
       
   128             CPhoneState::HandlePhoneEngineMessageL( aMessage, aCallId );
       
   129             break;
       
   130         }
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------
       
   134 // CPhoneStateStartup::HandlePEConstructionReadyL
       
   135 // -----------------------------------------------------------
       
   136 //
       
   137 void CPhoneStateStartup::HandlePEConstructionReadyL( TInt /*aCallId*/ )
       
   138     {
       
   139     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateStartup::HandlePEConstructionReadyL() ");
       
   140     // Indicate that phone engine construction is ready
       
   141     iPEReady = ETrue;
       
   142 
       
   143     // Only go to the idle state if phone is also ready
       
   144     if ( iPhoneReady )
       
   145         {
       
   146         // Security mode check. 
       
   147 	    TPhoneCmdParamBoolean isSecurityMode;      
       
   148         iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );        
       
   149         if ( !isSecurityMode.Boolean() && !IsSimOk() )
       
   150             {
       
   151             TPhoneCmdParamBoolean securityMode;
       
   152             securityMode.SetBoolean( ETrue );
       
   153             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSecurityMode, &securityMode );
       
   154             iCreateNote = CIdle::NewL( CActive::EPriorityHigh );
       
   155             
       
   156             CreateAndShowNoteAfterIdle(); 
       
   157             }
       
   158         // Go to idle state
       
   159         SetDefaultFlagsL();
       
   160         iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
       
   161         
       
   162         iViewCommandHandle->ExecuteCommand( EPhoneViewPrepareIcons );
       
   163         
       
   164         iStateMachine->ChangeState( EPhoneStateIdle );
       
   165         }
       
   166     }
       
   167 
       
   168 // -----------------------------------------------------------
       
   169 // CPhoneStateStartup::HandleKeyMessageL
       
   170 // -----------------------------------------------------------
       
   171 //
       
   172 EXPORT_C void CPhoneStateStartup::HandleKeyMessageL( 
       
   173     TPhoneKeyEventMessages /*aMessage*/,
       
   174     TKeyCode /*aCode*/ )
       
   175     {
       
   176     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateStartup::HandleKeyMessageL( ) ");
       
   177 
       
   178     // TBD: Panic if PE Construction fails
       
   179     // For Debug use only
       
   180     // If a key event is received in this state, either the phone engine
       
   181     // is not ready or the phone has not started up yet. Display an error note
       
   182     // if the phone engine is not ready.
       
   183     if ( iPhoneReady && !iPEReady )
       
   184         {
       
   185         SendGlobalErrorNoteL( EPhoneNoteTextPEFailedAtStartup );
       
   186         }
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------
       
   190 // CPhoneStateStartup::HandleKeyEventL
       
   191 // -----------------------------------------------------------
       
   192 //
       
   193 EXPORT_C void CPhoneStateStartup::HandleKeyEventL(
       
   194         const TKeyEvent& /*aKeyEvent*/, TEventCode /*aEventCode*/ )
       
   195     {
       
   196     // Empty implementation
       
   197     }
       
   198 
       
   199 // CPhoneStateStartup::HandleCreateNumberEntryL
       
   200 // -----------------------------------------------------------
       
   201 //
       
   202 EXPORT_C void CPhoneStateStartup::HandleCreateNumberEntryL( 
       
   203         const TKeyEvent& /* aKeyEvent */ ,
       
   204         TEventCode /* aEventCode */ )
       
   205     {
       
   206     // Empty implementation
       
   207     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateStartup::HandleCreateNumberEntryL() ");   
       
   208     }
       
   209 
       
   210 // -----------------------------------------------------------
       
   211 // CPhoneStateStartup::HandleDtmfKeyToneL
       
   212 // -----------------------------------------------------------
       
   213 //
       
   214 EXPORT_C void CPhoneStateStartup::HandleDtmfKeyToneL( 
       
   215         const TKeyEvent& /* aKeyEvent */,
       
   216         TEventCode /* aEventCode */ )
       
   217     {
       
   218     // Empty implementation
       
   219     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateStartup::HandleDtmfKeyToneL() ");
       
   220     }
       
   221     
       
   222 // -----------------------------------------------------------
       
   223 // CPhoneStateStartup::HandlePhoneStartupL
       
   224 // -----------------------------------------------------------
       
   225 //
       
   226 EXPORT_C void CPhoneStateStartup::HandlePhoneStartupL()
       
   227     {
       
   228     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateStartup::HandlePhoneStartupL() ");
       
   229     // Indicate that the phone is ready
       
   230     iPhoneReady = ETrue;
       
   231 
       
   232     // Only go to idle state when Phone engine is also ready
       
   233     if ( iPEReady )
       
   234         {
       
   235         // Security mode check.
       
   236 	    TPhoneCmdParamBoolean isSecurityMode;      
       
   237         iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );
       
   238         if ( !isSecurityMode.Boolean() && !IsSimOk() )
       
   239             {
       
   240             TPhoneCmdParamBoolean securityMode;
       
   241             securityMode.SetBoolean( ETrue );
       
   242             iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSecurityMode, &securityMode );
       
   243             iCreateNote = CIdle::NewL( CActive::EPriorityHigh );
       
   244             
       
   245             CreateAndShowNoteAfterIdle(); 
       
   246             }
       
   247         // Go to idle state
       
   248         SetDefaultFlagsL();
       
   249         iCbaManager->UpdateCbaL( EPhoneEmptyCBA );
       
   250         
       
   251         iViewCommandHandle->ExecuteCommand( EPhoneViewPrepareIcons );
       
   252         iViewCommandHandle->ExecuteCommand( EPhoneViewLoadPlugins );
       
   253         
       
   254         iStateMachine->ChangeState( EPhoneStateIdle );
       
   255         }
       
   256     }
       
   257 
       
   258 // ---------------------------------------------------------
       
   259 // CPhoneStateStartup::HandleIdleForegroundEventL
       
   260 // Phone should show security note asap. 
       
   261 // Active idle might be in front quite early if f.e. rejected SIM 
       
   262 // ---------------------------------------------------------
       
   263 //
       
   264 EXPORT_C void CPhoneStateStartup::HandleIdleForegroundEventL()
       
   265     {
       
   266     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateStartup::HandleIdleForegroundEventL( ) ");
       
   267     // Security mode check. 
       
   268     TPhoneCmdParamBoolean isSecurityMode;      
       
   269     iViewCommandHandle->ExecuteCommandL( EPhoneViewGetSecurityModeStatus, &isSecurityMode );        
       
   270     if ( !isSecurityMode.Boolean() && !IsSimOk() )
       
   271         {
       
   272         TPhoneCmdParamBoolean securityMode;
       
   273         securityMode.SetBoolean( ETrue );
       
   274         iViewCommandHandle->ExecuteCommandL( EPhoneViewSetSecurityMode, &securityMode );
       
   275         iCreateNote = CIdle::NewL( CActive::EPriorityHigh );
       
   276         
       
   277         CreateAndShowNoteAfterIdle(); 
       
   278         }
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CPhoneStateStartup::CreateAndShowNoteAfterIdle
       
   283 //
       
   284 // Callback function.
       
   285 // -----------------------------------------------------------------------------
       
   286 //
       
   287 void CPhoneStateStartup::CreateAndShowNoteAfterIdle()
       
   288     {
       
   289  __LOGMETHODSTARTEND( EPhoneControl, "CPhoneStateStartup::CreateAndShowNoteAfterIdle ");
       
   290         
       
   291     if ( !iCreateNote->IsActive() )
       
   292         {
       
   293         iCreateNote->Start( 
       
   294             TCallBack( DoShowNoteL, this ) );
       
   295         }
       
   296     }
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // CPhoneStateStartup::DoShowNoteL
       
   300 //
       
   301 // Callback function.
       
   302 // -----------------------------------------------------------------------------
       
   303 //
       
   304 TInt CPhoneStateStartup::DoShowNoteL( TAny* aAny )
       
   305     {        
       
   306     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneStateStartup::DoShowNoteL ");
       
   307     static_cast< CPhoneStateStartup* >( aAny )->
       
   308         StartShowSecurityNoteL();
       
   309 
       
   310     return KErrNone;
       
   311     }
       
   312 
       
   313 // End of File