videofeeds/hgvodui/src/vcxhgvodservicelistimpl.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:    HG VOD service list implementation*
       
    15 */
       
    16 
       
    17 
       
    18 // Version : %version: 19 %
       
    19 
       
    20 #include <akntitle.h>
       
    21 #include <aknViewAppUi.h>
       
    22 #include <aknnotewrappers.h>
       
    23 #include <eikmenup.h> 
       
    24 #include <StringLoader.h>
       
    25 #include <vcxhgvodui.rsg>
       
    26 #include <eikbtgpc.h>
       
    27 #include <ganes/HgScroller.h>
       
    28 
       
    29 #include <csxhelp/iptv.hlp.hrh>
       
    30 #include "vcxhgvodservicelistimpl.h"
       
    31 #include "vcxhgvodservicelistmodelhandler.h"
       
    32 #include "vcxhgvodmainview.h"
       
    33 #include "vcxhgvodmainviewcontainer.h"
       
    34 #include "vcxnsserviceproviderif.h"
       
    35 #include "vcxnsservice.h"
       
    36 #include "vcxhgvodui.hrh"
       
    37 #include "vcxhgvodutils.h"
       
    38 #include "vcxnsupdateprogresshandler.h"
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CVcxHgVodServiceListImpl::~CVcxHgVodServiceListImpl()
       
    42 // Destructor
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CVcxHgVodServiceListImpl::~CVcxHgVodServiceListImpl()
       
    46     {
       
    47     //always set model null to widget before destroying it
       
    48     delete iModelHandler;
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CVcxHgVodServiceListImpl::NewL()
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CVcxHgVodServiceListImpl* CVcxHgVodServiceListImpl::NewL(
       
    56     CHgScroller& aScroller, 
       
    57     CVcxNsUiEngine& aDataProviderIf,
       
    58     CVcxHgVodMainView& aView )
       
    59     {
       
    60     CVcxHgVodServiceListImpl* self = 
       
    61         CVcxHgVodServiceListImpl::NewLC( 
       
    62                   aScroller, aDataProviderIf, aView );
       
    63     CleanupStack::Pop( self );
       
    64     return self;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CVcxHgVodServiceListImpl::NewLC()
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CVcxHgVodServiceListImpl* CVcxHgVodServiceListImpl::NewLC(
       
    72     CHgScroller& aScroller, 
       
    73     CVcxNsUiEngine& aDataProviderIf,
       
    74     CVcxHgVodMainView& aView )
       
    75     {
       
    76     CVcxHgVodServiceListImpl* self = 
       
    77         new (ELeave) CVcxHgVodServiceListImpl( 
       
    78             aScroller, aDataProviderIf, aView );
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL( aDataProviderIf );
       
    81     return self;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // 
       
    86 // -----------------------------------------------------------------------------
       
    87 void CVcxHgVodServiceListImpl::DoActivateL( )
       
    88     {
       
    89     // refresh menu
       
    90     SetMenuResourceId( R_VCXHG_VOD_SERVICEVIEW_MENUBAR );
       
    91     UpdateTitlePaneL();
       
    92     SetEmptyListTextL( R_VCXHG_VOD_OPENING_FEEDS );
       
    93     SetMskL( R_VCXHG_VOD_MSK_BUTTON_DO_NOTHING );
       
    94     
       
    95     iScroller.SetSelectionObserver( *this );
       
    96     iView.AppUi()->AddToStackL( &iScroller );
       
    97     iScroller.SetFocus( ETrue );
       
    98 
       
    99     iModelHandler->DoActivateModelL();
       
   100     }
       
   101 // -----------------------------------------------------------------------------
       
   102 //  
       
   103 // -----------------------------------------------------------------------------
       
   104 void CVcxHgVodServiceListImpl::DoDeactivate( )
       
   105     {
       
   106     //Make sure that MSK is updated when returning to view
       
   107     iCurrentMskResource = 0;
       
   108     iMoving = EFalse;
       
   109     iModelHandler->DoDeActivateModel();
       
   110     iView.AppUi()->RemoveFromStack( &iScroller );
       
   111     iScroller.SetFocus( EFalse );
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 //  Activate usable menu items before showing menu
       
   116 // -----------------------------------------------------------------------------
       
   117 void CVcxHgVodServiceListImpl::ActivateMenuPaneItemsL( 
       
   118     CEikMenuPane* aMenuPane,
       
   119     TInt aResourceId )
       
   120     {
       
   121     if ( aMenuPane && 
       
   122          ( aResourceId == R_VCXHG_VOD_SERVICEVIEW_MENU ) )
       
   123         {
       
   124         TInt selected = iModelHandler->GetSelected();
       
   125         
       
   126         if ( !FeedRemovable( selected ) )
       
   127             {
       
   128             aMenuPane->SetItemDimmed( EVcxHgVodServiceRemoveCmd, ETrue );
       
   129             }
       
   130         
       
   131         aMenuPane->SetItemDimmed( EVcxHgVodServiceDetailsCmd, ETrue );
       
   132         aMenuPane->SetItemDimmed( EVcxHgVodServiceManageAccountCmd, ETrue );
       
   133         
       
   134         if ( !iModelHandler->IsEmptyModel() )
       
   135             {
       
   136             if ( iModelHandler->ServiceProvider()->HasAccountManagementUri( selected ) )
       
   137                 {
       
   138                 aMenuPane->SetItemDimmed( EVcxHgVodServiceManageAccountCmd, EFalse );
       
   139                 }
       
   140             
       
   141             if ( iModelHandler->ServiceProvider()->HasFeedDetails( selected ) )    
       
   142                 {
       
   143                 aMenuPane->SetItemDimmed( EVcxHgVodServiceDetailsCmd, EFalse );
       
   144                 }
       
   145             }
       
   146         
       
   147         if( ! iModelHandler->IsEmptyModel() &&
       
   148             ! iModelHandler->LastItemSelected() )
       
   149             {
       
   150             aMenuPane->SetItemDimmed( EVcxHgVodServiceMoveCmd, EFalse );
       
   151             }
       
   152         else
       
   153             {
       
   154             aMenuPane->SetItemDimmed( EVcxHgVodServiceMoveCmd, ETrue );
       
   155             }
       
   156 
       
   157         if ( !HasVideoServicesL() )
       
   158             {
       
   159             aMenuPane->SetItemDimmed( EVcxHgVodServiceRefreshAllCmd, ETrue );            
       
   160             }
       
   161         }
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CVcxHgVodServiceListImpl::CVcxHgVodServiceListImpl()
       
   166 // Constructor
       
   167 // -----------------------------------------------------------------------------
       
   168 //
       
   169 CVcxHgVodServiceListImpl::CVcxHgVodServiceListImpl( 
       
   170     CHgScroller& aScroller,
       
   171     CVcxNsUiEngine& aDataProviderIf,
       
   172     CVcxHgVodMainView& aView )
       
   173     : CVcxHgVodListImplBase( aView, aDataProviderIf, aScroller )
       
   174     {
       
   175     // None
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // CVcxHgVodServiceListImpl::ConstructL()
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 void CVcxHgVodServiceListImpl::ConstructL( 
       
   183     CVcxNsUiEngine& aDataProviderIf )
       
   184     {
       
   185     iModelHandler = CVcxHgVodServiceListModelHandler::NewL( 
       
   186                     aDataProviderIf, iView, iScroller, *this );
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CVcxHgVodServiceListImpl::HandleCommandL
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 void CVcxHgVodServiceListImpl::HandleCommandL( 
       
   194     TInt aCommand )
       
   195     {
       
   196     if ( !iModelHandler )
       
   197         {
       
   198         return;
       
   199         }
       
   200 
       
   201     TInt selected = iModelHandler->GetSelected();
       
   202     
       
   203     MVcxNsServiceProviderIf* serviceProvider = 
       
   204         iModelHandler->ServiceProvider();
       
   205     
       
   206     User::LeaveIfNull( serviceProvider );
       
   207     
       
   208     switch ( aCommand )
       
   209         {
       
   210         case EAknSoftkeyOpen:
       
   211         case EVcxHgVodServiceOpenCmd:
       
   212             {
       
   213             serviceProvider->OpenServiceL( selected );
       
   214             }
       
   215         break;
       
   216         
       
   217         case EVcxHgVodServiceRemoveCmd:
       
   218             {
       
   219             RemoveFeedL( selected );
       
   220             }
       
   221         break;
       
   222         
       
   223         case EVcxHgVodServiceRefreshAllCmd:
       
   224             {
       
   225             serviceProvider->RefreshAllServicesL();
       
   226             }
       
   227         break;
       
   228         
       
   229         case EVcxHgVodServiceManageAccountCmd:
       
   230             {
       
   231             serviceProvider->ManageAccountL( selected );
       
   232             }
       
   233             break;
       
   234         case EVcxHgVodServiceSubscriptionsCmd:
       
   235         case EVcxHgVodServiceAddManuallyCmd:
       
   236             {
       
   237             iView.OpenSettingsL( aCommand );
       
   238             }
       
   239         break;
       
   240         
       
   241         case EVcxHgVodServiceAddViaCatalogCmd:
       
   242             {
       
   243             serviceProvider->OpenVideoDirectoryL();
       
   244             iView.ChangeListViewL();
       
   245             }
       
   246         break;    
       
   247     
       
   248         case EVcxHgVodServiceDetailsCmd:
       
   249             {
       
   250             iModelHandler->ShowFeedDetailsL( selected );
       
   251             }
       
   252         break;
       
   253             
       
   254         case EVcxHgVodServiceMoveCmd:
       
   255             {
       
   256             StartMoveL();
       
   257             }
       
   258         break;
       
   259 
       
   260         case EVcxHgVodMovingSoftkeyOk:
       
   261             {
       
   262             StopMovingL( ETrue );
       
   263             }
       
   264         break;
       
   265 
       
   266         case EVcxHgVodMovingSoftkeyCancel:
       
   267             {
       
   268             StopMovingL( EFalse );
       
   269             }
       
   270         break;
       
   271         
       
   272         default: 
       
   273             break;
       
   274         }
       
   275     }
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // CVcxHgVodServiceListImpl::Refresh()
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 void CVcxHgVodServiceListImpl::Refresh()
       
   282     {
       
   283     if ( iModelHandler )
       
   284         {
       
   285         iModelHandler->RefreshView();
       
   286         }
       
   287     }
       
   288 
       
   289 // ---------------------------------------------------------
       
   290 // 
       
   291 // ---------------------------------------------------------
       
   292 //
       
   293 TKeyResponse CVcxHgVodServiceListImpl::HandleKeyEventL( 
       
   294         const TKeyEvent& aKeyEvent,
       
   295         TEventCode aType )
       
   296     {
       
   297     if( aType == EEventKeyUp && iModelHandler && IsMoving() )
       
   298         {
       
   299         CheckSoftkeysL();
       
   300         }
       
   301      
       
   302     if ( iModelHandler &&
       
   303 	     !IsMoving() &&
       
   304 	     aType == EEventKeyDown &&
       
   305          aKeyEvent.iScanCode == EStdKeyBackspace && 
       
   306 		 FeedRemovable( iModelHandler->GetSelected() ) )
       
   307         {
       
   308         RemoveFeedL( iModelHandler->GetSelected() );
       
   309         return EKeyWasConsumed;
       
   310         }
       
   311     
       
   312     return CVcxHgVodListImplBase::HandleKeyEventL( aKeyEvent, aType );
       
   313     }
       
   314 
       
   315 // ---------------------------------------------------------
       
   316 // 
       
   317 // ---------------------------------------------------------
       
   318 //
       
   319 void CVcxHgVodServiceListImpl::HandleSelectL( TInt /*aIndex*/ )
       
   320     {
       
   321     if( iModelHandler && IsMoving() )
       
   322         {
       
   323         CheckSoftkeysL();
       
   324         }
       
   325     }
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // CVcxHgVodServiceListImpl::HandleOpenL
       
   329 // -----------------------------------------------------------------------------
       
   330 //
       
   331 void CVcxHgVodServiceListImpl::HandleOpenL( TInt /*aIndex*/ )
       
   332     {
       
   333     if( IsMoving() )
       
   334         {
       
   335         HandleCommandL( EVcxHgVodMovingSoftkeyOk );
       
   336         }
       
   337     else
       
   338         {
       
   339         iView.HandleCommandL( EVcxHgVodServiceOpenCmd );
       
   340         }
       
   341     }
       
   342 
       
   343 // ---------------------------------------------------------
       
   344 // 
       
   345 // ---------------------------------------------------------
       
   346 //
       
   347 void CVcxHgVodServiceListImpl::CheckSoftkeysL()
       
   348     {
       
   349     CEikButtonGroupContainer* cba = iView.ViewCba();
       
   350 
       
   351     if( IsMoving() )
       
   352         {
       
   353         if( !iModelHandler->IsEmptyModel() &&
       
   354             !iModelHandler->LastItemSelected() )
       
   355             {
       
   356             cba->SetCommandSetL( R_VCXHG_VOD_SERVICEVIEW_MOVING_SOFTKEYS );
       
   357             }
       
   358         else
       
   359             {
       
   360             cba->SetCommandSetL( R_VCXHG_VOD_SERVICEVIEW_MOVING_SOFTKEYS_OK_DISABLED );
       
   361             }     
       
   362         }
       
   363     else
       
   364         {
       
   365         cba->SetCommandSetL( R_VCXHG_VOD_SOFTKEYS_OPTIONS_BACK__OPEN );
       
   366         
       
   367         if( !iModelHandler->IsEmptyModel() )
       
   368             {
       
   369             SetMskL( R_VCXHG_VOD_MSK_BUTTON_OPEN );
       
   370             }
       
   371         else
       
   372             {
       
   373             SetMskL( R_VCXHG_VOD_MSK_BUTTON_DO_NOTHING );
       
   374             }
       
   375         }
       
   376     
       
   377     cba->DrawNow();
       
   378     }
       
   379 
       
   380 // -----------------------------------------------------------------------------
       
   381 // CVcxHgVodServiceListImpl::FeedRemovable()
       
   382 // -----------------------------------------------------------------------------
       
   383 //
       
   384 TBool CVcxHgVodServiceListImpl::FeedRemovable( TInt aIndex ) 
       
   385     {
       
   386     if ( iModelHandler && 
       
   387             iModelHandler->ServiceProvider() )
       
   388         {
       
   389         CVcxNsService* service = 
       
   390             iModelHandler->ServiceProvider()->GetServiceData( aIndex );
       
   391 
       
   392         if ( service
       
   393                && ( service->Type() == CVcxNsService::EVcxNsEditable 
       
   394                   || service->Type() == CVcxNsService::EVcxNsMainGroup )
       
   395                && ( service->GetUpdateStatus() == CVcxNsService::ENotUpdating 
       
   396                   || service->GetUpdateStatus() == CVcxNsService::EUpdateFailed ) ) 
       
   397             {
       
   398             return ETrue;
       
   399             }
       
   400         }
       
   401     return EFalse;
       
   402     }
       
   403 
       
   404 // -----------------------------------------------------------------------------
       
   405 // CVcxHgVodServiceListImpl::RemoveService
       
   406 // -----------------------------------------------------------------------------
       
   407 //
       
   408 void CVcxHgVodServiceListImpl::RemoveFeedL( TInt aIndex )
       
   409     {
       
   410     if ( iModelHandler && 
       
   411             iModelHandler->ServiceProvider() )
       
   412         {
       
   413         CVcxNsService* service = 
       
   414             iModelHandler->ServiceProvider()->GetServiceData( aIndex );
       
   415     
       
   416         if ( service )
       
   417             {
       
   418             //Get texts for the message query
       
   419             HBufC* dlgText = StringLoader::LoadLC( R_VCXHG_REMOVE_FEED_QUERY_TXT, 
       
   420                                                    service->GetName() );
       
   421             
       
   422             CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   423             TInt result = dlg->ExecuteLD( R_VCXHG_VOD_REMOVE_FEED_QUERY, 
       
   424                                          *dlgText ); 
       
   425             
       
   426             CleanupStack::PopAndDestroy( dlgText );
       
   427             
       
   428             if ( result == EAknSoftkeyYes || result == EAknSoftkeyOk )
       
   429                 {
       
   430                 iModelHandler->ServiceProvider()->RemoveServiceL( aIndex );
       
   431                 }
       
   432             }
       
   433         }
       
   434     }
       
   435 
       
   436 // -----------------------------------------------------------------------------
       
   437 // CVcxHgVodServiceListImpl::IsMoving
       
   438 // -----------------------------------------------------------------------------
       
   439 TBool CVcxHgVodServiceListImpl::IsMoving() const
       
   440     {
       
   441     return iMoving;
       
   442     }
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CVcxHgVodServiceListImpl::StartMoveL
       
   446 // -----------------------------------------------------------------------------
       
   447 void CVcxHgVodServiceListImpl::StartMoveL()
       
   448     {
       
   449     if ( !iMoving )
       
   450         {
       
   451         iMoving = ETrue;
       
   452 
       
   453         CheckSoftkeysL();
       
   454 
       
   455         iSource = iModelHandler->GetSelected();
       
   456 
       
   457         iModelHandler->MarkItem( iSource );
       
   458         }
       
   459     }
       
   460 
       
   461 // -----------------------------------------------------------------------------
       
   462 // CVcxHgVodServiceListImpl::StopMovingL
       
   463 // -----------------------------------------------------------------------------
       
   464 void CVcxHgVodServiceListImpl::StopMovingL( TBool aSave )
       
   465     {
       
   466     if ( !iMoving )
       
   467         {
       
   468         return;
       
   469         }
       
   470     
       
   471     iMoving = EFalse;
       
   472 
       
   473     CheckSoftkeysL();
       
   474     
       
   475     iModelHandler->UnmarkItem( iSource );
       
   476 
       
   477     iTarget = iModelHandler->GetSelected();
       
   478 
       
   479     if ( aSave &&
       
   480          iTarget != iSource &&
       
   481          iSource >= 0 && 
       
   482          iTarget >= 0 && 
       
   483          iSource < iModelHandler->ItemCount() && 
       
   484          iTarget < iModelHandler->ItemCount() && 
       
   485          ! iModelHandler->LastItemSelected() )
       
   486         {
       
   487         if( KErrNone == iModel.GetServiceProviderL()->MoveServiceL( iSource, iTarget ) )
       
   488             {
       
   489             iModelHandler->MoveItemL( iSource, iTarget );                
       
   490             }
       
   491         }
       
   492     
       
   493     if( !aSave )
       
   494         {
       
   495         iModelHandler->SetSelected( iSource ); 
       
   496         }
       
   497     }
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CVcxHgVodServiceListImpl::GetHelpContext
       
   501 // -----------------------------------------------------------------------------
       
   502 //
       
   503 void CVcxHgVodServiceListImpl::GetHelpContext( TCoeHelpContext& aContext ) const
       
   504     {
       
   505     const TUid KUidIptvMainApp = { 0x102750E2 };
       
   506     
       
   507     aContext.iMajor   = KUidIptvMainApp;
       
   508     aContext.iContext = KIPTV_HLP_VODCAST_MAIN;
       
   509     }
       
   510 
       
   511 // -----------------------------------------------------------------------------
       
   512 // CVcxNsVodServiceListImpl::UpdateTitlePaneL
       
   513 // -----------------------------------------------------------------------------
       
   514 //
       
   515 void CVcxHgVodServiceListImpl::UpdateTitlePaneL()
       
   516     {
       
   517     SetTitlePaneTextFromResourceL( R_VCXHG_VIDEO_FEEDS_TITLE );
       
   518     }
       
   519 
       
   520 // -----------------------------------------------------------------------------
       
   521 // CVcxNsVodServiceListImpl::HasVideoServicesL
       
   522 // -----------------------------------------------------------------------------
       
   523 //
       
   524 TBool CVcxHgVodServiceListImpl::HasVideoServicesL()
       
   525     {
       
   526     TBool found (EFalse);
       
   527     
       
   528     if ( iModelHandler && 
       
   529             iModelHandler->ServiceProvider() )
       
   530         {
       
   531         RPointerArray<CVcxNsService>& services = 
       
   532 		    iModelHandler->ServiceProvider()->GetSubscribedServicesL();
       
   533         
       
   534         for ( TInt i = 0; i < services.Count(); i++ )
       
   535             {
       
   536             if ( services[i]->Type() != CVcxNsService::EVcxNsVideoDirectory )
       
   537                 {
       
   538                 found = ETrue;
       
   539                 break;
       
   540                 }
       
   541             }
       
   542         }
       
   543     
       
   544     return found;
       
   545     }