voiceui/voiceuivoicerecognition/src/vuicprecheckstate.cpp
changeset 13 57b735022c18
parent 1 b13cd05eeb2f
equal deleted inserted replaced
1:b13cd05eeb2f 13:57b735022c18
     1 /*
       
     2 * Copyright (c) 2006-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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include <coreapplicationuisdomainpskeys.h>
       
    22 #include <ctsydomainpskeys.h>
       
    23 #include <PSVariables.h>        // Property values
       
    24 
       
    25 #include "vuicstate.h"
       
    26 #include "vuicprecheckstate.h"
       
    27 #include "vuiccontextcheckstate.h"
       
    28 #include "vuicexitstate.h"
       
    29 #include "vuicerrorstate.h"
       
    30 
       
    31 #include "vuicdatastorage.h"
       
    32 
       
    33 #include "vuicvoicerecogdialogimpl.h"
       
    34 
       
    35 #include "rubydebug.h"
       
    36     
       
    37 // -----------------------------------------------------------------------------
       
    38 // CPrecheckState::NewL
       
    39 // Two-phased constructor.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CPrecheckState* CPrecheckState::NewL( CDataStorage& aDataStorage, CUiModel& aUiModel )
       
    43     {
       
    44     CPrecheckState* self = new (ELeave) CPrecheckState( aDataStorage, aUiModel );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL();
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }       
       
    50     
       
    51 // Destructor       
       
    52 CPrecheckState::~CPrecheckState()
       
    53     {
       
    54     RUBY_DEBUG0( "CPrecheckState::~CPrecheckState START" );
       
    55     
       
    56     RUBY_DEBUG0( "CPrecheckState::~CPrecheckState EXIT" );
       
    57     }
       
    58     
       
    59 // ---------------------------------------------------------
       
    60 // CPrecheckState::HandleEventL
       
    61 // ---------------------------------------------------------
       
    62 //       
       
    63 void CPrecheckState::HandleEventL( TInt aEvent )
       
    64     {
       
    65     RUBY_DEBUG_BLOCK( "CPrecheckState::HandleEventL" );
       
    66 
       
    67     CState* nextState = NULL;
       
    68 
       
    69     switch( aEvent )
       
    70         {
       
    71         case KErrNone:
       
    72         
       
    73             nextState = CContextCheckState::NewL( DataStorage(), UiModel() );
       
    74             break;
       
    75         
       
    76         case KErrGeneral:
       
    77         
       
    78             nextState = CExitState::NewL( DataStorage(), UiModel() );
       
    79             break;
       
    80         
       
    81         default:
       
    82         
       
    83             nextState = CErrorState::NewL( DataStorage(), UiModel(), aEvent );
       
    84             break;
       
    85         }
       
    86 
       
    87     DataStorage().VoiceRecognitionImpl()->ChangeState( nextState );
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------
       
    91 // CPrecheckState::ExecuteL
       
    92 // ---------------------------------------------------------
       
    93 //       
       
    94 void CPrecheckState::ExecuteL()
       
    95     {
       
    96     RUBY_DEBUG_BLOCK( "CPrecheckState::ExecuteL" );
       
    97     
       
    98     TInt error = KErrNone;
       
    99 
       
   100     // Check if autolock is on
       
   101     if ( GetAutoLockValue() > EAutolockOff )
       
   102         {
       
   103         if ( !DataStorage().DeviceLockMode() )
       
   104             {
       
   105             error = KErrGeneral;
       
   106             }
       
   107         }
       
   108     else
       
   109         {
       
   110         DataStorage().SetDeviceLockMode( EFalse );
       
   111         }
       
   112 
       
   113     // Check if phone or video call is currently active
       
   114     TInt state = CheckCallState();
       
   115     if ( ( state != EPSCTsyCallStateNone &&
       
   116            state != EPSCTsyCallStateUninitialized &&
       
   117            state != KErrUnknown ) || IsVideoCall() )
       
   118         {
       
   119         error = KErrCallInProgress;
       
   120         }
       
   121 
       
   122     HandleEventL( error );
       
   123     }
       
   124 
       
   125 // ---------------------------------------------------------
       
   126 // CPrecheckState::CPrecheckState
       
   127 // ---------------------------------------------------------
       
   128 //              
       
   129 CPrecheckState::CPrecheckState( CDataStorage& aDataStorage, CUiModel& aUiModel )
       
   130  : CState( aDataStorage, aUiModel )
       
   131     {
       
   132     }
       
   133    
       
   134 // ---------------------------------------------------------
       
   135 // CPrecheckState::GetAutoLockValue
       
   136 // ---------------------------------------------------------
       
   137 //
       
   138 TInt CPrecheckState::GetAutoLockValue()
       
   139     {
       
   140     RUBY_DEBUG0( "CPrecheckState::GetAutoLockValue START" );
       
   141   
       
   142     TInt autoLockValue;
       
   143     TInt err = RProperty::Get( KPSUidCoreApplicationUIs,
       
   144                                KCoreAppUIsAutolockStatus,
       
   145                                autoLockValue );
       
   146     if ( err == KErrNotFound )
       
   147         {
       
   148         autoLockValue = KErrNotFound;
       
   149         }
       
   150         
       
   151     RUBY_DEBUG0( "CPrecheckState::GetAutoLockValue EXIT" );
       
   152     
       
   153     return autoLockValue;
       
   154     }
       
   155     
       
   156 // ---------------------------------------------------------
       
   157 // CPrecheckState::CheckCallState
       
   158 // ---------------------------------------------------------
       
   159 //
       
   160 TInt CPrecheckState::CheckCallState()
       
   161     {
       
   162     RUBY_DEBUG0( "CPrecheckState::CheckCallState START" );
       
   163     
       
   164     TInt callState;
       
   165     TInt err = RProperty::Get( KPSUidCtsyCallInformation,
       
   166                                KCTsyCallState,
       
   167                                callState );
       
   168     if ( err == KErrNotFound )
       
   169         {
       
   170         callState = KErrNotFound;
       
   171         }
       
   172     
       
   173     RUBY_DEBUG0( "CPrecheckState::CheckCallState EXIT" );
       
   174     
       
   175     return callState;    
       
   176     }    
       
   177     
       
   178 // -----------------------------------------------------------------------------
       
   179 // CPrecheckState::IsVideoCall 
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 TBool CPrecheckState::IsVideoCall() 
       
   183     {
       
   184     RUBY_DEBUG0( "CPrecheckState::IsVideoCall START" );
       
   185     
       
   186     TInt callType;
       
   187     RProperty::Get( KPSUidCtsyCallInformation,
       
   188                     KCTsyCallType, 
       
   189                     callType );// Ignore errors  
       
   190 
       
   191     RUBY_DEBUG0( "CPrecheckState::IsVideoCall EXIT" );
       
   192 
       
   193     return callType == EPSCTsyCallTypeH324Multimedia;
       
   194     }    
       
   195 
       
   196     
       
   197 // End of File
       
   198