0
|
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 the License "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 |
/**
|
|
19 |
@test
|
|
20 |
@internalComponent
|
|
21 |
|
|
22 |
This contains CT_FileManData
|
|
23 |
*/
|
|
24 |
|
|
25 |
// User includes
|
|
26 |
#include "T_FileManData.h"
|
|
27 |
#include "T_SfSrvServer.h"
|
|
28 |
|
|
29 |
const TInt KMaxFileNameLength =255;
|
|
30 |
|
|
31 |
/*@{*/
|
|
32 |
/// Parameters
|
|
33 |
_LIT(KPath, "path");
|
|
34 |
_LIT(KFileName, "filename");
|
|
35 |
_LIT(KFileFrom, "filefrom");
|
|
36 |
_LIT(KFileTo, "fileto");
|
|
37 |
_LIT(KOldName, "oldname");
|
|
38 |
_LIT(KNewName, "newname");
|
|
39 |
_LIT(KRFsObject, "rfsObject");
|
|
40 |
_LIT(KRFileObject, "rfileObject");
|
|
41 |
_LIT(KUseObserver, "use_observer");
|
|
42 |
_LIT(KAsync, "async");
|
|
43 |
_LIT(KTime, "time");
|
|
44 |
_LIT(KSetMask, "setmask");
|
|
45 |
_LIT(KClearMask, "clearmask");
|
|
46 |
_LIT(KOperation, "operation");
|
|
47 |
_LIT(KCurrentAction, "current_action");
|
|
48 |
_LIT(KBytes, "bytes");
|
|
49 |
_LIT(KError, "error");
|
|
50 |
_LIT(KTarget, "target");
|
|
51 |
_LIT(KSource, "source");
|
|
52 |
_LIT(KNotifyType, "notify_type");
|
|
53 |
_LIT(KReadHistory, "read_history");
|
|
54 |
_LIT(KName, "name");
|
|
55 |
_LIT(KNullDesCStr, "KNullDesC");
|
|
56 |
_LIT(KTotalBytes, "total_bytes");
|
|
57 |
_LIT(KFlag, "flag");
|
|
58 |
_LIT(KClearHistory, "clear_history");
|
|
59 |
_LIT(KSetTcontrol, "set_tcontrol");
|
|
60 |
//For searching file names.
|
|
61 |
_LIT(KPattern, "*%S*");
|
|
62 |
|
|
63 |
/// Commands
|
|
64 |
_LIT(KCmdNewL, "NewL");
|
|
65 |
_LIT(KCmdAttribs, "Attribs");
|
|
66 |
_LIT(KCmdCopy, "Copy");
|
|
67 |
_LIT(KCmdMove, "Move");
|
|
68 |
_LIT(KCmdDelete, "Delete");
|
|
69 |
_LIT(KCmdRename, "Rename");
|
|
70 |
_LIT(KCmdRmDir, "RmDir");
|
|
71 |
_LIT(KCmdSetObserver, "SetObserver");
|
|
72 |
_LIT(KCmdCurrentAction, "CurrentAction");
|
|
73 |
_LIT(KCmdGetCurrentTarget, "GetCurrentTarget");
|
|
74 |
_LIT(KCmdGetCurrentSource, "GetCurrentSource");
|
|
75 |
_LIT(KCmdBytesTransferredByCopyStep, "BytesTransferredByCopyStep");
|
|
76 |
_LIT(KCmdCurrentEntry, "CurrentEntry");
|
|
77 |
_LIT(KCmdAbbreviatedPath, "AbbreviatedPath");
|
|
78 |
_LIT(KCmdFullPath, "FullPath");
|
|
79 |
_LIT(KCmdGetLastError, "GetLastError");
|
|
80 |
_LIT(KCmdGetMoreInfoAboutError, "GetMoreInfoAboutError");
|
|
81 |
_LIT(KCmdDestructor, "~");
|
|
82 |
|
|
83 |
// TActions
|
|
84 |
_LIT(KENone, "ENone");
|
|
85 |
_LIT(KEAttribs, "EAttribs");
|
|
86 |
_LIT(KECopy, "ECopy");
|
|
87 |
_LIT(KEDelete, "EDelete");
|
|
88 |
_LIT(KEMove, "EMove");
|
|
89 |
_LIT(KERename, "ERename");
|
|
90 |
_LIT(KERmDir, "ERmDir");
|
|
91 |
_LIT(KERenameInvalidEntry, "ERenameInvalidEntry");
|
|
92 |
_LIT(KECopyFromHandle, "ECopyFromHandle");
|
|
93 |
|
|
94 |
|
|
95 |
// TSwitch
|
|
96 |
_LIT(KEOverWrite, "EOverWrite");
|
|
97 |
_LIT(KERecurse, "ERecurse");
|
|
98 |
|
|
99 |
// TControl
|
|
100 |
_LIT(KEContinue, "EContinue");
|
|
101 |
_LIT(KEAbort, "EAbort");
|
|
102 |
_LIT(KECancel, "ECancel");
|
|
103 |
_LIT(KERetry, "ERetry");
|
|
104 |
|
|
105 |
// TFileManError
|
|
106 |
_LIT(KENoExtraInformation, "ENoExtraInformation");
|
|
107 |
_LIT(KEInitializationFailed, "EInitializationFailed");
|
|
108 |
_LIT(KEScanNextDirectoryFailed, "EScanNextDirectoryFailed");
|
|
109 |
_LIT(KESrcOpenFailed, "ESrcOpenFailed");
|
|
110 |
_LIT(KETrgOpenFailed, "ETrgOpenFailed");
|
|
111 |
_LIT(KENoFilesProcessed, "ENoFilesProcessed");
|
|
112 |
|
|
113 |
//Notifys
|
|
114 |
_LIT(KNotifyStarted, "started");
|
|
115 |
_LIT(KNotifyOperation, "operation");
|
|
116 |
_LIT(KNotifyEnded, "ended");
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
CT_FileManData* CT_FileManData::NewL()
|
|
121 |
/**
|
|
122 |
* Two phase constructor
|
|
123 |
*/
|
|
124 |
{
|
|
125 |
CT_FileManData* ret = new (ELeave) CT_FileManData();
|
|
126 |
CleanupStack::PushL(ret);
|
|
127 |
ret->ConstructL();
|
|
128 |
CleanupStack::Pop(ret);
|
|
129 |
return ret;
|
|
130 |
}
|
|
131 |
|
|
132 |
|
|
133 |
CT_FileManData::CT_FileManData()
|
|
134 |
: iFileMan(NULL)
|
|
135 |
, iAsyncErrorIndex(0)
|
|
136 |
, iAsyncCall(EFalse)
|
|
137 |
, iFileManObserver(NULL)
|
|
138 |
, iUseTControl(EFalse)
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Protected constructor. First phase construction
|
|
142 |
*/
|
|
143 |
{
|
|
144 |
}
|
|
145 |
|
|
146 |
|
|
147 |
void CT_FileManData::ConstructL()
|
|
148 |
/**
|
|
149 |
* Protected constructor. Second phase construction
|
|
150 |
*/
|
|
151 |
{
|
|
152 |
}
|
|
153 |
|
|
154 |
|
|
155 |
CT_FileManData::~CT_FileManData()
|
|
156 |
/**
|
|
157 |
* Destructor.
|
|
158 |
*/
|
|
159 |
{
|
|
160 |
DoCleanup();
|
|
161 |
|
|
162 |
iAttribs.ResetAndDestroy();
|
|
163 |
iCopy.ResetAndDestroy();
|
|
164 |
iDelete.ResetAndDestroy();
|
|
165 |
iMove.ResetAndDestroy();
|
|
166 |
iRename.ResetAndDestroy();
|
|
167 |
iRmDir.ResetAndDestroy();
|
|
168 |
|
|
169 |
ClearHistory();
|
|
170 |
}
|
|
171 |
|
|
172 |
TAny* CT_FileManData::GetObject()
|
|
173 |
{
|
|
174 |
return iFileMan;
|
|
175 |
}
|
|
176 |
|
|
177 |
|
|
178 |
TBool CT_FileManData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
|
179 |
/**
|
|
180 |
* Process a command read from the ini file
|
|
181 |
*
|
|
182 |
* @param aCommand the command to process
|
|
183 |
* @param aSection the section in the ini file requiring the command to be processed
|
|
184 |
*
|
|
185 |
* @return ETrue if the command is processed
|
|
186 |
*/
|
|
187 |
{
|
|
188 |
TBool retVal = ETrue;
|
|
189 |
|
|
190 |
if (aCommand == KCmdNewL)
|
|
191 |
{
|
|
192 |
DoCmdNewL(aSection);
|
|
193 |
}
|
|
194 |
else if (aCommand == KCmdDestructor)
|
|
195 |
{
|
|
196 |
DoCleanup();
|
|
197 |
}
|
|
198 |
else if (aCommand == KCmdAttribs)
|
|
199 |
{
|
|
200 |
DoCmdAttribsL(aSection, aAsyncErrorIndex);
|
|
201 |
}
|
|
202 |
else if (aCommand == KCmdCopy)
|
|
203 |
{
|
|
204 |
DoCmdCopyL(aSection, aAsyncErrorIndex);
|
|
205 |
}
|
|
206 |
else if (aCommand == KCmdMove)
|
|
207 |
{
|
|
208 |
DoCmdMoveL(aSection, aAsyncErrorIndex);
|
|
209 |
}
|
|
210 |
else if (aCommand == KCmdDelete)
|
|
211 |
{
|
|
212 |
DoCmdDeleteL(aSection, aAsyncErrorIndex);
|
|
213 |
}
|
|
214 |
else if (aCommand == KCmdRename)
|
|
215 |
{
|
|
216 |
DoCmdRenameL(aSection, aAsyncErrorIndex);
|
|
217 |
}
|
|
218 |
else if (aCommand == KCmdRmDir)
|
|
219 |
{
|
|
220 |
DoCmdRmDirL(aSection, aAsyncErrorIndex);
|
|
221 |
}
|
|
222 |
else if (aCommand == KCmdSetObserver)
|
|
223 |
{
|
|
224 |
DoCmdSetObserver();
|
|
225 |
}
|
|
226 |
else if (aCommand == KCmdCurrentAction)
|
|
227 |
{
|
|
228 |
DoCmdCurrentAction(aSection);
|
|
229 |
}
|
|
230 |
else if (aCommand == KCmdGetCurrentTarget)
|
|
231 |
{
|
|
232 |
DoCmdGetCurrentTarget(aSection);
|
|
233 |
}
|
|
234 |
else if (aCommand == KCmdGetCurrentSource)
|
|
235 |
{
|
|
236 |
DoCmdGetCurrentSource(aSection);
|
|
237 |
}
|
|
238 |
else if (aCommand == KCmdBytesTransferredByCopyStep)
|
|
239 |
{
|
|
240 |
DoCmdBytesTransferredByCopyStep(aSection);
|
|
241 |
}
|
|
242 |
else if(aCommand == KCmdCurrentEntry)
|
|
243 |
{
|
|
244 |
DoCmdCurrentEntryL(aSection);
|
|
245 |
}
|
|
246 |
else if(aCommand == KCmdAbbreviatedPath)
|
|
247 |
{
|
|
248 |
DoCmdAbbreviatedPath(aSection);
|
|
249 |
}
|
|
250 |
else if(aCommand == KCmdFullPath)
|
|
251 |
{
|
|
252 |
DoCmdFullPath(aSection);
|
|
253 |
}
|
|
254 |
else if(aCommand == KCmdGetLastError)
|
|
255 |
{
|
|
256 |
DoCmdGetLastError(aSection);
|
|
257 |
}
|
|
258 |
else if(aCommand == KCmdGetMoreInfoAboutError)
|
|
259 |
{
|
|
260 |
DoCmdGetMoreInfoAboutError(aSection);
|
|
261 |
}
|
|
262 |
return retVal;
|
|
263 |
}
|
|
264 |
|
|
265 |
void CT_FileManData::DoCleanup()
|
|
266 |
{
|
|
267 |
INFO_PRINTF1(_L("Doing cleanup"));
|
|
268 |
|
|
269 |
if (iFileMan)
|
|
270 |
{
|
|
271 |
delete(iFileMan);
|
|
272 |
iFileMan = NULL;
|
|
273 |
}
|
|
274 |
ClearHistory();
|
|
275 |
}
|
|
276 |
|
|
277 |
/** Inform the observer that an operation is about to start **/
|
|
278 |
MFileManObserver::TControl CT_FileManData::NotifyFileManStarted()
|
|
279 |
{
|
|
280 |
THistoryData *record = new THistoryData();
|
|
281 |
CreateHistoryRecord(*record);
|
|
282 |
iStartedHistory.Append(record);
|
|
283 |
if(record->iLastError != KErrNone)
|
|
284 |
{
|
|
285 |
if(iAsyncCall)
|
|
286 |
{
|
|
287 |
SetAsyncError(iAsyncErrorIndex, record->iLastError);
|
|
288 |
iAsyncCall = EFalse;
|
|
289 |
}
|
|
290 |
else
|
|
291 |
{
|
|
292 |
SetError(record->iLastError);
|
|
293 |
}
|
|
294 |
}
|
|
295 |
TControl ret = EContinue;
|
|
296 |
//Check if we need to return TControl value specified in INI.
|
|
297 |
if(iUseTControl && iObserverNotifyType == ENotifyStarted)
|
|
298 |
{
|
|
299 |
TBuf<KMaxFileNameLength> buffer;
|
|
300 |
buffer.Format(KPattern(), &iNotifyFileName);
|
|
301 |
//Check if we need to return TControl for this file.
|
|
302 |
if(record->iCurrentSource.Match(buffer) != KErrNotFound)
|
|
303 |
{
|
|
304 |
iUseTControl = EFalse;
|
|
305 |
ret = iTControl;
|
|
306 |
}
|
|
307 |
}
|
|
308 |
return ret;
|
|
309 |
}
|
|
310 |
|
|
311 |
/** Informs the observer that an operation, i.e. a copy or a move, is proceeding. **/
|
|
312 |
MFileManObserver::TControl CT_FileManData::NotifyFileManOperation()
|
|
313 |
{
|
|
314 |
THistoryData *record = new THistoryData();
|
|
315 |
CreateHistoryRecord(*record);
|
|
316 |
iOperationHistory.Append(record);
|
|
317 |
if(record->iLastError != KErrNone)
|
|
318 |
{
|
|
319 |
if(iAsyncCall)
|
|
320 |
{
|
|
321 |
SetAsyncError(iAsyncErrorIndex, record->iLastError);
|
|
322 |
iAsyncCall = EFalse;
|
|
323 |
}
|
|
324 |
else
|
|
325 |
{
|
|
326 |
SetError(record->iLastError);
|
|
327 |
}
|
|
328 |
}
|
|
329 |
TControl ret = EContinue;
|
|
330 |
//Check if we need to return TControl value specified in INI.
|
|
331 |
if(iUseTControl && iObserverNotifyType == ENotifyOperation)
|
|
332 |
{
|
|
333 |
TBuf<KMaxFileNameLength> buffer;
|
|
334 |
buffer.Format(KPattern(), &iNotifyFileName);
|
|
335 |
//Check if we need to return TControl for this file.
|
|
336 |
if(record->iCurrentSource.Match(buffer) != KErrNotFound)
|
|
337 |
{
|
|
338 |
iUseTControl = EFalse;
|
|
339 |
ret = iTControl;
|
|
340 |
}
|
|
341 |
}
|
|
342 |
return ret;
|
|
343 |
}
|
|
344 |
|
|
345 |
/** Informs the observer that an operation is complete. **/
|
|
346 |
MFileManObserver::TControl CT_FileManData::NotifyFileManEnded()
|
|
347 |
{
|
|
348 |
THistoryData *record = new THistoryData();
|
|
349 |
CreateHistoryRecord(*record);
|
|
350 |
iEndedHistory.Append(record);
|
|
351 |
if(record->iLastError != KErrNone)
|
|
352 |
{
|
|
353 |
if(iAsyncCall)
|
|
354 |
{
|
|
355 |
SetAsyncError(iAsyncErrorIndex, record->iLastError);
|
|
356 |
iAsyncCall = EFalse;
|
|
357 |
}
|
|
358 |
else
|
|
359 |
{
|
|
360 |
SetError(record->iLastError);
|
|
361 |
}
|
|
362 |
}
|
|
363 |
TControl ret = EContinue;
|
|
364 |
//Check if we need to return TControl value specified in INI.
|
|
365 |
if(iUseTControl && iObserverNotifyType == ENotifyEnded)
|
|
366 |
{
|
|
367 |
TBuf<KMaxFileNameLength> buffer;
|
|
368 |
buffer.Format(KPattern(), &iNotifyFileName);
|
|
369 |
//Check if we need to return TControl for this file.
|
|
370 |
if(record->iCurrentSource.Match(buffer) != KErrNotFound)
|
|
371 |
{
|
|
372 |
iUseTControl = EFalse;
|
|
373 |
ret = iTControl;
|
|
374 |
}
|
|
375 |
}
|
|
376 |
return ret;
|
|
377 |
}
|
|
378 |
|
|
379 |
void CT_FileManData::DoCmdNewL(const TDesC& aSection)
|
|
380 |
{
|
|
381 |
DoCleanup();
|
|
382 |
TBool useObserver = EFalse;
|
|
383 |
|
|
384 |
GET_OPTIONAL_BOOL_PARAMETER(KUseObserver, aSection, useObserver);
|
|
385 |
|
|
386 |
TPtrC rfsObjectName;
|
|
387 |
RFs* rfsObject = NULL;
|
|
388 |
if (GET_MANDATORY_STRING_PARAMETER(KRFsObject, aSection, rfsObjectName))
|
|
389 |
{
|
|
390 |
rfsObject = (RFs*)GetDataObjectL(rfsObjectName);
|
|
391 |
}
|
|
392 |
|
|
393 |
TInt err = KErrNone;
|
|
394 |
if(useObserver)
|
|
395 |
{
|
|
396 |
INFO_PRINTF1(_L("CFileMan::NewL(RFs, MFileManObserver)"));
|
|
397 |
TRAP(err, iFileMan = CFileMan::NewL(*rfsObject, iFileManObserver));
|
|
398 |
}
|
|
399 |
else
|
|
400 |
{
|
|
401 |
INFO_PRINTF1(_L("CFileMan::NewL(RFs)"));
|
|
402 |
TRAP(err, iFileMan = CFileMan::NewL(*rfsObject));
|
|
403 |
}
|
|
404 |
if (err != KErrNone)
|
|
405 |
{
|
|
406 |
ERR_PRINTF1(_L("CFileMan object is not created"));
|
|
407 |
SetBlockResult(EFail);
|
|
408 |
}
|
|
409 |
}
|
|
410 |
|
|
411 |
void CT_FileManData::DoCmdAttribsL(const TDesC& aSection, TInt aAsyncErrorIndex)
|
|
412 |
{
|
|
413 |
INFO_PRINTF1(_L("Setting attributes!"));
|
|
414 |
|
|
415 |
TBool dataOk = ETrue;
|
|
416 |
|
|
417 |
//Reading path for file or files.
|
|
418 |
TPtrC fileName;
|
|
419 |
if (!GET_MANDATORY_STRING_PARAMETER(KFileName, aSection, fileName))
|
|
420 |
{
|
|
421 |
dataOk = EFalse;
|
|
422 |
}
|
|
423 |
|
|
424 |
//Reading new TTime from ini
|
|
425 |
TPtrC inputTime;
|
|
426 |
TTime iniTime;
|
|
427 |
if(GET_MANDATORY_STRING_PARAMETER(KTime, aSection, inputTime))
|
|
428 |
{
|
|
429 |
TInt err = iniTime.Set(inputTime);
|
|
430 |
if (err != KErrNone)
|
|
431 |
{
|
|
432 |
ERR_PRINTF3(_L("Cannot convert (%S) to time. Error: %d"), &inputTime ,err);
|
|
433 |
dataOk = EFalse;
|
|
434 |
SetBlockResult(EFail);
|
|
435 |
}
|
|
436 |
}
|
|
437 |
else
|
|
438 |
{
|
|
439 |
dataOk = EFalse;
|
|
440 |
}
|
|
441 |
|
|
442 |
//Reading Async parameter (True/False)
|
|
443 |
TBool async = EFalse;
|
|
444 |
if(!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
|
|
445 |
{
|
|
446 |
dataOk = EFalse;
|
|
447 |
}
|
|
448 |
//Read SetMask attribute
|
|
449 |
TUint setMask;
|
|
450 |
if(!FileserverUtil::GetAttMask(*this, aSection, KSetMask(), setMask))
|
|
451 |
{
|
|
452 |
dataOk = EFalse;
|
|
453 |
}
|
|
454 |
|
|
455 |
//Read ClearMask attribute
|
|
456 |
TUint clearMask;
|
|
457 |
if(!FileserverUtil::GetAttMask(*this, aSection, KClearMask(), clearMask))
|
|
458 |
{
|
|
459 |
dataOk = EFalse;
|
|
460 |
}
|
|
461 |
|
|
462 |
//Read operation TSwitch
|
|
463 |
TUint operation;
|
|
464 |
if(!GetOperationFromConfig(KOperation(), aSection, operation))
|
|
465 |
{
|
|
466 |
dataOk = EFalse;
|
|
467 |
}
|
|
468 |
if(dataOk)
|
|
469 |
{
|
|
470 |
TInt error = KErrNone;
|
|
471 |
if(async)
|
|
472 |
{
|
|
473 |
CActiveCallback* active = CActiveCallback::NewLC(*this);
|
|
474 |
iAttribs.AppendL(active);
|
|
475 |
CleanupStack::Pop(active);
|
|
476 |
error = iFileMan->Attribs(fileName, setMask, clearMask, iniTime, operation, active->iStatus);
|
|
477 |
if(error == KErrNone)
|
|
478 |
{
|
|
479 |
active->Activate(aAsyncErrorIndex);
|
|
480 |
iAsyncErrorIndex = aAsyncErrorIndex;
|
|
481 |
iAsyncCall = ETrue;
|
|
482 |
IncOutstanding();
|
|
483 |
}
|
|
484 |
}
|
|
485 |
else
|
|
486 |
{
|
|
487 |
error = iFileMan->Attribs(fileName, setMask, clearMask, iniTime, operation);
|
|
488 |
}
|
|
489 |
if (error != KErrNone)
|
|
490 |
{
|
|
491 |
ERR_PRINTF3(_L("Attribs(%S) Error: %d"), &fileName, error);
|
|
492 |
SetError(error);
|
|
493 |
}
|
|
494 |
else
|
|
495 |
{
|
|
496 |
INFO_PRINTF2(_L("Attribs operation on (%S) is successfull!"), &fileName);
|
|
497 |
}
|
|
498 |
}
|
|
499 |
}
|
|
500 |
void CT_FileManData::DoCmdCopyL(const TDesC& aSection, TInt aAsyncErrorIndex)
|
|
501 |
{
|
|
502 |
TBool clearHistory = EFalse;
|
|
503 |
GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory);
|
|
504 |
if(clearHistory)
|
|
505 |
{
|
|
506 |
ClearHistory();
|
|
507 |
}
|
|
508 |
TBool setTControl = EFalse;
|
|
509 |
GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl);
|
|
510 |
if(setTControl)
|
|
511 |
{
|
|
512 |
ReadTControl(aSection);
|
|
513 |
}
|
|
514 |
|
|
515 |
INFO_PRINTF1(_L("Coping files!"));
|
|
516 |
TBool dataOk = ETrue;
|
|
517 |
TPtrC oldName;
|
|
518 |
TPtrC rfileObjectName;
|
|
519 |
RFile* rfileObject = NULL;
|
|
520 |
|
|
521 |
if (!GET_OPTIONAL_STRING_PARAMETER(KOldName, aSection, oldName))
|
|
522 |
{
|
|
523 |
if (GET_OPTIONAL_STRING_PARAMETER(KRFileObject, aSection, rfileObjectName))
|
|
524 |
{
|
|
525 |
rfileObject = (RFile*)GetDataObjectL(rfileObjectName);
|
|
526 |
}
|
|
527 |
else
|
|
528 |
{
|
|
529 |
ERR_PRINTF1(_L("Cannot read \"oldname\" or \"rfileObject\" arguments!"));
|
|
530 |
SetBlockResult(EFail);
|
|
531 |
dataOk = EFalse;
|
|
532 |
}
|
|
533 |
}
|
|
534 |
|
|
535 |
TPtrC newName;
|
|
536 |
if (!GET_MANDATORY_STRING_PARAMETER(KNewName, aSection, newName))
|
|
537 |
{
|
|
538 |
dataOk = EFalse;
|
|
539 |
}
|
|
540 |
|
|
541 |
TUint operation;
|
|
542 |
if (!GetOperationFromConfig(KOperation, aSection, operation))
|
|
543 |
{
|
|
544 |
dataOk = EFalse;
|
|
545 |
}
|
|
546 |
TBool async;
|
|
547 |
if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
|
|
548 |
{
|
|
549 |
dataOk = EFalse;
|
|
550 |
}
|
|
551 |
|
|
552 |
if(dataOk)
|
|
553 |
{
|
|
554 |
TInt error = KErrNone;
|
|
555 |
if(async)
|
|
556 |
{
|
|
557 |
CActiveCallback* active = CActiveCallback::NewLC(*this);
|
|
558 |
iCopy.AppendL(active);
|
|
559 |
CleanupStack::Pop(active);
|
|
560 |
if(rfileObject)
|
|
561 |
{
|
|
562 |
error = iFileMan->Copy(*rfileObject, newName, operation, active->iStatus);
|
|
563 |
}
|
|
564 |
else
|
|
565 |
{
|
|
566 |
error = iFileMan->Copy(oldName, newName, operation, active->iStatus);
|
|
567 |
}
|
|
568 |
if(error == KErrNone)
|
|
569 |
{
|
|
570 |
active->Activate(aAsyncErrorIndex);
|
|
571 |
iAsyncErrorIndex = aAsyncErrorIndex;
|
|
572 |
iAsyncCall = ETrue;
|
|
573 |
IncOutstanding();
|
|
574 |
}
|
|
575 |
}
|
|
576 |
else
|
|
577 |
{
|
|
578 |
if(rfileObject)
|
|
579 |
{
|
|
580 |
error = iFileMan->Copy(*rfileObject, newName, operation);
|
|
581 |
}
|
|
582 |
else
|
|
583 |
{
|
|
584 |
error = iFileMan->Copy(oldName, newName, operation);
|
|
585 |
}
|
|
586 |
}
|
|
587 |
if (error != KErrNone)
|
|
588 |
{
|
|
589 |
ERR_PRINTF2(_L("Copy(), Error: %d"), error);
|
|
590 |
SetError(error);
|
|
591 |
}
|
|
592 |
else
|
|
593 |
{
|
|
594 |
INFO_PRINTF1(_L("Copy() operation is successfully!"));
|
|
595 |
}
|
|
596 |
}
|
|
597 |
}
|
|
598 |
|
|
599 |
void CT_FileManData::DoCmdDeleteL(const TDesC& aSection, TInt aAsyncErrorIndex)
|
|
600 |
{
|
|
601 |
TBool clearHistory = EFalse;
|
|
602 |
GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory);
|
|
603 |
if(clearHistory)
|
|
604 |
{
|
|
605 |
ClearHistory();
|
|
606 |
}
|
|
607 |
TBool setTControl = EFalse;
|
|
608 |
GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl);
|
|
609 |
if(setTControl)
|
|
610 |
{
|
|
611 |
ReadTControl(aSection);
|
|
612 |
}
|
|
613 |
|
|
614 |
INFO_PRINTF1(_L("Deleting files!"));
|
|
615 |
|
|
616 |
TBool dataOk = ETrue;
|
|
617 |
TPtrC fileName;
|
|
618 |
if (GET_MANDATORY_STRING_PARAMETER(KFileName, aSection, fileName))
|
|
619 |
{
|
|
620 |
if(fileName == KNullDesCStr)
|
|
621 |
{
|
|
622 |
fileName.Set(KNullDesC);
|
|
623 |
}
|
|
624 |
}
|
|
625 |
else
|
|
626 |
{
|
|
627 |
dataOk = EFalse;
|
|
628 |
}
|
|
629 |
TUint operation;
|
|
630 |
if(!GetOperationFromConfig(KOperation, aSection, operation))
|
|
631 |
{
|
|
632 |
dataOk = EFalse;
|
|
633 |
}
|
|
634 |
TBool async = EFalse;
|
|
635 |
if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
|
|
636 |
{
|
|
637 |
dataOk = EFalse;
|
|
638 |
}
|
|
639 |
if(dataOk)
|
|
640 |
{
|
|
641 |
TInt error = KErrNone;
|
|
642 |
if(async)
|
|
643 |
{
|
|
644 |
CActiveCallback* active = CActiveCallback::NewLC(*this);
|
|
645 |
iDelete.AppendL(active);
|
|
646 |
CleanupStack::Pop(active);
|
|
647 |
error = iFileMan->Delete(fileName, operation, active->iStatus);
|
|
648 |
if (error == KErrNone)
|
|
649 |
{
|
|
650 |
active->Activate(aAsyncErrorIndex);
|
|
651 |
iAsyncErrorIndex = aAsyncErrorIndex;
|
|
652 |
iAsyncCall = ETrue;
|
|
653 |
IncOutstanding();
|
|
654 |
}
|
|
655 |
}
|
|
656 |
else
|
|
657 |
{
|
|
658 |
error = iFileMan->Delete(fileName, operation);
|
|
659 |
}
|
|
660 |
|
|
661 |
if (error != KErrNone)
|
|
662 |
{
|
|
663 |
ERR_PRINTF3(_L("Delete (%S), Error: %d"), &fileName, error);
|
|
664 |
SetError(error);
|
|
665 |
}
|
|
666 |
else
|
|
667 |
{
|
|
668 |
INFO_PRINTF2(_L("Delete (%S) operation is successfully!"), &fileName);
|
|
669 |
}
|
|
670 |
}
|
|
671 |
}
|
|
672 |
|
|
673 |
void CT_FileManData::DoCmdMoveL(const TDesC& aSection, TInt aAsyncErrorIndex)
|
|
674 |
{
|
|
675 |
TBool clearHistory = EFalse;
|
|
676 |
GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory);
|
|
677 |
if(clearHistory)
|
|
678 |
{
|
|
679 |
ClearHistory();
|
|
680 |
}
|
|
681 |
TBool setTControl = EFalse;
|
|
682 |
GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl);
|
|
683 |
if(setTControl)
|
|
684 |
{
|
|
685 |
ReadTControl(aSection);
|
|
686 |
}
|
|
687 |
|
|
688 |
INFO_PRINTF1(_L("Moving files!"));
|
|
689 |
|
|
690 |
TBool dataOk = ETrue;
|
|
691 |
TPtrC fileFrom;
|
|
692 |
if (!GET_MANDATORY_STRING_PARAMETER(KFileFrom, aSection, fileFrom))
|
|
693 |
{
|
|
694 |
dataOk = EFalse;
|
|
695 |
}
|
|
696 |
|
|
697 |
TPtrC fileTo;
|
|
698 |
if (!GET_MANDATORY_STRING_PARAMETER(KFileTo, aSection, fileTo))
|
|
699 |
{
|
|
700 |
dataOk = EFalse;
|
|
701 |
}
|
|
702 |
TBool async;
|
|
703 |
if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
|
|
704 |
{
|
|
705 |
dataOk = EFalse;
|
|
706 |
}
|
|
707 |
TUint operation;
|
|
708 |
if (!GetOperationFromConfig(KOperation, aSection, operation))
|
|
709 |
{
|
|
710 |
dataOk = EFalse;
|
|
711 |
}
|
|
712 |
if(dataOk)
|
|
713 |
{
|
|
714 |
TInt error = KErrNone;
|
|
715 |
if(async)
|
|
716 |
{
|
|
717 |
CActiveCallback* active = CActiveCallback::NewLC(*this);
|
|
718 |
iMove.AppendL(active);
|
|
719 |
CleanupStack::Pop(active);
|
|
720 |
error = iFileMan->Move(fileFrom, fileTo, operation, active->iStatus);
|
|
721 |
if(error == KErrNone)
|
|
722 |
{
|
|
723 |
active->Activate(aAsyncErrorIndex);
|
|
724 |
iAsyncErrorIndex = aAsyncErrorIndex;
|
|
725 |
iAsyncCall = ETrue;
|
|
726 |
IncOutstanding();
|
|
727 |
}
|
|
728 |
}
|
|
729 |
else
|
|
730 |
{
|
|
731 |
error = iFileMan->Move(fileFrom, fileTo, operation);
|
|
732 |
}
|
|
733 |
if (error != KErrNone)
|
|
734 |
{
|
|
735 |
ERR_PRINTF2(_L("Move(), Error: %d"), error);
|
|
736 |
SetError(error);
|
|
737 |
}
|
|
738 |
else
|
|
739 |
{
|
|
740 |
INFO_PRINTF1(_L("Move() operation is successfully!"));
|
|
741 |
}
|
|
742 |
}
|
|
743 |
}
|
|
744 |
|
|
745 |
void CT_FileManData::DoCmdRenameL(const TDesC& aSection, TInt aAsyncErrorIndex)
|
|
746 |
{
|
|
747 |
TBool clearHistory = EFalse;
|
|
748 |
GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory);
|
|
749 |
if(clearHistory)
|
|
750 |
{
|
|
751 |
ClearHistory();
|
|
752 |
}
|
|
753 |
TBool setTControl = EFalse;
|
|
754 |
GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl);
|
|
755 |
if(setTControl)
|
|
756 |
{
|
|
757 |
ReadTControl(aSection);
|
|
758 |
}
|
|
759 |
INFO_PRINTF1(_L("Renaming files!"));
|
|
760 |
|
|
761 |
TBool dataOk = ETrue;
|
|
762 |
|
|
763 |
//Reading Old Name
|
|
764 |
TPtrC oldName;
|
|
765 |
if (!GET_MANDATORY_STRING_PARAMETER(KOldName, aSection, oldName))
|
|
766 |
{
|
|
767 |
dataOk = EFalse;
|
|
768 |
}
|
|
769 |
|
|
770 |
//Reading New Name
|
|
771 |
TPtrC newName;
|
|
772 |
if (!GET_MANDATORY_STRING_PARAMETER(KNewName, aSection, newName))
|
|
773 |
{
|
|
774 |
dataOk = EFalse;
|
|
775 |
}
|
|
776 |
|
|
777 |
//Rading TSwitch - Operation
|
|
778 |
TUint operation;
|
|
779 |
if (!GetOperationFromConfig(KOperation(), aSection, operation))
|
|
780 |
{
|
|
781 |
dataOk = EFalse;
|
|
782 |
}
|
|
783 |
//Reading async
|
|
784 |
TBool async;
|
|
785 |
if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
|
|
786 |
{
|
|
787 |
dataOk = EFalse;
|
|
788 |
}
|
|
789 |
if(dataOk)
|
|
790 |
{
|
|
791 |
TInt error = KErrNone;
|
|
792 |
if(async)
|
|
793 |
{
|
|
794 |
CActiveCallback* active = CActiveCallback::NewLC(*this);
|
|
795 |
iRename.AppendL(active);
|
|
796 |
CleanupStack::Pop(active);
|
|
797 |
error = iFileMan->Rename(oldName, newName, operation, active->iStatus);
|
|
798 |
if(error == KErrNone)
|
|
799 |
{
|
|
800 |
active->Activate(aAsyncErrorIndex);
|
|
801 |
iAsyncErrorIndex = aAsyncErrorIndex;
|
|
802 |
iAsyncCall = ETrue;
|
|
803 |
IncOutstanding();
|
|
804 |
}
|
|
805 |
}
|
|
806 |
else
|
|
807 |
{
|
|
808 |
error = iFileMan->Rename(oldName, newName, operation);
|
|
809 |
}
|
|
810 |
if (error != KErrNone)
|
|
811 |
{
|
|
812 |
ERR_PRINTF2(_L("Rename() Error: %d"), error);
|
|
813 |
SetError(error);
|
|
814 |
}
|
|
815 |
else
|
|
816 |
{
|
|
817 |
INFO_PRINTF1(_L("Rename() operation is successfully!"));
|
|
818 |
}
|
|
819 |
}
|
|
820 |
}
|
|
821 |
|
|
822 |
void CT_FileManData::DoCmdRmDirL(const TDesC& aSection, TInt aAsyncErrorIndex)
|
|
823 |
{
|
|
824 |
INFO_PRINTF1(_L("Removing directory!"));
|
|
825 |
|
|
826 |
TBool dataOk = ETrue;
|
|
827 |
TPtrC path;
|
|
828 |
|
|
829 |
if (!GET_MANDATORY_STRING_PARAMETER(KPath, aSection, path))
|
|
830 |
{
|
|
831 |
dataOk = EFalse;
|
|
832 |
}
|
|
833 |
|
|
834 |
TBool async = EFalse;
|
|
835 |
if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
|
|
836 |
{
|
|
837 |
dataOk = EFalse;
|
|
838 |
}
|
|
839 |
|
|
840 |
if(dataOk)
|
|
841 |
{
|
|
842 |
TInt error = KErrNone;
|
|
843 |
if(async)
|
|
844 |
{
|
|
845 |
CActiveCallback* active = CActiveCallback::NewLC(*this);
|
|
846 |
iRmDir.AppendL(active);
|
|
847 |
CleanupStack::Pop(active);
|
|
848 |
error = iFileMan->RmDir(path, active->iStatus);
|
|
849 |
if(error == KErrNone)
|
|
850 |
{
|
|
851 |
active->Activate(aAsyncErrorIndex);
|
|
852 |
iAsyncErrorIndex = aAsyncErrorIndex;
|
|
853 |
iAsyncCall = ETrue;
|
|
854 |
IncOutstanding();
|
|
855 |
}
|
|
856 |
}
|
|
857 |
else
|
|
858 |
{
|
|
859 |
error = iFileMan->RmDir(path);
|
|
860 |
}
|
|
861 |
if (error != KErrNone)
|
|
862 |
{
|
|
863 |
ERR_PRINTF3(_L("RmDir(%S), Error: %d"), &path, error);
|
|
864 |
SetError(error);
|
|
865 |
}
|
|
866 |
else
|
|
867 |
{
|
|
868 |
INFO_PRINTF2(_L("Callled RmDir(%S)"), &path);
|
|
869 |
}
|
|
870 |
}
|
|
871 |
}
|
|
872 |
|
|
873 |
void CT_FileManData::DoCmdSetObserver()
|
|
874 |
{
|
|
875 |
INFO_PRINTF1(_L("Setting observer"));
|
|
876 |
|
|
877 |
iFileMan->SetObserver(this);
|
|
878 |
}
|
|
879 |
|
|
880 |
void CT_FileManData::DoCmdCurrentAction(const TDesC& aSection)
|
|
881 |
{
|
|
882 |
TBool readHistory = EFalse;
|
|
883 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
884 |
CFileMan::TAction currentAction = CFileMan::ENone;
|
|
885 |
TBool found = ETrue;
|
|
886 |
if(readHistory)
|
|
887 |
{
|
|
888 |
/** Get needed history array **/
|
|
889 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
890 |
if(history)
|
|
891 |
{
|
|
892 |
CFileMan::TAction expectedAction;
|
|
893 |
found = EFalse;
|
|
894 |
if(GetActionFromConfig(KCurrentAction(), aSection, expectedAction))
|
|
895 |
{
|
|
896 |
CFileMan::TAction action;
|
|
897 |
TInt count = history->Count();
|
|
898 |
/** Search for expected TAction in history **/
|
|
899 |
for(TInt i = 0; (i < count) && (!found); i++)
|
|
900 |
{
|
|
901 |
action = ((*history)[i])->iCurrentAction;
|
|
902 |
if( action == expectedAction)
|
|
903 |
{
|
|
904 |
currentAction = action;
|
|
905 |
found = ETrue;
|
|
906 |
}
|
|
907 |
}
|
|
908 |
if(!found)
|
|
909 |
{
|
|
910 |
TPtrC expectedActionStr;
|
|
911 |
ConvertActionToString(expectedAction, expectedActionStr);
|
|
912 |
ERR_PRINTF2(_L("CurrentAction() %S not found in history!"), &expectedActionStr);
|
|
913 |
SetBlockResult(EFail);
|
|
914 |
}
|
|
915 |
}
|
|
916 |
else
|
|
917 |
{
|
|
918 |
ERR_PRINTF2(_L("Cannot read %S"), &KCurrentAction());
|
|
919 |
SetBlockResult(EFail);
|
|
920 |
}
|
|
921 |
}
|
|
922 |
}
|
|
923 |
else
|
|
924 |
{
|
|
925 |
currentAction = iFileMan->CurrentAction();
|
|
926 |
}
|
|
927 |
|
|
928 |
if(found)
|
|
929 |
{
|
|
930 |
TPtrC actionStr;
|
|
931 |
ConvertActionToString(currentAction, actionStr);
|
|
932 |
|
|
933 |
CFileMan::TAction expectedAction;
|
|
934 |
if(GetActionFromConfig(KCurrentAction(), aSection, expectedAction))
|
|
935 |
{
|
|
936 |
TPtrC expectedActionStr;
|
|
937 |
ConvertActionToString(expectedAction, expectedActionStr);
|
|
938 |
if(expectedAction != currentAction)
|
|
939 |
{
|
|
940 |
ERR_PRINTF3(_L("CurrentAction(): %S != %S Expected Action"), &actionStr, &expectedActionStr);
|
|
941 |
SetBlockResult(EFail);
|
|
942 |
}
|
|
943 |
else
|
|
944 |
{
|
|
945 |
INFO_PRINTF3(_L("CurrentAction(): %S == %S Expected Action"), &actionStr, &expectedActionStr);
|
|
946 |
}
|
|
947 |
}
|
|
948 |
else
|
|
949 |
{
|
|
950 |
INFO_PRINTF2(_L("CurrentAction: %S"), &actionStr);
|
|
951 |
}
|
|
952 |
}
|
|
953 |
}
|
|
954 |
|
|
955 |
void CT_FileManData::DoCmdGetCurrentTarget(const TDesC& aSection)
|
|
956 |
{
|
|
957 |
TBool readHistory = EFalse;
|
|
958 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
959 |
TFileName target;
|
|
960 |
TBool found = ETrue;
|
|
961 |
if(readHistory)
|
|
962 |
{
|
|
963 |
/** Get needed history array **/
|
|
964 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
965 |
if(history)
|
|
966 |
{
|
|
967 |
TPtrC expectedTarget;
|
|
968 |
found = EFalse;
|
|
969 |
if(GET_MANDATORY_STRING_PARAMETER(KTarget, aSection, expectedTarget))
|
|
970 |
{
|
|
971 |
TInt count = history->Count();
|
|
972 |
/** Search for expected target in history **/
|
|
973 |
for(TInt i = 0; (!found) && (i < count); i++)
|
|
974 |
{
|
|
975 |
if( ((*history)[i])->iCurrentTarget == expectedTarget)
|
|
976 |
{
|
|
977 |
target = ((*history)[i])->iCurrentTarget;
|
|
978 |
found = ETrue;
|
|
979 |
}
|
|
980 |
}
|
|
981 |
if(!found)
|
|
982 |
{
|
|
983 |
ERR_PRINTF2(_L("GetCurrentTarget() %S not found in history!"), &expectedTarget);
|
|
984 |
SetBlockResult(EFail);
|
|
985 |
}
|
|
986 |
}
|
|
987 |
}
|
|
988 |
}
|
|
989 |
else
|
|
990 |
{
|
|
991 |
iFileMan->GetCurrentTarget(target);
|
|
992 |
}
|
|
993 |
if(found)
|
|
994 |
{
|
|
995 |
TPtrC expectedTarget;
|
|
996 |
if(GET_OPTIONAL_STRING_PARAMETER(KTarget, aSection, expectedTarget))
|
|
997 |
{
|
|
998 |
if(target == expectedTarget)
|
|
999 |
{
|
|
1000 |
INFO_PRINTF3(_L("GetCurrentTarget() %S == %S ExpectedResult"), &target, &expectedTarget);
|
|
1001 |
}
|
|
1002 |
else
|
|
1003 |
{
|
|
1004 |
ERR_PRINTF3(_L("GetCurrentTarget() %S != %S ExpectedResult"), &target, &expectedTarget);
|
|
1005 |
SetBlockResult(EFail);
|
|
1006 |
}
|
|
1007 |
|
|
1008 |
}
|
|
1009 |
else
|
|
1010 |
{
|
|
1011 |
INFO_PRINTF2(_L("GetCurrentTarget() %S"), &target);
|
|
1012 |
}
|
|
1013 |
}
|
|
1014 |
}
|
|
1015 |
void CT_FileManData::DoCmdGetCurrentSource(const TDesC& aSection)
|
|
1016 |
{
|
|
1017 |
TBool readHistory = EFalse;
|
|
1018 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
1019 |
TFileName source;
|
|
1020 |
TBool found = ETrue;
|
|
1021 |
if(readHistory)
|
|
1022 |
{
|
|
1023 |
/** Get needed history array **/
|
|
1024 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
1025 |
if(history)
|
|
1026 |
{
|
|
1027 |
TPtrC expectedSource;
|
|
1028 |
found = EFalse;
|
|
1029 |
if(GET_MANDATORY_STRING_PARAMETER(KSource, aSection, expectedSource))
|
|
1030 |
{
|
|
1031 |
TInt count = history->Count();
|
|
1032 |
/** Search for expected source in history **/
|
|
1033 |
for(TInt i = 0; (!found) && (i < count); i++)
|
|
1034 |
{
|
|
1035 |
if( (*history)[i]->iCurrentSource == expectedSource)
|
|
1036 |
{
|
|
1037 |
source = (*history)[i]->iCurrentSource;
|
|
1038 |
found = ETrue;
|
|
1039 |
}
|
|
1040 |
}
|
|
1041 |
if(!found)
|
|
1042 |
{
|
|
1043 |
ERR_PRINTF2(_L("GetCurrentSource() %S not found in history!"), &expectedSource);
|
|
1044 |
SetBlockResult(EFail);
|
|
1045 |
}
|
|
1046 |
}
|
|
1047 |
}
|
|
1048 |
}
|
|
1049 |
else
|
|
1050 |
{
|
|
1051 |
iFileMan->GetCurrentSource(source);
|
|
1052 |
}
|
|
1053 |
|
|
1054 |
if (found)
|
|
1055 |
{
|
|
1056 |
TPtrC expectedSource;
|
|
1057 |
if(GET_OPTIONAL_STRING_PARAMETER(KSource, aSection, expectedSource))
|
|
1058 |
{
|
|
1059 |
if(source == expectedSource)
|
|
1060 |
{
|
|
1061 |
INFO_PRINTF3(_L("GetCurrentSource() %S == %S ExpectedResult"), &source, &expectedSource);
|
|
1062 |
}
|
|
1063 |
else
|
|
1064 |
{
|
|
1065 |
ERR_PRINTF3(_L("GetCurrentSource() %S != %S ExpectedResult"), &source, &expectedSource);
|
|
1066 |
SetBlockResult(EFail);
|
|
1067 |
}
|
|
1068 |
|
|
1069 |
}
|
|
1070 |
else
|
|
1071 |
{
|
|
1072 |
INFO_PRINTF2(_L("GetCurrentSource() %S"), &source);
|
|
1073 |
}
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
}
|
|
1077 |
void CT_FileManData::DoCmdBytesTransferredByCopyStep(const TDesC& aSection)
|
|
1078 |
{
|
|
1079 |
TBool readHistory = EFalse;
|
|
1080 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
1081 |
TInt bytes = 0;
|
|
1082 |
TBool found = ETrue;
|
|
1083 |
if(readHistory)
|
|
1084 |
{
|
|
1085 |
/** Get needed history array **/
|
|
1086 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
1087 |
if(history)
|
|
1088 |
{
|
|
1089 |
TInt expectedBytes;
|
|
1090 |
found = EFalse;
|
|
1091 |
if(GET_MANDATORY_INT_PARAMETER(KBytes, aSection, expectedBytes))
|
|
1092 |
{
|
|
1093 |
TBool totalBytes = EFalse;
|
|
1094 |
GET_OPTIONAL_BOOL_PARAMETER(KTotalBytes, aSection, totalBytes);
|
|
1095 |
TInt count = history->Count();
|
|
1096 |
TInt bytesTemp;
|
|
1097 |
/** Search for expected transferred bytes in history **/
|
|
1098 |
for(TInt i = 0; (!found) && (i < count); i++)
|
|
1099 |
{
|
|
1100 |
bytesTemp = ((*history)[i])->iBytesTransferred;
|
|
1101 |
if(totalBytes)
|
|
1102 |
{
|
|
1103 |
bytes +=bytesTemp;
|
|
1104 |
}
|
|
1105 |
else
|
|
1106 |
{
|
|
1107 |
if( bytesTemp == expectedBytes)
|
|
1108 |
{
|
|
1109 |
bytes = bytesTemp;
|
|
1110 |
found = ETrue;
|
|
1111 |
}
|
|
1112 |
}
|
|
1113 |
}
|
|
1114 |
if(totalBytes)
|
|
1115 |
{
|
|
1116 |
found = ETrue;
|
|
1117 |
}
|
|
1118 |
if(!found)
|
|
1119 |
{
|
|
1120 |
ERR_PRINTF2(_L("BytesTransferredByCopyStep() %d not found in history!"), expectedBytes);
|
|
1121 |
SetBlockResult(EFail);
|
|
1122 |
}
|
|
1123 |
}
|
|
1124 |
}
|
|
1125 |
}
|
|
1126 |
else
|
|
1127 |
{
|
|
1128 |
bytes = iFileMan->BytesTransferredByCopyStep();
|
|
1129 |
}
|
|
1130 |
if (found)
|
|
1131 |
{
|
|
1132 |
TInt expectedBytes;
|
|
1133 |
if(GET_OPTIONAL_INT_PARAMETER(KBytes, aSection, expectedBytes))
|
|
1134 |
{
|
|
1135 |
if(expectedBytes != bytes)
|
|
1136 |
{
|
|
1137 |
ERR_PRINTF3(_L("BytesTransferredByCopyStep(): %d != %d Expected Bytes"), bytes, expectedBytes);
|
|
1138 |
SetBlockResult(EFail);
|
|
1139 |
}
|
|
1140 |
else
|
|
1141 |
{
|
|
1142 |
INFO_PRINTF3(_L("BytesTransferredByCopyStep(): %d == %d Expected Bytes"), bytes, expectedBytes);
|
|
1143 |
}
|
|
1144 |
}
|
|
1145 |
else
|
|
1146 |
{
|
|
1147 |
INFO_PRINTF2(_L("BytesTransferredByCopyStep(): %d"), bytes);
|
|
1148 |
}
|
|
1149 |
}
|
|
1150 |
}
|
|
1151 |
void CT_FileManData::DoCmdCurrentEntryL(const TDesC& aSection)
|
|
1152 |
{
|
|
1153 |
|
|
1154 |
TEntry* entryObject = NULL;
|
|
1155 |
TBool found = ETrue;
|
|
1156 |
TBool readHistory = EFalse;
|
|
1157 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
1158 |
if(readHistory)
|
|
1159 |
{
|
|
1160 |
/** Get needed history array **/
|
|
1161 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
1162 |
if(history)
|
|
1163 |
{
|
|
1164 |
TPtrC expectedName;
|
|
1165 |
found = EFalse;
|
|
1166 |
if(GET_MANDATORY_STRING_PARAMETER(KName, aSection, expectedName))
|
|
1167 |
{
|
|
1168 |
TInt count = history->Count();
|
|
1169 |
TEntry entry;
|
|
1170 |
/** Search for expected TEntry.iName in history **/
|
|
1171 |
for(TInt i = 0; (!found) && (i < count); i++)
|
|
1172 |
{
|
|
1173 |
entry = ((*history)[i])->iCurrentEntry;
|
|
1174 |
if( entry.iName == expectedName)
|
|
1175 |
{
|
|
1176 |
entryObject = &entry;
|
|
1177 |
found = ETrue;
|
|
1178 |
}
|
|
1179 |
}
|
|
1180 |
if(!found)
|
|
1181 |
{
|
|
1182 |
ERR_PRINTF1(_L("CurrentEntry() not found in history!"));
|
|
1183 |
SetBlockResult(EFail);
|
|
1184 |
}
|
|
1185 |
}
|
|
1186 |
}
|
|
1187 |
}
|
|
1188 |
else
|
|
1189 |
{
|
|
1190 |
*entryObject = iFileMan->CurrentEntry();
|
|
1191 |
}
|
|
1192 |
if(found)
|
|
1193 |
{
|
|
1194 |
if(!FileserverUtil::VerifyTEntryDataFromIniL(*this, aSection, *entryObject))
|
|
1195 |
{
|
|
1196 |
SetBlockResult(EFail);
|
|
1197 |
}
|
|
1198 |
}
|
|
1199 |
|
|
1200 |
}
|
|
1201 |
void CT_FileManData::DoCmdAbbreviatedPath(const TDesC& aSection)
|
|
1202 |
{
|
|
1203 |
TBool readHistory = EFalse;
|
|
1204 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
1205 |
TPtrC path;
|
|
1206 |
TBool found = ETrue;
|
|
1207 |
if(readHistory)
|
|
1208 |
{
|
|
1209 |
/** Get needed history array **/
|
|
1210 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
1211 |
if(history)
|
|
1212 |
{
|
|
1213 |
TPtrC expectedPath;
|
|
1214 |
found = EFalse;
|
|
1215 |
if(GET_MANDATORY_STRING_PARAMETER(KPath, aSection, expectedPath))
|
|
1216 |
{
|
|
1217 |
TInt count = history->Count();
|
|
1218 |
/** Search for expected abbreviated path in history **/
|
|
1219 |
for(TInt i = 0; (!found) && (i < count); i++)
|
|
1220 |
{
|
|
1221 |
if( ((*history)[i])->iAbbreviatedPath == expectedPath)
|
|
1222 |
{
|
|
1223 |
path.Set(((*history)[i])->iAbbreviatedPath);
|
|
1224 |
found = ETrue;
|
|
1225 |
}
|
|
1226 |
}
|
|
1227 |
if(!found)
|
|
1228 |
{
|
|
1229 |
ERR_PRINTF2(_L("AbbreviatedPath() %S not found in history!"), &expectedPath);
|
|
1230 |
SetBlockResult(EFail);
|
|
1231 |
}
|
|
1232 |
}
|
|
1233 |
}
|
|
1234 |
}
|
|
1235 |
else
|
|
1236 |
{
|
|
1237 |
path.Set(iFileMan->AbbreviatedPath());
|
|
1238 |
}
|
|
1239 |
|
|
1240 |
if (found)
|
|
1241 |
{
|
|
1242 |
TPtrC expectedPath;
|
|
1243 |
if(GET_OPTIONAL_STRING_PARAMETER(KPath, aSection, expectedPath))
|
|
1244 |
{
|
|
1245 |
if(expectedPath.Compare(path) != 0)
|
|
1246 |
{
|
|
1247 |
ERR_PRINTF3(_L("AbbreviatedPath(): %S != %S Expected Path"), &path, &expectedPath);
|
|
1248 |
SetBlockResult(EFail);
|
|
1249 |
}
|
|
1250 |
else
|
|
1251 |
{
|
|
1252 |
INFO_PRINTF3(_L("AbbreviatedPath(): %S == %S Expected Path"), &path, &expectedPath);
|
|
1253 |
}
|
|
1254 |
}
|
|
1255 |
else
|
|
1256 |
{
|
|
1257 |
INFO_PRINTF2(_L("AbbreviatedPath(): %S"), &path);
|
|
1258 |
}
|
|
1259 |
}
|
|
1260 |
}
|
|
1261 |
void CT_FileManData::DoCmdFullPath(const TDesC& aSection)
|
|
1262 |
{
|
|
1263 |
TBool readHistory = EFalse;
|
|
1264 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
1265 |
TPtrC fullPath;
|
|
1266 |
TBool found = ETrue;
|
|
1267 |
if(readHistory)
|
|
1268 |
{
|
|
1269 |
/** Get needed history array **/
|
|
1270 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
1271 |
if(history)
|
|
1272 |
{
|
|
1273 |
TPtrC expectedPath;
|
|
1274 |
found = EFalse;
|
|
1275 |
if(GET_MANDATORY_STRING_PARAMETER(KPath, aSection, expectedPath))
|
|
1276 |
{
|
|
1277 |
TInt count = history->Count();
|
|
1278 |
/** Search for expected full path in history **/
|
|
1279 |
for(TInt i = 0; (!found) && (i < count); i++)
|
|
1280 |
{
|
|
1281 |
if( ((*history)[i])->iFullPath == expectedPath)
|
|
1282 |
{
|
|
1283 |
fullPath.Set(((*history)[i])->iFullPath);
|
|
1284 |
found = ETrue;
|
|
1285 |
}
|
|
1286 |
}
|
|
1287 |
if(!found)
|
|
1288 |
{
|
|
1289 |
ERR_PRINTF2(_L("FullPath() %S not found in history!"), &expectedPath);
|
|
1290 |
SetBlockResult(EFail);
|
|
1291 |
}
|
|
1292 |
}
|
|
1293 |
}
|
|
1294 |
}
|
|
1295 |
else
|
|
1296 |
{
|
|
1297 |
fullPath.Set(iFileMan->FullPath());
|
|
1298 |
}
|
|
1299 |
if(found)
|
|
1300 |
{
|
|
1301 |
TPtrC expectedPath;
|
|
1302 |
if(GET_OPTIONAL_STRING_PARAMETER(KPath, aSection, expectedPath))
|
|
1303 |
{
|
|
1304 |
if(expectedPath.Compare(fullPath) != 0)
|
|
1305 |
{
|
|
1306 |
ERR_PRINTF3(_L("FullPath(): %S != %S Expected Path"), &fullPath, &expectedPath);
|
|
1307 |
SetBlockResult(EFail);
|
|
1308 |
}
|
|
1309 |
else
|
|
1310 |
{
|
|
1311 |
INFO_PRINTF3(_L("FullPath(): %S == %S Expected Path"), &fullPath, &expectedPath);
|
|
1312 |
}
|
|
1313 |
}
|
|
1314 |
else
|
|
1315 |
{
|
|
1316 |
INFO_PRINTF2(_L("FullPath(): %S"), &fullPath);
|
|
1317 |
}
|
|
1318 |
}
|
|
1319 |
}
|
|
1320 |
void CT_FileManData::DoCmdGetLastError(const TDesC& aSection)
|
|
1321 |
{
|
|
1322 |
TBool readHistory = EFalse;
|
|
1323 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
1324 |
TInt lastError = KErrNone;
|
|
1325 |
TBool found = ETrue;
|
|
1326 |
if(readHistory)
|
|
1327 |
{
|
|
1328 |
/** Get needed history array **/
|
|
1329 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
1330 |
if(history)
|
|
1331 |
{
|
|
1332 |
TInt expectedError;
|
|
1333 |
found = EFalse;
|
|
1334 |
if(GET_MANDATORY_INT_PARAMETER(KError, aSection, expectedError))
|
|
1335 |
{
|
|
1336 |
TInt count = history->Count();
|
|
1337 |
TInt err;
|
|
1338 |
/** Search for expected error in history **/
|
|
1339 |
for(TInt i = 0; (!found) && (i < count); i++)
|
|
1340 |
{
|
|
1341 |
err = (*history)[i]->iLastError;
|
|
1342 |
if( err == expectedError)
|
|
1343 |
{
|
|
1344 |
lastError = err;
|
|
1345 |
found = ETrue;
|
|
1346 |
}
|
|
1347 |
}
|
|
1348 |
if(!found)
|
|
1349 |
{
|
|
1350 |
ERR_PRINTF2(_L("GetLastError() %d not found in history!"), expectedError);
|
|
1351 |
SetBlockResult(EFail);
|
|
1352 |
}
|
|
1353 |
}
|
|
1354 |
}
|
|
1355 |
}
|
|
1356 |
else
|
|
1357 |
{
|
|
1358 |
lastError = iFileMan->GetLastError();
|
|
1359 |
}
|
|
1360 |
if (found)
|
|
1361 |
{
|
|
1362 |
TInt expectedError;
|
|
1363 |
if(GET_OPTIONAL_INT_PARAMETER(KError, aSection, expectedError))
|
|
1364 |
{
|
|
1365 |
if(expectedError != lastError)
|
|
1366 |
{
|
|
1367 |
ERR_PRINTF3(_L("GetLastError(): %d != %d Expected Error"), lastError, expectedError);
|
|
1368 |
SetBlockResult(EFail);
|
|
1369 |
}
|
|
1370 |
else
|
|
1371 |
{
|
|
1372 |
INFO_PRINTF3(_L("GetLastError(): %d == %d Expected Error"), lastError, expectedError);
|
|
1373 |
}
|
|
1374 |
}
|
|
1375 |
else
|
|
1376 |
{
|
|
1377 |
INFO_PRINTF2(_L("GetLastError(): %d"), lastError);
|
|
1378 |
}
|
|
1379 |
}
|
|
1380 |
}
|
|
1381 |
|
|
1382 |
void CT_FileManData::DoCmdGetMoreInfoAboutError(const TDesC& aSection)
|
|
1383 |
{
|
|
1384 |
TBool readHistory = EFalse;
|
|
1385 |
GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
|
|
1386 |
TFileManError lastError;
|
|
1387 |
TBool found = ETrue;
|
|
1388 |
if(readHistory)
|
|
1389 |
{
|
|
1390 |
/** Get needed history array **/
|
|
1391 |
RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
|
|
1392 |
if(history)
|
|
1393 |
{
|
|
1394 |
TFileManError expectedError;
|
|
1395 |
found = EFalse;
|
|
1396 |
if(GetFileManErrorFromConfig(KError, aSection, expectedError))
|
|
1397 |
{
|
|
1398 |
TInt count = history->Count();
|
|
1399 |
TFileManError error;
|
|
1400 |
/** Search for expected error in history **/
|
|
1401 |
for(TInt i = 0; (!found) && (i < count); i++)
|
|
1402 |
{
|
|
1403 |
error = (*history)[i]->iMoreInfoAboutError;
|
|
1404 |
if( (error == expectedError))
|
|
1405 |
{
|
|
1406 |
lastError = error;
|
|
1407 |
found = ETrue;
|
|
1408 |
}
|
|
1409 |
}
|
|
1410 |
if(!found)
|
|
1411 |
{
|
|
1412 |
ERR_PRINTF2(_L("GetMoreInfoAboutError() %S not found in history!"), expectedError);
|
|
1413 |
SetBlockResult(EFail);
|
|
1414 |
}
|
|
1415 |
}
|
|
1416 |
}
|
|
1417 |
}
|
|
1418 |
else
|
|
1419 |
{
|
|
1420 |
lastError = iFileMan->GetMoreInfoAboutError();
|
|
1421 |
}
|
|
1422 |
if (found)
|
|
1423 |
{
|
|
1424 |
TPtrC errorStr;
|
|
1425 |
ConvertFileManErrorToString(lastError, errorStr);
|
|
1426 |
TFileManError expectedError;
|
|
1427 |
if(GetFileManErrorFromConfig(KError, aSection, expectedError))
|
|
1428 |
{
|
|
1429 |
TPtrC expectedErrorStr;
|
|
1430 |
ConvertFileManErrorToString(expectedError, expectedErrorStr);
|
|
1431 |
|
|
1432 |
if(expectedError != lastError)
|
|
1433 |
{
|
|
1434 |
ERR_PRINTF3(_L("GetMoreInfoAboutError(): %S != %S Expected Error"), &errorStr, &expectedErrorStr);
|
|
1435 |
SetBlockResult(EFail);
|
|
1436 |
}
|
|
1437 |
else
|
|
1438 |
{
|
|
1439 |
INFO_PRINTF3(_L("GetMoreInfoAboutError(): %S == %S Expected Error"), &errorStr, &expectedErrorStr);
|
|
1440 |
}
|
|
1441 |
}
|
|
1442 |
else
|
|
1443 |
{
|
|
1444 |
INFO_PRINTF2(_L("GetMoreInfoAboutError(): %S"), &errorStr);
|
|
1445 |
}
|
|
1446 |
}
|
|
1447 |
|
|
1448 |
}
|
|
1449 |
void CT_FileManData::RunL(CActive* aActive, TInt aIndex)
|
|
1450 |
/**
|
|
1451 |
Virtual RunL - Called on completion of an asynchronous command
|
|
1452 |
@internalComponent
|
|
1453 |
@see MActiveCallback
|
|
1454 |
@param aActive Active Object that RunL has been called on
|
|
1455 |
@pre N/A
|
|
1456 |
@post N/A
|
|
1457 |
@leave system wide error code
|
|
1458 |
*/
|
|
1459 |
{
|
|
1460 |
INFO_PRINTF1(_L("CT_FileManData::RunL Called"));
|
|
1461 |
TBool foundActiveObject = EFalse;
|
|
1462 |
TInt index=0;
|
|
1463 |
TInt count=0;
|
|
1464 |
TBool completed=ETrue;
|
|
1465 |
|
|
1466 |
count = iAttribs.Count();
|
|
1467 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1468 |
{
|
|
1469 |
if( aActive == iAttribs[index] )
|
|
1470 |
{
|
|
1471 |
INFO_PRINTF1(_L("RunL iAttribs called"));
|
|
1472 |
foundActiveObject = ETrue;
|
|
1473 |
iAttribs.Remove(index);
|
|
1474 |
}
|
|
1475 |
}
|
|
1476 |
|
|
1477 |
count = iCopy.Count();
|
|
1478 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1479 |
{
|
|
1480 |
if( aActive == iCopy[index] )
|
|
1481 |
{
|
|
1482 |
INFO_PRINTF1(_L("RunL iCopy called"));
|
|
1483 |
foundActiveObject = ETrue;
|
|
1484 |
iCopy.Remove(index);
|
|
1485 |
}
|
|
1486 |
}
|
|
1487 |
|
|
1488 |
count = iDelete.Count();
|
|
1489 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1490 |
{
|
|
1491 |
if( aActive == iDelete[index] )
|
|
1492 |
{
|
|
1493 |
INFO_PRINTF1(_L("RunL iDelete called"));
|
|
1494 |
foundActiveObject = ETrue;
|
|
1495 |
iDelete.Remove(index);
|
|
1496 |
}
|
|
1497 |
}
|
|
1498 |
|
|
1499 |
count = iMove.Count();
|
|
1500 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1501 |
{
|
|
1502 |
if( aActive == iMove[index] )
|
|
1503 |
{
|
|
1504 |
INFO_PRINTF1(_L("RunL iMove called"));
|
|
1505 |
foundActiveObject = ETrue;
|
|
1506 |
iMove.Remove(index);
|
|
1507 |
}
|
|
1508 |
}
|
|
1509 |
|
|
1510 |
count = iRename.Count();
|
|
1511 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1512 |
{
|
|
1513 |
if( aActive == iRename[index] )
|
|
1514 |
{
|
|
1515 |
INFO_PRINTF1(_L("RunL iRename called"));
|
|
1516 |
foundActiveObject = ETrue;
|
|
1517 |
iRename.Remove(index);
|
|
1518 |
}
|
|
1519 |
}
|
|
1520 |
|
|
1521 |
count = iRmDir.Count();
|
|
1522 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1523 |
{
|
|
1524 |
if( aActive == iRmDir[index] )
|
|
1525 |
{
|
|
1526 |
INFO_PRINTF1(_L("RunL iRmDir called"));
|
|
1527 |
foundActiveObject = ETrue;
|
|
1528 |
iRmDir.Remove(index);
|
|
1529 |
}
|
|
1530 |
}
|
|
1531 |
|
|
1532 |
if( foundActiveObject )
|
|
1533 |
{
|
|
1534 |
TInt err = aActive->iStatus.Int();
|
|
1535 |
if( err != KErrNone )
|
|
1536 |
{
|
|
1537 |
ERR_PRINTF2(_L("RunL Error %d"), err);
|
|
1538 |
SetAsyncError( aIndex, err );
|
|
1539 |
iAsyncCall = EFalse;
|
|
1540 |
}
|
|
1541 |
|
|
1542 |
if ( completed )
|
|
1543 |
{
|
|
1544 |
// Reset the outstanding request state
|
|
1545 |
DecOutstanding();
|
|
1546 |
delete aActive;
|
|
1547 |
}
|
|
1548 |
}
|
|
1549 |
else
|
|
1550 |
{
|
|
1551 |
ERR_PRINTF1(_L("Stray RunL signal"));
|
|
1552 |
SetBlockResult(EFail);
|
|
1553 |
}
|
|
1554 |
}
|
|
1555 |
|
|
1556 |
|
|
1557 |
void CT_FileManData::DoCancel(CActive* aActive, TInt aIndex)
|
|
1558 |
/**
|
|
1559 |
Virtual DoCancel - Request to cancel the asynchronous command
|
|
1560 |
@internalComponent
|
|
1561 |
@see - MActiveCallback
|
|
1562 |
@param aActive Active Object that DoCancel has been called on
|
|
1563 |
@pre - N/A
|
|
1564 |
@post - N/A
|
|
1565 |
@leave system wide error code
|
|
1566 |
*/
|
|
1567 |
{
|
|
1568 |
INFO_PRINTF1(_L("CT_FileManData::DoCancelL Called"));
|
|
1569 |
|
|
1570 |
TBool foundActiveObject = EFalse;
|
|
1571 |
TInt index=0;
|
|
1572 |
TInt count=0;
|
|
1573 |
|
|
1574 |
|
|
1575 |
// See if it is in iAttribs
|
|
1576 |
count = iAttribs.Count();
|
|
1577 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1578 |
{
|
|
1579 |
if( aActive == iAttribs[index] )
|
|
1580 |
{
|
|
1581 |
INFO_PRINTF1(_L("DoCancel iAttribs called"));
|
|
1582 |
foundActiveObject = ETrue;
|
|
1583 |
iAttribs.Remove(index);
|
|
1584 |
}
|
|
1585 |
}
|
|
1586 |
|
|
1587 |
// See if it is in iCopy2
|
|
1588 |
count = iCopy.Count();
|
|
1589 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1590 |
{
|
|
1591 |
if( aActive == iCopy[index] )
|
|
1592 |
{
|
|
1593 |
INFO_PRINTF1(_L("DoCancel iCopy called"));
|
|
1594 |
foundActiveObject = ETrue;
|
|
1595 |
iCopy.Remove(index);
|
|
1596 |
}
|
|
1597 |
}
|
|
1598 |
|
|
1599 |
// See if it is in iDelete
|
|
1600 |
count = iDelete.Count();
|
|
1601 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1602 |
{
|
|
1603 |
if( aActive == iDelete[index] )
|
|
1604 |
{
|
|
1605 |
INFO_PRINTF1(_L("DoCancel iDelete called"));
|
|
1606 |
foundActiveObject = ETrue;
|
|
1607 |
iDelete.Remove(index);
|
|
1608 |
}
|
|
1609 |
}
|
|
1610 |
|
|
1611 |
// See if it is in iMove
|
|
1612 |
count = iMove.Count();
|
|
1613 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1614 |
{
|
|
1615 |
if( aActive == iMove[index] )
|
|
1616 |
{
|
|
1617 |
INFO_PRINTF1(_L("DoCancel iMove called"));
|
|
1618 |
foundActiveObject = ETrue;
|
|
1619 |
iMove.Remove(index);
|
|
1620 |
}
|
|
1621 |
}
|
|
1622 |
|
|
1623 |
// See if it is in iRename
|
|
1624 |
count = iRename.Count();
|
|
1625 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1626 |
{
|
|
1627 |
if( aActive == iRename[index] )
|
|
1628 |
{
|
|
1629 |
INFO_PRINTF1(_L("DoCancel iRename called"));
|
|
1630 |
foundActiveObject = ETrue;
|
|
1631 |
iRename.Remove(index);
|
|
1632 |
}
|
|
1633 |
}
|
|
1634 |
|
|
1635 |
// See if it is in iRmDir
|
|
1636 |
count = iRmDir.Count();
|
|
1637 |
for( index=0; (index<count) && (!foundActiveObject); ++index )
|
|
1638 |
{
|
|
1639 |
if( aActive == iRmDir[index] )
|
|
1640 |
{
|
|
1641 |
INFO_PRINTF1(_L("DoCancel iRmDir called"));
|
|
1642 |
foundActiveObject = ETrue;
|
|
1643 |
iRmDir.Remove(index);
|
|
1644 |
}
|
|
1645 |
}
|
|
1646 |
|
|
1647 |
if( foundActiveObject )
|
|
1648 |
{
|
|
1649 |
TInt err = aActive->iStatus.Int();
|
|
1650 |
if( err != KErrNone )
|
|
1651 |
{
|
|
1652 |
ERR_PRINTF2(_L("DoCancel Error %d"), err);
|
|
1653 |
SetAsyncError( aIndex, err );
|
|
1654 |
}
|
|
1655 |
|
|
1656 |
// Reset the outstanding request state
|
|
1657 |
DecOutstanding();
|
|
1658 |
|
|
1659 |
delete aActive;
|
|
1660 |
}
|
|
1661 |
else
|
|
1662 |
{
|
|
1663 |
ERR_PRINTF1(_L("Stray DoCancel signal"));
|
|
1664 |
SetBlockResult(EFail);
|
|
1665 |
}
|
|
1666 |
}
|
|
1667 |
|
|
1668 |
/** Reads TFileManError from INI and converts it to TFileManError type. **/
|
|
1669 |
TBool CT_FileManData::GetFileManErrorFromConfig(const TDesC& aParameterName, const TDesC& aSection, TFileManError& aError)
|
|
1670 |
{
|
|
1671 |
TPtrC errorStr;
|
|
1672 |
TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, errorStr);
|
|
1673 |
if(ret)
|
|
1674 |
{
|
|
1675 |
if(errorStr == KENoExtraInformation)
|
|
1676 |
{
|
|
1677 |
aError = ENoExtraInformation;
|
|
1678 |
}
|
|
1679 |
else if(errorStr == KEInitializationFailed)
|
|
1680 |
{
|
|
1681 |
aError = EInitializationFailed;
|
|
1682 |
}
|
|
1683 |
else if (errorStr == KEScanNextDirectoryFailed)
|
|
1684 |
{
|
|
1685 |
aError = EScanNextDirectoryFailed;
|
|
1686 |
}
|
|
1687 |
else if (errorStr == KESrcOpenFailed)
|
|
1688 |
{
|
|
1689 |
aError = ESrcOpenFailed;
|
|
1690 |
}
|
|
1691 |
else if (errorStr == KETrgOpenFailed)
|
|
1692 |
{
|
|
1693 |
aError = ETrgOpenFailed;
|
|
1694 |
}
|
|
1695 |
else if (errorStr == KENoFilesProcessed)
|
|
1696 |
{
|
|
1697 |
aError = ENoFilesProcessed;
|
|
1698 |
}
|
|
1699 |
else
|
|
1700 |
{
|
|
1701 |
ret = EFalse;
|
|
1702 |
}
|
|
1703 |
}
|
|
1704 |
return ret;
|
|
1705 |
}
|
|
1706 |
|
|
1707 |
/** Converts TFileManError type to string **/
|
|
1708 |
void CT_FileManData::ConvertFileManErrorToString(TFileManError& aError, TPtrC& aErrorStr)
|
|
1709 |
{
|
|
1710 |
if(aError == ENoExtraInformation)
|
|
1711 |
{
|
|
1712 |
aErrorStr.Set(KENoExtraInformation());
|
|
1713 |
}
|
|
1714 |
else if(aError == EInitializationFailed)
|
|
1715 |
{
|
|
1716 |
aErrorStr.Set(KEInitializationFailed());
|
|
1717 |
}
|
|
1718 |
else if (aError == EScanNextDirectoryFailed)
|
|
1719 |
{
|
|
1720 |
aErrorStr.Set(KEScanNextDirectoryFailed());
|
|
1721 |
}
|
|
1722 |
else if (aError == ESrcOpenFailed)
|
|
1723 |
{
|
|
1724 |
aErrorStr.Set(KESrcOpenFailed());
|
|
1725 |
}
|
|
1726 |
else if (aError == ETrgOpenFailed)
|
|
1727 |
{
|
|
1728 |
aErrorStr.Set(KETrgOpenFailed());
|
|
1729 |
}
|
|
1730 |
else if (aError == ENoFilesProcessed)
|
|
1731 |
{
|
|
1732 |
aErrorStr.Set(KENoFilesProcessed());
|
|
1733 |
}
|
|
1734 |
}
|
|
1735 |
|
|
1736 |
/** Converts CFileMan::TAction type to string **/
|
|
1737 |
void CT_FileManData::ConvertActionToString(CFileMan::TAction aAction, TPtrC& aActionStr)
|
|
1738 |
{
|
|
1739 |
if (aAction == CFileMan::EAttribs)
|
|
1740 |
{
|
|
1741 |
aActionStr.Set(KEAttribs());
|
|
1742 |
}
|
|
1743 |
else if (aAction == CFileMan::ECopy)
|
|
1744 |
{
|
|
1745 |
aActionStr.Set(KECopy());
|
|
1746 |
}
|
|
1747 |
else if (aAction == CFileMan::EDelete)
|
|
1748 |
{
|
|
1749 |
aActionStr.Set(KEDelete());
|
|
1750 |
}
|
|
1751 |
else if (aAction == CFileMan::EMove)
|
|
1752 |
{
|
|
1753 |
aActionStr.Set(KEMove());
|
|
1754 |
}
|
|
1755 |
else if (aAction == CFileMan::ERename)
|
|
1756 |
{
|
|
1757 |
aActionStr.Set(KERename());
|
|
1758 |
}
|
|
1759 |
else if (aAction == CFileMan::ERmDir)
|
|
1760 |
{
|
|
1761 |
aActionStr.Set(KERmDir());
|
|
1762 |
}
|
|
1763 |
else if (aAction == CFileMan::ERenameInvalidEntry)
|
|
1764 |
{
|
|
1765 |
aActionStr.Set(KERenameInvalidEntry());
|
|
1766 |
}
|
|
1767 |
else if (aAction == CFileMan::ECopyFromHandle)
|
|
1768 |
{
|
|
1769 |
aActionStr.Set(KECopyFromHandle());
|
|
1770 |
}
|
|
1771 |
else
|
|
1772 |
{
|
|
1773 |
aActionStr.Set(KENone());
|
|
1774 |
}
|
|
1775 |
|
|
1776 |
}
|
|
1777 |
|
|
1778 |
/** Reads CFileMan::TAction from INI and converts it to CFileMan::TAction type. **/
|
|
1779 |
TBool CT_FileManData::GetActionFromConfig(const TDesC& aParameterName, const TDesC& aSection, CFileMan::TAction& aAction)
|
|
1780 |
{
|
|
1781 |
TPtrC actionStr;
|
|
1782 |
TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, actionStr);
|
|
1783 |
if(ret)
|
|
1784 |
{
|
|
1785 |
if (actionStr == KEAttribs)
|
|
1786 |
{
|
|
1787 |
aAction = CFileMan::EAttribs;
|
|
1788 |
}
|
|
1789 |
else if (actionStr == KECopy)
|
|
1790 |
{
|
|
1791 |
aAction = CFileMan::ECopy;
|
|
1792 |
}
|
|
1793 |
else if (actionStr == KEDelete)
|
|
1794 |
{
|
|
1795 |
aAction = CFileMan::EDelete;
|
|
1796 |
}
|
|
1797 |
else if (actionStr == KEMove)
|
|
1798 |
{
|
|
1799 |
aAction = CFileMan::EMove;
|
|
1800 |
}
|
|
1801 |
else if (actionStr == KERename)
|
|
1802 |
{
|
|
1803 |
aAction = CFileMan::ERename;
|
|
1804 |
}
|
|
1805 |
else if (actionStr == KERmDir)
|
|
1806 |
{
|
|
1807 |
aAction = CFileMan::ERmDir;
|
|
1808 |
}
|
|
1809 |
else if (actionStr == KERenameInvalidEntry)
|
|
1810 |
{
|
|
1811 |
aAction = CFileMan::ERenameInvalidEntry;
|
|
1812 |
}
|
|
1813 |
else if (actionStr == KECopyFromHandle)
|
|
1814 |
{
|
|
1815 |
aAction = CFileMan::ECopyFromHandle;
|
|
1816 |
}
|
|
1817 |
else if (actionStr == KENone)
|
|
1818 |
{
|
|
1819 |
aAction = CFileMan::ENone;
|
|
1820 |
}
|
|
1821 |
else
|
|
1822 |
{
|
|
1823 |
ret = EFalse;
|
|
1824 |
}
|
|
1825 |
}
|
|
1826 |
return ret;
|
|
1827 |
}
|
|
1828 |
|
|
1829 |
/** Reads CFileMan::TSwitch from INI and converts it to CFileMan::TSwitch type. **/
|
|
1830 |
TBool CT_FileManData::GetOperationFromConfig(const TDesC& aParameterName, const TDesC& aSection, TUint& aSwitch)
|
|
1831 |
{
|
|
1832 |
TPtrC operation;
|
|
1833 |
TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, operation);
|
|
1834 |
if(ret)
|
|
1835 |
{
|
|
1836 |
if (operation == KEOverWrite)
|
|
1837 |
{
|
|
1838 |
aSwitch = CFileMan::EOverWrite;
|
|
1839 |
}
|
|
1840 |
else if (operation == KERecurse)
|
|
1841 |
{
|
|
1842 |
aSwitch = CFileMan::ERecurse;
|
|
1843 |
}
|
|
1844 |
else
|
|
1845 |
{
|
|
1846 |
TInt operationInt=0;
|
|
1847 |
ret = GET_MANDATORY_INT_PARAMETER(aParameterName, aSection, operationInt);
|
|
1848 |
if (ret)
|
|
1849 |
{
|
|
1850 |
aSwitch = (CFileMan::TSwitch) operationInt;
|
|
1851 |
}
|
|
1852 |
}
|
|
1853 |
}
|
|
1854 |
return ret;
|
|
1855 |
}
|
|
1856 |
|
|
1857 |
/** Clears all arrays with history **/
|
|
1858 |
void CT_FileManData::ClearHistory()
|
|
1859 |
{
|
|
1860 |
INFO_PRINTF1(_L("Clearing history!"));
|
|
1861 |
|
|
1862 |
iStartedHistory.ResetAndDestroy();
|
|
1863 |
iOperationHistory.ResetAndDestroy();
|
|
1864 |
iEndedHistory.ResetAndDestroy();
|
|
1865 |
}
|
|
1866 |
|
|
1867 |
/**
|
|
1868 |
* Creates a history entry.
|
|
1869 |
* This method runs only from NotifyFileManStarted(), NotifyFileManOperation(), NotifyFileManEnded().
|
|
1870 |
**/
|
|
1871 |
void CT_FileManData::CreateHistoryRecord(THistoryData& aRecord)
|
|
1872 |
{
|
|
1873 |
TFileName source;
|
|
1874 |
iFileMan->GetCurrentSource(source);
|
|
1875 |
aRecord.iCurrentSource = source;
|
|
1876 |
|
|
1877 |
TFileName target;
|
|
1878 |
iFileMan->GetCurrentTarget(target);
|
|
1879 |
aRecord.iCurrentTarget = target;
|
|
1880 |
|
|
1881 |
aRecord.iCurrentEntry = iFileMan->CurrentEntry();
|
|
1882 |
aRecord.iBytesTransferred = iFileMan->BytesTransferredByCopyStep();
|
|
1883 |
aRecord.iCurrentAction = iFileMan->CurrentAction();
|
|
1884 |
aRecord.iLastError = iFileMan->GetLastError();
|
|
1885 |
aRecord.iMoreInfoAboutError = iFileMan->GetMoreInfoAboutError();
|
|
1886 |
aRecord.iFullPath.Set( iFileMan->FullPath() );
|
|
1887 |
aRecord.iAbbreviatedPath.Set( iFileMan->AbbreviatedPath() );
|
|
1888 |
}
|
|
1889 |
|
|
1890 |
/** Reads type of notification from INI and converts it to TObserverNotifyType **/
|
|
1891 |
TBool CT_FileManData::GetNotifyType(const TDesC& aParameterName, const TDesC& aSection, TObserverNotifyType& aType)
|
|
1892 |
{
|
|
1893 |
TPtrC type;
|
|
1894 |
TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, type);
|
|
1895 |
if(ret)
|
|
1896 |
{
|
|
1897 |
if (type == KNotifyStarted)
|
|
1898 |
{
|
|
1899 |
aType = ENotifyStarted;
|
|
1900 |
}
|
|
1901 |
else if (type == KNotifyOperation)
|
|
1902 |
{
|
|
1903 |
aType = ENotifyOperation;
|
|
1904 |
}
|
|
1905 |
else if (type == KNotifyEnded)
|
|
1906 |
{
|
|
1907 |
aType = ENotifyEnded;
|
|
1908 |
}
|
|
1909 |
else
|
|
1910 |
{
|
|
1911 |
ret = EFalse;
|
|
1912 |
}
|
|
1913 |
}
|
|
1914 |
return ret;
|
|
1915 |
}
|
|
1916 |
|
|
1917 |
/** Returns specific array of history using TObserverNotifyType value **/
|
|
1918 |
RPointerArray<THistoryData>* CT_FileManData::GetHistoryDataByType(const TDesC& aSection)
|
|
1919 |
{
|
|
1920 |
TObserverNotifyType type;
|
|
1921 |
RPointerArray<THistoryData>* history = NULL;
|
|
1922 |
//Reads history name which must be returned.
|
|
1923 |
if (GetNotifyType(KNotifyType(), aSection, type))
|
|
1924 |
{
|
|
1925 |
if(type == ENotifyStarted)
|
|
1926 |
{
|
|
1927 |
history = (RPointerArray<THistoryData>*)&iStartedHistory;
|
|
1928 |
}
|
|
1929 |
else if(type == ENotifyOperation)
|
|
1930 |
{
|
|
1931 |
history = (RPointerArray<THistoryData>*)&iOperationHistory;
|
|
1932 |
}
|
|
1933 |
else if(type == ENotifyEnded)
|
|
1934 |
{
|
|
1935 |
history = (RPointerArray<THistoryData>*)&iEndedHistory;
|
|
1936 |
}
|
|
1937 |
}
|
|
1938 |
return history;
|
|
1939 |
}
|
|
1940 |
/** Reads TControl from config and converts it to TControl type **/
|
|
1941 |
TBool CT_FileManData::GetTControlFromConfig(const TDesC& aParameterName, const TDesC& aSection, TControl& aFlag)
|
|
1942 |
{
|
|
1943 |
TPtrC flag;
|
|
1944 |
TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, flag);
|
|
1945 |
if(ret)
|
|
1946 |
{
|
|
1947 |
if (flag == KEContinue)
|
|
1948 |
{
|
|
1949 |
aFlag = EContinue;
|
|
1950 |
}
|
|
1951 |
else if (flag == KEAbort)
|
|
1952 |
{
|
|
1953 |
aFlag = EAbort;
|
|
1954 |
}
|
|
1955 |
else if (flag == KECancel)
|
|
1956 |
{
|
|
1957 |
aFlag = ECancel;
|
|
1958 |
}
|
|
1959 |
else if (flag == KERetry)
|
|
1960 |
{
|
|
1961 |
aFlag = ERetry;
|
|
1962 |
}
|
|
1963 |
else
|
|
1964 |
{
|
|
1965 |
ret = EFalse;
|
|
1966 |
}
|
|
1967 |
}
|
|
1968 |
return ret;
|
|
1969 |
}
|
|
1970 |
|
|
1971 |
/** Reads TControl and file name from INI **/
|
|
1972 |
void CT_FileManData::ReadTControl(const TDesC& aSection)
|
|
1973 |
{
|
|
1974 |
TBool dataOk = ETrue;
|
|
1975 |
if(!GetNotifyType(KNotifyType(), aSection, iObserverNotifyType))
|
|
1976 |
{
|
|
1977 |
dataOk = EFalse;
|
|
1978 |
}
|
|
1979 |
TPtrC fileName;
|
|
1980 |
if(GET_MANDATORY_STRING_PARAMETER(KFileName(), aSection, fileName))
|
|
1981 |
{
|
|
1982 |
iNotifyFileName = fileName;
|
|
1983 |
}
|
|
1984 |
else
|
|
1985 |
{
|
|
1986 |
dataOk = EFalse;
|
|
1987 |
}
|
|
1988 |
if(!GetTControlFromConfig(KFlag(), aSection, iTControl))
|
|
1989 |
{
|
|
1990 |
dataOk = EFalse;
|
|
1991 |
}
|
|
1992 |
if(dataOk)
|
|
1993 |
{
|
|
1994 |
iUseTControl = ETrue;
|
|
1995 |
}
|
|
1996 |
}
|
|
1997 |
|
|
1998 |
|