os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_FsData.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
* All rights reserved.
sl@0
     4
* This component and the accompanying materials are made available
sl@0
     5
* under the terms of "Eclipse Public License v1.0"
sl@0
     6
* which accompanies this distribution, and is available
sl@0
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
*
sl@0
     9
* Initial Contributors:
sl@0
    10
* Nokia Corporation - initial contribution.
sl@0
    11
*
sl@0
    12
* Contributors:
sl@0
    13
*
sl@0
    14
* Description: 
sl@0
    15
*
sl@0
    16
*/
sl@0
    17
sl@0
    18
sl@0
    19
/**
sl@0
    20
@test
sl@0
    21
@internalComponent
sl@0
    22
sl@0
    23
This contains CT_FsData
sl@0
    24
*/
sl@0
    25
sl@0
    26
//	User includes
sl@0
    27
#include "T_FsData.h"
sl@0
    28
#include "T_SfSrvServer.h"
sl@0
    29
#include "DataWrapperBase.h"
sl@0
    30
sl@0
    31
/*@{*/
sl@0
    32
sl@0
    33
_LIT(KMessageSlots,							"messageSlots");
sl@0
    34
_LIT(KPath,									"path");
sl@0
    35
_LIT(KAddress,								"address");
sl@0
    36
_LIT(KType,									"type");
sl@0
    37
_LIT(KAll,									"all");
sl@0
    38
_LIT(KResources,							"resources");
sl@0
    39
_LIT(KNotify,								"notify");
sl@0
    40
_LIT(KInRom,								"inRom");
sl@0
    41
_LIT(KThreshold,							"threshold");
sl@0
    42
_LIT(KDrive,								"drive");
sl@0
    43
_LIT(KFunctionId,							"functionId");
sl@0
    44
_LIT(KAdd,									"add");
sl@0
    45
_LIT(KSub,									"sub");
sl@0
    46
_LIT(KUseFreeSpace,							"use_free_space");
sl@0
    47
_LIT(KVersionName,							"name");
sl@0
    48
_LIT(KVersionBuild,							"build");
sl@0
    49
_LIT(KVersionMajor,							"major");
sl@0
    50
_LIT(KVersionMinor,							"minor");
sl@0
    51
_LIT(KIndex,								"index");
sl@0
    52
_LIT(KParam1,								"param1");
sl@0
    53
_LIT(KParam2,								"param2");
sl@0
    54
_LIT(KFile,									"file");
sl@0
    55
_LIT(KCount,								"count");
sl@0
    56
sl@0
    57
///	Commands
sl@0
    58
_LIT(KCmdNew,								"new");
sl@0
    59
_LIT(KCmdClose,								"Close");
sl@0
    60
_LIT(KCmdDestructor,						"~");
sl@0
    61
_LIT(KCmdConnect,							"Connect");
sl@0
    62
_LIT(KCmdVersion,							"Version");
sl@0
    63
_LIT(KCmdNotifyChange,						"NotifyChange");
sl@0
    64
_LIT(KCmdNotifyChangeCancel,				"NotifyChangeCancel");
sl@0
    65
_LIT(KCmdNotifyDiskSpace,					"NotifyDiskSpace");
sl@0
    66
_LIT(KCmdNotifyDiskSpaceCancel,				"NotifyDiskSpaceCancel");
sl@0
    67
_LIT(KCmdIsRomAddress,						"IsRomAddress");
sl@0
    68
_LIT(KCmdResourceCountMarkStart,			"ResourceCountMarkStart");
sl@0
    69
_LIT(KCmdResourceCountMarkEnd,				"ResourceCountMarkEnd");
sl@0
    70
_LIT(KCmdResourceCount,						"ResourceCount");
sl@0
    71
_LIT(KCmdGetNotifyUser,						"GetNotifyUser");
sl@0
    72
_LIT(KCmdSetNotifyUser,						"SetNotifyUser");
sl@0
    73
_LIT(KCmdSetNotifyChange,					"SetNotifyChange");
sl@0
    74
_LIT(KCmdLoaderHeapFunction,				"LoaderHeapFunction");
sl@0
    75
_LIT(KCmdInitialisePropertiesFile,			"InitialisePropertiesFile");
sl@0
    76
/*@}*/
sl@0
    77
sl@0
    78
CT_FsData* CT_FsData::NewL()
sl@0
    79
/**
sl@0
    80
 * Two phase constructor
sl@0
    81
 */
sl@0
    82
	{
sl@0
    83
	CT_FsData*	ret = new (ELeave) CT_FsData();
sl@0
    84
	CleanupStack::PushL(ret);
sl@0
    85
	ret->ConstructL();
sl@0
    86
	CleanupStack::Pop(ret);
sl@0
    87
	return ret;	
sl@0
    88
	}
sl@0
    89
sl@0
    90
CT_FsData::CT_FsData()
sl@0
    91
/**
sl@0
    92
 * Protected constructor. First phase construction
sl@0
    93
 */
sl@0
    94
	{
sl@0
    95
	}
sl@0
    96
sl@0
    97
void CT_FsData::ConstructL()
sl@0
    98
/**
sl@0
    99
 * Protected constructor. Second phase construction
sl@0
   100
 */
sl@0
   101
	{
sl@0
   102
	
sl@0
   103
	}
sl@0
   104
sl@0
   105
CT_FsData::~CT_FsData()
sl@0
   106
/**
sl@0
   107
 * Destructor.
sl@0
   108
 */
sl@0
   109
	{
sl@0
   110
	DoCleanup();
sl@0
   111
sl@0
   112
	iNotifyChange.ResetAndDestroy();
sl@0
   113
	iNotifyDiskSpace.ResetAndDestroy();
sl@0
   114
	iNotifyDismount.ResetAndDestroy();
sl@0
   115
	iStartupInitComplete.ResetAndDestroy();
sl@0
   116
	}
sl@0
   117
sl@0
   118
void CT_FsData::DoCleanup()
sl@0
   119
/**
sl@0
   120
 * Contains cleanup implementation
sl@0
   121
 */
sl@0
   122
	{
sl@0
   123
	//Deleting RFs.
sl@0
   124
	if(iFs != NULL)
sl@0
   125
		{
sl@0
   126
		INFO_PRINTF1(_L("Deleting current RFs"));
sl@0
   127
		delete iFs;
sl@0
   128
		iFs = NULL;
sl@0
   129
		}
sl@0
   130
	}
sl@0
   131
sl@0
   132
TAny* CT_FsData::GetObject()
sl@0
   133
/**
sl@0
   134
 * Return a pointer to the object that the data wraps
sl@0
   135
 *
sl@0
   136
 * @return pointer to the object that the data wraps
sl@0
   137
 */
sl@0
   138
	{
sl@0
   139
	return iFs;
sl@0
   140
	}
sl@0
   141
sl@0
   142
TUint64 CT_FsData::ThreadId()
sl@0
   143
	{
sl@0
   144
	RThread currentThread;
sl@0
   145
	return currentThread.Id().Id();
sl@0
   146
	}
sl@0
   147
sl@0
   148
TBool CT_FsData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
sl@0
   149
/**
sl@0
   150
 * Process a command read from the ini file
sl@0
   151
 *
sl@0
   152
 * @param aCommand	the command to process
sl@0
   153
 * @param aSection		the entry in the ini file requiring the command to be processed
sl@0
   154
 *
sl@0
   155
 * @return ETrue if the command is processed
sl@0
   156
 */
sl@0
   157
	{
sl@0
   158
	TBool retVal = ETrue;
sl@0
   159
	if (aCommand == KCmdNew)
sl@0
   160
		{
sl@0
   161
		DoCmdNewL();
sl@0
   162
		}
sl@0
   163
	else if (aCommand == KCmdClose)
sl@0
   164
		{
sl@0
   165
		DoCmdClose();
sl@0
   166
		}
sl@0
   167
	else if (aCommand == KCmdDestructor)
sl@0
   168
		{
sl@0
   169
		DoCmdDestructor();
sl@0
   170
		}
sl@0
   171
	else if (aCommand == KCmdConnect)
sl@0
   172
		{
sl@0
   173
		DoCmdConnect(aSection);
sl@0
   174
		}
sl@0
   175
	else if (aCommand == KCmdVersion)
sl@0
   176
		{
sl@0
   177
		DoCmdVersion(aSection);
sl@0
   178
		}
sl@0
   179
	else if (aCommand == KCmdNotifyChange)
sl@0
   180
		{
sl@0
   181
		DoCmdNotifyChangeL(aSection, aAsyncErrorIndex);
sl@0
   182
		}
sl@0
   183
	else if (aCommand == KCmdNotifyChangeCancel)
sl@0
   184
		{
sl@0
   185
		DoCmdNotifyChangeCancel(aSection);
sl@0
   186
		}
sl@0
   187
	else if (aCommand == KCmdNotifyDiskSpace)
sl@0
   188
		{
sl@0
   189
		DoCmdNotifyDiskSpaceL(aSection, aAsyncErrorIndex);
sl@0
   190
		}
sl@0
   191
	else if (aCommand == KCmdNotifyDiskSpaceCancel)
sl@0
   192
		{
sl@0
   193
		DoCmdNotifyDiskSpaceCancel(aSection);
sl@0
   194
		}
sl@0
   195
	else if (aCommand == KCmdIsRomAddress)
sl@0
   196
		{
sl@0
   197
		DoCmdIsRomAddress(aSection);
sl@0
   198
		}
sl@0
   199
	else if (aCommand == KCmdResourceCountMarkStart)
sl@0
   200
		{
sl@0
   201
		DoCmdResourceCountMarkStart();
sl@0
   202
		}
sl@0
   203
	else if (aCommand == KCmdResourceCountMarkEnd)
sl@0
   204
		{
sl@0
   205
		DoCmdResourceCountMarkEnd();
sl@0
   206
		}
sl@0
   207
	else if (aCommand == KCmdResourceCount)
sl@0
   208
		{
sl@0
   209
		DoCmdResourceCount(aSection);
sl@0
   210
		}
sl@0
   211
	else if (aCommand == KCmdGetNotifyUser)
sl@0
   212
		{
sl@0
   213
		DoCmdGetNotifyUser(aSection);
sl@0
   214
		}
sl@0
   215
	else if (aCommand == KCmdSetNotifyUser)
sl@0
   216
		{
sl@0
   217
		DoCmdSetNotifyUser(aSection);
sl@0
   218
		}
sl@0
   219
	else if (aCommand == KCmdLoaderHeapFunction)
sl@0
   220
		{
sl@0
   221
		DoCmdLoaderHeapFunctionL(aSection);
sl@0
   222
		}
sl@0
   223
	else if (aCommand == KCmdSetNotifyChange)
sl@0
   224
		{
sl@0
   225
		DoCmdSetNotifyChange(aSection);
sl@0
   226
		}
sl@0
   227
	else if (aCommand == KCmdInitialisePropertiesFile)
sl@0
   228
		{
sl@0
   229
		DoCmdInitialisePropertiesFile(aSection);
sl@0
   230
		}
sl@0
   231
	else
sl@0
   232
		{
sl@0
   233
		if (!DoCommandDrivesL(aCommand, aSection, aAsyncErrorIndex))
sl@0
   234
			{
sl@0
   235
			if (!DoCommandMountsL(aCommand, aSection, aAsyncErrorIndex))
sl@0
   236
				{
sl@0
   237
				if (!DoCommandFilesL(aCommand, aSection, aAsyncErrorIndex))
sl@0
   238
					{
sl@0
   239
					retVal = EFalse;
sl@0
   240
					}
sl@0
   241
				}
sl@0
   242
			}
sl@0
   243
		}
sl@0
   244
	return retVal;
sl@0
   245
	}
sl@0
   246
sl@0
   247
sl@0
   248
void CT_FsData::DoCmdNewL()
sl@0
   249
/** Creates new RFs class instance */
sl@0
   250
	{
sl@0
   251
	INFO_PRINTF1(_L("Create new RFs class instance"));
sl@0
   252
	
sl@0
   253
	//Deletes previous RFs class instance if it was already created.
sl@0
   254
	DoCleanup();
sl@0
   255
sl@0
   256
	// do create
sl@0
   257
	TRAPD(err, iFs = new (ELeave) RFs());
sl@0
   258
	if ( err!=KErrNone )
sl@0
   259
		{
sl@0
   260
		ERR_PRINTF2(_L("new error %d"), err);
sl@0
   261
		SetError( err );
sl@0
   262
		}
sl@0
   263
	}
sl@0
   264
sl@0
   265
void CT_FsData::DoCmdClose()
sl@0
   266
/** Close RFs handle */
sl@0
   267
	{
sl@0
   268
	INFO_PRINTF1(_L("Closing RFs"));
sl@0
   269
	iFs->Close();
sl@0
   270
	}
sl@0
   271
sl@0
   272
sl@0
   273
void CT_FsData::DoCmdDestructor()
sl@0
   274
/** Destroy RFs the object */
sl@0
   275
	{
sl@0
   276
	INFO_PRINTF1(_L("Destroying the RFs object"));
sl@0
   277
	DoCleanup();
sl@0
   278
	}
sl@0
   279
sl@0
   280
void CT_FsData::DoCmdConnect(const TDesC& aSection)
sl@0
   281
/** Connects a client to the file server */
sl@0
   282
	{
sl@0
   283
sl@0
   284
	TInt	messageSlots = KFileServerDefaultMessageSlots;
sl@0
   285
	GetIntFromConfig(aSection, KMessageSlots, messageSlots);
sl@0
   286
sl@0
   287
	TInt err = iFs->Connect(messageSlots);
sl@0
   288
	INFO_PRINTF2(_L("Call Connect(messageSlots = %d)"), messageSlots);
sl@0
   289
sl@0
   290
	if ( err!=KErrNone )
sl@0
   291
		{
sl@0
   292
		ERR_PRINTF2(_L("Connect() error %d"), err);
sl@0
   293
		SetError( err );
sl@0
   294
		}
sl@0
   295
	}
sl@0
   296
sl@0
   297
void CT_FsData::DoCmdVersion(const TDesC& aSection)
sl@0
   298
/** Gets the client side version number */
sl@0
   299
	{
sl@0
   300
	
sl@0
   301
	TVersion		version=iFs->Version();
sl@0
   302
	TVersionName	versionName	= version.Name();
sl@0
   303
	INFO_PRINTF2(_L("Version name  : %S"), &versionName);
sl@0
   304
	INFO_PRINTF2(_L("Version build : %d"), (TInt)version.iBuild);
sl@0
   305
	INFO_PRINTF2(_L("Version major : %d"), (TInt)version.iMajor);
sl@0
   306
	INFO_PRINTF2(_L("Version minor : %d"), (TInt)version.iMinor);
sl@0
   307
sl@0
   308
	TPtrC	name;
sl@0
   309
	if ( GET_OPTIONAL_STRING_PARAMETER(KVersionName, aSection, name))
sl@0
   310
		{
sl@0
   311
		if ( name != version.Name() )
sl@0
   312
			{
sl@0
   313
			ERR_PRINTF3(_L("Name does not match expected name: %S, %S"), &name, &versionName);
sl@0
   314
			SetBlockResult(EFail);
sl@0
   315
			}
sl@0
   316
		}
sl@0
   317
sl@0
   318
	TInt	intTemp;
sl@0
   319
	if ( GET_OPTIONAL_INT_PARAMETER(KVersionBuild, aSection, intTemp) )
sl@0
   320
		{
sl@0
   321
		if ( intTemp != version.iBuild )
sl@0
   322
			{
sl@0
   323
			ERR_PRINTF1(_L("Build does not match expected build"));
sl@0
   324
			SetBlockResult(EFail);
sl@0
   325
			}
sl@0
   326
		}
sl@0
   327
sl@0
   328
	if ( GET_OPTIONAL_INT_PARAMETER(KVersionMajor, aSection, intTemp) )
sl@0
   329
		{
sl@0
   330
		if ( intTemp != version.iMajor )
sl@0
   331
			{
sl@0
   332
			ERR_PRINTF1(_L("Major does not match expected major"));
sl@0
   333
			SetBlockResult(EFail);
sl@0
   334
			}
sl@0
   335
		}
sl@0
   336
sl@0
   337
	if ( GET_OPTIONAL_INT_PARAMETER(KVersionMinor, aSection, intTemp) )
sl@0
   338
		{
sl@0
   339
		if ( intTemp != version.iMinor )
sl@0
   340
			{
sl@0
   341
			ERR_PRINTF1(_L("Minor does not match expected minor"));
sl@0
   342
			SetBlockResult(EFail);
sl@0
   343
			}
sl@0
   344
		}
sl@0
   345
sl@0
   346
	if (version.Name() == _L("") && version.iBuild == 0 && version.iMajor == 0 && version.iMinor == 0)
sl@0
   347
		{
sl@0
   348
		ERR_PRINTF1(_L("Some version fields are not set!"));
sl@0
   349
		SetBlockResult(EFail);
sl@0
   350
		}
sl@0
   351
	}
sl@0
   352
sl@0
   353
void CT_FsData::DoCmdNotifyChangeL(const TDesC& aSection, const TInt aAsyncErrorIndex)
sl@0
   354
/** Requests a notification of change to files or directories */
sl@0
   355
	{
sl@0
   356
	TNotifyType	type = ENotifyAll;
sl@0
   357
	TPtrC		typeTemp;
sl@0
   358
	TBool		dataOk = ETrue;
sl@0
   359
sl@0
   360
	if ( GET_MANDATORY_STRING_PARAMETER(KType, aSection, typeTemp) )
sl@0
   361
		{
sl@0
   362
		if(!ConvertToNotifyType(typeTemp, type))
sl@0
   363
			{
sl@0
   364
			TInt	typeNumber;
sl@0
   365
			if(GetIntFromConfig(aSection, KType(), typeNumber))
sl@0
   366
				{
sl@0
   367
				type = (TNotifyType)typeNumber;
sl@0
   368
				}
sl@0
   369
			else
sl@0
   370
				{
sl@0
   371
				ERR_PRINTF3(_L("NotifyChange() incorrect parameter %S in %S"), &typeTemp, &KType());
sl@0
   372
				SetBlockResult(EFail);
sl@0
   373
				dataOk = EFalse;
sl@0
   374
				}
sl@0
   375
			}
sl@0
   376
		}
sl@0
   377
	else
sl@0
   378
		{
sl@0
   379
		dataOk = EFalse;
sl@0
   380
		}
sl@0
   381
sl@0
   382
	TInt	count=1;
sl@0
   383
	GET_OPTIONAL_INT_PARAMETER(KCount, aSection, count);
sl@0
   384
sl@0
   385
	if(dataOk)
sl@0
   386
		{
sl@0
   387
		CT_ActiveNotifyChange*	active = CT_ActiveNotifyChange::NewLC(count, aAsyncErrorIndex, *this);
sl@0
   388
		iNotifyChange.AppendL(active);
sl@0
   389
		CleanupStack::Pop(active);
sl@0
   390
sl@0
   391
		TPtrC	path;
sl@0
   392
		if ( GetStringFromConfig(aSection, KPath(), path) )
sl@0
   393
			{
sl@0
   394
			iFs->NotifyChange(type, active->iStatus, path);
sl@0
   395
			INFO_PRINTF1(_L("NotifyChange(TNotifyType, TRequestStatus, const TDesC)"));
sl@0
   396
			}
sl@0
   397
		else
sl@0
   398
			{
sl@0
   399
			iFs->NotifyChange(type, active->iStatus);
sl@0
   400
			INFO_PRINTF1(_L("NotifyChange(TNotifyType TRequestStatus)"));
sl@0
   401
			}
sl@0
   402
			
sl@0
   403
		active->Activate();
sl@0
   404
		IncOutstanding();
sl@0
   405
		}
sl@0
   406
	}
sl@0
   407
sl@0
   408
sl@0
   409
void CT_FsData::DoCmdNotifyChangeCancel(const TDesC& aSection)
sl@0
   410
/** Cancels outstanding request(s) for notification of change to files or directories */
sl@0
   411
	{
sl@0
   412
	TBool	all = ETrue;
sl@0
   413
sl@0
   414
	if ( GET_MANDATORY_BOOL_PARAMETER(KAll, aSection, all) )
sl@0
   415
		{
sl@0
   416
		if(all)
sl@0
   417
			{
sl@0
   418
			// Cancels all outstanding requests.
sl@0
   419
			iFs->NotifyChangeCancel();
sl@0
   420
			INFO_PRINTF1(_L("NotifyChangeCancel()"));
sl@0
   421
			}
sl@0
   422
		else
sl@0
   423
			{
sl@0
   424
			// Cancels a specific outstanding request
sl@0
   425
			TInt	index=0;
sl@0
   426
			GetIntFromConfig(aSection, KIndex(), index);
sl@0
   427
sl@0
   428
			iFs->NotifyChangeCancel(iNotifyChange[index]->iStatus);
sl@0
   429
			INFO_PRINTF1(_L("NotifyChangeCancel(TRequestStatus)"));
sl@0
   430
			}
sl@0
   431
		}
sl@0
   432
	}
sl@0
   433
sl@0
   434
void CT_FsData::DoCmdNotifyDiskSpaceL(const TDesC& aSection, const TInt aAsyncErrorIndex)
sl@0
   435
