mmsharing/mmshui/src/musuireceiveview.cpp
changeset 15 ccd8e69b5392
parent 2 b31261fd4e04
child 20 e8be2c2e049d
child 22 496ad160a278
equal deleted inserted replaced
2:b31261fd4e04 15:ccd8e69b5392
     1 /*
       
     2 * Copyright (c) 2005 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:  The MUS application's UI class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "musuireceiveview.h"
       
    21 #include "musuireceivecontainer.h"
       
    22 #include "musuibackgroundviewcontainer.h"
       
    23 #include "musuireceivecontroller.h"
       
    24 #include "musuiactivitymanger.h"
       
    25 #include "musuiappui.h"
       
    26 #include "musuistatuspanehandler.h"
       
    27 #include "musui.hrh"
       
    28 #include "musuidefinitions.h"
       
    29 #include "muslogger.h" // debug logging
       
    30 #include <musui.rsg>
       
    31 #include <musui.mbg>
       
    32 
       
    33 #include <aknViewAppUi.h>
       
    34 #include <avkon.hrh>
       
    35 #include <eikmenup.h>
       
    36 #include <akntoolbar.h>
       
    37 
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // EPOC two-phased constructor
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 void CMusUiReceiveView::ConstructL()
       
    44     {
       
    45     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::ConstructL" );
       
    46     
       
    47     CMusUiGeneralView::ConstructL();
       
    48 
       
    49     Toolbar()->SetToolbarObserver( this );
       
    50     Toolbar()->UpdateBackground();
       
    51 
       
    52     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::ConstructL" );
       
    53     }
       
    54 
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // Destructor
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 CMusUiReceiveView::~CMusUiReceiveView()
       
    61     {
       
    62     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::~CMusUiReceiveView" );
       
    63     if ( iContainer )
       
    64         {
       
    65         AppUi()->RemoveFromViewStack( *this, iContainer );
       
    66         }
       
    67     delete iContainer;
       
    68 
       
    69     delete iController;
       
    70 
       
    71     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::~CMusUiReceiveView" );
       
    72     }
       
    73 
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TUid CMusUiReceiveView::Id() const
       
    80     {
       
    81     return KMusUidReceivingView;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // From MEikMenuObserver, Called by framework before constructing menupane
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CMusUiReceiveView::DynInitMenuPaneL( TInt aResourceId,
       
    89                                           CEikMenuPane* aMenuPane )
       
    90     {
       
    91     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::DynInitMenuPaneL" );
       
    92     
       
    93     // Base class initiated initialization first
       
    94     CMusUiGeneralView::DynInitMenuPaneL( aResourceId, aMenuPane );
       
    95     if(!MUS_NO_TOOLBAR)
       
    96         {
       
    97         SetInitialFocusedItemL();
       
    98         }
       
    99     
       
   100     if ( aResourceId == R_MUSUI_VIEW_MENU )
       
   101         {
       
   102         // Delete item which is present on toolbar
       
   103         if ( !MUS_NO_TOOLBAR )
       
   104             {
       
   105             aMenuPane->DeleteMenuItem( EMusuiCmdViewFullScreen );
       
   106             }
       
   107 
       
   108         // Delete items not related to receiving side:
       
   109         aMenuPane->DeleteMenuItem( EMusuiCmdViewReplay );
       
   110         aMenuPane->DeleteMenuItem( EMusuiCmdToolbarZoom );
       
   111         aMenuPane->DeleteMenuItem( EMusuiCmdToolbarBrightness );
       
   112         aMenuPane->DeleteMenuItem( EMusuiCmdViewZoom );
       
   113         aMenuPane->DeleteMenuItem( EMusuiCmdViewBrightness );
       
   114         aMenuPane->DeleteMenuItem( EMusuiCmdRecord );
       
   115         aMenuPane->DeleteMenuItem( EMusuiCmdStopRecording );
       
   116         
       
   117         // Delete EMusuiCmdViewAudioNormal or EMusuiCmdViewAudioMute
       
   118         // depending on the audio state of the clip:
       
   119         if ( iController->ClipContainsAudioL() )
       
   120             {
       
   121             aMenuPane->DeleteMenuItem( iController->ClipMutedL() ? 
       
   122                                         EMusuiCmdViewAudioMute : 
       
   123                                         EMusuiCmdViewAudioNormal );
       
   124             }
       
   125          else
       
   126             {
       
   127             aMenuPane->DeleteMenuItem( EMusuiCmdViewAudioMute );
       
   128             aMenuPane->DeleteMenuItem( EMusuiCmdViewAudioNormal );
       
   129             }
       
   130         
       
   131         }
       
   132     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::DynInitMenuPaneL" );
       
   133     }
       
   134  
       
   135     
       
   136 // -----------------------------------------------------------------------------
       
   137 // Called when focus event occurs.
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CMusUiReceiveView::DoHandleForegroundEventL( TBool aForeground )
       
   141     {
       
   142     CMusUiGeneralView::HandleForegroundEventL( aForeground, EFalse );
       
   143     }
       
   144 
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // 
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 void CMusUiReceiveView::HandleToolbarCommandL( TInt aCommand )
       
   151     {
       
   152     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::HandleToolbarCommandL" );
       
   153     
       
   154     __ASSERT_ALWAYS( iController, User::Leave( KErrNotReady ) );
       
   155     
       
   156     switch ( aCommand )
       
   157         {
       
   158         case EKeyLeftArrow:
       
   159             {
       
   160             HandleCommandL( 
       
   161                     iController->ToolbarVolumeSelected() ? EMusuiCmdViewVolumeDown :
       
   162                     EMusUiCmdToolbarLastIndex );
       
   163             break;
       
   164             }
       
   165         case EKeyRightArrow:
       
   166             {
       
   167             HandleCommandL( 
       
   168                     iController->ToolbarVolumeSelected() ? EMusuiCmdViewVolumeUp :
       
   169                     EMusUiCmdToolbarLastIndex );
       
   170             break;
       
   171             }
       
   172         case EKeyUpArrow:
       
   173             {
       
   174             HandleCommandL( 
       
   175                     iController->ToolbarVolumeSelected() ? EMusuiCmdViewVolumeUp :
       
   176                     EMusUiCmdToolbarLastIndex );
       
   177             break;
       
   178             }
       
   179         case EKeyDownArrow:
       
   180             {
       
   181             HandleCommandL( 
       
   182                     iController->ToolbarVolumeSelected() ? EMusuiCmdViewVolumeDown :
       
   183                     EMusUiCmdToolbarLastIndex );
       
   184             break;
       
   185             }
       
   186         case EMusuiCmdViewVolumeDown:
       
   187             {
       
   188             HandleCommandL( EMusuiCmdViewVolumeDown );
       
   189             break;
       
   190             }
       
   191         case EMusuiCmdViewVolumeUp:
       
   192             {
       
   193             HandleCommandL( EMusuiCmdViewVolumeUp );
       
   194             break;
       
   195             }
       
   196         default:
       
   197             {
       
   198             break;
       
   199             }
       
   200         }
       
   201     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::HandleToolbarCommandL" );
       
   202     }
       
   203 
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 void CMusUiReceiveView::SetInitialFocusedItemL()
       
   210     {
       
   211     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::SetInitialFocusedItemL" );
       
   212     
       
   213     __ASSERT_ALWAYS( iController, User::Leave( KErrNotReady ) );
       
   214     
       
   215     if ( iOperatorSpecificFunctionality && !AknLayoutUtils::PenEnabled()  )
       
   216         {
       
   217         MUS_LOG( "Focus changed in OPERATOR mode !!!!!!!!!!!!!" );
       
   218          if ( !( iController->DeviceHasDedicatedVolumeKeys() ) )
       
   219             {
       
   220             Toolbar()->SetFocusedItemL( EMusuiCmdToolbarVolume );
       
   221             }
       
   222         else
       
   223             {
       
   224        
       
   225         	Toolbar()->SetFocusedItemL( EMusuiCmdToolbarFullScreen );    
       
   226         	}
       
   227         
       
   228         }
       
   229     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::SetInitialFocusedItemL" );
       
   230     }
       
   231 
       
   232 
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 // -----------------------------------------------------------------------------
       
   236 //
       
   237 void CMusUiReceiveView::SetToolbarVisibility( TBool aVisible )
       
   238     {
       
   239     MUS_LOG1( "mus: [MUSUI ]  -> CMusUiReceiveView::SetToolbarVisibility: %d",
       
   240                             aVisible );
       
   241     if ( MUS_NO_TOOLBAR )
       
   242         {
       
   243         MUS_LOG( "                  Operator variant, no toolbar! Ignoring.." )
       
   244         MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::SetToolbarVisibility" );
       
   245         return;        
       
   246         }
       
   247     
       
   248     // Show toolbar only after established session and before of exit procedure
       
   249     if ( iController->FullScreenSelected() )
       
   250         {
       
   251         MUS_LOG( "mus: [MUSUI ] setting toolbar invisible" );
       
   252         
       
   253         Toolbar()->SetToolbarVisibility( EFalse );
       
   254         
       
   255         SharingContainer().RequestToolbarVisibilityOnceDialogDismissed( NULL );
       
   256         }
       
   257     else
       
   258         {
       
   259         CMusUiGeneralView::SetToolbarVisibility( aVisible );
       
   260         }
       
   261         
       
   262     MUS_LOG( "mus: [MUSUI ]  <- CMusUiGeneralView::SetToolbarVisibility" );
       
   263     }
       
   264 
       
   265 // -----------------------------------------------------------------------------
       
   266 // 
       
   267 // -----------------------------------------------------------------------------
       
   268 //
       
   269 void CMusUiReceiveView::DynInitToolbarL( TInt aResourceId, 
       
   270                                          CAknToolbar* aToolbar )
       
   271     {
       
   272     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::DynInitToolbarL" );
       
   273     
       
   274     // Items to be removed in Receive View:  
       
   275  	if (!AknLayoutUtils::PenEnabled())//(aResourceId == R_MUS_TOOLBAR_NONTOUCH)//
       
   276 	{
       
   277 	    if ( iController->DeviceHasDedicatedVolumeKeys() )
       
   278 	        {
       
   279 	        MUS_LOG( "mus: [MUSUI ]     CMusUiReceiveView::DynInitToolbarL\
       
   280 	                                    DeviceHasDedicatedVolumeKeys" );
       
   281 	        Toolbar()->RemoveItem( EMusuiCmdToolbarVolume );
       
   282 	        }
       
   283 	    else
       
   284 	        {
       
   285 	        aToolbar->SetFocusedItemL( EMusuiCmdToolbarVolume );
       
   286 	        }   
       
   287 
       
   288 	    Toolbar()->RemoveItem( EMusuiCmdToolbarFFRev );
       
   289 	    Toolbar()->RemoveItem( EMusuiCmdToolbarZoom );
       
   290 	    Toolbar()->RemoveItem( EMusuiCmdToolbarBrightness);
       
   291 	}
       
   292              
       
   293     Toolbar()->RemoveItem( EMusuiCmdToolbarPauseLive );
       
   294     Toolbar()->RemoveItem( EMusuiCmdToolbarUnPauseLive );
       
   295     Toolbar()->RemoveItem( EMusuiCmdToolbarPause );
       
   296     Toolbar()->RemoveItem( EMusuiCmdToolbarUnPause );
       
   297     
       
   298     if ( aToolbar->FocusedItem() == KErrNotFound && 
       
   299          !AknLayoutUtils::PenEnabled() )
       
   300         {
       
   301         aToolbar->SetFocusedItemL( EMusuiCmdToolbarFullScreen );
       
   302         }
       
   303     
       
   304     // Last generic base class functionality
       
   305     CMusUiGeneralView::DynInitToolbarL( aResourceId, aToolbar );
       
   306 
       
   307     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::DynInitToolbarL" );
       
   308     }
       
   309 
       
   310 
       
   311 // -----------------------------------------------------------------------------
       
   312 //
       
   313 // -----------------------------------------------------------------------------
       
   314 //
       
   315 void CMusUiReceiveView::ShowInvitationQueryL( const TDesC& aQuery )
       
   316     {
       
   317     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::ShowInvitationQueryL" );
       
   318     iContainer->ShowInvitationQueryL( aQuery, *iController );
       
   319     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::ShowInvitationQueryL" );
       
   320     }
       
   321 
       
   322 
       
   323 // -----------------------------------------------------------------------------
       
   324 //
       
   325 // -----------------------------------------------------------------------------
       
   326 //
       
   327 void CMusUiReceiveView::DismissInvitationQuery( TBool aDelete )
       
   328     {
       
   329     iContainer->DismissInvitationQuery( aDelete );
       
   330     }
       
   331 
       
   332 
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 void CMusUiReceiveView::SetFullScreenL( TBool aFullScreen )
       
   338     {
       
   339     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::SetFullScreenL" );
       
   340 
       
   341     if ( aFullScreen )
       
   342         {
       
   343         Cba()->MakeVisible( EFalse );
       
   344 		SetToolbarVisibility( EFalse );
       
   345         MusAppUi()->StatusPane()->MakeVisible( EFalse );
       
   346         
       
   347 		if( MusAppUi()->CurrentFixedToolbar() )
       
   348                 MusAppUi()->CurrentFixedToolbar()->MakeVisible( EFalse );  
       
   349 		
       
   350         if( MusAppUi()->CurrentPopupToolbar() )
       
   351                 MusAppUi()->CurrentPopupToolbar()->MakeVisible( EFalse );    
       
   352 		
       
   353         if( MusAppUi()->PopupToolbar() )
       
   354                 MusAppUi()->PopupToolbar()->MakeVisible( EFalse );        
       
   355         iController->ChangeOrientationL( CAknAppUiBase::EAppUiOrientationLandscape );
       
   356 
       
   357         iContainer->SetFullScreen( ETrue, MusAppUi()->ApplicationRect() );
       
   358         iController->SetRect( MusAppUi()->ApplicationRect() );
       
   359         }
       
   360     else
       
   361         {
       
   362         if( MusAppUi()->CurrentFixedToolbar() )
       
   363                 MusAppUi()->CurrentFixedToolbar()->MakeVisible( ETrue );   
       
   364 		
       
   365         if( MusAppUi()->CurrentPopupToolbar() )
       
   366                 MusAppUi()->CurrentPopupToolbar()->MakeVisible( ETrue );   
       
   367 		
       
   368         if( MusAppUi()->PopupToolbar() )
       
   369                 MusAppUi()->PopupToolbar()->MakeVisible( ETrue);
       
   370         // First make toolbar, cba and statuspane visible as those affect
       
   371         // to client rect
       
   372         MusAppUi()->StatusPane()->MakeVisible( ETrue );
       
   373         SetToolbarVisibility( ETrue );
       
   374         Cba()->MakeVisible( ETrue );
       
   375         
       
   376         iController->ChangeOrientationL( CAknAppUiBase::EAppUiOrientationAutomatic );
       
   377         iContainer->SetFullScreen( EFalse, ClientRect() );
       
   378         iController->SetRect( ClientRect() );
       
   379         }
       
   380 
       
   381     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::SetFullScreenL" );
       
   382     }
       
   383 
       
   384 
       
   385 // -----------------------------------------------------------------------------
       
   386 //
       
   387 // -----------------------------------------------------------------------------
       
   388 //
       
   389 void CMusUiReceiveView::RefreshView()
       
   390     {
       
   391     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::RefreshView" );
       
   392     
       
   393     if ( iContainer )
       
   394         {
       
   395         iContainer->SetRect( ClientRect() );
       
   396         }
       
   397     
       
   398     TRect videoRect( ClientRect().iTl.iX,
       
   399                      ClientRect().iTl.iY,
       
   400                      ClientRect().iBr.iX,
       
   401                      ClientRect().iBr.iY - ToolbarPlaceHolderHeight() );
       
   402     
       
   403     if ( iController )
       
   404         {
       
   405         iController->SetRect( videoRect );
       
   406         }
       
   407         
       
   408     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::RefreshView" );
       
   409     }
       
   410 
       
   411 
       
   412 // -----------------------------------------------------------------------------
       
   413 //
       
   414 // -----------------------------------------------------------------------------
       
   415 //
       
   416 CMusUiEventController* CMusUiReceiveView::EventController() const
       
   417     {
       
   418     return iController;
       
   419     }
       
   420 
       
   421 
       
   422 // -----------------------------------------------------------------------------
       
   423 //
       
   424 // -----------------------------------------------------------------------------
       
   425 //
       
   426 CMusUiViewContainer& CMusUiReceiveView::SharingContainer() const
       
   427     {
       
   428     return *iContainer;
       
   429     }
       
   430         
       
   431 
       
   432 // -----------------------------------------------------------------------------
       
   433 // From CAknView, Gets called from framework when activating this view
       
   434 // -----------------------------------------------------------------------------
       
   435 //
       
   436 void CMusUiReceiveView::DoActivateL( const TVwsViewId& aPrevViewId,
       
   437                                          TUid aCustomMessageId,
       
   438                                          const TDesC8& aCustomMessage )
       
   439     {
       
   440     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::DoActivateL" );
       
   441 
       
   442     // Base class activation first
       
   443     CMusUiGeneralView::DoActivateL( aPrevViewId,
       
   444                                     aCustomMessageId,
       
   445                                     aCustomMessage );
       
   446                                     
       
   447     if ( !iContainer )
       
   448         {
       
   449         // create the container and then add myself to the view stack
       
   450         iContainer = CMusUiReceiveContainer::NewL( *this, ClientRect() );
       
   451         iContainer->SetMopParent( this );
       
   452         AppUi()->AddToViewStackL( *this, iContainer );
       
   453         }
       
   454     
       
   455     /* Increase the ordinal position of background container
       
   456      * So that other control will be drawn first.     
       
   457      */
       
   458     UpdateBackgroundOrdinalPosition( ETrue );
       
   459         
       
   460     TRect videoRect( ClientRect().iTl.iX,
       
   461                      ClientRect().iTl.iY,
       
   462                      ClientRect().iBr.iX,
       
   463                      ClientRect().iBr.iY - ToolbarPlaceHolderHeight() );
       
   464 
       
   465     if ( !iController )
       
   466         {
       
   467         iController = CMusUiReceiveController::NewL( *MusAppUi(),
       
   468                                                      *this, 
       
   469                                                      *this, 
       
   470                                                      videoRect );
       
   471         }
       
   472 
       
   473     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::DoActivateL" );
       
   474     }
       
   475 
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // From AknView, Gets called from framework when deactivating this view
       
   479 // -----------------------------------------------------------------------------
       
   480 //
       
   481 void CMusUiReceiveView::DoDeactivate()
       
   482     {
       
   483     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::DoDeactivate" );
       
   484     
       
   485     CMusUiGeneralView::DoDeactivate(); // Base class deactivation first
       
   486     
       
   487     if ( iContainer )
       
   488         {
       
   489         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   490         delete iContainer;
       
   491         iContainer = NULL;
       
   492         }
       
   493 
       
   494     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::DoDeactivate" );
       
   495     }
       
   496 
       
   497 
       
   498 // end of file