sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@test
|
sl@0
|
21 |
@internalComponent
|
sl@0
|
22 |
v
|
sl@0
|
23 |
This contains CT_RDirData
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
// User includes
|
sl@0
|
27 |
#include "T_RDirData.h"
|
sl@0
|
28 |
#include "T_SfSrvServer.h"
|
sl@0
|
29 |
#include "FileserverUtil.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
|
sl@0
|
33 |
/*@{*/
|
sl@0
|
34 |
/// Parameters
|
sl@0
|
35 |
_LIT(KPath, "path");
|
sl@0
|
36 |
_LIT(KTUidType, "uidtype");
|
sl@0
|
37 |
_LIT(KRFsObjectName, "rfsObject");
|
sl@0
|
38 |
_LIT(KAsync, "async");
|
sl@0
|
39 |
_LIT(KArrayObjectName, "arrayObject");
|
sl@0
|
40 |
_LIT(KEntryObjectName, "entryObject");
|
sl@0
|
41 |
_LIT(KEntryAttMask, "attmask");
|
sl@0
|
42 |
_LIT(KParamExpectedFileName, "filename%d");
|
sl@0
|
43 |
_LIT(KReadArray, "readarray");
|
sl@0
|
44 |
_LIT(KCompareFiles, "compare");
|
sl@0
|
45 |
|
sl@0
|
46 |
|
sl@0
|
47 |
///Commands
|
sl@0
|
48 |
_LIT(KCmdNew, "new");
|
sl@0
|
49 |
_LIT(KCmdDestructor, "~");
|
sl@0
|
50 |
_LIT(KCmdOpen, "Open");
|
sl@0
|
51 |
_LIT(KCmdRead, "Read");
|
sl@0
|
52 |
_LIT(KCmdClose, "Close");
|
sl@0
|
53 |
|
sl@0
|
54 |
//Constants
|
sl@0
|
55 |
const TInt KBufferLength = 64;
|
sl@0
|
56 |
|
sl@0
|
57 |
CT_RDirData* CT_RDirData::NewL()
|
sl@0
|
58 |
/**
|
sl@0
|
59 |
* Two phase constructor
|
sl@0
|
60 |
*/
|
sl@0
|
61 |
{
|
sl@0
|
62 |
CT_RDirData* ret = new (ELeave) CT_RDirData();
|
sl@0
|
63 |
CleanupStack::PushL(ret);
|
sl@0
|
64 |
ret->ConstructL();
|
sl@0
|
65 |
CleanupStack::Pop(ret);
|
sl@0
|
66 |
return ret;
|
sl@0
|
67 |
}
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
|
sl@0
|
71 |
CT_RDirData::CT_RDirData()
|
sl@0
|
72 |
: iRDir(NULL)
|
sl@0
|
73 |
, iRead(NULL)
|
sl@0
|
74 |
, iReadBlock(NULL)
|
sl@0
|
75 |
, iEntry(NULL)
|
sl@0
|
76 |
, iExpectedNames(NULL)
|
sl@0
|
77 |
, iObjName(NULL)
|
sl@0
|
78 |
, iCompare(NULL)
|
sl@0
|
79 |
/**
|
sl@0
|
80 |
* Protected constructor. First phase construction
|
sl@0
|
81 |
*/
|
sl@0
|
82 |
{
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
|
sl@0
|
86 |
void CT_RDirData::ConstructL()
|
sl@0
|
87 |
/**
|
sl@0
|
88 |
* Protected constructor. Second phase construction
|
sl@0
|
89 |
*/
|
sl@0
|
90 |
{
|
sl@0
|
91 |
iRead = CActiveCallback::NewL( *this );
|
sl@0
|
92 |
iReadBlock = CActiveCallback::NewL( *this );
|
sl@0
|
93 |
iExpectedNames = new(ELeave) RPointerArray<TPath>();
|
sl@0
|
94 |
}
|
sl@0
|
95 |
|
sl@0
|
96 |
|
sl@0
|
97 |
CT_RDirData::~CT_RDirData()
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
* Destructor.
|
sl@0
|
100 |
*/
|
sl@0
|
101 |
{
|
sl@0
|
102 |
DoCleanup();
|
sl@0
|
103 |
}
|
sl@0
|
104 |
|
sl@0
|
105 |
|
sl@0
|
106 |
TAny* CT_RDirData::GetObject()
|
sl@0
|
107 |
{
|
sl@0
|
108 |
return iRDir;
|
sl@0
|
109 |
}
|
sl@0
|
110 |
|
sl@0
|
111 |
|
sl@0
|
112 |
TBool CT_RDirData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
sl@0
|
113 |
/**
|
sl@0
|
114 |
* Process a command read from the ini file
|
sl@0
|
115 |
*
|
sl@0
|
116 |
* @param aCommand the command to process
|
sl@0
|
117 |
* @param aSection the entry in the ini file requiring the command to be processed
|
sl@0
|
118 |
*
|
sl@0
|
119 |
* @return ETrue if the command is processed
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
{
|
sl@0
|
122 |
TBool ret = ETrue;
|
sl@0
|
123 |
|
sl@0
|
124 |
if (aCommand == KCmdNew)
|
sl@0
|
125 |
{
|
sl@0
|
126 |
DoCmdNew();
|
sl@0
|
127 |
}
|
sl@0
|
128 |
else if (aCommand == KCmdOpen)
|
sl@0
|
129 |
{
|
sl@0
|
130 |
DoCmdOpenL(aSection);
|
sl@0
|
131 |
}
|
sl@0
|
132 |
else if (aCommand == KCmdRead)
|
sl@0
|
133 |
{
|
sl@0
|
134 |
DoCmdReadL(aSection, aAsyncErrorIndex);
|
sl@0
|
135 |
}
|
sl@0
|
136 |
else if (aCommand == KCmdClose)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
DoCmdClose();
|
sl@0
|
139 |
}
|
sl@0
|
140 |
else if (aCommand == KCmdDestructor)
|
sl@0
|
141 |
{
|
sl@0
|
142 |
DoCmdDestructor();
|
sl@0
|
143 |
}
|
sl@0
|
144 |
else
|
sl@0
|
145 |
{
|
sl@0
|
146 |
ret = EFalse;
|
sl@0
|
147 |
}
|
sl@0
|
148 |
return ret;
|
sl@0
|
149 |
}
|
sl@0
|
150 |
|
sl@0
|
151 |
void CT_RDirData::DoCleanup()
|
sl@0
|
152 |
{
|
sl@0
|
153 |
INFO_PRINTF1(_L("Deleting current RDir"));
|
sl@0
|
154 |
delete iEntry;
|
sl@0
|
155 |
iEntry = NULL;
|
sl@0
|
156 |
delete iRDir;
|
sl@0
|
157 |
iRDir = NULL;
|
sl@0
|
158 |
|
sl@0
|
159 |
delete iRead;
|
sl@0
|
160 |
iRead = NULL;
|
sl@0
|
161 |
delete iReadBlock;
|
sl@0
|
162 |
iReadBlock = NULL;
|
sl@0
|
163 |
iExpectedNames->ResetAndDestroy();
|
sl@0
|
164 |
}
|
sl@0
|
165 |
|
sl@0
|
166 |
void CT_RDirData::DoCmdNew()
|
sl@0
|
167 |
{
|
sl@0
|
168 |
INFO_PRINTF1(_L("Create new RDirs class instance"));
|
sl@0
|
169 |
|
sl@0
|
170 |
delete iRDir;
|
sl@0
|
171 |
iRDir = NULL;
|
sl@0
|
172 |
|
sl@0
|
173 |
TRAPD(err, iRDir = new (ELeave) RDir());
|
sl@0
|
174 |
if ( err != KErrNone )
|
sl@0
|
175 |
{
|
sl@0
|
176 |
ERR_PRINTF2(_L("new error %d"), err);
|
sl@0
|
177 |
SetError( err );
|
sl@0
|
178 |
}
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
void CT_RDirData::DoCmdClose()
|
sl@0
|
182 |
/**
|
sl@0
|
183 |
* Close RDir handle
|
sl@0
|
184 |
*/
|
sl@0
|
185 |
{
|
sl@0
|
186 |
INFO_PRINTF1(_L("Closing RDir"));
|
sl@0
|
187 |
iRDir->Close();
|
sl@0
|
188 |
}
|
sl@0
|
189 |
|
sl@0
|
190 |
void CT_RDirData::DoCmdDestructor()
|
sl@0
|
191 |
/**
|
sl@0
|
192 |
* Destroy RDir the object
|
sl@0
|
193 |
*/
|
sl@0
|
194 |
{
|
sl@0
|
195 |
INFO_PRINTF1(_L("Destroying the RDir object"));
|
sl@0
|
196 |
DoCleanup();
|
sl@0
|
197 |
}
|
sl@0
|
198 |
|
sl@0
|
199 |
void CT_RDirData::DoCmdOpenL(const TDesC& aSection)
|
sl@0
|
200 |
{
|
sl@0
|
201 |
INFO_PRINTF1(_L("Opening directory!"));
|
sl@0
|
202 |
|
sl@0
|
203 |
TBool dataOk = ETrue;
|
sl@0
|
204 |
|
sl@0
|
205 |
TPtrC rfsObjectName;
|
sl@0
|
206 |
RFs* rfsObject = NULL;
|
sl@0
|
207 |
if(GET_MANDATORY_STRING_PARAMETER(KRFsObjectName(), aSection, rfsObjectName))
|
sl@0
|
208 |
{
|
sl@0
|
209 |
rfsObject = (RFs*)GetDataObjectL(rfsObjectName);
|
sl@0
|
210 |
}
|
sl@0
|
211 |
else
|
sl@0
|
212 |
{
|
sl@0
|
213 |
dataOk = EFalse;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
TPtrC path;
|
sl@0
|
217 |
if(!GET_MANDATORY_STRING_PARAMETER(KPath(), aSection, path))
|
sl@0
|
218 |
{
|
sl@0
|
219 |
dataOk = EFalse;
|
sl@0
|
220 |
}
|
sl@0
|
221 |
|
sl@0
|
222 |
TUidType uidType = KNullUid;
|
sl@0
|
223 |
TInt intUIDType;
|
sl@0
|
224 |
TBool isUidType = EFalse;
|
sl@0
|
225 |
|
sl@0
|
226 |
TUint attMask = KEntryAttNormal;
|
sl@0
|
227 |
INFO_PRINTF2(_L("section name - %S"),&aSection);
|
sl@0
|
228 |
|
sl@0
|
229 |
if(!FileserverUtil::GetAttMask(*this, aSection, KEntryAttMask(), attMask))
|
sl@0
|
230 |
{
|
sl@0
|
231 |
if (GET_MANDATORY_INT_PARAMETER(KTUidType(), aSection, intUIDType))
|
sl@0
|
232 |
{
|
sl@0
|
233 |
TUid id = TUid::Uid(intUIDType);
|
sl@0
|
234 |
uidType = TUidType(id);
|
sl@0
|
235 |
INFO_PRINTF2(_L("UID type set to %d"), uidType[0].iUid);
|
sl@0
|
236 |
isUidType = ETrue;
|
sl@0
|
237 |
}
|
sl@0
|
238 |
else
|
sl@0
|
239 |
{
|
sl@0
|
240 |
dataOk = EFalse;
|
sl@0
|
241 |
ERR_PRINTF2(_L("attmask or %S must be declared !!!"), &KTUidType);
|
sl@0
|
242 |
}
|
sl@0
|
243 |
}
|
sl@0
|
244 |
|
sl@0
|
245 |
if (dataOk)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
TInt err = KErrNone;
|
sl@0
|
248 |
|
sl@0
|
249 |
if (isUidType)
|
sl@0
|
250 |
{
|
sl@0
|
251 |
err = iRDir->Open(*rfsObject, path, uidType);
|
sl@0
|
252 |
}
|
sl@0
|
253 |
else
|
sl@0
|
254 |
{
|
sl@0
|
255 |
err = iRDir->Open(*rfsObject, path, attMask);
|
sl@0
|
256 |
}
|
sl@0
|
257 |
|
sl@0
|
258 |
if (err != KErrNone)
|
sl@0
|
259 |
{
|
sl@0
|
260 |
INFO_PRINTF2(_L("Open() error: %d"), err);
|
sl@0
|
261 |
SetError(err);
|
sl@0
|
262 |
}
|
sl@0
|
263 |
else
|
sl@0
|
264 |
{
|
sl@0
|
265 |
INFO_PRINTF1(_L("Directory has been opened!"));
|
sl@0
|
266 |
}
|
sl@0
|
267 |
}
|
sl@0
|
268 |
}
|
sl@0
|
269 |
|
sl@0
|
270 |
void CT_RDirData::DoCmdReadL(const TDesC& aSection, const TInt aAsyncErrorIndex)
|
sl@0
|
271 |
{
|
sl@0
|
272 |
INFO_PRINTF1(_L("Reading directory!"));
|
sl@0
|
273 |
|
sl@0
|
274 |
TBool async = EFalse;
|
sl@0
|
275 |
TBool readArray = EFalse;
|
sl@0
|
276 |
TBool compare = EFalse;
|
sl@0
|
277 |
|
sl@0
|
278 |
GET_OPTIONAL_BOOL_PARAMETER(KAsync(), aSection, async);
|
sl@0
|
279 |
|
sl@0
|
280 |
if(GET_OPTIONAL_BOOL_PARAMETER(KReadArray(),aSection,readArray))
|
sl@0
|
281 |
{
|
sl@0
|
282 |
ReadExpectedNamesL( aSection);
|
sl@0
|
283 |
}
|
sl@0
|
284 |
|
sl@0
|
285 |
if(GET_OPTIONAL_BOOL_PARAMETER(KCompareFiles(),aSection,compare))
|
sl@0
|
286 |
{
|
sl@0
|
287 |
iCompare = compare;
|
sl@0
|
288 |
}
|
sl@0
|
289 |
|
sl@0
|
290 |
TPtrC entryArrayName;
|
sl@0
|
291 |
if (GET_OPTIONAL_STRING_PARAMETER(KArrayObjectName(), aSection, entryArrayName))
|
sl@0
|
292 |
{
|
sl@0
|
293 |
TEntryArray* entryArray = new(ELeave) TEntryArray();
|
sl@0
|
294 |
CleanupStack::PushL(entryArray);
|
sl@0
|
295 |
|
sl@0
|
296 |
CT_EntryArrayData* entryArrayWrapper =
|
sl@0
|
297 |
static_cast<CT_EntryArrayData*> (GetDataWrapperL(entryArrayName));
|
sl@0
|
298 |
if (entryArrayWrapper)
|
sl@0
|
299 |
{
|
sl@0
|
300 |
entryArrayWrapper->SetObjectL(entryArray);
|
sl@0
|
301 |
}
|
sl@0
|
302 |
else
|
sl@0
|
303 |
{
|
sl@0
|
304 |
ERR_PRINTF2(_L("Not initialized %S"), &entryArrayName);
|
sl@0
|
305 |
SetBlockResult(EFail);
|
sl@0
|
306 |
}
|
sl@0
|
307 |
CleanupStack::Pop(entryArray);
|
sl@0
|
308 |
|
sl@0
|
309 |
if (async)
|
sl@0
|
310 |
{
|
sl@0
|
311 |
iObjName = entryArrayName;
|
sl@0
|
312 |
iRDir->Read(*entryArray, iReadBlock->iStatus);
|
sl@0
|
313 |
iReadBlock->Activate(aAsyncErrorIndex);
|
sl@0
|
314 |
IncOutstanding();
|
sl@0
|
315 |
}
|
sl@0
|
316 |
else
|
sl@0
|
317 |
{
|
sl@0
|
318 |
TInt err = iRDir->Read(*entryArray);
|
sl@0
|
319 |
|
sl@0
|
320 |
if((err == KErrNone) || (err == KErrEof))
|
sl@0
|
321 |
{
|
sl@0
|
322 |
INFO_PRINTF1(_L("Read function completed successfully"));
|
sl@0
|
323 |
SetError(err);
|
sl@0
|
324 |
if(compare)
|
sl@0
|
325 |
{
|
sl@0
|
326 |
CompareEntryArray(entryArray);
|
sl@0
|
327 |
}
|
sl@0
|
328 |
}
|
sl@0
|
329 |
else
|
sl@0
|
330 |
{
|
sl@0
|
331 |
ERR_PRINTF2(_L("Read function failed with error: %d"), err);
|
sl@0
|
332 |
SetError(err);
|
sl@0
|
333 |
}
|
sl@0
|
334 |
}
|
sl@0
|
335 |
}
|
sl@0
|
336 |
else
|
sl@0
|
337 |
{
|
sl@0
|
338 |
TPtrC entryName;
|
sl@0
|
339 |
if (GET_MANDATORY_STRING_PARAMETER(KEntryObjectName(), aSection, entryName))
|
sl@0
|
340 |
{
|
sl@0
|
341 |
TEntry* entry = new(ELeave) TEntry();
|
sl@0
|
342 |
CleanupStack::PushL(entry);
|
sl@0
|
343 |
|
sl@0
|
344 |
CT_EntryData* entryWrapper =
|
sl@0
|
345 |
static_cast<CT_EntryData*> (GetDataWrapperL(entryName));
|
sl@0
|
346 |
|
sl@0
|
347 |
if (entryWrapper)
|
sl@0
|
348 |
{
|
sl@0
|
349 |
entryWrapper->SetObjectL(entry);
|
sl@0
|
350 |
}
|
sl@0
|
351 |
else
|
sl@0
|
352 |
{
|
sl@0
|
353 |
ERR_PRINTF2(_L("Not initialized %S"), &entryName);
|
sl@0
|
354 |
SetBlockResult(EFail);
|
sl@0
|
355 |
}
|
sl@0
|
356 |
|
sl@0
|
357 |
CleanupStack::Pop(entry);
|
sl@0
|
358 |
|
sl@0
|
359 |
if (async)
|
sl@0
|
360 |
{
|
sl@0
|
361 |
iObjName = entryName;
|
sl@0
|
362 |
delete iEntry;
|
sl@0
|
363 |
iEntry = NULL;
|
sl@0
|
364 |
iEntry = new(ELeave) TPckg<TEntry>(*entry);
|
sl@0
|
365 |
iRDir->Read(*iEntry, iRead->iStatus);
|
sl@0
|
366 |
iRead->Activate(aAsyncErrorIndex);
|
sl@0
|
367 |
IncOutstanding();
|
sl@0
|
368 |
}
|
sl@0
|
369 |
else
|
sl@0
|
370 |
{
|
sl@0
|
371 |
TInt err = iRDir->Read(*entry);
|
sl@0
|
372 |
|
sl@0
|
373 |
if((err == KErrNone) || (err == KErrEof))
|
sl@0
|
374 |
{
|
sl@0
|
375 |
INFO_PRINTF1(_L("Read function completed successfully"));
|
sl@0
|
376 |
SetError(err);
|
sl@0
|
377 |
if(compare)
|
sl@0
|
378 |
{
|
sl@0
|
379 |
CompareEntryData(entry);
|
sl@0
|
380 |
}
|
sl@0
|
381 |
}
|
sl@0
|
382 |
else
|
sl@0
|
383 |
{
|
sl@0
|
384 |
ERR_PRINTF2(_L("Read function failed with error: %d"), err);
|
sl@0
|
385 |
SetError(err);
|
sl@0
|
386 |
}
|
sl@0
|
387 |
}
|
sl@0
|
388 |
}
|
sl@0
|
389 |
}
|
sl@0
|
390 |
}
|
sl@0
|
391 |
|
sl@0
|
392 |
|
sl@0
|
393 |
void CT_RDirData::ReadExpectedNamesL( const TDesC& aSection )
|
sl@0
|
394 |
/**
|
sl@0
|
395 |
* Read list of expected file names from ili file
|
sl@0
|
396 |
*/
|
sl@0
|
397 |
{
|
sl@0
|
398 |
iExpectedNames->ResetAndDestroy();
|
sl@0
|
399 |
|
sl@0
|
400 |
TBool moreData = EFalse;
|
sl@0
|
401 |
TInt index = 0;
|
sl@0
|
402 |
do
|
sl@0
|
403 |
{
|
sl@0
|
404 |
TBuf<KBufferLength> tempStore;
|
sl@0
|
405 |
tempStore.Format(KParamExpectedFileName(), ++index);
|
sl@0
|
406 |
TPtrC fileName;
|
sl@0
|
407 |
moreData = GET_OPTIONAL_STRING_PARAMETER(tempStore, aSection, fileName);
|
sl@0
|
408 |
if (moreData)
|
sl@0
|
409 |
{
|
sl@0
|
410 |
TPath* path = new(ELeave) TPath(fileName);
|
sl@0
|
411 |
CleanupStack::PushL(path);
|
sl@0
|
412 |
iExpectedNames->AppendL(path);
|
sl@0
|
413 |
CleanupStack::Pop();
|
sl@0
|
414 |
}
|
sl@0
|
415 |
}
|
sl@0
|
416 |
while (moreData);
|
sl@0
|
417 |
}
|
sl@0
|
418 |
|
sl@0
|
419 |
|
sl@0
|
420 |
void CT_RDirData::CompareEntryArray(TEntryArray* aEntryArray)
|
sl@0
|
421 |
/**
|
sl@0
|
422 |
* Compare TEntryArray entryes with list of expected files
|
sl@0
|
423 |
*/
|
sl@0
|
424 |
{
|
sl@0
|
425 |
if(aEntryArray->Count() == iExpectedNames->Count())
|
sl@0
|
426 |
{
|
sl@0
|
427 |
for(TInt i = 0; i < aEntryArray->Count(); i++)
|
sl@0
|
428 |
{
|
sl@0
|
429 |
TBool eof = EFalse;
|
sl@0
|
430 |
for(TInt k = 0; !eof && (k < iExpectedNames->Count()); k++)
|
sl@0
|
431 |
{
|
sl@0
|
432 |
TEntry* tmpEntry = new(ELeave) TEntry();
|
sl@0
|
433 |
*tmpEntry = aEntryArray->operator[](i);
|
sl@0
|
434 |
if(*(iExpectedNames->operator[](k)) == tmpEntry->iName)
|
sl@0
|
435 |
{
|
sl@0
|
436 |
TPath* name = iExpectedNames->operator[](k);
|
sl@0
|
437 |
INFO_PRINTF3( _L( "Entry name = expected name, %S = %S"), &tmpEntry->iName, name);
|
sl@0
|
438 |
|
sl@0
|
439 |
iExpectedNames->Remove(k);
|
sl@0
|
440 |
delete name;
|
sl@0
|
441 |
eof = ETrue;
|
sl@0
|
442 |
}
|
sl@0
|
443 |
|
sl@0
|
444 |
delete tmpEntry;
|
sl@0
|
445 |
}
|
sl@0
|
446 |
}
|
sl@0
|
447 |
if(iExpectedNames->Count() > 0)
|
sl@0
|
448 |
{
|
sl@0
|
449 |
ERR_PRINTF1(_L("TEntryArray members are not equal to expected"));
|
sl@0
|
450 |
SetBlockResult(EFail);
|
sl@0
|
451 |
}
|
sl@0
|
452 |
else
|
sl@0
|
453 |
{
|
sl@0
|
454 |
INFO_PRINTF1( _L( "TEntryArray members are equal to expected"));
|
sl@0
|
455 |
}
|
sl@0
|
456 |
}
|
sl@0
|
457 |
else if(aEntryArray->Count() > iExpectedNames->Count())
|
sl@0
|
458 |
{
|
sl@0
|
459 |
ERR_PRINTF1(_L("Found unexpecded file(s)"));
|
sl@0
|
460 |
SetBlockResult(EFail);
|
sl@0
|
461 |
}
|
sl@0
|
462 |
else if(aEntryArray->Count() < iExpectedNames->Count())
|
sl@0
|
463 |
{
|
sl@0
|
464 |
ERR_PRINTF1(_L("List of expected files more than amount of real files"));
|
sl@0
|
465 |
SetBlockResult(EFail);
|
sl@0
|
466 |
}
|
sl@0
|
467 |
}
|
sl@0
|
468 |
|
sl@0
|
469 |
void CT_RDirData::CompareEntryData(TEntry* aEntry)
|
sl@0
|
470 |
/**
|
sl@0
|
471 |
* Compare TEntry with entry in list of expected files
|
sl@0
|
472 |
*/
|
sl@0
|
473 |
{
|
sl@0
|
474 |
TBool eof = EFalse;
|
sl@0
|
475 |
TBool fileCompare = EFalse;
|
sl@0
|
476 |
for(TInt i = 0; !eof && (i < iExpectedNames->Count()); i++)
|
sl@0
|
477 |
{
|
sl@0
|
478 |
if(*(iExpectedNames->operator[](i)) == aEntry->iName)
|
sl@0
|
479 |
{
|
sl@0
|
480 |
TPath* name = iExpectedNames->operator[](i);
|
sl@0
|
481 |
fileCompare = ETrue;
|
sl@0
|
482 |
|
sl@0
|
483 |
iExpectedNames->Remove(i);
|
sl@0
|
484 |
delete name;
|
sl@0
|
485 |
eof = ETrue;
|
sl@0
|
486 |
}
|
sl@0
|
487 |
}
|
sl@0
|
488 |
if(!fileCompare)
|
sl@0
|
489 |
{
|
sl@0
|
490 |
ERR_PRINTF2(_L("Unexpected file - %S"),&aEntry->iName);
|
sl@0
|
491 |
SetBlockResult(EFail);
|
sl@0
|
492 |
}
|
sl@0
|
493 |
}
|
sl@0
|
494 |
|
sl@0
|
495 |
|
sl@0
|
496 |
void CT_RDirData::RunL(CActive* aActive, TInt aIndex)
|
sl@0
|
497 |
{
|
sl@0
|
498 |
INFO_PRINTF1(_L("RunL Called!"));
|
sl@0
|
499 |
|
sl@0
|
500 |
if ((aActive == iReadBlock) || (aActive == iRead))
|
sl@0
|
501 |
{
|
sl@0
|
502 |
|
sl@0
|
503 |
TInt err = aActive->iStatus.Int();
|
sl@0
|
504 |
if (err == KErrNone)
|
sl@0
|
505 |
{
|
sl@0
|
506 |
TEntry &actualEntry = iEntry->operator()();
|
sl@0
|
507 |
INFO_PRINTF2(_L("Asynchronous Read function completed successfully, %S"),&(actualEntry.iName));
|
sl@0
|
508 |
}
|
sl@0
|
509 |
else if (err == KErrEof)
|
sl@0
|
510 |
{
|
sl@0
|
511 |
INFO_PRINTF1(_L("Asynchronous Read function reached the end and returned expectedly KErrEof"));
|
sl@0
|
512 |
SetAsyncError(aIndex, err);
|
sl@0
|
513 |
}
|
sl@0
|
514 |
else
|
sl@0
|
515 |
{
|
sl@0
|
516 |
ERR_PRINTF2(_L("RunL Error: %d"), err);
|
sl@0
|
517 |
SetAsyncError(aIndex, err);
|
sl@0
|
518 |
}
|
sl@0
|
519 |
|
sl@0
|
520 |
|
sl@0
|
521 |
if(iCompare && ((err == KErrNone) || (err == KErrEof)))
|
sl@0
|
522 |
{
|
sl@0
|
523 |
if(aActive == iReadBlock)
|
sl@0
|
524 |
{
|
sl@0
|
525 |
TEntryArray *entryArray = static_cast<TEntryArray*>(GetDataObjectL(iObjName));
|
sl@0
|
526 |
if (entryArray)
|
sl@0
|
527 |
{
|
sl@0
|
528 |
CompareEntryArray(entryArray);
|
sl@0
|
529 |
}
|
sl@0
|
530 |
else
|
sl@0
|
531 |
{
|
sl@0
|
532 |
SetBlockResult(EFail);
|
sl@0
|
533 |
ERR_PRINTF2(_L("Empty Object: %S"), &iObjName);
|
sl@0
|
534 |
}
|
sl@0
|
535 |
}
|
sl@0
|
536 |
else if(aActive == iRead)
|
sl@0
|
537 |
{
|
sl@0
|
538 |
TEntry* entry = static_cast<TEntry*>(GetDataObjectL(iObjName));
|
sl@0
|
539 |
if (entry)
|
sl@0
|
540 |
{
|
sl@0
|
541 |
CompareEntryData(entry);
|
sl@0
|
542 |
}
|
sl@0
|
543 |
else
|
sl@0
|
544 |
{
|
sl@0
|
545 |
SetBlockResult(EFail);
|
sl@0
|
546 |
ERR_PRINTF2(_L("Empty Object: %S"), &iObjName);
|
sl@0
|
547 |
}
|
sl@0
|
548 |
}
|
sl@0
|
549 |
}
|
sl@0
|
550 |
|
sl@0
|
551 |
delete iEntry;
|
sl@0
|
552 |
iEntry = NULL;
|
sl@0
|
553 |
|
sl@0
|
554 |
DecOutstanding();
|
sl@0
|
555 |
}
|
sl@0
|
556 |
else
|
sl@0
|
557 |
{
|
sl@0
|
558 |
ERR_PRINTF1( _L("Stray RunL signal") );
|
sl@0
|
559 |
SetBlockResult( EFail );
|
sl@0
|
560 |
}
|
sl@0
|
561 |
}
|
sl@0
|
562 |
|
sl@0
|
563 |
void CT_RDirData::DoCancel(CActive* aActive, TInt aIndex)
|
sl@0
|
564 |
{
|
sl@0
|
565 |
INFO_PRINTF1(_L("DoCancel Called!"));
|
sl@0
|
566 |
|
sl@0
|
567 |
if ( aActive == iRead )
|
sl@0
|
568 |
{
|
sl@0
|
569 |
TInt err = aActive->iStatus.Int();
|
sl@0
|
570 |
if(err != KErrNone )
|
sl@0
|
571 |
{
|
sl@0
|
572 |
ERR_PRINTF2(_L("DoCancel Error: %d"), err);
|
sl@0
|
573 |
SetAsyncError(aIndex, err);
|
sl@0
|
574 |
}
|
sl@0
|
575 |
DecOutstanding();
|
sl@0
|
576 |
}
|
sl@0
|
577 |
else
|
sl@0
|
578 |
{
|
sl@0
|
579 |
ERR_PRINTF1( _L("Stray RunL signal") );
|
sl@0
|
580 |
SetBlockResult( EFail );
|
sl@0
|
581 |
}
|
sl@0
|
582 |
}
|