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_FsData sl@0: */ sl@0: sl@0: // User includes sl@0: #include "T_FsData.h" sl@0: #include "T_VolumeInfoData.h" sl@0: #include "FileserverUtil.h" sl@0: sl@0: /*@{*/ sl@0: ///Constants sl@0: sl@0: _LIT(KPromptProcess, "t_prompt.exe"); sl@0: sl@0: sl@0: /// Enumerations sl@0: _LIT(KMediaNotPresent, "EMediaNotPresent"); sl@0: _LIT(KMediaUnknown, "EMediaUnknown"); sl@0: _LIT(KMediaFloppy, "EMediaFloppy"); sl@0: _LIT(KMediaHardDisk, "EMediaHardDisk"); sl@0: _LIT(KMediaCdRom, "EMediaCdRom"); sl@0: _LIT(KMediaRam, "EMediaRam"); sl@0: _LIT(KMediaFlash, "EMediaFlash"); sl@0: _LIT(KMediaRom, "EMediaRom"); sl@0: _LIT(KMediaRemote, "EMediaRemote"); sl@0: _LIT(KMediaNANDFlash, "EMediaNANDFlash"); sl@0: sl@0: _LIT(KBatNotSupported, "EBatNotSupported"); sl@0: _LIT(KBatLow, "EBatLow"); sl@0: _LIT(KBatGood, "EBatGood"); sl@0: sl@0: _LIT(KDriveAttLocalStr, "KDriveAttLocal"); sl@0: _LIT(KDriveAttRomStr, "KDriveAttRom"); sl@0: _LIT(KDriveAttRedirectedStr, "KDriveAttRedirected"); sl@0: _LIT(KDriveAttSubstedStr, "KDriveAttSubsted"); sl@0: _LIT(KDriveAttInternalStr, "KDriveAttInternal"); sl@0: _LIT(KDriveAttRemovableStr, "KDriveAttRemovable"); sl@0: sl@0: _LIT(KMediaAttVariableSizeStr, "KMediaAttVariableSize"); sl@0: _LIT(KMediaAttDualDensityStr, "KMediaAttDualDensity"); sl@0: _LIT(KMediaAttFormattableStr, "KMediaAttFormattable"); sl@0: _LIT(KMediaAttWriteProtectedStr, "KMediaAttWriteProtected"); sl@0: _LIT(KMediaAttLockableStr, "KMediaAttLockable"); sl@0: _LIT(KMediaAttLockedStr, "KMediaAttLocked"); sl@0: sl@0: sl@0: /// Parameters sl@0: _LIT(KStore, "store"); sl@0: _LIT(KMediaType, "media_type"); sl@0: _LIT(KDriveAtt, "drive_att"); sl@0: _LIT(KMediaAtt, "media_att"); sl@0: _LIT(KDriveIndex, "drive_index"); sl@0: _LIT(KDriveChar, "drive_char"); sl@0: _LIT(KArraySize, "array_size"); sl@0: _LIT(KArrayIndex, "array_index_"); sl@0: _LIT(KVolumeLabel, "volume_label"); sl@0: _LIT(KSubstPath, "subst_path"); sl@0: _LIT(KDriveName, "drive_name"); sl@0: _LIT(KDriveOldPassword, "drive_old_password"); sl@0: _LIT(KDriveNewPassword, "drive_new_password"); sl@0: _LIT(KBytesToReserve, "bytes_to_reserve"); sl@0: _LIT(KDriveIsValid, "drive_is_valid"); sl@0: _LIT(KDrivePath, "drive_path"); sl@0: _LIT(KDrive, "drive"); sl@0: _LIT(KBatteryState, "battery_state"); sl@0: _LIT(KSaveInInstance, "save_in_instance"); sl@0: _LIT(KVolumeObject, "store_volume"); sl@0: sl@0: sl@0: /// Commands sl@0: _LIT(KCmdDriveList, "DriveList"); sl@0: _LIT(KCmdDrive, "Drive"); sl@0: _LIT(KCmdVolume, "Volume"); sl@0: _LIT(KCmdSetVolumeLabel, "SetVolumeLabel"); sl@0: _LIT(KCmdSubst, "Subst"); sl@0: _LIT(KCmdSetSubst, "SetSubst"); sl@0: _LIT(KCmdGetMediaSerialNumber, "GetMediaSerialNumber"); sl@0: _LIT(KCmdIsValidDrive, "IsValidDrive"); sl@0: _LIT(KCmdCharToDrive, "CharToDrive"); sl@0: _LIT(KCmdDriveToChar, "DriveToChar"); sl@0: _LIT(KCmdCheckDisk, "CheckDisk"); sl@0: _LIT(KCmdScanDrive, "ScanDrive"); sl@0: _LIT(KCmdGetDriveName, "GetDriveName"); sl@0: _LIT(KCmdSetDriveName, "SetDriveName"); sl@0: _LIT(KCmdLockDrive, "LockDrive"); sl@0: _LIT(KCmdUnlockDrive, "UnlockDrive"); sl@0: _LIT(KCmdClearPassword, "ClearPassword"); sl@0: _LIT(KCmdErasePassword, "ErasePassword"); sl@0: _LIT(KCmdReserveDriveSpace, "ReserveDriveSpace"); sl@0: _LIT(KCmdGetReserveAccess, "GetReserveAccess"); sl@0: _LIT(KCmdReleaseReserveAccess, "ReleaseReserveAccess"); sl@0: _LIT(KCmdPrompt, "prompt"); sl@0: _LIT(KCmdGetSystemDrive, "GetSystemDrive"); sl@0: _LIT(KCmdSetSystemDrive, "SetSystemDrive"); sl@0: _LIT(KCmdGetSystemDriveChar, "GetSystemDriveChar"); sl@0: _LIT(KCmdVolumeIOParam, "VolumeIOParam"); sl@0: sl@0: /*@}*/ sl@0: sl@0: /** sl@0: * Process a drives related command read from the ini file sl@0: * sl@0: * @param aCommand the command to process sl@0: * @param aSection the entry 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: TBool CT_FsData::DoCommandDrivesL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) sl@0: { sl@0: TBool retVal = ETrue; sl@0: //Parsing the aCommand to choose which function has to be executed. sl@0: sl@0: if (aCommand == KCmdDriveList) sl@0: { sl@0: DoCmdDriveList(aSection); sl@0: } sl@0: else if (aCommand == KCmdDrive) sl@0: { sl@0: DoCmdDriveL(aSection); sl@0: } sl@0: else if (aCommand == KCmdVolume) sl@0: { sl@0: DoCmdVolumeL(aSection); sl@0: } sl@0: else if (aCommand == KCmdSetVolumeLabel) sl@0: { sl@0: DoCmdSetVolumeLabel(aSection); sl@0: } sl@0: else if (aCommand == KCmdSubst) sl@0: { sl@0: DoCmdSubst(aSection); sl@0: } sl@0: else if (aCommand == KCmdSetSubst) sl@0: { sl@0: DoCmdSetSubst(aSection); sl@0: } sl@0: else if (aCommand == KCmdGetMediaSerialNumber) sl@0: { sl@0: DoCmdGetMediaSerialNumber(aSection); sl@0: } sl@0: else if (aCommand == KCmdIsValidDrive) sl@0: { sl@0: DoCmdIsValidDrive(aSection); sl@0: } sl@0: else if (aCommand == KCmdCharToDrive) sl@0: { sl@0: DoCmdCharToDrive(aSection); sl@0: } sl@0: else if (aCommand == KCmdDriveToChar) sl@0: { sl@0: DoCmdDriveToChar(aSection); sl@0: } sl@0: else if (aCommand == KCmdCheckDisk) sl@0: { sl@0: DoCmdCheckDisk(aSection); sl@0: } sl@0: else if (aCommand == KCmdScanDrive) sl@0: { sl@0: DoCmdScanDrive(aSection); sl@0: } sl@0: else if (aCommand == KCmdGetDriveName) sl@0: { sl@0: DoCmdGetDriveName(aSection); sl@0: } sl@0: else if (aCommand == KCmdSetDriveName) sl@0: { sl@0: DoCmdSetDriveName(aSection); sl@0: } sl@0: else if (aCommand == KCmdLockDrive) sl@0: { sl@0: DoCmdLockDrive(aSection); sl@0: } sl@0: else if (aCommand == KCmdUnlockDrive) sl@0: { sl@0: DoCmdUnlockDrive(aSection); sl@0: } sl@0: else if (aCommand == KCmdClearPassword) sl@0: { sl@0: DoCmdClearPassword(aSection); sl@0: } sl@0: else if (aCommand == KCmdErasePassword) sl@0: { sl@0: DoCmdErasePassword(aSection); sl@0: } sl@0: else if (aCommand == KCmdReserveDriveSpace) sl@0: { sl@0: DoCmdReserveDriveSpace(aSection); sl@0: } sl@0: else if (aCommand == KCmdGetReserveAccess) sl@0: { sl@0: DoCmdGetReserveAccess(aSection); sl@0: } sl@0: else if (aCommand == KCmdReleaseReserveAccess) sl@0: { sl@0: DoCmdReleaseReserveAccess(aSection); sl@0: } sl@0: else if (aCommand == KCmdPrompt) sl@0: { sl@0: DoCmdPromptL(aSection); sl@0: } sl@0: else if (aCommand == KCmdGetSystemDrive) sl@0: { sl@0: DoCmdGetSystemDrive(aSection); sl@0: } sl@0: else if (aCommand == KCmdGetSystemDriveChar) sl@0: { sl@0: DoCmdGetSystemDriveChar(aSection); sl@0: } sl@0: else if (aCommand == KCmdSetSystemDrive) sl@0: { sl@0: DoCmdSetSystemDrive(aSection); sl@0: } sl@0: else if (aCommand == KCmdVolumeIOParam) sl@0: { sl@0: DoCmdVolumeIOParam(aSection); sl@0: } sl@0: else sl@0: { sl@0: retVal = EFalse; sl@0: } sl@0: sl@0: return retVal; sl@0: } sl@0: sl@0: sl@0: TBool CT_FsData::GetMediaTypeFromConfig(const TDesC& aSection, TMediaType& aMediaType) sl@0: { sl@0: // Read media type from INI file sl@0: TPtrC mediaTypeStr; sl@0: TBool ret = GET_OPTIONAL_STRING_PARAMETER(KMediaType(), aSection, mediaTypeStr); sl@0: sl@0: if (ret) sl@0: { sl@0: if (mediaTypeStr == KMediaNotPresent) sl@0: { sl@0: aMediaType = EMediaNotPresent; sl@0: } sl@0: else if (mediaTypeStr == KMediaUnknown) sl@0: { sl@0: aMediaType = EMediaUnknown; sl@0: } sl@0: else if (mediaTypeStr == KMediaFloppy) sl@0: { sl@0: aMediaType = EMediaFloppy; sl@0: } sl@0: else if (mediaTypeStr == KMediaHardDisk) sl@0: { sl@0: aMediaType = EMediaHardDisk; sl@0: } sl@0: else if (mediaTypeStr == KMediaCdRom) sl@0: { sl@0: aMediaType = EMediaCdRom; sl@0: } sl@0: else if (mediaTypeStr == KMediaRam) sl@0: { sl@0: aMediaType = EMediaRam; sl@0: } sl@0: else if (mediaTypeStr == KMediaFlash) sl@0: { sl@0: aMediaType = EMediaFlash; sl@0: } sl@0: else if (mediaTypeStr == KMediaRom) sl@0: { sl@0: aMediaType = EMediaRom; sl@0: } sl@0: else if (mediaTypeStr == KMediaRemote) sl@0: { sl@0: aMediaType = EMediaRemote; sl@0: } sl@0: else if (mediaTypeStr == KMediaNANDFlash) sl@0: { sl@0: aMediaType = EMediaNANDFlash; sl@0: } sl@0: else sl@0: { sl@0: TInt mediaType = 0; sl@0: ret = GET_MANDATORY_INT_PARAMETER(KMediaType, aSection, mediaType); sl@0: if (ret) sl@0: { sl@0: aMediaType = (TMediaType) mediaType; sl@0: } sl@0: } sl@0: } sl@0: return ret; sl@0: } sl@0: sl@0: TBool CT_FsData::ConvertToDriveAtts(const TDesC& aDriveAttStr, TUint& aDriveAtt) sl@0: { sl@0: TBool ret = ETrue; sl@0: if ( aDriveAttStr==KDriveAttLocalStr ) sl@0: { sl@0: aDriveAtt=KDriveAttLocal; sl@0: } sl@0: else if ( aDriveAttStr==KDriveAttRomStr ) sl@0: { sl@0: aDriveAtt=KDriveAttRom; sl@0: } sl@0: else if ( aDriveAttStr==KDriveAttRedirectedStr ) sl@0: { sl@0: aDriveAtt=KDriveAttRedirected; sl@0: } sl@0: else if ( aDriveAttStr==KDriveAttSubstedStr ) sl@0: { sl@0: aDriveAtt=KDriveAttSubsted; sl@0: } sl@0: else if ( aDriveAttStr==KDriveAttInternalStr ) sl@0: { sl@0: aDriveAtt=KDriveAttInternal; sl@0: } sl@0: else if ( aDriveAttStr==KDriveAttRemovableStr ) sl@0: { sl@0: aDriveAtt=KDriveAttRemovable; sl@0: } sl@0: else sl@0: { sl@0: TInt location = aDriveAttStr.Match(_L("*|*")); sl@0: if( location!=KErrNotFound ) sl@0: { sl@0: //Converting Left part of the data sl@0: TPtrC tempStr = aDriveAttStr.Left(location); sl@0: ret=ConvertToDriveAtts(tempStr, aDriveAtt); sl@0: sl@0: //Converting right data can be with another "|" sl@0: tempStr.Set(aDriveAttStr.Mid(location+1)); sl@0: sl@0: TUint driveAttTmp; sl@0: if ( ConvertToDriveAtts(tempStr, driveAttTmp) ) sl@0: { sl@0: aDriveAtt=aDriveAtt|driveAttTmp; sl@0: } sl@0: else sl@0: { sl@0: ret=EFalse; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ret=EFalse; sl@0: } sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: void CT_FsData::DoCmdPromptL(const TDesC& /*aSection*/) sl@0: { sl@0: RProcess promptProcess; sl@0: TInt err = promptProcess.Create(KPromptProcess, KNullDesC); sl@0: sl@0: if (err == KErrNone) sl@0: { sl@0: CleanupClosePushL(promptProcess); sl@0: TRequestStatus promptStatus; sl@0: promptProcess.Rendezvous(promptStatus); sl@0: sl@0: if (promptStatus == KRequestPending) sl@0: { sl@0: promptProcess.Resume(); sl@0: User::WaitForRequest(promptStatus); sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Prompt process finished with error %d"), promptStatus.Int()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: promptProcess.RendezvousCancel(promptStatus); sl@0: promptProcess.Kill(0); sl@0: ERR_PRINTF2(_L("Executing of prompt process failed with error %d"), promptStatus.Int()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(); sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Failed to create prompt process with error %d"), err); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: TBool CT_FsData::GetDriveAttsFromConfig(const TDesC& aSection, TUint& aDriveAtt) sl@0: { sl@0: aDriveAtt = 0; sl@0: sl@0: TPtrC driveAttStr; sl@0: TBool ret = GET_OPTIONAL_STRING_PARAMETER(KDriveAtt(), aSection, driveAttStr); sl@0: if ( ret ) sl@0: { sl@0: if ( !ConvertToDriveAtts(driveAttStr, aDriveAtt) ) sl@0: { sl@0: TInt intTemp; sl@0: ret=GET_MANDATORY_INT_PARAMETER(KDriveAtt(), aSection, intTemp); sl@0: if ( ret ) sl@0: { sl@0: aDriveAtt=intTemp; sl@0: } sl@0: } sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: TBool CT_FsData::GetBatteryStateFromConfig(const TDesC& aSection, TBatteryState& aBatteryState) sl@0: { sl@0: // Read media type from INI file sl@0: aBatteryState = EBatLow; sl@0: sl@0: TPtrC batteryStateStr; sl@0: TBool ret = GET_OPTIONAL_STRING_PARAMETER(KBatteryState(), aSection, batteryStateStr); sl@0: sl@0: if (ret) sl@0: { sl@0: if (batteryStateStr == KBatNotSupported) sl@0: { sl@0: aBatteryState = EBatNotSupported; sl@0: } sl@0: else if (batteryStateStr == KBatGood) sl@0: { sl@0: aBatteryState = EBatGood; sl@0: } sl@0: sl@0: if (batteryStateStr == KBatLow) sl@0: { sl@0: aBatteryState = EBatLow; sl@0: } sl@0: else sl@0: { sl@0: aBatteryState = EBatNotSupported; sl@0: } sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: TBool CT_FsData::ConvertToMediaAtts(const TDesC& aMediaAttStr, TUint& aMediaAtt) sl@0: { sl@0: TBool ret = ETrue; sl@0: if ( aMediaAttStr==KMediaAttVariableSizeStr ) sl@0: { sl@0: aMediaAtt=KMediaAttVariableSize; sl@0: } sl@0: else if ( aMediaAttStr==KMediaAttDualDensityStr ) sl@0: { sl@0: aMediaAtt=KMediaAttDualDensity; sl@0: } sl@0: else if ( aMediaAttStr==KMediaAttFormattableStr ) sl@0: { sl@0: aMediaAtt=KMediaAttFormattable; sl@0: } sl@0: else if ( aMediaAttStr==KMediaAttWriteProtectedStr ) sl@0: { sl@0: aMediaAtt=KMediaAttWriteProtected; sl@0: } sl@0: else if ( aMediaAttStr==KMediaAttLockableStr ) sl@0: { sl@0: aMediaAtt=KMediaAttLockable; sl@0: } sl@0: else if ( aMediaAttStr==KMediaAttLockedStr ) sl@0: { sl@0: aMediaAtt=KMediaAttLocked; sl@0: } sl@0: else sl@0: { sl@0: TInt location = aMediaAttStr.Match(_L("*|*")); sl@0: if( location!=KErrNotFound ) sl@0: { sl@0: //Converting Left part of the data sl@0: TPtrC tempStr = aMediaAttStr.Left(location); sl@0: ret=ConvertToMediaAtts(tempStr, aMediaAtt); sl@0: sl@0: //Converting right data can be with another "|" sl@0: tempStr.Set(aMediaAttStr.Mid(location+1)); sl@0: sl@0: TUint mediaAttTmp; sl@0: if ( ConvertToMediaAtts(tempStr, mediaAttTmp) ) sl@0: { sl@0: aMediaAtt=aMediaAtt|mediaAttTmp; sl@0: } sl@0: else sl@0: { sl@0: ret=EFalse; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ret=EFalse; sl@0: } sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: TBool CT_FsData::GetMediaAttsFromConfig(const TDesC& aSection, TUint& aMediaAtt) sl@0: { sl@0: aMediaAtt = 0; sl@0: sl@0: TPtrC mediaAttStr; sl@0: TBool ret = GET_OPTIONAL_STRING_PARAMETER(KMediaAtt(), aSection, mediaAttStr); sl@0: if (ret) sl@0: { sl@0: if ( !ConvertToMediaAtts(mediaAttStr, aMediaAtt) ) sl@0: { sl@0: TInt intTemp; sl@0: ret=GET_MANDATORY_INT_PARAMETER(KMediaAtt(), aSection, intTemp); sl@0: if ( ret ) sl@0: { sl@0: aMediaAtt=intTemp; sl@0: } sl@0: } sl@0: } sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: void CT_FsData::DoCmdDriveList(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::DriveList().")); sl@0: sl@0: //Get the list of drives which presents in system. There should be 26 slots where each non-zero slot means a drive in system. sl@0: TDriveList driveList; sl@0: TInt errorCode = iFs->DriveList(driveList); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function DriveList() failed with %d error code."), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: else sl@0: { sl@0: //Get data from config sl@0: //Get first drive index from config. sl@0: TInt arraySize = 0; sl@0: TLex lexer; sl@0: if (GET_MANDATORY_INT_PARAMETER(KArraySize(), aSection, arraySize)) sl@0: { sl@0: sl@0: TInt arrayIndex = 0; sl@0: for(TInt i = 0; i < arraySize; i++) sl@0: { sl@0: TBuftmpBuff; sl@0: sl@0: tmpBuff.Append(KArrayIndex); sl@0: tmpBuff.AppendNum(i+1); sl@0: if (GET_MANDATORY_INT_PARAMETER( tmpBuff, aSection, arrayIndex)) sl@0: { sl@0: sl@0: //Check that drive C and drive Z or others what realy present are in list. Also user can change the drives and check their presence. sl@0: if (driveList[arrayIndex] == 0) sl@0: { sl@0: ERR_PRINTF2(_L(" Disk no. %d not present."), arrayIndex); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdDriveL(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::Drive().")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex); sl@0: sl@0: //Get info about drive. sl@0: TDriveInfo driveInfo; sl@0: TInt errorCode; sl@0: if(nonDefault) sl@0: { sl@0: errorCode = iFs->Drive(driveInfo, driveIndex); sl@0: } sl@0: else sl@0: { sl@0: errorCode = iFs->Drive(driveInfo); sl@0: } sl@0: sl@0: if(errorCode == KErrNone) sl@0: { sl@0: if ( !VerifyTDriveInfoDataFromIniL(aSection, driveInfo)) sl@0: { sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Function Drive() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: sl@0: TBool CT_FsData::VerifyTDriveInfoDataFromIniL(const TDesC& aSection, TDriveInfo& aDriveInfo) sl@0: { sl@0: TBool ret = ETrue; sl@0: sl@0: INFO_PRINTF2(_L("TDriveInfo.iType =%d"), aDriveInfo.iType); sl@0: INFO_PRINTF2(_L("TDriveInfo.iBattery =%d"), aDriveInfo.iBattery); sl@0: INFO_PRINTF2(_L("TDriveInfo.iDriveAtt=0x%X"), aDriveInfo.iDriveAtt); sl@0: TUint driveAttMask[]= sl@0: { sl@0: KDriveAttLocal, sl@0: KDriveAttRom, sl@0: KDriveAttRedirected, sl@0: KDriveAttSubsted, sl@0: KDriveAttInternal, sl@0: KDriveAttRemovable, sl@0: }; sl@0: TPtrC driveAttText[]= sl@0: { sl@0: KDriveAttLocalStr(), sl@0: KDriveAttRomStr(), sl@0: KDriveAttRedirectedStr(), sl@0: KDriveAttSubstedStr(), sl@0: KDriveAttInternalStr(), sl@0: KDriveAttRemovableStr(), sl@0: }; sl@0: TInt size = sizeof(driveAttMask) / sizeof(driveAttMask[0]); sl@0: TInt index; sl@0: for ( index=0; indexVolume(iVolumeInfo, driveIndex); sl@0: } sl@0: else sl@0: { sl@0: errorCode = iFs->Volume(iVolumeInfo); sl@0: } sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function Volume() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: else sl@0: { sl@0: if ( !FileserverUtil::VerifyTVolumeInfoDataFromIniL(*this, aSection, iVolumeInfo)) sl@0: { sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: if ( !VerifyTDriveInfoDataFromIniL(aSection, iVolumeInfo.iDrive)) sl@0: { sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: sl@0: TBool save; sl@0: if(GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save)) sl@0: { sl@0: if(save) sl@0: { sl@0: iVolumeLabel.Copy(iVolumeInfo.iName); sl@0: } sl@0: } sl@0: sl@0: TPtrC volumeObjectName; sl@0: if (GET_OPTIONAL_STRING_PARAMETER(KVolumeObject, aSection, volumeObjectName)) sl@0: { sl@0: CT_VolumeInfoData* volumeWrapperObject = NULL; sl@0: volumeWrapperObject = static_cast(GetDataWrapperL(volumeObjectName)); sl@0: if(volumeWrapperObject) sl@0: { sl@0: TVolumeInfo* volumeObject = new(ELeave) TVolumeInfo(); sl@0: *volumeObject = iVolumeInfo; sl@0: volumeWrapperObject->SetObjectL(volumeObject); sl@0: } sl@0: } sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdSetVolumeLabel(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs:: SetVolumeLabel().")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex); sl@0: sl@0: //Get volume name from config. sl@0: TPtrC volumeLabel; sl@0: if (!GET_OPTIONAL_STRING_PARAMETER(KVolumeLabel(), aSection, volumeLabel)) sl@0: { sl@0: volumeLabel.Set(iVolumeLabel); sl@0: } sl@0: sl@0: //Trying to set the volume label. By some reason it always retturn KErrNotSupported. sl@0: TInt errorCode; sl@0: if(nonDefault) sl@0: { sl@0: errorCode = iFs->SetVolumeLabel(volumeLabel, driveIndex); sl@0: } sl@0: else sl@0: { sl@0: errorCode = iFs->SetVolumeLabel(volumeLabel); sl@0: } sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function SetVolumeLabel() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdSubst(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs:: Subst().")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: sl@0: sl@0: TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex); sl@0: sl@0: sl@0: TBuf16 substPath; sl@0: sl@0: //Get the path to substed drive. sl@0: sl@0: TInt errorCode; sl@0: if(nonDefault) sl@0: { sl@0: errorCode = iFs->Subst(substPath, driveIndex); sl@0: } sl@0: else sl@0: { sl@0: errorCode = iFs->Subst(substPath); sl@0: } sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function Subst() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: else sl@0: { sl@0: //Get drive index from config. sl@0: TPtrC substPathFromConf; sl@0: if (GET_MANDATORY_STRING_PARAMETER(KSubstPath(), aSection, substPathFromConf)) sl@0: { sl@0: sl@0: //As long as it has to be in similar format we must convert substPathFromConf to TBuf16<255> sl@0: sl@0: //Comparing paths. sl@0: if (substPathFromConf.CompareF(substPath) != 0) sl@0: { sl@0: ERR_PRINTF2(_L("Subst path is wrong %S"), &substPathFromConf); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdSetSubst(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs:: SetSubst().")); sl@0: sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex); sl@0: sl@0: sl@0: //Get drive index from config. sl@0: TPtrC substPath; sl@0: if (GET_MANDATORY_STRING_PARAMETER(KSubstPath(), aSection, substPath)) sl@0: { sl@0: sl@0: //Substing the drive with index driveIndex to path substPath. sl@0: TInt errorCode; sl@0: if(nonDefault) sl@0: { sl@0: errorCode = iFs->SetSubst(substPath, driveIndex); sl@0: } sl@0: else sl@0: { sl@0: errorCode = iFs->SetSubst(substPath); sl@0: } sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function SetSubst() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdGetMediaSerialNumber(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::GetMediaSerialNumber().")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: //Get the media serial number. sl@0: TMediaSerialNumber mediaSerialNumber; sl@0: TInt errorCode = iFs->GetMediaSerialNumber(mediaSerialNumber, driveIndex); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function GetMediaSerialNumber() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdIsValidDrive(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::IsValidDirve().")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: TBool actualValid = RFs::IsValidDrive(driveIndex); sl@0: INFO_PRINTF2(_L("iFs->IsValidDrive = %d"), actualValid); sl@0: sl@0: //Get drive validity flag rom config. sl@0: TBool expectedValid; sl@0: if ( GET_OPTIONAL_BOOL_PARAMETER(KDriveIsValid(), aSection, expectedValid) ) sl@0: { sl@0: if ( actualValid!=expectedValid ) sl@0: { sl@0: ERR_PRINTF1(_L("Function IsValid() returned unexpected result")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdCharToDrive(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs:: CharToDrive().")); sl@0: sl@0: //Get drive index from config. sl@0: //We meed integer there, because function uses TInt, not TDriveNumber. sl@0: sl@0: TDriveNumber driveIndex; sl@0: sl@0: sl@0: //Get drive char from config. sl@0: TPtrC driveCharTmp; sl@0: if (GET_MANDATORY_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp)) sl@0: { sl@0: sl@0: TChar driveChar = driveCharTmp.Ptr()[0]; sl@0: TInt driveIndex2; sl@0: TInt errorCode = RFs::CharToDrive(driveChar, driveIndex2); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function CharToDrive() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: else sl@0: { sl@0: //Get drive index from config sl@0: if (GetDriveNumberFromConfig(aSection, KDriveIndex(), driveIndex)) sl@0: { sl@0: if (driveIndex != driveIndex2) sl@0: { sl@0: ERR_PRINTF1(_L("Wrong conversion from char to index")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdDriveToChar(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs:: DriveToChar().")); sl@0: sl@0: TPtrC driveCharTmp; sl@0: sl@0: //Get drive path from config. sl@0: TDriveNumber driveIndex; sl@0: if (GetDriveNumberFromConfig(aSection, KDriveIndex(), driveIndex)) sl@0: { sl@0: sl@0: TChar driveChar2; sl@0: TInt errorCode = RFs::DriveToChar(driveIndex, driveChar2); sl@0: //Check error code. sl@0: sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function DriveToChar() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF3(_L("DriveToChar(%d) = %c"), driveIndex, TUint(driveChar2)); sl@0: sl@0: //Get drive char from config. sl@0: if (GET_OPTIONAL_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp)) sl@0: { sl@0: sl@0: TChar driveChar= driveCharTmp.Ptr()[0]; sl@0: if (driveChar != driveChar2) sl@0: { sl@0: ERR_PRINTF1(_L("Wrong conversion from char to index")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdCheckDisk(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs:: CheckDisk().")); sl@0: sl@0: //Get drive path from config. sl@0: TPtrC drivePath; sl@0: if (GET_MANDATORY_STRING_PARAMETER(KDrivePath(), aSection, drivePath)) sl@0: { sl@0: sl@0: TInt errorCode = iFs->CheckDisk(drivePath); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function CheckDisk() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: sl@0: } sl@0: sl@0: } sl@0: sl@0: void CT_FsData::DoCmdScanDrive(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs:: ScanDisk().")); sl@0: sl@0: //Get drive path from config. sl@0: TPtrC drivePath; sl@0: if (GET_MANDATORY_STRING_PARAMETER(KDrivePath(), aSection, drivePath)) sl@0: { sl@0: sl@0: TInt errorCode = iFs->ScanDrive(drivePath); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function ScanDrive() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdGetDriveName(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::Calls GetDriveName()")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: TBuf driveName; sl@0: TInt errorCode = iFs->GetDriveName(driveIndex, driveName); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function SetDriveLabel() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: else sl@0: { sl@0: //Get drive name from config. sl@0: TPtrC driveNameFromConf; sl@0: if(GET_OPTIONAL_STRING_PARAMETER(KDriveName(), aSection, driveNameFromConf)) sl@0: { sl@0: TPtrC driveNamePtr = driveName; sl@0: if (driveNamePtr != driveNameFromConf) sl@0: { sl@0: ERR_PRINTF3(_L("Names mismatch: %S != %S"), &driveNamePtr, &driveNameFromConf); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: TBool save; sl@0: sl@0: if(GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save)) sl@0: { sl@0: if(save) sl@0: { sl@0: iDriveName.Copy(iDriveName); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdSetDriveName(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::SetDriveName().")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) ) sl@0: { sl@0: //Get drive name from config. sl@0: TPtrC driveName; sl@0: if ( !GET_OPTIONAL_STRING_PARAMETER(KDriveName(), aSection, driveName) ) sl@0: { sl@0: driveName.Set(iDriveName); sl@0: } sl@0: sl@0: //Check error code. sl@0: TInt errorCode = iFs->SetDriveName(driveIndex, driveName); sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function SetDriveLabel() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), KDriveIndex); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: // sl@0: void CT_FsData::DoCmdLockDrive(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::LockDrive().")); sl@0: sl@0: //Get old password from config. sl@0: TPtrC drivePassword; sl@0: if ( GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, drivePassword) ) sl@0: { sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) ) sl@0: { sl@0: //Get new password from config. sl@0: TPtrC driveNewPassword; sl@0: if ( GET_MANDATORY_STRING_PARAMETER(KDriveNewPassword(), aSection, driveNewPassword) ) sl@0: { sl@0: // get boolean value from config sl@0: TBool store; sl@0: if (GET_MANDATORY_BOOL_PARAMETER(KStore(), aSection, store)) sl@0: { sl@0: TMediaPassword password; sl@0: password.Copy(driveNewPassword); sl@0: iPassword.Copy(drivePassword); sl@0: sl@0: TInt errorCode = iFs->LockDrive(driveIndex, iPassword, password, store); sl@0: sl@0: //Check error code. sl@0: if (errorCode == KErrNone) sl@0: { sl@0: iPassword=password; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Function LockDrive() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdUnlockDrive(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::UnlockDrive().")); sl@0: sl@0: //Get old password from config. sl@0: TPtrC drivePassword; sl@0: if ( GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, drivePassword) ) sl@0: { sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: // get boolean value from config sl@0: TBool store; sl@0: if (GET_MANDATORY_BOOL_PARAMETER(KStore(), aSection, store)) sl@0: { sl@0: TMediaPassword password; sl@0: //Converting string to appropriative password format(TMediaPassword is typedef for TBuf<16>) sl@0: password.Copy(drivePassword); sl@0: sl@0: TInt errorCode = iFs->UnlockDrive(driveIndex, password, store); sl@0: sl@0: //Check error code. sl@0: if (errorCode == KErrNone) sl@0: { sl@0: iPassword=password; sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Function UnlockDrive() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"),KDrive); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdClearPassword(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::ClearPassword().")); sl@0: sl@0: //Get old password from config. sl@0: TPtrC driveOldPasswordTmp; sl@0: if (GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, driveOldPasswordTmp)) sl@0: { sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: //Converting string to appropriative password format(TMediaPassword is typedef for TBuf<16>) sl@0: TMediaPassword driveOldPassword; sl@0: driveOldPassword.Copy(driveOldPasswordTmp); sl@0: sl@0: TInt errorCode = iFs->ClearPassword(driveIndex, driveOldPassword); sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function ClearPassword() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"),KDrive); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdErasePassword(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::ErasePassword().")); sl@0: sl@0: //Get drive from config. sl@0: TDriveNumber driveIndex; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: TInt errorCode = iFs->ErasePassword(driveIndex); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function ErasePassword() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdReserveDriveSpace(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::ReserveDriveSpace().")); sl@0: sl@0: //Get amount of bytes to be reserved from config. sl@0: TInt bytesToReserve; sl@0: if (GET_MANDATORY_INT_PARAMETER(KBytesToReserve(), aSection, bytesToReserve)) sl@0: { sl@0: TDriveNumber driveIndex; sl@0: sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: TInt errorCode = iFs->ReserveDriveSpace(driveIndex, bytesToReserve); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function ReserveDriveSpace() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"),KDrive); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdGetReserveAccess(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::GetReserveAccess().")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: TInt errorCode = iFs->GetReserveAccess(driveIndex); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function GetReserveAccess() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: sl@0: void CT_FsData::DoCmdReleaseReserveAccess(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::ReleaseReserveAccess().")); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex)) sl@0: { sl@0: TInt errorCode = iFs->ReleaseReserveAccess(driveIndex); sl@0: sl@0: //Check error code. sl@0: if (errorCode != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("Function ReleaseReserveAccess() failed with %d error code"), errorCode); sl@0: SetError(errorCode); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdGetSystemDrive(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::GetSystemDrive().")); sl@0: sl@0: TDriveNumber driveNumber = RFs::GetSystemDrive(); sl@0: INFO_PRINTF2(_L("System Drive = %d"), driveNumber); sl@0: sl@0: //Get drive index from config. sl@0: TDriveNumber driveIndex; sl@0: if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) ) sl@0: { sl@0: //Check error code. sl@0: if (driveNumber != driveIndex) sl@0: { sl@0: ERR_PRINTF1(_L("GetSystemDrive() returned unexpected drive")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("Not found %S parameter"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdSetSystemDrive(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::SetSystemDrive()")); sl@0: sl@0: // get drive number from parameters sl@0: TDriveNumber driveNumber = EDriveA; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber)) sl@0: { sl@0: TInt err = iFs->SetSystemDrive(driveNumber); sl@0: // check error code sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("SetSystemDrive() error: %d"), err); sl@0: SetError(err); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("No %S"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: sl@0: } sl@0: sl@0: void CT_FsData::DoCmdGetSystemDriveChar(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::GetSystemDriveChar()")); sl@0: sl@0: TChar drvChar = RFs::GetSystemDriveChar(); sl@0: INFO_PRINTF2(_L("GetSystemDriveChar() = %c"), TUint(drvChar)); sl@0: //Get drive char from config. sl@0: TPtrC driveCharTmp; sl@0: if (GET_OPTIONAL_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp)) sl@0: { sl@0: TChar driveCharExpect = driveCharTmp.Ptr()[0]; sl@0: driveCharExpect.UpperCase(); sl@0: drvChar.UpperCase(); sl@0: if ( drvChar != driveCharExpect) sl@0: { sl@0: ERR_PRINTF1(_L("Drive char != expected drive char")); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: } sl@0: sl@0: void CT_FsData::DoCmdVolumeIOParam(const TDesC& aSection) sl@0: { sl@0: INFO_PRINTF1(_L("Calls RFs::VolumeIOParam()")); sl@0: sl@0: // get drive number from parameters sl@0: TDriveNumber driveNumber = EDriveA; sl@0: if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber)) sl@0: { sl@0: TVolumeIOParamInfo volumeIOParamInf; sl@0: TInt err = iFs->VolumeIOParam(driveNumber, volumeIOParamInf); sl@0: // check error code sl@0: if (err != KErrNone) sl@0: { sl@0: ERR_PRINTF2(_L("VolumeIOParam() error: %d"), err); sl@0: SetError(err); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF2(_L("VolumeIOParam BlockSize: %d"), volumeIOParamInf.iBlockSize ); sl@0: INFO_PRINTF2(_L("VolumeIOParam ClusterSize: %d"), volumeIOParamInf.iClusterSize ); sl@0: INFO_PRINTF2(_L("VolumeIOParam RecReadBufSize: %d"), volumeIOParamInf.iRecReadBufSize ); sl@0: INFO_PRINTF2(_L("VolumeIOParam RecWriteBufSize: %d"), volumeIOParamInf.iRecWriteBufSize ); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: ERR_PRINTF2(_L("No %S"), &KDrive()); sl@0: SetBlockResult(EFail); sl@0: } sl@0: } sl@0: sl@0: