|
1 /* |
|
2 * Copyright (c) 2006-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef HWRMFMTXSERVICE_H |
|
21 #define HWRMFMTXSERVICE_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "HWRMGenericTimer.h" |
|
26 #include "HWRMFmTxCommands.h" |
|
27 #include "HWRMFmTxData.h" |
|
28 #include "HWRMService.h" |
|
29 #include "HWRMFmTxCommonData.h" |
|
30 |
|
31 // CONSTANTS |
|
32 // None |
|
33 // Frequency ranges as of May 2007: |
|
34 // 88.1-107.9 MHz for rest of the world (FCC lower limit) |
|
35 // 88.1 - 90 MHz for Japan (we still cannot go lower than FCC lower limit) |
|
36 const TInt KHWRMFmTxBackupMinFreq = 88100; // kHz |
|
37 const TInt KHWRMFmTxBackupMaxFreq = 107900; // kHz |
|
38 const TInt KHWRMFmTxBackupStepSize = 50; // kHz |
|
39 |
|
40 // MACROS |
|
41 // None |
|
42 |
|
43 // DATA TYPES |
|
44 // None |
|
45 |
|
46 // FUNCTION PROTOTYPES |
|
47 // None |
|
48 |
|
49 // FORWARD DECLARATIONS |
|
50 class CHWRMFmTxCommonData; |
|
51 class CHWRMPluginHandler; |
|
52 class CHWRMReservationHandler; |
|
53 class CHWRMFmTxRdsTextConverter; |
|
54 |
|
55 // CLASS DECLARATION |
|
56 |
|
57 /** |
|
58 * Data storage class for FM Tx plug-in requests |
|
59 */ |
|
60 class THWRMFmTxPluginRequestData : public THWRMPluginRequestData |
|
61 { |
|
62 public: |
|
63 TInt iArg; // Generic integer param |
|
64 |
|
65 /** |
|
66 * Convenience constructor |
|
67 */ |
|
68 THWRMFmTxPluginRequestData(TInt aArg, |
|
69 const RMessage2& aRequestMessage, |
|
70 TUint8 aTransId, |
|
71 TInt aCommandId, |
|
72 TBool aSplitCommand) |
|
73 : THWRMPluginRequestData(aRequestMessage, aTransId, aCommandId, aSplitCommand), |
|
74 iArg(aArg) |
|
75 { |
|
76 }; |
|
77 /** |
|
78 * Virtual destructor. |
|
79 */ |
|
80 virtual ~THWRMFmTxPluginRequestData() |
|
81 { |
|
82 }; |
|
83 }; |
|
84 |
|
85 /** |
|
86 * Hardware Resource Manager server side service object for FmTx sessions. |
|
87 */ |
|
88 class CHWRMFmTxService : public CHWRMService |
|
89 { |
|
90 public: // Constructors and Destructor |
|
91 |
|
92 /** |
|
93 * Two-phased constructor. |
|
94 * |
|
95 * @param aPluginHandler The plugin handler to use with this service. |
|
96 * @param aWatcherPluginHandler The watcher plugin handler to use with this service. |
|
97 * @param aReservationHandler The reservation handler to use with this service. |
|
98 * @param aFmTxCommonData Commmon data instance to use with this service. |
|
99 * @param aRdsTextConverter Text converter instance to use with this service. |
|
100 */ |
|
101 static CHWRMFmTxService* NewL(CHWRMPluginHandler* aPluginHandler, |
|
102 CHWRMPluginHandler& aWatcherPluginHandler, |
|
103 CHWRMReservationHandler* aReservationHandler, |
|
104 CHWRMFmTxCommonData& aFmTxCommonData, |
|
105 CHWRMFmTxRdsTextConverter& aRdsTextConverter); |
|
106 |
|
107 /** |
|
108 * Destructor. |
|
109 */ |
|
110 virtual ~CHWRMFmTxService(); |
|
111 |
|
112 public: // Base class methods |
|
113 |
|
114 // From CHWRMService |
|
115 virtual TBool ExecuteMessageL( const RMessage2& aMessage ); |
|
116 virtual void ProcessResponseL( TInt aCommandId, TUint8 aTransId, TDesC8& aData, TBool aTimeout ); |
|
117 virtual void SuspendSubResource(TInt aSubResource); |
|
118 virtual void ResumeSubResource(TInt aSubResource); |
|
119 virtual void ActivateSubResource(TInt aSubResource, TBool aActivate); |
|
120 |
|
121 public: // Other methods |
|
122 |
|
123 /** |
|
124 * Handles plug-in requests that are not client initiated |
|
125 * Called by Common Data service instance |
|
126 * |
|
127 * @param aCommand the plug-in command to execute |
|
128 */ |
|
129 void ExecutePluginCommand(HWRMFmTxCommand::TFmTxCmd aCommand); |
|
130 |
|
131 /** |
|
132 * Handles plug-in requests that are not client initiated |
|
133 * Called by Common Data service instance |
|
134 * |
|
135 * @param aCommand the plug-in command to execute |
|
136 * @param aSplitCommand ETrue if this command is split into multiple transactions |
|
137 * @param aPckg Command package |
|
138 */ |
|
139 void ExecutePluginCommand(HWRMFmTxCommand::TFmTxCmd aCommand, |
|
140 TBool aSplitCommand, |
|
141 TDesC8& aPckg ); |
|
142 |
|
143 private: |
|
144 |
|
145 /** |
|
146 * C++ default constructor. |
|
147 */ |
|
148 CHWRMFmTxService(CHWRMPluginHandler& aWatcherPluginHandler, |
|
149 CHWRMFmTxCommonData& aFmTxCommonData, |
|
150 CHWRMFmTxRdsTextConverter& aRdsTextConverter); |
|
151 |
|
152 /** |
|
153 * By default Symbian 2nd phase constructor is private. |
|
154 */ |
|
155 void ConstructL(CHWRMPluginHandler* aPluginHandler, |
|
156 CHWRMReservationHandler* aReservationHandler); |
|
157 |
|
158 // Helpers for ProcessResponseL |
|
159 |
|
160 /** |
|
161 * Checks the response data size |
|
162 * |
|
163 * @return ETrue if aData.Size() is correct |
|
164 */ |
|
165 TBool CheckResponseDataSize(TInt aCommandId, TDesC8& aData); |
|
166 |
|
167 // Helpers for ExecuteMessageL |
|
168 |
|
169 /** |
|
170 * Handles EHWRMFmTxOn request |
|
171 * |
|
172 * @param aFrequency The requested initial Tx frequency |
|
173 */ |
|
174 void EnableL(const RMessage2& aMessage); |
|
175 |
|
176 /** |
|
177 * Handles EHWRMFmTxOff request |
|
178 * @return ETrue if client request can be completed immediately |
|
179 */ |
|
180 TBool DisableL(const RMessage2& aMessage); |
|
181 |
|
182 /** |
|
183 * Handles EGetTxFrequencyRangeCmdId request |
|
184 */ |
|
185 void GetFrequencyRangeL(const RMessage2& aMessage); |
|
186 |
|
187 /** |
|
188 * Handles EHWRMFmTxSetFreq request |
|
189 * |
|
190 * @return TBool ETrue if message can be completed immediately, on return |
|
191 */ |
|
192 TBool SetFrequencyL(const RMessage2& aMessage); |
|
193 |
|
194 /** |
|
195 * Handles EHWRMFmTxGetNextClearFreq requests. |
|
196 * |
|
197 * @param aClearFreqsRequired The number of clear frequencies requested |
|
198 */ |
|
199 void GetNextClearFrequencyL(const RMessage2& aMessage, |
|
200 TUint aClearFreqsRequired); |
|
201 |
|
202 /** |
|
203 * Handles EHWRMFmTxSetNextClearFreq requests |
|
204 * |
|
205 * @param aClearFreqsRequired The number of clear frequencies requested |
|
206 */ |
|
207 void SetNextClearFrequencyL(const RMessage2& aMessage, |
|
208 TUint aClearFreqsRequired); |
|
209 |
|
210 /** |
|
211 * Handles EHWRMFmTxSetRdsPty requests |
|
212 */ |
|
213 void SetRdsPtyL(const RMessage2& aMessage); |
|
214 |
|
215 /** |
|
216 * Handles EHWRMFmTxSetRdsPtyn requests |
|
217 */ |
|
218 void SetRdsPtynL(const RMessage2& aMessage); |
|
219 |
|
220 /** |
|
221 * Handles EHWRMFmTxSetRdsMs requests |
|
222 */ |
|
223 void SetRdsMsL(const RMessage2& aMessage); |
|
224 |
|
225 /** |
|
226 * Handles EHWRMFmTxSetRdsLanguageId requests |
|
227 */ |
|
228 void SetRdsLanguageIdL(const RMessage2& aMessage); |
|
229 |
|
230 /** |
|
231 * Handles EHWRMFmTxSetRadiotext requests |
|
232 */ |
|
233 void SetRadiotextL(const RMessage2& aMessage); |
|
234 void SetRadiotextL(const RMessage2& aMessage, TRtPlusTag aTag); |
|
235 void SetRadiotextL(const RMessage2& aMessage, TRtPlusTag aTag1, TRtPlusTag aTag2); |
|
236 |
|
237 /** |
|
238 * Handles EHWRMFmTxClearRdsData requests |
|
239 */ |
|
240 void ClearRdsDataL(const RMessage2& aMessage); |
|
241 |
|
242 /** |
|
243 * Handles EHWRMFmTxClearRtData requests |
|
244 */ |
|
245 void ClearRadiotextDataL(const RMessage2& aMessage); |
|
246 |
|
247 /** |
|
248 * Handles EHWRMFmTxRelease and EHWRMFmTxCleanup requests |
|
249 */ |
|
250 void DoRelease(); |
|
251 |
|
252 /** |
|
253 * Leaves if another client has reserved FM Tx |
|
254 */ |
|
255 void LeaveIfOtherReservationL(); |
|
256 |
|
257 /** |
|
258 * Leaves if FM Tx is not enabled |
|
259 */ |
|
260 void LeaveIfTransmitterOffL(); |
|
261 |
|
262 /** |
|
263 * Leaves if RT plus tag is not valid |
|
264 */ |
|
265 void LeaveIfTagInvalidL( TRtPlusTag aTag ); |
|
266 |
|
267 /** |
|
268 * Executes a plugin command and handles related transaction. |
|
269 * |
|
270 * @param aMessage Message related to this command. |
|
271 * @param aCommandId Command ID of the command. |
|
272 * @param aSplitCommand ETrue if this command is split into multiple transactions |
|
273 */ |
|
274 void ExecutePluginCommandL(const RMessage2& aMessage, |
|
275 HWRMFmTxCommand::TFmTxCmd aCommandId, |
|
276 TBool aSplitCommand ); |
|
277 |
|
278 /** |
|
279 * Executes a plugin command and handles related transaction. |
|
280 * |
|
281 * @param aMessage Message related to this command. |
|
282 * @param aCommandId Command ID of the command. |
|
283 * @param aSplitCommand ETrue if this command is split into multiple transactions |
|
284 * @param aPckg Command package |
|
285 */ |
|
286 void ExecutePluginCommandL(const RMessage2& aMessage, |
|
287 HWRMFmTxCommand::TFmTxCmd aCommandId, |
|
288 TBool aSplitCommand, |
|
289 TDesC8& aPckg ); |
|
290 |
|
291 |
|
292 /** |
|
293 * Executes a plugin command and handles related transaction. |
|
294 * |
|
295 * @param aMessage Message related to this command. |
|
296 * @param aCommandId Command ID of the command. |
|
297 * @param aSplitCommand ETrue if this command is split into multiple transactions |
|
298 * @param aPckg Command package |
|
299 * @param aArg Generic integer parameter for THWRMFmTxPluginRequestData |
|
300 */ |
|
301 void ExecutePluginCommandL(const RMessage2& aMessage, |
|
302 HWRMFmTxCommand::TFmTxCmd aCommandId, |
|
303 TBool aSplitCommand, |
|
304 TDesC8& aPckg, |
|
305 TInt aArg ); |
|
306 |
|
307 /** |
|
308 * Cancels a plugin command and handles the related transaction(s). |
|
309 * |
|
310 * @param aCommandId Command ID of the command. |
|
311 */ |
|
312 void CancelPluginCommandL(HWRMFmTxCommand::TFmTxCmd aCommandId); |
|
313 |
|
314 private: // data |
|
315 |
|
316 CHWRMPluginHandler& iWatcherPluginHandler; // Reference to watcher plugin handler. |
|
317 CHWRMPluginTransactionList* iWatcherTransactionList; // List of open watcher transactions. Owned. |
|
318 CHWRMFmTxCommonData& iFmTxCommonData; // Ref to FM Tx data object common to all sessions. Not owned. |
|
319 CHWRMFmTxRdsTextConverter& iRdsTextConverter; // Ref to Unicode->RDS text converter. Not owned. |
|
320 |
|
321 TBool iSuspended; // Flag to indicate if this session is suspended. |
|
322 TBool iReserved; // Flag to indicate if this session is reserved. |
|
323 }; |
|
324 |
|
325 #endif // HWRMFMTXSERVICE_H |
|
326 |
|
327 // End of File |