videoplayerapp/mpxvideoplayer/src/mpxvideoplayerappui.cpp
branchRCL_3
changeset 8 ce5ada96ab30
parent 1 6711b85517b7
child 9 5294c000a26d
equal deleted inserted replaced
6:7d91903f795f 8:ce5ada96ab30
    13 *
    13 *
    14 * Description:  AppUI implementation
    14 * Description:  AppUI implementation
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // Version : %version: 34 %
    18 // Version : %version: e92_37 %
    19 
    19 
    20 
    20 
    21 #include <hlplch.h>                     // Help launcher
    21 #include <hlplch.h>                     // Help launcher
    22 #include <sysutil.h>                    // disk space check
    22 #include <sysutil.h>                    // disk space check
    23 #include <f32file.h>                    // TDriveNumber::EDriveC
    23 #include <f32file.h>                    // TDriveNumber::EDriveC
    42 #include "mpxvideoplayerappuiengine.h"
    42 #include "mpxvideoplayerappuiengine.h"
    43 #include "mpxvideoplayeraiwparamextractor.h"
    43 #include "mpxvideoplayeraiwparamextractor.h"
    44 #include "mpxvideo_debug.h"
    44 #include "mpxvideo_debug.h"
    45 #include "videoplayerpskeys.h"
    45 #include "videoplayerpskeys.h"
    46 
    46 
    47 // Matrix uid, needed for activating the suite view.
       
    48 const TInt KVcxMatrixUid = 0x101F4CD2;
       
    49 
       
    50 // The action=exit flag tells menu that the suite app view is exiting via options->exit.
       
    51 _LIT8( KVcxVideoSuiteExitMessage, "mm://tvvideosuite?action=exit" );
       
    52 
       
    53 // ======== MEMBER FUNCTIONS ========
    47 // ======== MEMBER FUNCTIONS ========
    54 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    55 // CMpxVideoPlayerAppUi::CMpxVideoPlayerAppUi
    49 // CMpxVideoPlayerAppUi::CMpxVideoPlayerAppUi
    56 // -----------------------------------------------------------------------------
    50 // -----------------------------------------------------------------------------
    57 //
    51 //
    58 CMpxVideoPlayerAppUi::CMpxVideoPlayerAppUi()
    52 CMpxVideoPlayerAppUi::CMpxVideoPlayerAppUi()
    59     : iEndKeyExit( EFalse )
       
    60 {
    53 {
    61     MPX_DEBUG(_L("CMpxVideoPlayerAppUi::CMpxVideoPlayerAppUi()"));
    54     MPX_DEBUG(_L("CMpxVideoPlayerAppUi::CMpxVideoPlayerAppUi()"));
    62 }
    55 }
    63 
    56 
    64 // -----------------------------------------------------------------------------
    57 // -----------------------------------------------------------------------------
    68 void CMpxVideoPlayerAppUi::ConstructL()
    61 void CMpxVideoPlayerAppUi::ConstructL()
    69 {
    62 {
    70     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUi::ConstructL()"));
    63     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUi::ConstructL()"));
    71 
    64 
    72     BaseConstructL( EAknEnableSkin | EAknSingleClickCompatible );
    65     BaseConstructL( EAknEnableSkin | EAknSingleClickCompatible );
    73 
       
    74     DoWgIdUpkeep();
       
    75 
    66 
    76     if ( IsEmbedded() )
    67     if ( IsEmbedded() )
    77     {
    68     {
    78         //
    69         //
    79         //  Set the orientation to landscape for Embedded instances
    70         //  Set the orientation to landscape for Embedded instances
    80         //
    71         //
    81         SetOrientationL( CAknAppUiBase::EAppUiOrientationLandscape );
    72         SetOrientationL( CAknAppUiBase::EAppUiOrientationLandscape );
    82     }
    73     }
    83     else
       
    84     {
       
    85         //
       
    86         //  if we are stand alone mode store window group id to RProperty
       
    87         //  so we can identify it in ActionHandlerPlugin.
       
    88         //
       
    89         RProperty::Define( KVideoPlayerRPropertyCategory,
       
    90                            KVideoPlayerRPropertyWGIdKey,
       
    91                            RProperty::EInt );
       
    92 
       
    93         RProperty::Set( KVideoPlayerRPropertyCategory,
       
    94                         KVideoPlayerRPropertyWGIdKey,
       
    95                         iCoeEnv->RootWin().Identifier() );
       
    96     }
       
    97 
    74 
    98     iAppUiEngine = CMpxVideoPlayerAppUiEngine::NewL( this );
    75     iAppUiEngine = CMpxVideoPlayerAppUiEngine::NewL( this );
    99 }
       
   100 
       
   101 
       
   102 // -----------------------------------------------------------------------------
       
   103 // CMpxVideoPlayerAppUi::DoWgIdUpkeer
       
   104 // Checks if stored wgid is run by other application than us
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CMpxVideoPlayerAppUi::DoWgIdUpkeep()
       
   108 {
       
   109     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUi::DoWgIdUpkeep()"));
       
   110 
       
   111     // Do the upkeep for stand alone wg identifier
       
   112     // If we find that the WgId of this application is same
       
   113     // as the one stored in RProperty we know that the stand
       
   114     // alone has crashed and we have to clear it.
       
   115     TInt wgId( 0 );
       
   116     TInt err( RProperty::Get( KVideoPlayerRPropertyCategory, KVideoPlayerRPropertyWGIdKey, wgId ) );
       
   117 
       
   118     if ( wgId && !err )
       
   119     {
       
   120         if ( IsEmbedded() && wgId == iCoeEnv->RootWin().Identifier() )
       
   121         {
       
   122             // Stored wgId is ours and we are in embedded mode. Delete!
       
   123             RProperty::Delete( KVideoPlayerRPropertyCategory,
       
   124                                KVideoPlayerRPropertyWGIdKey );
       
   125         }
       
   126     }
       
   127 }
    76 }
   128 
    77 
   129 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
   130 // CMpxVideoPlayerAppUi::~CMpxVideoPlayerAppUi
    79 // CMpxVideoPlayerAppUi::~CMpxVideoPlayerAppUi
   131 // Destructor. Frees reserved resources
    80 // Destructor. Frees reserved resources
   132 // -----------------------------------------------------------------------------
    81 // -----------------------------------------------------------------------------
   133 //
    82 //
   134 CMpxVideoPlayerAppUi::~CMpxVideoPlayerAppUi()
    83 CMpxVideoPlayerAppUi::~CMpxVideoPlayerAppUi()
   135 {
    84 {
   136     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUi::~CMpxVideoPlayerAppUi()"));
    85     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUi::~CMpxVideoPlayerAppUi()"));
   137 
       
   138     // If we are running in embedded we keep the RProperty alive when exiting.
       
   139     if ( ! IsEmbedded() )
       
   140     {
       
   141         RProperty::Delete( KVideoPlayerRPropertyCategory,
       
   142                            KVideoPlayerRPropertyWGIdKey );
       
   143     }
       
   144 
    86 
   145     delete iAppUiEngine;
    87     delete iAppUiEngine;
   146 }
    88 }
   147 
    89 
   148 // -----------------------------------------------------------------------------
    90 // -----------------------------------------------------------------------------
   178 // ---------------------------------------------------------------------------
   120 // ---------------------------------------------------------------------------
   179 //
   121 //
   180 void CMpxVideoPlayerAppUi::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination )
   122 void CMpxVideoPlayerAppUi::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination )
   181 {
   123 {
   182     TInt eventType = aEvent.Type();
   124     TInt eventType = aEvent.Type();
   183     if ( eventType == KAknUidValueEndKeyCloseEvent // End Call key
   125 
   184             || eventType == KAknShutOrHideApp ) // Exit cmd from Task Switcher
   126     //
       
   127     //  Close from the End Call Key or the Exit Cmd from the Task Switcher
       
   128     //
       
   129     if ( eventType == KAknUidValueEndKeyCloseEvent || eventType == KAknShutOrHideApp )
   185     {
   130     {
   186         MPX_DEBUG(_L("CMpxVideoPlayerAppUi::HandleWsEventL() Closed by framework"));
   131         MPX_DEBUG(_L("CMpxVideoPlayerAppUi::HandleWsEventL() Closed by framework"));
   187 
   132 
   188         iEndKeyExit = ETrue;
   133         iAppUiEngine->ClosePlaybackPluginL();
   189         iAppUiEngine->PrepareCloseMpxL();
       
   190     }
   134     }
   191 
   135 
   192     CAknAppUi::HandleWsEventL( aEvent, aDestination );
   136     CAknAppUi::HandleWsEventL( aEvent, aDestination );
   193 }
   137 }
   194 
   138 
   206         case EEikCmdExit: // fall through
   150         case EEikCmdExit: // fall through
   207         case EAknCmdExit:
   151         case EAknCmdExit:
   208         {
   152         {
   209             MPX_DEBUG(_L("CMpxVideoPlayerAppUi::HandleCommandL() - Exit"));
   153             MPX_DEBUG(_L("CMpxVideoPlayerAppUi::HandleCommandL() - Exit"));
   210 
   154 
   211             iAppUiEngine->PrepareCloseMpxL();
   155             iAppUiEngine->ClosePlaybackPluginL();
   212 
       
   213             //
       
   214             //  Send message to matrix menu on a stand alone instance if:
       
   215             //     1)  End Key is pressed
       
   216             //     2)  Exit command has been issued
       
   217             //
       
   218             if ( ! IsEmbedded() && ( ! iEndKeyExit && iAppUiEngine->ExitToMatrixMenu() ) )
       
   219             {
       
   220                 LaunchMmViewL( KVcxVideoSuiteExitMessage );
       
   221             }
       
   222 
   156 
   223             HandleExit();
   157             HandleExit();
   224             break;
   158             break;
   225         }
   159         }
   226         case EAknSoftkeyBack:
   160         case EAknSoftkeyBack:
   235             break;
   169             break;
   236         }
   170         }
   237         case EAknCmdHideInBackground:
   171         case EAknCmdHideInBackground:
   238         {
   172         {
   239             iAppUiEngine->ClearPdlInformation();
   173             iAppUiEngine->ClearPdlInformation();
   240             break;
       
   241         }
       
   242         default:
       
   243         {
       
   244             // do nothing if the command is not reconized
       
   245             break;
   174             break;
   246         }
   175         }
   247     }
   176     }
   248 }
   177 }
   249 
   178 
   376 CAknView* CMpxVideoPlayerAppUi::View()
   305 CAknView* CMpxVideoPlayerAppUi::View()
   377 {
   306 {
   378     return iView;
   307     return iView;
   379 }
   308 }
   380 
   309 
   381 // ---------------------------------------------------------------------------
       
   382 // Sends a message to Matrix Menu
       
   383 // ---------------------------------------------------------------------------
       
   384 //
       
   385 void CMpxVideoPlayerAppUi::LaunchMmViewL( const TDesC8& aMessage )
       
   386 {
       
   387     MPX_ENTER_EXIT(_L("CMpxVideoPlayerAppUi::LaunchMmViewL()"));
       
   388 
       
   389     TApaTaskList taskList( iCoeEnv->WsSession() );
       
   390     TApaTask task = taskList.FindApp( TUid::Uid( KVcxMatrixUid ) );
       
   391 
       
   392     if ( task.Exists() )
       
   393     {
       
   394         //
       
   395         //  Matrix is already running in background - send APA Message
       
   396         //
       
   397         task.SendMessage( TUid::Uid( KUidApaMessageSwitchOpenFileValue ), aMessage );
       
   398     }
       
   399 }
       
   400