/** Requests notification when the free disk space on the specified drive crosses the specified threshold value */
sl@0
   436
	{
sl@0
   437
	//Get drive number from config
sl@0
   438
	TDriveNumber	drive = EDriveA;
sl@0
   439
	TBool 			dataOk = ETrue;
sl@0
   440
	if (!GetDriveNumberFromConfig(aSection, KDrive, drive))
sl@0
   441
		{
sl@0
   442
		ERR_PRINTF2(_L("No %S"), &KDrive());
sl@0
   443
		SetBlockResult(EFail);
sl@0
   444
		dataOk = EFalse;
sl@0
   445
		}
sl@0
   446
sl@0
   447
	TBool	useFreeSpace = EFalse;
sl@0
   448
	GET_OPTIONAL_BOOL_PARAMETER(KUseFreeSpace, aSection, useFreeSpace);
sl@0
   449
sl@0
   450
	TInt64 threshold = 0;
sl@0
   451
	//Defining treshold by free space
sl@0
   452
	if(useFreeSpace)
sl@0
   453
		{
sl@0
   454
		threshold = iVolumeInfo.iFree;
sl@0
   455
		//For Calculation free-temp(_sub), free+temp(_add)
sl@0
   456
		TInt temp;
sl@0
   457
		if(GetIntFromConfig(aSection, KAdd, temp))
sl@0
   458
			{
sl@0
   459
			threshold += temp;
sl@0
   460
			temp = 0;
sl@0
   461
			}
sl@0
   462
		if(GetIntFromConfig(aSection, KSub, temp))
sl@0
   463
			{
sl@0
   464
			threshold -= temp;
sl@0
   465
			temp = 0;
sl@0
   466
			}
sl@0
   467
		}
sl@0
   468
	//Defining treshold by some value
sl@0
   469
	else
sl@0
   470
		{
sl@0
   471
		TPtrC thold;
sl@0
   472
		if(GET_MANDATORY_STRING_PARAMETER(KThreshold, aSection, thold))
sl@0
   473
			{
sl@0
   474
			TLex lex(thold);
sl@0
   475
			TInt err = lex.Val(threshold);
sl@0
   476
			if(err)
sl@0
   477
				{
sl@0
   478
				ERR_PRINTF1(_L("NotifyDiskSpace() bad treshold value"));
sl@0
   479
				SetBlockResult(EFail);
sl@0
   480
				dataOk = EFalse;
sl@0
   481
				}
sl@0
   482
			}
sl@0
   483
		}
sl@0
   484
sl@0
   485
	if(dataOk)
sl@0
   486
		{
sl@0
   487
		CActiveCallback*	active = CActiveCallback::NewLC(*this);
sl@0
   488
		iNotifyDiskSpace.AppendL(active);
sl@0
   489
		CleanupStack::Pop(active);
sl@0
   490
sl@0
   491
		iFs->NotifyDiskSpace(threshold, drive, active->iStatus);
sl@0
   492
		INFO_PRINTF1(_L("NotifyDiskSpace()"));
sl@0
   493
		active->Activate(aAsyncErrorIndex);
sl@0
   494
		IncOutstanding();
sl@0
   495
		}
sl@0
   496
	}
sl@0
   497
sl@0
   498
sl@0
   499
void CT_FsData::DoCmdNotifyDiskSpaceCancel(const TDesC& aSection)
sl@0
   500
/** Cancels a specific outstanding request for free disk space notification */
sl@0
   501
	{
sl@0
   502
sl@0
   503
	TBool all = ETrue;
sl@0
   504
sl@0
   505
	if(GET_MANDATORY_BOOL_PARAMETER(KAll, aSection, all))
sl@0
   506
		{
sl@0
   507
		if (all)
sl@0
   508
			{
sl@0
   509
			//Cancels all outstanding requests.
sl@0
   510
			iFs->NotifyDiskSpaceCancel();
sl@0
   511
			INFO_PRINTF1(_L("NotifyDiskSpaceCancel()"));
sl@0
   512
			}
sl@0
   513
		else
sl@0
   514
			{
sl@0
   515
			// Cancels a specific outstanding request
sl@0
   516
			TInt	index=0;
sl@0
   517
			GetIntFromConfig(aSection, KIndex, index);
sl@0
   518
sl@0
   519
			iFs->NotifyDiskSpaceCancel(iNotifyDiskSpace[index]->iStatus);
sl@0
   520
			}
sl@0
   521
		}
sl@0
   522
	}
sl@0
   523
sl@0
   524
void CT_FsData::DoCmdIsRomAddress(const TDesC& aSection)
sl@0
   525
/** Tests whether the specified address is in ROM */
sl@0
   526
	{
sl@0
   527
	//reading address
sl@0
   528
	TUint8* address = NULL;
sl@0
   529
	TInt intAddress;
sl@0
   530
	TBool dataOk = ETrue;
sl@0
   531
	
sl@0
   532
	if(GetHexFromConfig(aSection, KAddress, intAddress))
sl@0
   533
		{
sl@0
   534
		address = (TUint8*)intAddress;
sl@0
   535
		}
sl@0
   536
	else if(iIsFileInRom)
sl@0
   537
		{
sl@0
   538
		address = iIsFileInRom;
sl@0
   539
		}
sl@0
   540
	else
sl@0
   541
		{
sl@0
   542
		ERR_PRINTF1(_L("Address not specified"));
sl@0
   543
		SetBlockResult(EFail);
sl@0
   544
		dataOk = EFalse;
sl@0
   545
		}
sl@0
   546
	if(dataOk)
sl@0
   547
		{
sl@0
   548
		INFO_PRINTF2(_L("Address %X"), address);
sl@0
   549
		//Address of file in ROM
sl@0
   550
		TBool	actual = RFs::IsRomAddress(address);
sl@0
   551
		INFO_PRINTF2(_L("RFs::IsRomAddress() %d"), actual);
sl@0
   552
			//Reading expected result
sl@0
   553
		TBool	expected = EFalse;
sl@0
   554
		if ( GET_OPTIONAL_BOOL_PARAMETER(KInRom, aSection, expected) )
sl@0
   555
			{
sl@0
   556
			if ( expected != actual )
sl@0
   557
				{
sl@0
   558
				ERR_PRINTF1(_L("Expected result does not match actual"));
sl@0
   559
				SetBlockResult(EFail);
sl@0
   560
				}
sl@0
   561
			}
sl@0
   562
		}
sl@0
   563
	}
sl@0
   564
sl@0
   565
void CT_FsData::DoCmdResourceCountMarkStart()
sl@0
   566
/** Marks the start of resource count checking */
sl@0
   567
	{
sl@0
   568
	iFs->ResourceCountMarkStart();
sl@0
   569
	INFO_PRINTF1(_L("ResourceCountMarkStart()"));
sl@0
   570
	}
sl@0
   571
sl@0
   572
void CT_FsData::DoCmdResourceCountMarkEnd()
sl@0
   573
/** Ends resource count checking */
sl@0
   574
	{
sl@0
   575
	iFs->ResourceCountMarkEnd();
sl@0
   576
	INFO_PRINTF1(_L("ResourceCountMarkEnd()"));
sl@0
   577
	}
