37 #include "radiohistorymodel.h" |
37 #include "radiohistorymodel.h" |
38 #include "radiohistoryitem.h" |
38 #include "radiohistoryitem.h" |
39 #include "radiosettings.h" |
39 #include "radiosettings.h" |
40 #include "radioscannerengine.h" |
40 #include "radioscannerengine.h" |
41 #include "radiogenrelocalizer.h" |
41 #include "radiogenrelocalizer.h" |
|
42 #include "radiotimerpool.h" |
42 #include "radiologger.h" |
43 #include "radiologger.h" |
43 |
44 |
44 // Constants |
45 // Constants |
45 const uint RADIO_CENREP_UID = 0x2002FF52; |
46 const uint RADIO_CENREP_UID = 0x2002FF52; |
46 const uint RADIO_CENREP_FREQUENCY_KEY = 0x207; |
47 const uint RADIO_CENREP_FREQUENCY_KEY = 0x207; |
56 // Constants used when launching radio server |
57 // Constants used when launching radio server |
57 const QLatin1String RADIO_SERVER_NAME( "radioserver.exe" ); |
58 const QLatin1String RADIO_SERVER_NAME( "radioserver.exe" ); |
58 const QLatin1String RADIO_RANGE_USEURO( "useuro" ); |
59 const QLatin1String RADIO_RANGE_USEURO( "useuro" ); |
59 const QLatin1String RADIO_RANGE_JAPAN( "japan" ); |
60 const QLatin1String RADIO_RANGE_JAPAN( "japan" ); |
60 |
61 |
|
62 enum TimerId { PowerOff }; |
|
63 |
61 // ====== STATIC FUNCTIONS ======== |
64 // ====== STATIC FUNCTIONS ======== |
62 |
65 |
63 /*! |
66 /*! |
64 * Gets the last tuned frequency from central repository |
67 * Gets the last tuned frequency from central repository |
65 */ |
68 */ |
178 */ |
181 */ |
179 void RadioUiEngine::setPowerOn() |
182 void RadioUiEngine::setPowerOn() |
180 { |
183 { |
181 setMute( false ); |
184 setMute( false ); |
182 |
185 |
183 Q_D( RadioUiEngine ); |
186 cancelTimer( PowerOff, this ); |
184 if ( d->mPowerOffTimer ) { |
|
185 d->mPowerOffTimer->stop(); |
|
186 d->mPowerOffTimer->deleteLater(); |
|
187 d->mPowerOffTimer = NULL; |
|
188 } |
|
189 } |
187 } |
190 |
188 |
191 /*! |
189 /*! |
192 * |
190 * |
193 */ |
191 */ |
194 void RadioUiEngine::setPowerOff( int delay ) |
192 void RadioUiEngine::setPowerOff( int delay ) |
195 { |
193 { |
196 Q_D( RadioUiEngine ); |
|
197 d->mEngineWrapper->setMute( true, false ); |
|
198 |
|
199 if ( delay > 0 ) { |
194 if ( delay > 0 ) { |
200 if ( !d->mPowerOffTimer ) { |
195 startTimer( delay, PowerOff, this, SIGNAL(powerOffRequested()) ); |
201 d->mPowerOffTimer = new QTimer( this ); |
|
202 Radio::connect( d->mPowerOffTimer, SIGNAL(timeout()), |
|
203 this, SIGNAL(powerOffRequested()) ); |
|
204 } |
|
205 |
|
206 d->mPowerOffTimer->start( delay ); |
|
207 } else { |
196 } else { |
208 emit powerOffRequested(); |
197 emit powerOffRequested(); |
209 } |
198 } |
|
199 |
|
200 Q_D( RadioUiEngine ); |
|
201 d->mEngineWrapper->setMute( true, false ); |
210 } |
202 } |
211 |
203 |
212 /*! |
204 /*! |
213 * |
205 * |
214 */ |
206 */ |
215 bool RadioUiEngine::isPoweringOff() const |
207 bool RadioUiEngine::isPoweringOff() const |
216 { |
208 { |
217 Q_D( const RadioUiEngine ); |
209 return isTimerActive( PowerOff, this ); |
218 return d->mPowerOffTimer && d->mPowerOffTimer->isActive(); |
|
219 } |
210 } |
220 |
211 |
221 /*! |
212 /*! |
222 * Returns the settings handler owned by the engine |
213 * Returns the settings handler owned by the engine |
223 */ |
214 */ |
471 if ( frequency != d->mStationModel->currentStation().frequency() && d->mEngineWrapper->isFrequencyValid( frequency ) ) { |
462 if ( frequency != d->mStationModel->currentStation().frequency() && d->mEngineWrapper->isFrequencyValid( frequency ) ) { |
472 LOG_FORMAT( "RadioUiEngine::tuneFrequency, frequency: %d", frequency ); |
463 LOG_FORMAT( "RadioUiEngine::tuneFrequency, frequency: %d", frequency ); |
473 d->cancelSeeking(); |
464 d->cancelSeeking(); |
474 d->mEngineWrapper->setFrequency( frequency, reason ); |
465 d->mEngineWrapper->setFrequency( frequency, reason ); |
475 } |
466 } |
|
467 } |
|
468 |
|
469 /*! |
|
470 * |
|
471 */ |
|
472 void RadioUiEngine::startTimer( int msec, int id, QObject* receiver, const char* member, QVariant param ) |
|
473 { |
|
474 Q_D( RadioUiEngine ); |
|
475 d->mTimerPool->startTimer( msec, id, receiver, member, param ); |
|
476 } |
|
477 |
|
478 /*! |
|
479 * |
|
480 */ |
|
481 void RadioUiEngine::cancelTimer( int id, const QObject* receiver ) |
|
482 { |
|
483 Q_D( RadioUiEngine ); |
|
484 if ( d->mTimerPool ) { |
|
485 d->mTimerPool->cancelTimer( id, receiver ); |
|
486 } |
|
487 } |
|
488 |
|
489 /*! |
|
490 * |
|
491 */ |
|
492 bool RadioUiEngine::isTimerActive( int id, const QObject* receiver ) const |
|
493 { |
|
494 Q_D( const RadioUiEngine ); |
|
495 return d->mTimerPool->isTimerActive( id, receiver ); |
476 } |
496 } |
477 |
497 |
478 /*! |
498 /*! |
479 * Public slot |
499 * Public slot |
480 * volume update command slot for the engine |
500 * volume update command slot for the engine |