187 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
190 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
188 CleanupStack::PushL( path ); |
191 CleanupStack::PushL( path ); |
189 iCollectionUid = TUid::Uid( aCollectionUid ); |
192 iCollectionUid = TUid::Uid( aCollectionUid ); |
190 path->AppendL( aCollectionUid ); |
193 path->AppendL( aCollectionUid ); |
191 |
194 |
|
195 TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionActionId, _L("Open collection") ) ); |
|
196 iCurrentActionHasResponse = EFalse; |
|
197 iCurrentActionId = KOpenCollectionActionId; |
192 SetRefreshStatus( ETrue ); |
198 SetRefreshStatus( ETrue ); |
193 |
199 |
194 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::OpenCollectionL: collectionId: 0x%x", aCollectionUid); |
|
195 |
|
196 iCollectionUtility->Collection().OpenL( *path ); |
200 iCollectionUtility->Collection().OpenL( *path ); |
197 iCurrentOpenedLevelIndex = -1; |
|
198 |
201 |
199 CleanupStack::PopAndDestroy( path ); |
202 CleanupStack::PopAndDestroy( path ); |
200 |
203 |
201 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::OpenCollectionL"); |
204 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::OpenCollectionL"); |
202 } |
205 } |
203 |
206 |
204 // ----------------------------------------------------------------------------- |
207 // ----------------------------------------------------------------------------- |
205 // CVCXMyVideosCollectionPluginTester::OpenLevelL |
208 // CVCXMyVideosCollectionPluginTester::OpenLevelL |
206 // ----------------------------------------------------------------------------- |
209 // ----------------------------------------------------------------------------- |
207 // |
210 // |
208 void CVCXMyVideosCollectionPluginTester::OpenLevelL( const TDesC& aLevelName ) |
211 void CVCXMyVideosCollectionPluginTester::OpenLevelL( TInt aIndex ) |
209 { |
212 { |
210 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL (by name)"); |
213 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL"); |
211 |
214 |
212 if( GetCurrentLevel() != 2 ) |
215 if( GetCurrentLevel() != 2 ) |
213 { |
216 { |
214 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!"); |
217 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!"); |
215 User::Leave( KErrGeneral ); |
218 User::Leave( KErrGeneral ); |
216 } |
219 } |
217 |
220 |
218 CMPXMedia* media; |
221 if( aIndex < 0 || aIndex > iMediaArray->Count() ) |
219 |
222 { |
220 int levelIndex(-1); |
223 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Error. Index (%d) out of bounds!", aIndex); |
221 |
224 User::Leave( KErrGeneral ); |
222 // From last to first |
225 } |
223 for( TInt i = iMediaArray->Count()-1; i >= 0; i-- ) |
226 |
224 { |
227 // Save the name of level |
225 media = (*iMediaArray)[i]; |
228 |
226 |
229 CMPXMedia* media(NULL); |
227 if( media->IsSupported( KMPXMediaGeneralTitle ) ) |
230 media = (*iMediaArray)[aIndex]; |
228 { |
231 |
229 if( media->ValueText( KMPXMediaGeneralTitle ).Compare( aLevelName ) == KErrNone ) |
232 if( media->IsSupported( KMPXMediaGeneralTitle ) ) |
230 { |
233 { |
231 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
234 delete iCurrentLevelName; |
232 VCXLOGLO3("CVCXMyVideosCollectionPluginTester::OpenLevelL: mpx id1: %d, id2: %d", itemId.iId1, itemId.iId2); |
235 iCurrentLevelName = NULL; |
233 |
236 iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL(); |
234 levelIndex = i; |
237 } |
235 delete iCurrentLevelName; |
238 |
236 iCurrentLevelName = NULL; |
|
237 iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL(); |
|
238 break; |
|
239 } |
|
240 } |
|
241 } |
|
242 |
|
243 if( levelIndex == -1 ) |
|
244 { |
|
245 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:::OpenLevelL: Couldn't find the level!"); |
|
246 User::Leave( KErrNotFound ); |
|
247 } |
|
248 |
|
249 // Open the level |
239 // Open the level |
250 iCollectionUtility->Collection().OpenL( levelIndex ); |
240 TRAP_IGNORE( iStats->ActionStartL( KOpenCollectionLevelActionId, _L("Open level") ) ); |
251 |
241 iCurrentActionHasResponse = EFalse; |
252 iCurrentOpenedLevelIndex = levelIndex; |
242 iCurrentActionId = KOpenCollectionLevelActionId; |
253 SetRefreshStatus( ETrue ); |
243 |
254 |
|
255 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:::OpenLevelL (by name)"); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CVCXMyVideosCollectionPluginTester::OpenLevelL |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void CVCXMyVideosCollectionPluginTester::OpenLevelL( TInt aIndex ) |
|
263 { |
|
264 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::OpenLevelL"); |
|
265 |
|
266 if( GetCurrentLevel() != 2 ) |
|
267 { |
|
268 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Error. My videos collection must be open!"); |
|
269 User::Leave( KErrGeneral ); |
|
270 } |
|
271 |
|
272 if( aIndex >= 0 || aIndex < iMediaArray->Count() ) |
|
273 { |
|
274 CMPXMedia* media(NULL); |
|
275 media = (*iMediaArray)[aIndex]; |
|
276 |
|
277 if( media->IsSupported( KMPXMediaGeneralTitle ) ) |
|
278 { |
|
279 delete iCurrentLevelName; |
|
280 iCurrentLevelName = NULL; |
|
281 iCurrentLevelName = media->ValueText( KMPXMediaGeneralTitle ).AllocL(); |
|
282 } |
|
283 } |
|
284 else |
|
285 { |
|
286 VCXLOGLO1("CVCXMyVideosCollectionPluginTester::OpenLevelL: level index is invalid. Opening.."); |
|
287 } |
|
288 |
|
289 // Open the level |
|
290 iCollectionUtility->Collection().OpenL( aIndex ); |
244 iCollectionUtility->Collection().OpenL( aIndex ); |
291 |
245 |
292 iCurrentOpenedLevelIndex = aIndex; |
246 iCurrentOpenedLevelIndex = aIndex; |
293 SetRefreshStatus( ETrue ); |
247 SetRefreshStatus( ETrue ); |
294 |
248 |
479 else |
441 else |
480 { |
442 { |
481 PrintMediasL( iMediaArray, ETrue, *iCurrentLevelName ); |
443 PrintMediasL( iMediaArray, ETrue, *iCurrentLevelName ); |
482 } |
444 } |
483 } |
445 } |
|
446 |
|
447 // Update download states and info |
|
448 if( GetCurrentLevel() == 3 && iUpdateDownloads && iDownloadsStarted ) |
|
449 { |
|
450 UpdateDownloadsL( iQuietMode ); |
|
451 } |
|
452 } |
|
453 else |
|
454 { |
|
455 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:: iMediaArray is NULL"); |
|
456 } |
|
457 } |
|
458 |
|
459 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL"); |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CVcxMyVideosCollectionTester::UpdateDownloadsL |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 void CVCXMyVideosCollectionPluginTester::UpdateDownloadsL( TBool aQuietMode ) |
|
467 { |
|
468 if( !iMediaArray || !iDlWatcher ) |
|
469 { |
|
470 return; |
|
471 } |
|
472 |
|
473 if( !aQuietMode ) |
|
474 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateDownloadsL ---------->"); |
|
475 |
|
476 iDlWatcher->PrepareCheck(); |
|
477 |
|
478 // Print short info about downloads |
|
479 CMPXMedia* media( NULL ); |
|
480 |
|
481 for( TInt i = 0; i < iMediaArray->Count(); i++ ) |
|
482 { |
|
483 media = (*iMediaArray)[i]; |
|
484 |
|
485 // If it's download then get info about it and update download watcher. |
|
486 if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) |
|
487 { |
|
488 TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
489 |
|
490 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
491 |
|
492 HBufC* titleBuff = NULL; |
|
493 HBufC* urlBuff = NULL; |
|
494 HBufC* pathBuff = NULL; |
|
495 |
|
496 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
|
497 { |
|
498 const TDesC& url = media->ValueText( KMPXMediaGeneralUri ); |
|
499 pathBuff = url.AllocL(); |
|
500 CleanupStack::PushL( pathBuff ); |
|
501 } |
|
502 |
|
503 if( media->IsSupported( KMPXMediaGeneralTitle ) ) |
|
504 { |
|
505 const TDesC& title = media->ValueText( KMPXMediaGeneralTitle ); |
|
506 titleBuff = title.AllocL(); |
|
507 CleanupStack::PushL( titleBuff ); |
|
508 } |
|
509 |
|
510 if( media->IsSupported( KVcxMediaMyVideosRemoteUrl ) ) |
|
511 { |
|
512 const TDesC& url = media->ValueText( KVcxMediaMyVideosRemoteUrl ); |
|
513 urlBuff = url.AllocL(); |
|
514 CleanupStack::PushL( urlBuff ); |
|
515 } |
|
516 |
|
517 TInt progress = 0; |
|
518 if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) ) |
|
519 { |
|
520 progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress ); |
|
521 } |
|
522 |
|
523 TUint32 downloadId = 0; |
|
524 if( media->IsSupported( KVcxMediaMyVideosDownloadId ) ) |
|
525 { |
|
526 downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); |
|
527 } |
|
528 |
|
529 TInt downloadError = 0; |
|
530 if( media->IsSupported( KVcxMediaMyVideosDownloadError ) ) |
|
531 { |
|
532 downloadError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadError ); |
|
533 } |
|
534 |
|
535 TInt globalError = 0; |
|
536 if( media->IsSupported( KVcxMediaMyVideosDownloadGlobalError ) ) |
|
537 { |
|
538 globalError = media->ValueTObjectL<TInt32>( KVcxMediaMyVideosDownloadGlobalError ); |
|
539 } |
|
540 |
|
541 CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByMpxId( itemId.iId1 ); |
|
542 |
|
543 if( !dl ) |
|
544 { |
|
545 // Tell dl watcher that dl has started. |
|
546 if( state != EVcxMyVideosDlStateNone ) |
|
547 { |
|
548 iDlWatcher->StartDownloadL( *urlBuff, *pathBuff, downloadId, itemId.iId1, *titleBuff, |
|
549 static_cast<TVcxMyVideosDownloadState>( state ), progress ); |
|
550 } |
|
551 } |
|
552 else |
|
553 { |
|
554 // Update download. |
|
555 iDlWatcher->UpdateDownloadStateL( itemId.iId1, downloadId, |
|
556 static_cast<TVcxMyVideosDownloadState>( state ), progress, |
|
557 downloadError, globalError ); |
|
558 |
|
559 } |
484 |
560 |
485 UpdateAlbumsListL(); |
561 if( state == EVcxMyVideosDlStatePaused && iAutoResume ) |
486 } |
562 { |
|
563 if( dl && !dl->iWaitingResume ) |
|
564 { |
|
565 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: <---------- Autoresuming the paused download. ---------->"); |
|
566 ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL ); |
|
567 iDlWatcher->SetDownloadResumedFlagL( itemId.iId1, downloadId ); |
|
568 dl->iWaitingPause = EFalse; |
|
569 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: <---------- Resume ok ---------->"); |
|
570 } |
|
571 } |
|
572 |
|
573 if( urlBuff ) |
|
574 { |
|
575 CleanupStack::PopAndDestroy( urlBuff ); |
|
576 } |
|
577 if( titleBuff ) |
|
578 { |
|
579 CleanupStack::PopAndDestroy( titleBuff ); |
|
580 } |
|
581 if( pathBuff ) |
|
582 { |
|
583 CleanupStack::PopAndDestroy( pathBuff ); |
|
584 } |
|
585 } |
|
586 } |
|
587 |
|
588 if( !aQuietMode ) |
|
589 { |
|
590 iDlWatcher->PrintDownloads(); |
|
591 } |
|
592 |
|
593 iDlWatcher->FinishCheckL(); |
|
594 if( !aQuietMode ) |
|
595 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateDownloadsL <----------"); |
|
596 } |
|
597 |
|
598 // ----------------------------------------------------------------------------- |
|
599 // CVcxMyVideosCollectionTester::CreateMpxCommandLC |
|
600 // ----------------------------------------------------------------------------- |
|
601 // |
|
602 CMPXCommand* CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aSync ) |
|
603 { |
|
604 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
605 CleanupStack::PushL( cmd ); |
|
606 |
|
607 cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId ); |
|
608 if( aCommandGeneralId == KVcxCommandIdMyVideos ) |
|
609 { |
|
610 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId ); |
|
611 } |
|
612 |
|
613 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync ); |
|
614 |
|
615 if( !aSync ) |
|
616 { |
|
617 // Transaction id is used also tracking stats, so increment for every command. |
|
618 iTransactions->NextTransactionId(); |
|
619 |
|
620 if( aCommandGeneralId == KVcxCommandIdMyVideos ) |
|
621 { |
|
622 cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, iTransactions->TransactionId() ); |
|
623 iTransactions->AddTransactionId( aMyVideosCommandId ); |
|
624 } |
|
625 } |
|
626 |
|
627 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid.iUid ); |
|
628 |
|
629 return cmd; |
|
630 } |
|
631 |
|
632 // ----------------------------------------------------------------------------- |
|
633 // CVcxMyVideosCollectionTester::SelectMediasL |
|
634 // ----------------------------------------------------------------------------- |
|
635 // |
|
636 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::SelectMediasL( TInt aDriveFilter, TInt aStartIndex, TInt aEndIndex ) |
|
637 { |
|
638 if( aStartIndex == -4 ) |
|
639 { |
|
640 VCXLOGLO1("CVCXMyVideosCollectionPluginTester::SelectMediasL - returning NULL"); |
|
641 return NULL; |
|
642 } |
|
643 |
|
644 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::SelectMediasL"); |
|
645 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL: aStartIndex: %d", aStartIndex); |
|
646 |
|
647 if( !iMediaArray ) |
|
648 { |
|
649 User::Leave( KErrNotReady ); |
|
650 } |
|
651 |
|
652 iRequestedMediaIds.Reset(); |
|
653 |
|
654 CMPXMediaArray* medias = CMPXMediaArray::NewL(); |
|
655 |
|
656 // None |
|
657 if( aStartIndex > aEndIndex ) |
|
658 { |
|
659 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Selected none of the videos."); |
|
660 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL"); |
|
661 return medias; |
|
662 } |
|
663 |
|
664 CleanupStack::PushL( medias ); |
|
665 |
|
666 if( aStartIndex >= 0 ) |
|
667 { |
|
668 if( aEndIndex > iMediaArray->Count() ) |
|
669 { |
|
670 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex); |
|
671 User::Leave( KErrArgument ); |
|
672 } |
|
673 |
|
674 TInt countToSelect = aEndIndex - aStartIndex; |
|
675 TInt indexOfVideoOnDrive = 0; |
|
676 |
|
677 for( TInt i = 0; i < iMediaArray->Count(); i++ ) |
|
678 { |
|
679 CMPXMedia* media = (*iMediaArray)[i]; |
|
680 |
|
681 if( media ) |
|
682 { |
|
683 TBool selectThis( EFalse ); |
|
684 |
|
685 if( aDriveFilter != -1 ) |
|
686 { |
|
687 // Drive specified, check path and index of video on the drive. |
|
688 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri ); |
|
689 TInt drive( 0 ); |
|
690 User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) ); |
|
691 |
|
692 if( drive == aDriveFilter ) |
|
693 { |
|
694 if( indexOfVideoOnDrive >= aStartIndex && indexOfVideoOnDrive < aEndIndex ) |
|
695 { |
|
696 selectThis = ETrue; |
|
697 } |
|
698 indexOfVideoOnDrive++; |
|
699 } |
|
700 } |
|
701 else |
|
702 { |
|
703 // No drive specified, just index check. |
|
704 if( i >= aStartIndex && i < aEndIndex ) |
|
705 { |
|
706 selectThis = ETrue; |
|
707 } |
|
708 } |
|
709 |
|
710 if( selectThis ) |
|
711 { |
|
712 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
713 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1); |
|
714 iRequestedMediaIds.Append( mpxId.iId1 ); |
|
715 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
716 CleanupStack::PushL( newMedia ); |
|
717 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
718 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
719 medias->AppendL( *newMedia ); |
|
720 CleanupStack::PopAndDestroy( newMedia ); |
|
721 |
|
722 if( medias->Count() >= countToSelect ) |
|
723 { |
|
724 break; |
|
725 } |
|
726 } |
|
727 } |
|
728 } |
|
729 } |
|
730 |
|
731 // Invalid IDs |
|
732 if( aStartIndex == -1 ) |
|
733 { |
|
734 for( TInt i = 0; i < aEndIndex; i++ ) |
|
735 { |
|
736 TMPXItemId mpxId; |
|
737 mpxId.iId1 = i+66666; |
|
738 mpxId.iId2 = 0; |
|
739 |
|
740 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Invalid MPX ID: %d", mpxId.iId1); |
|
741 |
|
742 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
743 CleanupStack::PushL( newMedia ); |
|
744 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
745 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
746 medias->AppendL( *newMedia ); |
|
747 CleanupStack::PopAndDestroy( newMedia ); |
|
748 } |
|
749 } |
|
750 |
|
751 // Duplicate IDs |
|
752 if( aStartIndex == -2 ) |
|
753 { |
|
754 if( aEndIndex > iMediaArray->Count() ) |
|
755 { |
|
756 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex); |
|
757 User::Leave( KErrArgument ); |
|
758 } |
|
759 |
|
760 for( TInt i = 0; i < aEndIndex; i++ ) |
|
761 { |
|
762 CMPXMedia* media = (*iMediaArray)[i]; |
|
763 |
|
764 if( media ) |
|
765 { |
|
766 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
767 |
|
768 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Add twice MPX ID: %d", mpxId.iId1); |
|
769 iRequestedMediaIds.Append( mpxId.iId1 ); |
|
770 iRequestedMediaIds.Append( mpxId.iId1 ); |
|
771 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
772 CleanupStack::PushL( newMedia ); |
|
773 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
774 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
775 medias->AppendL( *newMedia ); |
|
776 medias->AppendL( *newMedia ); |
|
777 CleanupStack::PopAndDestroy( newMedia ); |
|
778 } |
|
779 } |
|
780 } |
|
781 |
|
782 // Every second ID |
|
783 if( aStartIndex == -3 ) |
|
784 { |
|
785 if( aEndIndex > iMediaArray->Count() ) |
|
786 { |
|
787 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex); |
|
788 User::Leave( KErrArgument ); |
|
789 } |
|
790 |
|
791 for( TInt i = 0; i < aEndIndex; i+=2 ) |
|
792 { |
|
793 CMPXMedia* media = (*iMediaArray)[i]; |
|
794 |
|
795 if( media ) |
|
796 { |
|
797 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
798 |
|
799 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1); |
|
800 iRequestedMediaIds.Append( mpxId.iId1 ); |
|
801 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
802 CleanupStack::PushL( newMedia ); |
|
803 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
804 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
805 medias->AppendL( *newMedia ); |
|
806 CleanupStack::PopAndDestroy( newMedia ); |
|
807 } |
|
808 } |
|
809 } |
|
810 |
|
811 CleanupStack::Pop( medias ); |
|
812 |
|
813 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL"); |
|
814 return medias; |
|
815 } |
|
816 |
|
817 // ----------------------------------------------------------------------------- |
|
818 // CVcxMyVideosCollectionTester::UpdateOwnedMediaArray |
|
819 // ----------------------------------------------------------------------------- |
|
820 // |
|
821 void CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL() |
|
822 { |
|
823 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL"); |
|
824 |
|
825 if ( !iCollectionEntries ) |
|
826 { |
|
827 return; |
|
828 } |
|
829 |
|
830 if( !iCollectionEntries->IsSupported( KMPXMediaArrayContents ) ) |
|
831 { |
|
832 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No support for KMPXMediaArrayContents, cannot continue!"); |
|
833 User::Leave( KErrNotSupported ); |
|
834 } |
|
835 |
|
836 // Get up to date list of all medias in collection. |
|
837 CMPXMediaArray* medias = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
838 |
|
839 // Delete array of old medias |
|
840 if( iOldMediaArray ) |
|
841 { |
|
842 iOldMediaArray->Reset(); |
|
843 delete iOldMediaArray; |
|
844 } |
|
845 |
|
846 // Update the old array and create new |
|
847 iOldMediaArray = iMediaArray; |
|
848 iMediaArray = CMPXMediaArray::NewL(); |
|
849 |
|
850 TBool categories( EFalse ); |
|
851 |
|
852 // Make copies of the medias. |
|
853 for( TInt i=0; i<medias->Count(); i++ ) |
|
854 { |
|
855 CMPXMedia* media = (*medias)[i]; |
|
856 |
|
857 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
858 if( itemId.iId2 != 0 ) |
|
859 { |
|
860 categories = ETrue; |
|
861 } |
|
862 |
|
863 // Ignore medias on ROM. |
|
864 TBool isOnRom( EFalse ); |
|
865 |
|
866 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
|
867 { |
|
868 const TDesC& url = media->ValueText( KMPXMediaGeneralUri ); |
|
869 if( url.FindC( _L("z:" ) ) != KErrNotFound ) |
|
870 { |
|
871 isOnRom = ETrue; |
|
872 } |
|
873 } |
|
874 |
|
875 if( !isOnRom ) |
|
876 { |
|
877 iMediaArray->AppendL( *media ); |
|
878 } |
|
879 } |
|
880 |
|
881 iMediaCount = iMediaArray->Count(); |
|
882 |
|
883 // Update count of videos on ROM. |
|
884 if( !categories ) |
|
885 { |
|
886 iVideosOnRomCount = 0; |
|
887 |
|
888 for( TInt i=0; i<medias->Count(); i++ ) |
|
889 { |
|
890 CMPXMedia* media = (*medias)[i]; |
|
891 |
|
892 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
|
893 { |
|
894 const TDesC& url = media->ValueText( KMPXMediaGeneralUri ); |
|
895 if( url.FindC( _L("z:" ) ) != KErrNotFound ) |
|
896 { |
|
897 iVideosOnRomCount++; |
|
898 } |
|
899 } |
|
900 } |
|
901 |
|
902 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: iVideosOnRom: %d", iVideosOnRomCount); |
|
903 } |
|
904 |
|
905 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL"); |
|
906 } |
|
907 |
|
908 // ----------------------------------------------------------------------------- |
|
909 // CVcxMyVideosCollectionTester::GetChangedMedias |
|
910 // ----------------------------------------------------------------------------- |
|
911 // |
|
912 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetChangedMedias( const CMPXMediaArray* aNewMedias ) |
|
913 { |
|
914 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetChangedMedias"); |
|
915 |
|
916 CMPXMediaArray* changedMedias = CMPXMediaArray::NewL(); |
|
917 |
|
918 if( !aNewMedias ) |
|
919 { |
|
920 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias"); |
|
921 return changedMedias; |
|
922 } |
|
923 |
|
924 CleanupStack::PushL( changedMedias ); |
|
925 |
|
926 for( TInt i=0; i<aNewMedias->Count(); i++ ) |
|
927 { |
|
928 CMPXMedia* media(NULL); |
|
929 media = (*aNewMedias)[i]; |
|
930 |
|
931 if( !media ) |
|
932 { |
|
933 continue; |
|
934 } |
|
935 |
|
936 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
937 |
|
938 CMPXMedia* oldMedia = GetMediaByMpxId( iOldMediaArray, mpxId ); |
|
939 |
|
940 TBool add( EFalse ); |
|
941 |
|
942 // It's a new. |
|
943 if( !oldMedia ) |
|
944 { |
|
945 add = ETrue; |
|
946 } |
|
947 // Check changes |
487 else |
948 else |
488 { |
949 { |
489 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester:: iMediaArray is NULL"); |
950 const TArray<TMPXAttribute> newAttributes = media->Attributes(); |
490 } |
951 const TArray<TMPXAttribute> oldAttributes = oldMedia->Attributes(); |
491 } |
952 if( newAttributes.Count() != oldAttributes.Count() ) |
492 |
953 { |
493 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ProcessCurrentEntriesL"); |
954 add = ETrue; |
494 } |
955 } |
495 |
956 else |
496 // ----------------------------------------------------------------------------- |
957 { |
497 // CVCXMyVideosCollectionPluginTester::PrintMediasL |
958 for( TInt e=0; e<newAttributes.Count(); e++ ) |
|
959 { |
|
960 if( !oldMedia->Match( *media, newAttributes[e] ) ) |
|
961 { |
|
962 add = ETrue; |
|
963 break; |
|
964 } |
|
965 } |
|
966 } |
|
967 } |
|
968 |
|
969 // Add a copy of the media. |
|
970 if( add ) |
|
971 { |
|
972 changedMedias->AppendL( *media ); |
|
973 } |
|
974 } |
|
975 |
|
976 CleanupStack::Pop( changedMedias ); |
|
977 |
|
978 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias"); |
|
979 return changedMedias; |
|
980 } |
|
981 |
|
982 // ----------------------------------------------------------------------------- |
|
983 // CVcxMyVideosCollectionTester::GetMediaByMpxId |
|
984 // ----------------------------------------------------------------------------- |
|
985 // |
|
986 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaByMpxId( CMPXMediaArray* aMedias, TMPXItemId& aMpxId ) |
|
987 { |
|
988 if( !aMedias ) |
|
989 { |
|
990 return NULL; |
|
991 } |
|
992 |
|
993 for( TInt i=0; i<aMedias->Count(); i++ ) |
|
994 { |
|
995 CMPXMedia* media = (*aMedias)[i]; |
|
996 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
997 |
|
998 if( mpxId == aMpxId ) |
|
999 { |
|
1000 return media; |
|
1001 } |
|
1002 } |
|
1003 return NULL; |
|
1004 } |
|
1005 |
|
1006 // ----------------------------------------------------------------------------- |
|
1007 // CVcxMyVideosCollectionTester::SetRefreshStatus |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // |
|
1010 void CVCXMyVideosCollectionPluginTester::SetRefreshStatus( TBool aRefreshingCollection ) |
|
1011 { |
|
1012 iRefreshingCollection = aRefreshingCollection; |
|
1013 } |
|
1014 |
|
1015 // ----------------------------------------------------------------------------- |
|
1016 // CVcxMyVideosCollectionTester::CheckRequestMediaArrayL |
|
1017 // ----------------------------------------------------------------------------- |
|
1018 // |
|
1019 void CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL( CMPXMediaArray& aRequestResultMedias, RArray<TInt32>& aRequestedMediaIds ) |
|
1020 { |
|
1021 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL"); |
|
1022 |
|
1023 // Print requested ids |
|
1024 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested IDs:"); |
|
1025 for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ ) |
|
1026 { |
|
1027 VCXLOGLO2("Requested: iId1: %d", aRequestedMediaIds[i] ); |
|
1028 } |
|
1029 |
|
1030 // Print actual result ids and check for errors |
|
1031 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Request result media IDs:"); |
|
1032 for( TInt i = 0; i < aRequestResultMedias.Count(); i++ ) |
|
1033 { |
|
1034 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: at index: %d:", i); |
|
1035 CMPXMedia* media = aRequestResultMedias[i]; |
|
1036 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: got media"); |
|
1037 if( media ) |
|
1038 { |
|
1039 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1040 VCXLOGLO3("Result: iId1: %d, iId2: %d", mpxId.iId1, mpxId.iId2 ); |
|
1041 if( media->IsSupported( KVcxMediaMyVideosInt32Value ) ) |
|
1042 { |
|
1043 TInt32 result = (*media).ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value ); |
|
1044 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: result: %d:", result); |
|
1045 if( result != KErrNone && !( result == KErrCancel && iCancelRequested ) ) |
|
1046 { |
|
1047 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: ERROR in results: %d!", result); |
|
1048 User::Leave( result ); |
|
1049 } |
|
1050 } |
|
1051 } |
|
1052 else |
|
1053 { |
|
1054 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Result is NULL at index: %d", i); |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: rest of the checks"); |
|
1059 |
|
1060 // First check the counts match |
|
1061 if( aRequestResultMedias.Count() != aRequestedMediaIds.Count() ) |
|
1062 { |
|
1063 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Did not get all the requested entries!"); |
|
1064 User::Leave( KErrCorrupt ); |
|
1065 } |
|
1066 else |
|
1067 // Check that all requested ids are in the results |
|
1068 for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ ) |
|
1069 { |
|
1070 TMPXItemId mpxId; |
|
1071 mpxId.iId1 = aRequestedMediaIds[i]; |
|
1072 mpxId.iId2 = 0; |
|
1073 |
|
1074 TBool found( EFalse ); |
|
1075 for( TInt e = 0; e < aRequestResultMedias.Count(); e++ ) |
|
1076 { |
|
1077 CMPXMedia* media2 = aRequestResultMedias[e]; |
|
1078 if( media2 ) |
|
1079 { |
|
1080 TMPXItemId mpxId2 = *(*media2).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1081 |
|
1082 if( mpxId == mpxId2 ) |
|
1083 { |
|
1084 found = ETrue; |
|
1085 } |
|
1086 } |
|
1087 } |
|
1088 |
|
1089 if( !found ) |
|
1090 { |
|
1091 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested media not found from results!"); |
|
1092 User::Leave( KErrCorrupt ); |
|
1093 } |
|
1094 } |
|
1095 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL"); |
|
1096 } |
|
1097 |
|
1098 // ----------------------------------------------------------------------------- |
|
1099 // CVcxMyVideosCollectionTester::PrintMediasL |
498 // ----------------------------------------------------------------------------- |
1100 // ----------------------------------------------------------------------------- |
499 // |
1101 // |
500 void CVCXMyVideosCollectionPluginTester::PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle ) |
1102 void CVCXMyVideosCollectionPluginTester::PrintMediasL( CMPXMediaArray* aMediaArray, TBool aCheckChanges, const TDesC& aTitle ) |
501 { |
1103 { |
502 if( aMediaArray == NULL ) |
1104 if( aMediaArray == NULL ) |
863 VCXLOGLO2("KMPXMediaGeneralPath: %S", &value); |
1457 VCXLOGLO2("KMPXMediaGeneralPath: %S", &value); |
864 } |
1458 } |
865 } |
1459 } |
866 |
1460 |
867 // ----------------------------------------------------------------------------- |
1461 // ----------------------------------------------------------------------------- |
868 // CVCXMyVideosCollectionPluginTester::UpdateAlbumsListL |
1462 // CVcxMyVideosCollectionTester::HandleCollectionMessage |
869 // ----------------------------------------------------------------------------- |
|
870 // |
|
871 void CVCXMyVideosCollectionPluginTester::UpdateAlbumsListL() |
|
872 { |
|
873 CMPXMedia* media; |
|
874 |
|
875 for( TInt i = 0; i < iMediaArray->Count(); i++ ) |
|
876 { |
|
877 media = (*iMediaArray)[i]; |
|
878 |
|
879 if( media ) |
|
880 { |
|
881 TMPXItemId itemId = *media->Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
882 |
|
883 if( itemId.iId2 == KVcxMvcMediaTypeAlbum ) |
|
884 { |
|
885 int albumIndex(-1); |
|
886 for( TInt e = 0; e < iAlbumIds.Count(); e++ ) |
|
887 { |
|
888 if( iAlbumIds[e] == itemId ) |
|
889 { |
|
890 albumIndex = e; |
|
891 } |
|
892 } |
|
893 |
|
894 TBuf<256> title; |
|
895 if( media->IsSupported( KMPXMediaGeneralTitle ) ) |
|
896 { |
|
897 title = media->ValueText( KMPXMediaGeneralTitle ); |
|
898 |
|
899 if( albumIndex == -1 ) |
|
900 { |
|
901 HBufC* titleBuff = title.AllocL(); |
|
902 iAlbumNames.Append( titleBuff ); |
|
903 iAlbumIds.Append( itemId ); |
|
904 } |
|
905 else |
|
906 { |
|
907 if( iAlbumNames[albumIndex]->Compare( title )!= KErrNone ) |
|
908 { |
|
909 iAlbumNames[albumIndex]->Des().SetLength( 0 ); |
|
910 iAlbumNames[albumIndex]->ReAlloc( title.Length() ); |
|
911 iAlbumNames[albumIndex]->Des().Copy( title ); |
|
912 } |
|
913 } |
|
914 } |
|
915 } |
|
916 } |
|
917 } |
|
918 } |
|
919 |
|
920 // ----------------------------------------------------------------------------- |
|
921 // CVCXMyVideosCollectionPluginTester::GetAlbumIdL |
|
922 // ----------------------------------------------------------------------------- |
|
923 // |
|
924 TMPXItemId CVCXMyVideosCollectionPluginTester::GetAlbumIdL( const TDesC& aAlbumName ) |
|
925 { |
|
926 // Get the last album with the name. |
|
927 for( TInt i = iAlbumNames.Count()-1; i >= 0; i-- ) |
|
928 { |
|
929 if( iAlbumNames[i]->Des() == aAlbumName && i < iAlbumIds.Count() ) |
|
930 { |
|
931 VCXLOGLO3("CVCXMyVideosCollectionPluginTester::GetAlbumIdL: returning album id1: %d, id2: %d", iAlbumIds[i].iId1, iAlbumIds[i].iId2); |
|
932 return iAlbumIds[i]; |
|
933 } |
|
934 } |
|
935 |
|
936 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::GetAlbumIdL: could not find album '%S'", &aAlbumName); |
|
937 User::Leave( KErrNotFound ); |
|
938 |
|
939 return TMPXItemId::InvalidId(); |
|
940 } |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC |
|
944 // ----------------------------------------------------------------------------- |
|
945 // |
|
946 CMPXCommand* CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC( TInt aCommandGeneralId, TInt aMyVideosCommandId, TBool aSync ) |
|
947 { |
|
948 CMPXCommand* cmd = CMPXCommand::NewL(); |
|
949 CleanupStack::PushL( cmd ); |
|
950 |
|
951 cmd->SetTObjectValueL( KMPXCommandGeneralId, aCommandGeneralId ); |
|
952 if( aCommandGeneralId == KVcxCommandIdMyVideos ) |
|
953 { |
|
954 cmd->SetTObjectValueL( KVcxMediaMyVideosCommandId, aMyVideosCommandId ); |
|
955 } |
|
956 |
|
957 cmd->SetTObjectValueL( KMPXCommandGeneralDoSync, aSync ); |
|
958 |
|
959 if( !aSync ) |
|
960 { |
|
961 iTransactions->NextTransactionId(); |
|
962 |
|
963 if( aCommandGeneralId == KVcxCommandIdMyVideos ) |
|
964 { |
|
965 cmd->SetTObjectValueL( KVcxMediaMyVideosTransactionId, iTransactions->TransactionId() ); |
|
966 iTransactions->AddTransactionId( aMyVideosCommandId ); |
|
967 } |
|
968 } |
|
969 |
|
970 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::CreateMpxCommandLC: collectionId: 0x%x", iCollectionUid.iUid); |
|
971 cmd->SetTObjectValueL( KMPXCommandGeneralCollectionId, iCollectionUid.iUid ); |
|
972 |
|
973 return cmd; |
|
974 } |
|
975 |
|
976 // ----------------------------------------------------------------------------- |
|
977 // CVCXMyVideosCollectionPluginTester::SelectMediasL |
|
978 // ----------------------------------------------------------------------------- |
|
979 // |
|
980 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::SelectMediasL( TInt aDriveFilter, TInt aStartIndex, TInt aEndIndex ) |
|
981 { |
|
982 if( aStartIndex == -4 ) |
|
983 { |
|
984 VCXLOGLO1("CVCXMyVideosCollectionPluginTester::SelectMediasL - returning NULL"); |
|
985 return NULL; |
|
986 } |
|
987 |
|
988 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::SelectMediasL"); |
|
989 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL: aStartIndex: %d", aStartIndex); |
|
990 |
|
991 CMPXMediaArray* iSourceMedias; |
|
992 |
|
993 if( !iUseCopiedMedias ) |
|
994 { |
|
995 if( !iMediaArray ) |
|
996 { |
|
997 User::Leave( KErrNotReady ); |
|
998 } |
|
999 iSourceMedias = iMediaArray; |
|
1000 } |
|
1001 else |
|
1002 { |
|
1003 if( !iMediaArrayCopy ) |
|
1004 { |
|
1005 User::Leave( KErrNotReady ); |
|
1006 } |
|
1007 iSourceMedias = iMediaArrayCopy; |
|
1008 } |
|
1009 |
|
1010 iRequestedMediaIds.Reset(); |
|
1011 |
|
1012 CMPXMediaArray* medias = CMPXMediaArray::NewL(); |
|
1013 |
|
1014 // None |
|
1015 if( aStartIndex > aEndIndex ) |
|
1016 { |
|
1017 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Selected none of the videos."); |
|
1018 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL"); |
|
1019 return medias; |
|
1020 } |
|
1021 |
|
1022 CleanupStack::PushL( medias ); |
|
1023 |
|
1024 if( aStartIndex >= 0 ) |
|
1025 { |
|
1026 if( aEndIndex > iSourceMedias->Count() ) |
|
1027 { |
|
1028 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex); |
|
1029 User::Leave( KErrArgument ); |
|
1030 } |
|
1031 |
|
1032 TInt countToSelect = aEndIndex - aStartIndex; |
|
1033 TInt indexOfVideoOnDrive = 0; |
|
1034 |
|
1035 for( TInt i = 0; i < iSourceMedias->Count(); i++ ) |
|
1036 { |
|
1037 CMPXMedia* media = (*iSourceMedias)[i]; |
|
1038 |
|
1039 if( media ) |
|
1040 { |
|
1041 TBool selectThis( EFalse ); |
|
1042 |
|
1043 if( aDriveFilter != -1 ) |
|
1044 { |
|
1045 // Drive specified, check path and index of video on the drive. |
|
1046 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri ); |
|
1047 TInt drive( 0 ); |
|
1048 User::LeaveIfError( iFs.CharToDrive( localFilePath[0], drive ) ); |
|
1049 |
|
1050 if( drive == aDriveFilter ) |
|
1051 { |
|
1052 if( indexOfVideoOnDrive >= aStartIndex && indexOfVideoOnDrive < aEndIndex ) |
|
1053 { |
|
1054 selectThis = ETrue; |
|
1055 } |
|
1056 indexOfVideoOnDrive++; |
|
1057 } |
|
1058 } |
|
1059 else |
|
1060 { |
|
1061 // No drive specified, just index check. |
|
1062 if( i >= aStartIndex && i < aEndIndex ) |
|
1063 { |
|
1064 selectThis = ETrue; |
|
1065 } |
|
1066 } |
|
1067 |
|
1068 if( selectThis ) |
|
1069 { |
|
1070 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1071 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1); |
|
1072 iRequestedMediaIds.Append( mpxId.iId1 ); |
|
1073 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
1074 CleanupStack::PushL( newMedia ); |
|
1075 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
1076 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
1077 medias->AppendL( *newMedia ); |
|
1078 CleanupStack::PopAndDestroy( newMedia ); |
|
1079 |
|
1080 if( medias->Count() >= countToSelect ) |
|
1081 { |
|
1082 break; |
|
1083 } |
|
1084 } |
|
1085 } |
|
1086 } |
|
1087 } |
|
1088 |
|
1089 // Invalid IDs |
|
1090 if( aStartIndex == -1 ) |
|
1091 { |
|
1092 for( TInt i = 0; i < aEndIndex; i++ ) |
|
1093 { |
|
1094 TMPXItemId mpxId; |
|
1095 mpxId.iId1 = i+66666; |
|
1096 mpxId.iId2 = 0; |
|
1097 |
|
1098 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Invalid MPX ID: %d", mpxId.iId1); |
|
1099 |
|
1100 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
1101 CleanupStack::PushL( newMedia ); |
|
1102 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
1103 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
1104 medias->AppendL( *newMedia ); |
|
1105 CleanupStack::PopAndDestroy( newMedia ); |
|
1106 } |
|
1107 } |
|
1108 |
|
1109 // Duplicate IDs |
|
1110 if( aStartIndex == -2 ) |
|
1111 { |
|
1112 if( aEndIndex > iSourceMedias->Count() ) |
|
1113 { |
|
1114 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex); |
|
1115 User::Leave( KErrArgument ); |
|
1116 } |
|
1117 |
|
1118 for( TInt i = 0; i < aEndIndex; i++ ) |
|
1119 { |
|
1120 CMPXMedia* media = (*iSourceMedias)[i]; |
|
1121 |
|
1122 if( media ) |
|
1123 { |
|
1124 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1125 |
|
1126 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. Add twice MPX ID: %d", mpxId.iId1); |
|
1127 iRequestedMediaIds.Append( mpxId.iId1 ); |
|
1128 iRequestedMediaIds.Append( mpxId.iId1 ); |
|
1129 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
1130 CleanupStack::PushL( newMedia ); |
|
1131 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
1132 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
1133 medias->AppendL( *newMedia ); |
|
1134 medias->AppendL( *newMedia ); |
|
1135 CleanupStack::PopAndDestroy( newMedia ); |
|
1136 } |
|
1137 } |
|
1138 } |
|
1139 |
|
1140 // Every second ID |
|
1141 if( aStartIndex == -3 ) |
|
1142 { |
|
1143 if( aEndIndex > iSourceMedias->Count() ) |
|
1144 { |
|
1145 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::SelectMediasL end index: %d is out of bounds.", aEndIndex); |
|
1146 User::Leave( KErrArgument ); |
|
1147 } |
|
1148 |
|
1149 for( TInt i = 0; i < aEndIndex; i+=2 ) |
|
1150 { |
|
1151 CMPXMedia* media = (*iSourceMedias)[i]; |
|
1152 |
|
1153 if( media ) |
|
1154 { |
|
1155 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1156 |
|
1157 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Selected media. MPX ID: %d", mpxId.iId1); |
|
1158 iRequestedMediaIds.Append( mpxId.iId1 ); |
|
1159 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
1160 CleanupStack::PushL( newMedia ); |
|
1161 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
1162 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
1163 medias->AppendL( *newMedia ); |
|
1164 CleanupStack::PopAndDestroy( newMedia ); |
|
1165 } |
|
1166 } |
|
1167 } |
|
1168 |
|
1169 CleanupStack::Pop( medias ); |
|
1170 |
|
1171 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::SelectMediasL"); |
|
1172 return medias; |
|
1173 } |
|
1174 |
|
1175 // ----------------------------------------------------------------------------- |
|
1176 // CVCXMyVideosCollectionPluginTester::SetUseCopiedMediasL |
|
1177 // ----------------------------------------------------------------------------- |
|
1178 // |
|
1179 void CVCXMyVideosCollectionPluginTester::SetUseCopiedMediasL( TBool aUseCopiedMedias ) |
|
1180 { |
|
1181 if( aUseCopiedMedias ) |
|
1182 { |
|
1183 CreateCopyOfCurrentMediasL(); |
|
1184 } |
|
1185 |
|
1186 iUseCopiedMedias = aUseCopiedMedias; |
|
1187 } |
|
1188 |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL |
|
1191 // ----------------------------------------------------------------------------- |
|
1192 // |
|
1193 void CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL() |
|
1194 { |
|
1195 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL"); |
|
1196 |
|
1197 if( !iMediaArray ) |
|
1198 { |
|
1199 User::Leave( KErrNotReady ); |
|
1200 } |
|
1201 |
|
1202 if( iMediaArrayCopy ) |
|
1203 { |
|
1204 iMediaArrayCopy->Reset(); |
|
1205 delete iMediaArrayCopy; |
|
1206 iMediaArrayCopy = NULL; |
|
1207 } |
|
1208 |
|
1209 iMediaArrayCopy = CMPXMediaArray::NewL(); |
|
1210 |
|
1211 for( TInt i = 0; i < iMediaArray->Count(); i++ ) |
|
1212 { |
|
1213 CMPXMedia* media = (*iMediaArray)[i]; |
|
1214 |
|
1215 if( media ) |
|
1216 { |
|
1217 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1218 |
|
1219 CMPXMedia* newMedia = CMPXMedia::NewL(); |
|
1220 CleanupStack::PushL( newMedia ); |
|
1221 newMedia->SetTObjectValueL( KMPXMessageMediaGeneralId, mpxId ); |
|
1222 newMedia->SetTObjectValueL( KMPXMediaGeneralId, mpxId ); |
|
1223 iMediaArrayCopy->AppendL( *newMedia ); |
|
1224 CleanupStack::PopAndDestroy( newMedia ); |
|
1225 } |
|
1226 } |
|
1227 |
|
1228 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CreateCopyOfCurrentMediasL"); |
|
1229 } |
|
1230 |
|
1231 // ----------------------------------------------------------------------------- |
|
1232 // CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArray |
|
1233 // ----------------------------------------------------------------------------- |
|
1234 // |
|
1235 void CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL() |
|
1236 { |
|
1237 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL"); |
|
1238 |
|
1239 if ( !iCollectionEntries ) |
|
1240 { |
|
1241 return; |
|
1242 } |
|
1243 |
|
1244 if( !iCollectionEntries->IsSupported( KMPXMediaArrayContents ) ) |
|
1245 { |
|
1246 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: No support for KMPXMediaArrayContents, cannot continue!"); |
|
1247 User::Leave( KErrNotSupported ); |
|
1248 } |
|
1249 |
|
1250 // Get up to date list of all medias in collection. |
|
1251 CMPXMediaArray* medias = iCollectionEntries->Value<CMPXMediaArray>( KMPXMediaArrayContents ); |
|
1252 |
|
1253 // Delete array of old medias |
|
1254 if( iOldMediaArray ) |
|
1255 { |
|
1256 iOldMediaArray->Reset(); |
|
1257 delete iOldMediaArray; |
|
1258 } |
|
1259 |
|
1260 // Update the old array and create new |
|
1261 iOldMediaArray = iMediaArray; |
|
1262 iMediaArray = CMPXMediaArray::NewL(); |
|
1263 |
|
1264 TBool categories( EFalse ); |
|
1265 |
|
1266 // Make copies of the medias. |
|
1267 for( TInt i=0; i<medias->Count(); i++ ) |
|
1268 { |
|
1269 CMPXMedia* media = (*medias)[i]; |
|
1270 |
|
1271 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
1272 |
|
1273 if( itemId.iId2 != KVcxMvcMediaTypeVideo ) |
|
1274 { |
|
1275 categories = ETrue; |
|
1276 } |
|
1277 |
|
1278 // Ignore medias on ROM. |
|
1279 TBool isOnRom( EFalse ); |
|
1280 |
|
1281 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
|
1282 { |
|
1283 const TDesC& url = media->ValueText( KMPXMediaGeneralUri ); |
|
1284 if( url.FindC( _L("z:" ) ) != KErrNotFound ) |
|
1285 { |
|
1286 isOnRom = ETrue; |
|
1287 } |
|
1288 } |
|
1289 |
|
1290 if( !isOnRom ) |
|
1291 { |
|
1292 iMediaArray->AppendL( *media ); |
|
1293 } |
|
1294 } |
|
1295 |
|
1296 iMediaCount = iMediaArray->Count(); |
|
1297 |
|
1298 // Update count of videos on ROM. |
|
1299 if( !categories ) |
|
1300 { |
|
1301 iVideosOnRomCount = 0; |
|
1302 |
|
1303 for( TInt i=0; i<medias->Count(); i++ ) |
|
1304 { |
|
1305 CMPXMedia* media = (*medias)[i]; |
|
1306 |
|
1307 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
|
1308 { |
|
1309 const TDesC& url = media->ValueText( KMPXMediaGeneralUri ); |
|
1310 if( url.FindC( _L("z:" ) ) != KErrNotFound ) |
|
1311 { |
|
1312 iVideosOnRomCount++; |
|
1313 } |
|
1314 } |
|
1315 } |
|
1316 |
|
1317 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: iVideosOnRom: %d", iVideosOnRomCount); |
|
1318 } |
|
1319 |
|
1320 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::UpdateOwnedMediaArrayL"); |
|
1321 } |
|
1322 |
|
1323 // ----------------------------------------------------------------------------- |
|
1324 // CVCXMyVideosCollectionPluginTester::GetChangedMedias |
|
1325 // ----------------------------------------------------------------------------- |
|
1326 // |
|
1327 CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetChangedMedias( const CMPXMediaArray* aNewMedias ) |
|
1328 { |
|
1329 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::GetChangedMedias"); |
|
1330 |
|
1331 CMPXMediaArray* changedMedias = CMPXMediaArray::NewL(); |
|
1332 |
|
1333 if( !aNewMedias ) |
|
1334 { |
|
1335 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias"); |
|
1336 return changedMedias; |
|
1337 } |
|
1338 |
|
1339 CleanupStack::PushL( changedMedias ); |
|
1340 |
|
1341 for( TInt i=0; i<aNewMedias->Count(); i++ ) |
|
1342 { |
|
1343 CMPXMedia* media(NULL); |
|
1344 media = (*aNewMedias)[i]; |
|
1345 |
|
1346 if( !media ) |
|
1347 { |
|
1348 continue; |
|
1349 } |
|
1350 |
|
1351 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1352 |
|
1353 CMPXMedia* oldMedia = GetMediaByMpxId( iOldMediaArray, mpxId ); |
|
1354 |
|
1355 TBool add( EFalse ); |
|
1356 |
|
1357 // It's a new. |
|
1358 if( !oldMedia ) |
|
1359 { |
|
1360 add = ETrue; |
|
1361 } |
|
1362 // Check changes |
|
1363 else |
|
1364 { |
|
1365 const TArray<TMPXAttribute> newAttributes = media->Attributes(); |
|
1366 const TArray<TMPXAttribute> oldAttributes = oldMedia->Attributes(); |
|
1367 if( newAttributes.Count() != oldAttributes.Count() ) |
|
1368 { |
|
1369 add = ETrue; |
|
1370 } |
|
1371 else |
|
1372 { |
|
1373 for( TInt e=0; e<newAttributes.Count(); e++ ) |
|
1374 { |
|
1375 if( !oldMedia->Match( *media, newAttributes[e] ) ) |
|
1376 { |
|
1377 add = ETrue; |
|
1378 break; |
|
1379 } |
|
1380 } |
|
1381 } |
|
1382 } |
|
1383 |
|
1384 // Add a copy of the media. |
|
1385 if( add ) |
|
1386 { |
|
1387 changedMedias->AppendL( *media ); |
|
1388 } |
|
1389 } |
|
1390 |
|
1391 CleanupStack::Pop( changedMedias ); |
|
1392 |
|
1393 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::GetChangedMedias"); |
|
1394 return changedMedias; |
|
1395 } |
|
1396 |
|
1397 // ----------------------------------------------------------------------------- |
|
1398 // CVCXMyVideosCollectionPluginTester::GetMediaByMpxId |
|
1399 // ----------------------------------------------------------------------------- |
|
1400 // |
|
1401 CMPXMedia* CVCXMyVideosCollectionPluginTester::GetMediaByMpxId( CMPXMediaArray* aMedias, TMPXItemId& aMpxId ) |
|
1402 { |
|
1403 if( !aMedias ) |
|
1404 { |
|
1405 return NULL; |
|
1406 } |
|
1407 |
|
1408 for( TInt i=0; i<aMedias->Count(); i++ ) |
|
1409 { |
|
1410 CMPXMedia* media = (*aMedias)[i]; |
|
1411 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1412 |
|
1413 if( mpxId == aMpxId ) |
|
1414 { |
|
1415 return media; |
|
1416 } |
|
1417 } |
|
1418 return NULL; |
|
1419 } |
|
1420 |
|
1421 // ----------------------------------------------------------------------------- |
|
1422 // CVCXMyVideosCollectionPluginTester::SetRefreshStatus |
|
1423 // ----------------------------------------------------------------------------- |
|
1424 // |
|
1425 void CVCXMyVideosCollectionPluginTester::SetRefreshStatus( TBool aRefreshingCollection ) |
|
1426 { |
|
1427 iRefreshingCollection = aRefreshingCollection; |
|
1428 } |
|
1429 |
|
1430 // ----------------------------------------------------------------------------- |
|
1431 // CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL |
|
1432 // ----------------------------------------------------------------------------- |
|
1433 // |
|
1434 void CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL( CMPXMediaArray& aRequestResultMedias, RArray<TInt32>& aRequestedMediaIds ) |
|
1435 { |
|
1436 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL"); |
|
1437 |
|
1438 // Print requested ids |
|
1439 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested IDs:"); |
|
1440 for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ ) |
|
1441 { |
|
1442 VCXLOGLO2("Requested: iId1: %d", aRequestedMediaIds[i] ); |
|
1443 } |
|
1444 |
|
1445 // Print actual result ids and check for errors |
|
1446 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Request result media IDs:"); |
|
1447 for( TInt i = 0; i < aRequestResultMedias.Count(); i++ ) |
|
1448 { |
|
1449 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: at index: %d:", i); |
|
1450 CMPXMedia* media = aRequestResultMedias[i]; |
|
1451 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: got media"); |
|
1452 if( media ) |
|
1453 { |
|
1454 TMPXItemId mpxId = *(*media).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1455 VCXLOGLO3("Result: iId1: %d, iId2: %d", mpxId.iId1, mpxId.iId2 ); |
|
1456 if( media->IsSupported( KVcxMediaMyVideosInt32Value ) ) |
|
1457 { |
|
1458 TInt32 result = (*media).ValueTObjectL<TInt32>( KVcxMediaMyVideosInt32Value ); |
|
1459 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: result: %d:", result); |
|
1460 if( result != KErrNone && !( result == KErrCancel && iCancelRequested ) ) |
|
1461 { |
|
1462 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: ERROR in results: %d!", result); |
|
1463 User::Leave( result ); |
|
1464 } |
|
1465 } |
|
1466 } |
|
1467 else |
|
1468 { |
|
1469 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: Result is NULL at index: %d", i); |
|
1470 } |
|
1471 } |
|
1472 |
|
1473 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: rest of the checks"); |
|
1474 |
|
1475 // First check the counts match |
|
1476 if( aRequestResultMedias.Count() != aRequestedMediaIds.Count() ) |
|
1477 { |
|
1478 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Did not get all the requested entries!"); |
|
1479 User::Leave( KErrCorrupt ); |
|
1480 } |
|
1481 else |
|
1482 // Check that all requested ids are in the results |
|
1483 for( TInt i = 0; i < aRequestedMediaIds.Count(); i++ ) |
|
1484 { |
|
1485 TMPXItemId mpxId; |
|
1486 mpxId.iId1 = aRequestedMediaIds[i]; |
|
1487 mpxId.iId2 = 0; |
|
1488 |
|
1489 TBool found( EFalse ); |
|
1490 for( TInt e = 0; e < aRequestResultMedias.Count(); e++ ) |
|
1491 { |
|
1492 CMPXMedia* media2 = aRequestResultMedias[e]; |
|
1493 if( media2 ) |
|
1494 { |
|
1495 TMPXItemId mpxId2 = *(*media2).Value<TMPXItemId>( KMPXMediaGeneralId ); |
|
1496 |
|
1497 if( mpxId == mpxId2 ) |
|
1498 { |
|
1499 found = ETrue; |
|
1500 } |
|
1501 } |
|
1502 } |
|
1503 |
|
1504 if( !found ) |
|
1505 { |
|
1506 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Requested media not found from results!"); |
|
1507 User::Leave( KErrCorrupt ); |
|
1508 } |
|
1509 } |
|
1510 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CheckRequestMediaArrayL"); |
|
1511 } |
|
1512 |
|
1513 // ----------------------------------------------------------------------------- |
|
1514 // CVCXMyVideosCollectionPluginTester::HandleCollectionMessage |
|
1515 // ----------------------------------------------------------------------------- |
1463 // ----------------------------------------------------------------------------- |
1516 // |
1464 // |
1517 void CVCXMyVideosCollectionPluginTester::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError ) |
1465 void CVCXMyVideosCollectionPluginTester::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError ) |
1518 { |
1466 { |
1519 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMessage"); |
1467 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::HandleCollectionMessage"); |
2732 |
2700 |
2733 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL"); |
2701 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteMediaByMpxIdL"); |
2734 } |
2702 } |
2735 |
2703 |
2736 // ----------------------------------------------------------------------------- |
2704 // ----------------------------------------------------------------------------- |
2737 // CVCXMyVideosCollectionPluginTester::CancelDeleteL |
2705 // CVcxMyVideosCollectionTester::CancelDeleteL |
2738 // ----------------------------------------------------------------------------- |
2706 // ----------------------------------------------------------------------------- |
2739 // |
2707 // |
2740 void CVCXMyVideosCollectionPluginTester::CancelDeleteL( TBool aSync ) |
2708 void CVCXMyVideosCollectionPluginTester::CancelDeleteL( TBool aSync ) |
2741 { |
2709 { |
2742 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDeleteL"); |
2710 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDeleteL"); |
2743 |
2711 |
2744 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDelete, aSync ); |
2712 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDelete, aSync ); |
2745 |
2713 TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel delete") ) ); |
|
2714 iCurrentActionHasResponse = EFalse; |
2746 iCollectionUtility->Collection().CommandL( *cmd ); |
2715 iCollectionUtility->Collection().CommandL( *cmd ); |
2747 CleanupStack::PopAndDestroy( cmd ); |
2716 CleanupStack::PopAndDestroy( cmd ); |
2748 |
2717 |
2749 iCancelRequested = ETrue; |
2718 iCancelRequested = ETrue; |
2750 |
2719 |
2751 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDeleteL"); |
2720 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDeleteL"); |
2752 } |
2721 } |
2753 |
2722 |
2754 // ----------------------------------------------------------------------------- |
2723 // ----------------------------------------------------------------------------- |
2755 // CVCXMyVideosCollectionPluginTester::CreateAlbumL |
2724 // CVcxMyVideosCollectionTester::SetAutomaticRefresh |
2756 // ----------------------------------------------------------------------------- |
2725 // ----------------------------------------------------------------------------- |
2757 // |
2726 // |
2758 void CVCXMyVideosCollectionPluginTester::CreateAlbumL( const TDesC& aName, TBool aSync, TBool aInvalidCmd ) |
2727 void CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh( TBool aValue ) |
2759 { |
2728 { |
2760 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CreateAlbumL"); |
2729 iAutomaticContentRefresh = aValue; |
2761 |
2730 } |
2762 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosAddAlbum, aSync ); |
2731 |
2763 |
2732 // ----------------------------------------------------------------------------- |
2764 if( !aInvalidCmd ) |
2733 // CVcxMyVideosCollectionTester::IsRefreshing |
2765 { |
2734 // ----------------------------------------------------------------------------- |
2766 cmd->SetTextValueL( KMPXMediaGeneralTitle, aName ); |
2735 // |
2767 } |
2736 TBool CVCXMyVideosCollectionPluginTester::IsRefreshing() |
2768 |
2737 { |
|
2738 return iRefreshingCollection; |
|
2739 } |
|
2740 // ----------------------------------------------------------------------------- |
|
2741 // CVcxMyVideosCollectionTester::SetQuietMode |
|
2742 // ----------------------------------------------------------------------------- |
|
2743 // |
|
2744 void CVCXMyVideosCollectionPluginTester::SetQuietMode( TBool aValue ) |
|
2745 { |
|
2746 iQuietMode = aValue; |
|
2747 } |
|
2748 |
|
2749 // ----------------------------------------------------------------------------- |
|
2750 // CVcxMyVideosCollectionTester::StartDownloadL |
|
2751 // ----------------------------------------------------------------------------- |
|
2752 // |
|
2753 void CVCXMyVideosCollectionPluginTester::StartDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId, |
|
2754 TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword, |
|
2755 CMPXMedia* aMedia ) |
|
2756 { |
|
2757 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::StartDownloadL"); |
|
2758 |
|
2759 iUpdateDownloads = ETrue; |
|
2760 iDownloadsStarted = ETrue; |
|
2761 |
|
2762 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync ); |
|
2763 |
|
2764 CMPXMedia* startDownloadReq(NULL); |
|
2765 if( !aMedia ) |
|
2766 { |
|
2767 startDownloadReq = CMPXMedia::NewL(); |
|
2768 CleanupStack::PushL( startDownloadReq ); |
|
2769 } |
|
2770 else |
|
2771 { |
|
2772 startDownloadReq = aMedia; |
|
2773 } |
|
2774 |
|
2775 //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId ); |
|
2776 startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 ); |
|
2777 |
|
2778 // read only iap needed? |
|
2779 TUint flags = EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent; |
|
2780 |
|
2781 startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags ); |
|
2782 |
|
2783 VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: UserName: %S, Password: %S.", &aUserName, &aPassword); |
|
2784 |
|
2785 startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aTitle ); |
|
2786 startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl ); |
|
2787 startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName); |
|
2788 startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword); |
|
2789 |
|
2790 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq ); |
|
2791 |
|
2792 iDlWatcher->CreateDownloadL( aIapId, aServiceId, aContentId, aUrl, aSync, aUserName, aPassword ); |
|
2793 |
|
2794 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command."); |
2769 iCollectionUtility->Collection().CommandL( *cmd ); |
2795 iCollectionUtility->Collection().CommandL( *cmd ); |
|
2796 |
|
2797 if( !aMedia ) |
|
2798 { |
|
2799 CleanupStack::PopAndDestroy( startDownloadReq ); |
|
2800 } |
|
2801 |
2770 CleanupStack::PopAndDestroy( cmd ); |
2802 CleanupStack::PopAndDestroy( cmd ); |
2771 |
2803 |
2772 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CreateAlbumL"); |
2804 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::StartDownloadL"); |
2773 } |
2805 } |
2774 |
2806 |
2775 // ----------------------------------------------------------------------------- |
2807 // ----------------------------------------------------------------------------- |
2776 // CVCXMyVideosCollectionPluginTester::DeleteAlbumsL |
2808 // CVcxMyVideosCollectionTester::ResumeDownloadL |
2777 // ----------------------------------------------------------------------------- |
2809 // ----------------------------------------------------------------------------- |
2778 // |
2810 // |
2779 void CVCXMyVideosCollectionPluginTester::DeleteAlbumsL( RArray<TPtrC>& aAlbumNames ) |
2811 void CVCXMyVideosCollectionPluginTester::ResumeDownloadL( const TDesC& aTitle, TInt aIapId, TInt aServiceId, |
2780 { |
2812 TInt aContentId, const TDesC& aUrl, TBool aSync, const TDesC& aUserName, const TDesC& aPassword, |
2781 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAlbumsL"); |
2813 CMPXMedia* aMedia |
2782 |
2814 ) |
2783 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
2815 { |
2784 CleanupStack::PushL( array ); |
2816 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeDownloadL"); |
2785 |
2817 |
2786 for( int i = 0; i < aAlbumNames.Count(); i++ ) |
2818 iUpdateDownloads = ETrue; |
2787 { |
2819 iDownloadsStarted = ETrue; |
2788 TMPXItemId albumId; |
2820 |
2789 TRAPD(err, albumId = GetAlbumIdL( aAlbumNames[i] )); |
2821 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosStartDownload, aSync ); |
2790 if( err == KErrNone ) |
2822 |
2791 { |
2823 CMPXMedia* startDownloadReq(NULL); |
2792 CMPXMedia* album = CMPXMedia::NewL(); |
2824 if( !aMedia ) |
2793 CleanupStack::PushL( album ); |
2825 { |
2794 album->SetTObjectValueL( KMPXMediaGeneralId, albumId ); |
2826 startDownloadReq = CMPXMedia::NewL(); |
2795 array->AppendL( *album ); |
2827 CleanupStack::PushL( startDownloadReq ); |
2796 CleanupStack::PopAndDestroy( album ); |
2828 } |
2797 } |
2829 else |
2798 } |
2830 { |
2799 |
2831 startDownloadReq = aMedia; |
2800 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveAlbums, EFalse ); |
2832 } |
2801 |
2833 |
2802 cmd->SetCObjectValueL( KMPXMediaArrayContents, array ); |
2834 //startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, aIapId ); |
2803 |
2835 startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosIapId, 0 ); |
|
2836 |
|
2837 // read only iap needed? |
|
2838 TUint flags = EVcxMyVideosServiceHasReadOnlyIap | EVcxMyVideosSilent; |
|
2839 |
|
2840 startDownloadReq->SetTObjectValueL( KMPXMediaGeneralFlags, flags ); |
|
2841 |
|
2842 startDownloadReq->SetTextValueL( KMPXMediaGeneralTitle, aTitle ); |
|
2843 startDownloadReq->SetTextValueL( KVcxMediaMyVideosRemoteUrl, aUrl ); |
|
2844 startDownloadReq->SetTextValueL( KVcxMediaMyVideosUsername, aUserName); |
|
2845 startDownloadReq->SetTextValueL( KVcxMediaMyVideosPassword, aPassword); |
|
2846 |
|
2847 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, startDownloadReq ); |
|
2848 |
|
2849 CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl ); |
|
2850 if( dl ) |
|
2851 { |
|
2852 startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId ); |
|
2853 |
|
2854 TMPXItemId itemId; |
|
2855 itemId.iId1 = dl->iMpxId; |
|
2856 itemId.iId2 = 0; |
|
2857 startDownloadReq->SetTObjectValueL( KMPXMediaGeneralId, itemId ); |
|
2858 |
|
2859 dl->iInformed = EFalse; |
|
2860 dl->iWaitingPause = EFalse; |
|
2861 } |
|
2862 else |
|
2863 { |
|
2864 startDownloadReq->SetTObjectValueL( KVcxMediaMyVideosDownloadId, 6666 ); |
|
2865 iDlWatcher->CreateDownloadL( aIapId, aServiceId, aContentId, aUrl, aSync, aUserName, aPassword ); |
|
2866 } |
|
2867 |
|
2868 EnsureMediaFilesAreNotInUseL(); |
|
2869 |
|
2870 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command."); |
|
2871 TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Resume download") ) ); |
|
2872 iCurrentActionHasResponse = EFalse; |
2804 iCollectionUtility->Collection().CommandL( *cmd ); |
2873 iCollectionUtility->Collection().CommandL( *cmd ); |
2805 |
2874 |
|
2875 if( !aMedia ) |
|
2876 { |
|
2877 CleanupStack::PopAndDestroy( startDownloadReq ); |
|
2878 } |
|
2879 |
2806 CleanupStack::PopAndDestroy( cmd ); |
2880 CleanupStack::PopAndDestroy( cmd ); |
2807 CleanupStack::PopAndDestroy( array ); |
2881 |
2808 |
2882 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeDownloadL"); |
2809 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAlbumsL"); |
2883 } |
2810 } |
2884 |
2811 |
2885 // ----------------------------------------------------------------------------- |
2812 // ----------------------------------------------------------------------------- |
2886 // CVcxMyVideosCollectionTester::ResumeAllDownloadsL |
2813 // CVCXMyVideosCollectionPluginTester::DeleteAllAlbumL |
2887 // ----------------------------------------------------------------------------- |
2814 // ----------------------------------------------------------------------------- |
2888 // |
2815 // |
2889 void CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL() |
2816 void CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL() |
2890 { |
2817 { |
2891 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL"); |
2818 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL"); |
2892 |
2819 |
2893 iUpdateDownloads = ETrue; |
2820 CMPXMediaArray* array = CMPXMediaArray::NewL(); |
2894 iDownloadsStarted = ETrue; |
2821 CleanupStack::PushL( array ); |
2895 |
2822 CMPXMedia* album; |
2896 for( TInt i = 0; i < iDlWatcher->GetDownloadCount(); i++ ) |
2823 |
2897 { |
2824 for( TInt i = 0; i < iAlbumIds.Count(); i++ ) |
2898 CVCXMyVideosTestDownload* dl; |
2825 { |
2899 dl = iDlWatcher->GetDownloadByIndex( i ); |
2826 // don't remove photos albums |
2900 if( dl && dl->iState == EVcxMyVideosDlStatePaused ) |
2827 if( iAlbumIds[i].iId1 > 2 ) |
2901 { |
2828 { |
2902 ResumeDownloadL( _L("resume"), dl->iIapId, dl->iServiceId, dl->iContentId, *dl->iUrl, dl->iSyncCall, *dl->iUserName, *dl->iPassword, NULL ); |
2829 album = CMPXMedia::NewL(); |
2903 } |
2830 CleanupStack::PushL( album ); |
2904 } |
2831 album->SetTObjectValueL( KMPXMediaGeneralId, iAlbumIds[i] ); |
2905 |
2832 array->AppendL( *album ); |
2906 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::ResumeAllDownloadsL"); |
2833 CleanupStack::PopAndDestroy( album ); |
2907 } |
2834 } |
2908 |
2835 } |
2909 // ----------------------------------------------------------------------------- |
2836 |
2910 // CVcxMyVideosCollectionTester::CancelDownloadL |
2837 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveAlbums, EFalse ); |
2911 // ----------------------------------------------------------------------------- |
2838 |
2912 // |
2839 cmd->SetCObjectValueL( KMPXMediaArrayContents, array ); |
2913 void CVCXMyVideosCollectionPluginTester::CancelDownloadL( CVCXMyVideosTestDownload* aDownload, TBool aSync ) |
2840 |
2914 { |
|
2915 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL"); |
|
2916 |
|
2917 if( !aDownload ) |
|
2918 { |
|
2919 User::Leave( KErrArgument ); |
|
2920 } |
|
2921 |
|
2922 iUpdateDownloads = ETrue; |
|
2923 |
|
2924 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync ); |
|
2925 |
|
2926 CMPXMedia* cancelDownloadReq = CMPXMedia::NewL(); |
|
2927 CleanupStack::PushL( cancelDownloadReq ); |
|
2928 |
|
2929 cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( aDownload->iMpxId, 0 ) ); |
|
2930 cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, aDownload->iDownloadId ); |
|
2931 cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, aDownload->iPath->Des() ); |
|
2932 |
|
2933 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq ); |
|
2934 |
|
2935 iDlWatcher->CancelDownloadL( aDownload->iServiceId, aDownload->iContentId, *aDownload->iUrl ); |
|
2936 |
|
2937 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command."); |
|
2938 TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel download") ) ); |
|
2939 iCurrentActionHasResponse = EFalse; |
2841 iCollectionUtility->Collection().CommandL( *cmd ); |
2940 iCollectionUtility->Collection().CommandL( *cmd ); |
2842 |
2941 |
|
2942 CleanupStack::PopAndDestroy( cancelDownloadReq ); |
2843 CleanupStack::PopAndDestroy( cmd ); |
2943 CleanupStack::PopAndDestroy( cmd ); |
2844 CleanupStack::PopAndDestroy( array ); |
2944 |
2845 |
2945 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL"); |
2846 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::DeleteAllAlbumsL"); |
2946 } |
2847 } |
2947 |
2848 |
2948 // ----------------------------------------------------------------------------- |
2849 // ----------------------------------------------------------------------------- |
2949 // CVcxMyVideosCollectionTester::CancelDownloadL |
2850 // CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL |
2950 // ----------------------------------------------------------------------------- |
2851 // ----------------------------------------------------------------------------- |
2951 // |
2852 // |
2952 void CVCXMyVideosCollectionPluginTester::CancelDownloadL( TInt aMpxId, TInt aDownloadId, const TPtrC& aDownloadPath, TBool aSync ) |
2853 void CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL( const TDesC& aAlbumName, TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex ) |
2953 { |
2854 { |
2954 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::CancelDownloadL (by IDs)"); |
2855 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL"); |
2955 |
2856 |
2956 iUpdateDownloads = ETrue; |
2857 TMPXItemId albumId = GetAlbumIdL( aAlbumName ); |
2957 |
2858 |
2958 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosCancelDownload, aSync ); |
2859 CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex ); |
2959 |
2860 CleanupStack::PushL( medias ); |
2960 CMPXMedia* cancelDownloadReq = CMPXMedia::NewL(); |
2861 |
2961 CleanupStack::PushL( cancelDownloadReq ); |
2862 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosAddToAlbum, EFalse ); |
2962 |
2863 if( medias ) |
2963 CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByIndex(0); |
2864 { |
2964 |
2865 cmd->SetCObjectValueL( KMPXMediaArrayContents, medias ); |
2965 TPtrC downloadPath( aDownloadPath ); |
2866 } |
2966 |
2867 |
2967 if( aMpxId == -1 && dl ) |
2868 cmd->SetTObjectValueL( KVcxMediaMyVideosUint32Value, albumId ); |
2968 { |
2869 |
2969 aMpxId = dl->iMpxId; |
|
2970 } |
|
2971 |
|
2972 if( aDownloadId == -1 && dl ) |
|
2973 { |
|
2974 aDownloadId = dl->iDownloadId; |
|
2975 } |
|
2976 |
|
2977 if( aDownloadPath == _L("NULL") && dl ) |
|
2978 { |
|
2979 downloadPath.Set( *dl->iPath ); |
|
2980 } |
|
2981 |
|
2982 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: mpxId: %d", aMpxId); |
|
2983 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: downloadId: %d", aDownloadId); |
|
2984 VCXLOGLO2("CVCXMyVideosCollectionPluginTester:: downloadPath: %S", &aDownloadPath); |
|
2985 |
|
2986 cancelDownloadReq->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, TMPXItemId ( aMpxId, 0 ) ); |
|
2987 cancelDownloadReq->SetTObjectValueL<TUint32>( KVcxMediaMyVideosDownloadId, aDownloadId ); |
|
2988 cancelDownloadReq->SetTextValueL( KMPXMediaGeneralUri, downloadPath ); |
|
2989 |
|
2990 cmd->SetCObjectValueL<CMPXMedia>( KMPXCommandColAddMedia, cancelDownloadReq ); |
|
2991 |
|
2992 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command."); |
|
2993 TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Cancel download") ) ); |
|
2994 iCurrentActionHasResponse = EFalse; |
2870 iCollectionUtility->Collection().CommandL( *cmd ); |
2995 iCollectionUtility->Collection().CommandL( *cmd ); |
2871 |
2996 |
|
2997 CleanupStack::PopAndDestroy( cancelDownloadReq ); |
2872 CleanupStack::PopAndDestroy( cmd ); |
2998 CleanupStack::PopAndDestroy( cmd ); |
2873 CleanupStack::PopAndDestroy( medias ); |
2999 |
2874 |
3000 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::CancelDownloadL"); |
2875 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::AddMediasToAlbumL"); |
3001 } |
2876 } |
3002 |
2877 |
3003 // ----------------------------------------------------------------------------- |
2878 // ----------------------------------------------------------------------------- |
3004 // CVcxMyVideosCollectionTester::PauseDownloadL |
2879 // CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL |
3005 // ----------------------------------------------------------------------------- |
2880 // ----------------------------------------------------------------------------- |
3006 // |
2881 // |
3007 void CVCXMyVideosCollectionPluginTester::PauseDownloadL( TInt aServiceId, TInt aContentId, const TDesC& aUrl, TBool aSync ) |
2882 void CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL( const TDesC& aAlbumName, TInt aSourceDrive, TInt aStartIndex, TInt aEndIndex ) |
3008 { |
2883 { |
3009 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL"); |
2884 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL"); |
3010 |
2885 |
3011 iUpdateDownloads = ETrue; |
2886 TMPXItemId albumId = GetAlbumIdL( aAlbumName ); |
3012 |
2887 |
3013 CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aServiceId, aContentId, aUrl ); |
2888 CMPXMediaArray* medias = SelectMediasL( aSourceDrive, aStartIndex, aEndIndex ); |
3014 if( dl ) |
2889 CleanupStack::PushL( medias ); |
3015 { |
2890 |
3016 dl->iWaitingPause = ETrue; |
2891 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosRemoveFromAlbum, EFalse ); |
3017 } |
2892 if( medias ) |
3018 else |
2893 { |
3019 { |
2894 cmd->SetCObjectValueL( KMPXMediaArrayContents, medias ); |
3020 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!"); |
2895 } |
3021 User::Leave( KErrNotFound ); |
2896 |
3022 } |
2897 cmd->SetTObjectValueL( KVcxMediaMyVideosUint32Value, albumId ); |
3023 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync ); |
2898 |
3024 |
|
3025 cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId ); |
|
3026 |
|
3027 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command."); |
|
3028 TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) ); |
|
3029 iCurrentActionHasResponse = EFalse; |
2899 iCollectionUtility->Collection().CommandL( *cmd ); |
3030 iCollectionUtility->Collection().CommandL( *cmd ); |
2900 |
3031 |
2901 CleanupStack::PopAndDestroy( cmd ); |
3032 CleanupStack::PopAndDestroy( cmd ); |
2902 CleanupStack::PopAndDestroy( medias ); |
3033 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL"); |
2903 |
3034 } |
2904 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RemoveMediasFromAlbumL"); |
3035 |
2905 } |
3036 // ----------------------------------------------------------------------------- |
2906 |
3037 // CVcxMyVideosCollectionTester::PauseDownloadL |
2907 // ----------------------------------------------------------------------------- |
3038 // ----------------------------------------------------------------------------- |
2908 // CVCXMyVideosCollectionPluginTester::RenameAlbumL |
3039 // |
2909 // ----------------------------------------------------------------------------- |
3040 void CVCXMyVideosCollectionPluginTester::PauseDownloadL( const TDesC& aUrl, TBool aSync ) |
2910 // |
3041 { |
2911 void CVCXMyVideosCollectionPluginTester::RenameAlbumL( const TDesC& aAlbumName, const TDesC& aNewAlbumName ) |
3042 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::PauseDownloadL"); |
2912 { |
3043 |
2913 VCXLOGLO1(">>>CVCXMyVideosCollectionPluginTester::RenameAlbumL"); |
3044 iUpdateDownloads = ETrue; |
2914 |
3045 |
2915 TMPXItemId itemId = GetAlbumIdL( aAlbumName ); |
3046 CMPXCommand* cmd = CreateMpxCommandLC( KVcxCommandIdMyVideos, KVcxCommandMyVideosPauseDownload, aSync ); |
2916 CMPXMedia *media = CMPXMedia::NewL(); |
3047 |
2917 CleanupStack::PushL( media ); |
3048 CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownload( aUrl ); |
2918 media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, itemId ); |
3049 if( !dl ) |
2919 media->SetTextValueL( KMPXMediaGeneralTitle, aNewAlbumName ); |
3050 { |
2920 SetMediaL( media, ETrue ); |
3051 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Download not found!"); |
2921 CleanupStack::PopAndDestroy( media ); |
3052 User::Leave( KErrNotFound ); |
2922 |
3053 } |
2923 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::RenameAlbumL"); |
3054 else |
2924 } |
3055 { |
2925 |
3056 dl->iWaitingPause = ETrue; |
2926 // ----------------------------------------------------------------------------- |
3057 } |
2927 // CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh |
3058 |
2928 // ----------------------------------------------------------------------------- |
3059 |
2929 // |
3060 cmd->SetTObjectValueL( KVcxMediaMyVideosDownloadId, dl->iDownloadId ); |
2930 void CVCXMyVideosCollectionPluginTester::SetAutomaticRefresh( TBool aValue ) |
3061 |
2931 { |
3062 VCXLOGLO1("CVCXMyVideosCollectionPluginTester:: Making command."); |
2932 iAutomaticContentRefresh = aValue; |
3063 TRAP_IGNORE( iStats->ActionStartL( iTransactions->TransactionId(), _L("Pause download") ) ); |
2933 } |
3064 iCurrentActionHasResponse = EFalse; |
2934 |
3065 iCollectionUtility->Collection().CommandL( *cmd ); |
2935 // ----------------------------------------------------------------------------- |
3066 |
2936 // CVCXMyVideosCollectionPluginTester::IsRefreshing |
3067 CleanupStack::PopAndDestroy( cmd ); |
2937 // ----------------------------------------------------------------------------- |
3068 VCXLOGLO1("<<<CVCXMyVideosCollectionPluginTester::PauseDownloadL"); |
2938 // |
3069 } |
2939 TBool CVCXMyVideosCollectionPluginTester::IsRefreshing() |
3070 |
2940 { |
3071 // ----------------------------------------------------------------------------- |
2941 return iRefreshingCollection; |
3072 // CVcxMyVideosCollectionTester::GetDownloadWatcher |
2942 } |
3073 // ----------------------------------------------------------------------------- |
2943 |
3074 // |
2944 // ----------------------------------------------------------------------------- |
3075 CVCXMyVideosTestDlWatcher* CVCXMyVideosCollectionPluginTester::GetDownloadWatcher() |
2945 // CVCXMyVideosCollectionPluginTester::SetQuietMode |
3076 { |
2946 // ----------------------------------------------------------------------------- |
3077 return iDlWatcher; |
2947 // |
3078 } |
2948 void CVCXMyVideosCollectionPluginTester::SetQuietMode( TBool aValue ) |
3079 |
2949 { |
3080 // ----------------------------------------------------------------------------- |
2950 iQuietMode = aValue; |
3081 // CVcxMyVideosCollectionTester::GetActiveDownloadCountL |
2951 } |
3082 // ----------------------------------------------------------------------------- |
2952 |
3083 // |
2953 // ----------------------------------------------------------------------------- |
3084 TInt CVCXMyVideosCollectionPluginTester::GetActiveDownloadCountL() |
2954 // CVCXMyVideosCollectionPluginTester::GetCurrentLevel |
3085 { |
|
3086 TInt count = 0; |
|
3087 |
|
3088 CMPXMedia* media ( NULL ); |
|
3089 for( TInt i = 0; i < iMediaArray->Count(); i++ ) |
|
3090 { |
|
3091 media = (*iMediaArray)[i]; |
|
3092 |
|
3093 if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) |
|
3094 { |
|
3095 TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
3096 |
|
3097 if( state == EVcxMyVideosDlStateDownloading || ( state == EVcxMyVideosDlStatePaused && iAutoResume ) ) |
|
3098 { |
|
3099 count++; |
|
3100 } |
|
3101 } |
|
3102 } |
|
3103 |
|
3104 VCXLOGLO2(">>>CVCXMyVideosCollectionPluginTester:: Active downloads: %d", count); |
|
3105 |
|
3106 return count; |
|
3107 } |
|
3108 |
|
3109 // ----------------------------------------------------------------------------- |
|
3110 // CVcxMyVideosCollectionTester::SetAutoResume |
|
3111 // ----------------------------------------------------------------------------- |
|
3112 // |
|
3113 void CVCXMyVideosCollectionPluginTester::SetAutoResume( TBool aValue ) |
|
3114 { |
|
3115 iAutoResume = aValue; |
|
3116 } |
|
3117 |
|
3118 // ----------------------------------------------------------------------------- |
|
3119 // CVcxMyVideosCollectionTester::GetCurrentLevel |
2955 // ----------------------------------------------------------------------------- |
3120 // ----------------------------------------------------------------------------- |
2956 // |
3121 // |
2957 TInt CVCXMyVideosCollectionPluginTester::GetCurrentLevel() |
3122 TInt CVCXMyVideosCollectionPluginTester::GetCurrentLevel() |
2958 { |
3123 { |
2959 if ( iCollectionUtility ) |
3124 if ( iCollectionUtility ) |
3093 } |
3258 } |
3094 return count; |
3259 return count; |
3095 } |
3260 } |
3096 |
3261 |
3097 // ----------------------------------------------------------------------------- |
3262 // ----------------------------------------------------------------------------- |
3098 // CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia |
3263 // CVcxMyVideosCollectionTester::GetAllCollectionMedia |
3099 // ----------------------------------------------------------------------------- |
3264 // ----------------------------------------------------------------------------- |
3100 // |
3265 // |
3101 const CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia() |
3266 const CMPXMediaArray* CVCXMyVideosCollectionPluginTester::GetAllCollectionMedia() |
3102 { |
3267 { |
3103 return iCollectionMediaArray; |
3268 return iCollectionMediaArray; |
3104 } |
3269 } |
3105 |
3270 |
3106 // ----------------------------------------------------------------------------- |
3271 // ----------------------------------------------------------------------------- |
3107 // CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL |
3272 // CVcxMyVideosCollectionTester::EnsureMediaFilesAreNotInUseL |
3108 // ----------------------------------------------------------------------------- |
3273 // ----------------------------------------------------------------------------- |
3109 // |
3274 // |
3110 void CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL() |
3275 void CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL() |
3111 { |
3276 { |
3112 CMPXMediaArray* iSourceMedias; |
3277 if( iMediaArray->Count() <= 0 ) return; |
3113 |
|
3114 if( !iUseCopiedMedias ) |
|
3115 { |
|
3116 if( !iMediaArray ) |
|
3117 { |
|
3118 User::Leave( KErrNotReady ); |
|
3119 } |
|
3120 iSourceMedias = iMediaArray; |
|
3121 } |
|
3122 else |
|
3123 { |
|
3124 if( !iMediaArrayCopy ) |
|
3125 { |
|
3126 User::Leave( KErrNotReady ); |
|
3127 } |
|
3128 iSourceMedias = iMediaArrayCopy; |
|
3129 } |
|
3130 |
|
3131 if( iSourceMedias->Count() <= 0 ) return; |
|
3132 |
3278 |
3133 TInt retries = 200; |
3279 TInt retries = 200; |
3134 RFile64 file; |
3280 RFile64 file; |
3135 TInt error( KErrNone ); |
3281 TInt error( KErrInUse ); |
|
3282 |
|
3283 const TInt KEnsureMediasNotInUseID = 1234567; |
|
3284 |
|
3285 TRAP_IGNORE( iStats->ActionStartL( KEnsureMediasNotInUseID, _L("Ensure files.") ) ); |
3136 |
3286 |
3137 TBool filesLocked( ETrue ); |
3287 TBool filesLocked( ETrue ); |
3138 // Check all files that they are not in use, retry few times. |
3288 // Check all files that they are not in use, retry few times. |
3139 while( --retries >= 0 && filesLocked ) |
3289 while( --retries >= 0 && filesLocked ) |
3140 { |
3290 { |
3141 filesLocked = EFalse; |
3291 filesLocked = EFalse; |
3142 |
3292 |
3143 for( TInt i=0; i<iSourceMedias->Count(); i++ ) |
3293 for( TInt i=0; i<iMediaArray->Count(); i++ ) |
3144 { |
3294 { |
3145 CMPXMedia* media = (*iSourceMedias)[i]; |
3295 CMPXMedia* media = (*iMediaArray)[i]; |
3146 |
3296 |
3147 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
3297 if( media->IsSupported( KMPXMediaGeneralUri ) ) |
3148 { |
3298 { |
3149 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri ); |
3299 const TDesC& localFilePath = media->ValueText( KMPXMediaGeneralUri ); |
3150 |
3300 |
3151 TInt err = file.Open( iFs, localFilePath, EFileShareExclusive ); |
3301 error = file.Open( iFs, localFilePath, EFileShareExclusive ); |
3152 if( err == KErrInUse || err == KErrLocked ) |
3302 if( error == KErrInUse || error == KErrLocked ) |
3153 { |
3303 { |
3154 error = err; |
|
3155 filesLocked = ETrue; |
3304 filesLocked = ETrue; |
3156 User::After( 1000000 * 5 ); // Wait |
3305 User::After( 1000000 * 5 ); // Wait |
3157 break; |
3306 break; |
3158 } |
3307 } |
3159 file.Close(); |
3308 file.Close(); |
3160 } |
3309 } |
3161 } |
3310 } |
3162 |
|
3163 if(!filesLocked) |
|
3164 { |
|
3165 error = KErrNone; |
|
3166 } |
|
3167 } |
3311 } |
3168 |
3312 |
3169 if( error != KErrNone && error != KErrNotFound && error != KErrBadName ) |
3313 if( error != KErrNone && error != KErrNotFound && error != KErrBadName ) |
3170 { |
3314 { |
|
3315 TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, error ) ); |
3171 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: error: %d", error); |
3316 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: error: %d", error); |
3172 User::Leave( error ); |
3317 User::Leave( error ); |
3173 } |
3318 } |
|
3319 else |
|
3320 { |
|
3321 TRAP_IGNORE( iStats->ActionEndL( KEnsureMediasNotInUseID, KErrNone ) ); |
|
3322 } |
3174 |
3323 |
3175 VCXLOGLO1("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: All ok."); |
3324 VCXLOGLO1("CVCXMyVideosCollectionPluginTester::EnsureMediaFilesAreNotInUseL: All ok."); |
3176 } |
3325 } |
3177 |
3326 |
|
3327 // ----------------------------------------------------------------------------- |
|
3328 // CVCXMyVideosCollectionPluginTester::TimerComplete |
|
3329 // ----------------------------------------------------------------------------- |
|
3330 // |
|
3331 void CVCXMyVideosCollectionPluginTester::TimerComplete( TInt /* aTimerId */, TInt /* aError */ ) |
|
3332 { |
|
3333 if( iProgressTimer ) |
|
3334 { |
|
3335 iProgressTimer->After( 1000000 ); |
|
3336 } |
|
3337 |
|
3338 if( !iMediaArray || !iDlWatcher ) |
|
3339 { |
|
3340 return; |
|
3341 } |
|
3342 |
|
3343 if( iDownloadsStarted && iUpdateDownloads && GetCurrentLevel() == 3 ) |
|
3344 { |
|
3345 // Print short info about downloads |
|
3346 CMPXMedia* media( NULL ); |
|
3347 |
|
3348 VCXLOGLO2("CVCXMyVideosCollectionPluginTester::TimerComplete: medias: %d", iMediaArray->Count()); |
|
3349 for( TInt i = 0; i < iMediaArray->Count(); i++ ) |
|
3350 { |
|
3351 media = (*iMediaArray)[i]; |
|
3352 |
|
3353 if( media->IsSupported( KVcxMediaMyVideosDownloadState ) ) |
|
3354 { |
|
3355 TInt state = media->ValueTObjectL<TUint8>( KVcxMediaMyVideosDownloadState ); |
|
3356 |
|
3357 TMPXItemId itemId = *(media->Value<TMPXItemId>( KMPXMediaGeneralId )); |
|
3358 |
|
3359 TInt progress = -1; |
|
3360 if( media->IsSupported( KVcxMediaMyVideosDownloadProgress ) ) |
|
3361 { |
|
3362 progress = media->ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress ); |
|
3363 } |
|
3364 |
|
3365 TUint32 downloadId = 0; |
|
3366 if( media->IsSupported( KVcxMediaMyVideosDownloadId ) ) |
|
3367 { |
|
3368 downloadId = media->ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ); |
|
3369 } |
|
3370 |
|
3371 CVCXMyVideosTestDownload* dl = iDlWatcher->GetDownloadByMpxId( itemId.iId1 ); |
|
3372 |
|
3373 if( dl ) |
|
3374 { |
|
3375 // VCXLOGLO5("CVCXMyVideosCollectionPluginTester:: DL ID: %d, MPX ID: %d, state: %d, progress: %d", downloadId, itemId.iId1, state, progress ); |
|
3376 // VCXLOGLO3("CVCXMyVideosCollectionPluginTester:: serviceId: %d, contentId: %d", dl->iServiceId, dl->iContentId ); |
|
3377 iDlWatcher->UpdateDownloadProgressL( itemId.iId1, downloadId, progress ); |
|
3378 } |
|
3379 } |
|
3380 } |
|
3381 } |
|
3382 } |
3178 // End of File |
3383 // End of File |