40 #include "radioscannerengine.h" |
40 #include "radioscannerengine.h" |
41 #include "radiogenrelocalizer.h" |
41 #include "radiogenrelocalizer.h" |
42 #include "radiologger.h" |
42 #include "radiologger.h" |
43 |
43 |
44 // Constants |
44 // Constants |
45 const uint DEFAULT_MIN_FREQUENCY = 87500000; |
|
46 const uint RADIO_CENREP_UID = 0x2002FF52; |
45 const uint RADIO_CENREP_UID = 0x2002FF52; |
47 const uint RADIO_CENREP_FREQUENCY_KEY = 0x207; |
46 const uint RADIO_CENREP_FREQUENCY_KEY = 0x207; |
48 |
47 const uint RADIO_CENREP_HEADSET_VOLUME = 0x200; |
|
48 |
|
49 const QLatin1String OVI_STORE_URL( "http://www.music.nokia.co.uk/Touch/Search.aspx?artistsearch=#artist#&titlesearch=#title#" ); |
49 const QLatin1String OTHER_STORE_URL( "http://www.amazon.com/gp/search/ref=sr_adv_m_digital/?search-alias=digital-music&field-author=#artist#&field-title=#title#" ); |
50 const QLatin1String OTHER_STORE_URL( "http://www.amazon.com/gp/search/ref=sr_adv_m_digital/?search-alias=digital-music&field-author=#artist#&field-title=#title#" ); |
50 const QLatin1String OTHER_STORE_ARTIST_TAG( "#artist#" ); |
51 const QLatin1String OTHER_STORE_ARTIST_TAG( "#artist#" ); |
51 const QLatin1String OTHER_STORE_TITLE_TAG( "#title#" ); |
52 const QLatin1String OTHER_STORE_TITLE_TAG( "#title#" ); |
52 const char WHITESPACE = ' '; |
53 const char WHITESPACE = ' '; |
53 const char WHITESPACE_REPLACEMENT = '+'; |
54 const char WHITESPACE_REPLACEMENT = '+'; |
54 |
55 |
55 /*! |
56 // Constants used when launching radio server |
56 * |
57 const QLatin1String RADIO_SERVER_NAME( "radioserver.exe" ); |
57 */ |
58 const QLatin1String RADIO_RANGE_USEURO( "useuro" ); |
58 uint RadioUiEngine::lastTunedFrequency() |
59 const QLatin1String RADIO_RANGE_JAPAN( "japan" ); |
59 { |
60 |
60 uint frequency = DEFAULT_MIN_FREQUENCY; |
61 // ====== STATIC FUNCTIONS ======== |
|
62 |
|
63 /*! |
|
64 * Gets the last tuned frequency from central repository |
|
65 */ |
|
66 uint RadioUiEngine::lastTunedFrequency( uint defaultFrequency ) |
|
67 { |
|
68 uint frequency = defaultFrequency; |
61 |
69 |
62 #ifdef BUILD_WIN32 |
70 #ifdef BUILD_WIN32 |
63 QScopedPointer<QSettings> settings( new QSettings( "Nokia", "QtFmRadio" ) ); |
71 QScopedPointer<QSettings> settings( new QSettings( "Nokia", "QtFmRadio" ) ); |
64 frequency = settings->value( "CurrentFreq", DEFAULT_MIN_FREQUENCY ).toUInt(); |
72 frequency = settings->value( "CurrentFreq", DEFAULT_MIN_FREQUENCY ).toUInt(); |
65 if ( frequency == 0 ) { |
73 if ( frequency == 0 ) { |
66 frequency = DEFAULT_MIN_FREQUENCY; |
74 frequency = defaultFrequency; |
67 } |
75 } |
68 #else |
76 #else |
69 QScopedPointer<XQSettingsManager> settings( new XQSettingsManager() ); |
77 QScopedPointer<XQSettingsManager> settings( new XQSettingsManager() ); |
70 XQSettingsKey key( XQSettingsKey::TargetCentralRepository, RADIO_CENREP_UID, RADIO_CENREP_FREQUENCY_KEY ); |
78 XQSettingsKey key( XQSettingsKey::TargetCentralRepository, RADIO_CENREP_UID, RADIO_CENREP_FREQUENCY_KEY ); |
71 frequency = settings->readItemValue( key, XQSettingsManager::TypeInt ).toUInt(); |
79 frequency = settings->readItemValue( key, XQSettingsManager::TypeInt ).toUInt(); |
72 if ( frequency == 0 ) { |
80 if ( frequency == 0 ) { |
73 frequency = DEFAULT_MIN_FREQUENCY; |
81 frequency = defaultFrequency; |
74 } |
82 } |
75 #endif |
83 #endif |
76 |
84 |
77 return frequency; |
85 return frequency; |
78 } |
86 } |
|
87 |
|
88 /*! |
|
89 * Gets the last used volume level |
|
90 */ |
|
91 int RadioUiEngine::lastVolume() |
|
92 { |
|
93 int volume = DEFAULT_VOLUME_LEVEL; |
|
94 |
|
95 #ifndef BUILD_WIN32 |
|
96 QScopedPointer<XQSettingsManager> settings( new XQSettingsManager() ); |
|
97 XQSettingsKey key( XQSettingsKey::TargetCentralRepository, RADIO_CENREP_UID, RADIO_CENREP_HEADSET_VOLUME ); |
|
98 volume = settings->readItemValue( key, XQSettingsManager::TypeInt ).toInt(); |
|
99 if ( volume == 0 ) { |
|
100 volume = DEFAULT_VOLUME_LEVEL; |
|
101 } |
|
102 #endif |
|
103 |
|
104 return volume; |
|
105 } |
|
106 |
|
107 /*! |
|
108 * Launches the radio server process |
|
109 */ |
|
110 void RadioUiEngine::launchRadioServer() |
|
111 { |
|
112 QStringList args; |
|
113 args << RADIO_RANGE_USEURO; //TODO: Determine current region |
|
114 args << QString::number( lastTunedFrequency( 0 ) ); |
|
115 args << QString::number( lastVolume() ); |
|
116 |
|
117 QProcess serverProcess; |
|
118 bool success = serverProcess.startDetached( RADIO_SERVER_NAME, args ); |
|
119 LOG_ASSERT( success, LOG( "Failed to start radio server!" ) ); |
|
120 } |
|
121 |
|
122 // ====== MEMBER FUNCTIONS ======== |
79 |
123 |
80 /*! |
124 /*! |
81 * |
125 * |
82 */ |
126 */ |
83 RadioUiEngine::RadioUiEngine( QObject* parent ) : |
127 RadioUiEngine::RadioUiEngine( QObject* parent ) : |
374 /*! |
422 /*! |
375 * |
423 * |
376 */ |
424 */ |
377 void RadioUiEngine::openMusicStore( const RadioHistoryItem& item, MusicStore store ) |
425 void RadioUiEngine::openMusicStore( const RadioHistoryItem& item, MusicStore store ) |
378 { |
426 { |
379 if ( store == OviStore ) { |
427 QString artist = item.artist(); |
380 //TODO: Integrate to music store |
428 artist.replace( WHITESPACE, WHITESPACE_REPLACEMENT ); |
381 } else if ( store == OtherStore ) { |
429 QString title = item.title(); |
382 QString artist = item.artist(); |
430 title.replace( WHITESPACE, WHITESPACE_REPLACEMENT ); |
383 artist.replace( WHITESPACE, WHITESPACE_REPLACEMENT ); |
431 |
384 QString title = item.title(); |
432 QString url = store == OviStore ? OVI_STORE_URL : OTHER_STORE_URL; |
385 title.replace( WHITESPACE, WHITESPACE_REPLACEMENT ); |
433 url.replace( OTHER_STORE_ARTIST_TAG, artist ); |
386 |
434 url.replace( OTHER_STORE_TITLE_TAG, title ); |
387 QString url( OTHER_STORE_URL ); |
435 |
388 url.replace( OTHER_STORE_ARTIST_TAG, artist ); |
436 launchBrowser( url ); |
389 url.replace( OTHER_STORE_TITLE_TAG, title ); |
|
390 |
|
391 launchBrowser( url ); |
|
392 } |
|
393 } |
437 } |
394 |
438 |
395 /*! |
439 /*! |
396 * |
440 * |
397 */ |
441 */ |