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 |
|
19 #ifndef RADIOUIENGINE_H_ |
|
20 #define RADIOUIENGINE_H_ |
|
21 |
|
22 // System includes |
|
23 #include <QObject> |
|
24 #include <QString> |
|
25 #include <QScopedPointer> |
|
26 #include <QSharedPointer> |
|
27 |
|
28 // User includes |
|
29 #include "radiouiengineexport.h" |
|
30 #include "radio_global.h" |
|
31 |
|
32 // Forward declarations |
|
33 class RadioUiEnginePrivate; |
|
34 class RadioStationModel; |
|
35 class RadioSettingsIf; |
|
36 class RadioStation; |
|
37 class RadioHistoryModel; |
|
38 class RadioHistoryItem; |
|
39 class RadioScannerEngine; |
|
40 class RadioMonitorService; |
|
41 |
|
42 typedef QSharedPointer<RadioScannerEngine> RadioScannerEnginePtr; |
|
43 |
|
44 // Constants |
|
45 const uint DEFAULT_MIN_FREQUENCY = 87500000; |
|
46 |
|
47 class UI_ENGINE_DLL_EXPORT RadioUiEngine : public QObject |
|
48 { |
|
49 Q_OBJECT |
|
50 Q_DECLARE_PRIVATE_D( d_ptr.data(), RadioUiEngine ) |
|
51 Q_DISABLE_COPY( RadioUiEngine ) |
|
52 |
|
53 friend class RadioScannerEngine; |
|
54 |
|
55 public: // Static functions that are used before the ui engine is created |
|
56 |
|
57 /*! |
|
58 * Gets the last tuned frequency from central repository |
|
59 */ |
|
60 static uint lastTunedFrequency( uint defaultFrequency = DEFAULT_MIN_FREQUENCY ); |
|
61 |
|
62 /*! |
|
63 * Gets the last used volume level |
|
64 */ |
|
65 static int lastVolume(); |
|
66 |
|
67 /*! |
|
68 * Launches the radio server process |
|
69 */ |
|
70 static void launchRadioServer(); |
|
71 |
|
72 public: |
|
73 |
|
74 RadioUiEngine( QObject* parent = 0 ); |
|
75 ~RadioUiEngine(); |
|
76 |
|
77 bool isInitialized() const; |
|
78 |
|
79 bool init(); |
|
80 |
|
81 bool isFirstTimeStart(); |
|
82 void setFirstTimeStartPerformed( bool firstTimeStartPerformed ); |
|
83 |
|
84 void setPowerOn(); |
|
85 void setPowerOff( int delay = 0 ); |
|
86 bool isPoweringOff() const; |
|
87 |
|
88 /** |
|
89 * Getters for things owned by the engine |
|
90 */ |
|
91 RadioSettingsIf& settings(); |
|
92 RadioStationModel& stationModel(); |
|
93 RadioHistoryModel& historyModel(); |
|
94 RadioScannerEnginePtr createScannerEngine(); |
|
95 RadioScannerEngine* scannerEngine(); |
|
96 |
|
97 bool isRadioOn() const; |
|
98 bool isScanning() const; |
|
99 bool isMuted() const; |
|
100 bool isAntennaAttached() const; |
|
101 bool isUsingLoudspeaker() const; |
|
102 |
|
103 RadioRegion::Region region() const; |
|
104 uint currentFrequency() const; |
|
105 uint minFrequency() const; |
|
106 uint maxFrequency() const; |
|
107 uint frequencyStepSize() const; |
|
108 |
|
109 void setMute( bool muted ); |
|
110 |
|
111 QList<RadioStation> stationsInRange( uint minFrequency, uint maxFrequency ); |
|
112 |
|
113 QString genreToString( int genre, GenreTarget::Target target ); |
|
114 |
|
115 bool isSongRecognitionAppAvailable(); |
|
116 |
|
117 void addRecognizedSong( const QString& artist, const QString& title, const RadioStation& station ); |
|
118 |
|
119 uint skipStation( StationSkip::Mode mode, uint startFrequency = 0, const int reason = TuneReason::Skip ); |
|
120 |
|
121 enum MusicStore{ OviStore, OtherStore }; |
|
122 void openMusicStore( const RadioHistoryItem& item, MusicStore store = OviStore ); |
|
123 |
|
124 void launchBrowser( const QString& url ); |
|
125 |
|
126 void setManualSeekMode( bool manualSeek ); |
|
127 bool isInManualSeekMode() const; |
|
128 |
|
129 /** |
|
130 * Tunes the radio engine to given frequency |
|
131 */ |
|
132 void setFrequency( uint frequency, const int reason = TuneReason::Unspecified ); |
|
133 |
|
134 signals: |
|
135 |
|
136 void tunedToFrequency( uint frequency, int commandSender ); |
|
137 void seekingStarted( int direction ); |
|
138 void radioStatusChanged( bool radioIsOn ); |
|
139 |
|
140 void rdsAvailabilityChanged( bool available ); |
|
141 |
|
142 void volumeChanged( int volume ); |
|
143 void muteChanged( bool muted ); |
|
144 |
|
145 void audioRouteChanged( bool loudspeaker ); |
|
146 void antennaStatusChanged( bool connected ); |
|
147 |
|
148 void powerOffRequested(); |
|
149 |
|
150 public slots: |
|
151 |
|
152 /*! |
|
153 * volume update command slot for the engine |
|
154 */ |
|
155 void setVolume( int volume ); |
|
156 void toggleMute(); |
|
157 void toggleAudioRoute(); |
|
158 |
|
159 void seekStation( int seekDirection ); |
|
160 |
|
161 void launchSongRecognition(); |
|
162 |
|
163 private: |
|
164 |
|
165 /** |
|
166 * functions used only by the private class to get signals emitted |
|
167 */ |
|
168 void emitTunedToFrequency( uint frequency, int commandSender ); |
|
169 void emitSeekingStarted( Seek::Direction direction ); |
|
170 void emitRadioStatusChanged( bool radioIsOn ); |
|
171 void emitRdsAvailabilityChanged( bool available ); |
|
172 void emitVolumeChanged( int volume ); |
|
173 void emitMuteChanged( bool muted ); |
|
174 void emitAudioRouteChanged( bool loudspeaker ); |
|
175 void emitAntennaStatusChanged( bool connected ); |
|
176 |
|
177 private: // data |
|
178 |
|
179 /** |
|
180 * Unmodifiable pointer to the private implementation |
|
181 */ |
|
182 const QScopedPointer<RadioUiEnginePrivate> d_ptr; |
|
183 |
|
184 }; |
|
185 |
|
186 |
|
187 #endif // RADIOUIENGINE_H_ |
|