|
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 conatins StifTfIfProt implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <e32base.h> |
|
20 #include <e32svr.h> |
|
21 #include "StifTFwIfProt.h" |
|
22 |
|
23 #include <StifLogger.h> |
|
24 |
|
25 // EXTERNAL DATA STRUCTURES |
|
26 //extern ?external_data; |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 //extern ?external_function( ?arg_type,?arg_type ); |
|
30 |
|
31 // CONSTANTS |
|
32 //const ?type ?constant_var = ?constant; |
|
33 |
|
34 // MACROS |
|
35 //#define DEBUG(a) RDebug::Print(a) |
|
36 //#define DEBUG2(a,b) RDebug::Print(a,b) |
|
37 //#define DEBUG3(a,b,c) RDebug::Print(a,b,c) |
|
38 #define DEBUG(a) |
|
39 #define DEBUG2(a,b) |
|
40 #define DEBUG3(a,b,c) |
|
41 #define ERROR RDebug::Print |
|
42 |
|
43 // LOCAL CONSTANTS AND MACROS |
|
44 //const ?type ?constant_var = ?constant; |
|
45 //#define ?macro_name ?macro_def |
|
46 |
|
47 // MODULE DATA STRUCTURES |
|
48 //enum ?declaration |
|
49 //typedef ?declaration |
|
50 |
|
51 // LOCAL FUNCTION PROTOTYPES |
|
52 //?type ?function_name( ?arg_type, ?arg_type ); |
|
53 |
|
54 // FORWARD DECLARATIONS |
|
55 //class ?FORWARD_CLASSNAME; |
|
56 |
|
57 // ==================== LOCAL FUNCTIONS ======================================= |
|
58 |
|
59 /* |
|
60 ------------------------------------------------------------------------------- |
|
61 |
|
62 Function: <function name> |
|
63 |
|
64 Description: <one line description> |
|
65 |
|
66 <Description of the functionality |
|
67 description continues and... |
|
68 continues> |
|
69 |
|
70 Parameters: <arg1>: <in/out/inout>: <accepted values>: <Description> |
|
71 |
|
72 Return Values: <value_1: Description |
|
73 value_n: Description line 1 |
|
74 description line 2> |
|
75 |
|
76 Errors/Exceptions: <description how errors and exceptions are handled> |
|
77 |
|
78 Status: Draft |
|
79 |
|
80 ------------------------------------------------------------------------------- |
|
81 */ |
|
82 /* |
|
83 <type function_name( |
|
84 <arg_type arg,> |
|
85 <arg_type arg >) |
|
86 { |
|
87 // <comment> |
|
88 <code> |
|
89 |
|
90 // <comment> |
|
91 <code> |
|
92 } |
|
93 */ |
|
94 |
|
95 |
|
96 /* |
|
97 ------------------------------------------------------------------------------- |
|
98 |
|
99 DESCRIPTION |
|
100 |
|
101 This module contains the implementation of CStifTFwIfProt class |
|
102 member functions. |
|
103 |
|
104 ------------------------------------------------------------------------------- |
|
105 */ |
|
106 |
|
107 // ================= MEMBER FUNCTIONS ========================================= |
|
108 |
|
109 /* |
|
110 ------------------------------------------------------------------------------- |
|
111 |
|
112 Class: CStifTFwIfProt |
|
113 |
|
114 Method: CStifTFwIfProt |
|
115 |
|
116 Description: Default constructor |
|
117 |
|
118 C++ default constructor can NOT contain any code, that |
|
119 might leave. |
|
120 |
|
121 Parameters: none |
|
122 |
|
123 Return Values: None |
|
124 |
|
125 Errors/Exceptions: None |
|
126 |
|
127 Status: Draft |
|
128 |
|
129 ------------------------------------------------------------------------------- |
|
130 */ |
|
131 CStifTFwIfProt::CStifTFwIfProt(): iMessage(0,0) |
|
132 { |
|
133 }; |
|
134 |
|
135 /* |
|
136 ------------------------------------------------------------------------------- |
|
137 |
|
138 Class: CStifTFwIfProt |
|
139 |
|
140 Method: ConstructL |
|
141 |
|
142 Description: Symbian OS second phase constructor |
|
143 |
|
144 Symbian OS default constructor can leave. |
|
145 |
|
146 Parameters: None |
|
147 |
|
148 Return Values: None |
|
149 |
|
150 Errors/Exceptions: None. |
|
151 |
|
152 Status: Proposal |
|
153 |
|
154 ------------------------------------------------------------------------------- |
|
155 */ |
|
156 void CStifTFwIfProt::ConstructL() |
|
157 { |
|
158 |
|
159 } |
|
160 |
|
161 /* |
|
162 ------------------------------------------------------------------------------- |
|
163 |
|
164 Class: CStifTFwIfProt |
|
165 |
|
166 Method: NewL |
|
167 |
|
168 Description: Two-phased constructor. |
|
169 |
|
170 Parameters: None |
|
171 |
|
172 Return Values: CStifTFwIfProt*: new object |
|
173 |
|
174 Errors/Exceptions: Leaves if new or ConstructL leaves and in oom. |
|
175 |
|
176 Status: Proposal |
|
177 |
|
178 ------------------------------------------------------------------------------- |
|
179 */ |
|
180 EXPORT_C CStifTFwIfProt* CStifTFwIfProt::NewL() |
|
181 { |
|
182 |
|
183 CStifTFwIfProt* self = new (ELeave) CStifTFwIfProt(); |
|
184 |
|
185 CleanupStack::PushL( self ); |
|
186 self->ConstructL(); |
|
187 CleanupStack::Pop(); |
|
188 |
|
189 return self; |
|
190 |
|
191 } |
|
192 |
|
193 /* |
|
194 ------------------------------------------------------------------------------- |
|
195 |
|
196 Class: CStifTFwIfProt |
|
197 |
|
198 Method: ~CStifTFwIfProt |
|
199 |
|
200 Description: Destructor |
|
201 |
|
202 Parameters: None |
|
203 |
|
204 Return Values: None |
|
205 |
|
206 Errors/Exceptions: None |
|
207 |
|
208 Status: Draft |
|
209 |
|
210 ------------------------------------------------------------------------------- |
|
211 */ |
|
212 |
|
213 EXPORT_C CStifTFwIfProt::~CStifTFwIfProt() |
|
214 { |
|
215 |
|
216 delete iItem; |
|
217 delete iMessageBuf; |
|
218 iMessageBuf = NULL; |
|
219 |
|
220 } |
|
221 |
|
222 /* |
|
223 ------------------------------------------------------------------------------- |
|
224 |
|
225 Class: CStifTFwIfProt |
|
226 |
|
227 Method: CreateL |
|
228 |
|
229 Description: Create new empty protocol message. |
|
230 |
|
231 Parameters: TInt aLength: in: protocol message length |
|
232 |
|
233 Return Values: None |
|
234 |
|
235 Errors/Exceptions: Leave if oom. |
|
236 |
|
237 Status: Draft |
|
238 |
|
239 ------------------------------------------------------------------------------- |
|
240 */ |
|
241 EXPORT_C void CStifTFwIfProt::CreateL( TInt aLength ) |
|
242 { |
|
243 |
|
244 // Delete previous if exists |
|
245 delete iMessageBuf; |
|
246 iMessageBuf = NULL; |
|
247 iMessage.Set( 0, 0, 0 ); |
|
248 |
|
249 iMessageBuf = HBufC::NewL( aLength ); |
|
250 iMessage.Set( iMessageBuf->Des() ); |
|
251 |
|
252 } |
|
253 |
|
254 /* |
|
255 ------------------------------------------------------------------------------- |
|
256 |
|
257 Class: CStifTFwIfProt |
|
258 |
|
259 Method: Append |
|
260 |
|
261 Description: Append string to protocol message. |
|
262 |
|
263 Parameters: TInt aLength: in: protocol message length |
|
264 |
|
265 Return Values: None |
|
266 |
|
267 Errors/Exceptions: Leave if oom. |
|
268 |
|
269 Status: Draft |
|
270 |
|
271 ------------------------------------------------------------------------------- |
|
272 */ |
|
273 EXPORT_C TInt CStifTFwIfProt::Append( const TDesC& aStr ) |
|
274 { |
|
275 |
|
276 if( ( aStr.Length() + 1 ) > |
|
277 ( iMessage.MaxLength() - iMessage.Length() ) ) |
|
278 { |
|
279 ERROR( _L("No space left for string") ); |
|
280 return KErrOverflow; |
|
281 } |
|
282 iMessage.Append( aStr ); |
|
283 iMessage.Append( _L(" ") ); |
|
284 |
|
285 return KErrNone; |
|
286 |
|
287 } |
|
288 |
|
289 /* |
|
290 ------------------------------------------------------------------------------- |
|
291 |
|
292 Class: CStifTFwIfProt |
|
293 |
|
294 Method: Append |
|
295 |
|
296 Description: Append hexadecimal value to protocol message. |
|
297 |
|
298 Parameters: TInt aLength: in: protocol message length |
|
299 |
|
300 Return Values: None |
|
301 |
|
302 Errors/Exceptions: Leave if oom. |
|
303 |
|
304 Status: Draft |
|
305 |
|
306 ------------------------------------------------------------------------------- |
|
307 */ |
|
308 EXPORT_C TInt CStifTFwIfProt::AppendId( TUint32 aId ) |
|
309 { |
|
310 |
|
311 if( ( KMaxValueLength + 1 ) > |
|
312 ( iMessage.MaxLength() - iMessage.Length() ) ) |
|
313 { |
|
314 ERROR( _L("No space left for string") ); |
|
315 return KErrOverflow; |
|
316 } |
|
317 |
|
318 iMessage.AppendNumFixedWidth( aId, EHex, KProtocolIdLength ); |
|
319 iMessage.Append( _L(" ") ); |
|
320 |
|
321 return KErrNone; |
|
322 |
|
323 } |
|
324 |
|
325 /* |
|
326 ------------------------------------------------------------------------------- |
|
327 |
|
328 Class: CStifTFwIfProt |
|
329 |
|
330 Method: Append |
|
331 |
|
332 Description: Append string to protocol message. |
|
333 |
|
334 Parameters: TInt aLength: in: protocol message length |
|
335 |
|
336 Return Values: None |
|
337 |
|
338 Errors/Exceptions: Leave if oom. |
|
339 |
|
340 Status: Draft |
|
341 |
|
342 ------------------------------------------------------------------------------- |
|
343 */ |
|
344 EXPORT_C TInt CStifTFwIfProt::Append( KeywordFunc aFunc, TInt aKeyword ) |
|
345 { |
|
346 |
|
347 if( ( aFunc( aKeyword ).Length() + 1 ) > |
|
348 ( iMessage.MaxLength() - iMessage.Length() ) ) |
|
349 { |
|
350 ERROR( _L("No space left for string") ); |
|
351 return KErrOverflow; |
|
352 } |
|
353 iMessage.Append( aFunc( aKeyword ) ); |
|
354 iMessage.Append( _L(" ") ); |
|
355 |
|
356 return KErrNone; |
|
357 |
|
358 } |
|
359 |
|
360 /* |
|
361 ------------------------------------------------------------------------------- |
|
362 |
|
363 Class: CStifTFwIfProt |
|
364 |
|
365 Method: Append |
|
366 |
|
367 Description: Append type-value string to protocol message. |
|
368 |
|
369 Parameters: TInt aLength: in: protocol message length |
|
370 |
|
371 Return Values: None |
|
372 |
|
373 Errors/Exceptions: Leave if oom. |
|
374 |
|
375 Status: Draft |
|
376 |
|
377 ------------------------------------------------------------------------------- |
|
378 */ |
|
379 EXPORT_C TInt CStifTFwIfProt::Append( KeywordFunc aFunc, |
|
380 TInt aKeyword, |
|
381 const TDesC& aStr ) |
|
382 { |
|
383 |
|
384 if( ( aFunc( aKeyword ).Length() + 2 + aStr.Length() ) > |
|
385 ( iMessage.MaxLength() - iMessage.Length() ) ) |
|
386 { |
|
387 ERROR( _L("No space left for string") ); |
|
388 return KErrOverflow; |
|
389 } |
|
390 |
|
391 iMessage.Append( aFunc( aKeyword ) ); |
|
392 iMessage.Append( _L("=") ); |
|
393 iMessage.Append( aStr ); |
|
394 iMessage.Append( _L(" ") ); |
|
395 |
|
396 return KErrNone; |
|
397 |
|
398 } |
|
399 |
|
400 /* |
|
401 ------------------------------------------------------------------------------- |
|
402 |
|
403 Class: CStifTFwIfProt |
|
404 |
|
405 Method: Append |
|
406 |
|
407 Description: Append type-value string to protocol message. |
|
408 |
|
409 Parameters: TInt aLength: in: protocol message length |
|
410 |
|
411 Return Values: None |
|
412 |
|
413 Errors/Exceptions: Leave if oom. |
|
414 |
|
415 Status: Draft |
|
416 |
|
417 ------------------------------------------------------------------------------- |
|
418 */ |
|
419 EXPORT_C TInt CStifTFwIfProt::Append( KeywordFunc aFunc, |
|
420 TInt aKeyword, |
|
421 KeywordFunc aValueFunc, |
|
422 TInt aValue ) |
|
423 { |
|
424 |
|
425 if( ( aFunc( aKeyword ).Length() + 2 + aValueFunc( aValue ).Length() ) > |
|
426 ( iMessage.MaxLength() - iMessage.Length() ) ) |
|
427 { |
|
428 ERROR( _L("No space left for string") ); |
|
429 return KErrOverflow; |
|
430 } |
|
431 |
|
432 iMessage.Append( aFunc( aKeyword ) ); |
|
433 iMessage.Append( _L("=") ); |
|
434 iMessage.Append( aValueFunc( aValue ) ); |
|
435 iMessage.Append( _L(" ") ); |
|
436 |
|
437 return KErrNone; |
|
438 |
|
439 } |
|
440 |
|
441 /* |
|
442 ------------------------------------------------------------------------------- |
|
443 |
|
444 Class: CStifTFwIfProt |
|
445 |
|
446 Method: Append |
|
447 |
|
448 Description: Append type-value string to protocol message. |
|
449 |
|
450 Parameters: TInt aLength: in: protocol message length |
|
451 |
|
452 Return Values: None |
|
453 |
|
454 Errors/Exceptions: Leave if oom. |
|
455 |
|
456 Status: Draft |
|
457 |
|
458 ------------------------------------------------------------------------------- |
|
459 */ |
|
460 EXPORT_C TInt CStifTFwIfProt::Append( KeywordFunc aFunc, |
|
461 TInt aKeyword, |
|
462 TInt aValue ) |
|
463 { |
|
464 |
|
465 if( ( aFunc( aKeyword ).Length() + 2 + KMaxValueLength ) > |
|
466 ( iMessage.MaxLength() - iMessage.Length() ) ) |
|
467 { |
|
468 ERROR( _L("No space left for string") ); |
|
469 return KErrOverflow; |
|
470 } |
|
471 |
|
472 iMessage.Append( aFunc( aKeyword ) ); |
|
473 iMessage.Append( _L("=") ); |
|
474 iMessage.AppendNum( aValue ); |
|
475 iMessage.Append( _L(" ") ); |
|
476 |
|
477 return KErrNone; |
|
478 |
|
479 } |
|
480 |
|
481 /* |
|
482 ------------------------------------------------------------------------------- |
|
483 |
|
484 Class: CStifTFwIfProt |
|
485 |
|
486 Method: SetL |
|
487 |
|
488 Description: Set and parse protocol message. |
|
489 |
|
490 Parameters: TDesC& aMessage: in: protocol message |
|
491 |
|
492 Return Values: Symbian OS error code: If protocol message parsing fails, |
|
493 i.e. message prsing after header <msg type> <sdcid> <dstid> |
|
494 |
|
495 Errors/Exceptions: Leaves if protocol header parsing fails and oom. |
|
496 |
|
497 Status: Draft |
|
498 |
|
499 ------------------------------------------------------------------------------- |
|
500 */ |
|
501 EXPORT_C TInt CStifTFwIfProt::SetL( const TDesC& aMessage ) |
|
502 { |
|
503 |
|
504 // Delete previous if exists |
|
505 delete iMessageBuf; |
|
506 iMessageBuf = NULL; |
|
507 iMessage.Set( 0,0,0 ); |
|
508 |
|
509 iMessageBuf = aMessage.AllocL(); |
|
510 iMessage.Set( iMessageBuf->Des() ); |
|
511 |
|
512 return ParseMessageL(); |
|
513 |
|
514 } |
|
515 |
|
516 /* |
|
517 ------------------------------------------------------------------------------- |
|
518 |
|
519 Class: CStifTFwIfProt |
|
520 |
|
521 Method: SetL |
|
522 |
|
523 Description: Get protocol source identifier. |
|
524 |
|
525 Parameters: None |
|
526 |
|
527 Return Values: Source identifier. |
|
528 |
|
529 Errors/Exceptions: None. |
|
530 |
|
531 Status: Draft |
|
532 |
|
533 ------------------------------------------------------------------------------- |
|
534 */ |
|
535 EXPORT_C TUint32 CStifTFwIfProt::SrcId() |
|
536 { |
|
537 |
|
538 return iSrcId; |
|
539 |
|
540 } |
|
541 |
|
542 /* |
|
543 ------------------------------------------------------------------------------- |
|
544 |
|
545 Class: CStifTFwIfProt |
|
546 |
|
547 Method: SetL |
|
548 |
|
549 Description: Get protocol source device identifier. |
|
550 |
|
551 Parameters: None |
|
552 |
|
553 Return Values: Source device identifier. |
|
554 |
|
555 Errors/Exceptions: None. |
|
556 |
|
557 Status: Draft |
|
558 |
|
559 ------------------------------------------------------------------------------- |
|
560 */ |
|
561 EXPORT_C TUint16 CStifTFwIfProt::SrcDevId() |
|
562 { |
|
563 |
|
564 return DEVID( iSrcId ); |
|
565 |
|
566 } |
|
567 |
|
568 /* |
|
569 ------------------------------------------------------------------------------- |
|
570 |
|
571 Class: CStifTFwIfProt |
|
572 |
|
573 Method: SetL |
|
574 |
|
575 Description: Get protocol source test identifier. |
|
576 |
|
577 Parameters: None |
|
578 |
|
579 Return Values: Source test identifier. |
|
580 |
|
581 Errors/Exceptions: None. |
|
582 |
|
583 Status: Draft |
|
584 |
|
585 ------------------------------------------------------------------------------- |
|
586 */ |
|
587 EXPORT_C TUint16 CStifTFwIfProt::SrcTestId() |
|
588 { |
|
589 |
|
590 return TESTID( iSrcId ); |
|
591 |
|
592 } |
|
593 |
|
594 /* |
|
595 ------------------------------------------------------------------------------- |
|
596 |
|
597 Class: CStifTFwIfProt |
|
598 |
|
599 Method: SetL |
|
600 |
|
601 Description: Get protocol destination identifier. |
|
602 |
|
603 Parameters: None |
|
604 |
|
605 Return Values: Destination identifier. |
|
606 |
|
607 Errors/Exceptions: None. |
|
608 |
|
609 Status: Draft |
|
610 |
|
611 ------------------------------------------------------------------------------- |
|
612 */ |
|
613 EXPORT_C TUint32 CStifTFwIfProt::DstId() |
|
614 { |
|
615 |
|
616 return iDstId; |
|
617 |
|
618 } |
|
619 |
|
620 /* |
|
621 ------------------------------------------------------------------------------- |
|
622 |
|
623 Class: CStifTFwIfProt |
|
624 |
|
625 Method: SetL |
|
626 |
|
627 Description: Get protocol destination device identifier. |
|
628 |
|
629 Parameters: None |
|
630 |
|
631 Return Values: Destination device identifier. |
|
632 |
|
633 Errors/Exceptions: None. |
|
634 |
|
635 Status: Draft |
|
636 |
|
637 ------------------------------------------------------------------------------- |
|
638 */ |
|
639 EXPORT_C TUint16 CStifTFwIfProt::DstDevId() |
|
640 { |
|
641 |
|
642 return DEVID( iDstId ); |
|
643 |
|
644 } |
|
645 |
|
646 /* |
|
647 ------------------------------------------------------------------------------- |
|
648 |
|
649 Class: CStifTFwIfProt |
|
650 |
|
651 Method: SetL |
|
652 |
|
653 Description: Get protocol destination test identifier. |
|
654 |
|
655 Parameters: None |
|
656 |
|
657 Return Values: Destination test identifier. |
|
658 |
|
659 Errors/Exceptions: None. |
|
660 |
|
661 Status: Draft |
|
662 |
|
663 ------------------------------------------------------------------------------- |
|
664 */ |
|
665 EXPORT_C TUint16 CStifTFwIfProt::DstTestId() |
|
666 { |
|
667 |
|
668 return TESTID( iDstId ); |
|
669 |
|
670 } |
|
671 |
|
672 |
|
673 /* |
|
674 ------------------------------------------------------------------------------- |
|
675 |
|
676 Class: CStifTFwIfProt |
|
677 |
|
678 Method: ParseMessageL |
|
679 |
|
680 Description: Parse protocol message. |
|
681 |
|
682 Parameters: None |
|
683 |
|
684 Return Values: None. |
|
685 |
|
686 Errors/Exceptions: None. |
|
687 |
|
688 Status: Draft |
|
689 |
|
690 ------------------------------------------------------------------------------- |
|
691 */ |
|
692 TInt CStifTFwIfProt::ParseMessageL() |
|
693 { |
|
694 RDebug::Print(_L("CStifTFwIfProt::ParseMessageL start")); |
|
695 |
|
696 RDebug::Print(_L("CStifTFwIfProt::ParseMessageL message content: (next line)")); |
|
697 RDebug::Print(iMessage); |
|
698 |
|
699 iItem = CStifItemParser::NewL( iMessage, 0, iMessage.Length() ); |
|
700 |
|
701 ParseHeaderL(); |
|
702 |
|
703 TRAPD( err, |
|
704 switch( iMsgType ) |
|
705 { |
|
706 case EMsgReserve: |
|
707 RDebug::Print(_L("CStifTFwIfProt::ParseMessageL EMsgReserve")); |
|
708 ParseReserveL(); |
|
709 break; |
|
710 case EMsgRelease: |
|
711 RDebug::Print(_L("CStifTFwIfProt::ParseMessageL EMsgRelease")); |
|
712 break; |
|
713 case EMsgRemote: |
|
714 RDebug::Print(_L("CStifTFwIfProt::ParseMessageL EMsgRemote")); |
|
715 ParseRemoteL(); |
|
716 break; |
|
717 case EMsgResponse: |
|
718 RDebug::Print(_L("CStifTFwIfProt::ParseMessageL EMsgResponse")); |
|
719 ParseResponseL(); |
|
720 break; |
|
721 default: |
|
722 RDebug::Print(_L("CStifTFwIfProt::ParseMessageL ERROR invalid message type. Leaving!!!")); |
|
723 ERROR( _L("Invalid message type") ); |
|
724 User::Leave( KErrArgument ); |
|
725 } |
|
726 ); |
|
727 |
|
728 delete iItem; |
|
729 iItem = 0; |
|
730 |
|
731 return err; |
|
732 |
|
733 } |
|
734 |
|
735 /* |
|
736 ------------------------------------------------------------------------------- |
|
737 |
|
738 Class: CStifTFwIfProt |
|
739 |
|
740 Method: ParseHeaderL |
|
741 |
|
742 Description: Parse protocol header. |
|
743 |
|
744 Parameters: None |
|
745 |
|
746 Return Values: None. |
|
747 |
|
748 Errors/Exceptions: None. |
|
749 |
|
750 Status: Draft |
|
751 |
|
752 ------------------------------------------------------------------------------- |
|
753 */ |
|
754 void CStifTFwIfProt::ParseHeaderL() |
|
755 { |
|
756 |
|
757 TPtrC tmp; |
|
758 TInt ret; |
|
759 TInt tmpMsgType; |
|
760 |
|
761 // Get and parse message type |
|
762 ret = iItem->GetString( _L(""), tmp ); |
|
763 if( ret != KErrNone ) |
|
764 { |
|
765 ERROR( _L("No message type given") ); |
|
766 User::Leave( KErrNotFound ); |
|
767 } |
|
768 |
|
769 tmpMsgType = Parse( tmp, MsgType ); |
|
770 if( tmpMsgType < 0 ) |
|
771 { |
|
772 ERROR( _L("Invalid message type given") ); |
|
773 User::Leave( KErrArgument ); |
|
774 } |
|
775 iMsgType = ( TMsgType )tmpMsgType; |
|
776 |
|
777 // Get and parse srcid |
|
778 ret = iItem->GetNextString( tmp ); |
|
779 if( ret != KErrNone ) |
|
780 { |
|
781 ERROR( _L("No srcid given") ); |
|
782 User::Leave( KErrNotFound ); |
|
783 } |
|
784 // Check id length |
|
785 if( tmp.Length() != KProtocolIdLength ) |
|
786 { |
|
787 ERROR( _L("Invalid srcid length [%d]"), tmp.Length() ); |
|
788 User::Leave( KErrArgument ); |
|
789 } |
|
790 TUint32 id; |
|
791 TLex lex( tmp ); |
|
792 if( lex.Val( id, EHex ) != KErrNone ) |
|
793 { |
|
794 ERROR( _L("Invalid srcid given") ); |
|
795 User::Leave( KErrArgument ); |
|
796 } |
|
797 iSrcId = id; |
|
798 |
|
799 |
|
800 // Get and parse dstid |
|
801 ret = iItem->GetNextString( tmp ); |
|
802 if( ret != KErrNone ) |
|
803 { |
|
804 ERROR( _L("No dstid given") ); |
|
805 User::Leave( KErrNotFound ); |
|
806 } |
|
807 // Check id length |
|
808 if( tmp.Length() != KProtocolIdLength ) |
|
809 { |
|
810 ERROR( _L("Invalid srcid length [%d]"), tmp.Length() ); |
|
811 User::Leave( KErrArgument ); |
|
812 } |
|
813 lex.Assign( tmp ); |
|
814 if( lex.Val( id, EHex ) != KErrNone ) |
|
815 { |
|
816 ERROR( _L("Invalid dstid given") ); |
|
817 User::Leave( KErrArgument ); |
|
818 } |
|
819 iDstId = id; |
|
820 |
|
821 } |
|
822 |
|
823 |
|
824 /* |
|
825 ------------------------------------------------------------------------------- |
|
826 |
|
827 Class: CStifTFwIfProt |
|
828 |
|
829 Method: ParseReserveL |
|
830 |
|
831 Description: Parse protocol reserve message. |
|
832 |
|
833 Parameters: None |
|
834 |
|
835 Return Values: None. |
|
836 |
|
837 Errors/Exceptions: None. |
|
838 |
|
839 Status: Draft |
|
840 |
|
841 ------------------------------------------------------------------------------- |
|
842 */ |
|
843 void CStifTFwIfProt::ParseReserveL() |
|
844 { |
|
845 |
|
846 TPtrC tmp; |
|
847 TInt ret; |
|
848 TInt tmpRemoteType; |
|
849 |
|
850 // Get and parse remote type |
|
851 ret = iItem->GetNextString( tmp ); |
|
852 if( ret != KErrNone ) |
|
853 { |
|
854 ERROR( _L("No remote type given") ); |
|
855 User::Leave( KErrNotFound ); |
|
856 } |
|
857 |
|
858 tmpRemoteType = Parse( tmp, RemoteType ); |
|
859 if( tmpRemoteType < 0 ) |
|
860 { |
|
861 iRemoteType = ERemoteUnknown; |
|
862 } |
|
863 else |
|
864 { |
|
865 iRemoteType = ( TRemoteType ) tmpRemoteType; |
|
866 } |
|
867 |
|
868 } |
|
869 |
|
870 /* |
|
871 ------------------------------------------------------------------------------- |
|
872 |
|
873 Class: CStifTFwIfProt |
|
874 |
|
875 Method: ParseRemoteL |
|
876 |
|
877 Description: Parse protocol remote message. |
|
878 |
|
879 Parameters: None |
|
880 |
|
881 Return Values: None. |
|
882 |
|
883 Errors/Exceptions: None. |
|
884 |
|
885 Status: Draft |
|
886 |
|
887 ------------------------------------------------------------------------------- |
|
888 */ |
|
889 void CStifTFwIfProt::ParseRemoteL() |
|
890 { |
|
891 RDebug::Print(_L("CStifTFwIfProt::ParseRemoteL start")); |
|
892 |
|
893 TPtrC tmp; |
|
894 TInt ret; |
|
895 TInt tmpCmdType; |
|
896 |
|
897 // Set mode of item parser to be able to read titles with spaces inside |
|
898 iItem->SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
899 |
|
900 // Get and parse command |
|
901 ret = iItem->GetNextString( tmp ); |
|
902 if( ret != KErrNone ) |
|
903 { |
|
904 ERROR( _L("No command given") ); |
|
905 User::Leave( KErrNotFound ); |
|
906 } |
|
907 |
|
908 iCmdDes.Set( tmp ); |
|
909 tmpCmdType = Parse( tmp, CmdType ); |
|
910 RDebug::Print(_L("CStifTFwIfProt::ParseRemoteL read command %d"), tmpCmdType); |
|
911 if( tmpCmdType < 0 ) |
|
912 { |
|
913 iCmdType = ECmdUnknown; |
|
914 DEBUG( _L("Unknown command given") ); |
|
915 } |
|
916 else |
|
917 { |
|
918 iCmdType = ( TCmdType ) tmpCmdType; |
|
919 } |
|
920 |
|
921 switch( iCmdType ) |
|
922 { |
|
923 case ECmdRun: |
|
924 { |
|
925 RDebug::Print(_L("CStifTFwIfProt::ParseRemoteL iCmdType ECmdRun")); |
|
926 // Parse run parameters |
|
927 TPtrC arg; |
|
928 TPtrC val; |
|
929 iTestCaseNumber = KErrNotFound; |
|
930 while( iItem->GetNextString( tmp ) == KErrNone ) |
|
931 { |
|
932 if( ParseOptArg( tmp, arg, val ) == KErrNone ) |
|
933 { |
|
934 TInt param = Parse( arg, RunParams ); |
|
935 if( param < 0 ) |
|
936 { |
|
937 ERROR( _L("Invalid run parameter given") ); |
|
938 User::Leave( KErrArgument ); |
|
939 } |
|
940 |
|
941 switch( param ) |
|
942 { |
|
943 case ERunModule: |
|
944 iModule.Set( val ); |
|
945 break; |
|
946 case ERunInifile: |
|
947 iIniFile.Set( val ); |
|
948 break; |
|
949 case ERunTestcasefile: |
|
950 iTestCaseFile.Set( val ); |
|
951 break; |
|
952 case ERunTestcasenum: |
|
953 { |
|
954 TLex ptr( val ); |
|
955 if( ptr.Val( iTestCaseNumber ) != KErrNone ) |
|
956 { |
|
957 ERROR( _L("Invalid test case number given") ); |
|
958 User::Leave( KErrArgument ); |
|
959 } |
|
960 } |
|
961 break; |
|
962 case ERunTitle: |
|
963 iTitle.Set(val); |
|
964 break; |
|
965 default: |
|
966 ERROR( _L("Invalid run parameter given") ); |
|
967 User::Leave( KErrArgument ); |
|
968 } |
|
969 } |
|
970 else |
|
971 { |
|
972 ERROR( _L("Invalid run parameter given") ); |
|
973 User::Leave( KErrArgument ); |
|
974 } |
|
975 } |
|
976 if( iModule.Length() == 0 ) |
|
977 { |
|
978 ERROR( _L("No mandatory test module name given as run parameter") ); |
|
979 //User::Leave( KErrNotFound ); |
|
980 } |
|
981 if(iTestCaseNumber < 0 && iTitle.Length() == 0) //No test case number and no title |
|
982 { |
|
983 ERROR( _L("No mandatory test case number given as run parameter") ); |
|
984 //User::Leave( KErrNotFound ); |
|
985 } |
|
986 } |
|
987 break; |
|
988 case ECmdPause: |
|
989 case ECmdResume: |
|
990 case ECmdCancel: |
|
991 RDebug::Print(_L("CStifTFwIfProt::ParseRemoteL iCmdType ECmdPause,Resume,Cancel")); |
|
992 break; |
|
993 case ECmdRequest: |
|
994 case ECmdRelease: |
|
995 { |
|
996 RDebug::Print(_L("CStifTFwIfProt::ParseRemoteL iCmdType ECmdRequest,Release")); |
|
997 ret = iItem->GetNextString( tmp ); |
|
998 if( ret != KErrNone ) |
|
999 { |
|
1000 ERROR( _L("No event name given") ); |
|
1001 //User::Leave( KErrNotFound ); |
|
1002 iEventName.Set( 0, 0 ); |
|
1003 } |
|
1004 else |
|
1005 { |
|
1006 iEventName.Set( tmp ); |
|
1007 } |
|
1008 } |
|
1009 break; |
|
1010 case ECmdSetEvent: |
|
1011 case ECmdUnsetEvent: |
|
1012 { |
|
1013 RDebug::Print(_L("CStifTFwIfProt::ParseCmdResponseL ECmdSetEvent,UnsetEvent")); |
|
1014 ret = iItem->GetNextString( tmp ); |
|
1015 if( ret != KErrNone ) |
|
1016 { |
|
1017 ERROR( _L("No set/unset response event name given") ); |
|
1018 User::Leave( KErrNotFound ); |
|
1019 } |
|
1020 iEventName.Set( tmp ); |
|
1021 TPtrC optParam; |
|
1022 ret = iItem->GetNextString( optParam ); |
|
1023 iEventType = TEventIf::EIndication; |
|
1024 if( ret == KErrNone ) |
|
1025 { |
|
1026 if ( optParam != _L("state") ) |
|
1027 { |
|
1028 ERROR(_L("Invalid set/unset event optional argument")); |
|
1029 User::Leave( KErrArgument ); |
|
1030 } |
|
1031 iEventType = TEventIf::EState; |
|
1032 } |
|
1033 } |
|
1034 break; |
|
1035 case ECmdSendReceive: |
|
1036 { |
|
1037 RDebug::Print(_L("CStifTFwIfProt::ParseRemoteL iCmdType ECmdSendReceive")); |
|
1038 DEBUG( _L("sendreceive") ); |
|
1039 break; |
|
1040 } |
|
1041 default: |
|
1042 RDebug::Print(_L("CStifTFwIfProt::ParseRemoteL iCmdType UNKNOWN!!!")); |
|
1043 DEBUG( _L("Unknown command") ); |
|
1044 break; |
|
1045 } |
|
1046 } |
|
1047 |
|
1048 /* |
|
1049 ------------------------------------------------------------------------------- |
|
1050 |
|
1051 Class: CStifTFwIfProt |
|
1052 |
|
1053 Method: ParseResponseL |
|
1054 |
|
1055 Description: Parse protocol response message. |
|
1056 |
|
1057 Parameters: None |
|
1058 |
|
1059 Return Values: None. |
|
1060 |
|
1061 Errors/Exceptions: None. |
|
1062 |
|
1063 Status: Draft |
|
1064 |
|
1065 ------------------------------------------------------------------------------- |
|
1066 */ |
|
1067 void CStifTFwIfProt::ParseResponseL() |
|
1068 { |
|
1069 |
|
1070 TPtrC tmp; |
|
1071 TInt ret; |
|
1072 TInt tmpRespType; |
|
1073 TInt tmpCmdType; |
|
1074 |
|
1075 // Get and parse request response type |
|
1076 ret = iItem->GetNextString( tmp ); |
|
1077 if( ret != KErrNone ) |
|
1078 { |
|
1079 ERROR( _L("No request type given") ); |
|
1080 User::Leave( KErrNotFound ); |
|
1081 } |
|
1082 |
|
1083 tmpRespType = Parse( tmp, MsgType ); |
|
1084 if( tmpRespType < 0 ) |
|
1085 { |
|
1086 ERROR( _L("Invalid request type given") ); |
|
1087 User::Leave( KErrArgument ); |
|
1088 } |
|
1089 else |
|
1090 { |
|
1091 iRespType = ( TMsgType ) tmpRespType; |
|
1092 } |
|
1093 |
|
1094 ret = iItem->GetNextString( tmp ); |
|
1095 |
|
1096 // First check if this is a response to a remote command |
|
1097 if( iRespType == EMsgRemote ) |
|
1098 { |
|
1099 if( ret != KErrNone ) |
|
1100 { |
|
1101 ERROR( _L("No arguments for remote response given") ); |
|
1102 User::Leave( KErrNotFound ); |
|
1103 } |
|
1104 |
|
1105 iCmdDes.Set( tmp ); |
|
1106 tmpCmdType = Parse( tmp, CmdType );; |
|
1107 if( tmpCmdType >= 0 ) |
|
1108 { |
|
1109 iCmdType = ( TCmdType ) tmpCmdType; |
|
1110 DEBUG2( _L("Remote response for %S"), &tmp ); |
|
1111 ParseCmdResponseL(); |
|
1112 // Get and parse general response parameters |
|
1113 ret = iItem->GetNextString( tmp ); |
|
1114 } |
|
1115 else |
|
1116 { |
|
1117 iCmdType = (TCmdType)KErrNotFound; |
|
1118 } |
|
1119 } |
|
1120 while( ret == KErrNone ) |
|
1121 { |
|
1122 TPtrC arg; |
|
1123 TPtrC val; |
|
1124 if( ParseOptArg( tmp, arg, val ) == KErrNone ) |
|
1125 { |
|
1126 TInt param = Parse( arg, RespParam ); |
|
1127 if( param < 0 ) |
|
1128 { |
|
1129 ERROR( _L("Invalid parameter given") ); |
|
1130 User::Leave( KErrArgument ); |
|
1131 } |
|
1132 |
|
1133 switch( param ) |
|
1134 { |
|
1135 case ERespResult: |
|
1136 { |
|
1137 TLex ptr( val ); |
|
1138 if( ptr.Val( iResult ) != KErrNone ) |
|
1139 { |
|
1140 ERROR( _L("Invalid error code given") ); |
|
1141 User::Leave( KErrArgument ); |
|
1142 } |
|
1143 } |
|
1144 break; |
|
1145 default: |
|
1146 ERROR( _L("Invalid parameter given") ); |
|
1147 User::Leave( KErrArgument ); |
|
1148 } |
|
1149 } |
|
1150 #if 0 // Check all parameters anyway |
|
1151 else |
|
1152 { |
|
1153 ERROR( _L("Invalid parameter given") ); |
|
1154 User::Leave( KErrArgument ); |
|
1155 } |
|
1156 #endif |
|
1157 ret = iItem->GetNextString( tmp ); |
|
1158 |
|
1159 } |
|
1160 |
|
1161 } |
|
1162 |
|
1163 |
|
1164 /* |
|
1165 ------------------------------------------------------------------------------- |
|
1166 |
|
1167 Class: CStifTFwIfProt |
|
1168 |
|
1169 Method: ParseCmdResponseL |
|
1170 |
|
1171 Description: Parse protocol command response parameters. |
|
1172 |
|
1173 Parameters: None |
|
1174 |
|
1175 Return Values: None. |
|
1176 |
|
1177 Errors/Exceptions: None. |
|
1178 |
|
1179 Status: Draft |
|
1180 |
|
1181 ------------------------------------------------------------------------------- |
|
1182 */ |
|
1183 void CStifTFwIfProt::ParseCmdResponseL() |
|
1184 { |
|
1185 |
|
1186 TPtrC tmp; |
|
1187 TPtrC arg; |
|
1188 TPtrC val; |
|
1189 TInt ret; |
|
1190 TInt tmpRunStatus; |
|
1191 TInt tmpResultCategory; |
|
1192 TInt tmpEventStatus; |
|
1193 TInt tmpEventType; |
|
1194 |
|
1195 RDebug::Print(_L("CStifTFwIfProt::ParseCmdResponseL start")); |
|
1196 switch( iCmdType ) |
|
1197 { |
|
1198 case ECmdRun: |
|
1199 { |
|
1200 RDebug::Print(_L("CStifTFwIfProt::ParseCmdResponseL ECmdRun")); |
|
1201 // Parse run response status |
|
1202 ret = iItem->GetNextString( tmp ); |
|
1203 if( ret != KErrNone ) |
|
1204 { |
|
1205 ERROR( _L("No run response status given") ); |
|
1206 User::Leave( KErrNotFound ); |
|
1207 } |
|
1208 |
|
1209 tmpRunStatus = Parse( tmp, RunStatus );; |
|
1210 if( tmpRunStatus < 0 ) |
|
1211 { |
|
1212 ERROR( _L("Invalid run status in response given") ); |
|
1213 User::Leave( KErrArgument ); |
|
1214 } |
|
1215 else |
|
1216 { |
|
1217 iRunStatus = (TRunStatus) tmpRunStatus; |
|
1218 } |
|
1219 |
|
1220 // Parse runs status parameters |
|
1221 while( iItem->GetNextString( tmp ) == KErrNone ) |
|
1222 { |
|
1223 if( ParseOptArg( tmp, arg, val ) == KErrNone ) |
|
1224 { |
|
1225 TInt param = Parse( arg, RunStatusParams ); |
|
1226 if( param < 0 ) |
|
1227 { |
|
1228 ERROR( _L("Invalid run status parameter given") ); |
|
1229 User::Leave( KErrArgument ); |
|
1230 } |
|
1231 |
|
1232 switch( param ) |
|
1233 { |
|
1234 case ERunResult: |
|
1235 { |
|
1236 TLex ptr( val ); |
|
1237 if( ptr.Val( iResult ) != KErrNone ) |
|
1238 { |
|
1239 ERROR( _L("Invalid run result given") ); |
|
1240 User::Leave( KErrArgument ); |
|
1241 } |
|
1242 } |
|
1243 break; |
|
1244 case ERunCategory: |
|
1245 tmpResultCategory = Parse( val, ResultCategory ); |
|
1246 if( tmpResultCategory < 0 ) |
|
1247 { |
|
1248 ERROR( _L("Invalid run result category given") ); |
|
1249 User::Leave( KErrArgument ); |
|
1250 } |
|
1251 else |
|
1252 { |
|
1253 iResultCategory = ( TResultCategory ) tmpResultCategory; |
|
1254 } |
|
1255 break; |
|
1256 default: |
|
1257 ERROR( _L("Invalid run status parameter given") ); |
|
1258 User::Leave( KErrArgument ); |
|
1259 } |
|
1260 } |
|
1261 else |
|
1262 { |
|
1263 ERROR( _L("Invalid run status parameter given") ); |
|
1264 User::Leave( KErrArgument ); |
|
1265 } |
|
1266 } |
|
1267 } |
|
1268 break; |
|
1269 case ECmdPause: |
|
1270 case ECmdResume: |
|
1271 case ECmdCancel: |
|
1272 RDebug::Print(_L("CStifTFwIfProt::ParseCmdResponseL ECmdPause,Resume,Cancel")); |
|
1273 break; |
|
1274 case ECmdRequest: |
|
1275 { |
|
1276 RDebug::Print(_L("CStifTFwIfProt::ParseCmdResponseL ECmdRequest")); |
|
1277 // Parse event request response status |
|
1278 ret = iItem->GetNextString( tmp ); |
|
1279 if( ret != KErrNone ) |
|
1280 { |
|
1281 ERROR( _L("No request response status given") ); |
|
1282 User::Leave( KErrNotFound ); |
|
1283 } |
|
1284 |
|
1285 tmpEventStatus = Parse( tmp, EventStatus ); |
|
1286 if( tmpEventStatus < 0 ) |
|
1287 { |
|
1288 ERROR( _L("Invalid request status in response given") ); |
|
1289 User::Leave( KErrArgument ); |
|
1290 } |
|
1291 else |
|
1292 { |
|
1293 iEventStatus = (TEventStatus) tmpEventStatus; |
|
1294 } |
|
1295 |
|
1296 // Parse request response event name |
|
1297 ret = iItem->GetNextString( tmp ); |
|
1298 if( ret != KErrNone ) |
|
1299 { |
|
1300 ERROR( _L("No request response event name given") ); |
|
1301 User::Leave( KErrNotFound ); |
|
1302 } |
|
1303 iEventName.Set( tmp ); |
|
1304 |
|
1305 // Parse request response status parameters |
|
1306 while( iItem->GetNextString( tmp ) == KErrNone ) |
|
1307 { |
|
1308 if( ParseOptArg( tmp, arg, val ) == KErrNone ) |
|
1309 { |
|
1310 TInt param = Parse( arg, EventStatusParams ); |
|
1311 if( param < 0 ) |
|
1312 { |
|
1313 ERROR( _L("Invalid request response status parameter given") ); |
|
1314 User::Leave( KErrArgument ); |
|
1315 } |
|
1316 |
|
1317 switch( param ) |
|
1318 { |
|
1319 case EEventResult: |
|
1320 { |
|
1321 TLex ptr( val ); |
|
1322 if( ptr.Val( iResult ) != KErrNone ) |
|
1323 { |
|
1324 ERROR( _L("Invalid request response status parameter result given") ); |
|
1325 User::Leave( KErrArgument ); |
|
1326 } |
|
1327 } |
|
1328 break; |
|
1329 case EEventType: |
|
1330 tmpEventType = Parse( val, EventType );; |
|
1331 if( tmpEventType < 0 ) |
|
1332 { |
|
1333 ERROR( _L("Invalid request response status parameter event type given") ); |
|
1334 User::Leave( KErrArgument ); |
|
1335 } |
|
1336 else |
|
1337 { |
|
1338 iEventType = ( TEventIf::TEventType ) tmpEventType; |
|
1339 } |
|
1340 break; |
|
1341 default: |
|
1342 ERROR( _L("Invalid request response status parameter given") ); |
|
1343 User::Leave( KErrArgument ); |
|
1344 } |
|
1345 } |
|
1346 else |
|
1347 { |
|
1348 ERROR( _L("Invalid request response status parameter given") ); |
|
1349 User::Leave( KErrArgument ); |
|
1350 } |
|
1351 } |
|
1352 } |
|
1353 break; |
|
1354 case ECmdRelease: |
|
1355 { |
|
1356 RDebug::Print(_L("CStifTFwIfProt::ParseCmdResponseL ECmdRelease")); |
|
1357 // Parse release response event name |
|
1358 ret = iItem->GetNextString( tmp ); |
|
1359 if( ret != KErrNone ) |
|
1360 { |
|
1361 ERROR( _L("No release response event name given") ); |
|
1362 User::Leave( KErrNotFound ); |
|
1363 } |
|
1364 iEventName.Set( tmp ); |
|
1365 } |
|
1366 break; |
|
1367 case ECmdSetEvent: |
|
1368 case ECmdUnsetEvent: |
|
1369 { |
|
1370 RDebug::Print(_L("CStifTFwIfProt::ParseCmdResponseL ECmdSetEvent,UnsetEvent")); |
|
1371 // Parse release response event name |
|
1372 ret = iItem->GetNextString( tmp ); |
|
1373 if( ret != KErrNone ) |
|
1374 { |
|
1375 ERROR( _L("Set/unset invalid response") ); |
|
1376 User::Leave( KErrNotFound ); |
|
1377 } |
|
1378 |
|
1379 tmpEventStatus = Parse( tmp, EventStatus ); |
|
1380 if( tmpEventStatus >= 0 ) |
|
1381 { |
|
1382 iEventStatus = (TEventStatus) tmpEventStatus; |
|
1383 ret = iItem->GetNextString( tmp ); |
|
1384 if( ret != KErrNone ) |
|
1385 { |
|
1386 ERROR( _L("No set/unset response event name given") ); |
|
1387 User::Leave( KErrNotFound ); |
|
1388 } |
|
1389 iEventName.Set( tmp ); |
|
1390 } |
|
1391 else |
|
1392 { |
|
1393 if( ParseOptArg( tmp, arg, val ) == KErrNone ) |
|
1394 { |
|
1395 TInt param = Parse( arg, EventStatusParams ); |
|
1396 if( param < 0 ) |
|
1397 { |
|
1398 ERROR( _L("Invalid request response status parameter given") ); |
|
1399 User::Leave( KErrArgument ); |
|
1400 } |
|
1401 |
|
1402 if ( param == EEventResult ) |
|
1403 { |
|
1404 TLex ptr( val ); |
|
1405 if( ptr.Val( iResult ) != KErrNone ) |
|
1406 { |
|
1407 ERROR( _L("Invalid request response status parameter result given") ); |
|
1408 User::Leave( KErrArgument ); |
|
1409 } |
|
1410 } |
|
1411 else |
|
1412 { |
|
1413 ERROR( _L("Invalid request response status parameter given") ); |
|
1414 User::Leave( KErrArgument ); |
|
1415 } |
|
1416 } |
|
1417 else |
|
1418 { |
|
1419 ERROR( _L("Expected remote event set/unset result") ); |
|
1420 User::Leave( KErrArgument ); |
|
1421 } |
|
1422 } |
|
1423 |
|
1424 // Parse request response status parameters |
|
1425 while( iItem->GetNextString( tmp ) == KErrNone ) |
|
1426 { |
|
1427 if( ParseOptArg( tmp, arg, val ) == KErrNone ) |
|
1428 { |
|
1429 TInt param = Parse( arg, EventStatusParams ); |
|
1430 if( param < 0 ) |
|
1431 { |
|
1432 ERROR( _L("Invalid request response status parameter given") ); |
|
1433 User::Leave( KErrArgument ); |
|
1434 } |
|
1435 |
|
1436 if ( param == EEventType ) |
|
1437 { |
|
1438 tmpEventType = Parse( val, EventType );; |
|
1439 if( tmpEventType < 0 ) |
|
1440 { |
|
1441 ERROR( _L("Invalid request response status parameter event type given") ); |
|
1442 User::Leave( KErrArgument ); |
|
1443 } |
|
1444 else |
|
1445 { |
|
1446 iEventType = ( TEventIf::TEventType ) tmpEventType; |
|
1447 } |
|
1448 } |
|
1449 else |
|
1450 { |
|
1451 ERROR( _L("Invalid request response status parameter given") ); |
|
1452 User::Leave( KErrArgument ); |
|
1453 } |
|
1454 } |
|
1455 else |
|
1456 { |
|
1457 ERROR( _L("Invalid request response status parameter given") ); |
|
1458 User::Leave( KErrArgument ); |
|
1459 } |
|
1460 } |
|
1461 } |
|
1462 break; |
|
1463 case ECmdSendReceive: |
|
1464 { |
|
1465 RDebug::Print(_L("CStifTFwIfProt::ParseCmdResponseL ECmdSendReceive")); |
|
1466 // Parse sendreceive response status |
|
1467 ret = iItem->GetNextString( tmp ); |
|
1468 if( ret != KErrNone ) |
|
1469 { |
|
1470 ERROR( _L("No run response status given") ); |
|
1471 User::Leave( KErrNotFound ); |
|
1472 } |
|
1473 |
|
1474 tmpRunStatus = Parse( tmp, RunStatus ); |
|
1475 if( tmpRunStatus < 0 ) |
|
1476 { |
|
1477 ERROR( _L("Invalid run status in response given") ); |
|
1478 User::Leave( KErrArgument ); |
|
1479 } |
|
1480 else |
|
1481 { |
|
1482 iRunStatus = (TRunStatus) tmpRunStatus; |
|
1483 } |
|
1484 break; |
|
1485 } |
|
1486 default: |
|
1487 ERROR( _L("Invalid command response") ); |
|
1488 User::Leave( KErrArgument ); |
|
1489 |
|
1490 } |
|
1491 } |
|
1492 |
|
1493 |
|
1494 /* |
|
1495 ------------------------------------------------------------------------------- |
|
1496 |
|
1497 Class: CStifTFwIfProt |
|
1498 |
|
1499 Method: MsgType |
|
1500 |
|
1501 Description: Returns a string desrciptor corresponding |
|
1502 to message type number. |
|
1503 |
|
1504 Parameters: TInt aKeyword: in: keyword index. |
|
1505 |
|
1506 Return Values: TPtrC: keyword descriptor |
|
1507 |
|
1508 Errors/Exceptions: None |
|
1509 |
|
1510 Status: Draft |
|
1511 |
|
1512 ------------------------------------------------------------------------------- |
|
1513 */ |
|
1514 EXPORT_C TPtrC CStifTFwIfProt::MsgType( TInt aKeyword ) |
|
1515 { |
|
1516 static TText* const keywords[] = |
|
1517 { |
|
1518 (TText*)L"reserve", |
|
1519 (TText*)L"release", |
|
1520 (TText*)L"remote", |
|
1521 (TText*)L"response", |
|
1522 }; |
|
1523 |
|
1524 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1525 { |
|
1526 TPtrC null; |
|
1527 return null; |
|
1528 } |
|
1529 |
|
1530 TPtrC keyword( keywords[ aKeyword ] ); |
|
1531 return keyword; |
|
1532 |
|
1533 } |
|
1534 |
|
1535 /* |
|
1536 ------------------------------------------------------------------------------- |
|
1537 |
|
1538 Class: CStifTFwIfProt |
|
1539 |
|
1540 Method: ResultCategory |
|
1541 |
|
1542 Description: Returns a string desrciptor corresponding |
|
1543 to result category number. |
|
1544 |
|
1545 Parameters: TInt aKeyword: in: keyword index. |
|
1546 |
|
1547 Return Values: TPtrC: keyword descriptor |
|
1548 |
|
1549 Errors/Exceptions: None |
|
1550 |
|
1551 Status: Draft |
|
1552 |
|
1553 ------------------------------------------------------------------------------- |
|
1554 */ |
|
1555 EXPORT_C TPtrC CStifTFwIfProt::CmdType( TInt aKeyword ) |
|
1556 { |
|
1557 static TText* const keywords[] = |
|
1558 { |
|
1559 (TText*)L"run", |
|
1560 (TText*)L"pause", |
|
1561 (TText*)L"resume", |
|
1562 (TText*)L"cancel", |
|
1563 (TText*)L"request", |
|
1564 (TText*)L"release", |
|
1565 (TText*)L"sendreceive", |
|
1566 (TText*)L"set", |
|
1567 (TText*)L"unset", |
|
1568 }; |
|
1569 |
|
1570 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1571 { |
|
1572 TPtrC null; |
|
1573 return null; |
|
1574 } |
|
1575 |
|
1576 TPtrC keyword( keywords[ aKeyword ] ); |
|
1577 return keyword; |
|
1578 |
|
1579 } |
|
1580 |
|
1581 /* |
|
1582 ------------------------------------------------------------------------------- |
|
1583 |
|
1584 Class: CStifTFwIfProt |
|
1585 |
|
1586 Method: RemoteType |
|
1587 |
|
1588 Description: Returns a string desrciptor corresponding |
|
1589 to remote type number. |
|
1590 |
|
1591 Parameters: TInt aKeyword: in: keyword index. |
|
1592 |
|
1593 Return Values: TPtrC: keyword descriptor |
|
1594 |
|
1595 Errors/Exceptions: None |
|
1596 |
|
1597 Status: Draft |
|
1598 |
|
1599 ------------------------------------------------------------------------------- |
|
1600 */ |
|
1601 EXPORT_C TPtrC CStifTFwIfProt::RemoteType( TInt aKeyword ) |
|
1602 { |
|
1603 static TText* const keywords[] = |
|
1604 { |
|
1605 (TText*)L"phone", |
|
1606 }; |
|
1607 |
|
1608 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1609 { |
|
1610 TPtrC null; |
|
1611 return null; |
|
1612 } |
|
1613 |
|
1614 TPtrC keyword( keywords[ aKeyword ] ); |
|
1615 return keyword; |
|
1616 |
|
1617 } |
|
1618 |
|
1619 /* |
|
1620 ------------------------------------------------------------------------------- |
|
1621 |
|
1622 Class: CStifTFwIfProt |
|
1623 |
|
1624 Method: RunParams |
|
1625 |
|
1626 Description: Returns a string desrciptor corresponding |
|
1627 to run parameter number. |
|
1628 |
|
1629 Parameters: TInt aKeyword: in: keyword index. |
|
1630 |
|
1631 Return Values: TPtrC: keyword descriptor |
|
1632 |
|
1633 Errors/Exceptions: None |
|
1634 |
|
1635 Status: Draft |
|
1636 |
|
1637 ------------------------------------------------------------------------------- |
|
1638 */ |
|
1639 EXPORT_C TPtrC CStifTFwIfProt::RunParams( TInt aKeyword ) |
|
1640 { |
|
1641 static TText* const keywords[] = |
|
1642 { |
|
1643 (TText*)L"module", |
|
1644 (TText*)L"inifile", |
|
1645 (TText*)L"testcasefile", |
|
1646 (TText*)L"testcasenum", |
|
1647 (TText*)L"title", |
|
1648 }; |
|
1649 |
|
1650 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1651 { |
|
1652 TPtrC null; |
|
1653 return null; |
|
1654 } |
|
1655 |
|
1656 TPtrC keyword( keywords[ aKeyword ] ); |
|
1657 return keyword; |
|
1658 |
|
1659 } |
|
1660 |
|
1661 /* |
|
1662 ------------------------------------------------------------------------------- |
|
1663 |
|
1664 Class: CStifTFwIfProt |
|
1665 |
|
1666 Method: RunStatus |
|
1667 |
|
1668 Description: Returns a string desrciptor corresponding |
|
1669 to run status number. |
|
1670 |
|
1671 Parameters: TInt aKeyword: in: keyword index. |
|
1672 |
|
1673 Return Values: TPtrC: keyword descriptor |
|
1674 |
|
1675 Errors/Exceptions: None |
|
1676 |
|
1677 Status: Draft |
|
1678 |
|
1679 ------------------------------------------------------------------------------- |
|
1680 */ |
|
1681 EXPORT_C TPtrC CStifTFwIfProt::RunStatus( TInt aKeyword ) |
|
1682 { |
|
1683 static TText* const keywords[] = |
|
1684 { |
|
1685 (TText*)L"started", |
|
1686 (TText*)L"error", |
|
1687 (TText*)L"ready", |
|
1688 }; |
|
1689 |
|
1690 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1691 { |
|
1692 TPtrC null; |
|
1693 return null; |
|
1694 } |
|
1695 |
|
1696 TPtrC keyword( keywords[ aKeyword ] ); |
|
1697 return keyword; |
|
1698 |
|
1699 } |
|
1700 |
|
1701 /* |
|
1702 ------------------------------------------------------------------------------- |
|
1703 |
|
1704 Class: CStifTFwIfProt |
|
1705 |
|
1706 Method: RunStatusParams |
|
1707 |
|
1708 Description: Returns a string desrciptor corresponding |
|
1709 to run status parameter number. |
|
1710 |
|
1711 Parameters: TInt aKeyword: in: keyword index. |
|
1712 |
|
1713 Return Values: TPtrC: keyword descriptor |
|
1714 |
|
1715 Errors/Exceptions: None |
|
1716 |
|
1717 Status: Draft |
|
1718 |
|
1719 ------------------------------------------------------------------------------- |
|
1720 */ |
|
1721 EXPORT_C TPtrC CStifTFwIfProt::RunStatusParams( TInt aKeyword ) |
|
1722 { |
|
1723 static TText* const keywords[] = |
|
1724 { |
|
1725 (TText*)L"result", |
|
1726 (TText*)L"category", |
|
1727 }; |
|
1728 |
|
1729 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1730 { |
|
1731 TPtrC null; |
|
1732 return null; |
|
1733 } |
|
1734 |
|
1735 TPtrC keyword( keywords[ aKeyword ] ); |
|
1736 return keyword; |
|
1737 |
|
1738 } |
|
1739 |
|
1740 /* |
|
1741 ------------------------------------------------------------------------------- |
|
1742 |
|
1743 Class: CStifTFwIfProt |
|
1744 |
|
1745 Method: ResultCategory |
|
1746 |
|
1747 Description: Returns a string desrciptor corresponding |
|
1748 to command type number. |
|
1749 |
|
1750 Parameters: TInt aKeyword: in: keyword index. |
|
1751 |
|
1752 Return Values: TPtrC: keyword descriptor |
|
1753 |
|
1754 Errors/Exceptions: None |
|
1755 |
|
1756 Status: Draft |
|
1757 |
|
1758 ------------------------------------------------------------------------------- |
|
1759 */ |
|
1760 EXPORT_C TPtrC CStifTFwIfProt::ResultCategory( TInt aKeyword ) |
|
1761 { |
|
1762 static TText* const keywords[] = |
|
1763 { |
|
1764 (TText*)L"normal", |
|
1765 (TText*)L"panic", |
|
1766 (TText*)L"exception", |
|
1767 (TText*)L"timeout", |
|
1768 (TText*)L"leave", |
|
1769 }; |
|
1770 |
|
1771 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1772 { |
|
1773 TPtrC null; |
|
1774 return null; |
|
1775 } |
|
1776 |
|
1777 TPtrC keyword( keywords[ aKeyword ] ); |
|
1778 return keyword; |
|
1779 |
|
1780 } |
|
1781 |
|
1782 /* |
|
1783 ------------------------------------------------------------------------------- |
|
1784 |
|
1785 Class: CStifTFwIfProt |
|
1786 |
|
1787 Method: EventStatus |
|
1788 |
|
1789 Description: Returns a string desrciptor corresponding |
|
1790 to command type number. |
|
1791 |
|
1792 Parameters: TInt aKeyword: in: keyword index. |
|
1793 |
|
1794 Return Values: TPtrC: keyword descriptor |
|
1795 |
|
1796 Errors/Exceptions: None |
|
1797 |
|
1798 Status: Draft |
|
1799 |
|
1800 ------------------------------------------------------------------------------- |
|
1801 */ |
|
1802 EXPORT_C TPtrC CStifTFwIfProt::EventStatus( TInt aKeyword ) |
|
1803 { |
|
1804 static TText* const keywords[] = |
|
1805 { |
|
1806 (TText*)L"active", |
|
1807 (TText*)L"set", |
|
1808 (TText*)L"error", |
|
1809 (TText*)L"unset", |
|
1810 }; |
|
1811 |
|
1812 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1813 { |
|
1814 TPtrC null; |
|
1815 return null; |
|
1816 } |
|
1817 |
|
1818 TPtrC keyword( keywords[ aKeyword ] ); |
|
1819 return keyword; |
|
1820 |
|
1821 } |
|
1822 |
|
1823 /* |
|
1824 ------------------------------------------------------------------------------- |
|
1825 |
|
1826 Class: CStifTFwIfProt |
|
1827 |
|
1828 Method: EventStatusParams |
|
1829 |
|
1830 Description: Returns a string desrciptor corresponding |
|
1831 to command type number. |
|
1832 |
|
1833 Parameters: TInt aKeyword: in: keyword index. |
|
1834 |
|
1835 Return Values: TPtrC: keyword descriptor |
|
1836 |
|
1837 Errors/Exceptions: None |
|
1838 |
|
1839 Status: Draft |
|
1840 |
|
1841 ------------------------------------------------------------------------------- |
|
1842 */ |
|
1843 EXPORT_C TPtrC CStifTFwIfProt::EventStatusParams( TInt aKeyword ) |
|
1844 { |
|
1845 static TText* const keywords[] = |
|
1846 { |
|
1847 (TText*)L"result", |
|
1848 (TText*)L"type", |
|
1849 }; |
|
1850 |
|
1851 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1852 { |
|
1853 TPtrC null; |
|
1854 return null; |
|
1855 } |
|
1856 |
|
1857 TPtrC keyword( keywords[ aKeyword ] ); |
|
1858 return keyword; |
|
1859 |
|
1860 } |
|
1861 |
|
1862 /* |
|
1863 ------------------------------------------------------------------------------- |
|
1864 |
|
1865 Class: CStifTFwIfProt |
|
1866 |
|
1867 Method: EventType |
|
1868 |
|
1869 Description: Returns a string desrciptor corresponding |
|
1870 to event type number. |
|
1871 |
|
1872 Parameters: TInt aKeyword: in: keyword index. |
|
1873 |
|
1874 Return Values: TPtrC: keyword descriptor |
|
1875 |
|
1876 Errors/Exceptions: None |
|
1877 |
|
1878 Status: Draft |
|
1879 |
|
1880 ------------------------------------------------------------------------------- |
|
1881 */ |
|
1882 EXPORT_C TPtrC CStifTFwIfProt::EventType( TInt aKeyword ) |
|
1883 { |
|
1884 static TText* const keywords[] = |
|
1885 { |
|
1886 (TText*)L"indication", |
|
1887 (TText*)L"state", |
|
1888 }; |
|
1889 |
|
1890 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1891 { |
|
1892 TPtrC null; |
|
1893 return null; |
|
1894 } |
|
1895 |
|
1896 TPtrC keyword( keywords[ aKeyword ] ); |
|
1897 return keyword; |
|
1898 |
|
1899 } |
|
1900 |
|
1901 /* |
|
1902 ------------------------------------------------------------------------------- |
|
1903 |
|
1904 Class: CStifTFwIfProt |
|
1905 |
|
1906 Method: RespParam |
|
1907 |
|
1908 Description: Returns a string desrciptor corresponding |
|
1909 to response parameter number. |
|
1910 |
|
1911 Parameters: TInt aKeyword: in: keyword index. |
|
1912 |
|
1913 Return Values: TPtrC: keyword descriptor |
|
1914 |
|
1915 Errors/Exceptions: None |
|
1916 |
|
1917 Status: Draft |
|
1918 |
|
1919 ------------------------------------------------------------------------------- |
|
1920 */ |
|
1921 EXPORT_C TPtrC CStifTFwIfProt::RespParam( TInt aKeyword ) |
|
1922 { |
|
1923 static TText* const keywords[] = |
|
1924 { |
|
1925 (TText*)L"result", |
|
1926 }; |
|
1927 |
|
1928 if( (TUint)aKeyword >= (sizeof( keywords )/sizeof(TText*)) ) |
|
1929 { |
|
1930 TPtrC null; |
|
1931 return null; |
|
1932 } |
|
1933 |
|
1934 TPtrC keyword( keywords[ aKeyword ] ); |
|
1935 return keyword; |
|
1936 |
|
1937 } |
|
1938 |
|
1939 |
|
1940 /* |
|
1941 ------------------------------------------------------------------------------- |
|
1942 |
|
1943 Class: CStifTFwIfProt |
|
1944 |
|
1945 Method: SetSrcId |
|
1946 |
|
1947 Description: Set protocol source identifier. |
|
1948 |
|
1949 Parameters: TUint32 aSrcId: in: source identifier |
|
1950 |
|
1951 Return Values: Symbian OS error code |
|
1952 |
|
1953 Errors/Exceptions: None |
|
1954 |
|
1955 Status: Draft |
|
1956 |
|
1957 ------------------------------------------------------------------------------- |
|
1958 */ |
|
1959 EXPORT_C TInt CStifTFwIfProt::SetSrcId( TUint32 aSrcId ) |
|
1960 { |
|
1961 |
|
1962 iSrcId = aSrcId; |
|
1963 return AppendId( iSrcId ); |
|
1964 |
|
1965 } |
|
1966 |
|
1967 /* |
|
1968 ------------------------------------------------------------------------------- |
|
1969 |
|
1970 Class: CStifTFwIfProt |
|
1971 |
|
1972 Method: SetDstId |
|
1973 |
|
1974 Description: Set protocol destination identifier. |
|
1975 |
|
1976 Parameters: TUint32 aDstId: in: destination identifier |
|
1977 |
|
1978 Return Values: Symbian OS error code |
|
1979 |
|
1980 Errors/Exceptions: None |
|
1981 |
|
1982 Status: Draft |
|
1983 |
|
1984 ------------------------------------------------------------------------------- |
|
1985 */ |
|
1986 EXPORT_C TInt CStifTFwIfProt::SetDstId( TUint32 aDstId ) |
|
1987 { |
|
1988 |
|
1989 iDstId = aDstId; |
|
1990 return AppendId( iDstId ); |
|
1991 |
|
1992 } |
|
1993 |
|
1994 |
|
1995 /* |
|
1996 ------------------------------------------------------------------------------- |
|
1997 |
|
1998 Class: CStifTFwIfProt |
|
1999 |
|
2000 Method: SetMsgType |
|
2001 |
|
2002 Description: Set message type. |
|
2003 |
|
2004 Parameters: TMsgType iMsgType: in: message type |
|
2005 |
|
2006 Return Values: Symbian OS error code |
|
2007 |
|
2008 Errors/Exceptions: None |
|
2009 |
|
2010 Status: Draft |
|
2011 |
|
2012 ------------------------------------------------------------------------------- |
|
2013 */ |
|
2014 EXPORT_C TInt CStifTFwIfProt::SetMsgType( TMsgType aMsgType ) |
|
2015 { |
|
2016 |
|
2017 iMsgType = aMsgType; |
|
2018 return Append( CStifTFwIfProt::MsgType, iMsgType ); |
|
2019 |
|
2020 } |
|
2021 |
|
2022 |
|
2023 /* |
|
2024 ------------------------------------------------------------------------------- |
|
2025 |
|
2026 Class: CStifTFwIfProt |
|
2027 |
|
2028 Method: SetRespType |
|
2029 |
|
2030 Description: Set response type. |
|
2031 |
|
2032 Parameters: TMsgType iMsgType : in: set response type |
|
2033 |
|
2034 Return Values: Symbian OS error code |
|
2035 |
|
2036 Errors/Exceptions: None |
|
2037 |
|
2038 Status: Draft |
|
2039 |
|
2040 ------------------------------------------------------------------------------- |
|
2041 */ |
|
2042 EXPORT_C TInt CStifTFwIfProt::SetRespType( TMsgType aRespType ) |
|
2043 { |
|
2044 |
|
2045 iRespType = aRespType; |
|
2046 return Append( CStifTFwIfProt::MsgType, iRespType ); |
|
2047 |
|
2048 } |
|
2049 |
|
2050 /* |
|
2051 ------------------------------------------------------------------------------- |
|
2052 |
|
2053 Class: CStifTFwIfProt |
|
2054 |
|
2055 Method: SetCmdType |
|
2056 |
|
2057 Description: Set command type. |
|
2058 |
|
2059 Parameters: TCmdType iCmdType: in: command type |
|
2060 |
|
2061 Return Values: None |
|
2062 |
|
2063 Errors/Exceptions: None |
|
2064 |
|
2065 Status: Draft |
|
2066 |
|
2067 ------------------------------------------------------------------------------- |
|
2068 */ |
|
2069 EXPORT_C TInt CStifTFwIfProt::SetCmdType( TCmdType aCmdType ) |
|
2070 { |
|
2071 |
|
2072 iCmdType = aCmdType; |
|
2073 return Append( CStifTFwIfProt::CmdType, iCmdType ); |
|
2074 |
|
2075 } |
|
2076 |
|
2077 |
|
2078 /* |
|
2079 ------------------------------------------------------------------------------- |
|
2080 |
|
2081 Class: CStifTFwIfProt |
|
2082 |
|
2083 Method: Parse |
|
2084 |
|
2085 Description: Returns a keyword enum corresponding to keyword |
|
2086 string descriptor. |
|
2087 |
|
2088 Parameters: TPtrC aKeyword: in: keyword descriptor. |
|
2089 KeywordFunc aFunc: in: Function pointer to keyword parser |
|
2090 |
|
2091 Return Values: TInt: keyword index |
|
2092 KErrNotFound: Keyword does not exists |
|
2093 |
|
2094 Errors/Exceptions: None |
|
2095 |
|
2096 Status: Draft |
|
2097 |
|
2098 ------------------------------------------------------------------------------ |
|
2099 */ |
|
2100 TInt CStifTFwIfProt::Parse( TDesC& aKeyword, KeywordFunc aFunc ) |
|
2101 { |
|
2102 TInt ind; |
|
2103 for( ind = 0; aFunc( ind ).Length() > 0; ind++ ) |
|
2104 { |
|
2105 if( aFunc( ind ) == aKeyword ) |
|
2106 { |
|
2107 return ind; |
|
2108 } |
|
2109 } |
|
2110 return KErrNotFound; |
|
2111 }; |
|
2112 |
|
2113 |
|
2114 /* |
|
2115 ------------------------------------------------------------------------------- |
|
2116 |
|
2117 Class: CStifTFwIfProt |
|
2118 |
|
2119 Method: ParseOptArgL |
|
2120 |
|
2121 Description: Parses optional argument |
|
2122 |
|
2123 Parameters: const TDesC& aOptArg: in: |
|
2124 argument-value pair (format arg=value) |
|
2125 TPtrC& aArg: out: parsed argument |
|
2126 TPtrC& aVal: out: parsed value |
|
2127 |
|
2128 Return Values: KErrNone: Everything ok |
|
2129 Symbian OS error code: Not a valid optarg |
|
2130 |
|
2131 Errors/Exceptions: None |
|
2132 |
|
2133 Status: Draft |
|
2134 |
|
2135 ------------------------------------------------------------------------------- |
|
2136 */ |
|
2137 TInt CStifTFwIfProt::ParseOptArg( const TDesC& aOptArg, |
|
2138 TPtrC& aArg, |
|
2139 TPtrC& aVal ) |
|
2140 { |
|
2141 TInt length = aOptArg.Length(); |
|
2142 for( TInt i=0; i < length; i++) |
|
2143 { |
|
2144 // find the '=' sign |
|
2145 if( aOptArg[i] == '=' ) |
|
2146 { |
|
2147 if( i+1 >= length ) |
|
2148 { |
|
2149 return KErrArgument; |
|
2150 } |
|
2151 aArg.Set( aOptArg.Left( i ) ); |
|
2152 aVal.Set( aOptArg.Mid( i+1 ) ); |
|
2153 DEBUG3( _L( "arg '%S', val '%S'" ), |
|
2154 &aArg, &aVal ); |
|
2155 return KErrNone; |
|
2156 } |
|
2157 } |
|
2158 return KErrArgument; |
|
2159 |
|
2160 } |
|
2161 |
|
2162 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
2163 // None |
|
2164 |
|
2165 // End of File |