1 /* |
|
2 * Copyright (c) 2007-2008 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: Receives buton presses from volume keys* |
|
15 */ |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include "CamVolumeKeyObserver.h" |
|
21 #include <remconcoreapitarget.h> |
|
22 #include <remconinterfaceselector.h> |
|
23 #include "CamUtility.h" |
|
24 #include "CamAppUi.h" |
|
25 #include "CamZoomPane.h" |
|
26 #include <AknDef.h> |
|
27 #include <aknconsts.h> |
|
28 |
|
29 |
|
30 |
|
31 /** |
|
32 * Helper class for sending response back to |
|
33 * Remote Controller Framework |
|
34 * |
|
35 * @since 3.1 |
|
36 */ |
|
37 class CCamRemConKeyResponse : public CActive |
|
38 { |
|
39 public: // Constructors and destructor |
|
40 |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 * aparam Remote Controller instance |
|
44 * @return new instance. |
|
45 */ |
|
46 static CCamRemConKeyResponse* NewL( CRemConCoreApiTarget& |
|
47 aRemConCoreApiTarget ); |
|
48 |
|
49 /** |
|
50 * Destructor. |
|
51 */ |
|
52 virtual ~CCamRemConKeyResponse(); |
|
53 |
|
54 public: // new function |
|
55 |
|
56 /** |
|
57 * Send the any key response back to Remcon server |
|
58 * @since 3.1 |
|
59 * @param aOperationId Remcon operation |
|
60 */ |
|
61 void CompleteAnyKeyL( TRemConCoreApiOperationId aOperationId ); |
|
62 |
|
63 private: //from base class |
|
64 |
|
65 /** |
|
66 * From CActive |
|
67 * Called on completion of a request |
|
68 * @since 3.1 |
|
69 */ |
|
70 void RunL(); |
|
71 |
|
72 /** |
|
73 * From CActive |
|
74 * Cancels an outstanding request |
|
75 * @since 3.1 |
|
76 */ |
|
77 void DoCancel(); |
|
78 |
|
79 private: |
|
80 |
|
81 /** |
|
82 * C++ default constructor. |
|
83 * @since 3.1 |
|
84 * aparam Remote Controller instance |
|
85 */ |
|
86 CCamRemConKeyResponse( CRemConCoreApiTarget& aRemConCoreApiTarget ); |
|
87 |
|
88 private: |
|
89 |
|
90 // Response array |
|
91 RArray<TRemConCoreApiOperationId> iResponseArray; |
|
92 |
|
93 // Remote controller |
|
94 CRemConCoreApiTarget& iRemConCoreApiTarget; |
|
95 }; |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CCamRemConKeyResponse::CCamRemConKeyResponse |
|
100 // default C++ constructor |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 CCamRemConKeyResponse::CCamRemConKeyResponse( CRemConCoreApiTarget& |
|
104 aRemConCoreApiTarget ) |
|
105 : CActive ( EPriorityNormal ), |
|
106 iRemConCoreApiTarget ( aRemConCoreApiTarget ) |
|
107 |
|
108 { |
|
109 CActiveScheduler::Add( this ); |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CCamRemConKeyResponse::NewL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 CCamRemConKeyResponse* CCamRemConKeyResponse::NewL(CRemConCoreApiTarget& |
|
118 aRemConCoreApiTarget) |
|
119 { |
|
120 CCamRemConKeyResponse* self = |
|
121 new (ELeave) CCamRemConKeyResponse( aRemConCoreApiTarget ); |
|
122 |
|
123 return self; |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CCamRemConKeyResponse::~CCamRemConKeyResponse |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 CCamRemConKeyResponse::~CCamRemConKeyResponse() |
|
131 { |
|
132 PRINT( _L("Camera => ~CCamRemConKeyResponse::~CCamRemConKeyResponse")) |
|
133 Cancel(); |
|
134 PRINT( _L("Camera => ~CCamRemConKeyResponse::~CCamRemConKeyResponse B")) |
|
135 iResponseArray.Reset(); |
|
136 PRINT( _L("Camera => ~CCamRemConKeyResponse::~CCamRemConKeyResponse C")) |
|
137 iResponseArray.Close(); |
|
138 PRINT( _L("Camera <= ~CCamRemConKeyResponse::~CCamRemConKeyResponse")) |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CCamRemConKeyResponse::DoCancel |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CCamRemConKeyResponse::DoCancel() |
|
146 { |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CCamRemConKeyResponse::RunL |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CCamRemConKeyResponse::RunL() |
|
154 { |
|
155 // if any existing -> Send response |
|
156 if ( iResponseArray.Count() ) |
|
157 { |
|
158 CompleteAnyKeyL( iResponseArray[0] ); |
|
159 // Remove already completed key |
|
160 iResponseArray.Remove(0); |
|
161 iResponseArray.Compress(); |
|
162 } |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CCamConKeyResponse::CompleteAnyKeyL |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 void CCamRemConKeyResponse::CompleteAnyKeyL( TRemConCoreApiOperationId |
|
170 aOperationId ) |
|
171 { |
|
172 PRINT(_L("Camera => CCamRemConKeyResponse::CompleteAnyKeyL")) |
|
173 if ( !IsActive() ) |
|
174 { |
|
175 switch ( aOperationId ) |
|
176 { |
|
177 case ERemConCoreApiVolumeUp: |
|
178 { |
|
179 PRINT( _L("CCamRemConKeyResponse::CompleteAnyKeyL operation volume up") ); |
|
180 iRemConCoreApiTarget.VolumeUpResponse( iStatus, KErrNone ); |
|
181 SetActive(); |
|
182 } |
|
183 break; |
|
184 case ERemConCoreApiVolumeDown: |
|
185 { |
|
186 PRINT( _L("CCamRemConKeyResponse::CompleteAnyKeyL operation volume down") ); |
|
187 iRemConCoreApiTarget.VolumeDownResponse( iStatus, KErrNone ); |
|
188 SetActive(); |
|
189 } |
|
190 break; |
|
191 default: |
|
192 { |
|
193 PRINT( _L("CCamRemConKeyResponse::CompleteAnyKeyL operation - other operation") ); |
|
194 // Send general response for 'other' keys |
|
195 iRemConCoreApiTarget.SendResponse( iStatus, aOperationId, KErrNone ); |
|
196 SetActive(); |
|
197 } |
|
198 break; |
|
199 } |
|
200 } |
|
201 // already active. Append to array and complete later. |
|
202 else |
|
203 { |
|
204 User::LeaveIfError( iResponseArray.Append( aOperationId ) ); |
|
205 } |
|
206 } |
|
207 |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CCamRemConObserver::NewL |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 CCamRemConObserver* CCamRemConObserver::NewL( MCamVolumeKeyObserver &aObserver ) |
|
214 { |
|
215 CCamRemConObserver* self = new ( ELeave ) CCamRemConObserver( aObserver ); |
|
216 CleanupStack::PushL( self ); |
|
217 self->ConstructL( ); |
|
218 CleanupStack::Pop(); |
|
219 |
|
220 return self; |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CPhoneRemConObserver::~CPhoneRemConObserver |
|
225 // destructor |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 CCamRemConObserver::~CCamRemConObserver() |
|
229 { |
|
230 PRINT( _L("Camera => CCamRemConObserver::~CCamRemConObserver")) |
|
231 delete iActiveRemCon; |
|
232 |
|
233 delete iInterfaceSelector; |
|
234 |
|
235 PRINT( _L("Camera <= CCamRemConObserver::~CCamRemConObserver")) |
|
236 } |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CPhoneRemConObserver::CPhoneRemConObserver |
|
240 // C++ default constructor |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 CCamRemConObserver::CCamRemConObserver( MCamVolumeKeyObserver& aObserver ): |
|
244 iObserver ( aObserver ) |
|
245 { |
|
246 } |
|
247 |
|
248 // ----------------------------------------------------------------------------- |
|
249 // CPhoneRemConObserver::ConstructL |
|
250 // Symbian 2nd phase constructor |
|
251 // ----------------------------------------------------------------------------- |
|
252 // |
|
253 void CCamRemConObserver::ConstructL() |
|
254 { |
|
255 iInterfaceSelector = CRemConInterfaceSelector::NewL(); |
|
256 |
|
257 // owned by CRemConInterfaceSelector instance |
|
258 iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this ); |
|
259 |
|
260 iActiveRemCon = CCamRemConKeyResponse::NewL( *iCoreTarget ); |
|
261 |
|
262 iInterfaceSelector->OpenTargetL(); |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CPhoneRemConObserver::MrccatoCommand |
|
267 // A command has been received. |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 void CCamRemConObserver::MrccatoCommand( |
|
271 TRemConCoreApiOperationId aOperationId, |
|
272 TRemConCoreApiButtonAction aButtonAct ) |
|
273 { |
|
274 PRINT2( _L("Camera => CCamRemConObserver::MrccatoCommand op (%d) act (%d)"), aOperationId, aButtonAct ) |
|
275 switch ( aOperationId ) |
|
276 { |
|
277 case ERemConCoreApiVolumeUp: |
|
278 { |
|
279 // send the response back to Remcon server |
|
280 TRAP_IGNORE( iActiveRemCon->CompleteAnyKeyL( aOperationId ) ); |
|
281 |
|
282 // send button press to zoom pane |
|
283 iObserver.HandleVolumeKeyEvent( aOperationId, aButtonAct ); |
|
284 } |
|
285 break; |
|
286 case ERemConCoreApiVolumeDown: |
|
287 { |
|
288 TRAP_IGNORE( iActiveRemCon->CompleteAnyKeyL( aOperationId ) ); |
|
289 iObserver.HandleVolumeKeyEvent( aOperationId, aButtonAct ); |
|
290 } |
|
291 break; |
|
292 default: |
|
293 { |
|
294 // Complete any other operation id |
|
295 TRAP_IGNORE( iActiveRemCon->CompleteAnyKeyL( aOperationId ) ); |
|
296 } |
|
297 break; |
|
298 } |
|
299 } |
|
300 |
|
301 // ----------------------------------------------------------------------------- |
|
302 // CPhoneRemConObserver::MrccatoPlay |
|
303 // not used |
|
304 // ----------------------------------------------------------------------------- |
|
305 // |
|
306 void CCamRemConObserver::MrccatoPlay( TRemConCoreApiPlaybackSpeed /*aSpeed*/, |
|
307 TRemConCoreApiButtonAction /*aButtonAct*/ ) |
|
308 { |
|
309 // not used |
|
310 } |
|
311 |
|
312 // ----------------------------------------------------------------------------- |
|
313 // CPhoneRemConObserver::MrccatoTuneFunction |
|
314 // not used |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 void CCamRemConObserver::MrccatoTuneFunction( TBool /*aTwoPart*/, |
|
318 TUint /*aMajorChannel*/, |
|
319 TUint /*aMinorChannel*/, |
|
320 TRemConCoreApiButtonAction /*aButtonAct*/ ) |
|
321 { |
|
322 // not used |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CPhoneRemConObserver::MrccatoSelectDiskFunction |
|
327 // not used |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void CCamRemConObserver::MrccatoSelectDiskFunction( TUint /*aDisk*/, |
|
331 TRemConCoreApiButtonAction /*aButtonAct*/ ) |
|
332 { |
|
333 // not used |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CPhoneRemConObserver::MrccatoSelectAvInputFunction |
|
338 // not used |
|
339 // ----------------------------------------------------------------------------- |
|
340 // |
|
341 void CCamRemConObserver::MrccatoSelectAvInputFunction( TUint8 /*aAvInputSignalNumber*/, |
|
342 TRemConCoreApiButtonAction /*aButtonAct*/ ) |
|
343 { |
|
344 // not used |
|
345 } |
|
346 |
|
347 // ----------------------------------------------------------------------------- |
|
348 // CPhoneRemConObserver::MrccatoSelectAudioInputFunction |
|
349 // not used |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 void CCamRemConObserver::MrccatoSelectAudioInputFunction( TUint8 /*aAudioInputSignalNumber*/, |
|
353 TRemConCoreApiButtonAction /*aButtonAct*/ ) |
|
354 { |
|
355 // not used |
|
356 } |
|
357 |
|
358 // End of File |
|