videocollection/hgmyvideos/src/vcxhgmyvideosvideomodelhandler.cpp
branchRCL_3
changeset 9 5294c000a26d
parent 8 ce5ada96ab30
child 10 112a725ff2c2
equal deleted inserted replaced
8:ce5ada96ab30 9:5294c000a26d
   140 //
   140 //
   141 CVcxHgMyVideosVideoModelHandler::~CVcxHgMyVideosVideoModelHandler()
   141 CVcxHgMyVideosVideoModelHandler::~CVcxHgMyVideosVideoModelHandler()
   142     {
   142     {
   143     iResumeArray.Close();
   143     iResumeArray.Close();
   144     
   144     
       
   145     delete iVideoDetails;
   145     delete iVideoIndicator;
   146     delete iVideoIndicator;
   146     delete iDataUpdater;
   147     delete iDataUpdater;
   147     delete iDownloadUpdater;
   148     delete iDownloadUpdater;
   148     delete iVideoArray;
   149     delete iVideoArray;
   149     }
   150     }
   485         }
   486         }
   486     return KNullDesC;
   487     return KNullDesC;
   487     }
   488     }
   488 
   489 
   489 // -----------------------------------------------------------------------------
   490 // -----------------------------------------------------------------------------
       
   491 // CVcxHgMyVideosVideoModelHandler::GetVideoId()
       
   492 // -----------------------------------------------------------------------------
       
   493 //
       
   494 TInt CVcxHgMyVideosVideoModelHandler::GetVideoId( TInt aIndex )
       
   495     {
       
   496     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   497 
       
   498     if ( media && media->IsSupported( KMPXMediaGeneralId ) )
       
   499         {
       
   500         return media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ).iId1;
       
   501         }
       
   502     
       
   503     return KErrNotFound;
       
   504     }
       
   505 
       
   506 // -----------------------------------------------------------------------------
   490 // CVcxHgMyVideosVideoModelHandler::GetVideoSize()
   507 // CVcxHgMyVideosVideoModelHandler::GetVideoSize()
   491 // -----------------------------------------------------------------------------
   508 // -----------------------------------------------------------------------------
   492 //
   509 //
   493 TInt64 CVcxHgMyVideosVideoModelHandler::GetVideoSize( TInt aIndex )
   510 TInt64 CVcxHgMyVideosVideoModelHandler::GetVideoSize( TInt aIndex )
   494     {
   511     {
   514     CMPXMediaArray* mediasToDelete = CMPXMediaArray::NewL();
   531     CMPXMediaArray* mediasToDelete = CMPXMediaArray::NewL();
   515     CleanupStack::PushL( mediasToDelete );
   532     CleanupStack::PushL( mediasToDelete );
   516 
   533 
   517     for ( TInt i = 0; i < aOperationTargets.Count(); i++ )
   534     for ( TInt i = 0; i < aOperationTargets.Count(); i++ )
   518         {
   535         {
   519         media = iVideoArray->MPXMedia( aOperationTargets[i] );
   536         media = iVideoArray->MPXMediaByMPXItemId( TMPXItemId(aOperationTargets[i],0) );
   520 
   537 
   521         if ( media && media->IsSupported( KMPXMediaGeneralId ) )
   538         if ( media && media->IsSupported( KMPXMediaGeneralId ) )
   522             {
   539             {
   523             mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
   540             mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
   524             mediaToDelete = CMPXMedia::NewL();
   541             mediaToDelete = CMPXMedia::NewL();
   525             CleanupStack::PushL( mediaToDelete );
   542             CleanupStack::PushL( mediaToDelete );
   526             mediaToDelete->SetTObjectValueL( KMPXMediaGeneralId, mpxItemId );
   543             mediaToDelete->SetTObjectValueL( KMPXMediaGeneralId, mpxItemId );
   527             mediasToDelete->AppendL( *mediaToDelete );
   544             mediasToDelete->AppendL( *mediaToDelete );
   528             CleanupStack::PopAndDestroy( mediaToDelete );
   545             CleanupStack::PopAndDestroy( mediaToDelete );
   529             }
   546             iDataUpdater->PrepareForMoveOrDelete( mpxItemId );
       
   547             }
       
   548         }
       
   549 
       
   550     if ( mediasToDelete->Count() <= 0 )
       
   551         {
       
   552 		User::Leave( KErrNotFound );
   530         }
   553         }
   531 
   554 
   532     TRAPD( err, iModel.CollectionClient().DeleteVideosL( mediasToDelete ) );
   555     TRAPD( err, iModel.CollectionClient().DeleteVideosL( mediasToDelete ) );
   533     	
   556     	
   534     if ( err != KErrNone )
   557     if ( err != KErrNone )
   557     CMPXMediaArray* mediasToMoveOrCopy = CMPXMediaArray::NewL();
   580     CMPXMediaArray* mediasToMoveOrCopy = CMPXMediaArray::NewL();
   558     CleanupStack::PushL( mediasToMoveOrCopy );
   581     CleanupStack::PushL( mediasToMoveOrCopy );
   559 
   582 
   560     for ( TInt i = 0; i < aOperationTargets.Count(); i++ )
   583     for ( TInt i = 0; i < aOperationTargets.Count(); i++ )
   561         {
   584         {
   562         media = iVideoArray->MPXMedia( aOperationTargets[i] );
   585         media = iVideoArray->MPXMediaByMPXItemId( TMPXItemId(aOperationTargets[i],0) );
   563                     
   586                     
   564         if ( media && media->IsSupported( KMPXMediaGeneralId ) )
   587         if ( media && media->IsSupported( KMPXMediaGeneralId ) )
   565             {
   588             {
   566             mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
   589             mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
   567             mediaToMoveOrCopy = CMPXMedia::NewL();
   590             mediaToMoveOrCopy = CMPXMedia::NewL();
   568             CleanupStack::PushL( mediaToMoveOrCopy );
   591             CleanupStack::PushL( mediaToMoveOrCopy );
   569             mediaToMoveOrCopy->SetTObjectValueL( KMPXMediaGeneralId, mpxItemId );
   592             mediaToMoveOrCopy->SetTObjectValueL( KMPXMediaGeneralId, mpxItemId );
   570             mediasToMoveOrCopy->AppendL( *mediaToMoveOrCopy );
   593             mediasToMoveOrCopy->AppendL( *mediaToMoveOrCopy );
   571             CleanupStack::PopAndDestroy( mediaToMoveOrCopy );
   594             CleanupStack::PopAndDestroy( mediaToMoveOrCopy );
   572             }
   595             iDataUpdater->PrepareForMoveOrDelete( mpxItemId );
   573         }
   596             }
   574 
   597         }
       
   598 
       
   599     if ( mediasToMoveOrCopy->Count() <= 0 )
       
   600         {
       
   601 		User::Leave( KErrNotFound );
       
   602         }
       
   603 		
   575     iModel.CollectionClient().MoveOrCopyVideosL( mediasToMoveOrCopy, aTargetDrive, aCopy );
   604     iModel.CollectionClient().MoveOrCopyVideosL( mediasToMoveOrCopy, aTargetDrive, aCopy );
       
   605 
   576     CleanupStack::PopAndDestroy( mediasToMoveOrCopy );    
   606     CleanupStack::PopAndDestroy( mediasToMoveOrCopy );    
   577     }
   607     }
   578 
   608 
   579 // -----------------------------------------------------------------------------
   609 // -----------------------------------------------------------------------------
   580 // CVcxHgMyVideosVideoModelHandler::PlayVideoL()
   610 // CVcxHgMyVideosVideoModelHandler::PlayVideoL()
  1380 // MPX Collection calls this callback when details fetching is completed.
  1410 // MPX Collection calls this callback when details fetching is completed.
  1381 // -----------------------------------------------------------------------------
  1411 // -----------------------------------------------------------------------------
  1382 // 
  1412 // 
  1383 void CVcxHgMyVideosVideoModelHandler::VideoDetailsCompletedL( const CMPXMedia& aMedia )
  1413 void CVcxHgMyVideosVideoModelHandler::VideoDetailsCompletedL( const CMPXMedia& aMedia )
  1384     {
  1414     {
       
  1415     if ( !iVideoDetails )
       
  1416         {
       
  1417 	    iVideoDetails = CVcxHgMyVideosVideoDetailsDialog::NewL();
       
  1418         }
  1385     iVideoDetails->ShowVideoDetailsDialogL( aMedia );
  1419     iVideoDetails->ShowVideoDetailsDialogL( aMedia );
  1386     }
  1420     }
  1387 
  1421 
  1388 // -----------------------------------------------------------------------------
  1422 // -----------------------------------------------------------------------------
  1389 // CVcxHgMyVideosVideoModelHandler::UpdateScrollbarTypeL()
  1423 // CVcxHgMyVideosVideoModelHandler::UpdateScrollbarTypeL()