radioapp/radiouiengine/src/radioscannerengine_p.cpp
changeset 16 f54ebcfc1b80
child 19 afea38384506
equal deleted inserted replaced
14:63aabac4416d 16:f54ebcfc1b80
       
     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 #include "radioscannerengine_p.h"
       
    19 #include "radioscannerengine.h"
       
    20 #include "radiouiengine_p.h"
       
    21 #include "radiouiengine.h"
       
    22 #include "radiostationhandlerif.h"
       
    23 #include "radioenginewrapper.h"
       
    24 #include "radiostation.h"
       
    25 #include "radiostationmodel.h"
       
    26 
       
    27 /*!
       
    28  *
       
    29  * @param scanner
       
    30  * @param uiEngine
       
    31  * @return
       
    32  */
       
    33 RadioScannerEnginePrivate::RadioScannerEnginePrivate( RadioScannerEngine* scanner, RadioUiEnginePrivate& uiEngine ) :
       
    34     q_ptr( scanner ),
       
    35     mUiEngine( uiEngine ),
       
    36     mLastFoundFrequency( 0 ),
       
    37     mMutedByScanner( false )
       
    38 {
       
    39     mUiEngine.wrapper().addObserver( this );
       
    40 }
       
    41 
       
    42 /*!
       
    43  *
       
    44  * @return
       
    45  */
       
    46 RadioScannerEnginePrivate::~RadioScannerEnginePrivate()
       
    47 {
       
    48     mUiEngine.wrapper().removeObserver( this );
       
    49 }
       
    50 
       
    51 /*!
       
    52  * \reimp
       
    53  */
       
    54 void RadioScannerEnginePrivate::tunedToFrequency( uint frequency, int reason )
       
    55 {
       
    56     Q_Q( RadioScannerEngine );
       
    57     if ( reason == TuneReason::StationScanInitialization ) {
       
    58         mUiEngine.wrapper().startSeeking( Seeking::Up, TuneReason::StationScan );
       
    59     } else if ( reason == TuneReason::StationScan ) {
       
    60         if ( frequency > mLastFoundFrequency ) {
       
    61             // Station has been found normally
       
    62             mLastFoundFrequency = frequency;
       
    63             addFrequencyAndReport( frequency );
       
    64         } else if ( frequency == mUiEngine.api().minFrequency() ) {
       
    65             // Special case. A station has been found in the mininmum frequency
       
    66             addFrequencyAndReport( frequency );
       
    67         } else {
       
    68             // Seeking looped around the frequency band. Send invalid station as indicator that the scanning should stop
       
    69             q->emitStationFound( RadioStation() );
       
    70         }
       
    71     }
       
    72 
       
    73 }
       
    74 
       
    75 /*!
       
    76  *
       
    77  */
       
    78 void RadioScannerEnginePrivate::addFrequencyAndReport( const uint frequency )
       
    79 {
       
    80     mUiEngine.api().model().stationHandlerIf().addScannedFrequency( frequency );
       
    81     RadioStation station;
       
    82     mUiEngine.api().model().findFrequency( frequency, station );
       
    83     Q_Q( RadioScannerEngine );
       
    84     q->emitStationFound( station );
       
    85 }
       
    86