radioapp/radioenginewrapper/src/radioenginewrapper.cpp
branchRCL_3
changeset 20 93c594350b9a
parent 19 cce62ebc198e
equal deleted inserted replaced
19:cce62ebc198e 20:93c594350b9a
     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 // User includes
       
    19 #include "radioenginewrapper.h"
       
    20 #include "radioenginewrapperobserver.h"
       
    21 #include "radioenginewrapper_p.h"
       
    22 #include "radioenginehandler.h"
       
    23 
       
    24 /*!
       
    25  * Constructor
       
    26  */
       
    27 RadioEngineWrapper::RadioEngineWrapper( RadioStationHandlerIf& stationHandler ) :
       
    28     d_ptr( new RadioEngineWrapperPrivate( this, stationHandler ) )
       
    29 {
       
    30 }
       
    31 
       
    32 /*!
       
    33  * Destructor
       
    34  */
       
    35 RadioEngineWrapper::~RadioEngineWrapper()
       
    36 {
       
    37 }
       
    38 
       
    39 /*!
       
    40  *
       
    41  */
       
    42 bool RadioEngineWrapper::init()
       
    43 {
       
    44     Q_D( RadioEngineWrapper );
       
    45     return d->init();
       
    46 }
       
    47 
       
    48 /*!
       
    49  *
       
    50  */
       
    51 void RadioEngineWrapper::addObserver( RadioEngineWrapperObserver* observer )
       
    52 {
       
    53     Q_D( RadioEngineWrapper );
       
    54     d->mObservers.prepend( observer );
       
    55 }
       
    56 
       
    57 /*!
       
    58  *
       
    59  */
       
    60 void RadioEngineWrapper::removeObserver( RadioEngineWrapperObserver* observer )
       
    61 {
       
    62     Q_D( RadioEngineWrapper );
       
    63     d->mObservers.removeAll( observer );
       
    64 }
       
    65 
       
    66 /*!
       
    67  * Returns the settings handler owned by the engine
       
    68  */
       
    69 RadioSettingsIf& RadioEngineWrapper::settings()
       
    70 {
       
    71     Q_D( RadioEngineWrapper );
       
    72     return d->settings();
       
    73 }
       
    74 
       
    75 /*!
       
    76  * Returns the selected radio region
       
    77  */
       
    78 RadioRegion::Region RadioEngineWrapper::region() const
       
    79 {
       
    80     Q_D( const RadioEngineWrapper );
       
    81     return d->mEngineHandler->region();
       
    82 }
       
    83 
       
    84 /*!
       
    85  * Returns the minimum frequency
       
    86  */
       
    87 uint RadioEngineWrapper::minFrequency() const
       
    88 {
       
    89     Q_D( const RadioEngineWrapper );
       
    90     return d->mEngineHandler->minFrequency();
       
    91 }
       
    92 
       
    93 /*!
       
    94  * Returns the maximum frequency
       
    95  */
       
    96 uint RadioEngineWrapper::maxFrequency() const
       
    97 {
       
    98     Q_D( const RadioEngineWrapper );
       
    99     return d->mEngineHandler->maxFrequency();
       
   100 }
       
   101 
       
   102 /*!
       
   103  * Returns the frequency step size from the selected region
       
   104  */
       
   105 uint RadioEngineWrapper::frequencyStepSize() const
       
   106 {
       
   107     Q_D( const RadioEngineWrapper );
       
   108     return d->mEngineHandler->frequencyStepSize();
       
   109 }
       
   110 
       
   111 /*!
       
   112  * Returns true if frequency is valid, otherwise false
       
   113  */
       
   114 bool RadioEngineWrapper::isFrequencyValid( uint frequency ) const
       
   115 {
       
   116     return frequency >= minFrequency() && frequency <= maxFrequency();
       
   117 }
       
   118 
       
   119 /*!
       
   120  * Checks if the radio engine is on
       
   121  */
       
   122 bool RadioEngineWrapper::isRadioOn() const
       
   123 {
       
   124     Q_D( const RadioEngineWrapper );
       
   125     return d->mEngineHandler->isRadioOn();
       
   126 }
       
   127 
       
   128 /*!
       
   129  * Returns the currently tuned frequency
       
   130  */
       
   131 uint RadioEngineWrapper::currentFrequency() const
       
   132 {
       
   133     Q_D( const RadioEngineWrapper );
       
   134     return d->mEngineHandler->currentFrequency();
       
   135 }
       
   136 
       
   137 /*!
       
   138  * Returns the mute status
       
   139  */
       
   140 bool RadioEngineWrapper::isMuted() const
       
   141 {
       
   142     Q_D( const RadioEngineWrapper );
       
   143     return d->mEngineHandler->isMuted();
       
   144 }
       
   145 
       
   146 /*!
       
   147  * Returns the antenna connection status
       
   148  */
       
   149 bool RadioEngineWrapper::isAntennaAttached() const
       
   150 {
       
   151     Q_D( const RadioEngineWrapper );
       
   152     return d->mEngineHandler->isAntennaAttached();
       
   153 }
       
   154 
       
   155 /*!
       
   156  * Returns the "use loudspeaker" status
       
   157  */
       
   158 bool RadioEngineWrapper::isUsingLoudspeaker() const
       
   159 {
       
   160     Q_D( const RadioEngineWrapper );
       
   161     return d->mUseLoudspeaker;
       
   162 }
       
   163 
       
   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     if ( !manualSeek ) {
       
   172         RUN_NOTIFY_LOOP( d->observers(), tunedToFrequency( currentFrequency(), TuneReason::ManualSeekTune ) );
       
   173     }
       
   174 }
       
   175 
       
   176 /*!
       
   177  * Checks if the engine is in manual seek mode
       
   178  */
       
   179 bool RadioEngineWrapper::isInManualSeekMode() const
       
   180 {
       
   181     Q_D( const RadioEngineWrapper );
       
   182     return d->mEngineHandler->isInManualSeekMode();
       
   183 }
       
   184 
       
   185 /*!
       
   186  *
       
   187  */
       
   188 void RadioEngineWrapper::setRdsEnabled( bool rdsEnabled )
       
   189 {
       
   190     Q_D( RadioEngineWrapper );
       
   191     d->mEngineHandler->setRdsEnabled( rdsEnabled );
       
   192 }
       
   193 
       
   194 /*!
       
   195  * Tunes to the given frequency
       
   196  */
       
   197 void RadioEngineWrapper::setFrequency( uint frequency, const int reason )
       
   198 {
       
   199     Q_D( RadioEngineWrapper );
       
   200     d->setFrequency( frequency, reason );
       
   201 }
       
   202 
       
   203 /*!
       
   204  * volume increase command for the engine
       
   205  */
       
   206 void RadioEngineWrapper::increaseVolume()
       
   207 {
       
   208     Q_D( RadioEngineWrapper );
       
   209     d->mEngineHandler->increaseVolume();
       
   210 }
       
   211 
       
   212 /*!
       
   213  * volume decrease command for the engine
       
   214  */
       
   215 void RadioEngineWrapper::decreaseVolume()
       
   216 {
       
   217     Q_D( RadioEngineWrapper );
       
   218     d->mEngineHandler->decreaseVolume();
       
   219 }
       
   220 
       
   221 /*!
       
   222  * volume update command for the engine
       
   223  */
       
   224 void RadioEngineWrapper::setVolume( int volume )
       
   225 {
       
   226     Q_D( RadioEngineWrapper );
       
   227     d->mEngineHandler->setVolume( volume );
       
   228 }
       
   229 
       
   230 /*!
       
   231  *
       
   232  */
       
   233 void RadioEngineWrapper::setMute( bool muted, bool updateSettings )
       
   234 {
       
   235     Q_D( RadioEngineWrapper );
       
   236     d->mEngineHandler->setMute( muted, updateSettings );
       
   237 }
       
   238 
       
   239 /*!
       
   240  *
       
   241  */
       
   242 void RadioEngineWrapper::toggleAudioRoute()
       
   243 {
       
   244     Q_D( RadioEngineWrapper );
       
   245     d->mUseLoudspeaker = !d->mUseLoudspeaker;
       
   246     d->mEngineHandler->setAudioRouteToLoudspeaker( d->mUseLoudspeaker );
       
   247 }
       
   248 
       
   249 /*!
       
   250  *
       
   251  */
       
   252 void RadioEngineWrapper::startSeeking( Seek::Direction direction, const int reason )
       
   253 {
       
   254     Q_D( RadioEngineWrapper );
       
   255     d->startSeeking( direction, reason );
       
   256 }
       
   257 
       
   258 /*!
       
   259  *
       
   260  */
       
   261 void RadioEngineWrapper::cancelSeeking()
       
   262 {
       
   263     Q_D( RadioEngineWrapper );
       
   264     d->mEngineHandler->cancelSeek();
       
   265 }