videofeeds/hgvodui/src/vcxhgvodmainview.cpp
branchRCL_3
changeset 23 befca0ec475f
equal deleted inserted replaced
22:839377eedc2b 23:befca0ec475f
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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 Main view implementation*
       
    15 */
       
    16 
       
    17 // Version : %version: REL6_40 %
       
    18 
       
    19 #include <aknview.h>
       
    20 #include <aknViewAppUi.h>
       
    21 #include <akntitle.h>
       
    22 #include <aknnavi.h>
       
    23 #include <gulicon.h>
       
    24 
       
    25 #include <eikenv.h>
       
    26 #include <AknsBasicBackgroundControlContext.h>
       
    27 #include <aknlayoutscalable_avkon.cdl.h>
       
    28 #include <AknUtils.h>
       
    29 #include <AknsUtils.h>
       
    30 #include <AknIconUtils.h>
       
    31 #include <akntoolbar.h>
       
    32 #include <centralrepository.h>
       
    33 #include <ganes/HgDoubleGraphicList.h>
       
    34 #include <ganes/HgDoubleTextList.h>
       
    35 #include <data_caging_path_literals.hrh>
       
    36 
       
    37 #include <mpxviewutility.h>
       
    38 
       
    39 #include <vcxhgvodui.rsg>
       
    40 #include <vcxhgvoddefaulticons.mbg>
       
    41 #include "vcxnsuiengine.h"
       
    42 #include <hlplch.h>
       
    43 #include "vcxnscontentproviderif.h"
       
    44 
       
    45 #include "vcxhgvodmainview.h"
       
    46 #include "vcxhgvodmainviewcontainer.h"
       
    47 #include "vcxhgvodservicelistimpl.h"
       
    48 #include "vcxhgvodcategorylistimpl.h"
       
    49 #include "vcxhgvodcontentlistimpl.h"
       
    50 #include "vcxhgvodservicegrouplistimpl.h"
       
    51 #include "vcxhgvodlistimplbase.h"
       
    52 #include "vcxhgvodutils.h"
       
    53 #include "vcxhgvodtelephonyclient.h"
       
    54 #include "vcxhgvodui.hrh"
       
    55 #include "CIptvResourceLoader.h"
       
    56 #include "vcxnssettingsplugin.hrh"
       
    57 
       
    58 #include <avkon.rsg>
       
    59 #include <videoplayeractivationmessage.h>
       
    60 
       
    61 #include "vcxhgvodutils.h"
       
    62 #include "vcxviewmessageutility.h"
       
    63 #include "vcxnsserviceproviderif.h"
       
    64 #include "vcxnsservice.h"
       
    65 #include "vcxnsscheduleplugin.hrh"
       
    66 #include "mpxvideoplayercustomviewmsgconsts.h"
       
    67 
       
    68 _LIT( KVodViewResFile, "\\resource\\apps\\vcxhgvodui." );
       
    69 _LIT( KVodDefaultIconsMifFile, "vcxhgvoddefaulticons.mif" );
       
    70 
       
    71 const TUint32 KVcxNsFeedsViewUid = 0x102750DB;
       
    72 const TInt KVcxNsCenRepUid = 0x102750E2;
       
    73 const TInt KVcxNsCenRepParentControlKey = 0xC;
       
    74 
       
    75 void ScaleGulIconL( CGulIcon* aIcon, const TSize aSize )
       
    76     {
       
    77     User::LeaveIfError( AknIconUtils::SetSize( aIcon->Bitmap(), aSize, 
       
    78             EAspectRatioPreservedAndUnusedSpaceRemoved ) );
       
    79     User::LeaveIfError( AknIconUtils::SetSize( aIcon->Mask(), aSize, 
       
    80             EAspectRatioPreservedAndUnusedSpaceRemoved ) );
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CVcxHgVodMainView::~CVcxHgVodMainView()
       
    85 // Destructor
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 EXPORT_C CVcxHgVodMainView::~CVcxHgVodMainView()
       
    89     {
       
    90     if ( iActiveList )
       
    91         {
       
    92         iActiveList->DoDeactivate();
       
    93         }
       
    94     
       
    95     if ( iContainer )
       
    96         {
       
    97         AppUi()->RemoveFromStack( iContainer );
       
    98         delete iContainer;
       
    99         }
       
   100     
       
   101     delete iServiceList;
       
   102     delete iCategoryList;
       
   103     delete iContentList;
       
   104     delete iServiceGroupList;
       
   105     delete iResourceLoader;   
       
   106     delete iBgContext;
       
   107 
       
   108     if ( iViewUtility )
       
   109         {
       
   110         iViewUtility->Close();
       
   111         }    
       
   112 
       
   113     if( iModel )
       
   114         {
       
   115         iModel->ResetStates();
       
   116         iModel->DecreaseReferenceCount();
       
   117         }
       
   118     
       
   119     delete iGraphicScroller;
       
   120     delete iTextScroller;
       
   121     
       
   122     delete iContentDefaultIcon;
       
   123     delete iServiceDefaultIcon;
       
   124     
       
   125     delete iCenRep;
       
   126     delete iTelephonyClient;
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CVcxHgVodMainView::NewL()
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 EXPORT_C CVcxHgVodMainView* CVcxHgVodMainView::NewL( )
       
   134     {
       
   135     CVcxHgVodMainView* self = CVcxHgVodMainView::NewLC( );
       
   136     CleanupStack::Pop( self );
       
   137     return self;
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CVcxHgVodMainView::NewLC()
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C CVcxHgVodMainView* CVcxHgVodMainView::NewLC( )
       
   145     {
       
   146     CVcxHgVodMainView* self = new (ELeave) CVcxHgVodMainView( );
       
   147       CleanupStack::PushL( self );
       
   148     self->ConstructL();
       
   149     return self;
       
   150     }
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 //  Return view id
       
   154 // -----------------------------------------------------------------------------
       
   155 TUid CVcxHgVodMainView::Id() const
       
   156     {
       
   157     return TUid::Uid( KVcxNsFeedsViewUid );
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // 
       
   162 // -----------------------------------------------------------------------------
       
   163 void CVcxHgVodMainView::DoActivateL( 
       
   164     const TVwsViewId& /*aPrevViewId*/,
       
   165     TUid  /*aCustomMessageId*/,
       
   166     const TDesC8& aCustomMessage )
       
   167     {
       
   168     // ###
       
   169     if ( aCustomMessage.Length() > KVideoPlayerActivationMessageMinLength )
       
   170         {
       
   171         ProcessCustomMessageL( aCustomMessage );
       
   172         }
       
   173     else
       
   174         {
       
   175         // Normal startup, set UI engine's first state    
       
   176         if ( iModel->VcAppState() == EStateNoState )
       
   177             {
       
   178             iModel->SetVcAppState( EStateServiceView );
       
   179             }
       
   180         
       
   181         // Back from player, pop ui engine's state.
       
   182         else if ( iModel->VcAppState() == EStatePlayback )
       
   183             {
       
   184             TBool consumed = iModel->HandleBack();
       
   185             
       
   186             // If player was strated directly, exit the app.
       
   187             if ( !consumed )
       
   188                 {
       
   189                 AppUi()->HandleCommandL( EAknSoftkeyBack );
       
   190                 }
       
   191             }
       
   192         }
       
   193 
       
   194     if ( !iContainer )
       
   195         {
       
   196         iContainer = 
       
   197             new (ELeave) CVcxHgVodMainViewContainer( AppUi(), *this );
       
   198         iContainer->ConstructL( ClientRect() );
       
   199         iContainer->SetMopParent( this );
       
   200         }
       
   201 
       
   202     iContainer->MakeVisible( ETrue );
       
   203     AppUi()->AddToStackL( *this, iContainer );
       
   204 
       
   205 
       
   206     if ( IsTouchSupported() )
       
   207         {
       
   208         CAknToolbar* fixedToolbar( NULL );
       
   209         fixedToolbar = AppUi()->CurrentFixedToolbar();
       
   210         
       
   211         if ( fixedToolbar )
       
   212             {
       
   213             fixedToolbar->SetToolbarVisibility( ETrue );    
       
   214             }
       
   215         }
       
   216 
       
   217     // Activate correct list view
       
   218     if( iModel->VcAppState() == EStateServiceView ||
       
   219         iModel->VcAppState() == EStateCategoryView ||
       
   220         iModel->VcAppState() == EStateContentView ||
       
   221         iModel->VcAppState() == EStateCustomView )
       
   222         {
       
   223         // Activate correct list view
       
   224         ChangeListViewL();
       
   225         }
       
   226 
       
   227     CVcxViewMessageUtility::InstanceL()->AddObserverL( *this );
       
   228         
       
   229     HandleStatusPaneSizeChange(); // make sure that all rects are correct.
       
   230     }    
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 //  Deactivating of view
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 void CVcxHgVodMainView::DoDeactivate( )
       
   237     {
       
   238     if ( iActiveList )
       
   239         {
       
   240         iActiveList->DoDeactivate();
       
   241         SetActiveList( NULL );
       
   242         }
       
   243     
       
   244     if ( iContainer )
       
   245         {
       
   246         AppUi()->RemoveFromStack( iContainer );
       
   247         delete iContainer;
       
   248         iContainer = NULL;
       
   249         }
       
   250     
       
   251     TRAP_IGNORE( CVcxViewMessageUtility::InstanceL()->RemoveObserver( *this ) );
       
   252     }
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // CVcxHgVodMainView::HandleCommandL
       
   256 // -----------------------------------------------------------------------------
       
   257 //
       
   258 void CVcxHgVodMainView::HandleCommandL( TInt aCommand )
       
   259     {
       
   260     if ( iActiveList )
       
   261         {
       
   262         //Active list handles command first
       
   263         iActiveList->HandleCommandL( aCommand );
       
   264         }
       
   265     
       
   266     //Handle cases, that need list view changes
       
   267     switch ( aCommand )
       
   268         {
       
   269         case EAknSoftkeyOpen:
       
   270         case EVcxHgVodServiceOpenCmd:
       
   271         case EVcxHgVodCategoryOpenCmd:
       
   272         case EVcxHgVodServiceGroupOpenCmd:
       
   273             {
       
   274             ChangeListViewL();
       
   275             }
       
   276             break;
       
   277             
       
   278         case KVcxCustomViewMessageCmd:
       
   279             {
       
   280             HandleCustomViewMessageL();
       
   281             }
       
   282             break;
       
   283 
       
   284         case EAknCmdHelp:
       
   285             {
       
   286             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   287                                              AppUi()->AppHelpContextL() );
       
   288             }
       
   289             break;
       
   290 
       
   291         case EAknSoftkeyBack:
       
   292             {
       
   293             // Playback state may remain even if we're really in content
       
   294             // view when playback starting is canceled, because there may
       
   295             // not be any view transitions.
       
   296             if ( iModel->VcAppState() == EStatePlayback )
       
   297                 {
       
   298                 iModel->HandleBack();
       
   299                 }
       
   300             
       
   301             if ( iServiceList && iModel->VcAppState() == EStateBrowser )
       
   302                 {
       
   303                 iServiceList->CloseEmbeddedBrowser();
       
   304                 }            
       
   305             
       
   306             TBool consumed  = iModel->HandleBack();
       
   307 
       
   308             ChangeListViewL();
       
   309 
       
   310             if ( !consumed )
       
   311                 {
       
   312                 AppUi()->HandleCommandL( aCommand );
       
   313                 }
       
   314             }
       
   315             break;
       
   316 
       
   317         case EAknCmdExit:
       
   318         case EEikCmdExit:
       
   319             {
       
   320             if ( iActiveList )
       
   321                 {
       
   322                 iActiveList->DoDeactivate();
       
   323                 iActiveList = NULL;
       
   324                 }
       
   325             
       
   326             iModel->SetVcAppState( EStateNoState );
       
   327             
       
   328             AppUi()->HandleCommandL( aCommand );
       
   329             }
       
   330             break;
       
   331 
       
   332         default:
       
   333             {
       
   334             AppUi()->HandleCommandL( aCommand );
       
   335             }
       
   336             break;
       
   337         }
       
   338     }
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // CVcxHgVodMainView::CVcxHgVodMainView()
       
   342 // Constructor
       
   343 // -----------------------------------------------------------------------------
       
   344 //
       
   345 CVcxHgVodMainView::CVcxHgVodMainView( )
       
   346   : iViewId( TUid::Uid( EIptvVodFeedView ) ),
       
   347     iTouchSupport ( EFalse )
       
   348     {
       
   349     // None
       
   350     }
       
   351 
       
   352 
       
   353 // -----------------------------------------------------------------------------
       
   354 // CVcxHgVodMainView::ConstructL()
       
   355 // -----------------------------------------------------------------------------
       
   356 //
       
   357 void CVcxHgVodMainView::ConstructL()
       
   358     {
       
   359     iResourceLoader = CIptvResourceLoader::NewL( *iEikonEnv );
       
   360 
       
   361     if ( iResourceLoader )
       
   362         {
       
   363         iResourceLoader->AddResourceL( KVodViewResFile );
       
   364         }
       
   365 
       
   366     BaseConstructL( R_VCXHG_VOD_MAIN_VIEW );
       
   367     
       
   368     iModel = CVcxNsUiEngine::InstanceL();
       
   369 
       
   370     // Create background context.
       
   371     iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,
       
   372                                                            ClientRect(),
       
   373                                                            ETrue );
       
   374 
       
   375     if ( AknLayoutUtils::PenEnabled() )
       
   376         {
       
   377         iTouchSupport = ETrue;
       
   378         }
       
   379     }
       
   380 
       
   381 // -----------------------------------------------------------------------------
       
   382 // 
       
   383 // -----------------------------------------------------------------------------
       
   384 //
       
   385 CVcxHgVodListImplBase* CVcxHgVodMainView::ActiveList( )
       
   386     {
       
   387     return iActiveList; 
       
   388     }
       
   389 
       
   390 // -----------------------------------------------------------------------------
       
   391 // 
       
   392 // -----------------------------------------------------------------------------
       
   393 //
       
   394 void CVcxHgVodMainView::SetActiveList( CVcxHgVodListImplBase* aList )
       
   395     {
       
   396     iActiveList = aList; 
       
   397     }
       
   398 
       
   399 // -----------------------------------------------------------------------------
       
   400 // 
       
   401 // -----------------------------------------------------------------------------
       
   402 //
       
   403 CVcxNsPlayerWrapper* CVcxHgVodMainView::PlayerWrapper()
       
   404     {
       
   405     return NULL;
       
   406     }
       
   407 
       
   408 // -----------------------------------------------------------------------------
       
   409 // 
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 CVcxHgVodMainViewContainer* CVcxHgVodMainView::Container()
       
   413     {
       
   414     return iContainer;
       
   415     }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // 
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 TKeyResponse CVcxHgVodMainView::HandleKeyEventL( 
       
   422         const TKeyEvent& aKeyEvent, 
       
   423         TEventCode aType )
       
   424     {
       
   425     // Add checks for application state.
       
   426     
       
   427     TKeyResponse response( EKeyWasNotConsumed );
       
   428     
       
   429     if( iActiveList && MenuBar()->ItemSpecificCommandsEnabled() )
       
   430         {
       
   431         if ( ( aKeyEvent.iScanCode == EStdKeyEnter || aKeyEvent.iScanCode == EStdKeyDevice3 ) && 
       
   432              aType == EEventKey && 
       
   433              aKeyEvent.iRepeats == 0 )
       
   434             {
       
   435             iActiveList->HandleOpenL( KErrNotFound ); // index not needed or used in list impl.
       
   436             response = EKeyWasConsumed;
       
   437             }
       
   438         else
       
   439             {
       
   440             response = iActiveList->HandleKeyEventL( aKeyEvent, aType );            
       
   441             }
       
   442         }
       
   443 
       
   444     return response;    
       
   445     }
       
   446 
       
   447 // -----------------------------------------------------------------------------
       
   448 // Menu handling
       
   449 // -----------------------------------------------------------------------------
       
   450 //
       
   451 void CVcxHgVodMainView::DynInitMenuPaneL( 
       
   452     TInt aResourceId, 
       
   453     CEikMenuPane* aMenuPane )
       
   454     {
       
   455     if ( iActiveList )
       
   456         {
       
   457         iActiveList->ActivateMenuPaneItemsL( aMenuPane, aResourceId );
       
   458         }
       
   459     }
       
   460 
       
   461 // -----------------------------------------------------------------------------
       
   462 // Handle custom view message
       
   463 // -----------------------------------------------------------------------------
       
   464 //
       
   465 void CVcxHgVodMainView::HandleCustomViewMessageL(
       
   466     const TUid /*aMessageUid*/, 
       
   467     const TDesC8& aCustomMessage )
       
   468     {
       
   469     if ( aCustomMessage.Length() > KVideoPlayerActivationMessageMinLength )
       
   470         {
       
   471         ProcessCustomMessageL( aCustomMessage );
       
   472         }
       
   473     }
       
   474 
       
   475 // -----------------------------------------------------------------------------
       
   476 // Get pointer to title pane
       
   477 // -----------------------------------------------------------------------------
       
   478 //
       
   479 CAknTitlePane* CVcxHgVodMainView::TitlePaneL()
       
   480     {
       
   481     return static_cast<CAknTitlePane*>( StatusPane()->
       
   482             ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   483     }
       
   484 
       
   485 // -----------------------------------------------------------------------------
       
   486 // Get pointer to navi pane
       
   487 // -----------------------------------------------------------------------------
       
   488 //
       
   489 CAknNavigationControlContainer* CVcxHgVodMainView::NaviPaneL()
       
   490     {
       
   491     return static_cast<CAknNavigationControlContainer*>( StatusPane()->
       
   492             ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   493     }
       
   494 
       
   495 // ---------------------------------------------------------
       
   496 // Create list
       
   497 // ---------------------------------------------------------
       
   498 //
       
   499 void CVcxHgVodMainView::CreateListL( 
       
   500     TVcxHgVodListType aType )
       
   501     {
       
   502     if ( !iTextScroller && aType == EVcxNsCategoryList )
       
   503         {
       
   504         iTextScroller = CHgDoubleTextList::NewL( ClientRect(), 0 );
       
   505         }
       
   506     else if ( !iGraphicScroller )
       
   507         {
       
   508         iGraphicScroller = CHgDoubleGraphicList::NewL( ClientRect(), 0 );
       
   509         
       
   510         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   511         
       
   512         TFileName fileName;
       
   513         LocateMifFileL( fileName );
       
   514         
       
   515         if ( !iContentDefaultIcon ) // paranoia
       
   516             {
       
   517             iContentDefaultIcon = AknsUtils::CreateGulIconL( skin, 
       
   518                     KAknsIIDQgnPropMtvProgClip, 
       
   519 					fileName, 
       
   520                     EMbmVcxhgvoddefaulticonsQgn_prop_mtv_prog_clip, 
       
   521                     EMbmVcxhgvoddefaulticonsQgn_prop_mtv_prog_clip_mask );
       
   522             
       
   523             ScaleGulIconL( iContentDefaultIcon, 
       
   524                     CHgDoubleGraphicList::PreferredImageSize() );
       
   525             }
       
   526         
       
   527         if ( !iServiceDefaultIcon ) // paranoia
       
   528             {
       
   529             iServiceDefaultIcon = AknsUtils::CreateGulIconL( skin, 
       
   530                     KAknsIIDQgnPropMtvProgClip, 
       
   531                     fileName, 
       
   532                     EMbmVcxhgvoddefaulticonsQgn_prop_mtv_vodcast_feed, 
       
   533                     EMbmVcxhgvoddefaulticonsQgn_prop_mtv_vodcast_feed_mask );
       
   534             
       
   535             ScaleGulIconL( iServiceDefaultIcon, 
       
   536                     CHgDoubleGraphicList::PreferredImageSize() );
       
   537             }
       
   538         }
       
   539     
       
   540     if ( aType == EVcxNsServiceList && !iServiceList )
       
   541         {
       
   542         iServiceList = CVcxHgVodServiceListImpl::NewL( 
       
   543                 *iGraphicScroller, *iModel, *this );
       
   544         }
       
   545     else if ( ( aType == EVcxNsCategoryList ) && !iCategoryList )
       
   546         {
       
   547         iCategoryList = CVcxHgVodCategoryListImpl::NewL( 
       
   548                 *iTextScroller, *iModel, *this ); 
       
   549         }
       
   550     else if ( ( aType == EVcxNsContentList ) && !iContentList )
       
   551         {
       
   552         iContentList = CVcxHgVodContentListImpl::NewL( 
       
   553                  *iGraphicScroller, *iModel, *this );
       
   554         }
       
   555     else if ( ( aType == EVcxNsCustomList ) && !iServiceGroupList )
       
   556         {
       
   557         iServiceGroupList = CVcxHgVodServiceGroupListImpl::NewL(
       
   558                 *iGraphicScroller, *iModel, *this );
       
   559         }
       
   560     }
       
   561 
       
   562 // ---------------------------------------------------------
       
   563 // Activate list according to current state
       
   564 // ---------------------------------------------------------
       
   565 //
       
   566 void CVcxHgVodMainView::ChangeListViewL()
       
   567     {
       
   568     //Get application state from ui engine
       
   569     TVcxNsAppState newState = iModel->VcAppState();    
       
   570     
       
   571     if ( iActiveList )
       
   572         {
       
   573         iActiveList->DoDeactivate();
       
   574         SetActiveList( NULL );
       
   575         }
       
   576         
       
   577     if ( newState == EStateNoState )
       
   578         {
       
   579         // return, model not ready or application is closing.
       
   580         return;
       
   581         }
       
   582     
       
   583     
       
   584     if ( newState == EStateServiceView )
       
   585         {
       
   586         CreateListL( EVcxNsServiceList );
       
   587 
       
   588         iGraphicScroller->SetDefaultIconL( CVcxHgVodUtils::DuplicateGulIconL( iServiceDefaultIcon ) );
       
   589         
       
   590         iServiceList->DoActivateL();
       
   591         SetActiveList( iServiceList );
       
   592         }
       
   593     else if ( newState == EStateCategoryView )
       
   594         {
       
   595         CreateListL( EVcxNsCategoryList );
       
   596         iCategoryList->DoActivateL();
       
   597         SetActiveList( iCategoryList );
       
   598         }
       
   599     else if ( newState == EStateContentView )
       
   600         {
       
   601         CreateListL( EVcxNsContentList );
       
   602 
       
   603         iGraphicScroller->SetDefaultIconL( CVcxHgVodUtils::DuplicateGulIconL( iContentDefaultIcon ) );
       
   604 
       
   605         iContentList->DoActivateL();
       
   606         SetActiveList( iContentList );
       
   607         }
       
   608     else if ( newState == EStateCustomView )
       
   609         {
       
   610         CreateListL( EVcxNsCustomList );
       
   611 
       
   612         iGraphicScroller->SetDefaultIconL( CVcxHgVodUtils::DuplicateGulIconL( iServiceDefaultIcon ) );
       
   613 
       
   614         iServiceGroupList->DoActivateL();
       
   615         SetActiveList( iServiceGroupList );
       
   616         }
       
   617     }
       
   618 
       
   619 // ---------------------------------------------------------
       
   620 // Activate settings view
       
   621 // ---------------------------------------------------------
       
   622 //
       
   623 void CVcxHgVodMainView::OpenSettingsL( TInt aCommand )
       
   624     {
       
   625     // ###
       
   626 	TVideoPlayerActivationMessage params;
       
   627     
       
   628     if ( aCommand == EVcxHgVodServiceSubscriptionsCmd )
       
   629         {
       
   630         params.iMsgType = 
       
   631         TVideoPlayerActivationMessage::EOpenVCSettingsFeedSubscriptions;
       
   632         }
       
   633     else if ( aCommand == EVcxHgVodServiceAddManuallyCmd )
       
   634         {
       
   635         params.iMsgType = 
       
   636         TVideoPlayerActivationMessage::EOpenVCSettingsAddFeed;
       
   637         }
       
   638 
       
   639     TPckg<TVideoPlayerActivationMessage> paramsPckg( params );
       
   640     HBufC* customMsg = HBufC::NewLC( paramsPckg.Length() );
       
   641     customMsg->Des().Copy( paramsPckg );
       
   642     
       
   643     if ( !iViewUtility )
       
   644         {
       
   645         iViewUtility = MMPXViewUtility::UtilityL();
       
   646         }
       
   647     
       
   648     iViewUtility->ActivateViewL( 
       
   649         TUid::Uid ( KVcxNsSettingsPluginSettingsViewTypeId ), customMsg );
       
   650     
       
   651     CleanupStack::PopAndDestroy( customMsg );
       
   652     }
       
   653 
       
   654 // ---------------------------------------------------------
       
   655 // Activate schedule settings view
       
   656 // ---------------------------------------------------------
       
   657 //
       
   658 void CVcxHgVodMainView::OpenScheduleSettingsL()
       
   659     {
       
   660     CVcxNsService* service = iModel->GetServiceProviderL()->GetActiveServiceData();
       
   661 
       
   662     if ( !service )
       
   663         {
       
   664 	    return;
       
   665         }
       
   666     
       
   667 	TUint32 id = service->GetServiceId();
       
   668     TPckg<TUint32> paramsPckg( id );
       
   669     HBufC* customMsg = HBufC::NewLC( paramsPckg.Length() );
       
   670     customMsg->Des().Copy( paramsPckg );
       
   671     
       
   672     if ( !iViewUtility )
       
   673         {
       
   674         iViewUtility = MMPXViewUtility::UtilityL();
       
   675         }
       
   676     
       
   677     iViewUtility->ActivateViewL( 
       
   678         TUid::Uid ( KVcxNsSchedulePluginScheduleViewTypeId ), customMsg );
       
   679     
       
   680     CleanupStack::PopAndDestroy( customMsg );
       
   681     }
       
   682 
       
   683 // ---------------------------------------------------------
       
   684 // PlayInternalVideoL
       
   685 // ---------------------------------------------------------
       
   686 //
       
   687 void CVcxHgVodMainView::PlayInternalVideoL( CVcxNsContent* aContent )
       
   688     {
       
   689     if ( aContent )
       
   690         {
       
   691 	    if ( aContent->GetContentTypes() & CVcxNsContent::EVcxContentTypeVideo &&
       
   692                 aContent->GetDlStatus() == CVcxNsContent::EVcxContentDlStateDownloading ||
       
   693                 aContent->GetDlStatus() == CVcxNsContent::EVcxContentDlStateFailed ||
       
   694                 aContent->GetDlStatus() == CVcxNsContent::EVcxContentDlStatePaused || 
       
   695                 aContent->GetDlStatus() == CVcxNsContent::EVcxContentDlStateDownloaded ) 
       
   696 	        {
       
   697 	        iModel->PlayVideoL( aContent );
       
   698 	        iModel->VideoPlaybackStartingL( aContent );
       
   699 	        iModel->SetVcAppState( EStatePlayback );
       
   700 	        }
       
   701 	    else if ( aContent->GetContentTypes() & CVcxNsContent::EVcxContentTypeStream &&
       
   702 	              aContent->GetUrl( CVcxNsContent::EVcxContentTypeStream ).Length() > 0 ) 
       
   703             {
       
   704             iModel->PlayStreamL( aContent );
       
   705             iModel->VideoPlaybackStartingL( aContent );
       
   706             iModel->SetVcAppState( EStatePlayback );
       
   707             }
       
   708         }
       
   709     }
       
   710 
       
   711 
       
   712 // ---------------------------------------------------------
       
   713 // Stream video
       
   714 // ---------------------------------------------------------
       
   715 //
       
   716 void CVcxHgVodMainView::PlayStreamL( const TDesC& aUrl )
       
   717     {
       
   718     AppUi()->OpenFileL( aUrl );
       
   719     iModel->SetVcAppState( EStatePlayback );
       
   720     }
       
   721 
       
   722 // -----------------------------------------------------------------------------
       
   723 // 
       
   724 // -----------------------------------------------------------------------------
       
   725 // 
       
   726 TTypeUid::Ptr CVcxHgVodMainView::MopSupplyObject( TTypeUid aId )
       
   727     {   
       
   728     if ( iBgContext && aId.iUid == MAknsControlContext::ETypeId )
       
   729         {
       
   730         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   731         }  
       
   732     return CAknView::MopSupplyObject( aId );
       
   733     }
       
   734 
       
   735 // -----------------------------------------------------------------------------
       
   736 // 
       
   737 // -----------------------------------------------------------------------------
       
   738 //
       
   739 void CVcxHgVodMainView::HandleStatusPaneSizeChange()
       
   740     {
       
   741     // This function uses fonts from CCoeEnv, so we cannot  
       
   742     // execute function if the environment is already destroyed. This can
       
   743 	// happen e.g. when End key has pressed and application is closing.
       
   744     if ( iCoeEnv->NormalFont() )
       
   745         {
       
   746         TRect cr = ClientRect();
       
   747         
       
   748         TRect containerRect;
       
   749         if ( !AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, containerRect ) )
       
   750             {
       
   751             containerRect = cr;
       
   752             }
       
   753         
       
   754         if ( iBgContext )
       
   755             {
       
   756             iBgContext->SetRect( containerRect );
       
   757             }
       
   758     
       
   759         if ( iContainer )
       
   760             {
       
   761             iContainer->SetRect( containerRect );
       
   762             }
       
   763         
       
   764         if ( iGraphicScroller )
       
   765             {
       
   766             TRAP_IGNORE( iGraphicScroller->InitScreenL( cr ) );
       
   767             }
       
   768         
       
   769         if ( iTextScroller )
       
   770             {
       
   771             TRAP_IGNORE( iTextScroller->InitScreenL( cr ) );
       
   772             }
       
   773         
       
   774         if ( iActiveList )
       
   775             {
       
   776             iActiveList->HandleSizeChange();
       
   777             }
       
   778         }
       
   779     }
       
   780 
       
   781 // -----------------------------------------------------------------------------
       
   782 // 
       
   783 // -----------------------------------------------------------------------------
       
   784 //
       
   785 void CVcxHgVodMainView::HandleForegroundEventL( TBool aForeground )
       
   786     {
       
   787     CAknView::HandleForegroundEventL( aForeground );
       
   788     if ( iActiveList )
       
   789         {
       
   790         iActiveList->HandleForegroundEventL( aForeground );
       
   791         }
       
   792     }
       
   793 
       
   794 // ---------------------------------------------------------
       
   795 // Called by list implementation(s) when layout is changed.
       
   796 // ---------------------------------------------------------
       
   797 //
       
   798 void CVcxHgVodMainView::LayoutChanged()
       
   799     {
       
   800     HandleStatusPaneSizeChange();
       
   801     }
       
   802 
       
   803 // ---------------------------------------------------------
       
   804 // Get eikon env
       
   805 // ---------------------------------------------------------
       
   806 //
       
   807 CEikonEnv& CVcxHgVodMainView::EikonEnv()
       
   808     {
       
   809     return *iEikonEnv;
       
   810     }
       
   811 
       
   812 // ---------------------------------------------------------
       
   813 // Get Cba
       
   814 // ---------------------------------------------------------
       
   815 //
       
   816 CEikButtonGroupContainer* CVcxHgVodMainView::ViewCba()
       
   817     {
       
   818     return Cba();
       
   819     }
       
   820 
       
   821 // ---------------------------------------------------------
       
   822 // Touch support
       
   823 // ---------------------------------------------------------
       
   824 //
       
   825 TBool CVcxHgVodMainView::IsTouchSupported()
       
   826     {
       
   827     return iTouchSupport;
       
   828     }
       
   829 
       
   830 // ---------------------------------------------------------
       
   831 // 
       
   832 // ---------------------------------------------------------
       
   833 //
       
   834 void CVcxHgVodMainView::ProcessCustomMessageL( const TDesC8& aCustomMessage )
       
   835     {    
       
   836     TVideoPlayerActivationMessage params;
       
   837     TPckg<TVideoPlayerActivationMessage> paramsPckg( params );
       
   838     paramsPckg.Copy( aCustomMessage );
       
   839     
       
   840     // Message coming from note,
       
   841     // open to specified service
       
   842     if ( params.iMsgType == TVideoPlayerActivationMessage::ELaunchServiceById ) 
       
   843         {
       
   844         // Close the embedded browser if opened from here:
       
   845         TVcxNsAppState appState = iModel->VcAppState();
       
   846         if ( appState == EStateBrowser )
       
   847             {
       
   848             // Step the state back
       
   849             iModel->HandleBack();
       
   850             appState = iModel->VcAppState();
       
   851             
       
   852             if ( iServiceList && appState == EStateServiceView  )
       
   853                 {
       
   854                 iServiceList->CloseEmbeddedBrowser();
       
   855                 }
       
   856             }
       
   857         
       
   858         // Reset previous states.
       
   859         iModel->ResetStates();
       
   860 
       
   861         // Set state, where to return from content view
       
   862         iModel->SetVcAppState( EStateServiceView );
       
   863 
       
   864         // Open the actual service:
       
   865         iModel->GetServiceProviderL()->OpenServiceL( params.iServiceId );
       
   866         
       
   867         // Switch to correct view
       
   868         ChangeListViewL();
       
   869         }
       
   870 
       
   871     // Message coming from note or suite,
       
   872     // launch last watched video
       
   873     else if ( params.iMsgType == TVideoPlayerActivationMessage::ELaunchVideoToPlayer )
       
   874         {
       
   875 		iModel->PlayLastWatchedL();
       
   876         
       
   877 		iModel->SetVcAppState( EStatePlayback );
       
   878         
       
   879         // Switch to correct view
       
   880         ChangeListViewL();
       
   881         }
       
   882     }
       
   883 
       
   884 // -----------------------------------------------------------------------------
       
   885 //
       
   886 // -----------------------------------------------------------------------------
       
   887 //
       
   888 void CVcxHgVodMainView::CheckParentalControlL( TUint32 aAgeProfile )
       
   889     {
       
   890     TInt parentControlSetting( 0 );
       
   891     TInt error( KErrNone );
       
   892     if ( !iCenRep )
       
   893         {
       
   894         TRAP( error, iCenRep = CRepository::NewL( TUid::Uid( KVcxNsCenRepUid ) ) )
       
   895         }
       
   896     if ( error == KErrNone )
       
   897         {
       
   898         error = iCenRep->Get( KVcxNsCenRepParentControlKey, parentControlSetting );
       
   899         if ( error == KErrNone && parentControlSetting != 0 )
       
   900             {
       
   901             // Parental control has been set
       
   902             if ( static_cast<TInt>( aAgeProfile ) >= parentControlSetting )
       
   903                 {
       
   904                 // Must ask lock code to allow playing
       
   905                 if ( !iTelephonyClient )
       
   906                     {
       
   907                     iTelephonyClient = new( ELeave ) CVcxHgVodTelephonyClient();
       
   908                     }
       
   909                 if ( !iTelephonyClient->CheckLockCodeL() )
       
   910                     {
       
   911                     User::Leave( KErrPermissionDenied );
       
   912                     }
       
   913                 }
       
   914             }
       
   915         }
       
   916     }
       
   917 
       
   918 // -----------------------------------------------------------------------------
       
   919 // CVcxHgVodMainView::HandleCustomViewMessageL
       
   920 // -----------------------------------------------------------------------------
       
   921 //
       
   922 void CVcxHgVodMainView::HandleCustomViewMessageL()
       
   923     {
       
   924     TAny* ptr = UserSvr::DllTls( KVcxCustomViewMessagePtr );
       
   925     
       
   926     if ( ptr )
       
   927         {
       
   928         HBufC8* bufptr = ( HBufC8* ) ptr;
       
   929         
       
   930         if ( bufptr->Length() > KVideoPlayerActivationMessageMinLength )
       
   931             {
       
   932             ProcessCustomMessageL( *bufptr );
       
   933             }
       
   934         }
       
   935     }
       
   936 
       
   937 // -----------------------------------------------------------------------------
       
   938 // CVcxHgVodMainView::LocateMifFileL
       
   939 // -----------------------------------------------------------------------------
       
   940 //
       
   941 void CVcxHgVodMainView::LocateMifFileL( TFileName& aFileName )
       
   942     {
       
   943     // Get the path & file name with the drive not specified.
       
   944     TParse parse;
       
   945     parse.Set( KVodDefaultIconsMifFile, &KDC_APP_BITMAP_DIR, NULL );
       
   946     TPtrC mifFile = parse.FullName();
       
   947    
       
   948     // This is done to ensure upgraded file is used first.
       
   949     TFindFile find( iCoeEnv->FsSession() );
       
   950     TInt err = find.FindByDir( mifFile, KNullDesC );
       
   951     
       
   952     if ( err )
       
   953         {
       
   954         User::Leave( KErrNotFound );
       
   955         }
       
   956     else
       
   957         {
       
   958         aFileName.Append( find.File() );
       
   959         }
       
   960     }
       
   961