equal
deleted
inserted
replaced
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 // System includes |
18 // System includes |
19 #include <QTimer> |
19 #include <QTimer> |
|
20 #include <QRegExp> |
20 |
21 |
21 // User includes |
22 // User includes |
22 #include "radiomonitorservice.h" |
23 #include "radiomonitorservice.h" |
23 #include "radiouiengine.h" |
24 #include "radiouiengine.h" |
24 #include "radiouiengine_p.h" |
25 #include "radiouiengine_p.h" |
42 |
43 |
43 /*! |
44 /*! |
44 * |
45 * |
45 */ |
46 */ |
46 RadioMonitorService::RadioMonitorService( RadioUiEnginePrivate& engine ) : |
47 RadioMonitorService::RadioMonitorService( RadioUiEnginePrivate& engine ) : |
47 XQServiceProvider( RADIO_MONITOR_SERVICE, &engine.api() ), |
48 XQServiceProvider( RADIO_SERVICE +"."+ RADIO_MONITOR_SERVICE, &engine.api() ), |
48 mUiEngine( engine ), |
49 mUiEngine( engine ), |
49 mRadioStatus( RadioStatus::UnSpecified ), |
50 mRadioStatus( RadioStatus::UnSpecified ), |
50 mNotificationTimer( new QTimer( this ) ) |
51 mNotificationTimer( new QTimer( this ) ) |
51 { |
52 { |
52 mNotificationTimer->setSingleShot( true ); |
53 mNotificationTimer->setSingleShot( true ); |
53 mNotificationTimer->setInterval( NOTIFICATION_DELAY ); |
54 mNotificationTimer->setInterval( NOTIFICATION_DELAY ); |
54 Radio::connect( mNotificationTimer.data(), SIGNAL(timeout()), |
55 Radio::connect( mNotificationTimer, SIGNAL(timeout()), |
55 this, SLOT(sendNotifications()) ); |
56 this, SLOT(sendNotifications()) ); |
56 |
57 |
57 publishAll(); |
58 publishAll(); |
58 } |
59 } |
59 |
60 |
60 /*! |
61 /*! |
123 notificationList.append( notification ); |
124 notificationList.append( notification ); |
124 |
125 |
125 notification.setValue( RadioNotificationData( RadioServiceNotification::FavoriteCount, stationModel.favoriteCount() ) ); |
126 notification.setValue( RadioNotificationData( RadioServiceNotification::FavoriteCount, stationModel.favoriteCount() ) ); |
126 notificationList.append( notification ); |
127 notificationList.append( notification ); |
127 |
128 |
128 notification.setValue( RadioNotificationData( RadioServiceNotification::Frequency, station.frequency() ) ); |
129 notification.setValue( RadioNotificationData( RadioServiceNotification::Frequency, RadioStation::parseFrequency( station.frequency() ) ) ); |
129 notificationList.append( notification ); |
130 notificationList.append( notification ); |
130 |
131 |
131 if ( !station.name().isEmpty() ) { |
132 if ( !station.name().isEmpty() ) { |
132 notification.setValue( RadioNotificationData( RadioServiceNotification::Name, station.name() ) ); |
133 notification.setValue( RadioNotificationData( RadioServiceNotification::Name, station.name() ) ); |
133 notificationList.append( notification ); |
134 notificationList.append( notification ); |
138 mUiEngine.api().genreToString( station.genre(), GenreTarget::HomeScreen ) ) ); |
139 mUiEngine.api().genreToString( station.genre(), GenreTarget::HomeScreen ) ) ); |
139 notificationList.append( notification ); |
140 notificationList.append( notification ); |
140 } |
141 } |
141 |
142 |
142 if ( !station.radioText().isEmpty() ) { |
143 if ( !station.radioText().isEmpty() ) { |
143 notification.setValue( RadioNotificationData( RadioServiceNotification::RadioText, station.radioText() ) ); |
144 const QString trimmedRadioText = trimHtmlTags( station.radioText() ); |
|
145 notification.setValue( RadioNotificationData( RadioServiceNotification::RadioText, trimmedRadioText ) ); |
144 notificationList.append( notification ); |
146 notificationList.append( notification ); |
145 } |
147 } |
146 |
148 |
147 if ( !station.dynamicPsText().isEmpty() ) { |
149 if ( !station.dynamicPsText().isEmpty() ) { |
148 notification.setValue( RadioNotificationData( RadioServiceNotification::DynamicPS, station.dynamicPsText() ) ); |
150 notification.setValue( RadioNotificationData( RadioServiceNotification::DynamicPS, station.dynamicPsText() ) ); |
217 notification.setValue( RadioNotificationData( RadioServiceNotification::Name, station.name() ) ); |
219 notification.setValue( RadioNotificationData( RadioServiceNotification::Name, station.name() ) ); |
218 list.append( notification ); |
220 list.append( notification ); |
219 } |
221 } |
220 |
222 |
221 if ( station.hasDataChanged( RadioStation::RadioTextChanged ) ) { |
223 if ( station.hasDataChanged( RadioStation::RadioTextChanged ) ) { |
222 notification.setValue( RadioNotificationData( RadioServiceNotification::RadioText, station.radioText() ) ); |
224 const QString trimmedRadioText = trimHtmlTags( station.radioText() ); |
|
225 notification.setValue( RadioNotificationData( RadioServiceNotification::RadioText, trimmedRadioText ) ); |
223 list.append( notification ); |
226 list.append( notification ); |
224 } |
227 } |
225 |
228 |
226 notifyList( list ); |
229 notifyList( list ); |
227 } |
230 } |
241 */ |
244 */ |
242 void RadioMonitorService::tunedToFrequency( uint frequency, int reason ) |
245 void RadioMonitorService::tunedToFrequency( uint frequency, int reason ) |
243 { |
246 { |
244 Q_UNUSED( reason ); |
247 Q_UNUSED( reason ); |
245 if ( !mUiEngine.api().isScanning() ) { |
248 if ( !mUiEngine.api().isScanning() ) { |
246 RUN_NOTIFY( Frequency, frequency ); |
249 RUN_NOTIFY( Frequency, RadioStation::parseFrequency( frequency ) ); |
247 RadioStation station; |
250 RadioStation station; |
248 if ( mUiEngine.api().stationModel().findFrequency( frequency, station ) && !station.name().isEmpty() ) { |
251 if ( mUiEngine.api().stationModel().findFrequency( frequency, station ) && !station.name().isEmpty() ) { |
249 RUN_NOTIFY( Name, station.name() ); |
252 RUN_NOTIFY( Name, station.name() ); |
250 } |
253 } |
251 |
254 |
285 } |
288 } |
286 |
289 |
287 /*! |
290 /*! |
288 * |
291 * |
289 */ |
292 */ |
|
293 QString RadioMonitorService::trimHtmlTags( const QString& html ) |
|
294 { |
|
295 QString trimmed = html; |
|
296 QRegExp rex( "<.+>" ); |
|
297 rex.setMinimal( true ); |
|
298 trimmed.remove( rex ); |
|
299 return trimmed; |
|
300 } |
|
301 |
|
302 /*! |
|
303 * |
|
304 */ |
290 void RadioMonitorService::notify( const QVariant& notification ) |
305 void RadioMonitorService::notify( const QVariant& notification ) |
291 { |
306 { |
292 mNotificationTimer->stop(); |
307 mNotificationTimer->stop(); |
293 mNotificationList.append( notification ); |
308 mNotificationList.append( notification ); |
294 mNotificationTimer->start(); |
309 mNotificationTimer->start(); |