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: Implementation for the FM Radio Content Publisher Plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AknUtils.h> |
|
19 #include <bautils.h> |
|
20 #include <coemain.h> |
|
21 #include <data_caging_path_literals.hrh> |
|
22 #include <data_caging_paths_strings.hrh> |
|
23 #include <e32cmn.h> |
|
24 #include <ecom/implementationproxy.h> |
|
25 #include <liwvariant.h> |
|
26 #include <StringLoader.h> |
|
27 #include <AknsConstants.h> |
|
28 #include <AknsItemID.h> |
|
29 #include <fmradiomcpplugin.rsg> |
|
30 #include <fmradio.mbg> |
|
31 |
|
32 #include "fmradioactionhandler.h" |
|
33 #include "fmradioactionhandler.hrh" |
|
34 #include "fmradioactionhandlerdefs.h" |
|
35 #include "fmradioactiveidleengine.h" |
|
36 #include "fmradioactiveidleenginenotifyhandler.h" |
|
37 #include "fmradiodefines.h" |
|
38 #include "debug.h" |
|
39 #include "fmradiomcpplugin.h" |
|
40 #include "fmradiomcpplugin.hrh" |
|
41 |
|
42 _LIT( KFMRadioMifFileName, "fmradio.mif" ); |
|
43 _LIT( KFMRadioMifDir, "\\resource\\apps\\" ); |
|
44 |
|
45 _LIT( KFMRadioMCPPluginResourceFileName, "fmradiomcpplugin.rsc" ); |
|
46 _LIT8( KFMRadioPluginUid, "plugin_id" ); |
|
47 _LIT8( KFMRadioData, "data" ); |
|
48 _LIT8( KType, "type" ); |
|
49 |
|
50 const TUint KFMRadioPrevious = 0x001; //000000000001 |
|
51 const TUint KFMRadioNext = 0x002; //000000000010 |
|
52 const TUint KFMRadioMute = 0x004; //000000000100 |
|
53 const TUint KFMRadioUnmute = 0x008; //000000001000 |
|
54 const TUint KFMRadioPreviousDimmed = 0x010; //000000010000 |
|
55 const TUint KFMRadioNextDimmed = 0x020; //000000100000 |
|
56 const TUint KFMRadioMuteDimmed = 0x040; //000001000000 |
|
57 const TUint KFMRadioUnmuteDimmed = 0x080; //000010000000 |
|
58 |
|
59 CFMRadioMCPPlugin* CFMRadioMCPPlugin::NewL( MMCPPluginObserver* aObserver ) |
|
60 { |
|
61 CFMRadioMCPPlugin* self = new ( ELeave ) CFMRadioMCPPlugin( aObserver ); |
|
62 CleanupStack::PushL( self ); |
|
63 |
|
64 self->ConstructL(); |
|
65 |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 CFMRadioMCPPlugin::~CFMRadioMCPPlugin() |
|
71 { |
|
72 if ( iResourceOffset > 0 ) |
|
73 { |
|
74 CCoeEnv::Static()->DeleteResourceFile( iResourceOffset ); |
|
75 } |
|
76 |
|
77 delete iEngine; |
|
78 iAntennaNotConnectedText.Close(); |
|
79 iTuningText.Close(); |
|
80 iSavedStationFormat.Close(); |
|
81 iSavedStationFormatNoName.Close(); |
|
82 iFrequencyFormat.Close(); |
|
83 |
|
84 iMifFileName.Close(); |
|
85 } |
|
86 |
|
87 CFMRadioMCPPlugin::CFMRadioMCPPlugin( MMCPPluginObserver* aObserver ) |
|
88 : iObserver( aObserver ) |
|
89 { |
|
90 } |
|
91 |
|
92 void CFMRadioMCPPlugin::ConstructL() |
|
93 { |
|
94 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::ConstructL" ))); |
|
95 InitializeResourceLoadingL(); |
|
96 |
|
97 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
98 |
|
99 iAntennaNotConnectedText.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_CON_HEADSET, coeEnv ) ); |
|
100 iTuningText.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_TUNING, coeEnv ) ); |
|
101 iSavedStationFormat.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_STATION_SAVED, coeEnv ) ); |
|
102 iSavedStationFormatNoName.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_STATION_SAVED_FREQ, coeEnv ) ); |
|
103 iFrequencyFormat.Assign( StringLoader::LoadL( R_QTN_FMRADIO_WIDGET_NOTSAVED_FREQUENCY, coeEnv ) ); |
|
104 |
|
105 // Release the resource file, because we don't want to keep file handle open. |
|
106 // That would prevent updating the binary with SIS. |
|
107 if ( iResourceOffset > 0 ) |
|
108 { |
|
109 coeEnv->DeleteResourceFile( iResourceOffset ); |
|
110 iResourceOffset = 0; |
|
111 } |
|
112 |
|
113 TFindFile finder( coeEnv->FsSession() ); |
|
114 TInt err = finder.FindByDir( KFMRadioMifFileName, KFMRadioMifDir ); |
|
115 if ( err == KErrNone ) |
|
116 { |
|
117 iMifFileName.CreateL( finder.File() ); |
|
118 } |
|
119 |
|
120 iEngine = CFMRadioActiveIdleEngine::NewL( *this ); |
|
121 iEngine->ActivateL(); |
|
122 |
|
123 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::ConstructL - Exiting." ))); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // Initialize resource file for loading resources. |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CFMRadioMCPPlugin::InitializeResourceLoadingL() |
|
131 { |
|
132 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
133 RFs fs( coeEnv->FsSession() ); |
|
134 TFileName fileName; |
|
135 TFileName baseResource; |
|
136 TFindFile finder( fs ); |
|
137 TLanguage language( ELangNone ); |
|
138 |
|
139 TParsePtrC parse( KFMRadioMCPPluginResourceFileName ); |
|
140 _LIT( resourceFileWildExt, ".r*" ); |
|
141 |
|
142 // Make sure to find all resource files, not only .rsc files as it may be so |
|
143 // that there is only .r01, .r02, etc. files available |
|
144 fileName.Copy( parse.Name() ); |
|
145 fileName.Append( resourceFileWildExt ); |
|
146 |
|
147 // TFindFile applies search order that is from |
|
148 // drive Y to A, then Z |
|
149 CDir* entries = NULL; |
|
150 TInt err = finder.FindWildByDir( fileName , KDC_RESOURCE_FILES_DIR, entries ); |
|
151 delete entries; |
|
152 entries = NULL; |
|
153 TBool found = EFalse; |
|
154 while ( !found && err == KErrNone ) |
|
155 { |
|
156 // Found file |
|
157 fileName.Zero(); |
|
158 TParsePtrC foundPath( finder.File() ); |
|
159 fileName.Copy( foundPath.DriveAndPath() ); |
|
160 fileName.Append( KFMRadioMCPPluginResourceFileName ); |
|
161 BaflUtils::NearestLanguageFile( fs, fileName, language ); |
|
162 if ( language != ELangNone && BaflUtils::FileExists( fs, fileName ) ) |
|
163 { |
|
164 found = ETrue; |
|
165 iResourceOffset = coeEnv->AddResourceFileL( fileName ); |
|
166 } |
|
167 else |
|
168 { |
|
169 if ( language == ELangNone && |
|
170 !baseResource.Compare( KNullDesC ) && |
|
171 BaflUtils::FileExists( fs, fileName ) ) |
|
172 { |
|
173 baseResource.Copy( fileName ); |
|
174 } |
|
175 err = finder.FindWild( entries ); |
|
176 delete entries; |
|
177 entries = NULL; |
|
178 } |
|
179 } |
|
180 |
|
181 if ( !found && baseResource.Compare( KNullDesC ) ) |
|
182 { |
|
183 // If we found *.rsc then better to use that than nothing |
|
184 if ( BaflUtils::FileExists( fs, baseResource ) ) |
|
185 { |
|
186 iResourceOffset = coeEnv->AddResourceFileL( baseResource ); |
|
187 found = ETrue; |
|
188 } |
|
189 } |
|
190 |
|
191 if( !found ) |
|
192 { |
|
193 User::Leave( KErrNotFound ); |
|
194 } |
|
195 } |
|
196 |
|
197 void CFMRadioMCPPlugin::Deactivate() |
|
198 { |
|
199 iActive = EFalse; |
|
200 } |
|
201 |
|
202 void CFMRadioMCPPlugin::ActivateL() |
|
203 { |
|
204 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::ActivateL()" ))); |
|
205 iActive = ETrue; |
|
206 iObserver->BecameActiveL( this ); |
|
207 |
|
208 iObserver->PublishTextL( this, EMusicWidgetDefaultText, KNullDesC ); |
|
209 |
|
210 iObserver->PublishImageL( this, EMusicWidgetImage1, |
|
211 KAknsIIDQgnIndiRadioDefault, |
|
212 iMifFileName, |
|
213 EMbmFmradioQgn_indi_radio_default, |
|
214 EMbmFmradioQgn_indi_radio_default_mask ); |
|
215 |
|
216 InstallFMRadioCommandActionL( KFMRadioCommandValueStartNowPlaying, EMusicWidgetTrigger1 ); |
|
217 HandleChannelChangeL( iEngine->Channel() ); |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CFMRadioMCPPlugin::UpdatePublishedToolBarL |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CFMRadioMCPPlugin::UpdatePublishedToolBarL( TUint aToolBarState ) |
|
225 { |
|
226 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - Entering." ))); |
|
227 if ( iActive ) |
|
228 { |
|
229 TAknsItemID iconId; |
|
230 if ( KFMRadioPrevious & aToolBarState ) |
|
231 { |
|
232 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 1 Enter" ))); |
|
233 iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnPropImageTbPrev ); |
|
234 iObserver->PublishImageL( this, |
|
235 EMusicWidgetToolbarB1, |
|
236 iconId, |
|
237 iMifFileName, |
|
238 EMbmFmradioQgn_prop_image_tb_prev, |
|
239 EMbmFmradioQgn_prop_image_tb_prev_mask ); |
|
240 InstallFMRadioCommandActionL( KFMRadioCommandValueStepPrevious, EMusicWidgetTB1Trigger ); |
|
241 iTbPreviousState = KFMRadioPrevious; |
|
242 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 1 Exit" ))); |
|
243 } |
|
244 |
|
245 if ( KFMRadioPreviousDimmed & aToolBarState ) |
|
246 { |
|
247 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 2 Enter" ))); |
|
248 iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnPropImageTbPrevDimmed ); |
|
249 iObserver->PublishImageL( this, |
|
250 EMusicWidgetToolbarB1, |
|
251 iconId, |
|
252 iMifFileName, |
|
253 EMbmFmradioQgn_prop_image_tb_prev_dimmed, |
|
254 EMbmFmradioQgn_prop_image_tb_prev_dimmed_mask ); |
|
255 InstallEmptyActionL( EMusicWidgetTB1Trigger ); |
|
256 iTbPreviousState = KFMRadioPreviousDimmed; |
|
257 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 2 Exit" ))); |
|
258 } |
|
259 |
|
260 if ( KFMRadioNext & aToolBarState ) |
|
261 { |
|
262 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 3 Enter" ))); |
|
263 iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnPropImageTbNext ); |
|
264 iObserver->PublishImageL( this, |
|
265 EMusicWidgetToolbarB3, |
|
266 iconId, |
|
267 iMifFileName, |
|
268 EMbmFmradioQgn_prop_image_tb_next, |
|
269 EMbmFmradioQgn_prop_image_tb_next_mask ); |
|
270 InstallFMRadioCommandActionL( KFMRadioCommandValueStepNext, EMusicWidgetTB3Trigger ); |
|
271 iTbNextState = KFMRadioNext; |
|
272 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 3 Exit" ))); |
|
273 } |
|
274 |
|
275 if ( KFMRadioNextDimmed & aToolBarState ) |
|
276 { |
|
277 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 4 Enter" ))); |
|
278 iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnPropImageTbNextDimmed ); |
|
279 iObserver->PublishImageL( this, |
|
280 EMusicWidgetToolbarB3, |
|
281 iconId, |
|
282 iMifFileName, |
|
283 EMbmFmradioQgn_prop_image_tb_next_dimmed, |
|
284 EMbmFmradioQgn_prop_image_tb_next_dimmed_mask ); |
|
285 InstallEmptyActionL( EMusicWidgetTB3Trigger ); |
|
286 iTbNextState = KFMRadioNextDimmed; |
|
287 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 4 Exit" ))); |
|
288 } |
|
289 |
|
290 if ( KFMRadioMute & aToolBarState ) |
|
291 { |
|
292 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 5 Enter" ))); |
|
293 iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnIndiMusicWidgetTbRadioSound ); |
|
294 iObserver->PublishImageL( this, |
|
295 EMusicWidgetToolbarB2, |
|
296 iconId, |
|
297 iMifFileName, |
|
298 EMbmFmradioQgn_indi_music_widget_tb_radio_sound, |
|
299 EMbmFmradioQgn_indi_music_widget_tb_radio_sound_mask ); |
|
300 InstallFMRadioCommandActionL( KFMRadioCommandValueUnmute, EMusicWidgetTB2Trigger ); |
|
301 iTbMuteUnmuteState = KFMRadioMute; |
|
302 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 5 Exit" ))); |
|
303 } |
|
304 |
|
305 if ( KFMRadioUnmute & aToolBarState ) |
|
306 { |
|
307 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 6 Enter" ))); |
|
308 iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnIndiMusicWidgetTbRadioSoundMuted ); |
|
309 iObserver->PublishImageL( this, |
|
310 EMusicWidgetToolbarB2, |
|
311 iconId, |
|
312 iMifFileName, |
|
313 EMbmFmradioQgn_indi_music_widget_tb_radio_sound_muted, |
|
314 EMbmFmradioQgn_indi_music_widget_tb_radio_sound_muted_mask ); |
|
315 InstallFMRadioCommandActionL( KFMRadioCommandValueMute, EMusicWidgetTB2Trigger ); |
|
316 iTbMuteUnmuteState = KFMRadioUnmute; |
|
317 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 6 Exit" ))); |
|
318 } |
|
319 |
|
320 if ( KFMRadioMuteDimmed & aToolBarState ) |
|
321 { |
|
322 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 7 Enter" ))); |
|
323 iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnIndiMusicWidgetTbRadioSoundDimmed ); |
|
324 iObserver->PublishImageL( this, |
|
325 EMusicWidgetToolbarB2, |
|
326 iconId, |
|
327 iMifFileName, |
|
328 EMbmFmradioQgn_indi_music_widget_tb_radio_sound_dimmed, |
|
329 EMbmFmradioQgn_indi_music_widget_tb_radio_sound_dimmed_mask ); |
|
330 InstallEmptyActionL( EMusicWidgetTB2Trigger ); |
|
331 iTbMuteUnmuteState = KFMRadioMuteDimmed; |
|
332 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 7 Exit" ))); |
|
333 } |
|
334 |
|
335 if ( KFMRadioUnmuteDimmed & aToolBarState ) |
|
336 { |
|
337 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 8 Enter" ))); |
|
338 iconId.Set( EAknsMajorGeneric, EAknsMinorGenericQgnIndiMusicWidgetTbRadioSoundMutedDimmed ); |
|
339 iObserver->PublishImageL( this, |
|
340 EMusicWidgetToolbarB2, |
|
341 iconId, |
|
342 iMifFileName, |
|
343 EMbmFmradioQgn_indi_music_widget_tb_radio_sound_muted_dimmed, |
|
344 EMbmFmradioQgn_indi_music_widget_tb_radio_sound_muted_dimmed_mask ); |
|
345 InstallEmptyActionL( EMusicWidgetTB2Trigger ); |
|
346 iTbMuteUnmuteState = KFMRadioUnmuteDimmed; |
|
347 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdatePublishedToolBarL - 8 Exit" ))); |
|
348 } |
|
349 } |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // CFMRadioMCPPlugin::UpdateToolBarL |
|
354 // --------------------------------------------------------------------------- |
|
355 // |
|
356 void CFMRadioMCPPlugin::UpdateToolBarL( TBool aForceApplicationClosing ) |
|
357 { |
|
358 if ( iActive ) |
|
359 { |
|
360 TUint muteDimmedState = iEngine->MuteState() == EFMRadioPSMuteStateOn ? |
|
361 KFMRadioUnmuteDimmed : KFMRadioMuteDimmed; |
|
362 // Update Next and Previous buttons. |
|
363 if ( iEngine->AntennaStatus() == EFMRadioPSHeadsetDisconnected ) |
|
364 { |
|
365 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 1" ))); |
|
366 UpdatePublishedToolBarL( KFMRadioPreviousDimmed | muteDimmedState | KFMRadioNextDimmed); |
|
367 return; |
|
368 } |
|
369 else if ( iEngine->ApplicationRunningState() != EFMRadioPSApplicationRunning || aForceApplicationClosing ) |
|
370 { |
|
371 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 2" ))); |
|
372 UpdatePublishedToolBarL( KFMRadioPreviousDimmed | muteDimmedState | KFMRadioNextDimmed); |
|
373 return; |
|
374 } |
|
375 else if ( iEngine->PowerState() != EFMRadioPSRadioPowerOn ) |
|
376 { |
|
377 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 3" ))); |
|
378 UpdatePublishedToolBarL( KFMRadioPreviousDimmed | muteDimmedState | KFMRadioNextDimmed); |
|
379 return; |
|
380 } |
|
381 else if ( iEngine->TuningState() != EFMRadioPSTuningUninitialized ) |
|
382 { |
|
383 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 4" ))); |
|
384 UpdatePublishedToolBarL( KFMRadioPreviousDimmed | KFMRadioNextDimmed ); |
|
385 } |
|
386 else if ( iPresetCount > 1 || ( iPresetCount == 1 && iEngine->Channel() == KErrNotFound ) ) |
|
387 { |
|
388 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 5" ))); |
|
389 UpdatePublishedToolBarL( KFMRadioPrevious | KFMRadioNext ); |
|
390 } |
|
391 else |
|
392 { |
|
393 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 6" ))); |
|
394 UpdatePublishedToolBarL( KFMRadioPreviousDimmed | KFMRadioNextDimmed ); |
|
395 } |
|
396 |
|
397 // Update Mute/Unmute button |
|
398 if ( iEngine->ApplicationRunningState() != EFMRadioPSApplicationRunning || aForceApplicationClosing ) |
|
399 { |
|
400 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 7" ))); |
|
401 UpdatePublishedToolBarL( muteDimmedState ); |
|
402 } |
|
403 else if ( iEngine->TuningState() != EFMRadioPSTuningUninitialized ) |
|
404 { |
|
405 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 8" ))); |
|
406 UpdatePublishedToolBarL( muteDimmedState ); |
|
407 } |
|
408 else |
|
409 { |
|
410 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateToolBarL - 9" ))); |
|
411 HandleMuteStateChangeL( iEngine->MuteState() ); |
|
412 } |
|
413 } |
|
414 } |
|
415 // --------------------------------------------------------------------------- |
|
416 // CFMRadioMCPPlugin::UpdateMusicWidgetTextL |
|
417 // --------------------------------------------------------------------------- |
|
418 // |
|
419 void CFMRadioMCPPlugin::UpdateMusicWidgetTextL( TBool aForceApplicationClosing ) |
|
420 { |
|
421 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL" ))); |
|
422 if ( iActive ) |
|
423 { |
|
424 TInt rightToLeftCharWidth = AknLayoutUtils::LayoutMirrored() ? sizeof(TText16) : 0; |
|
425 |
|
426 // Homescreen publishing |
|
427 if ( iEngine->AntennaStatus() == EFMRadioPSHeadsetDisconnected && !aForceApplicationClosing ) |
|
428 { |
|
429 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing HS antenna not connected: \"%S\""), &iAntennaNotConnectedText )); |
|
430 iObserver->PublishTextL( this, EMusicWidgetText1, iAntennaNotConnectedText ); |
|
431 } |
|
432 else if ( iEngine->TuningState() != EFMRadioPSTuningUninitialized && !aForceApplicationClosing ) |
|
433 { |
|
434 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing HS tuning: \"%S\""), &iTuningText )); |
|
435 iObserver->PublishTextL( this, EMusicWidgetText1, iTuningText ); |
|
436 } |
|
437 else if ( iPresetCount && iEngine->Channel() != KErrNotFound ) |
|
438 { |
|
439 if( iEngine->ChannelName().Length() ) |
|
440 { |
|
441 // Station saved and name is available |
|
442 RBuf name; |
|
443 // For widget |
|
444 // Preserve space for the channel name, format string and maximum index number |
|
445 name.CreateL( iEngine->ChannelName().Length() + |
|
446 iSavedStationFormat.Length() + |
|
447 KDefaultRealWidth + |
|
448 rightToLeftCharWidth ); |
|
449 name.CleanupClosePushL(); |
|
450 StringLoader::Format( name, iSavedStationFormat, KErrNotFound, iEngine->Channel() + 1 ); |
|
451 |
|
452 HBufC* tempName = name.AllocL(); |
|
453 StringLoader::Format( name, *tempName, KErrNotFound, iEngine->ChannelName() ); |
|
454 delete tempName; |
|
455 tempName = NULL; |
|
456 |
|
457 if ( rightToLeftCharWidth ) |
|
458 { |
|
459 //E.g. 1. Name -> Name .1 |
|
460 name.Insert( 0, KRightToLeftMark ); |
|
461 } |
|
462 |
|
463 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Widget saved station: \"%S\""), &name )); |
|
464 iObserver->PublishTextL( this, EMusicWidgetText1, name ); |
|
465 CleanupStack::PopAndDestroy(); // name |
|
466 } |
|
467 else |
|
468 { |
|
469 // Station saved, but name for it is not available |
|
470 HBufC* frequencyString = FrequencyStringLC( iEngine->Frequency() ); |
|
471 RBuf formattedFrequency; |
|
472 |
|
473 // For widget |
|
474 formattedFrequency.CreateL( iSavedStationFormatNoName.Length() + |
|
475 frequencyString->Length() + |
|
476 KDefaultRealWidth + |
|
477 rightToLeftCharWidth ); |
|
478 formattedFrequency.CleanupClosePushL(); |
|
479 StringLoader::Format( formattedFrequency, iSavedStationFormatNoName, KErrNotFound, iEngine->Channel() + 1 ); |
|
480 |
|
481 HBufC* tempFrequency = formattedFrequency.AllocL(); |
|
482 StringLoader::Format( formattedFrequency, *tempFrequency, KErrNotFound, *frequencyString ); |
|
483 delete tempFrequency; |
|
484 tempFrequency = NULL; |
|
485 AknTextUtils::LanguageSpecificNumberConversion( formattedFrequency ); |
|
486 |
|
487 if ( rightToLeftCharWidth ) |
|
488 { |
|
489 //E.g. 1. Name -> Name .1 |
|
490 formattedFrequency.Insert( 0, KRightToLeftMark ); |
|
491 } |
|
492 |
|
493 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Widget saved station with frequency: \"%S\""), &formattedFrequency )); |
|
494 iObserver->PublishTextL( this, EMusicWidgetText1, formattedFrequency ); |
|
495 CleanupStack::PopAndDestroy( 2 ); // formattedFrequency, frequencyString |
|
496 } |
|
497 } |
|
498 else if ( iEngine->RDSProgramService().Length() > 0 ) |
|
499 { |
|
500 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing HS PS name: \"%S\""), &iEngine->RDSProgramService() )); |
|
501 iObserver->PublishTextL( this, EMusicWidgetText1, iEngine->RDSProgramService() ); |
|
502 } |
|
503 else |
|
504 { |
|
505 TInt currentFrequency = iEngine->Frequency(); |
|
506 // publish only valid frequency |
|
507 if ( currentFrequency > 0 ) |
|
508 { |
|
509 HBufC* frequencyString = FrequencyStringLC( currentFrequency ); |
|
510 |
|
511 RBuf formattedFrequency; |
|
512 // For widget |
|
513 // Preserve space for the format string and maximum index number |
|
514 formattedFrequency.CreateL( iFrequencyFormat.Length() + |
|
515 frequencyString->Length() + |
|
516 rightToLeftCharWidth ); |
|
517 formattedFrequency.CleanupClosePushL(); |
|
518 StringLoader::Format( formattedFrequency, iFrequencyFormat, KErrNotFound, *frequencyString ); |
|
519 AknTextUtils::LanguageSpecificNumberConversion( formattedFrequency ); |
|
520 |
|
521 if ( rightToLeftCharWidth ) |
|
522 { |
|
523 //E.g. 1. Name -> Name .1 |
|
524 formattedFrequency.Insert( 0, KRightToLeftMark ); |
|
525 } |
|
526 |
|
527 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::UpdateMusicWidgetTextL - Publishing Music Widget frequency: \"%S\""), &formattedFrequency )); |
|
528 iObserver->PublishTextL( this, EMusicWidgetText1, formattedFrequency ); |
|
529 CleanupStack::PopAndDestroy( 2 ); // formattedFrequency,frequencyString |
|
530 } |
|
531 else |
|
532 { |
|
533 // Publish empty text instead of 0.00 MHz |
|
534 iObserver->PublishTextL( this, EMusicWidgetText1, KNullDesC ); |
|
535 } |
|
536 } |
|
537 } |
|
538 } |
|
539 |
|
540 // --------------------------------------------------------------------------- |
|
541 // CFMRadioMCPPlugin::FrequencyStringLC |
|
542 // --------------------------------------------------------------------------- |
|
543 // |
|
544 HBufC* CFMRadioMCPPlugin::FrequencyStringLC( TInt aFrequency ) |
|
545 { |
|
546 TReal frequency = static_cast<TReal>( aFrequency / static_cast<TReal>( KHzConversionFactor )); |
|
547 TRealFormat format( KFrequencyMaxLength, iEngine->FrequencyDecimalCount() ); |
|
548 TBuf<KDefaultRealWidth> frequencyString; |
|
549 frequencyString.Num( frequency, format ); |
|
550 |
|
551 return frequencyString.AllocLC(); |
|
552 } |
|
553 |
|
554 void CFMRadioMCPPlugin::HandleRadioVolumeChangeL( TInt /* aVolume */ ) |
|
555 { |
|
556 } |
|
557 |
|
558 void CFMRadioMCPPlugin::HandleTuningStateChangeL( TFMRadioPSTuningState FDEBUGVAR( aTuningState ) ) |
|
559 { |
|
560 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleTuningStateChangeL: aTuningState=[%d]"), aTuningState)); |
|
561 |
|
562 if ( iActive ) |
|
563 { |
|
564 UpdateMusicWidgetTextL(); |
|
565 UpdateToolBarL(); |
|
566 } |
|
567 |
|
568 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleTuningStateChangeL - Exiting." ))); |
|
569 } |
|
570 |
|
571 void CFMRadioMCPPlugin::HandleFrequencyChangeL( TInt FDEBUGVAR( aFrequency ) ) |
|
572 { |
|
573 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleFrequencyChangeL: aFrequency=%d"), aFrequency)); |
|
574 } |
|
575 |
|
576 void CFMRadioMCPPlugin::HandleChannelChangeL( TInt FDEBUGVAR( aId ) ) |
|
577 { |
|
578 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelChangeL: aId=[%d]"), aId )); |
|
579 if ( iActive ) |
|
580 { |
|
581 UpdateMusicWidgetTextL(); |
|
582 UpdateToolBarL(); |
|
583 } |
|
584 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelChangeL - Exiting." ))); |
|
585 } |
|
586 |
|
587 void CFMRadioMCPPlugin::HandleChannelModifyL( TInt aId ) |
|
588 { |
|
589 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelModifyL: aId=[%d]"), aId )); |
|
590 if ( iActive && aId == iEngine->Channel() ) |
|
591 { |
|
592 UpdateMusicWidgetTextL(); |
|
593 } |
|
594 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelModifyL - Exiting." ))); |
|
595 } |
|
596 |
|
597 void CFMRadioMCPPlugin::HandleMuteStateChangeL( TFMRadioPSRadioMuteState aMuteState ) |
|
598 { |
|
599 if ( iActive ) |
|
600 { |
|
601 switch( aMuteState ) |
|
602 { |
|
603 case EFMRadioPSMuteStateOn: |
|
604 if ( iEngine->ApplicationRunningState() != EFMRadioPSApplicationRunning || |
|
605 iEngine->AntennaStatus() == EFMRadioPSHeadsetDisconnected ) |
|
606 { |
|
607 UpdatePublishedToolBarL( KFMRadioUnmuteDimmed ); |
|
608 } |
|
609 else |
|
610 { |
|
611 UpdatePublishedToolBarL( KFMRadioUnmute ); |
|
612 } |
|
613 break; |
|
614 case EFMRadioPSMuteStateOff: |
|
615 case EFMRadioPSMuteStateUninitialized: |
|
616 if ( iEngine->ApplicationRunningState() != EFMRadioPSApplicationRunning || |
|
617 iEngine->AntennaStatus() == EFMRadioPSHeadsetDisconnected ) |
|
618 { |
|
619 UpdatePublishedToolBarL( KFMRadioMuteDimmed ); |
|
620 } |
|
621 else |
|
622 { |
|
623 UpdatePublishedToolBarL( KFMRadioMute ); |
|
624 } |
|
625 break; |
|
626 default:break; |
|
627 } |
|
628 } |
|
629 } |
|
630 |
|
631 void CFMRadioMCPPlugin::HandleApplicationRunningStateChangeL( TFMRadioPSApplicationRunningState aRunningState ) |
|
632 { |
|
633 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleApplicationRunningStateChangeL - aRunningState=%d"), aRunningState )); |
|
634 |
|
635 switch ( aRunningState ) |
|
636 { |
|
637 case EFMRadioPSApplicationRunning: |
|
638 break; |
|
639 case EFMRadioPSApplicationClosing: |
|
640 UpdateMusicWidgetTextL( ETrue ); |
|
641 UpdateToolBarL( ETrue ); |
|
642 Deactivate(); |
|
643 break; |
|
644 default: |
|
645 break; |
|
646 } |
|
647 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleApplicationRunningStateChangeL - Exiting." ))); |
|
648 } |
|
649 |
|
650 void CFMRadioMCPPlugin::HandleFrequencyDecimalCountChangeL( TFMRadioPSFrequencyDecimalCount /* aDecimalCount */ ) |
|
651 { |
|
652 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleFrequencyDecimalCountChangeL." ))); |
|
653 if ( iActive ) |
|
654 { |
|
655 UpdateMusicWidgetTextL(); |
|
656 } |
|
657 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleFrequencyDecimalCountChangeL - Exiting." ))); |
|
658 } |
|
659 |
|
660 void CFMRadioMCPPlugin::HandleAntennaStatusChangeL( TFMRadioPSHeadsetStatus /*aAntennaStatus*/ ) |
|
661 { |
|
662 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleAntennaStatusChangeL - Enter"))); |
|
663 if ( iActive ) |
|
664 { |
|
665 UpdateMusicWidgetTextL(); |
|
666 UpdateToolBarL(); |
|
667 } |
|
668 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleAntennaStatusChangeL - Exiting."))); |
|
669 } |
|
670 |
|
671 void CFMRadioMCPPlugin::HandlePresetListCountChangeL( TInt aPresetCount ) |
|
672 { |
|
673 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePresetListCountChangeL(%d) - Enter"), aPresetCount)); |
|
674 iPresetCount = aPresetCount; |
|
675 if ( iActive ) |
|
676 { |
|
677 if( !aPresetCount ) |
|
678 { |
|
679 UpdateMusicWidgetTextL(); |
|
680 } |
|
681 UpdateToolBarL(); |
|
682 } |
|
683 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePresetListCountChangeL - Exiting."))); |
|
684 } |
|
685 |
|
686 void CFMRadioMCPPlugin::HandlePresetListFocusChangeL( TInt FDEBUGVAR( aPresetFocus ) ) |
|
687 { |
|
688 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePresetListFocusChangeL - %d"), aPresetFocus )); |
|
689 } |
|
690 |
|
691 void CFMRadioMCPPlugin::HandleRDSProgramServiceChangeL( const TDesC& /*aProgramService*/ ) |
|
692 { |
|
693 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleRDSProgramServiceChangeL." ))); |
|
694 if ( iActive ) |
|
695 { |
|
696 UpdateMusicWidgetTextL(); |
|
697 } |
|
698 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleRDSProgramServiceChangeL - Exiting." ))); |
|
699 } |
|
700 |
|
701 void CFMRadioMCPPlugin::HandleRDSRadioTextChangeL( const TDesC& /*aRdsText*/ ) |
|
702 { |
|
703 } |
|
704 |
|
705 void CFMRadioMCPPlugin::HandleChannelNameChangeL( const TDesC& /*aName*/ ) |
|
706 { |
|
707 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandleChannelNameChangeL." ))); |
|
708 } |
|
709 |
|
710 void CFMRadioMCPPlugin::HandlePowerStateChangeL( TFMRadioPSRadioPowerState aPowerState ) |
|
711 { |
|
712 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePowerStateChangeL(%d)."), aPowerState )); |
|
713 if( aPowerState == EFMRadioPSRadioPowerOn ) |
|
714 { |
|
715 ActivateL(); |
|
716 } |
|
717 if ( iActive ) |
|
718 { |
|
719 UpdateMusicWidgetTextL(); |
|
720 UpdateToolBarL(); |
|
721 } |
|
722 FTRACE(FPrint(_L(" *** S60 FMRadio -- CFMRadioMCPPlugin::HandlePowerStateChangeL - Exiting." ))); |
|
723 } |
|
724 |
|
725 void CFMRadioMCPPlugin::InstallEmptyActionL( TMCPTriggerDestination aDestination ) |
|
726 { |
|
727 CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); |
|
728 iObserver->PublishActionL( this, aDestination, mapTrigger ); |
|
729 CleanupStack::PopAndDestroy( mapTrigger ); |
|
730 } |
|
731 |
|
732 void CFMRadioMCPPlugin::InstallFMRadioCommandActionL( const TDesC& aCommand, TMCPTriggerDestination aDestination ) |
|
733 { |
|
734 CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); |
|
735 CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC(); |
|
736 |
|
737 mapTrigger->InsertL( KFMRadioPluginUid, TLiwVariant( TUid::Uid( KFMRadioActionHandlerImplementationUid ) ) ); |
|
738 mapData->InsertL( KType, TLiwVariant( aCommand ) ); |
|
739 mapData->InsertL( KFMRadioCommand , TLiwVariant( aCommand ) ); |
|
740 mapTrigger->InsertL( KFMRadioData, TLiwVariant( mapData ) ); |
|
741 |
|
742 if ( iActive ) |
|
743 { |
|
744 iObserver->PublishActionL( this, aDestination, mapTrigger ); |
|
745 } |
|
746 |
|
747 CleanupStack::PopAndDestroy( mapData ); |
|
748 CleanupStack::PopAndDestroy( mapTrigger ); |
|
749 } |
|
750 |
|
751 /** Provides a key-value pair table, that is used to identify the correct construction function for the requested interface. */ |
|
752 const TImplementationProxy KFMRadioMCPPluginImplementationTable[] = |
|
753 { |
|
754 IMPLEMENTATION_PROXY_ENTRY( KFMRadioMCPPluginImplementationUid, CFMRadioMCPPlugin::NewL ) |
|
755 }; |
|
756 |
|
757 const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ); |
|
758 |
|
759 // --------------------------------------------------------------------------- |
|
760 // Returns the implementations provided by this ECOM plugin DLL. |
|
761 // --------------------------------------------------------------------------- |
|
762 // |
|
763 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
764 { |
|
765 aTableCount = sizeof( KFMRadioMCPPluginImplementationTable ) / sizeof( TImplementationProxy ); |
|
766 return KFMRadioMCPPluginImplementationTable; |
|
767 } |
|