sysstatemgmt/systemstatereferenceplugins/custcmd/src/cmdcoopsysperformrestartactions.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalComponent
       
    19  @released
       
    20 */
       
    21 
       
    22 #include "cmdcoopsysperformrestartactions.h"
       
    23 #include <barsread2.h>
       
    24 
       
    25 CCustomCmdCoopSysPerformRestartActions* CCustomCmdCoopSysPerformRestartActions::NewL()
       
    26 	{
       
    27 	CCustomCmdCoopSysPerformRestartActions* self = new (ELeave) CCustomCmdCoopSysPerformRestartActions();
       
    28 	return self;
       
    29 	}
       
    30 
       
    31 CCustomCmdCoopSysPerformRestartActions::CCustomCmdCoopSysPerformRestartActions()
       
    32 	{
       
    33 	}
       
    34 
       
    35 CCustomCmdCoopSysPerformRestartActions::~CCustomCmdCoopSysPerformRestartActions()
       
    36 	{
       
    37 	}
       
    38 
       
    39 TInt CCustomCmdCoopSysPerformRestartActions::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/)
       
    40 	{
       
    41 	//Connect to RSsmStateAdaptation
       
    42 	return iSsmStateAdaptation.Connect();
       
    43 	}
       
    44 
       
    45 void CCustomCmdCoopSysPerformRestartActions::Close()
       
    46 	{
       
    47 	//Cancel the request if there is any
       
    48 	iSsmStateAdaptation.RequestCancel();
       
    49 	
       
    50 	//Close RSsmStateAdaptation
       
    51 	iSsmStateAdaptation.Close();
       
    52 	}
       
    53 
       
    54 void CCustomCmdCoopSysPerformRestartActions::Release()
       
    55 	{
       
    56 	delete this;
       
    57 	}
       
    58 
       
    59 void CCustomCmdCoopSysPerformRestartActions::Execute(const TDesC8& aParams, TRequestStatus& aStatus)
       
    60 	{
       
    61 	TInt reason = 0;
       
    62 
       
    63 	//Get the reason value
       
    64 	TRAPD(err, reason = ExecuteL(aParams));
       
    65 
       
    66 	if(KErrNone == err)
       
    67 		{
       
    68 		//Request coop system to perform restart actions
       
    69 		iSsmStateAdaptation.RequestCoopSysPerformRestartActions(reason, aStatus);
       
    70 		}
       
    71 	else
       
    72 		{
       
    73 		//In case of error complete the request with error code
       
    74 		TRequestStatus* status = &aStatus;
       
    75 		User::RequestComplete(status, err);
       
    76 		}
       
    77 	}
       
    78 
       
    79 TInt CCustomCmdCoopSysPerformRestartActions::ExecuteL(const TDesC8& aParams)
       
    80 	{
       
    81 	RResourceReader reader;
       
    82 
       
    83 	//Open the descriptor data
       
    84 	reader.OpenLC(aParams);
       
    85 
       
    86 	//Read the reason value from param data
       
    87 	const TInt reason = reader.ReadInt32L();
       
    88 	CleanupStack::PopAndDestroy(&reader);
       
    89 	return reason;
       
    90 	}
       
    91 
       
    92 void CCustomCmdCoopSysPerformRestartActions::ExecuteCancel()
       
    93 	{
       
    94 	//Cancel the request if there is any
       
    95 	iSsmStateAdaptation.RequestCancel();
       
    96 	}