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_MmcSDSessionData.h"
20 //MMCSD Commands index
22 _LIT(KCmdConstructor, "NewL");
23 _LIT(KCmdLoadDriver, "LoadDriver");
24 _LIT(KCmdUnLoadDriver, "UnLoadDriver");
25 _LIT(KCmdDriverOpen, "DriverOpen");
26 _LIT(KCmdDestructor, "~");
28 _LIT(KLDDName, "LDD");
29 _LIT(KStackNumber, "stacknumber");
35 * Create a new Socket Driver Data wrapper
37 * @return A Socket Driver Data wrapper
39 * @leave System wide error
41 CT_MmcSDSessionData* CT_MmcSDSessionData::NewL()
43 CT_MmcSDSessionData* ret=new (ELeave) CT_MmcSDSessionData();
44 CleanupStack::PushL(ret);
46 CleanupStack::Pop(ret);
55 CT_MmcSDSessionData::CT_MmcSDSessionData()
56 : CT_RBusLogicalChannelData()
57 , iMmcSDController(NULL)
62 * Second phase construction
66 * @leave System wide error
68 void CT_MmcSDSessionData::ConstructL()
77 CT_MmcSDSessionData::~CT_MmcSDSessionData()
82 * Return a pointer to the object that the data wraps
84 * @return pointer to the object that the data wraps
86 TAny* CT_MmcSDSessionData::GetObject()
88 return iMmcSDController;
92 * Return a pointer to the handle
94 * @return pointer to the MMC/SD Controller
96 RHandleBase* CT_MmcSDSessionData::GetHandleBase()
98 return iMmcSDController;
102 * Return a pointer to the logical channel
104 * @return pointer to the MMC/SD Controller
106 RBusLogicalChannel* CT_MmcSDSessionData::GetBusLogicalChannel()
108 return iMmcSDController;
116 void CT_MmcSDSessionData::DestroyData()
118 delete iMmcSDController;
119 iMmcSDController=NULL;
123 * Process a command read from the script file
125 * @param aCommand The command to process
126 * @param aSection The section in the ini containing data for the command
127 * @param aAsyncErrorIndex Command index for async calls to return errors to
129 * @return ETrue if the command is processed
131 * @leave System wide error
133 TBool CT_MmcSDSessionData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
137 if ( aCommand==KCmdConstructor )
141 else if ( aCommand==KCmdLoadDriver )
143 DoCmdLoadDriver(aSection);
145 else if ( aCommand==KCmdDriverOpen )
147 DoCmdDriverOpen(aSection);
149 else if ( aCommand==KCmdUnLoadDriver )
151 DoCmdUnLoadDriver(aSection);
153 else if ( aCommand==KCmdDestructor )
159 ret=CT_RBusLogicalChannelData::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
165 * Creates the RBusLogicalChannel derived interface
167 * @param aCommand None
171 void CT_MmcSDSessionData::DoCmdConstructor()
173 delete iMmcSDController;
174 iMmcSDController=NULL;
175 TRAPD(err, iMmcSDController=new (ELeave) RMMCSDTestControllerInterface());
178 ERR_PRINTF2(_L("RMMCSDTestControllerInterface Creation Error %d"), err);
184 * Loads the Device Driver
186 * @param aSection The section in the ini containing data for the command
190 void CT_MmcSDSessionData::DoCmdLoadDriver(const TDesC& aSection)
193 if(!GetStringFromConfig(aSection, KLDDName(), lddname))
195 ERR_PRINTF1(_L("Error in Reading Driver Name from INI file -Load"));
196 SetBlockResult(EFail);
198 User::LoadLogicalDevice(lddname);
202 * Unloads the Device Driver
204 * @param aSection The section in the ini containing data for the command
208 void CT_MmcSDSessionData::DoCmdUnLoadDriver(const TDesC& aSection)
211 if(!GetStringFromConfig(aSection, KLDDName(), lddname))
213 ERR_PRINTF1(_L("Error in Reading Driver Name from INI file-UnLoad"));
214 SetBlockResult(EFail);
216 User::FreeLogicalDevice(lddname);
220 * Opens the Driver Call
222 * @param aSection The section in the ini containing data for the command
226 void CT_MmcSDSessionData::DoCmdDriverOpen(const TDesC& aSection)
229 TInt stackNumber = 0;
230 GetIntFromConfig(aSection, KStackNumber(), stackNumber);
231 err=iMmcSDController->Open(stackNumber,iMmcSDController->VersionRequired());
234 ERR_PRINTF2(_L("Driver Open Call Failure %d"), err);
239 INFO_PRINTF2(_L("iMmcSDController = %x"), iMmcSDController);
244 * Destroys the objects
248 void CT_MmcSDSessionData::DoCmdDestructor()
250 INFO_PRINTF1(_L("CT_MmcSDSessionData::DoCmdDestructor()"));