mpxplugins/viewplugins/views/playbackview/src/mpxplaybackviewimp.cpp
changeset 0 ff3acec5bc43
child 21 a1247965635c
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Implementation of Playback view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <aknViewAppUi.h>
       
    22 #include <eikmenub.h>
       
    23 #include <eikapp.h>
       
    24 #include <AknUtils.h>
       
    25 #include <bautils.h>
       
    26 #include <data_caging_path_literals.hrh>
       
    27 #include <mpxcommonplaybackview.rsg>
       
    28 #include <mpxplaybackview.rsg>
       
    29 
       
    30 #include "mpxplaybackview.hrh"
       
    31 #include "mpxplaybackviewimp.h"
       
    32 #include "mpxplaybackviewcontainer.h"
       
    33 #include "mpxplaybackviewlayout.h"
       
    34 #include "mpxlog.h"
       
    35 
       
    36 #include <mpxplaybackutility.h>
       
    37 #include <akntoolbar.h>
       
    38 #include <aknbutton.h>
       
    39 #include "mpxcommonplaybackview.hrh"
       
    40 #include <mpxmessagegeneraldefs.h>
       
    41 #include <mpxplaybackmessage.h>
       
    42 
       
    43 // ======== MEMBER FUNCTIONS ========
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // C++ default constructor can NOT contain any code, that
       
    47 // might leave.
       
    48 // ---------------------------------------------------------------------------
       
    49 //
       
    50 CMPXPlaybackViewImp::CMPXPlaybackViewImp()
       
    51     {
       
    52     // Do nothing
       
    53     }
       
    54 
       
    55 // ---------------------------------------------------------------------------
       
    56 // Symbian 2nd phase constructor can leave.
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 void CMPXPlaybackViewImp::ConstructL()
       
    60     {
       
    61     MPX_FUNC( "CMPXPlaybackViewImp::ConstructL" );
       
    62 
       
    63     CMPXCommonPlaybackViewImp::ConstructL();
       
    64 
       
    65     BaseConstructL( R_MPX_PLAYBACK_VIEW );
       
    66     if(AknLayoutUtils::PenEnabled())
       
    67     {
       
    68     if ( Toolbar() )
       
    69         {
       
    70         iToolbar = Toolbar();
       
    71         iToolbar->SetToolbarObserver( this );
       
    72         }
       
    73     }
       
    74 
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // Two-phased constructor.
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CMPXPlaybackViewImp* CMPXPlaybackViewImp::NewL()
       
    82     {
       
    83     CMPXPlaybackViewImp* self = CMPXPlaybackViewImp::NewLC();
       
    84     CleanupStack::Pop( self );
       
    85     return self;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // Two-phased constructor.
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 CMPXPlaybackViewImp* CMPXPlaybackViewImp::NewLC()
       
    93     {
       
    94     CMPXPlaybackViewImp* self = new ( ELeave ) CMPXPlaybackViewImp();
       
    95     CleanupStack::PushL( self );
       
    96     self->ConstructL();
       
    97     return self;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // Destructor
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 CMPXPlaybackViewImp::~CMPXPlaybackViewImp()
       
   105     {
       
   106     MPX_DEBUG1( "CMPXPlaybackViewImp::~CMPXPlaybackViewImp entering" );
       
   107 
       
   108     delete iPlaybackViewLayout;
       
   109 
       
   110     MPX_DEBUG1( "CMPXPlaybackViewImp::~CMPXPlaybackViewImp exiting" );
       
   111     }
       
   112 
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // From MEikMenuObserver
       
   116 // Dynamically initialises a menu pane.
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CMPXPlaybackViewImp::DynInitMenuPaneL(
       
   120     TInt aResourceId,
       
   121     CEikMenuPane* aMenuPane )
       
   122     {
       
   123     CMPXCommonPlaybackViewImp::DynInitMenuPaneL( aResourceId, aMenuPane );
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // From CAknView
       
   128 // Returns views id.
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 TUid CMPXPlaybackViewImp::Id() const
       
   132     {
       
   133     return TUid::Uid( KMPXPlaybackViewId );
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------------------------
       
   137 // From CAknView
       
   138 // Processes user commands.
       
   139 // ---------------------------------------------------------------------------
       
   140 //
       
   141 void CMPXPlaybackViewImp::ProcessCommandL( TInt aCommand )
       
   142     {
       
   143     MPX_DEBUG2("CMPXPlaybackViewImp::ProcessCommandL(%d): entering", aCommand);
       
   144     if ( aCommand == EAknCmdExit )
       
   145         {
       
   146         if ( MenuBar() )
       
   147             {
       
   148             MenuBar()->StopDisplayingMenuBar();
       
   149             }
       
   150 		HandleCommandL( aCommand );
       
   151         }
       
   152     CAknView::ProcessCommandL( aCommand );
       
   153     MPX_DEBUG1("CMPXPlaybackViewImp::ProcessCommandL(): exiting");
       
   154     }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // From CAknView
       
   158 // Handles a view activation.
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CMPXPlaybackViewImp::DoActivateL(
       
   162     const TVwsViewId& aPrevViewId,
       
   163     TUid aCustomMessageId,
       
   164     const TDesC8& aCustomMessage )
       
   165     {
       
   166     MPX_FUNC( "CMPXPlaybackViewImp::DoActivateL()" );
       
   167 MPX_PERF_START(CWM_CMPXPlaybackViewImp_DoActivateL);
       
   168     if ( !iContainer )
       
   169         {
       
   170         if ( !iPlaybackViewLayout )
       
   171             {
       
   172             iPlaybackViewLayout = CMPXPlaybackViewLayout::NewL();
       
   173             }
       
   174         iContainer = new ( ELeave ) CMPXPlaybackViewContainer(
       
   175             this,
       
   176             this,
       
   177             iPlaybackViewLayout );
       
   178         iContainer->SetMopParent( this );
       
   179         iContainer->ConstructL( ClientRect() );
       
   180         AppUi()->AddToStackL( *this, iContainer );
       
   181         }
       
   182     else
       
   183         {
       
   184         AppUi()->AddToStackL( *this, iContainer );
       
   185         }
       
   186 
       
   187     CMPXCommonPlaybackViewImp::DoActivateL( aPrevViewId , aCustomMessageId, aCustomMessage );
       
   188     UpdateMiddleSoftKeyDisplayL();
       
   189     MPX_PERF_CHECKPT("Playback view displayed");
       
   190 MPX_PERF_END(CWM_CMPXPlaybackViewImp_DoActivateL);
       
   191     }
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // Handle playback message.
       
   195 // ---------------------------------------------------------------------------
       
   196 //
       
   197 void CMPXPlaybackViewImp::DoHandlePlaybackMessageL(
       
   198     const CMPXMessage& aMessage )
       
   199     {
       
   200     MPX_DEBUG1( "CMPXPlaybackViewImp::DoHandlePlaybackMessageL");
       
   201 
       
   202     TMPXMessageId id( *aMessage.Value<TMPXMessageId>( KMPXMessageGeneralId ) );
       
   203     if ( KMPXMessageGeneral == id )
       
   204         {
       
   205         TInt type( *aMessage.Value<TInt>( KMPXMessageGeneralType ) );
       
   206         TInt data( *aMessage.Value<TInt>( KMPXMessageGeneralData ) );
       
   207         switch ( *aMessage.Value<TInt>( KMPXMessageGeneralEvent ) )
       
   208             {
       
   209             case TMPXPlaybackMessage::EStateChanged:
       
   210                 UpdateMiddleSoftKeyDisplayL();
       
   211                 UpdateToolbar();
       
   212                 break;
       
   213 
       
   214             default:
       
   215                 break;
       
   216             }
       
   217         }
       
   218     CMPXCommonPlaybackViewImp::DoHandlePlaybackMessageL (aMessage);
       
   219     }
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // From MAknToolbarObserver
       
   223 // Used to change toolbar settings before toolbar becomes visible
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 void CMPXPlaybackViewImp::DynInitToolbarL(TInt aResourceId, CAknToolbar* aToolbar)
       
   227     {
       
   228     if (aResourceId == R_MPX_PBV_TOUCH_TOOLBAR)
       
   229         {
       
   230         // Put initializations here to take effect before toolbar is shown
       
   231         UpdateToolbar();
       
   232     	aToolbar->UpdateBackground();
       
   233        }
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // From MAknToolbarObserver
       
   238 // Handles toolbar events
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 void CMPXPlaybackViewImp::OfferToolbarEventL( TInt aCommandId )
       
   242     {
       
   243     TInt commandId = aCommandId;
       
   244     TInt eventModifiers = iToolbar->EventModifiers();
       
   245     if ( eventModifiers == CAknToolbar::ELongPress )
       
   246     	{
       
   247     	if ( aCommandId == EMPXPbvCmdNextListItem )
       
   248     		{
       
   249     		commandId = EMPXPbvCmdSeekForward;
       
   250     		}
       
   251     	else if ( aCommandId == EMPXPbvCmdPreviousListItem )
       
   252     		{
       
   253     		commandId = EMPXPbvCmdSeekBackward;
       
   254     		}
       
   255     	}
       
   256     else if ( eventModifiers == CAknToolbar::ELongPressEnded )
       
   257     	{
       
   258     	if ( aCommandId == EMPXPbvCmdNextListItem || aCommandId == EMPXPbvCmdPreviousListItem )
       
   259     	    {
       
   260     	    commandId = EMPXPbvCmdEndSeek;
       
   261     	    }
       
   262     	}
       
   263 
       
   264     CAknView::ProcessCommandL( commandId );
       
   265     }
       
   266 
       
   267 //  End of File