sl@0
   578
sl@0
   579
void CT_FsData::DoCmdResourceCount(const TDesC& aSection)
sl@0
   580
/** Gets the number of currently open resources */
sl@0
   581
	{
sl@0
   582
	TInt	resources = iFs->ResourceCount();//Number of resources currently opened
sl@0
   583
	INFO_PRINTF2(_L("ResourceCount() = %d"), resources);
sl@0
   584
sl@0
   585
	TInt expectedValue = 0; //Number of resources from config
sl@0
   586
	if(GetIntFromConfig(aSection, KResources, expectedValue))
sl@0
   587
		{
sl@0
   588
		if (expectedValue != resources)
sl@0
   589
			{
sl@0
   590
			ERR_PRINTF3(_L("ResourceCount() %d != %d expected value"), resources, expectedValue);
sl@0
   591
			SetBlockResult(EFail);
sl@0
   592
			}
sl@0
   593
		}
sl@0
   594
	}
sl@0
   595
sl@0
   596
void CT_FsData::DoCmdGetNotifyUser(const TDesC& aSection)
sl@0
   597
/** Tests whether user notification of file read or write failure is in effect */
sl@0
   598
	{
sl@0
   599
	TBool	actual = iFs->GetNotifyUser();
sl@0
   600
	INFO_PRINTF2(_L("iFs->GetNotifyUser() %d"), actual);
sl@0
   601
sl@0
   602
	TBool expected = EFalse;
sl@0
   603
	if ( GET_OPTIONAL_BOOL_PARAMETER(KNotify, aSection, expected) )
sl@0
   604
		{
sl@0
   605
		if ( expected!=actual )
sl@0
   606
			{
sl@0
   607
			ERR_PRINTF1(_L("Expected result does not match actual"));
sl@0
   608
			SetBlockResult(EFail);
sl@0
   609
			}
sl@0
   610
		}
sl@0
   611
	}
sl@0
   612
sl@0
   613
void CT_FsData::DoCmdSetNotifyUser(const TDesC& aSection)
sl@0
   614
/** Sets whether the user should be notified of file read or write failure */
sl@0
   615
	{
sl@0
   616
	TBool notify = EFalse;
sl@0
   617
sl@0
   618
	if(GET_MANDATORY_BOOL_PARAMETER(KNotify, aSection, notify))
sl@0
   619
		{
sl@0
   620
		iFs->SetNotifyUser(notify);
sl@0
   621
		TPtrC val = notify ? _L("TRUE") : _L("FALSE");
sl@0
   622
		INFO_PRINTF2(_L("SetNotifyUser() %S"), &val);
sl@0
   623
		}
sl@0
   624
sl@0
   625
sl@0
   626
	}
sl@0
   627
sl@0
   628
void CT_FsData::DoCmdLoaderHeapFunctionL(const TDesC& aSection)
sl@0
   629
/** returns KErrNotSupported*/
sl@0
   630
	{
sl@0
   631
	TPtrC	name;
sl@0
   632
	TAny*	param1 = NULL;
sl@0
   633
	if(GetStringFromConfig(aSection, KParam1(), name))
sl@0
   634
		{
sl@0
   635
			//param1 = iDataDictionary->GetObject(name);
sl@0
   636
		}
sl@0
   637
sl@0
   638
	TAny* param2 = NULL;
sl@0
   639
	if(GetStringFromConfig(aSection, KParam2(), name))
sl@0
   640
		{
sl@0
   641
			//param2 = iDataDictionary->GetObjectL(name);
sl@0
   642
		}
sl@0
   643
sl@0
   644
	TInt	functionId = 0;
sl@0
   645
	if(GET_MANDATORY_INT_PARAMETER(KFunctionId(), aSection, functionId))
sl@0
   646
		{
sl@0
   647
		TInt err = iFs->LoaderHeapFunction(functionId, param1, param2);
sl@0
   648
		if( err!=KErrNone )
sl@0
   649
			{
sl@0
   650
			ERR_PRINTF2(_L("LoaderHeapFunction() ERROR: %d"), err);
sl@0
   651
			SetError(err);
sl@0
   652
			}
sl@0
   653
		}
sl@0
   654
	}
sl@0
   655
sl@0
   656
void CT_FsData::DoCmdSetNotifyChange(const TDesC& aSection)
sl@0
   657
/** Enables/Disables change notification on a per-session basis. */
sl@0
   658
	{
sl@0
   659
sl@0
   660
	TBool notify = EFalse;
sl@0
   661
sl@0
   662
	if(GET_MANDATORY_BOOL_PARAMETER(KNotify, aSection, notify))
sl@0
   663
		{
sl@0
   664
		TInt err = iFs->SetNotifyChange(notify);
sl@0
   665
sl@0
   666
		TPtrC val = notify ? _L("TRUE") : _L("FALSE");
sl@0
   667
		if (err == KErrNone)
sl@0
   668
			{
sl@0
   669
			INFO_PRINTF2(_L("SetNotifyChange() %S"), &val);
sl@0
   670
			}
sl@0
   671
		else
sl@0
   672
			{
sl@0
   673
			ERR_PRINTF3(_L("SetNotifyChange() %S, Error: %d"), &val, err);
sl@0
   674
			SetError(err);
sl@0
   675
			}
sl@0
   676
		}
sl@0
   677
	}
sl@0
   678
sl@0
   679
void CT_FsData::DoCmdInitialisePropertiesFile(const TDesC& aSection)
sl@0
   680
