os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_FileData.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_FileData
sl@0
    24
*/
sl@0
    25
sl@0
    26
//	User includes
sl@0
    27
#include "T_FileData.h"
sl@0
    28
sl@0
    29
sl@0
    30
/*@{*/
sl@0
    31
///	Parameters
sl@0
    32
_LIT(KFile,								"file");
sl@0
    33
_LIT(KUParamPath,						"path");
sl@0
    34
_LIT(KUParamName,						"name");
sl@0
    35
_LIT(KRFsName,							"RFs");
sl@0
    36
_LIT(KFileMode,							"file_mode");
sl@0
    37
_LIT(KUParamExpectedString,				"expected_string");
sl@0
    38
_LIT(KUParamAsync,						"async");
sl@0
    39
_LIT(KUParamBufferLength,				"buffer_length");
sl@0
    40
_LIT(KUParamLength,						"length");
sl@0
    41
_LIT(KUParamStartPos,					"start_pos");
sl@0
    42
_LIT(KUParamEndPos,						"end_pos");
sl@0
    43
_LIT(KUParamUsage,						"usage");
sl@0
    44
_LIT(KUParamPos,						"position");
sl@0
    45
_LIT(KSeek, 							"seek");
sl@0
    46
_LIT(KUParamCancelAll,					"cancel_all");
sl@0
    47
_LIT(KUParamData, 						"datawrite");
sl@0
    48
_LIT(KUParamSize, 						"size");
sl@0
    49
_LIT(KUParamExpectedSize,				"expected_size");
sl@0
    50
_LIT(KUParamCompareValue,				"compare_value");
sl@0
    51
_LIT(KUParamSetAttMask,					"set_att_mask");
sl@0
    52
_LIT(KUParamClearAttMask, 				"clear_att_mask");
sl@0
    53
_LIT(KUParamDate, 						"date");
sl@0
    54
_LIT(KFileObjectName,					"file_object_name");
sl@0
    55
_LIT(KUParamOwnerType,					"owner_type");
sl@0
    56
_LIT(KUParamComparePath,				"compare_path");
sl@0
    57
sl@0
    58
// OwnerType
sl@0
    59
sl@0
    60
_LIT(KEOwnerProcess, 					"EOwnerProcess");
sl@0
    61
_LIT(KEOwnerThread, 					"EOwnerThread");
sl@0
    62
sl@0
    63
// Block Usage
sl@0
    64
sl@0
    65
_LIT(KEBlockMapUsagePaging, 			"EBlockMapUsagePaging");
sl@0
    66
_LIT(KETestDebug, 						"ETestDebug");
sl@0
    67
sl@0
    68
// FileMode
sl@0
    69
_LIT(KEFileShareExclusive,	 			"EFileShareExclusive");
sl@0
    70
_LIT(KEFileShareReadersOnly,	 		"EFileShareReadersOnly");
sl@0
    71
_LIT(KEFileShareAny,	 				"EFileShareAny");
sl@0
    72
_LIT(KEFileShareReadersOrWriters,	 	"EFileShareReadersOrWriters");
sl@0
    73
_LIT(KEFileStream,	 					"EFileStream");
sl@0
    74
_LIT(KEFileStreamText,					"EFileStreamText");
sl@0
    75
_LIT(KEFileRead,	 					"EFileRead");
sl@0
    76
_LIT(KEFileWrite,						"EFileWrite");
sl@0
    77
_LIT(KEFileReadAsyncAll,	 			"EFileReadAsyncAll");
sl@0
    78
sl@0
    79
sl@0
    80
// Seek
sl@0
    81
_LIT(KESeekStart,						"ESeekStart");
sl@0
    82
_LIT(KESeekCurrent,						"ESeekCurrent");
sl@0
    83
_LIT(KESeekEnd,							"ESeekEnd");
sl@0
    84
sl@0
    85
///	Commands
sl@0
    86
_LIT(KCmdNew,							"new");
sl@0
    87
_LIT(KCmdClose,							"Close");
sl@0
    88
_LIT(KCmdDestructor,					"~");
sl@0
    89
_LIT(KCmdBlockMap,						"BlockMap");
sl@0
    90
_LIT(KCmdOpen,							"Open");
sl@0
    91
_LIT(KCmdCreate,						"Create");
sl@0
    92
_LIT(KCmdWrite,							"Write");
sl@0
    93
_LIT(KCmdReplace, 						"Replace");
sl@0
    94
_LIT(KCmdRead,							"Read");
sl@0
    95
_LIT(KCmdFlush,							"Flush");
sl@0
    96
_LIT(KCmdTemp,							"Temp");
sl@0
    97
_LIT(KCmdRename,						"Rename");
sl@0
    98
_LIT(KCmdSeek,							"Seek");
sl@0
    99
_LIT(KCmdReadCancel,					"ReadCancel");
sl@0
   100
_LIT(KCmdLock,							"Lock");
sl@0
   101
_LIT(KCmdUnLock,						"UnLock");
sl@0
   102
_LIT(KCmdSize, 							"Size");
sl@0
   103
_LIT(KCmdSetSize, 						"SetSize");
sl@0
   104
_LIT(KCmdAtt,							"Att");
sl@0
   105
_LIT(KCmdSetAtt,						"SetAtt");
sl@0
   106
_LIT(KCmdModified, 						"Modified");
sl@0
   107
_LIT(KCmdSetModified,					"SetModified");
sl@0
   108
_LIT(KCmdSet,							"Set");
sl@0
   109
_LIT(KCmdChangeMode, 					"ChangeMode");
sl@0
   110
_LIT(KCmdDrive,							"Drive");
sl@0
   111
_LIT(KCmdDuplicate, 					"Duplicate");
sl@0
   112
_LIT(KCmdName,							"Name");
sl@0
   113
_LIT(KCmdFullName,						"FullName");
sl@0
   114
sl@0
   115
sl@0
   116
//Attributes
sl@0
   117
_LIT(KDEntryAttNormal,  				"KEntryAttNormal");
sl@0
   118
_LIT(KDEntryAttReadOnly, 				"KEntryAttReadOnly");
sl@0
   119
_LIT(KDEntryAttArchive,					"KEntryAttArchive");
sl@0
   120
_LIT(KDEntryAttHidden,					"KEntryAttHidden");
sl@0
   121
_LIT(KDEntryAttSystem,					"KEntryAttSystem");
sl@0
   122
_LIT(KDEntryAttVolume,					"KEntryAttVolume");
sl@0
   123
_LIT(KDEntryAttDir,						"KEntryAttDir");
sl@0
   124
_LIT(KDEntryAttXIP,						"KEntryAttXIP");
sl@0
   125
_LIT(KDEntryAttRemote,					"KEntryAttRemote");
sl@0
   126
sl@0
   127
//constants
sl@0
   128
const TInt KDefaultDescSize = 64;
sl@0
   129
sl@0
   130
/*@}*/
sl@0
   131
sl@0
   132
CT_FileData* CT_FileData::NewL()
sl@0
   133
/**
sl@0
   134
 * Two phase constructor
sl@0
   135
 */
sl@0
   136
	{
sl@0
   137
	CT_FileData* ret = new (ELeave) CT_FileData();
sl@0
   138
	CleanupStack::PushL(ret);
sl@0
   139
	ret->ConstructL();
sl@0
   140
	CleanupStack::Pop(ret);
sl@0
   141
	return ret;
sl@0
   142
	}
sl@0
   143
sl@0
   144
CT_FileData::CT_FileData()
sl@0
   145
/**
sl@0
   146
 * Protected constructor. First phase construction
sl@0
   147
 */
sl@0
   148
:	iFile(NULL)
sl@0
   149
	{
sl@0
   150
	}
sl@0
   151
sl@0
   152
void CT_FileData::ConstructL()
sl@0
   153
/**
sl@0
   154
 * Protected constructor. Second phase construction
sl@0
   155
 */
sl@0
   156
	{
sl@0
   157
	iFileOpened = EFalse;
sl@0
   158
	}
sl@0
   159
sl@0
   160
CT_FileData::~CT_FileData()
sl@0
   161
/**
sl@0
   162
 * Destructor.
sl@0
   163
 */
sl@0
   164
	{
sl@0
   165
	DoCleanup();
sl@0
   166
	}
sl@0
   167
sl@0
   168
void CT_FileData::DoCleanup()
sl@0
   169
/**
sl@0
   170
 * Contains cleanup implementation
sl@0
   171
 */
sl@0
   172
	{
sl@0
   173
	//Deleting RFile.
sl@0
   174
	if(iFile != NULL)
sl@0
   175
		{
sl@0
   176
		INFO_PRINTF1(_L("Deleting current RFile"));
sl@0
   177
		delete iFile;
sl@0
   178
		iFile = NULL;
sl@0
   179
		}
sl@0
   180
	iReadCallbackArray.Close();
sl@0
   181
	iWriteCallbackArray.Close();
sl@0
   182
	iFlushCallbackArray.Close();
sl@0
   183
	}
sl@0
   184
sl@0
   185
TAny* CT_FileData::GetObject()
sl@0
   186
/**
sl@0
   187
 * Return a pointer to the object that the data wraps
sl@0
   188
 *
sl@0
   189
 * @return pointer to the object that the data wraps
sl@0
   190
 */
sl@0
   191
	{
sl@0
   192
	return iFile;
sl@0
   193
	}
sl@0
   194
sl@0
   195
TBool CT_FileData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
sl@0
   196
/**
sl@0
   197
 * Process a command read from the ini file
sl@0
   198
 *
sl@0
   199
 * @param aCommand	the command to process
sl@0
   200
 * @param aSection		the entry in the ini file requiring the command to be processed
sl@0
   201
 * @param aAsyncErrorIndex the index of asynchronous command error code belongs to.
sl@0
   202
 *
sl@0
   203
 * @return ETrue if the command is processed
sl@0
   204
 */
sl@0
   205
	{
sl@0
   206
	TBool retVal = ETrue;
sl@0
   207
sl@0
   208
	if (aCommand == KCmdNew)
sl@0
   209
		{
sl@0
   210
		DoCmdNewL();
sl@0
   211
		}
sl@0
   212
	else if (aCommand == KCmdDestructor)
sl@0
   213
		{
sl@0
   214
		DoCmdDestructor();
sl@0
   215
		}
sl@0
   216
	else if (aCommand == KCmdOpen)
sl@0
   217
		{
sl@0
   218
		DoCmdOpenL(aSection);
sl@0
   219
		}
sl@0
   220
	else if (aCommand == KCmdWrite)
sl@0
   221
		{
sl@0
   222
		DoCmdWriteL(aSection, aAsyncErrorIndex);
sl@0
   223
		}
sl@0
   224
	else if (aCommand == KCmdClose)
sl@0
   225
		{
sl@0
   226
		DoCmdClose();
sl@0
   227
		}
sl@0
   228
	else if (aCommand == KCmdCreate)
sl@0
   229
		{
sl@0
   230
		DoCmdCreateL(aSection);
sl@0
   231
		}
sl@0
   232
	else if (aCommand == KCmdReplace)
sl@0
   233
		{
sl@0
   234
		DoCmdReplaceL(aSection);
sl@0
   235
		}
sl@0
   236
	else if (aCommand == KCmdRead)
sl@0
   237
		{
sl@0
   238
		DoCmdReadL(aSection, aAsyncErrorIndex);
sl@0
   239
		}	
sl@0
   240
	else if (aCommand == KCmdFlush)
sl@0
   241
		{
sl@0
   242
		DoCmdFlushL(aSection, aAsyncErrorIndex);
sl@0
   243
		}
sl@0
   244
	else if (aCommand == KCmdTemp)
sl@0
   245
		{
sl@0
   246
		DoCmdTempL(aSection);
sl@0
   247
		}	
sl@0
   248
	else if (aCommand == KCmdRename)
sl@0
   249
		{
sl@0
   250
		DoCmdRenameL(aSection);
sl@0
   251
		}
sl@0
   252
	else if (aCommand == KCmdSeek)
sl@0
   253
		{
sl@0
   254
		DoCmdSeekL(aSection);
sl@0
   255
		}
sl@0
   256
	else if (aCommand == KCmdReadCancel)
sl@0
   257
		{
sl@0
   258
		DoCmdReadCancelL(aSection);
sl@0
   259
		}	
sl@0
   260
	else if (aCommand == KCmdLock)
sl@0
   261
		{
sl@0
   262
		DoCmdLockL(aSection);
sl@0
   263
		}
sl@0
   264
	else if (aCommand == KCmdUnLock)
sl@0
   265
		{
sl@0
   266
		DoCmdUnLockL(aSection);
sl@0
   267
		}
sl@0
   268
	else if (aCommand == KCmdSize)
sl@0
   269
		{
sl@0
   270
		DoCmdSizeL(aSection);
sl@0
   271
		}		
sl@0
   272
	else if (aCommand == KCmdSetSize)
sl@0
   273
		{
sl@0
   274
		DoCmdSetSizeL(aSection);
sl@0
   275
		}
sl@0
   276
	else if (aCommand == KCmdAtt)
sl@0
   277
		{
sl@0
   278
		DoCmdAttL(aSection);
sl@0
   279
		}		
sl@0
   280
	else if (aCommand == KCmdSetAtt)
sl@0
   281
		{
sl@0
   282
		DoCmdSetAttL(aSection);
sl@0
   283
		}		
sl@0
   284
	else if (aCommand == KCmdModified)
sl@0
   285
		{
sl@0
   286
		DoCmdModifiedL(aSection);
sl@0
   287
		}
sl@0
   288
	else if (aCommand == KCmdSetModified)
sl@0
   289
		{
sl@0
   290
		DoCmdSetModifiedL(aSection);
sl@0
   291
		}
sl@0
   292
	else if (aCommand == KCmdSet)
sl@0
   293
		{
sl@0
   294
		DoCmdSetL(aSection);
sl@0
   295
		}
sl@0
   296
	else if (aCommand == KCmdChangeMode)
sl@0
   297
		{
sl@0
   298
		DoCmdChangeModeL(aSection);
sl@0
   299
		}
sl@0
   300
	else if (aCommand == KCmdDrive)
sl@0
   301
		{
sl@0
   302
		DoCmdDriveL(aSection);
sl@0
   303
		}
sl@0
   304
	else if (aCommand == KCmdName)
sl@0
   305
		{
sl@0
   306
		DoCmdNameL(aSection);
sl@0
   307
		}
sl@0
   308
	else if (aCommand == KCmdDuplicate)
sl@0
   309
		{
sl@0
   310
		DoCmdDuplicateL(aSection);
sl@0
   311
		}
sl@0
   312
	else if (aCommand == KCmdFullName)
sl@0
   313
		{
sl@0
   314
		DoCmdFullName(aSection);
sl@0
   315
		}
sl@0
   316
	else if (aCommand == KCmdBlockMap)
sl@0
   317
		{
sl@0
   318
		DoCmdBlockMap(aSection);
sl@0
   319
		}
sl@0
   320
	else
sl@0
   321
		{
sl@0
   322
		retVal = EFalse;
sl@0
   323
		}
sl@0
   324
	return retVal;
sl@0
   325
	}
