15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // User includes |
18 // User includes |
19 #include "radioenginewrapper.h" |
19 #include "radioenginewrapper.h" |
|
20 #include "radioenginewrapperobserver.h" |
20 #include "radioenginewrapper_p.h" |
21 #include "radioenginewrapper_p.h" |
21 #include "cradioenginehandler.h" |
22 #include "radioenginehandler.h" |
22 |
23 |
23 /*! |
24 /*! |
24 * Constructor |
25 * Constructor |
25 */ |
26 */ |
26 RadioEngineWrapper::RadioEngineWrapper( RadioStationHandlerIf& stationHandler ) : |
27 RadioEngineWrapper::RadioEngineWrapper( RadioStationHandlerIf& stationHandler ) : |
27 d_ptr( new RadioEngineWrapperPrivate( this, stationHandler ) ) |
28 d_ptr( new RadioEngineWrapperPrivate( this, stationHandler ) ) |
28 { |
29 { |
29 Q_D( RadioEngineWrapper ); |
|
30 d->init(); |
|
31 } |
30 } |
32 |
31 |
33 /*! |
32 /*! |
34 * Destructor |
33 * Destructor |
35 */ |
34 */ |
36 RadioEngineWrapper::~RadioEngineWrapper() |
35 RadioEngineWrapper::~RadioEngineWrapper() |
37 { |
36 { |
38 delete d_ptr; |
37 } |
|
38 |
|
39 /*! |
|
40 * |
|
41 */ |
|
42 bool RadioEngineWrapper::init() |
|
43 { |
|
44 Q_D( RadioEngineWrapper ); |
|
45 return d->init(); |
39 } |
46 } |
40 |
47 |
41 /*! |
48 /*! |
42 * |
49 * |
43 */ |
50 */ |
78 * Returns the selected radio region |
76 * Returns the selected radio region |
79 */ |
77 */ |
80 RadioRegion::Region RadioEngineWrapper::region() const |
78 RadioRegion::Region RadioEngineWrapper::region() const |
81 { |
79 { |
82 Q_D( const RadioEngineWrapper ); |
80 Q_D( const RadioEngineWrapper ); |
83 return d->mEngineHandler->Region(); |
81 return d->mEngineHandler->region(); |
84 } |
82 } |
85 |
83 |
86 /*! |
84 /*! |
87 * Returns the minimum frequency |
85 * Returns the minimum frequency |
88 */ |
86 */ |
89 uint RadioEngineWrapper::minFrequency() const |
87 uint RadioEngineWrapper::minFrequency() const |
90 { |
88 { |
91 Q_D( const RadioEngineWrapper ); |
89 Q_D( const RadioEngineWrapper ); |
92 return d->mEngineHandler->MinFrequency(); |
90 return d->mEngineHandler->minFrequency(); |
93 } |
91 } |
94 |
92 |
95 /*! |
93 /*! |
96 * Returns the maximum frequency |
94 * Returns the maximum frequency |
97 */ |
95 */ |
98 uint RadioEngineWrapper::maxFrequency() const |
96 uint RadioEngineWrapper::maxFrequency() const |
99 { |
97 { |
100 Q_D( const RadioEngineWrapper ); |
98 Q_D( const RadioEngineWrapper ); |
101 return d->mEngineHandler->MaxFrequency(); |
99 return d->mEngineHandler->maxFrequency(); |
102 } |
100 } |
103 |
101 |
104 /*! |
102 /*! |
105 * Returns the frequency step size from the selected region |
103 * Returns the frequency step size from the selected region |
106 */ |
104 */ |
107 uint RadioEngineWrapper::frequencyStepSize() const |
105 uint RadioEngineWrapper::frequencyStepSize() const |
108 { |
106 { |
109 Q_D( const RadioEngineWrapper ); |
107 Q_D( const RadioEngineWrapper ); |
110 return d->mEngineHandler->FrequencyStepSize(); |
108 return d->mEngineHandler->frequencyStepSize(); |
111 } |
109 } |
112 |
110 |
113 /*! |
111 /*! |
114 * Returns the frequency step size from the selected region |
112 * Returns true if frequency is valid, otherwise false |
115 */ |
113 */ |
116 bool RadioEngineWrapper::isFrequencyValid( uint frequency ) |
114 bool RadioEngineWrapper::isFrequencyValid( uint frequency ) const |
117 { |
115 { |
118 Q_D( const RadioEngineWrapper ); |
116 return frequency >= minFrequency() && frequency <= maxFrequency(); |
119 return d->mEngineHandler->IsFrequencyValid( frequency ); |
|
120 } |
117 } |
121 |
118 |
122 /*! |
119 /*! |
123 * Checks if the radio engine is on |
120 * Checks if the radio engine is on |
124 */ |
121 */ |
125 bool RadioEngineWrapper::isRadioOn() const |
122 bool RadioEngineWrapper::isRadioOn() const |
126 { |
123 { |
127 Q_D( const RadioEngineWrapper ); |
124 Q_D( const RadioEngineWrapper ); |
128 return d->mEngineHandler->IsRadioOn(); |
125 return d->mEngineHandler->isRadioOn(); |
129 } |
126 } |
130 |
127 |
131 /*! |
128 /*! |
132 * Returns the currently tuned frequency |
129 * Returns the currently tuned frequency |
133 */ |
130 */ |
134 uint RadioEngineWrapper::currentFrequency() const |
131 uint RadioEngineWrapper::currentFrequency() const |
135 { |
132 { |
136 Q_D( const RadioEngineWrapper ); |
133 Q_D( const RadioEngineWrapper ); |
137 return d->mEngineHandler->TunedFrequency(); |
134 return d->mEngineHandler->currentFrequency(); |
138 } |
135 } |
139 |
136 |
140 /*! |
137 /*! |
141 * Returns the mute status |
138 * Returns the mute status |
142 */ |
139 */ |
143 bool RadioEngineWrapper::isMuted() const |
140 bool RadioEngineWrapper::isMuted() const |
144 { |
141 { |
145 Q_D( const RadioEngineWrapper ); |
142 Q_D( const RadioEngineWrapper ); |
146 return d->mEngineHandler->IsMuted(); |
143 return d->mEngineHandler->isMuted(); |
147 } |
144 } |
148 |
145 |
149 /*! |
146 /*! |
150 * Returns the antenna connection status |
147 * Returns the antenna connection status |
151 */ |
148 */ |
152 bool RadioEngineWrapper::isAntennaAttached() const |
149 bool RadioEngineWrapper::isAntennaAttached() const |
153 { |
150 { |
154 Q_D( const RadioEngineWrapper ); |
151 Q_D( const RadioEngineWrapper ); |
155 return d->mEngineHandler->IsAntennaAttached(); |
152 return d->mEngineHandler->isAntennaAttached(); |
156 } |
153 } |
157 |
154 |
158 /*! |
155 /*! |
159 * Returns the "use loudspeaker" status |
156 * Returns the "use loudspeaker" status |
160 */ |
157 */ |
163 Q_D( const RadioEngineWrapper ); |
160 Q_D( const RadioEngineWrapper ); |
164 return d->mUseLoudspeaker; |
161 return d->mUseLoudspeaker; |
165 } |
162 } |
166 |
163 |
167 /*! |
164 /*! |
|
165 * Sets or unsets the engine to manual seek mode |
|
166 */ |
|
167 void RadioEngineWrapper::setManualSeekMode( bool manualSeek ) |
|
168 { |
|
169 Q_D( RadioEngineWrapper ); |
|
170 d->mEngineHandler->setManualSeekMode( manualSeek ); |
|
171 if ( !manualSeek ) { |
|
172 RUN_NOTIFY_LOOP( d->observers(), tunedToFrequency( currentFrequency(), TuneReason::ManualSeekTune ) ); |
|
173 } |
|
174 } |
|
175 |
|
176 /*! |
|
177 * Checks if the engine is in manual seek mode |
|
178 */ |
|
179 bool RadioEngineWrapper::isInManualSeekMode() const |
|
180 { |
|
181 Q_D( const RadioEngineWrapper ); |
|
182 return d->mEngineHandler->isInManualSeekMode(); |
|
183 } |
|
184 |
|
185 /*! |
|
186 * |
|
187 */ |
|
188 void RadioEngineWrapper::setRdsEnabled( bool rdsEnabled ) |
|
189 { |
|
190 Q_D( RadioEngineWrapper ); |
|
191 d->mEngineHandler->setRdsEnabled( rdsEnabled ); |
|
192 } |
|
193 |
|
194 /*! |
168 * Tunes to the given frequency |
195 * Tunes to the given frequency |
169 */ |
196 */ |
170 void RadioEngineWrapper::tuneFrequency( uint frequency, const int reason ) |
197 void RadioEngineWrapper::setFrequency( uint frequency, const int reason ) |
171 { |
198 { |
172 Q_D( RadioEngineWrapper ); |
199 Q_D( RadioEngineWrapper ); |
173 d->tuneFrequency( frequency, reason ); |
200 d->setFrequency( frequency, reason ); |
174 } |
201 } |
175 |
202 |
176 /*! |
203 /*! |
177 * Tunes to the given frequency after a delay |
204 * volume increase command for the engine |
178 */ |
205 */ |
179 void RadioEngineWrapper::tuneWithDelay( uint frequency, const int reason ) |
206 void RadioEngineWrapper::increaseVolume() |
180 { |
207 { |
181 Q_D( RadioEngineWrapper ); |
208 Q_D( RadioEngineWrapper ); |
182 d->tuneWithDelay( frequency, reason ); |
209 d->mEngineHandler->increaseVolume(); |
|
210 } |
|
211 |
|
212 /*! |
|
213 * volume decrease command for the engine |
|
214 */ |
|
215 void RadioEngineWrapper::decreaseVolume() |
|
216 { |
|
217 Q_D( RadioEngineWrapper ); |
|
218 d->mEngineHandler->decreaseVolume(); |
183 } |
219 } |
184 |
220 |
185 /*! |
221 /*! |
186 * volume update command for the engine |
222 * volume update command for the engine |
187 */ |
223 */ |
188 void RadioEngineWrapper::setVolume( int volume ) |
224 void RadioEngineWrapper::setVolume( int volume ) |
189 { |
225 { |
190 Q_D( RadioEngineWrapper ); |
226 Q_D( RadioEngineWrapper ); |
191 d->mEngineHandler->SetVolume( volume ); |
227 d->mEngineHandler->setVolume( volume ); |
192 } |
228 } |
193 |
229 |
194 /*! |
230 /*! |
195 * |
231 * |
196 */ |
232 */ |
197 void RadioEngineWrapper::setMute( bool muted ) |
233 void RadioEngineWrapper::setMute( bool muted, bool updateSettings ) |
198 { |
234 { |
199 Q_D( RadioEngineWrapper ); |
235 Q_D( RadioEngineWrapper ); |
200 d->mEngineHandler->SetMuted( muted ); |
236 d->mEngineHandler->setMute( muted, updateSettings ); |
201 } |
237 } |
202 |
238 |
203 /*! |
239 /*! |
204 * |
240 * |
205 */ |
241 */ |
206 void RadioEngineWrapper::toggleAudioRoute() |
242 void RadioEngineWrapper::toggleAudioRoute() |
207 { |
243 { |
208 Q_D( RadioEngineWrapper ); |
244 Q_D( RadioEngineWrapper ); |
209 d->mUseLoudspeaker = !d->mUseLoudspeaker; |
245 d->mUseLoudspeaker = !d->mUseLoudspeaker; |
210 d->mEngineHandler->SetAudioRouteToLoudspeaker( d->mUseLoudspeaker ); |
246 d->mEngineHandler->setAudioRouteToLoudspeaker( d->mUseLoudspeaker ); |
211 } |
247 } |
212 |
248 |
213 /*! |
249 /*! |
214 * |
250 * |
215 */ |
251 */ |
216 void RadioEngineWrapper::startSeeking( Seeking::Direction direction, const int reason ) |
252 void RadioEngineWrapper::startSeeking( Seek::Direction direction, const int reason ) |
217 { |
253 { |
218 Q_D( RadioEngineWrapper ); |
254 Q_D( RadioEngineWrapper ); |
219 d->startSeeking( direction, reason ); |
255 d->startSeeking( direction, reason ); |
220 } |
256 } |
221 |
257 |