sysstatemgmt/systemstatereferenceplugins/custcmd/src/cmdcoopsysstatechange.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 "cmdcoopsysstatechange.h"
       
    23 #include <ssm/ssmstate.h>
       
    24 #include <barsread2.h>
       
    25 
       
    26 CCustomCmdCoopSysStateChange* CCustomCmdCoopSysStateChange::NewL()
       
    27 	{
       
    28 	CCustomCmdCoopSysStateChange* self = new (ELeave) CCustomCmdCoopSysStateChange();
       
    29 	return self;
       
    30 	}
       
    31 
       
    32 CCustomCmdCoopSysStateChange::CCustomCmdCoopSysStateChange()
       
    33 	{
       
    34 	}
       
    35 
       
    36 CCustomCmdCoopSysStateChange::~CCustomCmdCoopSysStateChange()
       
    37 	{
       
    38 	}
       
    39 
       
    40 TInt CCustomCmdCoopSysStateChange::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/)
       
    41 	{
       
    42 	//Connect to RSsmStateAdaptation
       
    43 	return iSsmStateAdaptation.Connect();
       
    44 	}
       
    45 
       
    46 void CCustomCmdCoopSysStateChange::Close()
       
    47 	{
       
    48 	//Cancel the request if there is any
       
    49 	iSsmStateAdaptation.RequestCancel();
       
    50 	
       
    51 	//Close RSsmStateAdaptation
       
    52 	iSsmStateAdaptation.Close();
       
    53 	}
       
    54 
       
    55 void CCustomCmdCoopSysStateChange::Release()
       
    56 	{
       
    57 	delete this;
       
    58 	}
       
    59 
       
    60 void CCustomCmdCoopSysStateChange::Execute(const TDesC8& aParams, TRequestStatus& aStatus)
       
    61 	{
       
    62 	TSsmState ssmState;
       
    63 
       
    64 	//Internalise the param in to TSsmState
       
    65 	TRAPD(err, ssmState = ExecuteL(aParams));
       
    66 
       
    67 	if(KErrNone == err)
       
    68 		{
       
    69 		//Request coop system to perform Rfs actions
       
    70 		iSsmStateAdaptation.RequestCoopSysStateChange(ssmState, aStatus);
       
    71 		}
       
    72 	else
       
    73 		{
       
    74 		//In case of error complete the request with error code
       
    75 		TRequestStatus* status = &aStatus;
       
    76 		User::RequestComplete(status, err);
       
    77 		}
       
    78 	}
       
    79 
       
    80 TSsmState CCustomCmdCoopSysStateChange::ExecuteL(const TDesC8& aParams)
       
    81 	{
       
    82 	RResourceReader reader;
       
    83 
       
    84 	//Open the descriptor data to be internalised
       
    85 	reader.OpenLC(aParams);
       
    86 
       
    87 	//Read the main state from param data
       
    88 	const TInt mainState = reader.ReadInt16L();
       
    89 
       
    90 	//Read the substate from param data
       
    91 	const TInt subState = reader.ReadInt16L();
       
    92 	CleanupStack::PopAndDestroy(&reader); 
       
    93 
       
    94 	//Create a TSsmState object and return
       
    95 	return TSsmState(mainState, subState);
       
    96 	}
       
    97 
       
    98 void CCustomCmdCoopSysStateChange::ExecuteCancel()
       
    99 	{
       
   100 	//Cancel the request if there is any
       
   101 	iSsmStateAdaptation.RequestCancel();
       
   102 	}