os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_FsData.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_FsData.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,922 @@
     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_SfSrvServer.h"
    1.32 +#include "DataWrapperBase.h"
    1.33 +
    1.34 +/*@{*/
    1.35 +
    1.36 +_LIT(KMessageSlots,							"messageSlots");
    1.37 +_LIT(KPath,									"path");
    1.38 +_LIT(KAddress,								"address");
    1.39 +_LIT(KType,									"type");
    1.40 +_LIT(KAll,									"all");
    1.41 +_LIT(KResources,							"resources");
    1.42 +_LIT(KNotify,								"notify");
    1.43 +_LIT(KInRom,								"inRom");
    1.44 +_LIT(KThreshold,							"threshold");
    1.45 +_LIT(KDrive,								"drive");
    1.46 +_LIT(KFunctionId,							"functionId");
    1.47 +_LIT(KAdd,									"add");
    1.48 +_LIT(KSub,									"sub");
    1.49 +_LIT(KUseFreeSpace,							"use_free_space");
    1.50 +_LIT(KVersionName,							"name");
    1.51 +_LIT(KVersionBuild,							"build");
    1.52 +_LIT(KVersionMajor,							"major");
    1.53 +_LIT(KVersionMinor,							"minor");
    1.54 +_LIT(KIndex,								"index");
    1.55 +_LIT(KParam1,								"param1");
    1.56 +_LIT(KParam2,								"param2");
    1.57 +_LIT(KFile,									"file");
    1.58 +_LIT(KCount,								"count");
    1.59 +
    1.60 +///	Commands
    1.61 +_LIT(KCmdNew,								"new");
    1.62 +_LIT(KCmdClose,								"Close");
    1.63 +_LIT(KCmdDestructor,						"~");
    1.64 +_LIT(KCmdConnect,							"Connect");
    1.65 +_LIT(KCmdVersion,							"Version");
    1.66 +_LIT(KCmdNotifyChange,						"NotifyChange");
    1.67 +_LIT(KCmdNotifyChangeCancel,				"NotifyChangeCancel");
    1.68 +_LIT(KCmdNotifyDiskSpace,					"NotifyDiskSpace");
    1.69 +_LIT(KCmdNotifyDiskSpaceCancel,				"NotifyDiskSpaceCancel");
    1.70 +_LIT(KCmdIsRomAddress,						"IsRomAddress");
    1.71 +_LIT(KCmdResourceCountMarkStart,			"ResourceCountMarkStart");
    1.72 +_LIT(KCmdResourceCountMarkEnd,				"ResourceCountMarkEnd");
    1.73 +_LIT(KCmdResourceCount,						"ResourceCount");
    1.74 +_LIT(KCmdGetNotifyUser,						"GetNotifyUser");
    1.75 +_LIT(KCmdSetNotifyUser,						"SetNotifyUser");
    1.76 +_LIT(KCmdSetNotifyChange,					"SetNotifyChange");
    1.77 +_LIT(KCmdLoaderHeapFunction,				"LoaderHeapFunction");
    1.78 +_LIT(KCmdInitialisePropertiesFile,			"InitialisePropertiesFile");
    1.79 +/*@}*/
    1.80 +
    1.81 +CT_FsData* CT_FsData::NewL()
    1.82 +/**
    1.83 + * Two phase constructor
    1.84 + */
    1.85 +	{
    1.86 +	CT_FsData*	ret = new (ELeave) CT_FsData();
    1.87 +	CleanupStack::PushL(ret);
    1.88 +	ret->ConstructL();
    1.89 +	CleanupStack::Pop(ret);
    1.90 +	return ret;	
    1.91 +	}
    1.92 +
    1.93 +CT_FsData::CT_FsData()
    1.94 +/**
    1.95 + * Protected constructor. First phase construction
    1.96 + */
    1.97 +	{
    1.98 +	}
    1.99 +
   1.100 +void CT_FsData::ConstructL()
   1.101 +/**
   1.102 + * Protected constructor. Second phase construction
   1.103 + */
   1.104 +	{
   1.105 +	
   1.106 +	}
   1.107 +
   1.108 +CT_FsData::~CT_FsData()
   1.109 +/**
   1.110 + * Destructor.
   1.111 + */
   1.112 +	{
   1.113 +	DoCleanup();
   1.114 +
   1.115 +	iNotifyChange.ResetAndDestroy();
   1.116 +	iNotifyDiskSpace.ResetAndDestroy();
   1.117 +	iNotifyDismount.ResetAndDestroy();
   1.118 +	iStartupInitComplete.ResetAndDestroy();
   1.119 +	}
   1.120 +
   1.121 +void CT_FsData::DoCleanup()
   1.122 +/**
   1.123 + * Contains cleanup implementation
   1.124 + */
   1.125 +	{
   1.126 +	//Deleting RFs.
   1.127 +	if(iFs != NULL)
   1.128 +		{
   1.129 +		INFO_PRINTF1(_L("Deleting current RFs"));
   1.130 +		delete iFs;
   1.131 +		iFs = NULL;
   1.132 +		}
   1.133 +	}
   1.134 +
   1.135 +TAny* CT_FsData::GetObject()
   1.136 +/**
   1.137 + * Return a pointer to the object that the data wraps
   1.138 + *
   1.139 + * @return pointer to the object that the data wraps
   1.140 + */
   1.141 +	{
   1.142 +	return iFs;
   1.143 +	}
   1.144 +
   1.145 +TUint64 CT_FsData::ThreadId()
   1.146 +	{
   1.147 +	RThread currentThread;
   1.148 +	return currentThread.Id().Id();
   1.149 +	}
   1.150 +
   1.151 +TBool CT_FsData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
   1.152 +/**
   1.153 + * Process a command read from the ini file
   1.154 + *
   1.155 + * @param aCommand	the command to process
   1.156 + * @param aSection		the entry in the ini file requiring the command to be processed
   1.157 + *
   1.158 + * @return ETrue if the command is processed
   1.159 + */
   1.160 +	{
   1.161 +	TBool retVal = ETrue;
   1.162 +	if (aCommand == KCmdNew)
   1.163 +		{
   1.164 +		DoCmdNewL();
   1.165 +		}
   1.166 +	else if (aCommand == KCmdClose)
   1.167 +		{
   1.168 +		DoCmdClose();
   1.169 +		}
   1.170 +	else if (aCommand == KCmdDestructor)
   1.171 +		{
   1.172 +		DoCmdDestructor();
   1.173 +		}
   1.174 +	else if (aCommand == KCmdConnect)
   1.175 +		{
   1.176 +		DoCmdConnect(aSection);
   1.177 +		}
   1.178 +	else if (aCommand == KCmdVersion)
   1.179 +		{
   1.180 +		DoCmdVersion(aSection);
   1.181 +		}
   1.182 +	else if (aCommand == KCmdNotifyChange)
   1.183 +		{
   1.184 +		DoCmdNotifyChangeL(aSection, aAsyncErrorIndex);
   1.185 +		}
   1.186 +	else if (aCommand == KCmdNotifyChangeCancel)
   1.187 +		{
   1.188 +		DoCmdNotifyChangeCancel(aSection);
   1.189 +		}
   1.190 +	else if (aCommand == KCmdNotifyDiskSpace)
   1.191 +		{
   1.192 +		DoCmdNotifyDiskSpaceL(aSection, aAsyncErrorIndex);
   1.193 +		}
   1.194 +	else if (aCommand == KCmdNotifyDiskSpaceCancel)
   1.195 +		{
   1.196 +		DoCmdNotifyDiskSpaceCancel(aSection);
   1.197 +		}
   1.198 +	else if (aCommand == KCmdIsRomAddress)
   1.199 +		{
   1.200 +		DoCmdIsRomAddress(aSection);
   1.201 +		}
   1.202 +	else if (aCommand == KCmdResourceCountMarkStart)
   1.203 +		{
   1.204 +		DoCmdResourceCountMarkStart();
   1.205 +		}
   1.206 +	else if (aCommand == KCmdResourceCountMarkEnd)
   1.207 +		{
   1.208 +		DoCmdResourceCountMarkEnd();
   1.209 +		}
   1.210 +	else if (aCommand == KCmdResourceCount)
   1.211 +		{
   1.212 +		DoCmdResourceCount(aSection);
   1.213 +		}
   1.214 +	else if (aCommand == KCmdGetNotifyUser)
   1.215 +		{
   1.216 +		DoCmdGetNotifyUser(aSection);
   1.217 +		}
   1.218 +	else if (aCommand == KCmdSetNotifyUser)
   1.219 +		{
   1.220 +		DoCmdSetNotifyUser(aSection);
   1.221 +		}
   1.222 +	else if (aCommand == KCmdLoaderHeapFunction)
   1.223 +		{
   1.224 +		DoCmdLoaderHeapFunctionL(aSection);
   1.225 +		}
   1.226 +	else if (aCommand == KCmdSetNotifyChange)
   1.227 +		{
   1.228 +		DoCmdSetNotifyChange(aSection);
   1.229 +		}
   1.230 +	else if (aCommand == KCmdInitialisePropertiesFile)
   1.231 +		{
   1.232 +		DoCmdInitialisePropertiesFile(aSection);
   1.233 +		}
   1.234 +	else
   1.235 +		{
   1.236 +		if (!DoCommandDrivesL(aCommand, aSection, aAsyncErrorIndex))
   1.237 +			{
   1.238 +			if (!DoCommandMountsL(aCommand, aSection, aAsyncErrorIndex))
   1.239 +				{
   1.240 +				if (!DoCommandFilesL(aCommand, aSection, aAsyncErrorIndex))
   1.241 +					{
   1.242 +					retVal = EFalse;
   1.243 +					}
   1.244 +				}
   1.245 +			}
   1.246 +		}
   1.247 +	return retVal;
   1.248 +	}
   1.249 +
   1.250 +
   1.251 +void CT_FsData::DoCmdNewL()
   1.252 +/** Creates new RFs class instance */
   1.253 +	{
   1.254 +	INFO_PRINTF1(_L("Create new RFs class instance"));
   1.255 +	
   1.256 +	//Deletes previous RFs class instance if it was already created.
   1.257 +	DoCleanup();
   1.258 +
   1.259 +	// do create
   1.260 +	TRAPD(err, iFs = new (ELeave) RFs());
   1.261 +	if ( err!=KErrNone )
   1.262 +		{
   1.263 +		ERR_PRINTF2(_L("new error %d"), err);
   1.264 +		SetError( err );
   1.265 +		}
   1.266 +	}
   1.267 +
   1.268 +void CT_FsData::DoCmdClose()
   1.269 +/** Close RFs handle */
   1.270 +	{
   1.271 +	INFO_PRINTF1(_L("Closing RFs"));
   1.272 +	iFs->Close();
   1.273 +	}
   1.274 +
   1.275 +
   1.276 +void CT_FsData::DoCmdDestructor()
   1.277 +/** Destroy RFs the object */
   1.278 +	{
   1.279 +	INFO_PRINTF1(_L("Destroying the RFs object"));
   1.280 +	DoCleanup();
   1.281 +	}
   1.282 +
   1.283 +void CT_FsData::DoCmdConnect(const TDesC& aSection)
   1.284 +/** Connects a client to the file server */
   1.285 +	{
   1.286 +
   1.287 +	TInt	messageSlots = KFileServerDefaultMessageSlots;
   1.288 +	GetIntFromConfig(aSection, KMessageSlots, messageSlots);
   1.289 +
   1.290 +	TInt err = iFs->Connect(messageSlots);
   1.291 +	INFO_PRINTF2(_L("Call Connect(messageSlots = %d)"), messageSlots);
   1.292 +
   1.293 +	if ( err!=KErrNone )
   1.294 +		{
   1.295 +		ERR_PRINTF2(_L("Connect() error %d"), err);
   1.296 +		SetError( err );
   1.297 +		}
   1.298 +	}
   1.299 +
   1.300 +void CT_FsData::DoCmdVersion(const TDesC& aSection)
   1.301 +/** Gets the client side version number */
   1.302 +	{
   1.303 +	
   1.304 +	TVersion		version=iFs->Version();
   1.305 +	TVersionName	versionName	= version.Name();
   1.306 +	INFO_PRINTF2(_L("Version name  : %S"), &versionName);
   1.307 +	INFO_PRINTF2(_L("Version build : %d"), (TInt)version.iBuild);
   1.308 +	INFO_PRINTF2(_L("Version major : %d"), (TInt)version.iMajor);
   1.309 +	INFO_PRINTF2(_L("Version minor : %d"), (TInt)version.iMinor);
   1.310 +
   1.311 +	TPtrC	name;
   1.312 +	if ( GET_OPTIONAL_STRING_PARAMETER(KVersionName, aSection, name))
   1.313 +		{
   1.314 +		if ( name != version.Name() )
   1.315 +			{
   1.316 +			ERR_PRINTF3(_L("Name does not match expected name: %S, %S"), &name, &versionName);
   1.317 +			SetBlockResult(EFail);
   1.318 +			}
   1.319 +		}
   1.320 +
   1.321 +	TInt	intTemp;
   1.322 +	if ( GET_OPTIONAL_INT_PARAMETER(KVersionBuild, aSection, intTemp) )
   1.323 +		{
   1.324 +		if ( intTemp != version.iBuild )
   1.325 +			{
   1.326 +			ERR_PRINTF1(_L("Build does not match expected build"));
   1.327 +			SetBlockResult(EFail);
   1.328 +			}
   1.329 +		}
   1.330 +
   1.331 +	if ( GET_OPTIONAL_INT_PARAMETER(KVersionMajor, aSection, intTemp) )
   1.332 +		{
   1.333 +		if ( intTemp != version.iMajor )
   1.334 +			{
   1.335 +			ERR_PRINTF1(_L("Major does not match expected major"));
   1.336 +			SetBlockResult(EFail);
   1.337 +			}
   1.338 +		}
   1.339 +
   1.340 +	if ( GET_OPTIONAL_INT_PARAMETER(KVersionMinor, aSection, intTemp) )
   1.341 +		{
   1.342 +		if ( intTemp != version.iMinor )
   1.343 +			{
   1.344 +			ERR_PRINTF1(_L("Minor does not match expected minor"));
   1.345 +			SetBlockResult(EFail);
   1.346 +			}
   1.347 +		}
   1.348 +
   1.349 +	if (version.Name() == _L("") && version.iBuild == 0 && version.iMajor == 0 && version.iMinor == 0)
   1.350 +		{
   1.351 +		ERR_PRINTF1(_L("Some version fields are not set!"));
   1.352 +		SetBlockResult(EFail);
   1.353 +		}
   1.354 +	}
   1.355 +
   1.356 +void CT_FsData::DoCmdNotifyChangeL(const TDesC& aSection, const TInt aAsyncErrorIndex)
   1.357 +/** Requests a notification of change to files or directories */
   1.358 +	{
   1.359 +	TNotifyType	type = ENotifyAll;
   1.360 +	TPtrC		typeTemp;
   1.361 +	TBool		dataOk = ETrue;
   1.362 +
   1.363 +	if ( GET_MANDATORY_STRING_PARAMETER(KType, aSection, typeTemp) )
   1.364 +		{
   1.365 +		if(!ConvertToNotifyType(typeTemp, type))
   1.366 +			{
   1.367 +			TInt	typeNumber;
   1.368 +			if(GetIntFromConfig(aSection, KType(), typeNumber))
   1.369 +				{
   1.370 +				type = (TNotifyType)typeNumber;
   1.371 +				}
   1.372 +			else
   1.373 +				{
   1.374 +				ERR_PRINTF3(_L("NotifyChange() incorrect parameter %S in %S"), &typeTemp, &KType());
   1.375 +				SetBlockResult(EFail);
   1.376 +				dataOk = EFalse;
   1.377 +				}
   1.378 +			}
   1.379 +		}
   1.380 +	else
   1.381 +		{
   1.382 +		dataOk = EFalse;
   1.383 +		}
   1.384 +
   1.385 +	TInt	count=1;
   1.386 +	GET_OPTIONAL_INT_PARAMETER(KCount, aSection, count);
   1.387 +
   1.388 +	if(dataOk)
   1.389 +		{
   1.390 +		CT_ActiveNotifyChange*	active = CT_ActiveNotifyChange::NewLC(count, aAsyncErrorIndex, *this);
   1.391 +		iNotifyChange.AppendL(active);
   1.392 +		CleanupStack::Pop(active);
   1.393 +
   1.394 +		TPtrC	path;
   1.395 +		if ( GetStringFromConfig(aSection, KPath(), path) )
   1.396 +			{
   1.397 +			iFs->NotifyChange(type, active->iStatus, path);
   1.398 +			INFO_PRINTF1(_L("NotifyChange(TNotifyType, TRequestStatus, const TDesC)"));
   1.399 +			}
   1.400 +		else
   1.401 +			{
   1.402 +			iFs->NotifyChange(type, active->iStatus);
   1.403 +			INFO_PRINTF1(_L("NotifyChange(TNotifyType TRequestStatus)"));
   1.404 +			}
   1.405 +			
   1.406 +		active->Activate();
   1.407 +		IncOutstanding();
   1.408 +		}
   1.409 +	}
   1.410 +
   1.411 +
   1.412 +void CT_FsData::DoCmdNotifyChangeCancel(const TDesC& aSection)
   1.413 +/** Cancels outstanding request(s) for notification of change to files or directories */
   1.414 +	{
   1.415 +	TBool	all = ETrue;
   1.416 +
   1.417 +	if ( GET_MANDATORY_BOOL_PARAMETER(KAll, aSection, all) )
   1.418 +		{
   1.419 +		if(all)
   1.420 +			{
   1.421 +			// Cancels all outstanding requests.
   1.422 +			iFs->NotifyChangeCancel();
   1.423 +			INFO_PRINTF1(_L("NotifyChangeCancel()"));
   1.424 +			}
   1.425 +		else
   1.426 +			{
   1.427 +			// Cancels a specific outstanding request
   1.428 +			TInt	index=0;
   1.429 +			GetIntFromConfig(aSection, KIndex(), index);
   1.430 +
   1.431 +			iFs->NotifyChangeCancel(iNotifyChange[index]->iStatus);
   1.432 +			INFO_PRINTF1(_L("NotifyChangeCancel(TRequestStatus)"));
   1.433 +			}
   1.434 +		}
   1.435 +	}
   1.436 +
   1.437 +void CT_FsData::DoCmdNotifyDiskSpaceL(const TDesC& aSection, const TInt aAsyncErrorIndex)
   1.438 +/** Requests notification when the free disk space on the specified drive crosses the specified threshold value */
   1.439 +	{
   1.440 +	//Get drive number from config
   1.441 +	TDriveNumber	drive = EDriveA;
   1.442 +	TBool 			dataOk = ETrue;
   1.443 +	if (!GetDriveNumberFromConfig(aSection, KDrive, drive))
   1.444 +		{
   1.445 +		ERR_PRINTF2(_L("No %S"), &KDrive());
   1.446 +		SetBlockResult(EFail);
   1.447 +		dataOk = EFalse;
   1.448 +		}
   1.449 +
   1.450 +	TBool	useFreeSpace = EFalse;
   1.451 +	GET_OPTIONAL_BOOL_PARAMETER(KUseFreeSpace, aSection, useFreeSpace);
   1.452 +
   1.453 +	TInt64 threshold = 0;
   1.454 +	//Defining treshold by free space
   1.455 +	if(useFreeSpace)
   1.456 +		{
   1.457 +		threshold = iVolumeInfo.iFree;
   1.458 +		//For Calculation free-temp(_sub), free+temp(_add)
   1.459 +		TInt temp;
   1.460 +		if(GetIntFromConfig(aSection, KAdd, temp))
   1.461 +			{
   1.462 +			threshold += temp;
   1.463 +			temp = 0;
   1.464 +			}
   1.465 +		if(GetIntFromConfig(aSection, KSub, temp))
   1.466 +			{
   1.467 +			threshold -= temp;
   1.468 +			temp = 0;
   1.469 +			}
   1.470 +		}
   1.471 +	//Defining treshold by some value
   1.472 +	else
   1.473 +		{
   1.474 +		TPtrC thold;
   1.475 +		if(GET_MANDATORY_STRING_PARAMETER(KThreshold, aSection, thold))
   1.476 +			{
   1.477 +			TLex lex(thold);
   1.478 +			TInt err = lex.Val(threshold);
   1.479 +			if(err)
   1.480 +				{
   1.481 +				ERR_PRINTF1(_L("NotifyDiskSpace() bad treshold value"));
   1.482 +				SetBlockResult(EFail);
   1.483 +				dataOk = EFalse;
   1.484 +				}
   1.485 +			}
   1.486 +		}
   1.487 +
   1.488 +	if(dataOk)
   1.489 +		{
   1.490 +		CActiveCallback*	active = CActiveCallback::NewLC(*this);
   1.491 +		iNotifyDiskSpace.AppendL(active);
   1.492 +		CleanupStack::Pop(active);
   1.493 +
   1.494 +		iFs->NotifyDiskSpace(threshold, drive, active->iStatus);
   1.495 +		INFO_PRINTF1(_L("NotifyDiskSpace()"));
   1.496 +		active->Activate(aAsyncErrorIndex);
   1.497 +		IncOutstanding();
   1.498 +		}
   1.499 +	}
   1.500 +
   1.501 +
   1.502 +void CT_FsData::DoCmdNotifyDiskSpaceCancel(const TDesC& aSection)
   1.503 +/** Cancels a specific outstanding request for free disk space notification */
   1.504 +	{
   1.505 +
   1.506 +	TBool all = ETrue;
   1.507 +
   1.508 +	if(GET_MANDATORY_BOOL_PARAMETER(KAll, aSection, all))
   1.509 +		{
   1.510 +		if (all)
   1.511 +			{
   1.512 +			//Cancels all outstanding requests.
   1.513 +			iFs->NotifyDiskSpaceCancel();
   1.514 +			INFO_PRINTF1(_L("NotifyDiskSpaceCancel()"));
   1.515 +			}
   1.516 +		else
   1.517 +			{
   1.518 +			// Cancels a specific outstanding request
   1.519 +			TInt	index=0;
   1.520 +			GetIntFromConfig(aSection, KIndex, index);
   1.521 +
   1.522 +			iFs->NotifyDiskSpaceCancel(iNotifyDiskSpace[index]->iStatus);
   1.523 +			}
   1.524 +		}
   1.525 +	}
   1.526 +
   1.527 +void CT_FsData::DoCmdIsRomAddress(const TDesC& aSection)
   1.528 +/** Tests whether the specified address is in ROM */
   1.529 +	{
   1.530 +	//reading address
   1.531 +	TUint8* address = NULL;
   1.532 +	TInt intAddress;
   1.533 +	TBool dataOk = ETrue;
   1.534 +	
   1.535 +	if(GetHexFromConfig(aSection, KAddress, intAddress))
   1.536 +		{
   1.537 +		address = (TUint8*)intAddress;
   1.538 +		}
   1.539 +	else if(iIsFileInRom)
   1.540 +		{
   1.541 +		address = iIsFileInRom;
   1.542 +		}
   1.543 +	else
   1.544 +		{
   1.545 +		ERR_PRINTF1(_L("Address not specified"));
   1.546 +		SetBlockResult(EFail);
   1.547 +		dataOk = EFalse;
   1.548 +		}
   1.549 +	if(dataOk)
   1.550 +		{
   1.551 +		INFO_PRINTF2(_L("Address %X"), address);
   1.552 +		//Address of file in ROM
   1.553 +		TBool	actual = RFs::IsRomAddress(address);
   1.554 +		INFO_PRINTF2(_L("RFs::IsRomAddress() %d"), actual);
   1.555 +			//Reading expected result
   1.556 +		TBool	expected = EFalse;
   1.557 +		if ( GET_OPTIONAL_BOOL_PARAMETER(KInRom, aSection, expected) )
   1.558 +			{
   1.559 +			if ( expected != actual )
   1.560 +				{
   1.561 +				ERR_PRINTF1(_L("Expected result does not match actual"));
   1.562 +				SetBlockResult(EFail);
   1.563 +				}
   1.564 +			}
   1.565 +		}
   1.566 +	}
   1.567 +
   1.568 +void CT_FsData::DoCmdResourceCountMarkStart()
   1.569 +/** Marks the start of resource count checking */
   1.570 +	{
   1.571 +	iFs->ResourceCountMarkStart();
   1.572 +	INFO_PRINTF1(_L("ResourceCountMarkStart()"));
   1.573 +	}
   1.574 +
   1.575 +void CT_FsData::DoCmdResourceCountMarkEnd()
   1.576 +/** Ends resource count checking */
   1.577 +	{
   1.578 +	iFs->ResourceCountMarkEnd();
   1.579 +	INFO_PRINTF1(_L("ResourceCountMarkEnd()"));
   1.580 +	}
   1.581 +
   1.582 +void CT_FsData::DoCmdResourceCount(const TDesC& aSection)
   1.583 +/** Gets the number of currently open resources */
   1.584 +	{
   1.585 +	TInt	resources = iFs->ResourceCount();//Number of resources currently opened
   1.586 +	INFO_PRINTF2(_L("ResourceCount() = %d"), resources);
   1.587 +
   1.588 +	TInt expectedValue = 0; //Number of resources from config
   1.589 +	if(GetIntFromConfig(aSection, KResources, expectedValue))
   1.590 +		{
   1.591 +		if (expectedValue != resources)
   1.592 +			{
   1.593 +			ERR_PRINTF3(_L("ResourceCount() %d != %d expected value"), resources, expectedValue);
   1.594 +			SetBlockResult(EFail);
   1.595 +			}
   1.596 +		}
   1.597 +	}
   1.598 +
   1.599 +void CT_FsData::DoCmdGetNotifyUser(const TDesC& aSection)
   1.600 +/** Tests whether user notification of file read or write failure is in effect */
   1.601 +	{
   1.602 +	TBool	actual = iFs->GetNotifyUser();
   1.603 +	INFO_PRINTF2(_L("iFs->GetNotifyUser() %d"), actual);
   1.604 +
   1.605 +	TBool expected = EFalse;
   1.606 +	if ( GET_OPTIONAL_BOOL_PARAMETER(KNotify, aSection, expected) )
   1.607 +		{
   1.608 +		if ( expected!=actual )
   1.609 +			{
   1.610 +			ERR_PRINTF1(_L("Expected result does not match actual"));
   1.611 +			SetBlockResult(EFail);
   1.612 +			}
   1.613 +		}
   1.614 +	}
   1.615 +
   1.616 +void CT_FsData::DoCmdSetNotifyUser(const TDesC& aSection)
   1.617 +/** Sets whether the user should be notified of file read or write failure */
   1.618 +	{
   1.619 +	TBool notify = EFalse;
   1.620 +
   1.621 +	if(GET_MANDATORY_BOOL_PARAMETER(KNotify, aSection, notify))
   1.622 +		{
   1.623 +		iFs->SetNotifyUser(notify);
   1.624 +		TPtrC val = notify ? _L("TRUE") : _L("FALSE");
   1.625 +		INFO_PRINTF2(_L("SetNotifyUser() %S"), &val);
   1.626 +		}
   1.627 +
   1.628 +
   1.629 +	}
   1.630 +
   1.631 +void CT_FsData::DoCmdLoaderHeapFunctionL(const TDesC& aSection)
   1.632 +/** returns KErrNotSupported*/
   1.633 +	{
   1.634 +	TPtrC	name;
   1.635 +	TAny*	param1 = NULL;
   1.636 +	if(GetStringFromConfig(aSection, KParam1(), name))
   1.637 +		{
   1.638 +			//param1 = iDataDictionary->GetObject(name);
   1.639 +		}
   1.640 +
   1.641 +	TAny* param2 = NULL;
   1.642 +	if(GetStringFromConfig(aSection, KParam2(), name))
   1.643 +		{
   1.644 +			//param2 = iDataDictionary->GetObjectL(name);
   1.645 +		}
   1.646 +
   1.647 +	TInt	functionId = 0;
   1.648 +	if(GET_MANDATORY_INT_PARAMETER(KFunctionId(), aSection, functionId))
   1.649 +		{
   1.650 +		TInt err = iFs->LoaderHeapFunction(functionId, param1, param2);
   1.651 +		if( err!=KErrNone )
   1.652 +			{
   1.653 +			ERR_PRINTF2(_L("LoaderHeapFunction() ERROR: %d"), err);
   1.654 +			SetError(err);
   1.655 +			}
   1.656 +		}
   1.657 +	}
   1.658 +
   1.659 +void CT_FsData::DoCmdSetNotifyChange(const TDesC& aSection)
   1.660 +/** Enables/Disables change notification on a per-session basis. */
   1.661 +	{
   1.662 +
   1.663 +	TBool notify = EFalse;
   1.664 +
   1.665 +	if(GET_MANDATORY_BOOL_PARAMETER(KNotify, aSection, notify))
   1.666 +		{
   1.667 +		TInt err = iFs->SetNotifyChange(notify);
   1.668 +
   1.669 +		TPtrC val = notify ? _L("TRUE") : _L("FALSE");
   1.670 +		if (err == KErrNone)
   1.671 +			{
   1.672 +			INFO_PRINTF2(_L("SetNotifyChange() %S"), &val);
   1.673 +			}
   1.674 +		else
   1.675 +			{
   1.676 +			ERR_PRINTF3(_L("SetNotifyChange() %S, Error: %d"), &val, err);
   1.677 +			SetError(err);
   1.678 +			}
   1.679 +		}
   1.680 +	}
   1.681 +
   1.682 +void CT_FsData::DoCmdInitialisePropertiesFile(const TDesC& aSection)
   1.683 +/** Sets the F32 properties file ONLY in ESTART */
   1.684 +	{
   1.685 +	TPtrC tempStr;
   1.686 +	if(GET_MANDATORY_STRING_PARAMETER(KFile, aSection, tempStr))
   1.687 +		{
   1.688 +		TBuf8<KBufferStringLength>	buffer;
   1.689 +		buffer.Copy(tempStr);
   1.690 +		TPtrC8						iniFilePtr(buffer);
   1.691 +		INFO_PRINTF2(_L("InitialisePropertiesFile() %S"), &tempStr);
   1.692 +
   1.693 +		TInt	err = iFs ->InitialisePropertiesFile(iniFilePtr);
   1.694 +		if (err != KErrNone)
   1.695 +			{
   1.696 +			ERR_PRINTF2(_L("InitialisePropertiesFile() Error: %d"), err);
   1.697 +			SetError(err);
   1.698 +			}
   1.699 +		}
   1.700 +	}
   1.701 +
   1.702 +void CT_FsData::RunL(CActive* aActive, TInt aIndex)
   1.703 +	{
   1.704 +	INFO_PRINTF1(_L("CT_FsData::RunL Called"));
   1.705 +	TBool	foundActiveObject = EFalse;
   1.706 +	TInt	index=0;
   1.707 +	TInt	count=0;
   1.708 +	TBool	completed=ETrue;
   1.709 +
   1.710 +	// See if it is in iNotifyChange
   1.711 +	count=iNotifyChange.Count();
   1.712 +	for( index=0; (index<count) && (!foundActiveObject); ++index )
   1.713 + 		{
   1.714 + 		if( aActive == iNotifyChange[index] )
   1.715 +			{
   1.716 +			INFO_PRINTF1(_L("RunL iNotifyChange called"));
   1.717 +			foundActiveObject = ETrue;
   1.718 +			if ( iNotifyChange[index]->DecCount()>0 )
   1.719 +				{
   1.720 +				completed=EFalse;
   1.721 +				iNotifyChange[index]->Activate();
   1.722 +				}
   1.723 +			else
   1.724 +				{
   1.725 +				iNotifyChange.Remove(index);
   1.726 +				}
   1.727 +	 		}
   1.728 +		}
   1.729 +
   1.730 +	// See if it is in iNotifyDiskSpace
   1.731 +	count=iNotifyDiskSpace.Count();
   1.732 +	for( index=0; (index<count) && (!foundActiveObject); ++index )
   1.733 + 		{
   1.734 + 		if( aActive == iNotifyDiskSpace[index] )
   1.735 +			{
   1.736 +			INFO_PRINTF1(_L("RunL iNotifyDiskSpace called"));
   1.737 +			foundActiveObject = ETrue;
   1.738 +			iNotifyDiskSpace.Remove(index);
   1.739 +	 		}
   1.740 +		}
   1.741 +
   1.742 +	// See if it is in iNotifyDismount
   1.743 +	count=iNotifyDismount.Count();
   1.744 +	for( index=0; (index<count) && (!foundActiveObject); ++index )
   1.745 + 		{
   1.746 + 		if( aActive == iNotifyDismount[index] )
   1.747 +			{
   1.748 +			INFO_PRINTF1(_L("RunL iNotifyDismount called"));
   1.749 +			foundActiveObject = ETrue;
   1.750 +			iNotifyDismount.Remove(index);
   1.751 +	 		}
   1.752 +		}
   1.753 +
   1.754 +	// See if it is in iStartupInitComplete
   1.755 +	count=iStartupInitComplete.Count();
   1.756 +	for( index=0; (index<count) && (!foundActiveObject); ++index )
   1.757 + 		{
   1.758 + 		if( aActive == iStartupInitComplete[index] )
   1.759 +			{
   1.760 +			INFO_PRINTF1(_L("RunL iStartupInitComplete called"));
   1.761 +			foundActiveObject = ETrue;
   1.762 +			iStartupInitComplete.Remove(index);
   1.763 +	 		}
   1.764 +		}
   1.765 +
   1.766 + 	if( foundActiveObject )
   1.767 + 		{
   1.768 +		TInt	err = aActive->iStatus.Int();
   1.769 +		if( err != KErrNone )
   1.770 +			{
   1.771 +			ERR_PRINTF2(_L("RunL Error %d"), err);
   1.772 +			SetAsyncError( aIndex, err );
   1.773 +			}
   1.774 +
   1.775 +		if ( completed )
   1.776 +			{
   1.777 +			// Reset the outstanding request state
   1.778 +			delete aActive;
   1.779 +			DecOutstanding();
   1.780 +			}
   1.781 +		}
   1.782 +	else
   1.783 +		{
   1.784 + 		ERR_PRINTF1(_L("Stray RunL signal"));
   1.785 + 		SetBlockResult(EFail);
   1.786 +		}
   1.787 +	}
   1.788 +
   1.789 +void CT_FsData::DoCancel(CActive* aActive, TInt aIndex)
   1.790 +	{
   1.791 +	TBool	foundActiveObject = EFalse;
   1.792 +
   1.793 +	TInt	index=0;
   1.794 +	TInt	count=0;
   1.795 +
   1.796 +	// See if it is in iNotifyChange
   1.797 +	count=iNotifyChange.Count();
   1.798 +	for( index=0; (index<count) && (!foundActiveObject); ++index )
   1.799 + 		{
   1.800 + 		if( aActive == iNotifyChange[index] )
   1.801 +			{
   1.802 +			INFO_PRINTF1(_L("DoCancel iNotifyChange called"));
   1.803 +			foundActiveObject = ETrue;
   1.804 +			iNotifyChange.Remove(index);
   1.805 +	 		}
   1.806 +		}
   1.807 +
   1.808 +	// See if it is in iNotifyDiskSpace
   1.809 +	count=iNotifyDiskSpace.Count();
   1.810 +	for( index=0; (index<count) && (!foundActiveObject); ++index )
   1.811 + 		{
   1.812 + 		if( aActive == iNotifyDiskSpace[index] )
   1.813 +			{
   1.814 +			INFO_PRINTF1(_L("DoCancel iNotifyDiskSpace called"));
   1.815 +			foundActiveObject = ETrue;
   1.816 +			iNotifyDiskSpace.Remove(index);
   1.817 +	 		}
   1.818 +		}
   1.819 +
   1.820 +	// See if it is in iNotifyDismount
   1.821 +	count=iNotifyDismount.Count();
   1.822 +	for( index=0; (index<count) && (!foundActiveObject); ++index )
   1.823 + 		{
   1.824 + 		if( aActive == iNotifyDismount[index] )
   1.825 +			{
   1.826 +			INFO_PRINTF1(_L("DoCancel iNotifyDismount called"));
   1.827 +			foundActiveObject = ETrue;
   1.828 +			iNotifyDismount.Remove(index);
   1.829 +	 		}
   1.830 +		}
   1.831 +
   1.832 +	// See if it is in iStartupInitComplete
   1.833 +	count=iStartupInitComplete.Count();
   1.834 +	for( index=0; (index<count) && (!foundActiveObject); ++index )
   1.835 + 		{
   1.836 + 		if( aActive == iStartupInitComplete[index] )
   1.837 +			{
   1.838 +			INFO_PRINTF1(_L("DoCancel iStartupInitComplete called"));
   1.839 +			foundActiveObject = ETrue;
   1.840 +			iStartupInitComplete.Remove(index);
   1.841 +	 		}
   1.842 +		}
   1.843 +
   1.844 + 	if( foundActiveObject )
   1.845 + 		{
   1.846 +		TInt	err = aActive->iStatus.Int();
   1.847 +		if( err != KErrNone )
   1.848 +			{
   1.849 +			ERR_PRINTF2(_L("DoCancel Error %d"), err);
   1.850 +			SetAsyncError( aIndex, err );
   1.851 +			}
   1.852 +
   1.853 +		// Reset the outstanding request state
   1.854 +		DecOutstanding();
   1.855 +
   1.856 +		delete aActive;
   1.857 +		}
   1.858 +	else
   1.859 +		{
   1.860 + 		ERR_PRINTF1(_L("Stray DoCancel signal"));
   1.861 + 		SetBlockResult(EFail);
   1.862 +		}
   1.863 +	}
   1.864 +TBool CT_FsData::ConvertToNotifyType(const TDesC& aNotifyTypeStr, TNotifyType& aNotifyType)
   1.865 +{
   1.866 +	TBool ret = ETrue;
   1.867 +	if(aNotifyTypeStr == _L("ENotifyAll"))
   1.868 +		{
   1.869 +		aNotifyType = ENotifyAll;
   1.870 +		}
   1.871 +	else if(aNotifyTypeStr == _L("ENotifyEntry"))
   1.872 +		{
   1.873 +		aNotifyType = ENotifyEntry;
   1.874 +		}
   1.875 +	else if(aNotifyTypeStr == _L("ENotifyFile"))
   1.876 +		{
   1.877 +		aNotifyType = ENotifyFile;
   1.878 +		}
   1.879 +	else if(aNotifyTypeStr == _L("ENotifyDir"))
   1.880 +		{
   1.881 +		aNotifyType = ENotifyDir;
   1.882 +		}
   1.883 +	else if(aNotifyTypeStr == _L("ENotifyAttributes"))
   1.884 +		{
   1.885 +		aNotifyType = ENotifyAttributes;
   1.886 +		}
   1.887 +	else if(aNotifyTypeStr == _L("ENotifyWrite"))
   1.888 +		{
   1.889 +		aNotifyType = ENotifyWrite;
   1.890 +		}
   1.891 +	else if(aNotifyTypeStr == _L("ENotifyDisk"))
   1.892 +		{
   1.893 +		aNotifyType = ENotifyDisk;
   1.894 +		}
   1.895 +	//For COnverting data ENotifyFile|ENotifyDir
   1.896 +	else
   1.897 +		{
   1.898 +		TInt	location=aNotifyTypeStr.Match(_L("*|*"));
   1.899 +		if( location!=KErrNotFound )
   1.900 +			{
   1.901 +			//Converting Left part of the data
   1.902 +			TPtrC		tempStr=aNotifyTypeStr.Left(location);
   1.903 +			ret=ConvertToNotifyType(tempStr, aNotifyType);
   1.904 +
   1.905 +			//Converting right data can be with another "|"
   1.906 +			tempStr.Set(aNotifyTypeStr.Mid(location+1));
   1.907 +
   1.908 +			TNotifyType	notifyTypeTmp;
   1.909 +			if ( ConvertToNotifyType(tempStr, notifyTypeTmp) )
   1.910 +				{
   1.911 +				aNotifyType =(TNotifyType)((TInt)aNotifyType|(TInt)notifyTypeTmp);
   1.912 +				}
   1.913 +			else
   1.914 +				{
   1.915 +				ret = EFalse;
   1.916 +				}
   1.917 +			}
   1.918 +		else
   1.919 +			{
   1.920 +			ret = EFalse;
   1.921 +			}
   1.922 +		}
   1.923 +
   1.924 +	return ret;
   1.925 +	}