mpxplugins/serviceplugins/playbackplugins/progressdownloadsb/src/mpxprogressdownloadsb.cpp
equal
deleted
inserted
replaced
339 iConsumeStarted = EFalse; |
339 iConsumeStarted = EFalse; |
340 } |
340 } |
341 if ( !iFileSaved ) |
341 if ( !iFileSaved ) |
342 { |
342 { |
343 iDrmMediaUtility->Close(); // release file handle so we can move file. |
343 iDrmMediaUtility->Close(); // release file handle so we can move file. |
344 MoveDownloadedFileToMusicFolderL(); |
344 MoveDownloadedFileToMusicFolder(); |
345 } |
345 } |
346 } |
346 } |
347 iDrmMediaUtility->Close(); |
347 iDrmMediaUtility->Close(); |
348 break; |
348 break; |
349 case EPbCmdClose: |
349 case EPbCmdClose: |
355 iConsumeStarted = EFalse; |
355 iConsumeStarted = EFalse; |
356 } |
356 } |
357 if ( !iFileSaved ) |
357 if ( !iFileSaved ) |
358 { |
358 { |
359 iDrmMediaUtility->Close(); // release file handle so we can move file. |
359 iDrmMediaUtility->Close(); // release file handle so we can move file. |
360 MoveDownloadedFileToMusicFolderL(); |
360 MoveDownloadedFileToMusicFolder(); |
361 } |
361 } |
362 } |
362 } |
363 iDrmMediaUtility->Close(); |
363 iDrmMediaUtility->Close(); |
364 iState = EStateNotInitialised; |
364 iState = EStateNotInitialised; |
365 iDownloadState = EPbDlStateNotDownloading; |
365 iDownloadState = EPbDlStateNotDownloading; |
644 |
644 |
645 // Get the mime type |
645 // Get the mime type |
646 |
646 |
647 RApaLsSession aps; |
647 RApaLsSession aps; |
648 error = aps.Connect(); // always fail in console test |
648 error = aps.Connect(); // always fail in console test |
649 if ( KErrNone == error ) |
649 if ( iPdPath != NULL && KErrNone == error ) |
650 { |
650 { |
651 CleanupClosePushL(aps); |
651 CleanupClosePushL(aps); |
652 TUid ignore; |
652 TUid ignore; |
653 aps.AppForDocument( iPdPath->Des(), ignore, iMimeType ); |
653 aps.AppForDocument( iPdPath->Des(), ignore, iMimeType ); |
654 CleanupStack::PopAndDestroy(&aps); |
654 CleanupStack::PopAndDestroy(&aps); |
667 { |
667 { |
668 if ( iFileHandle ) |
668 if ( iFileHandle ) |
669 { |
669 { |
670 TRAP( err, metaDataUtility->OpenFileL( *iFileHandle, iMimeType.Des8() ) ); |
670 TRAP( err, metaDataUtility->OpenFileL( *iFileHandle, iMimeType.Des8() ) ); |
671 } |
671 } |
672 else |
672 else if ( iPdPath != NULL ) |
673 { |
673 { |
674 TRAP( err, metaDataUtility->OpenFileL( *iPdPath, iMimeType.Des8() ) ); |
674 TRAP( err, metaDataUtility->OpenFileL( *iPdPath, iMimeType.Des8() ) ); |
675 } |
675 } |
676 } |
676 } |
677 else |
677 else |
678 { |
678 { |
679 if ( iFileHandle ) |
679 if ( iFileHandle ) |
680 { |
680 { |
681 TRAP( err, metaDataUtility->OpenFileL( *iFileHandle ) ); |
681 TRAP( err, metaDataUtility->OpenFileL( *iFileHandle ) ); |
682 } |
682 } |
683 else |
683 else if( iPdPath != NULL ) |
684 { |
684 { |
685 TRAP( err, metaDataUtility->OpenFileL( *iPdPath ) ); |
685 TRAP( err, metaDataUtility->OpenFileL( *iPdPath ) ); |
686 } |
686 } |
687 } |
687 } |
688 |
688 |
789 field ); |
789 field ); |
790 } |
790 } |
791 break; |
791 break; |
792 } |
792 } |
793 case EMetaDataJpeg: |
793 case EMetaDataJpeg: |
794 if ( attrM & EMPXMediaMusicAlbumArtFileName ) |
794 if ( ( iPdPath != NULL ) && attrM & EMPXMediaMusicAlbumArtFileName ) |
795 { |
795 { |
796 media->SetTextValueL( |
796 media->SetTextValueL( |
797 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicAlbumArtFileName), |
797 TMPXAttribute(KMPXMediaIdMusic,EMPXMediaMusicAlbumArtFileName), |
798 *iPdPath); |
798 *iPdPath); |
799 } |
799 } |
812 CleanupStack::PopAndDestroy(metaDataUtility); |
812 CleanupStack::PopAndDestroy(metaDataUtility); |
813 |
813 |
814 } |
814 } |
815 |
815 |
816 |
816 |
817 if (attrG & EMPXMediaGeneralUri) |
817 if ( ( iPdPath != NULL ) && attrG & EMPXMediaGeneralUri) |
818 { |
818 { |
819 media->SetTextValueL( |
819 media->SetTextValueL( |
820 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralUri), |
820 TMPXAttribute(KMPXMediaIdGeneral,EMPXMediaGeneralUri), |
821 *iPdPath); |
821 *iPdPath); |
822 } |
822 } |
849 { |
849 { |
850 // TODO: How to get sampling rate through ProgDLSource? |
850 // TODO: How to get sampling rate through ProgDLSource? |
851 |
851 |
852 } |
852 } |
853 |
853 |
854 if (attrG & EMPXMediaGeneralSize) |
854 if ( ( iPdPath != NULL ) && attrG & EMPXMediaGeneralSize) |
855 { |
855 { |
856 RFs fs; |
856 RFs fs; |
857 User::LeaveIfError(fs.Connect()); |
857 User::LeaveIfError(fs.Connect()); |
858 CleanupClosePushL(fs); |
858 CleanupClosePushL(fs); |
859 TEntry entry; |
859 TEntry entry; |
1027 } |
1027 } |
1028 else |
1028 else |
1029 { |
1029 { |
1030 ConsumeRights( ContentAccess::EPause ); |
1030 ConsumeRights( ContentAccess::EPause ); |
1031 } |
1031 } |
1032 MoveDownloadedFileToMusicFolderL(); |
1032 MoveDownloadedFileToMusicFolder(); |
1033 } |
1033 } |
1034 } |
1034 } |
1035 else if ( event->GetErrorCode() == KErrDied || event->GetErrorCode() == KErrInUse || |
1035 else if ( event->GetErrorCode() == KErrDied || event->GetErrorCode() == KErrInUse || |
1036 event->GetErrorCode() == KErrAccessDenied ) |
1036 event->GetErrorCode() == KErrAccessDenied ) |
1037 { |
1037 { |
1202 |
1202 |
1203 if ((iState == EStateNotInitialised || |
1203 if ((iState == EStateNotInitialised || |
1204 (iState == EStateInitialising && iErrorOfStreamClosedEvent == KErrCANoRights)) |
1204 (iState == EStateInitialising && iErrorOfStreamClosedEvent == KErrCANoRights)) |
1205 && !iFileSaved ) |
1205 && !iFileSaved ) |
1206 { |
1206 { |
1207 MoveDownloadedFileToMusicFolderL(); |
1207 MoveDownloadedFileToMusicFolder(); |
1208 } |
1208 } |
1209 iErrorOfStreamClosedEvent = KErrNone ; |
1209 iErrorOfStreamClosedEvent = KErrNone ; |
1210 |
1210 |
1211 |
1211 |
1212 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
1212 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPDownloadStateChanged, |
1244 |
1244 |
1245 if ( !fileMoveError ) |
1245 if ( !fileMoveError ) |
1246 { |
1246 { |
1247 delete iPdPath; |
1247 delete iPdPath; |
1248 iPdPath = NULL; |
1248 iPdPath = NULL; |
1249 iPdPath = iMovedFileName.AllocL(); |
1249 MPX_TRAPD( err, iPdPath = iMovedFileName.AllocL() ); |
|
1250 if( err != KErrNone ) |
|
1251 { |
|
1252 MPX_DEBUG2("iPdPath = iMovedFileName.AllocL() with leave err=%d", err ); |
|
1253 break; |
|
1254 } |
1250 iFileSaved = ETrue; |
1255 iFileSaved = ETrue; |
1251 } |
1256 } |
1252 else |
1257 else |
1253 { |
1258 { |
1254 // TODO: If file is renamed, we need to get the new path. |
1259 // TODO: If file is renamed, we need to get the new path. |
1256 { |
1261 { |
1257 TPtr ptr( NULL, 0 ); |
1262 TPtr ptr( NULL, 0 ); |
1258 iMAudioProgDLSource->FileName( ptr ); |
1263 iMAudioProgDLSource->FileName( ptr ); |
1259 delete iPdPath; |
1264 delete iPdPath; |
1260 iPdPath = NULL; |
1265 iPdPath = NULL; |
1261 iPdPath = ptr.AllocL(); |
1266 MPX_TRAPD(err, iPdPath = ptr.AllocL() ); |
|
1267 if( err != KErrNone ) |
|
1268 { |
|
1269 MPX_DEBUG2("iPdPath = ptr.AllocL() with leave err=%d", err ); |
|
1270 break; |
|
1271 } |
1262 iFileSaved = ETrue; |
1272 iFileSaved = ETrue; |
1263 } |
1273 } |
1264 } |
1274 } |
1265 |
1275 |
1266 TRAP_IGNORE( iDrmMediaUtility->InitL( *iPdPath )); |
1276 TRAP_IGNORE( iDrmMediaUtility->InitL( *iPdPath )); |
1391 iMVolumeControl->SetVolume( newVolume ); |
1401 iMVolumeControl->SetVolume( newVolume ); |
1392 iMVolumeControl->Apply(); |
1402 iMVolumeControl->Apply(); |
1393 changed = ETrue; |
1403 changed = ETrue; |
1394 } |
1404 } |
1395 } |
1405 } |
1396 |
1406 |
1397 // Change setting in cenrep |
1407 // Change setting in cenrep |
1398 if ( aVolume != iVolumeWatcher->CurrentValueL() ) |
1408 TInt currentVol( 0 ); |
1399 { |
1409 MPX_TRAPD( volError, currentVol = iVolumeWatcher->CurrentValueL() ); |
1400 iVolumeWatcher->SetValueL( aVolume ); |
1410 if ( volError == KErrNone && aVolume != currentVol ) |
1401 } |
1411 { |
|
1412 MPX_TRAP( volError, iVolumeWatcher->SetValueL( aVolume ) ); |
|
1413 if( aVolume == 0 ) |
|
1414 { |
|
1415 MPX_TRAP( volError, iMuteWatcher->SetValueL( ETrue ) ); |
|
1416 } |
|
1417 else if( aVolume > 0 ) |
|
1418 { |
|
1419 TBool currentMute( EFalse ); |
|
1420 |
|
1421 MPX_TRAP( volError, currentMute = iMuteWatcher->CurrentValueL() ); |
|
1422 if( volError == KErrNone && currentMute ) |
|
1423 { |
|
1424 MPX_TRAP( volError, iMuteWatcher->SetValueL( EFalse ) ); |
|
1425 } |
|
1426 } |
|
1427 } |
|
1428 |
1402 |
1429 |
1403 // Notify observer if value changed |
1430 // Notify observer if value changed |
1404 if ( changed ) |
1431 if ( changed ) |
1405 { |
1432 { |
1406 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPVolumeChanged, |
1433 iObs->HandlePluginEvent( MMPXPlaybackPluginObserver::EPVolumeChanged, |
1466 |
1493 |
1467 // ----------------------------------------------------------------------------- |
1494 // ----------------------------------------------------------------------------- |
1468 // CMPXProgressDownloadSB::MoveDownloadedFileToMusicFolderL |
1495 // CMPXProgressDownloadSB::MoveDownloadedFileToMusicFolderL |
1469 // ----------------------------------------------------------------------------- |
1496 // ----------------------------------------------------------------------------- |
1470 // |
1497 // |
1471 void CMPXProgressDownloadSB::MoveDownloadedFileToMusicFolderL() |
1498 void CMPXProgressDownloadSB::MoveDownloadedFileToMusicFolder() |
1472 { |
1499 { |
1473 if ( iFileSaved || |
1500 if ( iFileSaved || iPdPath == NULL || |
1474 ( (*iPdPath).Length() == 0 ) || |
1501 ( (*iPdPath).Length() == 0 ) || |
1475 iMAudioProgDLSource->GetDownloadStatus() == MProgDLSource::EDeleted ) |
1502 iMAudioProgDLSource->GetDownloadStatus() == MProgDLSource::EDeleted ) |
1476 { |
1503 { |
1477 return; |
1504 return; |
1478 } |
1505 } |
1479 |
1506 |
1480 MPX_DEBUG1("CMPXProgressDownloadSB::MoveDownloadedFileToMusicFolderL() entering"); |
1507 MPX_DEBUG1("CMPXProgressDownloadSB::MoveDownloadedFileToMusicFolder() entering"); |
1481 TParse parse; |
1508 TParse parse; |
1482 parse.Set(*iPdPath,NULL,NULL); |
1509 parse.Set(*iPdPath,NULL,NULL); |
1483 TPtrC drive = parse.Drive(); |
1510 TPtrC drive = parse.Drive(); |
1484 |
1511 |
1485 iMovedFileName.Copy(drive); |
1512 iMovedFileName.Copy(drive); |
1492 if ( !error ) |
1519 if ( !error ) |
1493 { |
1520 { |
1494 iFileSaved = ETrue; |
1521 iFileSaved = ETrue; |
1495 } |
1522 } |
1496 |
1523 |
1497 MPX_DEBUG1("CMPXProgressDownloadSB::MoveDownloadedFileToMusicFolderL() exiting"); |
1524 MPX_DEBUG1("CMPXProgressDownloadSB::MoveDownloadedFileToMusicFolder() exiting"); |
1498 } |
1525 } |
1499 |
1526 |
1500 // ---------------------------------------------------------------------------- |
1527 // ---------------------------------------------------------------------------- |
1501 // Consumes the rights for the current media |
1528 // Consumes the rights for the current media |
1502 // ---------------------------------------------------------------------------- |
1529 // ---------------------------------------------------------------------------- |