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_ParseData.h"
23 _LIT( KCmdDelete, "~" );
24 _LIT( KCmdAddDir, "AddDir");
25 _LIT( KCmdPopDir, "PopDir");
26 _LIT( KCmdNew, "new" );
27 _LIT( KCmdSet, "Set" );
28 _LIT( KCmdSetNoWild, "SetNoWild" );
30 _LIT( KParamDefaultSpec, "DefaultSpec" );
31 _LIT( KParamFileSpec, "FileName" );
32 _LIT( KParamRelatedSpec, "RelatedSpec" );
33 _LIT( KParamDirName, "DirName" );
36 CT_ParseData* CT_ParseData::NewL()
38 * Two phase constructor
41 CT_ParseData* ret = new (ELeave) CT_ParseData();
42 CleanupStack::PushL( ret );
44 CleanupStack::Pop( ret );
48 TParseBase* CT_ParseData::GetParse()
54 CT_ParseData::CT_ParseData()
57 * Protected constructor. First phase construction
62 void CT_ParseData::ConstructL()
64 * Protected constructor. Second phase construction
69 CT_ParseData::~CT_ParseData()
78 TAny* CT_ParseData::GetObject()
80 * Return a pointer to the object that the data wraps
82 * @return pointer to the object that the data wraps
88 TBool CT_ParseData::DoCommandL( const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
90 * Process a command read from the ini file
92 * @param aCommand the command to process
93 * @param aSection the entry in the ini file requiring the command to be processed
95 * @return ETrue if the command is processed
100 if ( aCommand == KCmdDelete )
104 else if ( aCommand == KCmdNew )
108 else if ( aCommand == KCmdSet )
110 DoCmdSet( aSection );
112 else if ( aCommand == KCmdSetNoWild )
114 DoCmdSetNoWild( aSection );
116 else if ( aCommand == KCmdPopDir )
120 else if ( aCommand == KCmdAddDir )
122 DoCmdAddDir( aSection );
126 retVal = CT_ParseBaseData::DoCommandL(aCommand,aSection,aAsyncErrorIndex);
132 void CT_ParseData::DoCleanup()
133 /** Deletes TParse class instance */
135 INFO_PRINTF1( _L( "Delete TParse class instance." ) );
141 void CT_ParseData::DoCmdNew()
142 /** Creates new TParse class instance */
146 INFO_PRINTF1( _L( "Create new TParse class instance." ) );
148 TRAPD( err, iParse = new (ELeave) TParse() );
149 if ( err != KErrNone )
151 ERR_PRINTF2( _L( "new TParse error=%d" ), err );
156 void CT_ParseData::DoCmdSet( const TDesC& aSection )
159 if ( GET_MANDATORY_STRING_PARAMETER( KParamFileSpec, aSection, fileSpec ) )
161 TPtrC relatedSpec(_L(""));
162 GET_OPTIONAL_STRING_PARAMETER( KParamRelatedSpec, aSection, relatedSpec );
164 TPtrC defaultSpec(_L(""));
165 GET_OPTIONAL_STRING_PARAMETER( KParamDefaultSpec, aSection, defaultSpec );
167 INFO_PRINTF4( _L( "Set(%S, %S, %S)"), &fileSpec, &relatedSpec, &defaultSpec );
169 TInt error = iParse->Set( fileSpec, &relatedSpec, &defaultSpec );
171 if ( error != KErrNone)
173 ERR_PRINTF2( _L( "Set() returned %d error"), error);
179 void CT_ParseData::DoCmdSetNoWild( const TDesC& aSection )
182 if ( GET_MANDATORY_STRING_PARAMETER( KParamFileSpec, aSection, fileSpec ) )
184 TPtrC relatedSpec(_L(""));
185 GET_OPTIONAL_STRING_PARAMETER( KParamRelatedSpec, aSection, relatedSpec );
187 TPtrC defaultSpec(_L(""));
188 GET_OPTIONAL_STRING_PARAMETER( KParamDefaultSpec, aSection, defaultSpec );
190 INFO_PRINTF4( _L( "SetNoWild(%S, %S, %S)"), &fileSpec, &relatedSpec, &defaultSpec );
192 TInt error = iParse->SetNoWild( fileSpec, &relatedSpec, &defaultSpec );
194 if ( error != KErrNone)
196 ERR_PRINTF2( _L( "SetNoWild() returned %d error"), error);
203 void CT_ParseData::DoCmdPopDir()
204 /** Removes the last directory from the path using PopDir(). */
206 INFO_PRINTF1( _L( "PopDir()" ) );
208 TInt error = iParse->PopDir();
209 if( error != KErrNone)
211 ERR_PRINTF2( _L( "PopDir() returned %d error"), error);
217 void CT_ParseData::DoCmdAddDir( const TDesC& aSection )
218 /** Adds a single directory onto the end of the path using AddDir. */
221 if ( GET_MANDATORY_STRING_PARAMETER( KParamDirName, aSection, dirName ) )
223 INFO_PRINTF2( _L( "AddDir(\"%S\")" ), &dirName );
225 TInt error = iParse->AddDir( dirName );
226 if( error != KErrNone)
228 ERR_PRINTF2( _L( "AddDir() returned %d error"), error);