|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "T_MmcSDSessionData.h" |
|
19 |
|
20 //MMCSD Commands index |
|
21 /*@{*/ |
|
22 _LIT(KCmdConstructor, "NewL"); |
|
23 _LIT(KCmdLoadDriver, "LoadDriver"); |
|
24 _LIT(KCmdUnLoadDriver, "UnLoadDriver"); |
|
25 _LIT(KCmdDriverOpen, "DriverOpen"); |
|
26 _LIT(KCmdDestructor, "~"); |
|
27 |
|
28 _LIT(KLDDName, "LDD"); |
|
29 _LIT(KStackNumber, "stacknumber"); |
|
30 /*@}*/ |
|
31 |
|
32 |
|
33 |
|
34 /** |
|
35 * Create a new Socket Driver Data wrapper |
|
36 * |
|
37 * @return A Socket Driver Data wrapper |
|
38 * |
|
39 * @leave System wide error |
|
40 */ |
|
41 CT_MmcSDSessionData* CT_MmcSDSessionData::NewL() |
|
42 { |
|
43 CT_MmcSDSessionData* ret=new (ELeave) CT_MmcSDSessionData(); |
|
44 CleanupStack::PushL(ret); |
|
45 ret->ConstructL(); |
|
46 CleanupStack::Pop(ret); |
|
47 return ret; |
|
48 } |
|
49 |
|
50 /** |
|
51 * Construction |
|
52 * |
|
53 * @return N/A |
|
54 */ |
|
55 CT_MmcSDSessionData::CT_MmcSDSessionData() |
|
56 : CT_RBusLogicalChannelData() |
|
57 , iMmcSDController(NULL) |
|
58 { |
|
59 } |
|
60 |
|
61 /** |
|
62 * Second phase construction |
|
63 * |
|
64 * @return void |
|
65 * |
|
66 * @leave System wide error |
|
67 */ |
|
68 void CT_MmcSDSessionData::ConstructL() |
|
69 { |
|
70 } |
|
71 |
|
72 /** |
|
73 * Public destructor |
|
74 * |
|
75 * @return N/A |
|
76 */ |
|
77 CT_MmcSDSessionData::~CT_MmcSDSessionData() |
|
78 { |
|
79 } |
|
80 |
|
81 /** |
|
82 * Return a pointer to the object that the data wraps |
|
83 * |
|
84 * @return pointer to the object that the data wraps |
|
85 */ |
|
86 TAny* CT_MmcSDSessionData::GetObject() |
|
87 { |
|
88 return iMmcSDController; |
|
89 } |
|
90 |
|
91 /** |
|
92 * Return a pointer to the handle |
|
93 * |
|
94 * @return pointer to the MMC/SD Controller |
|
95 */ |
|
96 RHandleBase* CT_MmcSDSessionData::GetHandleBase() |
|
97 { |
|
98 return iMmcSDController; |
|
99 } |
|
100 |
|
101 /** |
|
102 * Return a pointer to the logical channel |
|
103 * |
|
104 * @return pointer to the MMC/SD Controller |
|
105 */ |
|
106 RBusLogicalChannel* CT_MmcSDSessionData::GetBusLogicalChannel() |
|
107 { |
|
108 return iMmcSDController; |
|
109 } |
|
110 |
|
111 /** |
|
112 * Close and clean |
|
113 * |
|
114 * @return void |
|
115 */ |
|
116 void CT_MmcSDSessionData::DestroyData() |
|
117 { |
|
118 delete iMmcSDController; |
|
119 iMmcSDController=NULL; |
|
120 } |
|
121 |
|
122 /** |
|
123 * Process a command read from the script file |
|
124 * |
|
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 |
|
128 * |
|
129 * @return ETrue if the command is processed |
|
130 * |
|
131 * @leave System wide error |
|
132 */ |
|
133 TBool CT_MmcSDSessionData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
134 { |
|
135 TBool ret=ETrue; |
|
136 |
|
137 if ( aCommand==KCmdConstructor ) |
|
138 { |
|
139 DoCmdConstructor(); |
|
140 } |
|
141 else if ( aCommand==KCmdLoadDriver ) |
|
142 { |
|
143 DoCmdLoadDriver(aSection); |
|
144 } |
|
145 else if ( aCommand==KCmdDriverOpen ) |
|
146 { |
|
147 DoCmdDriverOpen(aSection); |
|
148 } |
|
149 else if ( aCommand==KCmdUnLoadDriver ) |
|
150 { |
|
151 DoCmdUnLoadDriver(aSection); |
|
152 } |
|
153 else if ( aCommand==KCmdDestructor ) |
|
154 { |
|
155 DoCmdDestructor(); |
|
156 } |
|
157 else |
|
158 { |
|
159 ret=CT_RBusLogicalChannelData::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
160 } |
|
161 return ret; |
|
162 } |
|
163 |
|
164 /** |
|
165 * Creates the RBusLogicalChannel derived interface |
|
166 * |
|
167 * @param aCommand None |
|
168 * |
|
169 * @return None |
|
170 */ |
|
171 void CT_MmcSDSessionData::DoCmdConstructor() |
|
172 { |
|
173 delete iMmcSDController; |
|
174 iMmcSDController=NULL; |
|
175 TRAPD(err, iMmcSDController=new (ELeave) RMMCSDTestControllerInterface()); |
|
176 if ( err!=KErrNone ) |
|
177 { |
|
178 ERR_PRINTF2(_L("RMMCSDTestControllerInterface Creation Error %d"), err); |
|
179 SetError(err); |
|
180 } |
|
181 } |
|
182 |
|
183 /** |
|
184 * Loads the Device Driver |
|
185 * |
|
186 * @param aSection The section in the ini containing data for the command |
|
187 * |
|
188 * @return void |
|
189 */ |
|
190 void CT_MmcSDSessionData::DoCmdLoadDriver(const TDesC& aSection) |
|
191 { |
|
192 TPtrC lddname; |
|
193 if(!GetStringFromConfig(aSection, KLDDName(), lddname)) |
|
194 { |
|
195 ERR_PRINTF1(_L("Error in Reading Driver Name from INI file -Load")); |
|
196 SetBlockResult(EFail); |
|
197 } |
|
198 User::LoadLogicalDevice(lddname); |
|
199 } |
|
200 |
|
201 /** |
|
202 * Unloads the Device Driver |
|
203 * |
|
204 * @param aSection The section in the ini containing data for the command |
|
205 * |
|
206 * @return void |
|
207 */ |
|
208 void CT_MmcSDSessionData::DoCmdUnLoadDriver(const TDesC& aSection) |
|
209 { |
|
210 TPtrC lddname; |
|
211 if(!GetStringFromConfig(aSection, KLDDName(), lddname)) |
|
212 { |
|
213 ERR_PRINTF1(_L("Error in Reading Driver Name from INI file-UnLoad")); |
|
214 SetBlockResult(EFail); |
|
215 } |
|
216 User::FreeLogicalDevice(lddname); |
|
217 } |
|
218 |
|
219 /** |
|
220 * Opens the Driver Call |
|
221 * |
|
222 * @param aSection The section in the ini containing data for the command |
|
223 * |
|
224 * @return void |
|
225 */ |
|
226 void CT_MmcSDSessionData::DoCmdDriverOpen(const TDesC& aSection) |
|
227 { |
|
228 TInt err; |
|
229 TInt stackNumber = 0; |
|
230 GetIntFromConfig(aSection, KStackNumber(), stackNumber); |
|
231 err=iMmcSDController->Open(stackNumber,iMmcSDController->VersionRequired()); |
|
232 if ( err!=KErrNone ) |
|
233 { |
|
234 ERR_PRINTF2(_L("Driver Open Call Failure %d"), err); |
|
235 SetError(err); |
|
236 } |
|
237 else |
|
238 { |
|
239 INFO_PRINTF2(_L("iMmcSDController = %x"), iMmcSDController); |
|
240 } |
|
241 } |
|
242 |
|
243 /** |
|
244 * Destroys the objects |
|
245 * |
|
246 * @return void |
|
247 */ |
|
248 void CT_MmcSDSessionData::DoCmdDestructor() |
|
249 { |
|
250 INFO_PRINTF1(_L("CT_MmcSDSessionData::DoCmdDestructor()")); |
|
251 DestroyData(); |
|
252 } |
|
253 |