videoplayerapp/mpxvideoplayer/src/mpxvideoplayerappuiengine.cpp
changeset 0 96612d01cf9f
child 2 dec420019252
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 "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:  AppUI engine implementation
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: da1mmcf#58 %
       
    19 
       
    20 
       
    21 #include <eikon.hrh>
       
    22 #include <avkon.hrh>
       
    23 #include <aknview.h>
       
    24 #include <mpxviewutility.h>
       
    25 #include <mpxcommand.h>
       
    26 #include <mpxcommandgeneraldefs.h>
       
    27 #include <mpxmessagegeneraldefs.h>
       
    28 #include <mpxplaybackmessage.h>
       
    29 #include <mpxplaybackutility.h>
       
    30 #include <mpxcollectionmessage.h>
       
    31 #include <mpxmediageneraldefs.h>
       
    32 #include <mpxcollectionmessagedefs.h>
       
    33 #include <vcxmyvideosdefs.h>
       
    34 #include <vcxmyvideosuids.h>
       
    35 #include <mpxcollectionpath.h>
       
    36 #include <videoplayeractivationmessage.h>
       
    37 #include <AiwGenericParam.h>
       
    38 #include <mpxcollectionuihelper.h>
       
    39 #include <mpxcollectionhelperfactory.h>
       
    40 #include <mpxcollectionplugin.hrh>
       
    41 #include <mpxmediageneralextdefs.h>
       
    42 
       
    43 #include <streaminglinkmodel.h>
       
    44 #include <mpsettingsmodel.h>
       
    45 #include <coeutils.h>
       
    46 #include <videoplaylistutility.h>
       
    47 #include <cmmanagerext.h>
       
    48 #include <cmpluginwlandef.h>
       
    49 #include <commdb.h>             // CMDBSession
       
    50 #include <commsdattypesv1_1.h>  // CCDWAPIPBearerRecord
       
    51 #include <es_sock.h>
       
    52 #include <commdbconnpref.h>     // TCommDbConnPref
       
    53 #include <extendedconnpref.h>
       
    54 
       
    55 #include "mpxvideoplayerappuiengine.h"
       
    56 #include "mpxvideoplayerlogger.h"
       
    57 #include "mpxvideoplayerconstants.h"
       
    58 #include "mpxvideoembeddedpdlhandler.h"
       
    59 #include <mpxvideoplaybackdefs.h>
       
    60 #include "mpxvideo_debug.h"
       
    61 #include "mpxvideoplayercustomviewmsgconsts.h"
       
    62 
       
    63 _LIT( KMpxVideoPlayerQueryIap, "IAP\\Id" );
       
    64 
       
    65 const TInt KMpxPlaybackPluginTypeUid = 0x101FFCA0;
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 //   CMpxVideoPlayerAppUiEngine::CMpxVideoPlayerAppUiEngine
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 CMpxVideoPlayerAppUiEngine::CMpxVideoPlayerAppUiEngine( CMpxVideoPlayerAppUi* aAppUi )
       
    72     : iAppUi( aAppUi ),
       
    73       iPlaybackUtility( NULL ),
       
    74       iViewUtility( NULL ),
       
    75       iCollectionUtility( NULL ),
       
    76       iExitAo( NULL ),
       
    77       iRecognizer( NULL ),
       
    78       iExtAccessPointId( KErrUnknown ),
       
    79       iMultilinkPlaylist(EFalse),
       
    80       iSeekable(ETrue),
       
    81       iUpdateSeekInfo(EFalse),
       
    82       iExitToMatrixMenu(ETrue)
       
    83 {
       
    84 }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 //   CMpxVideoPlayerAppUiEngine::NewL
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 CMpxVideoPlayerAppUiEngine* CMpxVideoPlayerAppUiEngine::NewL( CMpxVideoPlayerAppUi* aAppUi )
       
    91 {
       
    92     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::NewL()"));
       
    93 
       
    94     CMpxVideoPlayerAppUiEngine* self = new( ELeave) CMpxVideoPlayerAppUiEngine( aAppUi );
       
    95 
       
    96     CleanupStack::PushL(self);
       
    97     self->ConstructL();
       
    98     CleanupStack::Pop(self);
       
    99     return self;
       
   100 }
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 //   CMpxVideoPlayerAppUiEngine::ConstructL
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CMpxVideoPlayerAppUiEngine::ConstructL()
       
   107 {
       
   108     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ConstructL()"));
       
   109 
       
   110     iRecognizer = CMediaRecognizer::NewL();
       
   111 
       
   112     //
       
   113     //  Create the View Utility
       
   114     //
       
   115     iViewUtility = MMPXViewUtility::UtilityL();
       
   116     iViewUtility->AddObserverL( this );
       
   117     iViewUtility->ConstructDefaultViewHistoryL();
       
   118 
       
   119     //
       
   120     //  Create the Collection Utility
       
   121     //
       
   122     if ( ! iAppUi->IsEmbedded() )
       
   123     {
       
   124         TUid collectionMode( KUidMpxVideoPlayerApplication );
       
   125 
       
   126         iCollectionUtility = MMPXCollectionUtility::NewL( this, collectionMode );
       
   127     }
       
   128 
       
   129     //
       
   130     //  Create Active Object for exiting the application
       
   131     //
       
   132     iExitAo = CIdle::NewL( CActive::EPriorityStandard );
       
   133 }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 //   CMpxVideoPlayerAppUiEngine::CreateCollectionUtilityMemberVariablesL
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 void CMpxVideoPlayerAppUiEngine::CreateCollectionUtilityMemberVariablesL()
       
   140 {
       
   141     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::CreateCollectionUtilityMemberVariablesL()"));
       
   142 
       
   143     if ( ! iCollectionUtility )
       
   144     {
       
   145         //  PLAYLIST default mode
       
   146         iCollectionUtility = MMPXCollectionUtility::NewL( this );
       
   147     }
       
   148 
       
   149     if ( ! iCollectionUiHelper )
       
   150     {
       
   151         iCollectionUiHelper = CMPXCollectionHelperFactory::NewCollectionUiHelperL();
       
   152     }
       
   153 }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 //   CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityMemberVariablesL
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityMemberVariablesL()
       
   160 {
       
   161     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::CreatePlaybackUtilityMemberVariablesL()"));
       
   162 
       
   163     if ( ! iPlaybackUtility )
       
   164     {
       
   165         //
       
   166         //  Create VideoHelix playback plugin
       
   167         //
       
   168         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( EMPXCategoryVideo, KPbModeNewPlayer );
       
   169         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   170         manager.SelectPlayerL( KVideoHelixPlaybackPluginUid );
       
   171         iPlaybackUtility->CommandL( EPbCmdSetAutoResume, EFalse );
       
   172     }
       
   173 }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 //   CMpxVideoPlayerAppUiEngine::CreateEmbeddedPdlPlaybackUtilityMemberVariablesL
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 void CMpxVideoPlayerAppUiEngine::CreateEmbeddedPdlPlaybackUtilityMemberVariablesL()
       
   180 {
       
   181     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::CreateEmbeddedPdlPlaybackUtilityMemberVariablesL()"));
       
   182 
       
   183     iViewUtility->PreLoadViewL( KVideoPdlPlaybackViewUid );
       
   184 
       
   185     if ( ! iPlaybackUtility )
       
   186     {
       
   187         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( EMPXCategoryVideo, KPbModeNewPlayer );
       
   188         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   189         manager.SelectPlayerL( KVideoHelixPlaybackPluginUid );
       
   190         iPlaybackUtility->CommandL( EPbCmdSetAutoResume, EFalse );
       
   191     }
       
   192 }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 //   CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine
       
   196 // -----------------------------------------------------------------------------
       
   197 //
       
   198 CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine()
       
   199 {
       
   200     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::~CMpxVideoPlayerAppUiEngine()"));
       
   201 
       
   202     if ( iExitAo )
       
   203     {
       
   204         delete iExitAo;
       
   205         iExitAo = NULL;
       
   206     }
       
   207 
       
   208     if ( iRecognizer )
       
   209     {
       
   210         delete iRecognizer;
       
   211         iRecognizer = NULL;
       
   212     }
       
   213 
       
   214     if ( iPdlHandler )
       
   215     {
       
   216         delete iPdlHandler;
       
   217         iPdlHandler = NULL;
       
   218     }
       
   219 
       
   220     if ( iCollectionUtility )
       
   221     {
       
   222         iCollectionUtility->Close();
       
   223     }
       
   224 
       
   225     if ( iCollectionUiHelper )
       
   226     {
       
   227         iCollectionUiHelper->Close();
       
   228     }
       
   229 
       
   230     if ( iViewUtility )
       
   231     {
       
   232         iViewUtility->RemoveObserver( this );
       
   233         iViewUtility->Close();
       
   234     }
       
   235 
       
   236     if ( iPlaybackUtility )
       
   237     {
       
   238         TRAP_IGNORE( iPlaybackUtility->CommandL( EPbCmdClose ) );
       
   239         iPlaybackUtility->Close();
       
   240     }
       
   241 }
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // From MMPXViewActivationObserver.
       
   245 // Handle view activation.
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 void CMpxVideoPlayerAppUiEngine::HandleViewActivation( const TUid& /*aCurrentViewType*/,
       
   249                                                        const TUid& /*aPreviousViewType*/ )
       
   250 {
       
   251 }
       
   252 
       
   253 // -------------------------------------------------------------------------------------------------
       
   254 //   CMpxVideoPlayerAppUiEngine::HandleAiwGenericParamListL()
       
   255 // -------------------------------------------------------------------------------------------------
       
   256 //
       
   257 TInt CMpxVideoPlayerAppUiEngine::HandleAiwGenericParamListL( const CAiwGenericParamList* aParams )
       
   258 {
       
   259     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleAiwGenericParamListL()"));
       
   260 
       
   261     TInt retVal = KErrNone;
       
   262 
       
   263     TInt index = 0;
       
   264 
       
   265     //
       
   266     //  Check if there is a terminate message.  If it exists, exit the application.
       
   267     //
       
   268     TInt32 terminateID = 0;
       
   269 
       
   270     const TAiwGenericParam* paramTerminate =
       
   271         aParams->FindFirst( index, EGenericParamTerminate, EVariantTypeTInt32 );
       
   272 
       
   273     if ( paramTerminate )
       
   274     {
       
   275         paramTerminate->Value().Get( terminateID );
       
   276     }
       
   277 
       
   278     if ( terminateID )
       
   279     {
       
   280         MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::HandleAiwGenericParamListL()  Terminate message received"));
       
   281 
       
   282         //
       
   283         //  Embedded app is being closed
       
   284         //
       
   285         iAppUi->HandleCommandL( EEikCmdExit );
       
   286 
       
   287         retVal = KErrCancel;
       
   288     }
       
   289     else
       
   290     {
       
   291         //
       
   292         //  Determine if these parameters are for PDL
       
   293         //
       
   294         index = 0;
       
   295         TInt32 dlId = KErrNotFound;
       
   296 
       
   297         const TAiwGenericParam* genParamDlId =
       
   298             aParams->FindFirst( index, EGenericParamDownloadId, EVariantTypeTInt32 );
       
   299 
       
   300         if ( genParamDlId )
       
   301         {
       
   302             genParamDlId->Value().Get( dlId );
       
   303 
       
   304             index = 0;
       
   305 
       
   306             const TAiwGenericParam* paramFileName =
       
   307                 aParams->FindFirst( index, EGenericParamFile, EVariantTypeDesC );
       
   308 
       
   309             TPtrC fileName;
       
   310 
       
   311             //
       
   312             //  Set the filename.  The LWPlayerAppUi checks for the
       
   313             //  filename and exits if it doesn't exist
       
   314             //
       
   315             fileName.Set( paramFileName->Value().AsDes() );
       
   316 
       
   317             if ( ! iPdlHandler )
       
   318             {
       
   319                 iPdlHandler = CMpxVideoEmbeddedPdlHandler::NewL( this );
       
   320             }
       
   321 
       
   322             iPdlHandler->ConnectToEmbeddedDownloadL( dlId, fileName );
       
   323         }
       
   324         else
       
   325         {
       
   326             //
       
   327             //  Check Access Point
       
   328             //
       
   329             index = 0;
       
   330 
       
   331             const TAiwGenericParam* genParamAccessPoint =
       
   332                 aParams->FindFirst( index, EGenericParamAccessPoint, EVariantTypeTInt32 );
       
   333 
       
   334             if ( index >= 0 && genParamAccessPoint )
       
   335             {
       
   336                 TInt32 apId = KErrUnknown;
       
   337                 genParamAccessPoint->Value().Get( apId );
       
   338                 iExtAccessPointId = apId;
       
   339             }
       
   340         }
       
   341     }
       
   342 
       
   343     return retVal;
       
   344 }
       
   345 
       
   346 // -----------------------------------------------------------------------------
       
   347 //   CMpxVideoPlayerAppUiEngine::OpenFileL
       
   348 // -----------------------------------------------------------------------------
       
   349 //
       
   350 void CMpxVideoPlayerAppUiEngine::OpenFileL( RFile& aFile, const CAiwGenericParamList* aParams )
       
   351 {
       
   352     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenFileL(RFile)"));
       
   353 
       
   354     TInt err = KErrNone;
       
   355 
       
   356     if ( aParams )
       
   357     {
       
   358         err = HandleAiwGenericParamListL( aParams );
       
   359     }
       
   360 
       
   361     if ( KErrNone == err && ! iPdlHandler )
       
   362     {
       
   363         //
       
   364         //  Create member variables for embedded use cases that are not PDL
       
   365         //
       
   366         CreatePlaybackUtilityMemberVariablesL();
       
   367 
       
   368         TFileName filename;
       
   369         aFile.FullName(filename);
       
   370 
       
   371         CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL( filename, aFile );
       
   372 
       
   373         if ( mediaType == CMediaRecognizer::ELocalRamFile ||
       
   374              mediaType == CMediaRecognizer::ELocalAsxFile )
       
   375         {
       
   376             HandleMultiLinksFileL( aFile, mediaType );
       
   377         }
       
   378         else if ( mediaType == CMediaRecognizer::ELocalSdpFile )
       
   379         {
       
   380             SetAccessPointL();
       
   381             iPlaybackUtility->InitStreamingL( aFile, iAccessPointId );
       
   382             ActivatePlaybackViewL();
       
   383         }
       
   384         else
       
   385         {
       
   386             iViewUtility->PreLoadViewL( KVideoPlaybackViewUid );
       
   387             iPlaybackUtility->InitL( aFile );
       
   388             ActivatePlaybackViewL();
       
   389         }
       
   390     }
       
   391 
       
   392     iRecognizer->FreeFilehandle();
       
   393 
       
   394     aFile.Close();
       
   395 }
       
   396 
       
   397 // -----------------------------------------------------------------------------
       
   398 //   CMpxVideoPlayerAppUiEngine::OpenFileL
       
   399 // -----------------------------------------------------------------------------
       
   400 //
       
   401 void CMpxVideoPlayerAppUiEngine::OpenFileL( const TDesC& aFileName )
       
   402 {
       
   403     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenFileL()"),
       
   404                    _L("aFileName = %S"), &aFileName);
       
   405 
       
   406     //
       
   407     //  Create member variables for embedded use cases that are not PDL
       
   408     //
       
   409     CreatePlaybackUtilityMemberVariablesL();
       
   410 
       
   411     // pre load the view and initialize the playback framework
       
   412     iViewUtility->PreLoadViewL( KVideoPlaybackViewUid );
       
   413 
       
   414     CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL(aFileName);
       
   415 
       
   416     if ( mediaType == CMediaRecognizer::ELocalVideoFile )
       
   417     {
       
   418         InitializeFileL( aFileName );
       
   419     }
       
   420     // check if aFileName is a path to a ram or asx file
       
   421     //          eg. c:\\data\\videos\\ramfile.ram
       
   422     else if ( mediaType == CMediaRecognizer::ELocalRamFile ||
       
   423               mediaType == CMediaRecognizer::ELocalAsxFile )
       
   424     {
       
   425         HandleMultiLinksFileL( aFileName, mediaType );
       
   426     }
       
   427     // check if this is a url eg. rtsp://someaddress/file.3gp
       
   428     //
       
   429     else if ( iRecognizer->IsValidStreamingPrefix( aFileName ) ||
       
   430               mediaType == CMediaRecognizer::ELocalSdpFile )
       
   431     {
       
   432     	InitializeStreamingLinkL( aFileName );
       
   433     }
       
   434     else
       
   435     {
       
   436         InitializeFileL( aFileName );
       
   437     }
       
   438 
       
   439     iRecognizer->FreeFilehandle();
       
   440 }
       
   441 
       
   442 // -------------------------------------------------------------------------------------------------
       
   443 //   CMpxVideoPlayerAppUiEngine::OpenMediaL()
       
   444 // -------------------------------------------------------------------------------------------------
       
   445 //
       
   446 void CMpxVideoPlayerAppUiEngine::OpenMediaL( const CMPXMedia& aMedia )
       
   447 {
       
   448     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::OpenMediaL()"));
       
   449 
       
   450     // Assume MPX medias are always local clips
       
   451     CMPXCollectionPath* mediaPath = CMPXCollectionPath::NewL();
       
   452     CleanupStack::PushL( mediaPath );
       
   453 
       
   454     mediaPath->AppendL( KVcxUidMyVideosMpxCollection );
       
   455     mediaPath->AppendL( KVcxMvcCategoryIdAll );
       
   456 
       
   457     mediaPath->AppendL( aMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
       
   458     mediaPath->SelectL( aMedia.ValueTObjectL<TMPXItemId>( KMPXMediaGeneralId ) );
       
   459 
       
   460     CMPXCollectionPlaylist* playList = CMPXCollectionPlaylist::NewL( *mediaPath );
       
   461     CleanupStack::PushL( playList );
       
   462     playList->SetSingleItemPlaylist();
       
   463     playList->SetToFirst();
       
   464 
       
   465     CreatePlaybackUtilityMemberVariablesL();
       
   466 
       
   467     iViewUtility->PreLoadViewL( KVideoPlaybackViewUid );
       
   468 
       
   469     InitializePlaylistL( *playList, ETrue );
       
   470 
       
   471     CleanupStack::PopAndDestroy( playList );
       
   472     CleanupStack::PopAndDestroy( mediaPath );
       
   473 }
       
   474 
       
   475 // ---------------------------------------------------------------------------
       
   476 //   Activate the proper playback view
       
   477 // ---------------------------------------------------------------------------
       
   478 //
       
   479 void CMpxVideoPlayerAppUiEngine::ActivatePlaybackViewL()
       
   480 {
       
   481     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ActivatePlaybackViewL()"));
       
   482 
       
   483     if ( iUpdateSeekInfo )
       
   484     {
       
   485         //
       
   486     	//  The plugin has been instantiated, update the media
       
   487     	//
       
   488         UpdatePbPluginMediaL();
       
   489         iUpdateSeekInfo = EFalse;
       
   490     }
       
   491 
       
   492     MMPXPlayer* player = iPlaybackUtility->PlayerManager().CurrentPlayer();
       
   493 
       
   494     TUid pluginUid( KNullUid );
       
   495     RArray<TUid> array;
       
   496 
       
   497     CleanupClosePushL( array );
       
   498 
       
   499     if ( iPdlHandler )
       
   500     {
       
   501         array.AppendL( KVideoPdlPlaybackViewUid );
       
   502     }
       
   503     else
       
   504     {
       
   505         if ( player )
       
   506         {
       
   507             pluginUid = player->UidL();
       
   508             array.AppendL( pluginUid );
       
   509         }
       
   510     }
       
   511 
       
   512     iViewUtility->ActivateViewL( array );
       
   513 
       
   514     CleanupStack::PopAndDestroy( &array );
       
   515 }
       
   516 
       
   517 // ---------------------------------------------------------------------------
       
   518 // Closed mpx components and readies to application takedown.
       
   519 // ---------------------------------------------------------------------------
       
   520 //
       
   521 void CMpxVideoPlayerAppUiEngine::PrepareCloseMpxL()
       
   522 {
       
   523     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::PrepareCloseMpxL()"));
       
   524 
       
   525     if ( iPlaybackUtility )
       
   526     {
       
   527         iPlaybackUtility->CommandL( EPbCmdClose );
       
   528         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   529         TRAP_IGNORE( manager.ClearSelectPlayersL() );
       
   530     }
       
   531 }
       
   532 
       
   533 // ---------------------------------------------------------------------------
       
   534 // Sets AppUiEngine in stand alone "mode"
       
   535 // ---------------------------------------------------------------------------
       
   536 //
       
   537 void CMpxVideoPlayerAppUiEngine::StartStandAloneL()
       
   538 {
       
   539     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::StartStandAloneL()"));
       
   540 
       
   541     iExitToMatrixMenu = EFalse;
       
   542 
       
   543     //
       
   544     //  Create the utilities for the stand alone player
       
   545     //
       
   546     CreatePlaybackUtilityMemberVariablesL();
       
   547 
       
   548     // Fetch the video collection UID
       
   549     RArray<TUid> uid;
       
   550     CleanupClosePushL( uid );
       
   551 
       
   552     uid.AppendL( TUid::Uid( KVcxMediaIdMyVideos ) );
       
   553 
       
   554     iVideoCollectionId = iCollectionUtility->CollectionIDL( uid.Array() );
       
   555 
       
   556     CleanupStack::PopAndDestroy( &uid );
       
   557 
       
   558     iViewUtility->SetAsDefaultViewL( KUidMyVideosViewType );
       
   559 }
       
   560 
       
   561 // -----------------------------------------------------------------------------
       
   562 // Handle collection message
       
   563 // -----------------------------------------------------------------------------
       
   564 //
       
   565 void CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL( CMPXMessage* aMessage )
       
   566 {
       
   567     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL()"));
       
   568 
       
   569     TMPXMessageId id = *(aMessage->Value<TMPXMessageId>( KMPXMessageGeneralId ));
       
   570 
       
   571     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL() TMPXMessageId = 0x%08x"), id );
       
   572 
       
   573     if ( id == KMPXMessageGeneral )
       
   574     {
       
   575         TInt event( *( aMessage->Value<TInt> ( KMPXMessageGeneralEvent )) );
       
   576         TInt type( *( aMessage->Value<TInt> ( KMPXMessageGeneralType )) );
       
   577         TInt data( *( aMessage->Value<TInt> ( KMPXMessageGeneralData )) );
       
   578 
       
   579         MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL event %d, type %d, data %d"), event, type, data );
       
   580 
       
   581         if ( event == TMPXCollectionMessage::EPathChanged && type == EMcPathChangedByOpen )
       
   582         {
       
   583             if ( data == EMcItemOpened )
       
   584             {
       
   585                 // An item was opened on the collection. Get the media attributes
       
   586                 // on the item so we can initiatiate playback
       
   587                 MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL: EMcItemOpened received. Can open video"));
       
   588 
       
   589                 CMPXCollectionPath* cPath = iCollectionUtility->Collection().PathL();
       
   590 
       
   591                 CleanupStack::PushL( cPath );
       
   592 
       
   593                 if ( cPath->Count() > 0 )
       
   594                 {
       
   595                     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL: Call MediaL() on collection."));
       
   596 
       
   597                     RArray<TMPXAttribute> attribs;
       
   598                     CleanupClosePushL( attribs );
       
   599 
       
   600                     attribs.Append( KMPXMediaGeneralUri );
       
   601                     attribs.Append( KVcxMediaMyVideosDownloadId );
       
   602                     iCollectionUtility->Collection().MediaL( *cPath, attribs.Array() );
       
   603 
       
   604                     CleanupStack::PopAndDestroy( &attribs );
       
   605                 }
       
   606 
       
   607                 CleanupStack::PopAndDestroy( cPath );
       
   608             }
       
   609             else if ( data == EMcContainerOpened && iMultilinkPlaylist )
       
   610             {
       
   611                 // start the playback for streaming playlists
       
   612                 // once the playlist is opened
       
   613                 iMultilinkPlaylist = EFalse;
       
   614 
       
   615                 // The playlist was opened, initiatiate playback
       
   616                 MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL: EMcContainerOpened received. initiatiate playback"));
       
   617 
       
   618                 CMPXCollectionPath* cPath = iCollectionUtility->Collection().PathL();
       
   619                 CleanupStack::PushL( cPath );
       
   620 
       
   621                 if ( cPath->Count() > 0 )
       
   622                 {
       
   623                     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMessageL: Call Playback utility with the playlist."));
       
   624 
       
   625                     CMPXCollectionPlaylist* playlist = CMPXCollectionPlaylist::NewL( *cPath );
       
   626                     CleanupStack::PushL( playlist );
       
   627 
       
   628                     // Set the AutoPlay mode to false
       
   629                     playlist->SetAutoPlay(EFalse);
       
   630                     // set pre init plugin to false
       
   631                     playlist->SetPreInitPlugin(EFalse);
       
   632 
       
   633                     InitializePlaylistL( *playlist, ETrue );
       
   634                     CleanupStack::PopAndDestroy( playlist );
       
   635                 }
       
   636                 CleanupStack::PopAndDestroy( cPath );
       
   637             }
       
   638         }
       
   639     }
       
   640 }
       
   641 
       
   642 // -------------------------------------------------------------------------------------------------
       
   643 //   CMpxVideoPlayerAppUiEngine::DoHandleCollectionMediaL()
       
   644 // -------------------------------------------------------------------------------------------------
       
   645 //
       
   646 void CMpxVideoPlayerAppUiEngine::DoHandleCollectionMediaL( const CMPXMedia& aMedia )
       
   647 {
       
   648     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandleCollectionMediaL()"));
       
   649 
       
   650     const TDesC& fileUri = aMedia.ValueText(KMPXMediaGeneralUri);
       
   651 
       
   652     MPX_DEBUG(_L("Video URI: %S"), &fileUri );
       
   653 
       
   654     if ( aMedia.IsSupported( KVcxMediaMyVideosDownloadId ) &&
       
   655          aMedia.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId ) != 0 )
       
   656     {
       
   657         TUint32 dlId = aMedia.ValueTObjectL<TUint32>( KVcxMediaMyVideosDownloadId );
       
   658 
       
   659         if ( ! iPdlHandler )
       
   660         {
       
   661             iPdlHandler = CMpxVideoEmbeddedPdlHandler::NewL( this );
       
   662         }
       
   663 
       
   664         iPdlHandler->ConnectToCollectionDownloadL( dlId, const_cast<TDesC&>( fileUri ) );
       
   665     }
       
   666     else
       
   667     {
       
   668         OpenMediaL( aMedia ); // Initialize and initiate playback of a single video
       
   669     }
       
   670 }
       
   671 
       
   672 // ---------------------------------------------------------------------------
       
   673 // Steps back one level back in collection path. Will activate previous view if level exists
       
   674 // ---------------------------------------------------------------------------
       
   675 //
       
   676 void CMpxVideoPlayerAppUiEngine::StepBackCollectionPathL()
       
   677 {
       
   678     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::StepBackCollectionPathL()"));
       
   679 
       
   680     // Back the collection path one level...
       
   681 
       
   682     CMPXCollectionPath* cPath = iCollectionUtility->Collection().PathL();
       
   683     CleanupStack::PushL( cPath );
       
   684 
       
   685     // Don't back up if there are no more levels or will panic
       
   686     if ( cPath->Levels() > 1 )
       
   687     {
       
   688         cPath->Back();
       
   689         iCollectionUtility->Collection().OpenL( *cPath );
       
   690         // ... and then activate the previous view.
       
   691         iViewUtility->ActivatePreviousViewL();
       
   692     }
       
   693 
       
   694     CleanupStack::PopAndDestroy( cPath );
       
   695 }
       
   696 
       
   697 // -------------------------------------------------------------------------------------------------
       
   698 //   CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL
       
   699 // -------------------------------------------------------------------------------------------------
       
   700 //
       
   701 void CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL( const TDesC& aFileName,
       
   702                                                         CMediaRecognizer::TMediaType aMediaType )
       
   703 {
       
   704     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL()"),
       
   705                    _L("aFileName = %S, type = %d"), &aFileName, aMediaType );
       
   706 
       
   707     TBool singleLink;
       
   708     TBool localFile;
       
   709 
       
   710     CVideoPlaylistUtility* playlistUtil = CVideoPlaylistUtility::NewL();
       
   711     CleanupStack::PushL(playlistUtil);
       
   712 
       
   713     playlistUtil->GetFileInfoL( aFileName, aMediaType, singleLink, localFile );
       
   714 
       
   715     DoHandleMultiLinksFileL( playlistUtil, singleLink, localFile );
       
   716 
       
   717     CleanupStack::PopAndDestroy( playlistUtil );
       
   718 }
       
   719 
       
   720 // -------------------------------------------------------------------------------------------------
       
   721 //   CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL
       
   722 // -------------------------------------------------------------------------------------------------
       
   723 //
       
   724 void CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL( RFile& aFile,
       
   725                                                         CMediaRecognizer::TMediaType aMediaType )
       
   726 {
       
   727     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleMultiLinksFileL(RFile)"));
       
   728 
       
   729     // playlist
       
   730     TBool singleLink;
       
   731     TBool localFile;
       
   732 
       
   733     CVideoPlaylistUtility* playlistUtil = CVideoPlaylistUtility::NewL();
       
   734     CleanupStack::PushL(playlistUtil);
       
   735 
       
   736     playlistUtil->GetFileInfoL( aFile, aMediaType, singleLink, localFile );
       
   737 
       
   738     DoHandleMultiLinksFileL( playlistUtil, singleLink, localFile );
       
   739 
       
   740     CleanupStack::PopAndDestroy( playlistUtil );
       
   741 }
       
   742 
       
   743 
       
   744 void CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL( CVideoPlaylistUtility* aPlaylistUtil,
       
   745                                                           TBool aSingleLink,
       
   746                                                           TBool aLocalFile )
       
   747 {
       
   748     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL()"),
       
   749                    _L("aSingleLink = %d aLocalFile %d "), aSingleLink, aLocalFile);
       
   750 
       
   751     if ( aSingleLink )
       
   752     {
       
   753         TPtrC link;
       
   754         link.Set( aPlaylistUtil->GetLinkLC() );
       
   755         iUpdateSeekInfo = ETrue;
       
   756         iSeekable = aPlaylistUtil->IsSeekable();
       
   757 
       
   758         if ( aLocalFile )
       
   759         {
       
   760             CMediaRecognizer::TMediaType mediaType = iRecognizer->IdentifyMediaTypeL( link );
       
   761 
       
   762             if ( mediaType == CMediaRecognizer::EUnidentified )
       
   763             {
       
   764                 User::Leave( KErrNotSupported );
       
   765             }
       
   766             else
       
   767             {
       
   768                 InitializeFileL( link );
       
   769             }
       
   770         }
       
   771         else
       
   772         {
       
   773         	InitializeStreamingLinkL( link );
       
   774         }
       
   775         CleanupStack::PopAndDestroy();  // link
       
   776     }
       
   777     else
       
   778     {
       
   779         if ( ! aLocalFile )
       
   780         {
       
   781             SetAccessPointL();
       
   782         }
       
   783 
       
   784         CMPXMedia* playlist = aPlaylistUtil->GetPlayListL( iAccessPointId );
       
   785         CleanupStack::PushL( playlist );
       
   786 
       
   787         //  Create FW utility member variables for playlist embedded use case
       
   788         CreateCollectionUtilityMemberVariablesL();
       
   789 
       
   790         // Set the flag to true
       
   791         iMultilinkPlaylist = ETrue;
       
   792 
       
   793         // load the in memory plugin
       
   794         iCollectionUiHelper->OpenL( KUidMpxVideoPlayerApplication,
       
   795                                     *playlist,
       
   796                                     this,
       
   797                                     EMPXCollectionPluginGallery );
       
   798 
       
   799         CleanupStack::PopAndDestroy( playlist );
       
   800     }
       
   801 }
       
   802 
       
   803 // -------------------------------------------------------------------------------------------------
       
   804 //   CMpxVideoPlayerAppUiEngine::SetAccessPointL
       
   805 // -------------------------------------------------------------------------------------------------
       
   806 //
       
   807 void CMpxVideoPlayerAppUiEngine::SetAccessPointL()
       
   808 {
       
   809     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::SetAccessPointL()"));
       
   810 
       
   811     //
       
   812     //  a value was passed in for argument aAPId
       
   813     //
       
   814     if ( ( iExtAccessPointId != KErrUnknown ) && IsWLANAccessPointL( iExtAccessPointId ) )
       
   815     {
       
   816         //
       
   817         //  An external WLAN access point was passed in by an embedding app, use it
       
   818         //
       
   819         iAccessPointId = iExtAccessPointId;
       
   820     }
       
   821     else
       
   822     {
       
   823         //
       
   824         //  No access point was passed in or it's not WLAN, retrieve the default access point
       
   825         //
       
   826         TInt defaultAPId(0);
       
   827 
       
   828         MPX_TRAPD( err, defaultAPId = GetDefaultAccessPointL() );
       
   829 
       
   830         if ( ( err == KErrNone ) && ( defaultAPId != 0 ))
       
   831         {
       
   832             //
       
   833             //  Use the default access point
       
   834             //
       
   835             iAccessPointId = defaultAPId;
       
   836         }
       
   837         else
       
   838         {
       
   839             //
       
   840             //  Valid default access point was not found
       
   841             //
       
   842             if ( iExtAccessPointId != KErrUnknown )
       
   843             {
       
   844                 //
       
   845                 //  Use the AP passed in by embedding app, regardless of bearer type
       
   846                 //
       
   847                 iAccessPointId = iExtAccessPointId;
       
   848             }
       
   849             else
       
   850             {
       
   851                 //
       
   852                 //  Try to fetch AP ID and open connection selection dialog if required
       
   853                 //
       
   854                 TUint32 apUid = TryToGetAccessPointL();
       
   855 
       
   856                 //
       
   857                 //  Use selected access point
       
   858                 //
       
   859                 if ( apUid != 0 )
       
   860                 {
       
   861                     //
       
   862                     //  convert the AccessPoint-Uid to AccessPoint-Id
       
   863                     //
       
   864                     iAccessPointId = GetAccessPointIdForUIDL( apUid );
       
   865                 }
       
   866             }
       
   867         }
       
   868     }
       
   869 }
       
   870 
       
   871 // -------------------------------------------------------------------------------------------------
       
   872 //   CMpxVideoPlayerAppUiEngine::IsWLANAccessPointL
       
   873 // -------------------------------------------------------------------------------------------------
       
   874 //
       
   875 TBool CMpxVideoPlayerAppUiEngine::IsWLANAccessPointL( TInt aAPId )
       
   876 {
       
   877     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::IsWLANAccessPointL(%d)"), aAPId);
       
   878 
       
   879     TBool wlanAP(EFalse);
       
   880     TUint32 bearer( 0 );
       
   881 
       
   882     RCmManagerExt cmManager;
       
   883     CleanupClosePushL( cmManager );
       
   884     cmManager.OpenL();
       
   885 
       
   886     bearer = cmManager.ConnectionMethodL( aAPId ).GetIntAttributeL( CMManager::ECmBearerType );
       
   887     CleanupStack::PopAndDestroy( &cmManager );
       
   888 
       
   889     if ( bearer == KUidWlanBearerType )
       
   890     {
       
   891         wlanAP = ETrue;
       
   892     }
       
   893 
       
   894     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::IsWLANAccessPointL() return %d"), wlanAP);
       
   895 
       
   896     return wlanAP;
       
   897 }
       
   898 
       
   899 // -----------------------------------------------------------------------------
       
   900 //   CMpxVideoPlayerAppUiEngine::GetDefaultAccessPointL
       
   901 // -----------------------------------------------------------------------------
       
   902 //
       
   903 TInt CMpxVideoPlayerAppUiEngine::GetDefaultAccessPointL()
       
   904 {
       
   905     TInt defaultAP(0);
       
   906     TUint32 iap;
       
   907 
       
   908     CMPSettingsModel* ropSettings = CMPSettingsModel::NewL( KSettingsModelForROPUid );
       
   909 
       
   910     CleanupStack::PushL( ropSettings );
       
   911 
       
   912     ropSettings->LoadSettingsL( EConfigDefault );
       
   913 
       
   914     User::LeaveIfError( ropSettings->GetDefaultAp( iap ) );
       
   915 
       
   916     CleanupStack::PopAndDestroy(); // ropSettings
       
   917 
       
   918     defaultAP = GetAccessPointIdForUIDL( iap );
       
   919 
       
   920     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::GetDefaultAccessPointL(%d)"), defaultAP);
       
   921 
       
   922     return defaultAP;
       
   923 }
       
   924 
       
   925 // -----------------------------------------------------------------------------
       
   926 //   CMpxVideoPlayerAppUiEngine::GetAccessPointIdForUIDL
       
   927 // -----------------------------------------------------------------------------
       
   928 //
       
   929 TInt CMpxVideoPlayerAppUiEngine::GetAccessPointIdForUIDL( TUint32 aAPUid )
       
   930 {
       
   931     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::GetAccessPointIdForUIDL()"),
       
   932                    _L(" aAPUid = %d"), aAPUid);
       
   933 
       
   934     TInt apId(0);
       
   935 
       
   936     CMDBSession* db = CMDBSession::NewL( CMDBSession::LatestVersion() );
       
   937     CleanupStack::PushL( db );
       
   938 
       
   939     //
       
   940     //  WapIpBearer table contains the mapping between wap and iap id's.
       
   941     //
       
   942     CCDWAPIPBearerRecord* wapBearerRecord =
       
   943         static_cast<CCDWAPIPBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPIPBearerRecord));
       
   944 
       
   945     CleanupStack::PushL( wapBearerRecord );
       
   946 
       
   947     wapBearerRecord->iWAPAccessPointId = aAPUid;
       
   948 
       
   949     TBool found = wapBearerRecord->FindL( *db );
       
   950 
       
   951     if ( ! found )
       
   952     {
       
   953         User::Leave( KErrNotFound );
       
   954     }
       
   955 
       
   956     apId = static_cast<TUint32>( wapBearerRecord->iWAPIAP );
       
   957 
       
   958     CleanupStack::PopAndDestroy( wapBearerRecord );
       
   959     CleanupStack::PopAndDestroy( db );
       
   960 
       
   961     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::GetAccessPointIdForUIDL(%d)"), apId);
       
   962 
       
   963     return apId;
       
   964 }
       
   965 
       
   966 // -----------------------------------------------------------------------------
       
   967 //   CMpxVideoPlayerAppUiEngine::TryToGetAccessPointL
       
   968 // -----------------------------------------------------------------------------
       
   969 //
       
   970 TUint32 CMpxVideoPlayerAppUiEngine::TryToGetAccessPointL()
       
   971 {
       
   972     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::TryToGetAccessPointL()"));
       
   973 
       
   974     TUint32 returnVal(0);
       
   975 
       
   976     RSocketServ ss;
       
   977     CleanupClosePushL( ss );
       
   978 
       
   979     User::LeaveIfError( ss.Connect() );
       
   980 
       
   981     RConnection conn;
       
   982     CleanupClosePushL( conn );
       
   983 
       
   984     User::LeaveIfError( conn.Open( ss ) );
       
   985 
       
   986     TConnPrefList prefList;
       
   987     TExtendedConnPref prefs;
       
   988     prefs.SetSnapPurpose( CMManager::ESnapPurposeInternet  );
       
   989     prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent );
       
   990     prefList.AppendL( &prefs );
       
   991 
       
   992     TInt err = conn.Start( prefList );
       
   993 
       
   994     if ( err == KErrNone )
       
   995     {
       
   996         returnVal = QueryIap( conn );
       
   997     }
       
   998     else if ( err == KErrNotFound )
       
   999     {
       
  1000         //
       
  1001         //  SNAP is empty or no WLAN was available.
       
  1002         //  Try again with connection selection dialog.
       
  1003         //
       
  1004         MPX_DEBUG(_L("    connection start returned KErrNotFound"));
       
  1005 
       
  1006         TConnPrefList prefList2;
       
  1007         TExtendedConnPref prefs2;
       
  1008 
       
  1009         prefs2.SetConnSelectionDialog( ETrue );
       
  1010         prefList2.AppendL( &prefs2 );
       
  1011 
       
  1012         err = conn.Start( prefList2 );
       
  1013 
       
  1014         if ( err == KErrNone )
       
  1015         {
       
  1016             returnVal = QueryIap( conn );
       
  1017         }
       
  1018         else
       
  1019         {
       
  1020             User::Leave( err );
       
  1021         }
       
  1022     }
       
  1023     else
       
  1024     {
       
  1025         User::Leave( err );
       
  1026     }
       
  1027 
       
  1028     CleanupStack::PopAndDestroy( &conn );
       
  1029 
       
  1030     CleanupStack::PopAndDestroy( &ss );
       
  1031 
       
  1032     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::TryToGetAccessPointL() AP ID: %d"), returnVal);
       
  1033 
       
  1034     return returnVal;
       
  1035 }
       
  1036 
       
  1037 // -------------------------------------------------------------------------------------------------
       
  1038 //   CMpxVideoPlayerAppUiEngine::QueryIap()
       
  1039 // -------------------------------------------------------------------------------------------------
       
  1040 //
       
  1041 TUint32 CMpxVideoPlayerAppUiEngine::QueryIap( RConnection& aConn )
       
  1042 {
       
  1043     TUint32 iap( 0 );
       
  1044     aConn.GetIntSetting( KMpxVideoPlayerQueryIap, iap );
       
  1045     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::QueryIap(%u)"), iap);
       
  1046     return iap;
       
  1047 }
       
  1048 
       
  1049 // -----------------------------------------------------------------------------
       
  1050 //   CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL
       
  1051 // -----------------------------------------------------------------------------
       
  1052 //
       
  1053 void CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL( const TDesC8 &aMsg )
       
  1054 {
       
  1055     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL()"));
       
  1056 
       
  1057     if ( aMsg.Length() < KVideoPlayerActivationMessageMinLength )
       
  1058     {
       
  1059         User::Leave( KErrNotSupported );
       
  1060     }
       
  1061 
       
  1062     TVideoPlayerActivationMessage msgHandler;
       
  1063     TPckg<TVideoPlayerActivationMessage> paramsPckg( msgHandler );
       
  1064     paramsPckg.Copy( aMsg );
       
  1065 
       
  1066     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL() sender = %d, type = %d"),
       
  1067         msgHandler.iMsgSender, msgHandler.iMsgType );
       
  1068 
       
  1069     if ( msgHandler.iMsgSender == TVideoPlayerActivationMessage::EMatrixMenu )
       
  1070     {
       
  1071         // Clear the view history, so app exits back to matrix.
       
  1072         iViewUtility->PushDefaultHistoryL();
       
  1073     }
       
  1074 
       
  1075     if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::EOpenInternetVideos )
       
  1076     {
       
  1077         iViewUtility->ActivateViewL( TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ) );
       
  1078     }
       
  1079     else if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::EOpenVideoStorage )
       
  1080     {
       
  1081         iViewUtility->ActivateViewL( TUid::Uid( KUidMyVideosViewTypeId ) );
       
  1082     }
       
  1083     else if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::ELaunchVideoToPlayer )
       
  1084     {
       
  1085         //
       
  1086         //  Launch video to player, it can be either local video or stream.
       
  1087         //  If there's path and mpx id, clip can be played directly.
       
  1088         //
       
  1089         if ( msgHandler.iServiceId && msgHandler.iFullPath.Length() > 0 )
       
  1090         {
       
  1091             if ( iRecognizer->IdentifyMediaTypeL( msgHandler.iFullPath )
       
  1092                   ==  CMediaRecognizer::ELocalVideoFile )
       
  1093             {
       
  1094                 TMPXItemId id;
       
  1095                 id.iId1 = msgHandler.iServiceId;
       
  1096                 CMPXMedia* media = CMPXMedia::NewL();
       
  1097                 CleanupStack::PushL( media );
       
  1098                 media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, id );
       
  1099                 OpenMediaL( *media );
       
  1100                 CleanupStack::PopAndDestroy( media );
       
  1101             }
       
  1102             else
       
  1103             {
       
  1104                 // Most likely the clip has been deleted
       
  1105                 User::Leave( KErrNotFound );
       
  1106             }
       
  1107         }
       
  1108         else
       
  1109         {
       
  1110             TBool vodUiRunning = ( iViewUtility->ActiveViewType() ==
       
  1111                                    TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ) );
       
  1112 
       
  1113             if ( vodUiRunning )
       
  1114             {
       
  1115                 // VOD is active, must use the utility to pass the message.
       
  1116                 SendCustomCommandToActiveViewL( aMsg );
       
  1117             }
       
  1118             else
       
  1119             {
       
  1120                 // VOD is not running, activate with custom message.
       
  1121                 HBufC* customMsg = HBufC::NewLC( paramsPckg.Length() );
       
  1122                 customMsg->Des().Copy( paramsPckg );
       
  1123                 iViewUtility->ActivateViewL( TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ), customMsg );
       
  1124                 CleanupStack::PopAndDestroy( customMsg );
       
  1125 
       
  1126                 // Clear the view history, so playback returns where it was started
       
  1127                 iViewUtility->PushDefaultHistoryL();
       
  1128             }
       
  1129         }
       
  1130     }
       
  1131     else if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::ELaunchServiceById )
       
  1132     {
       
  1133         if ( iViewUtility->ActiveViewType() == TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ) )
       
  1134         {
       
  1135             // VOD is active, must use the utility to pass the message.
       
  1136             SendCustomCommandToActiveViewL( aMsg );
       
  1137         }
       
  1138         else
       
  1139         {
       
  1140             // VOD is not running, activate with custom message.
       
  1141             HBufC* customMsg = HBufC::NewLC( paramsPckg.Length() );
       
  1142             customMsg->Des().Copy( paramsPckg );
       
  1143             iViewUtility->ActivateViewL( TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ), customMsg );
       
  1144             CleanupStack::PopAndDestroy( customMsg );
       
  1145         }
       
  1146     }
       
  1147 }
       
  1148 
       
  1149 // -----------------------------------------------------------------------------
       
  1150 //   CMpxVideoPlayerAppUiEngine::HandleMessageL()
       
  1151 // -----------------------------------------------------------------------------
       
  1152 //
       
  1153 TBool CMpxVideoPlayerAppUiEngine::HandleMessageL( TUid aMessageUid,
       
  1154                                                   const TDesC8& aMessageParameters )
       
  1155 {
       
  1156     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleMessageL()"));
       
  1157 
       
  1158     TBool msgHandled = EFalse;
       
  1159 
       
  1160     switch ( aMessageUid.iUid )
       
  1161     {
       
  1162         // TVideoPlayerActivationMessage received.
       
  1163         case KVideoPlayerVodStartPlayer:
       
  1164         {
       
  1165             //
       
  1166             //  Do nothing if we are loaded in a playback view
       
  1167             //
       
  1168             if ( iViewUtility->ActiveViewType() != TUid::Uid( KMpxPlaybackPluginTypeUid ) )
       
  1169             {
       
  1170                 ProcessActivationMessageL( aMessageParameters );
       
  1171             }
       
  1172 
       
  1173             msgHandled = ETrue;
       
  1174 
       
  1175             break;
       
  1176         }
       
  1177         case KVideoPlayerStartPDlPlayer:
       
  1178         {
       
  1179             // Start the PDl
       
  1180             if ( iPdlHandler )
       
  1181             {
       
  1182                 CBufFlat* paramBuf = CBufFlat::NewL( 1 );
       
  1183                 CleanupStack::PushL( paramBuf );
       
  1184                 paramBuf->InsertL( 0, aMessageParameters );
       
  1185                 RBufReadStream readStream( *paramBuf );
       
  1186 
       
  1187                 CAiwGenericParamList* genParamList = CAiwGenericParamList::NewLC( readStream );
       
  1188 
       
  1189                 HandleAiwGenericParamListL( genParamList );
       
  1190 
       
  1191                 CleanupStack::PopAndDestroy( genParamList );
       
  1192                 CleanupStack::PopAndDestroy( paramBuf );
       
  1193 
       
  1194                 msgHandled = ETrue;
       
  1195             }
       
  1196 
       
  1197             break;
       
  1198         }
       
  1199     }
       
  1200 
       
  1201     return msgHandled;
       
  1202 }
       
  1203 
       
  1204 // -------------------------------------------------------------------------------------------------
       
  1205 //   CMpxVideoPlayerAppUiEngine::HandleCollectionMessage()
       
  1206 // -------------------------------------------------------------------------------------------------
       
  1207 //
       
  1208 void CMpxVideoPlayerAppUiEngine::HandleCollectionMessage( CMPXMessage* aMessage, TInt aError )
       
  1209 {
       
  1210     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleCollectionMessage()"));
       
  1211 
       
  1212     if ( aError == KErrNone && aMessage )
       
  1213     {
       
  1214         TRAP_IGNORE( DoHandleCollectionMessageL( aMessage ) )
       
  1215     }
       
  1216 }
       
  1217 
       
  1218 // -------------------------------------------------------------------------------------------------
       
  1219 //   CMpxVideoPlayerAppUiEngine::HandleCollectionMediaL()
       
  1220 // -------------------------------------------------------------------------------------------------
       
  1221 //
       
  1222 void CMpxVideoPlayerAppUiEngine::HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError )
       
  1223 {
       
  1224     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleCollectionMediaL()"));
       
  1225 
       
  1226     if ( aError == KErrNone )
       
  1227     {
       
  1228         DoHandleCollectionMediaL( aMedia );
       
  1229     }
       
  1230 }
       
  1231 
       
  1232 // ---------------------------------------------------------------------------
       
  1233 // From MMPXCollectionObserver.
       
  1234 // Handles the collection entries being opened.
       
  1235 // ---------------------------------------------------------------------------
       
  1236 //
       
  1237 void CMpxVideoPlayerAppUiEngine::HandleOpenL( const CMPXMedia& /* aEntries */,
       
  1238                                               TInt /* aIndex */,
       
  1239                                               TBool /* aComplete */,
       
  1240                                               TInt aError )
       
  1241 {
       
  1242     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleOpenL(CMPXMedia)"));
       
  1243 
       
  1244     if ( aError != KErrNone )
       
  1245     {
       
  1246         //
       
  1247         //  Clip the collection path to root level and reopen
       
  1248         //  This could happen after a USB refresh event where the
       
  1249         //  item no longer exists
       
  1250         //
       
  1251         CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
       
  1252 
       
  1253         CleanupStack::PushL( path );
       
  1254 
       
  1255         while( path->Levels() > 1 )
       
  1256         {
       
  1257             path->Back();
       
  1258         }
       
  1259 
       
  1260         iCollectionUtility->Collection().OpenL( *path );
       
  1261         CleanupStack::PopAndDestroy( path );
       
  1262     }
       
  1263 }
       
  1264 
       
  1265 // -------------------------------------------------------------------------------------------------
       
  1266 //   CMpxVideoPlayerAppUiEngine::HandleOpenL()
       
  1267 // -------------------------------------------------------------------------------------------------
       
  1268 //
       
  1269 void CMpxVideoPlayerAppUiEngine::HandleOpenL( const CMPXCollectionPlaylist& aPlaylist, TInt aError )
       
  1270 {
       
  1271     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleOpenL(CMPXCollectionPlaylist)"));
       
  1272 
       
  1273     if ( aError == KErrNone )
       
  1274     {
       
  1275     	InitializePlaylistL( aPlaylist, EFalse );
       
  1276     }
       
  1277 }
       
  1278 
       
  1279 
       
  1280 // ---------------------------------------------------------------------------
       
  1281 // From MMPXCHelperEmbeddedOpenObserver
       
  1282 // Handles OpenL from that occured in embedded mode
       
  1283 // ---------------------------------------------------------------------------
       
  1284 //
       
  1285 void CMpxVideoPlayerAppUiEngine::HandleEmbeddedOpenL( TInt aErr, TMPXGeneralCategory /*aCategory*/ )
       
  1286 {
       
  1287     MPX_DEBUG(_L("CMPXVideoAppUi::HandleEmbeddedOpenL()"));
       
  1288 
       
  1289     if ( aErr == KErrNone )
       
  1290     {
       
  1291         iPlaybackUtility->CommandL( EPbCmdDisableEffect );
       
  1292     }
       
  1293 }
       
  1294 
       
  1295 
       
  1296 void CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()
       
  1297 {
       
  1298     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()"));
       
  1299 
       
  1300     //
       
  1301     //  if we're in top level of our local view stack,
       
  1302     //  back command exits the app.  otherwise activate
       
  1303     //  the previous view in our local view stack
       
  1304     //
       
  1305     if ( iViewUtility->ViewHistoryDepth() <= 1 )
       
  1306     {
       
  1307         iExitToMatrixMenu = EFalse;
       
  1308         ActivateExitActiveObject();
       
  1309     }
       
  1310     else
       
  1311     {
       
  1312         StepBackCollectionPathL();
       
  1313     }
       
  1314 }
       
  1315 
       
  1316 TBool CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL( TApaCommand aCommand,
       
  1317                                                              TFileName& aDocumentName,
       
  1318                                                              const TDesC8& aTail )
       
  1319 {
       
  1320     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL()"));
       
  1321 
       
  1322     TBool retVal = EFalse;
       
  1323 
       
  1324     //
       
  1325     //  If command line has tail, this is probably a message from Matrix, Live TV
       
  1326     //  reminder, Video Center soft notification, or other VC component.
       
  1327     //
       
  1328     if ( aTail.Length() > 0 )
       
  1329     {
       
  1330         ProcessActivationMessageL( aTail );
       
  1331     }
       
  1332     else
       
  1333     {
       
  1334         //
       
  1335         //  If we are embedded or the command is to open a document
       
  1336         //
       
  1337         if ( iAppUi->IsEmbedded() || aCommand != EApaCommandRun )
       
  1338         {
       
  1339             if ( iRecognizer->IsValidStreamingPrefix( aDocumentName ) )
       
  1340             {
       
  1341                 retVal = ETrue;
       
  1342             }
       
  1343             else
       
  1344             {
       
  1345                 retVal = ConeUtils::FileExists( aDocumentName );
       
  1346             }
       
  1347         }
       
  1348         else
       
  1349         {
       
  1350             StartStandAloneL();
       
  1351         }
       
  1352     }
       
  1353 
       
  1354     return retVal;
       
  1355 }
       
  1356 
       
  1357 void CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()
       
  1358 {
       
  1359     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()"));
       
  1360 
       
  1361     if ( ! iExitAo->IsActive() )
       
  1362     {
       
  1363         iExitAo->Start( TCallBack( CMpxVideoPlayerAppUiEngine::ExitApplicationL, this ) );
       
  1364     }
       
  1365 }
       
  1366 
       
  1367 // -----------------------------------------------------------------------------
       
  1368 //   CMpxVideoPlayerAppUiEngine::ExitApplicationL
       
  1369 // -----------------------------------------------------------------------------
       
  1370 //
       
  1371 TInt CMpxVideoPlayerAppUiEngine::ExitApplicationL( TAny* aPtr )
       
  1372 {
       
  1373     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ExitApplicationL()"));
       
  1374 
       
  1375     static_cast<CMpxVideoPlayerAppUiEngine*>(aPtr)->DoExitApplicationL();
       
  1376     return KErrNone;
       
  1377 }
       
  1378 
       
  1379 // -------------------------------------------------------------------------------------------------
       
  1380 //   CMpxVideoPlayerAppUiEngine::DoExitApplicationL
       
  1381 // -------------------------------------------------------------------------------------------------
       
  1382 //
       
  1383 void CMpxVideoPlayerAppUiEngine::DoExitApplicationL()
       
  1384 {
       
  1385     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoExitApplicationL()"));
       
  1386 
       
  1387     iAppUi->HandleCommandL( EEikCmdExit );
       
  1388 }
       
  1389 
       
  1390 // -------------------------------------------------------------------------------------------------
       
  1391 //   CMPXVideoBasePlaybackView::UpdatePbPluginMedia()
       
  1392 // -------------------------------------------------------------------------------------------------
       
  1393 //
       
  1394 void CMpxVideoPlayerAppUiEngine::UpdatePbPluginMediaL()
       
  1395 {
       
  1396     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::UpdatePbPluginMediaL()iSeekable %d"), iSeekable);
       
  1397 
       
  1398     CMPXCommand* cmd = CMPXCommand::NewL();
       
  1399     CleanupStack::PushL( cmd );
       
  1400 
       
  1401     cmd->SetTObjectValueL<TBool>( KMPXCommandGeneralDoSync, ETrue );
       
  1402 
       
  1403     cmd->SetTObjectValueL<TInt>( KMPXCommandGeneralId, KMPXMediaIdVideoPlayback );
       
  1404 
       
  1405     cmd->SetTObjectValueL<TMPXVideoPlaybackCommand>( KMPXMediaVideoPlaybackCommand,
       
  1406                                                      EPbCmdUpdateSeekable );
       
  1407 
       
  1408     cmd->SetTObjectValueL<TBool>( KMPXMediaGeneralExtVideoSeekable, iSeekable );
       
  1409 
       
  1410     iPlaybackUtility->CommandL( *cmd );
       
  1411 
       
  1412     CleanupStack::PopAndDestroy( cmd );
       
  1413 }
       
  1414 
       
  1415 // -------------------------------------------------------------------------------------------------
       
  1416 //   CMPXVideoBasePlaybackView::ViewHistoryDepth()
       
  1417 // -------------------------------------------------------------------------------------------------
       
  1418 //
       
  1419 TInt CMpxVideoPlayerAppUiEngine::ViewHistoryDepth()
       
  1420 {
       
  1421     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ViewHistoryDepth()"));
       
  1422 
       
  1423     return ( iViewUtility->ViewHistoryDepth() );
       
  1424 }
       
  1425 
       
  1426 // -------------------------------------------------------------------------------------------------
       
  1427 //   CMpxVideoPlayerAppUiEngine::SendCustomCommandToActiveViewL()
       
  1428 // -------------------------------------------------------------------------------------------------
       
  1429 //
       
  1430 void CMpxVideoPlayerAppUiEngine::SendCustomCommandToActiveViewL( const TDesC8& aMsg )
       
  1431 {
       
  1432     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::SendCustomCommandToActiveViewL()"));
       
  1433 
       
  1434     User::LeaveIfNull( iAppUi->View() );
       
  1435 
       
  1436     HBufC8* msgBuf = aMsg.AllocLC();
       
  1437 
       
  1438     TAny* ptr = (TAny*) msgBuf;
       
  1439 
       
  1440     UserSvr::DllSetTls( KVcxCustomViewMessagePtr, ptr );
       
  1441 
       
  1442     iAppUi->View()->HandleCommandL( KVcxCustomViewMessageCmd );
       
  1443 
       
  1444     UserSvr::DllFreeTls( KVcxCustomViewMessagePtr );
       
  1445 
       
  1446     CleanupStack::PopAndDestroy( msgBuf );
       
  1447 }
       
  1448 
       
  1449 // -------------------------------------------------------------------------------------------------
       
  1450 //   CMpxVideoPlayerAppUiEngine::ClearPdlInformation()
       
  1451 // -------------------------------------------------------------------------------------------------
       
  1452 //
       
  1453 void CMpxVideoPlayerAppUiEngine::ClearPdlInformation()
       
  1454 {
       
  1455     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ClearPdlInformation()"));
       
  1456 
       
  1457     if ( iPdlHandler )
       
  1458     {
       
  1459         iPdlHandler->ClearPdlInformation();
       
  1460     }
       
  1461 }
       
  1462 
       
  1463 // -------------------------------------------------------------------------------------------------
       
  1464 //   CMpxVideoPlayerAppUiEngine::StartedStandAlone()
       
  1465 // -------------------------------------------------------------------------------------------------
       
  1466 //
       
  1467 TBool CMpxVideoPlayerAppUiEngine::ExitToMatrixMenu()
       
  1468 {
       
  1469     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ExitToMatrixMenu(%d)"), iExitToMatrixMenu);
       
  1470     return iExitToMatrixMenu;
       
  1471 }
       
  1472 
       
  1473 // -------------------------------------------------------------------------------------------------
       
  1474 //   CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL()
       
  1475 // -------------------------------------------------------------------------------------------------
       
  1476 //
       
  1477 void CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL( const TDesC& aUri )
       
  1478 {
       
  1479     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL()"),
       
  1480     		       _L("aUri = %S"), &aUri );
       
  1481 
       
  1482     SetAccessPointL();
       
  1483 
       
  1484 	iPlaybackUtility->InitStreamingL( aUri,
       
  1485 									  (TDesC8*)(&KDATATYPEVIDEOHELIX),
       
  1486 									  iAccessPointId );
       
  1487 
       
  1488     ActivatePlaybackViewL();
       
  1489 }
       
  1490 
       
  1491 // -------------------------------------------------------------------------------------------------
       
  1492 //   CMpxVideoPlayerAppUiEngine::InitializeFileL()
       
  1493 // -------------------------------------------------------------------------------------------------
       
  1494 //
       
  1495 void CMpxVideoPlayerAppUiEngine::InitializeFileL( const TDesC& aFileName )
       
  1496 {
       
  1497     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::InitializeFileL()"),
       
  1498     		       _L("aFileName = %S"), &aFileName );
       
  1499 
       
  1500 	iPlaybackUtility->InitL( aFileName );
       
  1501 
       
  1502     ActivatePlaybackViewL();
       
  1503 }
       
  1504 
       
  1505 // -------------------------------------------------------------------------------------------------
       
  1506 //   CMpxVideoPlayerAppUiEngine::InitializePlaylistL()
       
  1507 // -------------------------------------------------------------------------------------------------
       
  1508 //
       
  1509 void CMpxVideoPlayerAppUiEngine::InitializePlaylistL( const CMPXCollectionPlaylist& aPlaylist,
       
  1510                                                       TBool aPlay )
       
  1511 {
       
  1512     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::InitializePlaylistL()"));
       
  1513 
       
  1514 	iPlaybackUtility->InitL( aPlaylist, aPlay );
       
  1515 
       
  1516     ActivatePlaybackViewL();
       
  1517 }
       
  1518 
       
  1519 
       
  1520 // EOF