author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 11 Jun 2010 13:38:32 +0300 | |
changeset 28 | 075425b8d9a4 |
parent 24 | 6df133bd92e1 |
child 32 | 189d20c34778 |
permissions | -rw-r--r-- |
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 ) { |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
62 |
mUiEngine.wrapper().startSeeking( Seek::Up, TuneReason::StationScan ); |
24 | 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 |
} |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
75 |
} else { |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
76 |
q->emitStationFound( RadioStation() ); |
24 | 77 |
} |
78 |
} |
|
79 |
||
80 |
/*! |
|
81 |
* |
|
82 |
*/ |
|
83 |
void RadioScannerEnginePrivate::addFrequencyAndReport( const uint frequency ) |
|
84 |
{ |
|
85 |
RadioStationModel& stationModel = mUiEngine.api().stationModel(); |
|
86 |
stationModel.stationHandlerIf().addScannedFrequency( frequency ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
87 |
|
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
88 |
// Return value of findFrequency() is intentionally ignored. The station was just added |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
89 |
// to the model in the previous line so it should be found and if it isn't then an |
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
90 |
// empty station is sent with the signal and scanner will stop the scanning process. |
24 | 91 |
RadioStation station; |
92 |
stationModel.findFrequency( frequency, station ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
93 |
|
24 | 94 |
Q_Q( RadioScannerEngine ); |
95 |
q->emitStationFound( station ); |
|
96 |
} |
|
97 |