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 #include <QScopedPointer> |
|
20 #include <QProcess> |
|
21 #include <QFile> |
|
22 |
|
23 #ifdef BUILD_WIN32 |
|
24 # include <QSettings> |
|
25 #else |
|
26 # include <qsysteminfo.h> |
|
27 # include <XQSettingsManager> |
|
28 using namespace QtMobility; |
|
29 #endif // WIN32_BUILD |
|
30 |
|
31 // User includes |
|
32 #include "radiouiengine.h" |
|
33 #include "radiouiengine_p.h" |
|
34 #include "radiologger.h" |
|
35 #include "radioenginewrapper.h" |
|
36 #include "radiostationmodel.h" |
|
37 #include "radiohistorymodel.h" |
|
38 #include "radiocarouselmodel.h" |
|
39 #include "radiohistoryitem.h" |
|
40 #include "radiosettings.h" |
|
41 #include "radiostationfiltermodel.h" |
|
42 #include "radioscannerengine.h" |
|
43 |
|
44 // Constants |
|
45 const QString KPathFormatter = "%1:%2%3"; |
|
46 const QString KApplicationDir = "\\sys\\bin\\"; |
|
47 const QString KSongRecognitionApp = "Shazam_0x200265B3.exe"; |
|
48 const QString KSongRecognitionAppParams = "-listen"; |
|
49 |
|
50 const uint DEFAULT_MIN_FREQUENCY = 87500000; |
|
51 const uint RADIO_CENREP_UID = 0x101FF976; |
|
52 const uint RADIO_CENREP_FREQUENCY_KEY = 0x00000107; |
|
53 |
|
54 struct GenreStruct |
|
55 { |
|
56 int mGenreCode; |
|
57 const char* mInCarousel; |
|
58 const char* mInStationsList; |
|
59 const char* mInHomeScreen; |
|
60 }; |
|
61 |
|
62 const GenreStruct EuropeanGenres[] = |
|
63 { |
|
64 { GenreEurope::RdsNone, "", "", "" } |
|
65 ,{ GenreEurope::RdsNews, "txt_rad_info_news", "txt_rad_dblist_l1_mhz_val_news", "txt_rad_info_news_hs" } |
|
66 ,{ GenreEurope::RdsCurrentAffairs, "txt_rad_info_current_affairs", "txt_rad_dblist_l1_mhz_val_current_affairs", "txt_rad_info_current_affairs_hs" } |
|
67 ,{ GenreEurope::RdsInformation, "txt_rad_info_information", "txt_rad_dblist_l1_mhz_val_information", "txt_rad_info_information_hs" } |
|
68 ,{ GenreEurope::RdsSport, "txt_rad_info_sport", "txt_rad_dblist_l1_mhz_val_sport", "txt_rad_info_sport_hs" } |
|
69 ,{ GenreEurope::RdsEducation, "txt_rad_info_education", "txt_rad_dblist_l1_mhz_val_education", "txt_rad_info_education_hs" } |
|
70 ,{ GenreEurope::RdsDrama, "txt_rad_info_drama", "txt_rad_dblist_l1_mhz_val_drama", "txt_rad_info_drama_hs" } |
|
71 ,{ GenreEurope::RdsCulture, "txt_rad_info_culture", "txt_rad_dblist_l1_mhz_val_culture", "txt_rad_info_culture_hs" } |
|
72 ,{ GenreEurope::RdsScience, "txt_rad_info_science", "txt_rad_dblist_l1_mhz_val_science", "txt_rad_info_science_hs" } |
|
73 ,{ GenreEurope::RdsVariedSpeech, "txt_rad_info_varied", "txt_rad_dblist_l1_mhz_val_varied", "txt_rad_info_varied_hs" } |
|
74 ,{ GenreEurope::RdsPopMusic, "txt_rad_info_pop_music", "txt_rad_dblist_l1_mhz_val_pop_music", "txt_rad_info_pop_music_hs" } |
|
75 ,{ GenreEurope::RdsRockMusic, "txt_rad_info_rock_music", "txt_rad_dblist_l1_mhz_val_rock_music", "txt_rad_info_rock_music_hs" } |
|
76 ,{ GenreEurope::RdsEasyListening, "txt_rad_info_easy_listening", "txt_rad_dblist_l1_mhz_val_easy_listening", "txt_rad_info_easy_listening_hs" } |
|
77 ,{ GenreEurope::RdsLightClassical, "txt_rad_info_light_classical", "txt_rad_dblist_l1_mhz_val_light_classical", "txt_rad_info_light_classical_hs" } |
|
78 ,{ GenreEurope::RdsSeriousClassical, "txt_rad_info_serious_classical", "txt_rad_dblist_l1_mhz_val_serious_classical", "txt_rad_info_serious_classical_hs" } |
|
79 ,{ GenreEurope::RdsOtherMusic, "txt_rad_info_other_music", "txt_rad_dblist_l1_mhz_val_other_music", "txt_rad_info_other_music_hs" } |
|
80 ,{ GenreEurope::RdsWeather, "txt_rad_info_weather", "txt_rad_dblist_l1_mhz_val_weather", "txt_rad_info_weather_hs" } |
|
81 ,{ GenreEurope::RdsFinance, "txt_rad_info_finance", "txt_rad_dblist_l1_mhz_val_finance", "txt_rad_info_finance_hs" } |
|
82 ,{ GenreEurope::RdsChildrensProgrammes, "txt_rad_info_childrens_programmes", "txt_rad_dblist_l1_mhz_val_childrens_programmes", "txt_rad_info_childrens_programmes_hs" } |
|
83 ,{ GenreEurope::RdsSocialAffairs, "txt_rad_info_social_affairs", "txt_rad_dblist_l1_mhz_val_social_affairs", "txt_rad_info_social_affairs_hs" } |
|
84 ,{ GenreEurope::RdsReligion, "txt_rad_info_religion", "txt_rad_dblist_l1_mhz_val_religion", "txt_rad_info_religion_hs" } |
|
85 ,{ GenreEurope::RdsPhoneIn, "txt_rad_info_phone_in", "txt_rad_dblist_l1_mhz_val_phone_in", "txt_rad_info_phone_in_hs" } |
|
86 ,{ GenreEurope::RdsTravel, "txt_rad_info_travel", "txt_rad_dblist_l1_mhz_val_travel", "txt_rad_info_travel_hs" } |
|
87 ,{ GenreEurope::RdsLeisure, "txt_rad_info_leisure", "txt_rad_dblist_l1_mhz_val_leisure", "txt_rad_info_leisure_hs" } |
|
88 ,{ GenreEurope::RdsJazzMusic, "txt_rad_info_jazz_music", "txt_rad_dblist_l1_mhz_val_jazz_music", "txt_rad_info_jazz_music_hs" } |
|
89 ,{ GenreEurope::RdsCountryMusic, "txt_rad_info_country_music", "txt_rad_dblist_l1_mhz_val_country_music", "txt_rad_info_country_music_hs" } |
|
90 ,{ GenreEurope::RdsNationalMusic, "txt_rad_info_national_music", "txt_rad_dblist_l1_mhz_val_national_music", "txt_rad_info_national_music_hs" } |
|
91 ,{ GenreEurope::RdsOldiesMusic, "txt_rad_info_oldies_music", "txt_rad_dblist_l1_mhz_val_oldies_music", "txt_rad_info_oldies_music_hs" } |
|
92 ,{ GenreEurope::RdsFolkMusic, "txt_rad_info_folk_music", "txt_rad_dblist_l1_mhz_val_folk_music", "txt_rad_info_folk_music_hs" } |
|
93 ,{ GenreEurope::RdsDocumentary, "txt_rad_info_documentary", "txt_rad_dblist_l1_mhz_val_documentary", "txt_rad_info_documentary_hs" } |
|
94 ,{ GenreEurope::RdsAlarmTest, "txt_rad_info_alarm_test", "txt_rad_dblist_l1_mhz_val_alarm_test", "txt_rad_info_alarm_test_hs" } |
|
95 ,{ GenreEurope::RdsAlarm, "txt_rad_info_alarm", "txt_rad_dblist_l1_mhz_val_alarm", "txt_rad_info_alarm_hs" } |
|
96 }; |
|
97 const int EuropeanGenresCount = sizeof( EuropeanGenres ) / sizeof ( EuropeanGenres[0] ); |
|
98 |
|
99 const GenreStruct AmericanGenres[] = |
|
100 { |
|
101 { GenreAmerica::RbdsNone, "", "", "" } |
|
102 ,{ GenreAmerica::RbdsNews, "txt_rad_info_news", "txt_rad_dblist_l1_mhz_val_news", "txt_rad_info_news_hs" } |
|
103 ,{ GenreAmerica::RbdsInformation, "txt_rad_info_information", "txt_rad_dblist_l1_mhz_val_information", "txt_rad_info_information_hs" } |
|
104 ,{ GenreAmerica::RbdsSports, "txt_rad_info_sport", "txt_rad_dblist_l1_mhz_val_sport", "txt_rad_info_sport_hs" } |
|
105 ,{ GenreAmerica::RbdsTalk, "txt_rad_info_talk", "txt_rad_dblist_l1_mhz_val_talk", "txt_rad_info_talk_hs" } |
|
106 ,{ GenreAmerica::RbdsRock, "txt_rad_info_rock_music", "txt_rad_dblist_l1_mhz_val_rock_music", "txt_rad_info_rock_music_hs" } //TODO: Check |
|
107 ,{ GenreAmerica::RbdsClassicRock, "txt_rad_info_classic_rock", "txt_rad_dblist_l1_mhz_val_classic_rock", "txt_rad_info_classic_rock_hs" } |
|
108 ,{ GenreAmerica::RbdsAdultHits, "txt_rad_info_adult_hits", "txt_rad_dblist_l1_mhz_val_adult_hits", "txt_rad_info_adult_hits_hs" } |
|
109 ,{ GenreAmerica::RbdsSoftRock, "txt_rad_info_soft_rock", "txt_rad_dblist_l1_mhz_val_soft_rock", "txt_rad_info_soft_rock_hs" } |
|
110 ,{ GenreAmerica::RbdsTop40, "txt_rad_info_top_40", "txt_rad_dblist_l1_mhz_val_top_40", "txt_rad_info_top_40_hs" } |
|
111 ,{ GenreAmerica::RbdsCountry, "txt_rad_info_country_music", "txt_rad_dblist_l1_mhz_val_country_music", "txt_rad_info_country_music_hs" } //TODO: Check |
|
112 ,{ GenreAmerica::RbdsOldies, "txt_rad_info_oldies_music", "txt_rad_dblist_l1_mhz_val_oldies_music", "txt_rad_info_oldies_music_hs" } //TODO: Check |
|
113 ,{ GenreAmerica::RbdsSoft, "txt_rad_info_soft", "txt_rad_dblist_l1_mhz_val_soft", "txt_rad_info_soft_hs" } |
|
114 ,{ GenreAmerica::RbdsNostalgia, "txt_rad_info_nostalgia", "txt_rad_dblist_l1_mhz_val_nostalgia", "txt_rad_info_nostalgia_hs" } |
|
115 ,{ GenreAmerica::RbdsJazz, "txt_rad_info_jazz_music", "txt_rad_dblist_l1_mhz_val_jazz_music", "txt_rad_info_jazz_music_hs" } //TODO: Check |
|
116 ,{ GenreAmerica::RbdsClassical, "txt_rad_info_classical", "txt_rad_dblist_l1_mhz_val_classical", "txt_rad_info_classical_hs" } |
|
117 ,{ GenreAmerica::RbdsRhythmAndBlues, "txt_rad_info_rhythm_and_blues", "txt_rad_dblist_l1_mhz_val_rhythm_and_blues", "txt_rad_info_rhythm_and_blues_hs" } |
|
118 ,{ GenreAmerica::RbdsSoftRhythmAndBlues, "txt_rad_info_soft_rhythm_and_blues", "txt_rad_dblist_l1_mhz_val_soft_rhythm_and_blues", "txt_rad_info_soft_rhythm_and_blues_hs" } |
|
119 ,{ GenreAmerica::RbdsLanguage, "txt_rad_info_language", "txt_rad_dblist_l1_mhz_val_language", "txt_rad_info_language_hs" } |
|
120 ,{ GenreAmerica::RbdsReligiousMusic, "txt_rad_info_religious_music", "txt_rad_dblist_l1_mhz_val_religious_music", "txt_rad_info_religious_music_hs" } |
|
121 ,{ GenreAmerica::RbdsReligiousTalk, "txt_rad_info_religious_talk", "txt_rad_dblist_l1_mhz_val_religious_talk", "txt_rad_info_religious_talk_hs" } |
|
122 ,{ GenreAmerica::RbdsPersonality, "txt_rad_info_personality", "txt_rad_dblist_l1_mhz_val_personality", "txt_rad_info_personality_hs" } |
|
123 ,{ GenreAmerica::RbdsPublic, "txt_rad_info_public", "txt_rad_dblist_l1_mhz_val_public", "txt_rad_info_public_hs" } |
|
124 ,{ GenreAmerica::RbdsCollege, "txt_rad_info_college", "txt_rad_dblist_l1_mhz_val_college", "txt_rad_info_college_hs" } |
|
125 ,{ GenreAmerica::RbdsUnassigned1, "", "", "" } |
|
126 ,{ GenreAmerica::RbdsUnassigned2, "", "", "" } |
|
127 ,{ GenreAmerica::RbdsUnassigned3, "", "", "" } |
|
128 ,{ GenreAmerica::RbdsUnassigned4, "", "", "" } |
|
129 ,{ GenreAmerica::RbdsUnassigned5, "", "", "" } |
|
130 ,{ GenreAmerica::RbdsWeather, "txt_rad_info_weather", "txt_rad_dblist_l1_mhz_val_weather", "txt_rad_info_weather_hs" }//TODO: Check |
|
131 ,{ GenreAmerica::RbdsEmergencyTest, "txt_rad_info_alarm_test", "txt_rad_dblist_l1_mhz_val_alarm_test", "txt_rad_info_alarm_test_hs" }//TODO: Check |
|
132 ,{ GenreAmerica::RbdsEmergency, "txt_rad_info_alarm", "txt_rad_dblist_l1_mhz_val_alarm", "txt_rad_info_alarm_hs" }//TODO: Check |
|
133 }; |
|
134 const int AmericanGenresCount = sizeof( AmericanGenres ) / sizeof ( AmericanGenres[0] ); |
|
135 |
|
136 /*! |
|
137 * |
|
138 */ |
|
139 bool RadioUiEngine::isOfflineProfile() |
|
140 { |
|
141 bool offline = false; |
|
142 |
|
143 #ifdef BUILD_WIN32 |
|
144 QScopedPointer<QSettings> settings( new QSettings( "Nokia", "QtFmRadio" ) ); |
|
145 offline = settings->value( "Offline", false ).toBool(); |
|
146 #else |
|
147 QSystemDeviceInfo deviceInfo; |
|
148 if ( deviceInfo.currentProfile() == QSystemDeviceInfo::OfflineProfile ) { |
|
149 offline = true; |
|
150 } |
|
151 #endif |
|
152 |
|
153 return offline; |
|
154 } |
|
155 |
|
156 /*! |
|
157 * |
|
158 */ |
|
159 uint RadioUiEngine::lastTunedFrequency() |
|
160 { |
|
161 uint frequency = DEFAULT_MIN_FREQUENCY; |
|
162 |
|
163 #ifdef BUILD_WIN32 |
|
164 QScopedPointer<QSettings> settings( new QSettings( "Nokia", "QtFmRadio" ) ); |
|
165 frequency = settings->value( "CurrentFreq", DEFAULT_MIN_FREQUENCY ).toUInt(); |
|
166 if ( frequency == 0 ) { |
|
167 frequency = DEFAULT_MIN_FREQUENCY; |
|
168 } |
|
169 #else |
|
170 QScopedPointer<XQSettingsManager> settings( new XQSettingsManager() ); |
|
171 XQSettingsKey key( XQSettingsKey::TargetCentralRepository, RADIO_CENREP_UID, RADIO_CENREP_FREQUENCY_KEY ); |
|
172 frequency = settings->readItemValue( key, XQSettingsManager::TypeInt ).toUInt(); |
|
173 #endif |
|
174 |
|
175 return frequency; |
|
176 } |
|
177 |
|
178 /*! |
|
179 * |
|
180 */ |
|
181 RadioUiEngine::RadioUiEngine( QObject* parent ) : |
|
182 QObject( parent ), |
|
183 d_ptr( new RadioUiEnginePrivate( this ) ) |
|
184 { |
|
185 } |
|
186 |
|
187 /*! |
|
188 * |
|
189 */ |
|
190 RadioUiEngine::~RadioUiEngine() |
|
191 { |
|
192 delete d_ptr; |
|
193 } |
|
194 |
|
195 /*! |
|
196 * |
|
197 */ |
|
198 bool RadioUiEngine::isInitialized() const |
|
199 { |
|
200 Q_D( const RadioUiEngine ); |
|
201 return !d->mEngineWrapper.isNull(); |
|
202 } |
|
203 |
|
204 /*! |
|
205 * |
|
206 */ |
|
207 bool RadioUiEngine::init() |
|
208 { |
|
209 Q_D( RadioUiEngine ); |
|
210 return d->init(); |
|
211 } |
|
212 |
|
213 /*! |
|
214 * |
|
215 */ |
|
216 bool RadioUiEngine::isFirstTimeStart() |
|
217 { |
|
218 Q_D( RadioUiEngine ); |
|
219 return d->mEngineWrapper->settings().isFirstTimeStart(); |
|
220 } |
|
221 |
|
222 /*! |
|
223 * Returns the settings handler owned by the engine |
|
224 */ |
|
225 RadioSettingsIf& RadioUiEngine::settings() |
|
226 { |
|
227 Q_D( RadioUiEngine ); |
|
228 return d->mEngineWrapper->settings(); |
|
229 } |
|
230 |
|
231 /*! |
|
232 * Returns the station model |
|
233 */ |
|
234 RadioStationModel& RadioUiEngine::stationModel() |
|
235 { |
|
236 Q_D( RadioUiEngine ); |
|
237 return *d->mStationModel; |
|
238 } |
|
239 |
|
240 /*! |
|
241 * Returns the history model |
|
242 */ |
|
243 RadioHistoryModel& RadioUiEngine::historyModel() |
|
244 { |
|
245 Q_D( RadioUiEngine ); |
|
246 return *d->mHistoryModel; |
|
247 } |
|
248 |
|
249 /*! |
|
250 * Creates a new filter model |
|
251 */ |
|
252 RadioStationFilterModel* RadioUiEngine::createNewFilterModel( QObject* parent ) |
|
253 { |
|
254 return new RadioStationFilterModel( *this, parent ); |
|
255 } |
|
256 |
|
257 /*! |
|
258 * Creates a new carousel model |
|
259 */ |
|
260 RadioCarouselModel* RadioUiEngine::carouselModel() |
|
261 { |
|
262 Q_D( RadioUiEngine ); |
|
263 if ( !d->mCarouselModel ) { |
|
264 d->mCarouselModel.reset( new RadioCarouselModel( *this, *d->mStationModel ) ); |
|
265 } |
|
266 |
|
267 return d->mCarouselModel.data(); |
|
268 } |
|
269 |
|
270 /*! |
|
271 * |
|
272 */ |
|
273 RadioScannerEngine* RadioUiEngine::scannerEngine() |
|
274 { |
|
275 Q_D( RadioUiEngine ); |
|
276 if ( !d->mScannerEngine ) { |
|
277 d->mScannerEngine = new RadioScannerEngine( *d ); |
|
278 } |
|
279 return d->mScannerEngine; |
|
280 } |
|
281 |
|
282 /*! |
|
283 * |
|
284 */ |
|
285 bool RadioUiEngine::isRadioOn() const |
|
286 { |
|
287 Q_D( const RadioUiEngine ); |
|
288 return d->mEngineWrapper->isRadioOn(); |
|
289 } |
|
290 |
|
291 /*! |
|
292 * |
|
293 */ |
|
294 bool RadioUiEngine::isScanning() const |
|
295 { |
|
296 Q_D( const RadioUiEngine ); |
|
297 if ( d->mScannerEngine ) { |
|
298 return d->mScannerEngine->isScanning(); |
|
299 } |
|
300 return false; |
|
301 } |
|
302 |
|
303 /*! |
|
304 * |
|
305 */ |
|
306 bool RadioUiEngine::isMuted() const |
|
307 { |
|
308 Q_D( const RadioUiEngine ); |
|
309 return d->mEngineWrapper->isMuted(); |
|
310 } |
|
311 |
|
312 /*! |
|
313 * |
|
314 */ |
|
315 bool RadioUiEngine::isAntennaAttached() const |
|
316 { |
|
317 Q_D( const RadioUiEngine ); |
|
318 return d->mEngineWrapper->isAntennaAttached(); |
|
319 } |
|
320 |
|
321 /*! |
|
322 * |
|
323 */ |
|
324 bool RadioUiEngine::isUsingLoudspeaker() const |
|
325 { |
|
326 Q_D( const RadioUiEngine ); |
|
327 return d->mEngineWrapper->isUsingLoudspeaker(); |
|
328 } |
|
329 |
|
330 /*! |
|
331 * Returns the selected radio region |
|
332 */ |
|
333 RadioRegion::Region RadioUiEngine::region() const |
|
334 { |
|
335 Q_D( const RadioUiEngine ); |
|
336 return d->mEngineWrapper->region(); |
|
337 } |
|
338 |
|
339 /*! |
|
340 * Returns the currently tuned frequency |
|
341 */ |
|
342 uint RadioUiEngine::currentFrequency() const |
|
343 { |
|
344 Q_D( const RadioUiEngine ); |
|
345 return d->mEngineWrapper->currentFrequency(); |
|
346 } |
|
347 |
|
348 /*! |
|
349 * Returns the minimum frequency |
|
350 */ |
|
351 uint RadioUiEngine::minFrequency() const |
|
352 { |
|
353 Q_D( const RadioUiEngine ); |
|
354 return d->mEngineWrapper->minFrequency(); |
|
355 } |
|
356 |
|
357 /*! |
|
358 * Returns the maximum frequency |
|
359 */ |
|
360 uint RadioUiEngine::maxFrequency() const |
|
361 { |
|
362 Q_D( const RadioUiEngine ); |
|
363 return d->mEngineWrapper->maxFrequency(); |
|
364 } |
|
365 |
|
366 /*! |
|
367 * Returns the frequency step size from the selected region |
|
368 */ |
|
369 uint RadioUiEngine::frequencyStepSize() const |
|
370 { |
|
371 Q_D( const RadioUiEngine ); |
|
372 return d->mEngineWrapper->frequencyStepSize(); |
|
373 } |
|
374 |
|
375 /*! |
|
376 * Sets the mute status |
|
377 */ |
|
378 void RadioUiEngine::setMute( bool muted ) |
|
379 { |
|
380 Q_D( RadioUiEngine ); |
|
381 d->mEngineWrapper->setMute( muted ); |
|
382 } |
|
383 |
|
384 /*! |
|
385 * |
|
386 */ |
|
387 QList<RadioStation> RadioUiEngine::stationsInRange( uint minFrequency, uint maxFrequency ) |
|
388 { |
|
389 Q_D( RadioUiEngine ); |
|
390 return d->mStationModel->stationsInRange( minFrequency, maxFrequency ); |
|
391 } |
|
392 |
|
393 /*! |
|
394 * |
|
395 */ |
|
396 QString RadioUiEngine::genreToString( int genre, GenreTarget::Target target ) |
|
397 { |
|
398 RadioRegion::Region currentRegion = region(); |
|
399 |
|
400 const GenreStruct* genreArray = currentRegion == RadioRegion::America ? AmericanGenres : EuropeanGenres; |
|
401 const int genreCount = currentRegion == RadioRegion::America ? AmericanGenresCount : EuropeanGenresCount; |
|
402 |
|
403 for( int i = 0; i < genreCount; ++i ) { |
|
404 if ( genreArray[i].mGenreCode == genre ) { |
|
405 if ( target == GenreTarget::Carousel ) { |
|
406 return qtTrId( genreArray[i].mInCarousel ); |
|
407 } else if ( target == GenreTarget::StationsList ) { |
|
408 return qtTrId( genreArray[i].mInStationsList ); |
|
409 } else if ( target == GenreTarget::HomeScreen ) { |
|
410 return qtTrId( genreArray[i].mInHomeScreen ); |
|
411 } |
|
412 } |
|
413 } |
|
414 |
|
415 return ""; |
|
416 } |
|
417 |
|
418 /*! |
|
419 * |
|
420 */ |
|
421 bool RadioUiEngine::isSongRecognitionAppAvailable() |
|
422 { |
|
423 //TODO: Check if there is a better way to check if an application is available |
|
424 bool available = false; |
|
425 |
|
426 // Check the Z: drive |
|
427 QString fullPath = QString( KPathFormatter ).arg( "Z" ).arg( KApplicationDir ).arg( KSongRecognitionApp ); |
|
428 available = QFile::exists( fullPath ); |
|
429 |
|
430 LOG_FORMAT( "Checking file: %s. found %d", GETSTRING( fullPath ), available ); |
|
431 |
|
432 if ( !available ) { |
|
433 // Check the C: drive |
|
434 fullPath = QString( KPathFormatter ).arg( "C" ).arg( KApplicationDir ).arg( KSongRecognitionApp ); |
|
435 available = QFile::exists( fullPath ); |
|
436 LOG_FORMAT( "Checking file: %s. found %d", GETSTRING( fullPath ), available ); |
|
437 if ( !available ) { |
|
438 // Check the E: drive |
|
439 fullPath = QString( KPathFormatter ).arg( "E" ).arg( KApplicationDir ).arg( KSongRecognitionApp ); |
|
440 available = QFile::exists( fullPath ); |
|
441 LOG_FORMAT( "Checking file: %s. found %d", GETSTRING( fullPath ), available ); |
|
442 } |
|
443 } |
|
444 return available; |
|
445 } |
|
446 |
|
447 /*! |
|
448 * |
|
449 */ |
|
450 void RadioUiEngine::addRecognizedSong( const QString& artist, const QString& title, const RadioStation& station ) |
|
451 { |
|
452 Q_D( RadioUiEngine ); |
|
453 d->mHistoryModel->addItem( artist, title, station ); |
|
454 } |
|
455 |
|
456 /*! |
|
457 * |
|
458 */ |
|
459 uint RadioUiEngine::skipStation( StationSkip::Mode mode, uint startFrequency ) |
|
460 { |
|
461 Q_D( RadioUiEngine ); |
|
462 return d->skip( mode, startFrequency ); |
|
463 } |
|
464 |
|
465 /*! |
|
466 * |
|
467 */ |
|
468 void RadioUiEngine::openMusicStore( const RadioHistoryItem& item, MusicStore store ) |
|
469 { |
|
470 Q_UNUSED( item ); |
|
471 Q_UNUSED( store ); |
|
472 //TODO: Integrate to music store |
|
473 } |
|
474 |
|
475 /*! |
|
476 * Public slot |
|
477 * Tunes to the given frequency |
|
478 */ |
|
479 void RadioUiEngine::tuneFrequency( uint frequency, const int reason ) |
|
480 { |
|
481 Q_D( RadioUiEngine ); |
|
482 if ( frequency != d->mStationModel->currentStation().frequency() && d->mEngineWrapper->isFrequencyValid( frequency ) ) { |
|
483 LOG_FORMAT( "RadioUiEngine::tuneFrequency, frequency: %d", frequency ); |
|
484 d->cancelSeeking(); |
|
485 d->mEngineWrapper->tuneFrequency( frequency, reason ); |
|
486 } |
|
487 } |
|
488 |
|
489 /*! |
|
490 * Public slot |
|
491 * Tunes to the given frequency after a delay |
|
492 */ |
|
493 void RadioUiEngine::tuneWithDelay( uint frequency, const int reason ) |
|
494 { |
|
495 Q_D( RadioUiEngine ); |
|
496 if ( frequency != d->mStationModel->currentStation().frequency() && d->mEngineWrapper->isFrequencyValid( frequency ) ) { |
|
497 LOG_FORMAT( "RadioEngineWrapperPrivate::tuneWithDelay, frequency: %d", frequency ); |
|
498 d->cancelSeeking(); |
|
499 d->mEngineWrapper->tuneWithDelay( frequency, reason ); |
|
500 } |
|
501 } |
|
502 |
|
503 /*! |
|
504 * Public slot |
|
505 * Tunes to the given preset |
|
506 */ |
|
507 void RadioUiEngine::tunePreset( int presetIndex ) |
|
508 { |
|
509 Q_D( RadioUiEngine ); |
|
510 if ( presetIndex != d->mStationModel->currentStation().presetIndex() ) { |
|
511 RadioStation station; |
|
512 if ( d->mStationModel->findPresetIndex( presetIndex, station ) != RadioStation::NotFound && |
|
513 d->mEngineWrapper->isFrequencyValid( station.frequency() ) ) { |
|
514 LOG_FORMAT( "RadioEngineWrapperPrivate::tunePreset, presetIndexPosition: %d", presetIndex ); |
|
515 |
|
516 d->mEngineWrapper->tuneFrequency( station.frequency(), TuneReason::Unspecified ); |
|
517 } |
|
518 } |
|
519 } |
|
520 |
|
521 /*! |
|
522 * Public slot |
|
523 * volume update command slot for the engine |
|
524 */ |
|
525 void RadioUiEngine::setVolume( int volume ) |
|
526 { |
|
527 Q_D( RadioUiEngine ); |
|
528 d->mEngineWrapper->setVolume( volume ); |
|
529 } |
|
530 |
|
531 /*! |
|
532 * Public slot |
|
533 * |
|
534 */ |
|
535 void RadioUiEngine::toggleMute() |
|
536 { |
|
537 Q_D( RadioUiEngine ); |
|
538 if ( !isScanning() ) { |
|
539 d->mEngineWrapper->setMute( !d->mEngineWrapper->isMuted() ); |
|
540 } |
|
541 } |
|
542 |
|
543 /*! |
|
544 * Public slot |
|
545 * |
|
546 */ |
|
547 void RadioUiEngine::toggleAudioRoute() |
|
548 { |
|
549 Q_D( RadioUiEngine ); |
|
550 d->mEngineWrapper->toggleAudioRoute(); |
|
551 } |
|
552 |
|
553 /*! |
|
554 * Public slot |
|
555 * |
|
556 */ |
|
557 void RadioUiEngine::seekStation( int seekDirection ) |
|
558 { |
|
559 if ( isAntennaAttached() ) { |
|
560 Q_D( RadioUiEngine ); |
|
561 Seeking::Direction direction = static_cast<Seeking::Direction>( seekDirection ); |
|
562 emitSeekingStarted( direction ); |
|
563 d->mEngineWrapper->startSeeking( direction, TuneReason::Seek ); |
|
564 } |
|
565 } |
|
566 |
|
567 /*! |
|
568 * Public slot |
|
569 * |
|
570 */ |
|
571 void RadioUiEngine::launchSongRecognition() |
|
572 { |
|
573 LOG_FORMAT("RadioUiEngine::launchSongRecognition() starting: %s", GETSTRING( KSongRecognitionApp ) ); |
|
574 |
|
575 QStringList arguments; |
|
576 arguments << KSongRecognitionAppParams; |
|
577 |
|
578 bool started = QProcess::startDetached( KSongRecognitionApp, arguments ); |
|
579 Q_UNUSED( started ); |
|
580 LOG_ASSERT( started, LOG_FORMAT("RadioUiEngine::launchSongRecognition() failed to start %s", GETSTRING( KSongRecognitionApp ) ) ); |
|
581 } |
|
582 |
|
583 /*! |
|
584 * Function used by the private implementation to emit a tunedToFrequency signal |
|
585 */ |
|
586 void RadioUiEngine::emitTunedToFrequency( uint frequency, int commandSender ) |
|
587 { |
|
588 emit tunedToFrequency( frequency, commandSender ); |
|
589 } |
|
590 |
|
591 /*! |
|
592 * Function used by the private implementation to emit a seekingStarted signal |
|
593 */ |
|
594 void RadioUiEngine::emitSeekingStarted( Seeking::Direction direction ) |
|
595 { |
|
596 emit seekingStarted( direction ); |
|
597 } |
|
598 |
|
599 /*! |
|
600 * Function used by the private implementation to emit a radioStatusChanged signal |
|
601 */ |
|
602 void RadioUiEngine::emitRadioStatusChanged( bool radioIsOn ) |
|
603 { |
|
604 emit radioStatusChanged( radioIsOn ); |
|
605 } |
|
606 |
|
607 /*! |
|
608 * Function used by the private implementation to emit a rdsAvailabilityChanged signal |
|
609 */ |
|
610 void RadioUiEngine::emitRdsAvailabilityChanged( bool available ) |
|
611 { |
|
612 emit rdsAvailabilityChanged( available ); |
|
613 } |
|
614 |
|
615 /*! |
|
616 * Function used by the private implementation to emit a volumeChanged signal |
|
617 */ |
|
618 void RadioUiEngine::emitVolumeChanged( int volume ) |
|
619 { |
|
620 emit volumeChanged( volume ); |
|
621 } |
|
622 |
|
623 /*! |
|
624 * Function used by the private implementation to emit a muteChanged signal |
|
625 */ |
|
626 void RadioUiEngine::emitMuteChanged( bool muted ) |
|
627 { |
|
628 emit muteChanged( muted ); |
|
629 } |
|
630 |
|
631 /*! |
|
632 * Function used by the private implementation to emit a audioRouteChanged signal |
|
633 */ |
|
634 void RadioUiEngine::emitAudioRouteChanged( bool loudspeaker ) |
|
635 { |
|
636 emit audioRouteChanged( loudspeaker ); |
|
637 } |
|
638 |
|
639 /*! |
|
640 * Function used by the private implementation to emit a antennaStatusChanged signal |
|
641 */ |
|
642 void RadioUiEngine::emitAntennaStatusChanged( bool connected ) |
|
643 { |
|
644 emit antennaStatusChanged( connected ); |
|
645 } |
|
646 |
|