/** Sets the F32 properties file ONLY in ESTART */
sl@0
   681
	{
sl@0
   682
	TPtrC tempStr;
sl@0
   683
	if(GET_MANDATORY_STRING_PARAMETER(KFile, aSection, tempStr))
sl@0
   684
		{
sl@0
   685
		TBuf8<KBufferStringLength>	buffer;
sl@0
   686
		buffer.Copy(tempStr);
sl@0
   687
		TPtrC8						iniFilePtr(buffer);
sl@0
   688
		INFO_PRINTF2(_L("InitialisePropertiesFile() %S"), &tempStr);
sl@0
   689
sl@0
   690
		TInt	err = iFs ->InitialisePropertiesFile(iniFilePtr);
sl@0
   691
		if (err != KErrNone)
sl@0
   692
			{
sl@0
   693
			ERR_PRINTF2(_L("InitialisePropertiesFile() Error: %d"), err);
sl@0
   694
			SetError(err);
sl@0
   695
			}
sl@0
   696
		}
sl@0
   697
	}
sl@0
   698
sl@0
   699
void CT_FsData::RunL(CActive* aActive, TInt aIndex)
sl@0
   700
	{
sl@0
   701
	INFO_PRINTF1(_L("CT_FsData::RunL Called"));
sl@0
   702
	TBool	foundActiveObject = EFalse;
sl@0
   703
	TInt	index=0;
sl@0
   704
	TInt	count=0;
sl@0
   705
	TBool	completed=ETrue;
sl@0
   706
sl@0
   707
	// See if it is in iNotifyChange
sl@0
   708
	count=iNotifyChange.Count();
sl@0
   709
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
   710
 		{
sl@0
   711
 		if( aActive == iNotifyChange[index] )
sl@0
   712
			{
sl@0
   713
			INFO_PRINTF1(_L("RunL iNotifyChange called"));
sl@0
   714
			foundActiveObject = ETrue;
sl@0
   715
			if ( iNotifyChange[index]->DecCount()>0 )
sl@0
   716
				{
sl@0
   717
				completed=EFalse;
sl@0
   718
				iNotifyChange[index]->Activate();
sl@0
   719
				}
sl@0
   720
			else
sl@0
   721
				{
sl@0
   722
				iNotifyChange.Remove(index);
sl@0
   723
				}
sl@0
   724
	 		}
sl@0
   725
		}
sl@0
   726
sl@0
   727
	// See if it is in iNotifyDiskSpace
sl@0
   728
	count=iNotifyDiskSpace.Count();
sl@0
   729
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
   730
 		{
sl@0
   731
 		if( aActive == iNotifyDiskSpace[index] )
sl@0
   732
			{
sl@0
   733
			INFO_PRINTF1(_L("RunL iNotifyDiskSpace called"));
sl@0
   734
			foundActiveObject = ETrue;
sl@0
   735
			iNotifyDiskSpace.Remove(index);
sl@0
   736
	 		}
sl@0
   737
		}
sl@0
   738
sl@0
   739
	// See if it is in iNotifyDismount
sl@0
   740
	count=iNotifyDismount.Count();
sl@0
   741
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
   742
 		{
sl@0
   743
 		if( aActive == iNotifyDismount[index] )
sl@0
   744
			{
sl@0
   745
			INFO_PRINTF1(_L("RunL iNotifyDismount called"));
sl@0
   746
			foundActiveObject = ETrue;
sl@0
   747
			iNotifyDismount.Remove(index);
sl@0
   748
	 		}
sl@0
   749
		}
sl@0
   750
sl@0
   751
	// See if it is in iStartupInitComplete
sl@0
   752
	count=iStartupInitComplete.Count();
sl@0
   753
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
   754
 		{
sl@0
   755
 		if( aActive == iStartupInitComplete[index] )
sl@0
   756
			{
sl@0
   757
			INFO_PRINTF1(_L("RunL iStartupInitComplete called"));
sl@0
   758
			foundActiveObject = ETrue;
sl@0
   759
			iStartupInitComplete.Remove(index);
sl@0
   760
	 		}
sl@0
   761
		}
sl@0
   762
sl@0
   763
 	if( foundActiveObject )
sl@0
   764
 		{
sl@0
   765
		TInt	err = aActive->iStatus.Int();
sl@0
   766
		if( err != KErrNone )
sl@0
   767
			{
sl@0
   768
			ERR_PRINTF2(_L("RunL Error %d"), err);
sl@0
   769
			SetAsyncError( aIndex, err );
sl@0
   770
			}
sl@0
   771
sl@0
   772
		if ( completed )
sl@0
   773
			{
sl@0
   774
			// Reset the outstanding request state
sl@0
   775
			delete aActive;
sl@0
   776
			DecOutstanding();
sl@0
   777
			}
sl@0
   778
		}
sl@0
   779
	else
sl@0
   780
		{
sl@0
   781
 		ERR_PRINTF1(_L("Stray RunL signal"));
sl@0
   782
 		SetBlockResult(EFail);
sl@0
   783
		}
sl@0
   784
	}
sl@0
   785
sl@0
   786
