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