|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of Playback view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <aknViewAppUi.h> |
|
22 #include <eikmenub.h> |
|
23 #include <eikapp.h> |
|
24 #include <AknUtils.h> |
|
25 #include <akntitle.h> |
|
26 #include <apgcli.h> |
|
27 #include <bautils.h> |
|
28 #include <featmgr.h> |
|
29 #include <StringLoader.h> |
|
30 #include <aknnotewrappers.h> |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <mpxmedia.h> |
|
33 #include <mpxplaybackutility.h> |
|
34 #include <mpxcollectionplaylist.h> |
|
35 #include <mpxcommonplaybackview.rsg> |
|
36 #include <mpxembeddedplaybackview.rsg> |
|
37 #include <mpxmediamusicdefs.h> |
|
38 #include <mpxmediadrmdefs.h> |
|
39 #include "mpxcommonuihelper.h" |
|
40 #include <mpxtlshelper.h> |
|
41 #include "mpxcommonplaybackview.hrh" |
|
42 #include "mpxembeddedplaybackview.hrh" |
|
43 #include "mpxembeddedplaybackviewimp.h" |
|
44 #include "mpxembeddedplaybackviewcontainer.h" |
|
45 #include "mpxembeddedplaybackviewlayout.h" |
|
46 #include <mpxappui.hrh> |
|
47 #include "mpxlog.h" |
|
48 #include <mpxplaybackutility.h> |
|
49 #include <akntoolbar.h> |
|
50 #include <aknbutton.h> |
|
51 #include "mpxcommonplaybackview.hrh" |
|
52 #include <mpxmessagegeneraldefs.h> |
|
53 #include <mpxplaybackmessage.h> |
|
54 #include <mpxuser.h> |
|
55 |
|
56 // CONSTANTS |
|
57 _LIT( KMPXEmbeddedPlaybackRscPath, "mpxembeddedplaybackview.rsc" ); |
|
58 const TInt KMPXOneSecInMilliSecs( 1000 ); |
|
59 _LIT(KMPXMusicplayerPrivateFolder, "\\private\\"); |
|
60 |
|
61 |
|
62 // ======== MEMBER FUNCTIONS ======== |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // C++ default constructor can NOT contain any code, that |
|
66 // might leave. |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CMPXEmbeddedPlaybackViewImp::CMPXEmbeddedPlaybackViewImp() |
|
70 { |
|
71 // Do nothing |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Symbian 2nd phase constructor can leave. |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CMPXEmbeddedPlaybackViewImp::ConstructL() |
|
79 { |
|
80 MPX_FUNC( "CMPXEmbeddedPlaybackViewImp::ConstructL" ); |
|
81 |
|
82 // Load embedded resource |
|
83 CCoeEnv* coeEnv = iEikonEnv; |
|
84 TParse parse; |
|
85 parse.Set( KMPXEmbeddedPlaybackRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
86 TFileName resourceFile( parse.FullName() ); |
|
87 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
88 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
89 iEmbeddedResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
90 |
|
91 CMPXCommonPlaybackViewImp::ConstructL(); |
|
92 BaseConstructL( R_MPX_EMBEDDED_PLAYBACK_VIEW ); |
|
93 |
|
94 if(AknLayoutUtils::PenEnabled()) |
|
95 { |
|
96 CAknView::ShowToolbarOnViewActivation(ETrue); |
|
97 if ( Toolbar() ) |
|
98 { |
|
99 iToolbar = Toolbar(); |
|
100 iToolbar->SetToolbarObserver( this ); |
|
101 } |
|
102 } |
|
103 |
|
104 // Override base class setting to allow |
|
105 // embedded playback to properly fetch media properties. |
|
106 iLastPBViewActivated = ETrue; |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // Two-phased constructor. |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 CMPXEmbeddedPlaybackViewImp* CMPXEmbeddedPlaybackViewImp::NewL() |
|
114 { |
|
115 CMPXEmbeddedPlaybackViewImp* self = CMPXEmbeddedPlaybackViewImp::NewLC(); |
|
116 CleanupStack::Pop( self ); |
|
117 return self; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // Two-phased constructor. |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 CMPXEmbeddedPlaybackViewImp* CMPXEmbeddedPlaybackViewImp::NewLC() |
|
125 { |
|
126 CMPXEmbeddedPlaybackViewImp* self = new ( ELeave ) CMPXEmbeddedPlaybackViewImp(); |
|
127 CleanupStack::PushL( self ); |
|
128 self->ConstructL(); |
|
129 return self; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // Destructor |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 CMPXEmbeddedPlaybackViewImp::~CMPXEmbeddedPlaybackViewImp() |
|
137 { |
|
138 MPX_DEBUG1( "CMPXEmbeddedPlaybackViewImp::~CMPXEmbeddedPlaybackViewImp entering" ); |
|
139 |
|
140 if ( iEmbeddedResourceOffset ) |
|
141 { |
|
142 iEikonEnv->DeleteResourceFile( iEmbeddedResourceOffset ); |
|
143 } |
|
144 |
|
145 delete iPlaybackViewLayout; |
|
146 |
|
147 MPX_DEBUG1( "CMPXEmbeddedPlaybackViewImp::~CMPXEmbeddedPlaybackViewImp exiting" ); |
|
148 } |
|
149 |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // Updates Title Pane. |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CMPXEmbeddedPlaybackViewImp::UpdateTitlePaneL() |
|
156 { |
|
157 MPX_FUNC( "CMPXEmbeddedPlaybackViewImp::UpdateTitlePaneL" ); |
|
158 |
|
159 CAknTitlePane* title( static_cast<CAknTitlePane*> |
|
160 ( StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle )))); |
|
161 if ( title ) |
|
162 { |
|
163 RProcess process; |
|
164 TApaAppInfo appInfo; |
|
165 RApaLsSession session; |
|
166 User::LeaveIfError( session.Connect() ); // May want to ignore error |
|
167 CleanupClosePushL( session ); |
|
168 |
|
169 TInt err = session.GetAppInfo( appInfo, MPXTlsHelper::HostUid() ); |
|
170 if(!err) |
|
171 { |
|
172 title->SetTextL( appInfo.iCaption ); |
|
173 } |
|
174 CleanupStack::PopAndDestroy(); // Close RApaLsSession session |
|
175 } |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // Updates track info field. |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CMPXEmbeddedPlaybackViewImp::UpdateTrackInfoL( |
|
183 const CMPXMedia* aMedia ) |
|
184 { |
|
185 MPX_FUNC( "CMPXEmbeddedPlaybackViewImp::UpdateTrackInfo" ); |
|
186 |
|
187 CMPXCommonPlaybackViewImp::UpdateTrackInfoL( aMedia ); |
|
188 |
|
189 if( iContainer && |
|
190 aMedia && |
|
191 iCommonUiHelper->IsHostPodcastingAppL() ) |
|
192 { |
|
193 // if embedded view is launched via podcasting app |
|
194 // display episode name and title |
|
195 |
|
196 // Set ETextArtist field as Podcast Title |
|
197 if ( aMedia->IsSupported( |
|
198 TMPXAttribute( KMPXMediaIdMusic, |
|
199 EMPXMediaMusicAlbum ))) |
|
200 { |
|
201 HBufC* titleText = aMedia->ValueText( |
|
202 TMPXAttribute( KMPXMediaIdMusic, |
|
203 EMPXMediaMusicAlbum )).AllocL(); |
|
204 CleanupStack::PushL(titleText); |
|
205 if ( titleText->Length() > 0) |
|
206 { |
|
207 iContainer->UpdateLabelL( ETextArtist, *titleText ); |
|
208 } |
|
209 else |
|
210 { |
|
211 HBufC* unknownText = |
|
212 StringLoader::LoadLC( R_MPX_QTN_NMP_UNKNOWN_TITLE ); |
|
213 iContainer->UpdateLabelL( |
|
214 ETextArtist, *unknownText ); |
|
215 CleanupStack::PopAndDestroy( unknownText ); |
|
216 } |
|
217 CleanupStack::PopAndDestroy( titleText ); |
|
218 } |
|
219 else |
|
220 { |
|
221 HBufC* unknownText = |
|
222 StringLoader::LoadLC( R_MPX_QTN_NMP_UNKNOWN_TITLE ); |
|
223 iContainer->UpdateLabelL( |
|
224 ETextArtist, *unknownText ); |
|
225 CleanupStack::PopAndDestroy( unknownText ); |
|
226 } |
|
227 } |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // Displays error notes. |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 void CMPXEmbeddedPlaybackViewImp::HandleErrorL( TInt aError ) |
|
235 { |
|
236 if ( aError ) |
|
237 { |
|
238 MPX_DEBUG2( "CMPXEmbeddedPlaybackViewImp::HandleErrorL(%d)", aError ); |
|
239 |
|
240 TBool omaFlag = EFalse; |
|
241 TInt plCount( KErrNotFound ); |
|
242 MMPXSource* source = iPlaybackUtility->Source(); |
|
243 if ( source ) |
|
244 { |
|
245 CMPXCollectionPlaylist* pl( source->PlaylistL() ); |
|
246 if ( pl ) |
|
247 { |
|
248 CleanupStack::PushL( pl ); |
|
249 plCount = pl->Count(); |
|
250 CleanupStack::PopAndDestroy( pl ); |
|
251 } |
|
252 } |
|
253 |
|
254 if ( plCount == 1 ) |
|
255 { |
|
256 #ifndef CAMESE_IN_DRM_UTILITY |
|
257 // If Camese support is enabled, |
|
258 // check if the song is protected WMA |
|
259 // and let Camese handle it in case it is. |
|
260 if (iCameseSuperDistSupport && |
|
261 iMedia) |
|
262 { |
|
263 // Check protection and media type |
|
264 if ( iMedia->IsSupported( KMPXMediaDrmProtected ) && |
|
265 iMedia->IsSupported( KMPXMediaDrmType ) ) |
|
266 { |
|
267 TBool prot( iMedia->ValueTObjectL<TBool>( KMPXMediaDrmProtected ) ); |
|
268 TMPXMediaDrmType type( iMedia->ValueTObjectL<TMPXMediaDrmType>( KMPXMediaDrmType ) ); |
|
269 |
|
270 if (prot && (EMPXDrmTypeWMA == type)) |
|
271 { |
|
272 MPX_DEBUG1( "CMPXEmbeddedPlaybackViewImp::HandleErrorL: Let Camese Handle Error"); |
|
273 // Let Camese Handle errors in this case. |
|
274 return; |
|
275 } |
|
276 if (prot && (EMPXDrmTypeOMA == type)) |
|
277 { |
|
278 omaFlag = ETrue; |
|
279 } |
|
280 } |
|
281 } |
|
282 #endif |
|
283 if ( aError == KErrCorrupt || aError == KErrNotSupported ) |
|
284 { |
|
285 // special handling is needed for KErrCorrupt/KErrNotSupported with just 1 song |
|
286 iCommonUiHelper->HandleErrorL( aError ); |
|
287 } |
|
288 else if (omaFlag) |
|
289 { |
|
290 iCommonUiHelper->HandleErrorL( aError, iMedia ); |
|
291 } |
|
292 else |
|
293 { |
|
294 CMPXCommonPlaybackViewImp::HandleErrorL( aError ); |
|
295 } |
|
296 |
|
297 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
298 if( aError != KErrArgument && aError != KErrCompletion ) |
|
299 { |
|
300 HandleCommandL( EAknSoftkeyBack ); |
|
301 } |
|
302 } |
|
303 else |
|
304 { |
|
305 // let base class handle it |
|
306 CMPXCommonPlaybackViewImp::HandleErrorL( aError ); |
|
307 } |
|
308 } |
|
309 } |
|
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // From base class CMPXCommonPlaybackViewImp |
|
313 // |
|
314 // Handle playback property. |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 void CMPXEmbeddedPlaybackViewImp::DoHandlePropertyL( |
|
318 TMPXPlaybackProperty aProperty, |
|
319 TInt aValue, |
|
320 TInt aError ) |
|
321 { |
|
322 MPX_FUNC( "CMPXEmbeddedPlaybackViewImp::DoHandlePropertyL" ); |
|
323 MPX_DEBUG4( "HandlePropertyL - Property(%d); Value(%d); Error(%d)", aProperty, aValue, aError ); |
|
324 |
|
325 if ( KErrNone == aError ) |
|
326 { |
|
327 switch ( aProperty ) |
|
328 { |
|
329 case EPbPropertyPosition: |
|
330 { |
|
331 TInt duration(aValue / KMPXOneSecInMilliSecs); |
|
332 if( duration > iDuration) |
|
333 { |
|
334 HandleCommandL(EMPXCmdStop); |
|
335 } |
|
336 else |
|
337 { |
|
338 CMPXCommonPlaybackViewImp::DoHandlePropertyL(aProperty, |
|
339 aValue, |
|
340 aError); |
|
341 } |
|
342 break; |
|
343 } |
|
344 default: |
|
345 { |
|
346 CMPXCommonPlaybackViewImp::DoHandlePropertyL(aProperty, |
|
347 aValue, |
|
348 aError); |
|
349 break; |
|
350 } |
|
351 } |
|
352 } |
|
353 else |
|
354 { |
|
355 HandleErrorL( aError ); |
|
356 } |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // From MMPXCHelperEmbeddedOpenObserver |
|
361 // Handles errors from that occured in embedded mode |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 void CMPXEmbeddedPlaybackViewImp::HandleEmbeddedOpenL( |
|
365 TInt aErr, |
|
366 TMPXGeneralCategory /*aCategory*/ ) |
|
367 { |
|
368 if ( KErrNone != aErr ) |
|
369 { |
|
370 HandleErrorL( aErr ); |
|
371 |
|
372 // Kill MPX |
|
373 AppUi()->RunAppShutter(); |
|
374 } |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------------------------- |
|
378 // From MEikMenuObserver |
|
379 // Dynamically initialises a menu pane. |
|
380 // --------------------------------------------------------------------------- |
|
381 // |
|
382 void CMPXEmbeddedPlaybackViewImp::DynInitMenuPaneL( |
|
383 TInt aResourceId, |
|
384 CEikMenuPane* aMenuPane ) |
|
385 { |
|
386 // Override base menu actions |
|
387 switch ( aResourceId ) |
|
388 { |
|
389 case R_MPX_EMBEDDED_PLAYBACK_VIEW_MENU: |
|
390 { |
|
391 if ( iCommonUiHelper->IsHostMessagingL() ) |
|
392 { |
|
393 AppUi()->HandleCommandL( EMPXCmdIsFileSaved ); |
|
394 } |
|
395 // Disable Save command if not launched from the specified apps |
|
396 if ( !MPXTlsHelper::NeedSave() || |
|
397 EPbStateNotInitialised == iPlaybackState || |
|
398 EPbStateInitialising == iPlaybackState ) |
|
399 { |
|
400 aMenuPane->SetItemDimmed( |
|
401 EMPXPbvCmdSave, |
|
402 ETrue); |
|
403 } |
|
404 TBool isOfflineMode( EFalse ); |
|
405 TBool isFormatNotSupported( EFalse ); |
|
406 if ( !isOfflineMode && iMedia ) |
|
407 { |
|
408 if ( iMedia->IsSupported( KMPXMediaDrmProtected ) ) |
|
409 { |
|
410 if ( iMedia->ValueTObjectL<TBool>( KMPXMediaDrmProtected ) && |
|
411 iMedia->IsSupported( KMPXMediaDrmCanSetAutomated ) ) |
|
412 { |
|
413 // if it's drm protected, check if |
|
414 // KMPXMediaDrmCanSetAutomated |
|
415 isFormatNotSupported = !( |
|
416 iMedia->ValueTObjectL<TBool>( KMPXMediaDrmCanSetAutomated ) ); |
|
417 } |
|
418 } |
|
419 } |
|
420 if ( isOfflineMode || |
|
421 !iMedia || |
|
422 isFormatNotSupported ) |
|
423 { |
|
424 aMenuPane->SetItemDimmed( |
|
425 EMPXPbvCmdUseAsCascade, |
|
426 ETrue ); |
|
427 } |
|
428 |
|
429 if(iCommonUiHelper->IsHostPodcastingAppL()) |
|
430 { |
|
431 aMenuPane->SetItemDimmed( |
|
432 EMPXPbvCmdUseAsCascade, |
|
433 ETrue ); |
|
434 |
|
435 aMenuPane->SetItemDimmed( |
|
436 EMPXPbvCmdSave, |
|
437 ETrue); |
|
438 } |
|
439 |
|
440 // Check if FM Transmitter is supported |
|
441 if ( !FeatureManager::FeatureSupported( KFeatureIdFmtx ) ) |
|
442 { |
|
443 aMenuPane->SetItemDimmed( |
|
444 EMPXPbvCmdFMTransmitter, |
|
445 ETrue ); |
|
446 } |
|
447 break; |
|
448 } |
|
449 default: |
|
450 { |
|
451 // Call base clase to handle other cases |
|
452 CMPXCommonPlaybackViewImp::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
453 break; |
|
454 } |
|
455 } |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // From CAknView |
|
460 // Returns views id. |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 TUid CMPXEmbeddedPlaybackViewImp::Id() const |
|
464 { |
|
465 return TUid::Uid( KMPXEmbeddedPlaybackViewId ); |
|
466 } |
|
467 |
|
468 // --------------------------------------------------------------------------- |
|
469 // From CAknView |
|
470 // Command handling function |
|
471 // --------------------------------------------------------------------------- |
|
472 // |
|
473 void CMPXEmbeddedPlaybackViewImp::HandleCommandL( TInt aCommand ) |
|
474 { |
|
475 MPX_DEBUG2("CMPXEmbeddedPlaybackViewImp::HandleCommandL(%d): entering", aCommand); |
|
476 |
|
477 switch ( aCommand ) |
|
478 { |
|
479 case EMPXPbvCmdSave: |
|
480 { |
|
481 HandleSaveL( EMPXNpvOpenAfterSave ); |
|
482 break; |
|
483 } |
|
484 case EMPXCmdSaveCancelled: |
|
485 { |
|
486 iSaveInProgress = EFalse; |
|
487 break; |
|
488 } |
|
489 case EMPXCmdSaveComplete: |
|
490 { |
|
491 iSaveInProgress = EFalse; |
|
492 MPXTlsHelper::SetNeedSave( EFalse ); |
|
493 break; |
|
494 } |
|
495 case EMPXCmdSaveNotProgress: |
|
496 { |
|
497 iSaveInProgress = EFalse; |
|
498 break; |
|
499 } |
|
500 case EAknSoftkeyBack: |
|
501 { |
|
502 if ( iCommonUiHelper->IsHostMessagingL() ) |
|
503 { |
|
504 AppUi()->HandleCommandL( EMPXCmdIsFileSaved ); |
|
505 } |
|
506 // If this was a playlist, transition back to collection view |
|
507 // |
|
508 if( MPXTlsHelper::LaunchMode() == EMPXLaunchModePlaylist ) |
|
509 { |
|
510 CMPXCommonPlaybackViewImp::HandleCommandL( aCommand ); |
|
511 } |
|
512 // Song Handling, does it need to be saved? |
|
513 // |
|
514 else if ( MPXTlsHelper::NeedSave() ) |
|
515 { |
|
516 HandleSaveL( EMXPNpvExitAppAfterSave ); |
|
517 } |
|
518 else |
|
519 { |
|
520 // If back command, only shutdown the embedded view |
|
521 AppUi()->RunAppShutter(); |
|
522 } |
|
523 break; |
|
524 } |
|
525 case EAknCmdExit: |
|
526 case EAknSoftkeyExit: |
|
527 case EEikCmdExit: |
|
528 { |
|
529 if ( MPXTlsHelper::NeedSave() ) |
|
530 { |
|
531 HandleSaveL( EMPXNpvExitHostAppAfterSave ); |
|
532 } |
|
533 else |
|
534 { |
|
535 // If exit command, then close host application as well |
|
536 CAknEnv::RunAppShutter(); |
|
537 } |
|
538 break; |
|
539 } |
|
540 case EMPXPbvCmdUseAsCascade: |
|
541 case EMPXPbvCmdAiwCmdAssign: |
|
542 { |
|
543 const TDesC& savedpath = MPXTlsHelper::FilePath(); |
|
544 const TDesC& mediapath = iMedia->ValueText( KMPXMediaGeneralUri ); |
|
545 TFileName fullName(mediapath); |
|
546 TParsePtrC fileParse( fullName ); |
|
547 TBool isPrivate = (fileParse.NamePresent() && |
|
548 !KMPXMusicplayerPrivateFolder().CompareF( |
|
549 fileParse.Path().Left( |
|
550 KMPXMusicplayerPrivateFolder().Length()))); |
|
551 |
|
552 if ( iCommonUiHelper->IsHostMessagingL() |
|
553 && mediapath.CompareF(savedpath) && isPrivate ) |
|
554 { |
|
555 HandleSaveL( (TMPXNpvSaveMode)aCommand ); |
|
556 } |
|
557 else |
|
558 { |
|
559 CMPXCommonPlaybackViewImp::HandleCommandL( aCommand ); |
|
560 } |
|
561 break; |
|
562 } |
|
563 default: |
|
564 { |
|
565 CMPXCommonPlaybackViewImp::HandleCommandL( aCommand ); |
|
566 break; |
|
567 } |
|
568 } |
|
569 |
|
570 MPX_DEBUG1("CMPXEmbeddedPlaybackViewImp::HandleCommandL(): exiting"); |
|
571 } |
|
572 |
|
573 // --------------------------------------------------------------------------- |
|
574 // From CAknView |
|
575 // Handles a view activation. |
|
576 // --------------------------------------------------------------------------- |
|
577 // |
|
578 void CMPXEmbeddedPlaybackViewImp::DoActivateL( |
|
579 const TVwsViewId& aPrevViewId, |
|
580 TUid aCustomMessageId, |
|
581 const TDesC8& aCustomMessage ) |
|
582 { |
|
583 MPX_FUNC( "CMPXEmbeddedPlaybackViewImp::DoActivateL()" ); |
|
584 |
|
585 if ( !iContainer ) |
|
586 { |
|
587 if ( !iPlaybackViewLayout ) |
|
588 { |
|
589 iPlaybackViewLayout = CMPXEmbeddedPlaybackViewLayout::NewL(); |
|
590 } |
|
591 iContainer = new ( ELeave ) CMPXEmbeddedPlaybackViewContainer( |
|
592 this, |
|
593 this, |
|
594 iPlaybackViewLayout, |
|
595 iCommonUiHelper ); |
|
596 iContainer->SetMopParent( this ); |
|
597 iContainer->ConstructL( ClientRect() ); |
|
598 AppUi()->AddToStackL( *this, iContainer ); |
|
599 } |
|
600 |
|
601 CMPXCommonPlaybackViewImp::DoActivateL( aPrevViewId , aCustomMessageId, aCustomMessage ); |
|
602 } |
|
603 |
|
604 // --------------------------------------------------------------------------- |
|
605 // Handle media properties. |
|
606 // Notes: The client is responsible for delete the object of aProperties. |
|
607 // --------------------------------------------------------------------------- |
|
608 // |
|
609 void CMPXEmbeddedPlaybackViewImp::DoHandleMediaL( |
|
610 const CMPXMedia& aMedia, |
|
611 TInt aError ) |
|
612 { |
|
613 MPX_FUNC("CMPXEmbeddedPlaybackViewImp::DoHandleMediaL"); |
|
614 if ( iPrepareToSave ) |
|
615 { |
|
616 delete iMedia; |
|
617 iMedia = NULL; |
|
618 iPrepareToSave = EFalse; |
|
619 |
|
620 if ( KErrNone == aError ) |
|
621 { |
|
622 iMedia = CMPXMedia::NewL( aMedia ); |
|
623 HandleSaveL( EMPXNpvUsePreviousMode ); |
|
624 } |
|
625 else |
|
626 { |
|
627 HandleErrorL( aError ); |
|
628 } |
|
629 } |
|
630 else |
|
631 { |
|
632 CMPXCommonPlaybackViewImp::DoHandleMediaL( aMedia, aError ); |
|
633 } |
|
634 } |
|
635 |
|
636 // --------------------------------------------------------------------------- |
|
637 // Handle saving a file |
|
638 // --------------------------------------------------------------------------- |
|
639 // |
|
640 void CMPXEmbeddedPlaybackViewImp::HandleSaveL( TMPXNpvSaveMode aMode ) |
|
641 { |
|
642 MPX_DEBUG1("CMPXEmbeddedPlaybackViewImp::HandleSaveL(): entering"); |
|
643 |
|
644 if ( !iSaveInProgress ) |
|
645 { |
|
646 if ( aMode != EMPXNpvUsePreviousMode ) |
|
647 { |
|
648 iSaveMode = aMode; |
|
649 } |
|
650 |
|
651 if ( !iMedia ) |
|
652 { |
|
653 iPrepareToSave = ETrue; |
|
654 RequestMediaL(); |
|
655 } |
|
656 else |
|
657 { |
|
658 iSaveInProgress = ETrue; |
|
659 TInt cmd( EMPXCmdSaveAndReopen ); |
|
660 if ( iSaveMode == EMXPNpvExitAppAfterSave ) |
|
661 { |
|
662 cmd = EMPXCmdSaveAndExit; |
|
663 } |
|
664 else if ( iSaveMode == EMPXNpvExitHostAppAfterSave ) |
|
665 { |
|
666 cmd = EMPXCmdSaveAndExitHostApp; |
|
667 } |
|
668 else if ( iSaveMode == EMPXPbvCmdUseAsCascade ) |
|
669 { |
|
670 cmd = EMPXCmdSaveForUseAsContact; |
|
671 } |
|
672 else if ( iSaveMode == EMPXPbvCmdAiwCmdAssign ) |
|
673 { |
|
674 cmd = EMPXCmdSaveForUseAsRingtone; |
|
675 } |
|
676 MPX_TRAPD( err, AppUi()->HandleCommandL( cmd ) ); |
|
677 if ( KErrNone != err ) |
|
678 { |
|
679 iSaveInProgress = EFalse; |
|
680 HandleErrorL( err ); |
|
681 } |
|
682 } |
|
683 } |
|
684 |
|
685 MPX_DEBUG1("CMPXEmbeddedPlaybackViewImp::HandleSaveL(): exiting"); |
|
686 } |
|
687 |
|
688 // --------------------------------------------------------------------------- |
|
689 // Handle playback message. |
|
690 // --------------------------------------------------------------------------- |
|
691 // |
|
692 void CMPXEmbeddedPlaybackViewImp::DoHandlePlaybackMessageL( |
|
693 const CMPXMessage& aMessage ) |
|
694 { |
|
695 MPX_DEBUG1( "CMPXEmbeddedPlaybackViewImp::DoHandlePlaybackMessageL"); |
|
696 |
|
697 TMPXMessageId id( *aMessage.Value<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
698 if ( KMPXMessageGeneral == id ) |
|
699 { |
|
700 TInt type( *aMessage.Value<TInt>( KMPXMessageGeneralType ) ); |
|
701 TInt data( *aMessage.Value<TInt>( KMPXMessageGeneralData ) ); |
|
702 switch ( *aMessage.Value<TInt>( KMPXMessageGeneralEvent ) ) |
|
703 { |
|
704 case TMPXPlaybackMessage::EStateChanged: |
|
705 UpdateMiddleSoftKeyDisplayL(); |
|
706 UpdateToolbar(); |
|
707 break; |
|
708 |
|
709 default: |
|
710 break; |
|
711 } |
|
712 } |
|
713 CMPXCommonPlaybackViewImp::DoHandlePlaybackMessageL (aMessage); |
|
714 } |
|
715 |
|
716 // ----------------------------------------------------------------------------- |
|
717 // From MAknToolbarObserver |
|
718 // Used to change toolbar settings before toolbar becomes visible |
|
719 // ----------------------------------------------------------------------------- |
|
720 // |
|
721 void CMPXEmbeddedPlaybackViewImp::DynInitToolbarL(TInt aResourceId, CAknToolbar* aToolbar) |
|
722 { |
|
723 if (aResourceId == R_MPX_PBV_TOUCH_TOOLBAR) |
|
724 { |
|
725 // Put initializations here to take effect before toolbar is shown |
|
726 UpdateToolbar(); |
|
727 aToolbar->UpdateBackground(); |
|
728 } |
|
729 } |
|
730 |
|
731 // ----------------------------------------------------------------------------- |
|
732 // From MAknToolbarObserver |
|
733 // Handles toolbar events |
|
734 // ----------------------------------------------------------------------------- |
|
735 // |
|
736 void CMPXEmbeddedPlaybackViewImp::OfferToolbarEventL( TInt aCommandId ) |
|
737 { |
|
738 TInt commandId = aCommandId; |
|
739 TInt eventModifiers = iToolbar->EventModifiers(); |
|
740 if ( eventModifiers == CAknToolbar::ELongPress ) |
|
741 { |
|
742 if ( aCommandId == EMPXPbvCmdNextListItem ) |
|
743 { |
|
744 commandId = EMPXPbvCmdSeekForward; |
|
745 } |
|
746 else if ( aCommandId == EMPXPbvCmdPreviousListItem ) |
|
747 { |
|
748 commandId = EMPXPbvCmdSeekBackward; |
|
749 } |
|
750 } |
|
751 else if ( eventModifiers == CAknToolbar::ELongPressEnded ) |
|
752 { |
|
753 if ( aCommandId == EMPXPbvCmdNextListItem || aCommandId == EMPXPbvCmdPreviousListItem ) |
|
754 { |
|
755 commandId = EMPXPbvCmdEndSeek; |
|
756 } |
|
757 } |
|
758 |
|
759 CAknView::ProcessCommandL( commandId ); |
|
760 } |
|
761 |
|
762 // End of File |