67 mVolume( 5 ), |
67 mVolume( 5 ), |
68 mMaxVolume( 10000 ), |
68 mMaxVolume( 10000 ), |
69 mFrequencyStepSize( 50000 ), |
69 mFrequencyStepSize( 50000 ), |
70 mRegionId( RadioRegion::Default ), |
70 mRegionId( RadioRegion::Default ), |
71 mMinFrequency( 87500000 ), |
71 mMinFrequency( 87500000 ), |
72 mMaxFrequency( 108000000 ) |
72 mMaxFrequency( 108000000 ), |
|
73 mManualSeekMode( false ) |
73 { |
74 { |
74 ::theInstance = this; |
75 ::theInstance = this; |
75 mEngineSettings.reset( new QSettings( "Nokia", "QtFmRadio" ) ); |
76 mEngineSettings.reset( new QSettings( "Nokia", "QtFmRadio" ) ); |
76 mFrequency = mEngineSettings->value( KKeyFrequency ).toUInt(); |
77 mFrequency = mEngineSettings->value( KKeyFrequency ).toUInt(); |
77 if ( mFrequency == 0 ) { |
78 if ( mFrequency == 0 ) { |
78 mFrequency = mMinFrequency; |
79 mFrequency = mMinFrequency; |
79 } |
80 } |
80 |
81 |
81 connectAndTest( mTuneTimer, SIGNAL(timeout()), this, SLOT(frequencyEvent()) ); |
82 Radio::connect( mTuneTimer, SIGNAL(timeout()), this, SLOT(frequencyEvent()) ); |
82 mTuneTimer->setSingleShot( true ); |
83 mTuneTimer->setSingleShot( true ); |
83 } |
84 } |
84 |
85 |
85 /*! |
86 /*! |
86 * |
87 * |
101 } |
102 } |
102 |
103 |
103 /*! |
104 /*! |
104 * Initializes the private implementation |
105 * Initializes the private implementation |
105 */ |
106 */ |
106 void RadioEngineWrapperPrivate::init() |
107 bool RadioEngineWrapperPrivate::init() |
107 { |
108 { |
108 mUseLoudspeaker = false; |
109 mUseLoudspeaker = false; |
109 if ( !mUseLoudspeaker ) { |
110 if ( !mUseLoudspeaker ) { |
110 RUN_NOTIFY_LOOP( mObservers, audioRouteChanged( false ) ); |
111 RUN_NOTIFY_LOOP( mObservers, audioRouteChanged( false ) ); |
111 } |
112 } |
112 |
113 |
113 parseData(); |
114 parseData(); |
114 } |
|
115 |
|
116 /*! |
|
117 * Starts up the radio engine |
|
118 */ |
|
119 bool RadioEngineWrapperPrivate::isEngineConstructed() |
|
120 { |
|
121 return true; |
115 return true; |
122 } |
116 } |
123 |
117 |
124 /*! |
118 /*! |
125 * Returns the settings handler owned by the engine |
119 * Returns the settings handler owned by the engine |
134 } |
128 } |
135 |
129 |
136 /*! |
130 /*! |
137 * Tunes to the given frequency |
131 * Tunes to the given frequency |
138 */ |
132 */ |
139 void RadioEngineWrapperPrivate::tuneFrequency( uint frequency, const int reason ) |
133 void RadioEngineWrapperPrivate::setFrequency( uint frequency, const int reason ) |
140 { |
134 { |
141 mNextFrequency = frequency; |
135 mNextFrequency = frequency; |
142 mTuneReason = reason; |
136 mTuneReason = reason; |
|
137 |
143 mTuneTimer->stop(); |
138 mTuneTimer->stop(); |
144 mTuneTimer->start( 500 ); |
139 if ( !mManualSeekMode ) { |
145 } |
140 mTuneTimer->start( 500 ); |
146 |
141 } else { |
147 /*! |
142 frequencyEvent(); |
148 * Tunes to the given frequency after a delay |
143 } |
149 */ |
144 } |
150 void RadioEngineWrapperPrivate::tuneWithDelay( uint frequency, const int reason ) |
145 |
151 { |
146 /*! |
152 mNextFrequency = frequency; |
147 * |
|
148 */ |
|
149 ObserverList& RadioEngineWrapperPrivate::observers() |
|
150 { |
|
151 return mObservers; |
|
152 } |
|
153 |
|
154 /*! |
|
155 * |
|
156 */ |
|
157 void RadioEngineWrapperPrivate::startSeeking( Seek::Direction direction, const int reason ) |
|
158 { |
153 mTuneReason = reason; |
159 mTuneReason = reason; |
154 mTuneTimer->stop(); |
160 mNextFrequency = 0; |
155 mTuneTimer->start( 1500 ); |
|
156 } |
|
157 |
|
158 /*! |
|
159 * |
|
160 */ |
|
161 ObserverList& RadioEngineWrapperPrivate::observers() |
|
162 { |
|
163 return mObservers; |
|
164 } |
|
165 |
|
166 /*! |
|
167 * |
|
168 */ |
|
169 void RadioEngineWrapperPrivate::startSeeking( Seeking::Direction direction, const int reason ) |
|
170 { |
|
171 mTuneReason = reason; |
|
172 |
161 |
173 // Find the previous and next favorite from current frequency |
162 // Find the previous and next favorite from current frequency |
174 uint previous = 0; |
163 uint previous = 0; |
175 uint next = 0; |
164 uint next = 0; |
176 for( int i = 0; i < KScanFrequencyCount; ++i ) { |
165 for( int i = 0; i < KScanFrequencyCount; ++i ) { |
284 /*! |
273 /*! |
285 * Private slot |
274 * Private slot |
286 */ |
275 */ |
287 void RadioEngineWrapperPrivate::frequencyEvent() |
276 void RadioEngineWrapperPrivate::frequencyEvent() |
288 { |
277 { |
289 mFrequency = mNextFrequency; |
278 if ( mNextFrequency > 0 ) { |
290 mEngineSettings->setValue( KKeyFrequency, mFrequency ); |
279 mFrequency = mNextFrequency; |
291 |
280 mEngineSettings->setValue( KKeyFrequency, mFrequency ); |
292 RUN_NOTIFY_LOOP( mObservers, tunedToFrequency( mFrequency, mTuneReason ) ); |
281 } |
|
282 |
|
283 if ( !mManualSeekMode ) { |
|
284 RUN_NOTIFY_LOOP( mObservers, tunedToFrequency( mNextFrequency, mTuneReason ) ); |
|
285 } |
293 } |
286 } |
294 |
287 |
295 /*! |
288 /*! |
296 * Private slot |
289 * Private slot |
297 */ |
290 */ |