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"
|
|
26 |
#include "cradioenginehandler.h"
|
|
27 |
#include "radiostationhandlerif.h"
|
|
28 |
#include "cradiopubsub.h"
|
|
29 |
#include "radiocontroleventlistener.h"
|
|
30 |
#include "radiordslistener.h"
|
|
31 |
#include "cradiorepositorymanager.h"
|
|
32 |
#include "radioenginewrapperobserver.h"
|
|
33 |
|
|
34 |
// Constants
|
|
35 |
|
|
36 |
/*!
|
|
37 |
*
|
|
38 |
*/
|
|
39 |
RadioEngineWrapperPrivate::RadioEngineWrapperPrivate( RadioEngineWrapper* wrapper,
|
|
40 |
RadioStationHandlerIf& stationHandler ) :
|
|
41 |
q_ptr( wrapper ),
|
|
42 |
mStationHandler( stationHandler ),
|
|
43 |
mEngineHandler( new CRadioEngineHandler( *this ) ),
|
|
44 |
mControlEventListener( new RadioControlEventListener( *this ) ),
|
|
45 |
mRdsListener ( new RadioRdsListener( mStationHandler, *this ) ),
|
|
46 |
mTuneReason( 0 ),
|
|
47 |
mUseLoudspeaker( false )
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
/*!
|
|
52 |
*
|
|
53 |
*/
|
|
54 |
RadioEngineWrapperPrivate::~RadioEngineWrapperPrivate()
|
|
55 |
{
|
|
56 |
// Destructor needs to be defined because some member variables that are forward declared
|
|
57 |
// in the header are managed by QT's smart pointers and they require that the owning class
|
|
58 |
// has a non-inlined destructor. Compiler generates an inlined destructor if it isn't defined.
|
|
59 |
}
|
|
60 |
|
|
61 |
/*!
|
|
62 |
* Initializes the private implementation
|
|
63 |
*/
|
|
64 |
void RadioEngineWrapperPrivate::init()
|
|
65 |
{
|
|
66 |
TRAPD( err, mEngineHandler->ConstructL() );
|
|
67 |
if ( err != KErrNone ) {
|
|
68 |
LOG_FORMAT( "RadioEngineWrapperPrivate::init, EngineHandler construct failed: %d", err );
|
|
69 |
mEngineHandler.reset();
|
|
70 |
return;
|
|
71 |
//TODO: Error handling?
|
|
72 |
}
|
|
73 |
|
|
74 |
mEngineHandler->SetRdsObserver( mRdsListener.data() );
|
|
75 |
mEngineHandler->PubSub().SetControlEventObserver( mControlEventListener.data() );
|
|
76 |
mControlEventListener->init();
|
|
77 |
|
|
78 |
// Start observing profile changes
|
|
79 |
mEngineHandler->Repository().AddEntityL( KCRUidProfileEngine,
|
|
80 |
KProEngActiveProfile,
|
|
81 |
CRadioRepositoryManager::ERadioEntityInt );
|
|
82 |
|
|
83 |
mUseLoudspeaker = mEngineHandler->IsAudioRoutedToLoudspeaker();
|
|
84 |
if ( !mUseLoudspeaker ) {
|
|
85 |
RUN_NOTIFY_LOOP( mObservers, audioRouteChanged( false ) );
|
|
86 |
}
|
|
87 |
}
|
|
88 |
|
|
89 |
/*!
|
|
90 |
* Starts up the radio engine
|
|
91 |
*/
|
|
92 |
bool RadioEngineWrapperPrivate::isEngineConstructed()
|
|
93 |
{
|
|
94 |
return mEngineHandler != 0;
|
|
95 |
}
|
|
96 |
|
|
97 |
/*!
|
|
98 |
* Returns the settings handler owned by the engine
|
|
99 |
*/
|
|
100 |
RadioSettingsIf& RadioEngineWrapperPrivate::settings()
|
|
101 |
{
|
|
102 |
if ( !mSettings ) {
|
|
103 |
mSettings.reset( new RadioSettings() );
|
|
104 |
mSettings->d_func()->init( &mEngineHandler->ApplicationSettings() );
|
|
105 |
}
|
|
106 |
return *mSettings;
|
|
107 |
}
|
|
108 |
|
|
109 |
/*!
|
|
110 |
* Returns the enginehandler owned by the engine
|
|
111 |
*/
|
|
112 |
CRadioEngineHandler& RadioEngineWrapperPrivate::RadioEnginehandler()
|
|
113 |
{
|
|
114 |
return *mEngineHandler;
|
|
115 |
}
|
|
116 |
|
|
117 |
/*!
|
|
118 |
* Tunes to the given frequency
|
|
119 |
*/
|
|
120 |
void RadioEngineWrapperPrivate::tuneFrequency( uint frequency, const int reason )
|
|
121 |
{
|
|
122 |
if ( mEngineHandler->TunedFrequency() != frequency ) {
|
|
123 |
mTuneReason = reason;
|
|
124 |
mEngineHandler->Tune( frequency );
|
|
125 |
}
|
|
126 |
}
|
|
127 |
|
|
128 |
/*!
|
|
129 |
* Tunes to the given frequency after a delay
|
|
130 |
*/
|
|
131 |
void RadioEngineWrapperPrivate::tuneWithDelay( uint frequency, const int reason )
|
|
132 |
{
|
|
133 |
if ( mEngineHandler->TunedFrequency() != frequency ) {
|
|
134 |
mTuneReason = reason;
|
|
135 |
mEngineHandler->TuneWithDelay( frequency );
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
/*!
|
|
140 |
*
|
|
141 |
*/
|
|
142 |
ObserverList& RadioEngineWrapperPrivate::observers()
|
|
143 |
{
|
|
144 |
return mObservers;
|
|
145 |
}
|
|
146 |
|
|
147 |
/*!
|
|
148 |
*
|
|
149 |
*/
|
|
150 |
void RadioEngineWrapperPrivate::startSeeking( Seeking::Direction direction, const int reason )
|
|
151 |
{
|
|
152 |
mTuneReason = reason;
|
|
153 |
mEngineHandler->Seek( direction );
|
|
154 |
}
|
|
155 |
|
|
156 |
/*!
|
|
157 |
* \reimp
|
|
158 |
*/
|
|
159 |
void RadioEngineWrapperPrivate::PowerEventL( TBool aPowerState, TInt DEBUGVAR( aError ) )
|
|
160 |
{
|
|
161 |
LOG_FORMAT( "RadioEngineWrapperPrivate::PowerEventL, PowerState: %d, Error: %d", aPowerState, aError );
|
|
162 |
RUN_NOTIFY_LOOP( mObservers, radioStatusChanged( aPowerState ) );
|
|
163 |
}
|
|
164 |
|
|
165 |
/*!
|
|
166 |
* \reimp
|
|
167 |
*/
|
|
168 |
void RadioEngineWrapperPrivate::FrequencyEventL( TUint32 aFrequency,
|
|
169 |
RadioEngine::TRadioFrequencyEventReason aReason,
|
|
170 |
TInt aError )
|
|
171 |
{
|
|
172 |
Q_UNUSED( aReason );
|
|
173 |
LOG_FORMAT( "RadioEngineWrapperPrivate::FrequencyEventL - Frequency: %d, Reason: %d, Error: %d", aFrequency, aReason, aError );
|
|
174 |
|
|
175 |
if ( !aError ) {
|
|
176 |
const uint frequency = static_cast<uint>( aFrequency );
|
|
177 |
RUN_NOTIFY_LOOP( mObservers, tunedToFrequency( frequency, mTuneReason ) );
|
|
178 |
}
|
|
179 |
}
|
|
180 |
|
|
181 |
/*!
|
|
182 |
* \reimp
|
|
183 |
*/
|
|
184 |
void RadioEngineWrapperPrivate::VolumeEventL( TInt aVolume, TInt aError )
|
|
185 |
{
|
|
186 |
Q_UNUSED( aError );
|
|
187 |
RUN_NOTIFY_LOOP( mObservers, volumeChanged( aVolume ) );
|
|
188 |
}
|
|
189 |
|
|
190 |
/*!
|
|
191 |
* \reimp
|
|
192 |
*/
|
|
193 |
void RadioEngineWrapperPrivate::MuteEventL( TBool aMuteState, TInt aError )
|
|
194 |
{
|
|
195 |
Q_UNUSED( aError );
|
|
196 |
RUN_NOTIFY_LOOP( mObservers, muteChanged( aMuteState ) );
|
|
197 |
}
|
|
198 |
|
|
199 |
/*!
|
|
200 |
* \reimp
|
|
201 |
*/
|
|
202 |
void RadioEngineWrapperPrivate::AudioModeEventL( TInt DEBUGVAR( aAudioMode ), TInt DEBUGVAR( aError ) )
|
|
203 |
{
|
|
204 |
LOG_FORMAT( "RadioEngineWrapperPrivate::AudioModeEventL, AudioMode: %d, Error: %d", aAudioMode, aError );
|
|
205 |
}
|
|
206 |
|
|
207 |
/*!
|
|
208 |
* \reimp
|
|
209 |
*/
|
|
210 |
void RadioEngineWrapperPrivate::AntennaEventL( TBool aAntennaAttached, TInt aError )
|
|
211 |
{
|
|
212 |
Q_UNUSED( aError );
|
|
213 |
RUN_NOTIFY_LOOP( mObservers, antennaStatusChanged( aAntennaAttached ) );
|
|
214 |
}
|
|
215 |
|
|
216 |
/*!
|
|
217 |
* \reimp
|
|
218 |
*/
|
|
219 |
void RadioEngineWrapperPrivate::AudioRoutingEventL( TInt aAudioDestination, TInt aError )
|
|
220 |
{
|
|
221 |
Q_UNUSED( aAudioDestination )
|
|
222 |
Q_UNUSED( aError )
|
|
223 |
}
|
|
224 |
|
|
225 |
/*!
|
|
226 |
* \reimp
|
|
227 |
*/
|
|
228 |
void RadioEngineWrapperPrivate::SeekingEventL( TInt aSeekingState, TInt aError )
|
|
229 |
{
|
|
230 |
Q_UNUSED( aSeekingState );
|
|
231 |
Q_UNUSED( aError );
|
|
232 |
}
|
|
233 |
|
|
234 |
/*!
|
|
235 |
* \reimp
|
|
236 |
*/
|
|
237 |
void RadioEngineWrapperPrivate::RegionEventL( TInt DEBUGVAR( aRegion ), TInt DEBUGVAR( aError ) )
|
|
238 |
{
|
|
239 |
LOG_FORMAT( "RadioEngineWrapperPrivate::RegionEventL, aRegion: %d, Error: %d", aRegion, aError );
|
|
240 |
}
|
|
241 |
|
|
242 |
/*!
|
|
243 |
* \reimp
|
|
244 |
*/
|
|
245 |
void RadioEngineWrapperPrivate::AudioRouteChangedL( RadioEngine::TRadioAudioRoute aRoute )
|
|
246 |
{
|
|
247 |
mUseLoudspeaker = aRoute == RadioEngine::ERadioSpeaker;
|
|
248 |
RUN_NOTIFY_LOOP( mObservers, audioRouteChanged( mUseLoudspeaker ) );
|
|
249 |
}
|
|
250 |
|
|
251 |
/*!
|
|
252 |
* \reimp
|
|
253 |
*/
|
|
254 |
void RadioEngineWrapperPrivate::HandleSystemEventL( TRadioSystemEventType DEBUGVAR( aEventType ) )
|
|
255 |
{
|
|
256 |
LOG_FORMAT( "RadioEngineWrapperPrivate::HandleSystemEventL, Event: %d", aEventType );
|
|
257 |
// ERadioHeadsetConnected, ///< Headset was connected
|
|
258 |
// ERadioHeadsetDisconnected, ///< Headset was disconnected
|
|
259 |
// ERadioNetworkCoverageUp, ///< Network coverage detected
|
|
260 |
// ERadioNetworkCoverageDown, ///< Network coverage lost
|
|
261 |
// ERadioCallActivated, ///< Call activated or ringing
|
|
262 |
// ERadioCallDeactivated, ///< Call disconnected
|
|
263 |
// ERadioEmergencyCallActivated, ///< Call activated or ringing
|
|
264 |
// ERadioEmergencyCallDeactivated, ///< Call disconnected
|
|
265 |
// ERadioLowDiskSpace, ///< Low disk space
|
|
266 |
// ERadioAudioRoutingHeadset, ///< Audio routed through headset
|
|
267 |
// ERadioAudioRoutingSpeaker, ///< Audio routed through speaker ( IHF )
|
|
268 |
// ERadioAudioResourcesAvailable, ///< Audio resources have become available
|
|
269 |
// ERadioAudioAutoResumeForbidden ///< Audio auto resuming is forbidden
|
|
270 |
}
|
|
271 |
|
|
272 |
/*!
|
|
273 |
* \reimp
|
|
274 |
*/
|
|
275 |
void RadioEngineWrapperPrivate::HandleRepositoryValueChangeL( const TUid& aUid, TUint32 aKey, TInt aValue, TInt aError )
|
|
276 |
{
|
|
277 |
if ( aUid == KCRUidProfileEngine && aKey == KProEngActiveProfile && !aError && aValue == KOfflineProfileId ) {
|
|
278 |
LOG( "RadioEngineWrapperPrivate::HandleRepositoryValueChangeL: Offline profile activated" );
|
|
279 |
}
|
|
280 |
}
|