author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:33:45 +0100 | |
branch | GCC_SURGE |
changeset 37 | 451b2e1545b2 |
parent 19 | afea38384506 |
parent 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 |
// System includes |
|
19 |
||
20 |
// User includes |
|
21 |
#include "radioenginewrapper_p.h" |
|
22 |
#include "radiosettings.h" |
|
23 |
#include "radiosettings_p.h" |
|
24 |
#include "radiologger.h" |
|
25 |
#include "radio_global.h" |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
26 |
#include "radioenginehandler.h" |
24 | 27 |
#include "radiostationhandlerif.h" |
28 |
#include "radiocontroleventlistener.h" |
|
29 |
#include "radiordslistener.h" |
|
30 |
#include "radioenginewrapperobserver.h" |
|
31 |
||
32 |
// Constants |
|
33 |
||
34 |
/*! |
|
35 |
* |
|
36 |
*/ |
|
37 |
RadioEngineWrapperPrivate::RadioEngineWrapperPrivate( RadioEngineWrapper* wrapper, |
|
38 |
RadioStationHandlerIf& stationHandler ) : |
|
39 |
q_ptr( wrapper ), |
|
40 |
mStationHandler( stationHandler ), |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
41 |
mEngineHandler( new RadioEngineHandler( *this ) ), |
24 | 42 |
mControlEventListener( new RadioControlEventListener( *this ) ), |
43 |
mRdsListener ( new RadioRdsListener( mStationHandler, *this ) ), |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
44 |
mTuneReason( TuneReason::Unspecified ), |
24 | 45 |
mUseLoudspeaker( false ) |
46 |
{ |
|
47 |
} |
|
48 |
||
49 |
/*! |
|
50 |
* |
|
51 |
*/ |
|
52 |
RadioEngineWrapperPrivate::~RadioEngineWrapperPrivate() |
|
53 |
{ |
|
54 |
// Destructor needs to be defined because some member variables that are forward declared |
|
55 |
// in the header are managed by QT's smart pointers and they require that the owning class |
|
56 |
// has a non-inlined destructor. Compiler generates an inlined destructor if it isn't defined. |
|
57 |
} |
|
58 |
||
59 |
/*! |
|
60 |
* Initializes the private implementation |
|
61 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
62 |
bool RadioEngineWrapperPrivate::init() |
24 | 63 |
{ |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
64 |
if ( !mEngineHandler->constructEngine() ) { |
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
65 |
LOG( "RadioEngineWrapperPrivate::init, EngineHandler construct failed" ); |
24 | 66 |
mEngineHandler.reset(); |
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
67 |
return false; |
24 | 68 |
} |
69 |
||
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
70 |
mEngineHandler->setRdsObserver( mRdsListener.data() ); |
24 | 71 |
mControlEventListener->init(); |
72 |
||
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
73 |
mUseLoudspeaker = mEngineHandler->isAudioRoutedToLoudspeaker(); |
24 | 74 |
if ( !mUseLoudspeaker ) { |
75 |
RUN_NOTIFY_LOOP( mObservers, audioRouteChanged( false ) ); |
|
76 |
} |
|
77 |
||
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
78 |
return true; |
24 | 79 |
} |
80 |
||
81 |
/*! |
|
82 |
* Returns the settings handler owned by the engine |
|
83 |
*/ |
|
84 |
RadioSettingsIf& RadioEngineWrapperPrivate::settings() |
|
85 |
{ |
|
86 |
if ( !mSettings ) { |
|
87 |
mSettings.reset( new RadioSettings() ); |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
88 |
mSettings->d_func()->init( &mEngineHandler->applicationSettings() ); |
24 | 89 |
} |
90 |
return *mSettings; |
|
91 |
} |
|
92 |
||
93 |
/*! |
|
94 |
* Returns the enginehandler owned by the engine |
|
95 |
*/ |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
96 |
RadioEngineHandler& RadioEngineWrapperPrivate::radioEnginehandler() |
24 | 97 |
{ |
98 |
return *mEngineHandler; |
|
99 |
} |
|
100 |
||
101 |
/*! |
|
102 |
* Tunes to the given frequency |
|
103 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
104 |
void RadioEngineWrapperPrivate::setFrequency( uint frequency, const int reason ) |
24 | 105 |
{ |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
106 |
if ( mEngineHandler->currentFrequency() != frequency ) { |
24 | 107 |
mTuneReason = reason; |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
108 |
mEngineHandler->setFrequency( frequency ); |
24 | 109 |
} |
110 |
} |
|
111 |
||
112 |
/*! |
|
113 |
* |
|
114 |
*/ |
|
115 |
ObserverList& RadioEngineWrapperPrivate::observers() |
|
116 |
{ |
|
117 |
return mObservers; |
|
118 |
} |
|
119 |
||
120 |
/*! |
|
121 |
* |
|
122 |
*/ |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
123 |
void RadioEngineWrapperPrivate::startSeeking( Seek::Direction direction, const int reason ) |
24 | 124 |
{ |
125 |
mTuneReason = reason; |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
126 |
mEngineHandler->seek( direction ); |
24 | 127 |
} |
128 |
||
129 |
/*! |
|
130 |
* \reimp |
|
131 |
*/ |
|
132 |
void RadioEngineWrapperPrivate::PowerEventL( TBool aPowerState, TInt DEBUGVAR( aError ) ) |
|
133 |
{ |
|
134 |
LOG_FORMAT( "RadioEngineWrapperPrivate::PowerEventL, PowerState: %d, Error: %d", aPowerState, aError ); |
|
135 |
RUN_NOTIFY_LOOP( mObservers, radioStatusChanged( aPowerState ) ); |
|
136 |
} |
|
137 |
||
138 |
/*! |
|
139 |
* \reimp |
|
140 |
*/ |
|
141 |
void RadioEngineWrapperPrivate::FrequencyEventL( TUint32 aFrequency, |
|
142 |
RadioEngine::TRadioFrequencyEventReason aReason, |
|
143 |
TInt aError ) |
|
144 |
{ |
|
145 |
Q_UNUSED( aReason ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
146 |
LOG_FORMAT( "RadioEngineWrapperPrivate::FrequencyEventL - Freq: %d, TuneReason: %d, Err: %d", aFrequency, mTuneReason, aError ); |
24 | 147 |
|
148 |
if ( !aError ) { |
|
149 |
const uint frequency = static_cast<uint>( aFrequency ); |
|
150 |
RUN_NOTIFY_LOOP( mObservers, tunedToFrequency( frequency, mTuneReason ) ); |
|
28
075425b8d9a4
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
24
diff
changeset
|
151 |
} else { |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
152 |
RUN_NOTIFY_LOOP( mObservers, tunedToFrequency( mEngineHandler->minFrequency(), TuneReason::StationScanNoStationsFound ) ); // no frequencies found |
24 | 153 |
} |
154 |
} |
|
155 |
||
156 |
/*! |
|
157 |
* \reimp |
|
158 |
*/ |
|
159 |
void RadioEngineWrapperPrivate::VolumeEventL( TInt aVolume, TInt aError ) |
|
160 |
{ |
|
161 |
Q_UNUSED( aError ); |
|
162 |
RUN_NOTIFY_LOOP( mObservers, volumeChanged( aVolume ) ); |
|
163 |
} |
|
164 |
||
165 |
/*! |
|
166 |
* \reimp |
|
167 |
*/ |
|
168 |
void RadioEngineWrapperPrivate::MuteEventL( TBool aMuteState, TInt aError ) |
|
169 |
{ |
|
170 |
Q_UNUSED( aError ); |
|
171 |
RUN_NOTIFY_LOOP( mObservers, muteChanged( aMuteState ) ); |
|
172 |
} |
|
173 |
||
174 |
/*! |
|
175 |
* \reimp |
|
176 |
*/ |
|
177 |
void RadioEngineWrapperPrivate::AudioModeEventL( TInt DEBUGVAR( aAudioMode ), TInt DEBUGVAR( aError ) ) |
|
178 |
{ |
|
179 |
LOG_FORMAT( "RadioEngineWrapperPrivate::AudioModeEventL, AudioMode: %d, Error: %d", aAudioMode, aError ); |
|
180 |
} |
|
181 |
||
182 |
/*! |
|
183 |
* \reimp |
|
184 |
*/ |
|
185 |
void RadioEngineWrapperPrivate::AntennaEventL( TBool aAntennaAttached, TInt aError ) |
|
186 |
{ |
|
187 |
Q_UNUSED( aError ); |
|
188 |
RUN_NOTIFY_LOOP( mObservers, antennaStatusChanged( aAntennaAttached ) ); |
|
189 |
} |
|
190 |
||
191 |
/*! |
|
192 |
* \reimp |
|
193 |
*/ |
|
194 |
void RadioEngineWrapperPrivate::AudioRoutingEventL( TInt aAudioDestination, TInt aError ) |
|
195 |
{ |
|
196 |
Q_UNUSED( aAudioDestination ) |
|
197 |
Q_UNUSED( aError ) |
|
198 |
} |
|
199 |
||
200 |
/*! |
|
201 |
* \reimp |
|
202 |
*/ |
|
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
203 |
void RadioEngineWrapperPrivate::SeekingEventL( TInt DEBUGVAR( aSeekingState ), TInt DEBUGVAR( aError ) ) |
24 | 204 |
{ |
32
189d20c34778
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
205 |
LOG_FORMAT( "RadioEngineWrapperPrivate::SeekingEventL, aSeekingState: %d, Error: %d", aSeekingState, aError ); |
24 | 206 |
} |
207 |
||
208 |
/*! |
|
209 |
* \reimp |
|
210 |
*/ |
|
211 |
void RadioEngineWrapperPrivate::RegionEventL( TInt DEBUGVAR( aRegion ), TInt DEBUGVAR( aError ) ) |
|
212 |
{ |
|
213 |
LOG_FORMAT( "RadioEngineWrapperPrivate::RegionEventL, aRegion: %d, Error: %d", aRegion, aError ); |
|
214 |
} |
|
215 |
||
216 |
/*! |
|
217 |
* \reimp |
|
218 |
*/ |
|
219 |
void RadioEngineWrapperPrivate::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute ) |
|
220 |
{ |
|
221 |
mUseLoudspeaker = aRoute == RadioEngine::ERadioSpeaker; |
|
222 |
RUN_NOTIFY_LOOP( mObservers, audioRouteChanged( mUseLoudspeaker ) ); |
|
223 |
} |
|
224 |
||
225 |
/*! |
|
226 |
* \reimp |
|
227 |
*/ |
|
228 |
void RadioEngineWrapperPrivate::HandleSystemEventL( TRadioSystemEventType DEBUGVAR( aEventType ) ) |
|
229 |
{ |
|
230 |
LOG_FORMAT( "RadioEngineWrapperPrivate::HandleSystemEventL, Event: %d", aEventType ); |
|
231 |
// ERadioHeadsetConnected, ///< Headset was connected |
|
232 |
// ERadioHeadsetDisconnected, ///< Headset was disconnected |
|
233 |
// ERadioNetworkCoverageUp, ///< Network coverage detected |
|
234 |
// ERadioNetworkCoverageDown, ///< Network coverage lost |
|
235 |
// ERadioCallActivated, ///< Call activated or ringing |
|
236 |
// ERadioCallDeactivated, ///< Call disconnected |
|
237 |
// ERadioEmergencyCallActivated, ///< Call activated or ringing |
|
238 |
// ERadioEmergencyCallDeactivated, ///< Call disconnected |
|
239 |
// ERadioLowDiskSpace, ///< Low disk space |
|
240 |
// ERadioAudioRoutingHeadset, ///< Audio routed through headset |
|
241 |
// ERadioAudioRoutingSpeaker, ///< Audio routed through speaker ( IHF ) |
|
242 |
// ERadioAudioResourcesAvailable, ///< Audio resources have become available |
|
243 |
// ERadioAudioAutoResumeForbidden ///< Audio auto resuming is forbidden |
|
244 |
} |