phoneapp/phoneuicontrol/src/cphonestatemachine.cpp
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
child 74 d1c62c765e48
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2005 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 CPhoneStateMachine class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <pevirtualengine.h>
       
    21 #include <mpeengineinfo.h>
       
    22 
       
    23 #include "phoneui.pan"
       
    24 #include "cphonestatemachine.h"
       
    25 #include "cphonestatestartup.h"
       
    26 #include "cphonestateidle.h"
       
    27 #include "cphonestateincoming.h"
       
    28 #include "cphonestatecallsetup.h"
       
    29 #include "cphonestateincall.h"
       
    30 #include "phonestatedefinitions.h"
       
    31 #include "phonelogger.h"
       
    32 #include "cphonestorage.h"
       
    33 #include "mphonestorage.h"
       
    34 
       
    35 // ================= MEMBER FUNCTIONS =======================
       
    36 
       
    37 // C++ default constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 //
       
    40 EXPORT_C CPhoneStateMachine::CPhoneStateMachine(
       
    41     MPhoneViewCommandHandle* aViewCommandHandle ) :
       
    42     iOldStateId( EPhoneStateNull ),
       
    43     iNewStateId( EPhoneStateNull ),
       
    44     iViewCommandHandle( aViewCommandHandle )
       
    45     {
       
    46     __ASSERT_ALWAYS( aViewCommandHandle,
       
    47         Panic( EPhoneCtrlParameterNotInitialized ) );
       
    48     }
       
    49 
       
    50 // -----------------------------------------------------------
       
    51 // CPhoneStateMachine::~CPhoneStateMachine()
       
    52 // Destructor
       
    53 // (other items were commented in a header).
       
    54 // -----------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CPhoneStateMachine::~CPhoneStateMachine()
       
    57     {
       
    58     if( iState == iIdleState )
       
    59         {
       
    60         delete iState;
       
    61         iState = NULL;
       
    62         iIdleState = NULL;          
       
    63         }
       
    64     else
       
    65         {
       
    66         if( iState )
       
    67             {
       
    68             delete iState;
       
    69             iState = NULL;          
       
    70             }
       
    71         if( iIdleState )
       
    72             {
       
    73             delete iIdleState;
       
    74             iIdleState = NULL;          
       
    75             }           
       
    76         }
       
    77     if( iPhoneEngine )
       
    78         {
       
    79         delete iPhoneEngine;
       
    80         iPhoneEngine = NULL;            
       
    81         }
       
    82     if( iPhoneStorage )
       
    83         {
       
    84         delete iPhoneStorage;
       
    85         iPhoneStorage = NULL;
       
    86         }
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------
       
    90 // CPhoneStateMachine::SetPhoneEngine
       
    91 // ---------------------------------------------------------
       
    92 //
       
    93 EXPORT_C void CPhoneStateMachine::SetPhoneEngine( 
       
    94     MPEPhoneModel* aPhoneEngine )
       
    95     {
       
    96     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneStateMachine::SetPhoneEngine ");
       
    97     __ASSERT_ALWAYS( aPhoneEngine, 
       
    98         Panic( EPhoneCtrlParameterNotInitialized ) );
       
    99     
       
   100     iPhoneEngine = aPhoneEngine;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------
       
   104 // CPhoneStateMachine::PhoneEngine
       
   105 // -----------------------------------------------------------
       
   106 //
       
   107 EXPORT_C MPEPhoneModel* CPhoneStateMachine::PhoneEngine()
       
   108     {
       
   109     __ASSERT_DEBUG( iPhoneEngine, Panic( EPhoneCtrlInvariant ) );
       
   110     return iPhoneEngine;
       
   111     }
       
   112 // -----------------------------------------------------------
       
   113 // CPhoneStateMachine::PhoneEngineInfo
       
   114 // -----------------------------------------------------------
       
   115 //
       
   116 EXPORT_C MPEEngineInfo* CPhoneStateMachine::PhoneEngineInfo()
       
   117     {
       
   118     if ( iPhoneEngine )
       
   119         {
       
   120         return iPhoneEngine->EngineInfo();
       
   121         }
       
   122     else
       
   123         {
       
   124         return NULL;
       
   125         }
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------
       
   129 // CPhoneStateMachine::ChangeState()
       
   130 // (other items were commented in a header).
       
   131 // -----------------------------------------------------------
       
   132 //
       
   133 EXPORT_C void CPhoneStateMachine::ChangeState( TInt aState )
       
   134     {
       
   135     __PHONELOGSTATECHANGE( iNewStateId, aState );
       
   136     iNewStateId = aState;
       
   137     }
       
   138 
       
   139 // -----------------------------------------------------------
       
   140 // CPhoneStateMachine::State()
       
   141 // (other items were commented in a header).
       
   142 // -----------------------------------------------------------
       
   143 //
       
   144 EXPORT_C MPhoneState* CPhoneStateMachine::State()
       
   145     {
       
   146     return iState;
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------
       
   150 // CPhoneStateMachine::CreatePhoneEngineL
       
   151 // (other items were commented in a header).
       
   152 // -----------------------------------------------------------
       
   153 //
       
   154 EXPORT_C MPEPhoneModel* CPhoneStateMachine::CreatePhoneEngineL(
       
   155     MEngineMonitor& /*aEngineMonitor*/ )
       
   156     {
       
   157     return NULL;        
       
   158     }
       
   159     
       
   160 // -----------------------------------------------------------
       
   161 // CPhoneStateMachine::SendPhoneEngineMessage
       
   162 // -----------------------------------------------------------
       
   163 //
       
   164 EXPORT_C void CPhoneStateMachine::SendPhoneEngineMessage( 
       
   165     TInt aMessage )
       
   166     {
       
   167     __PHONELOGENGINECMD( aMessage );
       
   168     PhoneEngine()->HandleMessage( aMessage );
       
   169     }
       
   170     
       
   171 // -----------------------------------------------------------
       
   172 // CPhoneStateMachine::SetCallId
       
   173 // -----------------------------------------------------------
       
   174 //
       
   175 EXPORT_C void CPhoneStateMachine::SetCallId( 
       
   176     TInt aCallId )
       
   177     {
       
   178     __PHONELOG1(
       
   179         EBasic, 
       
   180         EPhoneControl,
       
   181         "CALL ID: CPhoneStateMachine::SetCallId (%d)",
       
   182         aCallId);     
       
   183     PhoneEngineInfo()->SetCallId( aCallId );
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------
       
   187 // CPhoneStateMachine::PhoneStorage
       
   188 // -----------------------------------------------------------
       
   189 //
       
   190 EXPORT_C MPhoneStorage* CPhoneStateMachine::PhoneStorage()
       
   191     {
       
   192     if ( iPhoneStorage == NULL )
       
   193         {
       
   194         TInt err( KErrNone );
       
   195         TRAP( err, iPhoneStorage = CPhoneStorage::NewL());
       
   196         __ASSERT_ALWAYS( KErrNone == err, User::Invariant() );
       
   197         }
       
   198     return iPhoneStorage;
       
   199     }
       
   200 
       
   201 // End of File