os/kernelhwsrv/baseapitest/basesvs/validation/f32/sfsrv/src/T_EntryArrayData.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
#include "T_EntryArrayData.h"
sl@0
    20
#include "T_EntryData.h"
sl@0
    21
#include "FileserverUtil.h"
sl@0
    22
sl@0
    23
// Commands
sl@0
    24
_LIT( KCmdCount,				"count" );
sl@0
    25
_LIT( KCmdDelete,				"~" );
sl@0
    26
_LIT( KCmdNew,					"new" );
sl@0
    27
_LIT( KCmdIndexOperator,		"[]" );
sl@0
    28
sl@0
    29
// Parameters
sl@0
    30
_LIT( KParamDestination,		"destination" );
sl@0
    31
_LIT( KParamExpected,			"expected" );
sl@0
    32
_LIT( KParamIndex,				"index" );
sl@0
    33
sl@0
    34
sl@0
    35
CT_EntryArrayData* CT_EntryArrayData::NewL()
sl@0
    36
/**
sl@0
    37
* Two phase constructor
sl@0
    38
*/
sl@0
    39
	{
sl@0
    40
	CT_EntryArrayData* ret = new (ELeave) CT_EntryArrayData();
sl@0
    41
	CleanupStack::PushL( ret );
sl@0
    42
	ret->ConstructL();
sl@0
    43
	CleanupStack::Pop( ret );
sl@0
    44
	return ret;
sl@0
    45
	}
sl@0
    46
sl@0
    47
CT_EntryArrayData::CT_EntryArrayData()
sl@0
    48
:	iEntryArray(NULL)
sl@0
    49
/**
sl@0
    50
* Protected constructor. First phase construction
sl@0
    51
*/
sl@0
    52
	{
sl@0
    53
	}
sl@0
    54
	
sl@0
    55
void CT_EntryArrayData::ConstructL()
sl@0
    56
/**
sl@0
    57
* Protected constructor. Second phase construction
sl@0
    58
*/
sl@0
    59
	{
sl@0
    60
	}
sl@0
    61
	
sl@0
    62
CT_EntryArrayData::~CT_EntryArrayData()
sl@0
    63
/**
sl@0
    64
* Destructor.
sl@0
    65
*/
sl@0
    66
sl@0
    67
	{
sl@0
    68
	DoCmdDelete();
sl@0
    69
	}
sl@0
    70
	
sl@0
    71
TAny* CT_EntryArrayData::GetObject()
sl@0
    72
/**
sl@0
    73
* Return a pointer to the object that the data wraps
sl@0
    74
*
sl@0
    75
* @return pointer to the object that the data wraps
sl@0
    76
*/
sl@0
    77
sl@0
    78
	{
sl@0
    79
	return iEntryArray;
sl@0
    80
	}
sl@0
    81
sl@0
    82
TBool CT_EntryArrayData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/ )
sl@0
    83
/**
sl@0
    84
* Process a command read from the ini file
sl@0
    85
*
sl@0
    86
* @param aCommand	the command to process
sl@0
    87
* @param aSection		the entry in the ini file requiring the command to be processed
sl@0
    88
*
sl@0
    89
* @return ETrue if the command is processed
sl@0
    90
*/	
sl@0
    91
	{
sl@0
    92
	TBool retVal = ETrue;
sl@0
    93
	
sl@0
    94
	if ( aCommand == KCmdIndexOperator )
sl@0
    95
		{
sl@0
    96
		DoCmdIndexOperatorL( aSection );
sl@0
    97
		}
sl@0
    98
	else if ( aCommand == KCmdCount )
sl@0
    99
		{
sl@0
   100
		DoCmdCount( aSection );
sl@0
   101
		}
sl@0
   102
	else if ( aCommand == KCmdDelete )
sl@0
   103
		{
sl@0
   104
		DoCmdDelete();
sl@0
   105
		}
sl@0
   106
	else if ( aCommand == KCmdNew )
sl@0
   107
		{
sl@0
   108
		DoCmdNew();
sl@0
   109
		}
sl@0
   110
	else
sl@0
   111
	    {
sl@0
   112
	    retVal = EFalse;    
sl@0
   113
	    }
sl@0
   114
	
sl@0
   115
	return retVal;
sl@0
   116
	}
sl@0
   117
	
sl@0
   118
void CT_EntryArrayData::DoCmdIndexOperatorL( const TDesC& aSection )
sl@0
   119
/**
sl@0
   120
* Assigns an element of TEntryArray to another TEntry object using "=" operator
sl@0
   121
*/
sl@0
   122
	{
sl@0
   123
	TInt index;
sl@0
   124
	TPtrC entryObjectName;
sl@0
   125
	
sl@0
   126
	if( GET_MANDATORY_INT_PARAMETER( KParamIndex, aSection, index ) && 
sl@0
   127
		GET_MANDATORY_STRING_PARAMETER( KParamDestination, aSection, entryObjectName ))
sl@0
   128
		{
sl@0
   129
		TEntry* entry = new(ELeave) TEntry();
sl@0
   130
		CleanupStack::PushL(entry);
sl@0
   131
		
sl@0
   132
		*entry = iEntryArray->operator[](index);
sl@0
   133
		CT_EntryData* entryWrapperObject = static_cast<CT_EntryData*>(GetDataWrapperL(entryObjectName));
sl@0
   134
		
sl@0
   135
		if(!entryWrapperObject)
sl@0
   136
		    {
sl@0
   137
			ERR_PRINTF2(_L("%S is not initialised"), &entryObjectName);
sl@0
   138
		    SetBlockResult(EFail); 
sl@0
   139
		    CleanupStack::PopAndDestroy(entry);
sl@0
   140
		    }
sl@0
   141
		else
sl@0
   142
			{
sl@0
   143
			entryWrapperObject->SetObjectL(entry);
sl@0
   144
			CleanupStack::Pop(entry);
sl@0
   145
			}
sl@0
   146
		}
sl@0
   147
	}
sl@0
   148
	
sl@0
   149
void CT_EntryArrayData::DoCmdCount( const TDesC& aSection )
sl@0
   150
/**
sl@0
   151
* Checks if TEntryArray has expected number of elements
sl@0
   152
*/
sl@0
   153
	{
sl@0
   154
	TInt expected;	
sl@0
   155
	if( GET_MANDATORY_INT_PARAMETER( KParamExpected, aSection, expected ) )
sl@0
   156
		{
sl@0
   157
		INFO_PRINTF2( _L( "Count(). Expected value = %d" ), expected );
sl@0
   158
		
sl@0
   159
		TInt result = iEntryArray->Count();
sl@0
   160
		if ( result != expected )
sl@0
   161
			{
sl@0
   162
			ERR_PRINTF3(_L("Count %d != expected %d"), result, expected );
sl@0
   163
			SetBlockResult( EFail );
sl@0
   164
			}
sl@0
   165
		}
sl@0
   166
	}
sl@0
   167
	
sl@0
   168
void CT_EntryArrayData::DoCmdDelete()
sl@0
   169
/**
sl@0
   170
* Deletes TEntryArray class instance
sl@0
   171
*/
sl@0
   172
    {
sl@0
   173
	DoCleanup();
sl@0
   174
    }
sl@0
   175
	
sl@0
   176
void CT_EntryArrayData::DoCmdNew()
sl@0
   177
/**
sl@0
   178
* Creates new TEntryArray class instance
sl@0
   179
*/
sl@0
   180
	{
sl@0
   181
	DoCmdDelete();
sl@0
   182
	
sl@0
   183
	INFO_PRINTF1( _L( "Create new TEntryArray() class instance." ) );
sl@0
   184
	TRAPD( err, iEntryArray = new (ELeave) TEntryArray() );
sl@0
   185
	if ( err != KErrNone )
sl@0
   186
		{
sl@0
   187
		ERR_PRINTF2( _L( "new TEntryArray() error %d" ), err );
sl@0
   188
		SetBlockResult( EFail );
sl@0
   189
		}
sl@0
   190
	}
sl@0
   191
	
sl@0
   192
	
sl@0
   193
void CT_EntryArrayData::SetObjectL( TAny* aAny )
sl@0
   194
/**
sl@0
   195
* Set the wrapped data object with new value
sl@0
   196
*/
sl@0
   197
	{
sl@0
   198
	DoCleanup();
sl@0
   199
	iEntryArray = static_cast<TEntryArray*> ( aAny );
sl@0
   200
	}
sl@0
   201
	
sl@0
   202
void CT_EntryArrayData::DoCleanup()
sl@0
   203
/** Deltes TEntry class instance */
sl@0
   204
    {
sl@0
   205
	INFO_PRINTF1( _L( "Delete TEntryArray class instance" ) );
sl@0
   206
	delete iEntryArray;
sl@0
   207
	iEntryArray = NULL;
sl@0
   208
    }
sl@0
   209
sl@0
   210