sysstatemgmt/ssmpolicyplugins/ssmfailpolicy/src/ssmfailpolicy.cpp
changeset 0 4e1aa6a622a0
child 48 86cf7a1b7eb9
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 /*
       
     2 * Copyright (c) 2009 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 CSsmFailPolicy class.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <ssm/ssmstate.h>
       
    19 #include <ssm/ssmstatetransition.h>
       
    20 
       
    21 #include "ssmfailpolicy.h"
       
    22 #include "ssmsubstateext.hrh"
       
    23 #include "ssmmapperutility.h"
       
    24 #include "trace.h"
       
    25 
       
    26 /**
       
    27 * Fail state policy resource file path format :
       
    28 * "\private\<SID of SSM>\fail\"
       
    29 */
       
    30 _LIT( KCommandListPath, "Z:\\private\\2000D75B\\fail\\" );
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CSsmFailPolicy::NewL
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 EXPORT_C MSsmStatePolicy* CSsmFailPolicy::NewL()
       
    39     {
       
    40     CSsmFailPolicy* self = new( ELeave ) CSsmFailPolicy;
       
    41     CleanupStack::PushL( self );
       
    42     self->BaseConstructL();
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CSsmFailPolicy::~CSsmFailPolicy
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CSsmFailPolicy::~CSsmFailPolicy()
       
    53     {
       
    54     FUNC_LOG;
       
    55     }
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CSsmFailPolicy::GetNextState
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 TBool CSsmFailPolicy::GetNextState(
       
    63     TSsmState aCurrentTransition,
       
    64     TInt /*aReason*/,
       
    65     TInt ERROR_PARAM( aError ),
       
    66     TInt ERROR_PARAM( aSeverity ),
       
    67     TSsmState& /*aNextState*/ )
       
    68     {
       
    69     FUNC_LOG;
       
    70     INFO_2( "Current state %04x.%04x",
       
    71         aCurrentTransition.MainState(), aCurrentTransition.SubState() );
       
    72     ERROR_1( aError, "State transition resulted in an error, severity %d", aSeverity );
       
    73 
       
    74 	return EFalse;
       
    75     }
       
    76 
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CSsmFailPolicy::CSsmFailPolicy
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 CSsmFailPolicy::CSsmFailPolicy()
       
    83     {
       
    84     FUNC_LOG;
       
    85     }
       
    86 
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CSsmFailPolicy::GetCommandListPathL
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CSsmFailPolicy::GetCommandListPathL( TDes& aCmdListPath )
       
    93     {
       
    94     FUNC_LOG;
       
    95 
       
    96 	aCmdListPath = KCommandListPath;
       
    97 	iUtil->GetCommandListPath( aCmdListPath );
       
    98     }
       
    99 
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // CSsmFailPolicy::IsAllowedTargetState
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 TBool CSsmFailPolicy::IsAllowedTargetState(
       
   106     const TSsmStateTransition& aRequest ) const
       
   107     {
       
   108     FUNC_LOG;
       
   109 
       
   110     TUint16 mainState( aRequest.State().MainState() );
       
   111     INFO_2( "Requested target state = %04x.%04x", mainState, aRequest.State().SubState() );
       
   112 
       
   113     if ( mainState == ESsmShutdown )
       
   114         {
       
   115         return ETrue;
       
   116         }
       
   117 
       
   118     return EFalse;
       
   119     }
       
   120 
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // CSsmFailPolicy::TargetSubState
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 TUint16 CSsmFailPolicy::TargetSubState( const TUint16 aRequestedSubState )
       
   127     {
       
   128     FUNC_LOG;
       
   129     INFO_1( "Requested sub state %04x", aRequestedSubState );
       
   130 
       
   131 	TUint16 subState = ( aRequestedSubState == KSsmAnySubState ?
       
   132         ESsmStateFail : aRequestedSubState );
       
   133 
       
   134     INFO_1( "Target sub state %04x", subState );
       
   135     return subState;
       
   136     }