void CT_FsData::DoCancel(CActive* aActive, TInt aIndex)
sl@0
   787
	{
sl@0
   788
	TBool	foundActiveObject = EFalse;
sl@0
   789
sl@0
   790
	TInt	index=0;
sl@0
   791
	TInt	count=0;
sl@0
   792
sl@0
   793
	// See if it is in iNotifyChange
sl@0
   794
	count=iNotifyChange.Count();
sl@0
   795
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
   796
 		{
sl@0
   797
 		if( aActive == iNotifyChange[index] )
sl@0
   798
			{
sl@0
   799
			INFO_PRINTF1(_L("DoCancel iNotifyChange called"));
sl@0
   800
			foundActiveObject = ETrue;
sl@0
   801
			iNotifyChange.Remove(index);
sl@0
   802
	 		}
sl@0
   803
		}
sl@0
   804
sl@0
   805
	// See if it is in iNotifyDiskSpace
sl@0
   806
	count=iNotifyDiskSpace.Count();
sl@0
   807
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
   808
 		{
sl@0
   809
 		if( aActive == iNotifyDiskSpace[index] )
sl@0
   810
			{
sl@0
   811
			INFO_PRINTF1(_L("DoCancel iNotifyDiskSpace called"));
sl@0
   812
			foundActiveObject = ETrue;
sl@0
   813
			iNotifyDiskSpace.Remove(index);
sl@0
   814
	 		}
sl@0
   815
		}
sl@0
   816
sl@0
   817
	// See if it is in iNotifyDismount
sl@0
   818
	count=iNotifyDismount.Count();
sl@0
   819
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
   820
 		{
sl@0
   821
 		if( aActive == iNotifyDismount[index] )
sl@0
   822
			{
sl@0
   823
			INFO_PRINTF1(_L("DoCancel iNotifyDismount called"));
sl@0
   824
			foundActiveObject = ETrue;
sl@0
   825
			iNotifyDismount.Remove(index);
sl@0
   826
	 		}
sl@0
   827
		}
sl@0
   828
sl@0
   829
	// See if it is in iStartupInitComplete
sl@0
   830
	count=iStartupInitComplete.Count();
sl@0
   831
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
   832
 		{
sl@0
   833
 		if( aActive == iStartupInitComplete[index] )
sl@0
   834
			{
sl@0
   835
			INFO_PRINTF1(_L("DoCancel iStartupInitComplete called"));
sl@0
   836
			foundActiveObject = ETrue;
sl@0
   837
			iStartupInitComplete.Remove(index);
sl@0
   838
	 		}
sl@0
   839
		}
sl@0
   840
sl@0
   841
 	if( foundActiveObject )
sl@0
   842
 		{
sl@0
   843
		TInt	err = aActive->iStatus.Int();
sl@0
   844
		if( err != KErrNone )
sl@0
   845
			{
sl@0
   846
			ERR_PRINTF2(_L("DoCancel Error %d"), err);
sl@0
   847
			SetAsyncError( aIndex, err );
sl@0
   848
			}
sl@0
   849
sl@0
   850
		// Reset the outstanding request state
sl@0
   851
		DecOutstanding();
sl@0
   852
sl@0
   853
		delete aActive;
sl@0
   854
		}
sl@0
   855
	else
sl@0
   856
		{
sl@0
   857
 		ERR_PRINTF1(_L("Stray DoCancel signal"));
sl@0
   858
 		SetBlockResult(EFail);
sl@0
   859
		}
sl@0
   860
	}
sl@0
   861
TBool CT_FsData::ConvertToNotifyType(const TDesC& aNotifyTypeStr, TNotifyType& aNotifyType)
sl@0
   862
{
sl@0
   863
	TBool ret = ETrue;
sl@0
   864
	if(aNotifyTypeStr == _L("ENotifyAll"))
sl@0
   865
		{
sl@0
   866
		aNotifyType = ENotifyAll;
sl@0
   867
		}
sl@0
   868
	else if(aNotifyTypeStr == _L("ENotifyEntry"))
sl@0
   869
		{
sl@0
   870
		aNotifyType = ENotifyEntry;
sl@0
   871
		}
sl@0
   872
	else if(aNotifyTypeStr == _L("ENotifyFile"))
sl@0
   873
		{
sl@0
   874
		aNotifyType = ENotifyFile;
sl@0
   875
		}
sl@0
   876
	else if(aNotifyTypeStr == _L("ENotifyDir"))
sl@0
   877
		{
sl@0
   878
		aNotifyType = ENotifyDir;
sl@0
   879
		}
sl@0
   880
	else if(aNotifyTypeStr == _L("ENotifyAttributes"))
sl@0
   881
		{
sl@0
   882
		aNotifyType = ENotifyAttributes;
sl@0
   883
		}
sl@0
   884
	else if(aNotifyTypeStr == _L("ENotifyWrite"))
sl@0
   885
		{
sl@0
   886
		aNotifyType = ENotifyWrite;
sl@0
   887
		}
sl@0
   888
	else if(aNotifyTypeStr == _L("ENotifyDisk"))
sl@0
   889
		{
sl@0
   890
		aNotifyType = ENotifyDisk;
sl@0
   891
		}
sl@0
   892
	//For COnverting data ENotifyFile|ENotifyDir
sl@0
   893
	else
sl@0
   894
		{
sl@0
   895
		TInt	location=aNotifyTypeStr.Match(_L("*|*"));
sl@0
   896
		if( location!=KErrNotFound )
sl@0
   897
			{
sl@0
   898
			//Converting Left part of the data
sl@0
   899
			TPtrC		tempStr=aNotifyTypeStr.Left(location);
sl@0
   900
			ret=ConvertToNotifyType(tempStr, aNotifyType);
sl@0
   901
sl@0
   902
			//Converting right data can be with another "|"
sl@0
   903
			tempStr.Set(aNotifyTypeStr.Mid(location+1));
sl@0
   904
sl@0
   905
			TNotifyType	notifyTypeTmp;
sl@0
   906
			if ( ConvertToNotifyType(tempStr, notifyTypeTmp) )
sl@0
   907
				{
sl@0
   908
				aNotifyType =(TNotifyType)((TInt)aNotifyType|(TInt)notifyTypeTmp);
sl@0
   909
				}
sl@0
   910
			else
sl@0
   911
				{
sl@0
   912
				ret = EFalse;
sl@0
   913
				}
sl@0
   914
			}
sl@0
   915
		else
sl@0
   916
			{
sl@0
   917
			ret = EFalse;
sl@0
   918
			}
sl@0
   919
		}
sl@0
   920
sl@0
   921
	return ret;
sl@0
   922
	}