videocollection/hgmyvideos/src/vcxhgmyvideoscategorymodelhandler.cpp
branchRCL_3
changeset 24 f87e8c4ac026
parent 23 befca0ec475f
equal deleted inserted replaced
23:befca0ec475f 24:f87e8c4ac026
    37 #include <AknUtils.h>
    37 #include <AknUtils.h>
    38 #include <aknlayoutscalable_avkon.cdl.h>
    38 #include <aknlayoutscalable_avkon.cdl.h>
    39 #include <coemain.h>
    39 #include <coemain.h>
    40 #include <aknappui.h>
    40 #include <aknappui.h>
    41 #include <bautils.h>
    41 #include <bautils.h>
       
    42 #include <apgcli.h>
    42 
    43 
    43 #include <vcxhgmyvideosicons.mbg>
    44 #include <vcxhgmyvideosicons.mbg>
    44 #include <myvideosindicator.h>
    45 #include <myvideosindicator.h>
    45 #include <vcxhgmyvideos.rsg>
    46 #include <vcxhgmyvideos.rsg>
    46 #include <vcxmyvideosdefs.h>
    47 #include <vcxmyvideosdefs.h>
    66         CVcxHgMyVideosModel& aModel,
    67         CVcxHgMyVideosModel& aModel,
    67         CHgScroller& aScroller )
    68         CHgScroller& aScroller )
    68     {
    69     {
    69     CVcxHgMyVideosCategoryModelHandler* self = 
    70     CVcxHgMyVideosCategoryModelHandler* self = 
    70         new (ELeave) CVcxHgMyVideosCategoryModelHandler( aModel, aScroller );
    71         new (ELeave) CVcxHgMyVideosCategoryModelHandler( aModel, aScroller );
    71 
    72     CleanupStack::PushL( self );
       
    73     self->ConstructL();
       
    74     CleanupStack::Pop( self );
    72     return self;
    75     return self;
    73     }
    76     }
    74 
    77 
    75 
    78 
    76 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
    82     : iModel( aModel ),
    85     : iModel( aModel ),
    83       iScroller( aScroller ),
    86       iScroller( aScroller ),
    84       iTnManager( aModel.ThumbnailManager() ),
    87       iTnManager( aModel.ThumbnailManager() ),
    85       iTnRequestId( KErrNotFound )
    88       iTnRequestId( KErrNotFound )
    86     {
    89     {
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CVcxHgMyVideosCategoryModelHandler::ConstructL()
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CVcxHgMyVideosCategoryModelHandler::ConstructL()
       
    97     {
       
    98     CheckIfExtraItemsExistsL();
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CVcxHgMyVideosCategoryModelHandler::CheckIfExtraItemsExistsL()
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CVcxHgMyVideosCategoryModelHandler::CheckIfExtraItemsExistsL()
       
   106     {
       
   107     TInt value = 0;
       
   108     TBuf<KMyVideosTitleUrlMaxLength> url;
       
   109     // Check that cenrep exists and has some valid data
       
   110     iModel.GetMyVideosCustomizationString( KCRVideoPlayerExtraItem2Url, url ); // ignore error code
       
   111     if ( url.Length() == 0 )
       
   112         {
       
   113         TInt err = iModel.GetMyVideosCustomizationInt( KCRVideoPlayerExtraItem2Uid, value );
       
   114         if ( err == KErrNone && value != 0 ) 
       
   115             {
       
   116             if ( AppExistsL( TUid::Uid( value ) ) )
       
   117                 {
       
   118                 iExtraItem2Exists = ETrue;
       
   119                 }
       
   120             }
       
   121         }
       
   122     else
       
   123         {
       
   124         iExtraItem2Exists = ETrue;
       
   125         }
       
   126     
       
   127     value = 0;
       
   128     url.Zero();
       
   129     iModel.GetMyVideosCustomizationString( KCRVideoPlayerExtraItem3Url, url ); // ignore error code
       
   130     if ( url.Length() == 0 )
       
   131         {
       
   132         TInt err = iModel.GetMyVideosCustomizationInt( KCRVideoPlayerExtraItem3Uid, value );
       
   133         if ( err == KErrNone && value != 0 )
       
   134             {
       
   135             if ( AppExistsL( TUid::Uid( value ) ) )
       
   136                 {
       
   137                 iExtraItem3Exists = ETrue;
       
   138                 }
       
   139             }
       
   140         }
       
   141     else
       
   142         {
       
   143         iExtraItem3Exists = ETrue;
       
   144         }
       
   145     
    87     }
   146     }
    88 
   147 
    89 // -----------------------------------------------------------------------------
   148 // -----------------------------------------------------------------------------
    90 // CVcxHgMyVideosCategoryModelHandler::~CVcxHgMyVideosCategoryModelHandler()
   149 // CVcxHgMyVideosCategoryModelHandler::~CVcxHgMyVideosCategoryModelHandler()
    91 // -----------------------------------------------------------------------------
   150 // -----------------------------------------------------------------------------
   666 //
   725 //
   667 void CVcxHgMyVideosCategoryModelHandler::UpdateCategoryListL()
   726 void CVcxHgMyVideosCategoryModelHandler::UpdateCategoryListL()
   668     {
   727     {
   669     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # UpdateCategoryListL() - Enter" );
   728     IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # UpdateCategoryListL() - Enter" );
   670     
   729     
   671     MakeCategoryIdArray();
   730     MakeCategoryIdArrayL();
   672     
   731     
   673     if ( iCategoryIdArray.Count() != iScroller.ItemCount() )
   732     if ( iCategoryIdArray.Count() != iScroller.ItemCount() )
   674         {
   733         {
   675         iScroller.ResizeL( iCategoryIdArray.Count() );
   734         iScroller.ResizeL( iCategoryIdArray.Count() );
   676         }
   735         }
   756         }  
   815         }  
   757     return ret;
   816     return ret;
   758     }
   817     }
   759 
   818 
   760 // -----------------------------------------------------------------------------
   819 // -----------------------------------------------------------------------------
   761 // CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArray()
   820 // CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArrayL()
   762 // -----------------------------------------------------------------------------
   821 // -----------------------------------------------------------------------------
   763 //
   822 //
   764 void CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArray()
   823 void CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArrayL()
   765     {
   824     {
   766     IPTVLOGSTRING_LOW_LEVEL("CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArray");
   825     IPTVLOGSTRING_LOW_LEVEL("CVcxHgMyVideosCategoryModelHandler::MakeCategoryIdArrayL");
   767     
   826     
   768     iCategoryIdArray.Reset();    
   827     iCategoryIdArray.Reset();    
   769     
   828     
   770     TInt error = KErrNone;
   829     TInt error = KErrNone;
   771     TInt value = KErrNotFound;
   830     TInt value = KErrNotFound;
   774     // Check that cenrep exists and has some valid data
   833     // Check that cenrep exists and has some valid data
   775     error = iModel.GetMyVideosCustomizationInt( KCRVideoPlayerItemLocation1, value );
   834     error = iModel.GetMyVideosCustomizationInt( KCRVideoPlayerItemLocation1, value );
   776     
   835     
   777     if ( error == KErrNone && value > EMyVideosListItemTypeEmpty )
   836     if ( error == KErrNone && value > EMyVideosListItemTypeEmpty )
   778         {
   837         {
   779         IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # MakeCategoryIdArray() Getting category items from cenrep" ); 
   838         IPTVLOGSTRING_LOW_LEVEL( "MPX My Videos UI # MakeCategoryIdArrayL() Getting category items from cenrep" ); 
   780 
   839 
   781         for ( TInt i=KCRVideoPlayerItemLocation1; i<=KCRVideoPlayerItemLocation7; i++ )    
   840         for ( TInt i=KCRVideoPlayerItemLocation1; i<=KCRVideoPlayerItemLocation7; i++ )    
   782             {
   841             {
   783             error = iModel.GetMyVideosCustomizationInt( i , value );
   842             error = iModel.GetMyVideosCustomizationInt( i , value );
   784             if ( error == KErrNone && value != EMyVideosListItemTypeEmpty )
   843             if ( error == KErrNone && value != EMyVideosListItemTypeEmpty )
   811                         break;
   870                         break;
   812                     }
   871                     }
   813                 
   872                 
   814                 if ( AcceptCategory( categoryId ) )
   873                 if ( AcceptCategory( categoryId ) )
   815                     {
   874                     {
   816                     iCategoryIdArray.Append( categoryId );
   875                     iCategoryIdArray.AppendL( categoryId );
   817                     }
   876                     }
   818                 }
   877                 }
   819             }
   878             }
   820         }
   879         }
   821     else
   880     else
   822         {
   881         {
   823 		iCategoryIdArray.Append( KCategoryIdLastWatched );
   882 		iCategoryIdArray.AppendL( KCategoryIdLastWatched );
   824 		iCategoryIdArray.Append( KVcxMvcCategoryIdCaptured );	    
   883 		iCategoryIdArray.AppendL( KVcxMvcCategoryIdCaptured );	    
   825         iCategoryIdArray.Append( KVcxMvcCategoryIdOther );  
   884         iCategoryIdArray.AppendL( KVcxMvcCategoryIdOther );  
   826         iCategoryIdArray.Append( KCategoryIdExtraItem1 );
   885         iCategoryIdArray.AppendL( KCategoryIdExtraItem1 );
   827         }
   886         }
   828     }
   887     }
   829 
   888 
   830 // -----------------------------------------------------------------------------
   889 // -----------------------------------------------------------------------------
   831 // CVcxHgMyVideosCategoryModelHandler::AcceptCategory()
   890 // CVcxHgMyVideosCategoryModelHandler::AcceptCategory()
   839         case KVcxMvcCategoryIdAll:
   898         case KVcxMvcCategoryIdAll:
   840         case KVcxMvcCategoryIdCaptured:
   899         case KVcxMvcCategoryIdCaptured:
   841         case KVcxMvcCategoryIdOther:
   900         case KVcxMvcCategoryIdOther:
   842         case KCategoryIdLastWatched:
   901         case KCategoryIdLastWatched:
   843         case KCategoryIdExtraItem1:
   902         case KCategoryIdExtraItem1:
   844         case KCategoryIdExtraItem2:
       
   845         case KCategoryIdExtraItem3:
       
   846             IPTVLOGSTRING2_LOW_LEVEL( 
   903             IPTVLOGSTRING2_LOW_LEVEL( 
   847                     "MPX My Videos UI # AcceptCategory() Accepted category: %d", aCategoryId );
   904                     "MPX My Videos UI # AcceptCategory() Accepted category: %d", aCategoryId );
   848             ret = ETrue;
   905             ret = ETrue;
       
   906             break;
       
   907         case KCategoryIdExtraItem2:
       
   908             ret = iExtraItem2Exists;
       
   909             IPTVLOGSTRING2_LOW_LEVEL( 
       
   910                     "MPX My Videos UI # AcceptCategory() extra item 2 accepted: %d", ret );
       
   911             break;
       
   912         case KCategoryIdExtraItem3:
       
   913             ret = iExtraItem3Exists;
       
   914             IPTVLOGSTRING2_LOW_LEVEL( 
       
   915                     "MPX My Videos UI # AcceptCategory() extra item 3 accepted: %d", ret );
   849             break;
   916             break;
   850         default:
   917         default:
   851             IPTVLOGSTRING2_LOW_LEVEL( 
   918             IPTVLOGSTRING2_LOW_LEVEL( 
   852                     "MPX My Videos UI # AcceptCategory() Unknown category: %d", aCategoryId );
   919                     "MPX My Videos UI # AcceptCategory() Unknown category: %d", aCategoryId );
   853             break;            
   920             break;            
  1246     else
  1313     else
  1247         {
  1314         {
  1248         return EFalse;
  1315         return EFalse;
  1249         }
  1316         }
  1250     }
  1317     }
       
  1318 
       
  1319 // ------------------------------------------------------------------------------
       
  1320 // CVcxHgMyVideosVideoModelHandler::AppExistsL()
       
  1321 // ------------------------------------------------------------------------------
       
  1322 //
       
  1323 TBool CVcxHgMyVideosCategoryModelHandler::AppExistsL( const TUid& aAppUid )
       
  1324     {
       
  1325     IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::AppExistsL()" );
       
  1326     TBool retVal( EFalse );
       
  1327     RApaLsSession appArcSession;
       
  1328     User::LeaveIfError( appArcSession.Connect() );
       
  1329     CleanupClosePushL( appArcSession );
       
  1330     
       
  1331     TApaAppInfo appInfo;
       
  1332     TInt err = appArcSession.GetAppInfo( appInfo, aAppUid );
       
  1333     if ( err == KErrNone )
       
  1334         {
       
  1335         IPTVLOGSTRING_LOW_LEVEL( "CVcxHgMyVideosCategoryModelHandler::AppExistsL(): return TRUE" );
       
  1336         retVal = ETrue;
       
  1337         }
       
  1338     CleanupStack::PopAndDestroy( &appArcSession );
       
  1339     return retVal;
       
  1340     }