22 #include "radiosettings.h" |
22 #include "radiosettings.h" |
23 #include "radiosettings_p.h" |
23 #include "radiosettings_p.h" |
24 #include "radiologger.h" |
24 #include "radiologger.h" |
25 #include "radio_global.h" |
25 #include "radio_global.h" |
26 #include "cradioenginehandler.h" |
26 #include "cradioenginehandler.h" |
27 #include "radiofrequencyscanninghandler.h" |
|
28 #include "radiostationhandlerif.h" |
27 #include "radiostationhandlerif.h" |
29 #include "cradiopubsub.h" |
28 #include "cradiopubsub.h" |
30 #include "radiocontroleventlistener.h" |
29 #include "radiocontroleventlistener.h" |
31 #include "radiordslistener.h" |
30 #include "radiordslistener.h" |
32 #include "cradiorepositorymanager.h" |
31 #include "cradiorepositorymanager.h" |
36 |
35 |
37 /*! |
36 /*! |
38 * |
37 * |
39 */ |
38 */ |
40 RadioEngineWrapperPrivate::RadioEngineWrapperPrivate( RadioEngineWrapper* wrapper, |
39 RadioEngineWrapperPrivate::RadioEngineWrapperPrivate( RadioEngineWrapper* wrapper, |
41 RadioStationHandlerIf& stationHandler, |
40 RadioStationHandlerIf& stationHandler ) : |
42 RadioEngineWrapperObserver& observer ) : |
|
43 q_ptr( wrapper ), |
41 q_ptr( wrapper ), |
44 mStationHandler( stationHandler ), |
42 mStationHandler( stationHandler ), |
45 mObserver( observer ), |
|
46 mEngineHandler( new CRadioEngineHandler( *this ) ), |
43 mEngineHandler( new CRadioEngineHandler( *this ) ), |
47 mControlEventListener( new RadioControlEventListener( *this ) ), |
44 mControlEventListener( new RadioControlEventListener( *this ) ), |
48 mRdsListener ( new RadioRdsListener( mStationHandler, *this ) ), |
45 mRdsListener ( new RadioRdsListener( mStationHandler, *this ) ), |
49 mCommandSender( 0 ), |
46 mTuneReason( 0 ), |
50 mUseLoudspeaker( false ), |
47 mUseLoudspeaker( false ) |
51 mIsSeeking( false ) |
|
52 { |
48 { |
53 } |
49 } |
54 |
50 |
55 /*! |
51 /*! |
56 * |
52 * |
119 } |
115 } |
120 |
116 |
121 /*! |
117 /*! |
122 * Tunes to the given frequency |
118 * Tunes to the given frequency |
123 */ |
119 */ |
124 void RadioEngineWrapperPrivate::tuneFrequency( uint frequency, const int sender ) |
120 void RadioEngineWrapperPrivate::tuneFrequency( uint frequency, const int reason ) |
125 { |
121 { |
126 mCommandSender = sender; |
122 if ( mEngineHandler->TunedFrequency() != frequency ) { |
127 mEngineHandler->Tune( frequency ); |
123 mTuneReason = reason; |
|
124 mEngineHandler->Tune( frequency ); |
|
125 } |
128 } |
126 } |
129 |
127 |
130 /*! |
128 /*! |
131 * Tunes to the given frequency after a delay |
129 * Tunes to the given frequency after a delay |
132 */ |
130 */ |
133 void RadioEngineWrapperPrivate::tuneWithDelay( uint frequency, const int sender ) |
131 void RadioEngineWrapperPrivate::tuneWithDelay( uint frequency, const int reason ) |
134 { |
132 { |
135 mCommandSender = sender; |
133 if ( mEngineHandler->TunedFrequency() != frequency ) { |
136 mEngineHandler->TuneWithDelay( frequency ); |
134 mTuneReason = reason; |
137 } |
135 mEngineHandler->TuneWithDelay( frequency ); |
138 |
136 } |
139 /*! |
137 } |
140 * |
138 |
141 */ |
139 /*! |
142 RadioEngineWrapperObserver& RadioEngineWrapperPrivate::observer() |
140 * |
143 { |
141 */ |
144 return mObserver; |
142 ObserverList& RadioEngineWrapperPrivate::observers() |
145 } |
143 { |
146 |
144 return mObservers; |
147 /*! |
145 } |
148 * |
146 |
149 */ |
147 /*! |
150 void RadioEngineWrapperPrivate::startSeeking( Seeking::Direction direction ) |
148 * |
151 { |
149 */ |
|
150 void RadioEngineWrapperPrivate::startSeeking( Seeking::Direction direction, const int reason ) |
|
151 { |
|
152 mTuneReason = reason; |
152 mEngineHandler->Seek( direction ); |
153 mEngineHandler->Seek( direction ); |
153 mObserver.seekingStarted( direction ); |
|
154 } |
154 } |
155 |
155 |
156 /*! |
156 /*! |
157 * \reimp |
157 * \reimp |
158 */ |
158 */ |
159 void RadioEngineWrapperPrivate::PowerEventL( TBool aPowerState, TInt DEBUGVAR( aError ) ) |
159 void RadioEngineWrapperPrivate::PowerEventL( TBool aPowerState, TInt DEBUGVAR( aError ) ) |
160 { |
160 { |
161 LOG_FORMAT( "RadioEngineWrapperPrivate::PowerEventL, PowerState: %d, Error: %d", aPowerState, aError ); |
161 LOG_FORMAT( "RadioEngineWrapperPrivate::PowerEventL, PowerState: %d, Error: %d", aPowerState, aError ); |
162 mObserver.radioStatusChanged( aPowerState ); |
162 RUN_NOTIFY_LOOP( mObservers, radioStatusChanged( aPowerState ) ); |
163 mEngineHandler->PubSub().PublishPowerState( aPowerState ); |
|
164 } |
163 } |
165 |
164 |
166 /*! |
165 /*! |
167 * \reimp |
166 * \reimp |
168 */ |
167 */ |
169 void RadioEngineWrapperPrivate::FrequencyEventL( TUint32 aFrequency, |
168 void RadioEngineWrapperPrivate::FrequencyEventL( TUint32 aFrequency, |
170 RadioEngine::TRadioFrequencyEventReason aReason, |
169 RadioEngine::TRadioFrequencyEventReason aReason, |
171 TInt aError ) |
170 TInt aError ) |
172 { |
171 { |
|
172 Q_UNUSED( aReason ); |
173 LOG_FORMAT( "RadioEngineWrapperPrivate::FrequencyEventL - Frequency: %d, Reason: %d, Error: %d", aFrequency, aReason, aError ); |
173 LOG_FORMAT( "RadioEngineWrapperPrivate::FrequencyEventL - Frequency: %d, Reason: %d, Error: %d", aFrequency, aReason, aError ); |
174 |
|
175 if ( mFrequencyScanningHandler ) |
|
176 { |
|
177 // frequencyevents not handled during scanning //TODO remove |
|
178 return; |
|
179 } |
|
180 |
174 |
181 if ( !aError ) { |
175 if ( !aError ) { |
182 const uint frequency = static_cast<uint>( aFrequency ); |
176 const uint frequency = static_cast<uint>( aFrequency ); |
183 |
177 RUN_NOTIFY_LOOP( mObservers, tunedToFrequency( frequency, mTuneReason ) ); |
184 mStationHandler.setCurrentStation( frequency ); |
|
185 |
|
186 // Stations found by seeking (autotune) are saved as local stations |
|
187 if ( aReason == RadioEngine::ERadioFrequencyEventReasonSeekUp |
|
188 || aReason == RadioEngine::ERadioFrequencyEventReasonSeekDown ) |
|
189 { |
|
190 mStationHandler.addScannedFrequency( frequency ); |
|
191 mCommandSender = 0; |
|
192 } |
|
193 |
|
194 //mEngineHandler->SetMuted( EFalse ); |
|
195 LOG_TIMESTAMP( "Channel change finished" ); |
|
196 |
|
197 mObserver.tunedToFrequency( frequency, mCommandSender ); |
|
198 |
|
199 mStationHandler.startDynamicPsCheck(); |
|
200 |
|
201 mEngineHandler->PubSub().PublishFrequency( aFrequency ); |
|
202 } |
178 } |
203 } |
179 } |
204 |
180 |
205 /*! |
181 /*! |
206 * \reimp |
182 * \reimp |
207 */ |
183 */ |
208 void RadioEngineWrapperPrivate::VolumeEventL( TInt aVolume, TInt aError ) |
184 void RadioEngineWrapperPrivate::VolumeEventL( TInt aVolume, TInt aError ) |
209 { |
185 { |
210 Q_UNUSED( aError ); |
186 Q_UNUSED( aError ); |
211 mObserver.volumeChanged( aVolume ); |
187 RUN_NOTIFY_LOOP( mObservers, volumeChanged( aVolume ) ); |
212 mEngineHandler->PubSub().PublishVolume( aVolume ); |
|
213 } |
188 } |
214 |
189 |
215 /*! |
190 /*! |
216 * \reimp |
191 * \reimp |
217 */ |
192 */ |
218 void RadioEngineWrapperPrivate::MuteEventL( TBool aMuteState, TInt aError ) |
193 void RadioEngineWrapperPrivate::MuteEventL( TBool aMuteState, TInt aError ) |
219 { |
194 { |
220 Q_UNUSED( aError ); |
195 Q_UNUSED( aError ); |
221 mObserver.muteChanged( aMuteState ); |
196 RUN_NOTIFY_LOOP( mObservers, muteChanged( aMuteState ) ); |
222 mEngineHandler->PubSub().PublishRadioMuteState( aMuteState ); |
|
223 } |
197 } |
224 |
198 |
225 /*! |
199 /*! |
226 * \reimp |
200 * \reimp |
227 */ |
201 */ |
234 * \reimp |
208 * \reimp |
235 */ |
209 */ |
236 void RadioEngineWrapperPrivate::AntennaEventL( TBool aAntennaAttached, TInt aError ) |
210 void RadioEngineWrapperPrivate::AntennaEventL( TBool aAntennaAttached, TInt aError ) |
237 { |
211 { |
238 Q_UNUSED( aError ); |
212 Q_UNUSED( aError ); |
239 mObserver.headsetStatusChanged( aAntennaAttached ); |
213 RUN_NOTIFY_LOOP( mObservers, antennaStatusChanged( aAntennaAttached ) ); |
240 // doc->PubSubL().PublishHeadsetStatusL( EVRPSHeadsetConnected ); |
|
241 } |
214 } |
242 |
215 |
243 /*! |
216 /*! |
244 * \reimp |
217 * \reimp |
245 */ |
218 */ |
246 void RadioEngineWrapperPrivate::AudioRoutingEventL( TInt aAudioDestination, TInt aError ) |
219 void RadioEngineWrapperPrivate::AudioRoutingEventL( TInt aAudioDestination, TInt aError ) |
247 { |
220 { |
248 //TODO: Check how this event differs from AudioRoutingChangedL |
221 //TODO: Check how this event differs from AudioRoutingChangedL |
249 Q_UNUSED( aAudioDestination ) |
222 Q_UNUSED( aAudioDestination ) |
250 Q_UNUSED( aError ) |
223 Q_UNUSED( aError ) |
251 // doc->PubSubL().PublishLoudspeakerStatusL( EVRPSLoudspeakerNotInUse ); |
|
252 // Q_Q( RadioEngineWrapper ); |
224 // Q_Q( RadioEngineWrapper ); |
253 // q->audioRouteChanged( aAudioDestination == RadioEngine::ERadioSpeaker ); |
225 // q->audioRouteChanged( aAudioDestination == RadioEngine::ERadioSpeaker ); |
254 } |
226 } |
255 |
227 |
256 /*! |
228 /*! |
262 // LOG_FORMAT( "RadioEngineWrapperPrivate::SeekingEventL, aSeekingState: %d, Error: %d", aSeekingState, aError ); |
234 // LOG_FORMAT( "RadioEngineWrapperPrivate::SeekingEventL, aSeekingState: %d, Error: %d", aSeekingState, aError ); |
263 // if ( aSeekingState != RadioEngine::ERadioNotSeeking ) { |
235 // if ( aSeekingState != RadioEngine::ERadioNotSeeking ) { |
264 // // We only set the flag here. It is reset in the FrequencyEventL |
236 // // We only set the flag here. It is reset in the FrequencyEventL |
265 // mIsSeeking = true; |
237 // mIsSeeking = true; |
266 // } |
238 // } |
267 // Document()->PubSubL().PublishTuningStateL( EVRPSTuningStarted ); |
|
268 } |
239 } |
269 |
240 |
270 /*! |
241 /*! |
271 * \reimp |
242 * \reimp |
272 */ |
243 */ |
273 void RadioEngineWrapperPrivate::RegionEventL( TInt DEBUGVAR( aRegion ), TInt DEBUGVAR( aError ) ) |
244 void RadioEngineWrapperPrivate::RegionEventL( TInt DEBUGVAR( aRegion ), TInt DEBUGVAR( aError ) ) |
274 { |
245 { |
275 LOG_FORMAT( "RadioEngineWrapperPrivate::RegionEventL, aRegion: %d, Error: %d", aRegion, aError ); |
246 LOG_FORMAT( "RadioEngineWrapperPrivate::RegionEventL, aRegion: %d, Error: %d", aRegion, aError ); |
276 // Document()->PubSubL().PublishFrequencyDecimalCountL( |
|
277 // static_cast<TVRPSFrequencyDecimalCount>( Document()->RadioSettings()->DecimalCount() ) ); |
|
278 } |
247 } |
279 |
248 |
280 /*! |
249 /*! |
281 * \reimp |
250 * \reimp |
282 */ |
251 */ |
283 void RadioEngineWrapperPrivate::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute ) |
252 void RadioEngineWrapperPrivate::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute ) |
284 { |
253 { |
285 mUseLoudspeaker = aRoute == RadioEngine::ERadioSpeaker; |
254 mUseLoudspeaker = aRoute == RadioEngine::ERadioSpeaker; |
286 mObserver.audioRouteChanged( mUseLoudspeaker ); |
255 RUN_NOTIFY_LOOP( mObservers, audioRouteChanged( mUseLoudspeaker ) ); |
287 } |
256 } |
288 |
257 |
289 /*! |
258 /*! |
290 * \reimp |
259 * \reimp |
291 */ |
260 */ |