|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "HWRMServer.h" |
|
20 #include "HWRMService.h" |
|
21 #include "HWRMFmTxService.h" |
|
22 #include "HWRMPluginHandler.h" |
|
23 #include "HWRMReservationHandler.h" |
|
24 #include "HWRMFmTxCommands.h" |
|
25 #include "HWRMFmTxClientServer.h" |
|
26 #include "HWRMFmTxRdsTextConverter.h" |
|
27 #include "HWRMtrace.h" |
|
28 |
|
29 // CONSTANTS |
|
30 _LIT( KPanicCategory, "HWRMFmTxService" ); |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CHWRMFmTxService::CHWRMFmTxService |
|
36 // C++ constructor |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CHWRMFmTxService::CHWRMFmTxService(CHWRMPluginHandler& aWatcherPluginHandler, |
|
40 CHWRMFmTxCommonData& aFmTxCommonData, |
|
41 CHWRMFmTxRdsTextConverter& aRdsTextConverter) |
|
42 : iWatcherPluginHandler(aWatcherPluginHandler), |
|
43 iFmTxCommonData(aFmTxCommonData), |
|
44 iRdsTextConverter(aRdsTextConverter) |
|
45 { |
|
46 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::CHWRMFmTxService()" )); |
|
47 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::CHWRMFmTxService - return" )); |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CHWRMFmTxService::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CHWRMFmTxService::ConstructL(CHWRMPluginHandler* aPluginHandler, |
|
56 CHWRMReservationHandler* aReservationHandler) |
|
57 { |
|
58 COMPONENT_TRACE3( _L( "HWRM Server - CHWRMFmTxService::ConstructL(0x%x, 0x%x)" ), aPluginHandler, aReservationHandler); |
|
59 |
|
60 __ASSERT_ALWAYS(aPluginHandler, User::Panic(KPanicCategory, EPanicBadHandle)); |
|
61 __ASSERT_ALWAYS(aReservationHandler, User::Panic(KPanicCategory, EPanicBadHandle)); |
|
62 |
|
63 BaseConstructL(aPluginHandler, aReservationHandler); |
|
64 iWatcherTransactionList = CHWRMPluginTransactionList::NewL(); |
|
65 |
|
66 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ConstructL - return " ) ); |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CHWRMFmTxService::NewL |
|
71 // Two-phased constructor. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CHWRMFmTxService* CHWRMFmTxService::NewL(CHWRMPluginHandler* aPluginHandler, |
|
75 CHWRMPluginHandler& aWatcherPluginHandler, |
|
76 CHWRMReservationHandler* aReservationHandler, |
|
77 CHWRMFmTxCommonData& aFmTxCommonData, |
|
78 CHWRMFmTxRdsTextConverter& aRdsTextConverter) |
|
79 { |
|
80 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::NewL(0x%x)" ), aPluginHandler); |
|
81 |
|
82 CHWRMFmTxService* self = new( ELeave ) |
|
83 CHWRMFmTxService(aWatcherPluginHandler, aFmTxCommonData, aRdsTextConverter); |
|
84 |
|
85 CleanupStack::PushL( self ); |
|
86 self->ConstructL(aPluginHandler, aReservationHandler); |
|
87 CleanupStack::Pop( self ); |
|
88 |
|
89 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::NewL - return 0x%x" ), self ); |
|
90 |
|
91 return self; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // Destructor |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 CHWRMFmTxService::~CHWRMFmTxService() |
|
99 { |
|
100 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::~CHWRMFmTxService()" ) ); |
|
101 |
|
102 DoRelease(); |
|
103 |
|
104 // Base class cleanup |
|
105 BaseDestruct(); |
|
106 // Complete any pending watchertransaction requests |
|
107 while ( iWatcherTransactionList->GetFirstItem() ) |
|
108 { |
|
109 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>( |
|
110 iWatcherTransactionList->RemoveFirstItem() ); |
|
111 if (data->iRequestMessage.Handle()) |
|
112 { |
|
113 COMPONENT_TRACE1( ( _L( "HWRM Server - CHWRMService::~CHWRMFmTxService() - Canceling pending message" ) ) ); |
|
114 |
|
115 data->iRequestMessage.Complete(KErrCancel); |
|
116 } |
|
117 |
|
118 TRAPD(err, iWatcherPluginHandler.CancelCommandL(data->iTransId)); |
|
119 |
|
120 if ( err != KErrNone ) |
|
121 { |
|
122 COMPONENT_TRACE3( _L( "HWRM Server - CHWRMService::~CHWRMFmTxService - Cancelling Command (transid: %d) failed: %d" ), data->iTransId, err ); |
|
123 } |
|
124 |
|
125 delete data; |
|
126 } |
|
127 // Destroy watchertransaction list |
|
128 delete iWatcherTransactionList; |
|
129 |
|
130 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::~CHWRMFmTxService - return" ) ); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CHWRMFmTxService::ExecuteMessageL |
|
135 // Handles FM Tx requests. Called from the client session via CSession2::ServiceL |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 TBool CHWRMFmTxService::ExecuteMessageL( const RMessage2& aMessage ) |
|
139 { |
|
140 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ExecuteMessageL(0x%x)" ), aMessage.Function()); |
|
141 |
|
142 if ( aMessage.IsNull() ) |
|
143 { |
|
144 User::Leave(KErrBadHandle); |
|
145 } |
|
146 |
|
147 // All messages are by default asynchronous because of the nature of the plugin API |
|
148 TBool completeMessage(EFalse); |
|
149 |
|
150 switch ( aMessage.Function() ) |
|
151 { |
|
152 case EHWRMFmTxCleanup: |
|
153 { |
|
154 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxCleanup") ); |
|
155 DoRelease(); |
|
156 completeMessage = ETrue; |
|
157 } |
|
158 break; |
|
159 |
|
160 case EHWRMFmTxOn: |
|
161 { |
|
162 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxOn") ); |
|
163 EnableL( aMessage ); |
|
164 } |
|
165 break; |
|
166 |
|
167 case EHWRMFmTxOff: |
|
168 { |
|
169 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxOff") ); |
|
170 completeMessage = DisableL( aMessage ); |
|
171 } |
|
172 break; |
|
173 |
|
174 case EHWRMFmTxGetFreqRange: |
|
175 { |
|
176 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxGetFreqRange") ); |
|
177 GetFrequencyRangeL( aMessage ); |
|
178 |
|
179 } |
|
180 break; |
|
181 |
|
182 case EHWRMFmTxSetFreq: |
|
183 { |
|
184 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetFreq") ); |
|
185 completeMessage = SetFrequencyL( aMessage ); |
|
186 } |
|
187 break; |
|
188 |
|
189 case EHWRMFmTxReserve: |
|
190 { |
|
191 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxReserve") ); |
|
192 |
|
193 // If returned mask is non-zero, reservation was done in suspended mode. |
|
194 iSuspended = (iReservationHandler->ReserveL(aMessage, aMessage.Int1(), this, KHWRMAllSubResources)); |
|
195 iReserved = ETrue; |
|
196 |
|
197 completeMessage = ETrue; // Complete needed, as dummy used. |
|
198 } |
|
199 break; |
|
200 |
|
201 case EHWRMFmTxRelease: |
|
202 { |
|
203 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxRelease") ); |
|
204 |
|
205 DoRelease(); |
|
206 |
|
207 completeMessage = ETrue; // Complete needed, as dummy used. |
|
208 } |
|
209 break; |
|
210 |
|
211 case EHWRMFmTxGetNextClearFreq: |
|
212 { |
|
213 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxGetNextClearFreq") ); |
|
214 |
|
215 GetNextClearFrequencyL( aMessage, |
|
216 1/*1 clear frequency required*/ ); |
|
217 } |
|
218 break; |
|
219 |
|
220 case EHWRMFmTxGetNextClearFreqArray: |
|
221 { |
|
222 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxGetNextClearFreqArray") ); |
|
223 |
|
224 TPckgBuf<TUint> clientClearFreqCountPckg; |
|
225 aMessage.ReadL(1,clientClearFreqCountPckg); |
|
226 |
|
227 GetNextClearFrequencyL( aMessage, |
|
228 clientClearFreqCountPckg() /*number of clear frequencies required*/ ); |
|
229 } |
|
230 break; |
|
231 |
|
232 |
|
233 case EHWRMFmTxCancelGetNextClearFreq: |
|
234 { |
|
235 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxCancelGetNextClearFreq") ); |
|
236 |
|
237 CancelPluginCommandL( HWRMFmTxCommand::ETxScanRequestCmdId ); |
|
238 completeMessage = ETrue; // no responses from plugin cancel commands |
|
239 } |
|
240 break; |
|
241 |
|
242 case EHWRMFmTxSetNextClearFreq: |
|
243 { |
|
244 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetNextClearFreq") ); |
|
245 |
|
246 SetNextClearFrequencyL( aMessage, |
|
247 1/*1 clear frequency required*/ ); |
|
248 } |
|
249 break; |
|
250 |
|
251 case EHWRMFmTxCancelSetNextClearFreq: |
|
252 { |
|
253 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxCancelSetNextClearFreq") ); |
|
254 |
|
255 // no hope of cancelling the ESetTxFrequencyCmdId part, so try the ETxScanRequestCmdId |
|
256 CancelPluginCommandL( HWRMFmTxCommand::ETxScanRequestCmdId ); |
|
257 completeMessage = ETrue; // no responses from plugin cancel commands |
|
258 } |
|
259 break; |
|
260 |
|
261 case EHWRMFmTxSetRdsPty: |
|
262 { |
|
263 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetRdsPty") ); |
|
264 SetRdsPtyL( aMessage ); |
|
265 } |
|
266 break; |
|
267 |
|
268 case EHWRMFmTxSetRdsPtyn: |
|
269 { |
|
270 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetRdsPtyn") ); |
|
271 SetRdsPtynL( aMessage ); |
|
272 } |
|
273 break; |
|
274 |
|
275 case EHWRMFmTxSetRdsMs: |
|
276 { |
|
277 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetRdsMs") ); |
|
278 SetRdsMsL( aMessage ); |
|
279 } |
|
280 break; |
|
281 |
|
282 case EHWRMFmTxSetRdsLanguageId: |
|
283 { |
|
284 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetRdsLanguageId") ); |
|
285 SetRdsLanguageIdL( aMessage ); |
|
286 } |
|
287 break; |
|
288 |
|
289 case EHWRMFmTxSetRadiotext: |
|
290 { |
|
291 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetRadiotext") ); |
|
292 SetRadiotextL( aMessage ); |
|
293 } |
|
294 break; |
|
295 |
|
296 case EHWRMFmTxSetRadiotextPlus1: |
|
297 { |
|
298 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetRadiotext") ); |
|
299 TRtPlusTag tag; // create a RT tag |
|
300 tag.iContentType = (TRtPlusContentType)aMessage.Int1(); |
|
301 tag.iStartMarker = 0; |
|
302 tag.iLengthMarker = aMessage.GetDesLengthL(0); |
|
303 SetRadiotextL( aMessage, tag ); |
|
304 } |
|
305 break; |
|
306 |
|
307 case EHWRMFmTxSetRadiotextPlus2: |
|
308 { |
|
309 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetRadiotext") ); |
|
310 // read RT tag from client |
|
311 THWRMRtPlusTagCmdPackage tagPckg; |
|
312 if ( aMessage.Read(1, tagPckg) != KErrNone ) |
|
313 { |
|
314 User::Leave(KErrArgument); |
|
315 } |
|
316 TRtPlusTag tag = tagPckg(); |
|
317 SetRadiotextL( aMessage, tag ); |
|
318 } |
|
319 break; |
|
320 |
|
321 case EHWRMFmTxSetRadiotextPlus3: |
|
322 { |
|
323 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxSetRadiotext") ); |
|
324 // read RT tags from client |
|
325 THWRMRtPlusTagCmdPackage tagPckg1, tagPckg2; |
|
326 if ( aMessage.Read(1, tagPckg1) != KErrNone || |
|
327 aMessage.Read(2, tagPckg2) != KErrNone ) |
|
328 { |
|
329 User::Leave(KErrArgument); |
|
330 } |
|
331 TRtPlusTag tag1 = tagPckg1(); |
|
332 TRtPlusTag tag2 = tagPckg2(); |
|
333 SetRadiotextL( aMessage, tag1, tag2 ); |
|
334 } |
|
335 break; |
|
336 |
|
337 case EHWRMFmTxClearRdsData: |
|
338 { |
|
339 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxClearRdsData") ); |
|
340 ClearRdsDataL( aMessage ); |
|
341 } |
|
342 break; |
|
343 |
|
344 case EHWRMFmTxClearRtData: |
|
345 { |
|
346 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecuteMessageL - EHWRMFmTxClearRtData") ); |
|
347 ClearRadiotextDataL( aMessage ); |
|
348 } |
|
349 break; |
|
350 |
|
351 // Not currently supported |
|
352 case EHWRMFmTxAutoFreqOn: |
|
353 case EHWRMFmTxAutoFreqOff: |
|
354 { |
|
355 User::Leave(KErrNotSupported); |
|
356 } |
|
357 break; |
|
358 |
|
359 // Cannot identify the message, panic the client |
|
360 default: |
|
361 { |
|
362 CHWRMServer::PanicClient(aMessage, EPanicIllegalFunction); |
|
363 } |
|
364 break; |
|
365 } |
|
366 |
|
367 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ExecuteMessageL - return 0x%x" ), completeMessage ); |
|
368 |
|
369 return completeMessage; |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CHWRMFmTxService::EnableL |
|
374 // Sends a plug-in command to switch FM Tx ON |
|
375 // ----------------------------------------------------------------------------- |
|
376 // |
|
377 void CHWRMFmTxService::EnableL(const RMessage2& aMessage) |
|
378 { |
|
379 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::EnableL(0x%x)" ), aMessage.Int0() ); |
|
380 |
|
381 LeaveIfOtherReservationL(); |
|
382 |
|
383 // We cannot enable from "power save" state |
|
384 if ( iFmTxCommonData.IsAccessoryPowerSaveOn() ) |
|
385 { |
|
386 // We cannot enable during "power save" due to mutually exclusive accessory connection. |
|
387 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::EnableL - not ready in \"power save\" state" ) ); |
|
388 User::Leave(KErrNotReady); |
|
389 } |
|
390 else if ( iFmTxCommonData.IsFmTxHardwareOn() ) |
|
391 { |
|
392 // If already On, then send the new frequency instead |
|
393 COMPONENT_TRACE1( ( _L( "HWRM Server - CHWRMFmTxService::EnableL - HW already on" ) ) ); |
|
394 HWRMFmTxCommand::TSetFrequencyPackage pckg( aMessage.Int0() ); |
|
395 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ESetTxFrequencyCmdId, EFalse/*not split*/, pckg, aMessage.Int0() ); |
|
396 } |
|
397 else |
|
398 { |
|
399 //start observing |
|
400 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::EStartObservingCmdId, EFalse/*not split*/ ); |
|
401 iFmTxCommonData.UpdateFrequency( aMessage.Int0() ); |
|
402 } |
|
403 |
|
404 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::EnableL - return" ) ); |
|
405 } |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // CHWRMFmTxService::DisableL |
|
409 // Sends a plug-in command to switch FM Tx OFF |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 TBool CHWRMFmTxService::DisableL(const RMessage2& aMessage) |
|
413 { |
|
414 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::DisableL" ) ); |
|
415 |
|
416 LeaveIfOtherReservationL(); |
|
417 |
|
418 // We don't need to disable HW from some states |
|
419 if ( !iFmTxCommonData.IsFmTxHardwareOn() ) |
|
420 { |
|
421 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::DisableL - HW already off due to power-save mode" ) ); |
|
422 iFmTxCommonData.UpdateStatus(CHWRMFmTxCommonData::EFmTxStateTransRequestedOff); |
|
423 return ETrue; |
|
424 } |
|
425 |
|
426 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ETxOffCmdId, EFalse/*not split*/ ); |
|
427 |
|
428 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::DisableL - return" ) ); |
|
429 return EFalse; |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // CHWRMFmTxService::GetFrequencyRangeL |
|
434 // Sends a plug-in command to query the FM Tx frequency range |
|
435 // ----------------------------------------------------------------------------- |
|
436 // |
|
437 void CHWRMFmTxService::GetFrequencyRangeL(const RMessage2& aMessage) |
|
438 { |
|
439 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::GetFrequencyRangeL" ) ); |
|
440 |
|
441 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::EGetTxFrequencyRangeCmdId, EFalse/*not split*/ ); |
|
442 |
|
443 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::GetFrequencyRangeL - return" ) ); |
|
444 } |
|
445 |
|
446 // ----------------------------------------------------------------------------- |
|
447 // CHWRMFmTxService::SetFrequencyL |
|
448 // Sends a plug-in command to set the FM Tx frequency |
|
449 // ----------------------------------------------------------------------------- |
|
450 // |
|
451 TBool CHWRMFmTxService::SetFrequencyL(const RMessage2& aMessage) |
|
452 { |
|
453 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::SetFrequencyL(0x%x)" ), aMessage.Int0() ); |
|
454 |
|
455 LeaveIfOtherReservationL(); |
|
456 TInt retVal = EFalse; |
|
457 |
|
458 // Check Tx status |
|
459 if ( iFmTxCommonData.IsFmTxHardwareOn() ) |
|
460 { |
|
461 // Package & send the request |
|
462 HWRMFmTxCommand::TSetFrequencyPackage pckg( aMessage.Int0() ); |
|
463 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ESetTxFrequencyCmdId, EFalse/*not split*/, pckg, aMessage.Int0() ); |
|
464 retVal = EFalse; // don't complete message yet |
|
465 } |
|
466 else |
|
467 { |
|
468 // Just save the frequency for future use |
|
469 iFmTxCommonData.UpdateFrequency( aMessage.Int0() ); |
|
470 retVal = ETrue; // complete message now |
|
471 } |
|
472 |
|
473 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::SetFrequencyL - return %d" ), retVal ); |
|
474 return retVal; |
|
475 } |
|
476 |
|
477 // ----------------------------------------------------------------------------- |
|
478 // CHWRMFmTxService::GetNextClearFrequencyL |
|
479 // Sends a plug-in command to scan for an available (clear) frequency |
|
480 // ----------------------------------------------------------------------------- |
|
481 // |
|
482 void CHWRMFmTxService::GetNextClearFrequencyL(const RMessage2& aMessage, |
|
483 TUint aClearFreqsRequired) |
|
484 { |
|
485 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::GetNextClearFrequencyL(%d)" ), aClearFreqsRequired ); |
|
486 |
|
487 LeaveIfOtherReservationL(); |
|
488 |
|
489 LeaveIfTransmitterOffL(); |
|
490 |
|
491 // package up the request |
|
492 HWRMFmTxCommand::TScanRequestPackage pckg(aClearFreqsRequired); |
|
493 |
|
494 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ETxScanRequestCmdId, EFalse/*not split*/, pckg ); |
|
495 |
|
496 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::GetClearFrequencyL - return" ) ); |
|
497 } |
|
498 |
|
499 // ----------------------------------------------------------------------------- |
|
500 // CHWRMFmTxService::SetNextClearFrequencyL |
|
501 // Sends the 1st part of a split command, to scan for an available (clear) frequency |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 void CHWRMFmTxService::SetNextClearFrequencyL(const RMessage2& aMessage, |
|
505 TUint aClearFreqsRequired) |
|
506 { |
|
507 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::SetNextClearFrequencyL(%d)" ), aClearFreqsRequired ); |
|
508 |
|
509 LeaveIfOtherReservationL(); |
|
510 |
|
511 LeaveIfTransmitterOffL(); |
|
512 |
|
513 // package up the request |
|
514 HWRMFmTxCommand::TScanRequestPackage pckg(aClearFreqsRequired); |
|
515 |
|
516 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ETxScanRequestCmdId, ETrue/*split*/, pckg ); |
|
517 // wait until response before calling SetFrequencyL |
|
518 |
|
519 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetNextClearFrequencyL - return" ) ); |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // CHWRMFmTxService::SetRdsPtyL |
|
524 // Sends a plug-in command to set the Programme TYpe |
|
525 // ----------------------------------------------------------------------------- |
|
526 // |
|
527 void CHWRMFmTxService::SetRdsPtyL(const RMessage2& aMessage) |
|
528 { |
|
529 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::SetRdsPtyL(0x%x)" ), aMessage.Int0() ); |
|
530 |
|
531 LeaveIfOtherReservationL(); |
|
532 |
|
533 LeaveIfTransmitterOffL(); |
|
534 |
|
535 // package up the request |
|
536 HWRMFmTxCommand::TRdsPtyPackage pckg( aMessage.Int0() ); |
|
537 |
|
538 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ESetTxRdsPtyCmdId, EFalse/*not split*/, pckg ); |
|
539 |
|
540 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRdsPtyL - return" ) ); |
|
541 } |
|
542 |
|
543 // ----------------------------------------------------------------------------- |
|
544 // CHWRMFmTxService::SetRdsPtynL |
|
545 // Sends a plug-in command to set the Programme TYpe Name |
|
546 // ----------------------------------------------------------------------------- |
|
547 // |
|
548 void CHWRMFmTxService::SetRdsPtynL(const RMessage2& aMessage) |
|
549 { |
|
550 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRdsPtynL") ); |
|
551 |
|
552 LeaveIfOtherReservationL(); |
|
553 |
|
554 LeaveIfTransmitterOffL(); |
|
555 |
|
556 // Check input param |
|
557 TRdsProgrammeTypeName clientPtyn; |
|
558 if ( aMessage.Read(0,clientPtyn) != KErrNone ) |
|
559 { |
|
560 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRdsPtynL") ); |
|
561 User::Leave(KErrArgument); |
|
562 } |
|
563 |
|
564 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::SetRdsPtynL new PTYN = %S"), &clientPtyn ); |
|
565 |
|
566 // package up the request |
|
567 HWRMFmTxCommand::TRdsPtyn newPtyn; |
|
568 iRdsTextConverter.ConvertFromUnicodeL( clientPtyn, newPtyn ); // Insert the new PTYN |
|
569 HWRMFmTxCommand::TRdsPtynPackage pckg(newPtyn); |
|
570 |
|
571 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ESetTxRdsPtynCmdId, EFalse/*not split*/, pckg ); |
|
572 |
|
573 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRdsPtynL - return") ); |
|
574 } |
|
575 |
|
576 // ----------------------------------------------------------------------------- |
|
577 // CHWRMFmTxService::SetRdsMsL |
|
578 // Sends a plug-in command to set the Music/Speech flag |
|
579 // ----------------------------------------------------------------------------- |
|
580 // |
|
581 void CHWRMFmTxService::SetRdsMsL(const RMessage2& aMessage) |
|
582 { |
|
583 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRdsMsL") ); |
|
584 |
|
585 LeaveIfOtherReservationL(); |
|
586 |
|
587 LeaveIfTransmitterOffL(); |
|
588 |
|
589 // package up the request |
|
590 HWRMFmTxCommand::TRdsMsPackage pckg( aMessage.Int0() ); |
|
591 |
|
592 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ESetTxRdsMsCmdId, EFalse/*not split*/, pckg ); |
|
593 |
|
594 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRdsMsL - return") ); |
|
595 } |
|
596 |
|
597 // ----------------------------------------------------------------------------- |
|
598 // CHWRMFmTxService::SetRdsLanguageIdL |
|
599 // Sends a plug-in command to set the RDS language ID |
|
600 // ----------------------------------------------------------------------------- |
|
601 // |
|
602 void CHWRMFmTxService::SetRdsLanguageIdL(const RMessage2& aMessage) |
|
603 { |
|
604 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRdsLanguageIdL") ); |
|
605 |
|
606 LeaveIfOtherReservationL(); |
|
607 |
|
608 LeaveIfTransmitterOffL(); |
|
609 |
|
610 // package up the request |
|
611 HWRMFmTxCommand::TRdsLangIdPackage pckg( aMessage.Int0() ); |
|
612 |
|
613 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ESetTxRdsLangIdCmdId, EFalse/*not split*/, pckg ); |
|
614 |
|
615 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRdsLanguageIdL - return") ); |
|
616 } |
|
617 |
|
618 // ----------------------------------------------------------------------------- |
|
619 // CHWRMFmTxService::ClearRdsDataL |
|
620 // Sends a plug-in command, to set the RDS data back to default values |
|
621 // ----------------------------------------------------------------------------- |
|
622 // |
|
623 void CHWRMFmTxService::ClearRdsDataL(const RMessage2& aMessage) |
|
624 { |
|
625 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ClearRdsDataL") ); |
|
626 |
|
627 LeaveIfOtherReservationL(); |
|
628 |
|
629 LeaveIfTransmitterOffL(); |
|
630 |
|
631 // package up the requests |
|
632 HWRMFmTxCommand::TRdsPtyn newPtyn; |
|
633 newPtyn.Zero(); |
|
634 HWRMFmTxCommand::TRdsPtyPackage ptyPckg( KRdsPtyNone ); |
|
635 HWRMFmTxCommand::TRdsPtynPackage ptynPckg( newPtyn ); |
|
636 HWRMFmTxCommand::TRdsMsPackage msPckg( ETrue ); // defaults to Music |
|
637 HWRMFmTxCommand::TRdsLangIdPackage langIdPckg( KRdsLanguageUnknown ); |
|
638 |
|
639 // Clear RDS values |
|
640 ExecutePluginCommandL( aMessage, HWRMFmTxCommand::ESetTxRdsPtyCmdId, ETrue/*split*/, ptyPckg ); |
|
641 ExecutePluginCommandL( aMessage, HWRMFmTxCommand::ESetTxRdsPtynCmdId, ETrue/*split*/, ptynPckg ); |
|
642 ExecutePluginCommandL( aMessage, HWRMFmTxCommand::ESetTxRdsMsCmdId, ETrue/*split*/, msPckg ); |
|
643 ExecutePluginCommandL( aMessage, HWRMFmTxCommand::ESetTxRdsLangIdCmdId, ETrue/*split*/, langIdPckg ); |
|
644 |
|
645 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ClearRdsDataL - return") ); |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CHWRMFmTxService::ClearRadiotextDataL |
|
650 // Sends a plug-in command, to clear the RT data |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 void CHWRMFmTxService::ClearRadiotextDataL(const RMessage2& aMessage) |
|
654 { |
|
655 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ClearRadiotextDataL") ); |
|
656 |
|
657 LeaveIfOtherReservationL(); |
|
658 |
|
659 LeaveIfTransmitterOffL(); |
|
660 |
|
661 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::EClearTxRtCmdId, EFalse/*not split*/ ); |
|
662 |
|
663 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ClearRadiotextDataL - return") ); |
|
664 } |
|
665 |
|
666 // ----------------------------------------------------------------------------- |
|
667 // CHWRMFmTxService::SetRadiotextL |
|
668 // Sends a plug-in command, to set the RT data |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 void CHWRMFmTxService::SetRadiotextL(const RMessage2& aMessage) |
|
672 { |
|
673 TRtPlusTag dummyTag1, dummyTag2; // create some dummy tags |
|
674 dummyTag1.iContentType = dummyTag2.iContentType = ERtPlusInfoOther; |
|
675 dummyTag1.iStartMarker = dummyTag2.iStartMarker = 0; |
|
676 dummyTag1.iLengthMarker = dummyTag2.iLengthMarker = 0; |
|
677 |
|
678 SetRadiotextL( aMessage, dummyTag1, dummyTag2 ); |
|
679 } |
|
680 |
|
681 // ----------------------------------------------------------------------------- |
|
682 // CHWRMFmTxService::SetRadiotextL |
|
683 // Sends a plug-in command, to set the RT data |
|
684 // ----------------------------------------------------------------------------- |
|
685 // |
|
686 void CHWRMFmTxService::SetRadiotextL(const RMessage2& aMessage, TRtPlusTag aTag) |
|
687 { |
|
688 TRtPlusTag dummyTag; // create a dummy tag |
|
689 dummyTag.iContentType = ERtPlusInfoOther; |
|
690 dummyTag.iStartMarker = 0; |
|
691 dummyTag.iLengthMarker = 0; |
|
692 |
|
693 SetRadiotextL( aMessage, aTag, dummyTag ); |
|
694 } |
|
695 |
|
696 // ----------------------------------------------------------------------------- |
|
697 // CHWRMFmTxService::SetRadiotextL |
|
698 // Sends a plug-in command, to set the RT data |
|
699 // ----------------------------------------------------------------------------- |
|
700 // |
|
701 void CHWRMFmTxService::SetRadiotextL(const RMessage2& aMessage, TRtPlusTag aTag1, TRtPlusTag aTag2) |
|
702 { |
|
703 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRadiotextL") ); |
|
704 |
|
705 LeaveIfOtherReservationL(); |
|
706 |
|
707 LeaveIfTransmitterOffL(); |
|
708 |
|
709 LeaveIfTagInvalidL(aTag1); |
|
710 LeaveIfTagInvalidL(aTag2); |
|
711 |
|
712 // Check input descriptor |
|
713 TBuf<HWRMFmTxCommand::KMaxRtDataLength> clientRtData; |
|
714 if ( aMessage.GetDesLengthL(0) < HWRMFmTxCommand::KMaxRtDataLength ) |
|
715 { |
|
716 if ( aMessage.Read(0,clientRtData) != KErrNone ) |
|
717 { |
|
718 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SetRadiotextL, read error") ); |
|
719 User::Leave(KErrArgument); |
|
720 } |
|
721 } |
|
722 else |
|
723 { |
|
724 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::SetRadiotextL, length error %d"), aMessage.GetDesLengthL(0) ); |
|
725 User::Leave(KErrArgument); |
|
726 } |
|
727 |
|
728 // package up the request |
|
729 HWRMFmTxCommand::TRtData newRtData; |
|
730 iRdsTextConverter.ConvertFromUnicodeL( clientRtData, newRtData.iText ); // Convert to 8bit RDS format |
|
731 newRtData.iTag1.iContentType = aTag1.iContentType; |
|
732 newRtData.iTag1.iStartMarker = aTag1.iStartMarker; |
|
733 newRtData.iTag1.iLengthMarker = aTag1.iLengthMarker; |
|
734 newRtData.iTag2.iContentType = aTag2.iContentType; |
|
735 newRtData.iTag2.iStartMarker = aTag2.iStartMarker; |
|
736 newRtData.iTag2.iLengthMarker = aTag2.iLengthMarker; |
|
737 HWRMFmTxCommand::TRtPackage pckg(newRtData); |
|
738 |
|
739 ExecutePluginCommandL(aMessage, HWRMFmTxCommand::ESetTxRtCmdId, EFalse/*not split*/, pckg ); |
|
740 } |
|
741 |
|
742 // ----------------------------------------------------------------------------- |
|
743 // CHWRMFmTxService::ProcessResponseL |
|
744 // Handles responses to FM Tx requests. |
|
745 // ----------------------------------------------------------------------------- |
|
746 // |
|
747 void CHWRMFmTxService::ProcessResponseL( TInt aCommandId, TUint8 aTransId, TDesC8& aData, TBool aTimeout ) |
|
748 { |
|
749 COMPONENT_TRACE4( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL(%d , %d, <data>, %d)" ), aCommandId, aTransId, aTimeout ); |
|
750 |
|
751 TInt pluginErr(KErrNone); // Error came from plugin as data (or timeout). Used to complete RMessage. |
|
752 TInt contextErr(KErrNone); // Error in context, i.e. bad handle or descriptor. Used to leave. |
|
753 TBool watcherMsg( EFalse ); |
|
754 TBool completeWatcherMsg( EFalse ); |
|
755 |
|
756 if ( aTimeout) |
|
757 { |
|
758 pluginErr = KErrTimedOut; |
|
759 } |
|
760 else if ( CheckResponseDataSize(aCommandId, aData) == EFalse ) |
|
761 { |
|
762 pluginErr = KErrBadDescriptor; |
|
763 } |
|
764 else |
|
765 { |
|
766 // Handle the response |
|
767 switch ( aCommandId ) |
|
768 { |
|
769 case HWRMFmTxCommand::EStartObservingCmdId: |
|
770 { |
|
771 HWRMFmTxCommand::TConnStatusPackage pckg; |
|
772 pckg.Copy( aData ); |
|
773 HWRMFmTxCommand::TConnStatusData data( pckg() ); |
|
774 watcherMsg = ETrue; |
|
775 |
|
776 if( data.iConnected ) |
|
777 { |
|
778 completeWatcherMsg = ETrue; |
|
779 pluginErr = KErrNotReady; |
|
780 // Update common data power save state |
|
781 iFmTxCommonData.UpdatePowerSaveState( |
|
782 CHWRMFmTxCommonData::EHWRMFmTxPowerSaveAccessory ); |
|
783 // Store the new status |
|
784 iFmTxCommonData.UpdateStatus(CHWRMFmTxCommonData::EFmTxStateTransOff); |
|
785 } |
|
786 else |
|
787 { |
|
788 // Normal case - send the On request |
|
789 HWRMFmTxCommand::TSetFrequencyPackage pckg( iFmTxCommonData.Frequency() ); |
|
790 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>( |
|
791 iWatcherTransactionList->FindTransaction( aTransId, |
|
792 EFalse ) ); |
|
793 if(data) |
|
794 { |
|
795 TRAP( pluginErr, ExecutePluginCommandL( data->iRequestMessage, |
|
796 HWRMFmTxCommand::ETxOnCmdId, |
|
797 EFalse/*not split*/, |
|
798 pckg ) ); |
|
799 } |
|
800 else |
|
801 { |
|
802 pluginErr = KErrNotFound; // Data is null |
|
803 } |
|
804 |
|
805 } |
|
806 } |
|
807 break; |
|
808 |
|
809 case HWRMFmTxCommand::ETxOnCmdId: |
|
810 { |
|
811 // Unpack the error code |
|
812 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
813 errPckg.Copy(aData); |
|
814 pluginErr = errPckg(); |
|
815 |
|
816 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ETxOnCmdId pluginErr = %d" ), pluginErr ); |
|
817 |
|
818 if ( pluginErr == KErrNone || pluginErr == KErrInUse ) |
|
819 { |
|
820 pluginErr = KErrNone; // If already enabled, complete client request with KErrNone |
|
821 // Update common data power save |
|
822 iFmTxCommonData.UpdatePowerSaveState( |
|
823 CHWRMFmTxCommonData::EHWRMFmTxPowerSaveOff ); |
|
824 // Store the new status |
|
825 iFmTxCommonData.UpdateStatus(CHWRMFmTxCommonData::EFmTxStateTransOn); |
|
826 } |
|
827 } |
|
828 break; |
|
829 |
|
830 case HWRMFmTxCommand::ETxOffCmdId: |
|
831 { |
|
832 // Unpack the error code |
|
833 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
834 errPckg.Copy(aData); |
|
835 pluginErr = errPckg(); |
|
836 |
|
837 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ETxOffCmdId pluginErr = %d" ), pluginErr ); |
|
838 |
|
839 if ( pluginErr == KErrNone || pluginErr == KErrNotReady ) |
|
840 { |
|
841 pluginErr = KErrNone; // If already disabled, complete client request with KErrNone |
|
842 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
843 |
|
844 // Store the new status |
|
845 if ( data && data->iRequestMessage.Handle() ) |
|
846 { |
|
847 // User has disabled FM Tx |
|
848 iFmTxCommonData.UpdateStatus(CHWRMFmTxCommonData::EFmTxStateTransRequestedOff); |
|
849 ExecutePluginCommand(HWRMFmTxCommand::EStopObservingCmdId); |
|
850 } |
|
851 else |
|
852 { |
|
853 // FM Tx has been automatically powered down |
|
854 iFmTxCommonData.UpdateStatus(CHWRMFmTxCommonData::EFmTxStateTransOff); |
|
855 } |
|
856 } |
|
857 } |
|
858 break; |
|
859 |
|
860 case HWRMFmTxCommand::EGetTxFrequencyRangeCmdId: |
|
861 { |
|
862 // Unpack the FM Tx frequency range |
|
863 HWRMFmTxCommand::TFrequencyRangePackage freqRangePckg; |
|
864 freqRangePckg.Copy(aData); |
|
865 HWRMFmTxCommand::TFrequencyRangeData freqRange = freqRangePckg(); |
|
866 |
|
867 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, EGetTxFrequencyRangeCmdId error = %d" ), freqRange.iErrorCode ); |
|
868 |
|
869 // Validate response values. Tx frequency range will not be changed dynamically |
|
870 if ( freqRange.iErrorCode != KErrNone || |
|
871 freqRange.iMinFrequency == 0 || |
|
872 freqRange.iMaxFrequency == 0 || |
|
873 freqRange.iStepSize == 0 ) |
|
874 { |
|
875 // Set backup frequency range defaults |
|
876 freqRange.iMinFrequency = KHWRMFmTxBackupMinFreq; |
|
877 freqRange.iMaxFrequency = KHWRMFmTxBackupMaxFreq; |
|
878 freqRange.iStepSize = KHWRMFmTxBackupStepSize; |
|
879 } |
|
880 |
|
881 // Store the frequency range |
|
882 iFmTxCommonData.SetFrequencyRange( freqRange.iMinFrequency, freqRange.iMaxFrequency, freqRange.iStepSize ); |
|
883 |
|
884 // Return frequency range to client |
|
885 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
886 if ( data && data->iRequestMessage.Handle() ) |
|
887 { |
|
888 TFmTxFrequencyRange clientFreqRange; |
|
889 clientFreqRange.iMinFrequency = freqRange.iMinFrequency; |
|
890 clientFreqRange.iMaxFrequency = freqRange.iMaxFrequency; |
|
891 clientFreqRange.iStepSize = freqRange.iStepSize; |
|
892 TPckg<TFmTxFrequencyRange> clientFreqRangePckg(clientFreqRange); |
|
893 pluginErr = data->iRequestMessage.Write(0,clientFreqRangePckg); |
|
894 } |
|
895 } |
|
896 break; |
|
897 |
|
898 case HWRMFmTxCommand::ESetTxFrequencyCmdId: |
|
899 { |
|
900 // Unpack the error code |
|
901 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
902 errPckg.Copy(aData); |
|
903 pluginErr = errPckg(); |
|
904 |
|
905 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ESetTxFrequencyCmdId pluginErr = %d" ), pluginErr ); |
|
906 |
|
907 if ( pluginErr == KErrNone ) |
|
908 { |
|
909 // Get new Tx frequency from the request |
|
910 THWRMFmTxPluginRequestData* data = static_cast<THWRMFmTxPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
911 if ( data ) |
|
912 { |
|
913 // Store the new frequency |
|
914 iFmTxCommonData.UpdateFrequency( data->iArg ); |
|
915 } |
|
916 } |
|
917 } |
|
918 break; |
|
919 |
|
920 case HWRMFmTxCommand::ETxScanRequestCmdId: |
|
921 { |
|
922 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
923 |
|
924 // Unpack the scan response error code |
|
925 HWRMFmTxCommand::TScanResponsePackage scanPckg; |
|
926 scanPckg.Copy(aData); |
|
927 HWRMFmTxCommand::TScanResponseData scanResp = scanPckg(); |
|
928 COMPONENT_TRACE3( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ETxScanRequestCmdId error = %d, found = %d" ), scanResp.iErrorCode, scanResp.iFrequenciesFound ); |
|
929 |
|
930 if ( scanResp.iErrorCode != KErrNone || |
|
931 scanResp.iFrequenciesFound == 0 || |
|
932 scanResp.iFrequenciesFound > KClearFrequencyArrayMax ) |
|
933 { |
|
934 pluginErr = scanResp.iErrorCode; |
|
935 } |
|
936 else if ( data && data->iRequestMessage.Handle() ) |
|
937 { |
|
938 TInt firstClearFreq = scanResp.iChannels[0]; |
|
939 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL scanResp.iChannels[0] = %d" ), firstClearFreq ); |
|
940 |
|
941 if ( data->iRequestMessage.Function() == EHWRMFmTxGetNextClearFreqArray ) |
|
942 { |
|
943 // return clear frequency array to clients |
|
944 TPckg<TClearFrequencyArray> clientClearFreqArrayPckg( scanResp.iChannels ); |
|
945 pluginErr = data->iRequestMessage.Write(0,clientClearFreqArrayPckg); |
|
946 if ( pluginErr == KErrNone ) |
|
947 { |
|
948 // return number of clear frequencies found |
|
949 TPckg<TUint> clientClearFreqCountPckg( scanResp.iFrequenciesFound ); |
|
950 pluginErr = data->iRequestMessage.Write(1,clientClearFreqCountPckg); |
|
951 } |
|
952 } |
|
953 else // EHWRMFmTxGetNextClearFreq or EHWRMFmTxSetNextClearFreq |
|
954 { |
|
955 // return clear frequency to client |
|
956 TPckg<TInt> clientClearFreqPckg( firstClearFreq ); |
|
957 pluginErr = data->iRequestMessage.Write(0,clientClearFreqPckg); |
|
958 } |
|
959 |
|
960 if ( pluginErr == KErrNone && |
|
961 data->iRequestMessage.Function() == EHWRMFmTxSetNextClearFreq ) |
|
962 { |
|
963 // Continue split command |
|
964 HWRMFmTxCommand::TSetFrequencyPackage pckg( firstClearFreq ); |
|
965 TRAP(pluginErr, ExecutePluginCommandL(data->iRequestMessage, HWRMFmTxCommand::ESetTxFrequencyCmdId, ETrue/*split*/, pckg, firstClearFreq )); |
|
966 } |
|
967 } |
|
968 } |
|
969 break; |
|
970 |
|
971 case HWRMFmTxCommand::ESetTxRdsPsCmdId: |
|
972 { |
|
973 // Unpack the error code |
|
974 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
975 errPckg.Copy(aData); |
|
976 pluginErr = errPckg(); |
|
977 |
|
978 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ESetTxRdsPsCmdId pluginErr = %d" ), pluginErr ); |
|
979 } |
|
980 break; |
|
981 |
|
982 case HWRMFmTxCommand::ESetTxRdsPtyCmdId: |
|
983 { |
|
984 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
985 |
|
986 // Unpack the error code |
|
987 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
988 errPckg.Copy(aData); |
|
989 pluginErr = errPckg(); |
|
990 |
|
991 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ESetTxRdsPtyCmdId pluginErr = %d" ), pluginErr ); |
|
992 |
|
993 if ( data && data->iRequestMessage.Handle() && pluginErr == KErrNone ) |
|
994 { |
|
995 if ( data->iRequestMessage.Function() == EHWRMFmTxClearRdsData ) |
|
996 { |
|
997 iFmTxCommonData.UpdateRdsPty( KRdsPtyNone ); |
|
998 } |
|
999 else |
|
1000 { |
|
1001 iFmTxCommonData.UpdateRdsPty( data->iRequestMessage.Int0() ); |
|
1002 } |
|
1003 } |
|
1004 } |
|
1005 break; |
|
1006 |
|
1007 case HWRMFmTxCommand::ESetTxRdsPtynCmdId: |
|
1008 { |
|
1009 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
1010 |
|
1011 // Unpack the error code |
|
1012 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
1013 errPckg.Copy(aData); |
|
1014 pluginErr = errPckg(); |
|
1015 |
|
1016 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ESetTxRdsPtynCmdId pluginErr = %d" ), pluginErr ); |
|
1017 |
|
1018 if ( data && data->iRequestMessage.Handle() && pluginErr == KErrNone ) |
|
1019 { |
|
1020 if ( data->iRequestMessage.Function() == EHWRMFmTxClearRdsData ) |
|
1021 { |
|
1022 TBuf<1> emptyDes; |
|
1023 iFmTxCommonData.UpdateRdsPtyn( emptyDes ); |
|
1024 } |
|
1025 else |
|
1026 { |
|
1027 TRdsProgrammeTypeName clientPtyn; |
|
1028 if ( data->iRequestMessage.Read(0,clientPtyn) == KErrNone ) |
|
1029 { |
|
1030 iFmTxCommonData.UpdateRdsPtyn( clientPtyn ); |
|
1031 } |
|
1032 } |
|
1033 } |
|
1034 } |
|
1035 break; |
|
1036 |
|
1037 case HWRMFmTxCommand::ESetTxRdsMsCmdId: |
|
1038 { |
|
1039 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
1040 |
|
1041 // Unpack the error code |
|
1042 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
1043 errPckg.Copy(aData); |
|
1044 pluginErr = errPckg(); |
|
1045 |
|
1046 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ESetTxRdsMsCmdId pluginErr = %d" ), pluginErr ); |
|
1047 |
|
1048 if ( data && data->iRequestMessage.Handle() && pluginErr == KErrNone ) |
|
1049 { |
|
1050 if ( data->iRequestMessage.Function() == EHWRMFmTxClearRdsData ) |
|
1051 { |
|
1052 iFmTxCommonData.UpdateRdsMs( ETrue /*defaults to Music*/ ); |
|
1053 } |
|
1054 else |
|
1055 { |
|
1056 iFmTxCommonData.UpdateRdsMs( data->iRequestMessage.Int0() ); |
|
1057 } |
|
1058 } |
|
1059 } |
|
1060 break; |
|
1061 |
|
1062 case HWRMFmTxCommand::ESetTxRdsLangIdCmdId: |
|
1063 { |
|
1064 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->FindTransaction(aTransId, EFalse)); |
|
1065 |
|
1066 // Unpack the error code |
|
1067 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
1068 errPckg.Copy(aData); |
|
1069 pluginErr = errPckg(); |
|
1070 |
|
1071 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, ESetTxRdsLangIdCmdId pluginErr = %d" ), pluginErr ); |
|
1072 |
|
1073 if ( data && data->iRequestMessage.Handle() && pluginErr == KErrNone ) |
|
1074 { |
|
1075 if ( data->iRequestMessage.Function() == EHWRMFmTxClearRdsData ) |
|
1076 { |
|
1077 iFmTxCommonData.UpdateRdsLanguageId( KRdsLanguageUnknown ); |
|
1078 } |
|
1079 else |
|
1080 { |
|
1081 iFmTxCommonData.UpdateRdsLanguageId( data->iRequestMessage.Int0() ); |
|
1082 } |
|
1083 } |
|
1084 } |
|
1085 break; |
|
1086 |
|
1087 case HWRMFmTxCommand::ESetTxRtCmdId: |
|
1088 case HWRMFmTxCommand::EClearTxRtCmdId: |
|
1089 { |
|
1090 // Unpack the error code |
|
1091 HWRMFmTxCommand::TErrorCodeResponsePackage errPckg; |
|
1092 errPckg.Copy(aData); |
|
1093 pluginErr = errPckg(); |
|
1094 |
|
1095 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, RT pluginErr = %d" ), pluginErr ); |
|
1096 } |
|
1097 break; |
|
1098 |
|
1099 case HWRMFmTxCommand::EStopObservingCmdId: |
|
1100 { |
|
1101 watcherMsg = ETrue; |
|
1102 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL, watcher cmd pluginErr = %d" ), pluginErr ); |
|
1103 } |
|
1104 break; |
|
1105 |
|
1106 default: |
|
1107 { |
|
1108 iFmTxCommonData.UpdateStatus(CHWRMFmTxCommonData::EFmTxStateTransError); |
|
1109 } |
|
1110 break; |
|
1111 } |
|
1112 } |
|
1113 |
|
1114 // Complete request and delete transaction |
|
1115 if( !watcherMsg ) |
|
1116 { |
|
1117 contextErr = CompleteRequest( aTransId, pluginErr ); |
|
1118 } |
|
1119 else |
|
1120 { |
|
1121 contextErr = CompleteRequest( aTransId, |
|
1122 pluginErr, |
|
1123 iWatcherTransactionList, |
|
1124 completeWatcherMsg ); |
|
1125 } |
|
1126 |
|
1127 // Leave if there is error in context |
|
1128 User::LeaveIfError(contextErr); |
|
1129 |
|
1130 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ProcessResponseL - return" ) ); |
|
1131 } |
|
1132 |
|
1133 // ----------------------------------------------------------------------------- |
|
1134 // CHWRMFmTxService::CheckResponseDataSize |
|
1135 // Helper for ProcessResponseL. Checks data size returned in plugin responses. |
|
1136 // ----------------------------------------------------------------------------- |
|
1137 // |
|
1138 TBool CHWRMFmTxService::CheckResponseDataSize( TInt aCommandId, TDesC8& aData ) |
|
1139 { |
|
1140 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::CheckResponseDataSize(0x%x)" ), aCommandId); |
|
1141 |
|
1142 TInt requiredDataSize; |
|
1143 |
|
1144 switch ( aCommandId ) |
|
1145 { |
|
1146 case HWRMFmTxCommand::ETxOnCmdId: // fall through |
|
1147 case HWRMFmTxCommand::ETxOffCmdId: // fall through |
|
1148 case HWRMFmTxCommand::ESetTxFrequencyCmdId: // fall through |
|
1149 case HWRMFmTxCommand::ESetTxRdsPsCmdId: // fall through |
|
1150 case HWRMFmTxCommand::ESetTxRdsPtyCmdId: // fall through |
|
1151 case HWRMFmTxCommand::ESetTxRdsPtynCmdId: // fall through |
|
1152 case HWRMFmTxCommand::ESetTxRdsMsCmdId: // fall through |
|
1153 case HWRMFmTxCommand::ESetTxRdsLangIdCmdId: // fall through |
|
1154 case HWRMFmTxCommand::ESetTxRtCmdId: // fall through |
|
1155 case HWRMFmTxCommand::EClearTxRtCmdId: // fall through |
|
1156 case HWRMFmTxCommand::EStopObservingCmdId: // fall through |
|
1157 requiredDataSize = sizeof(TInt); |
|
1158 break; |
|
1159 |
|
1160 case HWRMFmTxCommand::EGetTxFrequencyRangeCmdId: |
|
1161 requiredDataSize = sizeof(HWRMFmTxCommand::TFrequencyRangeData); |
|
1162 break; |
|
1163 |
|
1164 case HWRMFmTxCommand::ETxScanRequestCmdId: |
|
1165 requiredDataSize = sizeof(HWRMFmTxCommand::TScanResponseData); |
|
1166 break; |
|
1167 |
|
1168 case HWRMFmTxCommand::EStartObservingCmdId: |
|
1169 requiredDataSize = sizeof(HWRMFmTxCommand::TConnStatusData); |
|
1170 break; |
|
1171 |
|
1172 case HWRMFmTxCommand::ENoCommandId: // fall through |
|
1173 default: |
|
1174 requiredDataSize = 0; |
|
1175 break; |
|
1176 } |
|
1177 |
|
1178 if ( aData.Size() != requiredDataSize ) |
|
1179 { |
|
1180 COMPONENT_TRACE3( _L( "HWRM Server - CHWRMFmTxService::CheckResponseDataSize error 0x%x, 0x%x" ), aData.Size(), requiredDataSize ); |
|
1181 return EFalse; // Data size is invalid |
|
1182 } |
|
1183 |
|
1184 return ETrue; // Data size is ok |
|
1185 } |
|
1186 |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // CHWRMFmTxService::SuspendSubResource |
|
1189 // Suspends FM Tx target |
|
1190 // ----------------------------------------------------------------------------- |
|
1191 // |
|
1192 void CHWRMFmTxService::SuspendSubResource(TInt /*aSubResource*/) |
|
1193 { |
|
1194 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::SuspendSubResource" ) ); |
|
1195 iSuspended = ETrue; |
|
1196 } |
|
1197 |
|
1198 // ----------------------------------------------------------------------------- |
|
1199 // CHWRMFmTxService::ResumeSubResource |
|
1200 // Resumes suspended FM Tx target |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // |
|
1203 void CHWRMFmTxService::ResumeSubResource(TInt /*aSubResource*/) |
|
1204 { |
|
1205 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ResumeSubResource" ) ); |
|
1206 iSuspended = EFalse; |
|
1207 } |
|
1208 |
|
1209 // ----------------------------------------------------------------------------- |
|
1210 // CHWRMFmTxService::ActivateSubResource |
|
1211 // FM Tx doesn't support activation/deactivation based on device state |
|
1212 // ----------------------------------------------------------------------------- |
|
1213 // |
|
1214 void CHWRMFmTxService::ActivateSubResource(TInt /*aSubResource*/, TBool /*aActivate*/) |
|
1215 { |
|
1216 //COMPONENT_TRACE3( _L( "HWRM Server - CHWRMFmTxService::ActivateSubResource(0x%x, 0x%x)" ), aSubResource, aActivate ); |
|
1217 // Do nothing |
|
1218 //COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ActivateSubResource - return" ) ); |
|
1219 } |
|
1220 |
|
1221 // ----------------------------------------------------------------------------- |
|
1222 // CHWRMFmTxService::LeaveIfOtherReservationL |
|
1223 // Helper for ExecuteMessageL methods |
|
1224 // ----------------------------------------------------------------------------- |
|
1225 // |
|
1226 void CHWRMFmTxService::LeaveIfOtherReservationL() |
|
1227 { |
|
1228 // Check reservation. |
|
1229 if ( iSuspended || iReservationHandler->IsReserved(this, KHWRMAllSubResources) ) |
|
1230 { |
|
1231 User::Leave(KErrInUse); |
|
1232 } |
|
1233 } |
|
1234 |
|
1235 // ----------------------------------------------------------------------------- |
|
1236 // CHWRMFmTxService::LeaveIfTransmitterOffL |
|
1237 // ----------------------------------------------------------------------------- |
|
1238 // |
|
1239 void CHWRMFmTxService::LeaveIfTransmitterOffL() |
|
1240 { |
|
1241 // Check Tx status |
|
1242 if ( !iFmTxCommonData.IsFmTxHardwareOn() ) |
|
1243 { |
|
1244 COMPONENT_TRACE1( ( _L( "HWRM Server - CHWRMFmTxService::LeaveIfTransmitterOffL()" ) ) ); |
|
1245 User::Leave( KErrNotReady ); |
|
1246 } |
|
1247 } |
|
1248 |
|
1249 // ----------------------------------------------------------------------------- |
|
1250 // CHWRMFmTxService::LeaveIfTagInvalidL |
|
1251 // ----------------------------------------------------------------------------- |
|
1252 // |
|
1253 void CHWRMFmTxService::LeaveIfTagInvalidL( TRtPlusTag aTag ) |
|
1254 { |
|
1255 const TInt KMaxRtPlusMarkerPos( HWRMFmTxCommand::KMaxRtDataLength - 1 ); |
|
1256 |
|
1257 // Check RT Plus tag |
|
1258 if ( aTag.iContentType < ERtPlusItemTitle || aTag.iContentType > ERtPlusGetData || |
|
1259 aTag.iStartMarker < 0 || aTag.iLengthMarker < 0 || |
|
1260 aTag.iLengthMarker > KMaxRtPlusMarkerPos || |
|
1261 aTag.iStartMarker > aTag.iLengthMarker ) |
|
1262 { |
|
1263 COMPONENT_TRACE4( _L( "HWRM Server - CHWRMFmTxService::LeaveIfTagInvalidL, tag error (%d, %d, %d)"), |
|
1264 aTag.iContentType, aTag.iStartMarker, aTag.iLengthMarker ); |
|
1265 User::Leave(KErrArgument); |
|
1266 } |
|
1267 } |
|
1268 |
|
1269 // ----------------------------------------------------------------------------- |
|
1270 // CHWRMFmTxService::DoRelease |
|
1271 // Helper for releasing FM Tx resource |
|
1272 // ----------------------------------------------------------------------------- |
|
1273 // |
|
1274 void CHWRMFmTxService::DoRelease() |
|
1275 { |
|
1276 if ( iReserved ) |
|
1277 { |
|
1278 iReservationHandler->Release(this, KHWRMAllSubResources); |
|
1279 } |
|
1280 |
|
1281 iReserved = EFalse; |
|
1282 iSuspended = EFalse; |
|
1283 } |
|
1284 |
|
1285 // ----------------------------------------------------------------------------- |
|
1286 // CHWRMFmTxService::ExecutePluginCommand |
|
1287 // Handles plug-in requests that are not client initiated |
|
1288 // Called by Common Data service instance |
|
1289 // ----------------------------------------------------------------------------- |
|
1290 // |
|
1291 void CHWRMFmTxService::ExecutePluginCommand(HWRMFmTxCommand::TFmTxCmd aCommand) |
|
1292 { |
|
1293 COMPONENT_TRACE1( _L("HWRM Server - CHWRMFmTxService::ExecutePluginCommand(), non-client version" ) ); |
|
1294 |
|
1295 RMessage2 dummy; |
|
1296 TInt ignoreErr; // avoid compiler warning with TRAPD |
|
1297 TRAP(ignoreErr, ExecutePluginCommandL(dummy, aCommand, EFalse/*not split*/ )); |
|
1298 |
|
1299 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommand - return" ) ); |
|
1300 } |
|
1301 |
|
1302 // ----------------------------------------------------------------------------- |
|
1303 // CHWRMFmTxService::ExecutePluginCommand |
|
1304 // Handles plug-in requests that are not client initiated |
|
1305 // Called by Common Data service instance |
|
1306 // ----------------------------------------------------------------------------- |
|
1307 // |
|
1308 void CHWRMFmTxService::ExecutePluginCommand(HWRMFmTxCommand::TFmTxCmd aCommand, |
|
1309 TBool /* aSplitCommand */, |
|
1310 TDesC8& aPckg ) |
|
1311 { |
|
1312 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommandL, non-client version" ) ); |
|
1313 |
|
1314 RMessage2 dummy; |
|
1315 TInt ignoreErr; // avoid compiler warning with TRAPD |
|
1316 TRAP(ignoreErr, ExecutePluginCommandL(dummy, aCommand, EFalse/*not split*/, aPckg )); |
|
1317 |
|
1318 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommandL - return" ) ); |
|
1319 } |
|
1320 |
|
1321 // ----------------------------------------------------------------------------- |
|
1322 // CHWRMFmTxService::ExecutePluginCommandL |
|
1323 // Executes a plugin command and handles related transaction. |
|
1324 // ----------------------------------------------------------------------------- |
|
1325 // |
|
1326 void CHWRMFmTxService::ExecutePluginCommandL(const RMessage2& aMessage, |
|
1327 HWRMFmTxCommand::TFmTxCmd aCommandId, |
|
1328 TBool aSplitCommand ) |
|
1329 { |
|
1330 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommandL" ) ); |
|
1331 |
|
1332 // Create new data (TransId is updated later) |
|
1333 THWRMPluginRequestData* data = new (ELeave) THWRMPluginRequestData(aMessage, 0, aCommandId, aSplitCommand); |
|
1334 CleanupStack::PushL( data ); |
|
1335 |
|
1336 TBuf8<1> emptyDes; |
|
1337 if( aCommandId == HWRMFmTxCommand::EStartObservingCmdId || |
|
1338 aCommandId == HWRMFmTxCommand::EStopObservingCmdId ) |
|
1339 { |
|
1340 data->iTransId = iWatcherPluginHandler.ProcessCommandL(aCommandId, emptyDes, this); |
|
1341 // data still needed, do not destroy, just pop |
|
1342 CleanupStack::Pop( data ); |
|
1343 // Add data to list |
|
1344 iWatcherTransactionList->AddTransaction( data ); |
|
1345 } |
|
1346 else |
|
1347 { |
|
1348 data->iTransId = iPluginHandler->ProcessCommandL(aCommandId, emptyDes, this); |
|
1349 // data still needed, do not destroy, just pop |
|
1350 CleanupStack::Pop( data ); |
|
1351 // Add data to list |
|
1352 iTransactionList->AddTransaction( data ); |
|
1353 } |
|
1354 |
|
1355 |
|
1356 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommandL - return" ) ); |
|
1357 } |
|
1358 |
|
1359 // ----------------------------------------------------------------------------- |
|
1360 // CHWRMFmTxService::ExecutePluginCommandL |
|
1361 // Executes a plugin command and handles related transaction. |
|
1362 // ----------------------------------------------------------------------------- |
|
1363 // |
|
1364 void CHWRMFmTxService::ExecutePluginCommandL(const RMessage2& aMessage, |
|
1365 HWRMFmTxCommand::TFmTxCmd aCommandId, |
|
1366 TBool aSplitCommand, |
|
1367 TDesC8& aPckg ) |
|
1368 { |
|
1369 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommandL with pckg" ) ); |
|
1370 |
|
1371 // Create new data (TransId is updated later) |
|
1372 THWRMPluginRequestData* data = new (ELeave) THWRMPluginRequestData(aMessage, 0, aCommandId, aSplitCommand); |
|
1373 CleanupStack::PushL( data ); |
|
1374 |
|
1375 data->iTransId = iPluginHandler->ProcessCommandL(aCommandId, aPckg, this); |
|
1376 |
|
1377 // data still needed, do not destroy, just pop |
|
1378 CleanupStack::Pop( data ); |
|
1379 |
|
1380 // Add data to list |
|
1381 iTransactionList->AddTransaction( data ); |
|
1382 |
|
1383 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommandL - return" ) ); |
|
1384 } |
|
1385 |
|
1386 // ----------------------------------------------------------------------------- |
|
1387 // CHWRMFmTxService::ExecutePluginCommandL |
|
1388 // Executes a plugin command and handles related transaction. |
|
1389 // ----------------------------------------------------------------------------- |
|
1390 // |
|
1391 void CHWRMFmTxService::ExecutePluginCommandL(const RMessage2& aMessage, |
|
1392 HWRMFmTxCommand::TFmTxCmd aCommandId, |
|
1393 TBool aSplitCommand, |
|
1394 TDesC8& aPckg, |
|
1395 TInt aArg ) |
|
1396 { |
|
1397 COMPONENT_TRACE2( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommandL aArg = %d" ), aArg ); |
|
1398 |
|
1399 // Create new data (TransId is updated later) |
|
1400 THWRMPluginRequestData* data = new (ELeave) THWRMFmTxPluginRequestData(aArg, aMessage, 0, aCommandId, aSplitCommand); |
|
1401 CleanupStack::PushL( data ); |
|
1402 |
|
1403 data->iTransId = iPluginHandler->ProcessCommandL(aCommandId, aPckg, this); |
|
1404 |
|
1405 // data still needed, do not destroy, just pop |
|
1406 CleanupStack::Pop( data ); |
|
1407 |
|
1408 // Add data to list |
|
1409 iTransactionList->AddTransaction( data ); |
|
1410 |
|
1411 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::ExecutePluginCommandL - return" ) ) ; |
|
1412 } |
|
1413 |
|
1414 // ----------------------------------------------------------------------------- |
|
1415 // CHWRMFmTxService::CancelPluginCommandL |
|
1416 // Cancels a plugin command and handles the related transaction(s). |
|
1417 // Note that plug-in handler CancelCommandL's will not cause client requests to complete |
|
1418 // ----------------------------------------------------------------------------- |
|
1419 // |
|
1420 void CHWRMFmTxService::CancelPluginCommandL(HWRMFmTxCommand::TFmTxCmd aCommandId) |
|
1421 { |
|
1422 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::CancelPluginCommandL" ) ); |
|
1423 |
|
1424 THWRMPluginRequestData* data = static_cast<THWRMPluginRequestData*>(iTransactionList->GetFirstItem()); |
|
1425 |
|
1426 // Cancel each transaction with the cancelled command ID |
|
1427 while ( data ) |
|
1428 { |
|
1429 if ( data->iCommandId == aCommandId && |
|
1430 data->iRequestMessage.Handle() ) |
|
1431 { |
|
1432 // Cancel transaction |
|
1433 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMService::CancelPluginCommandL() - Canceling pending message" ) ); |
|
1434 data->iRequestMessage.Complete(KErrCancel); |
|
1435 |
|
1436 // Record transaction ID, and move to next item |
|
1437 TUint8 cancelTransId = data->iTransId; |
|
1438 data = static_cast<THWRMPluginRequestData*>(data->iNextData); |
|
1439 |
|
1440 // Remove cancelled transaction items |
|
1441 // First cancel plugin command. If successful, then no call to ProcessResponseL |
|
1442 iPluginHandler->CancelCommandL( cancelTransId ); |
|
1443 iTransactionList->FindTransaction( cancelTransId, ETrue); |
|
1444 } |
|
1445 else |
|
1446 { |
|
1447 // Move to next item |
|
1448 data = static_cast<THWRMPluginRequestData*>(data->iNextData); |
|
1449 } |
|
1450 } |
|
1451 |
|
1452 COMPONENT_TRACE1( _L( "HWRM Server - CHWRMFmTxService::CancelPluginCommandL - return" ) ); |
|
1453 } |
|
1454 |
|
1455 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
1456 |
|
1457 // End of File |