os/boardsupport/haitest/bspsvs/suite/bsp/mmc/src/T_MmcSDMediaChangeDriverData.cpp
Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
18 #include "T_MmcSDMediaChangeDriverData.h"
20 //MMCSD Commands index
25 _LIT(KCmdMediaState, "MediaState");
26 _LIT(KCmdForceMediaChange, "ForceMediaChange");
27 _LIT(KCmdReplayCount, "ReplayCount");
29 _LIT(KExpectedMediaState, "expectedmediastate");
30 _LIT(KExpectedeventcount, "expectedeventcount");
32 _LIT(KOpened, "EOpened");
33 _LIT(KClosed, "EClosed");
35 const CDataWrapperBase::TEnumEntryTable CT_MMCSDMediaChangeDriverData::iEnumMediaState[] =
37 // Enum as a descriptor Enum
45 //////////////////////////////////////////////////////////////////////
46 // Construction/Destruction
47 //////////////////////////////////////////////////////////////////////
49 CT_MMCSDMediaChangeDriverData* CT_MMCSDMediaChangeDriverData::NewL()
51 CT_MMCSDMediaChangeDriverData* ret=new (ELeave) CT_MMCSDMediaChangeDriverData();
52 CleanupStack::PushL(ret);
54 CleanupStack::Pop(ret);
59 CT_MMCSDMediaChangeDriverData::CT_MMCSDMediaChangeDriverData()
60 : CT_MmcSDDriverData()
66 void CT_MMCSDMediaChangeDriverData::ConstructL()
68 * Second phase construction
77 * @leave system wide error
80 CT_MmcSDDriverData::ConstructL();
83 iCons = GetConsoleL();
88 CT_MMCSDMediaChangeDriverData::~CT_MMCSDMediaChangeDriverData()
96 TBool CT_MMCSDMediaChangeDriverData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
98 * Process a command read from the ini file
100 * @param aCommand The command to process
101 * @param aSection The section in the ini containing data for the command
102 * @param aAsyncErrorIndex Command index for async calls to return errors to
104 * @return ETrue if the command is processed
106 * @leave System wide error
111 if ( aCommand==KCmdMediaState)
113 DoCmdMediaState(aSection);
115 else if ( aCommand==KCmdForceMediaChange)
117 DoCmdForceMediaChange();
119 else if ( aCommand==KCmdReplayCount)
121 DoCmdReplayCount(aSection);
125 ret=CT_MmcSDDriverData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
131 * Get the Media State Information
133 * @param aSection The section in the ini containing data for the command
137 * @leave System wide error
139 void CT_MMCSDMediaChangeDriverData::DoCmdMediaState(const TDesC& aSection)
143 err= iMmcSDController->MediaStateInfo(mediaState);
146 ERR_PRINTF2(_L("MMC/SD : Error in getting MediaState information, error code = %d \n"),err);
147 SetBlockResult(EFail);
155 INFO_PRINTF1(_L("MMC/SD Current MediaChange MediaState - Opened"));
160 INFO_PRINTF1(_L("MMC/SD Current MediaChange MediaState - Closed"));
165 ERR_PRINTF2(_L("MMC/SD : Current Media State is not supported by the platform-MediaState= %d \n"),mediaState);
166 SetBlockResult(EFail);
170 TInt expectedmediaState;
171 if ( GetEnumFromConfig(aSection, KExpectedMediaState(), iEnumMediaState, expectedmediaState) )
173 if(mediaState != expectedmediaState)
175 ERR_PRINTF3(_L("mediaState(%d) != expectedmediaState(%d)"), mediaState, expectedmediaState);
176 SetBlockResult(EFail);
181 SetBlockResult(EFail);
182 WARN_PRINTF1(_L("expectedmediaState Value Missing From INI File"));
187 * Force Media to Change the State
189 * @param aSection The section in the ini containing data for the command
193 * @leave System wide error
195 void CT_MMCSDMediaChangeDriverData::DoCmdForceMediaChange()
198 err= iMmcSDController->ForceMediaChange();
201 ERR_PRINTF2(_L("MMC/SD : Error in forcing media state, error code = %d \n"),err);
207 * Count of media events yet to be acknowledged.
209 * @param aSection The section in the ini containing data for the command
213 * @leave System wide error
215 void CT_MMCSDMediaChangeDriverData::DoCmdReplayCount(const TDesC& aSection)
218 TInt mediaEventCount;
219 err=iMmcSDController->MediaChangeCounter(mediaEventCount);
222 ERR_PRINTF2(_L("MMC/SD : Error in reading media event replay count, error code = %d \n"),err);
223 SetBlockResult(EFail);
227 INFO_PRINTF2(_L("MMC/SD: Media Event Count = %d \n"),mediaEventCount);
228 TInt expectedmediaEventCount;
229 if(GetBoolFromConfig(aSection, KExpectedeventcount(), expectedmediaEventCount))
231 if(mediaEventCount != expectedmediaEventCount)
233 ERR_PRINTF3(_L("mediaEventCount(%d) != expectedchangedState(%d)"), mediaEventCount, expectedmediaEventCount);
234 SetBlockResult(EFail);
239 SetBlockResult(EFail);
240 WARN_PRINTF1(_L("expectedchangedState Value Missing From INI File"));