sysstatemgmt/ssmpolicyplugins/ssmswppolicybase/src/ssmswppolicybase.cpp
branchRCL_3
changeset 10 66ecddbca914
parent 0 4e1aa6a622a0
equal deleted inserted replaced
9:21e939dd208a 10:66ecddbca914
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    20 #include <ssm/ssmcommandlistresourcereader.h>
    20 #include <ssm/ssmcommandlistresourcereader.h>
    21 #include <ssm/ssmstatemanager.h>
    21 #include <ssm/ssmstatemanager.h>
    22 #include <ssm/ssmswp.h>
    22 #include <ssm/ssmswp.h>
    23 #include <ssm/ssmsubstates.hrh>
    23 #include <ssm/ssmsubstates.hrh>
    24 #include <ssm/starterclient.h>
    24 #include <ssm/starterclient.h>
       
    25 #include <startupdomaindefs.h>
    25 
    26 
    26 #include "ssmswppolicybase.h"
    27 #include "ssmswppolicybase.h"
    27 #include "trace.h"
    28 #include "trace.h"
    28 
    29 
    29 // ======== MEMBER FUNCTIONS ========
    30 // ======== MEMBER FUNCTIONS ========
   133         TRequestStatus* status = &aStatus;
   134         TRequestStatus* status = &aStatus;
   134         User::RequestComplete( status, KErrNone );
   135         User::RequestComplete( status, KErrNone );
   135         }
   136         }
   136     else
   137     else
   137         {
   138         {
   138         RSsmStateManager session;
   139 		TSsmState currentState;
   139         TInt errorCode = session.Connect();
   140 		TInt errorCode = GetCurrentState(currentState);
   140         ERROR( errorCode, "Failed to connect to RSsmStateManager" );
       
   141         if ( errorCode == KErrNone )
       
   142             {
       
   143             if ( ResetLimitReached() ) // Updates the reset count
       
   144                 {
       
   145                 INFO( "SWP transition failed -> Fail" );
       
   146                 errorCode = session.RequestStateTransition(
       
   147                     TSsmStateTransition( ESsmFail, KSsmAnySubState, 0 ) );
       
   148         	    }
       
   149     	    else
       
   150     	        {
       
   151                 INFO( "SWP transition failed -> Reset" );
       
   152                 errorCode = session.RequestStateTransition(
       
   153                     TSsmStateTransition( ESsmShutdown, KSsmAnySubState,
       
   154                         RStarterSession::EUnknownReset ) );
       
   155     	        }
       
   156 
   141 
   157             session.Close();
   142 		if ( ((currentState.MainState() != ESsmShutdown) && (currentState.MainState() != ESsmFail)) || KErrNone != errorCode)
   158             }
   143 			{
       
   144 			RSsmStateManager session;
       
   145 			errorCode = session.Connect();
       
   146 			ERROR( errorCode, "Failed to connect to RSsmStateManager" );
       
   147 			if ( KErrNone == errorCode )
       
   148 				{
       
   149 				if ( ResetLimitReached() ) // Updates the reset count
       
   150 					{
       
   151 					INFO_1( "SWP 0x%08x transition failed -> Fail", aSwp.Key() );
       
   152 					errorCode = session.RequestStateTransition(	TSsmStateTransition( ESsmFail, KSsmAnySubState, 0 ) );
       
   153 					}
       
   154 				else
       
   155 					{
       
   156 					INFO_1( "SWP 0x%08x transition failed -> Reset", aSwp.Key() );
       
   157 					errorCode = session.RequestStateTransition(
       
   158 									TSsmStateTransition( ESsmShutdown, KSsmAnySubState, RStarterSession::EUnknownReset ) );
       
   159 					}
       
   160 				session.Close();
       
   161 				}
       
   162 			}
   159 
   163 
   160         TRequestStatus* status = &aStatus;
   164         TRequestStatus* status = &aStatus;
   161         User::RequestComplete( status, errorCode );
   165         User::RequestComplete( status, errorCode );
   162         }
   166         }
   163 	}
   167 	}