0
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2006 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 the License "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: Abstract base class for all SIM ATK TSY tests classes.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef SATBASE_H
|
|
21 |
#define SATBASE_H
|
|
22 |
|
|
23 |
// INCLUDES
|
|
24 |
#include <e32base.h>
|
|
25 |
#include <testscripterinternal.h>
|
|
26 |
#include <etelsat.h>
|
|
27 |
|
|
28 |
// FORWARDS
|
|
29 |
class CStifItemParser;
|
|
30 |
class CStifLogger;
|
|
31 |
|
|
32 |
// DATA TYPES
|
|
33 |
typedef TInt TSatIpc;
|
|
34 |
|
|
35 |
// CLASS DECLARATION
|
|
36 |
|
|
37 |
/**
|
|
38 |
* Abstract base class for all SIM ATK TSY tests classes. Provides
|
|
39 |
* functionality to verify the received data against scripted values
|
|
40 |
* by providing general helper methods for all subclasses.
|
|
41 |
* @lib SimAtk.dll
|
|
42 |
*/
|
|
43 |
NONSHARABLE_CLASS( CSatBase ) : public CBase
|
|
44 |
{
|
|
45 |
public: // Constructors and destructor
|
|
46 |
|
|
47 |
/**
|
|
48 |
* Constructor.
|
|
49 |
*/
|
|
50 |
CSatBase( const TSatIpc aIpc, const RSat& aSat,
|
|
51 |
CStifItemParser& aParser, CStifLogger& aLog );
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Destructor.
|
|
55 |
*/
|
|
56 |
virtual ~CSatBase();
|
|
57 |
|
|
58 |
|
|
59 |
public: // Pure virtuals
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Pure virtual method. Must be overridden by subclasses.
|
|
63 |
* Method verifies the validity of received data by compaing
|
|
64 |
* them against scripted parameters.
|
|
65 |
* @return KErrNone if date was valid or KErrCorrupt if received data
|
|
66 |
* and script did not match.
|
|
67 |
*/
|
|
68 |
virtual TInt CheckData() = 0;
|
|
69 |
|
|
70 |
/**
|
|
71 |
* Pure virtual method. Must be overridden by subclasses.
|
|
72 |
* Method requests notifications from Etel for specific SAT feature
|
|
73 |
* and resets the internal data structure.
|
|
74 |
* @param aSimAtkStatus Reference to active object's request status
|
|
75 |
* @return KErrNone
|
|
76 |
*/
|
|
77 |
virtual TInt NotifySat( TRequestStatus& aSimAtkStatus ) = 0;
|
|
78 |
|
|
79 |
|
|
80 |
public: // New Methods
|
|
81 |
|
|
82 |
/**
|
|
83 |
* Cancels pending Etel request for current command.
|
|
84 |
* @return None
|
|
85 |
*/
|
|
86 |
void CancelRequest();
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Used to identify the Sat feature by IPC. Return appropriate
|
|
90 |
* boolean value.
|
|
91 |
* @return ETrue if provide IPC matches with the IPC of the feature.
|
|
92 |
* Otherwise EFalse is returned
|
|
93 |
*/
|
|
94 |
TBool MatchIpc( TSatIpc aRequestedIpc );
|
|
95 |
|
|
96 |
|
|
97 |
protected: // New Methods
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Helper method that verifies the validity of Address
|
|
101 |
* structure against scripted parameters.
|
|
102 |
* @param aAddress reference to Address structure which shall be verified
|
|
103 |
* @return KErrNone if data was valid, KErrCorrupt if received data
|
|
104 |
* and script did not match or KErrNotFound if script did not
|
|
105 |
* provide valid parameters.
|
|
106 |
*/
|
|
107 |
TInt CheckAddress( const RSat::TAddress& aAddress );
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Helper method that verifies the validity of AlphaId
|
|
111 |
* against scripted parameters.
|
|
112 |
* @param aAlphaId reference to AlphaId which shall be verified
|
|
113 |
* @param aAlphaIdTag Script tag which shall be used when parsing
|
|
114 |
* alphaId structure from the script. Default value is "AlphaId".
|
|
115 |
* @return KErrNone if data was valid, KErrCorrupt if received data
|
|
116 |
* and script did not match or KErrNotFound if script did not
|
|
117 |
* provide valid parameters.
|
|
118 |
*/
|
|
119 |
TInt CheckAlphaId( const RSat::TAlphaId& aAlphaId,
|
|
120 |
const TDesC& aAlphaIdTag = KNullDesC );
|
|
121 |
|
|
122 |
/**
|
|
123 |
* Helper method that verifies the validity of binary
|
|
124 |
* data buffer against scripted parameters.
|
|
125 |
* @param aTag Tag used to find reference binary data from script
|
|
126 |
* @param aData Contains data to be verified
|
|
127 |
* @return KErrNone if data was valid or KErrCorrupt if received data
|
|
128 |
* and script did not match. KErrNotFound if reference data was not
|
|
129 |
* found from the script.
|
|
130 |
*/
|
|
131 |
TInt CheckBuffer( const TDesC& aTag, const TDesC& aData );
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Helper method that verifies the validity of 8-bit binary
|
|
135 |
* data buffer against scripted parameters.
|
|
136 |
* @param aTag Tag used to find reference binary data from script
|
|
137 |
* @param aData Contains data to be verified
|
|
138 |
* @return KErrNone if data was valid or KErrCorrupt if received data
|
|
139 |
* and script did not match. KErrNotFound if reference data was not
|
|
140 |
* found from the script.
|
|
141 |
*/
|
|
142 |
TInt CheckBuffer( const TDesC& aTag, const TDesC8& aData );
|
|
143 |
|
|
144 |
/**
|
|
145 |
* Helper method that verifies the validity of Duration
|
|
146 |
* against scripted parameters. If script does not provide duration
|
|
147 |
* field, method verfifies that TimeUnit field is NoDurationAvailable
|
|
148 |
* and NumOfUnit is 0.
|
|
149 |
* @param aDuration reference to Duration which shall be verified
|
|
150 |
* @return KErrNone if data was valid, KErrCorrupt if received data
|
|
151 |
* and script did not match or KErrNotFound if script did not
|
|
152 |
* provide valid parameters.
|
|
153 |
*/
|
|
154 |
TInt CheckDuration( const RSat::TDuration& aDuration );
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Helper method that verifies the validity of Icon
|
|
158 |
* against scripted parameters. If script does not provide icon
|
|
159 |
* field, method verfifies that Qualifier field is NoIconId
|
|
160 |
* and identifier is 0.
|
|
161 |
* @param aIconId reference to Icon which shall be verified
|
|
162 |
* @param aIconTag Script tag which shall be used when parsing icon
|
|
163 |
* parameters from the script. Default value is "IconId".
|
|
164 |
* @return KErrNone if data was valid, KErrCorrupt if received data
|
|
165 |
* and script did not match or KErrNotFound if script did not
|
|
166 |
* provide valid parameters.
|
|
167 |
*/
|
|
168 |
TInt CheckIcon( const RSat::TIconId& aIconId,
|
|
169 |
const TDesC& aIconTag = KNullDesC );
|
|
170 |
|
|
171 |
#ifndef LEGACY
|
|
172 |
/**
|
|
173 |
* Helper method that verifies the validity of TTextAttribute
|
|
174 |
* against scripted parameters.
|
|
175 |
* @param aTa reference to TTextAttribute which shall be verified
|
|
176 |
* @return KErrNone if data was valid, KErrCorrupt if received data
|
|
177 |
* and script did not match or KErrArgument if script did not
|
|
178 |
* provide valid parameters.
|
|
179 |
*/
|
|
180 |
TInt CheckTextAttribute( const RSat::TTextAttribute& aTa );
|
|
181 |
#endif // LEGACY
|
|
182 |
|
|
183 |
/**
|
|
184 |
* Helper method that verifies the validity of text data against the
|
|
185 |
* scripted parameters.
|
|
186 |
* @param aTag Tag used to find text data from script
|
|
187 |
* @param aData Contains the text to be verified
|
|
188 |
* @return KErrNone if data was valid or KErrCorrupt if received data
|
|
189 |
* and script did not match. KErrNotFound if reference data was not
|
|
190 |
* found from the script.
|
|
191 |
*/
|
|
192 |
TInt CheckText( const TDesC& aTag, const TDesC& aData );
|
|
193 |
|
|
194 |
/**
|
|
195 |
* Helper method that verifies the validity of 8-bit text data against
|
|
196 |
* the scripted parameters.
|
|
197 |
* @param aTag Tag used to find text data from script
|
|
198 |
* @param aData Contains the text to be verified
|
|
199 |
* @return KErrNone if data was valid or KErrCorrupt if received data
|
|
200 |
* and script did not match. KErrNotFound if reference data was not
|
|
201 |
* found from the script.
|
|
202 |
*/
|
|
203 |
TInt CheckText( const TDesC& aTag, const TDesC8& aData );
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Helper method that verifies the validity of provided value against
|
|
207 |
* the scripted parameters.
|
|
208 |
* @param aTag Tag used to find text data from script
|
|
209 |
* @param aValue Contains the value to be verified
|
|
210 |
* @param aDefault When reference value isn't found from the script,
|
|
211 |
* verification is made againts the default value when provided.
|
|
212 |
* @return KErrNone if value was valid or KErrCorrupt if not.
|
|
213 |
* KErrNotFound if reference data was not found from the script and
|
|
214 |
* default value was not supported.
|
|
215 |
*/
|
|
216 |
TInt CheckValue( const TDesC& aTag, const TInt& aValue,
|
|
217 |
const TInt aDefault = KMaxTInt );
|
|
218 |
|
|
219 |
/**
|
|
220 |
* Helper method that verifies the validity of provided value against
|
|
221 |
* next value parsed from the script. Must not be used alone: use
|
|
222 |
* CheckValue first to find correct position in the script.
|
|
223 |
* @param aValue Contains the value to be verified
|
|
224 |
* @param aDefault When reference value isn't found from the script,
|
|
225 |
* verification is made againts the default value when provided.
|
|
226 |
* @return KErrNone if value was valid or KErrCorrupt if not.
|
|
227 |
* KErrNotFound if reference data was not found from the script and
|
|
228 |
* default value was not supported.
|
|
229 |
*/
|
|
230 |
TInt CheckNextValue( const TInt& aValue,
|
|
231 |
const TInt aDefault = KMaxTInt );
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Helper method that parses address structure from the script.
|
|
235 |
* Structure consist of three parameters, address, type of number and
|
|
236 |
* numbering plan. Address is mandatory. If TON and NPI are missing,
|
|
237 |
* defaults are used. Address can provided in one of the following
|
|
238 |
* formats:
|
|
239 |
* Address "address"
|
|
240 |
* Address "address" TON
|
|
241 |
* Address "address" TON NPI
|
|
242 |
* @param aAddress reference to packet which shall be constructed
|
|
243 |
* @return KErrNone or KErrNotFound if address was missing
|
|
244 |
*/
|
|
245 |
TInt GetAddress( RSat::TAddress& aAddress );
|
|
246 |
|
|
247 |
/*
|
|
248 |
* Method reads data from the script with given tag to a buffer.
|
|
249 |
* @param aTag Tag used to find data from script
|
|
250 |
* @param aBuffer Output where data is read to
|
|
251 |
* @return KErrNone if successful or system wide error code if not.
|
|
252 |
*/
|
|
253 |
TInt GetBuffer( const TDesC& aTag, TDes& aBuffer );
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Helper method reads requested value from the script. Format of
|
|
257 |
* scripted number can be given as argument, decimal is the default.
|
|
258 |
* @param aTag Tag used to find value from script
|
|
259 |
* @param aValue Value read from the script.
|
|
260 |
* @param aRadix Number format of scripted value.
|
|
261 |
* @return KErrNone if valid value was found or KErrCorrupt if not.
|
|
262 |
* KErrNotFound if value with provided tag was not found.
|
|
263 |
*/
|
|
264 |
TInt GetValue( const TDesC& aTag, TInt& aValue,
|
|
265 |
TRadix aRadix = EDecimal );
|
|
266 |
|
|
267 |
/**
|
|
268 |
* Helper method reads requested value from the script. Templated
|
|
269 |
* parameter enables reading typed parameters from the script.
|
|
270 |
* Declaration and implementation of template fuctions has to be
|
|
271 |
* in the same complilation unit ( = file )
|
|
272 |
* @param aTag Tag used to find value from script
|
|
273 |
* @param aValue Value read from the script.
|
|
274 |
* @param aRadix Number format of scripted value.
|
|
275 |
* @return KErrNone if valid value was found or KErrCorrupt if not.
|
|
276 |
* KErrNotFound if value with provided tag was not found.
|
|
277 |
*/
|
|
278 |
template <typename TGenType>
|
|
279 |
TInt GetValue( const TDesC& aTag, TGenType& aType,
|
|
280 |
TRadix aRadix = EDecimal )
|
|
281 |
{
|
|
282 |
return GetValue( aTag, reinterpret_cast<TInt&>( aType ), aRadix );
|
|
283 |
}
|
|
284 |
|
|
285 |
/**
|
|
286 |
* Helper method reads next value from the script. Format of
|
|
287 |
* scripted number can be given as argument, decimal is the default.
|
|
288 |
* Must not be used alone: use GetValue first to find correct position
|
|
289 |
* in the script.
|
|
290 |
* @param aValue Value read from the script.
|
|
291 |
* @return KErrNone if valid value was found or KErrCorrupt if not.
|
|
292 |
* KErrNotFound if value with provided tag was not found.
|
|
293 |
*/
|
|
294 |
TInt GetNextValue( TInt& aValue, TRadix aRadix = EDecimal );
|
|
295 |
|
|
296 |
/**
|
|
297 |
* Helper method that parses specific text string from the script as
|
|
298 |
* a value. Text can be presented as a quoted text string or by unicode
|
|
299 |
* hex values.
|
|
300 |
* @param aTag Tag used to find text from script
|
|
301 |
* @param aTextOutput Text output
|
|
302 |
* @return KErrNone or KErrNotFound no requested text strings wasn't
|
|
303 |
* found. KErrCorrupt if parsed string did not fit to output buffer.
|
|
304 |
*/
|
|
305 |
TInt GetText( const TDesC& aTag, TDes& aText );
|
|
306 |
|
|
307 |
/**
|
|
308 |
* Helper method that parses specific text string from the script as
|
|
309 |
* a reference. Text can be presented as a quoted text string or by
|
|
310 |
* unicode hex values.
|
|
311 |
* @param aTag Tag used to find text from script
|
|
312 |
* @param aText Text output
|
|
313 |
* @param aGetNext Specifies the parsing method. Used internally.
|
|
314 |
* @return KErrNone or KErrNotFound no requested text strings wasn't
|
|
315 |
* found. KErrCorrupt if parsed string did not fit to output buffer.
|
|
316 |
*/
|
|
317 |
TInt GetText( const TDesC& aTag, TPtrC& aText,
|
|
318 |
TBool aGetNext = EFalse );
|
|
319 |
|
|
320 |
/**
|
|
321 |
* Helper method reads next text string from the script as a reference.
|
|
322 |
* Must not be used alone: use GetText first to find correct position
|
|
323 |
* in the script.
|
|
324 |
* @param aTag Tag used to find text from script
|
|
325 |
* @param aTextOutput Text output
|
|
326 |
* @return KErrNone or KErrNotFound no requested text strings wasn't
|
|
327 |
* found. KErrCorrupt if parsed string did not fit to output buffer.
|
|
328 |
*/
|
|
329 |
TInt GetNextText( const TDesC& aTag, TPtrC& aText );
|
|
330 |
|
|
331 |
/**
|
|
332 |
* Helper method that parses UssdString structure from the script.
|
|
333 |
* UssdString can provided in one of the following formats:
|
|
334 |
* UssdString "string"
|
|
335 |
* UssdSting "string" DCS
|
|
336 |
* @param aUssdString reference to packet which shall be constructed
|
|
337 |
* @return KErrNone or KErrNotFound if string was missing
|
|
338 |
*/
|
|
339 |
TInt GetUssdString( RSat::TUssdString& aUssdString );
|
|
340 |
|
|
341 |
/**
|
|
342 |
* Template method that is used to initiate data structures with
|
|
343 |
* default values.
|
|
344 |
* Declaration and implementation of template fuctions has to be
|
|
345 |
* in the same complilation unit ( = file )
|
|
346 |
* @param aType Type to be initialized.
|
|
347 |
*/
|
|
348 |
template <typename TGenType>
|
|
349 |
void Init( TGenType& aType )
|
|
350 |
{
|
|
351 |
aType = TGenType();
|
|
352 |
}
|
|
353 |
|
|
354 |
|
|
355 |
private: // New methods
|
|
356 |
|
|
357 |
/**
|
|
358 |
* Method converts Hex-tagged integers with in a text string to
|
|
359 |
* hex numbers. Example in string "\x0F" -> value 0Fh in buffer.
|
|
360 |
* @param aString String to be converted
|
|
361 |
* @return None
|
|
362 |
*/
|
|
363 |
void ConvertHexTags( TDes& aString );
|
|
364 |
|
|
365 |
/**
|
|
366 |
* Method converts a string presentation of value to a integer.
|
|
367 |
* @param aNumberAsString String conteining the number
|
|
368 |
* @param aRadix Defines the number format of string. Hex of decimal
|
|
369 |
* @param aValue Number output
|
|
370 |
* @return KErrNone if successful or system wide error code if not.
|
|
371 |
*/
|
|
372 |
TInt ConvertToNumber( TPtrC& aNumberAsString, TRadix aRadix,
|
|
373 |
TInt& aValue );
|
|
374 |
|
|
375 |
|
|
376 |
protected: // Data
|
|
377 |
|
|
378 |
/**
|
|
379 |
* Reference to SAT
|
|
380 |
*/
|
|
381 |
const RSat& iSat;
|
|
382 |
|
|
383 |
/**
|
|
384 |
* Reference to logger
|
|
385 |
*/
|
|
386 |
CStifLogger& iLog;
|
|
387 |
|
|
388 |
|
|
389 |
private: // Data
|
|
390 |
|
|
391 |
/**
|
|
392 |
* IPC of the sat feature is stored here
|
|
393 |
*/
|
|
394 |
const TSatIpc iIpc;
|
|
395 |
|
|
396 |
/**
|
|
397 |
* Reference to config file parser
|
|
398 |
*/
|
|
399 |
CStifItemParser& iParser;
|
|
400 |
};
|
|
401 |
|
|
402 |
#endif // SATBASE_H
|
|
403 |
|
|
404 |
// End of
|