sl@0
   326
sl@0
   327
void CT_FileData::DoCmdNewL()
sl@0
   328
/** Creates new RFile class instance */
sl@0
   329
	{
sl@0
   330
	//Deletes previous RFile class instance if it was already created.
sl@0
   331
	DoCleanup();
sl@0
   332
sl@0
   333
	INFO_PRINTF1(_L("Create new RFile class instance"));
sl@0
   334
sl@0
   335
	// do create
sl@0
   336
	TRAPD(err, iFile = new (ELeave) RFile());
sl@0
   337
	if ( err!=KErrNone )
sl@0
   338
		{
sl@0
   339
		ERR_PRINTF2(_L("Error returned by New()%d"), err);
sl@0
   340
		SetError(err);
sl@0
   341
		}
sl@0
   342
	}
sl@0
   343
sl@0
   344
void CT_FileData::DoCmdDestructor()
sl@0
   345
/** Destroy RFile the object */
sl@0
   346
	{
sl@0
   347
	DoCleanup();
sl@0
   348
	}
sl@0
   349
sl@0
   350
void CT_FileData::DoCmdOpenL(const TDesC& aSection)
sl@0
   351
/**	Opens files */
sl@0
   352
	{
sl@0
   353
	RFs*	rfsObject=NULL;
sl@0
   354
	TPtrC	rfsObjectName;
sl@0
   355
	TBool	dataOk=GET_MANDATORY_STRING_PARAMETER(KRFsName(), aSection, rfsObjectName);
sl@0
   356
	if ( dataOk )
sl@0
   357
		{
sl@0
   358
		rfsObject=(RFs*)GetDataObjectL(rfsObjectName);
sl@0
   359
		}
sl@0
   360
sl@0
   361
	TPtrC	filePath;
sl@0
   362
	if ( !GET_MANDATORY_STRING_PARAMETER(KFile(), aSection, filePath) )
sl@0
   363
		{
sl@0
   364
		dataOk=EFalse;
sl@0
   365
		}
sl@0
   366
sl@0
   367
	TUint	fileMode = 0;
sl@0
   368
	if ( !GetFileModeL(KFileMode, aSection, fileMode) )
sl@0
   369
		{
sl@0
   370
		ERR_PRINTF2(_L("Open() error reading parameter. %S"), &KFileMode());
sl@0
   371
		SetBlockResult(EFail);
sl@0
   372
		dataOk=EFalse;
sl@0
   373
		}
sl@0
   374
sl@0
   375
	if ( dataOk )
sl@0
   376
		{
sl@0
   377
		if (rfsObject)
sl@0
   378
			{
sl@0
   379
			TInt	err = iFile->Open(*rfsObject, filePath, fileMode);
sl@0
   380
			if ( err!=KErrNone )
sl@0
   381
				{
sl@0
   382
				ERR_PRINTF2(_L("Open() failed with Error:%d"), err);
sl@0
   383
				SetError(err);
sl@0
   384
				}
sl@0
   385
			else
sl@0
   386
				{
sl@0
   387
				iFileOpened = true;
sl@0
   388
				}
sl@0
   389
			}
sl@0
   390
		else
sl@0
   391
			{
sl@0
   392
			ERR_PRINTF1(_L("RFs object is NULL"));
sl@0
   393
			SetBlockResult(EFail);
sl@0
   394
			}
sl@0
   395
		}
sl@0
   396
	}
sl@0
   397
sl@0
   398
sl@0
   399
void CT_FileData::DoCmdClose()
sl@0
   400
/** Close file	 */
sl@0
   401
	{
sl@0
   402
	INFO_PRINTF1(_L("Closing RFile"));
sl@0
   403
	iFile->Close();
sl@0
   404
	}
sl@0
   405
sl@0
   406
void CT_FileData::DoCmdCreateL(const TDesC& aSection)
sl@0
   407
/** create a new file */
sl@0
   408
	{
sl@0
   409
	RFs*	rfsObject=NULL;
sl@0
   410
	TPtrC	rfsObjectName;
sl@0
   411
	TBool	dataOk = ETrue;
sl@0
   412
	if ( GET_MANDATORY_STRING_PARAMETER(KRFsName, aSection, rfsObjectName) )
sl@0
   413
		{
sl@0
   414
		rfsObject=(RFs*)GetDataObjectL(rfsObjectName);
sl@0
   415
		}
sl@0
   416
	else
sl@0
   417
		{
sl@0
   418
		dataOk = EFalse;
sl@0
   419
		}
sl@0
   420
sl@0
   421
	//	Gets name of file from ini file.
sl@0
   422
	TPtrC	name;
sl@0
   423
	if ( !GET_MANDATORY_STRING_PARAMETER(KUParamName(), aSection, name) )
sl@0
   424
		{
sl@0
   425
		dataOk = EFalse;
sl@0
   426
		}
sl@0
   427
sl@0
   428
	TUint	fileMode = 0;
sl@0
   429
	if ( !GetFileModeL(KFileMode, aSection, fileMode) )
sl@0
   430
		{
sl@0
   431
		ERR_PRINTF2(_L("Create() error reading parameter. %S"), &KFileMode());
sl@0
   432
		SetBlockResult(EFail);
sl@0
   433
		dataOk = EFalse;
sl@0
   434
		}
sl@0
   435
sl@0
   436
	if ( dataOk )
sl@0
   437
		{
sl@0
   438
		//	Creates and opens a new file for writing.
sl@0
   439
		if (rfsObject)
sl@0
   440
			{
sl@0
   441
			TInt	err = iFile->Create(*rfsObject, name, fileMode);
sl@0
   442
			if ( err!=KErrNone )
sl@0
   443
				{
sl@0
   444
				ERR_PRINTF2(_L("Create(), error create() = %d"), err);
sl@0
   445
				SetError(err);
sl@0
   446
				}
sl@0
   447
			}
sl@0
   448
		else
sl@0
   449
			{
sl@0
   450
			ERR_PRINTF1(_L("RFs object is NULL"));
sl@0
   451
			SetBlockResult(EFail);
sl@0
   452
			}
sl@0
   453
		}
sl@0
   454
	}
sl@0
   455
	
sl@0
   456
void CT_FileData::DoCmdReplaceL(const TDesC& aSection)
sl@0
   457
/** replace a existing file or create new */
sl@0
   458
	{
sl@0
   459
	TPtrC rfsObjectName;
sl@0
   460
	RFs* rfsObject = NULL;
sl@0
   461
	
sl@0
   462
	TBool	dataOk = ETrue;
sl@0
   463
	if ( GET_MANDATORY_STRING_PARAMETER(KRFsName, aSection, rfsObjectName) )
sl@0
   464
		{
sl@0
   465
		rfsObject=(RFs*)GetDataObjectL(rfsObjectName);
sl@0
   466
		}
sl@0
   467
sl@0
   468
	//	Gets name of file from ini file.
sl@0
   469
	TPtrC path;
sl@0
   470
	if (!GET_MANDATORY_STRING_PARAMETER(KFile(), aSection, path))
sl@0
   471
		{
sl@0
   472
		dataOk = EFalse;
sl@0
   473
		}
sl@0
   474
	
sl@0
   475
	TUint fileMode = 0;
sl@0
   476
	if(!GetFileModeL(KFileMode, aSection, fileMode))
sl@0
   477
		{
sl@0
   478
		ERR_PRINTF2(_L("Replace() error reading parameter. %S"), &KFileMode());
sl@0
   479
		SetBlockResult(EFail);
sl@0
   480
		dataOk = EFalse;
sl@0
   481
		}
sl@0
   482
sl@0
   483
	//	Creates and opens a new file for writing.
sl@0
   484
	if ( dataOk )
sl@0
   485
		{
sl@0
   486
		//	Creates and opens a new file for writing.
sl@0
   487
		if (rfsObject)
sl@0
   488
			{
sl@0
   489
			TInt	err = iFile->Replace(*rfsObject, path, fileMode);
sl@0
   490
			if ( err!=KErrNone )
sl@0
   491
				{
sl@0
   492
				ERR_PRINTF2(_L("Replace() failed with error = %d"), err);
sl@0
   493
				SetError(err);
sl@0
   494
				}
sl@0
   495
			else
sl@0
   496
				{
sl@0
   497
				iFileOpened = ETrue;
sl@0
   498
				INFO_PRINTF2(_L("File: %S is replaced successfuly"), &path);				
sl@0
   499
				}
sl@0
   500
			}
sl@0
   501
		else
sl@0
   502
			{
sl@0
   503
			ERR_PRINTF1(_L("RFs object is NULL"));
sl@0
   504
			SetBlockResult(EFail);
sl@0
   505
			}
sl@0
   506
		}
sl@0
   507
sl@0
   508
	}	
sl@0
   509
sl@0
   510
void CT_FileData::DoCmdReadL(const TDesC& aSection, const TInt aAsyncErrorIndex)
sl@0
   511
/** wrapper for read commands */
sl@0
   512
	{
sl@0
   513
	TBool async = EFalse;
sl@0
   514
		if(GET_OPTIONAL_BOOL_PARAMETER(KUParamAsync, aSection, async))
sl@0
   515
			{
sl@0
   516
			if (async)
sl@0
   517
				{
sl@0
   518
				DoAsynchronousReadsL(aSection, aAsyncErrorIndex);	
sl@0
   519
				}
sl@0
   520
			else
sl@0
   521
				{
sl@0
   522
				DoSynchronousReadsL(aSection);
sl@0
   523
				}
sl@0
   524
			
sl@0
   525
			}
sl@0
   526
		else
sl@0
   527
			{
sl@0
   528
			DoSynchronousReadsL(aSection);
sl@0
   529
			}
sl@0
   530
	}
sl@0
   531
sl@0
   532
TBool CT_FileData::GetFileModeL(const TDesC& aParameterName, const TDesC& aSection, TUint& aFileMode)
sl@0
   533
/** process the filemode from ini  */
sl@0
   534
	{
sl@0
   535
	TBool ret = ETrue;
sl@0
   536
	
sl@0
   537
	TPtrC aModeStr;
sl@0
   538
	
sl@0
   539
	if(GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, aModeStr))
