Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "T_EntryArrayData.h"
20 #include "T_EntryData.h"
21 #include "FileserverUtil.h"
24 _LIT( KCmdCount, "count" );
25 _LIT( KCmdDelete, "~" );
26 _LIT( KCmdNew, "new" );
27 _LIT( KCmdIndexOperator, "[]" );
30 _LIT( KParamDestination, "destination" );
31 _LIT( KParamExpected, "expected" );
32 _LIT( KParamIndex, "index" );
35 CT_EntryArrayData* CT_EntryArrayData::NewL()
37 * Two phase constructor
40 CT_EntryArrayData* ret = new (ELeave) CT_EntryArrayData();
41 CleanupStack::PushL( ret );
43 CleanupStack::Pop( ret );
47 CT_EntryArrayData::CT_EntryArrayData()
50 * Protected constructor. First phase construction
55 void CT_EntryArrayData::ConstructL()
57 * Protected constructor. Second phase construction
62 CT_EntryArrayData::~CT_EntryArrayData()
71 TAny* CT_EntryArrayData::GetObject()
73 * Return a pointer to the object that the data wraps
75 * @return pointer to the object that the data wraps
82 TBool CT_EntryArrayData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/ )
84 * Process a command read from the ini file
86 * @param aCommand the command to process
87 * @param aSection the entry in the ini file requiring the command to be processed
89 * @return ETrue if the command is processed
94 if ( aCommand == KCmdIndexOperator )
96 DoCmdIndexOperatorL( aSection );
98 else if ( aCommand == KCmdCount )
100 DoCmdCount( aSection );
102 else if ( aCommand == KCmdDelete )
106 else if ( aCommand == KCmdNew )
118 void CT_EntryArrayData::DoCmdIndexOperatorL( const TDesC& aSection )
120 * Assigns an element of TEntryArray to another TEntry object using "=" operator
124 TPtrC entryObjectName;
126 if( GET_MANDATORY_INT_PARAMETER( KParamIndex, aSection, index ) &&
127 GET_MANDATORY_STRING_PARAMETER( KParamDestination, aSection, entryObjectName ))
129 TEntry* entry = new(ELeave) TEntry();
130 CleanupStack::PushL(entry);
132 *entry = iEntryArray->operator[](index);
133 CT_EntryData* entryWrapperObject = static_cast<CT_EntryData*>(GetDataWrapperL(entryObjectName));
135 if(!entryWrapperObject)
137 ERR_PRINTF2(_L("%S is not initialised"), &entryObjectName);
138 SetBlockResult(EFail);
139 CleanupStack::PopAndDestroy(entry);
143 entryWrapperObject->SetObjectL(entry);
144 CleanupStack::Pop(entry);
149 void CT_EntryArrayData::DoCmdCount( const TDesC& aSection )
151 * Checks if TEntryArray has expected number of elements
155 if( GET_MANDATORY_INT_PARAMETER( KParamExpected, aSection, expected ) )
157 INFO_PRINTF2( _L( "Count(). Expected value = %d" ), expected );
159 TInt result = iEntryArray->Count();
160 if ( result != expected )
162 ERR_PRINTF3(_L("Count %d != expected %d"), result, expected );
163 SetBlockResult( EFail );
168 void CT_EntryArrayData::DoCmdDelete()
170 * Deletes TEntryArray class instance
176 void CT_EntryArrayData::DoCmdNew()
178 * Creates new TEntryArray class instance
183 INFO_PRINTF1( _L( "Create new TEntryArray() class instance." ) );
184 TRAPD( err, iEntryArray = new (ELeave) TEntryArray() );
185 if ( err != KErrNone )
187 ERR_PRINTF2( _L( "new TEntryArray() error %d" ), err );
188 SetBlockResult( EFail );
193 void CT_EntryArrayData::SetObjectL( TAny* aAny )
195 * Set the wrapped data object with new value
199 iEntryArray = static_cast<TEntryArray*> ( aAny );
202 void CT_EntryArrayData::DoCleanup()
203 /** Deltes TEntry class instance */
205 INFO_PRINTF1( _L( "Delete TEntryArray class instance" ) );