videocollection/hgmyvideos/src/vcxhgmyvideosmainview.cpp
changeset 0 96612d01cf9f
child 1 6711b85517b7
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:      My Videos UI main view.*
       
    15 */
       
    16 
       
    17 
       
    18 // Version : %version: TB92_30 %
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <bldvariant.hrh>
       
    22 #include <aknViewAppUi.h>
       
    23 #include <avkon.hrh>
       
    24 #include <StringLoader.h>
       
    25 #include <coeaui.h>
       
    26 #include <aknnotewrappers.h>
       
    27 #include <hlplch.h>
       
    28 
       
    29 #include <AknsBasicBackgroundControlContext.h>
       
    30 #include <ganes/HgDoubleTextList.h>
       
    31 #include <ganes/HgDoubleGraphicList.h>
       
    32 
       
    33 #include "IptvDebug.h"
       
    34 #include "CIptvResourceLoader.h"
       
    35 #include <vcxhgmyvideos.rsg>
       
    36 
       
    37 #include "vcxhgmyvideosmodel.h"
       
    38 #include "vcxhgmyvideosmainview.h"
       
    39 #include "vcxhgmyvideosmainviewcontainer.h"
       
    40 #include "vcxhgmyvideoscategorylistimpl.h"
       
    41 #include "vcxhgmyvideosvideolistimpl.h"
       
    42 #include "vcxhgmyvideosvideomodelhandler.h"
       
    43 #include "vcxhgmyvideos.hrh"
       
    44 #include "vcxhgmyvideosmemorystatus.h"
       
    45 #include "vcxhgmyvideosvideodetailsdialog.h"
       
    46 #include "vcxhgmyvideosupnpinterface.h"
       
    47 
       
    48 // CONSTANTS
       
    49 _LIT( KVcxHgMyVideosMainViewResFile, "\\resource\\apps\\vcxhgmyvideos." );
       
    50 
       
    51 const TUint32 KVcxHgMyVideosViewUid = 0x20021191;
       
    52 
       
    53 // ============================ MEMBER FUNCTIONS ===============================
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CVcxHgMyVideosMainView::CVcxHgMyVideosMainView()
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CVcxHgMyVideosMainView::CVcxHgMyVideosMainView()
       
    60     {
       
    61     IPTVLOGSTRING_LOW_LEVEL( 
       
    62         "MPX My Videos UI # ----------- MPX My Videos UI starting -----------" );
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CVcxHgMyVideosMainView::NewL()
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 EXPORT_C CVcxHgMyVideosMainView* CVcxHgMyVideosMainView::NewL()
       
    70     {
       
    71     CVcxHgMyVideosMainView* self = 
       
    72         CVcxHgMyVideosMainView::NewLC();
       
    73     CleanupStack::Pop( self );
       
    74     return self;
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CVcxHgMyVideosMainView::NewLC()
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C CVcxHgMyVideosMainView* CVcxHgMyVideosMainView::NewLC()
       
    82     {
       
    83     CVcxHgMyVideosMainView* self = 
       
    84         new (ELeave) CVcxHgMyVideosMainView();
       
    85     CleanupStack::PushL( self );
       
    86     self->ConstructL();
       
    87     return self;
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CVcxHgMyVideosMainView::ConstructL()
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CVcxHgMyVideosMainView::ConstructL()
       
    95     {
       
    96     IPTVLOGSTRING_LOW_LEVEL( 
       
    97         "MPX My Videos UI # CVcxHgMyVideosMainView::ConstructL: Entered." );
       
    98     
       
    99     iResourceLoader = CIptvResourceLoader::NewL( *iCoeEnv );
       
   100     iResourceLoader->AddResourceL( KVcxHgMyVideosMainViewResFile );
       
   101 
       
   102     BaseConstructL( R_VCXHGMYVIDEOS_MAINVIEW );
       
   103     
       
   104     // Create component model.
       
   105     iModel = CVcxHgMyVideosModel::NewL();
       
   106 
       
   107     // Create background context.
       
   108     iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,
       
   109                                                            ClientRect(),
       
   110                                                            ETrue );
       
   111     IPTVLOGSTRING_LOW_LEVEL( 
       
   112         "MPX My Videos UI # CVcxHgMyVideosMainView::ConstructL: Exited." );
       
   113     }
       
   114 
       
   115 // -----------------------------------------------------------------------------
       
   116 // CVcxHgMyVideosMainView::~CVcxHgMyVideosMainView()
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 EXPORT_C CVcxHgMyVideosMainView::~CVcxHgMyVideosMainView()
       
   120     {
       
   121     IPTVLOGSTRING_LOW_LEVEL( 
       
   122         "MPX My Videos UI # ----------- MPX My Videos UI stopping -----------" );
       
   123 
       
   124     delete iCategoryList;
       
   125     delete iVideoList;    
       
   126     delete iModel;
       
   127     delete iBgContext;
       
   128     delete iResourceLoader;
       
   129     
       
   130     if ( iContainer )
       
   131         {
       
   132         AppUi()->RemoveFromStack( iContainer );
       
   133         delete iContainer;
       
   134         iContainer = NULL;
       
   135         }
       
   136     }
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CVcxHgMyVideosMainView::CategoryListL()
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 CVcxHgMyVideosCategoryListImpl* CVcxHgMyVideosMainView::CategoryListL()
       
   143     {
       
   144     if ( !iCategoryList )
       
   145         {
       
   146         IPTVLOGSTRING_LOW_LEVEL( 
       
   147             "MPX My Videos UI # CVcxHgMyVideosMainView::CategoryListL: Creating category list." );
       
   148         // Create category list control.
       
   149         CHgDoubleTextList* hgCategoryList = 
       
   150             CHgDoubleTextList::NewL( ClientRect(), 0 );
       
   151         CleanupStack::PushL( hgCategoryList );
       
   152       
       
   153         // Create list implementations. 
       
   154         // Ownership of list control is transferred. 
       
   155         iCategoryList = CVcxHgMyVideosCategoryListImpl::NewL( *iModel,
       
   156                                                               *this,
       
   157                                                               *hgCategoryList );
       
   158         CleanupStack::Pop( hgCategoryList );
       
   159         }
       
   160     
       
   161     return iCategoryList;
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CVcxHgMyVideosMainView::VideoListL()
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 CVcxHgMyVideosVideoListImpl* CVcxHgMyVideosMainView::VideoListL()
       
   169     {
       
   170     if ( !iVideoList )
       
   171         {
       
   172         IPTVLOGSTRING_LOW_LEVEL( 
       
   173             "MPX My Videos UI # CVcxHgMyVideosMainView::VideoListL: Creating video list." );
       
   174         
       
   175         // Create video list control.
       
   176         CHgDoubleGraphicList* hgVideoList = 
       
   177             CHgDoubleGraphicList::NewL( ClientRect(), 0 );
       
   178         CleanupStack::PushL( hgVideoList );
       
   179         
       
   180         // Create list implementation. 
       
   181         // Ownership of list control is transferred.        
       
   182         iVideoList = CVcxHgMyVideosVideoListImpl::NewL( *iModel,
       
   183                                                         *this,
       
   184                                                         *hgVideoList );
       
   185         CleanupStack::Pop( hgVideoList );
       
   186         }
       
   187     
       
   188     return iVideoList;
       
   189     }
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CVcxHgMyVideosMainView::Cba()
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 CEikButtonGroupContainer* CVcxHgMyVideosMainView::Cba()
       
   196     {
       
   197     return CAknView::Cba();
       
   198     }
       
   199 
       
   200 // -----------------------------------------------------------------------------
       
   201 // CVcxHgMyVideosMainView::Id()
       
   202 // -----------------------------------------------------------------------------
       
   203 // 
       
   204 TUid CVcxHgMyVideosMainView::Id() const
       
   205 	{
       
   206 	return TUid::Uid( KVcxHgMyVideosViewUid ); 
       
   207 	}
       
   208 
       
   209 // -----------------------------------------------------------------------------
       
   210 // CVcxHgMyVideosMainView::MopSupplyObject()
       
   211 // -----------------------------------------------------------------------------
       
   212 // 
       
   213 TTypeUid::Ptr CVcxHgMyVideosMainView::MopSupplyObject( TTypeUid aId )
       
   214     {   
       
   215     if ( iBgContext && aId.iUid == MAknsControlContext::ETypeId )
       
   216         {
       
   217         return MAknsControlContext::SupplyMopObject( aId, iBgContext );
       
   218         }  
       
   219     return CAknView::MopSupplyObject( aId );
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // CVcxHgMyVideosMainView::HandleStatusPaneSizeChange()
       
   224 // 
       
   225 // Called by the framework when the application status pane
       
   226 // size is changed.
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 void CVcxHgMyVideosMainView::HandleStatusPaneSizeChange()
       
   230     {
       
   231     UpdateLayout(); 
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CVcxHgMyVideosMainView::TitlePaneL()
       
   236 // -----------------------------------------------------------------------------
       
   237 // 
       
   238 CAknTitlePane* CVcxHgMyVideosMainView::TitlePaneL()
       
   239     {
       
   240     CAknTitlePane*  titlePane  = static_cast<CAknTitlePane*>(
       
   241             StatusPane()->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   242 
       
   243     return titlePane;
       
   244     }
       
   245 
       
   246 // -----------------------------------------------------------------------------
       
   247 // CVcxHgMyVideosMainView::DoActivateL()
       
   248 // -----------------------------------------------------------------------------
       
   249 // 
       
   250 void CVcxHgMyVideosMainView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
       
   251                                           TUid /*aCustomMessageId*/,
       
   252                                           const TDesC8& /*aCustomMessage*/ )
       
   253     {  
       
   254     if ( ! iContainer )
       
   255         {
       
   256         iContainer = CVcxHgMyVideosMainViewContainer::NewL( *this );
       
   257         AppUi()->AddToStackL( *this, iContainer );
       
   258         }
       
   259     
       
   260     CVcxHgMyVideosModel::TVcxMyVideosAppState appState = iModel->AppState();
       
   261     if ( ( appState == CVcxHgMyVideosModel::EVcxMyVideosAppStateUnknown ) ||
       
   262          ( appState == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle ) ||
       
   263          ( appState == CVcxHgMyVideosModel::EVcxMyVideosAppStatePlayer &&
       
   264            iModel->PreviousAppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle ) ) 
       
   265         {
       
   266         ActivateCategoryListL();
       
   267         }
       
   268     else
       
   269         {
       
   270         ActivateVideoListL( KErrNotFound ); // Try to activate old list. 
       
   271         }
       
   272     }
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CVcxHgMyVideosMainView::DoDeactivate()
       
   276 // -----------------------------------------------------------------------------
       
   277 // 
       
   278 void CVcxHgMyVideosMainView::DoDeactivate()
       
   279     {
       
   280     if ( iCategoryList )
       
   281         {
       
   282         TRAP_IGNORE( CategoryListL()->DoListDeactivate() );
       
   283         }
       
   284     
       
   285     if ( iVideoList )
       
   286         {
       
   287         TRAP_IGNORE( VideoListL()->DoListDeactivate() );
       
   288         }
       
   289 
       
   290     if ( iContainer )
       
   291 		{
       
   292 		AppUi()->RemoveFromStack( iContainer );
       
   293 		delete iContainer;
       
   294 		iContainer = NULL;
       
   295 		}
       
   296 	}
       
   297 
       
   298 // -----------------------------------------------------------------------------
       
   299 // CVcxHgMyVideosMainView::ActivateCategoryListL()
       
   300 // -----------------------------------------------------------------------------
       
   301 // 
       
   302 void CVcxHgMyVideosMainView::ActivateCategoryListL()
       
   303     {
       
   304     iModel->SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryBusy );
       
   305     
       
   306     CategoryListL()->DoListActivateL();
       
   307     
       
   308     if ( iVideoList )
       
   309         {
       
   310         VideoListL()->DoListDeactivate();
       
   311         }
       
   312     
       
   313     iModel->SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle );
       
   314     DynInitMskL();
       
   315     DynInitRskL();
       
   316     }
       
   317 
       
   318 // -----------------------------------------------------------------------------
       
   319 // CVcxHgMyVideosMainView::ActivateVideoListL()
       
   320 // -----------------------------------------------------------------------------
       
   321 // 
       
   322 void CVcxHgMyVideosMainView::ActivateVideoListL( TInt aIndex )
       
   323     {  
       
   324     iModel->SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoBusy );
       
   325         
       
   326     VideoListL()->DoListActivateL( aIndex );
       
   327     
       
   328     if ( iCategoryList )
       
   329         {   
       
   330         CategoryListL()->DoListDeactivate();
       
   331         }
       
   332     
       
   333     iModel->SetAppState( CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle );
       
   334     DynInitMskL();
       
   335     DynInitRskL();
       
   336     }
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 // CVcxHgMyVideosMainView::HandleCommandL()
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 void CVcxHgMyVideosMainView::HandleCommandL( TInt aCommand )
       
   343     {
       
   344     switch ( aCommand )
       
   345         {
       
   346         case EAknSoftkeyCancel:
       
   347             {
       
   348             HandleCancelL();
       
   349             break;
       
   350             }
       
   351         case EVcxHgMyVideosCmdPlay:
       
   352             {
       
   353             VideoListL()->PlayCurrentVideoL();
       
   354             }
       
   355             break;
       
   356         case EVcxHgMyVideosCmdOpen:
       
   357         case EAknSoftkeyOpen: // MSK
       
   358             {
       
   359             TInt highlight = CategoryListL()->Highlight();
       
   360             
       
   361             if ( highlight >= 0 )
       
   362                 {
       
   363                 ActivateVideoListL( highlight );
       
   364                 }
       
   365             }
       
   366             break;
       
   367         case EVcxHgMyVideosCmdDelete:
       
   368             {
       
   369             if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   370                 {
       
   371                 VideoListL()->DeleteVideosL();
       
   372                 }
       
   373             }
       
   374             break;
       
   375         case EVcxHgMyVideosCmdResumeDownload:
       
   376             {
       
   377             if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   378                 {
       
   379                 VideoListL()->ResumeDownloadL();
       
   380                 }
       
   381             }
       
   382             break;
       
   383         case EVcxHgMyVideosCmdCancelDownload:
       
   384             {
       
   385             if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   386                 {
       
   387                 VideoListL()->CancelDownloadL();
       
   388                 }
       
   389             }
       
   390             break;
       
   391         case EVcxHgMyVideosCmdVideoDetails:
       
   392             {
       
   393             VideoListL()->VideoModel().ShowVideoDetailsDialogL();
       
   394             }
       
   395             break;
       
   396         case EVcxHgMyVideosCmdShowViaHomenet:
       
   397             {            
       
   398             if ( ! VideoListL()->UPnPInterface().IsStarted() )
       
   399                 {
       
   400                  if ( VideoListL()->UPnPInterface().Start() != KErrNone )
       
   401                     {
       
   402                     break;
       
   403                     }
       
   404                 }
       
   405             VideoListL()->PlayCurrentVideoL();
       
   406             }
       
   407             break;
       
   408         case EVcxHgMyVideosCmdStopShowViaHomenet:
       
   409             {            
       
   410             VideoListL()->UPnPInterface().Stop();
       
   411             }
       
   412             break;
       
   413         case EVcxHgMyVideosCmdMemoryStatus:
       
   414             {
       
   415             iMemoryStatus->ShowMemoryStatusDialogL( *iModel );
       
   416             }
       
   417             break;
       
   418         case EVcxHgMyVideosCmdSortByDate:
       
   419         case EVcxHgMyVideosCmdSortByName:
       
   420         case EVcxHgMyVideosCmdSortBySize:
       
   421             {
       
   422             if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   423                 {
       
   424                 VideoListL()->HandleSortCommandL( aCommand );
       
   425                 }
       
   426             }
       
   427             break;
       
   428         case EVcxHgMyVideosCmdCopy:
       
   429         case EVcxHgMyVideosCmdMove:
       
   430             {
       
   431             if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   432                 {
       
   433                 VideoListL()->HandleMoveOrCopyCommandL( aCommand == EVcxHgMyVideosCmdCopy ? 
       
   434                                                         ETrue : EFalse );
       
   435                 }
       
   436             }
       
   437             break;
       
   438         case EVcxHgMyVideosCmdSend:
       
   439             {
       
   440             VideoListL()->HandleSendL();
       
   441             break;
       
   442             }        
       
   443         case EVcxHgMyVideosCmdMark:
       
   444         case EVcxHgMyVideosCmdUnmark:
       
   445         case EVcxHgMyVideosCmdMarkAll:
       
   446         case EVcxHgMyVideosCmdUnmarkAll:
       
   447         case EVcxHgMyVideosCmdToggleMultipleMarking:        
       
   448             {
       
   449             VideoListL()->HandleMarkCommandL( aCommand );
       
   450             }
       
   451             break;
       
   452         case EVcxHgMyVideosCmdHelp:
       
   453             {
       
   454             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   455                                                  AppUi()->AppHelpContextL() );
       
   456             }
       
   457             break;
       
   458         case EAknSoftkeySelect: // Select button / MSK.
       
   459             {
       
   460             if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle )
       
   461                 {
       
   462                 HandleCommandL( EVcxHgMyVideosCmdOpen );
       
   463                 }
       
   464             else if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   465                 {
       
   466                 RArray<TInt> markedVideos;
       
   467                 CleanupClosePushL( markedVideos );
       
   468                 
       
   469                 VideoListL()->VideoModel().MarkedVideosL( markedVideos );
       
   470                 if ( markedVideos.Count() <= 0 )
       
   471                     {
       
   472                     HandleCommandL( EVcxHgMyVideosCmdPlay );
       
   473                     }
       
   474                 CleanupStack::PopAndDestroy( &markedVideos );
       
   475                 }
       
   476             }
       
   477             break;
       
   478         case EAknSoftkeyBack:
       
   479             {
       
   480             if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   481                 {
       
   482                 VideoListL()->HandleMarkCommandL( EVcxHgMyVideosCmdUnmarkAll );
       
   483                 ActivateCategoryListL();
       
   484                 }
       
   485             else
       
   486                 {
       
   487                 AppUi()->HandleCommandL( aCommand );
       
   488                 }
       
   489             }
       
   490             break;
       
   491         case EVcxHgMyVideosCmdExit:
       
   492         case EAknSoftkeyExit:
       
   493         case EEikCmdExit:
       
   494         case EAknCmdExit:
       
   495             {
       
   496             // Pass command to app ui for handling.
       
   497             AppUi()->HandleCommandL( EAknCmdExit );
       
   498             }
       
   499             break;
       
   500         case EVcxHgMyVideosCmdNothing:
       
   501         default:
       
   502             {
       
   503             // The command could be an AIW command,  offer it
       
   504             // to AIW command handler
       
   505             VideoListL()->TryHandleAiwCommandL( aCommand );
       
   506             }
       
   507             break;
       
   508         }
       
   509 
       
   510     DynInitMskL();
       
   511     DynInitRskL();
       
   512     }
       
   513 
       
   514 // ------------------------------------------------------------------------------
       
   515 // CVcxHgMyVideosMainView::HandleKeyEventL()
       
   516 // ------------------------------------------------------------------------------
       
   517 //
       
   518 TKeyResponse CVcxHgMyVideosMainView::HandleKeyEventL( const TKeyEvent& aKeyEvent, 
       
   519                                                       TEventCode aType )
       
   520     {
       
   521     TKeyResponse response( EKeyWasNotConsumed );
       
   522     
       
   523     // Clear key performs either 'Delete' or 'Cancel Download'. As Cancel Download
       
   524     // cannot be performed if there are selections, selections always cause Delete.
       
   525     // When there is no selections, video's status dictates the operation.
       
   526     if ( aKeyEvent.iScanCode == EStdKeyBackspace && aType == EEventKey )
       
   527         {
       
   528         if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   529             {
       
   530             RArray<TInt> markedVideos;
       
   531             CleanupClosePushL( markedVideos );
       
   532             
       
   533             VideoListL()->VideoModel().MarkedVideosL( markedVideos );
       
   534             TInt count = markedVideos.Count();
       
   535 			CleanupStack::PopAndDestroy( &markedVideos );
       
   536 			
       
   537             if ( ( count > 0 ) ||
       
   538                  ( VideoListL()->VideoModel().VideoDownloadState( VideoListL()->Highlight() )
       
   539                    == EVcxMyVideosDlStateNone ) )
       
   540                 {
       
   541                 HandleCommandL( EVcxHgMyVideosCmdDelete );
       
   542                 }
       
   543             else
       
   544                 {
       
   545                 HandleCommandL( EVcxHgMyVideosCmdCancelDownload );
       
   546                 }
       
   547             
       
   548 			response = EKeyWasConsumed;
       
   549             }
       
   550         }
       
   551     
       
   552     // Enter key should work the same way as selection key.
       
   553     else if ( ( aKeyEvent.iScanCode == EStdKeyEnter || aKeyEvent.iScanCode == EStdKeyDevice3 )
       
   554               && aType == EEventKey )
       
   555         {
       
   556         HandleCommandL( EAknSoftkeySelect );
       
   557         response = EKeyWasConsumed;
       
   558         }
       
   559     
       
   560     return response;
       
   561     }
       
   562 
       
   563 // ------------------------------------------------------------------------------
       
   564 // CVcxHgMyVideosMainView::UpdateLayout()
       
   565 // ------------------------------------------------------------------------------
       
   566 //
       
   567 void CVcxHgMyVideosMainView::UpdateLayout()
       
   568     {
       
   569     TRect rect( ClientRect() );
       
   570     
       
   571     if ( iVideoList )
       
   572         {
       
   573         iVideoList->UpdateLayout( rect );
       
   574         }
       
   575     if ( iCategoryList )
       
   576         {
       
   577         iCategoryList->UpdateLayout( rect );
       
   578         }
       
   579     if ( iBgContext )
       
   580         {
       
   581         iBgContext->SetRect( rect );
       
   582         }
       
   583     }
       
   584 	
       
   585 // ------------------------------------------------------------------------------
       
   586 // CVcxHgMyVideosMainView::DynInitMenuPaneL()
       
   587 // ------------------------------------------------------------------------------
       
   588 //
       
   589 void CVcxHgMyVideosMainView::DynInitMenuPaneL( TInt aResourceId,
       
   590                                                CEikMenuPane* aMenuPane )
       
   591     {
       
   592     TBool showMoveAndCopySubmenu = EFalse;
       
   593     TBool showCopy = EFalse;
       
   594     TBool showMove = EFalse;
       
   595 
       
   596     if ( aResourceId == R_VCXHGMYVIDEOS_MAINVIEW_MENU )
       
   597         {
       
   598         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdDelete, ETrue );
       
   599         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdResumeDownload, ETrue );
       
   600         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdCancelDownload, ETrue );
       
   601         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdSortSubMenu, ETrue );        
       
   602         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdVideoDetails, ETrue );
       
   603         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdStopShowViaHomenet, ETrue );
       
   604         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdShowViaHomenet, ETrue );
       
   605         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdAiwAssign, ETrue );
       
   606         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdOpen, ETrue );
       
   607         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdPlay, ETrue );
       
   608         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMemoryStatus, ETrue );
       
   609         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdCopy, ETrue );
       
   610         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMove, ETrue );
       
   611         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMarkUnmarkSubMenu, ETrue);
       
   612                 
       
   613         if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle )
       
   614             {                    
       
   615             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdOpen, EFalse );    
       
   616             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMemoryStatus, EFalse );
       
   617             }
       
   618         else if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   619             {
       
   620             VideoListL()->ShowMoveAndCopyMenuItemsL( showMoveAndCopySubmenu, showCopy, showMove );
       
   621             
       
   622             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdPlay, EFalse );
       
   623             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdCopy, !showCopy );
       
   624             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMove, !showMove );
       
   625             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMemoryStatus, EFalse );
       
   626             aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdSortSubMenu, EFalse );
       
   627             
       
   628             // Video list handles initialisation of menu items specific to it.
       
   629             VideoListL()->DynInitMenuPaneL( aResourceId, aMenuPane );
       
   630             }
       
   631         
       
   632         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdHelp, EFalse );
       
   633         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdExit, EFalse );
       
   634         }
       
   635     else if ( aResourceId == R_VCXHGMYVIDEOS_SORT_SUBMENU )
       
   636         {
       
   637         if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle )
       
   638             {
       
   639             return;
       
   640             }
       
   641 
       
   642         switch ( iModel->VideolistSortOrderL() )
       
   643             {
       
   644             case EVcxMyVideosSortingCreationDate:
       
   645                 {
       
   646                 aMenuPane->SetItemButtonState( EVcxHgMyVideosCmdSortByDate,
       
   647                                                EEikMenuItemSymbolOn );
       
   648                 break;
       
   649                 }                    
       
   650             case EVcxMyVideosSortingName:
       
   651                 {
       
   652                 aMenuPane->SetItemButtonState( EVcxHgMyVideosCmdSortByName,
       
   653                                                EEikMenuItemSymbolOn );
       
   654                 break;
       
   655                 }                    
       
   656             case EVcxMyVideosSortingSize:
       
   657                 {
       
   658                 aMenuPane->SetItemButtonState( EVcxHgMyVideosCmdSortBySize,
       
   659                                                EEikMenuItemSymbolOn );
       
   660                 break;
       
   661                 }                    
       
   662             default:
       
   663                 {
       
   664                 break;
       
   665                 }
       
   666             }
       
   667         }        
       
   668     else if ( aResourceId == R_VCXHGMYVIDEOS_USE_AS_SUBMENU )
       
   669         {
       
   670         if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle )
       
   671             {
       
   672             return;
       
   673             }
       
   674 
       
   675         // Let video list handle AIW menu
       
   676         VideoListL()->DynInitMenuPaneL( aResourceId, aMenuPane );
       
   677         }
       
   678     else if ( aResourceId == R_VCXHGMYVIDEOS_MARK_SUBMENU )
       
   679         {
       
   680         if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle )
       
   681             {
       
   682             return;
       
   683             }
       
   684         TBool showMarkSubmenu = EFalse;
       
   685         TBool showStartMarking = EFalse;
       
   686         TBool showEndmarking = EFalse;
       
   687         TBool showMarkAll = EFalse;
       
   688         TBool showUnmarkAll = EFalse;
       
   689 
       
   690         VideoListL()->ShowMarkMenuItemsL(
       
   691                 showMarkSubmenu,
       
   692                 showStartMarking,
       
   693                 showEndmarking,
       
   694                 showMarkAll,
       
   695                 showUnmarkAll );
       
   696 
       
   697         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdToggleMultipleMarking, ! showStartMarking );        
       
   698         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdMarkAll, ! showMarkAll );
       
   699         aMenuPane->SetItemDimmed( EVcxHgMyVideosCmdUnmarkAll, ! showUnmarkAll );
       
   700         }
       
   701     }
       
   702 
       
   703 // ------------------------------------------------------------------------------
       
   704 // CVcxHgMyVideosMainView::DynInitMskL()
       
   705 // ------------------------------------------------------------------------------
       
   706 //
       
   707 void CVcxHgMyVideosMainView::DynInitMskL()
       
   708     {
       
   709     TInt mskToSet( 0 );
       
   710 
       
   711     if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryBusy ||
       
   712          iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateCategoryIdle )
       
   713         {
       
   714         mskToSet = R_VCXHGMYVIDEOS_MSK_OPEN;
       
   715         }
       
   716     else if ( iModel->AppState() == CVcxHgMyVideosModel::EVcxMyVideosAppStateVideoIdle )
       
   717         {
       
   718         mskToSet = VideoListL()->GetMskResourceL();
       
   719         }
       
   720     else
       
   721         {
       
   722         mskToSet = R_VCXHGMYVIDEOS_MSK_NOTHING;
       
   723         }
       
   724 
       
   725     if ( mskToSet != iCurrentMskResource )
       
   726         {
       
   727         iCurrentMskResource = mskToSet;
       
   728 
       
   729         if ( Cba() )
       
   730             {
       
   731             Cba()->SetCommandL( CEikButtonGroupContainer::EMiddleSoftkeyPosition,
       
   732                                 iCurrentMskResource );
       
   733             Cba()->DrawDeferred();
       
   734             }
       
   735         }
       
   736     }
       
   737 
       
   738 // ------------------------------------------------------------------------------
       
   739 // CVcxHgMyVideosMainView::DynInitRskL()
       
   740 // ------------------------------------------------------------------------------
       
   741 //
       
   742 void CVcxHgMyVideosMainView::DynInitRskL()
       
   743     {
       
   744     TInt rskToSet( 0 );
       
   745 
       
   746     if ( iVideoList && iVideoList->IsMarking() )
       
   747         {
       
   748         rskToSet = R_VCXHGMYVIDEOS_RSK_CANCEL;
       
   749         }    
       
   750     else
       
   751         {
       
   752         rskToSet = R_VCXHGMYVIDEOS_RSK_BACK;
       
   753         }
       
   754 
       
   755     if ( rskToSet != iCurrentRskResource )
       
   756         {
       
   757         iCurrentRskResource = rskToSet;
       
   758 
       
   759         if ( Cba() )
       
   760             {
       
   761             Cba()->SetCommandL( CEikButtonGroupContainer::ERightSoftkeyPosition,
       
   762                                 iCurrentRskResource );
       
   763             Cba()->DrawDeferred();
       
   764             }
       
   765         }
       
   766     }
       
   767 
       
   768 // ------------------------------------------------------------------------------
       
   769 // CVcxHgMyVideosMainView::HandleCancelL()
       
   770 // ------------------------------------------------------------------------------
       
   771 //
       
   772 void CVcxHgMyVideosMainView::HandleCancelL()
       
   773     {
       
   774     if ( VideoListL()->IsMarking() )
       
   775         {
       
   776         VideoListL()->HandleMarkCommandL( EVcxHgMyVideosCmdStopMarking );
       
   777         }    
       
   778     }