videocollection/hgmyvideos/src/vcxhgmyvideoscategorymodelhandler.cpp
branchRCL_3
changeset 8 ce5ada96ab30
parent 0 96612d01cf9f
child 9 5294c000a26d
equal deleted inserted replaced
6:7d91903f795f 8:ce5ada96ab30
     1     /*
     1 /*
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of the License "Eclipse Public License v1.0"
     5 * under the terms of the License "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
    24 #include <mpxmedia.h>
    24 #include <mpxmedia.h>
    25 #include <mpxmediaarray.h>
    25 #include <mpxmediaarray.h>
    26 
    26 
    27 #include <ganes/HgScroller.h>
    27 #include <ganes/HgScroller.h>
    28 #include <ganes/HgItem.h>
    28 #include <ganes/HgItem.h>
    29 
    29 #include <ganes/HgDoubleGraphicList.h>
       
    30 
       
    31 #include <thumbnailmanager.h>
       
    32 #include <thumbnailmanagerobserver.h>
       
    33 #include <thumbnailobjectsource.h>
       
    34 #include <thumbnaildata.h>
       
    35 #include <gulicon.h>
       
    36 #include <AknsUtils.h>
       
    37 #include <AknUtils.h>
       
    38 #include <aknlayoutscalable_avkon.cdl.h>
       
    39 
       
    40 #include <vcxhgmyvideosicons.mbg>
       
    41 #include <myvideosindicator.h>
    30 #include <vcxhgmyvideos.rsg>
    42 #include <vcxhgmyvideos.rsg>
    31 #include <vcxmyvideosdefs.h>
    43 #include <vcxmyvideosdefs.h>
       
    44 #include <vcxmyvideosuids.h>
    32 #include "IptvDebug.h"
    45 #include "IptvDebug.h"
    33 
    46 
    34 #include "vcxhgmyvideoscategorymodelhandler.h"
    47 #include "vcxhgmyvideoscategorymodelhandler.h"
    35 #include "vcxhgmyvideosmodel.h"
    48 #include "vcxhgmyvideosmodel.h"
    36 #include "vcxhgmyvideoscollectionclient.h"
    49 #include "vcxhgmyvideoscollectionclient.h"
       
    50 #include "vcxhgmyvideosthumbnailmanager.h"
       
    51 #include "vcxhgmyvideoscenrepkeys.h"
       
    52 
       
    53 const TInt KMyVideosTitleStringMaxLength = 64;
       
    54 const TInt KMyVideosTitleUrlMaxLength    = 128;
       
    55 
       
    56 _LIT( KVcxHgMyVideosMifFile, "\\resource\\apps\\vcxhgmyvideosicons.mif" );
    37 
    57 
    38 // ============================ MEMBER FUNCTIONS ===============================
    58 // ============================ MEMBER FUNCTIONS ===============================
       
    59 
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CVcxHgMyVideosCategoryModelHandler::NewL()
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 CVcxHgMyVideosCategoryModelHandler* CVcxHgMyVideosCategoryModelHandler::NewL(
       
    66         CVcxHgMyVideosModel& aModel,
       
    67         CHgScroller& aScroller )
       
    68     {
       
    69     CVcxHgMyVideosCategoryModelHandler* self = 
       
    70         new (ELeave) CVcxHgMyVideosCategoryModelHandler( aModel, aScroller );
       
    71 
       
    72     return self;
       
    73     }
       
    74 
    39 
    75 
    40 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    41 // CVcxHgMyVideosCategoryModelHandler::CVcxHgMyVideosCategoryModelHandler()
    77 // CVcxHgMyVideosCategoryModelHandler::CVcxHgMyVideosCategoryModelHandler()
    42 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    43 //
    79 //
    44 CVcxHgMyVideosCategoryModelHandler::CVcxHgMyVideosCategoryModelHandler(
    80 CVcxHgMyVideosCategoryModelHandler::CVcxHgMyVideosCategoryModelHandler(
    45         CVcxHgMyVideosModel& aModel, CHgScroller& aScroller )
    81         CVcxHgMyVideosModel& aModel, CHgScroller& aScroller )
    46     : iModel( aModel ),
    82     : iModel( aModel ),
    47       iScroller( aScroller )
    83       iScroller( aScroller ),
       
    84       iTnManager( aModel.ThumbnailManager() ),
       
    85       iTnRequestId( KErrNotFound )
    48     {
    86     {
    49     }
    87     }
    50 
    88 
    51 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    52 // CVcxHgMyVideosCategoryModelHandler::~CVcxHgMyVideosCategoryModelHandler()
    90 // CVcxHgMyVideosCategoryModelHandler::~CVcxHgMyVideosCategoryModelHandler()
    53 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    54 //
    92 //
    55 CVcxHgMyVideosCategoryModelHandler::~CVcxHgMyVideosCategoryModelHandler()
    93 CVcxHgMyVideosCategoryModelHandler::~CVcxHgMyVideosCategoryModelHandler()
    56     {
    94     {
    57     delete iCategoryList;
    95     delete iCategoryList;
       
    96     delete iLastWatched;
       
    97     delete iVideoIndicator;
       
    98     
    58     iCategoryIdArray.Reset();
    99     iCategoryIdArray.Reset();
    59     }
   100     }
    60 
   101 
    61 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
    62 // CVcxHgMyVideosCategoryModelHandler::DoModelActivateL()
   103 // CVcxHgMyVideosCategoryModelHandler::DoModelActivateL()
    66     {
   107     {
    67     IPTVLOGSTRING_LOW_LEVEL( 
   108     IPTVLOGSTRING_LOW_LEVEL( 
    68         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelActivateL() - Enter" );
   109         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelActivateL() - Enter" );
    69 
   110 
    70     iModel.CollectionClient().SetCategoryModelObserver( this );
   111     iModel.CollectionClient().SetCategoryModelObserver( this );
       
   112 
       
   113     iTnManager.AddObserverL( *this );
    71     
   114     
    72     IPTVLOGSTRING_LOW_LEVEL( 
   115     IPTVLOGSTRING_LOW_LEVEL( 
    73         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelActivateL() - Exit" );
   116         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelActivateL() - Exit" );
    74     }
   117     }
    75 
   118 
    81     {
   124     {
    82     IPTVLOGSTRING_LOW_LEVEL( 
   125     IPTVLOGSTRING_LOW_LEVEL( 
    83         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelDeactivate() - Enter" );
   126         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelDeactivate() - Enter" );
    84 
   127 
    85     iModel.CollectionClient().SetCategoryModelObserver( NULL );
   128     iModel.CollectionClient().SetCategoryModelObserver( NULL );
       
   129 
       
   130     iTnManager.RemoveObserver( *this );
       
   131     
       
   132     delete iLastWatched;
       
   133     iLastWatched = NULL;
    86     
   134     
    87     IPTVLOGSTRING_LOW_LEVEL( 
   135     IPTVLOGSTRING_LOW_LEVEL( 
    88         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelDeactivate() - Exit" );
   136         "MPX My Videos UI # CVcxHgMyVideosCategoryModelHandler::DoModelDeactivate() - Exit" );
    89     }
   137     }
    90 
   138 
   114 
   162 
   115 // -----------------------------------------------------------------------------
   163 // -----------------------------------------------------------------------------
   116 // CVcxHgMyVideosCategoryModelHandler::GetCategoryNameLC()
   164 // CVcxHgMyVideosCategoryModelHandler::GetCategoryNameLC()
   117 // -----------------------------------------------------------------------------
   165 // -----------------------------------------------------------------------------
   118 // 
   166 // 
   119 HBufC* CVcxHgMyVideosCategoryModelHandler::GetCategoryNameLC( TInt aIndex )
   167 HBufC* CVcxHgMyVideosCategoryModelHandler::GetCategoryNameLC( TInt aCategoryId )
   120     {
   168     {
   121     HBufC* name = NULL;
   169     HBufC* name = NULL;
   122 
   170 
   123     switch ( aIndex )
   171     switch ( aCategoryId )
   124         {
   172         {
   125         case KVcxMvcCategoryIdAll:
   173         case KVcxMvcCategoryIdAll:
   126             name = StringLoader::LoadLC( R_VCXHGMYVIDEOS_STORAGE_ALL_LIST );
   174             name = StringLoader::LoadLC( R_VCXHGMYVIDEOS_STORAGE_ALL_LIST );
   127             break;
   175             break;
   128         case KVcxMvcCategoryIdDownloads:
   176         case KVcxMvcCategoryIdDownloads:
   132             name = StringLoader::LoadLC( R_VCXHGMYVIDEOS_STORAGE_CAPTURED_LIST );
   180             name = StringLoader::LoadLC( R_VCXHGMYVIDEOS_STORAGE_CAPTURED_LIST );
   133             break;            
   181             break;            
   134         case KVcxMvcCategoryIdOther:
   182         case KVcxMvcCategoryIdOther:
   135             name = StringLoader::LoadLC( R_VCXHGMYVIDEOS_STORAGE_OTHER_LIST );
   183             name = StringLoader::LoadLC( R_VCXHGMYVIDEOS_STORAGE_OTHER_LIST );
   136             break;            
   184             break;            
       
   185         case KCategoryIdLastWatched:
       
   186             name = StringLoader::LoadLC( R_VCXHGMYVIDEOS_LAST_WATCHED );
       
   187             break;            
       
   188         case KCategoryIdExtraItem1:
       
   189             // ExtraItem1 is always interpreted as Ovi Store
       
   190             name = StringLoader::LoadLC( R_VCXHGMYVIDEOS_OVI_STORE ); 
       
   191 			break;
       
   192         case KCategoryIdExtraItem2:
       
   193         case KCategoryIdExtraItem3:
       
   194             {
       
   195             TInt key = 0;
       
   196             if ( aCategoryId == KCategoryIdExtraItem2 )
       
   197                 {
       
   198                 key = KCRVideoPlayerExtraItem2Title;
       
   199                 }
       
   200             else if ( aCategoryId == KCategoryIdExtraItem3 )
       
   201                 {
       
   202                 key = KCRVideoPlayerExtraItem3Title;
       
   203                 }
       
   204 
       
   205             TBuf<KMyVideosTitleStringMaxLength> titleString;
       
   206             TInt error = iModel.GetMyVideosCustomizationString( key, titleString );
       
   207             if ( error == KErrNone )
       
   208                 {
       
   209                 name = titleString.AllocLC();
       
   210                 }
       
   211             else 
       
   212                 {
       
   213                 name = KNullDesC().AllocLC();
       
   214                 }
       
   215             }
       
   216             break;
       
   217             
   137         default:
   218         default:
   138             {
   219             {
       
   220             name = KNullDesC().AllocLC();
   139             IPTVLOGSTRING_LOW_LEVEL( 
   221             IPTVLOGSTRING_LOW_LEVEL( 
   140                 "MPX My Videos UI # GetCategoryNameLC() Unexpected category!" );
   222                 "MPX My Videos UI # GetCategoryNameLC() Unexpected category!" );
   141             }
   223             }
   142             break;
   224             break;
   143         }
   225         }
   144     return name;    
   226     return name;    
   145     }
   227     }
   146 
   228 
   147 // -----------------------------------------------------------------------------
   229 // -----------------------------------------------------------------------------
       
   230 // CVcxHgMyVideosCategoryModelHandler::GetCategoryIconL()
       
   231 // -----------------------------------------------------------------------------
       
   232 // 
       
   233 CGulIcon* CVcxHgMyVideosCategoryModelHandler::GetCategoryIconL( TInt aCategoryId )
       
   234     {
       
   235     IPTVLOGSTRING2_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::GetCategoryIconL() Enter! Category id = %d", aCategoryId );
       
   236 
       
   237     CGulIcon* icon( NULL );
       
   238     TInt bitmapId( 0 );
       
   239     TInt maskId( 0 );
       
   240     TInt key( KErrNotFound );
       
   241     TFileName iconFile( KNullDesC() );
       
   242     
       
   243     // Find icon file & bitmap IDs or cenrep keys
       
   244     switch ( aCategoryId )
       
   245         {
       
   246         case KVcxMvcCategoryIdDownloads:    // fall through
       
   247         case KVcxMvcCategoryIdAll:          // fall through
       
   248         case KVcxMvcCategoryIdOther:
       
   249             iconFile = KVcxHgMyVideosMifFile;
       
   250             bitmapId = EMbmVcxhgmyvideosiconsQgn_prop_download_thumbnail_video;
       
   251             maskId = EMbmVcxhgmyvideosiconsQgn_prop_download_thumbnail_video_mask;
       
   252             break;
       
   253         case KVcxMvcCategoryIdCaptured:
       
   254             iconFile = KVcxHgMyVideosMifFile;
       
   255             bitmapId = EMbmVcxhgmyvideosiconsQgn_prop_captured_thumbnail_video;
       
   256             maskId = EMbmVcxhgmyvideosiconsQgn_prop_captured_thumbnail_video_mask;
       
   257             break;
       
   258         case KCategoryIdLastWatched:
       
   259             // If no last watched, dont show default icon
       
   260             if ( iLastWatched )
       
   261                 {
       
   262                 iconFile = KVcxHgMyVideosMifFile;
       
   263                 bitmapId = EMbmVcxhgmyvideosiconsQgn_prop_recent_thumbnail_video;
       
   264                 maskId = EMbmVcxhgmyvideosiconsQgn_prop_recent_thumbnail_video_mask;
       
   265                 }
       
   266             break;
       
   267         case KCategoryIdExtraItem1:
       
   268             // ExtraItem1 is always interpreted as Ovi Store
       
   269             iconFile = KVcxHgMyVideosMifFile;
       
   270             bitmapId = EMbmVcxhgmyvideosiconsQgn_prop_ovi_thumbnail_video;
       
   271             maskId = EMbmVcxhgmyvideosiconsQgn_prop_ovi_thumbnail_video_mask;
       
   272             break;
       
   273         case KCategoryIdExtraItem2:
       
   274             key = KCRVideoPlayerExtraItem2IconPath;
       
   275             break;
       
   276         case KCategoryIdExtraItem3:
       
   277             key = KCRVideoPlayerExtraItem3IconPath;
       
   278             break;
       
   279         default:
       
   280             {
       
   281             IPTVLOGSTRING_LOW_LEVEL( 
       
   282                 "MPX My Videos UI # GetCategoryIconLC() Unexpected category!" );
       
   283             }
       
   284             break;
       
   285         }
       
   286 
       
   287     if ( key != KErrNotFound ) 
       
   288         {
       
   289         // Extra item 2 or 3, get icon file from cenrep
       
   290         TInt error = iModel.GetMyVideosCustomizationString( key, iconFile );
       
   291         if ( error == KErrNone && iconFile.Length() > 0 )
       
   292             {
       
   293             IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::GetCategoryIconL() cenrep key %d iconFile %S", key, &iconFile );
       
   294             bitmapId = 0x4000;
       
   295             maskId = 0x4001;
       
   296             }
       
   297         else
       
   298             { // Use default service icon
       
   299             iconFile = KVcxHgMyVideosMifFile;
       
   300             bitmapId = EMbmVcxhgmyvideosiconsQgn_prop_service_thumbnail_video;
       
   301             maskId = EMbmVcxhgmyvideosiconsQgn_prop_service_thumbnail_video_mask;
       
   302             }
       
   303         }
       
   304 
       
   305     if ( bitmapId && iconFile.Length() > 0 )
       
   306         {
       
   307         // find mif file
       
   308         TFindFile findFile( iModel.FileServerSessionL() );
       
   309         TInt error = findFile.FindByDir( iconFile, KNullDesC );
       
   310 
       
   311         // Create icon if icon file was found
       
   312         if ( KErrNone == error )
       
   313             {
       
   314             TParse parse;
       
   315             parse.Set( findFile.File(), NULL, NULL );
       
   316             iconFile = parse.FullName();
       
   317             IPTVLOGSTRING3_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::GetCategoryIconLC() get %d from file %S", bitmapId, &iconFile );
       
   318 
       
   319             icon = CreateHgListIconL( iconFile, bitmapId, maskId );
       
   320             }
       
   321         else
       
   322             {
       
   323             IPTVLOGSTRING2_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::GetCategoryIconL() FindByDir() returned %d", error );
       
   324             }
       
   325         }
       
   326     else
       
   327         {
       
   328         IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::GetCategoryIconLC() no icon file or id" );
       
   329         }
       
   330 
       
   331     return icon;    
       
   332     }
       
   333 
       
   334 // -----------------------------------------------------------------------------
   148 // CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC()
   335 // CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC()
   149 // -----------------------------------------------------------------------------
   336 // -----------------------------------------------------------------------------
   150 // 
   337 // 
   151 HBufC* CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC( CMPXMedia& aMedia )
   338 HBufC* CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC( CMPXMedia& aMedia )
   152     {
   339     {    
       
   340     if ( !aMedia.IsSupported( KMPXMediaGeneralType ) ||
       
   341           aMedia.ValueTObjectL<TMPXGeneralType>( KMPXMediaGeneralType ) != EMPXGroup )
       
   342         {
       
   343         if ( aMedia.IsSupported( KMPXMediaGeneralTitle ) )
       
   344             {
       
   345             return aMedia.ValueText( KMPXMediaGeneralTitle ).AllocLC(); 
       
   346             }
       
   347 	    else
       
   348 		    {
       
   349 			return KNullDesC().AllocLC();
       
   350 			}
       
   351         }
       
   352     
   153     HBufC* details = NULL;
   353     HBufC* details = NULL;
   154     HBufC* newVideoName = NULL;
       
   155     TInt newVideos = 0;
   354     TInt newVideos = 0;
   156     TInt videos = 0;
   355     TInt videos = 0;
   157 
   356 
   158     if ( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemCount ) )
   357     if ( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemCount ) )
   159         {
   358         {
   164         videos = *( aMedia.Value<TInt>( KVcxMediaMyVideosCategoryItemCount ) );
   363         videos = *( aMedia.Value<TInt>( KVcxMediaMyVideosCategoryItemCount ) );
   165         }
   364         }
   166 
   365 
   167     if ( newVideos > 0 )
   366     if ( newVideos > 0 )
   168         {
   367         {
   169         if ( aMedia.IsSupported( KVcxMediaMyVideosCategoryNewItemName ) )
   368         if ( newVideos == 1 )
   170             {
   369             {
   171             newVideoName = aMedia.ValueText( KVcxMediaMyVideosCategoryNewItemName ).AllocLC();
   370             details = StringLoader::LoadL( R_VCXHGMYVIDEOS_ONE_NEW_VIDEO );
   172             }
   371             }
   173         else
   372         else
   174             {
   373             {
   175             newVideoName = KNullDesC().AllocLC();
   374             details = StringLoader::LoadL( R_VCXHGMYVIDEOS_N_NEW_VIDEOS, newVideos );
   176             }
   375             }
   177 
       
   178         if ( newVideos == 1 )
       
   179             {
       
   180             details = StringLoader::LoadL( R_VCXHGMYVIDEOS_ONE_NEW_VIDEO, *newVideoName );
       
   181             }
       
   182         else
       
   183             {
       
   184             CDesCArrayFlat* arrayForStrings = new ( ELeave ) CDesCArrayFlat( 1 );
       
   185             CleanupStack::PushL( arrayForStrings );
       
   186             arrayForStrings->AppendL( *newVideoName );
       
   187             
       
   188             CArrayFixFlat<TInt>* arrayForInts = new ( ELeave ) CArrayFixFlat<TInt>( 3 );
       
   189             CleanupStack::PushL( arrayForInts );
       
   190             arrayForInts->AppendL( newVideos );
       
   191             
       
   192             details = StringLoader::LoadL( R_VCXHGMYVIDEOS_N_NEW_VIDEOS,
       
   193                                            *arrayForStrings,
       
   194                                            *arrayForInts );
       
   195             
       
   196             CleanupStack::PopAndDestroy( arrayForInts );
       
   197             CleanupStack::PopAndDestroy( arrayForStrings );
       
   198             }
       
   199         
       
   200         CleanupStack::PopAndDestroy( newVideoName );
       
   201         CleanupStack::PushL( details );
   376         CleanupStack::PushL( details );
   202         }
   377         }
   203     else
   378     else
   204         {
   379         {
   205         if ( videos == 0 )
   380         if ( videos == 0 )
   215             details = StringLoader::LoadLC( R_VCXHGMYVIDEOS_VIDEOS_IN_CATEGORY, videos );
   390             details = StringLoader::LoadLC( R_VCXHGMYVIDEOS_VIDEOS_IN_CATEGORY, videos );
   216             }        
   391             }        
   217         }
   392         }
   218 
   393 
   219     return details;
   394     return details;
       
   395     }
       
   396 
       
   397 
       
   398 // -----------------------------------------------------------------------------
       
   399 // CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC()
       
   400 // -----------------------------------------------------------------------------
       
   401 // 
       
   402 HBufC* CVcxHgMyVideosCategoryModelHandler::FormatCategorySecondRowLC( TInt aCategoryId )
       
   403     {
       
   404     HBufC* secondRow = NULL;
       
   405    
       
   406     switch ( aCategoryId )
       
   407         {
       
   408         case KVcxMvcCategoryIdAll:
       
   409         case KVcxMvcCategoryIdDownloads:
       
   410         case KVcxMvcCategoryIdTvRecordings:
       
   411         case KVcxMvcCategoryIdCaptured:
       
   412         case KVcxMvcCategoryIdOther:
       
   413         case KCategoryIdLastWatched:
       
   414             {
       
   415             CMPXMedia* media = GetCategoryDataL( aCategoryId );
       
   416             if ( media )
       
   417                 {
       
   418                 secondRow = FormatCategorySecondRowLC( *media );
       
   419                 }
       
   420 			else
       
   421 			    {
       
   422 				secondRow = KNullDesC().AllocLC();
       
   423 				}
       
   424             }
       
   425             break;
       
   426         case KCategoryIdExtraItem1:
       
   427             // ExtraItem1 is always interpreted as Ovi Store
       
   428             secondRow = StringLoader::LoadLC( R_VCXHGMYVIDEOS_OVI_STORE_VIDEOS ); 
       
   429             break;
       
   430             
       
   431         case KCategoryIdExtraItem2:
       
   432         case KCategoryIdExtraItem3:
       
   433             {
       
   434             TInt key = 0;
       
   435             if ( aCategoryId == KCategoryIdExtraItem2 )
       
   436                 {
       
   437                 key = KCRVideoPlayerExtraItem2Text;
       
   438                 }
       
   439             else if ( aCategoryId == KCategoryIdExtraItem3 )
       
   440                 {
       
   441                 key = KCRVideoPlayerExtraItem3Text;
       
   442                 }
       
   443             
       
   444             TBuf<KMyVideosTitleStringMaxLength> detailsString;
       
   445             TInt error = iModel.GetMyVideosCustomizationString( key, detailsString );
       
   446             if ( error == KErrNone )
       
   447                 {
       
   448                 secondRow = detailsString.AllocLC();
       
   449                 }
       
   450             else 
       
   451                 {
       
   452                 secondRow = KNullDesC().AllocLC();
       
   453                 }
       
   454             break;
       
   455             }
       
   456         default:
       
   457             {
       
   458             secondRow = KNullDesC().AllocLC();
       
   459             IPTVLOGSTRING_LOW_LEVEL( 
       
   460                 "MPX My Videos UI # FormatCategorySecondRowLC() Unexpected category!" );
       
   461             break;
       
   462             }
       
   463         }
       
   464     return secondRow;
   220     }
   465     }
   221 
   466 
   222 // -----------------------------------------------------------------------------
   467 // -----------------------------------------------------------------------------
   223 // CVcxHgMyVideosCategoryModelHandler::UiIndexFromMpxItemId()
   468 // CVcxHgMyVideosCategoryModelHandler::UiIndexFromMpxItemId()
   224 // -----------------------------------------------------------------------------
   469 // -----------------------------------------------------------------------------
   242                 {
   487                 {
   243                 mpxItemId = *media->Value<TMPXItemId>( KMPXMediaGeneralId );
   488                 mpxItemId = *media->Value<TMPXItemId>( KMPXMediaGeneralId );
   244             
   489             
   245                 if ( mpxItemId == aMpxItemId )
   490                 if ( mpxItemId == aMpxItemId )
   246                     {
   491                     {
   247                     index = ResolveCategoryArrayIndexById( i );                                        
   492                     index = ResolveCategoryArrayIndexById( i );
   248                     break;
   493                     break;
   249                     }
   494                     }
   250                 }
   495                 }
   251             }
   496             }
   252         }
   497         }
   259 // CVcxHgMyVideosCategoryModelHandler::ResolveCategoryArrayIndexById()
   504 // CVcxHgMyVideosCategoryModelHandler::ResolveCategoryArrayIndexById()
   260 // -----------------------------------------------------------------------------
   505 // -----------------------------------------------------------------------------
   261 // 
   506 // 
   262 TInt CVcxHgMyVideosCategoryModelHandler::ResolveCategoryArrayIndexById( TInt aCategoryId )
   507 TInt CVcxHgMyVideosCategoryModelHandler::ResolveCategoryArrayIndexById( TInt aCategoryId )
   263     {
   508     {
   264     TInt ret( 0 );
   509     TInt ret( KErrNotFound );
       
   510     
   265     for(TInt i = 0; i < iCategoryIdArray.Count(); i++ )
   511     for(TInt i = 0; i < iCategoryIdArray.Count(); i++ )
   266         {
   512         {
   267         if( iCategoryIdArray[ i ] == aCategoryId )
   513         if( iCategoryIdArray[ i ] == aCategoryId )
   268             {
   514             {
   269             ret = i;
   515             ret = i;
   270             break;
   516             break;
   271             }
   517             }
   272         }  
   518         }  
       
   519     
   273     return ret;
   520     return ret;
   274     }
   521     }
   275     
   522     
   276 // -----------------------------------------------------------------------------
   523 // -----------------------------------------------------------------------------
   277 // CVcxHgMyVideosCategoryModelHandler::NewCategoryListL()
   524 // CVcxHgMyVideosCategoryModelHandler::NewCategoryListL()
   278 // MPX Collection calls this callback when new category list is available.
   525 // MPX Collection calls this callback when new category list is available.
   279 // -----------------------------------------------------------------------------
   526 // -----------------------------------------------------------------------------
   280 // 
   527 // 
   281 void CVcxHgMyVideosCategoryModelHandler::NewCategoryListL( 
   528 void CVcxHgMyVideosCategoryModelHandler::NewCategoryListL( 
   282         CMPXMediaArray* aCategoryList )
   529         CMPXMediaArray* aCategoryList, TBool aIsPartial )
   283     {
   530     {
   284     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # NewCategoryListL() - Enter" );
   531     IPTVLOGSTRING2_LOW_LEVEL( "MPX My Videos UI # NewCategoryListL() - Enter. IsPartial=%d", aIsPartial );
   285 
   532 
   286     delete iCategoryList;
   533     delete iCategoryList;
   287     iCategoryList = aCategoryList;
   534     iCategoryList = aCategoryList;
   288     
   535     
   289     UpdateCategoryListL();
   536     UpdateCategoryListL();
       
   537 	
       
   538     if ( !aIsPartial )
       
   539         {
       
   540         // KVcxMessageMyVideosListComplete does not come, finish list fetching now
       
   541         CategoryListFetchingCompletedL();
       
   542         }
   290     
   543     
   291     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # NewCategoryListL() - Exit" );
   544     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # NewCategoryListL() - Exit" );
   292     }
   545     }
   293 
   546 
   294 // -----------------------------------------------------------------------------
   547 // -----------------------------------------------------------------------------
   299 void CVcxHgMyVideosCategoryModelHandler::CategoryListModifiedL()
   552 void CVcxHgMyVideosCategoryModelHandler::CategoryListModifiedL()
   300     { 
   553     { 
   301     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListModifiedL() - Enter" );
   554     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListModifiedL() - Enter" );
   302     
   555     
   303     UpdateCategoryListL();
   556     UpdateCategoryListL();
   304         
   557     
       
   558     FetchLastWatchedL();
       
   559     SetLastWatchedIndicatorL();
       
   560     
   305     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListModifiedL() - Exit" );
   561     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListModifiedL() - Exit" );
   306     }
   562     }
   307 
   563 
   308 // -----------------------------------------------------------------------------
   564 // -----------------------------------------------------------------------------
   309 // CVcxHgMyVideosCategoryModelHandler::CategoryModifiedL()
   565 // CVcxHgMyVideosCategoryModelHandler::CategoryModifiedL()
   325             iScroller.RefreshScreen( uiIndex );
   581             iScroller.RefreshScreen( uiIndex );
   326             }
   582             }
   327             break;
   583             break;
   328             
   584             
   329         case EMPXItemInserted:
   585         case EMPXItemInserted:
       
   586             {
       
   587             if ( !iLastWatched )
       
   588                 {
       
   589                 TInt id1( 0 );
       
   590                 TInt ret = iModel.GetLastWatchedIdL( id1 );
       
   591                 TMPXItemId id ( id1 );
       
   592                 
       
   593                 if (  ret == KErrNone &&
       
   594                       id1 == aMpxItemId.iId1 )
       
   595                     {
       
   596                     FetchLastWatchedL();
       
   597                     }
       
   598                 }
       
   599             }
       
   600             break;
   330         case EMPXItemDeleted:
   601         case EMPXItemDeleted:
       
   602             {
       
   603             if ( iLastWatched && 
       
   604                  iLastWatched->IsSupported( KMPXMediaGeneralId ) &&
       
   605                  iLastWatched->Value<TMPXItemId>( KMPXMediaGeneralId )->iId1 == aMpxItemId.iId1 )
       
   606                 {
       
   607                 delete iLastWatched;
       
   608                 iLastWatched = NULL;
       
   609                 
       
   610                 UpdateCategoryListItemL( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
       
   611                 SetLastWatchedIndicatorL();
       
   612                 }
       
   613             }
       
   614             break;
   331         default:
   615         default:
   332             {
   616             {
   333             IPTVLOGSTRING_LOW_LEVEL( 
   617             IPTVLOGSTRING_LOW_LEVEL( 
   334                 "MPX My Videos UI # CategoryModifiedL() Unexpected event!" );
   618                 "MPX My Videos UI # CategoryModifiedL() Unexpected event!" );
   335             }
   619             }
   391         aListIndex < iScroller.ItemCount() &&
   675         aListIndex < iScroller.ItemCount() &&
   392         aListIndex < iCategoryIdArray.Count() )
   676         aListIndex < iCategoryIdArray.Count() )
   393         {
   677         {
   394         CHgItem& listItem = iScroller.ItemL( aListIndex );
   678         CHgItem& listItem = iScroller.ItemL( aListIndex );
   395         
   679         
   396         CMPXMedia* media( NULL );        
       
   397         media = (*iCategoryList)[ iCategoryIdArray[ aListIndex ] ];
       
   398         
       
   399         HBufC* categoryName( NULL );     
   680         HBufC* categoryName( NULL );     
   400         categoryName = GetCategoryNameLC( iCategoryIdArray[ aListIndex ] );
   681         categoryName = GetCategoryNameLC( iCategoryIdArray[ aListIndex ] );
   401         
   682         listItem.SetTitleL( *categoryName );
   402         if ( categoryName && media )
   683         CleanupStack::PopAndDestroy( categoryName );
   403             {
   684 
   404             // Insert the category name into first row of list item.
   685         HBufC* secondRow( NULL );
   405             listItem.SetTitleL( *categoryName );
   686         secondRow = FormatCategorySecondRowLC( iCategoryIdArray[ aListIndex ] );
   406             CleanupStack::PopAndDestroy( categoryName );
   687         listItem.SetTextL( *secondRow );
   407                     
   688         CleanupStack::PopAndDestroy( secondRow );
   408             // Insert video count into second row of list item.
   689 
   409             HBufC* secondRow( NULL );
   690         // Set icon for category
   410             secondRow = FormatCategorySecondRowLC( *media );
   691         listItem.SetIcon( GetCategoryIconL( iCategoryIdArray[ aListIndex ] ) );
   411             listItem.SetTextL( *secondRow );
       
   412             CleanupStack::PopAndDestroy( secondRow );            
       
   413             }
       
   414         else
       
   415             {
       
   416             // If category name or media was not found then 
       
   417             // the whole list item should be removed.
       
   418             RemoveCategoryListItem( aListIndex );
       
   419             }
       
   420         }
   692         }
   421         
   693         
   422     IPTVLOGSTRING_LOW_LEVEL( 
   694     IPTVLOGSTRING_LOW_LEVEL( 
   423         "MPX My Videos UI # UpdateCategoryListItemL() - Exit" );
   695         "MPX My Videos UI # UpdateCategoryListItemL() - Exit" );
   424     }
   696     }
   440 // -----------------------------------------------------------------------------
   712 // -----------------------------------------------------------------------------
   441 //
   713 //
   442 TInt CVcxHgMyVideosCategoryModelHandler::ResolveCategoryId( TInt aScrollerIndex )
   714 TInt CVcxHgMyVideosCategoryModelHandler::ResolveCategoryId( TInt aScrollerIndex )
   443     {
   715     {
   444     TInt ret( -1 );
   716     TInt ret( -1 );
   445     if ( aScrollerIndex <= iCategoryIdArray.Count() )
   717     if ( aScrollerIndex >= 0 &&
       
   718          aScrollerIndex <= iCategoryIdArray.Count() )
   446         {
   719         {
   447         ret = iCategoryIdArray[ aScrollerIndex ];
   720         ret = iCategoryIdArray[ aScrollerIndex ];
   448         }  
   721         }  
   449     return ret;
   722     return ret;
   450     }
   723     }
   458     IPTVLOGSTRING2_LOW_LEVEL( 
   731     IPTVLOGSTRING2_LOW_LEVEL( 
   459             "MPX My Videos UI # MakeCategoryArray (number of categories=%d)", aCategoriesAvailable );
   732             "MPX My Videos UI # MakeCategoryArray (number of categories=%d)", aCategoriesAvailable );
   460     
   733     
   461     iCategoryIdArray.Reset();    
   734     iCategoryIdArray.Reset();    
   462     
   735     
   463     for(TInt i = 0; i < aCategoriesAvailable; i++)
   736     TInt error = KErrNone;
   464         {
   737     TInt value = KErrNotFound;
   465         if( AcceptCategory( i ) )
   738     TInt categoryId = KErrNotFound;
   466             {
   739     
   467             iCategoryIdArray.Append( i );        
   740     // Check that cenrep exists and has some valid data
   468             }        
   741     error = iModel.GetMyVideosCustomizationInt( KCRVideoPlayerItemLocation1, value );
       
   742     
       
   743     if ( error == KErrNone && value > EMyVideosListItemTypeEmpty )
       
   744         {
       
   745         IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # MakeCategoryIdArray() Getting category items from cenrep" ); 
       
   746 
       
   747         for ( TInt i=KCRVideoPlayerItemLocation1; i<=KCRVideoPlayerItemLocation7; i++ )    
       
   748             {
       
   749             error = iModel.GetMyVideosCustomizationInt( i , value );
       
   750             if ( error == KErrNone && value != EMyVideosListItemTypeEmpty )
       
   751                 {
       
   752                 switch ( value )
       
   753                     {
       
   754                     case EMyVideosListItemTypeLastWatched:
       
   755                         categoryId = KCategoryIdLastWatched;
       
   756                         break;        
       
   757                     case EMyVideosListItemTypeCapturedVideos:
       
   758                         categoryId = KVcxMvcCategoryIdCaptured;
       
   759                         break;
       
   760                     case EMyVideosListItemTypeOtherVideos:
       
   761                         categoryId = KVcxMvcCategoryIdOther;
       
   762                         break;                        
       
   763                     case EMyVideosListItemTypeExtra1:
       
   764                         categoryId = KCategoryIdExtraItem1;
       
   765                         break;                        
       
   766                     case EMyVideosListItemTypeExtra2:
       
   767                         categoryId = KCategoryIdExtraItem2;
       
   768                         break;                        
       
   769                     case EMyVideosListItemTypeExtra3:
       
   770                         categoryId = KCategoryIdExtraItem3;
       
   771                         break;
       
   772                     case EMyVideosListItemTypeEmpty:
       
   773                         categoryId = KErrNotFound;
       
   774                         break;
       
   775                     default:
       
   776                         categoryId = KErrNotFound;
       
   777                         break;
       
   778                     }
       
   779                 
       
   780                 if ( AcceptCategory( categoryId ) )
       
   781                     {
       
   782                     iCategoryIdArray.Append( categoryId );
       
   783                     }
       
   784                 }
       
   785             }
       
   786         }
       
   787     else
       
   788         {
       
   789         IPTVLOGSTRING_LOW_LEVEL( 
       
   790             "MPX My Videos UI # MakeCategoryIdArray() Could not access CenRep!" ); 
       
   791     
       
   792         // If cenrep access fails then use these values as backup
       
   793 	    iCategoryIdArray.Append( KCategoryIdLastWatched );
       
   794 		
       
   795     	for(TInt i = 0; i < aCategoriesAvailable; i++)
       
   796         	{
       
   797 	        if( AcceptCategory( i ) )
       
   798     	        {
       
   799         	    iCategoryIdArray.Append( i );        
       
   800             	}        
       
   801         	}
   469         }
   802         }
   470     }
   803     }
   471 
   804 
   472 // -----------------------------------------------------------------------------
   805 // -----------------------------------------------------------------------------
   473 // CVcxHgMyVideosCategoryModelHandler::AcceptCategory()
   806 // CVcxHgMyVideosCategoryModelHandler::AcceptCategory()
   477     {
   810     {
   478     TBool ret(EFalse);
   811     TBool ret(EFalse);
   479     switch ( aCategoryId )
   812     switch ( aCategoryId )
   480         {
   813         {
   481         case KVcxMvcCategoryIdAll:
   814         case KVcxMvcCategoryIdAll:
   482         case KVcxMvcCategoryIdDownloads:
       
   483         case KVcxMvcCategoryIdCaptured:
   815         case KVcxMvcCategoryIdCaptured:
   484         case KVcxMvcCategoryIdOther:
   816         case KVcxMvcCategoryIdOther:
       
   817         case KCategoryIdLastWatched:
       
   818         case KCategoryIdExtraItem1:
       
   819         case KCategoryIdExtraItem2:
       
   820         case KCategoryIdExtraItem3:
   485             IPTVLOGSTRING2_LOW_LEVEL( 
   821             IPTVLOGSTRING2_LOW_LEVEL( 
   486                     "MPX My Videos UI # AcceptCategory() Accepted category: %d", aCategoryId );
   822                     "MPX My Videos UI # AcceptCategory() Accepted category: %d", aCategoryId );
   487             ret = ETrue;
   823             ret = ETrue;
   488             break;
   824             break;
   489         default:
   825         default:
   490             IPTVLOGSTRING2_LOW_LEVEL( 
   826             IPTVLOGSTRING2_LOW_LEVEL( 
   491                     "MPX My Videos UI # AcceptCategory() Uknowns category: %d", aCategoryId );
   827                     "MPX My Videos UI # AcceptCategory() Unknown category: %d", aCategoryId );
   492             break;            
   828             break;            
   493         }
   829         }
   494     
   830     
   495     return ret;
   831     return ret;
   496     }
   832     }
       
   833 
       
   834 // -----------------------------------------------------------------------------
       
   835 // CVcxHgMyVideosVideoModelHandler::VideoFetchingCompletedL()
       
   836 // MPX Collection calls this callback when a single video has fetched.
       
   837 // -----------------------------------------------------------------------------
       
   838 // 
       
   839 void CVcxHgMyVideosCategoryModelHandler::VideoFetchingCompletedL( CMPXMedia* aVideo )
       
   840     {
       
   841     TInt id( 0 );
       
   842     
       
   843     TInt ret = iModel.GetLastWatchedIdL( id );
       
   844                     
       
   845     if ( ret == KErrNone && 
       
   846          id && 
       
   847 		 aVideo &&
       
   848          aVideo->IsSupported( KMPXMediaGeneralId ) &&
       
   849          aVideo->Value<TMPXItemId>( KMPXMediaGeneralId )->iId1 == id )
       
   850         {
       
   851         delete iLastWatched;
       
   852         iLastWatched = aVideo;
       
   853 		
       
   854 		LoadLastWatchedIconL();
       
   855 		SetLastWatchedIndicatorL();
       
   856         }
       
   857     else 
       
   858 		{
       
   859 		delete aVideo;
       
   860 		aVideo = NULL;
       
   861 		}
       
   862     
       
   863     UpdateCategoryListItemL( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
       
   864     iScroller.RefreshScreen( ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
       
   865     }
       
   866 
       
   867 // -----------------------------------------------------------------------------
       
   868 // MPX Collection calls this callback when category list items have been fetched.
       
   869 // -----------------------------------------------------------------------------
       
   870 // 
       
   871 void CVcxHgMyVideosCategoryModelHandler::CategoryListFetchingCompletedL()
       
   872     {
       
   873     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # CategoryListFetchingCompletedL()" ); 
       
   874     FetchLastWatchedL();
       
   875     SetLastWatchedIndicatorL();
       
   876     }
       
   877 
       
   878 // -----------------------------------------------------------------------------
       
   879 // CVcxHgMyVideosVideoModelHandler::GetCategoryDataL()
       
   880 // 
       
   881 // -----------------------------------------------------------------------------
       
   882 // 
       
   883 CMPXMedia* CVcxHgMyVideosCategoryModelHandler::GetCategoryDataL( TInt aCategoryId )
       
   884     {
       
   885     if ( aCategoryId == KCategoryIdLastWatched )
       
   886         {
       
   887         return iLastWatched;
       
   888         }
       
   889     
       
   890     if ( aCategoryId >= 0 && iCategoryList->Count() > aCategoryId )
       
   891         {
       
   892         return (*iCategoryList)[ aCategoryId ];
       
   893         }
       
   894     
       
   895     return NULL;
       
   896     }
       
   897 
       
   898 // -----------------------------------------------------------------------------
       
   899 // CVcxHgMyVideosVideoModelHandler::FetchLastWatchedL()
       
   900 // 
       
   901 // -----------------------------------------------------------------------------
       
   902 // 
       
   903 void CVcxHgMyVideosCategoryModelHandler::FetchLastWatchedL()
       
   904     {
       
   905     TInt id1( 0 );
       
   906     TInt ret = iModel.GetLastWatchedIdL( id1 );
       
   907     TMPXItemId id ( id1 );
       
   908     
       
   909     if (  id1 != 0 && 
       
   910           KErrNone == ret )
       
   911         {
       
   912         if ( !iLastWatched ||
       
   913 		    ( iLastWatched &&
       
   914               iLastWatched->IsSupported( KMPXMediaGeneralId ) &&
       
   915               iLastWatched->Value<TMPXItemId>( KMPXMediaGeneralId )->iId1 != id1 ))
       
   916             {
       
   917             iModel.CollectionClient().FetchMpxMediaByMpxIdL( id );
       
   918             } 
       
   919         }
       
   920     }
       
   921 
       
   922 // -----------------------------------------------------------------------------
       
   923 // CVcxHgMyVideosVideoModelHandler::PlayLastWatchedVidedoL()
       
   924 // 
       
   925 // -----------------------------------------------------------------------------
       
   926 // 
       
   927 void CVcxHgMyVideosCategoryModelHandler::PlayLastWatchedVidedoL()
       
   928     {
       
   929     if (  iLastWatched && iLastWatched->IsSupported( KMPXMediaGeneralId ) )
       
   930         {
       
   931         iModel.CollectionClient().PlayVideoL(
       
   932                     *iLastWatched->Value<TMPXItemId>( KMPXMediaGeneralId ) );
       
   933 
       
   934         iModel.SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStatePlayer );
       
   935         }
       
   936     }
       
   937 
       
   938 // -----------------------------------------------------------------------------
       
   939 // CVcxHgMyVideosVideoModelHandler::LoadLastWatchedIconL()
       
   940 // 
       
   941 // -----------------------------------------------------------------------------
       
   942 // 
       
   943 void CVcxHgMyVideosCategoryModelHandler::LoadLastWatchedIconL()
       
   944     {
       
   945     CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( 
       
   946                     iLastWatched->ValueText( KMPXMediaGeneralUri ),
       
   947                     KNullDesC );
       
   948     
       
   949     iTnRequestId = iTnManager.GetL( *source );
       
   950     CleanupStack::PopAndDestroy( source );
       
   951 	}
       
   952 
       
   953 // -----------------------------------------------------------------------------
       
   954 // CVcxHgMyVideosVideoModelHandler::SetLastWatchedIndicatorL()
       
   955 // 
       
   956 // -----------------------------------------------------------------------------
       
   957 // 
       
   958 void CVcxHgMyVideosCategoryModelHandler::SetLastWatchedIndicatorL()
       
   959     {
       
   960     if ( KErrNotFound != ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) ) 
       
   961         {
       
   962         CHgItem& lastWatchedItem = iScroller.ItemL(
       
   963                 ResolveCategoryArrayIndexById( KCategoryIdLastWatched ) );
       
   964         if ( iLastWatched && VideoIndicatorL().IsIndicatorShown( *iLastWatched ) )
       
   965             {
       
   966             lastWatchedItem.SetFlags( CHgItem::EHgItemFlagsIconOverlayIndicator );
       
   967             }
       
   968         else
       
   969             {
       
   970             lastWatchedItem.ClearFlags( CHgItem::EHgItemFlagsIconOverlayIndicator );
       
   971             }
       
   972         }
       
   973     }
       
   974 
       
   975 // -----------------------------------------------------------------------------
       
   976 // CVcxHgMyVideosVideoModelHandler::VideoIndicatorL()
       
   977 // 
       
   978 // -----------------------------------------------------------------------------
       
   979 // 
       
   980 CMyVideosIndicator& CVcxHgMyVideosCategoryModelHandler::VideoIndicatorL()
       
   981     {
       
   982     if ( !iVideoIndicator )
       
   983         {
       
   984         iVideoIndicator = CMyVideosIndicator::NewL();
       
   985         }
       
   986     return *iVideoIndicator;
       
   987     }
       
   988 
       
   989 // -----------------------------------------------------------------------------
       
   990 // CVcxHgMyVideosVideoModelHandler::ThumbnailPreviewReady()
       
   991 // 
       
   992 // -----------------------------------------------------------------------------
       
   993 // 
       
   994 void CVcxHgMyVideosCategoryModelHandler::ThumbnailPreviewReady( 
       
   995                 MThumbnailData& /*aThumbnail*/,
       
   996                 TThumbnailRequestId /*aId*/ )
       
   997     {
       
   998     // No implementation
       
   999     }
       
  1000 
       
  1001 // -----------------------------------------------------------------------------
       
  1002 // CVcxHgMyVideosVideoModelHandler::ThumbnailReady()
       
  1003 // 
       
  1004 // -----------------------------------------------------------------------------
       
  1005 // 
       
  1006 void CVcxHgMyVideosCategoryModelHandler::ThumbnailReady( 
       
  1007                 TInt aError, 
       
  1008                 MThumbnailData& aThumbnail,
       
  1009                 TThumbnailRequestId aId )
       
  1010     {
       
  1011     if ( aId == iTnRequestId )
       
  1012         {
       
  1013         iTnRequestId = KErrNotFound;
       
  1014         
       
  1015         TRAP_IGNORE( ThumbnailReadyL( aError, aThumbnail, aId ) );
       
  1016         }
       
  1017     }
       
  1018 
       
  1019 // -----------------------------------------------------------------------------
       
  1020 // CVcxHgMyVideosVideoModelHandler::ThumbnailReady()
       
  1021 // 
       
  1022 // -----------------------------------------------------------------------------
       
  1023 // 
       
  1024 void CVcxHgMyVideosCategoryModelHandler::ThumbnailReadyL( 
       
  1025                 TInt aError, 
       
  1026                 MThumbnailData& aThumbnail,
       
  1027                 TThumbnailRequestId /*aId*/ )
       
  1028     {
       
  1029     TInt lastWatchedIndex = ResolveCategoryArrayIndexById( KCategoryIdLastWatched );
       
  1030     if ( lastWatchedIndex != KErrNotFound )
       
  1031         {
       
  1032         CHgItem& listItem = iScroller.ItemL( lastWatchedIndex );
       
  1033         CGulIcon* thumbnail( NULL );
       
  1034         
       
  1035         if ( !aError )
       
  1036             {
       
  1037             thumbnail = CGulIcon::NewL( aThumbnail.DetachBitmap() );
       
  1038             CleanupStack::PushL( thumbnail );
       
  1039             }
       
  1040         else
       
  1041             {
       
  1042             TFileName iconFile( KVcxHgMyVideosMifFile );
       
  1043             thumbnail = CreateHgListIconL( iconFile, 
       
  1044                 EMbmVcxhgmyvideosiconsQgn_prop_recent_thumbnail_video, 
       
  1045                 EMbmVcxhgmyvideosiconsQgn_prop_recent_thumbnail_video_mask );
       
  1046 
       
  1047             CleanupStack::PushL( thumbnail );
       
  1048             }
       
  1049         
       
  1050         listItem.SetIcon( thumbnail ); // Takes ownership
       
  1051         CleanupStack::Pop( thumbnail );
       
  1052         
       
  1053         iScroller.RefreshScreen( lastWatchedIndex );
       
  1054         }
       
  1055     }
       
  1056 
       
  1057 
       
  1058 // -----------------------------------------------------------------------------
       
  1059 // CVcxHgMyVideosVideoModelHandler::HandleExtraItemSelectionL()
       
  1060 // 
       
  1061 // -----------------------------------------------------------------------------
       
  1062 // 
       
  1063 void CVcxHgMyVideosCategoryModelHandler::HandleExtraItemSelectionL( 
       
  1064         TInt categoryId,
       
  1065         TVcxHgMyVideosCategoryItemType& aItemType,
       
  1066         TUid& aUid,
       
  1067         TDes& aUrl )
       
  1068     {
       
  1069     TInt uidKey = 0;
       
  1070     TInt urlKey = 0;
       
  1071    
       
  1072     aItemType = TVcxHgMyVideosCategoryItemTypeUndefined;
       
  1073     
       
  1074     switch ( categoryId )
       
  1075         {
       
  1076         case KCategoryIdExtraItem1:
       
  1077             {
       
  1078             uidKey = KCRVideoPlayerExtraItem1Uid;
       
  1079             urlKey = KCRVideoPlayerExtraItem1Url;                   
       
  1080             break;
       
  1081             }
       
  1082         case KCategoryIdExtraItem2:
       
  1083             {
       
  1084             uidKey = KCRVideoPlayerExtraItem2Uid;
       
  1085             urlKey = KCRVideoPlayerExtraItem2Url;                    
       
  1086             break;
       
  1087             }
       
  1088         case KCategoryIdExtraItem3:
       
  1089             {
       
  1090             uidKey = KCRVideoPlayerExtraItem3Uid;
       
  1091             urlKey = KCRVideoPlayerExtraItem3Url;                   
       
  1092             break;
       
  1093             }
       
  1094         default:
       
  1095             return;
       
  1096         }
       
  1097     
       
  1098     TBuf<KMyVideosTitleUrlMaxLength> urlString;
       
  1099     TInt uidInt( 0 ) ;
       
  1100     
       
  1101     // Try to get web link URL first.
       
  1102     TInt error = iModel.GetMyVideosCustomizationString( urlKey, urlString );
       
  1103     if ( error == KErrNone && urlString.Size() > 0 )
       
  1104         {
       
  1105         aUrl = urlString;
       
  1106         aItemType = TVcxHgMyVideosCategoryItemTypeUrl;
       
  1107         }
       
  1108     else 
       
  1109         {
       
  1110         // If URL is not found try to fetch application UID.
       
  1111         error = iModel.GetMyVideosCustomizationInt( uidKey, uidInt );
       
  1112         if ( error == KErrNone && uidInt != 0 )
       
  1113             {
       
  1114             aUid = TUid::Uid( uidInt );
       
  1115             aItemType = TVcxHgMyVideosCategoryItemTypeUid;
       
  1116             }
       
  1117         }
       
  1118     }
       
  1119 
       
  1120 // -----------------------------------------------------------------------------
       
  1121 // CVcxHgMyVideosVideoModelHandler::CreateHgListIconL()
       
  1122 // 
       
  1123 // -----------------------------------------------------------------------------
       
  1124 // 
       
  1125 CGulIcon* CVcxHgMyVideosCategoryModelHandler::CreateHgListIconL(
       
  1126         const TFileName& aFileName,
       
  1127         TInt aBitmapId,
       
  1128         TInt aMaskId )
       
  1129     {
       
  1130     IPTVLOGSTRING4_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::CreateHgListIconL() bitmap=%d mask=%d file %S", aBitmapId, aMaskId, &aFileName );
       
  1131     
       
  1132     CFbsBitmap* bitmap( NULL );
       
  1133     CFbsBitmap* mask( NULL );
       
  1134     CGulIcon* icon( NULL );
       
  1135 
       
  1136     // Create default icon for Hg list.
       
  1137     AknIconUtils::CreateIconLC(
       
  1138             bitmap,
       
  1139             mask,
       
  1140             aFileName, 
       
  1141             aBitmapId,
       
  1142             aMaskId );
       
  1143 
       
  1144     TInt error( KErrNone );
       
  1145     error = AknIconUtils::SetSize(
       
  1146             bitmap, 
       
  1147             CHgDoubleGraphicList::PreferredImageSize(), 
       
  1148             EAspectRatioPreservedAndUnusedSpaceRemoved );
       
  1149     User::LeaveIfError( error );
       
  1150 
       
  1151     error = AknIconUtils::SetSize(
       
  1152             mask, 
       
  1153             CHgDoubleGraphicList::PreferredImageSize(), 
       
  1154             EAspectRatioPreservedAndUnusedSpaceRemoved );
       
  1155     User::LeaveIfError( error );
       
  1156 
       
  1157     // Ownership of bitmap and mask is transferred to icon.
       
  1158     icon = CGulIcon::NewL( bitmap, mask );
       
  1159     CleanupStack::Pop( 2, bitmap ); // mask and bitmap
       
  1160 
       
  1161     IPTVLOGSTRING2_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::CreateHgListIconL() icon=0x%08x", icon );
       
  1162 
       
  1163     return icon;
       
  1164     }
       
  1165 
       
  1166 // -----------------------------------------------------------------------------
       
  1167 // CVcxHgMyVideosVideoModelHandler::CreateEmptyHgListIconL()
       
  1168 // 
       
  1169 // -----------------------------------------------------------------------------
       
  1170 // 
       
  1171 CGulIcon* CVcxHgMyVideosCategoryModelHandler::CreateEmptyHgListIconL()
       
  1172     {
       
  1173     IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::CreateEmptyHgListIconL()" );
       
  1174     CGulIcon* icon( NULL );
       
  1175     CFbsBitmap* bitmap = new (ELeave) CFbsBitmap;
       
  1176 
       
  1177     bitmap->Create( CHgDoubleGraphicList::PreferredImageSize(), ENone );
       
  1178     CleanupStack::PushL( bitmap );
       
  1179     icon = CGulIcon::NewL( bitmap );
       
  1180     CleanupStack::Pop( bitmap );
       
  1181 
       
  1182     return icon;
       
  1183     }