radioapp/radioenginewrapper/src/radioenginewrapper.cpp
changeset 28 075425b8d9a4
parent 24 6df133bd92e1
child 32 189d20c34778
child 34 bc10a61bd7d3
equal deleted inserted replaced
24:6df133bd92e1 28:075425b8d9a4
    24  * Constructor
    24  * Constructor
    25  */
    25  */
    26 RadioEngineWrapper::RadioEngineWrapper( RadioStationHandlerIf& stationHandler ) :
    26 RadioEngineWrapper::RadioEngineWrapper( RadioStationHandlerIf& stationHandler ) :
    27     d_ptr( new RadioEngineWrapperPrivate( this, stationHandler ) )
    27     d_ptr( new RadioEngineWrapperPrivate( this, stationHandler ) )
    28 {
    28 {
    29     Q_D( RadioEngineWrapper );
       
    30     d->init();
       
    31 }
    29 }
    32 
    30 
    33 /*!
    31 /*!
    34  * Destructor
    32  * Destructor
    35  */
    33  */
    39 }
    37 }
    40 
    38 
    41 /*!
    39 /*!
    42  *
    40  *
    43  */
    41  */
       
    42 bool RadioEngineWrapper::init()
       
    43 {
       
    44     Q_D( RadioEngineWrapper );
       
    45     return d->init();
       
    46 }
       
    47 
       
    48 /*!
       
    49  *
       
    50  */
    44 void RadioEngineWrapper::addObserver( RadioEngineWrapperObserver* observer )
    51 void RadioEngineWrapper::addObserver( RadioEngineWrapperObserver* observer )
    45 {
    52 {
    46     Q_D( RadioEngineWrapper );
    53     Q_D( RadioEngineWrapper );
    47     d->mObservers.append( observer );
    54     d->mObservers.append( observer );
    48 }
    55 }
    55     Q_D( RadioEngineWrapper );
    62     Q_D( RadioEngineWrapper );
    56     d->mObservers.removeAll( observer );
    63     d->mObservers.removeAll( observer );
    57 }
    64 }
    58 
    65 
    59 /*!
    66 /*!
    60  * Checks if the radio engine has been constructed properly
       
    61  */
       
    62 bool RadioEngineWrapper::isEngineConstructed()
       
    63 {
       
    64     Q_D( RadioEngineWrapper );
       
    65     return d->isEngineConstructed();
       
    66 }
       
    67 
       
    68 /*!
       
    69  * Returns the settings handler owned by the engine
    67  * Returns the settings handler owned by the engine
    70  */
    68  */
    71 RadioSettingsIf& RadioEngineWrapper::settings()
    69 RadioSettingsIf& RadioEngineWrapper::settings()
    72 {
    70 {
    73     Q_D( RadioEngineWrapper );
    71     Q_D( RadioEngineWrapper );
   111 }
   109 }
   112 
   110 
   113 /*!
   111 /*!
   114  * Returns the frequency step size from the selected region
   112  * Returns the frequency step size from the selected region
   115  */
   113  */
   116 bool RadioEngineWrapper::isFrequencyValid( uint frequency )
   114 bool RadioEngineWrapper::isFrequencyValid( uint frequency ) const
   117 {
   115 {
   118     Q_D( const RadioEngineWrapper );
   116     return frequency >= minFrequency() && frequency <= maxFrequency() && frequency % frequencyStepSize() == 0;
   119     return d->mEngineHandler->IsFrequencyValid( frequency );
       
   120 }
   117 }
   121 
   118 
   122 /*!
   119 /*!
   123  * Checks if the radio engine is on
   120  * Checks if the radio engine is on
   124  */
   121  */
   132  * Returns the currently tuned frequency
   129  * Returns the currently tuned frequency
   133  */
   130  */
   134 uint RadioEngineWrapper::currentFrequency() const
   131 uint RadioEngineWrapper::currentFrequency() const
   135 {
   132 {
   136     Q_D( const RadioEngineWrapper );
   133     Q_D( const RadioEngineWrapper );
   137     return d->mEngineHandler->TunedFrequency();
   134     return d->mEngineHandler->CurrentFrequency();
   138 }
   135 }
   139 
   136 
   140 /*!
   137 /*!
   141  * Returns the mute status
   138  * Returns the mute status
   142  */
   139  */
   163     Q_D( const RadioEngineWrapper );
   160     Q_D( const RadioEngineWrapper );
   164     return d->mUseLoudspeaker;
   161     return d->mUseLoudspeaker;
   165 }
   162 }
   166 
   163 
   167 /*!
   164 /*!
       
   165  * Sets or unsets the engine to manual seek mode
       
   166  */
       
   167 void RadioEngineWrapper::setManualSeekMode( bool manualSeek )
       
   168 {
       
   169     Q_D( RadioEngineWrapper );
       
   170     d->mEngineHandler->SetManualSeekMode( manualSeek );
       
   171 }
       
   172 
       
   173 /*!
       
   174  * Checks if the engine is in manual seek mode
       
   175  */
       
   176 bool RadioEngineWrapper::isInManualSeekMode() const
       
   177 {
       
   178     Q_D( const RadioEngineWrapper );
       
   179     return d->mEngineHandler->IsInManualSeekMode();
       
   180 }
       
   181 
       
   182 /*!
       
   183  *
       
   184  */
       
   185 void RadioEngineWrapper::setRdsEnabled( bool rdsEnabled )
       
   186 {
       
   187     Q_D( RadioEngineWrapper );
       
   188     d->mEngineHandler->SetRdsEnabled( rdsEnabled );
       
   189 }
       
   190 
       
   191 /*!
   168  * Tunes to the given frequency
   192  * Tunes to the given frequency
   169  */
   193  */
   170 void RadioEngineWrapper::tuneFrequency( uint frequency, const int reason )
   194 void RadioEngineWrapper::setFrequency( uint frequency, const int reason )
   171 {
   195 {
   172     Q_D( RadioEngineWrapper );
   196     Q_D( RadioEngineWrapper );
   173     d->tuneFrequency( frequency, reason );
   197     d->setFrequency( frequency, reason );
   174 }
   198 }
   175 
   199 
   176 /*!
   200 /*!
   177  * Tunes to the given frequency after a delay
   201  * volume increase command for the engine
   178  */
   202  */
   179 void RadioEngineWrapper::tuneWithDelay( uint frequency, const int reason )
   203 void RadioEngineWrapper::increaseVolume()
   180 {
   204 {
   181     Q_D( RadioEngineWrapper );
   205     Q_D( RadioEngineWrapper );
   182     d->tuneWithDelay( frequency, reason );
   206     d->mEngineHandler->IncreaseVolume();
       
   207 }
       
   208 
       
   209 /*!
       
   210  * volume decrease command for the engine
       
   211  */
       
   212 void RadioEngineWrapper::decreaseVolume()
       
   213 {
       
   214     Q_D( RadioEngineWrapper );
       
   215     d->mEngineHandler->DecreaseVolume();
   183 }
   216 }
   184 
   217 
   185 /*!
   218 /*!
   186  * volume update command for the engine
   219  * volume update command for the engine
   187  */
   220  */
   192 }
   225 }
   193 
   226 
   194 /*!
   227 /*!
   195  *
   228  *
   196  */
   229  */
   197 void RadioEngineWrapper::setMute( bool muted )
   230 void RadioEngineWrapper::setMute( bool muted, bool updateSettings )
   198 {
   231 {
   199     Q_D( RadioEngineWrapper );
   232     Q_D( RadioEngineWrapper );
   200     d->mEngineHandler->SetMuted( muted );
   233     d->mEngineHandler->SetMuted( muted, updateSettings );
   201 }
   234 }
   202 
   235 
   203 /*!
   236 /*!
   204  *
   237  *
   205  */
   238  */
   211 }
   244 }
   212 
   245 
   213 /*!
   246 /*!
   214  *
   247  *
   215  */
   248  */
   216 void RadioEngineWrapper::startSeeking( Seeking::Direction direction, const int reason )
   249 void RadioEngineWrapper::startSeeking( Seek::Direction direction, const int reason )
   217 {
   250 {
   218     Q_D( RadioEngineWrapper );
   251     Q_D( RadioEngineWrapper );
   219     d->startSeeking( direction, reason );
   252     d->startSeeking( direction, reason );
   220 }
   253 }
   221 
   254