videofeeds/hgvodui/src/vcxhgvodcontentlistimpl.cpp
changeset 0 96612d01cf9f
child 2 dec420019252
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    HG VOD category list implementation*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #include <eikenv.h>
       
    21 #include <eikmenup.h>
       
    22 #include <aknViewAppUi.h>
       
    23 #include <StringLoader.h>
       
    24 #include <SendUiConsts.h>
       
    25 #include <vcxhgvodui.rsg>
       
    26 #include <aknnotewrappers.h>
       
    27 #include <ganes/HgScroller.h>
       
    28 #include <csxhelp/iptv.hlp.hrh>
       
    29 
       
    30 #include "vcxnsuiengine.h"
       
    31 #include "vcxnscategory.h"
       
    32 #include "vcxnscategoryproviderif.h"
       
    33 #include "vcxnscontentproviderif.h"
       
    34 #include "vcxnsservice.h"
       
    35 #include "vcxnsserviceproviderif.h"
       
    36 
       
    37 #include "vcxhgvodcontentlistimpl.h"
       
    38 #include "vcxhgvodlistimplbase.h"
       
    39 
       
    40 #include "vcxhgvodcontentlistimpl.h"
       
    41 #include "vcxhgvodcontentlistmodelhandler.h"
       
    42 #include "vcxhgvodmainview.h"
       
    43 #include "vcxhgvodmainviewcontainer.h"
       
    44 #include "vcxhgvodui.hrh"
       
    45 #include "vcxhgvodutils.h"
       
    46 #include "vcxhgvodsearchimpl.h"
       
    47 
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CVcxHgVodContentListImpl::~CVcxHgVodContentListImpl()
       
    51 // Destructor
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 CVcxHgVodContentListImpl::~CVcxHgVodContentListImpl()
       
    55     {
       
    56     //always set model null to widget before destroying it
       
    57     delete iModelHandler;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // CVcxHgVodContentListImpl::NewL()
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CVcxHgVodContentListImpl* CVcxHgVodContentListImpl::NewL(
       
    65     CHgScroller& aScroller, 
       
    66     CVcxNsUiEngine& aDataProviderIf,
       
    67     CVcxHgVodMainView& aView )
       
    68     {
       
    69     CVcxHgVodContentListImpl* self = 
       
    70         CVcxHgVodContentListImpl::NewLC( 
       
    71                 aScroller, aDataProviderIf, aView );
       
    72     CleanupStack::Pop( self );
       
    73     return self;
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CVcxHgVodContentListImpl::NewLC()
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 CVcxHgVodContentListImpl* CVcxHgVodContentListImpl::NewLC(
       
    81     CHgScroller& aScroller, 
       
    82     CVcxNsUiEngine& aDataProviderIf, 
       
    83     CVcxHgVodMainView& aView )
       
    84     {
       
    85     CVcxHgVodContentListImpl* self = 
       
    86         new (ELeave) CVcxHgVodContentListImpl( 
       
    87             aScroller, aDataProviderIf, aView );
       
    88     CleanupStack::PushL( self );
       
    89     self->ConstructL( aDataProviderIf, aView );
       
    90     return self;
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // 
       
    95 // -----------------------------------------------------------------------------
       
    96 void CVcxHgVodContentListImpl::DoActivateL( )
       
    97     {
       
    98     if ( iSearchImpl )
       
    99         {
       
   100         iSearchImpl->RegisterObserver();
       
   101         }
       
   102     
       
   103     SetMenuResourceId( R_VCXHG_VOD_CONTENTVIEW_MENUBAR );
       
   104     SetEmptyListTextL( R_VCXHG_VOD_UPDATING_ITEMS );
       
   105     //Set default context menu
       
   106     iView.MenuBar()->SetContextMenuTitleResourceId( 
       
   107         R_VCXHG_VOD_MSK_CONTENT_CONTEXT_MENUBAR );
       
   108     SetMskL( R_VCXHG_VOD_MSK_BUTTON_DO_NOTHING );
       
   109         
       
   110     iScroller.SetSelectionObserver( *this );
       
   111     iView.AppUi()->AddToStackL( &iScroller );
       
   112     iScroller.SetFocus( ETrue );
       
   113     
       
   114     iModelHandler->DoActivateModelL();
       
   115     UpdateTitlePaneL();
       
   116 
       
   117     CVcxNsService* currentService =
       
   118         iModel.GetServiceProviderL()->GetActiveServiceData();
       
   119 
       
   120     TUint32 activeCategory = iModel.ActiveCategory();
       
   121 
       
   122     if ( ( activeCategory == KVcxNsSearchCategoryId )
       
   123             && ( iScroller.ItemCount() == 0 ) )
       
   124         {
       
   125         // Set empty list text "no videos found" when opened search
       
   126         // category and it's empty. 
       
   127         SetEmptyListTextL( R_VCXHG_NO_VIDEOS_FOUND );
       
   128         }
       
   129     else if ( iScroller.ItemCount() == 0 &&
       
   130               currentService->GetUpdateTime() != 0 )
       
   131         {
       
   132         // Set empty list text "no videos" only if content list is empty
       
   133         // and service has been updated successfully at least once.
       
   134         SetEmptyListTextL( R_VCXHG_VOD_NO_DATA );
       
   135         }
       
   136 
       
   137     if( currentService &&
       
   138         currentService->GetUpdateStatus() == CVcxNsService::EUpdateOngoing )
       
   139         {
       
   140         ShowInformationPopupL( ETrue, 0, 0 );
       
   141         }
       
   142     }    
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 //  
       
   146 // -----------------------------------------------------------------------------
       
   147 void CVcxHgVodContentListImpl::DoDeactivate( )
       
   148     {
       
   149     //Make sure that MSK is updated when returning to view
       
   150     iCurrentMskResource = 0;
       
   151     iModelHandler->DoDeActivateModel();
       
   152     iView.AppUi()->RemoveFromStack( &iScroller );
       
   153     iScroller.SetFocus( EFalse );
       
   154     TRAP_IGNORE( ShowInformationPopupL( EFalse, 0, 0 ) );
       
   155   
       
   156     if ( iSearchImpl )
       
   157         {
       
   158         iSearchImpl->DeRegisterObserver();
       
   159         }
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CVcxHgVodContentListImpl::CVcxHgVodContentListImpl()
       
   164 // Constructor
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 CVcxHgVodContentListImpl::CVcxHgVodContentListImpl( 
       
   168     CHgScroller& aScroller,
       
   169     CVcxNsUiEngine& aDataProviderIf,
       
   170     CVcxHgVodMainView& aView )
       
   171     : CVcxHgVodListImplBase( aView, aDataProviderIf, aScroller ),
       
   172       iEmailAccountEnabled ( EFalse )
       
   173     {
       
   174     // None
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CVcxHgVodContentListImpl::ConstructL()
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 void CVcxHgVodContentListImpl::ConstructL( 
       
   182     CVcxNsUiEngine& aDataProviderIf,
       
   183     CVcxHgVodMainView& aView )
       
   184     {
       
   185     iModelHandler = 
       
   186         CVcxHgVodContentListModelHandler::NewL( 
       
   187                 aDataProviderIf, aView, iScroller, *this );
       
   188 
       
   189     CVcxHgVodListImplBase::InitSearchImplL();
       
   190     
       
   191     iEmailAccountEnabled = CVcxHgVodUtils::IsDefaultSmtpAccountDefinedL();
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // CVcxHgVodContentListImpl::HandleCommandL
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 void CVcxHgVodContentListImpl::HandleCommandL( TInt aCommand )
       
   199     {
       
   200     TInt selected = iScroller.SelectedIndex();
       
   201     
       
   202     MVcxNsContentProviderIf* contentProvider = 
       
   203         iModelHandler->ContentProvider();
       
   204     
       
   205     switch ( aCommand )
       
   206         {
       
   207         case EVcxHgVodContentStartDownloadCmd:
       
   208             {
       
   209             if ( selected >= 0 ) 
       
   210                 {
       
   211                 contentProvider->StartDownloadL( selected );
       
   212                 }
       
   213             }
       
   214             break;
       
   215         case EVcxHgVodContentResumeDownloadCmd:
       
   216             {
       
   217             if ( selected >= 0 )
       
   218                 {
       
   219                 contentProvider->ResumeDownloadL( selected );
       
   220                 }
       
   221             }
       
   222             break;        
       
   223         case EVcxHgVodContentCancelDownloadCmd:
       
   224             {
       
   225             if ( selected >= 0 )
       
   226                 {
       
   227                 contentProvider->CancelDownloadL( selected );
       
   228                 
       
   229                 HBufC* text = StringLoader::LoadLC( R_VCXHGVOD_DOWNLOAD_CANCELED );
       
   230                 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue );
       
   231                 note->ExecuteLD( *text );
       
   232                 CleanupStack::PopAndDestroy( text );    
       
   233                 }
       
   234             }
       
   235             break;
       
   236         case EVcxHgVodContentPlayCmd:
       
   237             {
       
   238             StartPlaybackL();
       
   239             }
       
   240             break;
       
   241 
       
   242         case EVcxHgVodContentNewSearchCmd:
       
   243             {
       
   244             if ( iSearchImpl )
       
   245                 {
       
   246                 iSearchImpl->StartSearchL( EFalse );
       
   247                 }
       
   248             }
       
   249             break;
       
   250         case EVcxHgVodContentOpenLinkCmd:
       
   251             {
       
   252             if ( selected >= 0 )
       
   253                 {
       
   254                 OpenBrowserLinkL( selected );
       
   255                 }
       
   256             }
       
   257             break;
       
   258         case EVcxHgVodContentDetailsCmd:
       
   259             {
       
   260             if ( selected >= 0 )
       
   261                 {
       
   262                 iModelHandler->ShowVideoDetailsL( selected );
       
   263                 }
       
   264             }
       
   265             break;
       
   266         case EVcxHgVodContentSendCmd:
       
   267             {
       
   268             if ( !iEmailAccountEnabled )
       
   269                 {
       
   270                 HandleCommandL( EVcxHgVodContentSendViaMsgCmd );
       
   271                 }
       
   272             else
       
   273                 {
       
   274                 // Switching to context sensitive menu.
       
   275                 iView.MenuBar()->SetContextMenuTitleResourceId( R_VCXHG_VOD_SEND_CONTEXT_MENUBAR );
       
   276                 iView.MenuBar()->TryDisplayContextMenuBarL();
       
   277                 iView.MenuBar()->SetContextMenuTitleResourceId( R_VCXHG_VOD_MSK_CONTENT_CONTEXT_MENUBAR );
       
   278                 
       
   279                 // Switching back to normal options menu.
       
   280                 iView.MenuBar()->SetMenuType( CEikMenuBar::EMenuOptions );
       
   281                 iView.MenuBar()->SetMenuTitleResourceId( R_VCXHG_VOD_CONTENTVIEW_MENUBAR );
       
   282                 }
       
   283             }
       
   284             break;
       
   285         case EVcxHgVodContentSendViaMsgCmd:
       
   286             {
       
   287             ShareLinkL( KSenduiMtmSmsUid, selected );
       
   288             }
       
   289             break;
       
   290 
       
   291         case EVcxHgVodContentSendViaEmailCmd:
       
   292             {
       
   293             ShareLinkL( KSenduiMtmSmtpUid, selected  );
       
   294             }
       
   295             break;
       
   296         case EVcxHgVodContentScheduleDownloadsCmd:
       
   297             {
       
   298             iView.OpenScheduleSettingsL();
       
   299             }
       
   300             break;
       
   301 
       
   302         default:
       
   303             break;
       
   304         }
       
   305     }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // Activate usable menu items before showing menu
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 void CVcxHgVodContentListImpl::ActivateMenuPaneItemsL( 
       
   312     CEikMenuPane* aMenuPane,
       
   313     TInt aResourceId )
       
   314     {
       
   315     if ( aMenuPane )
       
   316         {
       
   317         if ( aResourceId == R_VCXHG_VOD_CONTENTVIEW_SHARE_LINK_SUBMENU )
       
   318             {
       
   319             if ( !iEmailAccountEnabled )
       
   320                 {
       
   321                 aMenuPane->SetItemDimmed( EVcxHgVodContentSendViaEmailCmd, ETrue );
       
   322                 }
       
   323             }
       
   324         if  ( aResourceId == R_VCXHG_VOD_CONTENTVIEW_MENU 
       
   325                 || aResourceId == R_VCXHG_VOD_CONTENTVIEW_CONTEXT_MENU )
       
   326             {
       
   327             TBool showPlay( EFalse );
       
   328             TBool showDownload( EFalse );
       
   329             TBool showResume ( EFalse );
       
   330             TBool showCancel( EFalse );
       
   331             TBool showOpenLink ( EFalse );
       
   332             TBool showDetails( EFalse );
       
   333             
       
   334             RPointerArray<CVcxNsContent>& contents = 
       
   335                 iModelHandler->ContentProvider()->GetContentsL();
       
   336             TInt highlight = iScroller.SelectedIndex();
       
   337             CVcxNsContent::TVcxContentDlStatus dlStatus( CVcxNsContent::EVcxContentDlStateNotFound );
       
   338             TUint32 dltypes( 0 );
       
   339     
       
   340             if( highlight >=0 && highlight < contents.Count() )
       
   341                 {
       
   342                 dlStatus = ( contents[highlight] )->GetDlStatus();
       
   343                 dltypes = ( contents[highlight] )->GetContentTypes();
       
   344                  
       
   345                 if ( ( contents[highlight] )->GetBrowserUrl().Length() > 0 )
       
   346                     {
       
   347                     showOpenLink = ETrue; 
       
   348                     }
       
   349                 
       
   350                 if ( !iModelHandler->IsEmptyModel() 
       
   351                         && iModelHandler->ContentProvider()->HasVideoDetailsL( highlight ) )
       
   352                     {
       
   353                     showDetails = ETrue;
       
   354                     }
       
   355                 
       
   356                 if( dltypes & CVcxNsContent::EVcxContentTypeVideo )
       
   357                     {
       
   358                     switch ( dlStatus )
       
   359                         {
       
   360                         case CVcxNsContent::EVcxContentDlStateNone:
       
   361                         case CVcxNsContent::EVcxContentDlStateNotFound:
       
   362                             {
       
   363                             showDownload = ETrue; 
       
   364                             }
       
   365                             break;
       
   366                         case CVcxNsContent::EVcxContentDlStateDownloading:
       
   367                             {
       
   368                             showCancel = ETrue; 
       
   369                             showPlay = ETrue;
       
   370                             }
       
   371                             break;
       
   372                         case CVcxNsContent::EVcxContentDlStateFailed:
       
   373                         case CVcxNsContent::EVcxContentDlStatePaused:
       
   374                             {
       
   375                             showPlay = ETrue;
       
   376                             showResume = ETrue;
       
   377                             showCancel = ETrue;
       
   378                             }
       
   379                             break;
       
   380                         case CVcxNsContent::EVcxContentDlStateDownloaded:
       
   381                             {
       
   382                             showPlay = ETrue;
       
   383                             }
       
   384                             break;
       
   385                         case CVcxNsContent::EVcxContentDlStateCanceling:
       
   386                             break;
       
   387                         default:
       
   388                             break;
       
   389                         }
       
   390                     }
       
   391                 
       
   392                 // Play cmd is always visible, if there's stream.
       
   393                 if( dltypes & CVcxNsContent::EVcxContentTypeStream )
       
   394                     {
       
   395                     showPlay = ETrue;
       
   396                     }
       
   397                 }
       
   398             
       
   399             //For both menus:
       
   400             aMenuPane->SetItemDimmed( EVcxHgVodContentStartDownloadCmd, !showDownload );
       
   401             aMenuPane->SetItemDimmed( EVcxHgVodContentPlayCmd, !showPlay );
       
   402             aMenuPane->SetItemDimmed( EVcxHgVodContentResumeDownloadCmd, !showResume );
       
   403             aMenuPane->SetItemDimmed( EVcxHgVodContentCancelDownloadCmd, !showCancel );
       
   404 
       
   405             
       
   406             if  ( aResourceId == R_VCXHG_VOD_CONTENTVIEW_MENU ) 
       
   407                 {
       
   408                 aMenuPane->SetItemDimmed( EVcxHgVodContentDetailsCmd, !showDetails );
       
   409                 aMenuPane->SetItemDimmed( EVcxHgVodContentOpenLinkCmd, !showOpenLink );
       
   410                 
       
   411                 if ( iModel.ActiveCategory() == KVcxNsSearchCategoryId )
       
   412                     {
       
   413                     aMenuPane->SetItemDimmed( EVcxHgVodContentNewSearchCmd, EFalse );
       
   414                     }
       
   415                 else
       
   416                     {
       
   417                     aMenuPane->SetItemDimmed( EVcxHgVodContentNewSearchCmd, ETrue );
       
   418                     }
       
   419                 
       
   420                 if ( iModelHandler->IsEmptyModel() )
       
   421                     {
       
   422                     aMenuPane->SetItemDimmed( EVcxHgVodContentSendCmd, ETrue );
       
   423                     }
       
   424                 }
       
   425             }
       
   426         }
       
   427     }
       
   428 
       
   429 // -----------------------------------------------------------------------------
       
   430 // CVcxHgVodContentListImpl::StartPlaybackL
       
   431 // -----------------------------------------------------------------------------
       
   432 //
       
   433 void CVcxHgVodContentListImpl::StartPlaybackL()
       
   434     {
       
   435     RPointerArray<CVcxNsContent>& contents = iModel.GetContentProviderL()->GetContentsL();
       
   436 
       
   437     TInt highlight = iScroller.SelectedIndex();
       
   438 
       
   439     if( highlight >= 0 && contents.Count() > highlight )
       
   440         {
       
   441         iView.PlayInternalVideoL( contents[highlight] );
       
   442         }
       
   443     }
       
   444 
       
   445 // -----------------------------------------------------------------------------
       
   446 //  
       
   447 // -----------------------------------------------------------------------------
       
   448 //
       
   449 void CVcxHgVodContentListImpl::HandleSelectL( TInt /*aIndex*/ )
       
   450     {
       
   451     CheckMskL();
       
   452     }
       
   453 
       
   454 // -----------------------------------------------------------------------------
       
   455 // CVcxHgVodContentListImpl::AakashItemSelectedL
       
   456 // -----------------------------------------------------------------------------
       
   457 //
       
   458 void CVcxHgVodContentListImpl::HandleOpenL( TInt /*aIndex*/ )
       
   459     {
       
   460     //This check must be done because ETypeSelect event is received
       
   461     //from antriksh even if context menu item defined as msk button.
       
   462     if ( iCurrentMskResource == R_VCXHG_VOD_MSK_BUTTON_CTXTMENU
       
   463           && ! iView.IsTouchSupported() )
       
   464         {
       
   465         return;
       
   466         }
       
   467     
       
   468     HandleSelectionL();
       
   469     }
       
   470 
       
   471 // -----------------------------------------------------------------------------
       
   472 // CVcxHgVodContentListImpl::MediaKeyEventL
       
   473 // -----------------------------------------------------------------------------
       
   474 //
       
   475 void CVcxHgVodContentListImpl::MediaKeyEventL(
       
   476     TRemConCoreApiOperationId aOperationId, 
       
   477     TRemConCoreApiButtonAction /*aButtonAct*/ )
       
   478     {
       
   479     if ( iModel.VcAppState() == EStateContentView &&
       
   480          ( aOperationId == ERemConCoreApiPause ||
       
   481            aOperationId == ERemConCoreApiPlay ||
       
   482            aOperationId == ERemConCoreApiPausePlayFunction ) )
       
   483         {
       
   484         HandleCommandL( EVcxHgVodContentPlayCmd );
       
   485         }
       
   486     }
       
   487 
       
   488 // -----------------------------------------------------------------------------
       
   489 // CVcxHgVodContentListImpl::UpdateTitlePaneL
       
   490 // -----------------------------------------------------------------------------
       
   491 //
       
   492 void CVcxHgVodContentListImpl::UpdateTitlePaneL()
       
   493     {
       
   494     CVcxNsCategory* currentCategory =
       
   495         iModel.GetCategoryProviderL()->GetActiveCategoryDataL();
       
   496     
       
   497     if ( currentCategory )
       
   498         {
       
   499         if ( currentCategory->GetCategoryId() == KVcxNsSearchCategoryId )
       
   500             {
       
   501             HBufC* searchTitle = StringLoader::LoadLC( R_VCXHG_TITLE_VIDEO_SEARCH );
       
   502             SetTitlePaneTextL( *searchTitle );
       
   503             CleanupStack::PopAndDestroy( searchTitle );
       
   504             }
       
   505         else
       
   506             {
       
   507             if( currentCategory->GetName().Length() > 0 )
       
   508                 {
       
   509                 SetTitlePaneTextL( currentCategory->GetName());
       
   510                 }
       
   511             else
       
   512                 {
       
   513                 SetTitlePaneTextFromResourceL( R_VCXHG_CATEGORIES_VIDEO_LIST );
       
   514                 }
       
   515             }
       
   516         }
       
   517     else
       
   518         {
       
   519         CVcxNsService* currentService = 
       
   520             iModel.GetServiceProviderL()->GetActiveServiceData();
       
   521         
       
   522         if ( currentService )
       
   523             {
       
   524             SetTitlePaneTextL( currentService->GetName());
       
   525             }
       
   526         }
       
   527     }
       
   528 // -----------------------------------------------------------------------------
       
   529 // CVcxHgVodContentListImpl::GetContentStatusDataL
       
   530 // -----------------------------------------------------------------------------
       
   531 //
       
   532 void CVcxHgVodContentListImpl::ContentStatusDataL(
       
   533     CVcxNsContent::TVcxContentDlStatus &aDlStatus,
       
   534     TUint32 &aContentTypes )
       
   535     {
       
   536     RPointerArray<CVcxNsContent>& contents = 
       
   537         iModelHandler->ContentProvider()->GetContentsL();
       
   538     
       
   539     //Default values:
       
   540     aDlStatus = CVcxNsContent::EVcxContentDlStateNotFound;
       
   541     aContentTypes = 0;
       
   542 
       
   543     TInt highlight = iScroller.SelectedIndex();
       
   544 
       
   545     if( highlight >= 0 && highlight < contents.Count() )
       
   546         {
       
   547         aDlStatus = ( contents[highlight] )->GetDlStatus();
       
   548         aContentTypes = ( contents[highlight] )->GetContentTypes();
       
   549         }
       
   550     }
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // CVcxHgVodContentListImpl::OpenBrowserLinkL
       
   554 // -----------------------------------------------------------------------------
       
   555 //
       
   556 void CVcxHgVodContentListImpl::OpenBrowserLinkL( TInt aSelected )
       
   557     {
       
   558     if ( aSelected >= 0 && 
       
   559             iModelHandler && iModelHandler->ContentProvider())
       
   560         {
       
   561         RPointerArray<CVcxNsContent>& contents = 
       
   562             iModelHandler->ContentProvider()->GetContentsL();
       
   563 
       
   564         if( aSelected >= 0 && aSelected < contents.Count() )
       
   565             {
       
   566             OpenEmbeddedBrowserL( ( contents[aSelected] )->GetBrowserUrl() );
       
   567             iModel.SetVcAppState( EStateBrowser );
       
   568             }
       
   569         
       
   570         }
       
   571     }
       
   572 
       
   573 // -----------------------------------------------------------------------------
       
   574 // CVcxHgVodContentListImpl::ShareLinkL
       
   575 // -----------------------------------------------------------------------------
       
   576 //
       
   577 void CVcxHgVodContentListImpl::ShareLinkL( 
       
   578     const TUid aMessageTypeModule,
       
   579     TInt aSelected )
       
   580     {
       
   581     RPointerArray<CVcxNsContent>& contents = 
       
   582         iModelHandler->ContentProvider()->GetContentsL();
       
   583 
       
   584     if( aSelected >= 0 && aSelected < contents.Count() )
       
   585         {
       
   586         TUint32 contentTypes( 0 );
       
   587         CVcxNsContent::TVcxNsContentAccessType caType = 
       
   588             CVcxNsContent::EVcxContentTypeNoType;
       
   589         
       
   590         contentTypes = ( contents[aSelected] )->GetContentTypes();
       
   591         if ( ( contentTypes & CVcxNsContent::EVcxContentTypeStream ) && 
       
   592              ( contents[aSelected] )->GetUrl(  
       
   593                    CVcxNsContent::EVcxContentTypeStream ).Length() > 0 )
       
   594             {
       
   595             caType = CVcxNsContent::EVcxContentTypeStream;
       
   596             }
       
   597         else if ( ( contentTypes & CVcxNsContent::EVcxContentTypeVideo ) && 
       
   598                 ( contents[aSelected] )->GetUrl( 
       
   599                       CVcxNsContent::EVcxContentTypeVideo ).Length() > 0 )
       
   600 
       
   601             {
       
   602             caType = CVcxNsContent::EVcxContentTypeVideo;
       
   603             }
       
   604         
       
   605         if ( caType == CVcxNsContent::EVcxContentTypeVideo
       
   606                 || caType == CVcxNsContent::EVcxContentTypeStream )
       
   607             {
       
   608             CVcxHgVodUtils::ShareLinkL( 
       
   609                 ( contents[aSelected] )->GetUrl( caType ), 
       
   610                 aMessageTypeModule,
       
   611                 iView.EikonEnv() );
       
   612             
       
   613             iView.LayoutChanged();
       
   614             }
       
   615         }
       
   616     }
       
   617 
       
   618 // ---------------------------------------------------------
       
   619 // CVcxHgVodContentListImpl::CheckMskL
       
   620 // ---------------------------------------------------------
       
   621 void CVcxHgVodContentListImpl::CheckMskL()
       
   622     {
       
   623     TBool showPlay( EFalse );
       
   624     TBool showStartDl( EFalse );
       
   625     TBool showResumeDl( EFalse );
       
   626     
       
   627     if ( !iModelHandler->IsEmptyModel() )
       
   628         {
       
   629         CVcxNsContent::TVcxContentDlStatus dlStatus;
       
   630         TUint32 contentTypes;
       
   631         ContentStatusDataL( dlStatus, contentTypes );
       
   632         
       
   633         if( contentTypes & CVcxNsContent::EVcxContentTypeVideo )
       
   634             {
       
   635             switch ( dlStatus )
       
   636                 {
       
   637                 case CVcxNsContent::EVcxContentDlStateNone:
       
   638                 case CVcxNsContent::EVcxContentDlStateNotFound:
       
   639                     {
       
   640                     showStartDl = ETrue;
       
   641                     }
       
   642                     break;
       
   643                 case CVcxNsContent::EVcxContentDlStateDownloading:
       
   644                     {
       
   645                     showPlay = ETrue;
       
   646                     }        
       
   647                     break;
       
   648                 case CVcxNsContent::EVcxContentDlStateCanceling:
       
   649                     {
       
   650                     // no handling 
       
   651                     }
       
   652                     break;
       
   653                 case CVcxNsContent::EVcxContentDlStateFailed:
       
   654                 case CVcxNsContent::EVcxContentDlStatePaused:
       
   655                     {
       
   656                     showResumeDl = ETrue;
       
   657                     //Check for progressive playback
       
   658                     }
       
   659                     break;
       
   660                 case CVcxNsContent::EVcxContentDlStateDownloaded:
       
   661                     {
       
   662                     showPlay = ETrue;
       
   663                     }
       
   664                     break;
       
   665                 default:
       
   666                     break;
       
   667                 }
       
   668             }
       
   669         
       
   670         if( contentTypes & CVcxNsContent::EVcxContentTypeStream )
       
   671             {
       
   672             showPlay = ETrue;
       
   673             }
       
   674         }
       
   675 
       
   676     CheckMskL( showStartDl, showPlay, showResumeDl );
       
   677     }
       
   678 
       
   679 // ---------------------------------------------------------
       
   680 // CVcxHgVodContentListImpl::CheckMskL
       
   681 // ---------------------------------------------------------
       
   682 void CVcxHgVodContentListImpl::CheckMskL( 
       
   683     TBool aShowDownload,
       
   684     TBool aShowPlay,
       
   685     TBool aShowResume )
       
   686     {
       
   687     TInt resourceId = 0;
       
   688     TInt numberOfCommands = ( aShowDownload ? 1 : 0 ) +
       
   689                             ( aShowPlay ? 1 : 0 ) +
       
   690                             ( aShowResume ? 1 : 0 );
       
   691 
       
   692     if ( numberOfCommands == 0 )
       
   693         {
       
   694         resourceId = R_VCXHG_VOD_MSK_BUTTON_DO_NOTHING;
       
   695         }
       
   696     else if ( numberOfCommands == 1 )
       
   697         {
       
   698         if ( aShowDownload )
       
   699             {
       
   700             resourceId = R_VCXHG_VOD_MSK_BUTTON_DOWNLOAD;
       
   701             }
       
   702         else if ( aShowPlay )
       
   703             {
       
   704             resourceId = R_VCXHG_VOD_MSK_BUTTON_PLAY;
       
   705             }
       
   706         else if ( aShowResume )
       
   707             {
       
   708             resourceId = R_VCXHG_VOD_MSK_BUTTON_RESUME;
       
   709             }
       
   710         }
       
   711     else // numberOfCommands >= 2
       
   712         {
       
   713         resourceId = R_VCXHG_VOD_MSK_BUTTON_CTXTMENU;
       
   714         }
       
   715 
       
   716     SetMskL( resourceId );
       
   717     }
       
   718 
       
   719 // -----------------------------------------------------------------------------
       
   720 // Handle selection
       
   721 // -----------------------------------------------------------------------------
       
   722 //
       
   723 void CVcxHgVodContentListImpl::HandleSelectionL()
       
   724     {
       
   725     CVcxNsContent::TVcxContentDlStatus dlStatus;
       
   726     TUint32 contentTypes;
       
   727     ContentStatusDataL( dlStatus, contentTypes );
       
   728 
       
   729     // Play if is or is being downloaded
       
   730     if ( contentTypes & CVcxNsContent::EVcxContentTypeVideo &&
       
   731          dlStatus != CVcxNsContent::EVcxContentDlStateNone  &&
       
   732          dlStatus != CVcxNsContent::EVcxContentDlStateNotFound )
       
   733         {
       
   734         HandleCommandL( EVcxHgVodContentPlayCmd );
       
   735         }
       
   736     // Play if has stream url
       
   737     else if ( contentTypes & CVcxNsContent::EVcxContentTypeStream )
       
   738         {
       
   739         HandleCommandL( EVcxHgVodContentPlayCmd );
       
   740         }
       
   741     // Dl only if no stream url nor being downloaded
       
   742     else if ( contentTypes & CVcxNsContent::EVcxContentTypeVideo )
       
   743         { 
       
   744         HandleCommandL( EVcxHgVodContentStartDownloadCmd );
       
   745         }
       
   746     }
       
   747 
       
   748 // -----------------------------------------------------------------------------
       
   749 // CVcxHgVodContentListImpl::GetHelpContext
       
   750 // -----------------------------------------------------------------------------
       
   751 //
       
   752 void CVcxHgVodContentListImpl::GetHelpContext( TCoeHelpContext& aContext ) const
       
   753     {
       
   754     const TUid KUidIptvMainApp = { 0x102750E2 };
       
   755     
       
   756     aContext.iMajor   = KUidIptvMainApp;
       
   757     aContext.iContext = KIPTV_HLP_VOD;
       
   758     }