|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
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". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "T_EComResolverParamsData.h" |
|
21 |
|
22 |
|
23 /*@{*/ |
|
24 /// Parameters |
|
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"); |
|
30 |
|
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"); |
|
38 |
|
39 _LIT( KEmptyString, ""); |
|
40 /*@}*/ |
|
41 |
|
42 ////////////////////////////////////////////////////////////////////// |
|
43 // Construction/Destruction |
|
44 ////////////////////////////////////////////////////////////////////// |
|
45 |
|
46 /** |
|
47 * Two phase constructor |
|
48 */ |
|
49 CT_EComResolverParamsData* CT_EComResolverParamsData::NewL() |
|
50 { |
|
51 CT_EComResolverParamsData* ret=new (ELeave) CT_EComResolverParamsData(); |
|
52 CleanupStack::PushL(ret); |
|
53 ret->ConstructL(); |
|
54 CleanupStack::Pop(ret); |
|
55 return ret; |
|
56 } |
|
57 |
|
58 /** |
|
59 * Constructor. First phase construction |
|
60 */ |
|
61 CT_EComResolverParamsData::CT_EComResolverParamsData() |
|
62 { |
|
63 } |
|
64 |
|
65 /** |
|
66 * Second phase construction |
|
67 */ |
|
68 void CT_EComResolverParamsData::ConstructL() |
|
69 { |
|
70 } |
|
71 |
|
72 /** |
|
73 * Destructor |
|
74 */ |
|
75 CT_EComResolverParamsData::~CT_EComResolverParamsData() |
|
76 { |
|
77 DestroyData(); |
|
78 } |
|
79 |
|
80 void CT_EComResolverParamsData::DestroyData() |
|
81 { |
|
82 } |
|
83 |
|
84 |
|
85 TAny* CT_EComResolverParamsData::GetObject() |
|
86 /** |
|
87 * Return a pointer to the object that the data wraps |
|
88 * |
|
89 * @return Pointer to the object that the data wraps |
|
90 */ |
|
91 { |
|
92 return &iResolverParams; |
|
93 }; |
|
94 |
|
95 ////////////////////////////////////////////////////////////////////// |
|
96 // Read data from INI file |
|
97 ////////////////////////////////////////////////////////////////////// |
|
98 |
|
99 TBool CT_EComResolverParamsData::GetExpectedString(const TDesC& aSection, TPtrC& aExpectedString) |
|
100 { |
|
101 aExpectedString.Set(KEmptyString); |
|
102 return GetStringFromConfig(aSection, KExpectedString(), aExpectedString); |
|
103 } |
|
104 |
|
105 TBool CT_EComResolverParamsData::GetDataType(const TDesC& aSection, TBuf8<KMaxTestExecuteCommandLength>& aDataType) |
|
106 { |
|
107 TPtrC dataType(KEmptyString); |
|
108 TBool ret=GetStringFromConfig(aSection, KDataType(), dataType); |
|
109 if ( ret ) |
|
110 { |
|
111 aDataType.Copy(dataType); |
|
112 } |
|
113 return ret; |
|
114 } |
|
115 |
|
116 TBool CT_EComResolverParamsData::GetExpectedBool(const TDesC& aSection, TBool& aBool) |
|
117 { |
|
118 aBool = EFalse; |
|
119 return GetBoolFromConfig(aSection, KExpectedBool(), aBool ); |
|
120 } |
|
121 |
|
122 TBool CT_EComResolverParamsData::GetGenericMatch(const TDesC& aSection, TBool& aGenericMatch) |
|
123 { |
|
124 aGenericMatch = EFalse; |
|
125 return GetBoolFromConfig(aSection, KGenericMatch(), aGenericMatch ); |
|
126 } |
|
127 |
|
128 TBool CT_EComResolverParamsData::GetWildcardMatch(const TDesC& aSection, TBool& aWildcardMatch) |
|
129 { |
|
130 aWildcardMatch = EFalse; |
|
131 return GetBoolFromConfig(aSection, KWildcardMatch(), aWildcardMatch ); |
|
132 } |
|
133 |
|
134 TBool CT_EComResolverParamsData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
135 /** |
|
136 * Process a command read from the ini file |
|
137 * |
|
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 |
|
141 * |
|
142 * @return ETrue if the command is processed |
|
143 * |
|
144 * @leave System wide error |
|
145 */ |
|
146 { |
|
147 TBool retVal=ETrue; |
|
148 |
|
149 if ( aCommand==KCmdDataType ) |
|
150 { |
|
151 DoCmdDataType(aSection); |
|
152 } |
|
153 else if ( aCommand==KCmdSetDataType ) |
|
154 { |
|
155 DoCmdSetDataType(aSection); |
|
156 } |
|
157 else if ( aCommand==KCmdSetGenericMatch ) |
|
158 { |
|
159 DoCmdSetGenericMatch(aSection); |
|
160 } |
|
161 else if ( aCommand==KCmdIsGenericMatch ) |
|
162 { |
|
163 DoCmdIsGenericMatch(aSection); |
|
164 } |
|
165 else if ( aCommand==KCmdSetWildcardMatch ) |
|
166 { |
|
167 DoCmdSetWildcardMatch(aSection); |
|
168 } |
|
169 else if ( aCommand==KCmdIsWildcardMatch ) |
|
170 { |
|
171 DoCmdIsWildcardMatch(aSection); |
|
172 } |
|
173 else |
|
174 { |
|
175 retVal=EFalse; |
|
176 } |
|
177 |
|
178 return retVal; |
|
179 } |
|
180 |
|
181 void CT_EComResolverParamsData::DoCmdDataType(const TDesC& aSection) |
|
182 { |
|
183 TBuf<KMaxTestExecuteCommandLength> actualValue; |
|
184 actualValue.Copy(iResolverParams.DataType()); |
|
185 INFO_PRINTF2(_L("DataType %S"), &actualValue); |
|
186 |
|
187 TPtrC expectedValue; |
|
188 if (GetExpectedString(aSection, expectedValue)) |
|
189 { |
|
190 if (actualValue!=expectedValue) |
|
191 { |
|
192 ERR_PRINTF3(_L("Actual value \"%S\" does not match expected value \"%S\""), &actualValue, &expectedValue); |
|
193 SetBlockResult(EFail); |
|
194 } |
|
195 } |
|
196 } |
|
197 |
|
198 void CT_EComResolverParamsData::DoCmdSetDataType(const TDesC& aSection) |
|
199 { |
|
200 if (!GetDataType(aSection, iDataType)) |
|
201 { |
|
202 ERR_PRINTF1(_L("Not enought arguments")); |
|
203 SetBlockResult(EFail); |
|
204 } |
|
205 else |
|
206 { |
|
207 iResolverParams.SetDataType(iDataType); |
|
208 } |
|
209 } |
|
210 |
|
211 void CT_EComResolverParamsData::DoCmdSetGenericMatch(const TDesC& aSection) |
|
212 { |
|
213 TBool setGenericMatch; |
|
214 if (!GetGenericMatch(aSection, setGenericMatch)) |
|
215 { |
|
216 ERR_PRINTF1(_L("Not enought arguments")); |
|
217 SetBlockResult(EFail); |
|
218 } |
|
219 else |
|
220 { |
|
221 iResolverParams.SetGenericMatch(setGenericMatch); |
|
222 } |
|
223 } |
|
224 |
|
225 void CT_EComResolverParamsData::DoCmdIsGenericMatch(const TDesC& aSection) |
|
226 { |
|
227 TBool actualValue=iResolverParams.IsGenericMatch(); |
|
228 INFO_PRINTF2(_L("IsGenericMatch %d"), actualValue); |
|
229 |
|
230 TBool expectedValue; |
|
231 if (GetExpectedBool(aSection, expectedValue)) |
|
232 { |
|
233 if (actualValue!=expectedValue) |
|
234 { |
|
235 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); |
|
236 SetBlockResult(EFail); |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 void CT_EComResolverParamsData::DoCmdSetWildcardMatch(const TDesC& aSection) |
|
242 { |
|
243 TBool setWildcardMatch; |
|
244 if (!GetWildcardMatch(aSection, setWildcardMatch)) |
|
245 { |
|
246 ERR_PRINTF1(_L("Not enought arguments")); |
|
247 SetBlockResult(EFail); |
|
248 } |
|
249 else |
|
250 { |
|
251 iResolverParams.SetWildcardMatch(setWildcardMatch); |
|
252 } |
|
253 } |
|
254 |
|
255 void CT_EComResolverParamsData::DoCmdIsWildcardMatch(const TDesC& aSection) |
|
256 { |
|
257 TBool actualValue=iResolverParams.IsWildcardMatch(); |
|
258 INFO_PRINTF2(_L("IsWildcardMatch %d"), actualValue); |
|
259 |
|
260 TBool expectedValue; |
|
261 if (GetExpectedBool(aSection, expectedValue)) |
|
262 { |
|
263 if (actualValue!=expectedValue) |
|
264 { |
|
265 ERR_PRINTF3(_L("Actual value %d does not match expected value %d"), actualValue, expectedValue); |
|
266 SetBlockResult(EFail); |
|
267 } |
|
268 } |
|
269 } |
|
270 |