videocollection/hgmyvideos/src/vcxhgmyvideoscategorymodelhandler.cpp
branchRCL_3
changeset 15 8f0df5c82986
parent 11 8970fbd719ec
child 16 67eb01668b0e
equal deleted inserted replaced
14:55fa1ec415c6 15:8f0df5c82986
    51 #include "vcxhgmyvideosmodel.h"
    51 #include "vcxhgmyvideosmodel.h"
    52 #include "vcxhgmyvideoscollectionclient.h"
    52 #include "vcxhgmyvideoscollectionclient.h"
    53 #include "vcxhgmyvideosthumbnailmanager.h"
    53 #include "vcxhgmyvideosthumbnailmanager.h"
    54 #include "vcxhgmyvideoscenrepkeys.h"
    54 #include "vcxhgmyvideoscenrepkeys.h"
    55 
    55 
    56 const TInt KMyVideosTitleStringMaxLength = 64;
       
    57 const TInt KMyVideosTitleUrlMaxLength    = 128;
       
    58 
       
    59 _LIT( KVcxHgMyVideosMifFile, "\\resource\\apps\\vcxhgmyvideosicons.mif" );
    56 _LIT( KVcxHgMyVideosMifFile, "\\resource\\apps\\vcxhgmyvideosicons.mif" );
    60 
    57 
    61 // ============================ MEMBER FUNCTIONS ===============================
    58 // ============================ MEMBER FUNCTIONS ===============================
    62 
    59 
    63 
    60 
    94 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    95 //
    92 //
    96 CVcxHgMyVideosCategoryModelHandler::~CVcxHgMyVideosCategoryModelHandler()
    93 CVcxHgMyVideosCategoryModelHandler::~CVcxHgMyVideosCategoryModelHandler()
    97     {
    94     {
    98     delete iCategoryList;
    95     delete iCategoryList;
    99     delete iLastWatched;
       
   100     delete iVideoIndicator;
    96     delete iVideoIndicator;
   101     
    97     
   102     iCategoryIdArray.Reset();
    98     iCategoryIdArray.Reset();
   103     }
    99     }
   104 
   100 
   109 void CVcxHgMyVideosCategoryModelHandler::DoModelActivateL()
   105 void CVcxHgMyVideosCategoryModelHandler::DoModelActivateL()
   110     {
   106     {
   111     IPTVLOGSTRING_LOW_LEVEL( 
   107     IPTVLOGSTRING_LOW_LEVEL( 
   112         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelActivateL() - Enter" );
   108         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelActivateL() - Enter" );
   113 
   109 
       
   110 	UpdateCategoryListL();
       
   111 	
   114     iModel.CollectionClient().SetCategoryModelObserver( this );
   112     iModel.CollectionClient().SetCategoryModelObserver( this );
   115 
   113 
   116     iTnManager.AddObserverL( *this );
   114     iTnManager.AddObserverL( *this );
   117     
   115     
   118     IPTVLOGSTRING_LOW_LEVEL( 
   116     IPTVLOGSTRING_LOW_LEVEL( 
   129         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelDeactivate() - Enter" );
   127         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelDeactivate() - Enter" );
   130 
   128 
   131     iModel.CollectionClient().SetCategoryModelObserver( NULL );
   129     iModel.CollectionClient().SetCategoryModelObserver( NULL );
   132 
   130 
   133     iTnManager.RemoveObserver( *this );
   131     iTnManager.RemoveObserver( *this );
   134     
   132 	
   135     delete iLastWatched;
   133     TRAP_IGNORE( ClearLastWatchedIconL() )
   136     iLastWatched = NULL;
       
   137     
   134     
   138     IPTVLOGSTRING_LOW_LEVEL( 
   135     IPTVLOGSTRING_LOW_LEVEL( 
   139         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelDeactivate() - Exit" );
   136         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelDeactivate() - Exit" );
   140     }
   137     }
   141 
   138 
   277             iconFile = KVcxHgMyVideosMifFile;
   274             iconFile = KVcxHgMyVideosMifFile;
   278             bitmapId = EMbmVcxhgmyvideosiconsQgn_prop_captured_thumbnail_video;
   275             bitmapId = EMbmVcxhgmyvideosiconsQgn_prop_captured_thumbnail_video;
   279             maskId = EMbmVcxhgmyvideosiconsQgn_prop_captured_thumbnail_video_mask;
   276             maskId = EMbmVcxhgmyvideosiconsQgn_prop_captured_thumbnail_video_mask;
   280             break;
   277             break;
   281         case KCategoryIdLastWatched:
   278         case KCategoryIdLastWatched:
   282 			 if ( !LastWatchedSetL() )
   279 			 LoadLastWatchedIconL();
   283 			    {
   280 			 if ( iTnRequestId == KErrNotFound )
   284 				LoadLastWatchedIconL();
   281 			     {
   285 				}
   282                  // Last watched or preloaded not found => show default icon
       
   283                  skinId.Set( KAknsIIDQgnPropRecentThumbnailVideo );
       
   284                  iconFile = KVcxHgMyVideosMifFile;
       
   285                  bitmapId = EMbmVcxhgmyvideosiconsQgn_prop_recent_thumbnail_video;
       
   286                  maskId = EMbmVcxhgmyvideosiconsQgn_prop_recent_thumbnail_video_mask;
       
   287 			     }
   286             break;
   288             break;
   287         case KCategoryIdExtraItem1:
   289         case KCategoryIdExtraItem1:
   288             // ExtraItem1 is always interpreted as Ovi Store
   290             // ExtraItem1 is always interpreted as Ovi Store
   289             skinId.Set( KAknsIIDQgnPropOviThumbnailVideo );
   291             skinId.Set( KAknsIIDQgnPropOviThumbnailVideo );
   290             iconFile = KVcxHgMyVideosMifFile;
   292             iconFile = KVcxHgMyVideosMifFile;
   357 // CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC()
   359 // CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC()
   358 // -----------------------------------------------------------------------------
   360 // -----------------------------------------------------------------------------
   359 // 
   361 // 
   360 HBufC* CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC( CMPXMedia& aMedia )
   362 HBufC* CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC( CMPXMedia& aMedia )
   361     {    
   363     {    
   362     if ( !aMedia.IsSupported( KMPXMediaGeneralType ) ||
       
   363           aMedia.ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType ) != EMPXGroup )
       
   364         {
       
   365         if ( aMedia.IsSupported( KMPXMediaGeneralTitle ) )
       
   366             {
       
   367             return aMedia.ValueText( KMPXMediaGeneralTitle ).AllocLC(); 
       
   368             }
       
   369 	    else
       
   370 		    {
       
   371 			return KNullDesC().AllocLC();
       
   372 			}
       
   373         }
       
   374     
       
   375     HBufC* details = NULL;
   364     HBufC* details = NULL;
   376     TInt newVideos = 0;
   365     TInt newVideos = 0;
   377     TInt videos = 0;
   366     TInt videos = 0;
   378 
   367 
   379     if ( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemCount ) )
   368     if ( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemCount ) )
   446             break;
   435             break;
   447         case KCategoryIdLastWatched:
   436         case KCategoryIdLastWatched:
   448             {
   437             {
   449             if ( LastWatchedSetL() )
   438             if ( LastWatchedSetL() )
   450                 {
   439                 {
   451                 CMPXMedia* media = GetCategoryDataL( aCategoryId );
   440                 TBuf<KMaxPath> path;
   452                 if ( media )
   441                 TInt error = iModel.GetLastWatchedPathL( path );
       
   442                 if ( BaflUtils::FileExists( iModel.FileServerSessionL(), path ) )
   453                     {
   443                     {
   454                     secondRow = FormatCategorySecondRowLC( *media );
   444                     TBuf<KMyVideosTitleStringMaxLength> string;
       
   445                     TInt error = iModel.GetLastWatchedNameL( string );
       
   446                     secondRow = error ? KNullDesC().AllocLC() : string.AllocLC();
   455                     }
   447                     }
   456                 else
   448                 else
   457                     {
   449                     {
   458                     secondRow = KNullDesC().AllocLC();
   450                     secondRow = StringLoader::LoadLC( R_VCXHGMYVIDEOS_NO_VIDEOS_IN_CATEGORY );
   459                     }
   451                     }
   460                 }
   452                 }
   461             else    
   453             else    
   462                 {
   454                 {
   463                 if ( PreloadedExistsL() )
   455                 if ( PreloadedExistsL() )
   467 					                        KCRVideoPlayerPreloadedVideoDescription, string );
   459 					                        KCRVideoPlayerPreloadedVideoDescription, string );
   468                     secondRow = error ? KNullDesC().AllocLC() : string.AllocLC();
   460                     secondRow = error ? KNullDesC().AllocLC() : string.AllocLC();
   469                     }
   461                     }
   470                 else
   462                 else
   471                     {
   463                     {
   472                     secondRow = KNullDesC().AllocLC();
   464                     secondRow = StringLoader::LoadLC( R_VCXHGMYVIDEOS_NO_VIDEOS_IN_CATEGORY );
   473                     }
   465                     }
   474                 }
   466                 }
   475             }
   467             }
   476             break;
   468             break;
   477 
   469 
   605     { 
   597     { 
   606     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListModifiedL() - Enter" );
   598     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListModifiedL() - Enter" );
   607     
   599     
   608     UpdateCategoryListL();
   600     UpdateCategoryListL();
   609     
   601     
   610     FetchLastWatchedL();
       
   611     SetLastWatchedIndicatorL();
       
   612     
       
   613     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListModifiedL() - Exit" );
   602     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListModifiedL() - Exit" );
   614     }
   603     }
   615 
   604 
   616 // -----------------------------------------------------------------------------
   605 // -----------------------------------------------------------------------------
   617 // CVcxHgMyVideosCategoryModelHandler::CategoryModifiedL()
   606 // CVcxHgMyVideosCategoryModelHandler::CategoryModifiedL()
   634             }
   623             }
   635             break;
   624             break;
   636             
   625             
   637         case EMPXItemInserted:
   626         case EMPXItemInserted:
   638             {
   627             {
   639             if ( !iLastWatched )
   628             TInt id1( 0 );
   640                 {
   629             TInt ret = iModel.GetLastWatchedIdL( id1 );
   641                 TInt id1( 0 );
   630 
   642                 TInt ret = iModel.GetLastWatchedIdL( id1 );
   631             if (  ret == KErrNone &&
   643                 TMPXItemId id ( id1 );
   632                   id1 == aMpxItemId.iId1 )
   644                 
   633                 {
   645                 if (  ret == KErrNone &&
   634                 UpdateCategoryListItemL( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
   646                       id1 == aMpxItemId.iId1 )
   635 				iScroller.RefreshScreen( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
   647                     {
   636 				}
   648                     FetchLastWatchedL();
       
   649                     }
       
   650                 }
       
   651             }
   637             }
   652             break;
   638             break;
   653         case EMPXItemDeleted:
   639         case EMPXItemDeleted:
   654             {
   640             {
   655             if ( iLastWatched && 
   641             TInt id1( 0 );
   656                  iLastWatched->IsSupported( KMPXMediaGeneralId ) &&
   642             TInt ret = iModel.GetLastWatchedIdL( id1 );
   657                  iLastWatched->Value<TMPXItemId>( KMPXMediaGeneralId )->iId1 == aMpxItemId.iId1 )
   643 
   658                 {
   644             if (  ret == KErrNone &&
   659                 delete iLastWatched;
   645                   id1 == aMpxItemId.iId1 )
   660                 iLastWatched = NULL;
   646                 {
   661                 
   647                 ClearLastWatchedIconL();
   662                 UpdateCategoryListItemL( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
   648                 UpdateCategoryListItemL( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
   663                 SetLastWatchedIndicatorL();
   649 				iScroller.RefreshScreen( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
   664                 }
   650                 }
   665             }
   651             }
   666             break;
   652             break;
   667         default:
   653         default:
   668             {
   654             {
   679 //
   665 //
   680 void CVcxHgMyVideosCategoryModelHandler::UpdateCategoryListL()
   666 void CVcxHgMyVideosCategoryModelHandler::UpdateCategoryListL()
   681     {
   667     {
   682     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # UpdateCategoryListL() - Enter" );
   668     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # UpdateCategoryListL() - Enter" );
   683     
   669     
   684     if ( iCategoryList )
   670     MakeCategoryIdArray();
   685         {        
   671     
   686         TInt categoryCount = iCategoryList->Count();
   672     if ( iCategoryIdArray.Count() != iScroller.ItemCount() )
       
   673         {
       
   674         iScroller.ResizeL( iCategoryIdArray.Count() );
       
   675         }
   687         
   676         
   688         MakeCategoryIdArray( categoryCount );
   677     if ( iCategoryIdArray.Count() > 0 )
   689         
   678         {                    
   690         IPTVLOGSTRING2_LOW_LEVEL( 
   679         for ( TInt i = 0; i < iCategoryIdArray.Count(); i++ )
   691                 "MPX My Videos UI # UpdateCategoryListL() - count = %d", categoryCount );
   680             {
   692         
   681             UpdateCategoryListItemL( i );
   693         if ( iCategoryIdArray.Count() != iScroller.ItemCount() )
   682             }
   694             {
   683         if ( iScroller.SelectedIndex() < 0 || 
   695             iScroller.ResizeL( iCategoryIdArray.Count() );
   684                 iScroller.SelectedIndex() >= iScroller.ItemCount() )
   696             }
   685             {
   697             
   686             iScroller.SetSelectedIndex( 0 );    
   698         if ( iCategoryIdArray.Count() > 0 )
   687             }           
   699             {                    
   688         }        
   700             for ( TInt i = 0; i < iCategoryIdArray.Count(); i++ )
   689     
   701                 {
   690     // Refresh the whole list.
   702                 UpdateCategoryListItemL( i );
   691     iScroller.DrawDeferred();
   703                 }
   692 
   704             if ( iScroller.SelectedIndex() < 0 || 
       
   705                     iScroller.SelectedIndex() >= iScroller.ItemCount() )
       
   706                 {
       
   707                 iScroller.SetSelectedIndex( 0 );    
       
   708                 }           
       
   709             }        
       
   710         
       
   711         // Refresh the whole list.
       
   712         iScroller.DrawDeferred();
       
   713         }
       
   714     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # UpdateCategoryListL() - Exit" );
   693     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # UpdateCategoryListL() - Exit" );
   715     }
   694     }
   716 
   695 
   717 // -----------------------------------------------------------------------------
   696 // -----------------------------------------------------------------------------
   718 // CVcxHgMyVideosCategoryModelHandler::UpdateCategoryListItemL()
   697 // CVcxHgMyVideosCategoryModelHandler::UpdateCategoryListItemL()
   738         secondRow = FormatCategorySecondRowLC( iCategoryIdArray[ aListIndex ] );
   717         secondRow = FormatCategorySecondRowLC( iCategoryIdArray[ aListIndex ] );
   739         listItem.SetTextL( *secondRow );
   718         listItem.SetTextL( *secondRow );
   740         CleanupStack::PopAndDestroy( secondRow );
   719         CleanupStack::PopAndDestroy( secondRow );
   741 
   720 
   742         // Set icon for category
   721         // Set icon for category
   743         listItem.SetIcon( GetCategoryIconL( iCategoryIdArray[ aListIndex ] ) );
   722         if ( !listItem.Icon() )
       
   723             {
       
   724             listItem.SetIcon( GetCategoryIconL( iCategoryIdArray[ aListIndex ] ) );
       
   725             }
   744         }
   726         }
   745         
   727         
   746     IPTVLOGSTRING_LOW_LEVEL( 
   728     IPTVLOGSTRING_LOW_LEVEL( 
   747         "MPX My Videos UI # UpdateCategoryListItemL() - Exit" );
   729         "MPX My Videos UI # UpdateCategoryListItemL() - Exit" );
   748     }
   730     }
   776 
   758 
   777 // -----------------------------------------------------------------------------
   759 // -----------------------------------------------------------------------------
   778 // CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArray()
   760 // CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArray()
   779 // -----------------------------------------------------------------------------
   761 // -----------------------------------------------------------------------------
   780 //
   762 //
   781 void CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArray( TInt aCategoriesAvailable )
   763 void CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArray()
   782     {
   764     {
   783     IPTVLOGSTRING2_LOW_LEVEL( 
   765     IPTVLOGSTRING_LOW_LEVEL("CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArray");
   784             "MPX My Videos UI # MakeCategoryArray (number of categories=%d)", aCategoriesAvailable );
       
   785     
   766     
   786     iCategoryIdArray.Reset();    
   767     iCategoryIdArray.Reset();    
   787     
   768     
   788     TInt error = KErrNone;
   769     TInt error = KErrNone;
   789     TInt value = KErrNotFound;
   770     TInt value = KErrNotFound;
   836                 }
   817                 }
   837             }
   818             }
   838         }
   819         }
   839     else
   820     else
   840         {
   821         {
   841         IPTVLOGSTRING_LOW_LEVEL( 
   822 		iCategoryIdArray.Append( KCategoryIdLastWatched );
   842             "MPX My Videos UI # MakeCategoryIdArray() Could not access CenRep!" ); 
   823 		iCategoryIdArray.Append( KVcxMvcCategoryIdCaptured );	    
   843     
   824         iCategoryIdArray.Append( KVcxMvcCategoryIdOther );  
   844         // If cenrep access fails then use these values as backup
   825         iCategoryIdArray.Append( KCategoryIdExtraItem1 );
   845 	    iCategoryIdArray.Append( KCategoryIdLastWatched );
       
   846 		
       
   847     	for(TInt i = 0; i < aCategoriesAvailable; i++)
       
   848         	{
       
   849 	        if( AcceptCategory( i ) )
       
   850     	        {
       
   851         	    iCategoryIdArray.Append( i );        
       
   852             	}        
       
   853         	}
       
   854         }
   826         }
   855     }
   827     }
   856 
   828 
   857 // -----------------------------------------------------------------------------
   829 // -----------------------------------------------------------------------------
   858 // CVcxHgMyVideosCategoryModelHandler::AcceptCategory()
   830 // CVcxHgMyVideosCategoryModelHandler::AcceptCategory()
   882     
   854     
   883     return ret;
   855     return ret;
   884     }
   856     }
   885 
   857 
   886 // -----------------------------------------------------------------------------
   858 // -----------------------------------------------------------------------------
   887 // CVcxHgMyVideosVideoModelHandler::VideoFetchingCompletedL()
       
   888 // MPX Collection calls this callback when a single video has fetched.
       
   889 // -----------------------------------------------------------------------------
       
   890 // 
       
   891 void CVcxHgMyVideosCategoryModelHandler::VideoFetchingCompletedL( CMPXMedia* aVideo )
       
   892     {
       
   893     TInt id( 0 );
       
   894     
       
   895     TInt ret = iModel.GetLastWatchedIdL( id );
       
   896                     
       
   897     if ( ret == KErrNone && 
       
   898          id && 
       
   899 		 aVideo &&
       
   900          aVideo->IsSupported( KMPXMediaGeneralId ) &&
       
   901          aVideo->Value<TMPXItemId>( KMPXMediaGeneralId )->iId1 == id )
       
   902         {
       
   903         delete iLastWatched;
       
   904         iLastWatched = aVideo;
       
   905 		
       
   906 		LoadLastWatchedIconL();
       
   907 		SetLastWatchedIndicatorL();
       
   908         }
       
   909     else 
       
   910 		{
       
   911 		delete aVideo;
       
   912 		aVideo = NULL;
       
   913 		}
       
   914     
       
   915     UpdateCategoryListItemL( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
       
   916     iScroller.RefreshScreen( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
       
   917     }
       
   918 
       
   919 // -----------------------------------------------------------------------------
       
   920 // MPX Collection calls this callback when category list items have been fetched.
   859 // MPX Collection calls this callback when category list items have been fetched.
   921 // -----------------------------------------------------------------------------
   860 // -----------------------------------------------------------------------------
   922 // 
   861 // 
   923 void CVcxHgMyVideosCategoryModelHandler::CategoryListFetchingCompletedL()
   862 void CVcxHgMyVideosCategoryModelHandler::CategoryListFetchingCompletedL()
   924     {
   863     {
   925     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListFetchingCompletedL()" ); 
   864     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListFetchingCompletedL()" ); 
   926     FetchLastWatchedL();
       
   927     SetLastWatchedIndicatorL();
       
   928 
   865 
   929     // Send custom command to appui that signals that the 
   866     // Send custom command to appui that signals that the 
   930     // my videos main view is constructed.
   867     // my videos main view is constructed.
   931     CAknAppUi* appui = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi() );
   868     CAknAppUi* appui = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi() );
   932     
   869     
   941 // 
   878 // 
   942 // -----------------------------------------------------------------------------
   879 // -----------------------------------------------------------------------------
   943 // 
   880 // 
   944 CMPXMedia* CVcxHgMyVideosCategoryModelHandler::GetCategoryDataL( TInt aCategoryId )
   881 CMPXMedia* CVcxHgMyVideosCategoryModelHandler::GetCategoryDataL( TInt aCategoryId )
   945     {
   882     {
   946     if ( aCategoryId == KCategoryIdLastWatched )
   883     if ( iCategoryList && aCategoryId >= 0 && iCategoryList->Count() > aCategoryId )
   947         {
       
   948         return iLastWatched;
       
   949         }
       
   950     
       
   951     if ( aCategoryId >= 0 && iCategoryList->Count() > aCategoryId )
       
   952         {
   884         {
   953         return (*iCategoryList)[ aCategoryId ];
   885         return (*iCategoryList)[ aCategoryId ];
   954         }
   886         }
   955     
   887     
   956     return NULL;
   888     return NULL;
   957     }
   889     }
   958 
   890 
   959 // -----------------------------------------------------------------------------
   891 // -----------------------------------------------------------------------------
   960 // CVcxHgMyVideosVideoModelHandler::FetchLastWatchedL()
       
   961 // 
       
   962 // -----------------------------------------------------------------------------
       
   963 // 
       
   964 void CVcxHgMyVideosCategoryModelHandler::FetchLastWatchedL()
       
   965     {
       
   966     TInt id1( 0 );
       
   967     TInt ret = iModel.GetLastWatchedIdL( id1 );
       
   968     TMPXItemId id ( id1 );
       
   969     
       
   970     if (  id1 != 0 && 
       
   971           KErrNone == ret )
       
   972         {
       
   973         if ( !iLastWatched ||
       
   974 		    ( iLastWatched &&
       
   975               iLastWatched->IsSupported( KMPXMediaGeneralId ) &&
       
   976               iLastWatched->Value<TMPXItemId>( KMPXMediaGeneralId )->iId1 != id1 ))
       
   977             {
       
   978             iModel.CollectionClient().FetchMpxMediaByMpxIdL( id );
       
   979             } 
       
   980         }
       
   981     }
       
   982 
       
   983 // -----------------------------------------------------------------------------
       
   984 // CVcxHgMyVideosVideoModelHandler::PlayLastWatchedVidedoL()
   892 // CVcxHgMyVideosVideoModelHandler::PlayLastWatchedVidedoL()
   985 // 
   893 // 
   986 // -----------------------------------------------------------------------------
   894 // -----------------------------------------------------------------------------
   987 // 
   895 // 
   988 void CVcxHgMyVideosCategoryModelHandler::PlayLastWatchedVidedoL()
   896 void CVcxHgMyVideosCategoryModelHandler::PlayLastWatchedVidedoL()
   989     {
   897     {
       
   898     TBuf<KMaxPath> path;
       
   899     TInt error( KErrNotFound );
       
   900 	if ( LastWatchedSetL() )
       
   901         {
       
   902         error = iModel.GetLastWatchedPathL( path );
       
   903         }
       
   904     else if ( PreloadedExistsL() )
       
   905         {
       
   906         error = iModel.GetMyVideosCustomizationString( 
       
   907                      KCRVideoPlayerPreloadedVideoPath, path );
       
   908         }
       
   909 
       
   910     if ( !error && path.Length() && BaflUtils::FileExists( iModel.FileServerSessionL(), path ) )
       
   911         {
       
   912         CAknAppUi* appui = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi() );
       
   913     
       
   914         if ( appui )
       
   915             {
       
   916             appui->OpenFileL( path );
       
   917             iModel.SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStatePlayer );
       
   918             }
       
   919         }
       
   920     }
       
   921 
       
   922 // -----------------------------------------------------------------------------
       
   923 // CVcxHgMyVideosVideoModelHandler::LoadLastWatchedIconL()
       
   924 // 
       
   925 // -----------------------------------------------------------------------------
       
   926 // 
       
   927 void CVcxHgMyVideosCategoryModelHandler::LoadLastWatchedIconL()
       
   928     {
   990     if ( LastWatchedSetL() )
   929     if ( LastWatchedSetL() )
   991         {
   930         {    
   992         if (  iLastWatched && iLastWatched->IsSupported( KMPXMediaGeneralId ) )
   931         TBuf<KMaxPath> path;
   993             {
   932         TInt error = iModel.GetLastWatchedPathL( path );
   994             iModel.CollectionClient().PlayVideoL(
   933         
   995                         *iLastWatched->Value<TMPXItemId>( KMPXMediaGeneralId ) );
   934         if ( BaflUtils::FileExists( iModel.FileServerSessionL(), path ) )
   996     
       
   997             iModel.SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStatePlayer );
       
   998             }
       
   999         }
       
  1000     else
       
  1001         {
       
  1002         if ( PreloadedExistsL() )
       
  1003             {
       
  1004             CAknAppUi* appui = static_cast<CAknAppUi*>( CCoeEnv::Static()->AppUi() );
       
  1005             
       
  1006             if ( appui )
       
  1007                 {
       
  1008                 TBuf<KMaxPath> path;
       
  1009                 TInt error = iModel.GetMyVideosCustomizationString( 
       
  1010 				                         KCRVideoPlayerPreloadedVideoPath, path );
       
  1011                 appui->OpenFileL( path );
       
  1012                 iModel.SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStatePlayer );
       
  1013                 }
       
  1014             }
       
  1015         }
       
  1016     }
       
  1017 
       
  1018 // -----------------------------------------------------------------------------
       
  1019 // CVcxHgMyVideosVideoModelHandler::LoadLastWatchedIconL()
       
  1020 // 
       
  1021 // -----------------------------------------------------------------------------
       
  1022 // 
       
  1023 void CVcxHgMyVideosCategoryModelHandler::LoadLastWatchedIconL()
       
  1024     {
       
  1025     if ( LastWatchedSetL() )
       
  1026         {
       
  1027         if ( iLastWatched )
       
  1028             {
   935             {
  1029             CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( 
   936             CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( 
  1030                             iLastWatched->ValueText( KMPXMediaGeneralUri ),
   937                         path, 
  1031                             KNullDesC );
   938                         KNullDesC );
  1032             
       
  1033             iTnRequestId = iTnManager.GetL( *source );
   939             iTnRequestId = iTnManager.GetL( *source );
  1034             CleanupStack::PopAndDestroy( source );
   940             CleanupStack::PopAndDestroy( source );
  1035             }
   941             }
  1036         }
   942         }
  1037     else 
   943     else 
  1050             }
   956             }
  1051         }
   957         }
  1052 	}
   958 	}
  1053 
   959 
  1054 // -----------------------------------------------------------------------------
   960 // -----------------------------------------------------------------------------
       
   961 // CVcxHgMyVideosVideoModelHandler::ClearLastWatchedIconL()
       
   962 // 
       
   963 // -----------------------------------------------------------------------------
       
   964 // 
       
   965 void CVcxHgMyVideosCategoryModelHandler::ClearLastWatchedIconL()
       
   966     {        
       
   967     CHgItem& item = iScroller.ItemL( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
       
   968     item.ClearFlags( CHgItem::EHgItemFlagsIconOverlayIndicator );
       
   969     item.SetIcon( NULL );
       
   970     }
       
   971 
       
   972 // -----------------------------------------------------------------------------
  1055 // CVcxHgMyVideosVideoModelHandler::SetLastWatchedIndicatorL()
   973 // CVcxHgMyVideosVideoModelHandler::SetLastWatchedIndicatorL()
  1056 // 
   974 // 
  1057 // -----------------------------------------------------------------------------
   975 // -----------------------------------------------------------------------------
  1058 // 
   976 // 
  1059 void CVcxHgMyVideosCategoryModelHandler::SetLastWatchedIndicatorL()
   977 void CVcxHgMyVideosCategoryModelHandler::SetLastWatchedIndicatorL()
  1060     {
   978     {
  1061     if ( KErrNotFound != ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) ) 
   979     if ( KErrNotFound != ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) ) 
  1062         {
   980         {
  1063         CHgItem& lastWatchedItem = iScroller.ItemL(
   981         CHgItem& lastWatchedItem = iScroller.ItemL(
  1064                 ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
   982                 ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
  1065         if ( iLastWatched && VideoIndicatorL().IsIndicatorShown( *iLastWatched ) )
   983         TInt isIndicator( 0 );
       
   984         iModel.GetLastWatchedIndicatorL( isIndicator );
       
   985 		
       
   986         TBuf<KMaxPath> path;
       
   987         TInt error = iModel.GetLastWatchedPathL( path );
       
   988 		TBool exist = BaflUtils::FileExists( iModel.FileServerSessionL(), path );
       
   989         if ( isIndicator && path.Length() && exist )
  1066             {
   990             {
  1067             lastWatchedItem.SetFlags( CHgItem::EHgItemFlagsIconOverlayIndicator );
   991             lastWatchedItem.SetFlags( CHgItem::EHgItemFlagsIconOverlayIndicator );
  1068             }
   992             }
  1069         else
   993         else
  1070             {
   994             {
  1150             CleanupStack::PushL( thumbnail );
  1074             CleanupStack::PushL( thumbnail );
  1151             }
  1075             }
  1152         
  1076         
  1153         listItem.SetIcon( thumbnail ); // Takes ownership
  1077         listItem.SetIcon( thumbnail ); // Takes ownership
  1154         CleanupStack::Pop( thumbnail );
  1078         CleanupStack::Pop( thumbnail );
  1155         
  1079         SetLastWatchedIndicatorL();
  1156         iScroller.RefreshScreen( lastWatchedIndex );
  1080         iScroller.RefreshScreen( lastWatchedIndex );
  1157         }
  1081         }
  1158     }
  1082     }
  1159 
  1083 
  1160 
  1084 
  1293 // CVcxHgMyVideosVideoModelHandler::LastWatchedSetL()
  1217 // CVcxHgMyVideosVideoModelHandler::LastWatchedSetL()
  1294 // -----------------------------------------------------------------------------
  1218 // -----------------------------------------------------------------------------
  1295 //
  1219 //
  1296 TBool CVcxHgMyVideosCategoryModelHandler::LastWatchedSetL()
  1220 TBool CVcxHgMyVideosCategoryModelHandler::LastWatchedSetL()
  1297     {
  1221     {
  1298     TInt id;
  1222     TBuf<KMaxPath> path;
  1299     if ( !iModel.GetLastWatchedIdL( id ) && id )
  1223     TInt error = iModel.GetLastWatchedPathL( path );
       
  1224     TInt length = path.Length();
       
  1225     
       
  1226     if ( error == KErrNone && length > 0 )
  1300         {
  1227         {
  1301         return ETrue;
  1228         return ETrue;
  1302         }
  1229         }
  1303     else
  1230     else
  1304         {
  1231         {