|
1 /* |
|
2 * Copyright (c) 2007 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 Progressive Download 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 <bautils.h> |
|
26 #include <featmgr.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 #include <mpxplaybackmessage.h> |
|
29 #include <mpxcommonplaybackview.rsg> |
|
30 #include <mpxpdsbplaybackview.rsg> |
|
31 #include <mpxcmn.h> |
|
32 #include <mpxplaybackutility.h> |
|
33 #include <mpxviewutility.h> |
|
34 #include <StringLoader.h> |
|
35 #include <AknQueryDialog.h> |
|
36 #include <MProfileEngine.h> |
|
37 #include <e32property.h> |
|
38 #include <mpxmessagegeneraldefs.h> |
|
39 #include <mpxcommandgeneraldefs.h> |
|
40 #include <apgwgnam.h> |
|
41 #include <mpxuser.h> |
|
42 #include <sacls.h> |
|
43 |
|
44 #include "mpxcommonuihelper.h" |
|
45 #include "mpxcommonplaybackview.hrh" |
|
46 #include "mpxpdsbplaybackview.hrh" |
|
47 #include "mpxpdsbplaybackviewimp.h" |
|
48 #include "mpxpdsbplaybackviewcontainer.h" |
|
49 #include "mpxpdsbplaybackviewlayout.h" |
|
50 #include "mpxlog.h" |
|
51 #include "mpxappui.hrh" |
|
52 |
|
53 #include <akntoolbar.h> |
|
54 #include <aknbutton.h> |
|
55 |
|
56 // CONSTANTS |
|
57 _LIT( KMPXPdSbPlaybackRscPath, "mpxpdsbplaybackview.rsc" ); |
|
58 #define KMPlayerBrowserUid 0x10008D39 |
|
59 #define KMPlayerBrowserUid2 0x1020724D |
|
60 #define KProgressDownloadUid 0x10207BCD |
|
61 |
|
62 // ======== MEMBER FUNCTIONS ======== |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // C++ default constructor can NOT contain any code, that |
|
66 // might leave. |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CMPXPdSbPlaybackViewImp::CMPXPdSbPlaybackViewImp() |
|
70 { |
|
71 // Do nothing |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // Symbian 2nd phase constructor can leave. |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CMPXPdSbPlaybackViewImp::ConstructL() |
|
79 { |
|
80 MPX_FUNC( "CMPXPdSbPlaybackViewImp::ConstructL" ); |
|
81 |
|
82 CMPXCommonPlaybackViewImp::ConstructL(); |
|
83 iPlaybackUtility->RemoveObserverL( *this ); |
|
84 iPlaybackUtility->Close(); |
|
85 iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid(KProgressDownloadUid) ); |
|
86 iPlaybackUtility->AddObserverL( *this ); |
|
87 |
|
88 // Need to set a higher priority because download manager sets it's |
|
89 // own priority high, so we need to make sure we're at least the same |
|
90 iPlaybackUtility->SetPriority( CActive::EPriorityStandard + 2 ); |
|
91 |
|
92 CCoeEnv* coeEnv = iEikonEnv; |
|
93 TParse parse; |
|
94 parse.Set( KMPXPdSbPlaybackRscPath, &KDC_APP_RESOURCE_DIR, NULL ); |
|
95 TFileName resourceFile = parse.FullName(); |
|
96 User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) ); |
|
97 BaflUtils::NearestLanguageFile( coeEnv->FsSession(), resourceFile ); |
|
98 iPdResourceOffset = coeEnv->AddResourceFileL( resourceFile ); |
|
99 |
|
100 BaseConstructL( R_MPX_PD_SB_PLAYBACK_VIEW ); |
|
101 if(AknLayoutUtils::PenEnabled()) |
|
102 { |
|
103 CAknView::ShowToolbarOnViewActivation(ETrue); |
|
104 if ( Toolbar() ) |
|
105 { |
|
106 iToolbar = Toolbar(); |
|
107 iToolbar->SetToolbarObserver( this ); |
|
108 } |
|
109 } |
|
110 iDownloadState = EPbDlStateDownloading; // Otherwise we will show "Download Stopped" |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // Two-phased constructor. |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 CMPXPdSbPlaybackViewImp* CMPXPdSbPlaybackViewImp::NewL() |
|
118 { |
|
119 CMPXPdSbPlaybackViewImp* self = CMPXPdSbPlaybackViewImp::NewLC(); |
|
120 CleanupStack::Pop( self ); |
|
121 return self; |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // Two-phased constructor. |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 CMPXPdSbPlaybackViewImp* CMPXPdSbPlaybackViewImp::NewLC() |
|
129 { |
|
130 CMPXPdSbPlaybackViewImp* self = new ( ELeave ) CMPXPdSbPlaybackViewImp(); |
|
131 CleanupStack::PushL( self ); |
|
132 self->ConstructL(); |
|
133 return self; |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // Destructor |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 CMPXPdSbPlaybackViewImp::~CMPXPdSbPlaybackViewImp() |
|
141 { |
|
142 MPX_DEBUG1( "CMPXPdSbPlaybackViewImp::~CMPXPdSbPlaybackViewImp entering" ); |
|
143 |
|
144 delete iPlaybackViewLayout; |
|
145 |
|
146 if ( iPdResourceOffset ) |
|
147 { |
|
148 iEikonEnv->DeleteResourceFile( iPdResourceOffset ); |
|
149 } |
|
150 |
|
151 MPX_DEBUG1( "CMPXPdSbPlaybackViewImp::~CMPXPdSbPlaybackViewImp exiting" ); |
|
152 } |
|
153 |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // Gets download information |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CMPXPdSbPlaybackViewImp::GetDownloadInformationL( |
|
160 TUint& aTransactionId, |
|
161 TMPXPlaybackPdDownloadState& aState, |
|
162 TInt& aDownloadedBytes, |
|
163 TInt& aTotalBytes ) |
|
164 { |
|
165 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::GetDownloadInformationL() entering"); |
|
166 |
|
167 // Create the command to send to MPX |
|
168 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
169 CleanupStack::PushL( cmd ); |
|
170 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
171 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD ); |
|
172 cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( KMPXCommandPlaybackGeneralType, EPbCmdGetPdStatus ); |
|
173 iPlaybackUtility->CommandL( *cmd ); |
|
174 |
|
175 // Check that return values were provided |
|
176 ASSERT( cmd->IsSupported( KMPXCommandPlaybackPDTransactionID ) && |
|
177 cmd->IsSupported( KMPXCommandPlaybackPDState ) && |
|
178 cmd->IsSupported( KMPXCommandPlaybackPDDownloadedBytes ) && |
|
179 cmd->IsSupported( KMPXCommandPlaybackPDTotalBytes )); |
|
180 |
|
181 // Copy the return values |
|
182 aTransactionId = cmd->ValueTObjectL<TUint>( KMPXCommandPlaybackPDTransactionID ); |
|
183 aState = cmd->ValueTObjectL<TMPXPlaybackPdDownloadState>( KMPXCommandPlaybackPDState ); |
|
184 aDownloadedBytes = cmd->ValueTObjectL<TInt>( KMPXCommandPlaybackPDDownloadedBytes ); |
|
185 aTotalBytes = cmd->ValueTObjectL<TInt>( KMPXCommandPlaybackPDTotalBytes ); |
|
186 CleanupStack::PopAndDestroy( cmd ); |
|
187 |
|
188 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::GetDownloadInformationL() exiting"); |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CMPXPdSbPlaybackViewImp::CheckSignalAvailableL |
|
193 // This checks for Network available, and Network Strength > none. |
|
194 // - Return ETrue if network available and network strength |
|
195 // is Low or Medium or High, otherwise return EFalse. |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 TBool CMPXPdSbPlaybackViewImp::CheckSignalAvailableL( TUid& aCheck, TInt& aState ) |
|
199 { |
|
200 TBool ret( ETrue ); |
|
201 |
|
202 // Check the network is available. |
|
203 aCheck = KUidNetworkStatus; |
|
204 TInt err( RProperty::Get( KUidSystemCategory, KUidNetworkStatusValue, aState )); |
|
205 if ( err != KErrNone ) |
|
206 { |
|
207 aState = ESANetworkUnAvailable; |
|
208 } |
|
209 if( aState != ESANetworkAvailable ) |
|
210 { |
|
211 ret = EFalse; |
|
212 } |
|
213 |
|
214 // Check network coverage. |
|
215 aCheck = KUidNetworkStrength; |
|
216 err = RProperty::Get( KUidSystemCategory, KUidNetworkStrengthValue, aState ); |
|
217 if ( err != KErrNone ) |
|
218 { |
|
219 aState = ESANetworkStrengthUnknown; |
|
220 } |
|
221 if( aState != ESANetworkStrengthLow && |
|
222 aState != ESANetworkStrengthMedium && |
|
223 aState != ESANetworkStrengthHigh ) |
|
224 { |
|
225 ret = EFalse; |
|
226 } |
|
227 |
|
228 //passed all tests, OK to send |
|
229 return ret; |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // Handle playback message. |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 void CMPXPdSbPlaybackViewImp::DoHandlePlaybackMessageL( |
|
237 const CMPXMessage& aMessage ) |
|
238 { |
|
239 MPX_FUNC( "-->CMPXPdSbPlaybackViewImp::DoHandlePlaybackMessageL" ); |
|
240 |
|
241 TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) ); |
|
242 if ( KMPXMessageGeneral == id ) |
|
243 { |
|
244 TInt type( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) ); |
|
245 TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ) ); |
|
246 MPX_DEBUG2( "CMPXPdPlaybackViewImp::DoHandlePlaybackMessageL type = %d", type ); |
|
247 switch ( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) ) |
|
248 { |
|
249 case TMPXPlaybackMessage::EDownloadPositionChanged: |
|
250 { |
|
251 if ( iContainer ) |
|
252 { |
|
253 MPX_DEBUG2( "CMPXPdPlaybackViewImp::DoHandlePlaybackMessageL - EDownloadPositionChanged(%d)", data ); |
|
254 CMPXPdSbPlaybackViewContainer* container = |
|
255 static_cast<CMPXPdSbPlaybackViewContainer*>(iContainer); |
|
256 container->HandleDownloadPositionChanged( data, iTotalBytes ); |
|
257 } |
|
258 break; |
|
259 } |
|
260 case TMPXPlaybackMessage::EDownloadStateChanged: |
|
261 { |
|
262 TInt data( *aMessage.Value<TInt>( KMPXMessageGeneralData ) ); |
|
263 MPX_DEBUG2( "CMPXPdSbPlaybackViewImp::DoHandlePlaybackMessageL - EDownloadStateChanged(%d)", data ); |
|
264 iDownloadState = static_cast<TMPXPlaybackPdDownloadState>( data ); |
|
265 if ( iDownloadState == EPbDlStateDownloading || |
|
266 iDownloadState == EPbDlStateDownloadCompleted ) |
|
267 { |
|
268 RequestMediaL(); |
|
269 } |
|
270 if( iContainer && iDownloadState == EPbDlStateDownloadCompleted ) |
|
271 { |
|
272 CMPXPdSbPlaybackViewContainer* container = |
|
273 static_cast<CMPXPdSbPlaybackViewContainer*>(iContainer); |
|
274 container->HandleDownloadPositionChanged( iTotalBytes, iTotalBytes ); |
|
275 } |
|
276 UpdateViewL(); |
|
277 break; |
|
278 } |
|
279 case TMPXPlaybackMessage::EStateChanged: |
|
280 { |
|
281 MPX_DEBUG2( "CMPXPdSbPlaybackViewImp::DoHandlePlaybackMessageL - EStateChanged(%d)", type ); |
|
282 |
|
283 UpdateToolbar(); |
|
284 UpdateMiddleSoftKeyDisplayL(); |
|
285 TInt data( *aMessage.Value<TInt>( KMPXMessageGeneralData ) ); |
|
286 TMPXPlaybackState state = |
|
287 static_cast<TMPXPlaybackState>( type ); |
|
288 DoHandleStateChangedL( state, data ); |
|
289 if ( iDownloadState == EPbDlStateDownloadPaused && state == EPbStatePaused ) |
|
290 { |
|
291 iCommonUiHelper->DisplayInfoNoteL( R_MPX_DOWNLOAD_PLAYED_ALL_CONTENT ); |
|
292 } |
|
293 break; |
|
294 } |
|
295 case TMPXPlaybackMessage::EDownloadStarted: |
|
296 { |
|
297 iTotalBytes = aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ); |
|
298 MPX_DEBUG2( "CMPXPdSbPlaybackViewImp::DoHandlePlaybackMessageL - DownloadStarted, totalBytes = %d", iTotalBytes ); |
|
299 break; |
|
300 } |
|
301 |
|
302 case TMPXPlaybackMessage::EDownloadUpdated: |
|
303 { |
|
304 iTotalBytes = aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ); |
|
305 MPX_DEBUG2( "CMPXPdSbPlaybackViewImp::DoHandlePlaybackMessageL - DownloadUpdated, totalBytes = %d", iTotalBytes ); |
|
306 break; |
|
307 } |
|
308 |
|
309 |
|
310 case TMPXPlaybackMessage::EMediaChanged: |
|
311 |
|
312 iPlaybackCompleted = ETrue; |
|
313 if ( !iForeground ) |
|
314 { |
|
315 //TODO: Add something like AppUi()->HandleCommandL( EMPXCmdGoToNowPlaying ); but it should not bring to foreground |
|
316 } |
|
317 break; |
|
318 case TMPXPlaybackMessage::EDownloadCmdCancelDownload: |
|
319 // stop playback |
|
320 // bring back previous now playing view |
|
321 AppUi()->HandleCommandL( EMPXCmdGoToNowPlaying ); |
|
322 // Bring Browser to foreground. |
|
323 BringUpBrowserL(); |
|
324 break; |
|
325 case TMPXPlaybackMessage::EDownloadFileMoved: |
|
326 { |
|
327 // set updated Uri from aMessage for iMedia |
|
328 iMedia->SetTextValueL( KMPXMediaGeneralUri, aMessage.ValueText( KMPXMediaGeneralUri ) ); |
|
329 break; |
|
330 } |
|
331 |
|
332 default: |
|
333 { |
|
334 CMPXCommonPlaybackViewImp::DoHandlePlaybackMessageL( aMessage ); |
|
335 break; |
|
336 } |
|
337 } |
|
338 } |
|
339 MPX_DEBUG1("<--CMPXPdSbPlaybackViewImp::DoHandlePlaybackMessageL()"); |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // Handle playback state changed. |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CMPXPdSbPlaybackViewImp::DoHandleStateChangedL( |
|
347 TMPXPlaybackState aState, |
|
348 TInt aData ) |
|
349 { |
|
350 MPX_DEBUG2( "CMPXPdSbPlaybackViewImp::DoHandleStateChangedL(%d)", aState ); |
|
351 |
|
352 switch ( aState ) |
|
353 { |
|
354 case EPbStateInitialising: |
|
355 { |
|
356 UpdatePlaybackState( aState ); |
|
357 UpdateDownloadStateLabelL(); |
|
358 RequestMediaL(); |
|
359 break; |
|
360 } |
|
361 case EPbStatePlaying: |
|
362 RequestMediaL(); |
|
363 CMPXCommonPlaybackViewImp::DoHandleStateChangedL( aState, aData ); |
|
364 break; |
|
365 case EPbStateStopped: |
|
366 case EPbStatePaused: |
|
367 if ( iExiting ) |
|
368 { |
|
369 AppUi()->RunAppShutter(); |
|
370 } |
|
371 default: |
|
372 { |
|
373 CMPXCommonPlaybackViewImp::DoHandleStateChangedL( aState, aData ); |
|
374 break; |
|
375 } |
|
376 } |
|
377 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::DoHandleStateChangedL()"); |
|
378 } |
|
379 |
|
380 // --------------------------------------------------------------------------- |
|
381 // Updates download state label. |
|
382 // --------------------------------------------------------------------------- |
|
383 // |
|
384 void CMPXPdSbPlaybackViewImp::UpdateDownloadStateLabelL() |
|
385 { |
|
386 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::UpdateDownloadStateLabelL() entering"); |
|
387 |
|
388 if ( iContainer && !iSwitchingView ) |
|
389 { |
|
390 TInt resId = KErrNotFound; |
|
391 switch ( iDownloadState ) |
|
392 { |
|
393 case EPbDlStateBuffering: |
|
394 { |
|
395 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::UpdateDownloadStateLabelL() - Buffering"); |
|
396 resId = R_MPX_DOWNLOAD_STATUS_BUFFERING; |
|
397 break; |
|
398 } |
|
399 case EPbDlStateDownloadPaused: |
|
400 { |
|
401 // If offline mode, this case will be entered. |
|
402 resId = R_MPX_DOWNLOAD_STATUS_PAUSED; |
|
403 TBool offLine( EFalse ); |
|
404 |
|
405 // Check profile, display "Download Stopped" if |
|
406 // Offline enabled. |
|
407 MProfileEngine* profileEngine( CreateProfileEngineL() ); |
|
408 |
|
409 if ( profileEngine->ActiveProfileId() == EProfileOffLineId ) |
|
410 { |
|
411 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::UpdateDownloadStateLabelL() -- OffLine "); |
|
412 offLine = ETrue; |
|
413 resId = R_MPX_DOWNLOAD_STATUS_INTERRUPTED; |
|
414 } |
|
415 profileEngine->Release(); |
|
416 |
|
417 if ( !offLine ) |
|
418 { |
|
419 // Check network coverage, display "Download Stopped" if |
|
420 // No coverage. |
|
421 TUid uid; |
|
422 TInt res( 0 ); |
|
423 TBool signalAvailable( CheckSignalAvailableL( uid, res )); |
|
424 |
|
425 if ( !signalAvailable ) |
|
426 { |
|
427 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::UpdateDownloadStateLabelL() -- No Signal "); |
|
428 resId = R_MPX_DOWNLOAD_STATUS_INTERRUPTED; |
|
429 } |
|
430 } |
|
431 |
|
432 break; |
|
433 } |
|
434 case EPbDlStateDownloadError: |
|
435 case EPbDlStateDownloadCanceled: |
|
436 case EPbDlStateNotDownloading: |
|
437 { |
|
438 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::UpdateDownloadStateLabelL() - Download Canceled"); |
|
439 resId = R_MPX_DOWNLOAD_STATUS_INTERRUPTED; |
|
440 break; |
|
441 } |
|
442 case EPbDlStateDownloadCompleted: |
|
443 { |
|
444 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::UpdateDownloadStateLabelL() - Download Completed"); |
|
445 resId = R_MPX_DOWNLOAD_STATUS_COMPLETED; |
|
446 break; |
|
447 } |
|
448 case EPbDlStateDownloading: |
|
449 default: |
|
450 { |
|
451 MPX_DEBUG2(" default state: %d", iDownloadState ); |
|
452 // Do nothing |
|
453 break; |
|
454 } |
|
455 } |
|
456 /* |
|
457 // Display Album art in progressive download |
|
458 if( iActualAlbumArtBitmap ) |
|
459 { |
|
460 MPX_DEBUG1("CMPlayerPlaybackContainer::UpdateDownloadStateLabelL() - Draw ActualAlbumArt"); |
|
461 iAlbumArtBitmap = iActualAlbumArtBitmap; |
|
462 DrawNow(); |
|
463 } |
|
464 else |
|
465 { |
|
466 MPX_DEBUG1("CMPlayerPlaybackContainer::UpdateDownloadStateLabelL() - Draw DefaultAlbumArt"); |
|
467 // Display default Album Art |
|
468 iAlbumArtBitmap = iDefaultAlbumArtBitmap; |
|
469 DrawNow(); |
|
470 } |
|
471 */ |
|
472 |
|
473 if (resId != KErrNotFound) |
|
474 { |
|
475 // Display download status text |
|
476 HBufC* statusText = StringLoader::LoadLC( resId ); |
|
477 iContainer->UpdateLabelL( ETextDownloadState, *statusText ); |
|
478 CleanupStack::PopAndDestroy( statusText ); |
|
479 } |
|
480 else |
|
481 { |
|
482 // Clear download status text |
|
483 iContainer->UpdateLabelL( ETextDownloadState, KNullDesC ); |
|
484 } |
|
485 } |
|
486 |
|
487 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::UpdateDownloadStateLabelL() exiting"); |
|
488 } |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 // Displays error notes. |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 void CMPXPdSbPlaybackViewImp::HandleErrorL( TInt aError ) |
|
495 { |
|
496 MPX_DEBUG2("CMPXPdSbPlaybackViewImp::HandleErrorL(%d): Entering", aError); |
|
497 if ( aError ) |
|
498 { |
|
499 TUint transactionId(0); |
|
500 TMPXPlaybackPdDownloadState state( EPbDlStateNotDownloading ); |
|
501 TInt downloadedBytes(0); |
|
502 TInt totalBytes(0); |
|
503 GetDownloadInformationL( transactionId, |
|
504 state, |
|
505 downloadedBytes, |
|
506 totalBytes ); |
|
507 if ( EPbDlStateBuffering == state || |
|
508 EPbDlStateDownloading == state || |
|
509 EPbDlStateDownloadPaused == state ) |
|
510 { |
|
511 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
512 CleanupStack::PushL( cmd ); |
|
513 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
514 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD ); |
|
515 cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( |
|
516 KMPXCommandPlaybackGeneralType, |
|
517 EPbCmdCancelPd ); |
|
518 iPlaybackUtility->CommandL( *cmd ); |
|
519 CleanupStack::PopAndDestroy( cmd ); |
|
520 } |
|
521 iCommonUiHelper->HandleErrorL( aError ); |
|
522 CMPXCommonPlaybackViewImp::HandleCommandL( EAknSoftkeyBack ); |
|
523 } |
|
524 } |
|
525 |
|
526 // --------------------------------------------------------------------------- |
|
527 // From MEikMenuObserver |
|
528 // Dynamically initialises a menu pane. |
|
529 // --------------------------------------------------------------------------- |
|
530 // |
|
531 void CMPXPdSbPlaybackViewImp::DynInitMenuPaneL( |
|
532 TInt aResourceId, |
|
533 CEikMenuPane* aMenuPane ) |
|
534 { |
|
535 MPX_DEBUG2("CMPXPdSbPlaybackViewImp::DynInitMenuPaneL(%d): entering", aResourceId); |
|
536 |
|
537 // Override base menu actions |
|
538 switch ( aResourceId ) |
|
539 { |
|
540 case R_MPX_PD_SB_PLAYBACK_VIEW_MENU: |
|
541 { |
|
542 aMenuPane->SetItemDimmed( |
|
543 EMPXPbvCmdResumeDownload, |
|
544 iDownloadState != EPbDlStateDownloadPaused); |
|
545 aMenuPane->SetItemDimmed( |
|
546 EMPXPbvCmdCancelDownload, |
|
547 iDownloadState != EPbDlStateDownloading && |
|
548 iDownloadState != EPbDlStateBuffering && |
|
549 iDownloadState != EPbDlStateDownloadPaused); |
|
550 |
|
551 // Check if FM Transmitter is supported |
|
552 if ( !FeatureManager::FeatureSupported( KFeatureIdFmtx ) ) |
|
553 { |
|
554 aMenuPane->SetItemDimmed( |
|
555 EMPXPbvCmdFMTransmitter, |
|
556 ETrue ); |
|
557 } |
|
558 |
|
559 if ( iDownloadState == EPbDlStateDownloading || |
|
560 iDownloadState == EPbDlStateBuffering || |
|
561 iDownloadState == EPbDlStateDownloadPaused || |
|
562 iPlaybackState == EPbStateInitialising || |
|
563 iPlaybackState == EPbStatePlaying || |
|
564 iPlaybackState == EPbStatePaused ) |
|
565 { |
|
566 aMenuPane->SetItemDimmed( |
|
567 EMPXPbvCmdUseAsCascade, ETrue ); |
|
568 } |
|
569 else |
|
570 { |
|
571 aMenuPane->SetItemDimmed( |
|
572 EMPXPbvCmdUseAsCascade, EFalse ); |
|
573 } |
|
574 break; |
|
575 } |
|
576 default: |
|
577 { |
|
578 // Call base clase to handle most cases |
|
579 CMPXCommonPlaybackViewImp::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
580 break; |
|
581 } |
|
582 } |
|
583 |
|
584 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::DynInitMenuPaneL(): exiting"); |
|
585 } |
|
586 |
|
587 // --------------------------------------------------------------------------- |
|
588 // From CAknView |
|
589 // Command handling function. |
|
590 // --------------------------------------------------------------------------- |
|
591 // |
|
592 void CMPXPdSbPlaybackViewImp::HandleCommandL( TInt aCommand ) |
|
593 { |
|
594 MPX_DEBUG2("CMPXPdSbPlaybackViewImp::HandleCommandL(%d) entering", aCommand); |
|
595 |
|
596 switch (aCommand) |
|
597 { |
|
598 case EMPXPbvCmdResumeDownload: |
|
599 { |
|
600 if ( EPbDlStateDownloadPaused == iDownloadState ) |
|
601 { |
|
602 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
603 CleanupStack::PushL( cmd ); |
|
604 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
605 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD ); |
|
606 cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( |
|
607 KMPXCommandPlaybackGeneralType, |
|
608 EPbCmdResumePd ); |
|
609 iPlaybackUtility->CommandL( *cmd ); |
|
610 CleanupStack::PopAndDestroy( cmd ); |
|
611 } |
|
612 break; |
|
613 } |
|
614 case EMPXPbvCmdCancelDownload: |
|
615 { |
|
616 if ( EPbDlStateDownloading == iDownloadState || |
|
617 EPbDlStateBuffering == iDownloadState || |
|
618 EPbDlStateDownloadPaused == iDownloadState ) |
|
619 { |
|
620 HBufC* queryTxt = StringLoader::LoadLC( R_MPX_CONF_CANCEL_DOWNLOAD_TXT ); |
|
621 CAknQueryDialog* query = CAknQueryDialog::NewL( |
|
622 CAknQueryDialog::EConfirmationTone ); |
|
623 |
|
624 /* TODO: add when we support cover UI |
|
625 #ifdef __COVER_DISPLAY //VCPCCMOD_BEGIN |
|
626 query->PublishDialogL( |
|
627 EMPXNoteMusicshopCancel, |
|
628 KMPXNoteCategory); |
|
629 #endif //__COVER_DISPLAY //VCPCCMOD_END |
|
630 */ |
|
631 |
|
632 if ( query->ExecuteLD( |
|
633 R_MPX_GENERIC_CONFIRMATION_QUERY, |
|
634 *queryTxt )) |
|
635 { |
|
636 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
637 CMPXCommand* cmd( CMPXCommand::NewL() ); |
|
638 CleanupStack::PushL( cmd ); |
|
639 cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue ); |
|
640 cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXCommandIdPlaybackPD ); |
|
641 cmd->SetTObjectValueL<TMPXPlaybackPdCommand>( |
|
642 KMPXCommandPlaybackGeneralType, |
|
643 EPbCmdCancelPd ); |
|
644 iPlaybackUtility->CommandL( *cmd ); |
|
645 CleanupStack::PopAndDestroy( cmd ); |
|
646 iPlaybackUtility->CommandL( EPbCmdClose ); |
|
647 } |
|
648 CleanupStack::PopAndDestroy( queryTxt ); |
|
649 } |
|
650 break; |
|
651 } |
|
652 case EAknSoftkeyBack: |
|
653 { |
|
654 if ( iPlaybackCompleted ) |
|
655 { |
|
656 AppUi()->HandleCommandL( EMPXCmdGoToNowPlaying ); |
|
657 } |
|
658 // Goto Browser, Bring Browser to foreground. |
|
659 if ( !BringUpBrowserL() ) |
|
660 { |
|
661 //We are in Music Store, launched from Download Mgr. Instead, stop playback |
|
662 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
663 iPlaybackUtility->CommandL( EPbCmdClose ); |
|
664 iExiting = ETrue; |
|
665 } |
|
666 } |
|
667 break; |
|
668 case EMPXPbvCmdExitPDPlaybackView: |
|
669 if ( iPlaybackState == EPbStatePlaying ) |
|
670 { |
|
671 iPlaybackUtility->CommandL( EPbCmdStop ); |
|
672 iExiting = ETrue; |
|
673 } |
|
674 else |
|
675 { |
|
676 AppUi()->RunAppShutter(); |
|
677 } |
|
678 break; |
|
679 case EMPXPbvCmdGotoMusicMenu: |
|
680 AppUi()->HandleCommandL( EMPXCmdGotoCollection ); |
|
681 |
|
682 default: |
|
683 { |
|
684 CMPXCommonPlaybackViewImp::HandleCommandL( aCommand ); |
|
685 break; |
|
686 } |
|
687 } |
|
688 |
|
689 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::HandleCommandL() exiting"); |
|
690 } |
|
691 |
|
692 // --------------------------------------------------------------------------- |
|
693 // Handle playback property. |
|
694 // --------------------------------------------------------------------------- |
|
695 // |
|
696 void CMPXPdSbPlaybackViewImp::DoHandlePropertyL( |
|
697 TMPXPlaybackProperty aProperty, |
|
698 TInt aValue, |
|
699 TInt aError ) |
|
700 { |
|
701 MPX_FUNC( "CMPXPdSbPlaybackViewImp::DoHandlePropertyL" ); |
|
702 MPX_DEBUG4( "HandlePropertyL - Property(%d); Value(%d); Error(%d)", aProperty, aValue, aError ); |
|
703 |
|
704 if ( KErrNone == aError ) |
|
705 { |
|
706 switch ( aProperty ) |
|
707 { |
|
708 case EPbPropertyRandomMode: |
|
709 case EPbPropertyRepeatMode: |
|
710 // ignore these cases in PD |
|
711 break; |
|
712 default: |
|
713 { |
|
714 CMPXCommonPlaybackViewImp::DoHandlePropertyL(aProperty,aValue,aError); |
|
715 break; |
|
716 } |
|
717 } |
|
718 } |
|
719 else |
|
720 { |
|
721 HandleErrorL( aError ); |
|
722 } |
|
723 } |
|
724 |
|
725 // --------------------------------------------------------------------------- |
|
726 // From CAknView |
|
727 // Returns views id. |
|
728 // --------------------------------------------------------------------------- |
|
729 // |
|
730 TUid CMPXPdSbPlaybackViewImp::Id() const |
|
731 { |
|
732 return TUid::Uid( KMPXPdSbPlaybackViewId ); |
|
733 } |
|
734 |
|
735 // --------------------------------------------------------------------------- |
|
736 // From CAknView |
|
737 // Processes user commands. |
|
738 // --------------------------------------------------------------------------- |
|
739 // |
|
740 void CMPXPdSbPlaybackViewImp::ProcessCommandL( TInt aCommand ) |
|
741 { |
|
742 MPX_DEBUG2("CMPXPdSbPlaybackViewImp::ProcessCommandL(%d): entering", aCommand); |
|
743 if ( aCommand == EAknCmdExit ) |
|
744 { |
|
745 if ( MenuBar() ) |
|
746 { |
|
747 MenuBar()->StopDisplayingMenuBar(); |
|
748 } |
|
749 } |
|
750 CAknView::ProcessCommandL( aCommand ); |
|
751 MPX_DEBUG1("CMPXPdSbPlaybackViewImp::ProcessCommandL(): exiting"); |
|
752 } |
|
753 |
|
754 // --------------------------------------------------------------------------- |
|
755 // From CAknView |
|
756 // Handles a view activation. |
|
757 // --------------------------------------------------------------------------- |
|
758 // |
|
759 void CMPXPdSbPlaybackViewImp::DoActivateL( |
|
760 const TVwsViewId& aPrevViewId, |
|
761 TUid aCustomMessageId, |
|
762 const TDesC8& aCustomMessage ) |
|
763 { |
|
764 MPX_FUNC( "CMPXPdSbPlaybackViewImp::DoActivateL()" ); |
|
765 |
|
766 if ( !iContainer ) |
|
767 { |
|
768 if ( !iPlaybackViewLayout ) |
|
769 { |
|
770 iPlaybackViewLayout = CMPXPdSbPlaybackViewLayout::NewL(); |
|
771 } |
|
772 iContainer = new ( ELeave ) CMPXPdSbPlaybackViewContainer( |
|
773 this, |
|
774 this, |
|
775 iPlaybackViewLayout ); |
|
776 iContainer->SetMopParent( this ); |
|
777 iContainer->ConstructL( ClientRect() ); |
|
778 AppUi()->AddToStackL( *this, iContainer ); |
|
779 } |
|
780 |
|
781 CMPXCommonPlaybackViewImp::DoActivateL( aPrevViewId , aCustomMessageId, aCustomMessage ); |
|
782 UpdateMiddleSoftKeyDisplayL(); |
|
783 } |
|
784 |
|
785 |
|
786 // --------------------------------------------------------- |
|
787 // Bring Browser application to the foreground. |
|
788 // --------------------------------------------------------- |
|
789 // |
|
790 TBool CMPXPdSbPlaybackViewImp::BringUpBrowserL() |
|
791 { |
|
792 RWsSession& wsSession=iEikonEnv->WsSession(); |
|
793 TInt count=wsSession.NumWindowGroups( 0 ); |
|
794 |
|
795 RArray<RWsSession::TWindowGroupChainInfo> allWgIds; |
|
796 CleanupClosePushL(allWgIds); |
|
797 User::LeaveIfError(wsSession.WindowGroupList(&allWgIds)); |
|
798 |
|
799 count = allWgIds.Count(); |
|
800 |
|
801 CApaWindowGroupName* windowName; |
|
802 |
|
803 TBool browserFound = EFalse; |
|
804 for ( TInt index=0; index < count; index++ ) |
|
805 { |
|
806 RWsSession::TWindowGroupChainInfo& info = allWgIds[index]; |
|
807 |
|
808 if ( info.iParentId <= 0 ) |
|
809 { |
|
810 TInt wgId=info.iId; |
|
811 windowName = CApaWindowGroupName::NewLC(wsSession, wgId); |
|
812 TUid applicationUid = windowName->AppUid(); |
|
813 if ( applicationUid == TUid::Uid(KMPlayerBrowserUid)) |
|
814 { |
|
815 TApaTask task( iEikonEnv->WsSession() ); |
|
816 task.SetWgId( wgId ); |
|
817 task.BringToForeground(); |
|
818 browserFound = ETrue; |
|
819 } |
|
820 CleanupStack::PopAndDestroy(); //windowName |
|
821 } |
|
822 } |
|
823 |
|
824 CleanupStack::PopAndDestroy( &allWgIds ); |
|
825 |
|
826 return browserFound; |
|
827 } |
|
828 |
|
829 |
|
830 // --------------------------------------------------------------------------- |
|
831 // From CAknView |
|
832 // Foreground event handling function. |
|
833 // --------------------------------------------------------------------------- |
|
834 // |
|
835 void CMPXPdSbPlaybackViewImp::HandleForegroundEventL( TBool aForeground ) |
|
836 { |
|
837 MPX_DEBUG2( "--->CMPXPdSbPlaybackViewImp::HandleForegroundEventL(%d)", aForeground ); |
|
838 |
|
839 iForeground = aForeground; |
|
840 CMPXCommonPlaybackViewImp::HandleForegroundEventL(aForeground); |
|
841 MPX_DEBUG1( "<---CMPXPdSbPlaybackViewImp::HandleForegroundEventL()" ); |
|
842 } |
|
843 |
|
844 |
|
845 // ----------------------------------------------------------------------------- |
|
846 // From MAknToolbarObserver |
|
847 // Used to change toolbar settings before toolbar becomes visible |
|
848 // ----------------------------------------------------------------------------- |
|
849 // |
|
850 void CMPXPdSbPlaybackViewImp::DynInitToolbarL(TInt aResourceId, CAknToolbar* aToolbar) |
|
851 { |
|
852 if(aResourceId == R_MPX_PBV_TOUCH_TOOLBAR) |
|
853 { |
|
854 // Put initializations here to take effect before toolbar is shown |
|
855 aToolbar->SetItemDimmed( EMPXPbvCmdPreviousListItem, ETrue, EFalse ); |
|
856 aToolbar->SetItemDimmed( EMPXPbvCmdNextListItem, ETrue, EFalse ); |
|
857 UpdateToolbar(); |
|
858 aToolbar->UpdateBackground(); |
|
859 } |
|
860 } |
|
861 |
|
862 // ----------------------------------------------------------------------------- |
|
863 // From MAknToolbarObserver |
|
864 // Handles toolbar events |
|
865 // ----------------------------------------------------------------------------- |
|
866 // |
|
867 void CMPXPdSbPlaybackViewImp::OfferToolbarEventL( TInt aCommandId ) |
|
868 { |
|
869 CAknView::ProcessCommandL( aCommandId ); |
|
870 } |
|
871 |
|
872 // --------------------------------------------------------------------------- |
|
873 // Updates the middle toolbar button |
|
874 // --------------------------------------------------------------------------- |
|
875 // |
|
876 void CMPXPdSbPlaybackViewImp::UpdateToolbar() |
|
877 { |
|
878 MPX_FUNC( "CMPXPdSbPlaybackViewImp::UpdateToolbar" ); |
|
879 |
|
880 if ( AknLayoutUtils::PenEnabled() && Toolbar()) |
|
881 { |
|
882 CAknToolbar* toolbar = Toolbar(); |
|
883 TBool pausePlayDimmed(ETrue); |
|
884 MMPXSource* s = iPlaybackUtility->Source(); |
|
885 if ( s ) |
|
886 { |
|
887 TMPXPlaybackState state = iPlaybackUtility->StateL(); |
|
888 CAknButton* pausePlayControl; |
|
889 pausePlayControl = (CAknButton*)(toolbar->ComponentControl( 1 )); |
|
890 if ((state == EPbStateInitialising) || (state == EPbStatePlaying)) |
|
891 { |
|
892 pausePlayControl->SetCurrentState(0, ETrue); |
|
893 } |
|
894 else |
|
895 { |
|
896 pausePlayControl->SetCurrentState(1, ETrue); |
|
897 } |
|
898 if ( state == EPbStatePlaying || |
|
899 state == EPbStatePaused || |
|
900 state == EPbStateStopped ) |
|
901 { |
|
902 pausePlayDimmed = EFalse; |
|
903 } |
|
904 } |
|
905 toolbar->SetItemDimmed( EMPXPbvCmdPlayPause, pausePlayDimmed, ETrue ); |
|
906 } |
|
907 } |
|
908 // End of File |