equal
deleted
inserted
replaced
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // System includes |
18 // System includes |
19 #include <qtimer> |
19 #include <QTimer> |
20 #include <qsettings> |
20 #include <QSettings> |
21 |
21 |
22 // User includes |
22 // User includes |
23 #include "radioenginewrapper_win32_p.h" |
23 #include "radioenginewrapper_win32_p.h" |
24 #include "radiosettings.h" |
24 #include "radiosettings.h" |
25 #include "radiosettings_p.h" |
25 #include "radiosettings_p.h" |
31 |
31 |
32 static RadioEngineWrapperPrivate* theInstance = 0; |
32 static RadioEngineWrapperPrivate* theInstance = 0; |
33 |
33 |
34 const QString KKeyFrequency = "CurrentFreq"; |
34 const QString KKeyFrequency = "CurrentFreq"; |
35 const QString KKeyOffline = "Offline"; |
35 const QString KKeyOffline = "Offline"; |
|
36 |
|
37 const uint KScanFrequencies[] = { |
|
38 87600000, |
|
39 88000000, |
|
40 89400000, |
|
41 96000000, |
|
42 97600000, |
|
43 100600000, |
|
44 101300000, |
|
45 102600000, |
|
46 103500000, |
|
47 104100000, |
|
48 105500000, |
|
49 107500000 |
|
50 }; |
|
51 |
|
52 const int KScanFrequencyCount = sizeof( KScanFrequencies ) / sizeof( KScanFrequencies[0] ); |
36 |
53 |
37 /*! |
54 /*! |
38 * |
55 * |
39 */ |
56 */ |
40 RadioEngineWrapperPrivate::RadioEngineWrapperPrivate( RadioEngineWrapper* wrapper, |
57 RadioEngineWrapperPrivate::RadioEngineWrapperPrivate( RadioEngineWrapper* wrapper, |
47 mCommandSender( 0 ), |
64 mCommandSender( 0 ), |
48 mUseLoudspeaker( false ), |
65 mUseLoudspeaker( false ), |
49 mIsSeeking( false ), |
66 mIsSeeking( false ), |
50 mAntennaAttached( true ), |
67 mAntennaAttached( true ), |
51 mFrequency( 0 ), |
68 mFrequency( 0 ), |
|
69 mNextFrequency( 0 ), |
52 mVolume( 5 ), |
70 mVolume( 5 ), |
53 mMaxVolume( 10000 ), |
71 mMaxVolume( 10000 ), |
54 mFrequencyStepSize( 50000 ), |
72 mFrequencyStepSize( 50000 ), |
55 mRegionId( RadioRegion::Default ), |
73 mRegionId( RadioRegion::Default ), |
56 mMinFrequency( 87500000 ), |
74 mMinFrequency( 87500000 ), |
154 * |
172 * |
155 */ |
173 */ |
156 void RadioEngineWrapperPrivate::startSeeking( Seeking::Direction direction ) |
174 void RadioEngineWrapperPrivate::startSeeking( Seeking::Direction direction ) |
157 { |
175 { |
158 mObserver.seekingStarted( direction ); |
176 mObserver.seekingStarted( direction ); |
|
177 |
|
178 // Find the previous and next favorite from current frequency |
|
179 uint previous = 0; |
|
180 uint next = 0; |
|
181 for( int i = 0; i < KScanFrequencyCount; ++i ) { |
|
182 int testFreq = KScanFrequencies[i]; |
|
183 if ( testFreq > mFrequency ) { |
|
184 next = testFreq; |
|
185 break; |
|
186 } |
|
187 previous = testFreq; |
|
188 } |
|
189 |
|
190 |
|
191 if ( direction == Seeking::Up ) { |
|
192 if ( next == 0 ) { |
|
193 next = KScanFrequencies[0]; |
|
194 } |
|
195 mNextFrequency = next; |
|
196 } else { |
|
197 if ( previous == 0 ) { |
|
198 previous = KScanFrequencies[KScanFrequencyCount - 1]; |
|
199 } |
|
200 mNextFrequency = previous; |
|
201 } |
|
202 |
|
203 mTuneTimer->start( 1000 ); |
159 } |
204 } |
160 |
205 |
161 /*! |
206 /*! |
162 * |
207 * |
163 */ |
208 */ |
188 * |
233 * |
189 */ |
234 */ |
190 void RadioEngineWrapperPrivate::addSong( const QString& artist, const QString& title ) |
235 void RadioEngineWrapperPrivate::addSong( const QString& artist, const QString& title ) |
191 { |
236 { |
192 QString radioText = QString( "Now Playing: %1 - %2" ).arg( artist ).arg( title ); |
237 QString radioText = QString( "Now Playing: %1 - %2" ).arg( artist ).arg( title ); |
|
238 mArtist = artist; |
|
239 mTitle = title; |
193 |
240 |
194 const uint frequency = mStationHandler.currentFrequency(); |
241 const uint frequency = mStationHandler.currentFrequency(); |
195 mStationHandler.setCurrentRadioText( frequency, radioText ); |
242 mStationHandler.setCurrentRadioText( frequency, radioText ); |
196 mStationHandler.setCurrentRadioTextPlus( frequency, RtPlus::Artist, artist ); |
243 |
197 mStationHandler.setCurrentRadioTextPlus( frequency, RtPlus::Title, title ); |
244 QTimer::singleShot( 500, this, SLOT(addSongTags()) ); |
198 } |
245 } |
199 |
246 |
200 /*! |
247 /*! |
201 * |
248 * |
202 */ |
249 */ |
224 /*! |
271 /*! |
225 * Private slot |
272 * Private slot |
226 */ |
273 */ |
227 void RadioEngineWrapperPrivate::frequencyEvent() |
274 void RadioEngineWrapperPrivate::frequencyEvent() |
228 { |
275 { |
|
276 if ( mNextFrequency ) { // Seeking |
|
277 mFrequency = mNextFrequency; |
|
278 mStationHandler.addScannedFrequency( mFrequency ); |
|
279 } |
|
280 |
229 mStationHandler.setCurrentStation( mFrequency ); |
281 mStationHandler.setCurrentStation( mFrequency ); |
230 mObserver.tunedToFrequency( mFrequency, mCommandSender ); |
282 mObserver.tunedToFrequency( mFrequency, mCommandSender ); |
231 mStationHandler.startDynamicPsCheck(); |
283 mStationHandler.startDynamicPsCheck(); |
|
284 } |
|
285 |
|
286 /*! |
|
287 * Private slot |
|
288 */ |
|
289 void RadioEngineWrapperPrivate::addSongTags() |
|
290 { |
|
291 const uint frequency = mStationHandler.currentFrequency(); |
|
292 mStationHandler.setCurrentRadioTextPlus( frequency, RtPlus::Artist, mArtist ); |
|
293 mStationHandler.setCurrentRadioTextPlus( frequency, RtPlus::Title, mTitle ); |
|
294 mArtist = ""; |
|
295 mTitle = ""; |
232 } |
296 } |
233 |
297 |
234 /*! |
298 /*! |
235 * |
299 * |
236 */ |
300 */ |