1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_FileManData.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1999 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +/**
1.23 +@test
1.24 +@internalComponent
1.25 +
1.26 +This contains CT_FileManData
1.27 +*/
1.28 +
1.29 +// User includes
1.30 +#include "T_FileManData.h"
1.31 +#include "T_SfSrvServer.h"
1.32 +
1.33 +const TInt KMaxFileNameLength =255;
1.34 +
1.35 +/*@{*/
1.36 +/// Parameters
1.37 +_LIT(KPath, "path");
1.38 +_LIT(KFileName, "filename");
1.39 +_LIT(KFileFrom, "filefrom");
1.40 +_LIT(KFileTo, "fileto");
1.41 +_LIT(KOldName, "oldname");
1.42 +_LIT(KNewName, "newname");
1.43 +_LIT(KRFsObject, "rfsObject");
1.44 +_LIT(KRFileObject, "rfileObject");
1.45 +_LIT(KUseObserver, "use_observer");
1.46 +_LIT(KAsync, "async");
1.47 +_LIT(KTime, "time");
1.48 +_LIT(KSetMask, "setmask");
1.49 +_LIT(KClearMask, "clearmask");
1.50 +_LIT(KOperation, "operation");
1.51 +_LIT(KCurrentAction, "current_action");
1.52 +_LIT(KBytes, "bytes");
1.53 +_LIT(KError, "error");
1.54 +_LIT(KTarget, "target");
1.55 +_LIT(KSource, "source");
1.56 +_LIT(KNotifyType, "notify_type");
1.57 +_LIT(KReadHistory, "read_history");
1.58 +_LIT(KName, "name");
1.59 +_LIT(KNullDesCStr, "KNullDesC");
1.60 +_LIT(KTotalBytes, "total_bytes");
1.61 +_LIT(KFlag, "flag");
1.62 +_LIT(KClearHistory, "clear_history");
1.63 +_LIT(KSetTcontrol, "set_tcontrol");
1.64 +//For searching file names.
1.65 +_LIT(KPattern, "*%S*");
1.66 +
1.67 +/// Commands
1.68 +_LIT(KCmdNewL, "NewL");
1.69 +_LIT(KCmdAttribs, "Attribs");
1.70 +_LIT(KCmdCopy, "Copy");
1.71 +_LIT(KCmdMove, "Move");
1.72 +_LIT(KCmdDelete, "Delete");
1.73 +_LIT(KCmdRename, "Rename");
1.74 +_LIT(KCmdRmDir, "RmDir");
1.75 +_LIT(KCmdSetObserver, "SetObserver");
1.76 +_LIT(KCmdCurrentAction, "CurrentAction");
1.77 +_LIT(KCmdGetCurrentTarget, "GetCurrentTarget");
1.78 +_LIT(KCmdGetCurrentSource, "GetCurrentSource");
1.79 +_LIT(KCmdBytesTransferredByCopyStep, "BytesTransferredByCopyStep");
1.80 +_LIT(KCmdCurrentEntry, "CurrentEntry");
1.81 +_LIT(KCmdAbbreviatedPath, "AbbreviatedPath");
1.82 +_LIT(KCmdFullPath, "FullPath");
1.83 +_LIT(KCmdGetLastError, "GetLastError");
1.84 +_LIT(KCmdGetMoreInfoAboutError, "GetMoreInfoAboutError");
1.85 +_LIT(KCmdDestructor, "~");
1.86 +
1.87 +// TActions
1.88 +_LIT(KENone, "ENone");
1.89 +_LIT(KEAttribs, "EAttribs");
1.90 +_LIT(KECopy, "ECopy");
1.91 +_LIT(KEDelete, "EDelete");
1.92 +_LIT(KEMove, "EMove");
1.93 +_LIT(KERename, "ERename");
1.94 +_LIT(KERmDir, "ERmDir");
1.95 +_LIT(KERenameInvalidEntry, "ERenameInvalidEntry");
1.96 +_LIT(KECopyFromHandle, "ECopyFromHandle");
1.97 +
1.98 +
1.99 +// TSwitch
1.100 +_LIT(KEOverWrite, "EOverWrite");
1.101 +_LIT(KERecurse, "ERecurse");
1.102 +
1.103 +// TControl
1.104 +_LIT(KEContinue, "EContinue");
1.105 +_LIT(KEAbort, "EAbort");
1.106 +_LIT(KECancel, "ECancel");
1.107 +_LIT(KERetry, "ERetry");
1.108 +
1.109 +// TFileManError
1.110 +_LIT(KENoExtraInformation, "ENoExtraInformation");
1.111 +_LIT(KEInitializationFailed, "EInitializationFailed");
1.112 +_LIT(KEScanNextDirectoryFailed, "EScanNextDirectoryFailed");
1.113 +_LIT(KESrcOpenFailed, "ESrcOpenFailed");
1.114 +_LIT(KETrgOpenFailed, "ETrgOpenFailed");
1.115 +_LIT(KENoFilesProcessed, "ENoFilesProcessed");
1.116 +
1.117 +//Notifys
1.118 +_LIT(KNotifyStarted, "started");
1.119 +_LIT(KNotifyOperation, "operation");
1.120 +_LIT(KNotifyEnded, "ended");
1.121 +
1.122 +
1.123 +
1.124 +CT_FileManData* CT_FileManData::NewL()
1.125 +/**
1.126 +* Two phase constructor
1.127 +*/
1.128 + {
1.129 + CT_FileManData* ret = new (ELeave) CT_FileManData();
1.130 + CleanupStack::PushL(ret);
1.131 + ret->ConstructL();
1.132 + CleanupStack::Pop(ret);
1.133 + return ret;
1.134 + }
1.135 +
1.136 +
1.137 +CT_FileManData::CT_FileManData()
1.138 +: iFileMan(NULL)
1.139 +, iAsyncErrorIndex(0)
1.140 +, iAsyncCall(EFalse)
1.141 +, iFileManObserver(NULL)
1.142 +, iUseTControl(EFalse)
1.143 +
1.144 +/**
1.145 +* Protected constructor. First phase construction
1.146 +*/
1.147 + {
1.148 + }
1.149 +
1.150 +
1.151 +void CT_FileManData::ConstructL()
1.152 +/**
1.153 +* Protected constructor. Second phase construction
1.154 +*/
1.155 + {
1.156 + }
1.157 +
1.158 +
1.159 +CT_FileManData::~CT_FileManData()
1.160 +/**
1.161 +* Destructor.
1.162 +*/
1.163 + {
1.164 + DoCleanup();
1.165 +
1.166 + iAttribs.ResetAndDestroy();
1.167 + iCopy.ResetAndDestroy();
1.168 + iDelete.ResetAndDestroy();
1.169 + iMove.ResetAndDestroy();
1.170 + iRename.ResetAndDestroy();
1.171 + iRmDir.ResetAndDestroy();
1.172 +
1.173 + ClearHistory();
1.174 + }
1.175 +
1.176 +TAny* CT_FileManData::GetObject()
1.177 + {
1.178 + return iFileMan;
1.179 + }
1.180 +
1.181 +
1.182 +TBool CT_FileManData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.183 +/**
1.184 +* Process a command read from the ini file
1.185 +*
1.186 +* @param aCommand the command to process
1.187 +* @param aSection the section in the ini file requiring the command to be processed
1.188 +*
1.189 +* @return ETrue if the command is processed
1.190 +*/
1.191 + {
1.192 + TBool retVal = ETrue;
1.193 +
1.194 + if (aCommand == KCmdNewL)
1.195 + {
1.196 + DoCmdNewL(aSection);
1.197 + }
1.198 + else if (aCommand == KCmdDestructor)
1.199 + {
1.200 + DoCleanup();
1.201 + }
1.202 + else if (aCommand == KCmdAttribs)
1.203 + {
1.204 + DoCmdAttribsL(aSection, aAsyncErrorIndex);
1.205 + }
1.206 + else if (aCommand == KCmdCopy)
1.207 + {
1.208 + DoCmdCopyL(aSection, aAsyncErrorIndex);
1.209 + }
1.210 + else if (aCommand == KCmdMove)
1.211 + {
1.212 + DoCmdMoveL(aSection, aAsyncErrorIndex);
1.213 + }
1.214 + else if (aCommand == KCmdDelete)
1.215 + {
1.216 + DoCmdDeleteL(aSection, aAsyncErrorIndex);
1.217 + }
1.218 + else if (aCommand == KCmdRename)
1.219 + {
1.220 + DoCmdRenameL(aSection, aAsyncErrorIndex);
1.221 + }
1.222 + else if (aCommand == KCmdRmDir)
1.223 + {
1.224 + DoCmdRmDirL(aSection, aAsyncErrorIndex);
1.225 + }
1.226 + else if (aCommand == KCmdSetObserver)
1.227 + {
1.228 + DoCmdSetObserver();
1.229 + }
1.230 + else if (aCommand == KCmdCurrentAction)
1.231 + {
1.232 + DoCmdCurrentAction(aSection);
1.233 + }
1.234 + else if (aCommand == KCmdGetCurrentTarget)
1.235 + {
1.236 + DoCmdGetCurrentTarget(aSection);
1.237 + }
1.238 + else if (aCommand == KCmdGetCurrentSource)
1.239 + {
1.240 + DoCmdGetCurrentSource(aSection);
1.241 + }
1.242 + else if (aCommand == KCmdBytesTransferredByCopyStep)
1.243 + {
1.244 + DoCmdBytesTransferredByCopyStep(aSection);
1.245 + }
1.246 + else if(aCommand == KCmdCurrentEntry)
1.247 + {
1.248 + DoCmdCurrentEntryL(aSection);
1.249 + }
1.250 + else if(aCommand == KCmdAbbreviatedPath)
1.251 + {
1.252 + DoCmdAbbreviatedPath(aSection);
1.253 + }
1.254 + else if(aCommand == KCmdFullPath)
1.255 + {
1.256 + DoCmdFullPath(aSection);
1.257 + }
1.258 + else if(aCommand == KCmdGetLastError)
1.259 + {
1.260 + DoCmdGetLastError(aSection);
1.261 + }
1.262 + else if(aCommand == KCmdGetMoreInfoAboutError)
1.263 + {
1.264 + DoCmdGetMoreInfoAboutError(aSection);
1.265 + }
1.266 + return retVal;
1.267 + }
1.268 +
1.269 +void CT_FileManData::DoCleanup()
1.270 + {
1.271 + INFO_PRINTF1(_L("Doing cleanup"));
1.272 +
1.273 + if (iFileMan)
1.274 + {
1.275 + delete(iFileMan);
1.276 + iFileMan = NULL;
1.277 + }
1.278 + ClearHistory();
1.279 + }
1.280 +
1.281 +/** Inform the observer that an operation is about to start **/
1.282 +MFileManObserver::TControl CT_FileManData::NotifyFileManStarted()
1.283 + {
1.284 + THistoryData *record = new THistoryData();
1.285 + CreateHistoryRecord(*record);
1.286 + iStartedHistory.Append(record);
1.287 + if(record->iLastError != KErrNone)
1.288 + {
1.289 + if(iAsyncCall)
1.290 + {
1.291 + SetAsyncError(iAsyncErrorIndex, record->iLastError);
1.292 + iAsyncCall = EFalse;
1.293 + }
1.294 + else
1.295 + {
1.296 + SetError(record->iLastError);
1.297 + }
1.298 + }
1.299 + TControl ret = EContinue;
1.300 + //Check if we need to return TControl value specified in INI.
1.301 + if(iUseTControl && iObserverNotifyType == ENotifyStarted)
1.302 + {
1.303 + TBuf<KMaxFileNameLength> buffer;
1.304 + buffer.Format(KPattern(), &iNotifyFileName);
1.305 + //Check if we need to return TControl for this file.
1.306 + if(record->iCurrentSource.Match(buffer) != KErrNotFound)
1.307 + {
1.308 + iUseTControl = EFalse;
1.309 + ret = iTControl;
1.310 + }
1.311 + }
1.312 + return ret;
1.313 + }
1.314 +
1.315 +/** Informs the observer that an operation, i.e. a copy or a move, is proceeding. **/
1.316 +MFileManObserver::TControl CT_FileManData::NotifyFileManOperation()
1.317 + {
1.318 + THistoryData *record = new THistoryData();
1.319 + CreateHistoryRecord(*record);
1.320 + iOperationHistory.Append(record);
1.321 + if(record->iLastError != KErrNone)
1.322 + {
1.323 + if(iAsyncCall)
1.324 + {
1.325 + SetAsyncError(iAsyncErrorIndex, record->iLastError);
1.326 + iAsyncCall = EFalse;
1.327 + }
1.328 + else
1.329 + {
1.330 + SetError(record->iLastError);
1.331 + }
1.332 + }
1.333 + TControl ret = EContinue;
1.334 + //Check if we need to return TControl value specified in INI.
1.335 + if(iUseTControl && iObserverNotifyType == ENotifyOperation)
1.336 + {
1.337 + TBuf<KMaxFileNameLength> buffer;
1.338 + buffer.Format(KPattern(), &iNotifyFileName);
1.339 + //Check if we need to return TControl for this file.
1.340 + if(record->iCurrentSource.Match(buffer) != KErrNotFound)
1.341 + {
1.342 + iUseTControl = EFalse;
1.343 + ret = iTControl;
1.344 + }
1.345 + }
1.346 + return ret;
1.347 + }
1.348 +
1.349 +/** Informs the observer that an operation is complete. **/
1.350 +MFileManObserver::TControl CT_FileManData::NotifyFileManEnded()
1.351 + {
1.352 + THistoryData *record = new THistoryData();
1.353 + CreateHistoryRecord(*record);
1.354 + iEndedHistory.Append(record);
1.355 + if(record->iLastError != KErrNone)
1.356 + {
1.357 + if(iAsyncCall)
1.358 + {
1.359 + SetAsyncError(iAsyncErrorIndex, record->iLastError);
1.360 + iAsyncCall = EFalse;
1.361 + }
1.362 + else
1.363 + {
1.364 + SetError(record->iLastError);
1.365 + }
1.366 + }
1.367 + TControl ret = EContinue;
1.368 + //Check if we need to return TControl value specified in INI.
1.369 + if(iUseTControl && iObserverNotifyType == ENotifyEnded)
1.370 + {
1.371 + TBuf<KMaxFileNameLength> buffer;
1.372 + buffer.Format(KPattern(), &iNotifyFileName);
1.373 + //Check if we need to return TControl for this file.
1.374 + if(record->iCurrentSource.Match(buffer) != KErrNotFound)
1.375 + {
1.376 + iUseTControl = EFalse;
1.377 + ret = iTControl;
1.378 + }
1.379 + }
1.380 + return ret;
1.381 + }
1.382 +
1.383 +void CT_FileManData::DoCmdNewL(const TDesC& aSection)
1.384 + {
1.385 + DoCleanup();
1.386 + TBool useObserver = EFalse;
1.387 +
1.388 + GET_OPTIONAL_BOOL_PARAMETER(KUseObserver, aSection, useObserver);
1.389 +
1.390 + TPtrC rfsObjectName;
1.391 + RFs* rfsObject = NULL;
1.392 + if (GET_MANDATORY_STRING_PARAMETER(KRFsObject, aSection, rfsObjectName))
1.393 + {
1.394 + rfsObject = (RFs*)GetDataObjectL(rfsObjectName);
1.395 + }
1.396 +
1.397 + TInt err = KErrNone;
1.398 + if(useObserver)
1.399 + {
1.400 + INFO_PRINTF1(_L("CFileMan::NewL(RFs, MFileManObserver)"));
1.401 + TRAP(err, iFileMan = CFileMan::NewL(*rfsObject, iFileManObserver));
1.402 + }
1.403 + else
1.404 + {
1.405 + INFO_PRINTF1(_L("CFileMan::NewL(RFs)"));
1.406 + TRAP(err, iFileMan = CFileMan::NewL(*rfsObject));
1.407 + }
1.408 + if (err != KErrNone)
1.409 + {
1.410 + ERR_PRINTF1(_L("CFileMan object is not created"));
1.411 + SetBlockResult(EFail);
1.412 + }
1.413 + }
1.414 +
1.415 +void CT_FileManData::DoCmdAttribsL(const TDesC& aSection, TInt aAsyncErrorIndex)
1.416 + {
1.417 + INFO_PRINTF1(_L("Setting attributes!"));
1.418 +
1.419 + TBool dataOk = ETrue;
1.420 +
1.421 + //Reading path for file or files.
1.422 + TPtrC fileName;
1.423 + if (!GET_MANDATORY_STRING_PARAMETER(KFileName, aSection, fileName))
1.424 + {
1.425 + dataOk = EFalse;
1.426 + }
1.427 +
1.428 + //Reading new TTime from ini
1.429 + TPtrC inputTime;
1.430 + TTime iniTime;
1.431 + if(GET_MANDATORY_STRING_PARAMETER(KTime, aSection, inputTime))
1.432 + {
1.433 + TInt err = iniTime.Set(inputTime);
1.434 + if (err != KErrNone)
1.435 + {
1.436 + ERR_PRINTF3(_L("Cannot convert (%S) to time. Error: %d"), &inputTime ,err);
1.437 + dataOk = EFalse;
1.438 + SetBlockResult(EFail);
1.439 + }
1.440 + }
1.441 + else
1.442 + {
1.443 + dataOk = EFalse;
1.444 + }
1.445 +
1.446 + //Reading Async parameter (True/False)
1.447 + TBool async = EFalse;
1.448 + if(!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
1.449 + {
1.450 + dataOk = EFalse;
1.451 + }
1.452 + //Read SetMask attribute
1.453 + TUint setMask;
1.454 + if(!FileserverUtil::GetAttMask(*this, aSection, KSetMask(), setMask))
1.455 + {
1.456 + dataOk = EFalse;
1.457 + }
1.458 +
1.459 + //Read ClearMask attribute
1.460 + TUint clearMask;
1.461 + if(!FileserverUtil::GetAttMask(*this, aSection, KClearMask(), clearMask))
1.462 + {
1.463 + dataOk = EFalse;
1.464 + }
1.465 +
1.466 + //Read operation TSwitch
1.467 + TUint operation;
1.468 + if(!GetOperationFromConfig(KOperation(), aSection, operation))
1.469 + {
1.470 + dataOk = EFalse;
1.471 + }
1.472 + if(dataOk)
1.473 + {
1.474 + TInt error = KErrNone;
1.475 + if(async)
1.476 + {
1.477 + CActiveCallback* active = CActiveCallback::NewLC(*this);
1.478 + iAttribs.AppendL(active);
1.479 + CleanupStack::Pop(active);
1.480 + error = iFileMan->Attribs(fileName, setMask, clearMask, iniTime, operation, active->iStatus);
1.481 + if(error == KErrNone)
1.482 + {
1.483 + active->Activate(aAsyncErrorIndex);
1.484 + iAsyncErrorIndex = aAsyncErrorIndex;
1.485 + iAsyncCall = ETrue;
1.486 + IncOutstanding();
1.487 + }
1.488 + }
1.489 + else
1.490 + {
1.491 + error = iFileMan->Attribs(fileName, setMask, clearMask, iniTime, operation);
1.492 + }
1.493 + if (error != KErrNone)
1.494 + {
1.495 + ERR_PRINTF3(_L("Attribs(%S) Error: %d"), &fileName, error);
1.496 + SetError(error);
1.497 + }
1.498 + else
1.499 + {
1.500 + INFO_PRINTF2(_L("Attribs operation on (%S) is successfull!"), &fileName);
1.501 + }
1.502 + }
1.503 + }
1.504 +void CT_FileManData::DoCmdCopyL(const TDesC& aSection, TInt aAsyncErrorIndex)
1.505 + {
1.506 + TBool clearHistory = EFalse;
1.507 + GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory);
1.508 + if(clearHistory)
1.509 + {
1.510 + ClearHistory();
1.511 + }
1.512 + TBool setTControl = EFalse;
1.513 + GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl);
1.514 + if(setTControl)
1.515 + {
1.516 + ReadTControl(aSection);
1.517 + }
1.518 +
1.519 + INFO_PRINTF1(_L("Coping files!"));
1.520 + TBool dataOk = ETrue;
1.521 + TPtrC oldName;
1.522 + TPtrC rfileObjectName;
1.523 + RFile* rfileObject = NULL;
1.524 +
1.525 + if (!GET_OPTIONAL_STRING_PARAMETER(KOldName, aSection, oldName))
1.526 + {
1.527 + if (GET_OPTIONAL_STRING_PARAMETER(KRFileObject, aSection, rfileObjectName))
1.528 + {
1.529 + rfileObject = (RFile*)GetDataObjectL(rfileObjectName);
1.530 + }
1.531 + else
1.532 + {
1.533 + ERR_PRINTF1(_L("Cannot read \"oldname\" or \"rfileObject\" arguments!"));
1.534 + SetBlockResult(EFail);
1.535 + dataOk = EFalse;
1.536 + }
1.537 + }
1.538 +
1.539 + TPtrC newName;
1.540 + if (!GET_MANDATORY_STRING_PARAMETER(KNewName, aSection, newName))
1.541 + {
1.542 + dataOk = EFalse;
1.543 + }
1.544 +
1.545 + TUint operation;
1.546 + if (!GetOperationFromConfig(KOperation, aSection, operation))
1.547 + {
1.548 + dataOk = EFalse;
1.549 + }
1.550 + TBool async;
1.551 + if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
1.552 + {
1.553 + dataOk = EFalse;
1.554 + }
1.555 +
1.556 + if(dataOk)
1.557 + {
1.558 + TInt error = KErrNone;
1.559 + if(async)
1.560 + {
1.561 + CActiveCallback* active = CActiveCallback::NewLC(*this);
1.562 + iCopy.AppendL(active);
1.563 + CleanupStack::Pop(active);
1.564 + if(rfileObject)
1.565 + {
1.566 + error = iFileMan->Copy(*rfileObject, newName, operation, active->iStatus);
1.567 + }
1.568 + else
1.569 + {
1.570 + error = iFileMan->Copy(oldName, newName, operation, active->iStatus);
1.571 + }
1.572 + if(error == KErrNone)
1.573 + {
1.574 + active->Activate(aAsyncErrorIndex);
1.575 + iAsyncErrorIndex = aAsyncErrorIndex;
1.576 + iAsyncCall = ETrue;
1.577 + IncOutstanding();
1.578 + }
1.579 + }
1.580 + else
1.581 + {
1.582 + if(rfileObject)
1.583 + {
1.584 + error = iFileMan->Copy(*rfileObject, newName, operation);
1.585 + }
1.586 + else
1.587 + {
1.588 + error = iFileMan->Copy(oldName, newName, operation);
1.589 + }
1.590 + }
1.591 + if (error != KErrNone)
1.592 + {
1.593 + ERR_PRINTF2(_L("Copy(), Error: %d"), error);
1.594 + SetError(error);
1.595 + }
1.596 + else
1.597 + {
1.598 + INFO_PRINTF1(_L("Copy() operation is successfully!"));
1.599 + }
1.600 + }
1.601 + }
1.602 +
1.603 +void CT_FileManData::DoCmdDeleteL(const TDesC& aSection, TInt aAsyncErrorIndex)
1.604 + {
1.605 + TBool clearHistory = EFalse;
1.606 + GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory);
1.607 + if(clearHistory)
1.608 + {
1.609 + ClearHistory();
1.610 + }
1.611 + TBool setTControl = EFalse;
1.612 + GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl);
1.613 + if(setTControl)
1.614 + {
1.615 + ReadTControl(aSection);
1.616 + }
1.617 +
1.618 + INFO_PRINTF1(_L("Deleting files!"));
1.619 +
1.620 + TBool dataOk = ETrue;
1.621 + TPtrC fileName;
1.622 + if (GET_MANDATORY_STRING_PARAMETER(KFileName, aSection, fileName))
1.623 + {
1.624 + if(fileName == KNullDesCStr)
1.625 + {
1.626 + fileName.Set(KNullDesC);
1.627 + }
1.628 + }
1.629 + else
1.630 + {
1.631 + dataOk = EFalse;
1.632 + }
1.633 + TUint operation;
1.634 + if(!GetOperationFromConfig(KOperation, aSection, operation))
1.635 + {
1.636 + dataOk = EFalse;
1.637 + }
1.638 + TBool async = EFalse;
1.639 + if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
1.640 + {
1.641 + dataOk = EFalse;
1.642 + }
1.643 + if(dataOk)
1.644 + {
1.645 + TInt error = KErrNone;
1.646 + if(async)
1.647 + {
1.648 + CActiveCallback* active = CActiveCallback::NewLC(*this);
1.649 + iDelete.AppendL(active);
1.650 + CleanupStack::Pop(active);
1.651 + error = iFileMan->Delete(fileName, operation, active->iStatus);
1.652 + if (error == KErrNone)
1.653 + {
1.654 + active->Activate(aAsyncErrorIndex);
1.655 + iAsyncErrorIndex = aAsyncErrorIndex;
1.656 + iAsyncCall = ETrue;
1.657 + IncOutstanding();
1.658 + }
1.659 + }
1.660 + else
1.661 + {
1.662 + error = iFileMan->Delete(fileName, operation);
1.663 + }
1.664 +
1.665 + if (error != KErrNone)
1.666 + {
1.667 + ERR_PRINTF3(_L("Delete (%S), Error: %d"), &fileName, error);
1.668 + SetError(error);
1.669 + }
1.670 + else
1.671 + {
1.672 + INFO_PRINTF2(_L("Delete (%S) operation is successfully!"), &fileName);
1.673 + }
1.674 + }
1.675 + }
1.676 +
1.677 +void CT_FileManData::DoCmdMoveL(const TDesC& aSection, TInt aAsyncErrorIndex)
1.678 + {
1.679 + TBool clearHistory = EFalse;
1.680 + GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory);
1.681 + if(clearHistory)
1.682 + {
1.683 + ClearHistory();
1.684 + }
1.685 + TBool setTControl = EFalse;
1.686 + GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl);
1.687 + if(setTControl)
1.688 + {
1.689 + ReadTControl(aSection);
1.690 + }
1.691 +
1.692 + INFO_PRINTF1(_L("Moving files!"));
1.693 +
1.694 + TBool dataOk = ETrue;
1.695 + TPtrC fileFrom;
1.696 + if (!GET_MANDATORY_STRING_PARAMETER(KFileFrom, aSection, fileFrom))
1.697 + {
1.698 + dataOk = EFalse;
1.699 + }
1.700 +
1.701 + TPtrC fileTo;
1.702 + if (!GET_MANDATORY_STRING_PARAMETER(KFileTo, aSection, fileTo))
1.703 + {
1.704 + dataOk = EFalse;
1.705 + }
1.706 + TBool async;
1.707 + if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
1.708 + {
1.709 + dataOk = EFalse;
1.710 + }
1.711 + TUint operation;
1.712 + if (!GetOperationFromConfig(KOperation, aSection, operation))
1.713 + {
1.714 + dataOk = EFalse;
1.715 + }
1.716 + if(dataOk)
1.717 + {
1.718 + TInt error = KErrNone;
1.719 + if(async)
1.720 + {
1.721 + CActiveCallback* active = CActiveCallback::NewLC(*this);
1.722 + iMove.AppendL(active);
1.723 + CleanupStack::Pop(active);
1.724 + error = iFileMan->Move(fileFrom, fileTo, operation, active->iStatus);
1.725 + if(error == KErrNone)
1.726 + {
1.727 + active->Activate(aAsyncErrorIndex);
1.728 + iAsyncErrorIndex = aAsyncErrorIndex;
1.729 + iAsyncCall = ETrue;
1.730 + IncOutstanding();
1.731 + }
1.732 + }
1.733 + else
1.734 + {
1.735 + error = iFileMan->Move(fileFrom, fileTo, operation);
1.736 + }
1.737 + if (error != KErrNone)
1.738 + {
1.739 + ERR_PRINTF2(_L("Move(), Error: %d"), error);
1.740 + SetError(error);
1.741 + }
1.742 + else
1.743 + {
1.744 + INFO_PRINTF1(_L("Move() operation is successfully!"));
1.745 + }
1.746 + }
1.747 + }
1.748 +
1.749 +void CT_FileManData::DoCmdRenameL(const TDesC& aSection, TInt aAsyncErrorIndex)
1.750 + {
1.751 + TBool clearHistory = EFalse;
1.752 + GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory);
1.753 + if(clearHistory)
1.754 + {
1.755 + ClearHistory();
1.756 + }
1.757 + TBool setTControl = EFalse;
1.758 + GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl);
1.759 + if(setTControl)
1.760 + {
1.761 + ReadTControl(aSection);
1.762 + }
1.763 + INFO_PRINTF1(_L("Renaming files!"));
1.764 +
1.765 + TBool dataOk = ETrue;
1.766 +
1.767 + //Reading Old Name
1.768 + TPtrC oldName;
1.769 + if (!GET_MANDATORY_STRING_PARAMETER(KOldName, aSection, oldName))
1.770 + {
1.771 + dataOk = EFalse;
1.772 + }
1.773 +
1.774 + //Reading New Name
1.775 + TPtrC newName;
1.776 + if (!GET_MANDATORY_STRING_PARAMETER(KNewName, aSection, newName))
1.777 + {
1.778 + dataOk = EFalse;
1.779 + }
1.780 +
1.781 + //Rading TSwitch - Operation
1.782 + TUint operation;
1.783 + if (!GetOperationFromConfig(KOperation(), aSection, operation))
1.784 + {
1.785 + dataOk = EFalse;
1.786 + }
1.787 + //Reading async
1.788 + TBool async;
1.789 + if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
1.790 + {
1.791 + dataOk = EFalse;
1.792 + }
1.793 + if(dataOk)
1.794 + {
1.795 + TInt error = KErrNone;
1.796 + if(async)
1.797 + {
1.798 + CActiveCallback* active = CActiveCallback::NewLC(*this);
1.799 + iRename.AppendL(active);
1.800 + CleanupStack::Pop(active);
1.801 + error = iFileMan->Rename(oldName, newName, operation, active->iStatus);
1.802 + if(error == KErrNone)
1.803 + {
1.804 + active->Activate(aAsyncErrorIndex);
1.805 + iAsyncErrorIndex = aAsyncErrorIndex;
1.806 + iAsyncCall = ETrue;
1.807 + IncOutstanding();
1.808 + }
1.809 + }
1.810 + else
1.811 + {
1.812 + error = iFileMan->Rename(oldName, newName, operation);
1.813 + }
1.814 + if (error != KErrNone)
1.815 + {
1.816 + ERR_PRINTF2(_L("Rename() Error: %d"), error);
1.817 + SetError(error);
1.818 + }
1.819 + else
1.820 + {
1.821 + INFO_PRINTF1(_L("Rename() operation is successfully!"));
1.822 + }
1.823 + }
1.824 + }
1.825 +
1.826 +void CT_FileManData::DoCmdRmDirL(const TDesC& aSection, TInt aAsyncErrorIndex)
1.827 + {
1.828 + INFO_PRINTF1(_L("Removing directory!"));
1.829 +
1.830 + TBool dataOk = ETrue;
1.831 + TPtrC path;
1.832 +
1.833 + if (!GET_MANDATORY_STRING_PARAMETER(KPath, aSection, path))
1.834 + {
1.835 + dataOk = EFalse;
1.836 + }
1.837 +
1.838 + TBool async = EFalse;
1.839 + if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async))
1.840 + {
1.841 + dataOk = EFalse;
1.842 + }
1.843 +
1.844 + if(dataOk)
1.845 + {
1.846 + TInt error = KErrNone;
1.847 + if(async)
1.848 + {
1.849 + CActiveCallback* active = CActiveCallback::NewLC(*this);
1.850 + iRmDir.AppendL(active);
1.851 + CleanupStack::Pop(active);
1.852 + error = iFileMan->RmDir(path, active->iStatus);
1.853 + if(error == KErrNone)
1.854 + {
1.855 + active->Activate(aAsyncErrorIndex);
1.856 + iAsyncErrorIndex = aAsyncErrorIndex;
1.857 + iAsyncCall = ETrue;
1.858 + IncOutstanding();
1.859 + }
1.860 + }
1.861 + else
1.862 + {
1.863 + error = iFileMan->RmDir(path);
1.864 + }
1.865 + if (error != KErrNone)
1.866 + {
1.867 + ERR_PRINTF3(_L("RmDir(%S), Error: %d"), &path, error);
1.868 + SetError(error);
1.869 + }
1.870 + else
1.871 + {
1.872 + INFO_PRINTF2(_L("Callled RmDir(%S)"), &path);
1.873 + }
1.874 + }
1.875 + }
1.876 +
1.877 +void CT_FileManData::DoCmdSetObserver()
1.878 + {
1.879 + INFO_PRINTF1(_L("Setting observer"));
1.880 +
1.881 + iFileMan->SetObserver(this);
1.882 + }
1.883 +
1.884 +void CT_FileManData::DoCmdCurrentAction(const TDesC& aSection)
1.885 + {
1.886 + TBool readHistory = EFalse;
1.887 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.888 + CFileMan::TAction currentAction = CFileMan::ENone;
1.889 + TBool found = ETrue;
1.890 + if(readHistory)
1.891 + {
1.892 + /** Get needed history array **/
1.893 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.894 + if(history)
1.895 + {
1.896 + CFileMan::TAction expectedAction;
1.897 + found = EFalse;
1.898 + if(GetActionFromConfig(KCurrentAction(), aSection, expectedAction))
1.899 + {
1.900 + CFileMan::TAction action;
1.901 + TInt count = history->Count();
1.902 + /** Search for expected TAction in history **/
1.903 + for(TInt i = 0; (i < count) && (!found); i++)
1.904 + {
1.905 + action = ((*history)[i])->iCurrentAction;
1.906 + if( action == expectedAction)
1.907 + {
1.908 + currentAction = action;
1.909 + found = ETrue;
1.910 + }
1.911 + }
1.912 + if(!found)
1.913 + {
1.914 + TPtrC expectedActionStr;
1.915 + ConvertActionToString(expectedAction, expectedActionStr);
1.916 + ERR_PRINTF2(_L("CurrentAction() %S not found in history!"), &expectedActionStr);
1.917 + SetBlockResult(EFail);
1.918 + }
1.919 + }
1.920 + else
1.921 + {
1.922 + ERR_PRINTF2(_L("Cannot read %S"), &KCurrentAction());
1.923 + SetBlockResult(EFail);
1.924 + }
1.925 + }
1.926 + }
1.927 + else
1.928 + {
1.929 + currentAction = iFileMan->CurrentAction();
1.930 + }
1.931 +
1.932 + if(found)
1.933 + {
1.934 + TPtrC actionStr;
1.935 + ConvertActionToString(currentAction, actionStr);
1.936 +
1.937 + CFileMan::TAction expectedAction;
1.938 + if(GetActionFromConfig(KCurrentAction(), aSection, expectedAction))
1.939 + {
1.940 + TPtrC expectedActionStr;
1.941 + ConvertActionToString(expectedAction, expectedActionStr);
1.942 + if(expectedAction != currentAction)
1.943 + {
1.944 + ERR_PRINTF3(_L("CurrentAction(): %S != %S Expected Action"), &actionStr, &expectedActionStr);
1.945 + SetBlockResult(EFail);
1.946 + }
1.947 + else
1.948 + {
1.949 + INFO_PRINTF3(_L("CurrentAction(): %S == %S Expected Action"), &actionStr, &expectedActionStr);
1.950 + }
1.951 + }
1.952 + else
1.953 + {
1.954 + INFO_PRINTF2(_L("CurrentAction: %S"), &actionStr);
1.955 + }
1.956 + }
1.957 + }
1.958 +
1.959 +void CT_FileManData::DoCmdGetCurrentTarget(const TDesC& aSection)
1.960 + {
1.961 + TBool readHistory = EFalse;
1.962 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.963 + TFileName target;
1.964 + TBool found = ETrue;
1.965 + if(readHistory)
1.966 + {
1.967 + /** Get needed history array **/
1.968 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.969 + if(history)
1.970 + {
1.971 + TPtrC expectedTarget;
1.972 + found = EFalse;
1.973 + if(GET_MANDATORY_STRING_PARAMETER(KTarget, aSection, expectedTarget))
1.974 + {
1.975 + TInt count = history->Count();
1.976 + /** Search for expected target in history **/
1.977 + for(TInt i = 0; (!found) && (i < count); i++)
1.978 + {
1.979 + if( ((*history)[i])->iCurrentTarget == expectedTarget)
1.980 + {
1.981 + target = ((*history)[i])->iCurrentTarget;
1.982 + found = ETrue;
1.983 + }
1.984 + }
1.985 + if(!found)
1.986 + {
1.987 + ERR_PRINTF2(_L("GetCurrentTarget() %S not found in history!"), &expectedTarget);
1.988 + SetBlockResult(EFail);
1.989 + }
1.990 + }
1.991 + }
1.992 + }
1.993 + else
1.994 + {
1.995 + iFileMan->GetCurrentTarget(target);
1.996 + }
1.997 + if(found)
1.998 + {
1.999 + TPtrC expectedTarget;
1.1000 + if(GET_OPTIONAL_STRING_PARAMETER(KTarget, aSection, expectedTarget))
1.1001 + {
1.1002 + if(target == expectedTarget)
1.1003 + {
1.1004 + INFO_PRINTF3(_L("GetCurrentTarget() %S == %S ExpectedResult"), &target, &expectedTarget);
1.1005 + }
1.1006 + else
1.1007 + {
1.1008 + ERR_PRINTF3(_L("GetCurrentTarget() %S != %S ExpectedResult"), &target, &expectedTarget);
1.1009 + SetBlockResult(EFail);
1.1010 + }
1.1011 +
1.1012 + }
1.1013 + else
1.1014 + {
1.1015 + INFO_PRINTF2(_L("GetCurrentTarget() %S"), &target);
1.1016 + }
1.1017 + }
1.1018 + }
1.1019 +void CT_FileManData::DoCmdGetCurrentSource(const TDesC& aSection)
1.1020 + {
1.1021 + TBool readHistory = EFalse;
1.1022 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.1023 + TFileName source;
1.1024 + TBool found = ETrue;
1.1025 + if(readHistory)
1.1026 + {
1.1027 + /** Get needed history array **/
1.1028 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.1029 + if(history)
1.1030 + {
1.1031 + TPtrC expectedSource;
1.1032 + found = EFalse;
1.1033 + if(GET_MANDATORY_STRING_PARAMETER(KSource, aSection, expectedSource))
1.1034 + {
1.1035 + TInt count = history->Count();
1.1036 + /** Search for expected source in history **/
1.1037 + for(TInt i = 0; (!found) && (i < count); i++)
1.1038 + {
1.1039 + if( (*history)[i]->iCurrentSource == expectedSource)
1.1040 + {
1.1041 + source = (*history)[i]->iCurrentSource;
1.1042 + found = ETrue;
1.1043 + }
1.1044 + }
1.1045 + if(!found)
1.1046 + {
1.1047 + ERR_PRINTF2(_L("GetCurrentSource() %S not found in history!"), &expectedSource);
1.1048 + SetBlockResult(EFail);
1.1049 + }
1.1050 + }
1.1051 + }
1.1052 + }
1.1053 + else
1.1054 + {
1.1055 + iFileMan->GetCurrentSource(source);
1.1056 + }
1.1057 +
1.1058 + if (found)
1.1059 + {
1.1060 + TPtrC expectedSource;
1.1061 + if(GET_OPTIONAL_STRING_PARAMETER(KSource, aSection, expectedSource))
1.1062 + {
1.1063 + if(source == expectedSource)
1.1064 + {
1.1065 + INFO_PRINTF3(_L("GetCurrentSource() %S == %S ExpectedResult"), &source, &expectedSource);
1.1066 + }
1.1067 + else
1.1068 + {
1.1069 + ERR_PRINTF3(_L("GetCurrentSource() %S != %S ExpectedResult"), &source, &expectedSource);
1.1070 + SetBlockResult(EFail);
1.1071 + }
1.1072 +
1.1073 + }
1.1074 + else
1.1075 + {
1.1076 + INFO_PRINTF2(_L("GetCurrentSource() %S"), &source);
1.1077 + }
1.1078 + }
1.1079 +
1.1080 + }
1.1081 +void CT_FileManData::DoCmdBytesTransferredByCopyStep(const TDesC& aSection)
1.1082 + {
1.1083 + TBool readHistory = EFalse;
1.1084 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.1085 + TInt bytes = 0;
1.1086 + TBool found = ETrue;
1.1087 + if(readHistory)
1.1088 + {
1.1089 + /** Get needed history array **/
1.1090 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.1091 + if(history)
1.1092 + {
1.1093 + TInt expectedBytes;
1.1094 + found = EFalse;
1.1095 + if(GET_MANDATORY_INT_PARAMETER(KBytes, aSection, expectedBytes))
1.1096 + {
1.1097 + TBool totalBytes = EFalse;
1.1098 + GET_OPTIONAL_BOOL_PARAMETER(KTotalBytes, aSection, totalBytes);
1.1099 + TInt count = history->Count();
1.1100 + TInt bytesTemp;
1.1101 + /** Search for expected transferred bytes in history **/
1.1102 + for(TInt i = 0; (!found) && (i < count); i++)
1.1103 + {
1.1104 + bytesTemp = ((*history)[i])->iBytesTransferred;
1.1105 + if(totalBytes)
1.1106 + {
1.1107 + bytes +=bytesTemp;
1.1108 + }
1.1109 + else
1.1110 + {
1.1111 + if( bytesTemp == expectedBytes)
1.1112 + {
1.1113 + bytes = bytesTemp;
1.1114 + found = ETrue;
1.1115 + }
1.1116 + }
1.1117 + }
1.1118 + if(totalBytes)
1.1119 + {
1.1120 + found = ETrue;
1.1121 + }
1.1122 + if(!found)
1.1123 + {
1.1124 + ERR_PRINTF2(_L("BytesTransferredByCopyStep() %d not found in history!"), expectedBytes);
1.1125 + SetBlockResult(EFail);
1.1126 + }
1.1127 + }
1.1128 + }
1.1129 + }
1.1130 + else
1.1131 + {
1.1132 + bytes = iFileMan->BytesTransferredByCopyStep();
1.1133 + }
1.1134 + if (found)
1.1135 + {
1.1136 + TInt expectedBytes;
1.1137 + if(GET_OPTIONAL_INT_PARAMETER(KBytes, aSection, expectedBytes))
1.1138 + {
1.1139 + if(expectedBytes != bytes)
1.1140 + {
1.1141 + ERR_PRINTF3(_L("BytesTransferredByCopyStep(): %d != %d Expected Bytes"), bytes, expectedBytes);
1.1142 + SetBlockResult(EFail);
1.1143 + }
1.1144 + else
1.1145 + {
1.1146 + INFO_PRINTF3(_L("BytesTransferredByCopyStep(): %d == %d Expected Bytes"), bytes, expectedBytes);
1.1147 + }
1.1148 + }
1.1149 + else
1.1150 + {
1.1151 + INFO_PRINTF2(_L("BytesTransferredByCopyStep(): %d"), bytes);
1.1152 + }
1.1153 + }
1.1154 + }
1.1155 +void CT_FileManData::DoCmdCurrentEntryL(const TDesC& aSection)
1.1156 + {
1.1157 +
1.1158 + TEntry* entryObject = NULL;
1.1159 + TBool found = ETrue;
1.1160 + TBool readHistory = EFalse;
1.1161 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.1162 + if(readHistory)
1.1163 + {
1.1164 + /** Get needed history array **/
1.1165 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.1166 + if(history)
1.1167 + {
1.1168 + TPtrC expectedName;
1.1169 + found = EFalse;
1.1170 + if(GET_MANDATORY_STRING_PARAMETER(KName, aSection, expectedName))
1.1171 + {
1.1172 + TInt count = history->Count();
1.1173 + TEntry entry;
1.1174 + /** Search for expected TEntry.iName in history **/
1.1175 + for(TInt i = 0; (!found) && (i < count); i++)
1.1176 + {
1.1177 + entry = ((*history)[i])->iCurrentEntry;
1.1178 + if( entry.iName == expectedName)
1.1179 + {
1.1180 + entryObject = &entry;
1.1181 + found = ETrue;
1.1182 + }
1.1183 + }
1.1184 + if(!found)
1.1185 + {
1.1186 + ERR_PRINTF1(_L("CurrentEntry() not found in history!"));
1.1187 + SetBlockResult(EFail);
1.1188 + }
1.1189 + }
1.1190 + }
1.1191 + }
1.1192 + else
1.1193 + {
1.1194 + *entryObject = iFileMan->CurrentEntry();
1.1195 + }
1.1196 + if(found)
1.1197 + {
1.1198 + if(!FileserverUtil::VerifyTEntryDataFromIniL(*this, aSection, *entryObject))
1.1199 + {
1.1200 + SetBlockResult(EFail);
1.1201 + }
1.1202 + }
1.1203 +
1.1204 + }
1.1205 +void CT_FileManData::DoCmdAbbreviatedPath(const TDesC& aSection)
1.1206 + {
1.1207 + TBool readHistory = EFalse;
1.1208 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.1209 + TPtrC path;
1.1210 + TBool found = ETrue;
1.1211 + if(readHistory)
1.1212 + {
1.1213 + /** Get needed history array **/
1.1214 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.1215 + if(history)
1.1216 + {
1.1217 + TPtrC expectedPath;
1.1218 + found = EFalse;
1.1219 + if(GET_MANDATORY_STRING_PARAMETER(KPath, aSection, expectedPath))
1.1220 + {
1.1221 + TInt count = history->Count();
1.1222 + /** Search for expected abbreviated path in history **/
1.1223 + for(TInt i = 0; (!found) && (i < count); i++)
1.1224 + {
1.1225 + if( ((*history)[i])->iAbbreviatedPath == expectedPath)
1.1226 + {
1.1227 + path.Set(((*history)[i])->iAbbreviatedPath);
1.1228 + found = ETrue;
1.1229 + }
1.1230 + }
1.1231 + if(!found)
1.1232 + {
1.1233 + ERR_PRINTF2(_L("AbbreviatedPath() %S not found in history!"), &expectedPath);
1.1234 + SetBlockResult(EFail);
1.1235 + }
1.1236 + }
1.1237 + }
1.1238 + }
1.1239 + else
1.1240 + {
1.1241 + path.Set(iFileMan->AbbreviatedPath());
1.1242 + }
1.1243 +
1.1244 + if (found)
1.1245 + {
1.1246 + TPtrC expectedPath;
1.1247 + if(GET_OPTIONAL_STRING_PARAMETER(KPath, aSection, expectedPath))
1.1248 + {
1.1249 + if(expectedPath.Compare(path) != 0)
1.1250 + {
1.1251 + ERR_PRINTF3(_L("AbbreviatedPath(): %S != %S Expected Path"), &path, &expectedPath);
1.1252 + SetBlockResult(EFail);
1.1253 + }
1.1254 + else
1.1255 + {
1.1256 + INFO_PRINTF3(_L("AbbreviatedPath(): %S == %S Expected Path"), &path, &expectedPath);
1.1257 + }
1.1258 + }
1.1259 + else
1.1260 + {
1.1261 + INFO_PRINTF2(_L("AbbreviatedPath(): %S"), &path);
1.1262 + }
1.1263 + }
1.1264 + }
1.1265 +void CT_FileManData::DoCmdFullPath(const TDesC& aSection)
1.1266 + {
1.1267 + TBool readHistory = EFalse;
1.1268 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.1269 + TPtrC fullPath;
1.1270 + TBool found = ETrue;
1.1271 + if(readHistory)
1.1272 + {
1.1273 + /** Get needed history array **/
1.1274 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.1275 + if(history)
1.1276 + {
1.1277 + TPtrC expectedPath;
1.1278 + found = EFalse;
1.1279 + if(GET_MANDATORY_STRING_PARAMETER(KPath, aSection, expectedPath))
1.1280 + {
1.1281 + TInt count = history->Count();
1.1282 + /** Search for expected full path in history **/
1.1283 + for(TInt i = 0; (!found) && (i < count); i++)
1.1284 + {
1.1285 + if( ((*history)[i])->iFullPath == expectedPath)
1.1286 + {
1.1287 + fullPath.Set(((*history)[i])->iFullPath);
1.1288 + found = ETrue;
1.1289 + }
1.1290 + }
1.1291 + if(!found)
1.1292 + {
1.1293 + ERR_PRINTF2(_L("FullPath() %S not found in history!"), &expectedPath);
1.1294 + SetBlockResult(EFail);
1.1295 + }
1.1296 + }
1.1297 + }
1.1298 + }
1.1299 + else
1.1300 + {
1.1301 + fullPath.Set(iFileMan->FullPath());
1.1302 + }
1.1303 + if(found)
1.1304 + {
1.1305 + TPtrC expectedPath;
1.1306 + if(GET_OPTIONAL_STRING_PARAMETER(KPath, aSection, expectedPath))
1.1307 + {
1.1308 + if(expectedPath.Compare(fullPath) != 0)
1.1309 + {
1.1310 + ERR_PRINTF3(_L("FullPath(): %S != %S Expected Path"), &fullPath, &expectedPath);
1.1311 + SetBlockResult(EFail);
1.1312 + }
1.1313 + else
1.1314 + {
1.1315 + INFO_PRINTF3(_L("FullPath(): %S == %S Expected Path"), &fullPath, &expectedPath);
1.1316 + }
1.1317 + }
1.1318 + else
1.1319 + {
1.1320 + INFO_PRINTF2(_L("FullPath(): %S"), &fullPath);
1.1321 + }
1.1322 + }
1.1323 + }
1.1324 +void CT_FileManData::DoCmdGetLastError(const TDesC& aSection)
1.1325 + {
1.1326 + TBool readHistory = EFalse;
1.1327 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.1328 + TInt lastError = KErrNone;
1.1329 + TBool found = ETrue;
1.1330 + if(readHistory)
1.1331 + {
1.1332 + /** Get needed history array **/
1.1333 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.1334 + if(history)
1.1335 + {
1.1336 + TInt expectedError;
1.1337 + found = EFalse;
1.1338 + if(GET_MANDATORY_INT_PARAMETER(KError, aSection, expectedError))
1.1339 + {
1.1340 + TInt count = history->Count();
1.1341 + TInt err;
1.1342 + /** Search for expected error in history **/
1.1343 + for(TInt i = 0; (!found) && (i < count); i++)
1.1344 + {
1.1345 + err = (*history)[i]->iLastError;
1.1346 + if( err == expectedError)
1.1347 + {
1.1348 + lastError = err;
1.1349 + found = ETrue;
1.1350 + }
1.1351 + }
1.1352 + if(!found)
1.1353 + {
1.1354 + ERR_PRINTF2(_L("GetLastError() %d not found in history!"), expectedError);
1.1355 + SetBlockResult(EFail);
1.1356 + }
1.1357 + }
1.1358 + }
1.1359 + }
1.1360 + else
1.1361 + {
1.1362 + lastError = iFileMan->GetLastError();
1.1363 + }
1.1364 + if (found)
1.1365 + {
1.1366 + TInt expectedError;
1.1367 + if(GET_OPTIONAL_INT_PARAMETER(KError, aSection, expectedError))
1.1368 + {
1.1369 + if(expectedError != lastError)
1.1370 + {
1.1371 + ERR_PRINTF3(_L("GetLastError(): %d != %d Expected Error"), lastError, expectedError);
1.1372 + SetBlockResult(EFail);
1.1373 + }
1.1374 + else
1.1375 + {
1.1376 + INFO_PRINTF3(_L("GetLastError(): %d == %d Expected Error"), lastError, expectedError);
1.1377 + }
1.1378 + }
1.1379 + else
1.1380 + {
1.1381 + INFO_PRINTF2(_L("GetLastError(): %d"), lastError);
1.1382 + }
1.1383 + }
1.1384 + }
1.1385 +
1.1386 +void CT_FileManData::DoCmdGetMoreInfoAboutError(const TDesC& aSection)
1.1387 + {
1.1388 + TBool readHistory = EFalse;
1.1389 + GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory);
1.1390 + TFileManError lastError;
1.1391 + TBool found = ETrue;
1.1392 + if(readHistory)
1.1393 + {
1.1394 + /** Get needed history array **/
1.1395 + RPointerArray<THistoryData>* history = GetHistoryDataByType(aSection);
1.1396 + if(history)
1.1397 + {
1.1398 + TFileManError expectedError;
1.1399 + found = EFalse;
1.1400 + if(GetFileManErrorFromConfig(KError, aSection, expectedError))
1.1401 + {
1.1402 + TInt count = history->Count();
1.1403 + TFileManError error;
1.1404 + /** Search for expected error in history **/
1.1405 + for(TInt i = 0; (!found) && (i < count); i++)
1.1406 + {
1.1407 + error = (*history)[i]->iMoreInfoAboutError;
1.1408 + if( (error == expectedError))
1.1409 + {
1.1410 + lastError = error;
1.1411 + found = ETrue;
1.1412 + }
1.1413 + }
1.1414 + if(!found)
1.1415 + {
1.1416 + ERR_PRINTF2(_L("GetMoreInfoAboutError() %S not found in history!"), expectedError);
1.1417 + SetBlockResult(EFail);
1.1418 + }
1.1419 + }
1.1420 + }
1.1421 + }
1.1422 + else
1.1423 + {
1.1424 + lastError = iFileMan->GetMoreInfoAboutError();
1.1425 + }
1.1426 + if (found)
1.1427 + {
1.1428 + TPtrC errorStr;
1.1429 + ConvertFileManErrorToString(lastError, errorStr);
1.1430 + TFileManError expectedError;
1.1431 + if(GetFileManErrorFromConfig(KError, aSection, expectedError))
1.1432 + {
1.1433 + TPtrC expectedErrorStr;
1.1434 + ConvertFileManErrorToString(expectedError, expectedErrorStr);
1.1435 +
1.1436 + if(expectedError != lastError)
1.1437 + {
1.1438 + ERR_PRINTF3(_L("GetMoreInfoAboutError(): %S != %S Expected Error"), &errorStr, &expectedErrorStr);
1.1439 + SetBlockResult(EFail);
1.1440 + }
1.1441 + else
1.1442 + {
1.1443 + INFO_PRINTF3(_L("GetMoreInfoAboutError(): %S == %S Expected Error"), &errorStr, &expectedErrorStr);
1.1444 + }
1.1445 + }
1.1446 + else
1.1447 + {
1.1448 + INFO_PRINTF2(_L("GetMoreInfoAboutError(): %S"), &errorStr);
1.1449 + }
1.1450 + }
1.1451 +
1.1452 + }
1.1453 +void CT_FileManData::RunL(CActive* aActive, TInt aIndex)
1.1454 +/**
1.1455 + Virtual RunL - Called on completion of an asynchronous command
1.1456 + @internalComponent
1.1457 + @see MActiveCallback
1.1458 + @param aActive Active Object that RunL has been called on
1.1459 + @pre N/A
1.1460 + @post N/A
1.1461 + @leave system wide error code
1.1462 +*/
1.1463 + {
1.1464 + INFO_PRINTF1(_L("CT_FileManData::RunL Called"));
1.1465 + TBool foundActiveObject = EFalse;
1.1466 + TInt index=0;
1.1467 + TInt count=0;
1.1468 + TBool completed=ETrue;
1.1469 +
1.1470 + count = iAttribs.Count();
1.1471 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1472 + {
1.1473 + if( aActive == iAttribs[index] )
1.1474 + {
1.1475 + INFO_PRINTF1(_L("RunL iAttribs called"));
1.1476 + foundActiveObject = ETrue;
1.1477 + iAttribs.Remove(index);
1.1478 + }
1.1479 + }
1.1480 +
1.1481 + count = iCopy.Count();
1.1482 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1483 + {
1.1484 + if( aActive == iCopy[index] )
1.1485 + {
1.1486 + INFO_PRINTF1(_L("RunL iCopy called"));
1.1487 + foundActiveObject = ETrue;
1.1488 + iCopy.Remove(index);
1.1489 + }
1.1490 + }
1.1491 +
1.1492 + count = iDelete.Count();
1.1493 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1494 + {
1.1495 + if( aActive == iDelete[index] )
1.1496 + {
1.1497 + INFO_PRINTF1(_L("RunL iDelete called"));
1.1498 + foundActiveObject = ETrue;
1.1499 + iDelete.Remove(index);
1.1500 + }
1.1501 + }
1.1502 +
1.1503 + count = iMove.Count();
1.1504 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1505 + {
1.1506 + if( aActive == iMove[index] )
1.1507 + {
1.1508 + INFO_PRINTF1(_L("RunL iMove called"));
1.1509 + foundActiveObject = ETrue;
1.1510 + iMove.Remove(index);
1.1511 + }
1.1512 + }
1.1513 +
1.1514 + count = iRename.Count();
1.1515 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1516 + {
1.1517 + if( aActive == iRename[index] )
1.1518 + {
1.1519 + INFO_PRINTF1(_L("RunL iRename called"));
1.1520 + foundActiveObject = ETrue;
1.1521 + iRename.Remove(index);
1.1522 + }
1.1523 + }
1.1524 +
1.1525 + count = iRmDir.Count();
1.1526 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1527 + {
1.1528 + if( aActive == iRmDir[index] )
1.1529 + {
1.1530 + INFO_PRINTF1(_L("RunL iRmDir called"));
1.1531 + foundActiveObject = ETrue;
1.1532 + iRmDir.Remove(index);
1.1533 + }
1.1534 + }
1.1535 +
1.1536 + if( foundActiveObject )
1.1537 + {
1.1538 + TInt err = aActive->iStatus.Int();
1.1539 + if( err != KErrNone )
1.1540 + {
1.1541 + ERR_PRINTF2(_L("RunL Error %d"), err);
1.1542 + SetAsyncError( aIndex, err );
1.1543 + iAsyncCall = EFalse;
1.1544 + }
1.1545 +
1.1546 + if ( completed )
1.1547 + {
1.1548 + // Reset the outstanding request state
1.1549 + DecOutstanding();
1.1550 + delete aActive;
1.1551 + }
1.1552 + }
1.1553 + else
1.1554 + {
1.1555 + ERR_PRINTF1(_L("Stray RunL signal"));
1.1556 + SetBlockResult(EFail);
1.1557 + }
1.1558 + }
1.1559 +
1.1560 +
1.1561 +void CT_FileManData::DoCancel(CActive* aActive, TInt aIndex)
1.1562 +/**
1.1563 + Virtual DoCancel - Request to cancel the asynchronous command
1.1564 + @internalComponent
1.1565 + @see - MActiveCallback
1.1566 + @param aActive Active Object that DoCancel has been called on
1.1567 + @pre - N/A
1.1568 + @post - N/A
1.1569 + @leave system wide error code
1.1570 +*/
1.1571 + {
1.1572 + INFO_PRINTF1(_L("CT_FileManData::DoCancelL Called"));
1.1573 +
1.1574 + TBool foundActiveObject = EFalse;
1.1575 + TInt index=0;
1.1576 + TInt count=0;
1.1577 +
1.1578 +
1.1579 + // See if it is in iAttribs
1.1580 + count = iAttribs.Count();
1.1581 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1582 + {
1.1583 + if( aActive == iAttribs[index] )
1.1584 + {
1.1585 + INFO_PRINTF1(_L("DoCancel iAttribs called"));
1.1586 + foundActiveObject = ETrue;
1.1587 + iAttribs.Remove(index);
1.1588 + }
1.1589 + }
1.1590 +
1.1591 + // See if it is in iCopy2
1.1592 + count = iCopy.Count();
1.1593 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1594 + {
1.1595 + if( aActive == iCopy[index] )
1.1596 + {
1.1597 + INFO_PRINTF1(_L("DoCancel iCopy called"));
1.1598 + foundActiveObject = ETrue;
1.1599 + iCopy.Remove(index);
1.1600 + }
1.1601 + }
1.1602 +
1.1603 + // See if it is in iDelete
1.1604 + count = iDelete.Count();
1.1605 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1606 + {
1.1607 + if( aActive == iDelete[index] )
1.1608 + {
1.1609 + INFO_PRINTF1(_L("DoCancel iDelete called"));
1.1610 + foundActiveObject = ETrue;
1.1611 + iDelete.Remove(index);
1.1612 + }
1.1613 + }
1.1614 +
1.1615 + // See if it is in iMove
1.1616 + count = iMove.Count();
1.1617 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1618 + {
1.1619 + if( aActive == iMove[index] )
1.1620 + {
1.1621 + INFO_PRINTF1(_L("DoCancel iMove called"));
1.1622 + foundActiveObject = ETrue;
1.1623 + iMove.Remove(index);
1.1624 + }
1.1625 + }
1.1626 +
1.1627 + // See if it is in iRename
1.1628 + count = iRename.Count();
1.1629 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1630 + {
1.1631 + if( aActive == iRename[index] )
1.1632 + {
1.1633 + INFO_PRINTF1(_L("DoCancel iRename called"));
1.1634 + foundActiveObject = ETrue;
1.1635 + iRename.Remove(index);
1.1636 + }
1.1637 + }
1.1638 +
1.1639 + // See if it is in iRmDir
1.1640 + count = iRmDir.Count();
1.1641 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1642 + {
1.1643 + if( aActive == iRmDir[index] )
1.1644 + {
1.1645 + INFO_PRINTF1(_L("DoCancel iRmDir called"));
1.1646 + foundActiveObject = ETrue;
1.1647 + iRmDir.Remove(index);
1.1648 + }
1.1649 + }
1.1650 +
1.1651 + if( foundActiveObject )
1.1652 + {
1.1653 + TInt err = aActive->iStatus.Int();
1.1654 + if( err != KErrNone )
1.1655 + {
1.1656 + ERR_PRINTF2(_L("DoCancel Error %d"), err);
1.1657 + SetAsyncError( aIndex, err );
1.1658 + }
1.1659 +
1.1660 + // Reset the outstanding request state
1.1661 + DecOutstanding();
1.1662 +
1.1663 + delete aActive;
1.1664 + }
1.1665 + else
1.1666 + {
1.1667 + ERR_PRINTF1(_L("Stray DoCancel signal"));
1.1668 + SetBlockResult(EFail);
1.1669 + }
1.1670 + }
1.1671 +
1.1672 +/** Reads TFileManError from INI and converts it to TFileManError type. **/
1.1673 +TBool CT_FileManData::GetFileManErrorFromConfig(const TDesC& aParameterName, const TDesC& aSection, TFileManError& aError)
1.1674 + {
1.1675 + TPtrC errorStr;
1.1676 + TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, errorStr);
1.1677 + if(ret)
1.1678 + {
1.1679 + if(errorStr == KENoExtraInformation)
1.1680 + {
1.1681 + aError = ENoExtraInformation;
1.1682 + }
1.1683 + else if(errorStr == KEInitializationFailed)
1.1684 + {
1.1685 + aError = EInitializationFailed;
1.1686 + }
1.1687 + else if (errorStr == KEScanNextDirectoryFailed)
1.1688 + {
1.1689 + aError = EScanNextDirectoryFailed;
1.1690 + }
1.1691 + else if (errorStr == KESrcOpenFailed)
1.1692 + {
1.1693 + aError = ESrcOpenFailed;
1.1694 + }
1.1695 + else if (errorStr == KETrgOpenFailed)
1.1696 + {
1.1697 + aError = ETrgOpenFailed;
1.1698 + }
1.1699 + else if (errorStr == KENoFilesProcessed)
1.1700 + {
1.1701 + aError = ENoFilesProcessed;
1.1702 + }
1.1703 + else
1.1704 + {
1.1705 + ret = EFalse;
1.1706 + }
1.1707 + }
1.1708 + return ret;
1.1709 + }
1.1710 +
1.1711 +/** Converts TFileManError type to string **/
1.1712 +void CT_FileManData::ConvertFileManErrorToString(TFileManError& aError, TPtrC& aErrorStr)
1.1713 + {
1.1714 + if(aError == ENoExtraInformation)
1.1715 + {
1.1716 + aErrorStr.Set(KENoExtraInformation());
1.1717 + }
1.1718 + else if(aError == EInitializationFailed)
1.1719 + {
1.1720 + aErrorStr.Set(KEInitializationFailed());
1.1721 + }
1.1722 + else if (aError == EScanNextDirectoryFailed)
1.1723 + {
1.1724 + aErrorStr.Set(KEScanNextDirectoryFailed());
1.1725 + }
1.1726 + else if (aError == ESrcOpenFailed)
1.1727 + {
1.1728 + aErrorStr.Set(KESrcOpenFailed());
1.1729 + }
1.1730 + else if (aError == ETrgOpenFailed)
1.1731 + {
1.1732 + aErrorStr.Set(KETrgOpenFailed());
1.1733 + }
1.1734 + else if (aError == ENoFilesProcessed)
1.1735 + {
1.1736 + aErrorStr.Set(KENoFilesProcessed());
1.1737 + }
1.1738 + }
1.1739 +
1.1740 +/** Converts CFileMan::TAction type to string **/
1.1741 +void CT_FileManData::ConvertActionToString(CFileMan::TAction aAction, TPtrC& aActionStr)
1.1742 + {
1.1743 + if (aAction == CFileMan::EAttribs)
1.1744 + {
1.1745 + aActionStr.Set(KEAttribs());
1.1746 + }
1.1747 + else if (aAction == CFileMan::ECopy)
1.1748 + {
1.1749 + aActionStr.Set(KECopy());
1.1750 + }
1.1751 + else if (aAction == CFileMan::EDelete)
1.1752 + {
1.1753 + aActionStr.Set(KEDelete());
1.1754 + }
1.1755 + else if (aAction == CFileMan::EMove)
1.1756 + {
1.1757 + aActionStr.Set(KEMove());
1.1758 + }
1.1759 + else if (aAction == CFileMan::ERename)
1.1760 + {
1.1761 + aActionStr.Set(KERename());
1.1762 + }
1.1763 + else if (aAction == CFileMan::ERmDir)
1.1764 + {
1.1765 + aActionStr.Set(KERmDir());
1.1766 + }
1.1767 + else if (aAction == CFileMan::ERenameInvalidEntry)
1.1768 + {
1.1769 + aActionStr.Set(KERenameInvalidEntry());
1.1770 + }
1.1771 + else if (aAction == CFileMan::ECopyFromHandle)
1.1772 + {
1.1773 + aActionStr.Set(KECopyFromHandle());
1.1774 + }
1.1775 + else
1.1776 + {
1.1777 + aActionStr.Set(KENone());
1.1778 + }
1.1779 +
1.1780 + }
1.1781 +
1.1782 +/** Reads CFileMan::TAction from INI and converts it to CFileMan::TAction type. **/
1.1783 +TBool CT_FileManData::GetActionFromConfig(const TDesC& aParameterName, const TDesC& aSection, CFileMan::TAction& aAction)
1.1784 + {
1.1785 + TPtrC actionStr;
1.1786 + TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, actionStr);
1.1787 + if(ret)
1.1788 + {
1.1789 + if (actionStr == KEAttribs)
1.1790 + {
1.1791 + aAction = CFileMan::EAttribs;
1.1792 + }
1.1793 + else if (actionStr == KECopy)
1.1794 + {
1.1795 + aAction = CFileMan::ECopy;
1.1796 + }
1.1797 + else if (actionStr == KEDelete)
1.1798 + {
1.1799 + aAction = CFileMan::EDelete;
1.1800 + }
1.1801 + else if (actionStr == KEMove)
1.1802 + {
1.1803 + aAction = CFileMan::EMove;
1.1804 + }
1.1805 + else if (actionStr == KERename)
1.1806 + {
1.1807 + aAction = CFileMan::ERename;
1.1808 + }
1.1809 + else if (actionStr == KERmDir)
1.1810 + {
1.1811 + aAction = CFileMan::ERmDir;
1.1812 + }
1.1813 + else if (actionStr == KERenameInvalidEntry)
1.1814 + {
1.1815 + aAction = CFileMan::ERenameInvalidEntry;
1.1816 + }
1.1817 + else if (actionStr == KECopyFromHandle)
1.1818 + {
1.1819 + aAction = CFileMan::ECopyFromHandle;
1.1820 + }
1.1821 + else if (actionStr == KENone)
1.1822 + {
1.1823 + aAction = CFileMan::ENone;
1.1824 + }
1.1825 + else
1.1826 + {
1.1827 + ret = EFalse;
1.1828 + }
1.1829 + }
1.1830 + return ret;
1.1831 + }
1.1832 +
1.1833 +/** Reads CFileMan::TSwitch from INI and converts it to CFileMan::TSwitch type. **/
1.1834 +TBool CT_FileManData::GetOperationFromConfig(const TDesC& aParameterName, const TDesC& aSection, TUint& aSwitch)
1.1835 + {
1.1836 + TPtrC operation;
1.1837 + TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, operation);
1.1838 + if(ret)
1.1839 + {
1.1840 + if (operation == KEOverWrite)
1.1841 + {
1.1842 + aSwitch = CFileMan::EOverWrite;
1.1843 + }
1.1844 + else if (operation == KERecurse)
1.1845 + {
1.1846 + aSwitch = CFileMan::ERecurse;
1.1847 + }
1.1848 + else
1.1849 + {
1.1850 + TInt operationInt=0;
1.1851 + ret = GET_MANDATORY_INT_PARAMETER(aParameterName, aSection, operationInt);
1.1852 + if (ret)
1.1853 + {
1.1854 + aSwitch = (CFileMan::TSwitch) operationInt;
1.1855 + }
1.1856 + }
1.1857 + }
1.1858 + return ret;
1.1859 + }
1.1860 +
1.1861 +/** Clears all arrays with history **/
1.1862 +void CT_FileManData::ClearHistory()
1.1863 + {
1.1864 + INFO_PRINTF1(_L("Clearing history!"));
1.1865 +
1.1866 + iStartedHistory.ResetAndDestroy();
1.1867 + iOperationHistory.ResetAndDestroy();
1.1868 + iEndedHistory.ResetAndDestroy();
1.1869 + }
1.1870 +
1.1871 +/**
1.1872 +* Creates a history entry.
1.1873 +* This method runs only from NotifyFileManStarted(), NotifyFileManOperation(), NotifyFileManEnded().
1.1874 +**/
1.1875 +void CT_FileManData::CreateHistoryRecord(THistoryData& aRecord)
1.1876 + {
1.1877 + TFileName source;
1.1878 + iFileMan->GetCurrentSource(source);
1.1879 + aRecord.iCurrentSource = source;
1.1880 +
1.1881 + TFileName target;
1.1882 + iFileMan->GetCurrentTarget(target);
1.1883 + aRecord.iCurrentTarget = target;
1.1884 +
1.1885 + aRecord.iCurrentEntry = iFileMan->CurrentEntry();
1.1886 + aRecord.iBytesTransferred = iFileMan->BytesTransferredByCopyStep();
1.1887 + aRecord.iCurrentAction = iFileMan->CurrentAction();
1.1888 + aRecord.iLastError = iFileMan->GetLastError();
1.1889 + aRecord.iMoreInfoAboutError = iFileMan->GetMoreInfoAboutError();
1.1890 + aRecord.iFullPath.Set( iFileMan->FullPath() );
1.1891 + aRecord.iAbbreviatedPath.Set( iFileMan->AbbreviatedPath() );
1.1892 + }
1.1893 +
1.1894 +/** Reads type of notification from INI and converts it to TObserverNotifyType **/
1.1895 +TBool CT_FileManData::GetNotifyType(const TDesC& aParameterName, const TDesC& aSection, TObserverNotifyType& aType)
1.1896 + {
1.1897 + TPtrC type;
1.1898 + TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, type);
1.1899 + if(ret)
1.1900 + {
1.1901 + if (type == KNotifyStarted)
1.1902 + {
1.1903 + aType = ENotifyStarted;
1.1904 + }
1.1905 + else if (type == KNotifyOperation)
1.1906 + {
1.1907 + aType = ENotifyOperation;
1.1908 + }
1.1909 + else if (type == KNotifyEnded)
1.1910 + {
1.1911 + aType = ENotifyEnded;
1.1912 + }
1.1913 + else
1.1914 + {
1.1915 + ret = EFalse;
1.1916 + }
1.1917 + }
1.1918 + return ret;
1.1919 + }
1.1920 +
1.1921 +/** Returns specific array of history using TObserverNotifyType value **/
1.1922 +RPointerArray<THistoryData>* CT_FileManData::GetHistoryDataByType(const TDesC& aSection)
1.1923 + {
1.1924 + TObserverNotifyType type;
1.1925 + RPointerArray<THistoryData>* history = NULL;
1.1926 + //Reads history name which must be returned.
1.1927 + if (GetNotifyType(KNotifyType(), aSection, type))
1.1928 + {
1.1929 + if(type == ENotifyStarted)
1.1930 + {
1.1931 + history = (RPointerArray<THistoryData>*)&iStartedHistory;
1.1932 + }
1.1933 + else if(type == ENotifyOperation)
1.1934 + {
1.1935 + history = (RPointerArray<THistoryData>*)&iOperationHistory;
1.1936 + }
1.1937 + else if(type == ENotifyEnded)
1.1938 + {
1.1939 + history = (RPointerArray<THistoryData>*)&iEndedHistory;
1.1940 + }
1.1941 + }
1.1942 + return history;
1.1943 + }
1.1944 +/** Reads TControl from config and converts it to TControl type **/
1.1945 +TBool CT_FileManData::GetTControlFromConfig(const TDesC& aParameterName, const TDesC& aSection, TControl& aFlag)
1.1946 + {
1.1947 + TPtrC flag;
1.1948 + TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, flag);
1.1949 + if(ret)
1.1950 + {
1.1951 + if (flag == KEContinue)
1.1952 + {
1.1953 + aFlag = EContinue;
1.1954 + }
1.1955 + else if (flag == KEAbort)
1.1956 + {
1.1957 + aFlag = EAbort;
1.1958 + }
1.1959 + else if (flag == KECancel)
1.1960 + {
1.1961 + aFlag = ECancel;
1.1962 + }
1.1963 + else if (flag == KERetry)
1.1964 + {
1.1965 + aFlag = ERetry;
1.1966 + }
1.1967 + else
1.1968 + {
1.1969 + ret = EFalse;
1.1970 + }
1.1971 + }
1.1972 + return ret;
1.1973 + }
1.1974 +
1.1975 +/** Reads TControl and file name from INI **/
1.1976 +void CT_FileManData::ReadTControl(const TDesC& aSection)
1.1977 + {
1.1978 + TBool dataOk = ETrue;
1.1979 + if(!GetNotifyType(KNotifyType(), aSection, iObserverNotifyType))
1.1980 + {
1.1981 + dataOk = EFalse;
1.1982 + }
1.1983 + TPtrC fileName;
1.1984 + if(GET_MANDATORY_STRING_PARAMETER(KFileName(), aSection, fileName))
1.1985 + {
1.1986 + iNotifyFileName = fileName;
1.1987 + }
1.1988 + else
1.1989 + {
1.1990 + dataOk = EFalse;
1.1991 + }
1.1992 + if(!GetTControlFromConfig(KFlag(), aSection, iTControl))
1.1993 + {
1.1994 + dataOk = EFalse;
1.1995 + }
1.1996 + if(dataOk)
1.1997 + {
1.1998 + iUseTControl = ETrue;
1.1999 + }
1.2000 + }
1.2001 +
1.2002 +