sl@0
   540
		{
sl@0
   541
		//break the file mode string to array of file modes
sl@0
   542
		//in case there's more than one filemode		
sl@0
   543
		RPointerArray<HBufC> fileModes = SplitL(aModeStr, "|");		
sl@0
   544
			
sl@0
   545
		for ( int i = 0 ; i < fileModes.Count() ; i++ )
sl@0
   546
			{
sl@0
   547
			if (*fileModes[i] == KEFileShareExclusive)
sl@0
   548
				{
sl@0
   549
				aFileMode = aFileMode | EFileShareExclusive ;
sl@0
   550
				}
sl@0
   551
			else if (*fileModes[i] ==  KEFileShareReadersOnly)
sl@0
   552
				{
sl@0
   553
				aFileMode = aFileMode | EFileShareReadersOnly;
sl@0
   554
				}
sl@0
   555
			else if (*fileModes[i] ==  KEFileShareAny)
sl@0
   556
				{
sl@0
   557
				aFileMode = aFileMode | EFileShareAny;
sl@0
   558
				}		
sl@0
   559
			else if (*fileModes[i] ==  KEFileShareReadersOrWriters)
sl@0
   560
				{
sl@0
   561
				aFileMode = aFileMode | EFileShareReadersOrWriters;
sl@0
   562
				}					
sl@0
   563
			else if (*fileModes[i] ==  KEFileStream)
sl@0
   564
				{
sl@0
   565
				aFileMode = aFileMode | EFileStream;
sl@0
   566
				}					
sl@0
   567
			else if (*fileModes[i] ==  KEFileStreamText)
sl@0
   568
				{
sl@0
   569
				aFileMode = aFileMode | EFileStreamText;
sl@0
   570
				}					
sl@0
   571
			else if (*fileModes[i] ==  KEFileRead)
sl@0
   572
				{
sl@0
   573
				aFileMode = aFileMode | EFileRead;
sl@0
   574
				}					
sl@0
   575
			else if (*fileModes[i] ==  KEFileWrite)
sl@0
   576
				{
sl@0
   577
				aFileMode = aFileMode | EFileWrite;
sl@0
   578
				}
sl@0
   579
			else if (*fileModes[i] ==  KEFileReadAsyncAll)
sl@0
   580
				{
sl@0
   581
				aFileMode = aFileMode | EFileReadAsyncAll;
sl@0
   582
				}
sl@0
   583
			else
sl@0
   584
				{
sl@0
   585
				aFileMode = EFileShareAny;
sl@0
   586
				ret = EFalse;
sl@0
   587
				}
sl@0
   588
			}
sl@0
   589
			
sl@0
   590
		for (int j=0 ; j<fileModes.Count() ; j++)
sl@0
   591
			{
sl@0
   592
			HBufC* temp = fileModes[j];
sl@0
   593
			delete temp;
sl@0
   594
			temp = NULL;
sl@0
   595
			}
sl@0
   596
			
sl@0
   597
		fileModes.Close();
sl@0
   598
		}
sl@0
   599
	else
sl@0
   600
		{
sl@0
   601
		ret = EFalse;
sl@0
   602
		}
sl@0
   603
sl@0
   604
	return ret;
sl@0
   605
	}
sl@0
   606
sl@0
   607
sl@0
   608
void CT_FileData::DoSynchronousReadsL(const TDesC& aSection)
sl@0
   609
/** process all synchronous reads */
sl@0
   610
	{	
sl@0
   611
	TInt length;
sl@0
   612
	TInt pos;
sl@0
   613
	
sl@0
   614
	HBufC8* filedata = NULL;	
sl@0
   615
	TInt bufferLength;
sl@0
   616
	
sl@0
   617
//get optional buffer length from ini file	
sl@0
   618
	if (GET_OPTIONAL_INT_PARAMETER(KUParamBufferLength, aSection, bufferLength))
sl@0
   619
		{
sl@0
   620
		filedata = HBufC8::NewLC(bufferLength);
sl@0
   621
		}
sl@0
   622
	else
sl@0
   623
		{
sl@0
   624
		filedata = HBufC8::NewLC(KDefaultDescSize);
sl@0
   625
		}
sl@0
   626
				
sl@0
   627
		
sl@0
   628
	TPtr8 filedataPtr = filedata->Des();
sl@0
   629
	TInt err = 0;
sl@0
   630
//devide which read to call, by switching between parameters fetched from ini file.	
sl@0
   631
	if(GET_OPTIONAL_INT_PARAMETER(KUParamLength, aSection, length))
sl@0
   632
		{
sl@0
   633
		if(GET_OPTIONAL_INT_PARAMETER(KUParamPos, aSection, pos))
sl@0
   634
			{
sl@0
   635
			INFO_PRINTF1(_L("calling RFile::Read(TInt& aPos, TDes8 &aData, TInt aLen)"));
sl@0
   636
			err = iFile->Read(pos, filedataPtr, length);
sl@0
   637
			HandleExpectedString(filedataPtr, aSection);
sl@0
   638
			}
sl@0
   639
		else
sl@0
   640
			{
sl@0
   641
			INFO_PRINTF1(_L("calling RFile::Read(TDes8 &aData, TInt aLen)"));
sl@0
   642
			err = iFile->Read(filedataPtr, length);
sl@0
   643
			HandleExpectedString(filedataPtr, aSection);
sl@0
   644
			}
sl@0
   645
		}
sl@0
   646
	else
sl@0
   647
		{
sl@0
   648
		if(GET_OPTIONAL_INT_PARAMETER(KUParamPos, aSection, pos))
sl@0
   649
			{
sl@0
   650
			INFO_PRINTF1(_L("calling RFile::Read(TInt& aPos, TDes8 &aData)"));
sl@0
   651
			err = iFile->Read(pos, filedataPtr);
sl@0
   652
			HandleExpectedString(filedataPtr, aSection);
sl@0
   653
			}
sl@0
   654
		else
sl@0
   655
			{
sl@0
   656
			INFO_PRINTF1(_L("calling RFile::Read(TDes8 &aData)"));
sl@0
   657
			err = iFile->Read(filedataPtr);
sl@0
   658
			HandleExpectedString(filedataPtr, aSection);
sl@0
   659
			}
sl@0
   660
		}
sl@0
   661
		
sl@0
   662
	TBuf<KDefaultDescSize> filedata16;
sl@0
   663
	filedata16.Copy(filedataPtr);
sl@0
   664
	INFO_PRINTF2(_L("read \"%S\" from file"), &filedata16);		
sl@0
   665
		
sl@0
   666
//did the read complete with error code?		
sl@0
   667
	if (err != KErrNone)
sl@0
   668
		{
sl@0
   669
		ERR_PRINTF2(_L("error executing synchronous read %d"), err);
sl@0
   670
		SetError(err);
sl@0
   671
		}
sl@0
   672
		
sl@0
   673
	CleanupStack::PopAndDestroy(1);		
sl@0
   674
		
sl@0
   675
	}
sl@0
   676
		
sl@0
   677
void CT_FileData::DoAsynchronousReadsL(const TDesC& aSection, const TInt aAsyncErrorIndex)
sl@0
   678
/**process all asynchronous reads */
sl@0
   679
	{
sl@0
   680
	TInt length;
sl@0
   681
	TInt pos;
sl@0
   682
	
sl@0
   683
	CT_FileActiveCallback* active = CT_FileActiveCallback::NewL(*this);
sl@0
   684
	iReadCallbackArray.Append(active);
sl@0
   685
		
sl@0
   686
	TInt bufferLength;
sl@0
   687
	
sl@0
   688
	//Get the buffer length, and create the buffer for activeCallback object
sl@0
   689
	if (GET_OPTIONAL_INT_PARAMETER(KUParamBufferLength, aSection, bufferLength))
sl@0
   690
		{
sl@0
   691
		active->CreateFileDataBufferL(bufferLength);
sl@0
   692
		}
sl@0
   693
	else
sl@0
   694
		{
sl@0
   695
		active->CreateFileDataBufferL(KDefaultDescSize);
sl@0
   696
		}	
sl@0
   697
		
sl@0
   698
	TPtr8 fileDataPtr = active->iFileData->Des();
sl@0
   699
		
sl@0
   700
	//decide which read to call	
sl@0
   701
	if(GET_OPTIONAL_INT_PARAMETER(KUParamLength, aSection, length))
sl@0
   702
		{
sl@0
   703
		if(GET_OPTIONAL_INT_PARAMETER(KUParamPos, aSection, pos))
sl@0
   704
			{
sl@0
   705
			INFO_PRINTF1(_L("calling RFile::Read(TInt& aPos, TDes8 &aData, TInt aLen, TRequestiStatus aiStatus)"));
sl@0
   706
			iFile->Read(pos, fileDataPtr, length,active->iStatus);
sl@0
   707
			}
sl@0
   708
		else
sl@0
   709
			{
sl@0
   710
			INFO_PRINTF1(_L("calling RFile::Read(TDes8 &aData, TInt aLen, TRequestiStatus aiStatus)"));
sl@0
   711
			iFile->Read(fileDataPtr, length, active->iStatus);
sl@0
   712
			}
sl@0
   713
		}
sl@0
   714
	else
sl@0
   715
		{
sl@0
   716
		if(GET_OPTIONAL_INT_PARAMETER(KUParamPos, aSection, pos))
sl@0
   717
			{
sl@0
   718
			INFO_PRINTF1(_L("calling RFile::Read(TInt& aPos, TDes8 &aData, TRequestiStatus aiStatus)"));
sl@0
   719
			iFile->Read(pos, fileDataPtr, active->iStatus);
sl@0
   720
			}
sl@0
   721
		else
sl@0
   722
			{
sl@0
   723
			INFO_PRINTF1(_L("calling RFile::Read(TDesC &aData, TRequestiStatus aiStatus)"));
sl@0
   724
			iFile->Read(fileDataPtr, active->iStatus);
sl@0
   725
			}
sl@0
   726
		}
sl@0
   727
		
sl@0
   728
	//acitvate callback object
sl@0
   729
	active->SetSection(aSection);
sl@0
   730
	active->Activate(aAsyncErrorIndex);
sl@0
   731
	IncOutstanding();
sl@0
   732
sl@0
   733
	}
sl@0
   734
	
sl@0
   735
	
sl@0
   736
void CT_FileData::HandleExpectedString(const TDesC& aReadedData, const TDesC& aSection)
sl@0
   737
/** compare the expected string with readed string, takes 16-bit parameter*/
sl@0
   738
	{
sl@0
   739
	TPtrC expectedString;
sl@0
   740
	if(GET_OPTIONAL_STRING_PARAMETER(KUParamExpectedString, aSection, expectedString))
sl@0
   741
		{
sl@0
   742
		if (aReadedData == expectedString)
sl@0
   743
			{
sl@0
   744
			INFO_PRINTF1(_L("expected string matches with the data read"));			
sl@0
   745
			}
sl@0
   746
		else
sl@0
   747
			{
sl@0
   748
			ERR_PRINTF1(_L("expected string does not match with the data read"));
sl@0
   749
			SetBlockResult(EFail);
sl@0
   750
			}
sl@0
   751
		}
sl@0
   752
	}
sl@0
   753
	
sl@0
   754
sl@0
   755
void CT_FileData::HandleExpectedString(const TDesC8& aReadedData, const TDesC& aSection)
sl@0
   756
/** compare the expected string with readed string, takes 16-bit parameter */
sl@0
   757
	{
sl@0
   758
	TBuf<KDefaultDescSize> readedData16;
sl@0
   759
	readedData16.Copy(aReadedData);
sl@0
   760
	TPtrC expectedString;
sl@0
   761
	if(GET_OPTIONAL_STRING_PARAMETER(KUParamExpectedString, aSection, expectedString))
sl@0
   762
		{
sl@0
   763
		if (readedData16 == expectedString)
sl@0
   764
			{
sl@0
   765
			INFO_PRINTF1(_L("expected string matches with the data read"));			
sl@0
   766
			}
sl@0
   767
		else
sl@0
   768
			{
sl@0
   769
			ERR_PRINTF1(_L("expected string does not match with the data read"));
sl@0
   770
			SetBlockResult(EFail);
sl@0
   771
			}
sl@0
   772
		}
sl@0
   773
	}		
sl@0
   774
	
sl@0
   775
	
sl@0
   776
void CT_FileData::DoCmdFlushL(const TDesC& aSection, const TInt aAsyncErrorIndex)
sl@0
   777
/** flush all the internal buffers to file */
sl@0
   778
	{
sl@0
   779
	TBool async = false;
sl@0
   780
	TInt err = 0;
sl@0
   781
	//get the parameter from ini, to decide which version of RFile::Flush to call
sl@0
   782
	GET_OPTIONAL_BOOL_PARAMETER(KUParamAsync, aSection, async);
sl@0
   783
	if (async == true)
sl@0
   784
		{		
sl@0
   785
		CActiveCallback* active = CActiveCallback::NewL(*this);
sl@0
   786
		iFlushCallbackArray.Append( active );
sl@0
   787
		iFile->Flush(active->iStatus);
sl@0
   788
		active->Activate(aAsyncErrorIndex);
sl@0
   789
		IncOutstanding();
sl@0
   790
		}
sl@0
   791
	else
sl@0
   792
		{
sl@0
   793
		err = iFile->Flush();
sl@0
   794
		if (err != KErrNone)
sl@0
   795
			{
sl@0
   796
			ERR_PRINTF2(_L("Flush() failed with error code. %d"), err);
sl@0
   797
			SetError(err);
sl@0
   798
			}
sl@0
   799
		else
sl@0
   800
			{
sl@0
   801
			INFO_PRINTF1(_L("Succesfully flushed the file"));
sl@0
   802
			}
sl@0
   803
		}	
sl@0
   804
	}	
sl@0
   805
	
sl@0
   806
sl@0
   807
void CT_FileData::DoCmdTempL(const TDesC& aSection)
sl@0
   808
/* create temporary file */
sl@0
   809
	{
sl@0
   810
	
sl@0
   811
	TPtrC rfsObjectName;
sl@0
   812
	RFs* rfsObject = NULL;
sl@0
   813
	
sl@0
   814
	TBool	dataOk=GET_MANDATORY_STRING_PARAMETER(KRFsName, aSection, rfsObjectName);
sl@0
   815
	if ( dataOk )
sl@0
   816
		{
sl@0
   817
		rfsObject=(RFs*)GetDataObjectL(rfsObjectName);
sl@0
   818
		}
sl@0
   819
sl@0
   820
	//	Gets name of file from ini file.
sl@0
   821
	TPtrC path;
sl@0
   822
	if (!GET_MANDATORY_STRING_PARAMETER(KUParamPath(), aSection, path))
sl@0
   823
		{
sl@0
   824
		dataOk=EFalse;
sl@0
   825
		}
sl@0
   826
	
sl@0
   827
	TUint fileMode = 0;
sl@0
   828
	if(!GetFileModeL(KFileMode, aSection, fileMode))
sl@0
   829
		{
sl@0
   830
		ERR_PRINTF2(_L("Temp() error reading parameter. %S"), &KFileMode());
sl@0
   831
		SetBlockResult(EFail);
sl@0
   832
		dataOk=EFalse;
sl@0
   833
		}
sl@0
   834
sl@0
   835
	//	Creates Temporary file.
sl@0
   836
	TFileName fileName;
sl@0
   837
	if ( dataOk )
sl@0
   838
		{
sl@0
   839
		if (rfsObject)
sl@0
   840
			{
sl@0
   841
			TInt	err = iFile->Temp(*rfsObject, path, fileName,fileMode);
sl@0
   842
			INFO_PRINTF2(_L("File: %S is created"), &fileName);			
sl@0
   843
			if ( err!=KErrNone )
sl@0
   844
				{
sl@0
   845
				ERR_PRINTF2(_L("Temp() failed with error = %d"), err);
sl@0
   846
				SetError(err);
sl@0
   847
				}
sl@0
   848
			else
sl@0
   849
				{
sl@0
   850
				iFileOpened = ETrue;				
sl@0
   851
				}				
sl@0
   852
			}
sl@0
   853
		else
sl@0
   854
			{
sl@0
   855
			ERR_PRINTF1(_L("RFs object is NULL"));
sl@0
   856
			SetBlockResult(EFail);
sl@0
   857
			}
sl@0
   858
		}	
sl@0
   859
	
sl@0
   860
	}	
sl@0
   861
	
sl@0
   862
void CT_FileData::DoCmdRenameL(const TDesC& aSection)
sl@0
   863
/** rename the file */
sl@0
   864
	{
sl@0
   865
	
sl@0
   866
	TPtrC newName;
sl@0
   867
	//get the name from ini and rename the file.
sl@0
   868
	if(GET_MANDATORY_STRING_PARAMETER(KUParamName(), aSection, newName))
sl@0
   869
		{	
sl@0
   870
		TInt err = iFile->Rename(newName);
sl@0
   871
	
sl@0
   872
		if (err != KErrNone)
sl@0
   873
			{
sl@0
   874
			ERR_PRINTF2(_L("Rename() failed with error code %d"), err);
sl@0
   875
			SetError(err);
sl@0
   876
			}
sl@0
   877
		}
sl@0
   878
	
sl@0
   879
	}	
sl@0
   880
	
sl@0
   881
void CT_FileData::DoCmdSeekL(const TDesC& aSection)
sl@0
   882
/** set the file cursor to specified location in file */
sl@0
   883
	{
sl@0
   884
	TSeek seek = ESeekStart;
sl@0
   885
	TBool dataOk = EFalse;
sl@0
   886
	TInt pos;
sl@0
   887
sl@0
   888
	//convert the mode string from ini to TSeek
sl@0
   889
	if(ConvertToSeek(KSeek, aSection,seek))
sl@0
   890
		{
sl@0
   891
		dataOk = GET_MANDATORY_INT_PARAMETER(KUParamPos(), aSection, pos);		
sl@0
   892
		}	
sl@0
   893
		
sl@0
   894
	if(dataOk)
sl@0
   895
		{
sl@0
   896
		TInt err = iFile->Seek(seek, pos);
sl@0
   897
	
sl@0
   898
		if(err != KErrNone)	
sl@0
   899
			{
sl@0
   900
			ERR_PRINTF2(_L("Seek(), error seeking() = %d"), err);
sl@0
   901
			SetError(err);
sl@0
   902
			}
sl@0
   903
		else
sl@0
   904
			{
sl@0
   905
			INFO_PRINTF1(_L("Succesfully seeked the file"));
sl@0
   906
			}
sl@0
   907
		}
sl@0
   908
	}	
sl@0
   909
	
sl@0
   910
TBool CT_FileData::ConvertToSeek(const TDesC& aParameterName, const TDesC& aSection, TSeek& aSeek)
sl@0
   911
/** convert a seek mode string from ini to TSeek */
sl@0
   912
	{
sl@0
   913
	TBool ret = ETrue;
sl@0
   914
	
sl@0
   915
	TPtrC aModeStr;
sl@0
   916
	
sl@0
   917
	if(GET_MANDATORY_STRING_PARAMETER(aParameterName, aSection, aModeStr))
sl@0
   918
		{
sl@0
   919
		
sl@0
   920
		if (aModeStr == KESeekStart)
sl@0
   921
			{
sl@0
   922
			aSeek = ESeekStart;
sl@0
   923
			}
sl@0
   924
		else if (aModeStr == KESeekCurrent)
sl@0
   925
			{
sl@0
   926
			aSeek = ESeekCurrent;
sl@0
   927
			}
sl@0
   928
		else if (aModeStr == KESeekEnd)
sl@0
   929
			{
sl@0
   930
			aSeek = ESeekEnd;
sl@0
   931
			}
sl@0
   932
		else
sl@0
   933
			{
sl@0
   934
			ret = EFalse;
sl@0
   935
			}
sl@0
   936
		
sl@0
   937
		}
sl@0
   938
	else
sl@0
   939
		{
sl@0
   940
		ret = EFalse;
sl@0
   941
		}
sl@0
   942
sl@0
   943
	return ret;
sl@0
   944
	}	
sl@0
   945
	
sl@0
   946
	
sl@0
   947
void CT_FileData::DoCmdReadCancelL(const TDesC& aSection)
sl@0
   948
/** wrapper for readcancels */
sl@0
   949
	{
sl@0
   950
	
sl@0
   951
	TBool cancelAll;
sl@0
   952
	
sl@0
   953
	//decide which ReadCancel to call
sl@0
   954
	if(GET_OPTIONAL_BOOL_PARAMETER(KUParamCancelAll, aSection, cancelAll))
sl@0
   955
		{
sl@0
   956
		if (cancelAll == true)
sl@0
   957
			{
sl@0
   958
			ReadCancelAll();
sl@0
   959
			}
sl@0
   960
		else
sl@0
   961
			{
sl@0
   962
			ReadCancel();
sl@0
   963
			}
sl@0
   964
		}
sl@0
   965
	else
sl@0
   966
		{
sl@0
   967
		ReadCancel();
sl@0
   968
		}
sl@0
   969
	}	
sl@0
   970
		
sl@0
   971
void CT_FileData::ReadCancel()
sl@0
   972
/** will cancel the last active request by default */
sl@0
   973
	{
sl@0
   974
	iFile->ReadCancel(iReadCallbackArray[iReadCallbackArray.Count()-1]->iStatus);
sl@0
   975
	}
sl@0
   976
	
sl@0
   977
void CT_FileData::ReadCancelAll()
sl@0
   978
/** cancel all outstanding read requests */
sl@0
   979
	{
sl@0
   980
	iFile->ReadCancel();
sl@0
   981
	}
sl@0
   982
sl@0
   983
// the write implementation
sl@0
   984
void CT_FileData::DoCmdWriteL(const TDesC& aSection, const TInt aAsyncErrorIndex)
sl@0
   985
/** wrapper for write commands */
sl@0
   986
	{
sl@0
   987
	TBool async = EFalse;
sl@0
   988
	//decide which write to call
sl@0
   989
	GET_OPTIONAL_BOOL_PARAMETER(KUParamAsync, aSection, async);
sl@0
   990
	if (async == true)
sl@0
   991
		{
sl@0
   992
		DoAsynchronousWritesL(aSection, aAsyncErrorIndex);	
sl@0
   993
		}
sl@0
   994
	else
sl@0
   995
		{
sl@0
   996
		DoSynchronousWritesL(aSection);
sl@0
   997
		}
sl@0
   998
	}
sl@0
   999
	
sl@0
  1000
void CT_FileData::DoAsynchronousWritesL(const TDesC& aSection, const TInt aAsyncErrorIndex)
sl@0
  1001
/** call asynchronous writes */
sl@0
  1002
	{
sl@0
  1003
	HBufC8* dataWrite8;
sl@0
  1004
	TInt bufferLength;
sl@0
  1005
	
sl@0
  1006
	//Get the buffer length, and create the buffer for activeCallback object
sl@0
  1007
	if (GET_OPTIONAL_INT_PARAMETER(KUParamBufferLength, aSection, bufferLength))
sl@0
  1008
		{
sl@0
  1009
		dataWrite8 = HBufC8::NewLC(bufferLength);
sl@0
  1010
		}
sl@0
  1011
	else
sl@0
  1012
		{
sl@0
  1013
		dataWrite8 = HBufC8::NewLC(KDefaultDescSize);
sl@0
  1014
		}	
sl@0
  1015
	TPtr8 data8Ptr = dataWrite8->Des();
sl@0
  1016
	
sl@0
  1017
	TPtrC data;
sl@0
  1018
	// Get the data to write
sl@0
  1019
	if(GET_MANDATORY_STRING_PARAMETER(KUParamData(), aSection, data))
sl@0
  1020
		{
sl@0
  1021
		//convert it to 8-bit
sl@0
  1022
		data8Ptr.Copy(data);
sl@0
  1023
		
sl@0
  1024
		CActiveCallback* active = CActiveCallback::NewL(*this);
sl@0
  1025
	
sl@0
  1026
		iWriteCallbackArray.Append( active );
sl@0
  1027
		
sl@0
  1028
		TInt length;
sl@0
  1029
		TInt pos;	
sl@0
  1030
		//now, decide which read to call
sl@0
  1031
		if(GET_OPTIONAL_INT_PARAMETER(KUParamLength, aSection, length))
sl@0
  1032
			{
sl@0
  1033
			if(GET_OPTIONAL_INT_PARAMETER(KUParamPos, aSection, pos))
sl@0
  1034
				{
sl@0
  1035
				INFO_PRINTF1(_L("calling RFile::Write(TInt& aPos, TDesC8 &aData, TInt aLen, TRequestStatus &aStatus)"));
sl@0
  1036
				iFile->Write(pos, *dataWrite8, length, active->iStatus);
sl@0
  1037
				}
sl@0
  1038
			else
sl@0
  1039
				{
sl@0
  1040
				INFO_PRINTF1(_L("calling RFile::Write(TDesC8 &aData, TInt aLen, , TRequestStatus &aStatus)"));
sl@0
  1041
				iFile->Write(*dataWrite8, length, active->iStatus);
sl@0
  1042
				}
sl@0
  1043
			}
sl@0
  1044
		else
sl@0
  1045
			{
sl@0
  1046
			if(GET_OPTIONAL_INT_PARAMETER(KUParamPos, aSection, pos))
sl@0
  1047
				{
sl@0
  1048
				INFO_PRINTF1(_L("calling RFile::Write(TInt& aPos, TDesC8 &aData, TRequestStatus &aStatus)"));
sl@0
  1049
				iFile->Write(pos, *dataWrite8, active->iStatus);
sl@0
  1050
				}
sl@0
  1051
			else
sl@0
  1052
				{
sl@0
  1053
				INFO_PRINTF1(_L("calling RFile::Write(TDesC8 &aData, TRequestStatus &aStatus)"));
sl@0
  1054
				iFile->Write(*dataWrite8, active->iStatus);
sl@0
  1055
				}
sl@0
  1056
			}
sl@0
  1057
			
sl@0
  1058
		active->Activate(aAsyncErrorIndex);
sl@0
  1059
		IncOutstanding();
sl@0
  1060
		}
sl@0
  1061
sl@0
  1062
	CleanupStack::PopAndDestroy();	
sl@0
  1063
	}
sl@0
  1064
	
sl@0
  1065
void CT_FileData::DoSynchronousWritesL(const TDesC& aSection)
sl@0
  1066
/** cakk synchronous writes */
sl@0
  1067
	{
sl@0
  1068
	HBufC8* dataWrite8;
sl@0
  1069
	TInt bufferLength;
sl@0
  1070
	
sl@0
  1071
	//Get the buffer length, and create the buffer for activeCallback object
sl@0
  1072
	if (GET_OPTIONAL_INT_PARAMETER(KUParamBufferLength, aSection, bufferLength))
sl@0
  1073
		{
sl@0
  1074
		dataWrite8 = HBufC8::NewLC(bufferLength);
sl@0
  1075
		}
sl@0
  1076
	else
sl@0
  1077
		{
sl@0
  1078
		dataWrite8 = HBufC8::NewLC(KDefaultDescSize);
sl@0
  1079
		}	
sl@0
  1080
	TPtr8 data8Ptr = dataWrite8->Des();
sl@0
  1081
	TInt err = 0;
sl@0
  1082
	
sl@0
  1083
	TPtrC data;	
sl@0
  1084
	// get the data
sl@0
  1085
	if (GET_MANDATORY_STRING_PARAMETER(KUParamData(), aSection, data))
sl@0
  1086
		{
sl@0
  1087
		//convert it to 8-bit		
sl@0
  1088
		data8Ptr.Copy(data);
sl@0
  1089
		
sl@0
  1090
		TInt length;
sl@0
  1091
		TInt pos;
sl@0
  1092
		
sl@0
  1093
		//will decide which write to call 
sl@0
  1094
		if(GET_OPTIONAL_INT_PARAMETER(KUParamLength, aSection, length))
sl@0
  1095
			{
sl@0
  1096
			if(GET_OPTIONAL_INT_PARAMETER(KUParamPos, aSection, pos))
sl@0
  1097
				{
sl@0
  1098
				INFO_PRINTF1(_L("calling RFile::Write(TInt& aPos, TDesC8 &aData, TInt aLen)"));
sl@0
  1099
				err = iFile->Write(pos, *dataWrite8, length);
sl@0
  1100
				}
sl@0
  1101
			else
sl@0
  1102
				{
sl@0
  1103
				INFO_PRINTF1(_L("calling RFile::Write(TDesC8 &aData, TInt aLen)"));
sl@0
  1104
				err = iFile->Write(*dataWrite8, length);
sl@0
  1105
				}
sl@0
  1106
			}
sl@0
  1107
		else
sl@0
  1108
			{
sl@0
  1109
			if(GET_OPTIONAL_INT_PARAMETER(KUParamPos, aSection, pos))
sl@0
  1110
				{
sl@0
  1111
				INFO_PRINTF1(_L("calling RFile::Write(TInt& aPos, TDesC8 &aData)"));
sl@0
  1112
				err = iFile->Write(pos, *dataWrite8);
sl@0
  1113
				}
sl@0
  1114
			else
sl@0
  1115
				{
sl@0
  1116
				INFO_PRINTF1(_L("calling RFile::Write(TDesC8 &aData)"));
sl@0
  1117
				err = iFile->Write(*dataWrite8);
sl@0
  1118
				}
sl@0
  1119
			}
sl@0
  1120
			
sl@0
  1121
		if (err == KErrNone)
sl@0
  1122
			{
sl@0
  1123
			INFO_PRINTF2(_L("written \"%S\" to file"), &data);
sl@0
  1124
			}
sl@0
  1125
		else
sl@0
  1126
			{
sl@0
  1127
			ERR_PRINTF2(_L("Error executing synchronous write %d"), err);
sl@0
  1128
			SetError(err);
sl@0
  1129
			}
sl@0
  1130
		}
sl@0
  1131
	CleanupStack::PopAndDestroy();	
sl@0
  1132
	}	
sl@0
  1133
	
sl@0
  1134
void CT_FileData::DoCmdLockL(const TDesC& aSection)
sl@0
  1135
/** lock a region in file */
sl@0
  1136
	{
sl@0
  1137
	
sl@0
  1138
	TInt pos=0;
sl@0
  1139
	TBool dataOk = ETrue;
sl@0
  1140
	
sl@0
  1141
	//get the position
sl@0
  1142
	if(!GET_MANDATORY_INT_PARAMETER(KUParamPos(), aSection, pos))
sl@0
  1143
		{
sl@0
  1144
		dataOk = EFalse;
sl@0
  1145
		}
sl@0
  1146
		
sl@0
  1147
	TInt length=0;	
sl@0
  1148
	
sl@0
  1149
	// get the length
sl@0
  1150
	if(!GET_MANDATORY_INT_PARAMETER(KUParamLength(), aSection, length))
sl@0
  1151
		{
sl@0
  1152
		dataOk = EFalse;
sl@0
  1153
		}
sl@0
  1154
	
sl@0
  1155
	//Lock!!
sl@0
  1156
	if (dataOk)
sl@0
  1157
		{
sl@0
  1158
		TInt err = iFile->Lock(pos, length);
sl@0
  1159
		
sl@0
  1160
		if(err!=KErrNone)
sl@0
  1161
			{
sl@0
  1162
			ERR_PRINTF2(_L("Lock() error locking file. %d"), err);
sl@0
  1163
			SetError(err);	
sl@0
  1164
			}	
sl@0
  1165
		}
sl@0
  1166
sl@0
  1167
	}	
sl@0
  1168
	
sl@0
  1169
	
sl@0
  1170
void CT_FileData::DoCmdUnLockL(const TDesC& aSection)
sl@0
  1171
/** unlock a region that has been previously locked */
sl@0
  1172
	{
sl@0
  1173
	TBool dataOk = ETrue;
sl@0
  1174
	
sl@0
  1175
	TInt pos=0;
sl@0
  1176
	
sl@0
  1177
	//get the position
sl@0
  1178
	if(!GET_MANDATORY_INT_PARAMETER(KUParamPos(), aSection, pos))
sl@0
  1179
		{
sl@0
  1180
		dataOk = EFalse;
sl@0
  1181
		}
sl@0
  1182
sl@0
  1183
	TInt length=0;
sl@0
  1184
	
sl@0
  1185
	// get the length
sl@0
  1186
	if(!GET_MANDATORY_INT_PARAMETER(KUParamLength(), aSection, length))
sl@0
  1187
		{
sl@0
  1188
		dataOk = EFalse;
sl@0
  1189
		}
sl@0
  1190
	
sl@0
  1191
	//call UnLock
sl@0
  1192
	if (dataOk)
sl@0
  1193
		{
sl@0
  1194
		TInt err = iFile->UnLock(pos, length);
sl@0
  1195
		
sl@0
  1196
		if(err!=KErrNone)
sl@0
  1197
			{
sl@0
  1198
			ERR_PRINTF2(_L("UnLock() error unlocking file. %d"), err);
sl@0
  1199
			SetError(err);	
sl@0
  1200
			}
sl@0
  1201
		else
sl@0
  1202
			{
sl@0
  1203
			INFO_PRINTF1(_L("Succesfully unlocked the file"));
sl@0
  1204
			}
sl@0
  1205
		}
sl@0
  1206
	
sl@0
  1207
	}	
sl@0
  1208
	
sl@0
  1209
	
sl@0
  1210
void CT_FileData::DoCmdSizeL(const TDesC& aSection)
sl@0
  1211
/** get file size */
sl@0
  1212
	{
sl@0
  1213
	
sl@0
  1214
	TInt expectedSize =  0;
sl@0
  1215
	
sl@0
  1216
	TInt size = 0;
sl@0
  1217
	TInt err = iFile->Size(size);
sl@0
  1218
	INFO_PRINTF2(_L("The Size of the file is %d bytes"), size);	
sl@0
  1219
	
sl@0
  1220
	if (err != KErrNone)
sl@0
  1221
		{
sl@0
  1222
		ERR_PRINTF2(_L("Size() error getting file size. %d"), err);
sl@0
  1223
		SetError(err);
sl@0
  1224
		}
sl@0
  1225
	else
sl@0
  1226
		{
sl@0
  1227
		//get expected size from ini
sl@0
  1228
		if(GET_OPTIONAL_INT_PARAMETER(KUParamExpectedSize(), aSection, expectedSize))		
sl@0
  1229
			{
sl@0
  1230
			if(expectedSize != size)
sl@0
  1231
				{
sl@0
  1232
				ERR_PRINTF3(_L("The file size does not match the expected size %d != %d"), size, expectedSize)				
sl@0
  1233
				SetBlockResult(EFail);
sl@0
  1234
				}
sl@0
  1235
			}
sl@0
  1236
		}
sl@0
  1237
	
sl@0
  1238
	}
sl@0
  1239
sl@0
  1240
void CT_FileData::DoCmdSetSizeL(const TDesC& aSection)
sl@0
  1241
/** set file size */
sl@0
  1242
	{
sl@0
  1243
	TInt size=0;
sl@0
  1244
	
sl@0
  1245
	if(GET_MANDATORY_INT_PARAMETER(KUParamSize(), aSection, size))
sl@0
  1246
		{
sl@0
  1247
		TInt err = iFile->SetSize(size);
sl@0
  1248
		
sl@0
  1249
		if (err != KErrNone)
sl@0
  1250
			{
sl@0
  1251
			ERR_PRINTF2(_L("SetSize() error setting file size. %d"), err);
sl@0
  1252
			SetError(err);	
sl@0
  1253
			}
sl@0
  1254
		else
sl@0
  1255
			{
sl@0
  1256
			INFO_PRINTF2(_L("The Size of the fail is set to %d bytes"), size);	
sl@0
  1257
			}			
sl@0
  1258
		}
sl@0
  1259
	}	
sl@0
  1260
	
sl@0
  1261
void CT_FileData::DoCmdAttL(const TDesC& aSection)
sl@0
  1262
/** get file attributes */
sl@0
  1263
	{
sl@0
  1264
	
sl@0
  1265
	TUint attValue = 0;
sl@0
  1266
	
sl@0
  1267
	TInt err = iFile->Att(attValue);
sl@0
  1268
	
sl@0
  1269
	PrintFileAttributes(attValue);
sl@0
  1270
	
sl@0
  1271
	if (err != KErrNone)
sl@0
  1272
		{
sl@0
  1273
		ERR_PRINTF2(_L("Att() getting attributes. %d"), err);
sl@0
  1274
		SetError(err);	
sl@0
  1275
		}
sl@0
  1276
	else
sl@0
  1277
		{
sl@0
  1278
		TUint bitmask = 0x000000FF;
sl@0
  1279
		//lets filter out symbian specific bits
sl@0
  1280
		attValue = attValue & bitmask;
sl@0
  1281
			
sl@0
  1282
		TUint attCompare = 0;
sl@0
  1283
		
sl@0
  1284
		//compare the expected att value with the file attributes
sl@0
  1285
		if (ConvertToAttributeL(KUParamCompareValue, aSection, attCompare))
sl@0
  1286
			{
sl@0
  1287
			if (attCompare == attValue)
sl@0
  1288
				{
sl@0
  1289
				INFO_PRINTF1(_L("attributes match"));
sl@0
  1290
				}
sl@0
  1291
			else
sl@0
  1292
				{
sl@0
  1293
				ERR_PRINTF1(_L("Attributes does not match"));
sl@0
  1294
				SetBlockResult(EFail);
sl@0
  1295
				}
sl@0
  1296
			}
sl@0
  1297
				
sl@0
  1298
		}
sl@0
  1299
	
sl@0
  1300
	}
sl@0
  1301
	
sl@0
  1302
void CT_FileData::DoCmdSetAttL(const TDesC& aSection)
sl@0
  1303
/** set file attributes */
sl@0
  1304
	{
sl@0
  1305
	
sl@0
  1306
	TUint setAttMask = 0;
sl@0
  1307
	TBool dataOk = ETrue;
sl@0
  1308
	
sl@0
  1309
	//get the attribute mask to set
sl@0
  1310
	if(!ConvertToAttributeL(KUParamSetAttMask, aSection, setAttMask))
sl@0
  1311
		{
sl@0
  1312
		ERR_PRINTF2(_L("SetATt() error reading parameter. %S"), &KUParamSetAttMask());
sl@0
  1313
		SetBlockResult(EFail);	
sl@0
  1314
		dataOk = EFalse;
sl@0
  1315
		}
sl@0
  1316
		
sl@0
  1317
	TUint clearAttMask = 0;
sl@0
  1318
	
sl@0
  1319
	//get the attribute mask to clear
sl@0
  1320
	if(!ConvertToAttributeL(KUParamClearAttMask, aSection, clearAttMask))
sl@0
  1321
		{
sl@0
  1322
		ERR_PRINTF2(_L("SetAtt() error reading parameter. %S"), &KUParamClearAttMask());
sl@0
  1323
		SetBlockResult(EFail);	
sl@0
  1324
		dataOk = EFalse;
sl@0
  1325
		}
sl@0
  1326
		
sl@0
  1327
	// all ok? let's call SetAtt		
sl@0
  1328
	if (dataOk)
sl@0
  1329
		{
sl@0
  1330
		TInt err = iFile->SetAtt(setAttMask, clearAttMask);
sl@0
  1331
		
sl@0
  1332
		if (err != KErrNone)
sl@0
  1333
			{
sl@0
  1334
			ERR_PRINTF2(_L("SetAtt() failed with, err: %d"), err);
sl@0
  1335
			SetError(err);	
sl@0
  1336
			}
sl@0
  1337
		else
sl@0
  1338
			{
sl@0
  1339
			INFO_PRINTF1(_L("The attribute value has been set"));	
sl@0
  1340
			}	
sl@0
  1341
		}
sl@0
  1342
		
sl@0
  1343
	}	
sl@0
  1344
	
sl@0
  1345
	
sl@0
  1346
TBool CT_FileData::ConvertToAttributeL(const TDesC& aParameterName, const TDesC& aSection, TUint& aAttribute)
sl@0
  1347
/** convert attribute string from ini to file attribute bitmask */
sl@0
  1348
	{
sl@0
  1349
	TBool ret = ETrue;
sl@0
  1350
	
sl@0
  1351
	TPtrC aModeStr;
sl@0
  1352
	
sl@0
  1353
	if(GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, aModeStr))
sl@0
  1354
		{
sl@0
  1355
		//break the file mode string to array of file modes
sl@0
  1356
		//in case there's more than one filemode		
sl@0
  1357
		RPointerArray<HBufC> fileModes = SplitL(aModeStr, "|");		
sl@0
  1358
			
sl@0
  1359
		for ( int i = 0 ; i < fileModes.Count() ; i++ )
sl@0
  1360
			{
sl@0
  1361
			if (aModeStr == KDEntryAttNormal)
sl@0
  1362
				{
sl@0
  1363
				aAttribute = aAttribute | KEntryAttNormal;
sl@0
  1364
				}
sl@0
  1365
			else if (aModeStr == KDEntryAttReadOnly)
sl@0
  1366
				{
sl@0
  1367
				aAttribute = aAttribute | KEntryAttReadOnly;
sl@0
  1368
				}
sl@0
  1369
			else if (aModeStr == KDEntryAttArchive)
sl@0
  1370
				{
sl@0
  1371
				aAttribute = aAttribute | KEntryAttArchive;
sl@0
  1372
				}
sl@0
  1373
			else if (aModeStr == KDEntryAttHidden)
sl@0
  1374
				{
sl@0
  1375
				aAttribute = aAttribute | KEntryAttHidden;
sl@0
  1376
				}
sl@0
  1377
sl@0
  1378
			else if (aModeStr == KDEntryAttSystem)
sl@0
  1379
				{
sl@0
  1380
				aAttribute = aAttribute | KEntryAttSystem;
sl@0
  1381
				}
sl@0
  1382
sl@0
  1383
			else if (aModeStr == KDEntryAttVolume)
sl@0
  1384
				{
sl@0
  1385
				aAttribute = aAttribute | KEntryAttVolume;
sl@0
  1386
				}
sl@0
  1387
sl@0
  1388
			else if (aModeStr == KDEntryAttDir)
sl@0
  1389
				{
sl@0
  1390
				aAttribute = aAttribute | KEntryAttDir;
sl@0
  1391
				}
sl@0
  1392
sl@0
  1393
			else if (aModeStr == KDEntryAttXIP)
sl@0
  1394
				{
sl@0
  1395
				aAttribute = aAttribute | KEntryAttXIP;
sl@0
  1396
				}
sl@0
  1397
sl@0
  1398
			else if (aModeStr == KDEntryAttRemote)
sl@0
  1399
				{
sl@0
  1400
				aAttribute = aAttribute | KEntryAttRemote;
sl@0
  1401
				}
sl@0
  1402
			else
sl@0
  1403
				{
sl@0
  1404
				ret = EFalse;
sl@0
  1405
				}
sl@0
  1406
			}
sl@0
  1407
			
sl@0
  1408
		for (int j=0 ; j<fileModes.Count() ; j++)
sl@0
  1409
			{
sl@0
  1410
			HBufC* temp = fileModes[j];
sl@0
  1411
			delete temp;
sl@0
  1412
			temp = NULL;
sl@0
  1413
			}
sl@0
  1414
			
sl@0
  1415
		fileModes.Close();
sl@0
  1416
		}
sl@0
  1417
	else
sl@0
  1418
		{
sl@0
  1419
		ret = EFalse;
sl@0
  1420
		}
sl@0
  1421
sl@0
  1422
	return ret;
sl@0
  1423
	
sl@0
  1424
	}	
sl@0
  1425
	
sl@0
  1426
void CT_FileData::DoCmdModifiedL(const TDesC& aSection)
sl@0
  1427
/** get file modification date */
sl@0
  1428
	{
sl@0
  1429
	
sl@0
  1430
	TTime time;
sl@0
  1431
	
sl@0
  1432
	TInt err = iFile->Modified(time);
sl@0
  1433
	
sl@0
  1434
	_LIT(KDateString,"%E%D%X%N%Y %1 %2 %3");	
sl@0
  1435
		
sl@0
  1436
	TBuf<KDefaultDescSize> dateString;
sl@0
  1437
	
sl@0
  1438
	//format the time to string	
sl@0
  1439
	TRAPD(err2, time.FormatL(dateString, KDateString));
sl@0
  1440
	
sl@0
  1441
	if(err2 != KErrNone)
sl@0
  1442
		{
sl@0
  1443
		ERR_PRINTF2(_L("Modified() error formating date string err: %d"), err);
sl@0
  1444
		}
sl@0
  1445
	
sl@0
  1446
	INFO_PRINTF2(_L("Modified() returned: %S"), &dateString);
sl@0
  1447
	
sl@0
  1448
	if (err != KErrNone)
sl@0
  1449
		{
sl@0
  1450
		ERR_PRINTF2(_L("Modified() failed with, err: %d"), err);
sl@0
  1451
		SetError(err);	
sl@0
  1452
		}
sl@0
  1453
	else
sl@0
  1454
		{
sl@0
  1455
		
sl@0
  1456
		//compare the file modification date with the date readed from inin
sl@0
  1457
		TPtrC compValue;
sl@0
  1458
		
sl@0
  1459
		if (GET_OPTIONAL_STRING_PARAMETER(KUParamCompareValue, aSection, compValue))
sl@0
  1460
			{
sl@0
  1461
			
sl@0
  1462
			TTime compTime;
sl@0
  1463
			err = compTime.Set(compValue);
sl@0
  1464
			
sl@0
  1465
			if ( err != KErrNone )
sl@0
  1466
				{
sl@0
  1467
				ERR_PRINTF1(_L("invalid compare value"));
sl@0
  1468
				}
sl@0
  1469
			else
sl@0
  1470
				{
sl@0
  1471
				if (compTime == time)
sl@0
  1472
					{
sl@0
  1473
					INFO_PRINTF1(_L("The dates match"));
sl@0
  1474
					}
sl@0
  1475
				else
sl@0
  1476
					{
sl@0
  1477
					ERR_PRINTF1(_L("The values do not match"));
sl@0
  1478
					SetBlockResult(EFail);
sl@0
  1479
					}
sl@0
  1480
				}
sl@0
  1481
				
sl@0
  1482
			}		
sl@0
  1483
		}		
sl@0
  1484
	}
sl@0
  1485
sl@0
  1486
void CT_FileData::DoCmdSetModifiedL(const TDesC& aSection)
sl@0
  1487
/** set file modification date */
sl@0
  1488
	{
sl@0
  1489
	
sl@0
  1490
	TPtrC dateDesc;
sl@0
  1491
	TBool dataOk = ETrue;
sl@0
  1492
	TTime time;
sl@0
  1493
	TInt err = KErrNone;
sl@0
  1494
	
sl@0
  1495
	if(!GET_MANDATORY_STRING_PARAMETER(KUParamDate(), aSection, dateDesc))
sl@0
  1496
		{
sl@0
  1497
		dataOk = EFalse;
sl@0
  1498
		}
sl@0
  1499
	else
sl@0
  1500
		{
sl@0
  1501
		err = time.Set(dateDesc);
sl@0
  1502
		}
sl@0
  1503
	
sl@0
  1504
	if (err != KErrNone)
sl@0
  1505
		{
sl@0
  1506
		ERR_PRINTF2(_L("time.Set() failed with error code %d"), err);
sl@0
  1507
		SetBlockResult(EFail);
sl@0
  1508
		dataOk = EFalse;
sl@0
  1509
		}
sl@0
  1510
		
sl@0
  1511
	if (dataOk)
sl@0
  1512
		{
sl@0
  1513
		err = iFile->SetModified(time);
sl@0
  1514
		
sl@0
  1515
		if (err != KErrNone)
sl@0
  1516
			{
sl@0
  1517
			ERR_PRINTF2(_L("SetModified() failed with error code %d"), err);
sl@0
  1518
			SetError(err);			
sl@0
  1519
			}		
sl@0
  1520
		}
sl@0
  1521
	}
sl@0
  1522
	
sl@0
  1523
void CT_FileData::DoCmdSetL(const TDesC& aSection)
sl@0
  1524
/** set file attributes and modification time */
sl@0
  1525
	{
sl@0
  1526
	TPtrC dateDesc;
sl@0
  1527
	TBool dataOk = ETrue;
sl@0
  1528
	TInt err = KErrNone;
sl@0
  1529
	TTime time;
sl@0
  1530
	
sl@0
  1531
	//get and process the date string
sl@0
  1532
	if(!GET_MANDATORY_STRING_PARAMETER(KUParamDate(), aSection, dateDesc))
sl@0
  1533
		{
sl@0
  1534
		dataOk = EFalse;
sl@0
  1535
		}
sl@0
  1536
	else
sl@0
  1537
		{
sl@0
  1538
		err = time.Set(dateDesc);
sl@0
  1539
		}		
sl@0
  1540
		
sl@0
  1541
	TUint setAttMask = 0;
sl@0
  1542
		
sl@0
  1543
	// get the attribute masks	
sl@0
  1544
	if(!ConvertToAttributeL(KUParamSetAttMask, aSection,setAttMask))
sl@0
  1545
		{
sl@0
  1546
		dataOk = EFalse;
sl@0
  1547
		}	
sl@0
  1548
		
sl@0
  1549
	TUint clearAttMask = 0;	
sl@0
  1550
		
sl@0
  1551
	if(!ConvertToAttributeL(KUParamClearAttMask, aSection, clearAttMask))
sl@0
  1552
		{
sl@0
  1553
		dataOk = EFalse;
sl@0
  1554
		}			
sl@0
  1555
	// if all Ok then proceed with Set	
sl@0
  1556
	if (dataOk)
sl@0
  1557
		{
sl@0
  1558
		err = iFile->Set(time, setAttMask, clearAttMask);
sl@0
  1559
		
sl@0
  1560
		if ( err != KErrNone)
sl@0
  1561
			{
sl@0
  1562
			ERR_PRINTF2(_L("Set() failed with error code %d"), err);
sl@0
  1563
			SetError(err);
sl@0
  1564
			}		
sl@0
  1565
		}
sl@0
  1566
	}
sl@0
  1567
	
sl@0
  1568
void CT_FileData::DoCmdChangeModeL(const TDesC& aSection)
sl@0
  1569
/** Change the file mode */
sl@0
  1570
	{
sl@0
  1571
	TUint fileMode = 0;
sl@0
  1572
	
sl@0
  1573
	if(!GetFileModeL(KFileMode, aSection, fileMode))
sl@0
  1574
		{
sl@0
  1575
		ERR_PRINTF2(_L("Set() error reading parameter. %S"), &KFileMode());
sl@0
  1576
		SetBlockResult(EFail);	
sl@0
  1577
		}
sl@0
  1578
	else
sl@0
  1579
		{
sl@0
  1580
		TInt err = iFile->ChangeMode((TFileMode)fileMode);
sl@0
  1581
		
sl@0
  1582
		if ( err != KErrNone )
sl@0
  1583
			{
sl@0
  1584
			ERR_PRINTF2(_L("ChangeMode() failed with error code %d"), err);
sl@0
  1585
			SetError(err);
sl@0
  1586
			}	
sl@0
  1587
		}
sl@0
  1588
	}	
sl@0
  1589
	
sl@0
  1590
void CT_FileData::DoCmdDriveL(const TDesC& aSection)
sl@0
  1591
/** Get the drive info, in which the file is stored */
sl@0
  1592
	{
sl@0
  1593
	TDriveInfo driveInfo;
sl@0
  1594
	TInt driveNumber;
sl@0
  1595
	int err = iFile->Drive(driveNumber, driveInfo);
sl@0
  1596
	
sl@0
  1597
	INFO_PRINTF2(_L("TDriveInfo.iType    =%d"), driveInfo.iType);
sl@0
  1598
	INFO_PRINTF2(_L("TDriveInfo.iBattery =%d"), driveInfo.iBattery);
sl@0
  1599
	INFO_PRINTF2(_L("TDriveInfo.iDriveAtt=0x%X"), driveInfo.iDriveAtt);
sl@0
  1600
	INFO_PRINTF2(_L("Drivenumber 		 =%d"), driveNumber);	
sl@0
  1601
	
sl@0
  1602
	if (err != KErrNone)
sl@0
  1603
		{
sl@0
  1604
		ERR_PRINTF2(_L("Drive() failed with error code %d"), err);
sl@0
  1605
		SetError(err);
sl@0
  1606
		}
sl@0
  1607
	else
sl@0
  1608
		{
sl@0
  1609
		TInt compDriveNumber;
sl@0
  1610
			
sl@0
  1611
		if ( GET_OPTIONAL_INT_PARAMETER(KUParamCompareValue, aSection, compDriveNumber))
sl@0
  1612
			{
sl@0
  1613
				if ( compDriveNumber == driveNumber )
sl@0
  1614
					{
sl@0
  1615
					INFO_PRINTF3(_L("drivenumbers match %d == %d "), compDriveNumber, driveNumber);
sl@0
  1616
					}
sl@0
  1617
				else 
sl@0
  1618
					{
sl@0
  1619
					ERR_PRINTF3(_L("drivenumbers do not match %d != %d"), compDriveNumber, driveNumber);
sl@0
  1620
					SetBlockResult(EFail);
sl@0
  1621
					}
sl@0
  1622
			}		
sl@0
  1623
		}
sl@0
  1624
	
sl@0
  1625
	}	
sl@0
  1626
	
sl@0
  1627
void CT_FileData::DoCmdDuplicateL(const TDesC& aSection)
sl@0
  1628
/** Duplicate the file */
sl@0
  1629
	{
sl@0
  1630
	TPtrC rFileObjectName;
sl@0
  1631
	TBool dataOk = GET_MANDATORY_STRING_PARAMETER(KFileObjectName, aSection, rFileObjectName);
sl@0
  1632
		
sl@0
  1633
	// get the RFile handle to duplicate	
sl@0
  1634
	RFile* rFileObject = NULL;
sl@0
  1635
	if (dataOk)
sl@0
  1636
		{
sl@0
  1637
		rFileObject=(RFile*)GetDataObjectL(rFileObjectName);
sl@0
  1638
	
sl@0
  1639
		if(rFileObject == NULL)
sl@0
  1640
			{
sl@0
  1641
			ERR_PRINTF2(_L("Duplicate() error getting object. %S"), KFileObjectName);
sl@0
  1642
			SetBlockResult(EFail);	
sl@0
  1643
			dataOk = EFalse;
sl@0
  1644
			}
sl@0
  1645
		}
sl@0
  1646
		
sl@0
  1647
	// if handle ok then procees with duplication	
sl@0
  1648
	if (dataOk)
sl@0
  1649
		{
sl@0
  1650
		TOwnerType ownerType;
sl@0
  1651
			
sl@0
  1652
		TInt err = KErrNone;	
sl@0
  1653
		// determine the owner type to pass to duplicate
sl@0
  1654
		if (ConvertToOwnerType(KUParamOwnerType, aSection, ownerType) && dataOk)
sl@0
  1655
			{
sl@0
  1656
			err = iFile->Duplicate(*rFileObject, ownerType);
sl@0
  1657
			}
sl@0
  1658
		else
sl@0
  1659
			{
sl@0
  1660
			err = iFile->Duplicate(*rFileObject);
sl@0
  1661
			}
sl@0
  1662
			
sl@0
  1663
		
sl@0
  1664
		if (err != KErrNone)
sl@0
  1665
			{
sl@0
  1666
			ERR_PRINTF2(_L("Duplicate() error duplicating %d"), err);
sl@0
  1667
			SetError(err);
sl@0
  1668
			}
sl@0
  1669
		else
sl@0
  1670
			{	
sl@0
  1671
			//lets mark the file to be opened
sl@0
  1672
			iFileOpened = ETrue;		
sl@0
  1673
			}
sl@0
  1674
		}
sl@0
  1675
	
sl@0
  1676
	}	
sl@0
  1677
	
sl@0
  1678
TBool CT_FileData::ConvertToOwnerType(const TDesC& aParameterName, const TDesC& aSection, TOwnerType& aResult)
sl@0
  1679
/** convert the ownerType string from ini to EOwnerType */
sl@0
  1680
	{
sl@0
  1681
	
sl@0
  1682
	TBool ret = ETrue;
sl@0
  1683
	
sl@0
  1684
	TPtrC ownerTypeString;
sl@0
  1685
	
sl@0
  1686
	if(GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, ownerTypeString))
sl@0
  1687
		{
sl@0
  1688
		
sl@0
  1689
		if (ownerTypeString == KEOwnerProcess )
sl@0
  1690
			{
sl@0
  1691
			aResult = EOwnerProcess;
sl@0
  1692
			}
sl@0
  1693
		else if (ownerTypeString == KEOwnerThread)
sl@0
  1694
			{
sl@0
  1695
			aResult = EOwnerThread;
sl@0
  1696
			}
sl@0
  1697
		else
sl@0
  1698
			{
sl@0
  1699
			ret = EFalse;
sl@0
  1700
			}
sl@0
  1701
		
sl@0
  1702
		}
sl@0
  1703
	else
sl@0
  1704
		{
sl@0
  1705
		ret = EFalse;
sl@0
  1706
		}
sl@0
  1707
sl@0
  1708
	return ret;
sl@0
  1709
	}	
sl@0
  1710
	
sl@0
  1711
void CT_FileData::DoCmdFullName(const TDesC& aSection)
sl@0
  1712
/** get the file fullname */
sl@0
  1713
	{
sl@0
  1714
	TBuf<128> name;
sl@0
  1715
	TInt err = iFile->FullName(name);
sl@0
  1716
	
sl@0
  1717
	INFO_PRINTF2(_L("FullName() returned  %S"), &name);		
sl@0
  1718
	
sl@0
  1719
	if(err != KErrNone)
sl@0
  1720
		{
sl@0
  1721
		ERR_PRINTF2(_L("FullName() error, returned. %d"), err);
sl@0
  1722
		SetError(err);	
sl@0
  1723
		}
sl@0
  1724
	else
sl@0
  1725
		{
sl@0
  1726
		TPtrC path;	
sl@0
  1727
		if(GET_OPTIONAL_STRING_PARAMETER(KUParamComparePath, aSection, path))
sl@0
  1728
			{
sl@0
  1729
			if (path == name)
sl@0
  1730
				{
sl@0
  1731
				INFO_PRINTF1(_L("the paths match"));	
sl@0
  1732
				}
sl@0
  1733
			else
sl@0
  1734
				{
sl@0
  1735
				ERR_PRINTF1(_L("the paths do not match"));
sl@0
  1736
				SetBlockResult(EFail);
sl@0
  1737
				}
sl@0
  1738
			}				
sl@0
  1739
		}
sl@0
  1740
	}	
sl@0
  1741
	
sl@0
  1742
void CT_FileData::DoCmdNameL(const TDesC& aSection)
sl@0
  1743
/** get the file name */
sl@0
  1744
	{
sl@0
  1745
	TBuf<KDefaultDescSize> name;
sl@0
  1746
	TInt err = iFile->Name(name);
sl@0
  1747
	INFO_PRINTF2(_L("Name() returned  %S"), &name);	
sl@0
  1748
	
sl@0
  1749
	if(err != KErrNone)
sl@0
  1750
		{
sl@0
  1751
		ERR_PRINTF2(_L("Name() error, returned. %d"), err);
sl@0
  1752
		SetError(err);	
sl@0
  1753
		}
sl@0
  1754
	else	
sl@0
  1755
		{
sl@0
  1756
		
sl@0
  1757
				
sl@0
  1758
		TPtrC compValue;	
sl@0
  1759
			
sl@0
  1760
		if (GET_OPTIONAL_STRING_PARAMETER(KUParamCompareValue, aSection, compValue))
sl@0
  1761
			{
sl@0
  1762
			if (compValue == name)
sl@0
  1763
				{
sl@0
  1764
				INFO_PRINTF3(_L("The names match %S == %S"), &name, &compValue);
sl@0
  1765
				}
sl@0
  1766
			else
sl@0
  1767
				{
sl@0
  1768
				ERR_PRINTF3(_L("The names do not match %S == %S"), &name, &compValue);			
sl@0
  1769
				SetBlockResult(EFail);
sl@0
  1770
				}
sl@0
  1771
			}		
sl@0
  1772
		}
sl@0
  1773
	}	
sl@0
  1774
sl@0
  1775
TBool CT_FileData::ConvertToBlockMapUsage(const TDesC& aParameterName, const TDesC& aSection, TBlockMapUsage& aResult)
sl@0
  1776
	{
sl@0
  1777
	
sl@0
  1778
	TBool ret = ETrue;
sl@0
  1779
	
sl@0
  1780
	TPtrC blockmapeUsageString;
sl@0
  1781
	
sl@0
  1782
	if(GET_OPTIONAL_STRING_PARAMETER(aParameterName, aSection, blockmapeUsageString))
sl@0
  1783
		{
sl@0
  1784
		
sl@0
  1785
		if (blockmapeUsageString == KEBlockMapUsagePaging )
sl@0
  1786
			{
sl@0
  1787
			aResult = EBlockMapUsagePaging;
sl@0
  1788
			}
sl@0
  1789
		else if (blockmapeUsageString == KETestDebug)
sl@0
  1790
			{
sl@0
  1791
			aResult = ETestDebug;
sl@0
  1792
			}
sl@0
  1793
		else
sl@0
  1794
			{
sl@0
  1795
			ret = EFalse;
sl@0
  1796
			}
sl@0
  1797
		
sl@0
  1798
		}
sl@0
  1799
	else
sl@0
  1800
		{
sl@0
  1801
		ret = EFalse;
sl@0
  1802
		}
sl@0
  1803
sl@0
  1804
	return ret;
sl@0
  1805
	}	
sl@0
  1806
	
sl@0
  1807
void CT_FileData::DoCmdBlockMap(const TDesC& aSection)
sl@0
  1808
	{
sl@0
  1809
	TInt64 startPos = 0;
sl@0
  1810
	GET_OPTIONAL_INT64_PARAMETER(KUParamStartPos, aSection, startPos);
sl@0
  1811
		
sl@0
  1812
	SBlockMapInfo blockMapInfo;
sl@0
  1813
	TInt err = KErrNone;
sl@0
  1814
	TInt64 endPos = -1;
sl@0
  1815
	if (GET_OPTIONAL_INT64_PARAMETER(KUParamEndPos, aSection, endPos))
sl@0
  1816
		{
sl@0
  1817
		TBlockMapUsage usage;
sl@0
  1818
		if (ConvertToBlockMapUsage(KUParamUsage, aSection, usage))
sl@0
  1819
			{
sl@0
  1820
			err = iFile->BlockMap(blockMapInfo, startPos, endPos, usage);
sl@0
  1821
			}
sl@0
  1822
		else
sl@0
  1823
			{
sl@0
  1824
			err = iFile->BlockMap(blockMapInfo, startPos, endPos);
sl@0
  1825
			}
sl@0
  1826
		}
sl@0
  1827
	else
sl@0
  1828
		{
sl@0
  1829
		TBlockMapUsage usage;
sl@0
  1830
		if (ConvertToBlockMapUsage(KUParamUsage, aSection, usage))
sl@0
  1831
			{
sl@0
  1832
			err = iFile->BlockMap(blockMapInfo, startPos, usage);
sl@0
  1833
			}
sl@0
  1834
		else
sl@0
  1835
			{		
sl@0
  1836
			err = iFile->BlockMap(blockMapInfo, startPos);
sl@0
  1837
			}
sl@0
  1838
		}
sl@0
  1839
		
sl@0
  1840
	if (KErrNone != err)
sl@0
  1841
		{
sl@0
  1842
		ERR_PRINTF2(_L("BlockMap Returned an error %d"), err);
sl@0
  1843
		SetError(err);
sl@0
  1844
		}
sl@0
  1845
	if (KErrNone == err || KErrCompletion == err)
sl@0
  1846
		{
sl@0
  1847
		INFO_PRINTF2(_L("Returned start position %d"), startPos);
sl@0
  1848
sl@0
  1849
		INFO_PRINTF2(_L("Local drive number %d"), blockMapInfo.iLocalDriveNumber);
sl@0
  1850
		INFO_PRINTF2(_L("Block start address %d"), blockMapInfo.iStartBlockAddress);
sl@0
  1851
		INFO_PRINTF2(_L("Block start offset %u"), blockMapInfo.iBlockStartOffset);
sl@0
  1852
		INFO_PRINTF2(_L("Block graduality %u"), blockMapInfo.iBlockGranularity);	
sl@0
  1853
		}
sl@0
  1854
	
sl@0
  1855
	}
sl@0
  1856
sl@0
  1857
//function that adds the buffer to the end of the array
sl@0
  1858
void CT_FileData::ToArrayL(RPointerArray<HBufC>& aArray, HBufC*& aBuffer)
sl@0
  1859
	{
sl@0
  1860
	HBufC* arrayElement = HBufC::NewL(aBuffer->Length());
sl@0
  1861
	TPtr arrayElementPtr = arrayElement->Des();
sl@0
  1862
	arrayElementPtr.Copy(*aBuffer);
sl@0
  1863
	arrayElementPtr.TrimAll();
sl@0
  1864
	aArray.Append(arrayElement);
sl@0
  1865
	arrayElement = NULL;
sl@0
  1866
	}
sl@0
  1867
	
sl@0
  1868
sl@0
  1869
// helper function to split filemodes or attributes to array
sl@0
  1870
RPointerArray<HBufC> CT_FileData::SplitL(const TDesC& aInput, const char* aToken)
sl@0
  1871
	{
sl@0
  1872
	RPointerArray<HBufC> fileModeArray;
sl@0
  1873
	HBufC*  buffer = HBufC::NewL(aInput.Length());
sl@0
  1874
	TPtr bufferPtr = buffer->Des();
sl@0
  1875
	for (int i=0;i<aInput.Length();i++)
sl@0
  1876
		{
sl@0
  1877
		if (aInput[i] == *aToken)
sl@0
  1878
			{
sl@0
  1879
			ToArrayL(fileModeArray, buffer);
sl@0
  1880
			delete buffer;	
sl@0
  1881
				
sl@0
  1882
			buffer = NULL;
sl@0
  1883
			buffer = HBufC::NewL( aInput.Length() - i);	
sl@0
  1884
			bufferPtr = buffer->Des();
sl@0
  1885
			}
sl@0
  1886
		else
sl@0
  1887
			{
sl@0
  1888
			bufferPtr.Append(aInput[i]);
sl@0
  1889
			}
sl@0
  1890
		}
sl@0
  1891
	
sl@0
  1892
	ToArrayL(fileModeArray, buffer);		
sl@0
  1893
	delete buffer;
sl@0
  1894
	
sl@0
  1895
	buffer = NULL;		
sl@0
  1896
		
sl@0
  1897
	return fileModeArray;
sl@0
  1898
 	
sl@0
  1899
	}
sl@0
  1900
	
sl@0
  1901
void CT_FileData::DoCancel(CActive* aActive, TInt aIndex)
sl@0
  1902
	{
sl@0
  1903
	TBool	foundActiveObject = EFalse;
sl@0
  1904
sl@0
  1905
	TInt	index=0;
sl@0
  1906
	TInt	count=0;
sl@0
  1907
sl@0
  1908
	count=iReadCallbackArray.Count();
sl@0
  1909
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
  1910
 		{
sl@0
  1911
 		if( aActive == iReadCallbackArray[index] )
sl@0
  1912
			{
sl@0
  1913
			INFO_PRINTF1(_L("DoCancel iReadCallbackArray called"));
sl@0
  1914
			foundActiveObject = ETrue;
sl@0
  1915
			iReadCallbackArray.Remove(index);
sl@0
  1916
	 		}
sl@0
  1917
		}
sl@0
  1918
sl@0
  1919
	count=iWriteCallbackArray.Count();
sl@0
  1920
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
  1921
 		{
sl@0
  1922
 		if( aActive == iWriteCallbackArray[index] )
sl@0
  1923
			{
sl@0
  1924
			INFO_PRINTF1(_L("DoCancel iWriteCallbackArray called"));
sl@0
  1925
			foundActiveObject = ETrue;
sl@0
  1926
			iWriteCallbackArray.Remove(index);
sl@0
  1927
	 		}
sl@0
  1928
		}
sl@0
  1929
sl@0
  1930
	// See if it is in iFlushCallbackArray
sl@0
  1931
	count=iFlushCallbackArray.Count();
sl@0
  1932
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
  1933
 		{
sl@0
  1934
 		if( aActive == iFlushCallbackArray[index] )
sl@0
  1935
			{
sl@0
  1936
			INFO_PRINTF1(_L("DoCancel iFlushCallbackArray called"));
sl@0
  1937
			foundActiveObject = ETrue;
sl@0
  1938
			iFlushCallbackArray.Remove(index);
sl@0
  1939
	 		}
sl@0
  1940
		}
sl@0
  1941
sl@0
  1942
 	if( foundActiveObject )
sl@0
  1943
 		{
sl@0
  1944
		TInt	err = aActive->iStatus.Int();
sl@0
  1945
		if( err != KErrNone )
sl@0
  1946
			{
sl@0
  1947
			ERR_PRINTF2(_L("DoCancel Error %d"), err);
sl@0
  1948
			SetAsyncError( aIndex, err );
sl@0
  1949
			}
sl@0
  1950
sl@0
  1951
		// Reset the outstanding request state
sl@0
  1952
		DecOutstanding();
sl@0
  1953
sl@0
  1954
		delete aActive;
sl@0
  1955
		}
sl@0
  1956
	else
sl@0
  1957
		{
sl@0
  1958
 		ERR_PRINTF1(_L("Stray DoCancel signal"));
sl@0
  1959
 		SetBlockResult(EFail);
sl@0
  1960
		}
sl@0
  1961
	}
sl@0
  1962
sl@0
  1963
void CT_FileData::RunL(CActive* aActive, TInt aIndex)
sl@0
  1964
	{
sl@0
  1965
sl@0
  1966
	
sl@0
  1967
	TBool	foundActiveObject = EFalse;
sl@0
  1968
	TInt	index=0;
sl@0
  1969
	TInt	count=0;
sl@0
  1970
	
sl@0
  1971
	count=iReadCallbackArray.Count();
sl@0
  1972
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
  1973
 		{
sl@0
  1974
 		if( aActive == iReadCallbackArray[index] )
sl@0
  1975
			{
sl@0
  1976
			foundActiveObject = ETrue;
sl@0
  1977
			TInt	err = aActive->iStatus.Int();
sl@0
  1978
			
sl@0
  1979
			TBuf<KDefaultDescSize> info;
sl@0
  1980
			info.Copy(iReadCallbackArray[index]->iFileData->Des());
sl@0
  1981
			INFO_PRINTF2(_L("readed \"%S\" from file"), &info);
sl@0
  1982
			
sl@0
  1983
			HandleExpectedString(iReadCallbackArray[index]->iFileData->Des(), *iReadCallbackArray[index]->iSection);
sl@0
  1984
			
sl@0
  1985
			if( err != KErrNone )
sl@0
  1986
				{
sl@0
  1987
				ERR_PRINTF2(_L("Async Read error %d"), err);
sl@0
  1988
				SetAsyncError( aIndex, err );
sl@0
  1989
				}
sl@0
  1990
			else
sl@0
  1991
				{
sl@0
  1992
				INFO_PRINTF1(_L("Succesfully completed Async Read"));
sl@0
  1993
				}
sl@0
  1994
				
sl@0
  1995
			iReadCallbackArray.Remove(index);	
sl@0
  1996
			delete aActive;
sl@0
  1997
			
sl@0
  1998
	 		}
sl@0
  1999
		}
sl@0
  2000
		
sl@0
  2001
	count=iWriteCallbackArray.Count();
sl@0
  2002
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
  2003
 		{
sl@0
  2004
 		if( aActive == iWriteCallbackArray[index] )
sl@0
  2005
			{
sl@0
  2006
			foundActiveObject = ETrue;
sl@0
  2007
			TInt	err = aActive->iStatus.Int();
sl@0
  2008
			
sl@0
  2009
			if( err != KErrNone )
sl@0
  2010
				{
sl@0
  2011
				ERR_PRINTF2(_L("Async Write Error %d"), err);
sl@0
  2012
				SetAsyncError( aIndex, err );
sl@0
  2013
				}				
sl@0
  2014
			else
sl@0
  2015
				{
sl@0
  2016
				INFO_PRINTF1(_L("Succesfully completed Async Write"));
sl@0
  2017
				}
sl@0
  2018
			iWriteCallbackArray.Remove(index);				
sl@0
  2019
			delete aActive;			
sl@0
  2020
	 		}
sl@0
  2021
		}	
sl@0
  2022
		
sl@0
  2023
	count=iFlushCallbackArray.Count();
sl@0
  2024
	for( index=0; (index<count) && (!foundActiveObject); ++index )
sl@0
  2025
 		{
sl@0
  2026
 		if( aActive == iFlushCallbackArray[index] )
sl@0
  2027
			{
sl@0
  2028
			foundActiveObject = ETrue;
sl@0
  2029
			TInt	err = aActive->iStatus.Int();
sl@0
  2030
			
sl@0
  2031
			if( err != KErrNone )
sl@0
  2032
				{
sl@0
  2033
				ERR_PRINTF2(_L("Async Flush Error %d"), err);
sl@0
  2034
				SetAsyncError( aIndex, err );
sl@0
  2035
				}				
sl@0
  2036
			iFlushCallbackArray.Remove(index);				
sl@0
  2037
			delete aActive;			
sl@0
  2038
	 		}
sl@0
  2039
		}				
sl@0
  2040
	
sl@0
  2041
	DecOutstanding();
sl@0
  2042
	}
sl@0
  2043
sl@0
  2044
void CT_FileData::PrintFileAttributes(TUint aAttValue)
sl@0
  2045
/** Prints file attributes */
sl@0
  2046
	{
sl@0
  2047
	if ((aAttValue & KEntryAttNormal) == KEntryAttNormal)
sl@0
  2048
		{
sl@0
  2049
		INFO_PRINTF1(_L("KEntryAttNormal"));
sl@0
  2050
		}
sl@0
  2051
	if ((aAttValue & KEntryAttReadOnly) == KEntryAttReadOnly)
sl@0
  2052
		{
sl@0
  2053
		INFO_PRINTF1(_L("KEntryAttReadOnly"));
sl@0
  2054
		}
sl@0
  2055
		
sl@0
  2056
	if ((aAttValue & KEntryAttHidden) == KEntryAttHidden)
sl@0
  2057
		{
sl@0
  2058
		INFO_PRINTF1(_L("KEntryAttHidden"));
sl@0
  2059
		}
sl@0
  2060
sl@0
  2061
	if ((aAttValue & KEntryAttSystem) == KEntryAttSystem)
sl@0
  2062
		{
sl@0
  2063
		INFO_PRINTF1(_L("KEntryAttSystem"));
sl@0
  2064
		}
sl@0
  2065
sl@0
  2066
	if ((aAttValue & KEntryAttVolume) == KEntryAttVolume)
sl@0
  2067
		{
sl@0
  2068
		INFO_PRINTF1(_L("KEntryAttVolume"));
sl@0
  2069
		}
sl@0
  2070
sl@0
  2071
	if ((aAttValue & KEntryAttDir) == KEntryAttDir)
sl@0
  2072
		{
sl@0
  2073
		INFO_PRINTF1(_L("KEntryAttDir"));
sl@0
  2074
		}
sl@0
  2075
sl@0
  2076
	if ((aAttValue & KEntryAttArchive) == KEntryAttArchive)
sl@0
  2077
		{
sl@0
  2078
		INFO_PRINTF1(_L("KEntryAttArchive"));
sl@0
  2079
		}
sl@0
  2080
sl@0
  2081
	if ((aAttValue & KEntryAttXIP) == KEntryAttXIP)
sl@0
  2082
		{
sl@0
  2083
		INFO_PRINTF1(_L("KEntryAttXIP"));
sl@0
  2084
		}
sl@0
  2085
sl@0
  2086
	if ((aAttValue & KEntryAttRemote) == KEntryAttRemote)
sl@0
  2087
		{
sl@0
  2088
		INFO_PRINTF1(_L("KEntryAttRemote"));
sl@0
  2089
		}	
sl@0
  2090
	}
sl@0
  2091