videocollection/hgmyvideos/src/vcxhgmyvideosvideomodelhandler.cpp
branchRCL_3
changeset 15 8f0df5c82986
parent 14 55fa1ec415c6
child 18 baf439b22ddd
equal deleted inserted replaced
14:55fa1ec415c6 15:8f0df5c82986
    29 
    29 
    30 #include <vcxhgmyvideos.rsg>
    30 #include <vcxhgmyvideos.rsg>
    31 #include <vcxmyvideosdefs.h>
    31 #include <vcxmyvideosdefs.h>
    32 #include <MPFileDetailsDialog.h>
    32 #include <MPFileDetailsDialog.h>
    33 #include <myvideosindicator.h>
    33 #include <myvideosindicator.h>
       
    34 #include <centralrepository.h>
       
    35 
    34 #include "IptvDebug.h"
    36 #include "IptvDebug.h"
    35 
    37 
    36 #include "vcxhgmyvideosmodel.h"
    38 #include "vcxhgmyvideosmodel.h"
    37 #include "vcxhgmyvideosmainview.h"
    39 #include "vcxhgmyvideosmainview.h"
    38 #include "vcxhgmyvideoscollectionclient.h"
    40 #include "vcxhgmyvideoscollectionclient.h"
    39 #include "vcxhgmyvideosdownloadclient.h"
       
    40 #include "vcxhgmyvideosvideomodelhandler.h"
    41 #include "vcxhgmyvideosvideomodelhandler.h"
    41 #include "vcxhgmyvideosvideolistimpl.h"
    42 #include "vcxhgmyvideosvideolistimpl.h"
    42 #include "vcxhgmyvideosvideodataupdater.h"
    43 #include "vcxhgmyvideosvideodataupdater.h"
    43 #include "vcxhgmyvideosdownloadupdater.h"
       
    44 
    44 
    45 #include "vcxhgmyvideos.hrh"
    45 #include "vcxhgmyvideos.hrh"
    46 #include "vcxhgmyvideoslistbase.h"
    46 #include "vcxhgmyvideoslistbase.h"
    47 #include "vcxhgmyvideosindicatorhelper.h"
    47 #include "vcxhgmyvideosindicatorhelper.h"
    48 #include "vcxhgmyvideosvideodetailsdialog.h"
    48 #include "vcxhgmyvideosvideodetailsdialog.h"
   127 
   127 
   128     iDataUpdater = CVcxHgMyVideosVideoDataUpdater::NewL( iModel,
   128     iDataUpdater = CVcxHgMyVideosVideoDataUpdater::NewL( iModel,
   129                                                          iScroller,                                                        
   129                                                          iScroller,                                                        
   130                                                          *iVideoArray );
   130                                                          *iVideoArray );
   131 
   131 
   132     iDownloadUpdater = CVcxHgMyVideosDownloadUpdater::NewL( *this, *iVideoArray );
       
   133     
       
   134     iVideoIndicator = CMyVideosIndicator::NewL();
   132     iVideoIndicator = CMyVideosIndicator::NewL();
   135     }
   133     }
   136 
   134 
   137 // -----------------------------------------------------------------------------
   135 // -----------------------------------------------------------------------------
   138 // Destructor
   136 // Destructor
   139 // -----------------------------------------------------------------------------
   137 // -----------------------------------------------------------------------------
   140 //
   138 //
   141 CVcxHgMyVideosVideoModelHandler::~CVcxHgMyVideosVideoModelHandler()
   139 CVcxHgMyVideosVideoModelHandler::~CVcxHgMyVideosVideoModelHandler()
   142     {
   140     {
   143     iResumeArray.Close();
       
   144     iMarkedMediaList.Close();
   141     iMarkedMediaList.Close();
   145     
   142     
   146     delete iVideoDetails;
   143     delete iVideoDetails;
   147     delete iVideoIndicator;
   144     delete iVideoIndicator;
   148     delete iDataUpdater;
   145     delete iDataUpdater;
   149     delete iDownloadUpdater;
       
   150     delete iVideoArray;
   146     delete iVideoArray;
       
   147 	delete iRepository;
   151     }
   148     }
   152 
   149 
   153 // -----------------------------------------------------------------------------
   150 // -----------------------------------------------------------------------------
   154 // CVcxHgMyVideosVideoModelHandler::DoModelActivateL()
   151 // CVcxHgMyVideosVideoModelHandler::DoModelActivateL()
   155 // -----------------------------------------------------------------------------
   152 // -----------------------------------------------------------------------------
   158     {
   155     {
   159     IPTVLOGSTRING_LOW_LEVEL( 
   156     IPTVLOGSTRING_LOW_LEVEL( 
   160         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::DoModelActivateL() - Enter" );
   157         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::DoModelActivateL() - Enter" );
   161     
   158     
   162     iDataUpdater->SetPausedL( EFalse );
   159     iDataUpdater->SetPausedL( EFalse );
   163     iDownloadUpdater->SetPausedL( EFalse );
       
   164     iModel.CollectionClient().SetVideoModelObserver( this );
   160     iModel.CollectionClient().SetVideoModelObserver( this );
   165 
   161 
   166     // Set scroller strip type
   162     // Set scroller strip type
   167     TVcxMyVideosSortingOrder sortOrder = iModel.VideolistSortOrderL();
   163     TVcxMyVideosSortingOrder sortOrder = iModel.VideolistSortOrderL();
   168     UpdateScrollbarTypeL( sortOrder );
   164     UpdateScrollbarTypeL( sortOrder );
   182     {
   178     {
   183     IPTVLOGSTRING_LOW_LEVEL( 
   179     IPTVLOGSTRING_LOW_LEVEL( 
   184         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::DoModelDeactivate() - Enter" );
   180         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::DoModelDeactivate() - Enter" );
   185     
   181     
   186     TRAP_IGNORE( iDataUpdater->SetPausedL( ETrue ) );
   182     TRAP_IGNORE( iDataUpdater->SetPausedL( ETrue ) );
   187     TRAP_IGNORE( iDownloadUpdater->SetPausedL( ETrue ) );
       
   188     iModel.CollectionClient().SetVideoModelObserver( NULL );
   183     iModel.CollectionClient().SetVideoModelObserver( NULL );
   189     iScroller.DisableScrollBuffer();
   184     iScroller.DisableScrollBuffer();
   190 
   185 
   191     TRAP_IGNORE( SaveFirstListItemIdL() );
   186     TRAP_IGNORE( SaveFirstListItemIdL() );
   192 
   187 
   213     IPTVLOGSTRING_LOW_LEVEL( 
   208     IPTVLOGSTRING_LOW_LEVEL( 
   214         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::UpdateVideoListL() - Enter" );
   209         "MPX My Videos UI # CVcxHgMyVideosVideoModelHandler::UpdateVideoListL() - Enter" );
   215 
   210 
   216     CVcxHgMyVideosCollectionClient& collectionClient = iModel.CollectionClient();
   211     CVcxHgMyVideosCollectionClient& collectionClient = iModel.CollectionClient();
   217 
   212 
   218     // If we are re-opening the same video list again, then try 
   213     if ( aCategoryIndex == iCurrentCategoryIndex )
   219     // restore the highlight to previous position.
   214         {
   220     aCategoryIndex == iCurrentCategoryIndex ? iRestoreListPosition = ETrue :
   215         // If we are re-opening the same video list again, then try 
   221                                               iRestoreListPosition = EFalse;
   216         // restore the highlight to previous position.
   222     // Removes videos from video list.
   217         iRestoreListPosition = ETrue;
   223     iVideoArray->RemoveVideoList();
   218         }
   224          
   219     else
   225     // Removes videos from scroller. After this command, list highlight 
   220         {
   226     // disappears, so don't forget to set highlight in NewVideoListL() 
   221         iRestoreListPosition = EFalse;
   227     // function.
   222         
   228     iScroller.Reset();
   223         // Removes videos from video list.
       
   224         iVideoArray->RemoveVideoList();
       
   225         
       
   226         // Removes videos from scroller. After this command, list highlight 
       
   227         // disappears, so don't forget to set highlight in NewVideoListL() 
       
   228         // function.
       
   229         iScroller.Reset();
       
   230         }
   229         
   231         
   230     // Ask for video list from MPX collection.
   232     // Ask for video list from MPX collection.
   231     collectionClient.GetVideoListL( aCategoryIndex );
   233     collectionClient.GetVideoListL( aCategoryIndex );
   232 
   234 
   233     iCurrentCategoryIndex = aCategoryIndex;
   235     iCurrentCategoryIndex = aCategoryIndex;
   245     IPTVLOGSTRING_LOW_LEVEL( 
   247     IPTVLOGSTRING_LOW_LEVEL( 
   246         "MPX My Videos UI # ResortVideoListL() - Enter" );
   248         "MPX My Videos UI # ResortVideoListL() - Enter" );
   247         	
   249         	
   248     if ( iScroller.ItemCount() > 0 )
   250     if ( iScroller.ItemCount() > 0 )
   249         {
   251         {
   250         iDownloadUpdater->SetPausedL( ETrue );
       
   251     	
       
   252         TVcxMyVideosSortingOrder sortOrder = iModel.VideolistSortOrderL();
   252         TVcxMyVideosSortingOrder sortOrder = iModel.VideolistSortOrderL();
   253 
   253 
   254         if ( iVideoListImpl.IsMarking() )
   254         if ( iVideoListImpl.IsMarking() )
   255             {
   255             {
   256             SaveMarkingsL();
   256             SaveMarkingsL();
   269         if ( iVideoListImpl.IsMarking() )
   269         if ( iVideoListImpl.IsMarking() )
   270             {
   270             {
   271             RestoreMarkingsL();
   271             RestoreMarkingsL();
   272             }
   272             }
   273 
   273 
   274         iDownloadUpdater->VideoArrayChangedL();
       
   275         iDownloadUpdater->SetPausedL( EFalse );
       
   276 
       
   277         // Switch to appropriate scroller strip
   274         // Switch to appropriate scroller strip
   278         UpdateScrollbarTypeL( sortOrder );
   275         UpdateScrollbarTypeL( sortOrder );
   279         }
   276         }
   280         IPTVLOGSTRING_LOW_LEVEL( 
   277         IPTVLOGSTRING_LOW_LEVEL( 
   281             "MPX My Videos UI # ResortVideoListL() - Exit" );
   278             "MPX My Videos UI # ResortVideoListL() - Exit" );
   314 //
   311 //
   315 void CVcxHgMyVideosVideoModelHandler::MarkedVideosL( 
   312 void CVcxHgMyVideosVideoModelHandler::MarkedVideosL( 
   316         RArray<TInt>& aMarkedVideos )
   313         RArray<TInt>& aMarkedVideos )
   317     {
   314     {
   318     iScroller.GetMarkedItemsL( aMarkedVideos );
   315     iScroller.GetMarkedItemsL( aMarkedVideos );
   319     }
       
   320 
       
   321 // -----------------------------------------------------------------------------
       
   322 // CVcxHgMyVideosVideoModelHandler::OngoingDownloads()
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 void CVcxHgMyVideosVideoModelHandler::OngoingDownloads(
       
   326         RArray<TInt>& aDownloads )
       
   327     {
       
   328     iVideoArray->GetOngoingDownloads( aDownloads );
       
   329     }
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 // CVcxHgMyVideosVideoModelHandler::VideoDownloadState()
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 TVcxMyVideosDownloadState CVcxHgMyVideosVideoModelHandler::VideoDownloadState( 
       
   336         TInt aIndex )
       
   337     {
       
   338     return iVideoArray->VideoDownloadState( aIndex );
       
   339     }
       
   340 
       
   341 // -----------------------------------------------------------------------------
       
   342 // CVcxHgMyVideosVideoModelHandler::IsProgressivePlayPossible()
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 TBool CVcxHgMyVideosVideoModelHandler::IsProgressivePlayPossible( TInt aIndex )
       
   346     {
       
   347     return iDownloadUpdater->IsPlayPossible( aIndex );
       
   348     }
   316     }
   349 
   317 
   350 // -----------------------------------------------------------------------------
   318 // -----------------------------------------------------------------------------
   351 // CVcxHgMyVideosVideoModelHandler::HandleMarkCommandL()
   319 // CVcxHgMyVideosVideoModelHandler::HandleMarkCommandL()
   352 // -----------------------------------------------------------------------------
   320 // -----------------------------------------------------------------------------
   629 
   597 
   630     if ( media && media->IsSupported( KMPXMediaGeneralId ) )
   598     if ( media && media->IsSupported( KMPXMediaGeneralId ) )
   631         {
   599         {
   632         // Playback should be tried always when single clicking a video in My Videos
   600         // Playback should be tried always when single clicking a video in My Videos
   633         TMPXItemId mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
   601         TMPXItemId mpxItemId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId );
   634         IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosVideoModelHandler::PlayVideoL() aIndex=%d mpxItemId=%d", aIndex, (TInt) mpxItemId );
   602         SetVideoLastWatchedL( *media );
       
   603         ClearNewVideoFlagL( *media );
       
   604 		IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosVideoModelHandler::PlayVideoL() aIndex=%d mpxItemId=%d", aIndex, (TInt) mpxItemId );
   635         iModel.CollectionClient().PlayVideoL( mpxItemId );        
   605         iModel.CollectionClient().PlayVideoL( mpxItemId );        
   636         }
       
   637     }
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 // CVcxHgMyVideosVideoModelHandler::ResumeDownloadL()
       
   641 // -----------------------------------------------------------------------------
       
   642 //
       
   643 void CVcxHgMyVideosVideoModelHandler::ResumeDownloadL( TInt aIndex )
       
   644     {
       
   645     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   646 
       
   647     if ( media && media->IsSupported( KMPXMediaGeneralId ) )
       
   648         {
       
   649         TVcxMyVideosDownloadState dlState = VideoDownloadState( aIndex );
       
   650         
       
   651         if ( dlState == EVcxMyVideosDlStatePaused || dlState == EVcxMyVideosDlStateFailed )
       
   652             {
       
   653             iModel.DownloadClient().ResumeDownloadL( *media );
       
   654             
       
   655             TUint32 mpxId = media->ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ).iId1;
       
   656             if ( iResumeArray.Find( mpxId ) == KErrNotFound )
       
   657                 {
       
   658                 iResumeArray.AppendL( mpxId );
       
   659                 }
       
   660             }
       
   661         }
       
   662     }
       
   663 
       
   664 // -----------------------------------------------------------------------------
       
   665 // CVcxHgMyVideosVideoModelHandler::CancelDownloadL()
       
   666 // -----------------------------------------------------------------------------
       
   667 //
       
   668 void CVcxHgMyVideosVideoModelHandler::CancelDownloadL( TInt aIndex )
       
   669     {
       
   670     CMPXMedia* media = iVideoArray->MPXMedia( aIndex );
       
   671 
       
   672     if ( media )
       
   673         {            
       
   674         iModel.DownloadClient().CancelDownloadL( *media );
       
   675         }
   606         }
   676     }
   607     }
   677 
   608 
   678 // -----------------------------------------------------------------------------
   609 // -----------------------------------------------------------------------------
   679 // CVcxHgMyVideosVideoModelHandler::Release()
   610 // CVcxHgMyVideosVideoModelHandler::Release()
   737 
   668 
   738 // -----------------------------------------------------------------------------
   669 // -----------------------------------------------------------------------------
   739 // CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowLC()
   670 // CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowLC()
   740 // -----------------------------------------------------------------------------
   671 // -----------------------------------------------------------------------------
   741 // 
   672 // 
   742 HBufC* CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowLC(
   673 HBufC* CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowLC( CMPXMedia& aMedia )
   743             TInt aIndex,
   674 
   744             CMPXMedia& aMedia,
       
   745             TBool& aIsDownloading )
       
   746 
       
   747     {
       
   748     if ( VideoDownloadState( aIndex ) == EVcxMyVideosDlStateNone )
       
   749         {
       
   750         aIsDownloading = EFalse;
       
   751         return FormatVideoSecondRowCompletedLC( aMedia );
       
   752         }
       
   753     else
       
   754         {
       
   755         aIsDownloading = ETrue;
       
   756         return FormatVideoSecondRowDownloadingLC( aIndex, aMedia );
       
   757         }
       
   758     }
       
   759 
       
   760 // -----------------------------------------------------------------------------
       
   761 // CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowCompletedLC()
       
   762 // -----------------------------------------------------------------------------
       
   763 // 
       
   764 HBufC* CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowCompletedLC( 
       
   765         CMPXMedia& aMedia )
       
   766     {
   675     {
   767     _LIT( KVcxSecondLineSeparator, "," );
   676     _LIT( KVcxSecondLineSeparator, "," );
   768 
   677 
   769     HBufC* details = NULL;
   678     HBufC* details = NULL;
   770     HBufC* sizeStr = NULL;
   679     HBufC* sizeStr = NULL;
   865     CleanupStack::PushL( details );
   774     CleanupStack::PushL( details );
   866     return details;
   775     return details;
   867     }
   776     }
   868 
   777 
   869 // -----------------------------------------------------------------------------
   778 // -----------------------------------------------------------------------------
   870 // CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowDownloadingLC()
       
   871 // -----------------------------------------------------------------------------
       
   872 // 
       
   873 HBufC* CVcxHgMyVideosVideoModelHandler::FormatVideoSecondRowDownloadingLC(
       
   874             TInt aIndex,
       
   875             CMPXMedia& aMedia )
       
   876     {
       
   877     HBufC* details = NULL;
       
   878     TInt progress = DownloadProgressL( aMedia );
       
   879 
       
   880     switch ( VideoDownloadState( aIndex ) )
       
   881         {
       
   882         case EVcxMyVideosDlStateDownloading:
       
   883             {
       
   884             details = StringLoader::LoadLC( R_VCXHGMYVIDEOS_VIDEO_DOWNLOADING, progress );
       
   885             break;
       
   886             }
       
   887         case EVcxMyVideosDlStateFailed:
       
   888             {
       
   889             details = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DOWNLOAD_FAILED, progress );
       
   890             break;
       
   891             }
       
   892         case EVcxMyVideosDlStatePaused:
       
   893             {
       
   894             details = StringLoader::LoadLC( R_VCXHGMYVIDEOS_DOWNLOAD_PAUSED, progress );
       
   895             break;
       
   896             }
       
   897         case EVcxMyVideosDlStateNone:            
       
   898         case EVcxMyVideosDlStateDownloaded:
       
   899         default:
       
   900             {
       
   901             IPTVLOGSTRING2_LOW_LEVEL( 
       
   902                 "MPX My Videos UI # FormatVideoSecondRowDownloadingL() Unexpected state (%d)!",
       
   903                 VideoDownloadState( aIndex ) );
       
   904             #ifdef _DEBUG
       
   905             User::Panic( KVcxHgMyVideosPanic, EVcxHgMyVideosPanicLogicalVideo );
       
   906             #else
       
   907             User::Leave( KErrArgument );
       
   908             #endif // _DEBUG
       
   909             }
       
   910         }
       
   911 
       
   912     return details;
       
   913     }
       
   914 
       
   915 // -----------------------------------------------------------------------------
       
   916 // CVcxHgMyVideosVideoModelHandler::ReplaceVideoArrayL()
   779 // CVcxHgMyVideosVideoModelHandler::ReplaceVideoArrayL()
   917 // -----------------------------------------------------------------------------
   780 // -----------------------------------------------------------------------------
   918 // 
   781 // 
   919 void CVcxHgMyVideosVideoModelHandler::ReplaceVideoArrayL( CMPXMediaArray& aVideoList )
   782 void CVcxHgMyVideosVideoModelHandler::ReplaceVideoArrayL( CMPXMediaArray& aVideoList )
   920     {
   783     {
   921     iVideoArray->ReplaceVideoListL( aVideoList );
   784     iVideoArray->ReplaceVideoListL( aVideoList );
   922     iDataUpdater->InfoArrayChanged();
   785     iDataUpdater->InfoArrayChanged();
   923     iDownloadUpdater->VideoArrayChangedL();
       
   924     }
       
   925 
       
   926 // -----------------------------------------------------------------------------
       
   927 // CVcxHgMyVideosVideoModelHandler::DownloadProgressL()
       
   928 // -----------------------------------------------------------------------------
       
   929 // 
       
   930 TInt CVcxHgMyVideosVideoModelHandler::DownloadProgressL( const CMPXMedia& aMpxMedia )
       
   931     {
       
   932     TInt progress = 0;
       
   933 
       
   934     if ( aMpxMedia.IsSupported( KVcxMediaMyVideosDownloadProgress ) )
       
   935         {
       
   936         progress = static_cast<TInt>( 
       
   937                        aMpxMedia.ValueTObjectL<TInt8>( KVcxMediaMyVideosDownloadProgress ) );
       
   938         }
       
   939 
       
   940     IPTVLOGSTRING3_LOW_LEVEL(
       
   941         "MPX My Videos UI # DownloadProgressL() Id:%d Progress:%d",
       
   942         static_cast<TInt>( aMpxMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) ),
       
   943         progress );
       
   944 
       
   945     progress = ( progress >= 0 ? progress : 0 );
       
   946     progress = ( progress < 100 ? progress : 99 );
       
   947 
       
   948     return progress;
       
   949     }
   786     }
   950 
   787 
   951 // -----------------------------------------------------------------------------
   788 // -----------------------------------------------------------------------------
   952 // CVcxHgMyVideosVideoModelHandler::UpdateVideoListItemL()
   789 // CVcxHgMyVideosVideoModelHandler::UpdateVideoListItemL()
   953 // -----------------------------------------------------------------------------
   790 // -----------------------------------------------------------------------------
   975                     {
   812                     {
   976                     item.SetTitleL( *name );
   813                     item.SetTitleL( *name );
   977                     }
   814                     }
   978                 CleanupStack::PopAndDestroy( name );
   815                 CleanupStack::PopAndDestroy( name );
   979                 }
   816                 }
   980             TBool isDownloading( EFalse );
   817 
   981             HBufC* details( NULL );
   818             HBufC* details( NULL );
   982             
   819             
   983             details = FormatVideoSecondRowLC( aListIndex, *media, isDownloading );
   820             details = FormatVideoSecondRowLC( *media );
   984             if ( details->Length() > 0 )
   821             if ( details->Length() > 0 )
   985                 {
   822                 {
   986                 item.SetTextL( *details );
   823                 item.SetTextL( *details );
   987                 }
   824                 }
   988             CleanupStack::PopAndDestroy( details );
   825             CleanupStack::PopAndDestroy( details );
  1036 // CVcxHgMyVideosVideoModelHandler::DeleteItemL()
   873 // CVcxHgMyVideosVideoModelHandler::DeleteItemL()
  1037 // -----------------------------------------------------------------------------
   874 // -----------------------------------------------------------------------------
  1038 // 
   875 // 
  1039 void CVcxHgMyVideosVideoModelHandler::DeleteItemL( TMPXItemId aMpxItemId )
   876 void CVcxHgMyVideosVideoModelHandler::DeleteItemL( TMPXItemId aMpxItemId )
  1040     {
   877     {
  1041     // Remove video from data and download updaters.
   878     // Remove video from data updater.
  1042     iDataUpdater->ReleaseData( aMpxItemId );
   879     iDataUpdater->ReleaseData( aMpxItemId );
  1043     iDownloadUpdater->RemoveDownload( aMpxItemId );
       
  1044 
   880 
  1045     // Remove video from video array.
   881     // Remove video from video array.
  1046     TInt removedIndex = iVideoArray->RemoveVideo( aMpxItemId );
   882     TInt removedIndex = iVideoArray->RemoveVideo( aMpxItemId );
  1047     
   883     
  1048     if ( removedIndex != KErrNotFound )
   884     if ( removedIndex != KErrNotFound )
  1080         // confirmation note, as user needs to clicks them to start the delete).
   916         // confirmation note, as user needs to clicks them to start the delete).
  1081         iScroller.SetFocus( ETrue ); 
   917         iScroller.SetFocus( ETrue ); 
  1082         
   918         
  1083         iScroller.DrawDeferred();
   919         iScroller.DrawDeferred();
  1084         iView.DynInitMskL();
   920         iView.DynInitMskL();
  1085         }
       
  1086     
       
  1087     TInt index( KErrNotFound );
       
  1088     index = iResumeArray.Find( aMpxItemId.iId1 );
       
  1089     
       
  1090     if ( index >= 0 && index < iResumeArray.Count() )
       
  1091         {
       
  1092         iResumeArray.Remove( index );
       
  1093         }
   921         }
  1094     }
   922     }
  1095 
   923 
  1096 // -----------------------------------------------------------------------------
   924 // -----------------------------------------------------------------------------
  1097 // CVcxHgMyVideosVideoModelHandler::InsertVideoL()
   925 // CVcxHgMyVideosVideoModelHandler::InsertVideoL()
  1131                 // Update screen.
   959                 // Update screen.
  1132                 iScroller.DrawDeferred();
   960                 iScroller.DrawDeferred();
  1133                 iView.DynInitMskL();
   961                 iView.DynInitMskL();
  1134                                                     
   962                                                     
  1135                 iDataUpdater->RequestDataL( itemId );    
   963                 iDataUpdater->RequestDataL( itemId );    
  1136                 iDownloadUpdater->VideoModifiedL( 
       
  1137                     EMPXItemInserted, itemId, EVcxMyVideosListNoInfo );
       
  1138                 }
   964                 }
  1139             }
   965             }
  1140          else
   966          else
  1141             {
   967             {
  1142             delete aVideo;
   968             delete aVideo;
  1206 void CVcxHgMyVideosVideoModelHandler::NewVideoListL( CMPXMediaArray& aVideoList )
  1032 void CVcxHgMyVideosVideoModelHandler::NewVideoListL( CMPXMediaArray& aVideoList )
  1207     {
  1033     {
  1208     IPTVLOGSTRING2_LOW_LEVEL( 
  1034     IPTVLOGSTRING2_LOW_LEVEL( 
  1209         "MPX My Videos UI # NewVideoListL(count=%d) - Enter", aVideoList.Count() );
  1035         "MPX My Videos UI # NewVideoListL(count=%d) - Enter", aVideoList.Count() );
  1210         
  1036         
  1211     ReplaceVideoArrayL( aVideoList );
  1037     TBool sameItems = iVideoArray->HasSameItemsL( aVideoList );
       
  1038     if ( !sameItems )
       
  1039         {
       
  1040         ReplaceVideoArrayL( aVideoList );
       
  1041         }
  1212     
  1042     
  1213     TInt videoCount = iVideoArray->VideoCount();         
  1043     TInt videoCount = iVideoArray->VideoCount();         
  1214     if (  videoCount > 0 )
  1044     if (  videoCount > 0 )
  1215         {
  1045         {
  1216         ResizeScrollerL( videoCount );
  1046         if ( !sameItems )
       
  1047             {
       
  1048             ResizeScrollerL( videoCount );
       
  1049             }
  1217 
  1050 
  1218         TInt firstItemIndex( KErrNotFound );
  1051         TInt firstItemIndex( KErrNotFound );
  1219 
  1052 
  1220         if ( iRestoreListPosition )
  1053         if ( iRestoreListPosition )
  1221             {
  1054             {
  1310                     UpdateVideoListItemL( index );              
  1143                     UpdateVideoListItemL( index );              
  1311                     iScroller.RefreshScreen( index );
  1144                     iScroller.RefreshScreen( index );
  1312                 
  1145                 
  1313                     if ( ! aSimulated )
  1146                     if ( ! aSimulated )
  1314                         {
  1147                         {
  1315                         iDownloadUpdater->VideoModifiedL( aEventType, aMpxItemId, aExtraInfo );
       
  1316                         iDataUpdater->RequestDataL( aMpxItemId );    
  1148                         iDataUpdater->RequestDataL( aMpxItemId );    
  1317 					    }                      
  1149 					    }                      
  1318                     iView.DynInitMskL();
  1150                     iView.DynInitMskL();
  1319                     }
  1151                     }
  1320                 }
  1152                 }
  1359         delete aVideo;
  1191         delete aVideo;
  1360         }
  1192         }
  1361     }
  1193     }
  1362 
  1194 
  1363 // -----------------------------------------------------------------------------
  1195 // -----------------------------------------------------------------------------
  1364 // CVcxHgMyVideosVideoModelHandler::ResumeStartedFromBeginningL()
       
  1365 // Download updater calls this when resume has started from beginning.
       
  1366 // -----------------------------------------------------------------------------
       
  1367 // 
       
  1368 void CVcxHgMyVideosVideoModelHandler::ResumeStartedFromBeginningL( TUint32 aMpxId )
       
  1369     {
       
  1370     TInt index = iResumeArray.Find( aMpxId );
       
  1371     if ( index >= 0 )
       
  1372         {
       
  1373         iResumeArray.Remove( index );
       
  1374         iVideoListImpl.ShowResumeStartsFromBeginningNoteL();
       
  1375         }
       
  1376     }
       
  1377 
       
  1378 // -----------------------------------------------------------------------------
       
  1379 // CVcxHgMyVideosVideoModelHandler::VideoDeletionCompletedL()
  1196 // CVcxHgMyVideosVideoModelHandler::VideoDeletionCompletedL()
  1380 // MPX Collection calls this callback when deletion of multiple videos completes.
  1197 // MPX Collection calls this callback when deletion of multiple videos completes.
  1381 // -----------------------------------------------------------------------------
  1198 // -----------------------------------------------------------------------------
  1382 // 
  1199 // 
  1383 void CVcxHgMyVideosVideoModelHandler::VideoDeletionCompletedL( TInt aFailedCount,
  1200 void CVcxHgMyVideosVideoModelHandler::VideoDeletionCompletedL( TInt aFailedCount,
  1553         IPTVLOGSTRING4_LOW_LEVEL( "CVcxHgMyVideosVideoModelHandler::RestoreMarkingsL() list index = %d CMPXMedia = 0x%08x found = %d", i, media, found );
  1370         IPTVLOGSTRING4_LOW_LEVEL( "CVcxHgMyVideosVideoModelHandler::RestoreMarkingsL() list index = %d CMPXMedia = 0x%08x found = %d", i, media, found );
  1554         }
  1371         }
  1555 
  1372 
  1556     iMarkedMediaList.Reset();
  1373     iMarkedMediaList.Reset();
  1557     }
  1374     }
       
  1375 // -----------------------------------------------------------------------------
       
  1376 // CVcxHgMyVideosVideoModelHandler::SetVideoLastWatchedL()
       
  1377 // -----------------------------------------------------------------------------
       
  1378 //
       
  1379 void CVcxHgMyVideosVideoModelHandler::SetVideoLastWatchedL( CMPXMedia& aMedia )
       
  1380     {    
       
  1381     if ( !iRepository )
       
  1382         {
       
  1383         iRepository = CRepository::NewL( TUid::Uid( KVcxMyVideosCollectionCenrepUid ) );
       
  1384         }
       
  1385     iRepository->Set( KVcxMyVideosCollectionCenrepKeyLastWatchedMpxId, 
       
  1386                       TInt( aMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ).iId1 ));
       
  1387 
       
  1388     iRepository->Set( KVcxMyVideosCollectionCenrepKeyLastWatchedName,
       
  1389                        aMedia.ValueText( KMPXMediaGeneralTitle ));
       
  1390 
       
  1391     iRepository->Set( KVcxMyVideosCollectionCenrepKeyLastWatchedPath,
       
  1392                        aMedia.ValueText( KMPXMediaGeneralUri ));
       
  1393 
       
  1394     iRepository->Set( KVcxMyVideosCollectionCenrepKeyLastWatchedIndicator,
       
  1395                        TInt( VideoIndicator().IsIndicatorShown( aMedia )) );
       
  1396 	}
       
  1397 
       
  1398 // -----------------------------------------------------------------------------
       
  1399 // CVcxHgMyVideosVideoModelHandler::ClearNewVideoFlagL()
       
  1400 // -----------------------------------------------------------------------------
       
  1401 //
       
  1402 void CVcxHgMyVideosVideoModelHandler::ClearNewVideoFlagL( CMPXMedia& aMedia )
       
  1403     {    
       
  1404     TUint32 flags = aMedia.ValueTObjectL<TUint32>( KMPXMediaGeneralFlags );
       
  1405     if( flags & EVcxMyVideosVideoNew )
       
  1406         {
       
  1407         flags &= ~EVcxMyVideosVideoNew;
       
  1408         iModel.CollectionClient().SetFlagsL( 
       
  1409 		    aMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ), flags );   
       
  1410         }    
       
  1411     }