sl@0: /* sl@0: * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @test sl@0: @internalComponent sl@0: sl@0: This contains CT_FileManData sl@0: */ sl@0: sl@0: // User includes sl@0: #include "T_FileManData.h" sl@0: #include "T_SfSrvServer.h" sl@0: sl@0: const TInt KMaxFileNameLength =255; sl@0: sl@0: /*@{*/ sl@0: /// Parameters sl@0: _LIT(KPath, "path"); sl@0: _LIT(KFileName, "filename"); sl@0: _LIT(KFileFrom, "filefrom"); sl@0: _LIT(KFileTo, "fileto"); sl@0: _LIT(KOldName, "oldname"); sl@0: _LIT(KNewName, "newname"); sl@0: _LIT(KRFsObject, "rfsObject"); sl@0: _LIT(KRFileObject, "rfileObject"); sl@0: _LIT(KUseObserver, "use_observer"); sl@0: _LIT(KAsync, "async"); sl@0: _LIT(KTime, "time"); sl@0: _LIT(KSetMask, "setmask"); sl@0: _LIT(KClearMask, "clearmask"); sl@0: _LIT(KOperation, "operation"); sl@0: _LIT(KCurrentAction, "current_action"); sl@0: _LIT(KBytes, "bytes"); sl@0: _LIT(KError, "error"); sl@0: _LIT(KTarget, "target"); sl@0: _LIT(KSource, "source"); sl@0: _LIT(KNotifyType, "notify_type"); sl@0: _LIT(KReadHistory, "read_history"); sl@0: _LIT(KName, "name"); sl@0: _LIT(KNullDesCStr, "KNullDesC"); sl@0: _LIT(KTotalBytes, "total_bytes"); sl@0: _LIT(KFlag, "flag"); sl@0: _LIT(KClearHistory, "clear_history"); sl@0: _LIT(KSetTcontrol, "set_tcontrol"); sl@0: //For searching file names. sl@0: _LIT(KPattern, "*%S*"); sl@0: sl@0: /// Commands sl@0: _LIT(KCmdNewL, "NewL"); sl@0: _LIT(KCmdAttribs, "Attribs"); sl@0: _LIT(KCmdCopy, "Copy"); sl@0: _LIT(KCmdMove, "Move"); sl@0: _LIT(KCmdDelete, "Delete"); sl@0: _LIT(KCmdRename, "Rename"); sl@0: _LIT(KCmdRmDir, "RmDir"); sl@0: _LIT(KCmdSetObserver, "SetObserver"); sl@0: _LIT(KCmdCurrentAction, "CurrentAction"); sl@0: _LIT(KCmdGetCurrentTarget, "GetCurrentTarget"); sl@0: _LIT(KCmdGetCurrentSource, "GetCurrentSource"); sl@0: _LIT(KCmdBytesTransferredByCopyStep, "BytesTransferredByCopyStep"); sl@0: _LIT(KCmdCurrentEntry, "CurrentEntry"); sl@0: _LIT(KCmdAbbreviatedPath, "AbbreviatedPath"); sl@0: _LIT(KCmdFullPath, "FullPath"); sl@0: _LIT(KCmdGetLastError, "GetLastError"); sl@0: _LIT(KCmdGetMoreInfoAboutError, "GetMoreInfoAboutError"); sl@0: _LIT(KCmdDestructor, "~"); sl@0: sl@0: // TActions sl@0: _LIT(KENone, "ENone"); sl@0: _LIT(KEAttribs, "EAttribs"); sl@0: _LIT(KECopy, "ECopy"); sl@0: _LIT(KEDelete, "EDelete"); sl@0: _LIT(KEMove, "EMove"); sl@0: _LIT(KERename, "ERename"); sl@0: _LIT(KERmDir, "ERmDir"); sl@0: _LIT(KERenameInvalidEntry, "ERenameInvalidEntry"); sl@0: _LIT(KECopyFromHandle, "ECopyFromHandle"); sl@0: sl@0: sl@0: // TSwitch sl@0: _LIT(KEOverWrite, "EOverWrite"); sl@0: _LIT(KERecurse, "ERecurse"); sl@0: sl@0: // TControl sl@0: _LIT(KEContinue, "EContinue"); sl@0: _LIT(KEAbort, "EAbort"); sl@0: _LIT(KECancel, "ECancel"); sl@0: _LIT(KERetry, "ERetry"); sl@0: sl@0: // TFileManError sl@0: _LIT(KENoExtraInformation, "ENoExtraInformation"); sl@0: _LIT(KEInitializationFailed, "EInitializationFailed"); sl@0: _LIT(KEScanNextDirectoryFailed, "EScanNextDirectoryFailed"); sl@0: _LIT(KESrcOpenFailed, "ESrcOpenFailed"); sl@0: _LIT(KETrgOpenFailed, "ETrgOpenFailed"); sl@0: _LIT(KENoFilesProcessed, "ENoFilesProcessed"); sl@0: sl@0: //Notifys sl@0: _LIT(KNotifyStarted, "started"); sl@0: _LIT(KNotifyOperation, "operation"); sl@0: _LIT(KNotifyEnded, "ended"); sl@0: sl@0: sl@0: sl@0: CT_FileManData* CT_FileManData::NewL() sl@0: /** sl@0: * Two phase constructor sl@0: */ sl@0: { sl@0: CT_FileManData* ret = new (ELeave) CT_FileManData(); sl@0: CleanupStack::PushL(ret); sl@0: ret->ConstructL(); sl@0: CleanupStack::Pop(ret); sl@0: return ret; sl@0: } sl@0: sl@0: sl@0: CT_FileManData::CT_FileManData() sl@0: : iFileMan(NULL) sl@0: , iAsyncErrorIndex(0) sl@0: , iAsyncCall(EFalse) sl@0: , iFileManObserver(NULL) sl@0: , iUseTControl(EFalse) sl@0: sl@0: /** sl@0: * Protected constructor. First phase construction sl@0: */ sl@0: { sl@0: } sl@0: sl@0: sl@0: void CT_FileManData::ConstructL() sl@0: /** sl@0: * Protected constructor. Second phase construction sl@0: */ sl@0: { sl@0: } sl@0: sl@0: sl@0: CT_FileManData::~CT_FileManData() sl@0: /** sl@0: * Destructor. sl@0: */ sl@0: { sl@0: DoCleanup(); sl@0: sl@0: iAttribs.ResetAndDestroy(); sl@0: iCopy.ResetAndDestroy(); sl@0: iDelete.ResetAndDestroy(); sl@0: iMove.ResetAndDestroy(); sl@0: iRename.ResetAndDestroy(); sl@0: iRmDir.ResetAndDestroy(); sl@0: sl@0: ClearHistory(); sl@0: } sl@0: sl@0: TAny* CT_FileManData::GetObject() sl@0: { sl@0: return iFileMan; sl@0: } sl@0: sl@0: sl@0: TBool CT_FileManData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) sl@0: /** sl@0: * Process a command read from the ini file sl@0: * sl@0: * @param aCommand the command to process sl@0: * @param aSection the section in the ini file requiring the command to be processed sl@0: * sl@0: * @return ETrue if the command is processed sl@0: */ sl@0: { sl@0: TBool retVal = ETrue; sl@0: sl@0: if (aCommand == KCmdNewL) sl@0: { sl@0: DoCmdNewL(aSection); sl@0: } sl@0: else if (aCommand == KCmdDestructor) sl@0: { sl@0: DoCleanup(); sl@0: } sl@0: else if (aCommand == KCmdAttribs) sl@0: { sl@0: DoCmdAttribsL(aSection, aAsyncErrorIndex); sl@0: } sl@0: else if (aCommand == KCmdCopy) sl@0: { sl@0: DoCmdCopyL(aSection, aAsyncErrorIndex); sl@0: } sl@0: else if (aCommand == KCmdMove) sl@0: { sl@0: DoCmdMoveL(aSection, aAsyncErrorIndex); sl@0: } sl@0: else if (aCommand == KCmdDelete) sl@0: { sl@0: DoCmdDeleteL(aSection, aAsyncErrorIndex); sl@0: } sl@0: else if (aCommand == KCmdRename) sl@0: { sl@0: DoCmdRenameL(aSection, aAsyncErrorIndex); sl@0: } sl@0: else if (aCommand == KCmdRmDir) sl@0: { sl@0: DoCmdRmDirL(aSection, aAsyncErrorIndex); sl@0: } sl@0: else if (aCommand == KCmdSetObserver) sl@0: { sl@0: DoCmdSetObserver(); sl@0: } sl@0: else if (aCommand == KCmdCurrentAction) sl@0: { sl@0: DoCmdCurrentAction(aSection); sl@0: } sl@0: else if (aCommand == KCmdGetCurrentTarget) sl@0: { sl@0: DoCmdGetCurrentTarget(aSection); sl@0: } sl@0: else if (aCommand == KCmdGetCurrentSource) sl@0: { sl@0: DoCmdGetCurrentSource(aSection); sl@0: } sl@0: else if (aCommand == KCmdBytesTransferredByCopyStep) sl@0: { sl@0: DoCmdBytesTransferredByCopyStep(aSection); sl@0: } sl@0: else if(aCommand == KCmdCurrentEntry) sl@0: { sl@0: DoCmdCurrentEntryL(aSection); sl@0: } sl@0: else if(aCommand == KCmdAbbreviatedPath) sl@0: { sl@0: DoCmdAbbreviatedPath(aSection); sl@0: } sl@0: else if(aCommand == KCmdFullPath) sl@0: { sl@0: DoCmdFullPath(aSection); sl@0: } sl@0: else if(aCommand == KCmdGetLastError) sl@0: { sl@0: DoCmdGetLastError(aSection); sl@0: } sl@0: else if(aCommand == KCmdGetMoreInfoAboutError) sl@0: { sl@0: DoCmdGetMoreInfoAboutError(aSection); sl@0: } sl@0: return retVal; sl@0: } sl@0: sl@0: void CT_FileManData::DoCleanup() sl@0: { sl@0: INFO_PRINTF1(_L("Doing cleanup")); sl@0: sl@0: if (iFileMan) sl@0: { sl@0: delete(iFileMan); sl@0: iFileMan = NULL; sl@0: } sl@0: ClearHistory(); sl@0: } sl@0: sl@0: /** Inform the observer that an operation is about to start **/ sl@0: MFileManObserver::TControl CT_FileManData::NotifyFileManStarted() sl@0: { sl@0: THistoryData *record = new THistoryData(); sl@0: CreateHistoryRecord(*record); sl@0: iStartedHistory.Append(record); sl@0: if(record->iLastError != KErrNone) sl@0: { sl@0: if(iAsyncCall) sl@0: { sl@0: SetAsyncError(iAsyncErrorIndex, record->iLastError); sl@0: iAsyncCall = EFalse; sl@0: } sl@0: else sl@0: { sl@0: SetError(record->iLastError); sl@0: } sl@0: } sl@0: TControl ret = EContinue; sl@0: //Check if we need to return TControl value specified in INI. sl@0: if(iUseTControl && iObserverNotifyType == ENotifyStarted) sl@0: { sl@0: TBuf buffer; sl@0: buffer.Format(KPattern(), &iNotifyFileName); sl@0: //Check if we need to return TControl for this file. sl@0: if(record->iCurrentSource.Match(buffer) != KErrNotFound) sl@0: { sl@0: iUseTControl = EFalse; sl@0: ret = iTControl; sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: /** Informs the observer that an operation, i.e. a copy or a move, is proceeding. **/ sl@0: MFileManObserver::TControl CT_FileManData::NotifyFileManOperation() sl@0: { sl@0: THistoryData *record = new THistoryData(); sl@0: CreateHistoryRecord(*record); sl@0: iOperationHistory.Append(record); sl@0: if(record->iLastError != KErrNone) sl@0: { sl@0: if(iAsyncCall) sl@0: { sl@0: SetAsyncError(iAsyncErrorIndex, record->iLastError); sl@0: iAsyncCall = EFalse; sl@0: } sl@0: else sl@0: { sl@0: SetError(record->iLastError); sl@0: } sl@0: } sl@0: TControl ret = EContinue; sl@0: //Check if we need to return TControl value specified in INI. sl@0: if(iUseTControl && iObserverNotifyType == ENotifyOperation) sl@0: { sl@0: TBuf buffer; sl@0: buffer.Format(KPattern(), &iNotifyFileName); sl@0: //Check if we need to return TControl for this file. sl@0: if(record->iCurrentSource.Match(buffer) != KErrNotFound) sl@0: { sl@0: iUseTControl = EFalse; sl@0: ret = iTControl; sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: /** Informs the observer that an operation is complete. **/ sl@0: MFileManObserver::TControl CT_FileManData::NotifyFileManEnded() sl@0: { sl@0: THistoryData *record = new THistoryData(); sl@0: CreateHistoryRecord(*record); sl@0: iEndedHistory.Append(record); sl@0: if(record->iLastError != KErrNone) sl@0: { sl@0: if(iAsyncCall) sl@0: { sl@0: SetAsyncError(iAsyncErrorIndex, record->iLastError); sl@0: iAsyncCall = EFalse; sl@0: } sl@0: else sl@0: { sl@0: SetError(record->iLastError); sl@0: } sl@0: } sl@0: TControl ret = EContinue; sl@0: //Check if we need to return TControl value specified in INI. sl@0: if(iUseTControl && iObserverNotifyType == ENotifyEnded) sl@0: { sl@0: TBuf buffer; sl@0: buffer.Format(KPattern(), &iNotifyFileName); sl@0: //Check if we need to return TControl for this file. sl@0: if(record->iCurrentSource.Match(buffer) != KErrNotFound) sl@0: { sl@0: iUseTControl = EFalse; sl@0: ret = iTControl; sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdNewL(const TDesC& aSection) sl@0: { sl@0: DoCleanup(); sl@0: TBool useObserver = EFalse; sl@0: sl@0: GET_OPTIONAL_BOOL_PARAMETER(KUseObserver, aSection, useObserver); sl@0: sl@0: TPtrC rfsObjectName; sl@0: RFs* rfsObject = NULL; sl@0: if (GET_MANDATORY_STRING_PARAMETER(KRFsObject, aSection, rfsObjectName)) sl@0: { sl@0: rfsObject = (RFs*)GetDataObjectL(rfsObjectName); sl@0: } sl@0: sl@0: TInt err = KErrNone; sl@0: if(useObserver) sl@0: { sl@0: INFO_PRINTF1(_L("CFileMan::NewL(RFs, MFileManObserver)")); sl@0: TRAP(err, iFileMan = CFileMan::NewL(*rfsObject, iFileManObserver)); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("CFileMan::NewL(RFs)")); sl@0: TRAP(err, iFileMan = CFileMan::NewL(*rfsObject)); sl@0: } sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF1(_L("CFileMan object is not created")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdAttribsL(const TDesC& aSection, TInt aAsyncErrorIndex) sl@0: { sl@0: INFO_PRINTF1(_L("Setting attributes!")); sl@0: sl@0: TBool dataOk = ETrue; sl@0: sl@0: //Reading path for file or files. sl@0: TPtrC fileName; sl@0: if (!GET_MANDATORY_STRING_PARAMETER(KFileName, aSection, fileName)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: //Reading new TTime from ini sl@0: TPtrC inputTime; sl@0: TTime iniTime; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KTime, aSection, inputTime)) sl@0: { sl@0: TInt err = iniTime.Set(inputTime); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("Cannot convert (%S) to time. Error: %d"), &inputTime ,err); sl@0: dataOk = EFalse; sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: //Reading Async parameter (True/False) sl@0: TBool async = EFalse; sl@0: if(!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: //Read SetMask attribute sl@0: TUint setMask; sl@0: if(!FileserverUtil::GetAttMask(*this, aSection, KSetMask(), setMask)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: //Read ClearMask attribute sl@0: TUint clearMask; sl@0: if(!FileserverUtil::GetAttMask(*this, aSection, KClearMask(), clearMask)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: //Read operation TSwitch sl@0: TUint operation; sl@0: if(!GetOperationFromConfig(KOperation(), aSection, operation)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(async) sl@0: { sl@0: CActiveCallback* active = CActiveCallback::NewLC(*this); sl@0: iAttribs.AppendL(active); sl@0: CleanupStack::Pop(active); sl@0: error = iFileMan->Attribs(fileName, setMask, clearMask, iniTime, operation, active->iStatus); sl@0: if(error == KErrNone) sl@0: { sl@0: active->Activate(aAsyncErrorIndex); sl@0: iAsyncErrorIndex = aAsyncErrorIndex; sl@0: iAsyncCall = ETrue; sl@0: IncOutstanding(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: error = iFileMan->Attribs(fileName, setMask, clearMask, iniTime, operation); sl@0: } sl@0: if (error != KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("Attribs(%S) Error: %d"), &fileName, error); sl@0: SetError(error); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Attribs operation on (%S) is successfull!"), &fileName); sl@0: } sl@0: } sl@0: } sl@0: void CT_FileManData::DoCmdCopyL(const TDesC& aSection, TInt aAsyncErrorIndex) sl@0: { sl@0: TBool clearHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory); sl@0: if(clearHistory) sl@0: { sl@0: ClearHistory(); sl@0: } sl@0: TBool setTControl = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl); sl@0: if(setTControl) sl@0: { sl@0: ReadTControl(aSection); sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("Coping files!")); sl@0: TBool dataOk = ETrue; sl@0: TPtrC oldName; sl@0: TPtrC rfileObjectName; sl@0: RFile* rfileObject = NULL; sl@0: sl@0: if (!GET_OPTIONAL_STRING_PARAMETER(KOldName, aSection, oldName)) sl@0: { sl@0: if (GET_OPTIONAL_STRING_PARAMETER(KRFileObject, aSection, rfileObjectName)) sl@0: { sl@0: rfileObject = (RFile*)GetDataObjectL(rfileObjectName); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Cannot read \"oldname\" or \"rfileObject\" arguments!")); sl@0: SetBlockResult(EFail); sl@0: dataOk = EFalse; sl@0: } sl@0: } sl@0: sl@0: TPtrC newName; sl@0: if (!GET_MANDATORY_STRING_PARAMETER(KNewName, aSection, newName)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: TUint operation; sl@0: if (!GetOperationFromConfig(KOperation, aSection, operation)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: TBool async; sl@0: if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: if(dataOk) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(async) sl@0: { sl@0: CActiveCallback* active = CActiveCallback::NewLC(*this); sl@0: iCopy.AppendL(active); sl@0: CleanupStack::Pop(active); sl@0: if(rfileObject) sl@0: { sl@0: error = iFileMan->Copy(*rfileObject, newName, operation, active->iStatus); sl@0: } sl@0: else sl@0: { sl@0: error = iFileMan->Copy(oldName, newName, operation, active->iStatus); sl@0: } sl@0: if(error == KErrNone) sl@0: { sl@0: active->Activate(aAsyncErrorIndex); sl@0: iAsyncErrorIndex = aAsyncErrorIndex; sl@0: iAsyncCall = ETrue; sl@0: IncOutstanding(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: if(rfileObject) sl@0: { sl@0: error = iFileMan->Copy(*rfileObject, newName, operation); sl@0: } sl@0: else sl@0: { sl@0: error = iFileMan->Copy(oldName, newName, operation); sl@0: } sl@0: } sl@0: if (error != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Copy(), Error: %d"), error); sl@0: SetError(error); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Copy() operation is successfully!")); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdDeleteL(const TDesC& aSection, TInt aAsyncErrorIndex) sl@0: { sl@0: TBool clearHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory); sl@0: if(clearHistory) sl@0: { sl@0: ClearHistory(); sl@0: } sl@0: TBool setTControl = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl); sl@0: if(setTControl) sl@0: { sl@0: ReadTControl(aSection); sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("Deleting files!")); sl@0: sl@0: TBool dataOk = ETrue; sl@0: TPtrC fileName; sl@0: if (GET_MANDATORY_STRING_PARAMETER(KFileName, aSection, fileName)) sl@0: { sl@0: if(fileName == KNullDesCStr) sl@0: { sl@0: fileName.Set(KNullDesC); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: TUint operation; sl@0: if(!GetOperationFromConfig(KOperation, aSection, operation)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: TBool async = EFalse; sl@0: if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(async) sl@0: { sl@0: CActiveCallback* active = CActiveCallback::NewLC(*this); sl@0: iDelete.AppendL(active); sl@0: CleanupStack::Pop(active); sl@0: error = iFileMan->Delete(fileName, operation, active->iStatus); sl@0: if (error == KErrNone) sl@0: { sl@0: active->Activate(aAsyncErrorIndex); sl@0: iAsyncErrorIndex = aAsyncErrorIndex; sl@0: iAsyncCall = ETrue; sl@0: IncOutstanding(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: error = iFileMan->Delete(fileName, operation); sl@0: } sl@0: sl@0: if (error != KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("Delete (%S), Error: %d"), &fileName, error); sl@0: SetError(error); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Delete (%S) operation is successfully!"), &fileName); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdMoveL(const TDesC& aSection, TInt aAsyncErrorIndex) sl@0: { sl@0: TBool clearHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory); sl@0: if(clearHistory) sl@0: { sl@0: ClearHistory(); sl@0: } sl@0: TBool setTControl = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl); sl@0: if(setTControl) sl@0: { sl@0: ReadTControl(aSection); sl@0: } sl@0: sl@0: INFO_PRINTF1(_L("Moving files!")); sl@0: sl@0: TBool dataOk = ETrue; sl@0: TPtrC fileFrom; sl@0: if (!GET_MANDATORY_STRING_PARAMETER(KFileFrom, aSection, fileFrom)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: TPtrC fileTo; sl@0: if (!GET_MANDATORY_STRING_PARAMETER(KFileTo, aSection, fileTo)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: TBool async; sl@0: if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: TUint operation; sl@0: if (!GetOperationFromConfig(KOperation, aSection, operation)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(async) sl@0: { sl@0: CActiveCallback* active = CActiveCallback::NewLC(*this); sl@0: iMove.AppendL(active); sl@0: CleanupStack::Pop(active); sl@0: error = iFileMan->Move(fileFrom, fileTo, operation, active->iStatus); sl@0: if(error == KErrNone) sl@0: { sl@0: active->Activate(aAsyncErrorIndex); sl@0: iAsyncErrorIndex = aAsyncErrorIndex; sl@0: iAsyncCall = ETrue; sl@0: IncOutstanding(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: error = iFileMan->Move(fileFrom, fileTo, operation); sl@0: } sl@0: if (error != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Move(), Error: %d"), error); sl@0: SetError(error); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Move() operation is successfully!")); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdRenameL(const TDesC& aSection, TInt aAsyncErrorIndex) sl@0: { sl@0: TBool clearHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KClearHistory, aSection, clearHistory); sl@0: if(clearHistory) sl@0: { sl@0: ClearHistory(); sl@0: } sl@0: TBool setTControl = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KSetTcontrol, aSection, setTControl); sl@0: if(setTControl) sl@0: { sl@0: ReadTControl(aSection); sl@0: } sl@0: INFO_PRINTF1(_L("Renaming files!")); sl@0: sl@0: TBool dataOk = ETrue; sl@0: sl@0: //Reading Old Name sl@0: TPtrC oldName; sl@0: if (!GET_MANDATORY_STRING_PARAMETER(KOldName, aSection, oldName)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: //Reading New Name sl@0: TPtrC newName; sl@0: if (!GET_MANDATORY_STRING_PARAMETER(KNewName, aSection, newName)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: //Rading TSwitch - Operation sl@0: TUint operation; sl@0: if (!GetOperationFromConfig(KOperation(), aSection, operation)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: //Reading async sl@0: TBool async; sl@0: if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(async) sl@0: { sl@0: CActiveCallback* active = CActiveCallback::NewLC(*this); sl@0: iRename.AppendL(active); sl@0: CleanupStack::Pop(active); sl@0: error = iFileMan->Rename(oldName, newName, operation, active->iStatus); sl@0: if(error == KErrNone) sl@0: { sl@0: active->Activate(aAsyncErrorIndex); sl@0: iAsyncErrorIndex = aAsyncErrorIndex; sl@0: iAsyncCall = ETrue; sl@0: IncOutstanding(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: error = iFileMan->Rename(oldName, newName, operation); sl@0: } sl@0: if (error != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Rename() Error: %d"), error); sl@0: SetError(error); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("Rename() operation is successfully!")); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdRmDirL(const TDesC& aSection, TInt aAsyncErrorIndex) sl@0: { sl@0: INFO_PRINTF1(_L("Removing directory!")); sl@0: sl@0: TBool dataOk = ETrue; sl@0: TPtrC path; sl@0: sl@0: if (!GET_MANDATORY_STRING_PARAMETER(KPath, aSection, path)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: TBool async = EFalse; sl@0: if (!GET_MANDATORY_BOOL_PARAMETER(KAsync, aSection, async)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: sl@0: if(dataOk) sl@0: { sl@0: TInt error = KErrNone; sl@0: if(async) sl@0: { sl@0: CActiveCallback* active = CActiveCallback::NewLC(*this); sl@0: iRmDir.AppendL(active); sl@0: CleanupStack::Pop(active); sl@0: error = iFileMan->RmDir(path, active->iStatus); sl@0: if(error == KErrNone) sl@0: { sl@0: active->Activate(aAsyncErrorIndex); sl@0: iAsyncErrorIndex = aAsyncErrorIndex; sl@0: iAsyncCall = ETrue; sl@0: IncOutstanding(); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: error = iFileMan->RmDir(path); sl@0: } sl@0: if (error != KErrNone) sl@0: { sl@0: ERR_PRINTF3(_L("RmDir(%S), Error: %d"), &path, error); sl@0: SetError(error); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("Callled RmDir(%S)"), &path); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdSetObserver() sl@0: { sl@0: INFO_PRINTF1(_L("Setting observer")); sl@0: sl@0: iFileMan->SetObserver(this); sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdCurrentAction(const TDesC& aSection) sl@0: { sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: CFileMan::TAction currentAction = CFileMan::ENone; sl@0: TBool found = ETrue; sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: CFileMan::TAction expectedAction; sl@0: found = EFalse; sl@0: if(GetActionFromConfig(KCurrentAction(), aSection, expectedAction)) sl@0: { sl@0: CFileMan::TAction action; sl@0: TInt count = history->Count(); sl@0: /** Search for expected TAction in history **/ sl@0: for(TInt i = 0; (i < count) && (!found); i++) sl@0: { sl@0: action = ((*history)[i])->iCurrentAction; sl@0: if( action == expectedAction) sl@0: { sl@0: currentAction = action; sl@0: found = ETrue; sl@0: } sl@0: } sl@0: if(!found) sl@0: { sl@0: TPtrC expectedActionStr; sl@0: ConvertActionToString(expectedAction, expectedActionStr); sl@0: ERR_PRINTF2(_L("CurrentAction() %S not found in history!"), &expectedActionStr); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Cannot read %S"), &KCurrentAction()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: currentAction = iFileMan->CurrentAction(); sl@0: } sl@0: sl@0: if(found) sl@0: { sl@0: TPtrC actionStr; sl@0: ConvertActionToString(currentAction, actionStr); sl@0: sl@0: CFileMan::TAction expectedAction; sl@0: if(GetActionFromConfig(KCurrentAction(), aSection, expectedAction)) sl@0: { sl@0: TPtrC expectedActionStr; sl@0: ConvertActionToString(expectedAction, expectedActionStr); sl@0: if(expectedAction != currentAction) sl@0: { sl@0: ERR_PRINTF3(_L("CurrentAction(): %S != %S Expected Action"), &actionStr, &expectedActionStr); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("CurrentAction(): %S == %S Expected Action"), &actionStr, &expectedActionStr); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("CurrentAction: %S"), &actionStr); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdGetCurrentTarget(const TDesC& aSection) sl@0: { sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: TFileName target; sl@0: TBool found = ETrue; sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: TPtrC expectedTarget; sl@0: found = EFalse; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KTarget, aSection, expectedTarget)) sl@0: { sl@0: TInt count = history->Count(); sl@0: /** Search for expected target in history **/ sl@0: for(TInt i = 0; (!found) && (i < count); i++) sl@0: { sl@0: if( ((*history)[i])->iCurrentTarget == expectedTarget) sl@0: { sl@0: target = ((*history)[i])->iCurrentTarget; sl@0: found = ETrue; sl@0: } sl@0: } sl@0: if(!found) sl@0: { sl@0: ERR_PRINTF2(_L("GetCurrentTarget() %S not found in history!"), &expectedTarget); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: iFileMan->GetCurrentTarget(target); sl@0: } sl@0: if(found) sl@0: { sl@0: TPtrC expectedTarget; sl@0: if(GET_OPTIONAL_STRING_PARAMETER(KTarget, aSection, expectedTarget)) sl@0: { sl@0: if(target == expectedTarget) sl@0: { sl@0: INFO_PRINTF3(_L("GetCurrentTarget() %S == %S ExpectedResult"), &target, &expectedTarget); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("GetCurrentTarget() %S != %S ExpectedResult"), &target, &expectedTarget); sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("GetCurrentTarget() %S"), &target); sl@0: } sl@0: } sl@0: } sl@0: void CT_FileManData::DoCmdGetCurrentSource(const TDesC& aSection) sl@0: { sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: TFileName source; sl@0: TBool found = ETrue; sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: TPtrC expectedSource; sl@0: found = EFalse; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KSource, aSection, expectedSource)) sl@0: { sl@0: TInt count = history->Count(); sl@0: /** Search for expected source in history **/ sl@0: for(TInt i = 0; (!found) && (i < count); i++) sl@0: { sl@0: if( (*history)[i]->iCurrentSource == expectedSource) sl@0: { sl@0: source = (*history)[i]->iCurrentSource; sl@0: found = ETrue; sl@0: } sl@0: } sl@0: if(!found) sl@0: { sl@0: ERR_PRINTF2(_L("GetCurrentSource() %S not found in history!"), &expectedSource); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: iFileMan->GetCurrentSource(source); sl@0: } sl@0: sl@0: if (found) sl@0: { sl@0: TPtrC expectedSource; sl@0: if(GET_OPTIONAL_STRING_PARAMETER(KSource, aSection, expectedSource)) sl@0: { sl@0: if(source == expectedSource) sl@0: { sl@0: INFO_PRINTF3(_L("GetCurrentSource() %S == %S ExpectedResult"), &source, &expectedSource); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF3(_L("GetCurrentSource() %S != %S ExpectedResult"), &source, &expectedSource); sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("GetCurrentSource() %S"), &source); sl@0: } sl@0: } sl@0: sl@0: } sl@0: void CT_FileManData::DoCmdBytesTransferredByCopyStep(const TDesC& aSection) sl@0: { sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: TInt bytes = 0; sl@0: TBool found = ETrue; sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: TInt expectedBytes; sl@0: found = EFalse; sl@0: if(GET_MANDATORY_INT_PARAMETER(KBytes, aSection, expectedBytes)) sl@0: { sl@0: TBool totalBytes = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KTotalBytes, aSection, totalBytes); sl@0: TInt count = history->Count(); sl@0: TInt bytesTemp; sl@0: /** Search for expected transferred bytes in history **/ sl@0: for(TInt i = 0; (!found) && (i < count); i++) sl@0: { sl@0: bytesTemp = ((*history)[i])->iBytesTransferred; sl@0: if(totalBytes) sl@0: { sl@0: bytes +=bytesTemp; sl@0: } sl@0: else sl@0: { sl@0: if( bytesTemp == expectedBytes) sl@0: { sl@0: bytes = bytesTemp; sl@0: found = ETrue; sl@0: } sl@0: } sl@0: } sl@0: if(totalBytes) sl@0: { sl@0: found = ETrue; sl@0: } sl@0: if(!found) sl@0: { sl@0: ERR_PRINTF2(_L("BytesTransferredByCopyStep() %d not found in history!"), expectedBytes); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: bytes = iFileMan->BytesTransferredByCopyStep(); sl@0: } sl@0: if (found) sl@0: { sl@0: TInt expectedBytes; sl@0: if(GET_OPTIONAL_INT_PARAMETER(KBytes, aSection, expectedBytes)) sl@0: { sl@0: if(expectedBytes != bytes) sl@0: { sl@0: ERR_PRINTF3(_L("BytesTransferredByCopyStep(): %d != %d Expected Bytes"), bytes, expectedBytes); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("BytesTransferredByCopyStep(): %d == %d Expected Bytes"), bytes, expectedBytes); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("BytesTransferredByCopyStep(): %d"), bytes); sl@0: } sl@0: } sl@0: } sl@0: void CT_FileManData::DoCmdCurrentEntryL(const TDesC& aSection) sl@0: { sl@0: sl@0: TEntry* entryObject = NULL; sl@0: TBool found = ETrue; sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: TPtrC expectedName; sl@0: found = EFalse; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KName, aSection, expectedName)) sl@0: { sl@0: TInt count = history->Count(); sl@0: TEntry entry; sl@0: /** Search for expected TEntry.iName in history **/ sl@0: for(TInt i = 0; (!found) && (i < count); i++) sl@0: { sl@0: entry = ((*history)[i])->iCurrentEntry; sl@0: if( entry.iName == expectedName) sl@0: { sl@0: entryObject = &entry; sl@0: found = ETrue; sl@0: } sl@0: } sl@0: if(!found) sl@0: { sl@0: ERR_PRINTF1(_L("CurrentEntry() not found in history!")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: *entryObject = iFileMan->CurrentEntry(); sl@0: } sl@0: if(found) sl@0: { sl@0: if(!FileserverUtil::VerifyTEntryDataFromIniL(*this, aSection, *entryObject)) sl@0: { sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: } sl@0: void CT_FileManData::DoCmdAbbreviatedPath(const TDesC& aSection) sl@0: { sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: TPtrC path; sl@0: TBool found = ETrue; sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: TPtrC expectedPath; sl@0: found = EFalse; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KPath, aSection, expectedPath)) sl@0: { sl@0: TInt count = history->Count(); sl@0: /** Search for expected abbreviated path in history **/ sl@0: for(TInt i = 0; (!found) && (i < count); i++) sl@0: { sl@0: if( ((*history)[i])->iAbbreviatedPath == expectedPath) sl@0: { sl@0: path.Set(((*history)[i])->iAbbreviatedPath); sl@0: found = ETrue; sl@0: } sl@0: } sl@0: if(!found) sl@0: { sl@0: ERR_PRINTF2(_L("AbbreviatedPath() %S not found in history!"), &expectedPath); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: path.Set(iFileMan->AbbreviatedPath()); sl@0: } sl@0: sl@0: if (found) sl@0: { sl@0: TPtrC expectedPath; sl@0: if(GET_OPTIONAL_STRING_PARAMETER(KPath, aSection, expectedPath)) sl@0: { sl@0: if(expectedPath.Compare(path) != 0) sl@0: { sl@0: ERR_PRINTF3(_L("AbbreviatedPath(): %S != %S Expected Path"), &path, &expectedPath); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("AbbreviatedPath(): %S == %S Expected Path"), &path, &expectedPath); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("AbbreviatedPath(): %S"), &path); sl@0: } sl@0: } sl@0: } sl@0: void CT_FileManData::DoCmdFullPath(const TDesC& aSection) sl@0: { sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: TPtrC fullPath; sl@0: TBool found = ETrue; sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: TPtrC expectedPath; sl@0: found = EFalse; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KPath, aSection, expectedPath)) sl@0: { sl@0: TInt count = history->Count(); sl@0: /** Search for expected full path in history **/ sl@0: for(TInt i = 0; (!found) && (i < count); i++) sl@0: { sl@0: if( ((*history)[i])->iFullPath == expectedPath) sl@0: { sl@0: fullPath.Set(((*history)[i])->iFullPath); sl@0: found = ETrue; sl@0: } sl@0: } sl@0: if(!found) sl@0: { sl@0: ERR_PRINTF2(_L("FullPath() %S not found in history!"), &expectedPath); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: fullPath.Set(iFileMan->FullPath()); sl@0: } sl@0: if(found) sl@0: { sl@0: TPtrC expectedPath; sl@0: if(GET_OPTIONAL_STRING_PARAMETER(KPath, aSection, expectedPath)) sl@0: { sl@0: if(expectedPath.Compare(fullPath) != 0) sl@0: { sl@0: ERR_PRINTF3(_L("FullPath(): %S != %S Expected Path"), &fullPath, &expectedPath); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("FullPath(): %S == %S Expected Path"), &fullPath, &expectedPath); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("FullPath(): %S"), &fullPath); sl@0: } sl@0: } sl@0: } sl@0: void CT_FileManData::DoCmdGetLastError(const TDesC& aSection) sl@0: { sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: TInt lastError = KErrNone; sl@0: TBool found = ETrue; sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: TInt expectedError; sl@0: found = EFalse; sl@0: if(GET_MANDATORY_INT_PARAMETER(KError, aSection, expectedError)) sl@0: { sl@0: TInt count = history->Count(); sl@0: TInt err; sl@0: /** Search for expected error in history **/ sl@0: for(TInt i = 0; (!found) && (i < count); i++) sl@0: { sl@0: err = (*history)[i]->iLastError; sl@0: if( err == expectedError) sl@0: { sl@0: lastError = err; sl@0: found = ETrue; sl@0: } sl@0: } sl@0: if(!found) sl@0: { sl@0: ERR_PRINTF2(_L("GetLastError() %d not found in history!"), expectedError); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: lastError = iFileMan->GetLastError(); sl@0: } sl@0: if (found) sl@0: { sl@0: TInt expectedError; sl@0: if(GET_OPTIONAL_INT_PARAMETER(KError, aSection, expectedError)) sl@0: { sl@0: if(expectedError != lastError) sl@0: { sl@0: ERR_PRINTF3(_L("GetLastError(): %d != %d Expected Error"), lastError, expectedError); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("GetLastError(): %d == %d Expected Error"), lastError, expectedError); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("GetLastError(): %d"), lastError); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FileManData::DoCmdGetMoreInfoAboutError(const TDesC& aSection) sl@0: { sl@0: TBool readHistory = EFalse; sl@0: GET_OPTIONAL_BOOL_PARAMETER(KReadHistory, aSection, readHistory); sl@0: TFileManError lastError; sl@0: TBool found = ETrue; sl@0: if(readHistory) sl@0: { sl@0: /** Get needed history array **/ sl@0: RPointerArray* history = GetHistoryDataByType(aSection); sl@0: if(history) sl@0: { sl@0: TFileManError expectedError; sl@0: found = EFalse; sl@0: if(GetFileManErrorFromConfig(KError, aSection, expectedError)) sl@0: { sl@0: TInt count = history->Count(); sl@0: TFileManError error; sl@0: /** Search for expected error in history **/ sl@0: for(TInt i = 0; (!found) && (i < count); i++) sl@0: { sl@0: error = (*history)[i]->iMoreInfoAboutError; sl@0: if( (error == expectedError)) sl@0: { sl@0: lastError = error; sl@0: found = ETrue; sl@0: } sl@0: } sl@0: if(!found) sl@0: { sl@0: ERR_PRINTF2(_L("GetMoreInfoAboutError() %S not found in history!"), expectedError); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: lastError = iFileMan->GetMoreInfoAboutError(); sl@0: } sl@0: if (found) sl@0: { sl@0: TPtrC errorStr; sl@0: ConvertFileManErrorToString(lastError, errorStr); sl@0: TFileManError expectedError; sl@0: if(GetFileManErrorFromConfig(KError, aSection, expectedError)) sl@0: { sl@0: TPtrC expectedErrorStr; sl@0: ConvertFileManErrorToString(expectedError, expectedErrorStr); sl@0: sl@0: if(expectedError != lastError) sl@0: { sl@0: ERR_PRINTF3(_L("GetMoreInfoAboutError(): %S != %S Expected Error"), &errorStr, &expectedErrorStr); sl@0: SetBlockResult(EFail); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("GetMoreInfoAboutError(): %S == %S Expected Error"), &errorStr, &expectedErrorStr); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("GetMoreInfoAboutError(): %S"), &errorStr); sl@0: } sl@0: } sl@0: sl@0: } sl@0: void CT_FileManData::RunL(CActive* aActive, TInt aIndex) sl@0: /** sl@0: Virtual RunL - Called on completion of an asynchronous command sl@0: @internalComponent sl@0: @see MActiveCallback sl@0: @param aActive Active Object that RunL has been called on sl@0: @pre N/A sl@0: @post N/A sl@0: @leave system wide error code sl@0: */ sl@0: { sl@0: INFO_PRINTF1(_L("CT_FileManData::RunL Called")); sl@0: TBool foundActiveObject = EFalse; sl@0: TInt index=0; sl@0: TInt count=0; sl@0: TBool completed=ETrue; sl@0: sl@0: count = iAttribs.Count(); sl@0: for( index=0; (indexiStatus.Int(); sl@0: if( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("RunL Error %d"), err); sl@0: SetAsyncError( aIndex, err ); sl@0: iAsyncCall = EFalse; sl@0: } sl@0: sl@0: if ( completed ) sl@0: { sl@0: // Reset the outstanding request state sl@0: DecOutstanding(); sl@0: delete aActive; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Stray RunL signal")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FileManData::DoCancel(CActive* aActive, TInt aIndex) sl@0: /** sl@0: Virtual DoCancel - Request to cancel the asynchronous command sl@0: @internalComponent sl@0: @see - MActiveCallback sl@0: @param aActive Active Object that DoCancel has been called on sl@0: @pre - N/A sl@0: @post - N/A sl@0: @leave system wide error code sl@0: */ sl@0: { sl@0: INFO_PRINTF1(_L("CT_FileManData::DoCancelL Called")); sl@0: sl@0: TBool foundActiveObject = EFalse; sl@0: TInt index=0; sl@0: TInt count=0; sl@0: sl@0: sl@0: // See if it is in iAttribs sl@0: count = iAttribs.Count(); sl@0: for( index=0; (indexiStatus.Int(); sl@0: if( err != KErrNone ) sl@0: { sl@0: ERR_PRINTF2(_L("DoCancel Error %d"), err); sl@0: SetAsyncError( aIndex, err ); sl@0: } sl@0: sl@0: // Reset the outstanding request state sl@0: DecOutstanding(); sl@0: sl@0: delete aActive; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF1(_L("Stray DoCancel signal")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: /** Reads TFileManError from INI and converts it to TFileManError type. **/ sl@0: TBool CT_FileManData::GetFileManErrorFromConfig(const TDesC& aParameterName, const TDesC& aSection, TFileManError& aError) sl@0: { sl@0: TPtrC errorStr; sl@0: TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, errorStr); sl@0: if(ret) sl@0: { sl@0: if(errorStr == KENoExtraInformation) sl@0: { sl@0: aError = ENoExtraInformation; sl@0: } sl@0: else if(errorStr == KEInitializationFailed) sl@0: { sl@0: aError = EInitializationFailed; sl@0: } sl@0: else if (errorStr == KEScanNextDirectoryFailed) sl@0: { sl@0: aError = EScanNextDirectoryFailed; sl@0: } sl@0: else if (errorStr == KESrcOpenFailed) sl@0: { sl@0: aError = ESrcOpenFailed; sl@0: } sl@0: else if (errorStr == KETrgOpenFailed) sl@0: { sl@0: aError = ETrgOpenFailed; sl@0: } sl@0: else if (errorStr == KENoFilesProcessed) sl@0: { sl@0: aError = ENoFilesProcessed; sl@0: } sl@0: else sl@0: { sl@0: ret = EFalse; sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: /** Converts TFileManError type to string **/ sl@0: void CT_FileManData::ConvertFileManErrorToString(TFileManError& aError, TPtrC& aErrorStr) sl@0: { sl@0: if(aError == ENoExtraInformation) sl@0: { sl@0: aErrorStr.Set(KENoExtraInformation()); sl@0: } sl@0: else if(aError == EInitializationFailed) sl@0: { sl@0: aErrorStr.Set(KEInitializationFailed()); sl@0: } sl@0: else if (aError == EScanNextDirectoryFailed) sl@0: { sl@0: aErrorStr.Set(KEScanNextDirectoryFailed()); sl@0: } sl@0: else if (aError == ESrcOpenFailed) sl@0: { sl@0: aErrorStr.Set(KESrcOpenFailed()); sl@0: } sl@0: else if (aError == ETrgOpenFailed) sl@0: { sl@0: aErrorStr.Set(KETrgOpenFailed()); sl@0: } sl@0: else if (aError == ENoFilesProcessed) sl@0: { sl@0: aErrorStr.Set(KENoFilesProcessed()); sl@0: } sl@0: } sl@0: sl@0: /** Converts CFileMan::TAction type to string **/ sl@0: void CT_FileManData::ConvertActionToString(CFileMan::TAction aAction, TPtrC& aActionStr) sl@0: { sl@0: if (aAction == CFileMan::EAttribs) sl@0: { sl@0: aActionStr.Set(KEAttribs()); sl@0: } sl@0: else if (aAction == CFileMan::ECopy) sl@0: { sl@0: aActionStr.Set(KECopy()); sl@0: } sl@0: else if (aAction == CFileMan::EDelete) sl@0: { sl@0: aActionStr.Set(KEDelete()); sl@0: } sl@0: else if (aAction == CFileMan::EMove) sl@0: { sl@0: aActionStr.Set(KEMove()); sl@0: } sl@0: else if (aAction == CFileMan::ERename) sl@0: { sl@0: aActionStr.Set(KERename()); sl@0: } sl@0: else if (aAction == CFileMan::ERmDir) sl@0: { sl@0: aActionStr.Set(KERmDir()); sl@0: } sl@0: else if (aAction == CFileMan::ERenameInvalidEntry) sl@0: { sl@0: aActionStr.Set(KERenameInvalidEntry()); sl@0: } sl@0: else if (aAction == CFileMan::ECopyFromHandle) sl@0: { sl@0: aActionStr.Set(KECopyFromHandle()); sl@0: } sl@0: else sl@0: { sl@0: aActionStr.Set(KENone()); sl@0: } sl@0: sl@0: } sl@0: sl@0: /** Reads CFileMan::TAction from INI and converts it to CFileMan::TAction type. **/ sl@0: TBool CT_FileManData::GetActionFromConfig(const TDesC& aParameterName, const TDesC& aSection, CFileMan::TAction& aAction) sl@0: { sl@0: TPtrC actionStr; sl@0: TBool ret = GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, actionStr); sl@0: if(ret) sl@0: { sl@0: if (actionStr == KEAttribs) sl@0: { sl@0: aAction = CFileMan::EAttribs; sl@0: } sl@0: else if (actionStr == KECopy) sl@0: { sl@0: aAction = CFileMan::ECopy; sl@0: } sl@0: else if (actionStr == KEDelete) sl@0: { sl@0: aAction = CFileMan::EDelete; sl@0: } sl@0: else if (actionStr == KEMove) sl@0: { sl@0: aAction = CFileMan::EMove; sl@0: } sl@0: else if (actionStr == KERename) sl@0: { sl@0: aAction = CFileMan::ERename; sl@0: } sl@0: else if (actionStr == KERmDir) sl@0: { sl@0: aAction = CFileMan::ERmDir; sl@0: } sl@0: else if (actionStr == KERenameInvalidEntry) sl@0: { sl@0: aAction = CFileMan::ERenameInvalidEntry; sl@0: } sl@0: else if (actionStr == KECopyFromHandle) sl@0: { sl@0: aAction = CFileMan::ECopyFromHandle; sl@0: } sl@0: else if (actionStr == KENone) sl@0: { sl@0: aAction = CFileMan::ENone; sl@0: } sl@0: else sl@0: { sl@0: ret = EFalse; sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: /** Reads CFileMan::TSwitch from INI and converts it to CFileMan::TSwitch type. **/ sl@0: TBool CT_FileManData::GetOperationFromConfig(const TDesC& aParameterName, const TDesC& aSection, TUint& aSwitch) sl@0: { sl@0: TPtrC operation; sl@0: TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, operation); sl@0: if(ret) sl@0: { sl@0: if (operation == KEOverWrite) sl@0: { sl@0: aSwitch = CFileMan::EOverWrite; sl@0: } sl@0: else if (operation == KERecurse) sl@0: { sl@0: aSwitch = CFileMan::ERecurse; sl@0: } sl@0: else sl@0: { sl@0: TInt operationInt=0; sl@0: ret = GET_MANDATORY_INT_PARAMETER(aParameterName, aSection, operationInt); sl@0: if (ret) sl@0: { sl@0: aSwitch = (CFileMan::TSwitch) operationInt; sl@0: } sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: /** Clears all arrays with history **/ sl@0: void CT_FileManData::ClearHistory() sl@0: { sl@0: INFO_PRINTF1(_L("Clearing history!")); sl@0: sl@0: iStartedHistory.ResetAndDestroy(); sl@0: iOperationHistory.ResetAndDestroy(); sl@0: iEndedHistory.ResetAndDestroy(); sl@0: } sl@0: sl@0: /** sl@0: * Creates a history entry. sl@0: * This method runs only from NotifyFileManStarted(), NotifyFileManOperation(), NotifyFileManEnded(). sl@0: **/ sl@0: void CT_FileManData::CreateHistoryRecord(THistoryData& aRecord) sl@0: { sl@0: TFileName source; sl@0: iFileMan->GetCurrentSource(source); sl@0: aRecord.iCurrentSource = source; sl@0: sl@0: TFileName target; sl@0: iFileMan->GetCurrentTarget(target); sl@0: aRecord.iCurrentTarget = target; sl@0: sl@0: aRecord.iCurrentEntry = iFileMan->CurrentEntry(); sl@0: aRecord.iBytesTransferred = iFileMan->BytesTransferredByCopyStep(); sl@0: aRecord.iCurrentAction = iFileMan->CurrentAction(); sl@0: aRecord.iLastError = iFileMan->GetLastError(); sl@0: aRecord.iMoreInfoAboutError = iFileMan->GetMoreInfoAboutError(); sl@0: aRecord.iFullPath.Set( iFileMan->FullPath() ); sl@0: aRecord.iAbbreviatedPath.Set( iFileMan->AbbreviatedPath() ); sl@0: } sl@0: sl@0: /** Reads type of notification from INI and converts it to TObserverNotifyType **/ sl@0: TBool CT_FileManData::GetNotifyType(const TDesC& aParameterName, const TDesC& aSection, TObserverNotifyType& aType) sl@0: { sl@0: TPtrC type; sl@0: TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, type); sl@0: if(ret) sl@0: { sl@0: if (type == KNotifyStarted) sl@0: { sl@0: aType = ENotifyStarted; sl@0: } sl@0: else if (type == KNotifyOperation) sl@0: { sl@0: aType = ENotifyOperation; sl@0: } sl@0: else if (type == KNotifyEnded) sl@0: { sl@0: aType = ENotifyEnded; sl@0: } sl@0: else sl@0: { sl@0: ret = EFalse; sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: /** Returns specific array of history using TObserverNotifyType value **/ sl@0: RPointerArray* CT_FileManData::GetHistoryDataByType(const TDesC& aSection) sl@0: { sl@0: TObserverNotifyType type; sl@0: RPointerArray* history = NULL; sl@0: //Reads history name which must be returned. sl@0: if (GetNotifyType(KNotifyType(), aSection, type)) sl@0: { sl@0: if(type == ENotifyStarted) sl@0: { sl@0: history = (RPointerArray*)&iStartedHistory; sl@0: } sl@0: else if(type == ENotifyOperation) sl@0: { sl@0: history = (RPointerArray*)&iOperationHistory; sl@0: } sl@0: else if(type == ENotifyEnded) sl@0: { sl@0: history = (RPointerArray*)&iEndedHistory; sl@0: } sl@0: } sl@0: return history; sl@0: } sl@0: /** Reads TControl from config and converts it to TControl type **/ sl@0: TBool CT_FileManData::GetTControlFromConfig(const TDesC& aParameterName, const TDesC& aSection, TControl& aFlag) sl@0: { sl@0: TPtrC flag; sl@0: TBool ret=GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, flag); sl@0: if(ret) sl@0: { sl@0: if (flag == KEContinue) sl@0: { sl@0: aFlag = EContinue; sl@0: } sl@0: else if (flag == KEAbort) sl@0: { sl@0: aFlag = EAbort; sl@0: } sl@0: else if (flag == KECancel) sl@0: { sl@0: aFlag = ECancel; sl@0: } sl@0: else if (flag == KERetry) sl@0: { sl@0: aFlag = ERetry; sl@0: } sl@0: else sl@0: { sl@0: ret = EFalse; sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: /** Reads TControl and file name from INI **/ sl@0: void CT_FileManData::ReadTControl(const TDesC& aSection) sl@0: { sl@0: TBool dataOk = ETrue; sl@0: if(!GetNotifyType(KNotifyType(), aSection, iObserverNotifyType)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: TPtrC fileName; sl@0: if(GET_MANDATORY_STRING_PARAMETER(KFileName(), aSection, fileName)) sl@0: { sl@0: iNotifyFileName = fileName; sl@0: } sl@0: else sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: if(!GetTControlFromConfig(KFlag(), aSection, iTControl)) sl@0: { sl@0: dataOk = EFalse; sl@0: } sl@0: if(dataOk) sl@0: { sl@0: iUseTControl = ETrue; sl@0: } sl@0: } sl@0: sl@0: