1 /* |
|
2 * Copyright (c) 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: This file contains the header file of the |
|
15 * CStifTFwIfProt. |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef STIF_TFW_IF_PROT_H |
|
20 #define STIF_TFW_IF_PROT_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32std.h> |
|
24 #include <e32base.h> |
|
25 #include <StifTestEventInterface.h> |
|
26 #include <StifParser.h> |
|
27 |
|
28 // CONSTANTS |
|
29 // Protocol identifier length |
|
30 const TInt KProtocolIdLength=8; |
|
31 // Default allocation size for message created with CreateL |
|
32 const TInt KDefaultMsgSize=0x200; |
|
33 // Maximum length for value added to type-value parameter |
|
34 const TInt KMaxValueLength=12; |
|
35 |
|
36 // MACROS |
|
37 // Macros for identifier manipulation |
|
38 #define DEVID(x) ((TUint16)( ( 0xffff0000 & ((TUint32)(x)) ) >> 16 )) |
|
39 #define TESTID(x) ((TUint16)( 0x0000ffff & ((TUint32)(x)) )) |
|
40 #define SETID(d,t) ((TUint32)(( ( 0x0000ffff & ((TUint32)(d)) ) << 16 )|( 0x0000ffff & ((TUint32)(t)) ))) |
|
41 #define GETDEVID(x) ((TUint32)( 0xffff0000 & ((TUint32)(x)) )) |
|
42 |
|
43 // DATA TYPES |
|
44 typedef TPtrC (*KeywordFunc)( TInt aKeyword ); |
|
45 // typedef TBuf<KDefaultMessageSize> TRemoteProtMsg; |
|
46 |
|
47 // FUNCTION PROTOTYPES |
|
48 // None |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 // None |
|
52 |
|
53 // CLASS DECLARATION |
|
54 |
|
55 // DESCRIPTION |
|
56 |
|
57 // CStifTFwIfProt is the control protocol interface |
|
58 class CStifTFwIfProt |
|
59 :public CBase |
|
60 { |
|
61 public: // Enumerations |
|
62 |
|
63 // Message type |
|
64 enum TMsgType |
|
65 { |
|
66 EMsgReserve, |
|
67 EMsgRelease, |
|
68 EMsgRemote, |
|
69 EMsgResponse, |
|
70 }; |
|
71 |
|
72 // Command types |
|
73 enum TCmdType |
|
74 { |
|
75 ECmdRun, |
|
76 ECmdPause, |
|
77 ECmdResume, |
|
78 ECmdCancel, |
|
79 ECmdRequest, |
|
80 ECmdRelease, |
|
81 ECmdSendReceive, |
|
82 ECmdSetEvent, |
|
83 ECmdUnsetEvent, |
|
84 |
|
85 ECmdUnknown, |
|
86 }; |
|
87 |
|
88 // Remote device type |
|
89 enum TRemoteType |
|
90 { |
|
91 ERemotePhone, |
|
92 //ERemoteCallBox, ... |
|
93 |
|
94 ERemoteUnknown, |
|
95 }; |
|
96 |
|
97 // Run parameters |
|
98 enum TRunParams |
|
99 { |
|
100 ERunModule, |
|
101 ERunInifile, |
|
102 ERunTestcasefile, |
|
103 ERunTestcasenum, |
|
104 ERunTitle, |
|
105 }; |
|
106 |
|
107 // Response parameters |
|
108 enum TRespParam |
|
109 { |
|
110 ERespResult, |
|
111 }; |
|
112 |
|
113 // Run status |
|
114 enum TRunStatus |
|
115 { |
|
116 ERunStarted, |
|
117 ERunError, |
|
118 ERunReady, |
|
119 }; |
|
120 |
|
121 // Run status parameters |
|
122 enum TRunStatusParams |
|
123 { |
|
124 ERunResult, |
|
125 ERunCategory, |
|
126 }; |
|
127 |
|
128 // Execution result category |
|
129 enum TResultCategory |
|
130 { |
|
131 EResultNormal = 0, |
|
132 EResultPanic, |
|
133 EResultException, |
|
134 EResultTimeout, |
|
135 EResultLeave, |
|
136 }; |
|
137 |
|
138 // Event status |
|
139 enum TEventStatus |
|
140 { |
|
141 EEventActive, |
|
142 EEventSet, |
|
143 EEventError, |
|
144 }; |
|
145 |
|
146 // Event status |
|
147 enum TEventStatusParams |
|
148 { |
|
149 EEventResult, |
|
150 EEventType, |
|
151 }; |
|
152 |
|
153 private: // Enumerations |
|
154 |
|
155 public: // Constructors and destructor |
|
156 |
|
157 /** |
|
158 * Two-phased constructor. |
|
159 */ |
|
160 IMPORT_C static CStifTFwIfProt* NewL(); |
|
161 |
|
162 /** |
|
163 * Destructor. |
|
164 */ |
|
165 IMPORT_C virtual ~CStifTFwIfProt(); |
|
166 |
|
167 public: // New functions |
|
168 |
|
169 /* |
|
170 * Get message handle |
|
171 */ |
|
172 virtual const TDesC& Message(){ return iMessage; }; |
|
173 |
|
174 /** |
|
175 * Set message. |
|
176 */ |
|
177 IMPORT_C TInt SetL( const TDesC& aMessage ); |
|
178 |
|
179 /** |
|
180 * Create message. |
|
181 */ |
|
182 IMPORT_C void CreateL( TInt aLength = KDefaultMsgSize ); |
|
183 |
|
184 /** |
|
185 * Append string to message. |
|
186 */ |
|
187 IMPORT_C TInt Append( const TDesC& aStr ); |
|
188 |
|
189 /** |
|
190 * Append hexadecimal protocol identifier to message. |
|
191 */ |
|
192 IMPORT_C TInt AppendId( TUint32 aId ); |
|
193 |
|
194 /** |
|
195 * Append keyword string to message. |
|
196 */ |
|
197 IMPORT_C TInt Append( KeywordFunc aFunc, TInt aKeyword ); |
|
198 |
|
199 /** |
|
200 * Append keyword type-value string to message. |
|
201 */ |
|
202 IMPORT_C TInt Append( KeywordFunc aFunc, TInt aKeyword, TInt aValue ); |
|
203 |
|
204 /** |
|
205 * Append keyword type-value string to message. |
|
206 */ |
|
207 IMPORT_C TInt Append( KeywordFunc aFunc, |
|
208 TInt aKeyword, |
|
209 const TDesC& aStr ); |
|
210 |
|
211 /** |
|
212 * Append keyword type-value string to message. |
|
213 */ |
|
214 IMPORT_C TInt Append( KeywordFunc aFunc, |
|
215 TInt aKeyword, |
|
216 KeywordFunc aValueFunc, |
|
217 TInt aValue ); |
|
218 |
|
219 /** |
|
220 * Get protocol source identifier. |
|
221 */ |
|
222 IMPORT_C TUint32 SrcId(); |
|
223 |
|
224 /** |
|
225 * Get protocol source device identifier. |
|
226 */ |
|
227 IMPORT_C TUint16 SrcDevId(); |
|
228 |
|
229 /** |
|
230 * Get protocol source test identifier. |
|
231 */ |
|
232 IMPORT_C TUint16 SrcTestId(); |
|
233 |
|
234 /** |
|
235 * Get protocol destination identifier. |
|
236 */ |
|
237 IMPORT_C TUint32 DstId(); |
|
238 |
|
239 /** |
|
240 * Get protocol destination device identifier. |
|
241 */ |
|
242 IMPORT_C TUint16 DstDevId(); |
|
243 |
|
244 /** |
|
245 * Get protocol destination test identifier. |
|
246 */ |
|
247 IMPORT_C TUint16 DstTestId(); |
|
248 |
|
249 /** |
|
250 * Set protocol source identifier. |
|
251 */ |
|
252 IMPORT_C TInt SetSrcId( TUint32 aSrcId ); |
|
253 |
|
254 /** |
|
255 * Set protocol destination identifier. |
|
256 */ |
|
257 IMPORT_C TInt SetDstId( TUint32 aDstId ); |
|
258 |
|
259 /** |
|
260 * Set message type. |
|
261 */ |
|
262 IMPORT_C TInt SetMsgType( TMsgType aMsgType ); |
|
263 |
|
264 /** |
|
265 * Set response type. |
|
266 */ |
|
267 IMPORT_C TInt SetRespType( TMsgType aRespType ); |
|
268 |
|
269 /** |
|
270 * Set message type. |
|
271 */ |
|
272 IMPORT_C TInt SetCmdType( TCmdType aCmdType ); |
|
273 |
|
274 /* |
|
275 * String containers. |
|
276 */ |
|
277 IMPORT_C static TPtrC MsgType( TInt aKeyword ); |
|
278 |
|
279 IMPORT_C static TPtrC CmdType( TInt aKeyword ); |
|
280 |
|
281 IMPORT_C static TPtrC RemoteType( TInt aKeyword ); |
|
282 |
|
283 IMPORT_C static TPtrC RunParams( TInt aKeyword ); |
|
284 |
|
285 IMPORT_C static TPtrC RunStatus( TInt aKeyword ); |
|
286 |
|
287 IMPORT_C static TPtrC RunStatusParams( TInt aKeyword ); |
|
288 |
|
289 IMPORT_C static TPtrC ResultCategory( TInt aKeyword ); |
|
290 |
|
291 IMPORT_C static TPtrC EventStatus( TInt aKeyword ); |
|
292 |
|
293 IMPORT_C static TPtrC EventStatusParams( TInt aKeyword ); |
|
294 |
|
295 IMPORT_C static TPtrC EventType( TInt aKeyword ); |
|
296 |
|
297 IMPORT_C static TPtrC RespParam( TInt aKeyword ); |
|
298 |
|
299 public: // Functions from base classes |
|
300 |
|
301 /** |
|
302 * From <base_class member_description. |
|
303 */ |
|
304 //<type member_function( type arg1 );> |
|
305 |
|
306 protected: // New functions |
|
307 |
|
308 /** |
|
309 * <member_description.> |
|
310 */ |
|
311 //<type member_function( type arg1 );> |
|
312 |
|
313 protected: // Functions from base classes |
|
314 |
|
315 /** |
|
316 * From <base_class member_description> |
|
317 */ |
|
318 //<type member_function();> |
|
319 |
|
320 private: |
|
321 /** |
|
322 * C++ default constructor. |
|
323 */ |
|
324 CStifTFwIfProt(); |
|
325 |
|
326 /** |
|
327 * By default Symbian OS constructor is private. |
|
328 */ |
|
329 void ConstructL(); |
|
330 |
|
331 /** |
|
332 * Parsing functions. |
|
333 */ |
|
334 TInt ParseMessageL(); |
|
335 |
|
336 void ParseHeaderL(); |
|
337 |
|
338 void ParseReserveL(); |
|
339 |
|
340 void ParseRemoteL(); |
|
341 |
|
342 void ParseResponseL(); |
|
343 |
|
344 void ParseCmdResponseL(); |
|
345 |
|
346 static TInt Parse( TDesC& aKeyword, KeywordFunc aFunc ); |
|
347 |
|
348 static TInt ParseOptArg( const TDesC& aOptArg, TPtrC& aArg, TPtrC& aVal ); |
|
349 |
|
350 public: //Data |
|
351 // Message type |
|
352 TMsgType iMsgType; |
|
353 // Remote type |
|
354 TRemoteType iRemoteType; |
|
355 // Response request type |
|
356 TMsgType iRespType; |
|
357 // Remote command type (valid only if TMsgType is EMsgRemote) |
|
358 TCmdType iCmdType; |
|
359 TPtrC iCmdDes; |
|
360 |
|
361 // Run parameters (valid only if run command) |
|
362 // Test module name |
|
363 TPtrC iModule; |
|
364 // Test module initialization file |
|
365 TPtrC iIniFile; |
|
366 // Test module initialization file |
|
367 TPtrC iTestCaseFile; |
|
368 // Test case number |
|
369 TInt iTestCaseNumber; |
|
370 // Test case title |
|
371 TPtrC iTitle; |
|
372 |
|
373 // Event parameters |
|
374 // Event name |
|
375 TPtrC iEventName; |
|
376 |
|
377 // Result from request or command |
|
378 TInt iResult; |
|
379 |
|
380 // Response status |
|
381 union |
|
382 { |
|
383 TRunStatus iRunStatus; |
|
384 TEventStatus iEventStatus; |
|
385 }; |
|
386 // Result category |
|
387 TResultCategory iResultCategory; |
|
388 // Event response parameters |
|
389 // Event type |
|
390 TEventIf::TEventType iEventType; |
|
391 |
|
392 protected: // Data |
|
393 //<data_declaration;> |
|
394 |
|
395 private: // Data |
|
396 // Message buffer |
|
397 HBufC* iMessageBuf; |
|
398 // Message ptr |
|
399 TPtr iMessage; |
|
400 |
|
401 // Message parser |
|
402 CStifItemParser* iItem; |
|
403 |
|
404 // SrcId |
|
405 TInt32 iSrcId; |
|
406 // DstId |
|
407 TInt32 iDstId; |
|
408 |
|
409 public: // Friend classes |
|
410 //<friend_class_declaration;> |
|
411 |
|
412 protected: // Friend classes |
|
413 //<friend_class_declaration;> |
|
414 |
|
415 private: // Friend classes |
|
416 //<friend_class_declaration;> |
|
417 |
|
418 }; |
|
419 |
|
420 #endif // STIF_TFW_IF_PROT_H |
|
421 |
|
422 // End of File |
|