|
1 /* |
|
2 * Copyright (c) 2008-2008 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: Updates Music Content Publisher |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <mpxlog.h> // MPX_DEBUG |
|
19 #include <implementationproxy.h> |
|
20 #include <LiwServiceHandler.h> |
|
21 #include <LiwVariant.h> |
|
22 #include <LiwGenericParam.h> |
|
23 #include <StringLoader.h> |
|
24 #include <AknUtils.h> |
|
25 #include <AknsUtils.h> |
|
26 #include <aknsconstants.hrh> |
|
27 #include <musichomescreenicons.mbg> |
|
28 #include <musichomescreen.rsg> |
|
29 #include <bautils.h> |
|
30 #include <data_caging_path_literals.hrh> |
|
31 #include <mpxmessagegeneraldefs.h> |
|
32 #include <mpxcollectionmessage.h> |
|
33 #include <mpxcollectionutility.h> |
|
34 #include <mpxcollectionframeworkdefs.h> |
|
35 #include <AknTaskList.h> |
|
36 |
|
37 |
|
38 |
|
39 #include "cpglobals.h" //to be moved to domain API |
|
40 |
|
41 #include "mcpmusicplayer.h" |
|
42 #include "mcpmusicplayeruids.hrh" |
|
43 #include "aiplayerpluginengine.h" |
|
44 #include "filemonitor.h" |
|
45 #include "applicationmonitor.h" |
|
46 #include "pnsmonitor.h" |
|
47 |
|
48 //const TUid KLocalPlaybackUid = { 0x101FFC06 }; |
|
49 const TInt KMusicPlayerAppUidAsTInt = 0x102072C3; |
|
50 |
|
51 const TInt KMmUid3AsTInt( 0x101f4cd2 ); |
|
52 const TInt KMSGUidAsTInt( 0x10003A39 ); |
|
53 |
|
54 namespace TBK |
|
55 { |
|
56 const TUint KSkeep_L = 0x001; //000000000001 |
|
57 const TUint KSkeep_R = 0x002; //000000000010 |
|
58 const TUint KPause = 0x004; //000000000100 |
|
59 const TUint KPlay = 0x008; //000000001000 |
|
60 const TUint KSkeep_L_dimmed = 0x010; //000000010000 |
|
61 const TUint KSkeep_R_dimmed = 0x020; //000000100000 |
|
62 const TUint KPause_dimmed = 0x040; //000001000000 |
|
63 const TUint KPlay_dimmed = 0x080; //000010000000 |
|
64 const TUint KPlay_last_played = 0x100; //000100000000 |
|
65 } |
|
66 |
|
67 _LIT( KEmpty, "" ); |
|
68 _LIT( KNowPlaying, "LOC:NOW PLAYING" ); |
|
69 _LIT( KLastPlayed, "LOC:LAST PLAYED" ); |
|
70 |
|
71 |
|
72 _LIT( KMIF, "z:\\resource\\apps\\musichomescreenicons.mif"); |
|
73 |
|
74 _LIT( KResourceFile, "z:musichomescreen.rsc"); |
|
75 |
|
76 //for music player action handler - playback command |
|
77 _LIT( KActionPlaybackCommand , "PlaybackCommand" ); |
|
78 _LIT8( KPBCommand, "command" ); |
|
79 |
|
80 //for music player action handler - message to music player |
|
81 _LIT( KactionMessageToMusicPlayer, "MessageToMusicPlayer" ); |
|
82 _LIT( KGoToNowPlaying, "GoToNowPlaying" ); |
|
83 _LIT( KGoToLastPlayed, "GoToLastPlayed" ); |
|
84 _LIT( KGoToLastPlayedMinimized, "GoToLastPlayedMinimized" ); |
|
85 |
|
86 _LIT8( KMessage, "message" ); |
|
87 _LIT8( KAdditionalData, "additional_data" ); |
|
88 |
|
89 //for application launcher AHPlugin |
|
90 _LIT( KCmdLine, "cmd_line" ); |
|
91 _LIT( KLaunchApp, "launch_application" ); |
|
92 _LIT( KMessageWithTail, "message_with_tail" ); |
|
93 _LIT8( KMessageForMMOpenMusicSuiteWithHide, "mm://root/musicsuite?exit=hide"); |
|
94 |
|
95 |
|
96 //for time |
|
97 //_LIT( KSeparator, "/" ); |
|
98 _LIT( KSeparatorhyphen, " - " ); |
|
99 //_LIT( KMPXZeroDurationMark, "--" ); |
|
100 //_LIT( KTitleNowPlaying, "Now Playing" ); |
|
101 //_LIT( KTitleLastPlayed, "Last Played" ); |
|
102 |
|
103 const TInt KMusicPlayerOpeningTimerInterval = 15000000; // 15 seconds |
|
104 |
|
105 // ======== MEMBER FUNCTIONS ======== |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // Constructor |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 CMCPMusicPlayer::CMCPMusicPlayer(MMCPPluginObserver* aObserver) |
|
112 { |
|
113 iMHObserver = aObserver; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // Symbian 2nd phase constructor can leave. |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void CMCPMusicPlayer::ConstructL() |
|
121 { |
|
122 MPX_DEBUG1("CMCPMusicPlayer::ConstructL <---"); |
|
123 MPX_DEBUG1("CMCPMusicPlayer::ConstructL creating engine"); |
|
124 iEngine = CAiPlayerPluginEngine::NewL( *this ); |
|
125 MPX_DEBUG1("CMCPMusicPlayer::ConstructL engine created"); |
|
126 AknsUtils::InitSkinSupportL(); |
|
127 //Load Loc strings |
|
128 MPX_DEBUG1("CMCPMusicPlayer::ConstructL getting resource file"); |
|
129 RFs fs; |
|
130 User::LeaveIfError(fs.Connect()); |
|
131 CleanupClosePushL(fs); |
|
132 TFileName fileName; |
|
133 TParse* parseObj = new(ELeave) TParse(); |
|
134 TInt errInt = parseObj->Set( KResourceFile(),&KDC_APP_RESOURCE_DIR,NULL ); |
|
135 if(KErrNone != errInt) |
|
136 { |
|
137 delete parseObj; |
|
138 User::Leave(errInt); |
|
139 } |
|
140 fileName = parseObj->FullName(); |
|
141 delete parseObj; |
|
142 BaflUtils::NearestLanguageFile(fs,fileName); |
|
143 if(!BaflUtils::FileExists(fs,fileName)) |
|
144 { |
|
145 User::Leave(KErrNotFound); |
|
146 } |
|
147 RResourceFile resourceFile; |
|
148 resourceFile.OpenL(fs,fileName); |
|
149 CleanupClosePushL(resourceFile); |
|
150 resourceFile.ConfirmSignatureL(); |
|
151 GetLocalizedStringL(resourceFile, iGoToMusicBuffer, R_MUSICHOMESCREEN_GO_TO_MUSIC); |
|
152 GetLocalizedStringL(resourceFile, iOpeningBuffer, R_MUSICHOMESCREEN_OPENING); |
|
153 CleanupStack::PopAndDestroy(&resourceFile); |
|
154 CleanupStack::PopAndDestroy(&fs); |
|
155 MPX_DEBUG1("CMCPMusicPlayer::ConstructL resources loaded"); |
|
156 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
157 TRAPD(err, iArtBitmapMask = AknsUtils::CreateBitmapL( skin, |
|
158 KAknsIIDQgnHomePhotoMask ) ); |
|
159 if (err == KErrNone) |
|
160 { |
|
161 AknIconUtils::DisableCompression(iArtBitmapMask); |
|
162 TSize size( 70 , 70); |
|
163 AknIconUtils::SetSize( iArtBitmapMask, size ); |
|
164 if (iArtBitmapMask->SetDisplayMode( EGray256 ) != KErrNone) |
|
165 { |
|
166 delete iArtBitmapMask; |
|
167 iArtBitmapMask = NULL; |
|
168 } |
|
169 } |
|
170 else |
|
171 { |
|
172 delete iArtBitmapMask; |
|
173 iArtBitmapMask = NULL; |
|
174 } |
|
175 iCollectionUtility = MMPXCollectionUtility::NewL( this, KMcModeDefault ); |
|
176 iMusicPlayerOpeningTimer = CPeriodic::NewL( CActive::EPriorityLow ); |
|
177 MPX_DEBUG1("CMCPMusicPlayer::ConstructL --->"); |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // Two-phased constructor. |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 CMCPMusicPlayer* CMCPMusicPlayer::NewL(MMCPPluginObserver* aObserver) |
|
185 { |
|
186 CMCPMusicPlayer* self = new ( ELeave ) |
|
187 CMCPMusicPlayer( aObserver ); |
|
188 CleanupStack::PushL( self ); |
|
189 self->ConstructL(); |
|
190 CleanupStack::Pop( self ); |
|
191 return self; |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // Destructor |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 CMCPMusicPlayer::~CMCPMusicPlayer() |
|
199 { |
|
200 MPX_DEBUG1("CMCPMusicPlayer::~CMCPMusicPlayer <---"); |
|
201 if (iArtCached && iArtBitmap != iCachedArtBitmap) |
|
202 { |
|
203 delete iCachedArtBitmap; |
|
204 } |
|
205 delete iArtBitmap; |
|
206 delete iArtBitmapMask; |
|
207 delete iEngine; |
|
208 delete iFileMonitor; |
|
209 delete iAppMonitor; |
|
210 delete iPNSMonitor; |
|
211 delete iGoToMusicBuffer; |
|
212 delete iOpeningBuffer; |
|
213 if ( iCollectionUtility ) |
|
214 { |
|
215 iCollectionUtility->Close(); |
|
216 } |
|
217 delete iMusicPlayerOpeningTimer; |
|
218 MPX_DEBUG1("CMCPMusicPlayer::~CMCPMusicPlayer --->"); |
|
219 } |
|
220 |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 TBool CMCPMusicPlayer::IsOKToPublishData() |
|
227 { |
|
228 return iActive; |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 void CMCPMusicPlayer::InstallPlaybackCommandActionL(TMPXPlaybackCommand aCmd, |
|
236 TMCPTriggerDestination aDestination) |
|
237 { |
|
238 MPX_DEBUG1("CMCPMusicPlayer::InstallPlaybackCommandActionL <---"); |
|
239 CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); |
|
240 CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC(); |
|
241 |
|
242 mapTrigger->InsertL( KPluginUid, TLiwVariant( TUid::Uid( 0x10207C16 ) ) ); |
|
243 mapData->InsertL( KType, TLiwVariant( KActionPlaybackCommand ) ); |
|
244 TInt32 cmd; |
|
245 cmd=static_cast<TInt32>( aCmd ); |
|
246 mapData->InsertL( KPBCommand, TLiwVariant( cmd ) ); |
|
247 mapTrigger->InsertL( KData , TLiwVariant( mapData ) ); |
|
248 |
|
249 iMHObserver->PublishActionL( this, aDestination, mapTrigger ); |
|
250 |
|
251 CleanupStack::PopAndDestroy( mapData ); |
|
252 CleanupStack::PopAndDestroy( mapTrigger ); |
|
253 MPX_DEBUG1("CMCPMusicPlayer::InstallPlaybackCommandActionL --->"); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CMCPMusicPlayer::InstallLaunchMusicPlayerL( |
|
261 TMCPTriggerDestination aDestination ) |
|
262 { |
|
263 MPX_DEBUG1("CMCPMusicPlayer::InstallLaunchMusicPlayerL <---"); |
|
264 CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); |
|
265 CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC(); |
|
266 mapTrigger->InsertL( KPluginUid, TLiwVariant( TUid::Uid( 0x10282E5F ) ) ); |
|
267 mapData->InsertL( KType, TLiwVariant( KLaunchApp ) ); |
|
268 mapData->InsertL( KLaunchMethod, TLiwVariant( KCmdLine ) ); |
|
269 mapData->InsertL(KApplicationUid, |
|
270 TLiwVariant(TInt32(KMusicPlayerAppUidAsTInt) ) ); |
|
271 mapTrigger->InsertL( KData, TLiwVariant( mapData ) ); |
|
272 |
|
273 iMHObserver->PublishActionL( this, aDestination, mapTrigger ); |
|
274 |
|
275 CleanupStack::PopAndDestroy( mapData ); |
|
276 CleanupStack::PopAndDestroy( mapTrigger ); |
|
277 MPX_DEBUG1("CMCPMusicPlayer::InstallLaunchMusicPlayerL --->"); |
|
278 } |
|
279 |
|
280 |
|
281 // --------------------------------------------------------------------------- |
|
282 // |
|
283 // --------------------------------------------------------------------------- |
|
284 // |
|
285 void CMCPMusicPlayer::InstallGoToNowPlayingL( |
|
286 TMCPTriggerDestination aDestination ) |
|
287 { |
|
288 MPX_DEBUG1("CMCPMusicPlayer::InstallGoToNowPlayingL <---"); |
|
289 CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); |
|
290 CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC(); |
|
291 |
|
292 mapTrigger->InsertL( KPluginUid, TLiwVariant( TUid::Uid( 0x10207C16 ) ) ); |
|
293 mapData->InsertL( KType, TLiwVariant( KactionMessageToMusicPlayer ) ); |
|
294 mapData->InsertL( KMessage, TLiwVariant( KGoToNowPlaying ) ); |
|
295 mapTrigger->InsertL( KData , TLiwVariant( mapData ) ); |
|
296 |
|
297 iMHObserver->PublishActionL( this, aDestination, mapTrigger ); |
|
298 |
|
299 CleanupStack::PopAndDestroy( mapData ); |
|
300 CleanupStack::PopAndDestroy( mapTrigger ); |
|
301 MPX_DEBUG1("CMCPMusicPlayer::InstallGoToNowPlayingL --->"); |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 void CMCPMusicPlayer::InstallGoToLastPlayedL( |
|
309 TMCPTriggerDestination aDestination, TBool aMinimized ) |
|
310 { |
|
311 MPX_DEBUG1("CMCPMusicPlayer::InstallGoToLastPlayedL <---"); |
|
312 CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); |
|
313 CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC(); |
|
314 |
|
315 mapTrigger->InsertL( KPluginUid, TLiwVariant( TUid::Uid( 0x10207C16 ) ) ); |
|
316 mapData->InsertL( KType, TLiwVariant( KactionMessageToMusicPlayer ) ); |
|
317 if (aMinimized) |
|
318 { |
|
319 mapData->InsertL( KMessage, TLiwVariant( KGoToLastPlayedMinimized ) ); |
|
320 } |
|
321 else |
|
322 { |
|
323 mapData->InsertL( KMessage, TLiwVariant( KGoToLastPlayed ) ); |
|
324 } |
|
325 mapTrigger->InsertL( KData , TLiwVariant( mapData ) ); |
|
326 |
|
327 iMHObserver->PublishActionL( this, aDestination, mapTrigger ); |
|
328 |
|
329 CleanupStack::PopAndDestroy( mapData ); |
|
330 CleanupStack::PopAndDestroy( mapTrigger ); |
|
331 MPX_DEBUG1("CMCPMusicPlayer::InstallGoToLastPlayedL --->"); |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // |
|
336 // --------------------------------------------------------------------------- |
|
337 // |
|
338 void CMCPMusicPlayer::InstallGoToMusicL( |
|
339 TMCPTriggerDestination aDestination ) |
|
340 { |
|
341 MPX_DEBUG1("CMCPMusicPlayer::InstallGoToMusicL <---"); |
|
342 CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); |
|
343 CLiwDefaultMap* mapData = CLiwDefaultMap::NewLC(); |
|
344 |
|
345 mapTrigger->InsertL( KPluginUid, TLiwVariant( TUid::Uid( 0x10282E5F ) ) ); |
|
346 |
|
347 mapData->InsertL( KType, TLiwVariant( KLaunchApp ) ); |
|
348 mapData->InsertL( KLaunchMethod, TLiwVariant( KMessageWithTail ) ); |
|
349 mapData->InsertL(KApplicationUid, |
|
350 TLiwVariant(TInt32(KMmUid3AsTInt) ) ); |
|
351 mapData->InsertL( KAdditionalData, |
|
352 TLiwVariant( KMessageForMMOpenMusicSuiteWithHide ) ); |
|
353 mapData->InsertL(KMessageUid, |
|
354 TLiwVariant(TInt32(KMSGUidAsTInt) ) ); |
|
355 |
|
356 mapTrigger->InsertL( KData, TLiwVariant( mapData ) ); |
|
357 |
|
358 iMHObserver->PublishActionL( this, aDestination, mapTrigger ); |
|
359 |
|
360 CleanupStack::PopAndDestroy( mapData ); |
|
361 CleanupStack::PopAndDestroy( mapTrigger ); |
|
362 MPX_DEBUG1("CMCPMusicPlayer::InstallGoToMusicL --->"); |
|
363 } |
|
364 |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 void CMCPMusicPlayer::InstallEmptyActionL( |
|
371 TMCPTriggerDestination aDestination ) |
|
372 { |
|
373 MPX_DEBUG1("CMCPMusicPlayer::InstallEmptyActionL <---"); |
|
374 CLiwDefaultMap* mapTrigger = CLiwDefaultMap::NewLC(); |
|
375 iMHObserver->PublishActionL( this, aDestination, mapTrigger ); |
|
376 CleanupStack::PopAndDestroy( mapTrigger ); |
|
377 MPX_DEBUG1("CMCPMusicPlayer::InstallEmptyActionL --->"); |
|
378 } |
|
379 |
|
380 // --------------------------------------------------------------------------- |
|
381 // Installs actions and icons in the toolbar. |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 |
|
385 void CMCPMusicPlayer::UpdateToolBarL(TUint aToolBarState) |
|
386 { |
|
387 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL <---"); |
|
388 if (IsOKToPublishData()) |
|
389 { |
|
390 TInt updateState; |
|
391 //we update if there is a change on the state and if the new propery |
|
392 //was set. |
|
393 // updateState = ( new ^ old ) & new = new & ~old |
|
394 updateState = aToolBarState & ~iToolBarState; |
|
395 TAknsItemID iconId; |
|
396 |
|
397 if ( TBK::KSkeep_L & updateState ) |
|
398 { |
|
399 iconId.Set( EAknsMajorGeneric, |
|
400 EAknsMinorGenericQgnPropImageTbPrev); |
|
401 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB1, iconId, |
|
402 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_prev, |
|
403 EMbmMusichomescreeniconsQgn_prop_image_tb_prev_mask); |
|
404 InstallPlaybackCommandActionL(EPbCmdPrevious, |
|
405 EMusicWidgetTB1Trigger); |
|
406 iToolBarState |= TBK::KPlay_dimmed; |
|
407 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KSkeep_L"); |
|
408 } |
|
409 |
|
410 if ( TBK::KSkeep_R & updateState ) |
|
411 { |
|
412 iconId.Set( EAknsMajorGeneric, |
|
413 EAknsMinorGenericQgnPropImageTbNext); |
|
414 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB3, iconId, |
|
415 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_next, |
|
416 EMbmMusichomescreeniconsQgn_prop_image_tb_next_mask); |
|
417 InstallPlaybackCommandActionL(EPbCmdNext, EMusicWidgetTB3Trigger); |
|
418 iToolBarState |= TBK::KSkeep_R; |
|
419 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KSkeep_R"); |
|
420 } |
|
421 |
|
422 if ( TBK::KPause & updateState ) |
|
423 { |
|
424 iconId.Set( EAknsMajorGeneric, |
|
425 EAknsMinorGenericQgnPropImageTbPause); |
|
426 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB2, iconId, |
|
427 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_pause, |
|
428 EMbmMusichomescreeniconsQgn_prop_image_tb_pause_mask); |
|
429 InstallPlaybackCommandActionL(EPbCmdPlayPause, |
|
430 EMusicWidgetTB2Trigger); |
|
431 iToolBarState |= TBK::KPause; |
|
432 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KPause"); |
|
433 } |
|
434 |
|
435 if ( TBK::KPlay & updateState ) |
|
436 { |
|
437 iconId.Set( EAknsMajorGeneric, |
|
438 EAknsMinorGenericQgnPropImageTbPlay2 ); |
|
439 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB2, iconId, |
|
440 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_play2, |
|
441 EMbmMusichomescreeniconsQgn_prop_image_tb_play2_mask); |
|
442 InstallPlaybackCommandActionL(EPbCmdPlayPause, |
|
443 EMusicWidgetTB2Trigger); |
|
444 iToolBarState |= TBK::KPlay; |
|
445 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KPlay"); |
|
446 } |
|
447 |
|
448 if ( TBK::KPlay_last_played & updateState ) |
|
449 { |
|
450 iconId.Set( EAknsMajorGeneric, |
|
451 EAknsMinorGenericQgnPropImageTbPlay2 ); |
|
452 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB2, iconId, |
|
453 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_play2, |
|
454 EMbmMusichomescreeniconsQgn_prop_image_tb_play2_mask); |
|
455 InstallGoToLastPlayedL(EMusicWidgetTB2Trigger, ETrue); |
|
456 iToolBarState |= TBK::KPlay_last_played; |
|
457 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KPlay_last_played"); |
|
458 } |
|
459 |
|
460 if ( TBK::KSkeep_L_dimmed & updateState ) |
|
461 { |
|
462 iconId.Set( EAknsMajorGeneric, |
|
463 EAknsMinorGenericQgnPropImageTbPrevDimmed); |
|
464 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB1, iconId, |
|
465 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_prev_dimmed, |
|
466 EMbmMusichomescreeniconsQgn_prop_image_tb_prev_dimmed_mask); |
|
467 InstallEmptyActionL( EMusicWidgetTB1Trigger); |
|
468 iToolBarState |= TBK::KSkeep_L_dimmed; |
|
469 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KSkeep_L_dimmed"); |
|
470 } |
|
471 |
|
472 if ( TBK::KSkeep_R_dimmed & updateState ) |
|
473 { |
|
474 iconId.Set( EAknsMajorGeneric, |
|
475 EAknsMinorGenericQgnPropImageTbNextDimmed); |
|
476 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB3, iconId, |
|
477 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_next_dimmed, |
|
478 EMbmMusichomescreeniconsQgn_prop_image_tb_next_dimmed_mask); |
|
479 InstallEmptyActionL( EMusicWidgetTB3Trigger); |
|
480 iToolBarState |= TBK::KSkeep_R_dimmed; |
|
481 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KSkeep_R_dimmed"); |
|
482 } |
|
483 |
|
484 if ( TBK::KPause_dimmed & updateState ) |
|
485 { |
|
486 iconId.Set( EAknsMajorGeneric, |
|
487 EAknsMinorGenericQgnPropImageTbPauseDimmed); |
|
488 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB2, iconId, |
|
489 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_pause_dimmed, |
|
490 EMbmMusichomescreeniconsQgn_prop_image_tb_pause_dimmed_mask); |
|
491 InstallEmptyActionL( EMusicWidgetTB2Trigger); |
|
492 iToolBarState |= TBK::KPause_dimmed; |
|
493 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KPause_dimmed"); |
|
494 } |
|
495 |
|
496 if ( TBK::KPlay_dimmed & updateState ) |
|
497 { |
|
498 iconId.Set( EAknsMajorGeneric, |
|
499 EAknsMinorGenericQgnPropImageTbPlay2Dimmed); |
|
500 iMHObserver->PublishImageL( this, EMusicWidgetToolbarB2, iconId, |
|
501 KMIF, EMbmMusichomescreeniconsQgn_prop_image_tb_play2_dimmed, |
|
502 EMbmMusichomescreeniconsQgn_prop_image_tb_play2_dimmed_mask); |
|
503 InstallEmptyActionL( EMusicWidgetTB2Trigger); |
|
504 iToolBarState |= TBK::KPlay_dimmed; |
|
505 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL KPlay_dimmed"); |
|
506 } |
|
507 |
|
508 iToolBarState = aToolBarState; |
|
509 } |
|
510 MPX_DEBUG1("CMCPMusicPlayer::UpdateToolBarL <---"); |
|
511 } |
|
512 |
|
513 // --------------------------------------------------------------------------- |
|
514 // Resets the widget an Music Suite. |
|
515 // --------------------------------------------------------------------------- |
|
516 // |
|
517 void CMCPMusicPlayer::ResetL() |
|
518 { |
|
519 MPX_DEBUG1("CMCPMusicPlayer::ResetL <---"); |
|
520 //Note that we are not checking if IsOKToPublishData()This will only get |
|
521 //published if the plugin is still active on the music content publisher |
|
522 //meaning that no other plugin has preempted us. |
|
523 if ( iAppMonitor ) |
|
524 { |
|
525 delete iAppMonitor; |
|
526 iAppMonitor = NULL; |
|
527 } |
|
528 if (iFileMonitor) |
|
529 { |
|
530 delete iFileMonitor; |
|
531 iFileMonitor = NULL; |
|
532 } |
|
533 if ( iPNSMonitor ) |
|
534 { |
|
535 delete iPNSMonitor; |
|
536 iPNSMonitor = NULL; |
|
537 } |
|
538 //Reset |
|
539 iMHObserver->PublishTextL( this,EMusicWidgetDefaultText, iGoToMusicBuffer->Des() ); |
|
540 iMHObserver->PublishImageL(this,EMusicWidgetImage1,KEmpty); |
|
541 InstallGoToMusicL( EMusicWidgetTrigger1 ); |
|
542 iMHObserver->PublishTextL( this,EMusicWidgetText1, KEmpty ); |
|
543 iMHObserver->PublishImageL(this,EMusicWidgetToolbarB1,KEmpty); |
|
544 iMHObserver->PublishImageL(this,EMusicWidgetToolbarB2,KEmpty); |
|
545 iMHObserver->PublishImageL(this,EMusicWidgetToolbarB3,KEmpty); |
|
546 InstallEmptyActionL(EMusicWidgetTB1Trigger); |
|
547 InstallEmptyActionL(EMusicWidgetTB2Trigger); |
|
548 InstallEmptyActionL(EMusicWidgetTB3Trigger); |
|
549 InstallGoToMusicL( EMusicWidgetTrigger2 ); |
|
550 |
|
551 |
|
552 |
|
553 //Reset the music menu info |
|
554 InstallEmptyActionL(EMusicMenuMusicInfoTrigger); |
|
555 iMHObserver->PublishTextL( this, EMusicMenuMusicInfoLine1, |
|
556 KLastPlayed ); |
|
557 iMHObserver->PublishTextL( this, EMusicMenuMusicInfoLine2, |
|
558 KEmpty ); |
|
559 iMHObserver->PublishImageL( this, EMusicMenuMusicInfoImage1, |
|
560 KAknsIIDQgnIndiMupDefaultAlbum, |
|
561 KMIF, |
|
562 EMbmMusichomescreeniconsQgn_indi_mup_default_album, |
|
563 EMbmMusichomescreeniconsQgn_indi_mup_default_album_mask); |
|
564 MPX_DEBUG1("CMCPMusicPlayer::ResetL --->"); |
|
565 } |
|
566 |
|
567 // ---------------------------------------------------------------------------- |
|
568 // Get a heap descriptor from the resource file |
|
569 // ---------------------------------------------------------------------------- |
|
570 // |
|
571 void CMCPMusicPlayer::GetLocalizedStringL(RResourceFile& aResourceFile ,HBufC*& aRetBuf, |
|
572 TInt aResourceId ) |
|
573 { |
|
574 MPX_DEBUG1("CMCPMusicPlayer::GetLocalizedStringL <---"); |
|
575 HBufC8* dataBuffer = aResourceFile.AllocReadLC(aResourceId); |
|
576 TResourceReader theReader; |
|
577 theReader.SetBuffer(dataBuffer); |
|
578 aRetBuf = theReader.ReadHBufCL(); |
|
579 CleanupStack::PopAndDestroy(dataBuffer); |
|
580 MPX_DEBUG1("CMCPMusicPlayer::GetLocalizedStringL --->"); |
|
581 } |
|
582 |
|
583 // ---------------------------------------------------------------------------- |
|
584 // Sets the plugin as active. |
|
585 // ---------------------------------------------------------------------------- |
|
586 // |
|
587 void CMCPMusicPlayer::ActivateL() |
|
588 { |
|
589 MPX_DEBUG1("CMCPMusicPlayer::ActivateL <---"); |
|
590 if ( iPNSMonitor ) |
|
591 { |
|
592 delete iPNSMonitor; |
|
593 iFileMonitor = NULL; |
|
594 MPX_DEBUG1("CMCPMusicPlayer::ActivateL pns monitor deleted"); |
|
595 } |
|
596 iPNSMonitor = CPNSMonitor::NewL(*this); |
|
597 MPX_DEBUG1("CMCPMusicPlayer::ActivateL pns monitor created"); |
|
598 iPNSMonitor->Start(); |
|
599 if ( iAppMonitor ) |
|
600 { |
|
601 delete iAppMonitor; |
|
602 iAppMonitor = NULL; |
|
603 } |
|
604 MPX_DEBUG1("CMCPMusicPlayer::ActivateL app monitor deleted"); |
|
605 iAppMonitor = CApplicationMonitor::NewL(*this); |
|
606 MPX_DEBUG1("CMCPMusicPlayer::ActivateL app monitor created"); |
|
607 TRAPD(err, |
|
608 iAppMonitor->StartL( TUid::Uid( KMusicPlayerAppUidAsTInt ) ) |
|
609 ); |
|
610 MPX_DEBUG1("CMCPMusicPlayer::ActivateL app monitor started"); |
|
611 if (KErrNone != err) //Music player is not running, it died somehow. |
|
612 { |
|
613 MPX_DEBUG1("CMCPMusicPlayer::ActivateL music player is not running"); |
|
614 if (iFileMonitor) |
|
615 { |
|
616 delete iFileMonitor; |
|
617 iFileMonitor = NULL; |
|
618 } |
|
619 MPX_DEBUG1("CMCPMusicPlayer::ActivateL file monitor deleted"); |
|
620 const TDesC& uri = iEngine->Uri(); |
|
621 if ( uri != KNullDesC ) |
|
622 { |
|
623 MPX_DEBUG1("CMCPMusicPlayer::ActivateL uri is not null creatin file monitor"); |
|
624 iFileMonitor = CFileMonitor::NewL(*this); |
|
625 iFileMonitor->StartL( uri ); |
|
626 } |
|
627 iActive = EFalse; |
|
628 } |
|
629 else //Music player is running |
|
630 { |
|
631 MPX_DEBUG1("CMCPMusicPlayer::ActivateL music player is running, activating..."); |
|
632 iMHObserver->BecameActiveL(this); |
|
633 iActive = ETrue; |
|
634 MPX_DEBUG1("CMCPMusicPlayer::ActivateL we are active now"); |
|
635 |
|
636 iMHObserver->PublishTextL( this, EMusicWidgetDefaultText, KEmpty ); |
|
637 InstallGoToNowPlayingL(EMusicWidgetTrigger1); |
|
638 InstallGoToLastPlayedL(EMusicMenuMusicInfoTrigger, EFalse); |
|
639 iMHObserver->PublishTextL(this, EMusicMenuMusicInfoLine1, |
|
640 KNowPlaying); |
|
641 DoUpdateTrackInfoL(iEngine->TitleL(), iEngine->Artist()); |
|
642 iToolBarState = 0; |
|
643 DoUpdatePlayerStateL( iEngine->PlayerState() ); |
|
644 DoUpdateAlbumArtL(iArtCached ? iCachedArtBitmap : iArtBitmap); |
|
645 } |
|
646 MPX_DEBUG1("CMCPMusicPlayer::ActivateL --->"); |
|
647 } |
|
648 |
|
649 |
|
650 void CMCPMusicPlayer::DoUpdatePlayerStateL(TMPlayerState aState) |
|
651 { |
|
652 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL <---"); |
|
653 switch ( aState ) |
|
654 { |
|
655 case EMPlayerStatePlaying: |
|
656 { |
|
657 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStatePlaying"); |
|
658 iMusicPlayerOpeningTimer->Cancel(); |
|
659 UpdateToolBarL(TBK::KSkeep_L|TBK::KPause|TBK::KSkeep_R); |
|
660 break; |
|
661 } |
|
662 case EMPlayerStatePaused: |
|
663 { |
|
664 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStatePaused"); |
|
665 UpdateToolBarL(TBK::KSkeep_L|TBK::KPlay|TBK::KSkeep_R); |
|
666 break; |
|
667 } |
|
668 case EMPlayerStateSeeking: |
|
669 { |
|
670 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStateSeeking"); |
|
671 UpdateToolBarL(TBK::KSkeep_L_dimmed | |
|
672 TBK::KPlay_dimmed | |
|
673 TBK::KSkeep_R_dimmed); |
|
674 break; |
|
675 } |
|
676 case EMPlayerStateStopped: |
|
677 { |
|
678 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL EMPlayerStateStopped"); |
|
679 if ( iBlockingOperationOngoing ) |
|
680 { |
|
681 UpdateToolBarL( TBK::KSkeep_L_dimmed | |
|
682 TBK::KPlay_dimmed | |
|
683 TBK::KSkeep_R_dimmed ); |
|
684 } |
|
685 else |
|
686 { |
|
687 UpdateToolBarL(TBK::KSkeep_L|TBK::KPlay|TBK::KSkeep_R); |
|
688 } |
|
689 break; |
|
690 } |
|
691 default: |
|
692 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL default"); |
|
693 break; |
|
694 } |
|
695 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL --->"); |
|
696 } |
|
697 |
|
698 void CMCPMusicPlayer::DoUpdateTrackInfoL(const TDesC& aTitle, const TDesC& aArtist) |
|
699 { |
|
700 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL <---"); |
|
701 if ( IsOKToPublishData() ) |
|
702 { |
|
703 HBufC* nowPlayingForMM = HBufC::NewLC( aTitle.Length() + |
|
704 KSeparatorhyphen().Length() + aArtist.Length() ); |
|
705 TPtr nowPlayingForMMPtr = nowPlayingForMM->Des(); |
|
706 if ( &aTitle && aTitle.Length() ) |
|
707 { |
|
708 nowPlayingForMMPtr.Copy( aTitle ); |
|
709 } |
|
710 if ( &aArtist && aArtist.Length() ) |
|
711 { |
|
712 nowPlayingForMMPtr.Append(KSeparatorhyphen); |
|
713 nowPlayingForMMPtr.Append(aArtist); |
|
714 } |
|
715 iMHObserver->PublishTextL( this,EMusicWidgetText1, *nowPlayingForMM ); |
|
716 iMHObserver->PublishTextL(this, EMusicMenuMusicInfoLine2, |
|
717 *nowPlayingForMM); |
|
718 CleanupStack::PopAndDestroy( nowPlayingForMM ); |
|
719 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL deliting file monitor"); |
|
720 if (iFileMonitor) |
|
721 { |
|
722 delete iFileMonitor; |
|
723 iFileMonitor = NULL; |
|
724 } |
|
725 |
|
726 const TDesC& uri = iEngine->Uri(); |
|
727 if ( uri != KNullDesC ) |
|
728 { |
|
729 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL creating file monitor"); |
|
730 iFileMonitor = CFileMonitor::NewL(*this); |
|
731 iFileMonitor->StartL( uri ); |
|
732 } |
|
733 } |
|
734 MPX_DEBUG1("CMCPMusicPlayer::DoUpdatePlayerStateL --->"); |
|
735 } |
|
736 |
|
737 void CMCPMusicPlayer::DoUpdatePlaybackPositionL(TInt /*aPosition*/) |
|
738 { |
|
739 /* |
|
740 * |
|
741 * This code was left here in case some parts are helpfull |
|
742 * in the future, here is some code that used to work, |
|
743 * Members and APIs used migh have changed. |
|
744 * |
|
745 if ( IsOKToPublishData() ) |
|
746 { |
|
747 const TInt KMPXMinSecSeparatorIndex = 2; |
|
748 const TInt KMPXOneSecInMicroSecs = 1000000; |
|
749 const TInt KMPXOneHourInSeconds = 60 * 60; |
|
750 const TInt KMPXTimeIndicatorLength = 16; |
|
751 |
|
752 TBuf<KMPXTimeIndicatorLength> elapsed; |
|
753 TBuf<KMPXTimeIndicatorLength> total; |
|
754 |
|
755 TInt64 playbackPosInSeconds; |
|
756 TInt64 totalLengthInSeconds; |
|
757 |
|
758 playbackPosInSeconds = aPosition; |
|
759 totalLengthInSeconds = iEngine->Duration(); |
|
760 HBufC* longFormatString; |
|
761 HBufC* shortFormatString; |
|
762 |
|
763 longFormatString = StringLoader::LoadL( |
|
764 R_QTN_TIME_DURAT_LONG_WITH_ZERO ); |
|
765 shortFormatString = StringLoader::LoadL( |
|
766 R_QTN_TIME_DURAT_MIN_SEC_WITH_ZERO) ; |
|
767 TPtrC format = *shortFormatString; |
|
768 |
|
769 if ( totalLengthInSeconds >= KMPXOneHourInSeconds ) |
|
770 { |
|
771 // For tracks longer than an hour we use different time format and |
|
772 //a slightly different layout which has more space for the time |
|
773 //labels. |
|
774 format.Set( *longFormatString ); |
|
775 } |
|
776 |
|
777 TTime elapsedTime( playbackPosInSeconds * KMPXOneSecInMicroSecs ); |
|
778 TTime totalTime( totalLengthInSeconds * KMPXOneSecInMicroSecs ); |
|
779 |
|
780 if ( aPosition == 0 ) |
|
781 { |
|
782 totalLengthInSeconds = 0; |
|
783 } |
|
784 |
|
785 // Convert total playing time to texts. |
|
786 elapsedTime.FormatL( elapsed, format ); |
|
787 |
|
788 if ( totalLengthInSeconds ) |
|
789 { |
|
790 // Time remaining |
|
791 totalTime.FormatL( total, format ); |
|
792 } |
|
793 else |
|
794 { |
|
795 // Time remaining: --:-- |
|
796 TLocale locale; |
|
797 TBuf<KMPXTimeIndicatorLength> pos; |
|
798 TChar separator = locale.TimeSeparator(KMPXMinSecSeparatorIndex); |
|
799 total = KMPXZeroDurationMark; |
|
800 total.Append( separator ); |
|
801 total += KMPXZeroDurationMark; |
|
802 } |
|
803 |
|
804 AknTextUtils::LanguageSpecificNumberConversion( elapsed ); |
|
805 AknTextUtils::LanguageSpecificNumberConversion( total ); |
|
806 TBuf<128> duration; |
|
807 TBuf<128> elapsedTimebuf; |
|
808 |
|
809 elapsedTimebuf.Copy( elapsed ); |
|
810 |
|
811 duration.Copy( elapsed ); |
|
812 duration.Append( KSeparator ); |
|
813 duration.Append( total ); |
|
814 |
|
815 iMHObserver->PublishTextL( this, EMusicWidgetText3, duration ); |
|
816 |
|
817 delete longFormatString; |
|
818 delete shortFormatString; |
|
819 } |
|
820 */ |
|
821 } |
|
822 |
|
823 void CMCPMusicPlayer::DoUpdateAlbumArtL( CFbsBitmap* aBitmap ) |
|
824 { |
|
825 MPX_DEBUG1("CMCPMusicPlayer::DoUpdateAlbumArtL <---"); |
|
826 //Make sure that iCachedArtBitmap is deleted or nulled in case it is an alias. |
|
827 //This ensures that the data is not double deleted nor orphan. |
|
828 if ( iCachedArtBitmap && iCachedArtBitmap != aBitmap && iCachedArtBitmap != iArtBitmap) |
|
829 { |
|
830 MPX_DEBUG1("CMCPMusicPlayer::DoUpdateAlbumArtL delete iCachedArtBitmap"); |
|
831 delete iCachedArtBitmap; |
|
832 } |
|
833 iCachedArtBitmap = NULL; |
|
834 //Store the new bitmap. |
|
835 if ( aBitmap != iArtBitmap ) |
|
836 { |
|
837 MPX_DEBUG1("CMCPMusicPlayer::DoUpdateAlbumArtL delete iArtBitmap"); |
|
838 delete iArtBitmap; |
|
839 } |
|
840 iArtBitmap = aBitmap; |
|
841 iArtCached = EFalse; |
|
842 |
|
843 if (iArtBitmap) |
|
844 { |
|
845 TInt handle = iArtBitmap->Handle(); |
|
846 if (iArtBitmapMask) |
|
847 { |
|
848 TInt mskHandle = iArtBitmapMask->Handle(); |
|
849 iMHObserver->PublishImageL(this,EMusicWidgetImage1,handle, |
|
850 mskHandle); |
|
851 } |
|
852 else |
|
853 { |
|
854 iMHObserver->PublishImageL(this,EMusicWidgetImage1,handle); |
|
855 } |
|
856 iMHObserver->PublishImageL( this, EMusicMenuMusicInfoImage1, |
|
857 handle ); |
|
858 } |
|
859 else |
|
860 { |
|
861 iMHObserver->PublishImageL( this, EMusicMenuMusicInfoImage1, |
|
862 KAknsIIDQgnIndiMupDefaultAlbum, |
|
863 KMIF, EMbmMusichomescreeniconsQgn_indi_mup_default_album, |
|
864 EMbmMusichomescreeniconsQgn_indi_mup_default_album_mask); |
|
865 iMHObserver->PublishImageL( this, EMusicWidgetImage1, |
|
866 KAknsIIDQgnIndiMupDefaultAlbum, |
|
867 KMIF, EMbmMusichomescreeniconsQgn_indi_mup_default_album, |
|
868 EMbmMusichomescreeniconsQgn_indi_mup_default_album_mask); |
|
869 } |
|
870 MPX_DEBUG1("CMCPMusicPlayer::DoUpdateAlbumArtL --->"); |
|
871 } |
|
872 |
|
873 void CMCPMusicPlayer::DoHandleOpeningL() |
|
874 { |
|
875 MPX_DEBUG1("CMCPMusicPlayer::DoHandleOpeningL <---"); |
|
876 if ( IsOKToPublishData() ) |
|
877 { |
|
878 iMHObserver->PublishTextL( this,EMusicWidgetText1, iOpeningBuffer->Des() ); |
|
879 } |
|
880 MPX_DEBUG1("CMCPMusicPlayer::DoHandleOpeningL --->"); |
|
881 } |
|
882 |
|
883 void CMCPMusicPlayer::DoHandlePlaylisIsEmptyL() |
|
884 { |
|
885 MPX_DEBUG1("CMCPMusicPlayer::DoHandlePlaylisIsEmptyL <---"); |
|
886 iActive = EFalse; |
|
887 ResetL(); |
|
888 MPX_DEBUG1("CMCPMusicPlayer::DoHandlePlaylisIsEmptyL --->"); |
|
889 } |
|
890 void CMCPMusicPlayer::DoHandleSkinChangedL() |
|
891 { |
|
892 MPX_DEBUG1("CMCPMusicPlayer::DoHandleSkinChangedL <---"); |
|
893 //To make sure the mask gets recreated even if we don't use it right now. |
|
894 delete iArtBitmapMask; |
|
895 iArtBitmapMask = NULL; |
|
896 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
897 |
|
898 TRAPD(err, iArtBitmapMask = AknsUtils::CreateBitmapL( skin, |
|
899 KAknsIIDQgnHomePhotoMask ) ); |
|
900 if (err == KErrNone) |
|
901 { |
|
902 AknIconUtils::DisableCompression(iArtBitmapMask); |
|
903 TSize size( 70 , 70); |
|
904 AknIconUtils::SetSize( iArtBitmapMask, size ); |
|
905 if (iArtBitmapMask->SetDisplayMode( EGray256 ) != KErrNone) |
|
906 { |
|
907 delete iArtBitmapMask; |
|
908 iArtBitmapMask = NULL; |
|
909 } |
|
910 } |
|
911 else |
|
912 { |
|
913 delete iArtBitmapMask; |
|
914 iArtBitmapMask = NULL; |
|
915 } |
|
916 |
|
917 if (iArtBitmap) |
|
918 { |
|
919 TInt handle = iArtBitmap->Handle(); |
|
920 if (iArtBitmapMask) |
|
921 { |
|
922 TInt mskHandle = iArtBitmapMask->Handle(); |
|
923 iMHObserver->PublishImageL( |
|
924 this, |
|
925 EMusicWidgetImage1, |
|
926 handle, |
|
927 mskHandle); |
|
928 } |
|
929 else |
|
930 { |
|
931 iMHObserver->PublishImageL( |
|
932 this, |
|
933 EMusicWidgetImage1, |
|
934 handle); |
|
935 } |
|
936 } |
|
937 else |
|
938 { |
|
939 iMHObserver->PublishImageL( this, EMusicMenuMusicInfoImage1, |
|
940 KAknsIIDQgnIndiMupDefaultAlbum, |
|
941 KMIF, EMbmMusichomescreeniconsQgn_indi_mup_default_album, |
|
942 EMbmMusichomescreeniconsQgn_indi_mup_default_album_mask); |
|
943 iMHObserver->PublishImageL( this, EMusicWidgetImage1, |
|
944 KAknsIIDQgnIndiMupDefaultAlbum, |
|
945 KMIF, EMbmMusichomescreeniconsQgn_indi_mup_default_album, |
|
946 EMbmMusichomescreeniconsQgn_indi_mup_default_album_mask); |
|
947 } |
|
948 |
|
949 TUint tbstate = iToolBarState; |
|
950 //To Force a change on the toolbar with the current properties. |
|
951 iToolBarState = 0; |
|
952 if (!iActive) |
|
953 { |
|
954 //This is to force the icons to update, but we still want to keep |
|
955 //the plugin as incative. |
|
956 iActive = ETrue; |
|
957 UpdateToolBarL(tbstate); |
|
958 iActive = EFalse; |
|
959 } |
|
960 else |
|
961 { |
|
962 UpdateToolBarL(tbstate); |
|
963 } |
|
964 MPX_DEBUG1("CMCPMusicPlayer::DoHandleSkinChangedL --->"); |
|
965 } |
|
966 |
|
967 |
|
968 |
|
969 // --------------------------------------------------------------------------- |
|
970 // From CMCPPlugin |
|
971 // --------------------------------------------------------------------------- |
|
972 // |
|
973 void CMCPMusicPlayer::Deactivate() |
|
974 { |
|
975 MPX_DEBUG1("CMCPMusicPlayer::Deactivate() <---"); |
|
976 iActive = EFalse; |
|
977 if (iFileMonitor) |
|
978 { |
|
979 delete iFileMonitor; |
|
980 iFileMonitor = NULL; |
|
981 } |
|
982 if (iAppMonitor) |
|
983 { |
|
984 delete iAppMonitor; |
|
985 iAppMonitor = NULL; |
|
986 } |
|
987 if ( iPNSMonitor ) |
|
988 { |
|
989 delete iPNSMonitor; |
|
990 iPNSMonitor = NULL; |
|
991 } |
|
992 MPX_DEBUG1("CMCPMusicPlayer::Deactivate() --->"); |
|
993 } |
|
994 |
|
995 // --------------------------------------------------------------------------- |
|
996 // From CMCPPlugin |
|
997 // --------------------------------------------------------------------------- |
|
998 // |
|
999 void CMCPMusicPlayer::SkinChanged() |
|
1000 { |
|
1001 MPX_DEBUG1("CMCPMusicPlayer::SkinChanged() <---"); |
|
1002 TRAP_IGNORE( DoHandleSkinChangedL() ); |
|
1003 MPX_DEBUG1("CMCPMusicPlayer::SkinChanged() --->"); |
|
1004 } |
|
1005 |
|
1006 // --------------------------------------------------------------------------- |
|
1007 // From MAiPlayerPluginEngineObserver |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // |
|
1010 void CMCPMusicPlayer::PlayerStateChanged( TMPlayerState aState ) |
|
1011 { |
|
1012 MPX_DEBUG1("CMCPMusicPlayer::PlayerStateChanged <---"); |
|
1013 //we want to activate only with states that can be triggered by the user. |
|
1014 if (!iActive && |
|
1015 aState == EMPlayerStatePlaying) |
|
1016 { |
|
1017 //ActivateL updates the whole widget and music suite data. |
|
1018 MPX_DEBUG1("CMCPMusicPlayer::PlayerStateChanged activating"); |
|
1019 TRAP_IGNORE( ActivateL() ); |
|
1020 } |
|
1021 else |
|
1022 { |
|
1023 MPX_DEBUG1("CMCPMusicPlayer::PlayerStateChanged updating state"); |
|
1024 TRAP_IGNORE(DoUpdatePlayerStateL(aState)); |
|
1025 } |
|
1026 MPX_DEBUG1("CMCPMusicPlayer::PlayerStateChanged --->"); |
|
1027 } |
|
1028 |
|
1029 // --------------------------------------------------------------------------- |
|
1030 // From MAiPlayerPluginEngineObserver |
|
1031 // --------------------------------------------------------------------------- |
|
1032 // |
|
1033 void CMCPMusicPlayer::TrackInfoChanged( const TDesC& aTitle, |
|
1034 const TDesC& aArtist ) |
|
1035 |
|
1036 { |
|
1037 MPX_DEBUG1("CMCPMusicPlayer::TrackInfoChanged <---"); |
|
1038 if (iActive) |
|
1039 { |
|
1040 MPX_DEBUG1("CMCPMusicPlayer::TrackInfoChanged updating track info"); |
|
1041 TRAP_IGNORE(DoUpdateTrackInfoL(aTitle, aArtist)); |
|
1042 } |
|
1043 MPX_DEBUG1("CMCPMusicPlayer::TrackInfoChanged --->"); |
|
1044 } |
|
1045 |
|
1046 // --------------------------------------------------------------------------- |
|
1047 // From MAiPlayerPluginEngineObserver |
|
1048 // --------------------------------------------------------------------------- |
|
1049 // |
|
1050 void CMCPMusicPlayer::PlaybackPositionChanged( TInt aPosition ) |
|
1051 { |
|
1052 TRAP_IGNORE( DoUpdatePlaybackPositionL( aPosition ) ); |
|
1053 } |
|
1054 |
|
1055 // --------------------------------------------------------------------------- |
|
1056 // From MAiPlayerPluginEngineObserver |
|
1057 // --------------------------------------------------------------------------- |
|
1058 // |
|
1059 void CMCPMusicPlayer::AlbumArtChanged( CFbsBitmap* aBitmap ) |
|
1060 { |
|
1061 MPX_DEBUG1("CMCPMusicPlayer::AlbumArtChanged <---"); |
|
1062 if (!iActive) |
|
1063 { |
|
1064 iCachedArtBitmap = aBitmap; |
|
1065 iArtCached = ETrue; |
|
1066 } |
|
1067 else |
|
1068 { |
|
1069 MPX_DEBUG1("CMCPMusicPlayer::AlbumArtChanged updating album art"); |
|
1070 TRAP_IGNORE( DoUpdateAlbumArtL( aBitmap ) ); |
|
1071 } |
|
1072 MPX_DEBUG1("CMCPMusicPlayer::AlbumArtChanged --->"); |
|
1073 } |
|
1074 |
|
1075 // --------------------------------------------------------------------------- |
|
1076 // From MAiPlayerPluginEngineObserver |
|
1077 // --------------------------------------------------------------------------- |
|
1078 // |
|
1079 void CMCPMusicPlayer::Opening() |
|
1080 { |
|
1081 MPX_DEBUG1("CMCPMusicPlayer::Opening <---"); |
|
1082 TRAP_IGNORE( DoHandleOpeningL() ); |
|
1083 MPX_DEBUG1("CMCPMusicPlayer::Opening --->"); |
|
1084 } |
|
1085 |
|
1086 |
|
1087 // --------------------------------------------------------------------------- |
|
1088 // From MAiPlayerPluginEngineObserver |
|
1089 // --------------------------------------------------------------------------- |
|
1090 // |
|
1091 void CMCPMusicPlayer::PlaylisIsEmpty() |
|
1092 { |
|
1093 //TRAP_IGNORE( DoHandlePlaylisIsEmptyL() ); |
|
1094 } |
|
1095 // --------------------------------------------------------------------------- |
|
1096 // From MAiPlayerPluginEngineObserver |
|
1097 // --------------------------------------------------------------------------- |
|
1098 // |
|
1099 void CMCPMusicPlayer::HandleFileRemovedL() |
|
1100 { |
|
1101 MPX_DEBUG1("CMCPMusicPlayer::HandleFileRemovedL <---"); |
|
1102 iActive = EFalse; |
|
1103 ResetL(); |
|
1104 MPX_DEBUG1("CMCPMusicPlayer::HandleFileRemovedL --->"); |
|
1105 } |
|
1106 |
|
1107 |
|
1108 // --------------------------------------------------------------------------- |
|
1109 // From MApplicationMonitorObserver |
|
1110 // --------------------------------------------------------------------------- |
|
1111 // |
|
1112 void CMCPMusicPlayer::HandleApplicationClosedL(TExitType aReason) |
|
1113 { |
|
1114 MPX_DEBUG1("CMCPMusicPlayer::HandleApplicationClosedL <---"); |
|
1115 if (aReason == EExitPanic) |
|
1116 { |
|
1117 MPX_DEBUG1("CMCPMusicPlayer::HandleApplicationClosedL panic"); |
|
1118 iActive = EFalse; |
|
1119 ResetL(); |
|
1120 } |
|
1121 else |
|
1122 { |
|
1123 MPX_DEBUG1("CMCPMusicPlayer::HandleApplicationClosedL normal close"); |
|
1124 UpdateToolBarL( TBK::KSkeep_L_dimmed | |
|
1125 TBK::KPlay_last_played | |
|
1126 TBK::KSkeep_R_dimmed ); |
|
1127 if (IsOKToPublishData() ) |
|
1128 { |
|
1129 iMHObserver->PublishTextL( this, EMusicWidgetDefaultText, KEmpty ); |
|
1130 InstallGoToLastPlayedL(EMusicMenuMusicInfoTrigger, EFalse); |
|
1131 iMHObserver->PublishTextL(this, EMusicMenuMusicInfoLine1, |
|
1132 KLastPlayed); |
|
1133 DoUpdateTrackInfoL(iEngine->TitleL(), iEngine->Artist()); |
|
1134 DoUpdateAlbumArtL(iArtCached ? iCachedArtBitmap : iArtBitmap); |
|
1135 } |
|
1136 if ( iAppMonitor ) |
|
1137 { |
|
1138 MPX_DEBUG1("CMCPMusicPlayer::HandleApplicationClosedL deliting app monitor"); |
|
1139 delete iAppMonitor; |
|
1140 iAppMonitor = NULL; |
|
1141 } |
|
1142 |
|
1143 iActive = EFalse; |
|
1144 //in case the app closed before the info was updated. |
|
1145 if (iEngine->TitleL() == KNullDesC) |
|
1146 { |
|
1147 MPX_DEBUG1("CMCPMusicPlayer::HandleApplicationClosedL there is no title - resetting"); |
|
1148 ResetL(); |
|
1149 } |
|
1150 } |
|
1151 MPX_DEBUG1("CMCPMusicPlayer::HandleApplicationClosedL --->"); |
|
1152 } |
|
1153 // --------------------------------------------------------------------------- |
|
1154 // From MMPXCollectionObserver |
|
1155 // Handle collection messages. |
|
1156 // --------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CMCPMusicPlayer::HandleCollectionMessage( CMPXMessage* aMsg, TInt aErr ) |
|
1159 { |
|
1160 MPX_DEBUG1("--->CMCPMusicPlayer::HandleCollectionMessage()"); |
|
1161 if ( aErr == KErrNone && aMsg ) |
|
1162 { |
|
1163 TRAP_IGNORE( HandleCollectionMessageL( aMsg )); |
|
1164 } |
|
1165 MPX_DEBUG1("<---CMCPMusicPlayer::HandleCollectionMessage()"); |
|
1166 } |
|
1167 // --------------------------------------------------------------------------- |
|
1168 // Handle collection messages. |
|
1169 // --------------------------------------------------------------------------- |
|
1170 // |
|
1171 void CMCPMusicPlayer::HandleCollectionMessageL( CMPXMessage* aMsg ) |
|
1172 { |
|
1173 MPX_DEBUG1("--->CMCPMusicPlayer::HandleCollectionMessageL()"); |
|
1174 TMPXMessageId messageId = aMsg->ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ); |
|
1175 if ( messageId == KMPXMessageGeneral ) |
|
1176 { |
|
1177 DoHandleGeneralMessageL( *aMsg ); |
|
1178 } |
|
1179 MPX_DEBUG1("<---CMCPMusicPlayer::HandleCollectionMessageL()"); |
|
1180 } |
|
1181 // --------------------------------------------------------------------------- |
|
1182 // Handle collection general message. |
|
1183 // --------------------------------------------------------------------------- |
|
1184 // |
|
1185 void CMCPMusicPlayer::DoHandleGeneralMessageL(const CMPXMessage& aMsg) |
|
1186 { |
|
1187 TInt event = aMsg.ValueTObjectL<TInt> ( KMPXMessageGeneralEvent ); |
|
1188 TInt type = aMsg.ValueTObjectL<TInt> ( KMPXMessageGeneralType ); |
|
1189 MPX_DEBUG3("--->CMCPMusicPlayer::DoHandleGeneralMessageL(), event = %d, type = %d", event, type); |
|
1190 |
|
1191 if ( event == TMPXCollectionMessage::EBroadcastEvent |
|
1192 && ( type == EMcMsgUSBMassStorageStart || |
|
1193 type == EMcMsgUSBMTPStart || |
|
1194 type == EMcMsgRefreshStart )) |
|
1195 { |
|
1196 iBlockingOperationOngoing = ETrue; |
|
1197 MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iBlockingOperationOngoing changed to: %d", |
|
1198 iBlockingOperationOngoing ); |
|
1199 UpdateToolBarL( TBK::KSkeep_L_dimmed | |
|
1200 TBK::KPlay_dimmed | |
|
1201 TBK::KSkeep_R_dimmed ); |
|
1202 if ( IsOKToPublishData() ) |
|
1203 { |
|
1204 InstallGoToNowPlayingL( EMusicMenuMusicInfoTrigger ); |
|
1205 } |
|
1206 } |
|
1207 else if ( event == TMPXCollectionMessage::EBroadcastEvent |
|
1208 && ( type == EMcMsgUSBMassStorageEnd || |
|
1209 type == EMcMsgUSBMTPEnd || |
|
1210 type == EMcMsgRefreshEnd )) |
|
1211 { |
|
1212 iBlockingOperationOngoing = EFalse; |
|
1213 MPX_DEBUG2("CMCPMusicPlayer::DoHandleGeneralMessageL(), iBlockingOperationOngoing changed to: %d", |
|
1214 iBlockingOperationOngoing ); |
|
1215 DoUpdatePlayerStateL( iEngine->PlayerState() ); |
|
1216 if ( IsOKToPublishData() ) |
|
1217 { |
|
1218 iMHObserver->PublishTextL( this, EMusicWidgetDefaultText, |
|
1219 KEmpty ); |
|
1220 InstallGoToLastPlayedL( EMusicMenuMusicInfoTrigger, ETrue ); |
|
1221 iMHObserver->PublishTextL( this, EMusicMenuMusicInfoLine1, |
|
1222 KLastPlayed ); |
|
1223 DoUpdateTrackInfoL( iEngine->TitleL(), iEngine->Artist() ); |
|
1224 DoUpdateAlbumArtL( iArtCached ? iCachedArtBitmap : iArtBitmap ); |
|
1225 } |
|
1226 } |
|
1227 MPX_DEBUG3("<---CMCPMusicPlayer::DoHandleGeneralMessageL(), event = %d, type = %d", event, type); |
|
1228 } |
|
1229 // --------------------------------------------------------------------------- |
|
1230 // From MMPXCollectionObserver |
|
1231 // --------------------------------------------------------------------------- |
|
1232 // |
|
1233 void CMCPMusicPlayer::HandleOpenL( const CMPXMedia& /*aEntries*/, |
|
1234 TInt /*aIndex*/, TBool /*aComplete*/, TInt /*aError*/ ) |
|
1235 { |
|
1236 // Do nothing |
|
1237 } |
|
1238 |
|
1239 // --------------------------------------------------------------------------- |
|
1240 // From MMPXCollectionObserver |
|
1241 // --------------------------------------------------------------------------- |
|
1242 // |
|
1243 void CMCPMusicPlayer::HandleOpenL( const CMPXCollectionPlaylist& /*aPlaylist*/, |
|
1244 TInt /*aError*/ ) |
|
1245 { |
|
1246 // Do nothing |
|
1247 } |
|
1248 |
|
1249 // --------------------------------------------------------------------------- |
|
1250 // From MMPXCollectionMediaObserver |
|
1251 // --------------------------------------------------------------------------- |
|
1252 void CMCPMusicPlayer::HandleCollectionMediaL( const CMPXMedia& /*aMedia*/, TInt /*aError*/ ) |
|
1253 { |
|
1254 // Do nothing |
|
1255 } |
|
1256 |
|
1257 // --------------------------------------------------------------------------- |
|
1258 // From MPNSMonitorObserver |
|
1259 // --------------------------------------------------------------------------- |
|
1260 // |
|
1261 void CMCPMusicPlayer::OpeningMusicPlayer() |
|
1262 { |
|
1263 MPX_DEBUG1("CMCPMusicPlayer::OpeningMusicPlayer <---"); |
|
1264 // in this position, iActive is EFalse, so we can not call function |
|
1265 // DoHandleOpeningL() directly. |
|
1266 TRAP_IGNORE( |
|
1267 iMHObserver->PublishTextL( this, |
|
1268 EMusicWidgetText1, |
|
1269 iOpeningBuffer->Des() ) ); |
|
1270 |
|
1271 TCallBack cb( MusicPlayerOpeningTimerCallback, this ); |
|
1272 iMusicPlayerOpeningTimer->Cancel(); |
|
1273 iMusicPlayerOpeningTimer->Start( KMusicPlayerOpeningTimerInterval, |
|
1274 KMusicPlayerOpeningTimerInterval, cb ); |
|
1275 |
|
1276 MPX_DEBUG1("CMCPMusicPlayer::OpeningMusicPlayer --->"); |
|
1277 } |
|
1278 |
|
1279 // ---------------------------------------------------------------------------- |
|
1280 // Music Player opening timer callback |
|
1281 // ---------------------------------------------------------------------------- |
|
1282 // |
|
1283 TInt CMCPMusicPlayer::MusicPlayerOpeningTimerCallback( TAny* aPtr ) |
|
1284 { |
|
1285 MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback <---"); |
|
1286 if ( EMPlayerStatePlaying != static_cast<CMCPMusicPlayer*>(aPtr)->iEngine->PlayerState() ) |
|
1287 { |
|
1288 MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback Music Player not Playing"); |
|
1289 //Reset the widget and menu, music player is not running and playing. |
|
1290 static_cast<CMCPMusicPlayer*>(aPtr)->iActive = EFalse; |
|
1291 TRAP_IGNORE( static_cast<CMCPMusicPlayer*>(aPtr)->ResetL() ); |
|
1292 } |
|
1293 static_cast<CMCPMusicPlayer*>(aPtr)->iMusicPlayerOpeningTimer->Cancel(); |
|
1294 |
|
1295 MPX_DEBUG1("CMCPMusicPlayer::MusicPlayerOpeningTimerCallback --->"); |
|
1296 return KErrNone; |
|
1297 } |
|
1298 // End of File |