sysstatemgmt/sysrestart/src/restartsys.cpp
changeset 0 4e1aa6a622a0
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 restartsys class.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <ssm/ssmstatemanager.h>
       
    19 #include <ssm/ssmsubstates.hrh>
       
    20 #include <ssm/starterclient.h>
       
    21 #include "restartsys.h"
       
    22 #include "trace.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // RestartSys::RestartSystem
       
    28 //
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 EXPORT_C TInt RestartSys::RestartSystem()
       
    32     {
       
    33     FUNC_LOG;
       
    34 
       
    35     return RestartSystem( RStarterSession::EUnknownReset );
       
    36     }
       
    37 
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // RestartSys::RestartSystem
       
    41 //
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 EXPORT_C TInt RestartSys::RestartSystem( TInt aStartupMode )
       
    45     {
       
    46     FUNC_LOG;
       
    47     INFO_1( "System re-start requested, mode %d", aStartupMode );
       
    48 
       
    49     RSsmStateManager session;
       
    50     TInt errorCode = session.Connect();
       
    51     ERROR( errorCode, "Failed to connect to RSsmStateManager" );
       
    52 
       
    53     if ( errorCode == KErrNone )
       
    54         {
       
    55         TSsmStateTransition stateinfo( ESsmShutdown, 
       
    56             KSsmAnySubState, aStartupMode );
       
    57 
       
    58         // Make request and ignore return value
       
    59         errorCode = session.RequestStateTransition( stateinfo );
       
    60         ERROR( errorCode, "Failed to RequestStateTransition" );
       
    61         session.Close();
       
    62         }
       
    63 
       
    64     return errorCode;
       
    65     }