|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Key event class for internal use in converter. Maps key |
|
15 * actions, operation IDs, event prerequisities etc. to |
|
16 * TRemConKeyEventData -instances. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "RemConKeyEvent.h" |
|
23 #include "RemConDebug.h" |
|
24 |
|
25 // LOCAL CONSTANTS AND MACROS |
|
26 |
|
27 // Length of KCoreApiParameterLength is sufficient as long as values of |
|
28 // TRemConCoreApiButtonAction are from 0 to 2^32 |
|
29 const TInt KCoreApiParameterLength = 10; |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS =============================== |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CRemConKeyEvent::CRemConKeyEvent |
|
35 // C++ default constructor can NOT contain any code, that |
|
36 // might leave. |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CRemConKeyEvent::CRemConKeyEvent() |
|
40 { |
|
41 COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEvent::CRemConKeyEvent()" ); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CRemConKeyEvent::ConstructL |
|
46 // Symbian 2nd phase constructor can leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CRemConKeyEvent::ConstructL( const TRemConKeyEventData& aKeyEvent, |
|
50 const TUid& aInterfaceUID, |
|
51 const TUint& aOperationID, |
|
52 TDesC8& aParameter ) |
|
53 { |
|
54 COM_TRACE_2( "[AccFW:RemConConverter] CRemConKeyEvent::ConstructL( %d, %d )", aKeyEvent, aOperationID ); |
|
55 |
|
56 iKeyEvent = aKeyEvent; |
|
57 iInterfaceUID = aInterfaceUID; |
|
58 iOperationID = aOperationID; |
|
59 iParameter = HBufC8::NewL( aParameter.Size() ); |
|
60 iParameter->Des().Copy( aParameter ); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CRemConKeyEvent::NewL |
|
65 // Two-phased constructor. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CRemConKeyEvent* CRemConKeyEvent::NewL( const TRemConKeyEventData& aKeyEvent, |
|
69 const TUid& aInterfaceUid, |
|
70 const TUint& aOperationID, |
|
71 const TRemConCoreApiButtonAction& aButtonAction ) |
|
72 { |
|
73 COM_TRACE_2( "[AccFW:RemConConverter] CRemConKeyEvent::NewL( %d, %d )", aKeyEvent, aOperationID ); |
|
74 |
|
75 CRemConKeyEvent* self = new( ELeave ) CRemConKeyEvent; |
|
76 CleanupStack::PushL( self ); |
|
77 |
|
78 TBuf8< KCoreApiParameterLength > parameter; |
|
79 parameter.Append( aButtonAction ); |
|
80 self->ConstructL( aKeyEvent, aInterfaceUid, aOperationID, parameter ); |
|
81 |
|
82 CleanupStack::Pop( self ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CRemConKeyEvent::NewL |
|
88 // Two-phased constructor. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CRemConKeyEvent* CRemConKeyEvent::NewL( const TRemConKeyEventData& aKeyEvent, |
|
92 const TUid& aInterfaceUid, |
|
93 const TUint& aOperationID, |
|
94 TDesC8& aParameter ) |
|
95 { |
|
96 COM_TRACE_2( "[AccFW:RemConConverter] CRemConKeyEvent::NewL( %d, %d )", aKeyEvent, aOperationID ); |
|
97 |
|
98 CRemConKeyEvent* self = new( ELeave ) CRemConKeyEvent; |
|
99 |
|
100 CleanupStack::PushL( self ); |
|
101 self->ConstructL( aKeyEvent, aInterfaceUid, aOperationID, aParameter ); |
|
102 |
|
103 CleanupStack::Pop( self ); |
|
104 return self; |
|
105 } |
|
106 |
|
107 // Destructor |
|
108 CRemConKeyEvent::~CRemConKeyEvent() |
|
109 { |
|
110 COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEvent::~CRemConKeyEvent()" ); |
|
111 |
|
112 delete iParameter; |
|
113 |
|
114 COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEvent::~CRemConKeyEvent() return void." ); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CRemConKeyEvent::Compare |
|
119 // Compare two TRemConKeyEventData instances for equality. |
|
120 // (other items were commented in a header). |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TBool CRemConKeyEvent::Compare( const TRemConKeyEventData& aKeyEvent ) const |
|
124 { |
|
125 COM_TRACE_1( "[AccFW:RemConConverter] CRemConKeyEvent::Compare( %d )", aKeyEvent ); |
|
126 COM_TRACE_2( "[AccFW:RemConConverter] key code : l:%d r:%d ", iKeyEvent.iKeyCode, aKeyEvent.iKeyCode ); |
|
127 COM_TRACE_2( "[AccFW:RemConConverter] key modifiers: l:%d r:%d ", iKeyEvent.iKeyModifiers, aKeyEvent.iKeyModifiers ); |
|
128 COM_TRACE_2( "[AccFW:RemConConverter] key state : l:%d r:%d ", iKeyEvent.iKeyState, aKeyEvent.iKeyState ); |
|
129 COM_TRACE_2( "[AccFW:RemConConverter] key event : l:%d r:%d ", iKeyEvent.iKeyEventType, aKeyEvent.iKeyEventType ); |
|
130 |
|
131 TBool match( ( aKeyEvent.iKeyCode == iKeyEvent.iKeyCode ) && |
|
132 ( aKeyEvent.iKeyEventType == iKeyEvent.iKeyEventType ) && |
|
133 ( aKeyEvent.iKeyModifiers == iKeyEvent.iKeyModifiers ) && |
|
134 ( aKeyEvent.iKeyState == iKeyEvent.iKeyState ) ); |
|
135 |
|
136 COM_TRACE_1( "[AccFW:RemConConverter] Match: %d. ",match ); |
|
137 return ( match ); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CRemConKeyEvent::InterfaceUID |
|
142 // Return the interface UID of a certain key-event. |
|
143 // (other items were commented in a header). |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TUid CRemConKeyEvent::InterfaceUID() const |
|
147 { |
|
148 COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEvent::OperationID()" ); |
|
149 return iInterfaceUID; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CRemConKeyEvent::OperationID |
|
154 // Return the operation ID of a certain key-event. |
|
155 // (other items were commented in a header). |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 TUint CRemConKeyEvent::OperationID() const |
|
159 { |
|
160 COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEvent::OperationID()" ); |
|
161 return iOperationID; |
|
162 } |
|
163 |
|
164 // ----------------------------------------------------------------------------- |
|
165 // CRemConKeyEvent::Parameter |
|
166 // Returns parameter of a certain key-event. |
|
167 // (other items were commented in a header). |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 TDesC8& CRemConKeyEvent::Parameter() const |
|
171 { |
|
172 COM_TRACE_( "[AccFW:RemConConverter] CRemConKeyEvent::Parameter()" ); |
|
173 return *iParameter; |
|
174 //return iParameter; |
|
175 } |
|
176 |
|
177 // End of File |