author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 15 | 4122176ea935 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
0 | 3 |
* All rights reserved. |
4 |
* This component and the accompanying materials are made available |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
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 |
* |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
14 |
* Description: |
0 | 15 |
* |
16 |
*/ |
|
17 |
||
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
18 |
|
0 | 19 |
/** |
20 |
@test |
|
21 |
@internalComponent |
|
22 |
||
23 |
This contains CT_FsData |
|
24 |
*/ |
|
25 |
||
26 |
// User includes |
|
27 |
#include "T_FsData.h" |
|
28 |
#include "T_SfSrvServer.h" |
|
29 |
#include "DataWrapperBase.h" |
|
30 |
||
31 |
/*@{*/ |
|
32 |
||
33 |
_LIT(KMessageSlots, "messageSlots"); |
|
34 |
_LIT(KPath, "path"); |
|
35 |
_LIT(KAddress, "address"); |
|
36 |
_LIT(KType, "type"); |
|
37 |
_LIT(KAll, "all"); |
|
38 |
_LIT(KResources, "resources"); |
|
39 |
_LIT(KNotify, "notify"); |
|
40 |
_LIT(KInRom, "inRom"); |
|
41 |
_LIT(KThreshold, "threshold"); |
|
42 |
_LIT(KDrive, "drive"); |
|
43 |
_LIT(KFunctionId, "functionId"); |
|
44 |
_LIT(KAdd, "add"); |
|
45 |
_LIT(KSub, "sub"); |
|
46 |
_LIT(KUseFreeSpace, "use_free_space"); |
|
47 |
_LIT(KVersionName, "name"); |
|
48 |
_LIT(KVersionBuild, "build"); |
|
49 |
_LIT(KVersionMajor, "major"); |
|
50 |
_LIT(KVersionMinor, "minor"); |
|
51 |
_LIT(KIndex, "index"); |
|
52 |
_LIT(KParam1, "param1"); |
|
53 |
_LIT(KParam2, "param2"); |
|
54 |
_LIT(KFile, "file"); |
|
55 |
_LIT(KCount, "count"); |
|
56 |
||
57 |
/// Commands |
|
58 |
_LIT(KCmdNew, "new"); |
|
59 |
_LIT(KCmdClose, "Close"); |
|
60 |
_LIT(KCmdDestructor, "~"); |
|
61 |
_LIT(KCmdConnect, "Connect"); |
|
62 |
_LIT(KCmdVersion, "Version"); |
|
63 |
_LIT(KCmdNotifyChange, "NotifyChange"); |
|
64 |
_LIT(KCmdNotifyChangeCancel, "NotifyChangeCancel"); |
|
65 |
_LIT(KCmdNotifyDiskSpace, "NotifyDiskSpace"); |
|
66 |
_LIT(KCmdNotifyDiskSpaceCancel, "NotifyDiskSpaceCancel"); |
|
67 |
_LIT(KCmdIsRomAddress, "IsRomAddress"); |
|
68 |
_LIT(KCmdResourceCountMarkStart, "ResourceCountMarkStart"); |
|
69 |
_LIT(KCmdResourceCountMarkEnd, "ResourceCountMarkEnd"); |
|
70 |
_LIT(KCmdResourceCount, "ResourceCount"); |
|
71 |
_LIT(KCmdGetNotifyUser, "GetNotifyUser"); |
|
72 |
_LIT(KCmdSetNotifyUser, "SetNotifyUser"); |
|
73 |
_LIT(KCmdSetNotifyChange, "SetNotifyChange"); |
|
74 |
_LIT(KCmdLoaderHeapFunction, "LoaderHeapFunction"); |
|
75 |
_LIT(KCmdInitialisePropertiesFile, "InitialisePropertiesFile"); |
|
76 |
/*@}*/ |
|
77 |
||
78 |
CT_FsData* CT_FsData::NewL() |
|
79 |
/** |
|
80 |
* Two phase constructor |
|
81 |
*/ |
|
82 |
{ |
|
83 |
CT_FsData* ret = new (ELeave) CT_FsData(); |
|
84 |
CleanupStack::PushL(ret); |
|
85 |
ret->ConstructL(); |
|
86 |
CleanupStack::Pop(ret); |
|
87 |
return ret; |
|
88 |
} |
|
89 |
||
90 |
CT_FsData::CT_FsData() |
|
91 |
/** |
|
92 |
* Protected constructor. First phase construction |
|
93 |
*/ |
|
94 |
{ |
|
95 |
} |
|
96 |
||
97 |
void CT_FsData::ConstructL() |
|
98 |
/** |
|
99 |
* Protected constructor. Second phase construction |
|
100 |
*/ |
|
101 |
{ |
|
102 |
||
103 |
} |
|
104 |
||
105 |
CT_FsData::~CT_FsData() |
|
106 |
/** |
|
107 |
* Destructor. |
|
108 |
*/ |
|
109 |
{ |
|
110 |
DoCleanup(); |
|
111 |
||
112 |
iNotifyChange.ResetAndDestroy(); |
|
113 |
iNotifyDiskSpace.ResetAndDestroy(); |
|
114 |
iNotifyDismount.ResetAndDestroy(); |
|
115 |
iStartupInitComplete.ResetAndDestroy(); |
|
116 |
} |
|
117 |
||
118 |
void CT_FsData::DoCleanup() |
|
119 |
/** |
|
120 |
* Contains cleanup implementation |
|
121 |
*/ |
|
122 |
{ |
|
123 |
//Deleting RFs. |
|
124 |
if(iFs != NULL) |
|
125 |
{ |
|
126 |
INFO_PRINTF1(_L("Deleting current RFs")); |
|
127 |
delete iFs; |
|
128 |
iFs = NULL; |
|
129 |
} |
|
130 |
} |
|
131 |
||
132 |
TAny* CT_FsData::GetObject() |
|
133 |
/** |
|
134 |
* Return a pointer to the object that the data wraps |
|
135 |
* |
|
136 |
* @return pointer to the object that the data wraps |
|
137 |
*/ |
|
138 |
{ |
|
139 |
return iFs; |
|
140 |
} |
|
141 |
||
142 |
TUint64 CT_FsData::ThreadId() |
|
143 |
{ |
|
144 |
RThread currentThread; |
|
145 |
return currentThread.Id().Id(); |
|
146 |
} |
|
147 |
||
148 |
TBool CT_FsData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
149 |
/** |
|
150 |
* Process a command read from the ini file |
|
151 |
* |
|
152 |
* @param aCommand the command to process |
|
153 |
* @param aSection the entry in the ini file requiring the command to be processed |
|
154 |
* |
|
155 |
* @return ETrue if the command is processed |
|
156 |
*/ |
|
157 |
{ |
|
158 |
TBool retVal = ETrue; |
|
159 |
if (aCommand == KCmdNew) |
|
160 |
{ |
|
161 |
DoCmdNewL(); |
|
162 |
} |
|
163 |
else if (aCommand == KCmdClose) |
|
164 |
{ |
|
165 |
DoCmdClose(); |
|
166 |
} |
|
167 |
else if (aCommand == KCmdDestructor) |
|
168 |
{ |
|
169 |
DoCmdDestructor(); |
|
170 |
} |
|
171 |
else if (aCommand == KCmdConnect) |
|
172 |
{ |
|
173 |
DoCmdConnect(aSection); |
|
174 |
} |
|
175 |
else if (aCommand == KCmdVersion) |
|
176 |
{ |
|
177 |
DoCmdVersion(aSection); |
|
178 |
} |
|
179 |
else if (aCommand == KCmdNotifyChange) |
|
180 |
{ |
|
181 |
DoCmdNotifyChangeL(aSection, aAsyncErrorIndex); |
|
182 |
} |
|
183 |
else if (aCommand == KCmdNotifyChangeCancel) |
|
184 |
{ |
|
185 |
DoCmdNotifyChangeCancel(aSection); |
|
186 |
} |
|
187 |
else if (aCommand == KCmdNotifyDiskSpace) |
|
188 |
{ |
|
189 |
DoCmdNotifyDiskSpaceL(aSection, aAsyncErrorIndex); |
|
190 |
} |
|
191 |
else if (aCommand == KCmdNotifyDiskSpaceCancel) |
|
192 |
{ |
|
193 |
DoCmdNotifyDiskSpaceCancel(aSection); |
|
194 |
} |
|
195 |
else if (aCommand == KCmdIsRomAddress) |
|
196 |
{ |
|
197 |
DoCmdIsRomAddress(aSection); |
|
198 |
} |
|
199 |
else if (aCommand == KCmdResourceCountMarkStart) |
|
200 |
{ |
|
201 |
DoCmdResourceCountMarkStart(); |
|
202 |
} |
|
203 |
else if (aCommand == KCmdResourceCountMarkEnd) |
|
204 |
{ |
|
205 |
DoCmdResourceCountMarkEnd(); |
|
206 |
} |
|
207 |
else if (aCommand == KCmdResourceCount) |
|
208 |
{ |
|
209 |
DoCmdResourceCount(aSection); |
|
210 |
} |
|
211 |
else if (aCommand == KCmdGetNotifyUser) |
|
212 |
{ |
|
213 |
DoCmdGetNotifyUser(aSection); |
|
214 |
} |
|
215 |
else if (aCommand == KCmdSetNotifyUser) |
|
216 |
{ |
|
217 |
DoCmdSetNotifyUser(aSection); |
|
218 |
} |
|
219 |
else if (aCommand == KCmdLoaderHeapFunction) |
|
220 |
{ |
|
221 |
DoCmdLoaderHeapFunctionL(aSection); |
|
222 |
} |
|
223 |
else if (aCommand == KCmdSetNotifyChange) |
|
224 |
{ |
|
225 |
DoCmdSetNotifyChange(aSection); |
|
226 |
} |
|
227 |
else if (aCommand == KCmdInitialisePropertiesFile) |
|
228 |
{ |
|
229 |
DoCmdInitialisePropertiesFile(aSection); |
|
230 |
} |
|
231 |
else |
|
232 |
{ |
|
233 |
if (!DoCommandDrivesL(aCommand, aSection, aAsyncErrorIndex)) |
|
234 |
{ |
|
235 |
if (!DoCommandMountsL(aCommand, aSection, aAsyncErrorIndex)) |
|
236 |
{ |
|
237 |
if (!DoCommandFilesL(aCommand, aSection, aAsyncErrorIndex)) |
|
238 |
{ |
|
239 |
retVal = EFalse; |
|
240 |
} |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
return retVal; |
|
245 |
} |
|
246 |
||
247 |
||
248 |
void CT_FsData::DoCmdNewL() |
|
249 |
/** Creates new RFs class instance */ |
|
250 |
{ |
|
251 |
INFO_PRINTF1(_L("Create new RFs class instance")); |
|
252 |
||
253 |
//Deletes previous RFs class instance if it was already created. |
|
254 |
DoCleanup(); |
|
255 |
||
256 |
// do create |
|
257 |
TRAPD(err, iFs = new (ELeave) RFs()); |
|
258 |
if ( err!=KErrNone ) |
|
259 |
{ |
|
260 |
ERR_PRINTF2(_L("new error %d"), err); |
|
261 |
SetError( err ); |
|
262 |
} |
|
263 |
} |
|
264 |
||
265 |
void CT_FsData::DoCmdClose() |
|
266 |
/** Close RFs handle */ |
|
267 |
{ |
|
268 |
INFO_PRINTF1(_L("Closing RFs")); |
|
269 |
iFs->Close(); |
|
270 |
} |
|
271 |
||
272 |
||
273 |
void CT_FsData::DoCmdDestructor() |
|
274 |
/** Destroy RFs the object */ |
|
275 |
{ |
|
276 |
INFO_PRINTF1(_L("Destroying the RFs object")); |
|
277 |
DoCleanup(); |
|
278 |
} |
|
279 |
||
280 |
void CT_FsData::DoCmdConnect(const TDesC& aSection) |
|
281 |
/** Connects a client to the file server */ |
|
282 |
{ |
|
283 |
||
284 |
TInt messageSlots = KFileServerDefaultMessageSlots; |
|
285 |
GetIntFromConfig(aSection, KMessageSlots, messageSlots); |
|
286 |
||
287 |
TInt err = iFs->Connect(messageSlots); |
|
288 |
INFO_PRINTF2(_L("Call Connect(messageSlots = %d)"), messageSlots); |
|
289 |
||
290 |
if ( err!=KErrNone ) |
|
291 |
{ |
|
292 |
ERR_PRINTF2(_L("Connect() error %d"), err); |
|
293 |
SetError( err ); |
|
294 |
} |
|
295 |
} |
|
296 |
||
297 |
void CT_FsData::DoCmdVersion(const TDesC& aSection) |
|
298 |
/** Gets the client side version number */ |
|
299 |
{ |
|
300 |
||
301 |
TVersion version=iFs->Version(); |
|
302 |
TVersionName versionName = version.Name(); |
|
303 |
INFO_PRINTF2(_L("Version name : %S"), &versionName); |
|
304 |
INFO_PRINTF2(_L("Version build : %d"), (TInt)version.iBuild); |
|
305 |
INFO_PRINTF2(_L("Version major : %d"), (TInt)version.iMajor); |
|
306 |
INFO_PRINTF2(_L("Version minor : %d"), (TInt)version.iMinor); |
|
307 |
||
308 |
TPtrC name; |
|
309 |
if ( GET_OPTIONAL_STRING_PARAMETER(KVersionName, aSection, name)) |
|
310 |
{ |
|
311 |
if ( name != version.Name() ) |
|
312 |
{ |
|
313 |
ERR_PRINTF3(_L("Name does not match expected name: %S, %S"), &name, &versionName); |
|
314 |
SetBlockResult(EFail); |
|
315 |
} |
|
316 |
} |
|
317 |
||
318 |
TInt intTemp; |
|
319 |
if ( GET_OPTIONAL_INT_PARAMETER(KVersionBuild, aSection, intTemp) ) |
|
320 |
{ |
|
321 |
if ( intTemp != version.iBuild ) |
|
322 |
{ |
|
323 |
ERR_PRINTF1(_L("Build does not match expected build")); |
|
324 |
SetBlockResult(EFail); |
|
325 |
} |
|
326 |
} |
|
327 |
||
328 |
if ( GET_OPTIONAL_INT_PARAMETER(KVersionMajor, aSection, intTemp) ) |
|
329 |
{ |
|
330 |
if ( intTemp != version.iMajor ) |
|
331 |
{ |
|
332 |
ERR_PRINTF1(_L("Major does not match expected major")); |
|
333 |
SetBlockResult(EFail); |
|
334 |
} |
|
335 |
} |
|
336 |
||
337 |
if ( GET_OPTIONAL_INT_PARAMETER(KVersionMinor, aSection, intTemp) ) |
|
338 |
{ |
|
339 |
if ( intTemp != version.iMinor ) |
|
340 |
{ |
|
341 |
ERR_PRINTF1(_L("Minor does not match expected minor")); |
|
342 |
SetBlockResult(EFail); |
|
343 |
} |
|
344 |
} |
|
345 |
||
346 |
if (version.Name() == _L("") && version.iBuild == 0 && version.iMajor == 0 && version.iMinor == 0) |
|
347 |
{ |
|
348 |
ERR_PRINTF1(_L("Some version fields are not set!")); |
|
349 |
SetBlockResult(EFail); |
|
350 |
} |
|
351 |
} |
|
352 |
||
353 |
void CT_FsData::DoCmdNotifyChangeL(const TDesC& aSection, const TInt aAsyncErrorIndex) |
|
354 |
/** Requests a notification of change to files or directories */ |
|
355 |
{ |
|
356 |
TNotifyType type = ENotifyAll; |
|
357 |
TPtrC typeTemp; |
|
358 |
TBool dataOk = ETrue; |
|
359 |
||
360 |
if ( GET_MANDATORY_STRING_PARAMETER(KType, aSection, typeTemp) ) |
|
361 |
{ |
|
362 |
if(!ConvertToNotifyType(typeTemp, type)) |
|
363 |
{ |
|
364 |
TInt typeNumber; |
|
365 |
if(GetIntFromConfig(aSection, KType(), typeNumber)) |
|
366 |
{ |
|
367 |
type = (TNotifyType)typeNumber; |
|
368 |
} |
|
369 |
else |
|
370 |
{ |
|
371 |
ERR_PRINTF3(_L("NotifyChange() incorrect parameter %S in %S"), &typeTemp, &KType()); |
|
372 |
SetBlockResult(EFail); |
|
373 |
dataOk = EFalse; |
|
374 |
} |
|
375 |
} |
|
376 |
} |
|
377 |
else |
|
378 |
{ |
|
379 |
dataOk = EFalse; |
|
380 |
} |
|
381 |
||
382 |
TInt count=1; |
|
383 |
GET_OPTIONAL_INT_PARAMETER(KCount, aSection, count); |
|
384 |
||
385 |
if(dataOk) |
|
386 |
{ |
|
387 |
CT_ActiveNotifyChange* active = CT_ActiveNotifyChange::NewLC(count, aAsyncErrorIndex, *this); |
|
388 |
iNotifyChange.AppendL(active); |
|
389 |
CleanupStack::Pop(active); |
|
390 |
||
391 |
TPtrC path; |
|
392 |
if ( GetStringFromConfig(aSection, KPath(), path) ) |
|
393 |
{ |
|
394 |
iFs->NotifyChange(type, active->iStatus, path); |
|
395 |
INFO_PRINTF1(_L("NotifyChange(TNotifyType, TRequestStatus, const TDesC)")); |
|
396 |
} |
|
397 |
else |
|
398 |
{ |
|
399 |
iFs->NotifyChange(type, active->iStatus); |
|
400 |
INFO_PRINTF1(_L("NotifyChange(TNotifyType TRequestStatus)")); |
|
401 |
} |
|
402 |
||
403 |
active->Activate(); |
|
404 |
IncOutstanding(); |
|
405 |
} |
|
406 |
} |
|
407 |
||
408 |
||
409 |
void CT_FsData::DoCmdNotifyChangeCancel(const TDesC& aSection) |
|
410 |
/** Cancels outstanding request(s) for notification of change to files or directories */ |
|
411 |
{ |
|
412 |
TBool all = ETrue; |
|
413 |
||
414 |
if ( GET_MANDATORY_BOOL_PARAMETER(KAll, aSection, all) ) |
|
415 |
{ |
|
416 |
if(all) |
|
417 |
{ |
|
418 |
// Cancels all outstanding requests. |
|
419 |
iFs->NotifyChangeCancel(); |
|
420 |
INFO_PRINTF1(_L("NotifyChangeCancel()")); |
|
421 |
} |
|
422 |
else |
|
423 |
{ |
|
424 |
// Cancels a specific outstanding request |
|
425 |
TInt index=0; |
|
426 |
GetIntFromConfig(aSection, KIndex(), index); |
|
427 |
||
428 |
iFs->NotifyChangeCancel(iNotifyChange[index]->iStatus); |
|
429 |
INFO_PRINTF1(_L("NotifyChangeCancel(TRequestStatus)")); |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
||
434 |
void CT_FsData::DoCmdNotifyDiskSpaceL(const TDesC& aSection, const TInt aAsyncErrorIndex) |
|
435 |
/** Requests notification when the free disk space on the specified drive crosses the specified threshold value */ |
|
436 |
{ |
|
437 |
//Get drive number from config |
|
438 |
TDriveNumber drive = EDriveA; |
|
439 |
TBool dataOk = ETrue; |
|
440 |
if (!GetDriveNumberFromConfig(aSection, KDrive, drive)) |
|
441 |
{ |
|
442 |
ERR_PRINTF2(_L("No %S"), &KDrive()); |
|
443 |
SetBlockResult(EFail); |
|
444 |
dataOk = EFalse; |
|
445 |
} |
|
446 |
||
447 |
TBool useFreeSpace = EFalse; |
|
448 |
GET_OPTIONAL_BOOL_PARAMETER(KUseFreeSpace, aSection, useFreeSpace); |
|
449 |
||
450 |
TInt64 threshold = 0; |
|
451 |
//Defining treshold by free space |
|
452 |
if(useFreeSpace) |
|
453 |
{ |
|
454 |
threshold = iVolumeInfo.iFree; |
|
455 |
//For Calculation free-temp(_sub), free+temp(_add) |
|
456 |
TInt temp; |
|
457 |
if(GetIntFromConfig(aSection, KAdd, temp)) |
|
458 |
{ |
|
459 |
threshold += temp; |
|
460 |
temp = 0; |
|
461 |
} |
|
462 |
if(GetIntFromConfig(aSection, KSub, temp)) |
|
463 |
{ |
|
464 |
threshold -= temp; |
|
465 |
temp = 0; |
|
466 |
} |
|
467 |
} |
|
468 |
//Defining treshold by some value |
|
469 |
else |
|
470 |
{ |
|
471 |
TPtrC thold; |
|
472 |
if(GET_MANDATORY_STRING_PARAMETER(KThreshold, aSection, thold)) |
|
473 |
{ |
|
474 |
TLex lex(thold); |
|
475 |
TInt err = lex.Val(threshold); |
|
476 |
if(err) |
|
477 |
{ |
|
478 |
ERR_PRINTF1(_L("NotifyDiskSpace() bad treshold value")); |
|
479 |
SetBlockResult(EFail); |
|
480 |
dataOk = EFalse; |
|
481 |
} |
|
482 |
} |
|
483 |
} |
|
484 |
||
485 |
if(dataOk) |
|
486 |
{ |
|
487 |
CActiveCallback* active = CActiveCallback::NewLC(*this); |
|
488 |
iNotifyDiskSpace.AppendL(active); |
|
489 |
CleanupStack::Pop(active); |
|
490 |
||
491 |
iFs->NotifyDiskSpace(threshold, drive, active->iStatus); |
|
492 |
INFO_PRINTF1(_L("NotifyDiskSpace()")); |
|
493 |
active->Activate(aAsyncErrorIndex); |
|
494 |
IncOutstanding(); |
|
495 |
} |
|
496 |
} |
|
497 |
||
498 |
||
499 |
void CT_FsData::DoCmdNotifyDiskSpaceCancel(const TDesC& aSection) |
|
500 |
/** Cancels a specific outstanding request for free disk space notification */ |
|
501 |
{ |
|
502 |
||
503 |
TBool all = ETrue; |
|
504 |
||
505 |
if(GET_MANDATORY_BOOL_PARAMETER(KAll, aSection, all)) |
|
506 |
{ |
|
507 |
if (all) |
|
508 |
{ |
|
509 |
//Cancels all outstanding requests. |
|
510 |
iFs->NotifyDiskSpaceCancel(); |
|
511 |
INFO_PRINTF1(_L("NotifyDiskSpaceCancel()")); |
|
512 |
} |
|
513 |
else |
|
514 |
{ |
|
515 |
// Cancels a specific outstanding request |
|
516 |
TInt index=0; |
|
517 |
GetIntFromConfig(aSection, KIndex, index); |
|
518 |
||
519 |
iFs->NotifyDiskSpaceCancel(iNotifyDiskSpace[index]->iStatus); |
|
520 |
} |
|
521 |
} |
|
522 |
} |
|
523 |
||
524 |
void CT_FsData::DoCmdIsRomAddress(const TDesC& aSection) |
|
525 |
/** Tests whether the specified address is in ROM */ |
|
526 |
{ |
|
527 |
//reading address |
|
528 |
TUint8* address = NULL; |
|
529 |
TInt intAddress; |
|
530 |
TBool dataOk = ETrue; |
|
531 |
||
532 |
if(GetHexFromConfig(aSection, KAddress, intAddress)) |
|
533 |
{ |
|
534 |
address = (TUint8*)intAddress; |
|
535 |
} |
|
536 |
else if(iIsFileInRom) |
|
537 |
{ |
|
538 |
address = iIsFileInRom; |
|
539 |
} |
|
540 |
else |
|
541 |
{ |
|
542 |
ERR_PRINTF1(_L("Address not specified")); |
|
543 |
SetBlockResult(EFail); |
|
544 |
dataOk = EFalse; |
|
545 |
} |
|
546 |
if(dataOk) |
|
547 |
{ |
|
548 |
INFO_PRINTF2(_L("Address %X"), address); |
|
549 |
//Address of file in ROM |
|
550 |
TBool actual = RFs::IsRomAddress(address); |
|
551 |
INFO_PRINTF2(_L("RFs::IsRomAddress() %d"), actual); |
|
552 |
//Reading expected result |
|
553 |
TBool expected = EFalse; |
|
554 |
if ( GET_OPTIONAL_BOOL_PARAMETER(KInRom, aSection, expected) ) |
|
555 |
{ |
|
556 |
if ( expected != actual ) |
|
557 |
{ |
|
558 |
ERR_PRINTF1(_L("Expected result does not match actual")); |
|
559 |
SetBlockResult(EFail); |
|
560 |
} |
|
561 |
} |
|
562 |
} |
|
563 |
} |
|
564 |
||
565 |
void CT_FsData::DoCmdResourceCountMarkStart() |
|
566 |
/** Marks the start of resource count checking */ |
|
567 |
{ |
|
568 |
iFs->ResourceCountMarkStart(); |
|
569 |
INFO_PRINTF1(_L("ResourceCountMarkStart()")); |
|
570 |
} |
|
571 |
||
572 |
void CT_FsData::DoCmdResourceCountMarkEnd() |
|
573 |
/** Ends resource count checking */ |
|
574 |
{ |
|
575 |
iFs->ResourceCountMarkEnd(); |
|
576 |
INFO_PRINTF1(_L("ResourceCountMarkEnd()")); |
|
577 |
} |
|
578 |
||
579 |
void CT_FsData::DoCmdResourceCount(const TDesC& aSection) |
|
580 |
/** Gets the number of currently open resources */ |
|
581 |
{ |
|
582 |
TInt resources = iFs->ResourceCount();//Number of resources currently opened |
|
583 |
INFO_PRINTF2(_L("ResourceCount() = %d"), resources); |
|
584 |
||
585 |
TInt expectedValue = 0; //Number of resources from config |
|
586 |
if(GetIntFromConfig(aSection, KResources, expectedValue)) |
|
587 |
{ |
|
588 |
if (expectedValue != resources) |
|
589 |
{ |
|
590 |
ERR_PRINTF3(_L("ResourceCount() %d != %d expected value"), resources, expectedValue); |
|
591 |
SetBlockResult(EFail); |
|
592 |
} |
|
593 |
} |
|
594 |
} |
|
595 |
||
596 |
void CT_FsData::DoCmdGetNotifyUser(const TDesC& aSection) |
|
597 |
/** Tests whether user notification of file read or write failure is in effect */ |
|
598 |
{ |
|
599 |
TBool actual = iFs->GetNotifyUser(); |
|
600 |
INFO_PRINTF2(_L("iFs->GetNotifyUser() %d"), actual); |
|
601 |
||
602 |
TBool expected = EFalse; |
|
603 |
if ( GET_OPTIONAL_BOOL_PARAMETER(KNotify, aSection, expected) ) |
|
604 |
{ |
|
605 |
if ( expected!=actual ) |
|
606 |
{ |
|
607 |
ERR_PRINTF1(_L("Expected result does not match actual")); |
|
608 |
SetBlockResult(EFail); |
|
609 |
} |
|
610 |
} |
|
611 |
} |
|
612 |
||
613 |
void CT_FsData::DoCmdSetNotifyUser(const TDesC& aSection) |
|
614 |
/** Sets whether the user should be notified of file read or write failure */ |
|
615 |
{ |
|
616 |
TBool notify = EFalse; |
|
617 |
||
618 |
if(GET_MANDATORY_BOOL_PARAMETER(KNotify, aSection, notify)) |
|
619 |
{ |
|
620 |
iFs->SetNotifyUser(notify); |
|
621 |
TPtrC val = notify ? _L("TRUE") : _L("FALSE"); |
|
622 |
INFO_PRINTF2(_L("SetNotifyUser() %S"), &val); |
|
623 |
} |
|
624 |
||
625 |
||
626 |
} |
|
627 |
||
628 |
void CT_FsData::DoCmdLoaderHeapFunctionL(const TDesC& aSection) |
|
629 |
/** returns KErrNotSupported*/ |
|
630 |
{ |
|
631 |
TPtrC name; |
|
632 |
TAny* param1 = NULL; |
|
633 |
if(GetStringFromConfig(aSection, KParam1(), name)) |
|
634 |
{ |
|
635 |
//param1 = iDataDictionary->GetObject(name); |
|
636 |
} |
|
637 |
||
638 |
TAny* param2 = NULL; |
|
639 |
if(GetStringFromConfig(aSection, KParam2(), name)) |
|
640 |
{ |
|
641 |
//param2 = iDataDictionary->GetObjectL(name); |
|
642 |
} |
|
643 |
||
644 |
TInt functionId = 0; |
|
645 |
if(GET_MANDATORY_INT_PARAMETER(KFunctionId(), aSection, functionId)) |
|
646 |
{ |
|
647 |
TInt err = iFs->LoaderHeapFunction(functionId, param1, param2); |
|
648 |
if( err!=KErrNone ) |
|
649 |
{ |
|
650 |
ERR_PRINTF2(_L("LoaderHeapFunction() ERROR: %d"), err); |
|
651 |
SetError(err); |
|
652 |
} |
|
653 |
} |
|
654 |
} |
|
655 |
||
656 |
void CT_FsData::DoCmdSetNotifyChange(const TDesC& aSection) |
|
657 |
/** Enables/Disables change notification on a per-session basis. */ |
|
658 |
{ |
|
659 |
||
660 |
TBool notify = EFalse; |
|
661 |
||
662 |
if(GET_MANDATORY_BOOL_PARAMETER(KNotify, aSection, notify)) |
|
663 |
{ |
|
664 |
TInt err = iFs->SetNotifyChange(notify); |
|
665 |
||
666 |
TPtrC val = notify ? _L("TRUE") : _L("FALSE"); |
|
667 |
if (err == KErrNone) |
|
668 |
{ |
|
669 |
INFO_PRINTF2(_L("SetNotifyChange() %S"), &val); |
|
670 |
} |
|
671 |
else |
|
672 |
{ |
|
673 |
ERR_PRINTF3(_L("SetNotifyChange() %S, Error: %d"), &val, err); |
|
674 |
SetError(err); |
|
675 |
} |
|
676 |
} |
|
677 |
} |
|
678 |
||
679 |
void CT_FsData::DoCmdInitialisePropertiesFile(const TDesC& aSection) |
|
680 |
/** Sets the F32 properties file ONLY in ESTART */ |
|
681 |
{ |
|
682 |
TPtrC tempStr; |
|
683 |
if(GET_MANDATORY_STRING_PARAMETER(KFile, aSection, tempStr)) |
|
684 |
{ |
|
685 |
TBuf8<KBufferStringLength> buffer; |
|
686 |
buffer.Copy(tempStr); |
|
687 |
TPtrC8 iniFilePtr(buffer); |
|
688 |
INFO_PRINTF2(_L("InitialisePropertiesFile() %S"), &tempStr); |
|
689 |
||
690 |
TInt err = iFs ->InitialisePropertiesFile(iniFilePtr); |
|
691 |
if (err != KErrNone) |
|
692 |
{ |
|
693 |
ERR_PRINTF2(_L("InitialisePropertiesFile() Error: %d"), err); |
|
694 |
SetError(err); |
|
695 |
} |
|
696 |
} |
|
697 |
} |
|
698 |
||
699 |
void CT_FsData::RunL(CActive* aActive, TInt aIndex) |
|
700 |
{ |
|
701 |
INFO_PRINTF1(_L("CT_FsData::RunL Called")); |
|
702 |
TBool foundActiveObject = EFalse; |
|
703 |
TInt index=0; |
|
704 |
TInt count=0; |
|
705 |
TBool completed=ETrue; |
|
706 |
||
707 |
// See if it is in iNotifyChange |
|
708 |
count=iNotifyChange.Count(); |
|
709 |
for( index=0; (index<count) && (!foundActiveObject); ++index ) |
|
710 |
{ |
|
711 |
if( aActive == iNotifyChange[index] ) |
|
712 |
{ |
|
713 |
INFO_PRINTF1(_L("RunL iNotifyChange called")); |
|
714 |
foundActiveObject = ETrue; |
|
715 |
if ( iNotifyChange[index]->DecCount()>0 ) |
|
716 |
{ |
|
717 |
completed=EFalse; |
|
718 |
iNotifyChange[index]->Activate(); |
|
719 |
} |
|
720 |
else |
|
721 |
{ |
|
722 |
iNotifyChange.Remove(index); |
|
723 |
} |
|
724 |
} |
|
725 |
} |
|
726 |
||
727 |
// See if it is in iNotifyDiskSpace |
|
728 |
count=iNotifyDiskSpace.Count(); |
|
729 |
for( index=0; (index<count) && (!foundActiveObject); ++index ) |
|
730 |
{ |
|
731 |
if( aActive == iNotifyDiskSpace[index] ) |
|
732 |
{ |
|
733 |
INFO_PRINTF1(_L("RunL iNotifyDiskSpace called")); |
|
734 |
foundActiveObject = ETrue; |
|
735 |
iNotifyDiskSpace.Remove(index); |
|
736 |
} |
|
737 |
} |
|
738 |
||
739 |
// See if it is in iNotifyDismount |
|
740 |
count=iNotifyDismount.Count(); |
|
741 |
for( index=0; (index<count) && (!foundActiveObject); ++index ) |
|
742 |
{ |
|
743 |
if( aActive == iNotifyDismount[index] ) |
|
744 |
{ |
|
745 |
INFO_PRINTF1(_L("RunL iNotifyDismount called")); |
|
746 |
foundActiveObject = ETrue; |
|
747 |
iNotifyDismount.Remove(index); |
|
748 |
} |
|
749 |
} |
|
750 |
||
751 |
// See if it is in iStartupInitComplete |
|
752 |
count=iStartupInitComplete.Count(); |
|
753 |
for( index=0; (index<count) && (!foundActiveObject); ++index ) |
|
754 |
{ |
|
755 |
if( aActive == iStartupInitComplete[index] ) |
|
756 |
{ |
|
757 |
INFO_PRINTF1(_L("RunL iStartupInitComplete called")); |
|
758 |
foundActiveObject = ETrue; |
|
759 |
iStartupInitComplete.Remove(index); |
|
760 |
} |
|
761 |
} |
|
762 |
||
763 |
if( foundActiveObject ) |
|
764 |
{ |
|
765 |
TInt err = aActive->iStatus.Int(); |
|
766 |
if( err != KErrNone ) |
|
767 |
{ |
|
768 |
ERR_PRINTF2(_L("RunL Error %d"), err); |
|
769 |
SetAsyncError( aIndex, err ); |
|
770 |
} |
|
771 |
||
772 |
if ( completed ) |
|
773 |
{ |
|
774 |
// Reset the outstanding request state |
|
775 |
delete aActive; |
|
776 |
DecOutstanding(); |
|
777 |
} |
|
778 |
} |
|
779 |
else |
|
780 |
{ |
|
781 |
ERR_PRINTF1(_L("Stray RunL signal")); |
|
782 |
SetBlockResult(EFail); |
|
783 |
} |
|
784 |
} |
|
785 |
||
786 |
void CT_FsData::DoCancel(CActive* aActive, TInt aIndex) |
|
787 |
{ |
|
788 |
TBool foundActiveObject = EFalse; |
|
789 |
||
790 |
TInt index=0; |
|
791 |
TInt count=0; |
|
792 |
||
793 |
// See if it is in iNotifyChange |
|
794 |
count=iNotifyChange.Count(); |
|
795 |
for( index=0; (index<count) && (!foundActiveObject); ++index ) |
|
796 |
{ |
|
797 |
if( aActive == iNotifyChange[index] ) |
|
798 |
{ |
|
799 |
INFO_PRINTF1(_L("DoCancel iNotifyChange called")); |
|
800 |
foundActiveObject = ETrue; |
|
801 |
iNotifyChange.Remove(index); |
|
802 |
} |
|
803 |
} |
|
804 |
||
805 |
// See if it is in iNotifyDiskSpace |
|
806 |
count=iNotifyDiskSpace.Count(); |
|
807 |
for( index=0; (index<count) && (!foundActiveObject); ++index ) |
|
808 |
{ |
|
809 |
if( aActive == iNotifyDiskSpace[index] ) |
|
810 |
{ |
|
811 |
INFO_PRINTF1(_L("DoCancel iNotifyDiskSpace called")); |
|
812 |
foundActiveObject = ETrue; |
|
813 |
iNotifyDiskSpace.Remove(index); |
|
814 |
} |
|
815 |
} |
|
816 |
||
817 |
// See if it is in iNotifyDismount |
|
818 |
count=iNotifyDismount.Count(); |
|
819 |
for( index=0; (index<count) && (!foundActiveObject); ++index ) |
|
820 |
{ |
|
821 |
if( aActive == iNotifyDismount[index] ) |
|
822 |
{ |
|
823 |
INFO_PRINTF1(_L("DoCancel iNotifyDismount called")); |
|
824 |
foundActiveObject = ETrue; |
|
825 |
iNotifyDismount.Remove(index); |
|
826 |
} |
|
827 |
} |
|
828 |
||
829 |
// See if it is in iStartupInitComplete |
|
830 |
count=iStartupInitComplete.Count(); |
|
831 |
for( index=0; (index<count) && (!foundActiveObject); ++index ) |
|
832 |
{ |
|
833 |
if( aActive == iStartupInitComplete[index] ) |
|
834 |
{ |
|
835 |
INFO_PRINTF1(_L("DoCancel iStartupInitComplete called")); |
|
836 |
foundActiveObject = ETrue; |
|
837 |
iStartupInitComplete.Remove(index); |
|
838 |
} |
|
839 |
} |
|
840 |
||
841 |
if( foundActiveObject ) |
|
842 |
{ |
|
843 |
TInt err = aActive->iStatus.Int(); |
|
844 |
if( err != KErrNone ) |
|
845 |
{ |
|
846 |
ERR_PRINTF2(_L("DoCancel Error %d"), err); |
|
847 |
SetAsyncError( aIndex, err ); |
|
848 |
} |
|
849 |
||
850 |
// Reset the outstanding request state |
|
851 |
DecOutstanding(); |
|
852 |
||
853 |
delete aActive; |
|
854 |
} |
|
855 |
else |
|
856 |
{ |
|
857 |
ERR_PRINTF1(_L("Stray DoCancel signal")); |
|
858 |
SetBlockResult(EFail); |
|
859 |
} |
|
860 |
} |
|
861 |
TBool CT_FsData::ConvertToNotifyType(const TDesC& aNotifyTypeStr, TNotifyType& aNotifyType) |
|
862 |
{ |
|
863 |
TBool ret = ETrue; |
|
864 |
if(aNotifyTypeStr == _L("ENotifyAll")) |
|
865 |
{ |
|
866 |
aNotifyType = ENotifyAll; |
|
867 |
} |
|
868 |
else if(aNotifyTypeStr == _L("ENotifyEntry")) |
|
869 |
{ |
|
870 |
aNotifyType = ENotifyEntry; |
|
871 |
} |
|
872 |
else if(aNotifyTypeStr == _L("ENotifyFile")) |
|
873 |
{ |
|
874 |
aNotifyType = ENotifyFile; |
|
875 |
} |
|
876 |
else if(aNotifyTypeStr == _L("ENotifyDir")) |
|
877 |
{ |
|
878 |
aNotifyType = ENotifyDir; |
|
879 |
} |
|
880 |
else if(aNotifyTypeStr == _L("ENotifyAttributes")) |
|
881 |
{ |
|
882 |
aNotifyType = ENotifyAttributes; |
|
883 |
} |
|
884 |
else if(aNotifyTypeStr == _L("ENotifyWrite")) |
|
885 |
{ |
|
886 |
aNotifyType = ENotifyWrite; |
|
887 |
} |
|
888 |
else if(aNotifyTypeStr == _L("ENotifyDisk")) |
|
889 |
{ |
|
890 |
aNotifyType = ENotifyDisk; |
|
891 |
} |
|
892 |
//For COnverting data ENotifyFile|ENotifyDir |
|
893 |
else |
|
894 |
{ |
|
895 |
TInt location=aNotifyTypeStr.Match(_L("*|*")); |
|
896 |
if( location!=KErrNotFound ) |
|
897 |
{ |
|
898 |
//Converting Left part of the data |
|
899 |
TPtrC tempStr=aNotifyTypeStr.Left(location); |
|
900 |
ret=ConvertToNotifyType(tempStr, aNotifyType); |
|
901 |
||
902 |
//Converting right data can be with another "|" |
|
903 |
tempStr.Set(aNotifyTypeStr.Mid(location+1)); |
|
904 |
||
905 |
TNotifyType notifyTypeTmp; |
|
906 |
if ( ConvertToNotifyType(tempStr, notifyTypeTmp) ) |
|
907 |
{ |
|
908 |
aNotifyType =(TNotifyType)((TInt)aNotifyType|(TInt)notifyTypeTmp); |
|
909 |
} |
|
910 |
else |
|
911 |
{ |
|
912 |
ret = EFalse; |
|
913 |
} |
|
914 |
} |
|
915 |
else |
|
916 |
{ |
|
917 |
ret = EFalse; |
|
918 |
} |
|
919 |
} |
|
920 |
||
921 |
return ret; |
|
922 |
} |