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.
20 #include "T_EComResolverParamsData.h"
25 _LIT(KExpectedString, "expected_string");
26 _LIT(KExpectedBool, "expected_bool");
27 _LIT(KDataType, "data_type");
28 _LIT(KGenericMatch, "generic_match");
29 _LIT(KWildcardMatch, "wildcard_match");
31 /// TEcomResolverParams
32 _LIT(KCmdDataType, "DataType");
33 _LIT(KCmdSetDataType, "SetDataType");
34 _LIT(KCmdSetGenericMatch, "SetGenericMatch");
35 _LIT(KCmdIsGenericMatch, "IsGenericMatch");
36 _LIT(KCmdSetWildcardMatch, "SetWildcardMatch");
37 _LIT(KCmdIsWildcardMatch, "IsWildcardMatch");
39 _LIT( KEmptyString, "");
42 //////////////////////////////////////////////////////////////////////
43 // Construction/Destruction
44 //////////////////////////////////////////////////////////////////////
47 * Two phase constructor
49 CT_EComResolverParamsData* CT_EComResolverParamsData::NewL()
51 CT_EComResolverParamsData* ret=new (ELeave) CT_EComResolverParamsData();
52 CleanupStack::PushL(ret);
54 CleanupStack::Pop(ret);
59 * Constructor. First phase construction
61 CT_EComResolverParamsData::CT_EComResolverParamsData()
66 * Second phase construction
68 void CT_EComResolverParamsData::ConstructL()
75 CT_EComResolverParamsData::~CT_EComResolverParamsData()
80 void CT_EComResolverParamsData::DestroyData()
85 TAny* CT_EComResolverParamsData::GetObject()
87 * Return a pointer to the object that the data wraps
89 * @return Pointer to the object that the data wraps
92 return &iResolverParams;
95 //////////////////////////////////////////////////////////////////////
96 // Read data from INI file
97 //////////////////////////////////////////////////////////////////////
99 TBool CT_EComResolverParamsData::GetExpectedString(const TDesC& aSection, TPtrC& aExpectedString)
101 aExpectedString.Set(KEmptyString);
102 return GetStringFromConfig(aSection, KExpectedString(), aExpectedString);
105 TBool CT_EComResolverParamsData::GetDataType(const TDesC& aSection, TBuf8<KMaxTestExecuteCommandLength>& aDataType)
107 TPtrC dataType(KEmptyString);
108 TBool ret=GetStringFromConfig(aSection, KDataType(), dataType);
111 aDataType.Copy(dataType);
116 TBool CT_EComResolverParamsData::GetExpectedBool(const TDesC& aSection, TBool& aBool)
119 return GetBoolFromConfig(aSection, KExpectedBool(), aBool );
122 TBool CT_EComResolverParamsData::GetGenericMatch(const TDesC& aSection, TBool& aGenericMatch)
124 aGenericMatch = EFalse;
125 return GetBoolFromConfig(aSection, KGenericMatch(), aGenericMatch );
128 TBool CT_EComResolverParamsData::GetWildcardMatch(const TDesC& aSection, TBool& aWildcardMatch)
130 aWildcardMatch = EFalse;
131 return GetBoolFromConfig(aSection, KWildcardMatch(), aWildcardMatch );
134 TBool CT_EComResolverParamsData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/)
136 * Process a command read from the ini file
138 * @param aCommand The command to process
139 * @param aSection The section in the ini containing data for the command
140 * @param aAsyncErrorIndex Command index for async calls to return errors to
142 * @return ETrue if the command is processed
144 * @leave System wide error
149 if ( aCommand==KCmdDataType )
151 DoCmdDataType(aSection);
153 else if ( aCommand==KCmdSetDataType )
155 DoCmdSetDataType(aSection);
157 else if ( aCommand==KCmdSetGenericMatch )
159 DoCmdSetGenericMatch(aSection);
161 else if ( aCommand==KCmdIsGenericMatch )
163 DoCmdIsGenericMatch(aSection);
165 else if ( aCommand==KCmdSetWildcardMatch )
167 DoCmdSetWildcardMatch(aSection);
169 else if ( aCommand==KCmdIsWildcardMatch )
171 DoCmdIsWildcardMatch(aSection);
181 void CT_EComResolverParamsData::DoCmdDataType(const TDesC& aSection)
183 TBuf<KMaxTestExecuteCommandLength> actualValue;
184 actualValue.Copy(iResolverParams.DataType());
185 INFO_PRINTF2(_L("DataType %S"), &actualValue);
188 if (GetExpectedString(aSection, expectedValue))
190 if (actualValue!=expectedValue)
192 ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue);
193 SetBlockResult(EFail);
198 void CT_EComResolverParamsData::DoCmdSetDataType(const TDesC& aSection)
200 if (!GetDataType(aSection, iDataType))
202 ERR_PRINTF1(_L("Not enought arguments"));
203 SetBlockResult(EFail);
207 iResolverParams.SetDataType(iDataType);
211 void CT_EComResolverParamsData::DoCmdSetGenericMatch(const TDesC& aSection)
213 TBool setGenericMatch;
214 if (!GetGenericMatch(aSection, setGenericMatch))
216 ERR_PRINTF1(_L("Not enought arguments"));
217 SetBlockResult(EFail);
221 iResolverParams.SetGenericMatch(setGenericMatch);
225 void CT_EComResolverParamsData::DoCmdIsGenericMatch(const TDesC& aSection)
227 TBool actualValue=iResolverParams.IsGenericMatch();
228 INFO_PRINTF2(_L("IsGenericMatch %d"), actualValue);
231 if (GetExpectedBool(aSection, expectedValue))
233 if (actualValue!=expectedValue)
235 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
236 SetBlockResult(EFail);
241 void CT_EComResolverParamsData::DoCmdSetWildcardMatch(const TDesC& aSection)
243 TBool setWildcardMatch;
244 if (!GetWildcardMatch(aSection, setWildcardMatch))
246 ERR_PRINTF1(_L("Not enought arguments"));
247 SetBlockResult(EFail);
251 iResolverParams.SetWildcardMatch(setWildcardMatch);
255 void CT_EComResolverParamsData::DoCmdIsWildcardMatch(const TDesC& aSection)
257 TBool actualValue=iResolverParams.IsWildcardMatch();
258 INFO_PRINTF2(_L("IsWildcardMatch %d"), actualValue);
261 if (GetExpectedBool(aSection, expectedValue))
263 if (actualValue!=expectedValue)
265 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue);
266 SetBlockResult(EFail);