24
|
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 "radioscannerengine_p.h"
|
|
20 |
#include "radioscannerengine.h"
|
|
21 |
#include "radiouiengine_p.h"
|
|
22 |
#include "radiouiengine.h"
|
|
23 |
#include "radiostationhandlerif.h"
|
|
24 |
#include "radioenginewrapper.h"
|
|
25 |
#include "radiostation.h"
|
|
26 |
#include "radiostationmodel.h"
|
|
27 |
|
|
28 |
/*!
|
|
29 |
*
|
|
30 |
* @param scanner
|
|
31 |
* @param uiEngine
|
|
32 |
*/
|
|
33 |
RadioScannerEnginePrivate::RadioScannerEnginePrivate( RadioScannerEngine* scanner, RadioUiEnginePrivate& uiEngine ) :
|
|
34 |
q_ptr( scanner ),
|
|
35 |
mUiEngine( uiEngine ),
|
|
36 |
mLastFoundFrequency( 0 ),
|
|
37 |
mMutedByScanner( false ),
|
|
38 |
mIsScanning( false )
|
|
39 |
{
|
|
40 |
mUiEngine.wrapper().addObserver( this );
|
|
41 |
}
|
|
42 |
|
|
43 |
/*!
|
|
44 |
*
|
|
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 |
if ( !mIsScanning ) {
|
|
57 |
return;
|
|
58 |
}
|
|
59 |
|
|
60 |
Q_Q( RadioScannerEngine );
|
|
61 |
if ( reason == TuneReason::StationScanInitialization ) {
|
|
62 |
mUiEngine.wrapper().startSeeking( Seeking::Up, TuneReason::StationScan );
|
|
63 |
} else if ( reason == TuneReason::StationScan ) {
|
|
64 |
if ( frequency > mLastFoundFrequency ) {
|
|
65 |
// Station has been found normally
|
|
66 |
mLastFoundFrequency = frequency;
|
|
67 |
addFrequencyAndReport( frequency );
|
|
68 |
} else if ( frequency == mUiEngine.api().minFrequency() ) {
|
|
69 |
// Special case. A station has been found in the mininmum frequency
|
|
70 |
addFrequencyAndReport( frequency );
|
|
71 |
} else {
|
|
72 |
// Seeking looped around the frequency band. Send invalid station as indicator that the scanning should stop
|
|
73 |
q->emitStationFound( RadioStation() );
|
|
74 |
}
|
|
75 |
}
|
|
76 |
}
|
|
77 |
|
|
78 |
/*!
|
|
79 |
*
|
|
80 |
*/
|
|
81 |
void RadioScannerEnginePrivate::addFrequencyAndReport( const uint frequency )
|
|
82 |
{
|
|
83 |
RadioStationModel& stationModel = mUiEngine.api().stationModel();
|
|
84 |
stationModel.stationHandlerIf().addScannedFrequency( frequency );
|
|
85 |
RadioStation station;
|
|
86 |
stationModel.findFrequency( frequency, station );
|
|
87 |
Q_Q( RadioScannerEngine );
|
|
88 |
q->emitStationFound( station );
|
|
89 |
}
|
|
90 |
|