|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Used as an reference implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <remcon/remconconverterplugin.h> |
|
21 #include <remcon/bearerparams.h> |
|
22 #include <remconaddress.h> |
|
23 #include <RemConKeyEventData.h> |
|
24 #include <remconcoreapi.h> |
|
25 #include "WiredAccessoryKeyEventHandler.h" |
|
26 #include "AdaptationMessage.h" |
|
27 |
|
28 #include "AdaptationMessageDefinitions.h" |
|
29 #include "acc_debug.h" |
|
30 |
|
31 // EXTERNAL DATA STRUCTURES |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 |
|
35 // CONSTANTS |
|
36 |
|
37 // MACROS |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 |
|
41 // MODULE DATA STRUCTURES |
|
42 |
|
43 // LOCAL FUNCTION PROTOTYPES |
|
44 |
|
45 // FORWARD DECLARATIONS |
|
46 |
|
47 // ============================= LOCAL FUNCTIONS =============================== |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CWiredAccessoryKeyEventHandler::CWiredAccessoryKeyEventHandler |
|
51 // C++ default constructor can NOT contain any code, that |
|
52 // might leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CWiredAccessoryKeyEventHandler::CWiredAccessoryKeyEventHandler( TBearerParams& aBearerParams ) |
|
56 : CRemConBearerPlugin( aBearerParams ) |
|
57 , iState( EAccKeyEventHandlerStateUnknown ) |
|
58 , iOperationId( 0 ) |
|
59 , iTransactionId( 0 ) |
|
60 { |
|
61 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::CWiredAccessoryKeyEventHandler() - Enter" ); |
|
62 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::CWiredAccessoryKeyEventHandler() - Return" ); |
|
63 |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CWiredAccessoryKeyEventHandler::ConstructL |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CWiredAccessoryKeyEventHandler::ConstructL() |
|
72 { |
|
73 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::ConstructL() - Enter" ); |
|
74 // |
|
75 // initialization of event subscribe(s) can be done here. |
|
76 // |
|
77 iState = EAccKeyEventHandlerStateReady; |
|
78 |
|
79 |
|
80 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::ConstructL() - Return" ); |
|
81 |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CWiredAccessoryKeyEventHandler::NewL |
|
86 // Two-phased constructor. |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CWiredAccessoryKeyEventHandler* CWiredAccessoryKeyEventHandler::NewL( TBearerParams& aBearerParams ) |
|
90 { |
|
91 CWiredAccessoryKeyEventHandler* self = new (ELeave) CWiredAccessoryKeyEventHandler( aBearerParams ); |
|
92 CleanupStack::PushL( self ); |
|
93 self->ConstructL(); |
|
94 CleanupStack::Pop( self ); |
|
95 return self; |
|
96 } |
|
97 |
|
98 // Destructor |
|
99 CWiredAccessoryKeyEventHandler::~CWiredAccessoryKeyEventHandler() |
|
100 { |
|
101 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::~CWiredAccessoryKeyEventHandler() - Enter" ); |
|
102 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::~CWiredAccessoryKeyEventHandler() - Return" ); |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CWiredAccessoryKeyEventHandler::GetInterface |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TAny* CWiredAccessoryKeyEventHandler::GetInterface( TUid aUid ) |
|
110 { |
|
111 |
|
112 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::GetInterface() - Enter" ); |
|
113 |
|
114 |
|
115 TAny* bearer = NULL; |
|
116 |
|
117 if ( aUid == TUid::Uid( KRemConBearerInterface1 ) ) |
|
118 { |
|
119 bearer = reinterpret_cast<TAny*>( static_cast<MRemConBearerInterface*>( this ) ); |
|
120 } |
|
121 else |
|
122 { |
|
123 // Interface is not supported! |
|
124 } |
|
125 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::GetInterface() - Return" ); |
|
126 |
|
127 return bearer; |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CWiredAccessoryKeyEventHandler::GetResponse |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TInt CWiredAccessoryKeyEventHandler::GetResponse( TUid& aInterfaceUid, |
|
135 TUint& aTransactionId, |
|
136 TUint& aOperationId, |
|
137 RBuf8& aCommandData, |
|
138 TRemConAddress& aAddr ) |
|
139 { |
|
140 |
|
141 // Only events are forwarded, thus no need to implement get response |
|
142 TInt err ( KErrNotSupported ); |
|
143 |
|
144 ( void ) aTransactionId; |
|
145 ( void ) aOperationId; |
|
146 ( void ) aCommandData; |
|
147 ( void ) aAddr; |
|
148 ( void ) aInterfaceUid; |
|
149 |
|
150 return err; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CSACAccessoryKeyEventHandler::GetCommand |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 TInt CWiredAccessoryKeyEventHandler::GetCommand( TUid& aInterfaceUid, |
|
158 TUint& aTransactionId, |
|
159 TUint& aOperationId, |
|
160 RBuf8& aCommandData, |
|
161 TRemConAddress& aAddr ) |
|
162 { |
|
163 |
|
164 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::GetCommand() - Enter" ); |
|
165 TInt err ( KErrNone ); |
|
166 |
|
167 if ( iState != EAccKeyEventHandlerStateNewCommand ) |
|
168 { |
|
169 err = KErrNotReady; |
|
170 } |
|
171 else |
|
172 { |
|
173 aInterfaceUid = iInterfaceUid; |
|
174 aTransactionId = iTransactionId++; |
|
175 aOperationId = iOperationId; |
|
176 |
|
177 aAddr.BearerUid() = Uid(); |
|
178 aAddr.Addr() = KNullDesC8(); |
|
179 |
|
180 iState = EAccKeyEventHandlerStateReady; |
|
181 |
|
182 TRAP( err, aCommandData.CreateL( iData ) ); |
|
183 |
|
184 if ( err != KErrNone ) |
|
185 { |
|
186 //GetCommand - failed to create data |
|
187 } |
|
188 } |
|
189 |
|
190 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::GetCommand() - Return" ); |
|
191 return err; |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CWiredAccessoryKeyEventHandler::SendCommand |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 TInt CWiredAccessoryKeyEventHandler::SendCommand( TUid aInterfaceUid, |
|
199 TUint aOperationId, |
|
200 TUint aTransactionId, |
|
201 RBuf8& aData, |
|
202 const TRemConAddress& aAddr ) |
|
203 { |
|
204 |
|
205 // Only events are forwarded, thus no need to implement send command |
|
206 TInt err ( KErrNotSupported ); |
|
207 |
|
208 ( void ) aTransactionId; |
|
209 ( void ) aOperationId; |
|
210 ( void ) aAddr; |
|
211 ( void ) aInterfaceUid; |
|
212 ( void ) aData; |
|
213 |
|
214 return err; |
|
215 } |
|
216 |
|
217 // ----------------------------------------------------------------------------- |
|
218 // CWiredAccessoryKeyEventHandler::SendResponse |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 TInt CWiredAccessoryKeyEventHandler::SendResponse( TUid aInterfaceUid, |
|
222 TUint aOperationId, |
|
223 TUint aTransactionId, |
|
224 RBuf8& aData, |
|
225 const TRemConAddress& aAddr ) |
|
226 { |
|
227 |
|
228 // Only events are forwarded, thus no need to implement send response |
|
229 TInt err ( KErrNotSupported ); |
|
230 |
|
231 ( void ) aTransactionId; |
|
232 ( void ) aOperationId; |
|
233 ( void ) aAddr; |
|
234 ( void ) aInterfaceUid; |
|
235 ( void ) aData; |
|
236 |
|
237 return err; |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CWiredAccessoryKeyEventHandler::ConnectRequest |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CWiredAccessoryKeyEventHandler::ConnectRequest( const TRemConAddress& aAddr ) |
|
245 { |
|
246 |
|
247 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::ConnectRequest() - Enter" ); |
|
248 |
|
249 |
|
250 TInt err = Observer().ConnectConfirm( aAddr, KErrNone ); |
|
251 |
|
252 if ( err != KErrNone ) |
|
253 { |
|
254 // ConnectConfirm failed |
|
255 } |
|
256 |
|
257 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::ConnectRequest() - Return" ); |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CWiredAccessoryKeyEventHandler::DisconnectRequest |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 void CWiredAccessoryKeyEventHandler::DisconnectRequest( const TRemConAddress& aAddr ) |
|
265 { |
|
266 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::DisconnectRequest() - Enter" ); |
|
267 |
|
268 Observer().DisconnectConfirm( aAddr, KErrNone ); |
|
269 |
|
270 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::DisconnectRequest() - Return" ); |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CWiredAccessoryKeyEventHandler::ClientStatus |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 void CWiredAccessoryKeyEventHandler::ClientStatus( TBool aControllerPresent, TBool aTargetPresent ) |
|
278 { |
|
279 ( void ) aTargetPresent; |
|
280 ( void ) aControllerPresent; |
|
281 } |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CWiredAccessoryKeyEventHandler::SecurityPolicy |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 TSecurityPolicy CWiredAccessoryKeyEventHandler::SecurityPolicy() const |
|
288 { |
|
289 |
|
290 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::SecurityPolicy() - Enter" ); |
|
291 TSecurityPolicy securityPolicy ( ECapabilitySwEvent ); |
|
292 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::SecurityPolicy() - Return" ); |
|
293 return securityPolicy; |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CWiredAccessoryKeyEventHandler::ProcessResponseL |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 void CWiredAccessoryKeyEventHandler::ProcessResponseL( TAdaptationMessage& aMessage ) |
|
301 { |
|
302 ( void ) aMessage; |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CWiredAccessoryKeyEventHandler::ProcessErrorResponseL |
|
307 // ----------------------------------------------------------------------------- |
|
308 // |
|
309 void CWiredAccessoryKeyEventHandler::ProcessErrorResponseL( TInt aErrorCode, |
|
310 TAdaptationMessage& aMessage ) |
|
311 { |
|
312 ( void ) aErrorCode; |
|
313 ( void ) aMessage; |
|
314 } |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CWiredAccessoryKeyEventHandler::RaiseEventL |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 void CWiredAccessoryKeyEventHandler::RaiseEventL( TAdaptationMessage& aMessage ) |
|
321 { |
|
322 |
|
323 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::RaiseEventL() - Enter" ); |
|
324 //Accessory key events are received from Accessory Driver/Domestic OS. |
|
325 |
|
326 if ( iState != EAccKeyEventHandlerStateReady ) |
|
327 { |
|
328 User::Leave( KErrNotReady ); |
|
329 } |
|
330 |
|
331 // only key events are supported |
|
332 if ( aMessage.GroupId() != KBearerMessageGroupAccessoryEvent && aMessage.MessageId() != KBearerMessageGroupAccessoryKeyEvent ) |
|
333 { |
|
334 User::Leave( KErrArgument ); |
|
335 } |
|
336 |
|
337 TRemConMessageType type( ERemConCommand ); |
|
338 |
|
339 // Note! |
|
340 // following uid 0x102069AA should be used if platform key event converter is used, |
|
341 // uid is hard coded to platfrom converter which is returned to remotecontrol. |
|
342 // Data should give as format defined in S60_Accessory_Key_Event_Handling_API_Specification_C.doc. |
|
343 const TInt KWireBearerUid = 0x102069AA; |
|
344 |
|
345 TInt err = Observer().BearerToInterface( TUid::Uid( KWireBearerUid ), |
|
346 aMessage.Data(), |
|
347 aMessage.Data(), |
|
348 iInterfaceUid, |
|
349 iOperationId, |
|
350 type, |
|
351 iData ); |
|
352 if ( err == KErrNotSupported ) |
|
353 { |
|
354 |
|
355 } |
|
356 else if ( err == KErrNone ) |
|
357 { |
|
358 iState = EAccKeyEventHandlerStateNewCommand; |
|
359 |
|
360 TRemConAddress addr; |
|
361 addr.BearerUid() = Uid(); |
|
362 addr.Addr() = KNullDesC8(); |
|
363 |
|
364 err = Observer().NewCommand( addr ); |
|
365 |
|
366 if ( err != KErrNone ) |
|
367 { |
|
368 User::Leave( err ); |
|
369 } |
|
370 } |
|
371 else |
|
372 // leave if converting fails |
|
373 { |
|
374 User::Leave( err ); |
|
375 } |
|
376 |
|
377 COM_TRACE_( "[AccFW:WiredBearerReference] CWiredAccessoryKeyEventHandler::RaiseEventL() - Return" ); |
|
378 } |
|
379 |
|
380 // End of File |