1 /* |
|
2 * Copyright (c) 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 #ifndef _CRADIOENGINEHANDLER_H_ |
|
19 #define _CRADIOENGINEHANDLER_H_ |
|
20 |
|
21 // System includes |
|
22 #include <e32base.h> |
|
23 |
|
24 #include <mw/ProfileEngineSDKCRKeys.h> |
|
25 |
|
26 // User includes |
|
27 #include "radio_global.h" |
|
28 #include "mradioengineinitializer.h" |
|
29 |
|
30 // Forward declarations |
|
31 class CRadioEngine; |
|
32 class MRadioScanObserver; |
|
33 class MRadioRdsDataObserver; |
|
34 class CRadioRepositoryManager; |
|
35 class MRadioEngineHandlerObserver; |
|
36 class MRadioApplicationSettings; |
|
37 |
|
38 // Class declaration |
|
39 class CRadioEngineHandler : public CBase |
|
40 , public MRadioEngineInitializer |
|
41 { |
|
42 public: |
|
43 |
|
44 CRadioEngineHandler( MRadioEngineHandlerObserver& aObserver ); |
|
45 |
|
46 ~CRadioEngineHandler(); |
|
47 |
|
48 void ConstructL(); |
|
49 |
|
50 /** |
|
51 * Sets the rds data observer |
|
52 */ |
|
53 void SetRdsObserver( MRadioRdsDataObserver* aObserver ); |
|
54 |
|
55 /** |
|
56 * Returns the radio status |
|
57 * @return ETrue = radio is on, EFalse = radio is off |
|
58 */ |
|
59 TBool IsRadioOn(); |
|
60 |
|
61 /** |
|
62 * Tune to the specified frequency |
|
63 * @param aFrequency - frequency to lock onto. |
|
64 */ |
|
65 void Tune( TUint aFrequency ); |
|
66 |
|
67 /** |
|
68 * Tune to the specified frequency after a delay |
|
69 * @param aFrequency - frequency to lock onto. |
|
70 */ |
|
71 void TuneWithDelay( TUint aFrequency ); |
|
72 |
|
73 /** |
|
74 * Sets the audio mute state |
|
75 * @param aMuted - flag to determine whether mute should be turned on or off |
|
76 */ |
|
77 void SetMuted( const TBool aMuted ); |
|
78 |
|
79 /** |
|
80 * Gets the audio mute state |
|
81 * @return ETrue or EFalse to indicate whether mute is currently on. |
|
82 */ |
|
83 TBool IsMuted() const; |
|
84 |
|
85 /** |
|
86 * Sets the volume level of the FM radio |
|
87 * @param aVolume - the volume to be used. |
|
88 */ |
|
89 void SetVolume( TInt aVolume ); |
|
90 |
|
91 /** |
|
92 * Gets the volumelevel. |
|
93 * @return the current volume |
|
94 */ |
|
95 TInt Volume() const; |
|
96 |
|
97 /** |
|
98 * Gets the max volumelevel. |
|
99 * @return the max volume |
|
100 */ |
|
101 TInt MaxVolume() const; |
|
102 |
|
103 /** |
|
104 * Increases the volume by one increment |
|
105 */ |
|
106 void IncreaseVolume(); |
|
107 |
|
108 /** |
|
109 * Decreases the volume by one increment |
|
110 */ |
|
111 void DecreaseVolume(); |
|
112 |
|
113 /** |
|
114 * Checks if the antenna is attached |
|
115 * @return ETrue or EFalse to indicate whether antenna is currently attached. |
|
116 */ |
|
117 TBool IsAntennaAttached() const; |
|
118 |
|
119 /** |
|
120 * Retrieves the current frequency. |
|
121 * @return the frequency in hertz |
|
122 */ |
|
123 TUint TunedFrequency() const; |
|
124 |
|
125 /** |
|
126 * Returns the minimum allowed frequency in the current region |
|
127 */ |
|
128 TUint MinFrequency() const; |
|
129 |
|
130 /** |
|
131 * Returns the maximum allowed frequency in the current region |
|
132 */ |
|
133 TUint MaxFrequency() const; |
|
134 |
|
135 /** |
|
136 * Checks if the given frequency is valid in the current region |
|
137 */ |
|
138 TBool IsFrequencyValid( TUint aFrequency ) const; |
|
139 |
|
140 /** |
|
141 * Scan up to the next available frequency. |
|
142 */ |
|
143 void Seek( Seeking::Direction direction ); |
|
144 |
|
145 /** |
|
146 * Cancel previously requested scan. |
|
147 */ |
|
148 void CancelSeek(); |
|
149 |
|
150 /** |
|
151 * Returns the engine seeking state |
|
152 */ |
|
153 Seeking::State SeekingState() const; |
|
154 |
|
155 void StartScan( MRadioScanObserver& aObserver ); |
|
156 |
|
157 void StopScan( TInt aError = KErrCancel ); |
|
158 |
|
159 /** |
|
160 * Rreturn step size for tuning. |
|
161 * @return step size |
|
162 */ |
|
163 TUint32 FrequencyStepSize() const; |
|
164 |
|
165 /** |
|
166 * Determine current region |
|
167 * @return fmradio region. In case of error, returns EFMRadioRegionNone. |
|
168 */ |
|
169 RadioRegion::Region Region() const; |
|
170 |
|
171 /** |
|
172 * Sets whether or not audio should be routed to loudspeaker |
|
173 * @param aLoudspeaker ETrue if loudspeaker should be used, EFalse if not |
|
174 */ |
|
175 void SetAudioRouteToLoudspeaker( TBool aLoudspeaker ); |
|
176 |
|
177 /** |
|
178 * Checks if audio is routed to loudspeaker |
|
179 * @return ETrue if loudspeaker is used, EFalse if headset is used |
|
180 */ |
|
181 TBool IsAudioRoutedToLoudspeaker() const; |
|
182 |
|
183 /** |
|
184 * Returns ar reference to the publish & subscribe handler |
|
185 */ |
|
186 CRadioPubSub& PubSub(); |
|
187 |
|
188 /** |
|
189 * Returns the repository manager. |
|
190 * |
|
191 * @return The repository manager. |
|
192 */ |
|
193 CRadioRepositoryManager& Repository() const; |
|
194 |
|
195 MRadioApplicationSettings& ApplicationSettings() const; |
|
196 |
|
197 private: |
|
198 |
|
199 // from base class MRadioEngineInitializer |
|
200 |
|
201 CRadioAudioRouter* InitAudioRouterL(); |
|
202 CRadioSystemEventCollector* InitSystemEventCollectorL(); |
|
203 CRadioSettings* InitSettingsL(); |
|
204 CRadioPubSub* InitPubSubL(); |
|
205 |
|
206 // New functions |
|
207 |
|
208 /** |
|
209 * Static callback function to be used by the tune delay timer |
|
210 * @param aSelf Pointer to this |
|
211 * @return not used |
|
212 */ |
|
213 static TInt TuneDelayCallback( TAny* aSelf ); |
|
214 |
|
215 private: // data |
|
216 |
|
217 /** |
|
218 * Radio engine holder |
|
219 * Own. |
|
220 */ |
|
221 CRadioEngine* iEngine; |
|
222 |
|
223 /** |
|
224 * Radio handler observer |
|
225 * Not own. |
|
226 */ |
|
227 MRadioEngineHandlerObserver& iObserver; |
|
228 |
|
229 /** |
|
230 * Frequency used by delayed tuning |
|
231 */ |
|
232 TUint iFrequency; |
|
233 |
|
234 /** |
|
235 * Timer used for delayed tuning |
|
236 * Own. |
|
237 */ |
|
238 CPeriodic* iDelayTimer; |
|
239 |
|
240 /** |
|
241 * Selected radio region |
|
242 */ |
|
243 RadioRegion::Region iRegion; |
|
244 |
|
245 }; |
|
246 |
|
247 #endif //_CRADIOENGINEHANDLER_H_ |
|