00001 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: A dummy disk status system wide property is provided to demonstrate 00014 // the System State Manager framework. 00015 // 00016 00036 #include <ssm/ssmswppolicy.h> 00037 #include <ssm/ssmcommandlist.h> 00038 #include <ssm/ssmcommandlistresourcereader.h> 00039 #include "dummy_diskstatus_swppolicy.h" 00040 #include "dummy_diskstatus_swppolicy.hrh" 00041 00045 _LIT(KCommandListPath, "z:\\private\\2000d75b\\ssmaeg\\swp_dummy_diskstatus\\"); 00046 00050 _LIT(KExamplePolicyPanic,"DummyDiskStatus"); 00051 00057 EXPORT_C MSsmSwpPolicy* CSsmDummyDiskStatusSwpPolicy::NewL() 00058 { 00059 CSsmDummyDiskStatusSwpPolicy* self = new (ELeave) CSsmDummyDiskStatusSwpPolicy; 00060 CleanupStack::PushL(self); 00061 self->ConstructL(); 00062 CleanupStack::Pop(self); 00063 return self; 00064 } 00065 00069 CSsmDummyDiskStatusSwpPolicy::CSsmDummyDiskStatusSwpPolicy() 00070 { 00071 } 00072 00076 CSsmDummyDiskStatusSwpPolicy::~CSsmDummyDiskStatusSwpPolicy() 00077 { 00078 iFs.Close(); 00079 delete iCommandListResourceReader; 00080 } 00081 00085 void CSsmDummyDiskStatusSwpPolicy::ConstructL() 00086 { 00087 User::LeaveIfError(iFs.Connect()); 00088 // create resource reader 00089 iCommandListResourceReader = CSsmCommandListResourceReader::NewL(iFs, KCommandListPath(), *this); 00090 } 00091 00095 void CSsmDummyDiskStatusSwpPolicy::Initialize(TRequestStatus& aStatus) 00096 { 00097 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader)); 00098 // initialise command list resource reader. 00099 iCommandListResourceReader->Initialise(aStatus); 00100 } 00101 00105 void CSsmDummyDiskStatusSwpPolicy::InitializeCancel() 00106 { 00107 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader)); 00108 iCommandListResourceReader->InitialiseCancel(); 00109 } 00110 00116 void CSsmDummyDiskStatusSwpPolicy::Release() 00117 { 00118 delete this; 00119 } 00120 00129 MSsmSwpPolicy::TResponse CSsmDummyDiskStatusSwpPolicy::TransitionAllowed(const TSsmSwp& /*aSwp*/, const RMessagePtr2& /*aMessage*/) 00130 { 00131 TResponse response = EAllowed; 00132 return response; 00133 } 00134 00141 void CSsmDummyDiskStatusSwpPolicy::PrepareCommandList(const TSsmSwp& aSwp, TRequestStatus& aStatus) 00142 { 00143 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader)); 00144 // Build the command list for this value from a resource 00145 iCommandListResourceReader->PrepareCommandList(aSwp.Value(), aSwp, aStatus); 00146 } 00147 00152 void CSsmDummyDiskStatusSwpPolicy::PrepareCommandListCancel() 00153 { 00154 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader)); 00155 iCommandListResourceReader->PrepareCommandListCancel(); 00156 } 00157 00164 CSsmCommandList* CSsmDummyDiskStatusSwpPolicy::CommandList() 00165 { 00166 __ASSERT_ALWAYS(iCommandListResourceReader, User::Panic(KExamplePolicyPanic, EInvalidResourceReader)); 00167 return iCommandListResourceReader->GetCommandList(); 00168 } 00169 00178 void CSsmDummyDiskStatusSwpPolicy::HandleCleReturnValue(const TSsmSwp& /*aSwp*/, TInt /*aError*/, TInt /*aSeverity*/, TRequestStatus& aStatus) 00179 { 00180 /* 00181 This function is going to handle the return value. Even an reported error is treated as 00182 a successful API request. The request always needs to be completed with KErrNone. 00183 */ 00184 TRequestStatus* rs = &aStatus; 00185 User::RequestComplete(rs, KErrNone); 00186 } 00187 00192 void CSsmDummyDiskStatusSwpPolicy::HandleCleReturnValueCancel() 00193 { 00194 // Nothing to do as HandleCleReturnValue always completes immediately 00195 } 00196 00207 TBool CSsmDummyDiskStatusSwpPolicy::ConditionalCommandAllowedL(CResourceFile& /*aResourceFile*/, TInt /*aResourceId*/) 00208 { 00209 return EFalse; // command list does not contain commands that have conditions, so return EFalse 00210 }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.