mmsharing/mmshui/src/musuireceiveview.cpp
branchRCL_3
changeset 33 bc78a40cd63c
child 38 ac48f0cc9f9c
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
       
     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     Toolbar()->RemoveItem( EMusuiCmdToolbarBlank );
       
   305     
       
   306     // Last generic base class functionality
       
   307     CMusUiGeneralView::DynInitToolbarL( aResourceId, aToolbar );
       
   308 
       
   309     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::DynInitToolbarL" );
       
   310     }
       
   311 
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 //
       
   315 // -----------------------------------------------------------------------------
       
   316 //
       
   317 void CMusUiReceiveView::ShowInvitationQueryL( const TDesC& aQuery )
       
   318     {
       
   319     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::ShowInvitationQueryL" );
       
   320     iContainer->ShowInvitationQueryL( aQuery, *iController );
       
   321     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::ShowInvitationQueryL" );
       
   322     }
       
   323 
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 //
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 void CMusUiReceiveView::DismissInvitationQuery( TBool aDelete )
       
   330     {
       
   331     iContainer->DismissInvitationQuery( aDelete );
       
   332     }
       
   333 
       
   334 
       
   335 // -----------------------------------------------------------------------------
       
   336 //
       
   337 // -----------------------------------------------------------------------------
       
   338 //
       
   339 void CMusUiReceiveView::SetFullScreenL( TBool aFullScreen )
       
   340     {
       
   341     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::SetFullScreenL" );
       
   342 
       
   343     if ( aFullScreen )
       
   344         {
       
   345         Cba()->MakeVisible( EFalse );
       
   346 		SetToolbarVisibility( EFalse );
       
   347         MusAppUi()->StatusPane()->MakeVisible( EFalse );
       
   348         
       
   349 		if( MusAppUi()->CurrentFixedToolbar() )
       
   350                 MusAppUi()->CurrentFixedToolbar()->MakeVisible( EFalse );  
       
   351 		
       
   352         if( MusAppUi()->CurrentPopupToolbar() )
       
   353                 MusAppUi()->CurrentPopupToolbar()->MakeVisible( EFalse );    
       
   354 		
       
   355         if( MusAppUi()->PopupToolbar() )
       
   356                 MusAppUi()->PopupToolbar()->MakeVisible( EFalse );        
       
   357         iController->ChangeOrientationL( CAknAppUiBase::EAppUiOrientationLandscape );
       
   358 
       
   359         iContainer->SetFullScreen( ETrue, MusAppUi()->ApplicationRect() );
       
   360         iController->SetRect( MusAppUi()->ApplicationRect() );
       
   361         }
       
   362     else
       
   363         {
       
   364         if( MusAppUi()->CurrentFixedToolbar() )
       
   365                 MusAppUi()->CurrentFixedToolbar()->MakeVisible( ETrue );   
       
   366 		
       
   367         if( MusAppUi()->CurrentPopupToolbar() )
       
   368                 MusAppUi()->CurrentPopupToolbar()->MakeVisible( ETrue );   
       
   369 		
       
   370         if( MusAppUi()->PopupToolbar() )
       
   371                 MusAppUi()->PopupToolbar()->MakeVisible( ETrue);
       
   372         // First make toolbar, cba and statuspane visible as those affect
       
   373         // to client rect
       
   374         MusAppUi()->StatusPane()->MakeVisible( ETrue );
       
   375         SetToolbarVisibility( ETrue );
       
   376         Cba()->MakeVisible( ETrue );
       
   377         
       
   378         iController->ChangeOrientationL( CAknAppUiBase::EAppUiOrientationAutomatic );
       
   379         iContainer->SetFullScreen( EFalse, ClientRect() );
       
   380         iController->SetRect( ClientRect() );
       
   381         }
       
   382 
       
   383     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::SetFullScreenL" );
       
   384     }
       
   385 
       
   386 
       
   387 // -----------------------------------------------------------------------------
       
   388 //
       
   389 // -----------------------------------------------------------------------------
       
   390 //
       
   391 void CMusUiReceiveView::RefreshView()
       
   392     {
       
   393     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::RefreshView" );
       
   394     
       
   395     RefreshBackgroundContainer();
       
   396     
       
   397     if ( iContainer )
       
   398         {
       
   399         iContainer->SetRect( ClientRect() );
       
   400         iContainer->UpdatePointerCapture();
       
   401         }
       
   402     
       
   403     TRect videoRect( ClientRect().iTl.iX,
       
   404                      ClientRect().iTl.iY,
       
   405                      ClientRect().iBr.iX,
       
   406                      ClientRect().iBr.iY - ToolbarPlaceHolderHeight() );
       
   407     
       
   408     if ( iController )
       
   409         {
       
   410         iController->SetRect( videoRect );
       
   411         }
       
   412         
       
   413     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::RefreshView" );
       
   414     }
       
   415 
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 CMusUiEventController* CMusUiReceiveView::EventController() const
       
   422     {
       
   423     return iController;
       
   424     }
       
   425 
       
   426 
       
   427 // -----------------------------------------------------------------------------
       
   428 //
       
   429 // -----------------------------------------------------------------------------
       
   430 //
       
   431 CMusUiViewContainer& CMusUiReceiveView::SharingContainer() const
       
   432     {
       
   433     return *iContainer;
       
   434     }
       
   435         
       
   436 
       
   437 // -----------------------------------------------------------------------------
       
   438 // From CAknView, Gets called from framework when activating this view
       
   439 // -----------------------------------------------------------------------------
       
   440 //
       
   441 void CMusUiReceiveView::DoActivateL( const TVwsViewId& aPrevViewId,
       
   442                                          TUid aCustomMessageId,
       
   443                                          const TDesC8& aCustomMessage )
       
   444     {
       
   445     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::DoActivateL" );
       
   446 
       
   447     // Base class activation first
       
   448     CMusUiGeneralView::DoActivateL( aPrevViewId,
       
   449                                     aCustomMessageId,
       
   450                                     aCustomMessage );
       
   451                                     
       
   452     if ( !iContainer )
       
   453         {
       
   454         // create the container and then add myself to the view stack
       
   455         iContainer = CMusUiReceiveContainer::NewL( *this, ClientRect() );
       
   456         iContainer->SetMopParent( this );
       
   457         AppUi()->AddToViewStackL( *this, iContainer );
       
   458         }
       
   459     
       
   460     /* Increase the ordinal position of background container
       
   461      * So that other control will be drawn first.     
       
   462      */
       
   463     UpdateBackgroundOrdinalPosition( ETrue );
       
   464         
       
   465     TRect videoRect( ClientRect().iTl.iX,
       
   466                      ClientRect().iTl.iY,
       
   467                      ClientRect().iBr.iX,
       
   468                      ClientRect().iBr.iY - ToolbarPlaceHolderHeight() );
       
   469 
       
   470     if ( !iController )
       
   471         {
       
   472         iController = CMusUiReceiveController::NewL( *MusAppUi(),
       
   473                                                      *this, 
       
   474                                                      *this, 
       
   475                                                      videoRect );
       
   476         }
       
   477 
       
   478     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::DoActivateL" );
       
   479     }
       
   480 
       
   481 
       
   482 // -----------------------------------------------------------------------------
       
   483 // From AknView, Gets called from framework when deactivating this view
       
   484 // -----------------------------------------------------------------------------
       
   485 //
       
   486 void CMusUiReceiveView::DoDeactivate()
       
   487     {
       
   488     MUS_LOG( "mus: [MUSUI ]  -> CMusUiReceiveView::DoDeactivate" );
       
   489     
       
   490     CMusUiGeneralView::DoDeactivate(); // Base class deactivation first
       
   491     
       
   492     if ( iContainer )
       
   493         {
       
   494         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   495         delete iContainer;
       
   496         iContainer = NULL;
       
   497         }
       
   498 
       
   499     MUS_LOG( "mus: [MUSUI ]  <- CMusUiReceiveView::DoDeactivate" );
       
   500     }
       
   501 
       
   502 
       
   503 // end of file