videofeeds/vcnsuiengine/src/vcxnseventrouter.cpp
changeset 0 96612d01cf9f
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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <mpxmessage2.h>
       
    22 #include <mpxcollectionutility.h>
       
    23 #include <mpxmediacontainerdefs.h>
       
    24 #include <mpxmediageneraldefs.h>
       
    25 #include <mpxmessagegeneraldefs.h>
       
    26 #include <mpxcollectionmessagedefs.h>
       
    27 #include <mpxcollectionpath.h>
       
    28 #include <mpxmessage2.h>
       
    29 #include <mpxcollectionmessage.h>
       
    30 #include <mpxlog.h>
       
    31 #include <mpxitemid.h>
       
    32 #include <mpxmessagecontainerdefs.h>
       
    33 #include <vcxmyvideosdefs.h>
       
    34 #include <mpxcommandgeneraldefs.h>
       
    35 #include <mpxcollectioncommanddefs.h>
       
    36 #include <vcxmyvideosdefs.h>
       
    37 #include <vcxmyvideosuids.h>
       
    38 
       
    39 #include "vcxnseventrouter.h"
       
    40 #include "vcxnsuiengine.h"
       
    41 #include "CIptvSmEvent.h"
       
    42 #include "CIptvUtil.h"
       
    43 #include "vcxnsserviceprovider.h"
       
    44 #include "vcxnscontentprovider.h"
       
    45 #include "vcxnscategoryprovider.h"
       
    46 #include "vcxnsservice.h"
       
    47 #include "vcxnscontent.h"
       
    48 #include "vcxnscategory.h"
       
    49 #include "vcxnsmpxcollectionclienthandler.h"
       
    50 #include "vcxnscontentsearchhandler.h"
       
    51 #include "vcxnsupdateprogresshandler.h"
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CVcxNsEventRouter::CVcxNsEventRouter()
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CVcxNsEventRouter::CVcxNsEventRouter( CVcxNsUiEngine& aUiEngine )
       
    58     :iUiEngine( aUiEngine )
       
    59     {
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CVcxNsEventRouter::~CVcxNsEventRouter()
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CVcxNsEventRouter::~CVcxNsEventRouter( )
       
    67     {
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CVcxNsEventRouter::NewL()
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 CVcxNsEventRouter* CVcxNsEventRouter::NewL( CVcxNsUiEngine& aUiEngine )
       
    75     {
       
    76     CVcxNsEventRouter* self = new ( ELeave ) CVcxNsEventRouter( aUiEngine );
       
    77     return self;
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CVcxNsEventRouter::HandleSmEvent()
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CVcxNsEventRouter::HandleSmEvent( CIptvSmEvent& aEvent )
       
    85     {
       
    86     // check when to reset the data
       
    87     if( iUiEngine.ServiceProvider() )
       
    88          {
       
    89          iUiEngine.ServiceProvider()->RemoveServiceData();
       
    90          }
       
    91 
       
    92     RemoveServiceData( aEvent.iServiceId );
       
    93     
       
    94     if( iUiEngine.VcAppState() == EStateServiceView || 
       
    95         aEvent.iServiceId == iUiEngine.ActiveService() )
       
    96         {
       
    97         // Services can be added or deleted, so let's redraw all.
       
    98         UpdateActiveView();
       
    99         
       
   100         if ( aEvent.iEvent == CIptvSmEvent::EServiceAdded )
       
   101             {
       
   102             // Assume that the added is always first
       
   103             iUiEngine.ServiceProvider()->ServiceAdded( 0 );
       
   104             }
       
   105         }
       
   106     }
       
   107 
       
   108 // -----------------------------------------------------------------------------
       
   109 // CVcxNsEventRouter::HandleEpgManagerMsgL()
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CVcxNsEventRouter::HandleEpgManagerMsgL( 
       
   113     TInt aMsg, TInt aInfo, TIptvServiceId aServiceId )
       
   114     {
       
   115     CVcxNsUpdateProgressHandler* progressHandler = iUiEngine.GetProgressHandler();
       
   116     if ( progressHandler )
       
   117         {
       
   118         progressHandler->HandleUpdateStatusChangeL( aServiceId, aMsg, aInfo );
       
   119         }
       
   120 
       
   121     CVcxNsServiceProvider* serviceProvider = iUiEngine.ServiceProvider();
       
   122     User::LeaveIfNull( serviceProvider );
       
   123     
       
   124     switch( aMsg )
       
   125         {
       
   126         case KIptvVodUpdateNotStarted:
       
   127             {
       
   128             serviceProvider->RefreshNextPendingService();
       
   129 
       
   130             IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvVodUpdateNotStarted");
       
   131             }
       
   132             break;
       
   133         case KIptvVodUpdateStarted: //Update process started
       
   134             {
       
   135             IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvVodUpdateStarted");
       
   136             iUpdatedService = aServiceId;
       
   137             serviceProvider->UpdateServiceUpdateStatusL( aServiceId, CVcxNsService::EUpdateOngoing );
       
   138             if ( iUiEngine.VcAppState() == EStateContentView  && 
       
   139                  iUiEngine.GetContentProviderL()->GetContentsL().Count() == 0 )
       
   140                 {
       
   141                 UpdateActiveView();
       
   142                 }
       
   143 
       
   144             iThumbnailCount = 0;
       
   145             iThumbnailsDownloaded = 0;
       
   146             UpdateInfoPopupL();
       
   147             }
       
   148             break;
       
   149 
       
   150         case KIptvContentUpdateCompleted:
       
   151             {
       
   152             IPTVLOGSTRING_LOW_LEVEL(
       
   153                 "CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvContentUpdateCompleted");
       
   154 
       
   155             // Refresh the view before thumbnails are downloaded, if there was
       
   156             // no old data. Empty category view shouldn't be ever shown.
       
   157             
       
   158             RPointerArray< CVcxNsCategory > categories =
       
   159                 iUiEngine.GetCategoryProviderL()->GetCategorysL();
       
   160 
       
   161             if( ( iUiEngine.VcAppState() == EStateContentView  &&
       
   162                     categories.Count() == 0 )
       
   163                 || ( iUiEngine.VcAppState() == EStateCategoryView &&
       
   164                         categories.Count() == 0 )
       
   165                 || ( iUiEngine.VcAppState() == EStateCategoryView &&
       
   166                         categories.Count() == 1 &&
       
   167                         categories[0]->GetCategoryId() == KIptvRssSearchCategoryId )
       
   168                 || ( iUiEngine.VcAppState() == EStateCustomView &&
       
   169                      iUiEngine.ActiveService() == aServiceId ) )
       
   170                 {
       
   171                 if ( !( iUiEngine.VcAppState() == EStateCustomView ) )
       
   172                     {
       
   173                     CheckAppStateL( aServiceId );
       
   174                     }
       
   175                 UpdateActiveView();
       
   176                 }
       
   177           
       
   178             iThumbnailCount = 0;
       
   179             iThumbnailsDownloaded = 0;
       
   180             UpdateInfoPopupL();
       
   181             }
       
   182             break;
       
   183 
       
   184         case KIptvThumbnailCount:
       
   185             {
       
   186             IPTVLOGSTRING_LOW_LEVEL(
       
   187                 "CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvThumbnailCount");
       
   188 
       
   189             // Store the tbn count even if we're in wrong service.
       
   190             iThumbnailCount = aInfo;
       
   191             UpdateInfoPopupL();
       
   192             }
       
   193             break;
       
   194 
       
   195         case KIptvServiceThumbnailDownloaded:
       
   196             {
       
   197             IPTVLOGSTRING_LOW_LEVEL(
       
   198                 "CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvServiceThumbnailDownloaded");
       
   199             serviceProvider->ReloadThumbnailPathL( aServiceId );
       
   200             if( iUiEngine.VcAppState() == EStateServiceView )
       
   201                 {
       
   202                 serviceProvider->UpdateService( aServiceId );
       
   203                 }
       
   204           
       
   205             iThumbnailsDownloaded++;
       
   206             UpdateInfoPopupL();
       
   207             }
       
   208             break;
       
   209 
       
   210         case KIptvContentThumbnailDownloaded:
       
   211             {
       
   212             IPTVLOGSTRING_LOW_LEVEL(
       
   213                 "CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvContentThumbnailDownloaded");
       
   214             //When downloading group thumbnails, 
       
   215             //aInfo includes service id information for grouped service
       
   216             CVcxNsService* serviceData = serviceProvider->GetServiceDataById( aServiceId );
       
   217             if ( serviceData && serviceData->Type() == CVcxNsService::EVcxNsMainGroup )
       
   218                 {
       
   219                 serviceProvider->ReloadThumbnailPathL( aInfo );
       
   220                 }
       
   221 
       
   222             // Store the tbn count even if we're in wrong service.
       
   223             iThumbnailsDownloaded++;
       
   224             UpdateInfoPopupL();
       
   225             }
       
   226             break;
       
   227 
       
   228         case KIptvErrorEpgUpdateStopped:
       
   229             {
       
   230             //This event comes when plugin has stopped all activities for update
       
   231             //We can start updating next service as server is not busy with last update anymore.
       
   232             IPTVLOGSTRING_LOW_LEVEL(
       
   233                 "CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvErrorEpgUpdateStopped");
       
   234             serviceProvider->RefreshNextPendingService();
       
   235             }
       
   236             break;
       
   237         case KIptvErrorEpgUpdateSuccessed:
       
   238             {
       
   239             IPTVLOGSTRING_LOW_LEVEL(
       
   240                 "CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvErrorEpgUpdateSuccessed");
       
   241             HandleEpgUpdateSucceededL( aServiceId );
       
   242             }
       
   243             break;
       
   244 
       
   245         case KIptvErrorEpgUpdateFailed:
       
   246             {
       
   247             IPTVLOGSTRING_LOW_LEVEL(
       
   248                 "CVcxNsEventRouter::HandleEpgManagerMsgL: KIptvErrorEpgUpdateFailed");
       
   249             HandleEpgUpdateFailedL( aInfo, aServiceId );
       
   250             }
       
   251             break;
       
   252         case KIptvErrorRssSearchNoIap: //fall trough
       
   253         case KIptvErrorRssSearchStarted: //fall through
       
   254         case KIptvErrorRssSearchFailed:  //fall through
       
   255         case KIptvErrorRssSearchSucceed: //fall through
       
   256         case KIptvRssSearchContentUpdateCompleted: //fall through
       
   257         case KIptvRssSearchThumbnailCount: //fall through
       
   258         case KIptvRssSearchContentThumbnailDownloaded:
       
   259             iUiEngine.GetContentSearchHandlerL()->HandleSearchMsgL( aMsg, aInfo );
       
   260             break;
       
   261         default:
       
   262             break;
       
   263         }
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------------------------
       
   267 // CVcxNsEventRouter::HandleCollectionMessageL()
       
   268 // -----------------------------------------------------------------------------
       
   269 //
       
   270 void CVcxNsEventRouter::HandleCollectionMessageL( CMPXMessage* aMsg, TInt /*aErr*/ )
       
   271     {
       
   272     IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::HandleCollectionMessageL IN");
       
   273     // what the err represents?
       
   274     
       
   275     if( !iUiEngine.ContentProvider() )
       
   276         {
       
   277         return;
       
   278         }
       
   279     
       
   280     TUid colId = aMsg->ValueTObjectL<TUid>(KMPXMessageCollectionId);
       
   281     TMPXChangeEventType type = aMsg->ValueTObjectL<TMPXChangeEventType>(KMPXMessageChangeEventType);
       
   282 
       
   283     if( colId.iUid == KVcxUidMyVideosMpxCollection )
       
   284         {
       
   285         TMPXItemId itemId = aMsg->ValueTObjectL<TMPXItemId>( KMPXMessageMediaGeneralId );
       
   286 
       
   287         if ( type == EMPXItemModified )
       
   288             {
       
   289             IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::HandleCollectionMessageL EMPXItemModified");
       
   290             CVcxNsContent* content = iUiEngine.GetMpxCollectionClientHandlerL()->SearchFromDownloadList( itemId );            
       
   291             if( content )
       
   292                 {
       
   293                 iUiEngine.ContentProvider()->UpdateContent( content );
       
   294                 }
       
   295             }
       
   296         }
       
   297 
       
   298     IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::HandleCollectionMessageL OUT");
       
   299     }
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 // CVcxNsEventRouter::UpdateActiveView
       
   303 // -----------------------------------------------------------------------------
       
   304 //
       
   305 void CVcxNsEventRouter::UpdateActiveView()
       
   306     {
       
   307     IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::UpdateActiveView");
       
   308     
       
   309     if( iUiEngine.VcAppState()== EStateServiceView 
       
   310             || iUiEngine.VcAppState()== EStateCustomView )
       
   311         {
       
   312         if ( iUiEngine.ServiceProvider() )
       
   313             {
       
   314             iUiEngine.ServiceProvider()->RefreshView();
       
   315             }
       
   316         }
       
   317     else if( iUiEngine.VcAppState()== EStateContentView )
       
   318         {
       
   319         if( iUiEngine.ContentProvider() )
       
   320             {
       
   321             iUiEngine.ContentProvider()->RefreshView();
       
   322             }
       
   323         }
       
   324     else if( iUiEngine.VcAppState()== EStateCategoryView )
       
   325         {
       
   326         if( iUiEngine.CategoryProvider() )
       
   327             {
       
   328             iUiEngine.CategoryProvider()->RefreshView();
       
   329             }
       
   330         }
       
   331     }
       
   332 
       
   333 // -----------------------------------------------------------------------------
       
   334 // CVcxNsEventRouter::RemoveServiceData()
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 void CVcxNsEventRouter::RemoveServiceData( TUint32 aServiceId )
       
   338     {
       
   339     IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::RemoveServiceData");
       
   340     
       
   341     CVcxNsMpxCollectionClientHandler* collectionClient( NULL );
       
   342     
       
   343     TRAP_IGNORE( collectionClient = iUiEngine.GetMpxCollectionClientHandlerL() );
       
   344     
       
   345     if ( collectionClient && iUiEngine.ActiveService() == aServiceId )
       
   346         {
       
   347         collectionClient->ResetDownloadList( ETrue );
       
   348         }
       
   349     if ( iUiEngine.ContentProvider() )
       
   350         {
       
   351         iUiEngine.ContentProvider()->RemoveServiceData( aServiceId );
       
   352         }            
       
   353     if ( iUiEngine.CategoryProvider() )
       
   354         {
       
   355         iUiEngine.CategoryProvider()->RemoveServiceData( aServiceId );
       
   356         } 
       
   357     }
       
   358 
       
   359 // -----------------------------------------------------------------------------
       
   360 // CVcxNsEventRouter::UpdateInfoPopupL()
       
   361 // -----------------------------------------------------------------------------
       
   362 //
       
   363 void CVcxNsEventRouter::UpdateInfoPopupL()
       
   364     {
       
   365     IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::UpdateInfoPopupL");
       
   366     CVcxNsServiceProvider* serviceProvider = iUiEngine.ServiceProvider();
       
   367     if ( !serviceProvider )
       
   368         {
       
   369         return;
       
   370         }
       
   371 
       
   372     CVcxNsService* service = serviceProvider->GetServiceDataById( iUpdatedService ); 
       
   373 
       
   374     CVcxNsService::TServiceUpdateStatus status ( CVcxNsService::ENotUpdating );
       
   375     
       
   376     if ( service )
       
   377         {
       
   378         status = service->GetUpdateStatus();
       
   379         }
       
   380 
       
   381     TBool updating = ( status == CVcxNsService::EUpdateOngoing ? ETrue : EFalse );
       
   382 
       
   383     if( iUiEngine.ActiveService() == iUpdatedService )
       
   384         {
       
   385         switch( iUiEngine.VcAppState() )
       
   386             {
       
   387             case EStateContentView:
       
   388                 {
       
   389                 if( iUiEngine.ContentProvider() )
       
   390                     {
       
   391                     iUiEngine.ContentProvider()->ShowUpdatingNoteL( 
       
   392                         updating ,iThumbnailCount, iThumbnailsDownloaded );
       
   393                     }
       
   394                 break;
       
   395                 }
       
   396             case EStateCategoryView:
       
   397                 {
       
   398                 if( iUiEngine.CategoryProvider() )
       
   399                     {
       
   400                     iUiEngine.CategoryProvider()->ShowUpdatingNoteL( 
       
   401                         updating, iThumbnailCount, iThumbnailsDownloaded );
       
   402                     }
       
   403                 break;
       
   404                 }
       
   405             default:
       
   406                 {
       
   407                 break;
       
   408                 }
       
   409             }
       
   410         }
       
   411     }
       
   412 
       
   413 // -----------------------------------------------------------------------------
       
   414 // CVcxNsEventRouter::HandleEpgUpdateFailedL()
       
   415 // -----------------------------------------------------------------------------
       
   416 //
       
   417 void CVcxNsEventRouter::HandleEpgUpdateFailedL( 
       
   418     TInt aError,
       
   419     TIptvServiceId aServiceId )
       
   420     {
       
   421     IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::HandleEpgUpdateFailedL");
       
   422     TVcxNsAppState appState = iUiEngine.VcAppState();
       
   423     CVcxNsServiceProvider* serviceProvider = iUiEngine.ServiceProvider();
       
   424     
       
   425     if ( serviceProvider )
       
   426         {
       
   427         // Check if Updating manually failed, epg update still pending (EUpdatePending)
       
   428         serviceProvider->UpdateServiceUpdateStatusL( 
       
   429                 aServiceId, CVcxNsService::EUpdateFailed );
       
   430 
       
   431         if( appState == EStateServiceView )
       
   432             {
       
   433             serviceProvider->UpdateService( aServiceId );
       
   434             }
       
   435         } 
       
   436 
       
   437     if ( appState == EStateCategoryView && iUiEngine.CategoryProvider() )
       
   438         {
       
   439         iUiEngine.CategoryProvider()->HandleErrorL( aError, aServiceId );
       
   440         }
       
   441 
       
   442     if ( appState == EStateContentView && iUiEngine.ContentProvider() )
       
   443         {
       
   444         iUiEngine.ContentProvider()->HandleErrorL( aError, ETrue, aServiceId );
       
   445         }
       
   446     
       
   447     if ( appState == EStateCustomView && serviceProvider )
       
   448         {
       
   449         serviceProvider->RefreshView();
       
   450         }
       
   451 
       
   452     iThumbnailCount = 0;
       
   453     iThumbnailsDownloaded = 0;
       
   454     UpdateInfoPopupL();
       
   455     }
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // CVcxNsEventRouter::HandleEpgUpdateSucceededL()
       
   459 // -----------------------------------------------------------------------------
       
   460 //
       
   461 void CVcxNsEventRouter::HandleEpgUpdateSucceededL( TIptvServiceId aServiceId )
       
   462     {
       
   463     IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::HandleEpgUpdateSucceededL");
       
   464     
       
   465     CheckAppStateL( aServiceId );
       
   466 
       
   467     iUiEngine.ServiceProvider()->UpdateServiceUpdateStatusL( 
       
   468             aServiceId, CVcxNsService::ENotUpdating );
       
   469 
       
   470     iUiEngine.ServiceProvider()->UpdateServiceInCacheL( aServiceId );        
       
   471     
       
   472     if( iUiEngine.VcAppState() == EStateServiceView )
       
   473         {
       
   474         // Update just the one item
       
   475         iUiEngine.ServiceProvider()->UpdateService( aServiceId );
       
   476         }
       
   477     else if( ( iUiEngine.VcAppState() == EStateContentView ||                            
       
   478           iUiEngine.VcAppState() == EStateCategoryView  ||
       
   479           iUiEngine.VcAppState() == EStateCustomView ) &&
       
   480           iUiEngine.ActiveService() == aServiceId )
       
   481         {
       
   482         // Update whole list
       
   483         UpdateActiveView();
       
   484         }
       
   485 
       
   486     iThumbnailCount = 0;
       
   487     iThumbnailsDownloaded = 0;
       
   488     UpdateInfoPopupL();
       
   489     }
       
   490                              
       
   491 // -----------------------------------------------------------------------------
       
   492 // Check, is the view switch needed
       
   493 // Note that this removes old service data.
       
   494 // -----------------------------------------------------------------------------
       
   495 //
       
   496 void CVcxNsEventRouter::CheckAppStateL( TIptvServiceId aServiceId )
       
   497     {
       
   498     TUint32 activeServiceId = iUiEngine.ActiveService();
       
   499     
       
   500     if( aServiceId == activeServiceId &&
       
   501           iUiEngine.CategoryProvider() &&
       
   502         ( iUiEngine.VcAppState() == EStateContentView ||                            
       
   503           iUiEngine.VcAppState() == EStateCategoryView ) )
       
   504         {
       
   505         RPointerArray<CVcxNsCategory> oldCategories = 
       
   506             iUiEngine.CategoryProvider()->GetCategorysL();
       
   507         TInt oldCategoryCount = oldCategories.Count();
       
   508         TBool wasSingle = oldCategoryCount == 0 || 
       
   509                           ( oldCategoryCount == 1 && 
       
   510                             oldCategories[0]->GetCategoryId() != 
       
   511                             KIptvRssSearchCategoryId ) ? ETrue : EFalse ;
       
   512 
       
   513         RemoveServiceData( aServiceId );
       
   514 
       
   515         RPointerArray<CVcxNsCategory> newCategories = 
       
   516             iUiEngine.CategoryProvider()->GetCategorysL();
       
   517         TInt newCategoryCount = newCategories.Count();
       
   518         TBool isSingle = newCategoryCount == 0 || 
       
   519                           ( newCategoryCount == 1 && 
       
   520                             newCategories[0]->GetCategoryId() != 
       
   521                             KIptvRssSearchCategoryId ) ? ETrue : EFalse ;
       
   522         
       
   523         
       
   524         TVcxNsAppState oldState = iUiEngine.VcAppState();
       
   525         // check that the old category really exists
       
   526         TBool activeCategoryExists = 
       
   527                 iUiEngine.CategoryProvider()->GetActiveCategoryDataL()
       
   528                     ? ETrue : EFalse;
       
   529 
       
   530         // Used only if switching to single category view.
       
   531         TUint32 newActiveCategory( newCategoryCount == 1 ?
       
   532                                     ( newCategories[0] )->GetCategoryId():
       
   533                                     KIptvVodContentCategoryRootId );
       
   534 
       
   535         // Categories are increased from single to multiple
       
   536         if ( wasSingle && !isSingle &&
       
   537             oldState == EStateContentView )
       
   538             {
       
   539             iUiEngine.PopAppStateStack(); // Back to service level
       
   540             iUiEngine.SetVcAppState( EStateCategoryView );
       
   541             iUiEngine.ContentProvider()->HandleAppStateChangedL();
       
   542             }
       
   543         // Categories kept single, check still if category has changed.
       
   544         else if ( wasSingle && isSingle &&
       
   545             oldState == EStateContentView )
       
   546             {
       
   547             iUiEngine.SetActiveCategory( newActiveCategory );
       
   548             }
       
   549         // Category count has dropped from multiple to single, in category view.
       
   550         else if ( !wasSingle && isSingle &&
       
   551                   oldState == EStateCategoryView )
       
   552             {
       
   553             iUiEngine.PopAppStateStack(); // Back to service level            
       
   554             iUiEngine.SetVcAppState( EStateContentView );
       
   555             iUiEngine.SetActiveCategory( newActiveCategory );
       
   556             iUiEngine.CategoryProvider()->HandleAppStateChangedL();
       
   557             }
       
   558         // Category count has dropped from multiple to single, in content view.
       
   559         else if ( !wasSingle && isSingle &&
       
   560                    oldState == EStateContentView )
       
   561             {
       
   562             iUiEngine.PopAppStateStack(); // Back to category level
       
   563             iUiEngine.PopAppStateStack(); // Back to service level
       
   564             iUiEngine.SetActiveCategory( newActiveCategory );
       
   565             iUiEngine.SetVcAppState( EStateContentView );
       
   566             iUiEngine.ContentProvider()->HandleAppStateChangedL();
       
   567             }
       
   568         // Category count has not changed from multiple to single.
       
   569         else if( !wasSingle && !isSingle &&
       
   570                   oldState == EStateContentView && 
       
   571                   !activeCategoryExists )
       
   572             {
       
   573             iUiEngine.HandleBack(); // Back to category level
       
   574             iUiEngine.ContentProvider()->HandleAppStateChangedL();
       
   575             }
       
   576         }
       
   577     else
       
   578         {
       
   579         RemoveServiceData( aServiceId );
       
   580         }
       
   581     }
       
   582 
       
   583 // -----------------------------------------------------------------------------
       
   584 // CVcxNsEventRouter::HandleDlErrorL()
       
   585 // -----------------------------------------------------------------------------
       
   586 //
       
   587 void CVcxNsEventRouter::HandleDlErrorL( 
       
   588     TIptvDlError aError,
       
   589     CVcxNsContent& aContent )
       
   590     {
       
   591     IPTVLOGSTRING_LOW_LEVEL("CVcxNsEventRouter::HandleDlErrorL");
       
   592     
       
   593     TVcxNsAppState appState = iUiEngine.VcAppState();
       
   594     
       
   595     if ( appState == EStateContentView && iUiEngine.ContentProvider() )
       
   596         {
       
   597         iUiEngine.ContentProvider()->HandleDlErrorL( aError, aContent );
       
   598         }
       
   599     }