1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_FsDataDrives.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1525 @@
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_FsData
1.27 +*/
1.28 +
1.29 +// User includes
1.30 +#include "T_FsData.h"
1.31 +#include "T_VolumeInfoData.h"
1.32 +#include "FileserverUtil.h"
1.33 +
1.34 +/*@{*/
1.35 +///Constants
1.36 +
1.37 +_LIT(KPromptProcess, "t_prompt.exe");
1.38 +
1.39 +
1.40 +/// Enumerations
1.41 +_LIT(KMediaNotPresent, "EMediaNotPresent");
1.42 +_LIT(KMediaUnknown, "EMediaUnknown");
1.43 +_LIT(KMediaFloppy, "EMediaFloppy");
1.44 +_LIT(KMediaHardDisk, "EMediaHardDisk");
1.45 +_LIT(KMediaCdRom, "EMediaCdRom");
1.46 +_LIT(KMediaRam, "EMediaRam");
1.47 +_LIT(KMediaFlash, "EMediaFlash");
1.48 +_LIT(KMediaRom, "EMediaRom");
1.49 +_LIT(KMediaRemote, "EMediaRemote");
1.50 +_LIT(KMediaNANDFlash, "EMediaNANDFlash");
1.51 +
1.52 +_LIT(KBatNotSupported, "EBatNotSupported");
1.53 +_LIT(KBatLow, "EBatLow");
1.54 +_LIT(KBatGood, "EBatGood");
1.55 +
1.56 +_LIT(KDriveAttLocalStr, "KDriveAttLocal");
1.57 +_LIT(KDriveAttRomStr, "KDriveAttRom");
1.58 +_LIT(KDriveAttRedirectedStr, "KDriveAttRedirected");
1.59 +_LIT(KDriveAttSubstedStr, "KDriveAttSubsted");
1.60 +_LIT(KDriveAttInternalStr, "KDriveAttInternal");
1.61 +_LIT(KDriveAttRemovableStr, "KDriveAttRemovable");
1.62 +
1.63 +_LIT(KMediaAttVariableSizeStr, "KMediaAttVariableSize");
1.64 +_LIT(KMediaAttDualDensityStr, "KMediaAttDualDensity");
1.65 +_LIT(KMediaAttFormattableStr, "KMediaAttFormattable");
1.66 +_LIT(KMediaAttWriteProtectedStr, "KMediaAttWriteProtected");
1.67 +_LIT(KMediaAttLockableStr, "KMediaAttLockable");
1.68 +_LIT(KMediaAttLockedStr, "KMediaAttLocked");
1.69 +
1.70 +
1.71 +/// Parameters
1.72 +_LIT(KStore, "store");
1.73 +_LIT(KMediaType, "media_type");
1.74 +_LIT(KDriveAtt, "drive_att");
1.75 +_LIT(KMediaAtt, "media_att");
1.76 +_LIT(KDriveIndex, "drive_index");
1.77 +_LIT(KDriveChar, "drive_char");
1.78 +_LIT(KArraySize, "array_size");
1.79 +_LIT(KArrayIndex, "array_index_");
1.80 +_LIT(KVolumeLabel, "volume_label");
1.81 +_LIT(KSubstPath, "subst_path");
1.82 +_LIT(KDriveName, "drive_name");
1.83 +_LIT(KDriveOldPassword, "drive_old_password");
1.84 +_LIT(KDriveNewPassword, "drive_new_password");
1.85 +_LIT(KBytesToReserve, "bytes_to_reserve");
1.86 +_LIT(KDriveIsValid, "drive_is_valid");
1.87 +_LIT(KDrivePath, "drive_path");
1.88 +_LIT(KDrive, "drive");
1.89 +_LIT(KBatteryState, "battery_state");
1.90 +_LIT(KSaveInInstance, "save_in_instance");
1.91 +_LIT(KVolumeObject, "store_volume");
1.92 +
1.93 +
1.94 +/// Commands
1.95 +_LIT(KCmdDriveList, "DriveList");
1.96 +_LIT(KCmdDrive, "Drive");
1.97 +_LIT(KCmdVolume, "Volume");
1.98 +_LIT(KCmdSetVolumeLabel, "SetVolumeLabel");
1.99 +_LIT(KCmdSubst, "Subst");
1.100 +_LIT(KCmdSetSubst, "SetSubst");
1.101 +_LIT(KCmdGetMediaSerialNumber, "GetMediaSerialNumber");
1.102 +_LIT(KCmdIsValidDrive, "IsValidDrive");
1.103 +_LIT(KCmdCharToDrive, "CharToDrive");
1.104 +_LIT(KCmdDriveToChar, "DriveToChar");
1.105 +_LIT(KCmdCheckDisk, "CheckDisk");
1.106 +_LIT(KCmdScanDrive, "ScanDrive");
1.107 +_LIT(KCmdGetDriveName, "GetDriveName");
1.108 +_LIT(KCmdSetDriveName, "SetDriveName");
1.109 +_LIT(KCmdLockDrive, "LockDrive");
1.110 +_LIT(KCmdUnlockDrive, "UnlockDrive");
1.111 +_LIT(KCmdClearPassword, "ClearPassword");
1.112 +_LIT(KCmdErasePassword, "ErasePassword");
1.113 +_LIT(KCmdReserveDriveSpace, "ReserveDriveSpace");
1.114 +_LIT(KCmdGetReserveAccess, "GetReserveAccess");
1.115 +_LIT(KCmdReleaseReserveAccess, "ReleaseReserveAccess");
1.116 +_LIT(KCmdPrompt, "prompt");
1.117 +_LIT(KCmdGetSystemDrive, "GetSystemDrive");
1.118 +_LIT(KCmdSetSystemDrive, "SetSystemDrive");
1.119 +_LIT(KCmdGetSystemDriveChar, "GetSystemDriveChar");
1.120 +_LIT(KCmdVolumeIOParam, "VolumeIOParam");
1.121 +
1.122 +/*@}*/
1.123 +
1.124 +/**
1.125 +* Process a drives related command read from the ini file
1.126 +*
1.127 +* @param aCommand the command to process
1.128 +* @param aSection the entry in the ini file requiring the command to be processed
1.129 +*
1.130 +* @return ETrue if the command is processed
1.131 +*/
1.132 +TBool CT_FsData::DoCommandDrivesL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
1.133 + {
1.134 + TBool retVal = ETrue;
1.135 + //Parsing the aCommand to choose which function has to be executed.
1.136 +
1.137 + if (aCommand == KCmdDriveList)
1.138 + {
1.139 + DoCmdDriveList(aSection);
1.140 + }
1.141 + else if (aCommand == KCmdDrive)
1.142 + {
1.143 + DoCmdDriveL(aSection);
1.144 + }
1.145 + else if (aCommand == KCmdVolume)
1.146 + {
1.147 + DoCmdVolumeL(aSection);
1.148 + }
1.149 + else if (aCommand == KCmdSetVolumeLabel)
1.150 + {
1.151 + DoCmdSetVolumeLabel(aSection);
1.152 + }
1.153 + else if (aCommand == KCmdSubst)
1.154 + {
1.155 + DoCmdSubst(aSection);
1.156 + }
1.157 + else if (aCommand == KCmdSetSubst)
1.158 + {
1.159 + DoCmdSetSubst(aSection);
1.160 + }
1.161 + else if (aCommand == KCmdGetMediaSerialNumber)
1.162 + {
1.163 + DoCmdGetMediaSerialNumber(aSection);
1.164 + }
1.165 + else if (aCommand == KCmdIsValidDrive)
1.166 + {
1.167 + DoCmdIsValidDrive(aSection);
1.168 + }
1.169 + else if (aCommand == KCmdCharToDrive)
1.170 + {
1.171 + DoCmdCharToDrive(aSection);
1.172 + }
1.173 + else if (aCommand == KCmdDriveToChar)
1.174 + {
1.175 + DoCmdDriveToChar(aSection);
1.176 + }
1.177 + else if (aCommand == KCmdCheckDisk)
1.178 + {
1.179 + DoCmdCheckDisk(aSection);
1.180 + }
1.181 + else if (aCommand == KCmdScanDrive)
1.182 + {
1.183 + DoCmdScanDrive(aSection);
1.184 + }
1.185 + else if (aCommand == KCmdGetDriveName)
1.186 + {
1.187 + DoCmdGetDriveName(aSection);
1.188 + }
1.189 + else if (aCommand == KCmdSetDriveName)
1.190 + {
1.191 + DoCmdSetDriveName(aSection);
1.192 + }
1.193 + else if (aCommand == KCmdLockDrive)
1.194 + {
1.195 + DoCmdLockDrive(aSection);
1.196 + }
1.197 + else if (aCommand == KCmdUnlockDrive)
1.198 + {
1.199 + DoCmdUnlockDrive(aSection);
1.200 + }
1.201 + else if (aCommand == KCmdClearPassword)
1.202 + {
1.203 + DoCmdClearPassword(aSection);
1.204 + }
1.205 + else if (aCommand == KCmdErasePassword)
1.206 + {
1.207 + DoCmdErasePassword(aSection);
1.208 + }
1.209 + else if (aCommand == KCmdReserveDriveSpace)
1.210 + {
1.211 + DoCmdReserveDriveSpace(aSection);
1.212 + }
1.213 + else if (aCommand == KCmdGetReserveAccess)
1.214 + {
1.215 + DoCmdGetReserveAccess(aSection);
1.216 + }
1.217 + else if (aCommand == KCmdReleaseReserveAccess)
1.218 + {
1.219 + DoCmdReleaseReserveAccess(aSection);
1.220 + }
1.221 + else if (aCommand == KCmdPrompt)
1.222 + {
1.223 + DoCmdPromptL(aSection);
1.224 + }
1.225 + else if (aCommand == KCmdGetSystemDrive)
1.226 + {
1.227 + DoCmdGetSystemDrive(aSection);
1.228 + }
1.229 + else if (aCommand == KCmdGetSystemDriveChar)
1.230 + {
1.231 + DoCmdGetSystemDriveChar(aSection);
1.232 + }
1.233 + else if (aCommand == KCmdSetSystemDrive)
1.234 + {
1.235 + DoCmdSetSystemDrive(aSection);
1.236 + }
1.237 + else if (aCommand == KCmdVolumeIOParam)
1.238 + {
1.239 + DoCmdVolumeIOParam(aSection);
1.240 + }
1.241 + else
1.242 + {
1.243 + retVal = EFalse;
1.244 + }
1.245 +
1.246 + return retVal;
1.247 + }
1.248 +
1.249 +
1.250 +TBool CT_FsData::GetMediaTypeFromConfig(const TDesC& aSection, TMediaType& aMediaType)
1.251 + {
1.252 + // Read media type from INI file
1.253 + TPtrC mediaTypeStr;
1.254 + TBool ret = GET_OPTIONAL_STRING_PARAMETER(KMediaType(), aSection, mediaTypeStr);
1.255 +
1.256 + if (ret)
1.257 + {
1.258 + if (mediaTypeStr == KMediaNotPresent)
1.259 + {
1.260 + aMediaType = EMediaNotPresent;
1.261 + }
1.262 + else if (mediaTypeStr == KMediaUnknown)
1.263 + {
1.264 + aMediaType = EMediaUnknown;
1.265 + }
1.266 + else if (mediaTypeStr == KMediaFloppy)
1.267 + {
1.268 + aMediaType = EMediaFloppy;
1.269 + }
1.270 + else if (mediaTypeStr == KMediaHardDisk)
1.271 + {
1.272 + aMediaType = EMediaHardDisk;
1.273 + }
1.274 + else if (mediaTypeStr == KMediaCdRom)
1.275 + {
1.276 + aMediaType = EMediaCdRom;
1.277 + }
1.278 + else if (mediaTypeStr == KMediaRam)
1.279 + {
1.280 + aMediaType = EMediaRam;
1.281 + }
1.282 + else if (mediaTypeStr == KMediaFlash)
1.283 + {
1.284 + aMediaType = EMediaFlash;
1.285 + }
1.286 + else if (mediaTypeStr == KMediaRom)
1.287 + {
1.288 + aMediaType = EMediaRom;
1.289 + }
1.290 + else if (mediaTypeStr == KMediaRemote)
1.291 + {
1.292 + aMediaType = EMediaRemote;
1.293 + }
1.294 + else if (mediaTypeStr == KMediaNANDFlash)
1.295 + {
1.296 + aMediaType = EMediaNANDFlash;
1.297 + }
1.298 + else
1.299 + {
1.300 + TInt mediaType = 0;
1.301 + ret = GET_MANDATORY_INT_PARAMETER(KMediaType, aSection, mediaType);
1.302 + if (ret)
1.303 + {
1.304 + aMediaType = (TMediaType) mediaType;
1.305 + }
1.306 + }
1.307 + }
1.308 + return ret;
1.309 + }
1.310 +
1.311 +TBool CT_FsData::ConvertToDriveAtts(const TDesC& aDriveAttStr, TUint& aDriveAtt)
1.312 + {
1.313 + TBool ret = ETrue;
1.314 + if ( aDriveAttStr==KDriveAttLocalStr )
1.315 + {
1.316 + aDriveAtt=KDriveAttLocal;
1.317 + }
1.318 + else if ( aDriveAttStr==KDriveAttRomStr )
1.319 + {
1.320 + aDriveAtt=KDriveAttRom;
1.321 + }
1.322 + else if ( aDriveAttStr==KDriveAttRedirectedStr )
1.323 + {
1.324 + aDriveAtt=KDriveAttRedirected;
1.325 + }
1.326 + else if ( aDriveAttStr==KDriveAttSubstedStr )
1.327 + {
1.328 + aDriveAtt=KDriveAttSubsted;
1.329 + }
1.330 + else if ( aDriveAttStr==KDriveAttInternalStr )
1.331 + {
1.332 + aDriveAtt=KDriveAttInternal;
1.333 + }
1.334 + else if ( aDriveAttStr==KDriveAttRemovableStr )
1.335 + {
1.336 + aDriveAtt=KDriveAttRemovable;
1.337 + }
1.338 + else
1.339 + {
1.340 + TInt location = aDriveAttStr.Match(_L("*|*"));
1.341 + if( location!=KErrNotFound )
1.342 + {
1.343 + //Converting Left part of the data
1.344 + TPtrC tempStr = aDriveAttStr.Left(location);
1.345 + ret=ConvertToDriveAtts(tempStr, aDriveAtt);
1.346 +
1.347 + //Converting right data can be with another "|"
1.348 + tempStr.Set(aDriveAttStr.Mid(location+1));
1.349 +
1.350 + TUint driveAttTmp;
1.351 + if ( ConvertToDriveAtts(tempStr, driveAttTmp) )
1.352 + {
1.353 + aDriveAtt=aDriveAtt|driveAttTmp;
1.354 + }
1.355 + else
1.356 + {
1.357 + ret=EFalse;
1.358 + }
1.359 + }
1.360 + else
1.361 + {
1.362 + ret=EFalse;
1.363 + }
1.364 + }
1.365 +
1.366 + return ret;
1.367 + }
1.368 +
1.369 +void CT_FsData::DoCmdPromptL(const TDesC& /*aSection*/)
1.370 + {
1.371 + RProcess promptProcess;
1.372 + TInt err = promptProcess.Create(KPromptProcess, KNullDesC);
1.373 +
1.374 + if (err == KErrNone)
1.375 + {
1.376 + CleanupClosePushL(promptProcess);
1.377 + TRequestStatus promptStatus;
1.378 + promptProcess.Rendezvous(promptStatus);
1.379 +
1.380 + if (promptStatus == KRequestPending)
1.381 + {
1.382 + promptProcess.Resume();
1.383 + User::WaitForRequest(promptStatus);
1.384 + if (err != KErrNone)
1.385 + {
1.386 + ERR_PRINTF2(_L("Prompt process finished with error %d"), promptStatus.Int());
1.387 + SetBlockResult(EFail);
1.388 + }
1.389 + }
1.390 + else
1.391 + {
1.392 + promptProcess.RendezvousCancel(promptStatus);
1.393 + promptProcess.Kill(0);
1.394 + ERR_PRINTF2(_L("Executing of prompt process failed with error %d"), promptStatus.Int());
1.395 + SetBlockResult(EFail);
1.396 + }
1.397 +
1.398 + CleanupStack::PopAndDestroy();
1.399 + }
1.400 + else
1.401 + {
1.402 + ERR_PRINTF2(_L("Failed to create prompt process with error %d"), err);
1.403 + SetBlockResult(EFail);
1.404 + }
1.405 + }
1.406 +
1.407 +TBool CT_FsData::GetDriveAttsFromConfig(const TDesC& aSection, TUint& aDriveAtt)
1.408 + {
1.409 + aDriveAtt = 0;
1.410 +
1.411 + TPtrC driveAttStr;
1.412 + TBool ret = GET_OPTIONAL_STRING_PARAMETER(KDriveAtt(), aSection, driveAttStr);
1.413 + if ( ret )
1.414 + {
1.415 + if ( !ConvertToDriveAtts(driveAttStr, aDriveAtt) )
1.416 + {
1.417 + TInt intTemp;
1.418 + ret=GET_MANDATORY_INT_PARAMETER(KDriveAtt(), aSection, intTemp);
1.419 + if ( ret )
1.420 + {
1.421 + aDriveAtt=intTemp;
1.422 + }
1.423 + }
1.424 + }
1.425 +
1.426 + return ret;
1.427 + }
1.428 +
1.429 +TBool CT_FsData::GetBatteryStateFromConfig(const TDesC& aSection, TBatteryState& aBatteryState)
1.430 + {
1.431 + // Read media type from INI file
1.432 + aBatteryState = EBatLow;
1.433 +
1.434 + TPtrC batteryStateStr;
1.435 + TBool ret = GET_OPTIONAL_STRING_PARAMETER(KBatteryState(), aSection, batteryStateStr);
1.436 +
1.437 + if (ret)
1.438 + {
1.439 + if (batteryStateStr == KBatNotSupported)
1.440 + {
1.441 + aBatteryState = EBatNotSupported;
1.442 + }
1.443 + else if (batteryStateStr == KBatGood)
1.444 + {
1.445 + aBatteryState = EBatGood;
1.446 + }
1.447 +
1.448 + if (batteryStateStr == KBatLow)
1.449 + {
1.450 + aBatteryState = EBatLow;
1.451 + }
1.452 + else
1.453 + {
1.454 + aBatteryState = EBatNotSupported;
1.455 + }
1.456 + }
1.457 +
1.458 + return ret;
1.459 + }
1.460 +
1.461 +TBool CT_FsData::ConvertToMediaAtts(const TDesC& aMediaAttStr, TUint& aMediaAtt)
1.462 + {
1.463 + TBool ret = ETrue;
1.464 + if ( aMediaAttStr==KMediaAttVariableSizeStr )
1.465 + {
1.466 + aMediaAtt=KMediaAttVariableSize;
1.467 + }
1.468 + else if ( aMediaAttStr==KMediaAttDualDensityStr )
1.469 + {
1.470 + aMediaAtt=KMediaAttDualDensity;
1.471 + }
1.472 + else if ( aMediaAttStr==KMediaAttFormattableStr )
1.473 + {
1.474 + aMediaAtt=KMediaAttFormattable;
1.475 + }
1.476 + else if ( aMediaAttStr==KMediaAttWriteProtectedStr )
1.477 + {
1.478 + aMediaAtt=KMediaAttWriteProtected;
1.479 + }
1.480 + else if ( aMediaAttStr==KMediaAttLockableStr )
1.481 + {
1.482 + aMediaAtt=KMediaAttLockable;
1.483 + }
1.484 + else if ( aMediaAttStr==KMediaAttLockedStr )
1.485 + {
1.486 + aMediaAtt=KMediaAttLocked;
1.487 + }
1.488 + else
1.489 + {
1.490 + TInt location = aMediaAttStr.Match(_L("*|*"));
1.491 + if( location!=KErrNotFound )
1.492 + {
1.493 + //Converting Left part of the data
1.494 + TPtrC tempStr = aMediaAttStr.Left(location);
1.495 + ret=ConvertToMediaAtts(tempStr, aMediaAtt);
1.496 +
1.497 + //Converting right data can be with another "|"
1.498 + tempStr.Set(aMediaAttStr.Mid(location+1));
1.499 +
1.500 + TUint mediaAttTmp;
1.501 + if ( ConvertToMediaAtts(tempStr, mediaAttTmp) )
1.502 + {
1.503 + aMediaAtt=aMediaAtt|mediaAttTmp;
1.504 + }
1.505 + else
1.506 + {
1.507 + ret=EFalse;
1.508 + }
1.509 + }
1.510 + else
1.511 + {
1.512 + ret=EFalse;
1.513 + }
1.514 + }
1.515 +
1.516 + return ret;
1.517 + }
1.518 +
1.519 +TBool CT_FsData::GetMediaAttsFromConfig(const TDesC& aSection, TUint& aMediaAtt)
1.520 + {
1.521 + aMediaAtt = 0;
1.522 +
1.523 + TPtrC mediaAttStr;
1.524 + TBool ret = GET_OPTIONAL_STRING_PARAMETER(KMediaAtt(), aSection, mediaAttStr);
1.525 + if (ret)
1.526 + {
1.527 + if ( !ConvertToMediaAtts(mediaAttStr, aMediaAtt) )
1.528 + {
1.529 + TInt intTemp;
1.530 + ret=GET_MANDATORY_INT_PARAMETER(KMediaAtt(), aSection, intTemp);
1.531 + if ( ret )
1.532 + {
1.533 + aMediaAtt=intTemp;
1.534 + }
1.535 + }
1.536 + }
1.537 +
1.538 + return ret;
1.539 + }
1.540 +
1.541 +void CT_FsData::DoCmdDriveList(const TDesC& aSection)
1.542 + {
1.543 + INFO_PRINTF1(_L("Calls RFs::DriveList()."));
1.544 +
1.545 + //Get the list of drives which presents in system. There should be 26 slots where each non-zero slot means a drive in system.
1.546 + TDriveList driveList;
1.547 + TInt errorCode = iFs->DriveList(driveList);
1.548 +
1.549 + //Check error code.
1.550 + if (errorCode != KErrNone)
1.551 + {
1.552 + ERR_PRINTF2(_L("Function DriveList() failed with %d error code."), errorCode);
1.553 + SetError(errorCode);
1.554 + }
1.555 + else
1.556 + {
1.557 + //Get data from config
1.558 + //Get first drive index from config.
1.559 + TInt arraySize = 0;
1.560 + TLex lexer;
1.561 + if (GET_MANDATORY_INT_PARAMETER(KArraySize(), aSection, arraySize))
1.562 + {
1.563 +
1.564 + TInt arrayIndex = 0;
1.565 + for(TInt i = 0; i < arraySize; i++)
1.566 + {
1.567 + TBuf<KBufferStringLength>tmpBuff;
1.568 +
1.569 + tmpBuff.Append(KArrayIndex);
1.570 + tmpBuff.AppendNum(i+1);
1.571 + if (GET_MANDATORY_INT_PARAMETER( tmpBuff, aSection, arrayIndex))
1.572 + {
1.573 +
1.574 + //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.
1.575 + if (driveList[arrayIndex] == 0)
1.576 + {
1.577 + ERR_PRINTF2(_L(" Disk no. %d not present."), arrayIndex);
1.578 + SetBlockResult(EFail);
1.579 + }
1.580 + }
1.581 + }
1.582 +
1.583 + }
1.584 + }
1.585 + }
1.586 +
1.587 +
1.588 +void CT_FsData::DoCmdDriveL(const TDesC& aSection)
1.589 + {
1.590 + INFO_PRINTF1(_L("Calls RFs::Drive()."));
1.591 +
1.592 + //Get drive index from config.
1.593 + TDriveNumber driveIndex;
1.594 + TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
1.595 +
1.596 + //Get info about drive.
1.597 + TDriveInfo driveInfo;
1.598 + TInt errorCode;
1.599 + if(nonDefault)
1.600 + {
1.601 + errorCode = iFs->Drive(driveInfo, driveIndex);
1.602 + }
1.603 + else
1.604 + {
1.605 + errorCode = iFs->Drive(driveInfo);
1.606 + }
1.607 +
1.608 + if(errorCode == KErrNone)
1.609 + {
1.610 + if ( !VerifyTDriveInfoDataFromIniL(aSection, driveInfo))
1.611 + {
1.612 + SetBlockResult(EFail);
1.613 + }
1.614 + }
1.615 + else
1.616 + {
1.617 + ERR_PRINTF2(_L("Function Drive() failed with %d error code"), errorCode);
1.618 + SetError(errorCode);
1.619 + }
1.620 + }
1.621 +
1.622 +TBool CT_FsData::VerifyTDriveInfoDataFromIniL(const TDesC& aSection, TDriveInfo& aDriveInfo)
1.623 + {
1.624 + TBool ret = ETrue;
1.625 +
1.626 + INFO_PRINTF2(_L("TDriveInfo.iType =%d"), aDriveInfo.iType);
1.627 + INFO_PRINTF2(_L("TDriveInfo.iBattery =%d"), aDriveInfo.iBattery);
1.628 + INFO_PRINTF2(_L("TDriveInfo.iDriveAtt=0x%X"), aDriveInfo.iDriveAtt);
1.629 + TUint driveAttMask[]=
1.630 + {
1.631 + KDriveAttLocal,
1.632 + KDriveAttRom,
1.633 + KDriveAttRedirected,
1.634 + KDriveAttSubsted,
1.635 + KDriveAttInternal,
1.636 + KDriveAttRemovable,
1.637 + };
1.638 + TPtrC driveAttText[]=
1.639 + {
1.640 + KDriveAttLocalStr(),
1.641 + KDriveAttRomStr(),
1.642 + KDriveAttRedirectedStr(),
1.643 + KDriveAttSubstedStr(),
1.644 + KDriveAttInternalStr(),
1.645 + KDriveAttRemovableStr(),
1.646 + };
1.647 + TInt size = sizeof(driveAttMask) / sizeof(driveAttMask[0]);
1.648 + TInt index;
1.649 + for ( index=0; index<size; ++index )
1.650 + {
1.651 + if ( aDriveInfo.iDriveAtt&driveAttMask[index] )
1.652 + {
1.653 + INFO_PRINTF2(_L("DriveAtt %S ON"), &driveAttText[index]);
1.654 + }
1.655 + }
1.656 + INFO_PRINTF2(_L("TDriveInfo.iMediaAtt=0x%X"), aDriveInfo.iMediaAtt);
1.657 + TUint mediaAttMask[]=
1.658 + {
1.659 + KMediaAttVariableSize,
1.660 + KMediaAttDualDensity,
1.661 + KMediaAttFormattable,
1.662 + KMediaAttWriteProtected,
1.663 + KMediaAttLockable,
1.664 + KMediaAttLocked,
1.665 + };
1.666 + TPtrC mediaAttText[]=
1.667 + {
1.668 + KMediaAttVariableSizeStr(),
1.669 + KMediaAttDualDensityStr(),
1.670 + KMediaAttFormattableStr(),
1.671 + KMediaAttWriteProtectedStr(),
1.672 + KMediaAttLockableStr(),
1.673 + KMediaAttLockedStr(),
1.674 + };
1.675 +
1.676 + size = sizeof(mediaAttMask) / sizeof(mediaAttMask[0]);
1.677 + for ( index=0; index<size; ++index )
1.678 + {
1.679 + if ( aDriveInfo.iMediaAtt&mediaAttMask[index] )
1.680 + {
1.681 + INFO_PRINTF2(_L("MediaAtt %S ON"), &mediaAttText[index]);
1.682 + }
1.683 + }
1.684 +
1.685 + //Get drive type from config.
1.686 + TMediaType mediaType;
1.687 + if (GetMediaTypeFromConfig(aSection, mediaType))
1.688 + {
1.689 + //Checking that type of drive is equal to passed through config file.
1.690 + if (aDriveInfo.iType != mediaType)
1.691 + {
1.692 + ERR_PRINTF3(_L("Drive has wrong type. actual: %d, expected: %d"), aDriveInfo.iType, mediaType);
1.693 + ret = EFalse;
1.694 + }
1.695 + }
1.696 +
1.697 + //Optional battery state checking
1.698 + TBatteryState batteryState;
1.699 + if (GetBatteryStateFromConfig(aSection, batteryState))
1.700 + {
1.701 + //Checking that type of drive is equal to passed through config file.
1.702 + if (aDriveInfo.iBattery != batteryState)
1.703 + {
1.704 + ERR_PRINTF3(_L("BatteryState is wrong. actual: %d, expected: %d"), aDriveInfo.iBattery, batteryState);
1.705 + ret = EFalse;
1.706 + }
1.707 + }
1.708 +
1.709 + //Optional media attributes checking
1.710 + TUint mediaAtts;
1.711 + if (GetMediaAttsFromConfig(aSection, mediaAtts))
1.712 + {
1.713 + //Checking that type of drive is equal to passed through config file.
1.714 + if ( (aDriveInfo.iMediaAtt&mediaAtts)==mediaAtts )
1.715 + {
1.716 + ERR_PRINTF1(_L("Media attributes are wrong"));
1.717 + ret = EFalse;
1.718 + }
1.719 + }
1.720 +
1.721 + //Optional drive attributes checking.
1.722 + TUint driveAtts;
1.723 + if (GetDriveAttsFromConfig(aSection, driveAtts))
1.724 + {
1.725 + //Checking that type of drive is equal to passed through config file.
1.726 + if ( (aDriveInfo.iDriveAtt!=driveAtts)==driveAtts )
1.727 + {
1.728 + ERR_PRINTF1(_L("Drive attributes are wrong"));
1.729 + ret = EFalse;
1.730 + }
1.731 + }
1.732 +
1.733 + return ret;
1.734 + }
1.735 +
1.736 +void CT_FsData::DoCmdVolumeL(const TDesC& aSection)
1.737 + {
1.738 + INFO_PRINTF1(_L("Calls RFs:: Volume()."));
1.739 +
1.740 + //Get drive index from config.
1.741 + TDriveNumber driveIndex;
1.742 +
1.743 + TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
1.744 +
1.745 + //Get info about volume.
1.746 + TInt errorCode;
1.747 +
1.748 + if(nonDefault)
1.749 + {
1.750 + errorCode = iFs->Volume(iVolumeInfo, driveIndex);
1.751 + }
1.752 + else
1.753 + {
1.754 + errorCode = iFs->Volume(iVolumeInfo);
1.755 + }
1.756 + //Check error code.
1.757 + if (errorCode != KErrNone)
1.758 + {
1.759 + ERR_PRINTF2(_L("Function Volume() failed with %d error code"), errorCode);
1.760 + SetError(errorCode);
1.761 + }
1.762 + else
1.763 + {
1.764 + if ( !FileserverUtil::VerifyTVolumeInfoDataFromIniL(*this, aSection, iVolumeInfo))
1.765 + {
1.766 + SetBlockResult(EFail);
1.767 + }
1.768 +
1.769 + if ( !VerifyTDriveInfoDataFromIniL(aSection, iVolumeInfo.iDrive))
1.770 + {
1.771 + SetBlockResult(EFail);
1.772 + }
1.773 +
1.774 +
1.775 + TBool save;
1.776 + if(GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save))
1.777 + {
1.778 + if(save)
1.779 + {
1.780 + iVolumeLabel.Copy(iVolumeInfo.iName);
1.781 + }
1.782 + }
1.783 +
1.784 + TPtrC volumeObjectName;
1.785 + if (GET_OPTIONAL_STRING_PARAMETER(KVolumeObject, aSection, volumeObjectName))
1.786 + {
1.787 + CT_VolumeInfoData* volumeWrapperObject = NULL;
1.788 + volumeWrapperObject = static_cast<CT_VolumeInfoData*>(GetDataWrapperL(volumeObjectName));
1.789 + if(volumeWrapperObject)
1.790 + {
1.791 + TVolumeInfo* volumeObject = new(ELeave) TVolumeInfo();
1.792 + *volumeObject = iVolumeInfo;
1.793 + volumeWrapperObject->SetObjectL(volumeObject);
1.794 + }
1.795 + }
1.796 + }
1.797 +
1.798 + }
1.799 +
1.800 +
1.801 +void CT_FsData::DoCmdSetVolumeLabel(const TDesC& aSection)
1.802 + {
1.803 + INFO_PRINTF1(_L("Calls RFs:: SetVolumeLabel()."));
1.804 +
1.805 + //Get drive index from config.
1.806 + TDriveNumber driveIndex;
1.807 + TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
1.808 +
1.809 + //Get volume name from config.
1.810 + TPtrC volumeLabel;
1.811 + if (!GET_OPTIONAL_STRING_PARAMETER(KVolumeLabel(), aSection, volumeLabel))
1.812 + {
1.813 + volumeLabel.Set(iVolumeLabel);
1.814 + }
1.815 +
1.816 + //Trying to set the volume label. By some reason it always retturn KErrNotSupported.
1.817 + TInt errorCode;
1.818 + if(nonDefault)
1.819 + {
1.820 + errorCode = iFs->SetVolumeLabel(volumeLabel, driveIndex);
1.821 + }
1.822 + else
1.823 + {
1.824 + errorCode = iFs->SetVolumeLabel(volumeLabel);
1.825 + }
1.826 +
1.827 + //Check error code.
1.828 + if (errorCode != KErrNone)
1.829 + {
1.830 + ERR_PRINTF2(_L("Function SetVolumeLabel() failed with %d error code"), errorCode);
1.831 + SetError(errorCode);
1.832 + }
1.833 + }
1.834 +
1.835 +
1.836 +void CT_FsData::DoCmdSubst(const TDesC& aSection)
1.837 + {
1.838 + INFO_PRINTF1(_L("Calls RFs:: Subst()."));
1.839 +
1.840 + //Get drive index from config.
1.841 + TDriveNumber driveIndex;
1.842 +
1.843 +
1.844 + TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
1.845 +
1.846 +
1.847 + TBuf16<KBufferStringLength> substPath;
1.848 +
1.849 + //Get the path to substed drive.
1.850 +
1.851 + TInt errorCode;
1.852 + if(nonDefault)
1.853 + {
1.854 + errorCode = iFs->Subst(substPath, driveIndex);
1.855 + }
1.856 + else
1.857 + {
1.858 + errorCode = iFs->Subst(substPath);
1.859 + }
1.860 +
1.861 + //Check error code.
1.862 + if (errorCode != KErrNone)
1.863 + {
1.864 + ERR_PRINTF2(_L("Function Subst() failed with %d error code"), errorCode);
1.865 + SetError(errorCode);
1.866 + }
1.867 + else
1.868 + {
1.869 + //Get drive index from config.
1.870 + TPtrC substPathFromConf;
1.871 + if (GET_MANDATORY_STRING_PARAMETER(KSubstPath(), aSection, substPathFromConf))
1.872 + {
1.873 +
1.874 + //As long as it has to be in similar format we must convert substPathFromConf to TBuf16<255>
1.875 +
1.876 + //Comparing paths.
1.877 + if (substPathFromConf.CompareF(substPath) != 0)
1.878 + {
1.879 + ERR_PRINTF2(_L("Subst path is wrong %S"), &substPathFromConf);
1.880 + SetBlockResult(EFail);
1.881 + }
1.882 + }
1.883 + }
1.884 +
1.885 +
1.886 + }
1.887 +
1.888 +
1.889 +void CT_FsData::DoCmdSetSubst(const TDesC& aSection)
1.890 + {
1.891 + INFO_PRINTF1(_L("Calls RFs:: SetSubst()."));
1.892 +
1.893 +
1.894 + //Get drive index from config.
1.895 + TDriveNumber driveIndex;
1.896 + TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
1.897 +
1.898 +
1.899 + //Get drive index from config.
1.900 + TPtrC substPath;
1.901 + if (GET_MANDATORY_STRING_PARAMETER(KSubstPath(), aSection, substPath))
1.902 + {
1.903 +
1.904 + //Substing the drive with index driveIndex to path substPath.
1.905 + TInt errorCode;
1.906 + if(nonDefault)
1.907 + {
1.908 + errorCode = iFs->SetSubst(substPath, driveIndex);
1.909 + }
1.910 + else
1.911 + {
1.912 + errorCode = iFs->SetSubst(substPath);
1.913 + }
1.914 +
1.915 + //Check error code.
1.916 + if (errorCode != KErrNone)
1.917 + {
1.918 + ERR_PRINTF2(_L("Function SetSubst() failed with %d error code"), errorCode);
1.919 + SetError(errorCode);
1.920 + }
1.921 +
1.922 + }
1.923 +
1.924 +
1.925 +
1.926 + }
1.927 +
1.928 +
1.929 +void CT_FsData::DoCmdGetMediaSerialNumber(const TDesC& aSection)
1.930 + {
1.931 + INFO_PRINTF1(_L("Calls RFs::GetMediaSerialNumber()."));
1.932 +
1.933 + //Get drive index from config.
1.934 + TDriveNumber driveIndex;
1.935 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.936 + {
1.937 + //Get the media serial number.
1.938 + TMediaSerialNumber mediaSerialNumber;
1.939 + TInt errorCode = iFs->GetMediaSerialNumber(mediaSerialNumber, driveIndex);
1.940 +
1.941 + //Check error code.
1.942 + if (errorCode != KErrNone)
1.943 + {
1.944 + ERR_PRINTF2(_L("Function GetMediaSerialNumber() failed with %d error code"), errorCode);
1.945 + SetError(errorCode);
1.946 + }
1.947 + }
1.948 + else
1.949 + {
1.950 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.951 + SetBlockResult(EFail);
1.952 + }
1.953 +
1.954 + }
1.955 +
1.956 +
1.957 +void CT_FsData::DoCmdIsValidDrive(const TDesC& aSection)
1.958 + {
1.959 + INFO_PRINTF1(_L("Calls RFs::IsValidDirve()."));
1.960 +
1.961 + //Get drive index from config.
1.962 + TDriveNumber driveIndex;
1.963 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.964 + {
1.965 + TBool actualValid = RFs::IsValidDrive(driveIndex);
1.966 + INFO_PRINTF2(_L("iFs->IsValidDrive = %d"), actualValid);
1.967 +
1.968 + //Get drive validity flag rom config.
1.969 + TBool expectedValid;
1.970 + if ( GET_OPTIONAL_BOOL_PARAMETER(KDriveIsValid(), aSection, expectedValid) )
1.971 + {
1.972 + if ( actualValid!=expectedValid )
1.973 + {
1.974 + ERR_PRINTF1(_L("Function IsValid() returned unexpected result"));
1.975 + SetBlockResult(EFail);
1.976 + }
1.977 + }
1.978 + }
1.979 + else
1.980 + {
1.981 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.982 + SetBlockResult(EFail);
1.983 + }
1.984 + }
1.985 +
1.986 +
1.987 +void CT_FsData::DoCmdCharToDrive(const TDesC& aSection)
1.988 + {
1.989 + INFO_PRINTF1(_L("Calls RFs:: CharToDrive()."));
1.990 +
1.991 + //Get drive index from config.
1.992 + //We meed integer there, because function uses TInt, not TDriveNumber.
1.993 +
1.994 + TDriveNumber driveIndex;
1.995 +
1.996 +
1.997 + //Get drive char from config.
1.998 + TPtrC driveCharTmp;
1.999 + if (GET_MANDATORY_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
1.1000 + {
1.1001 +
1.1002 + TChar driveChar = driveCharTmp.Ptr()[0];
1.1003 + TInt driveIndex2;
1.1004 + TInt errorCode = RFs::CharToDrive(driveChar, driveIndex2);
1.1005 +
1.1006 + //Check error code.
1.1007 + if (errorCode != KErrNone)
1.1008 + {
1.1009 + ERR_PRINTF2(_L("Function CharToDrive() failed with %d error code"), errorCode);
1.1010 + SetError(errorCode);
1.1011 + }
1.1012 + else
1.1013 + {
1.1014 + //Get drive index from config
1.1015 + if (GetDriveNumberFromConfig(aSection, KDriveIndex(), driveIndex))
1.1016 + {
1.1017 + if (driveIndex != driveIndex2)
1.1018 + {
1.1019 + ERR_PRINTF1(_L("Wrong conversion from char to index"));
1.1020 + SetBlockResult(EFail);
1.1021 + }
1.1022 + }
1.1023 + }
1.1024 + }
1.1025 + else
1.1026 + {
1.1027 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.1028 + SetBlockResult(EFail);
1.1029 + }
1.1030 + }
1.1031 +
1.1032 +
1.1033 +void CT_FsData::DoCmdDriveToChar(const TDesC& aSection)
1.1034 + {
1.1035 + INFO_PRINTF1(_L("Calls RFs:: DriveToChar()."));
1.1036 +
1.1037 + TPtrC driveCharTmp;
1.1038 +
1.1039 + //Get drive path from config.
1.1040 + TDriveNumber driveIndex;
1.1041 + if (GetDriveNumberFromConfig(aSection, KDriveIndex(), driveIndex))
1.1042 + {
1.1043 +
1.1044 + TChar driveChar2;
1.1045 + TInt errorCode = RFs::DriveToChar(driveIndex, driveChar2);
1.1046 + //Check error code.
1.1047 +
1.1048 + if (errorCode != KErrNone)
1.1049 + {
1.1050 + ERR_PRINTF2(_L("Function DriveToChar() failed with %d error code"), errorCode);
1.1051 + SetError(errorCode);
1.1052 + }
1.1053 + else
1.1054 + {
1.1055 + INFO_PRINTF3(_L("DriveToChar(%d) = %c"), driveIndex, TUint(driveChar2));
1.1056 +
1.1057 + //Get drive char from config.
1.1058 + if (GET_OPTIONAL_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
1.1059 + {
1.1060 +
1.1061 + TChar driveChar= driveCharTmp.Ptr()[0];
1.1062 + if (driveChar != driveChar2)
1.1063 + {
1.1064 + ERR_PRINTF1(_L("Wrong conversion from char to index"));
1.1065 + SetBlockResult(EFail);
1.1066 + }
1.1067 + }
1.1068 + }
1.1069 + }
1.1070 + else
1.1071 + {
1.1072 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.1073 + SetBlockResult(EFail);
1.1074 + }
1.1075 + }
1.1076 +
1.1077 +
1.1078 +void CT_FsData::DoCmdCheckDisk(const TDesC& aSection)
1.1079 + {
1.1080 + INFO_PRINTF1(_L("Calls RFs:: CheckDisk()."));
1.1081 +
1.1082 + //Get drive path from config.
1.1083 + TPtrC drivePath;
1.1084 + if (GET_MANDATORY_STRING_PARAMETER(KDrivePath(), aSection, drivePath))
1.1085 + {
1.1086 +
1.1087 + TInt errorCode = iFs->CheckDisk(drivePath);
1.1088 +
1.1089 + //Check error code.
1.1090 + if (errorCode != KErrNone)
1.1091 + {
1.1092 + ERR_PRINTF2(_L("Function CheckDisk() failed with %d error code"), errorCode);
1.1093 + SetError(errorCode);
1.1094 + }
1.1095 +
1.1096 + }
1.1097 +
1.1098 + }
1.1099 +
1.1100 +void CT_FsData::DoCmdScanDrive(const TDesC& aSection)
1.1101 + {
1.1102 + INFO_PRINTF1(_L("Calls RFs:: ScanDisk()."));
1.1103 +
1.1104 + //Get drive path from config.
1.1105 + TPtrC drivePath;
1.1106 + if (GET_MANDATORY_STRING_PARAMETER(KDrivePath(), aSection, drivePath))
1.1107 + {
1.1108 +
1.1109 + TInt errorCode = iFs->ScanDrive(drivePath);
1.1110 +
1.1111 + //Check error code.
1.1112 + if (errorCode != KErrNone)
1.1113 + {
1.1114 + ERR_PRINTF2(_L("Function ScanDrive() failed with %d error code"), errorCode);
1.1115 + SetError(errorCode);
1.1116 + }
1.1117 +
1.1118 + }
1.1119 +
1.1120 + }
1.1121 +
1.1122 +
1.1123 +void CT_FsData::DoCmdGetDriveName(const TDesC& aSection)
1.1124 + {
1.1125 + INFO_PRINTF1(_L("Calls RFs::Calls GetDriveName()"));
1.1126 +
1.1127 + //Get drive index from config.
1.1128 + TDriveNumber driveIndex;
1.1129 +
1.1130 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.1131 + {
1.1132 + TBuf<KBufferStringLength> driveName;
1.1133 + TInt errorCode = iFs->GetDriveName(driveIndex, driveName);
1.1134 +
1.1135 + //Check error code.
1.1136 + if (errorCode != KErrNone)
1.1137 + {
1.1138 + ERR_PRINTF2(_L("Function SetDriveLabel() failed with %d error code"), errorCode);
1.1139 + SetError(errorCode);
1.1140 + }
1.1141 + else
1.1142 + {
1.1143 + //Get drive name from config.
1.1144 + TPtrC driveNameFromConf;
1.1145 + if(GET_OPTIONAL_STRING_PARAMETER(KDriveName(), aSection, driveNameFromConf))
1.1146 + {
1.1147 + TPtrC driveNamePtr = driveName;
1.1148 + if (driveNamePtr != driveNameFromConf)
1.1149 + {
1.1150 + ERR_PRINTF3(_L("Names mismatch: %S != %S"), &driveNamePtr, &driveNameFromConf);
1.1151 + SetBlockResult(EFail);
1.1152 + }
1.1153 + }
1.1154 +
1.1155 + TBool save;
1.1156 +
1.1157 + if(GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save))
1.1158 + {
1.1159 + if(save)
1.1160 + {
1.1161 + iDriveName.Copy(iDriveName);
1.1162 + }
1.1163 + }
1.1164 + }
1.1165 + }
1.1166 + else
1.1167 + {
1.1168 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.1169 + SetBlockResult(EFail);
1.1170 + }
1.1171 + }
1.1172 +
1.1173 +
1.1174 +void CT_FsData::DoCmdSetDriveName(const TDesC& aSection)
1.1175 + {
1.1176 + INFO_PRINTF1(_L("Calls RFs::SetDriveName()."));
1.1177 +
1.1178 + //Get drive index from config.
1.1179 + TDriveNumber driveIndex;
1.1180 + if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
1.1181 + {
1.1182 + //Get drive name from config.
1.1183 + TPtrC driveName;
1.1184 + if ( !GET_OPTIONAL_STRING_PARAMETER(KDriveName(), aSection, driveName) )
1.1185 + {
1.1186 + driveName.Set(iDriveName);
1.1187 + }
1.1188 +
1.1189 + //Check error code.
1.1190 + TInt errorCode = iFs->SetDriveName(driveIndex, driveName);
1.1191 + if (errorCode != KErrNone)
1.1192 + {
1.1193 + ERR_PRINTF2(_L("Function SetDriveLabel() failed with %d error code"), errorCode);
1.1194 + SetError(errorCode);
1.1195 + }
1.1196 + }
1.1197 + else
1.1198 + {
1.1199 + ERR_PRINTF2(_L("Not found %S parameter"), KDriveIndex);
1.1200 + SetBlockResult(EFail);
1.1201 + }
1.1202 + }
1.1203 +
1.1204 +//
1.1205 +void CT_FsData::DoCmdLockDrive(const TDesC& aSection)
1.1206 + {
1.1207 + INFO_PRINTF1(_L("Calls RFs::LockDrive()."));
1.1208 +
1.1209 + //Get old password from config.
1.1210 + TPtrC drivePassword;
1.1211 + if ( GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, drivePassword) )
1.1212 + {
1.1213 + //Get drive index from config.
1.1214 + TDriveNumber driveIndex;
1.1215 + if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
1.1216 + {
1.1217 + //Get new password from config.
1.1218 + TPtrC driveNewPassword;
1.1219 + if ( GET_MANDATORY_STRING_PARAMETER(KDriveNewPassword(), aSection, driveNewPassword) )
1.1220 + {
1.1221 + // get boolean value from config
1.1222 + TBool store;
1.1223 + if (GET_MANDATORY_BOOL_PARAMETER(KStore(), aSection, store))
1.1224 + {
1.1225 + TMediaPassword password;
1.1226 + password.Copy(driveNewPassword);
1.1227 + iPassword.Copy(drivePassword);
1.1228 +
1.1229 + TInt errorCode = iFs->LockDrive(driveIndex, iPassword, password, store);
1.1230 +
1.1231 + //Check error code.
1.1232 + if (errorCode == KErrNone)
1.1233 + {
1.1234 + iPassword=password;
1.1235 + }
1.1236 + else
1.1237 + {
1.1238 + ERR_PRINTF2(_L("Function LockDrive() failed with %d error code"), errorCode);
1.1239 + SetError(errorCode);
1.1240 + }
1.1241 + }
1.1242 + }
1.1243 + }
1.1244 + }
1.1245 + }
1.1246 +
1.1247 +
1.1248 +void CT_FsData::DoCmdUnlockDrive(const TDesC& aSection)
1.1249 + {
1.1250 + INFO_PRINTF1(_L("Calls RFs::UnlockDrive()."));
1.1251 +
1.1252 + //Get old password from config.
1.1253 + TPtrC drivePassword;
1.1254 + if ( GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, drivePassword) )
1.1255 + {
1.1256 + //Get drive index from config.
1.1257 + TDriveNumber driveIndex;
1.1258 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.1259 + {
1.1260 + // get boolean value from config
1.1261 + TBool store;
1.1262 + if (GET_MANDATORY_BOOL_PARAMETER(KStore(), aSection, store))
1.1263 + {
1.1264 + TMediaPassword password;
1.1265 + //Converting string to appropriative password format(TMediaPassword is typedef for TBuf<16>)
1.1266 + password.Copy(drivePassword);
1.1267 +
1.1268 + TInt errorCode = iFs->UnlockDrive(driveIndex, password, store);
1.1269 +
1.1270 + //Check error code.
1.1271 + if (errorCode == KErrNone)
1.1272 + {
1.1273 + iPassword=password;
1.1274 + }
1.1275 + else
1.1276 + {
1.1277 + ERR_PRINTF2(_L("Function UnlockDrive() failed with %d error code"), errorCode);
1.1278 + SetError(errorCode);
1.1279 + }
1.1280 + }
1.1281 + }
1.1282 + else
1.1283 + {
1.1284 + ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
1.1285 + SetBlockResult(EFail);
1.1286 + }
1.1287 + }
1.1288 + }
1.1289 +
1.1290 +
1.1291 +void CT_FsData::DoCmdClearPassword(const TDesC& aSection)
1.1292 + {
1.1293 + INFO_PRINTF1(_L("Calls RFs::ClearPassword()."));
1.1294 +
1.1295 + //Get old password from config.
1.1296 + TPtrC driveOldPasswordTmp;
1.1297 + if (GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, driveOldPasswordTmp))
1.1298 + {
1.1299 + //Get drive index from config.
1.1300 + TDriveNumber driveIndex;
1.1301 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.1302 + {
1.1303 + //Converting string to appropriative password format(TMediaPassword is typedef for TBuf<16>)
1.1304 + TMediaPassword driveOldPassword;
1.1305 + driveOldPassword.Copy(driveOldPasswordTmp);
1.1306 +
1.1307 + TInt errorCode = iFs->ClearPassword(driveIndex, driveOldPassword);
1.1308 + if (errorCode != KErrNone)
1.1309 + {
1.1310 + ERR_PRINTF2(_L("Function ClearPassword() failed with %d error code"), errorCode);
1.1311 + SetError(errorCode);
1.1312 + }
1.1313 + }
1.1314 + else
1.1315 + {
1.1316 + ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
1.1317 + SetBlockResult(EFail);
1.1318 + }
1.1319 + }
1.1320 + }
1.1321 +
1.1322 +
1.1323 +void CT_FsData::DoCmdErasePassword(const TDesC& aSection)
1.1324 + {
1.1325 + INFO_PRINTF1(_L("Calls RFs::ErasePassword()."));
1.1326 +
1.1327 + //Get drive from config.
1.1328 + TDriveNumber driveIndex;
1.1329 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.1330 + {
1.1331 + TInt errorCode = iFs->ErasePassword(driveIndex);
1.1332 +
1.1333 + //Check error code.
1.1334 + if (errorCode != KErrNone)
1.1335 + {
1.1336 + ERR_PRINTF2(_L("Function ErasePassword() failed with %d error code"), errorCode);
1.1337 + SetError(errorCode);
1.1338 + }
1.1339 + }
1.1340 + else
1.1341 + {
1.1342 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.1343 + SetBlockResult(EFail);
1.1344 + }
1.1345 + }
1.1346 +
1.1347 +
1.1348 +void CT_FsData::DoCmdReserveDriveSpace(const TDesC& aSection)
1.1349 + {
1.1350 + INFO_PRINTF1(_L("Calls RFs::ReserveDriveSpace()."));
1.1351 +
1.1352 + //Get amount of bytes to be reserved from config.
1.1353 + TInt bytesToReserve;
1.1354 + if (GET_MANDATORY_INT_PARAMETER(KBytesToReserve(), aSection, bytesToReserve))
1.1355 + {
1.1356 + TDriveNumber driveIndex;
1.1357 +
1.1358 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.1359 + {
1.1360 + TInt errorCode = iFs->ReserveDriveSpace(driveIndex, bytesToReserve);
1.1361 +
1.1362 + //Check error code.
1.1363 + if (errorCode != KErrNone)
1.1364 + {
1.1365 + ERR_PRINTF2(_L("Function ReserveDriveSpace() failed with %d error code"), errorCode);
1.1366 + SetError(errorCode);
1.1367 + }
1.1368 + }
1.1369 + else
1.1370 + {
1.1371 + ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
1.1372 + SetBlockResult(EFail);
1.1373 + }
1.1374 + }
1.1375 + }
1.1376 +
1.1377 +
1.1378 +void CT_FsData::DoCmdGetReserveAccess(const TDesC& aSection)
1.1379 + {
1.1380 + INFO_PRINTF1(_L("Calls RFs::GetReserveAccess()."));
1.1381 +
1.1382 + //Get drive index from config.
1.1383 + TDriveNumber driveIndex;
1.1384 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.1385 + {
1.1386 + TInt errorCode = iFs->GetReserveAccess(driveIndex);
1.1387 +
1.1388 + //Check error code.
1.1389 + if (errorCode != KErrNone)
1.1390 + {
1.1391 + ERR_PRINTF2(_L("Function GetReserveAccess() failed with %d error code"), errorCode);
1.1392 + SetError(errorCode);
1.1393 + }
1.1394 + }
1.1395 + else
1.1396 + {
1.1397 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.1398 + SetBlockResult(EFail);
1.1399 + }
1.1400 + }
1.1401 +
1.1402 +
1.1403 +void CT_FsData::DoCmdReleaseReserveAccess(const TDesC& aSection)
1.1404 + {
1.1405 + INFO_PRINTF1(_L("Calls RFs::ReleaseReserveAccess()."));
1.1406 +
1.1407 + //Get drive index from config.
1.1408 + TDriveNumber driveIndex;
1.1409 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
1.1410 + {
1.1411 + TInt errorCode = iFs->ReleaseReserveAccess(driveIndex);
1.1412 +
1.1413 + //Check error code.
1.1414 + if (errorCode != KErrNone)
1.1415 + {
1.1416 + ERR_PRINTF2(_L("Function ReleaseReserveAccess() failed with %d error code"), errorCode);
1.1417 + SetError(errorCode);
1.1418 + }
1.1419 + }
1.1420 + else
1.1421 + {
1.1422 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.1423 + SetBlockResult(EFail);
1.1424 + }
1.1425 + }
1.1426 +
1.1427 +void CT_FsData::DoCmdGetSystemDrive(const TDesC& aSection)
1.1428 + {
1.1429 + INFO_PRINTF1(_L("Calls RFs::GetSystemDrive()."));
1.1430 +
1.1431 + TDriveNumber driveNumber = RFs::GetSystemDrive();
1.1432 + INFO_PRINTF2(_L("System Drive = %d"), driveNumber);
1.1433 +
1.1434 + //Get drive index from config.
1.1435 + TDriveNumber driveIndex;
1.1436 + if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
1.1437 + {
1.1438 + //Check error code.
1.1439 + if (driveNumber != driveIndex)
1.1440 + {
1.1441 + ERR_PRINTF1(_L("GetSystemDrive() returned unexpected drive"));
1.1442 + SetBlockResult(EFail);
1.1443 + }
1.1444 + }
1.1445 + else
1.1446 + {
1.1447 + ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
1.1448 + SetBlockResult(EFail);
1.1449 + }
1.1450 + }
1.1451 +
1.1452 +void CT_FsData::DoCmdSetSystemDrive(const TDesC& aSection)
1.1453 + {
1.1454 + INFO_PRINTF1(_L("Calls RFs::SetSystemDrive()"));
1.1455 +
1.1456 + // get drive number from parameters
1.1457 + TDriveNumber driveNumber = EDriveA;
1.1458 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
1.1459 + {
1.1460 + TInt err = iFs->SetSystemDrive(driveNumber);
1.1461 + // check error code
1.1462 + if (err != KErrNone)
1.1463 + {
1.1464 + ERR_PRINTF2(_L("SetSystemDrive() error: %d"), err);
1.1465 + SetError(err);
1.1466 + }
1.1467 + }
1.1468 + else
1.1469 + {
1.1470 + ERR_PRINTF2(_L("No %S"), &KDrive());
1.1471 + SetBlockResult(EFail);
1.1472 + }
1.1473 +
1.1474 + }
1.1475 +
1.1476 +void CT_FsData::DoCmdGetSystemDriveChar(const TDesC& aSection)
1.1477 + {
1.1478 + INFO_PRINTF1(_L("Calls RFs::GetSystemDriveChar()"));
1.1479 +
1.1480 + TChar drvChar = RFs::GetSystemDriveChar();
1.1481 + INFO_PRINTF2(_L("GetSystemDriveChar() = %c"), TUint(drvChar));
1.1482 + //Get drive char from config.
1.1483 + TPtrC driveCharTmp;
1.1484 + if (GET_OPTIONAL_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
1.1485 + {
1.1486 + TChar driveCharExpect = driveCharTmp.Ptr()[0];
1.1487 + driveCharExpect.UpperCase();
1.1488 + drvChar.UpperCase();
1.1489 + if ( drvChar != driveCharExpect)
1.1490 + {
1.1491 + ERR_PRINTF1(_L("Drive char != expected drive char"));
1.1492 + SetBlockResult(EFail);
1.1493 + }
1.1494 + }
1.1495 + }
1.1496 +
1.1497 +void CT_FsData::DoCmdVolumeIOParam(const TDesC& aSection)
1.1498 + {
1.1499 + INFO_PRINTF1(_L("Calls RFs::VolumeIOParam()"));
1.1500 +
1.1501 + // get drive number from parameters
1.1502 + TDriveNumber driveNumber = EDriveA;
1.1503 + if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
1.1504 + {
1.1505 + TVolumeIOParamInfo volumeIOParamInf;
1.1506 + TInt err = iFs->VolumeIOParam(driveNumber, volumeIOParamInf);
1.1507 + // check error code
1.1508 + if (err != KErrNone)
1.1509 + {
1.1510 + ERR_PRINTF2(_L("VolumeIOParam() error: %d"), err);
1.1511 + SetError(err);
1.1512 + }
1.1513 + else
1.1514 + {
1.1515 + INFO_PRINTF2(_L("VolumeIOParam BlockSize: %d"), volumeIOParamInf.iBlockSize );
1.1516 + INFO_PRINTF2(_L("VolumeIOParam ClusterSize: %d"), volumeIOParamInf.iClusterSize );
1.1517 + INFO_PRINTF2(_L("VolumeIOParam RecReadBufSize: %d"), volumeIOParamInf.iRecReadBufSize );
1.1518 + INFO_PRINTF2(_L("VolumeIOParam RecWriteBufSize: %d"), volumeIOParamInf.iRecWriteBufSize );
1.1519 + }
1.1520 + }
1.1521 + else
1.1522 + {
1.1523 + ERR_PRINTF2(_L("No %S"), &KDrive());
1.1524 + SetBlockResult(EFail);
1.1525 + }
1.1526 + }
1.1527 +
1.1528 +