videofeeds/vcnsuiengine/src/vcxnsuiengine.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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "IptvDebug.h"
       
    21 #include <e32svr.h>
       
    22 #include <coemain.h>
       
    23 #include <eikappui.h>
       
    24 #include <ipvideo/vcxconnectionutility.h>
       
    25 #include <videoplayercustommessage.h>
       
    26 #include <MediatorEventProvider.h>
       
    27 
       
    28 #include "vcxnsuiengine.h"
       
    29 #include "iptvlastwatchedapi.h"
       
    30 #include "vcxnsmediatorids.h"
       
    31 #include "vcxnsservice.h"
       
    32 #include "vcxnsserviceprovider.h"
       
    33 #include "vcxnsserviceproviderif.h"
       
    34 #include "vcxnscontent.h"
       
    35 #include "vcxnscontentaccess.h"
       
    36 #include "vcxnscontentprovider.h"
       
    37 #include "vcxnscontentproviderif.h"
       
    38 #include "vcxnscategory.h"
       
    39 #include "vcxnscategoryprovider.h"
       
    40 #include "vcxnscategoryproviderif.h"
       
    41 #include "vcxnsserviceclienthandler.h"
       
    42 #include "vcxnscontentclienthandler.h"
       
    43 #include "vcxnsmpxcollectionclienthandler.h"
       
    44 #include "vcxnseventrouter.h"
       
    45 #include "vcxnscontentsearchif.h"
       
    46 #include "vcxnscontentsearchhandler.h"
       
    47 #include "vcxnsupdateprogressif.h"
       
    48 #include "vcxnsupdateprogresshandler.h"
       
    49 #include "vcxnsstreaminghandler.h"
       
    50 
       
    51 const TInt KVcxNsUiEngineInstance = 0x2000B43D;
       
    52 
       
    53 // Version : %version: tr1ido#REL6_54 %
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CVcxNsUiEngine::CVcxNsUiEngine()
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CVcxNsUiEngine::CVcxNsUiEngine() :
       
    60     iApplicationState( EStateNoState ),
       
    61     iActiveServiceGroup( KMaxTUint )
       
    62     {
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CVcxNsUiEngine::~CVcxNsUiEngine()
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CVcxNsUiEngine::~CVcxNsUiEngine()
       
    70     {
       
    71     iAppStateStack.Close();
       
    72     
       
    73     delete iStreamingHandler;
       
    74     delete iServiceProvider;
       
    75     delete iContentProvider;
       
    76     delete iCategoryProvider;
       
    77 
       
    78     delete iServiceClientHandler;
       
    79     delete iContentClientHandler;
       
    80     delete iMpxCollectionClientHandler;
       
    81     delete iContentSearchHandler;
       
    82 
       
    83     if ( iConnUtil )
       
    84         {
       
    85         iConnUtil->DecreaseReferenceCount();
       
    86         }
       
    87     
       
    88     delete iEventRouter;
       
    89     delete iProgressHandler;
       
    90     delete iLastWatchedApi;
       
    91     delete iMediatorEventProvider;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CVcxNsUiEngine::ConstructL()
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 void CVcxNsUiEngine::ConstructL()
       
    99     {
       
   100     iEventRouter = CVcxNsEventRouter::NewL( *this );
       
   101     iLastWatchedApi = CIptvLastWatchedApi::NewL();
       
   102     iMediatorEventProvider = CMediatorEventProvider::NewL();
       
   103     
       
   104     IPTVLOGSTRING_HIGH_LEVEL("UI Engine ## CVcxNsUiEngine::ConstructL()");
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CVcxNsUiEngine::InstanceL()
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C CVcxNsUiEngine* CVcxNsUiEngine::InstanceL()
       
   112     {
       
   113     CVcxNsUiEngine* self = NULL;
       
   114     TAny* instance = UserSvr::DllTls( KVcxNsUiEngineInstance );
       
   115 
       
   116     if ( !instance )
       
   117         {
       
   118         IPTVLOGSTRING_LOW_LEVEL( "CVcxNsUiEngine::InstanceL(): Creating new instance of singleton." );
       
   119         self = new( ELeave ) CVcxNsUiEngine;
       
   120         CleanupStack::PushL( self );
       
   121         self->ConstructL();
       
   122         User::LeaveIfError( UserSvr::DllSetTls( KVcxNsUiEngineInstance, self ) );
       
   123         CleanupStack::Pop( self );
       
   124         IPTVLOGSTRING2_LOW_LEVEL( "CVcxNsUiEngine::InstanceL(): Instance created (0x%x).", (TUint32)self );
       
   125         }
       
   126     else
       
   127         {
       
   128         self = reinterpret_cast<CVcxNsUiEngine*>(instance );
       
   129         IPTVLOGSTRING2_LOW_LEVEL( "CVcxNsUiEngine::InstanceL(): returning old instance (0x%x).", (TUint32)self );
       
   130         }
       
   131 
       
   132     self->IncreaseReferenceCount();
       
   133 
       
   134     return self;
       
   135     }
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // CVcxNsUiEngine::IncreaseReferenceCount()
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CVcxNsUiEngine::IncreaseReferenceCount()
       
   142     {
       
   143     iReferenceCount++;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CVcxNsUiEngine::DecreaseReferenceCount()
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 EXPORT_C void CVcxNsUiEngine::DecreaseReferenceCount()
       
   151     {
       
   152     iReferenceCount--;
       
   153 
       
   154     if ( iReferenceCount == 0 )
       
   155         {
       
   156         DeleteInstance( this );
       
   157         }
       
   158     }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CVcxNsUiEngine::DeleteInstance()
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CVcxNsUiEngine::DeleteInstance( CVcxNsUiEngine* aThis )
       
   165     {
       
   166     TAny* singleton = UserSvr::DllTls( KVcxNsUiEngineInstance );
       
   167 
       
   168     if ( singleton != aThis )
       
   169         {
       
   170         IPTVLOGSTRING3_LOW_LEVEL( "CVcxNsUiEngine::DeleteInstance(): ERROR: POINTER STORED IN THREAD LOCAL STORAGE DOES NOT MATCH WITH THE ONE FOR DELETION! (TLS = 0x%x != instance = 0x%x)", singleton, aThis );
       
   171         _LIT( KPanic, "NSUIENGINE" );
       
   172         User::Panic( KPanic, 0);
       
   173         }
       
   174 
       
   175     UserSvr::DllFreeTls( KVcxNsUiEngineInstance );
       
   176 
       
   177     delete aThis;
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // CVcxNsUiEngine::GetServiceProviderL()
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 EXPORT_C MVcxNsServiceProviderIf* CVcxNsUiEngine::GetServiceProviderL()
       
   185     {
       
   186     IPTVLOGSTRING_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetServiceProviderL() -- Enter");
       
   187 
       
   188     if ( !iServiceProvider )
       
   189         {
       
   190         iServiceProvider = CVcxNsServiceProvider::NewL( *this );
       
   191         }
       
   192 
       
   193     IPTVLOGSTRING2_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetServiceProviderL() -- Returning: %d", (TInt) iServiceProvider);
       
   194 
       
   195     return iServiceProvider;
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CVcxNsUiEngine::GetContentProviderL()
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 EXPORT_C MVcxNsContentProviderIf* CVcxNsUiEngine::GetContentProviderL()
       
   203     {
       
   204     IPTVLOGSTRING_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetContentProviderL() -- Enter");
       
   205 
       
   206     if ( !iContentProvider )
       
   207         {
       
   208         iContentProvider = CVcxNsContentProvider::NewL( *this );
       
   209         }
       
   210 
       
   211     IPTVLOGSTRING2_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetContentProviderL() -- Returning: %d", (TInt) iContentProvider);
       
   212 
       
   213     return iContentProvider;
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // CVcxNsUiEngine::GetCategoryProviderL()
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 EXPORT_C MVcxNsCategoryProviderIf* CVcxNsUiEngine::GetCategoryProviderL()
       
   221     {
       
   222     IPTVLOGSTRING_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetCategoryProviderL() -- Enter");
       
   223 
       
   224     if ( !iCategoryProvider )
       
   225         {
       
   226         iCategoryProvider = CVcxNsCategoryProvider::NewL( *this );
       
   227         }
       
   228 
       
   229     IPTVLOGSTRING2_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetCategoryProviderL() -- Returning: %d", (TInt) iCategoryProvider);
       
   230 
       
   231     return iCategoryProvider;
       
   232     }
       
   233 // -----------------------------------------------------------------------------
       
   234 // CVcxNsUiEngine::ContentSearchHandlerL()
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 EXPORT_C MVcxNsContentSearchIf* CVcxNsUiEngine::ContentSearchHandlerL()
       
   238     {
       
   239     IPTVLOGSTRING_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::ContentSearchIfL() -- Enter");
       
   240 
       
   241     if ( !iContentSearchHandler )
       
   242         {
       
   243         iContentSearchHandler = CVcxNsContentSearchHandler::NewL( *this );
       
   244         }
       
   245 
       
   246     IPTVLOGSTRING2_LOW_LEVEL(
       
   247             "UI Engine ## CVcxNsUiEngine::ContentSearchIfL() -- Returning: %d", (TInt) iContentSearchHandler );
       
   248 
       
   249     return iContentSearchHandler;
       
   250     }
       
   251 
       
   252 // -----------------------------------------------------------------------------
       
   253 // 
       
   254 // -----------------------------------------------------------------------------
       
   255 //
       
   256 EXPORT_C MVcxNsUpdateProgressIf* CVcxNsUiEngine::ProgressHandlerL()
       
   257     {
       
   258     IPTVLOGSTRING_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::ProgressHandlerL() -- Enter");
       
   259 
       
   260     if ( !iProgressHandler )
       
   261         {
       
   262         iProgressHandler = CVcxNsUpdateProgressHandler::NewL( *this );
       
   263         }
       
   264 
       
   265     IPTVLOGSTRING2_LOW_LEVEL(
       
   266             "UI Engine ## CVcxNsUiEngine::ProgressHandlerL(): Returning: %d", 
       
   267             (TInt) iProgressHandler );
       
   268 
       
   269     return iProgressHandler;
       
   270     }
       
   271 
       
   272 // -----------------------------------------------------------------------------
       
   273 // CVcxNsUiEngine::VcAppState()
       
   274 // -----------------------------------------------------------------------------
       
   275 //
       
   276 EXPORT_C TVcxNsAppState CVcxNsUiEngine::VcAppState()
       
   277     {
       
   278 #ifdef _DEBUG
       
   279     switch ( iApplicationState )
       
   280         {
       
   281         case EStateServiceView:
       
   282             IPTVLOGSTRING_LOW_LEVEL(
       
   283                     "CVcxNsUiEngine::VcAppState state = EStateServiceView");
       
   284             break;
       
   285         case EStateCategoryView:
       
   286             IPTVLOGSTRING_LOW_LEVEL(
       
   287                     "CVcxNsUiEngine::VcAppState state = EStateCategoryView" );
       
   288             break;
       
   289         case EStateContentView:
       
   290             IPTVLOGSTRING_LOW_LEVEL(
       
   291                     "CVcxNsUiEngine::VcAppState state = EStateContentView" );
       
   292             break;
       
   293         case EStateBrowser:
       
   294             IPTVLOGSTRING_LOW_LEVEL(
       
   295                     "CVcxNsUiEngine::VcAppState state = EStateBrowser" );
       
   296             break;
       
   297         default:
       
   298             IPTVLOGSTRING2_LOW_LEVEL( "CVcxNsUiEngine::VcAppState state = %d", iApplicationState );
       
   299             break;
       
   300         }
       
   301 #endif
       
   302     return iApplicationState;
       
   303     }
       
   304 
       
   305 // -----------------------------------------------------------------------------
       
   306 // CVcxNsUiEngine::SetVcAppState()
       
   307 // -----------------------------------------------------------------------------
       
   308 //
       
   309 EXPORT_C void CVcxNsUiEngine::SetVcAppState( TVcxNsAppState aAppState )
       
   310     {
       
   311     IPTVLOGSTRING2_LOW_LEVEL("CVcxNsUiEngine::SetVcAppState state = %d", aAppState);
       
   312     
       
   313     if ( iApplicationState != aAppState )
       
   314         {
       
   315         iAppStateStack.Append( aAppState );
       
   316         iApplicationState = aAppState;
       
   317         }
       
   318     }
       
   319 
       
   320 // -----------------------------------------------------------------------------
       
   321 // CVcxNsUiEngine::HandleBack()
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 EXPORT_C TBool CVcxNsUiEngine::HandleBack()
       
   325     {
       
   326     IPTVLOGSTRING_LOW_LEVEL("CVcxNsUiEngine::HandleBack");
       
   327 
       
   328     TVcxNsAppState lastState ( EStateNoState );
       
   329     TInt count = iAppStateStack.Count();
       
   330     
       
   331     if ( count > 0 )
       
   332         {
       
   333         lastState = iAppStateStack[count-1];
       
   334         }
       
   335     
       
   336     IPTVLOGSTRING2_LOW_LEVEL("CVcxNsUiEngine::HandleBack: current state = %d", lastState );
       
   337     
       
   338     PopAppStateStack();
       
   339     
       
   340     count = iAppStateStack.Count();
       
   341 
       
   342     if ( count > 0 )
       
   343         {
       
   344         TVcxNsAppState newState = iAppStateStack[ count-1 ];
       
   345         iApplicationState = newState;
       
   346         
       
   347         if ( iApplicationState == EStateCustomView 
       
   348              && ( lastState == EStateCategoryView || lastState == EStateContentView ) )
       
   349             {
       
   350             SetActiveService( ActiveServiceGroup() );
       
   351             SetActiveServiceGroup( KMaxTUint );
       
   352             }
       
   353         
       
   354         IPTVLOGSTRING2_LOW_LEVEL("CVcxNsUiEngine::HandleBack: new state = %d", newState );
       
   355         return ETrue;
       
   356         }
       
   357     else
       
   358         {
       
   359         IPTVLOGSTRING_LOW_LEVEL("CVcxNsUiEngine::HandleBack: state stack is empty" );
       
   360         iApplicationState = EStateNoState;
       
   361         return EFalse;
       
   362         }
       
   363     }
       
   364 
       
   365 // -----------------------------------------------------------------------------
       
   366 // CVcxNsUiEngine::ResetStates()
       
   367 // -----------------------------------------------------------------------------
       
   368 //
       
   369 EXPORT_C void CVcxNsUiEngine::ResetStates()
       
   370     {
       
   371     iAppStateStack.Reset();
       
   372     iApplicationState = EStateNoState;
       
   373     }
       
   374 
       
   375 // -----------------------------------------------------------------------------
       
   376 // CVcxNsUiEngine::ActiveCategory()
       
   377 // -----------------------------------------------------------------------------
       
   378 //
       
   379 EXPORT_C TUint32 CVcxNsUiEngine::ActiveCategory()
       
   380     {
       
   381     return iActiveCategory;
       
   382     }
       
   383 
       
   384 // -----------------------------------------------------------------------------
       
   385 // CVcxNsUiEngine::GetAvailableIapL()
       
   386 // -----------------------------------------------------------------------------
       
   387 //
       
   388 EXPORT_C TUint32 CVcxNsUiEngine::GetAvailableIapL()
       
   389     {
       
   390     TUint32 iap( 0 );
       
   391 
       
   392     if ( ! iConnUtil )
       
   393         {
       
   394         iConnUtil = CVcxConnectionUtility::InstanceL();
       
   395         }
       
   396 
       
   397     if ( iConnUtil )
       
   398         {
       
   399         iConnUtil->GetIap( iap, EFalse );
       
   400         }
       
   401 
       
   402     return iap;
       
   403     }
       
   404 
       
   405 // -----------------------------------------------------------------------------
       
   406 // CVcxNsUiEngine::GetAvailableWapIdL()
       
   407 // -----------------------------------------------------------------------------
       
   408 //
       
   409 EXPORT_C TUint32 CVcxNsUiEngine::GetAvailableWapIdL()
       
   410     {
       
   411     TUint32 wap( 0 );
       
   412     TUint32 iap = GetAvailableIapL();
       
   413     if ( iap != 0 && iConnUtil )
       
   414         {
       
   415         wap = iConnUtil->WapIdFromIapIdL( iap );
       
   416         }
       
   417     
       
   418     return wap;
       
   419     }
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CVcxNsUiEngine::PlayVideoL()
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 EXPORT_C void CVcxNsUiEngine::PlayVideoL( CVcxNsContent* aContent )
       
   426     {
       
   427     IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsUiEngine::PlayVideoL");
       
   428     
       
   429     if( aContent )
       
   430          {
       
   431          TUint32 typeFlags = aContent->GetContentTypes();
       
   432          
       
   433          if( ( typeFlags & CVcxNsContent::EVcxContentTypeVideo )  &&
       
   434                 aContent->GetMpxId() )
       
   435              {
       
   436              GetMpxCollectionClientHandlerL()->PlayVideoL( aContent->GetMpxId() );
       
   437              }
       
   438          }
       
   439     
       
   440     IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsUiEngine::PlayVideoL");
       
   441     }
       
   442 
       
   443 // -----------------------------------------------------------------------------
       
   444 // CVcxNsUiEngine::PlayStreamL()
       
   445 // -----------------------------------------------------------------------------
       
   446 //
       
   447 EXPORT_C void CVcxNsUiEngine::PlayStreamL( CVcxNsContent* aContent )
       
   448     {
       
   449     IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsUiEngine::PlayStreamL");
       
   450     
       
   451     if( aContent )
       
   452         {
       
   453         TUint32 typeFlags = aContent->GetContentTypes();
       
   454          
       
   455         if( typeFlags & CVcxNsContent::EVcxContentTypeStream ) 
       
   456             {
       
   457             CEikAppUi* appui = (CEikAppUi*) CCoeEnv::Static()->AppUi();
       
   458             
       
   459             User::LeaveIfNull( appui );
       
   460             
       
   461             appui->OpenFileL( aContent->GetUrl( CVcxNsContent::EVcxContentTypeStream ) );
       
   462 
       
   463 		    if ( !iStreamingHandler )
       
   464 		       {
       
   465 		       iStreamingHandler = CVcxNsStreamingHandler::NewL( *this );
       
   466 		       }
       
   467     
       
   468 		    iStreamingHandler->HandleOpenStreamL( aContent );
       
   469 		    }
       
   470         }
       
   471     
       
   472     IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsUiEngine::PlayStreamL");
       
   473     }
       
   474 // -----------------------------------------------------------------------------
       
   475 // CVcxNsUiEngine::PlayLastWatchedL()
       
   476 // -----------------------------------------------------------------------------
       
   477 //
       
   478 EXPORT_C void CVcxNsUiEngine::PlayLastWatchedL()
       
   479     {
       
   480     IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsUiEngine::PlayLastWatchedL");
       
   481     
       
   482     CVcxNsContent* content = LastWatchedToContentL();
       
   483     
       
   484     if ( !content )
       
   485         {
       
   486         User::Leave( KErrNotFound );
       
   487         }
       
   488     
       
   489     CleanupStack::PushL( content );
       
   490     
       
   491     TUint32 typeFlags = content->GetContentTypes();
       
   492      
       
   493     if( typeFlags & CVcxNsContent::EVcxContentTypeVideo ) 
       
   494         {
       
   495         GetMpxCollectionClientHandlerL()->GetMediaDetailsSyncL( content->GetMpxId() );
       
   496         
       
   497         PlayVideoL( content );
       
   498         }
       
   499     else if( typeFlags & CVcxNsContent::EVcxContentTypeStream ) 
       
   500         {
       
   501         PlayStreamL( content );
       
   502         }
       
   503 
       
   504     CleanupStack::PopAndDestroy( content );
       
   505     
       
   506     IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsUiEngine::PlayLastWatchedL");
       
   507     }
       
   508 
       
   509 // -----------------------------------------------------------------------------
       
   510 // 
       
   511 // -----------------------------------------------------------------------------
       
   512 //
       
   513 EXPORT_C void CVcxNsUiEngine::VideoPlaybackStartingL( CVcxNsContent* aContent )
       
   514     {
       
   515     IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsUiEngine::VideoPlaybackStartingL");
       
   516     
       
   517     WriteLastWatchedL( aContent );
       
   518     RaisePlayEventL( aContent );
       
   519 
       
   520     TUint32 mpxId = aContent->GetMpxId( CVcxNsContent::EVcxContentTypeVideo );
       
   521     
       
   522     if( mpxId )
       
   523         {
       
   524         // This also loads the played object media data to cache while playing.
       
   525         // Sometimes MDS has the item locked and the new video flag setting fails
       
   526         // We don't want to prevent playback starting in that case -> trap ignore.
       
   527         TRAP_IGNORE( GetMpxCollectionClientHandlerL()->MarkVideoAsWatchedL( mpxId ));
       
   528         }
       
   529     
       
   530     IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsUiEngine::VideoPlaybackStartingL");
       
   531     }
       
   532 
       
   533 // -----------------------------------------------------------------------------
       
   534 // 
       
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 void CVcxNsUiEngine::RaisePlayEventL( CVcxNsContent* aContent )
       
   538     {
       
   539     IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsUiEngine::RaisePlayEventL");
       
   540     
       
   541     TBool isLocal ( aContent->GetContentTypes() & CVcxNsContent::EVcxContentTypeVideo ); 
       
   542     
       
   543     TVideoPlayerCustomMessage msg;
       
   544 
       
   545     if ( isLocal )
       
   546         {
       
   547         msg.iContent = aContent->GetLocalFilepath( CVcxNsContent::EVcxContentTypeVideo );
       
   548         }
       
   549     else 
       
   550         {
       
   551         msg.iContent = aContent->GetUrl( CVcxNsContent::EVcxContentTypeStream );
       
   552         }
       
   553     
       
   554     msg.iIcon = aContent->GetIconPath();
       
   555     msg.iName = aContent->GetName();
       
   556     
       
   557     TPckg<TVideoPlayerCustomMessage> videoInfoPckg( msg );
       
   558     
       
   559     iMediatorEventProvider->RaiseEvent( KVcxNsVideoCenterMediatorDomain,
       
   560                                         KVcxNsPlayerGeneralCategory,
       
   561                                         KVcxNsMediatorEventPlayerLastWatch,
       
   562                                         TVersion( KVcxNsMediatorPlayerVersion, 0, 0 ),
       
   563                                         videoInfoPckg );
       
   564     
       
   565     IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsUiEngine::RaisePlayEventL");
       
   566     }
       
   567 
       
   568 // -----------------------------------------------------------------------------
       
   569 // 
       
   570 // -----------------------------------------------------------------------------
       
   571 //
       
   572 void CVcxNsUiEngine::WriteLastWatchedL( CVcxNsContent* aContent )
       
   573     {
       
   574     IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsUiEngine::WriteLastWatchedL");
       
   575     
       
   576     CIptvLastWatchedData* lwData = CIptvLastWatchedData::NewL();
       
   577     CleanupStack::PushL( lwData );
       
   578 
       
   579     TUint32 mpxId = aContent->GetMpxId( CVcxNsContent::EVcxContentTypeVideo );
       
   580     TBool isLocal ( aContent->GetContentTypes() & CVcxNsContent::EVcxContentTypeVideo ); 
       
   581     
       
   582     if( mpxId && isLocal )
       
   583         {
       
   584         lwData->SetMpxId( mpxId );
       
   585         }
       
   586     
       
   587     if ( isLocal )
       
   588         {
       
   589         lwData->SetUriL( aContent->GetLocalFilepath( CVcxNsContent::EVcxContentTypeVideo ) );
       
   590         }
       
   591     else 
       
   592         {
       
   593         lwData->SetUriL( aContent->GetUrl( CVcxNsContent::EVcxContentTypeStream ) );
       
   594         }
       
   595     
       
   596     lwData->SetIconPathL( aContent->GetIconPath() );
       
   597     lwData->SetLaunchType( CIptvLastWatchedData::EUndefined ); 
       
   598     lwData->SetServiceId( aContent->GetServiceId() );
       
   599     lwData->SetContentId( aContent->GetContentId() );
       
   600     lwData->SetNameL( aContent->GetName() );
       
   601     lwData->SetParentalControl( aContent->GetAgeProfile() );
       
   602     
       
   603     iLastWatchedApi->SetLastWatchedDataL( *lwData );
       
   604     CleanupStack::PopAndDestroy( lwData );
       
   605     
       
   606     IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsUiEngine::WriteLastWatchedL");
       
   607     }
       
   608 
       
   609 // -----------------------------------------------------------------------------
       
   610 // VcxNsUiEngine::LastWatchedToContentL
       
   611 // -----------------------------------------------------------------------------
       
   612 //
       
   613 CVcxNsContent* CVcxNsUiEngine::LastWatchedToContentL()
       
   614     {
       
   615     IPTVLOGSTRING_LOW_LEVEL(">>>CVcxNsUiEngine::LastWatchedToContentL");
       
   616     
       
   617     CIptvLastWatchedData* lwData = CIptvLastWatchedData::NewL();
       
   618     CleanupStack::PushL( lwData );
       
   619     iLastWatchedApi->GetLastWatchedDataL( *lwData );
       
   620     
       
   621     CVcxNsContent* content = NULL;
       
   622     
       
   623     if ( lwData->MpxId() != KIdUndefined )
       
   624         {
       
   625         IPTVLOGSTRING_LOW_LEVEL("CVcxNsUiEngine::LastWatchedToContentL lw = video");
       
   626         
       
   627         content = CVcxNsContent::NewL();
       
   628         CleanupStack::PushL( content );
       
   629         
       
   630         CVcxNsContentAccess* ca =  CVcxNsContentAccess::NewL();
       
   631         ca->iType = CVcxNsContent::EVcxContentTypeVideo;
       
   632         
       
   633         content->AddContentAccess( ca );
       
   634         content->SetMpxId( lwData->MpxId(), CVcxNsContent::EVcxContentTypeVideo );
       
   635         
       
   636         CleanupStack::Pop( content );
       
   637         }
       
   638     else if ( lwData->Uri().Length() > 0 )
       
   639         {
       
   640         IPTVLOGSTRING_LOW_LEVEL("CVcxNsUiEngine::LastWatchedToContentL lw = stream");
       
   641         
       
   642         GetContentProviderL();
       
   643         
       
   644         CVcxNsContent* contentInCache = ContentProvider()->GetContentL( lwData->ServiceId(),
       
   645                                                                         lwData->ContentId() );
       
   646         if ( contentInCache )
       
   647             {
       
   648             content = CVcxNsContent::NewL( *contentInCache );
       
   649             }
       
   650         else
       
   651             {
       
   652             content = CVcxNsContent::NewL();
       
   653             CleanupStack::PushL( content );
       
   654             CVcxNsContentAccess* ca = CVcxNsContentAccess::NewL();
       
   655             CleanupStack::PushL( ca );
       
   656             ca->SetUrlL( lwData->Uri() );
       
   657             ca->iType = CVcxNsContent::EVcxContentTypeStream;
       
   658             CleanupStack::Pop( ca );
       
   659             content->AddContentAccess( ca );
       
   660             CleanupStack::Pop( content );
       
   661             }
       
   662         }
       
   663     else
       
   664         {
       
   665         IPTVLOGSTRING_LOW_LEVEL("CVcxNsUiEngine::LastWatchedToContentL no last watched ");
       
   666         }
       
   667     
       
   668     CleanupStack::PopAndDestroy( lwData );
       
   669     
       
   670     IPTVLOGSTRING_LOW_LEVEL("<<<CVcxNsUiEngine::LastWatchedToContentL");
       
   671     
       
   672     return content;
       
   673     }
       
   674 
       
   675 // -----------------------------------------------------------------------------
       
   676 //
       
   677 // -----------------------------------------------------------------------------
       
   678 //
       
   679 void CVcxNsUiEngine::PopAppStateStack()
       
   680     {
       
   681     TInt count = iAppStateStack.Count();
       
   682 
       
   683     if( count > 0 )
       
   684         {
       
   685         //remove current state
       
   686         iAppStateStack.Remove( count-1 );
       
   687         iAppStateStack.Compress();
       
   688         }
       
   689     }
       
   690 
       
   691 // -----------------------------------------------------------------------------
       
   692 //
       
   693 // -----------------------------------------------------------------------------
       
   694 //
       
   695 TInt CVcxNsUiEngine::MnpwoLastPlaybackPosition( const TDesC& /*aContentUri*/ )
       
   696     {
       
   697     return 0;
       
   698     }
       
   699 
       
   700 // -----------------------------------------------------------------------------
       
   701 //
       
   702 // -----------------------------------------------------------------------------
       
   703 //
       
   704 void CVcxNsUiEngine::MnpwoSetLastPlaybackPosition( const TDesC& /*aContentUri*/, TInt /*aPos*/ )
       
   705     {
       
   706     }
       
   707 
       
   708 // -----------------------------------------------------------------------------
       
   709 // CVcxNsUiEngine::GetServiceClientHandlerL()
       
   710 // -----------------------------------------------------------------------------
       
   711 //
       
   712 CVcxNsServiceClientHandler* CVcxNsUiEngine::GetServiceClientHandlerL()
       
   713     {
       
   714     IPTVLOGSTRING_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetServiceClientHandlerL() -- Enter");
       
   715 
       
   716     if ( !iServiceClientHandler )
       
   717         {
       
   718         iServiceClientHandler = CVcxNsServiceClientHandler::NewL( *this );
       
   719         }
       
   720 
       
   721     IPTVLOGSTRING2_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetServiceClientHandlerL() -- Returning: %d", (TInt) iServiceClientHandler );
       
   722 
       
   723     return iServiceClientHandler;
       
   724     }
       
   725 
       
   726 // -----------------------------------------------------------------------------
       
   727 // CVcxNsUiEngine::GetContentClientHandlerL()
       
   728 // -----------------------------------------------------------------------------
       
   729 //
       
   730 CVcxNsContentClientHandler* CVcxNsUiEngine::GetContentClientHandlerL()
       
   731     {
       
   732     IPTVLOGSTRING_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetContentClientHandlerL() -- Enter");
       
   733 
       
   734     if ( ! iContentClientHandler )
       
   735         {
       
   736         if ( ! iConnUtil )
       
   737             {
       
   738             iConnUtil = CVcxConnectionUtility::InstanceL();
       
   739             }
       
   740 
       
   741         iContentClientHandler = CVcxNsContentClientHandler::NewL( *this, *iConnUtil );
       
   742         }
       
   743 
       
   744     IPTVLOGSTRING2_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetContentClientHandlerL() -- Returning: %d", (TInt) iContentClientHandler );
       
   745 
       
   746      return iContentClientHandler;
       
   747     }
       
   748 
       
   749 // -----------------------------------------------------------------------------
       
   750 // CVcxNsUiEngine::GetMpxCollectionClientHandler()
       
   751 // -----------------------------------------------------------------------------
       
   752 //
       
   753 CVcxNsMpxCollectionClientHandler* CVcxNsUiEngine::GetMpxCollectionClientHandlerL()
       
   754     {
       
   755     IPTVLOGSTRING2_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetMpxCollectionClientHandler() -- Returning: %d", (TInt) iContentClientHandler );
       
   756 
       
   757     if ( ! iMpxCollectionClientHandler )
       
   758         {
       
   759         iMpxCollectionClientHandler = CVcxNsMpxCollectionClientHandler::NewL( *this );
       
   760         }
       
   761 
       
   762     return iMpxCollectionClientHandler;
       
   763     }
       
   764 
       
   765 // -----------------------------------------------------------------------------
       
   766 // CVcxNsUiEngine::GetContentSearchHandlerL()
       
   767 // -----------------------------------------------------------------------------
       
   768 //
       
   769 CVcxNsContentSearchHandler* CVcxNsUiEngine::GetContentSearchHandlerL()
       
   770     {
       
   771     IPTVLOGSTRING2_LOW_LEVEL("UI Engine ## CVcxNsUiEngine::GetContentSearchHandlerL() -- Returning: %d", 
       
   772             (TInt)iContentSearchHandler );
       
   773 
       
   774     return iContentSearchHandler;
       
   775     }
       
   776 
       
   777 // -----------------------------------------------------------------------------
       
   778 // CVcxNsUiEngine::GetEventRouter()
       
   779 // -----------------------------------------------------------------------------
       
   780 //
       
   781 CVcxNsEventRouter* CVcxNsUiEngine::GetEventRouter()
       
   782     {
       
   783     return iEventRouter;
       
   784     }
       
   785 
       
   786 // -----------------------------------------------------------------------------
       
   787 // CVcxNsUiEngine::GetUpdateProgressHandler
       
   788 // -----------------------------------------------------------------------------
       
   789 //
       
   790 CVcxNsUpdateProgressHandler* CVcxNsUiEngine::GetProgressHandler()
       
   791     {
       
   792     IPTVLOGSTRING2_LOW_LEVEL(
       
   793             "UI Engine ## CVcxNsUiEngine::GetProgressHandler() -- Returning: %d", 
       
   794             (TInt)iProgressHandler );
       
   795     return iProgressHandler;
       
   796     }
       
   797 
       
   798  // -----------------------------------------------------------------------------
       
   799  // CVcxNsUiEngine::ActiveService()
       
   800  // -----------------------------------------------------------------------------
       
   801  //
       
   802 TUint32 CVcxNsUiEngine::ActiveService()
       
   803     {
       
   804     return iActiveService;
       
   805     }
       
   806 
       
   807 // -----------------------------------------------------------------------------
       
   808 // CVcxNsUiEngine::SetActiveService()
       
   809 // -----------------------------------------------------------------------------
       
   810 //
       
   811 void CVcxNsUiEngine::SetActiveService( TUint32 aServiceId )
       
   812     {
       
   813     iActiveService = aServiceId;
       
   814     }
       
   815 
       
   816 // -----------------------------------------------------------------------------
       
   817 // CVcxNsUiEngine::ActiveServiceGroup()
       
   818 // -----------------------------------------------------------------------------
       
   819 //
       
   820 TUint32 CVcxNsUiEngine::ActiveServiceGroup()
       
   821    {
       
   822    return iActiveServiceGroup;
       
   823    }
       
   824 
       
   825 // -----------------------------------------------------------------------------
       
   826 // CVcxNsUiEngine::SetActiveServiceGroup()
       
   827 // -----------------------------------------------------------------------------
       
   828 //
       
   829 void CVcxNsUiEngine::SetActiveServiceGroup( TUint32 aServiceId )
       
   830    {
       
   831    iActiveServiceGroup = aServiceId;
       
   832    }
       
   833 
       
   834 // -----------------------------------------------------------------------------
       
   835 // CVcxNsUiEngine::SetActiveCategory()
       
   836 // -----------------------------------------------------------------------------
       
   837 //
       
   838 void CVcxNsUiEngine::SetActiveCategory( TUint32 aCategoryId )
       
   839     {
       
   840     iActiveCategory = aCategoryId;
       
   841     }
       
   842 
       
   843 // -----------------------------------------------------------------------------
       
   844 // CVcxNsUiEngine::ServiceProvider()
       
   845 // -----------------------------------------------------------------------------
       
   846 //
       
   847 CVcxNsServiceProvider* CVcxNsUiEngine::ServiceProvider()
       
   848      {
       
   849      return iServiceProvider;
       
   850      }
       
   851 
       
   852 // -----------------------------------------------------------------------------
       
   853 // CVcxNsUiEngine::ContentProvider()
       
   854 // -----------------------------------------------------------------------------
       
   855 //
       
   856 CVcxNsContentProvider* CVcxNsUiEngine::ContentProvider()
       
   857      {
       
   858      return iContentProvider;
       
   859      }
       
   860 
       
   861 // -----------------------------------------------------------------------------
       
   862 // CVcxNsUiEngine::CategoryProvider()
       
   863 // -----------------------------------------------------------------------------
       
   864 //
       
   865 CVcxNsCategoryProvider* CVcxNsUiEngine::CategoryProvider()
       
   866      {
       
   867      return iCategoryProvider;
       
   868      }