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