os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_FsDataDrives.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 /**
    20 @test
    21 @internalComponent
    22 
    23 This contains CT_FsData
    24 */
    25 
    26 //	User includes
    27 #include "T_FsData.h"
    28 #include "T_VolumeInfoData.h"
    29 #include "FileserverUtil.h"
    30 
    31 /*@{*/
    32 ///Constants
    33 
    34 _LIT(KPromptProcess,				"t_prompt.exe");
    35 
    36 
    37 /// Enumerations
    38 _LIT(KMediaNotPresent,				"EMediaNotPresent");
    39 _LIT(KMediaUnknown,					"EMediaUnknown");
    40 _LIT(KMediaFloppy,					"EMediaFloppy");
    41 _LIT(KMediaHardDisk,				"EMediaHardDisk");
    42 _LIT(KMediaCdRom,					"EMediaCdRom");
    43 _LIT(KMediaRam,						"EMediaRam");
    44 _LIT(KMediaFlash,					"EMediaFlash");
    45 _LIT(KMediaRom,						"EMediaRom");
    46 _LIT(KMediaRemote,					"EMediaRemote");
    47 _LIT(KMediaNANDFlash,				"EMediaNANDFlash");
    48 
    49 _LIT(KBatNotSupported,				"EBatNotSupported");
    50 _LIT(KBatLow,						"EBatLow");
    51 _LIT(KBatGood,						"EBatGood");
    52 
    53 _LIT(KDriveAttLocalStr,				"KDriveAttLocal");
    54 _LIT(KDriveAttRomStr,				"KDriveAttRom");
    55 _LIT(KDriveAttRedirectedStr,		"KDriveAttRedirected");
    56 _LIT(KDriveAttSubstedStr,			"KDriveAttSubsted");
    57 _LIT(KDriveAttInternalStr,			"KDriveAttInternal");
    58 _LIT(KDriveAttRemovableStr,			"KDriveAttRemovable");
    59 
    60 _LIT(KMediaAttVariableSizeStr,		"KMediaAttVariableSize");
    61 _LIT(KMediaAttDualDensityStr,		"KMediaAttDualDensity");
    62 _LIT(KMediaAttFormattableStr,		"KMediaAttFormattable");
    63 _LIT(KMediaAttWriteProtectedStr,	"KMediaAttWriteProtected");
    64 _LIT(KMediaAttLockableStr,			"KMediaAttLockable");
    65 _LIT(KMediaAttLockedStr,			"KMediaAttLocked");
    66 
    67 
    68 ///	Parameters
    69 _LIT(KStore,						"store");
    70 _LIT(KMediaType,					"media_type");
    71 _LIT(KDriveAtt,						"drive_att");
    72 _LIT(KMediaAtt,						"media_att");
    73 _LIT(KDriveIndex,					"drive_index");
    74 _LIT(KDriveChar,					"drive_char");
    75 _LIT(KArraySize,					"array_size");
    76 _LIT(KArrayIndex,					"array_index_");
    77 _LIT(KVolumeLabel,					"volume_label");
    78 _LIT(KSubstPath,					"subst_path");
    79 _LIT(KDriveName,					"drive_name");
    80 _LIT(KDriveOldPassword,				"drive_old_password");
    81 _LIT(KDriveNewPassword,				"drive_new_password");
    82 _LIT(KBytesToReserve,				"bytes_to_reserve");
    83 _LIT(KDriveIsValid,					"drive_is_valid");
    84 _LIT(KDrivePath,					"drive_path");
    85 _LIT(KDrive,						"drive");
    86 _LIT(KBatteryState,					"battery_state");
    87 _LIT(KSaveInInstance,				"save_in_instance");
    88 _LIT(KVolumeObject,					"store_volume");
    89 
    90 
    91 ///	Commands
    92 _LIT(KCmdDriveList,					"DriveList");
    93 _LIT(KCmdDrive,						"Drive");
    94 _LIT(KCmdVolume,					"Volume");
    95 _LIT(KCmdSetVolumeLabel,			"SetVolumeLabel");
    96 _LIT(KCmdSubst,						"Subst");
    97 _LIT(KCmdSetSubst,					"SetSubst");
    98 _LIT(KCmdGetMediaSerialNumber,		"GetMediaSerialNumber");
    99 _LIT(KCmdIsValidDrive,				"IsValidDrive");
   100 _LIT(KCmdCharToDrive,				"CharToDrive");
   101 _LIT(KCmdDriveToChar,				"DriveToChar");
   102 _LIT(KCmdCheckDisk,					"CheckDisk");
   103 _LIT(KCmdScanDrive,					"ScanDrive");
   104 _LIT(KCmdGetDriveName,				"GetDriveName");
   105 _LIT(KCmdSetDriveName,				"SetDriveName");
   106 _LIT(KCmdLockDrive,					"LockDrive");
   107 _LIT(KCmdUnlockDrive,				"UnlockDrive");
   108 _LIT(KCmdClearPassword,				"ClearPassword");
   109 _LIT(KCmdErasePassword,				"ErasePassword");
   110 _LIT(KCmdReserveDriveSpace,			"ReserveDriveSpace");
   111 _LIT(KCmdGetReserveAccess,			"GetReserveAccess");
   112 _LIT(KCmdReleaseReserveAccess,		"ReleaseReserveAccess");
   113 _LIT(KCmdPrompt,					"prompt");
   114 _LIT(KCmdGetSystemDrive,			"GetSystemDrive");
   115 _LIT(KCmdSetSystemDrive,			"SetSystemDrive");
   116 _LIT(KCmdGetSystemDriveChar,		"GetSystemDriveChar");
   117 _LIT(KCmdVolumeIOParam,				"VolumeIOParam");
   118 
   119 /*@}*/
   120 
   121 /**
   122 * Process a drives related command read from the ini file
   123 *
   124 * @param aCommand	the command to process
   125 * @param aSection		the entry in the ini file requiring the command to be processed
   126 *
   127 * @return ETrue if the command is processed
   128 */
   129 TBool CT_FsData::DoCommandDrivesL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
   130 	{
   131 	TBool retVal = ETrue;
   132 	//Parsing the aCommand to choose which function has to be executed.
   133 
   134 	if (aCommand == KCmdDriveList)
   135 		{
   136 		DoCmdDriveList(aSection);
   137 		}
   138 	else if (aCommand  == KCmdDrive)
   139 		{
   140 		DoCmdDriveL(aSection);
   141 		}
   142 	else if (aCommand == KCmdVolume)
   143 		{
   144 		DoCmdVolumeL(aSection);
   145 		}
   146 	else if (aCommand == KCmdSetVolumeLabel)
   147 		{
   148 		DoCmdSetVolumeLabel(aSection);
   149 		}
   150 	else if (aCommand == KCmdSubst)
   151 		{
   152 		DoCmdSubst(aSection);
   153 		}
   154 	else if (aCommand == KCmdSetSubst)
   155 		{
   156 		DoCmdSetSubst(aSection);
   157 		}
   158 	else if (aCommand == KCmdGetMediaSerialNumber)
   159 		{
   160 		DoCmdGetMediaSerialNumber(aSection);
   161 		}
   162 	else if (aCommand == KCmdIsValidDrive)
   163 		{
   164 		DoCmdIsValidDrive(aSection);
   165 		}
   166 	else if (aCommand == KCmdCharToDrive)
   167 		{
   168 		DoCmdCharToDrive(aSection);
   169 		}
   170 	else if (aCommand == KCmdDriveToChar)
   171 		{
   172 		DoCmdDriveToChar(aSection);
   173 		}
   174 	else if (aCommand == KCmdCheckDisk)
   175 		{
   176 		DoCmdCheckDisk(aSection);
   177 		}
   178 	else if (aCommand == KCmdScanDrive)
   179 		{
   180 		DoCmdScanDrive(aSection);
   181 		}
   182 	else if (aCommand == KCmdGetDriveName)
   183 		{
   184 		DoCmdGetDriveName(aSection);
   185 		}
   186 	else if (aCommand == KCmdSetDriveName)
   187 		{
   188 		DoCmdSetDriveName(aSection);
   189 		}
   190 	else if (aCommand == KCmdLockDrive)
   191 		{
   192 		DoCmdLockDrive(aSection);
   193 		}
   194 	else if (aCommand == KCmdUnlockDrive)
   195 		{
   196 		DoCmdUnlockDrive(aSection);
   197 		}
   198 	else if (aCommand == KCmdClearPassword)
   199 		{
   200 		DoCmdClearPassword(aSection);
   201 		}
   202 	else if (aCommand == KCmdErasePassword)
   203 		{
   204 		DoCmdErasePassword(aSection);
   205 		}
   206 	else if (aCommand == KCmdReserveDriveSpace)
   207 		{
   208 		DoCmdReserveDriveSpace(aSection);
   209 		}
   210 	else if (aCommand == KCmdGetReserveAccess)
   211 		{
   212 		DoCmdGetReserveAccess(aSection);
   213 		}
   214 	else if (aCommand == KCmdReleaseReserveAccess)
   215 		{
   216 		DoCmdReleaseReserveAccess(aSection);
   217 		}
   218 	else if (aCommand == KCmdPrompt)
   219 		{
   220 		DoCmdPromptL(aSection);
   221 		}
   222 	else if (aCommand == KCmdGetSystemDrive)
   223 		{
   224 		DoCmdGetSystemDrive(aSection);
   225 		}
   226 	else if (aCommand == KCmdGetSystemDriveChar)
   227 		{
   228 		DoCmdGetSystemDriveChar(aSection);
   229 		}
   230 	else if (aCommand == KCmdSetSystemDrive)
   231 		{
   232 		DoCmdSetSystemDrive(aSection);
   233 		}
   234 	else if (aCommand == KCmdVolumeIOParam)
   235 		{
   236 		DoCmdVolumeIOParam(aSection);
   237 		}
   238 	else
   239 		{
   240 		retVal = EFalse;
   241 		}
   242 
   243 	return retVal;
   244 	}
   245 
   246 
   247 TBool CT_FsData::GetMediaTypeFromConfig(const TDesC& aSection, TMediaType& aMediaType)
   248 	{
   249 	// Read media type from INI file
   250 	TPtrC mediaTypeStr;
   251 	TBool ret = GET_OPTIONAL_STRING_PARAMETER(KMediaType(), aSection, mediaTypeStr);
   252 
   253 	if (ret)
   254 		{
   255 		if (mediaTypeStr == KMediaNotPresent)
   256 			{
   257 			aMediaType = EMediaNotPresent;
   258 			}
   259 		else if (mediaTypeStr == KMediaUnknown)
   260 			{
   261 			aMediaType = EMediaUnknown;
   262 			}
   263 		else if (mediaTypeStr == KMediaFloppy)
   264 			{
   265 			aMediaType = EMediaFloppy;
   266 			}
   267 		else if (mediaTypeStr == KMediaHardDisk)
   268 			{
   269 			aMediaType = EMediaHardDisk;
   270 			}
   271 		else if (mediaTypeStr == KMediaCdRom)
   272 			{
   273 			aMediaType = EMediaCdRom;
   274 			}
   275 		else if (mediaTypeStr == KMediaRam)
   276 			{
   277 			aMediaType = EMediaRam;
   278 			}
   279 		else if (mediaTypeStr == KMediaFlash)
   280 			{
   281 			aMediaType = EMediaFlash;
   282 			}
   283 		else if (mediaTypeStr == KMediaRom)
   284 			{
   285 			aMediaType = EMediaRom;
   286 			}
   287 		else if (mediaTypeStr == KMediaRemote)
   288 			{
   289 			aMediaType = EMediaRemote;
   290 			}
   291 		else if (mediaTypeStr == KMediaNANDFlash)
   292 			{
   293 			aMediaType = EMediaNANDFlash;
   294 			}
   295 		else
   296 			{
   297 			TInt mediaType = 0;
   298 			ret = GET_MANDATORY_INT_PARAMETER(KMediaType, aSection, mediaType);
   299 			if (ret)
   300 				{
   301 				aMediaType = (TMediaType) mediaType;
   302 				}
   303 			}
   304 		}
   305 	return ret;
   306 	}
   307 
   308 TBool CT_FsData::ConvertToDriveAtts(const TDesC& aDriveAttStr, TUint& aDriveAtt)
   309 	{
   310 	TBool	ret = ETrue;
   311 	if ( aDriveAttStr==KDriveAttLocalStr )
   312 		{
   313 		aDriveAtt=KDriveAttLocal;
   314 		}
   315 	else if ( aDriveAttStr==KDriveAttRomStr )
   316 		{
   317 		aDriveAtt=KDriveAttRom;
   318 		}
   319 	else if ( aDriveAttStr==KDriveAttRedirectedStr )
   320 		{
   321 		aDriveAtt=KDriveAttRedirected;
   322 		}
   323 	else if ( aDriveAttStr==KDriveAttSubstedStr )
   324 		{
   325 		aDriveAtt=KDriveAttSubsted;
   326 		}
   327 	else if ( aDriveAttStr==KDriveAttInternalStr )
   328 		{
   329 		aDriveAtt=KDriveAttInternal;
   330 		}
   331 	else if ( aDriveAttStr==KDriveAttRemovableStr )
   332 		{
   333 		aDriveAtt=KDriveAttRemovable;
   334 		}
   335 	else
   336 		{
   337 		TInt	location = aDriveAttStr.Match(_L("*|*"));
   338 		if( location!=KErrNotFound )
   339 			{
   340 			//Converting Left part of the data
   341 			TPtrC	tempStr = aDriveAttStr.Left(location);
   342 			ret=ConvertToDriveAtts(tempStr, aDriveAtt);
   343 
   344 			//Converting right data can be with another "|"
   345 			tempStr.Set(aDriveAttStr.Mid(location+1));
   346 
   347 			TUint	driveAttTmp;
   348 			if ( ConvertToDriveAtts(tempStr, driveAttTmp) )
   349 				{
   350 				aDriveAtt=aDriveAtt|driveAttTmp;
   351 				}
   352 			else
   353 				{
   354 				ret=EFalse;
   355 				}
   356 			}
   357 		else
   358 			{
   359 			ret=EFalse;
   360 			}
   361 		}
   362 
   363 	return ret;
   364 	}
   365 
   366 void CT_FsData::DoCmdPromptL(const TDesC& /*aSection*/)
   367 	{
   368 	RProcess promptProcess;
   369 	TInt err = promptProcess.Create(KPromptProcess, KNullDesC);
   370 	
   371 	if (err == KErrNone)
   372 		{
   373 		CleanupClosePushL(promptProcess);
   374 		TRequestStatus promptStatus;
   375 		promptProcess.Rendezvous(promptStatus);
   376 
   377 		if (promptStatus == KRequestPending)
   378 			{
   379 			promptProcess.Resume();
   380 			User::WaitForRequest(promptStatus);
   381 			if (err != KErrNone)
   382 				{
   383 				ERR_PRINTF2(_L("Prompt process finished with error %d"), promptStatus.Int());
   384 				SetBlockResult(EFail);
   385 				}
   386 			}
   387 		else
   388 			{
   389 			promptProcess.RendezvousCancel(promptStatus);
   390 			promptProcess.Kill(0);
   391 			ERR_PRINTF2(_L("Executing of prompt process failed with error %d"), promptStatus.Int());
   392 			SetBlockResult(EFail);
   393 			}
   394 
   395 		CleanupStack::PopAndDestroy();
   396 		}
   397 	else
   398 		{
   399 		ERR_PRINTF2(_L("Failed to create prompt process with error %d"), err);
   400 		SetBlockResult(EFail);
   401 		}
   402 	}
   403 	
   404 TBool CT_FsData::GetDriveAttsFromConfig(const TDesC& aSection, TUint& aDriveAtt)
   405 	{
   406 	aDriveAtt = 0;
   407 
   408 	TPtrC	driveAttStr;
   409 	TBool ret = GET_OPTIONAL_STRING_PARAMETER(KDriveAtt(), aSection, driveAttStr);
   410 	if ( ret )
   411 		{
   412 		if ( !ConvertToDriveAtts(driveAttStr, aDriveAtt) )
   413 			{
   414 			TInt	intTemp;
   415 			ret=GET_MANDATORY_INT_PARAMETER(KDriveAtt(), aSection, intTemp);
   416 			if ( ret )
   417 				{
   418 				aDriveAtt=intTemp;
   419 				}
   420 			}
   421 		}
   422 
   423 	return ret;
   424 	}
   425 
   426 TBool CT_FsData::GetBatteryStateFromConfig(const TDesC& aSection, TBatteryState& aBatteryState)
   427 	{
   428 	// Read media type from INI file
   429 	aBatteryState = EBatLow;
   430 
   431 	TPtrC batteryStateStr;
   432 	TBool ret = GET_OPTIONAL_STRING_PARAMETER(KBatteryState(), aSection, batteryStateStr);
   433 
   434 	if (ret)
   435 		{
   436 		if (batteryStateStr == KBatNotSupported)
   437 			{
   438 			aBatteryState = EBatNotSupported;
   439 			}
   440 		else if (batteryStateStr == KBatGood)
   441 			{
   442 			aBatteryState = EBatGood;
   443 			}
   444 
   445 		if (batteryStateStr == KBatLow)
   446 			{
   447 			aBatteryState = EBatLow;
   448 			}
   449 		else
   450 			{
   451 			aBatteryState = EBatNotSupported;
   452 			}
   453 		}
   454 
   455 	return ret;
   456 	}
   457 
   458 TBool CT_FsData::ConvertToMediaAtts(const TDesC& aMediaAttStr, TUint& aMediaAtt)
   459 	{
   460 	TBool	ret = ETrue;
   461 	if ( aMediaAttStr==KMediaAttVariableSizeStr )
   462 		{
   463 		aMediaAtt=KMediaAttVariableSize;
   464 		}
   465 	else if ( aMediaAttStr==KMediaAttDualDensityStr )
   466 		{
   467 		aMediaAtt=KMediaAttDualDensity;
   468 		}
   469 	else if ( aMediaAttStr==KMediaAttFormattableStr )
   470 		{
   471 		aMediaAtt=KMediaAttFormattable;
   472 		}
   473 	else if ( aMediaAttStr==KMediaAttWriteProtectedStr )
   474 		{
   475 		aMediaAtt=KMediaAttWriteProtected;
   476 		}
   477 	else if ( aMediaAttStr==KMediaAttLockableStr )
   478 		{
   479 		aMediaAtt=KMediaAttLockable;
   480 		}
   481 	else if ( aMediaAttStr==KMediaAttLockedStr )
   482 		{
   483 		aMediaAtt=KMediaAttLocked;
   484 		}
   485 	else
   486 		{
   487 		TInt	location = aMediaAttStr.Match(_L("*|*"));
   488 		if( location!=KErrNotFound )
   489 			{
   490 			//Converting Left part of the data
   491 			TPtrC	tempStr = aMediaAttStr.Left(location);
   492 			ret=ConvertToMediaAtts(tempStr, aMediaAtt);
   493 
   494 			//Converting right data can be with another "|"
   495 			tempStr.Set(aMediaAttStr.Mid(location+1));
   496 
   497 			TUint	mediaAttTmp;
   498 			if ( ConvertToMediaAtts(tempStr, mediaAttTmp) )
   499 				{
   500 				aMediaAtt=aMediaAtt|mediaAttTmp;
   501 				}
   502 			else
   503 				{
   504 				ret=EFalse;
   505 				}
   506 			}
   507 		else
   508 			{
   509 			ret=EFalse;
   510 			}
   511 		}
   512 
   513 	return ret;
   514 	}
   515 
   516 TBool CT_FsData::GetMediaAttsFromConfig(const TDesC& aSection, TUint& aMediaAtt)
   517 	{
   518 	aMediaAtt = 0;
   519 
   520 	TPtrC	mediaAttStr;
   521 	TBool	ret = GET_OPTIONAL_STRING_PARAMETER(KMediaAtt(), aSection, mediaAttStr);
   522 	if (ret)
   523 		{
   524 		if ( !ConvertToMediaAtts(mediaAttStr, aMediaAtt) )
   525 			{
   526 			TInt	intTemp;
   527 	 		ret=GET_MANDATORY_INT_PARAMETER(KMediaAtt(), aSection, intTemp);
   528 			if ( ret )
   529 				{
   530 				aMediaAtt=intTemp;
   531 				}
   532 			}
   533 		}
   534 
   535 	return ret;
   536 	}
   537 
   538 void CT_FsData::DoCmdDriveList(const TDesC& aSection)
   539 	{
   540 	INFO_PRINTF1(_L("Calls RFs::DriveList()."));
   541 
   542 	//Get the list of drives which presents in system. There should be 26 slots where each non-zero slot means a drive in system.
   543 	TDriveList driveList;
   544 	TInt errorCode = iFs->DriveList(driveList);
   545 
   546 	//Check error code.
   547 	if (errorCode != KErrNone)
   548 		{
   549 		ERR_PRINTF2(_L("Function DriveList() failed with %d error code."), errorCode);
   550 		SetError(errorCode);
   551 		}
   552 	else
   553 		{
   554 		//Get data from config
   555 		//Get first drive index from config.
   556 		TInt arraySize = 0;
   557 		TLex lexer;
   558 		if (GET_MANDATORY_INT_PARAMETER(KArraySize(), aSection, arraySize))
   559 			{
   560 
   561 			TInt arrayIndex = 0;
   562 			for(TInt i = 0; i < arraySize; i++)
   563 				{
   564 				TBuf<KBufferStringLength>tmpBuff;
   565 
   566 				tmpBuff.Append(KArrayIndex);
   567 				tmpBuff.AppendNum(i+1);
   568 				if (GET_MANDATORY_INT_PARAMETER( tmpBuff, aSection, arrayIndex))
   569 					{
   570 
   571 					//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.
   572 					if (driveList[arrayIndex] == 0)
   573 						{
   574 						ERR_PRINTF2(_L(" Disk no. %d not present."), arrayIndex);
   575 						SetBlockResult(EFail);
   576 						}
   577 					}
   578 				}
   579 
   580 			}
   581 		}
   582 	}
   583 
   584 
   585 void CT_FsData::DoCmdDriveL(const TDesC& aSection)
   586 	{
   587 	INFO_PRINTF1(_L("Calls RFs::Drive()."));
   588 
   589 	//Get drive index from config.
   590 	TDriveNumber	driveIndex;
   591 	TBool			nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
   592 
   593 	//Get info about drive.
   594 	TDriveInfo		driveInfo;
   595 	TInt			errorCode;
   596 	if(nonDefault)
   597 		{
   598 		errorCode = iFs->Drive(driveInfo, driveIndex);
   599 		}
   600 	else
   601 		{
   602 		errorCode = iFs->Drive(driveInfo);
   603 		}
   604 		
   605 	if(errorCode == KErrNone)
   606 		{
   607 		if ( !VerifyTDriveInfoDataFromIniL(aSection, driveInfo))
   608 			{
   609 			SetBlockResult(EFail);
   610 			}
   611 		}
   612 	else
   613 		{
   614 		ERR_PRINTF2(_L("Function Drive() failed with %d error code"), errorCode);
   615 		SetError(errorCode);
   616 		}	
   617 	}
   618 	
   619 TBool CT_FsData::VerifyTDriveInfoDataFromIniL(const TDesC& aSection, TDriveInfo& aDriveInfo)
   620 	{
   621 	TBool ret = ETrue;
   622 	
   623 	INFO_PRINTF2(_L("TDriveInfo.iType    =%d"), aDriveInfo.iType);
   624 	INFO_PRINTF2(_L("TDriveInfo.iBattery =%d"), aDriveInfo.iBattery);
   625 	INFO_PRINTF2(_L("TDriveInfo.iDriveAtt=0x%X"), aDriveInfo.iDriveAtt);
   626 	TUint	driveAttMask[]=
   627 		{
   628 		KDriveAttLocal,
   629 		KDriveAttRom,
   630 		KDriveAttRedirected,
   631 		KDriveAttSubsted,
   632 		KDriveAttInternal,
   633 		KDriveAttRemovable,
   634 		};
   635 	TPtrC	driveAttText[]=
   636 		{
   637 		KDriveAttLocalStr(),
   638 		KDriveAttRomStr(),
   639 		KDriveAttRedirectedStr(),
   640 		KDriveAttSubstedStr(),
   641 		KDriveAttInternalStr(),
   642 		KDriveAttRemovableStr(),
   643 		};
   644 	TInt	size = sizeof(driveAttMask) / sizeof(driveAttMask[0]);
   645 	TInt	index;
   646 	for ( index=0; index<size; ++index )
   647 		{
   648 		if ( aDriveInfo.iDriveAtt&driveAttMask[index] )
   649 			{
   650 			INFO_PRINTF2(_L("DriveAtt %S ON"), &driveAttText[index]);
   651 			}
   652 		}
   653 	INFO_PRINTF2(_L("TDriveInfo.iMediaAtt=0x%X"), aDriveInfo.iMediaAtt);
   654 	TUint	mediaAttMask[]=
   655 		{
   656 		KMediaAttVariableSize,
   657 		KMediaAttDualDensity,
   658 		KMediaAttFormattable,
   659 		KMediaAttWriteProtected,
   660 		KMediaAttLockable,
   661 		KMediaAttLocked,
   662 		};
   663 	TPtrC	mediaAttText[]=
   664 		{
   665 		KMediaAttVariableSizeStr(),
   666 		KMediaAttDualDensityStr(),
   667 		KMediaAttFormattableStr(),
   668 		KMediaAttWriteProtectedStr(),
   669 		KMediaAttLockableStr(),
   670 		KMediaAttLockedStr(),
   671 		};
   672 
   673 	size = sizeof(mediaAttMask) / sizeof(mediaAttMask[0]);
   674 	for ( index=0; index<size; ++index )
   675 		{
   676 		if ( aDriveInfo.iMediaAtt&mediaAttMask[index] )
   677 			{
   678 			INFO_PRINTF2(_L("MediaAtt %S ON"), &mediaAttText[index]);
   679 			}
   680 		}
   681 
   682 	//Get drive type from config.
   683 	TMediaType	mediaType;
   684 	if (GetMediaTypeFromConfig(aSection, mediaType))
   685 		{
   686 		//Checking that type of drive is equal to passed through config file.
   687 		if (aDriveInfo.iType != mediaType)
   688 			{
   689 			ERR_PRINTF3(_L("Drive has wrong type. actual: %d, expected: %d"), aDriveInfo.iType, mediaType);
   690 			ret = EFalse;
   691 			}
   692 		}
   693 	
   694 	//Optional battery state checking
   695 	TBatteryState	batteryState;
   696 	if (GetBatteryStateFromConfig(aSection, batteryState))
   697 		{
   698 		//Checking that type of drive is equal to passed through config file.
   699 		if (aDriveInfo.iBattery != batteryState)
   700 			{
   701 			ERR_PRINTF3(_L("BatteryState is wrong. actual: %d, expected: %d"), aDriveInfo.iBattery, batteryState);
   702 			ret = EFalse;
   703 			}
   704 		}
   705 	
   706 	//Optional media attributes checking
   707 	TUint	mediaAtts;
   708 	if (GetMediaAttsFromConfig(aSection, mediaAtts))
   709 		{
   710 		//Checking that type of drive is equal to passed through config file.
   711 		if ( (aDriveInfo.iMediaAtt&mediaAtts)==mediaAtts )
   712 			{
   713 			ERR_PRINTF1(_L("Media attributes are wrong"));
   714 			ret = EFalse;
   715 			}
   716 		}
   717 
   718 	//Optional drive attributes checking.
   719 	TUint	driveAtts;
   720 	if (GetDriveAttsFromConfig(aSection, driveAtts))
   721 		{
   722 		//Checking that type of drive is equal to passed through config file.
   723 		if ( (aDriveInfo.iDriveAtt!=driveAtts)==driveAtts )
   724 			{
   725 			ERR_PRINTF1(_L("Drive attributes are wrong"));
   726 			ret = EFalse;
   727 			}
   728 		}
   729 	
   730 	return ret;
   731 	}
   732 
   733 void CT_FsData::DoCmdVolumeL(const TDesC& aSection)
   734 	{
   735 	INFO_PRINTF1(_L("Calls RFs:: Volume()."));
   736 
   737 	//Get drive index from config.
   738 	TDriveNumber driveIndex;
   739 
   740 	TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
   741 
   742 	//Get info about volume.
   743 	TInt	errorCode;
   744 
   745 	if(nonDefault)
   746 		{
   747 		errorCode = iFs->Volume(iVolumeInfo, driveIndex);
   748 		}
   749 	else
   750 		{
   751 		errorCode = iFs->Volume(iVolumeInfo);
   752 		}
   753 	//Check error code.
   754 	if (errorCode != KErrNone)
   755 		{
   756 		ERR_PRINTF2(_L("Function Volume() failed with %d error code"), errorCode);
   757 		SetError(errorCode);
   758 		}
   759 	else
   760 		{
   761 		if ( !FileserverUtil::VerifyTVolumeInfoDataFromIniL(*this, aSection, iVolumeInfo))
   762 			{
   763 			SetBlockResult(EFail);
   764 			}
   765 		
   766 		if ( !VerifyTDriveInfoDataFromIniL(aSection, iVolumeInfo.iDrive))
   767 			{
   768 			SetBlockResult(EFail);
   769 			}	
   770 		
   771 			
   772 		TBool	save;
   773 		if(GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save))
   774 			{
   775 			if(save)
   776 				{
   777 				iVolumeLabel.Copy(iVolumeInfo.iName);
   778 				}
   779 			}
   780 	
   781 		TPtrC		volumeObjectName;
   782 		if (GET_OPTIONAL_STRING_PARAMETER(KVolumeObject, aSection, volumeObjectName))
   783 			{
   784 			CT_VolumeInfoData* volumeWrapperObject = NULL;
   785 			volumeWrapperObject = static_cast<CT_VolumeInfoData*>(GetDataWrapperL(volumeObjectName));
   786 			if(volumeWrapperObject)
   787 				{
   788 				TVolumeInfo* volumeObject = new(ELeave) TVolumeInfo();
   789 				*volumeObject = iVolumeInfo;
   790 				volumeWrapperObject->SetObjectL(volumeObject);
   791 				}
   792 			}
   793 		}
   794 
   795 	}
   796 
   797 
   798 void CT_FsData::DoCmdSetVolumeLabel(const TDesC& aSection)
   799 	{
   800 	INFO_PRINTF1(_L("Calls RFs:: SetVolumeLabel()."));
   801 
   802 	//Get drive index from config.
   803 	TDriveNumber	driveIndex;
   804 	TBool			nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
   805 
   806 	//Get volume name from config.
   807 	TPtrC	volumeLabel;
   808 	if (!GET_OPTIONAL_STRING_PARAMETER(KVolumeLabel(), aSection, volumeLabel))
   809 		{
   810 		volumeLabel.Set(iVolumeLabel);
   811 		}
   812 
   813 	//Trying to set the volume label. By some reason it always retturn KErrNotSupported.
   814 	TInt	errorCode;
   815 	if(nonDefault)
   816 		{
   817 		errorCode = iFs->SetVolumeLabel(volumeLabel, driveIndex);
   818 		}
   819 	else
   820 		{
   821 		errorCode = iFs->SetVolumeLabel(volumeLabel);
   822 		}
   823 
   824 	//Check error code.
   825 	if (errorCode != KErrNone)
   826 		{
   827 		ERR_PRINTF2(_L("Function SetVolumeLabel() failed with %d error code"), errorCode);
   828 		SetError(errorCode);
   829 		}
   830 	}
   831 
   832 
   833 void CT_FsData::DoCmdSubst(const TDesC& aSection)
   834 	{
   835 	INFO_PRINTF1(_L("Calls RFs:: Subst()."));
   836 
   837 	//Get drive index from config.
   838 	TDriveNumber driveIndex;
   839 
   840 
   841 	TBool	nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
   842 
   843 
   844 	TBuf16<KBufferStringLength> substPath;
   845 
   846 	//Get the path to substed drive.
   847 
   848 	TInt errorCode;
   849 	if(nonDefault)
   850 		{
   851 		errorCode = iFs->Subst(substPath, driveIndex);
   852 		}
   853 	else
   854 		{
   855 		errorCode = iFs->Subst(substPath);
   856 		}
   857 
   858 	//Check error code.
   859 	if (errorCode != KErrNone)
   860 		{
   861 		ERR_PRINTF2(_L("Function Subst() failed with %d error code"), errorCode);
   862 		SetError(errorCode);
   863 		}
   864 	else
   865 		{
   866 		//Get drive index from config.
   867 		TPtrC substPathFromConf;
   868 		if (GET_MANDATORY_STRING_PARAMETER(KSubstPath(), aSection, substPathFromConf))
   869 			{
   870 
   871 			//As long as it has to be in similar format we must convert substPathFromConf to TBuf16<255>
   872 
   873 			//Comparing paths.
   874 			if (substPathFromConf.CompareF(substPath) != 0)
   875 				{
   876 				ERR_PRINTF2(_L("Subst path is wrong %S"), &substPathFromConf);
   877 				SetBlockResult(EFail);
   878 				}
   879 			}
   880 		}
   881 
   882 
   883 	}
   884 
   885 
   886 void CT_FsData::DoCmdSetSubst(const TDesC& aSection)
   887 	{
   888 	INFO_PRINTF1(_L("Calls RFs:: SetSubst()."));
   889 
   890 
   891 	//Get drive index from config.
   892 	TDriveNumber driveIndex;
   893 	TBool nonDefault = GetDriveNumberFromConfig(aSection, KDrive(), driveIndex);
   894 
   895 
   896 	//Get drive index from config.
   897 	TPtrC substPath;
   898 	if (GET_MANDATORY_STRING_PARAMETER(KSubstPath(), aSection, substPath))
   899 		{
   900 
   901 	//Substing the drive with index driveIndex to path substPath.
   902 		TInt errorCode;
   903 		if(nonDefault)
   904 			{
   905 			errorCode = iFs->SetSubst(substPath, driveIndex);
   906 			}
   907 		else
   908 			{
   909 			errorCode = iFs->SetSubst(substPath);
   910 			}
   911 
   912 		//Check error code.
   913 		if (errorCode != KErrNone)
   914 			{
   915 			ERR_PRINTF2(_L("Function SetSubst() failed with %d error code"), errorCode);
   916 			SetError(errorCode);
   917 			}
   918 
   919 		}
   920 
   921 
   922 
   923 	}
   924 
   925 
   926 void CT_FsData::DoCmdGetMediaSerialNumber(const TDesC& aSection)
   927 	{
   928 	INFO_PRINTF1(_L("Calls RFs::GetMediaSerialNumber()."));
   929 
   930 	//Get drive index from config.
   931 	TDriveNumber driveIndex;
   932 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
   933 		{
   934 		//Get the media serial number.
   935 		TMediaSerialNumber	mediaSerialNumber;
   936 		TInt				errorCode = iFs->GetMediaSerialNumber(mediaSerialNumber, driveIndex);
   937 
   938 		//Check error code.
   939 		if (errorCode != KErrNone)
   940 			{
   941 			ERR_PRINTF2(_L("Function GetMediaSerialNumber() failed with %d error code"), errorCode);
   942 			SetError(errorCode);
   943 			}
   944 		}
   945 	else
   946 		{
   947 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
   948 		SetBlockResult(EFail);
   949 		}
   950 
   951 	}
   952 
   953 
   954 void CT_FsData::DoCmdIsValidDrive(const TDesC& aSection)
   955 	{
   956 	INFO_PRINTF1(_L("Calls RFs::IsValidDirve()."));
   957 
   958 	//Get drive index from config.
   959 	TDriveNumber driveIndex;
   960 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
   961 		{
   962 		TBool	actualValid = RFs::IsValidDrive(driveIndex);
   963 		INFO_PRINTF2(_L("iFs->IsValidDrive = %d"), actualValid);
   964 
   965 		//Get drive validity flag rom config.
   966 		TBool	expectedValid;
   967 		if ( GET_OPTIONAL_BOOL_PARAMETER(KDriveIsValid(), aSection, expectedValid) )
   968 			{
   969 			if ( actualValid!=expectedValid )
   970 				{
   971 				ERR_PRINTF1(_L("Function IsValid() returned unexpected result"));
   972 				SetBlockResult(EFail);
   973 				}
   974 			}
   975 		}
   976 	else
   977 		{
   978 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
   979 		SetBlockResult(EFail);
   980 		}
   981 	}
   982 
   983 
   984 void CT_FsData::DoCmdCharToDrive(const TDesC& aSection)
   985 	{
   986 	INFO_PRINTF1(_L("Calls RFs:: CharToDrive()."));
   987 
   988 	//Get drive index from config.
   989 	//We meed integer there, because function uses TInt, not TDriveNumber.
   990 
   991 	TDriveNumber driveIndex;
   992 
   993 
   994 	//Get drive char from config.
   995 	TPtrC driveCharTmp;
   996 	if (GET_MANDATORY_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
   997 		{
   998 
   999 		TChar driveChar = driveCharTmp.Ptr()[0];
  1000 		TInt driveIndex2;
  1001 		TInt errorCode = RFs::CharToDrive(driveChar, driveIndex2);
  1002 
  1003 		//Check error code.
  1004 		if (errorCode != KErrNone)
  1005 			{
  1006 			ERR_PRINTF2(_L("Function CharToDrive() failed with %d error code"), errorCode);
  1007 			SetError(errorCode);
  1008 			}
  1009 		else
  1010 			{
  1011 			//Get drive index from config
  1012 			if (GetDriveNumberFromConfig(aSection, KDriveIndex(), driveIndex))
  1013 				{
  1014 				if (driveIndex != driveIndex2)
  1015 					{
  1016 					ERR_PRINTF1(_L("Wrong conversion from char to index"));
  1017 					SetBlockResult(EFail);
  1018 					}
  1019 				}
  1020 			}
  1021 		}
  1022 	else
  1023 		{
  1024 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
  1025 		SetBlockResult(EFail);
  1026 		}
  1027 	}
  1028 
  1029 
  1030 void CT_FsData::DoCmdDriveToChar(const TDesC& aSection)
  1031 	{
  1032 	INFO_PRINTF1(_L("Calls RFs:: DriveToChar()."));
  1033 
  1034 	TPtrC driveCharTmp;
  1035 
  1036 	//Get drive path from config.
  1037 	TDriveNumber	driveIndex;
  1038 	if (GetDriveNumberFromConfig(aSection, KDriveIndex(), driveIndex))
  1039 		{
  1040 
  1041 		TChar	driveChar2;
  1042 		TInt	errorCode = RFs::DriveToChar(driveIndex, driveChar2);
  1043 		//Check error code.
  1044 
  1045 		if (errorCode != KErrNone)
  1046 			{
  1047 			ERR_PRINTF2(_L("Function DriveToChar() failed with %d error code"), errorCode);
  1048 			SetError(errorCode);
  1049 			}
  1050 		else
  1051 			{
  1052 			INFO_PRINTF3(_L("DriveToChar(%d) = %c"), driveIndex, TUint(driveChar2));
  1053 
  1054 			//Get drive char from config.
  1055 			if (GET_OPTIONAL_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
  1056 				{
  1057 
  1058 				TChar driveChar= driveCharTmp.Ptr()[0];
  1059 				if (driveChar != driveChar2)
  1060 					{
  1061 					ERR_PRINTF1(_L("Wrong conversion from char to index"));
  1062 					SetBlockResult(EFail);
  1063 					}
  1064 				}
  1065 			}
  1066 		}
  1067 	else
  1068 		{
  1069 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
  1070 		SetBlockResult(EFail);
  1071 		}
  1072 	}
  1073 
  1074 
  1075 void CT_FsData::DoCmdCheckDisk(const TDesC& aSection)
  1076 	{
  1077 	INFO_PRINTF1(_L("Calls RFs:: CheckDisk()."));
  1078 
  1079 	//Get drive path from config.
  1080 	TPtrC drivePath;
  1081 	if (GET_MANDATORY_STRING_PARAMETER(KDrivePath(), aSection, drivePath))
  1082 		{
  1083 
  1084 		TInt errorCode = iFs->CheckDisk(drivePath);
  1085 
  1086 		//Check error code.
  1087 		if (errorCode != KErrNone)
  1088 			{
  1089 			ERR_PRINTF2(_L("Function CheckDisk() failed with %d error code"), errorCode);
  1090 			SetError(errorCode);
  1091 			}
  1092 
  1093 		}
  1094 
  1095 	}
  1096 
  1097 void CT_FsData::DoCmdScanDrive(const TDesC& aSection)
  1098 	{
  1099 	INFO_PRINTF1(_L("Calls RFs:: ScanDisk()."));
  1100 
  1101 	//Get drive path from config.
  1102 	TPtrC drivePath;
  1103 	if (GET_MANDATORY_STRING_PARAMETER(KDrivePath(), aSection, drivePath))
  1104 		{
  1105 
  1106 		TInt errorCode = iFs->ScanDrive(drivePath);
  1107 
  1108 		//Check error code.
  1109 		if (errorCode != KErrNone)
  1110 			{
  1111 			ERR_PRINTF2(_L("Function ScanDrive() failed with %d error code"), errorCode);
  1112 			SetError(errorCode);
  1113 			}
  1114 
  1115 		}
  1116 
  1117 	}
  1118 
  1119 
  1120 void CT_FsData::DoCmdGetDriveName(const TDesC& aSection)
  1121 	{
  1122 	INFO_PRINTF1(_L("Calls RFs::Calls GetDriveName()"));
  1123 
  1124 	//Get drive index from config.
  1125 	TDriveNumber	driveIndex;
  1126 
  1127 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
  1128 		{
  1129 		TBuf<KBufferStringLength>	driveName;
  1130 		TInt		errorCode = iFs->GetDriveName(driveIndex, driveName);
  1131 
  1132 		//Check error code.
  1133 		if (errorCode != KErrNone)
  1134 			{
  1135 			ERR_PRINTF2(_L("Function SetDriveLabel() failed with %d error code"), errorCode);
  1136 			SetError(errorCode);
  1137 			}
  1138 		else
  1139 			{
  1140 			//Get drive name from config.
  1141 			TPtrC driveNameFromConf;
  1142 			if(GET_OPTIONAL_STRING_PARAMETER(KDriveName(), aSection, driveNameFromConf))
  1143 				{
  1144 				TPtrC driveNamePtr = driveName;
  1145 				if (driveNamePtr != driveNameFromConf)
  1146 					{
  1147 					ERR_PRINTF3(_L("Names mismatch: %S != %S"), &driveNamePtr, &driveNameFromConf);
  1148 					SetBlockResult(EFail);
  1149 					}
  1150 				}
  1151 
  1152 			TBool save;
  1153 
  1154 			if(GET_OPTIONAL_BOOL_PARAMETER(KSaveInInstance(), aSection, save))
  1155 				{
  1156 				if(save)
  1157 					{
  1158 					iDriveName.Copy(iDriveName);
  1159 					}
  1160 				}
  1161 			}
  1162 		}
  1163 	else
  1164 		{
  1165 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
  1166 		SetBlockResult(EFail);
  1167 		}
  1168 	}
  1169 
  1170 
  1171 void CT_FsData::DoCmdSetDriveName(const TDesC& aSection)
  1172 	{
  1173 	INFO_PRINTF1(_L("Calls RFs::SetDriveName()."));
  1174 
  1175 	//Get drive index from config.
  1176 	TDriveNumber	driveIndex;
  1177 	if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
  1178 		{
  1179 		//Get drive name from config.
  1180 		TPtrC	driveName;
  1181 		if ( !GET_OPTIONAL_STRING_PARAMETER(KDriveName(), aSection, driveName) )
  1182 			{
  1183 			driveName.Set(iDriveName);
  1184 			}
  1185 
  1186 		//Check error code.
  1187 		TInt	errorCode = iFs->SetDriveName(driveIndex, driveName);
  1188 		if (errorCode != KErrNone)
  1189 			{
  1190 			ERR_PRINTF2(_L("Function SetDriveLabel() failed with %d error code"), errorCode);
  1191 			SetError(errorCode);
  1192 			}
  1193 		}
  1194 	else
  1195 		{
  1196 		ERR_PRINTF2(_L("Not found %S parameter"), KDriveIndex);
  1197 		SetBlockResult(EFail);
  1198 		}
  1199 	}
  1200 
  1201 //
  1202 void CT_FsData::DoCmdLockDrive(const TDesC& aSection)
  1203 	{
  1204 	INFO_PRINTF1(_L("Calls RFs::LockDrive()."));
  1205 
  1206 	//Get old password from config.
  1207 	TPtrC	drivePassword;
  1208 	if ( GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, drivePassword) )
  1209 		{
  1210 		//Get drive index from config.
  1211 		TDriveNumber	driveIndex;
  1212 		if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
  1213 			{
  1214 			//Get new password from config.
  1215 			TPtrC	driveNewPassword;
  1216 			if ( GET_MANDATORY_STRING_PARAMETER(KDriveNewPassword(), aSection, driveNewPassword) )
  1217 				{
  1218 				// get boolean value from config
  1219 				TBool	store;
  1220 				if (GET_MANDATORY_BOOL_PARAMETER(KStore(), aSection, store))
  1221 					{
  1222 					TMediaPassword	password;
  1223 					password.Copy(driveNewPassword);
  1224 					iPassword.Copy(drivePassword);
  1225 
  1226 					TInt errorCode = iFs->LockDrive(driveIndex, iPassword, password, store);
  1227 
  1228 					//Check error code.
  1229 					if (errorCode == KErrNone)
  1230 						{
  1231 						iPassword=password;
  1232 						}
  1233 					else
  1234 						{
  1235 						ERR_PRINTF2(_L("Function LockDrive() failed with %d error code"), errorCode);
  1236 						SetError(errorCode);
  1237 						}
  1238 					}
  1239 				}
  1240 			}
  1241 		}
  1242 	}
  1243 
  1244 
  1245 void CT_FsData::DoCmdUnlockDrive(const TDesC& aSection)
  1246 	{
  1247 	INFO_PRINTF1(_L("Calls RFs::UnlockDrive()."));
  1248 
  1249 	//Get old password from config.
  1250 	TPtrC	drivePassword;
  1251 	if ( GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, drivePassword) )
  1252 		{
  1253 		//Get drive index from config.
  1254 		TDriveNumber	driveIndex;
  1255 		if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
  1256 			{
  1257 			// get boolean value from config
  1258 			TBool	store;
  1259 			if (GET_MANDATORY_BOOL_PARAMETER(KStore(), aSection, store))
  1260 				{
  1261 				TMediaPassword	password;
  1262 				//Converting string to appropriative password format(TMediaPassword is typedef for TBuf<16>)
  1263 				password.Copy(drivePassword);
  1264 
  1265 				TInt	errorCode = iFs->UnlockDrive(driveIndex, password, store);
  1266 
  1267 				//Check error code.
  1268 				if (errorCode == KErrNone)
  1269 					{
  1270 					iPassword=password;
  1271 					}
  1272 				else
  1273 					{
  1274 					ERR_PRINTF2(_L("Function UnlockDrive() failed with %d error code"), errorCode);
  1275 					SetError(errorCode);
  1276 					}
  1277 				}
  1278 			}
  1279 		else
  1280 			{
  1281 			ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
  1282 			SetBlockResult(EFail);
  1283 			}
  1284 		}
  1285 	}
  1286 
  1287 
  1288 void CT_FsData::DoCmdClearPassword(const TDesC& aSection)
  1289 	{
  1290 	INFO_PRINTF1(_L("Calls RFs::ClearPassword()."));
  1291 
  1292 	//Get old password from config.
  1293 	TPtrC	driveOldPasswordTmp;
  1294 	if (GET_MANDATORY_STRING_PARAMETER(KDriveOldPassword(), aSection, driveOldPasswordTmp))
  1295 		{
  1296 		//Get drive index from config.
  1297 		TDriveNumber	driveIndex;
  1298 		if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
  1299 			{
  1300 			//Converting string to appropriative password format(TMediaPassword is typedef for TBuf<16>)
  1301 			TMediaPassword	driveOldPassword;
  1302 			driveOldPassword.Copy(driveOldPasswordTmp);
  1303 
  1304 			TInt	errorCode = iFs->ClearPassword(driveIndex, driveOldPassword);
  1305 			if (errorCode != KErrNone)
  1306 				{
  1307 				ERR_PRINTF2(_L("Function ClearPassword() failed with %d error code"), errorCode);
  1308 				SetError(errorCode);
  1309 				}
  1310 			}
  1311 		else
  1312 			{
  1313 			ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
  1314 			SetBlockResult(EFail);
  1315 			}
  1316 		}
  1317 	}
  1318 
  1319 
  1320 void CT_FsData::DoCmdErasePassword(const TDesC& aSection)
  1321 	{
  1322 	INFO_PRINTF1(_L("Calls RFs::ErasePassword()."));
  1323 
  1324 	//Get drive from config.
  1325 	TDriveNumber	driveIndex;
  1326 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
  1327 		{
  1328 		TInt	errorCode = iFs->ErasePassword(driveIndex);
  1329 
  1330 		//Check error code.
  1331 		if (errorCode != KErrNone)
  1332 			{
  1333 			ERR_PRINTF2(_L("Function ErasePassword() failed with %d error code"), errorCode);
  1334 			SetError(errorCode);
  1335 			}
  1336 		}
  1337 	else
  1338 		{
  1339 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
  1340 		SetBlockResult(EFail);
  1341 		}
  1342 	}
  1343 
  1344 
  1345 void CT_FsData::DoCmdReserveDriveSpace(const TDesC& aSection)
  1346 	{
  1347 	INFO_PRINTF1(_L("Calls RFs::ReserveDriveSpace()."));
  1348 
  1349 	//Get amount of bytes to be reserved from config.
  1350 	TInt	bytesToReserve;
  1351 	if (GET_MANDATORY_INT_PARAMETER(KBytesToReserve(), aSection, bytesToReserve))
  1352 		{
  1353 		TDriveNumber	driveIndex;
  1354 
  1355 		if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
  1356 			{
  1357 			TInt	errorCode = iFs->ReserveDriveSpace(driveIndex, bytesToReserve);
  1358 
  1359 			//Check error code.
  1360 			if (errorCode != KErrNone)
  1361 				{
  1362 				ERR_PRINTF2(_L("Function ReserveDriveSpace() failed with %d error code"), errorCode);
  1363 				SetError(errorCode);
  1364 				}
  1365 			}
  1366 		else
  1367 			{
  1368 			ERR_PRINTF2(_L("Not found %S parameter"),KDrive);
  1369 			SetBlockResult(EFail);
  1370 			}
  1371 		}
  1372 	}
  1373 
  1374 
  1375 void CT_FsData::DoCmdGetReserveAccess(const TDesC& aSection)
  1376 	{
  1377 	INFO_PRINTF1(_L("Calls RFs::GetReserveAccess()."));
  1378 
  1379 	//Get drive index from config.
  1380 	TDriveNumber	driveIndex;
  1381 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
  1382 		{
  1383 		TInt	errorCode = iFs->GetReserveAccess(driveIndex);
  1384 
  1385 		//Check error code.
  1386 		if (errorCode != KErrNone)
  1387 			{
  1388 			ERR_PRINTF2(_L("Function GetReserveAccess() failed with %d error code"), errorCode);
  1389 			SetError(errorCode);
  1390 			}
  1391 		}
  1392 	else
  1393 		{
  1394 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
  1395 		SetBlockResult(EFail);
  1396 		}
  1397 	}
  1398 
  1399 
  1400 void CT_FsData::DoCmdReleaseReserveAccess(const TDesC& aSection)
  1401 	{
  1402 	INFO_PRINTF1(_L("Calls RFs::ReleaseReserveAccess()."));
  1403 
  1404 	//Get drive index from config.
  1405 	TDriveNumber	driveIndex;
  1406 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveIndex))
  1407 		{
  1408 		TInt	errorCode = iFs->ReleaseReserveAccess(driveIndex);
  1409 
  1410 		//Check error code.
  1411 		if (errorCode != KErrNone)
  1412 			{
  1413 			ERR_PRINTF2(_L("Function ReleaseReserveAccess() failed with %d error code"), errorCode);
  1414 			SetError(errorCode);
  1415 			}
  1416 		}
  1417 	else
  1418 		{
  1419 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
  1420 		SetBlockResult(EFail);
  1421 		}
  1422 	}
  1423 
  1424 void CT_FsData::DoCmdGetSystemDrive(const TDesC& aSection)
  1425 	{
  1426 	INFO_PRINTF1(_L("Calls RFs::GetSystemDrive()."));
  1427 
  1428 	TDriveNumber	driveNumber = RFs::GetSystemDrive();
  1429 	INFO_PRINTF2(_L("System Drive = %d"), driveNumber);
  1430 
  1431 	//Get drive index from config.
  1432 	TDriveNumber	driveIndex;
  1433 	if ( GetDriveNumberFromConfig(aSection, KDrive(), driveIndex) )
  1434 		{
  1435 		//Check error code.
  1436 		if (driveNumber != driveIndex)
  1437 			{
  1438 			ERR_PRINTF1(_L("GetSystemDrive() returned unexpected drive"));
  1439 			SetBlockResult(EFail);
  1440 			}
  1441 		}
  1442 	else
  1443 		{
  1444 		ERR_PRINTF2(_L("Not found %S parameter"), &KDrive());
  1445 		SetBlockResult(EFail);
  1446 		}
  1447 	}
  1448 
  1449 void CT_FsData::DoCmdSetSystemDrive(const TDesC& aSection)
  1450 	{
  1451 	INFO_PRINTF1(_L("Calls RFs::SetSystemDrive()"));
  1452 
  1453 	// get drive number from parameters
  1454 	TDriveNumber	driveNumber = EDriveA;
  1455 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
  1456 		{
  1457 		TInt	err = iFs->SetSystemDrive(driveNumber);
  1458 		// check error code
  1459 		if (err != KErrNone)
  1460 			{
  1461 			ERR_PRINTF2(_L("SetSystemDrive() error: %d"), err);
  1462 			SetError(err);
  1463 			}
  1464 		}
  1465 	else
  1466 		{
  1467 		ERR_PRINTF2(_L("No %S"), &KDrive());
  1468 		SetBlockResult(EFail);
  1469 		}
  1470 
  1471 	}
  1472 
  1473 void CT_FsData::DoCmdGetSystemDriveChar(const TDesC& aSection)
  1474 	{
  1475 	INFO_PRINTF1(_L("Calls RFs::GetSystemDriveChar()"));
  1476 
  1477 	TChar	drvChar = RFs::GetSystemDriveChar();
  1478 	INFO_PRINTF2(_L("GetSystemDriveChar() = %c"), TUint(drvChar));
  1479 	//Get drive char from config.
  1480 	TPtrC	driveCharTmp;
  1481 	if (GET_OPTIONAL_STRING_PARAMETER(KDriveChar(), aSection, driveCharTmp))
  1482 		{
  1483 		TChar	driveCharExpect = driveCharTmp.Ptr()[0];
  1484 		driveCharExpect.UpperCase();
  1485 		drvChar.UpperCase();
  1486 		if ( drvChar != driveCharExpect)
  1487 			{
  1488 			ERR_PRINTF1(_L("Drive char != expected drive char"));
  1489 			SetBlockResult(EFail);
  1490 			}
  1491 		}
  1492 	}
  1493 
  1494 void CT_FsData::DoCmdVolumeIOParam(const TDesC& aSection)
  1495 	{
  1496 	INFO_PRINTF1(_L("Calls RFs::VolumeIOParam()"));
  1497 
  1498 	// get drive number from parameters
  1499 	TDriveNumber	driveNumber = EDriveA;
  1500 	if (GetDriveNumberFromConfig(aSection, KDrive(), driveNumber))
  1501 		{
  1502 		TVolumeIOParamInfo	volumeIOParamInf;
  1503 		TInt				err = iFs->VolumeIOParam(driveNumber, volumeIOParamInf);
  1504 		// check error code
  1505 		if (err != KErrNone)
  1506 			{
  1507 			ERR_PRINTF2(_L("VolumeIOParam()  error: %d"), err);
  1508 			SetError(err);
  1509 			}
  1510 		else
  1511 			{
  1512 			INFO_PRINTF2(_L("VolumeIOParam BlockSize: %d"), volumeIOParamInf.iBlockSize );
  1513 			INFO_PRINTF2(_L("VolumeIOParam ClusterSize: %d"), volumeIOParamInf.iClusterSize );
  1514 			INFO_PRINTF2(_L("VolumeIOParam RecReadBufSize: %d"), volumeIOParamInf.iRecReadBufSize );
  1515 			INFO_PRINTF2(_L("VolumeIOParam RecWriteBufSize: %d"), volumeIOParamInf.iRecWriteBufSize );
  1516 			}
  1517 		}
  1518 	else
  1519 		{
  1520 		ERR_PRINTF2(_L("No %S"), &KDrive());
  1521 		SetBlockResult(EFail);
  1522 		}
  1523 	}
  1524 
  1525