|
1 /* |
|
2 * Component Name: Headset Simulator |
|
3 * Author: Comarch S.A. |
|
4 * Version: 1.0 |
|
5 * Copyright (c) 2010 Comarch S.A. |
|
6 * |
|
7 * This Software is submitted by Comarch S.A. to Symbian Foundation Limited on |
|
8 * the basis of the Member Contribution Agreement entered between Comarch S.A. |
|
9 * and Symbian Foundation Limited on 5th June 2009 (“Agreement”) and may be |
|
10 * used only in accordance with the terms and conditions of the Agreement. |
|
11 * Any other usage, duplication or redistribution of this Software is not |
|
12 * allowed without written permission of Comarch S.A. |
|
13 * |
|
14 */ |
|
15 |
|
16 #include "hsremotecontroldatahandler.h" |
|
17 #include "hsremotecontroltools.h" |
|
18 #include "debug.h" |
|
19 |
|
20 CHsRemoteControlDataHandler* CHsRemoteControlDataHandler::NewL() |
|
21 { |
|
22 CHsRemoteControlDataHandler *self = CHsRemoteControlDataHandler::NewLC(); |
|
23 CleanupStack::Pop( self ); |
|
24 return self; |
|
25 } |
|
26 |
|
27 CHsRemoteControlDataHandler* CHsRemoteControlDataHandler::NewLC() |
|
28 { |
|
29 CHsRemoteControlDataHandler *self = |
|
30 new ( ELeave ) CHsRemoteControlDataHandler; |
|
31 CleanupStack::PushL( self ); |
|
32 self->ConstructL(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 CHsRemoteControlDataHandler::CHsRemoteControlDataHandler() |
|
37 { |
|
38 |
|
39 } |
|
40 |
|
41 CHsRemoteControlDataHandler::~CHsRemoteControlDataHandler() |
|
42 { |
|
43 TRACE_FUNC_ENTRY |
|
44 if ( iParser ) |
|
45 { |
|
46 delete iParser; |
|
47 } |
|
48 TRACE_FUNC_EXIT |
|
49 } |
|
50 |
|
51 void CHsRemoteControlDataHandler::ConstructL() |
|
52 { |
|
53 iParser = CHsRemoteControlParser::NewL(); |
|
54 } |
|
55 |
|
56 TInt CHsRemoteControlDataHandler::RecognizeCommand( const TDesC8 &aDataIn, |
|
57 THsRemoteControlCommand& aCmd ) |
|
58 { |
|
59 TRACE_FUNC_ENTRY |
|
60 TRAPD(err,iParser->ParseL(aDataIn, aCmd)); |
|
61 |
|
62 if ( KErrNone != err ) |
|
63 { |
|
64 TRACE_FUNC_EXIT |
|
65 return err; |
|
66 } |
|
67 |
|
68 if ( !IsCommandValid( aCmd ) ) |
|
69 { |
|
70 TRACE_FUNC_EXIT |
|
71 return KErrArgument; |
|
72 } |
|
73 |
|
74 TRACE_FUNC_EXIT |
|
75 return KErrNone; |
|
76 } |
|
77 |
|
78 TBool CHsRemoteControlDataHandler::IsCommandValid( |
|
79 THsRemoteControlCommand& aCmd ) |
|
80 { |
|
81 TRACE_FUNC_ENTRY |
|
82 THsRemoteControlCommandType type = EHsLast; |
|
83 aCmd.GetType( type ); |
|
84 TRACE_FUNC_EXIT |
|
85 return ( type < EHsLast ); |
|
86 } |
|
87 |