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