videoplayerapp/mpxvideoplayer/src/mpxvideoplayerappuiengine.cpp
branchRCL_3
changeset 8 ce5ada96ab30
parent 6 7d91903f795f
child 9 5294c000a26d
equal deleted inserted replaced
6:7d91903f795f 8:ce5ada96ab30
    13 *
    13 *
    14 * Description:  AppUI engine implementation
    14 * Description:  AppUI engine implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: da1mmcf#61 %
    18 // Version : %version: e92_66 %
    19 
    19 
    20 
    20 
    21 #include <eikon.hrh>
    21 #include <eikon.hrh>
    22 #include <avkon.hrh>
    22 #include <avkon.hrh>
    23 #include <aknview.h>
    23 #include <aknview.h>
    37 #include <AiwGenericParam.h>
    37 #include <AiwGenericParam.h>
    38 #include <mpxcollectionuihelper.h>
    38 #include <mpxcollectionuihelper.h>
    39 #include <mpxcollectionhelperfactory.h>
    39 #include <mpxcollectionhelperfactory.h>
    40 #include <mpxcollectionplugin.hrh>
    40 #include <mpxcollectionplugin.hrh>
    41 #include <mpxmediageneralextdefs.h>
    41 #include <mpxmediageneralextdefs.h>
    42 
       
    43 #include <streaminglinkmodel.h>
    42 #include <streaminglinkmodel.h>
    44 #include <mpsettingsmodel.h>
       
    45 #include <coeutils.h>
    43 #include <coeutils.h>
    46 #include <videoplaylistutility.h>
    44 #include <videoplaylistutility.h>
    47 #include <cmmanagerext.h>
    45 #include <mmf/common/mmfcontrollerframeworkbase.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 
    46 
    55 #include "mpxvideoplayerappuiengine.h"
    47 #include "mpxvideoplayerappuiengine.h"
    56 #include "mpxvideoplayerlogger.h"
    48 #include "mpxvideoplayerlogger.h"
    57 #include "mpxvideoplayerconstants.h"
    49 #include "mpxvideoplayerconstants.h"
    58 #include "mpxvideoembeddedpdlhandler.h"
    50 #include "mpxvideoembeddedpdlhandler.h"
    59 #include <mpxvideoplaybackdefs.h>
    51 #include <mpxvideoplaybackdefs.h>
    60 #include "mpxvideo_debug.h"
    52 #include "mpxvideo_debug.h"
    61 #include "mpxvideoplayercustomviewmsgconsts.h"
    53 #include "mpxvideoplayercustomviewmsgconsts.h"
    62 
    54 
    63 _LIT( KMpxVideoPlayerQueryIap, "IAP\\Id" );
       
    64 
       
    65 const TInt KMpxPlaybackPluginTypeUid = 0x101FFCA0;
    55 const TInt KMpxPlaybackPluginTypeUid = 0x101FFCA0;
    66 
    56 
    67 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    68 //   CMpxVideoPlayerAppUiEngine::CMpxVideoPlayerAppUiEngine
    58 //   CMpxVideoPlayerAppUiEngine::CMpxVideoPlayerAppUiEngine
    69 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    73       iPlaybackUtility( NULL ),
    63       iPlaybackUtility( NULL ),
    74       iViewUtility( NULL ),
    64       iViewUtility( NULL ),
    75       iCollectionUtility( NULL ),
    65       iCollectionUtility( NULL ),
    76       iExitAo( NULL ),
    66       iExitAo( NULL ),
    77       iRecognizer( NULL ),
    67       iRecognizer( NULL ),
    78       iExtAccessPointId( KErrUnknown ),
    68       iAccessPointId( KUseDefaultIap ),
    79       iMultilinkPlaylist(EFalse),
    69       iMultilinkPlaylist(EFalse),
    80       iSeekable(ETrue),
    70       iSeekable(ETrue),
    81       iUpdateSeekInfo(EFalse),
    71       iUpdateSeekInfo(EFalse)
    82       iExitToMatrixMenu(ETrue)
       
    83 {
    72 {
    84 }
    73 }
    85 
    74 
    86 // -----------------------------------------------------------------------------
    75 // -----------------------------------------------------------------------------
    87 //   CMpxVideoPlayerAppUiEngine::NewL
    76 //   CMpxVideoPlayerAppUiEngine::NewL
   233         iViewUtility->Close();
   222         iViewUtility->Close();
   234     }
   223     }
   235 
   224 
   236     if ( iPlaybackUtility )
   225     if ( iPlaybackUtility )
   237     {
   226     {
   238         TRAP_IGNORE( iPlaybackUtility->CommandL( EPbCmdClose ) );
   227         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   228         TRAP_IGNORE( manager.ClearSelectPlayersL() );
   239         iPlaybackUtility->Close();
   229         iPlaybackUtility->Close();
   240     }
   230     }
   241 }
   231 }
   242 
   232 
   243 // ---------------------------------------------------------------------------
   233 // ---------------------------------------------------------------------------
   333 
   323 
   334             if ( index >= 0 && genParamAccessPoint )
   324             if ( index >= 0 && genParamAccessPoint )
   335             {
   325             {
   336                 TInt32 apId = KErrUnknown;
   326                 TInt32 apId = KErrUnknown;
   337                 genParamAccessPoint->Value().Get( apId );
   327                 genParamAccessPoint->Value().Get( apId );
   338                 iExtAccessPointId = apId;
   328                 iAccessPointId = apId;
   339             }
   329             }
   340         }
   330         }
   341     }
   331     }
   342 
   332 
   343     return retVal;
   333     return retVal;
   375         {
   365         {
   376             HandleMultiLinksFileL( aFile, mediaType );
   366             HandleMultiLinksFileL( aFile, mediaType );
   377         }
   367         }
   378         else if ( mediaType == CMediaRecognizer::ELocalSdpFile )
   368         else if ( mediaType == CMediaRecognizer::ELocalSdpFile )
   379         {
   369         {
   380             SetAccessPointL();
       
   381             iPlaybackUtility->InitStreamingL( aFile, iAccessPointId );
   370             iPlaybackUtility->InitStreamingL( aFile, iAccessPointId );
   382             ActivatePlaybackViewL();
   371             ActivatePlaybackViewL();
   383         }
   372         }
   384         else
   373         else
   385         {
   374         {
   513 
   502 
   514     CleanupStack::PopAndDestroy( &array );
   503     CleanupStack::PopAndDestroy( &array );
   515 }
   504 }
   516 
   505 
   517 // ---------------------------------------------------------------------------
   506 // ---------------------------------------------------------------------------
   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         ClosePlaybackPluginL();
       
   528 
       
   529         MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
       
   530         TRAP_IGNORE( manager.ClearSelectPlayersL() );
       
   531     }
       
   532 }
       
   533 
       
   534 // ---------------------------------------------------------------------------
       
   535 // Sets AppUiEngine in stand alone "mode"
   507 // Sets AppUiEngine in stand alone "mode"
   536 // ---------------------------------------------------------------------------
   508 // ---------------------------------------------------------------------------
   537 //
   509 //
   538 void CMpxVideoPlayerAppUiEngine::StartStandAloneL()
   510 void CMpxVideoPlayerAppUiEngine::StartStandAloneL()
   539 {
   511 {
   540     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::StartStandAloneL()"));
   512     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::StartStandAloneL()"));
   541 
       
   542     iExitToMatrixMenu = EFalse;
       
   543 
   513 
   544     //
   514     //
   545     //  Create the utilities for the stand alone player
   515     //  Create the utilities for the stand alone player
   546     //
   516     //
   547     CreatePlaybackUtilityMemberVariablesL();
   517     CreatePlaybackUtilityMemberVariablesL();
   739     DoHandleMultiLinksFileL( playlistUtil, singleLink, localFile );
   709     DoHandleMultiLinksFileL( playlistUtil, singleLink, localFile );
   740 
   710 
   741     CleanupStack::PopAndDestroy( playlistUtil );
   711     CleanupStack::PopAndDestroy( playlistUtil );
   742 }
   712 }
   743 
   713 
   744 
   714 // -------------------------------------------------------------------------------------------------
       
   715 //   CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL()
       
   716 // -------------------------------------------------------------------------------------------------
       
   717 //
   745 void CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL( CVideoPlaylistUtility* aPlaylistUtil,
   718 void CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL( CVideoPlaylistUtility* aPlaylistUtil,
   746                                                           TBool aSingleLink,
   719                                                           TBool aSingleLink,
   747                                                           TBool aLocalFile )
   720                                                           TBool aLocalFile )
   748 {
   721 {
   749     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL()"),
   722     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::DoHandleMultiLinksFileL()"),
   775         }
   748         }
   776         CleanupStack::PopAndDestroy();  // link
   749         CleanupStack::PopAndDestroy();  // link
   777     }
   750     }
   778     else
   751     else
   779     {
   752     {
   780         if ( ! aLocalFile )
       
   781         {
       
   782             SetAccessPointL();
       
   783         }
       
   784 
       
   785         CMPXMedia* playlist = aPlaylistUtil->GetPlayListL( iAccessPointId );
   753         CMPXMedia* playlist = aPlaylistUtil->GetPlayListL( iAccessPointId );
   786         CleanupStack::PushL( playlist );
   754         CleanupStack::PushL( playlist );
   787 
   755 
   788         //  Create FW utility member variables for playlist embedded use case
   756         //  Create FW utility member variables for playlist embedded use case
   789         CreateCollectionUtilityMemberVariablesL();
   757         CreateCollectionUtilityMemberVariablesL();
   799 
   767 
   800         CleanupStack::PopAndDestroy( playlist );
   768         CleanupStack::PopAndDestroy( playlist );
   801     }
   769     }
   802 }
   770 }
   803 
   771 
   804 // -------------------------------------------------------------------------------------------------
       
   805 //   CMpxVideoPlayerAppUiEngine::SetAccessPointL
       
   806 // -------------------------------------------------------------------------------------------------
       
   807 //
       
   808 void CMpxVideoPlayerAppUiEngine::SetAccessPointL()
       
   809 {
       
   810     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::SetAccessPointL()"));
       
   811 
       
   812     //
       
   813     //  a value was passed in for argument aAPId
       
   814     //
       
   815     if ( ( iExtAccessPointId != KErrUnknown ) && IsWLANAccessPointL( iExtAccessPointId ) )
       
   816     {
       
   817         //
       
   818         //  An external WLAN access point was passed in by an embedding app, use it
       
   819         //
       
   820         iAccessPointId = iExtAccessPointId;
       
   821     }
       
   822     else
       
   823     {
       
   824         //
       
   825         //  No access point was passed in or it's not WLAN, retrieve the default access point
       
   826         //
       
   827         TInt defaultAPId(0);
       
   828 
       
   829         MPX_TRAPD( err, defaultAPId = GetDefaultAccessPointL() );
       
   830 
       
   831         if ( ( err == KErrNone ) && ( defaultAPId != 0 ))
       
   832         {
       
   833             //
       
   834             //  Use the default access point
       
   835             //
       
   836             iAccessPointId = defaultAPId;
       
   837         }
       
   838         else
       
   839         {
       
   840             //
       
   841             //  Valid default access point was not found
       
   842             //
       
   843             if ( iExtAccessPointId != KErrUnknown )
       
   844             {
       
   845                 //
       
   846                 //  Use the AP passed in by embedding app, regardless of bearer type
       
   847                 //
       
   848                 iAccessPointId = iExtAccessPointId;
       
   849             }
       
   850             else
       
   851             {
       
   852                 //
       
   853                 //  Try to fetch AP ID and open connection selection dialog if required
       
   854                 //
       
   855                 TUint32 apUid = TryToGetAccessPointL();
       
   856 
       
   857                 //
       
   858                 //  Use selected access point
       
   859                 //
       
   860                 if ( apUid != 0 )
       
   861                 {
       
   862                     //
       
   863                     //  convert the AccessPoint-Uid to AccessPoint-Id
       
   864                     //
       
   865                     iAccessPointId = GetAccessPointIdForUIDL( apUid );
       
   866                 }
       
   867             }
       
   868         }
       
   869     }
       
   870 }
       
   871 
       
   872 // -------------------------------------------------------------------------------------------------
       
   873 //   CMpxVideoPlayerAppUiEngine::IsWLANAccessPointL
       
   874 // -------------------------------------------------------------------------------------------------
       
   875 //
       
   876 TBool CMpxVideoPlayerAppUiEngine::IsWLANAccessPointL( TInt aAPId )
       
   877 {
       
   878     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::IsWLANAccessPointL(%d)"), aAPId);
       
   879 
       
   880     TBool wlanAP(EFalse);
       
   881     TUint32 bearer( 0 );
       
   882 
       
   883     RCmManagerExt cmManager;
       
   884     CleanupClosePushL( cmManager );
       
   885     cmManager.OpenL();
       
   886 
       
   887     bearer = cmManager.ConnectionMethodL( aAPId ).GetIntAttributeL( CMManager::ECmBearerType );
       
   888     CleanupStack::PopAndDestroy( &cmManager );
       
   889 
       
   890     if ( bearer == KUidWlanBearerType )
       
   891     {
       
   892         wlanAP = ETrue;
       
   893     }
       
   894 
       
   895     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::IsWLANAccessPointL() return %d"), wlanAP);
       
   896 
       
   897     return wlanAP;
       
   898 }
       
   899 
       
   900 // -----------------------------------------------------------------------------
       
   901 //   CMpxVideoPlayerAppUiEngine::GetDefaultAccessPointL
       
   902 // -----------------------------------------------------------------------------
       
   903 //
       
   904 TInt CMpxVideoPlayerAppUiEngine::GetDefaultAccessPointL()
       
   905 {
       
   906     TInt defaultAP(0);
       
   907     TUint32 iap;
       
   908 
       
   909     CMPSettingsModel* ropSettings = CMPSettingsModel::NewL( KSettingsModelForROPUid );
       
   910 
       
   911     CleanupStack::PushL( ropSettings );
       
   912 
       
   913     ropSettings->LoadSettingsL( EConfigDefault );
       
   914 
       
   915     User::LeaveIfError( ropSettings->GetDefaultAp( iap ) );
       
   916 
       
   917     CleanupStack::PopAndDestroy(); // ropSettings
       
   918 
       
   919     defaultAP = GetAccessPointIdForUIDL( iap );
       
   920 
       
   921     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::GetDefaultAccessPointL(%d)"), defaultAP);
       
   922 
       
   923     return defaultAP;
       
   924 }
       
   925 
       
   926 // -----------------------------------------------------------------------------
       
   927 //   CMpxVideoPlayerAppUiEngine::GetAccessPointIdForUIDL
       
   928 // -----------------------------------------------------------------------------
       
   929 //
       
   930 TInt CMpxVideoPlayerAppUiEngine::GetAccessPointIdForUIDL( TUint32 aAPUid )
       
   931 {
       
   932     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::GetAccessPointIdForUIDL()"),
       
   933                    _L(" aAPUid = %d"), aAPUid);
       
   934 
       
   935     TInt apId(0);
       
   936 
       
   937     CMDBSession* db = CMDBSession::NewL( CMDBSession::LatestVersion() );
       
   938     CleanupStack::PushL( db );
       
   939 
       
   940     //
       
   941     //  WapIpBearer table contains the mapping between wap and iap id's.
       
   942     //
       
   943     CCDWAPIPBearerRecord* wapBearerRecord =
       
   944         static_cast<CCDWAPIPBearerRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdWAPIPBearerRecord));
       
   945 
       
   946     CleanupStack::PushL( wapBearerRecord );
       
   947 
       
   948     wapBearerRecord->iWAPAccessPointId = aAPUid;
       
   949 
       
   950     TBool found = wapBearerRecord->FindL( *db );
       
   951 
       
   952     if ( ! found )
       
   953     {
       
   954         User::Leave( KErrNotFound );
       
   955     }
       
   956 
       
   957     apId = static_cast<TUint32>( wapBearerRecord->iWAPIAP );
       
   958 
       
   959     CleanupStack::PopAndDestroy( wapBearerRecord );
       
   960     CleanupStack::PopAndDestroy( db );
       
   961 
       
   962     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::GetAccessPointIdForUIDL(%d)"), apId);
       
   963 
       
   964     return apId;
       
   965 }
       
   966 
       
   967 // -----------------------------------------------------------------------------
       
   968 //   CMpxVideoPlayerAppUiEngine::TryToGetAccessPointL
       
   969 // -----------------------------------------------------------------------------
       
   970 //
       
   971 TUint32 CMpxVideoPlayerAppUiEngine::TryToGetAccessPointL()
       
   972 {
       
   973     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::TryToGetAccessPointL()"));
       
   974 
       
   975     TUint32 returnVal(0);
       
   976 
       
   977     RSocketServ ss;
       
   978     CleanupClosePushL( ss );
       
   979 
       
   980     User::LeaveIfError( ss.Connect() );
       
   981 
       
   982     RConnection conn;
       
   983     CleanupClosePushL( conn );
       
   984 
       
   985     User::LeaveIfError( conn.Open( ss ) );
       
   986 
       
   987     TConnPrefList prefList;
       
   988     TExtendedConnPref prefs;
       
   989     prefs.SetSnapPurpose( CMManager::ESnapPurposeInternet  );
       
   990     prefs.SetNoteBehaviour( TExtendedConnPref::ENoteBehaviourConnSilent );
       
   991     prefList.AppendL( &prefs );
       
   992 
       
   993     TInt err = conn.Start( prefList );
       
   994 
       
   995     if ( err == KErrNone )
       
   996     {
       
   997         returnVal = QueryIap( conn );
       
   998     }
       
   999     else if ( err == KErrNotFound )
       
  1000     {
       
  1001         //
       
  1002         //  SNAP is empty or no WLAN was available.
       
  1003         //  Try again with connection selection dialog.
       
  1004         //
       
  1005         MPX_DEBUG(_L("    connection start returned KErrNotFound"));
       
  1006 
       
  1007         TConnPrefList prefList2;
       
  1008         TExtendedConnPref prefs2;
       
  1009 
       
  1010         prefs2.SetConnSelectionDialog( ETrue );
       
  1011         prefList2.AppendL( &prefs2 );
       
  1012 
       
  1013         err = conn.Start( prefList2 );
       
  1014 
       
  1015         if ( err == KErrNone )
       
  1016         {
       
  1017             returnVal = QueryIap( conn );
       
  1018         }
       
  1019         else
       
  1020         {
       
  1021             User::Leave( err );
       
  1022         }
       
  1023     }
       
  1024     else
       
  1025     {
       
  1026         User::Leave( err );
       
  1027     }
       
  1028 
       
  1029     CleanupStack::PopAndDestroy( &conn );
       
  1030 
       
  1031     CleanupStack::PopAndDestroy( &ss );
       
  1032 
       
  1033     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::TryToGetAccessPointL() AP ID: %d"), returnVal);
       
  1034 
       
  1035     return returnVal;
       
  1036 }
       
  1037 
       
  1038 // -------------------------------------------------------------------------------------------------
       
  1039 //   CMpxVideoPlayerAppUiEngine::QueryIap()
       
  1040 // -------------------------------------------------------------------------------------------------
       
  1041 //
       
  1042 TUint32 CMpxVideoPlayerAppUiEngine::QueryIap( RConnection& aConn )
       
  1043 {
       
  1044     TUint32 iap( 0 );
       
  1045     aConn.GetIntSetting( KMpxVideoPlayerQueryIap, iap );
       
  1046     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::QueryIap(%u)"), iap);
       
  1047     return iap;
       
  1048 }
       
  1049 
       
  1050 // -----------------------------------------------------------------------------
       
  1051 //   CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL
       
  1052 // -----------------------------------------------------------------------------
       
  1053 //
       
  1054 void CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL( const TDesC8 &aMsg )
       
  1055 {
       
  1056     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL()"));
       
  1057 
       
  1058     if ( aMsg.Length() < KVideoPlayerActivationMessageMinLength )
       
  1059     {
       
  1060         User::Leave( KErrNotSupported );
       
  1061     }
       
  1062 
       
  1063     TVideoPlayerActivationMessage msgHandler;
       
  1064     TPckg<TVideoPlayerActivationMessage> paramsPckg( msgHandler );
       
  1065     paramsPckg.Copy( aMsg );
       
  1066 
       
  1067     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ProcessActivationMessageL() sender = %d, type = %d"),
       
  1068         msgHandler.iMsgSender, msgHandler.iMsgType );
       
  1069 
       
  1070     if ( msgHandler.iMsgSender == TVideoPlayerActivationMessage::EMatrixMenu )
       
  1071     {
       
  1072         // Clear the view history, so app exits back to matrix.
       
  1073         iViewUtility->PushDefaultHistoryL();
       
  1074     }
       
  1075 
       
  1076     if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::EOpenInternetVideos )
       
  1077     {
       
  1078         iViewUtility->ActivateViewL( TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ) );
       
  1079     }
       
  1080     else if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::EOpenVideoStorage )
       
  1081     {
       
  1082         iViewUtility->ActivateViewL( TUid::Uid( KUidMyVideosViewTypeId ) );
       
  1083     }
       
  1084     else if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::ELaunchVideoToPlayer )
       
  1085     {
       
  1086         //
       
  1087         //  Launch video to player, it can be either local video or stream.
       
  1088         //  If there's path and mpx id, clip can be played directly.
       
  1089         //
       
  1090         if ( msgHandler.iServiceId && msgHandler.iFullPath.Length() > 0 )
       
  1091         {
       
  1092             if ( iRecognizer->IdentifyMediaTypeL( msgHandler.iFullPath )
       
  1093                   ==  CMediaRecognizer::ELocalVideoFile )
       
  1094             {
       
  1095                 TMPXItemId id;
       
  1096                 id.iId1 = msgHandler.iServiceId;
       
  1097                 CMPXMedia* media = CMPXMedia::NewL();
       
  1098                 CleanupStack::PushL( media );
       
  1099                 media->SetTObjectValueL<TMPXItemId>( KMPXMediaGeneralId, id );
       
  1100                 OpenMediaL( *media );
       
  1101                 CleanupStack::PopAndDestroy( media );
       
  1102             }
       
  1103             else
       
  1104             {
       
  1105                 // Most likely the clip has been deleted
       
  1106                 User::Leave( KErrNotFound );
       
  1107             }
       
  1108         }
       
  1109         else
       
  1110         {
       
  1111             TBool vodUiRunning = ( iViewUtility->ActiveViewType() ==
       
  1112                                    TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ) );
       
  1113 
       
  1114             if ( vodUiRunning )
       
  1115             {
       
  1116                 // VOD is active, must use the utility to pass the message.
       
  1117                 SendCustomCommandToActiveViewL( aMsg );
       
  1118             }
       
  1119             else
       
  1120             {
       
  1121                 // VOD is not running, activate with custom message.
       
  1122                 HBufC* customMsg = HBufC::NewLC( paramsPckg.Length() );
       
  1123                 customMsg->Des().Copy( paramsPckg );
       
  1124                 iViewUtility->ActivateViewL( TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ), customMsg );
       
  1125                 CleanupStack::PopAndDestroy( customMsg );
       
  1126 
       
  1127                 // Clear the view history, so playback returns where it was started
       
  1128                 iViewUtility->PushDefaultHistoryL();
       
  1129             }
       
  1130         }
       
  1131     }
       
  1132     else if ( msgHandler.iMsgType == TVideoPlayerActivationMessage::ELaunchServiceById )
       
  1133     {
       
  1134         if ( iViewUtility->ActiveViewType() == TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ) )
       
  1135         {
       
  1136             // VOD is active, must use the utility to pass the message.
       
  1137             SendCustomCommandToActiveViewL( aMsg );
       
  1138         }
       
  1139         else
       
  1140         {
       
  1141             // VOD is not running, activate with custom message.
       
  1142             HBufC* customMsg = HBufC::NewLC( paramsPckg.Length() );
       
  1143             customMsg->Des().Copy( paramsPckg );
       
  1144             iViewUtility->ActivateViewL( TUid::Uid( KMpxVideoPlayerVodViewPluginTypeId ), customMsg );
       
  1145             CleanupStack::PopAndDestroy( customMsg );
       
  1146         }
       
  1147     }
       
  1148 }
       
  1149 
   772 
  1150 // -----------------------------------------------------------------------------
   773 // -----------------------------------------------------------------------------
  1151 //   CMpxVideoPlayerAppUiEngine::HandleMessageL()
   774 //   CMpxVideoPlayerAppUiEngine::HandleMessageL()
  1152 // -----------------------------------------------------------------------------
   775 // -----------------------------------------------------------------------------
  1153 //
   776 //
  1161     switch ( aMessageUid.iUid )
   784     switch ( aMessageUid.iUid )
  1162     {
   785     {
  1163         // TVideoPlayerActivationMessage received.
   786         // TVideoPlayerActivationMessage received.
  1164         case KVideoPlayerVodStartPlayer:
   787         case KVideoPlayerVodStartPlayer:
  1165         {
   788         {
  1166             //
   789             //  Do nothing
  1167             //  Do nothing if we are loaded in a playback view
       
  1168             //
       
  1169             if ( iViewUtility->ActiveViewType() != TUid::Uid( KMpxPlaybackPluginTypeUid ) )
       
  1170             {
       
  1171                 ProcessActivationMessageL( aMessageParameters );
       
  1172             }
       
  1173 
       
  1174             msgHandled = ETrue;
       
  1175 
       
  1176             break;
   790             break;
  1177         }
   791         }
  1178         case KVideoPlayerStartPDlPlayer:
   792         case KVideoPlayerStartPDlPlayer:
  1179         {
   793         {
  1180             // Start the PDl
   794             // Start the PDl
  1292         iPlaybackUtility->CommandL( EPbCmdDisableEffect );
   906         iPlaybackUtility->CommandL( EPbCmdDisableEffect );
  1293     }
   907     }
  1294 }
   908 }
  1295 
   909 
  1296 
   910 
       
   911 // -----------------------------------------------------------------------------
       
   912 // 
       
   913 // -----------------------------------------------------------------------------
       
   914 //
  1297 void CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()
   915 void CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()
  1298 {
   916 {
  1299     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()"));
   917     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::HandleSoftKeyBackL()"));
  1300 
   918 
  1301     //
   919     //
  1303     //  back command exits the app.  otherwise activate
   921     //  back command exits the app.  otherwise activate
  1304     //  the previous view in our local view stack
   922     //  the previous view in our local view stack
  1305     //
   923     //
  1306     if ( iViewUtility->ViewHistoryDepth() <= 1 )
   924     if ( iViewUtility->ViewHistoryDepth() <= 1 )
  1307     {
   925     {
  1308         iExitToMatrixMenu = EFalse;
       
  1309         ActivateExitActiveObject();
   926         ActivateExitActiveObject();
  1310     }
   927     }
  1311     else
   928     else
  1312     {
   929     {
  1313         StepBackCollectionPathL();
   930         StepBackCollectionPathL();
  1314     }
   931     }
  1315 }
   932 }
  1316 
   933 
       
   934 // -----------------------------------------------------------------------------
       
   935 // 
       
   936 // -----------------------------------------------------------------------------
       
   937 //
  1317 TBool CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL( TApaCommand aCommand,
   938 TBool CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL( TApaCommand aCommand,
  1318                                                              TFileName& aDocumentName,
   939                                                              TFileName& aDocumentName,
  1319                                                              const TDesC8& aTail )
   940                                                              const TDesC8& aTail )
  1320 {
   941 {
  1321     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL()"));
   942     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ProcessCommandParametersL()"));
  1322 
   943 
  1323     TBool retVal = EFalse;
   944     TBool retVal = EFalse;
  1324 
   945 
  1325     //
   946     //
  1326     //  If command line has tail, this is probably a message from Matrix, Live TV
   947     //  If we are embedded or the command is to open a document
  1327     //  reminder, Video Center soft notification, or other VC component.
   948     //
  1328     //
   949     if ( iAppUi->IsEmbedded() || aCommand != EApaCommandRun )
  1329     if ( aTail.Length() > 0 )
   950     {
  1330     {
   951         if ( iRecognizer->IsValidStreamingPrefix( aDocumentName ) )
  1331         ProcessActivationMessageL( aTail );
   952         {
       
   953             retVal = ETrue;
       
   954         }
       
   955         else
       
   956         {
       
   957             retVal = ConeUtils::FileExists( aDocumentName );
       
   958         }
  1332     }
   959     }
  1333     else
   960     else
  1334     {
   961     {
  1335         //
   962         StartStandAloneL();
  1336         //  If we are embedded or the command is to open a document
       
  1337         //
       
  1338         if ( iAppUi->IsEmbedded() || aCommand != EApaCommandRun )
       
  1339         {
       
  1340             if ( iRecognizer->IsValidStreamingPrefix( aDocumentName ) )
       
  1341             {
       
  1342                 retVal = ETrue;
       
  1343             }
       
  1344             else
       
  1345             {
       
  1346                 retVal = ConeUtils::FileExists( aDocumentName );
       
  1347             }
       
  1348         }
       
  1349         else
       
  1350         {
       
  1351             StartStandAloneL();
       
  1352         }
       
  1353     }
   963     }
  1354 
   964 
  1355     return retVal;
   965     return retVal;
  1356 }
   966 }
  1357 
   967 
       
   968 // -----------------------------------------------------------------------------
       
   969 // 
       
   970 // -----------------------------------------------------------------------------
       
   971 //
  1358 void CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()
   972 void CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()
  1359 {
   973 {
  1360     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()"));
   974     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::ActivateExitActiveObject()"));
  1361 
   975 
  1362     if ( ! iExitAo->IsActive() )
   976     if ( ! iExitAo->IsActive() )
  1363     {
   977     {
  1364         iExitAo->Start( TCallBack( CMpxVideoPlayerAppUiEngine::ExitApplicationL, this ) );
   978         iExitAo->Start( TCallBack( CMpxVideoPlayerAppUiEngine::ExitApplicationL, this ) );
  1365     }
   979     }
  1366 }
   980 }
  1367 
   981 
  1368 // -----------------------------------------------------------------------------
   982 // -------------------------------------------------------------------------------------------------
  1369 //   CMpxVideoPlayerAppUiEngine::ExitApplicationL
   983 //   CMpxVideoPlayerAppUiEngine::ExitApplicationL
  1370 // -----------------------------------------------------------------------------
   984 // -------------------------------------------------------------------------------------------------
  1371 //
   985 //
  1372 TInt CMpxVideoPlayerAppUiEngine::ExitApplicationL( TAny* aPtr )
   986 TInt CMpxVideoPlayerAppUiEngine::ExitApplicationL( TAny* aPtr )
  1373 {
   987 {
  1374     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ExitApplicationL()"));
   988     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ExitApplicationL()"));
  1375 
   989 
  1423 
  1037 
  1424     return ( iViewUtility->ViewHistoryDepth() );
  1038     return ( iViewUtility->ViewHistoryDepth() );
  1425 }
  1039 }
  1426 
  1040 
  1427 // -------------------------------------------------------------------------------------------------
  1041 // -------------------------------------------------------------------------------------------------
  1428 //   CMpxVideoPlayerAppUiEngine::SendCustomCommandToActiveViewL()
       
  1429 // -------------------------------------------------------------------------------------------------
       
  1430 //
       
  1431 void CMpxVideoPlayerAppUiEngine::SendCustomCommandToActiveViewL( const TDesC8& aMsg )
       
  1432 {
       
  1433     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::SendCustomCommandToActiveViewL()"));
       
  1434 
       
  1435     User::LeaveIfNull( iAppUi->View() );
       
  1436 
       
  1437     HBufC8* msgBuf = aMsg.AllocLC();
       
  1438 
       
  1439     TAny* ptr = (TAny*) msgBuf;
       
  1440 
       
  1441     UserSvr::DllSetTls( KVcxCustomViewMessagePtr, ptr );
       
  1442 
       
  1443     iAppUi->View()->HandleCommandL( KVcxCustomViewMessageCmd );
       
  1444 
       
  1445     UserSvr::DllFreeTls( KVcxCustomViewMessagePtr );
       
  1446 
       
  1447     CleanupStack::PopAndDestroy( msgBuf );
       
  1448 }
       
  1449 
       
  1450 // -------------------------------------------------------------------------------------------------
       
  1451 //   CMpxVideoPlayerAppUiEngine::ClearPdlInformation()
  1042 //   CMpxVideoPlayerAppUiEngine::ClearPdlInformation()
  1452 // -------------------------------------------------------------------------------------------------
  1043 // -------------------------------------------------------------------------------------------------
  1453 //
  1044 //
  1454 void CMpxVideoPlayerAppUiEngine::ClearPdlInformation()
  1045 void CMpxVideoPlayerAppUiEngine::ClearPdlInformation()
  1455 {
  1046 {
  1457 
  1048 
  1458     if ( iPdlHandler )
  1049     if ( iPdlHandler )
  1459     {
  1050     {
  1460         iPdlHandler->ClearPdlInformation();
  1051         iPdlHandler->ClearPdlInformation();
  1461     }
  1052     }
  1462 }
       
  1463 
       
  1464 // -------------------------------------------------------------------------------------------------
       
  1465 //   CMpxVideoPlayerAppUiEngine::StartedStandAlone()
       
  1466 // -------------------------------------------------------------------------------------------------
       
  1467 //
       
  1468 TBool CMpxVideoPlayerAppUiEngine::ExitToMatrixMenu()
       
  1469 {
       
  1470     MPX_DEBUG(_L("CMpxVideoPlayerAppUiEngine::ExitToMatrixMenu(%d)"), iExitToMatrixMenu);
       
  1471     return iExitToMatrixMenu;
       
  1472 }
  1053 }
  1473 
  1054 
  1474 // -------------------------------------------------------------------------------------------------
  1055 // -------------------------------------------------------------------------------------------------
  1475 //   CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL()
  1056 //   CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL()
  1476 // -------------------------------------------------------------------------------------------------
  1057 // -------------------------------------------------------------------------------------------------
  1477 //
  1058 //
  1478 void CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL( const TDesC& aUri )
  1059 void CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL( const TDesC& aUri )
  1479 {
  1060 {
  1480     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL()"),
  1061     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::InitializeStreamingLinkL()"),
  1481                    _L("aUri = %S"), &aUri );
  1062                    _L("aUri = %S"), &aUri );
  1482 
       
  1483     SetAccessPointL();
       
  1484 
  1063 
  1485     iPlaybackUtility->InitStreamingL( aUri,
  1064     iPlaybackUtility->InitStreamingL( aUri,
  1486                                       (TDesC8*)(&KDATATYPEVIDEOHELIX),
  1065                                       (TDesC8*)(&KDATATYPEVIDEOHELIX),
  1487                                       iAccessPointId );
  1066                                       iAccessPointId );
  1488 
  1067 
  1530         //
  1109         //
  1531         //  The display window must be removed before closing the playback plugin
  1110         //  The display window must be removed before closing the playback plugin
  1532         //
  1111         //
  1533         iAppUi->View()->HandleCommandL( EAknSoftkeyClose );
  1112         iAppUi->View()->HandleCommandL( EAknSoftkeyClose );
  1534     }
  1113     }
  1535 
  1114     else
  1536     iPlaybackUtility->CommandL( EPbCmdClose );
  1115     {
       
  1116         if (iPlaybackUtility)
       
  1117         {
       
  1118             iPlaybackUtility->CommandL( EPbCmdClose );
       
  1119         }
       
  1120     }
       
  1121 }
       
  1122 
       
  1123 // -------------------------------------------------------------------------------------------------
       
  1124 //   CMpxVideoPlayerAppUiEngine::SignalViewPdlReloading()
       
  1125 // -------------------------------------------------------------------------------------------------
       
  1126 //
       
  1127 void CMpxVideoPlayerAppUiEngine::SignalViewPdlReloading()
       
  1128 {
       
  1129     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUiEngine::SignalViewPdlReloading"));
       
  1130 
       
  1131     if ( iViewUtility->ActiveViewType() == TUid::Uid( KMpxPlaybackPluginTypeUid ) )
       
  1132     {
       
  1133         //
       
  1134         //  The display window must be removed before closing the playback plugin
       
  1135         //
       
  1136         iAppUi->View()->HandleCommandL( KMpxVideoPlaybackPdlReloading );
       
  1137     }
  1537 }
  1138 }
  1538 
  1139 
  1539 
  1140 
  1540 // EOF
  1141 // EOF