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 "radioenginewrapper.h" |
|
20 #include "radioenginewrapper_p.h" |
|
21 #include "cradioenginehandler.h" |
|
22 |
|
23 /*! |
|
24 * Constructor |
|
25 */ |
|
26 RadioEngineWrapper::RadioEngineWrapper( RadioStationHandlerIf& stationHandler ) : |
|
27 d_ptr( new RadioEngineWrapperPrivate( this, stationHandler ) ) |
|
28 { |
|
29 Q_D( RadioEngineWrapper ); |
|
30 d->init(); |
|
31 } |
|
32 |
|
33 /*! |
|
34 * Destructor |
|
35 */ |
|
36 RadioEngineWrapper::~RadioEngineWrapper() |
|
37 { |
|
38 delete d_ptr; |
|
39 } |
|
40 |
|
41 /*! |
|
42 * |
|
43 */ |
|
44 void RadioEngineWrapper::addObserver( RadioEngineWrapperObserver* observer ) |
|
45 { |
|
46 Q_D( RadioEngineWrapper ); |
|
47 d->mObservers.append( observer ); |
|
48 } |
|
49 |
|
50 /*! |
|
51 * |
|
52 */ |
|
53 void RadioEngineWrapper::removeObserver( RadioEngineWrapperObserver* observer ) |
|
54 { |
|
55 Q_D( RadioEngineWrapper ); |
|
56 d->mObservers.removeAll( observer ); |
|
57 } |
|
58 |
|
59 /*! |
|
60 * Checks if the radio engine has been constructed properly |
|
61 */ |
|
62 bool RadioEngineWrapper::isEngineConstructed() |
|
63 { |
|
64 Q_D( RadioEngineWrapper ); |
|
65 return d->isEngineConstructed(); |
|
66 } |
|
67 |
|
68 /*! |
|
69 * Returns the settings handler owned by the engine |
|
70 */ |
|
71 RadioSettingsIf& RadioEngineWrapper::settings() |
|
72 { |
|
73 Q_D( RadioEngineWrapper ); |
|
74 return d->settings(); |
|
75 } |
|
76 |
|
77 /*! |
|
78 * Returns the selected radio region |
|
79 */ |
|
80 RadioRegion::Region RadioEngineWrapper::region() const |
|
81 { |
|
82 Q_D( const RadioEngineWrapper ); |
|
83 return d->mEngineHandler->Region(); |
|
84 } |
|
85 |
|
86 /*! |
|
87 * Returns the minimum frequency |
|
88 */ |
|
89 uint RadioEngineWrapper::minFrequency() const |
|
90 { |
|
91 Q_D( const RadioEngineWrapper ); |
|
92 return d->mEngineHandler->MinFrequency(); |
|
93 } |
|
94 |
|
95 /*! |
|
96 * Returns the maximum frequency |
|
97 */ |
|
98 uint RadioEngineWrapper::maxFrequency() const |
|
99 { |
|
100 Q_D( const RadioEngineWrapper ); |
|
101 return d->mEngineHandler->MaxFrequency(); |
|
102 } |
|
103 |
|
104 /*! |
|
105 * Returns the frequency step size from the selected region |
|
106 */ |
|
107 uint RadioEngineWrapper::frequencyStepSize() const |
|
108 { |
|
109 Q_D( const RadioEngineWrapper ); |
|
110 return d->mEngineHandler->FrequencyStepSize(); |
|
111 } |
|
112 |
|
113 /*! |
|
114 * Returns the frequency step size from the selected region |
|
115 */ |
|
116 bool RadioEngineWrapper::isFrequencyValid( uint frequency ) |
|
117 { |
|
118 Q_D( const RadioEngineWrapper ); |
|
119 return d->mEngineHandler->IsFrequencyValid( frequency ); |
|
120 } |
|
121 |
|
122 /*! |
|
123 * Checks if the radio engine is on |
|
124 */ |
|
125 bool RadioEngineWrapper::isRadioOn() const |
|
126 { |
|
127 Q_D( const RadioEngineWrapper ); |
|
128 return d->mEngineHandler->IsRadioOn(); |
|
129 } |
|
130 |
|
131 /*! |
|
132 * Returns the currently tuned frequency |
|
133 */ |
|
134 uint RadioEngineWrapper::currentFrequency() const |
|
135 { |
|
136 Q_D( const RadioEngineWrapper ); |
|
137 return d->mEngineHandler->TunedFrequency(); |
|
138 } |
|
139 |
|
140 /*! |
|
141 * Returns the mute status |
|
142 */ |
|
143 bool RadioEngineWrapper::isMuted() const |
|
144 { |
|
145 Q_D( const RadioEngineWrapper ); |
|
146 return d->mEngineHandler->IsMuted(); |
|
147 } |
|
148 |
|
149 /*! |
|
150 * Returns the antenna connection status |
|
151 */ |
|
152 bool RadioEngineWrapper::isAntennaAttached() const |
|
153 { |
|
154 Q_D( const RadioEngineWrapper ); |
|
155 return d->mEngineHandler->IsAntennaAttached(); |
|
156 } |
|
157 |
|
158 /*! |
|
159 * Returns the "use loudspeaker" status |
|
160 */ |
|
161 bool RadioEngineWrapper::isUsingLoudspeaker() const |
|
162 { |
|
163 Q_D( const RadioEngineWrapper ); |
|
164 return d->mUseLoudspeaker; |
|
165 } |
|
166 |
|
167 /*! |
|
168 * Tunes to the given frequency |
|
169 */ |
|
170 void RadioEngineWrapper::tuneFrequency( uint frequency, const int reason ) |
|
171 { |
|
172 Q_D( RadioEngineWrapper ); |
|
173 d->tuneFrequency( frequency, reason ); |
|
174 } |
|
175 |
|
176 /*! |
|
177 * Tunes to the given frequency after a delay |
|
178 */ |
|
179 void RadioEngineWrapper::tuneWithDelay( uint frequency, const int reason ) |
|
180 { |
|
181 Q_D( RadioEngineWrapper ); |
|
182 d->tuneWithDelay( frequency, reason ); |
|
183 } |
|
184 |
|
185 /*! |
|
186 * volume update command for the engine |
|
187 */ |
|
188 void RadioEngineWrapper::setVolume( int volume ) |
|
189 { |
|
190 Q_D( RadioEngineWrapper ); |
|
191 d->mEngineHandler->SetVolume( volume ); |
|
192 } |
|
193 |
|
194 /*! |
|
195 * |
|
196 */ |
|
197 void RadioEngineWrapper::setMute( bool muted ) |
|
198 { |
|
199 Q_D( RadioEngineWrapper ); |
|
200 d->mEngineHandler->SetMuted( muted ); |
|
201 } |
|
202 |
|
203 /*! |
|
204 * |
|
205 */ |
|
206 void RadioEngineWrapper::toggleAudioRoute() |
|
207 { |
|
208 Q_D( RadioEngineWrapper ); |
|
209 d->mUseLoudspeaker = !d->mUseLoudspeaker; |
|
210 d->mEngineHandler->SetAudioRouteToLoudspeaker( d->mUseLoudspeaker ); |
|
211 } |
|
212 |
|
213 /*! |
|
214 * |
|
215 */ |
|
216 void RadioEngineWrapper::startSeeking( Seeking::Direction direction, const int reason ) |
|
217 { |
|
218 Q_D( RadioEngineWrapper ); |
|
219 d->startSeeking( direction, reason ); |
|
220 } |
|
221 |
|
222 /*! |
|
223 * |
|
224 */ |
|
225 void RadioEngineWrapper::cancelSeeking() |
|
226 { |
|
227 Q_D( RadioEngineWrapper ); |
|
228 d->mEngineHandler->CancelSeek(); |
|
229 } |
|