radioapp/radioenginewrapper/src/radioenginewrapper.cpp
changeset 13 46974bebc798
child 16 f54ebcfc1b80
equal deleted inserted replaced
0:f3d95d9c00ab 13:46974bebc798
       
     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 "radioenginewrapper_p.h"
       
    21 #include "cradioenginehandler.h"
       
    22 #include "radiofrequencyscanninghandler.h"
       
    23 
       
    24 /*!
       
    25  * Constructor
       
    26  */
       
    27 RadioEngineWrapper::RadioEngineWrapper( RadioStationHandlerIf& stationHandler,
       
    28                                         RadioEngineWrapperObserver& observer ) :
       
    29     d_ptr( new RadioEngineWrapperPrivate( this, stationHandler, observer ) )
       
    30 {
       
    31     Q_D( RadioEngineWrapper );
       
    32     d->init();
       
    33 }
       
    34 
       
    35 /*!
       
    36  * Destructor
       
    37  */
       
    38 RadioEngineWrapper::~RadioEngineWrapper()
       
    39 {
       
    40     delete d_ptr;
       
    41 }
       
    42 
       
    43 /*!
       
    44  * Checks if the radio engine has been constructed properly
       
    45  */
       
    46 bool RadioEngineWrapper::isEngineConstructed()
       
    47 {
       
    48     Q_D( RadioEngineWrapper );
       
    49     return d->isEngineConstructed();
       
    50 }
       
    51 
       
    52 /*!
       
    53  * Returns the settings handler owned by the engine
       
    54  */
       
    55 RadioSettings& RadioEngineWrapper::settings()
       
    56 {
       
    57     Q_D( RadioEngineWrapper );
       
    58     return d->settings();
       
    59 }
       
    60 
       
    61 /*!
       
    62  * Returns the selected radio region
       
    63  */
       
    64 RadioRegion::Region RadioEngineWrapper::region() const
       
    65 {
       
    66     Q_D( const RadioEngineWrapper );
       
    67     return d->mEngineHandler->Region();
       
    68 }
       
    69 
       
    70 /*!
       
    71  * Returns the minimum frequency
       
    72  */
       
    73 uint RadioEngineWrapper::minFrequency() const
       
    74 {
       
    75     Q_D( const RadioEngineWrapper );
       
    76     return d->mEngineHandler->MinFrequency();
       
    77 }
       
    78 
       
    79 /*!
       
    80  * Returns the maximum frequency
       
    81  */
       
    82 uint RadioEngineWrapper::maxFrequency() const
       
    83 {
       
    84     Q_D( const RadioEngineWrapper );
       
    85     return d->mEngineHandler->MaxFrequency();
       
    86 }
       
    87 
       
    88 /*!
       
    89  * Returns the frequency step size from the selected region
       
    90  */
       
    91 uint RadioEngineWrapper::frequencyStepSize() const
       
    92 {
       
    93     Q_D( const RadioEngineWrapper );
       
    94     return d->mEngineHandler->FrequencyStepSize();
       
    95 }
       
    96 
       
    97 /*!
       
    98  * Returns the frequency step size from the selected region
       
    99  */
       
   100 bool RadioEngineWrapper::isFrequencyValid( uint frequency )
       
   101 {
       
   102     Q_D( const RadioEngineWrapper );
       
   103     return d->mEngineHandler->IsFrequencyValid( frequency );
       
   104 }
       
   105 
       
   106 /*!
       
   107  * Checks if the radio engine is on
       
   108  */
       
   109 bool RadioEngineWrapper::isRadioOn() const
       
   110 {
       
   111     Q_D( const RadioEngineWrapper );
       
   112     return d->mEngineHandler->IsRadioOn();
       
   113 }
       
   114 
       
   115 /*!
       
   116  * Checks if the scan is on
       
   117  */
       
   118 bool RadioEngineWrapper::isScanning() const
       
   119 {
       
   120     Q_D( const RadioEngineWrapper );
       
   121     return !d->mFrequencyScanningHandler.isNull();
       
   122 }
       
   123 
       
   124 /*!
       
   125  * Returns the currently tuned frequency
       
   126  */
       
   127 uint RadioEngineWrapper::currentFrequency() const
       
   128 {
       
   129     Q_D( const RadioEngineWrapper );
       
   130     return d->mEngineHandler->TunedFrequency();
       
   131 }
       
   132 
       
   133 /*!
       
   134  * Returns the mute status
       
   135  */
       
   136 bool RadioEngineWrapper::isMuted() const
       
   137 {
       
   138     Q_D( const RadioEngineWrapper );
       
   139     return d->mEngineHandler->IsMuted();
       
   140 }
       
   141 
       
   142 /*!
       
   143  * Returns the headset connection status
       
   144  */
       
   145 bool RadioEngineWrapper::isAntennaAttached() const
       
   146 {
       
   147     Q_D( const RadioEngineWrapper );
       
   148     return d->mEngineHandler->IsAntennaAttached();
       
   149 }
       
   150 
       
   151 /*!
       
   152  * Returns the "use loudspeaker" status
       
   153  */
       
   154 bool RadioEngineWrapper::isUsingLoudspeaker() const
       
   155 {
       
   156     Q_D( const RadioEngineWrapper );
       
   157     return d->mUseLoudspeaker;
       
   158 }
       
   159 
       
   160 /*!
       
   161  * Tunes to the given frequency
       
   162  */
       
   163 void RadioEngineWrapper::tuneFrequency( uint frequency, const int sender )
       
   164 {
       
   165     Q_D( RadioEngineWrapper );
       
   166     d->tuneFrequency( frequency, sender );
       
   167 }
       
   168 
       
   169 /*!
       
   170  * Tunes to the given frequency after a delay
       
   171  */
       
   172 void RadioEngineWrapper::tuneWithDelay( uint frequency, const int sender )
       
   173 {
       
   174     Q_D( RadioEngineWrapper );
       
   175     d->tuneWithDelay( frequency, sender );
       
   176 }
       
   177 
       
   178 /*!
       
   179  * volume update command for the engine
       
   180  */
       
   181 void RadioEngineWrapper::setVolume( int volume )
       
   182 {
       
   183     Q_D( RadioEngineWrapper );
       
   184     d->mEngineHandler->SetVolume( volume );
       
   185 }
       
   186 
       
   187 /*!
       
   188  *
       
   189  */
       
   190 void RadioEngineWrapper::toggleMute()
       
   191 {
       
   192     Q_D( RadioEngineWrapper );
       
   193     d->mEngineHandler->SetMuted( !d->mEngineHandler->IsMuted() );
       
   194 }
       
   195 
       
   196 /*!
       
   197  *
       
   198  */
       
   199 void RadioEngineWrapper::toggleAudioRoute()
       
   200 {
       
   201     Q_D( RadioEngineWrapper );
       
   202     d->mUseLoudspeaker = !d->mUseLoudspeaker;
       
   203     d->mEngineHandler->SetAudioRouteToLoudspeaker( d->mUseLoudspeaker );
       
   204 }
       
   205 
       
   206 /*!
       
   207  *
       
   208  */
       
   209 void RadioEngineWrapper::startSeeking( Seeking::Direction direction )
       
   210 {
       
   211     Q_D( RadioEngineWrapper );
       
   212     d->startSeeking( direction );
       
   213 }
       
   214 
       
   215 /*!
       
   216  *
       
   217  */
       
   218 void RadioEngineWrapper::scanFrequencyBand()
       
   219 {
       
   220     Q_D( RadioEngineWrapper );
       
   221     if ( !d->mFrequencyScanningHandler ) {
       
   222         d->mFrequencyScanningHandler.reset( new RadioFrequencyScanningHandler( *d ) );
       
   223     }
       
   224     d->mFrequencyScanningHandler->startScanning( d->mEngineHandler->IsMuted() );
       
   225 }
       
   226 
       
   227 /*!
       
   228  *
       
   229  */
       
   230 void RadioEngineWrapper::cancelScanFrequencyBand()
       
   231 {
       
   232     Q_D( RadioEngineWrapper );
       
   233     d->mFrequencyScanningHandler->cancel();
       
   234     d->frequencyScannerFinished();
       
   235 }