camerauis/cameraapp/generic/src/CamPreCaptureViewBase.cpp
branchRCL_3
changeset 54 bac7acad7cb3
child 62 f0c0788c4de2
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007-2010 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:  Base class for pre capture views*
       
    15 */
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <eikbtgpc.h>
       
    20 #include <eikmenub.h>
       
    21 #include <musresourceproperties.h>
       
    22 #include <cameraplatpskeys.h>
       
    23 #include <cameraapp.rsg>
       
    24 #include <vgacamsettings.rsg>
       
    25 #include <akntoolbar.h>
       
    26 #include <akntoolbarextension.h>
       
    27 #include <aknbutton.h>
       
    28 #include <eiksoftkeypostingtransparency.h>
       
    29 #include <AknsUtils.h>
       
    30 #include <gulicon.h>
       
    31 
       
    32 #include "Cam.hrh"
       
    33 #include "CamAppUi.h"
       
    34 #include "CamUtility.h"
       
    35 #include "CamAppController.h"
       
    36 #include "CamPreCaptureContainerBase.h"
       
    37 #include "CamLogger.h"
       
    38 #include "CamPanic.h"
       
    39 #include "CamCaptureSetupMenu.h"
       
    40 #include "CamStandbyContainer.h"
       
    41 #include "CamSelfTimer.h"
       
    42 #include "CamTimer.h"
       
    43 #include "camactivepalettehandler.h"
       
    44 #include "CamPreCaptureViewBase.h"
       
    45 #include "CameraUiConfigManager.h"
       
    46 #include "OstTraceDefinitions.h"
       
    47 #ifdef OST_TRACE_COMPILER_IN_USE
       
    48 #include "CamPreCaptureViewBaseTraces.h"
       
    49 #endif
       
    50 
       
    51 #include "camstartuplogocontroller.h" 
       
    52 
       
    53 // ===========================================================================
       
    54 // Constants
       
    55 
       
    56 
       
    57 
       
    58 // ========================= MEMBER FUNCTIONS ================================
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CCamPreCaptureViewBase destructor
       
    62 // 
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CCamPreCaptureViewBase::~CCamPreCaptureViewBase()
       
    66   {
       
    67   PRINT( _L("Camera => ~CCamPreCaptureViewBase") );
       
    68   if ( iGestureFw ) 
       
    69       {
       
    70       delete iGestureFw;
       
    71       }
       
    72   PRINT( _L("Camera <= ~CCamPreCaptureViewBase") );
       
    73   }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CCamPreCaptureViewBase::HandleCommandL
       
    77 // Handle commands
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CCamPreCaptureViewBase::HandleCommandL( TInt aCommand )
       
    81     {
       
    82     PRINT( _L("Camera => CCamPreCaptureViewBase::HandleCommandL") );
       
    83 
       
    84     iLastMovement = 0;
       
    85     switch ( aCommand )
       
    86         {              
       
    87         case ECamCmdShootSetup:
       
    88             {
       
    89             CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( AppUi() );
       
    90             TBool selfTimerEnabled = appUi->SelfTimerEnabled();
       
    91 
       
    92             if ( selfTimerEnabled )
       
    93                 {                
       
    94                 CCamSelfTimer* selftimer = appUi->SelfTimer();
       
    95 
       
    96                 // If self-timer is enabled, we need to check that it is in
       
    97                 // self-timer standby, ie Enabled but not Active (ie not 
       
    98                 // counting down)
       
    99                 if ( selftimer && !selftimer->IsActive() )
       
   100                     {
       
   101                     // In self-timer standby, pressing "select" button starts 
       
   102                     // self-timer count down.  Pass this event on to AppUi.
       
   103                     appUi->HandleCommandL( ECamCmdSelfTimerActivate );
       
   104                     }
       
   105                 }
       
   106             else 
       
   107                 {
       
   108                 // we are not in self -timer mode and check we are
       
   109                 // not already in capture setup mode
       
   110                 if ( !iCaptureSetupMenuModeActive )
       
   111                     {
       
   112                     // Ensure first item is selected in CSM.
       
   113                     iCaptureSetupMenuLastItemIndex = 0;
       
   114                     SwitchToCaptureSetupMenuModeL();
       
   115                     }
       
   116                     
       
   117                 }            
       
   118             }
       
   119             break;
       
   120 
       
   121         // If an item in the capture setup menu has been selected.
       
   122         case EAknSoftkeySelect:  
       
   123             {
       
   124             if ( ActiveSettingMode() == ECamSettingModeCaptureMenu )
       
   125                 {
       
   126                 iCaptureSetupMenuContainer->HandleCommandL( aCommand );
       
   127                 }
       
   128             else
       
   129                 {          
       
   130                 CCamCaptureSetupViewBase::HandleCommandL( aCommand );             
       
   131                 }
       
   132             }
       
   133             break;
       
   134             
       
   135         // If capture setup menu is active and user presses softkey back,
       
   136         //  deactivate the menu. This is EEikBidCancel which has the same
       
   137         //  enumeration value as EAknSoftkeyCancel.
       
   138         case EAknSoftkeyCancel:
       
   139             {            
       
   140             if ( ActiveSettingMode() == ECamSettingModeCaptureMenu )
       
   141                 {
       
   142                 ExitCaptureSetupMenuModeL();
       
   143                 }
       
   144             else if ( iController.SequenceCaptureInProgress() )                         
       
   145                 // Check if currently capturing a burst, if so, cancel it
       
   146                 {
       
   147                 // If already received all the snapshots
       
   148                 if ( iController.AllSnapshotsReceived() ) 
       
   149                     {
       
   150                     // stop burst immediately
       
   151                     iController.StopSequenceCaptureL();
       
   152                     }
       
   153                 else
       
   154                     {
       
   155                     // capture the min images (2), before stopping the burst
       
   156                     iController.SetKeyUp( ETrue );
       
   157                     iController.SoftStopBurstL( ETrue );
       
   158                     }
       
   159                 // Update CBA for setup pane usage
       
   160                 SetSoftKeysL( R_CAM_SOFTKEYS_BLANK ); 
       
   161                 }     
       
   162             else
       
   163                 {
       
   164                 CCamCaptureSetupViewBase::HandleCommandL( aCommand );                                                                                       
       
   165                 }                        
       
   166             }
       
   167             break;
       
   168         case EAknSoftkeyOptions:
       
   169             {
       
   170             // do nothing, the command is handled by the framework
       
   171             }
       
   172             break;
       
   173             
       
   174         // Note: CaptureSetupMenu mode also uses a 'Back' softkey but this has
       
   175         // the command value EEikBidCancel            
       
   176         case EAknSoftkeyBack:
       
   177             {                                          
       
   178             // exit to embedded app if we're embedded and in plain pre-capture
       
   179             if ( iEmbedded 
       
   180                 && ActiveSettingMode() != ECamSettingModeScene 
       
   181                 && ActiveSettingMode() != ECamSettingModeInfoListBox )
       
   182                 {
       
   183                 CCamCaptureSetupViewBase::HandleCommandL( ECamCmdInternalExit );
       
   184                 }
       
   185             else
       
   186                 {
       
   187                 CCamCaptureSetupViewBase::HandleCommandL( aCommand );              
       
   188                 }                           
       
   189                
       
   190             }
       
   191             break;
       
   192             
       
   193         case EAknSoftkeyOk:
       
   194             {                                                                
       
   195                 // Else pass on to lower levels
       
   196                 CCamCaptureSetupViewBase::HandleCommandL( aCommand );                                     
       
   197             }
       
   198             break;
       
   199             
       
   200         case ECamCmdToggleCourtesyUI:
       
   201             {
       
   202             CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
   203             
       
   204             if ( appUi )
       
   205                 {
       
   206                 appUi->SetAlwaysDrawPreCaptureCourtesyUI( !appUi->AlwaysDrawPreCaptureCourtesyUI() );
       
   207                 }
       
   208             }
       
   209             break;
       
   210        case ECamCmdPopUpMenuZoom: 
       
   211             {
       
   212             if ( iContainer )
       
   213                 {
       
   214                 iContainer->ShowZoomPaneWithTimer();
       
   215                 }
       
   216             }     
       
   217             break;
       
   218         case ECamCmdCaptureSetupFlashStill:
       
   219             {
       
   220             iToolbarExtensionInvisible = ETrue;
       
   221            	CCamCaptureSetupViewBase::HandleCommandL( aCommand );
       
   222             }     
       
   223             break;
       
   224         case ECamCmdInternalExit:
       
   225             {
       
   226             const TCamCaptureOperation operation( 
       
   227                     iController.CurrentOperation() );
       
   228             
       
   229                  if ( ECamPaused == operation )
       
   230                    {
       
   231                    iController.StopVideoRecording();
       
   232                    iController.SetCaptureKeyPressedWhileImageSaving( ETrue );
       
   233                    }
       
   234             StopViewFinder();
       
   235             CCamCaptureSetupViewBase::HandleCommandL( aCommand );
       
   236             if ( iController.IsTouchScreenSupported() )
       
   237                 {
       
   238                 CAknToolbar* fixedToolbar = Toolbar();
       
   239                 if ( fixedToolbar )
       
   240                     {
       
   241                     CAknToolbarExtension* extension = 
       
   242                         fixedToolbar->ToolbarExtension();
       
   243                     if ( extension )
       
   244                         {
       
   245                         // Reset toolbar extension button and view to closed state
       
   246                         extension->SetShown( EFalse );
       
   247                         extension->SetCurrentState( 0, EFalse );
       
   248                         }
       
   249                     }
       
   250                 }
       
   251             }     
       
   252             break;
       
   253         case ECamCmdSettings:
       
   254             // Hide the capture button
       
   255             if ( iContainer )
       
   256                 {
       
   257                 iContainer->SetFocus( EFalse );
       
   258                 }
       
   259             // fall-through
       
   260         default:
       
   261             {                                       
       
   262             CCamCaptureSetupViewBase::HandleCommandL( aCommand );                            
       
   263             }
       
   264         }
       
   265     PRINT( _L("Camera <= CCamPreCaptureViewBase::HandleCommandL") );
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CCamPreCaptureViewBase::HandleForegroundEventL
       
   270 // Handle a move to the foreground
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CCamPreCaptureViewBase::HandleForegroundEventL( TBool aForeground )
       
   274   {
       
   275   PRINT1( _L( "Camera => CCamPreCaptureViewBase::HandleForegroundEventL %d" ), aForeground );    
       
   276 
       
   277   iLastMovement = 0;
       
   278   CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );                
       
   279   __ASSERT_DEBUG(appUi, CamPanic(ECamPanicNullPointer));
       
   280 
       
   281   // -----------------------------------------------------
       
   282   // coming to the foreground
       
   283   if ( aForeground )
       
   284     {
       
   285     // Ignore foregrounding if view switch to postcapture anyway in progress.
       
   286     if( appUi->TargetViewState() == ECamViewStatePostCapture
       
   287      || appUi->TargetViewState() == ECamViewStateBurstThumbnail 
       
   288      || ( iStandbyModeActive && !appUi->IsRecoverableStatus() ) ) {
       
   289       PRINT( _L( "Camera <= CCamPreCaptureViewBase::HandleForegroundEventL, ignored states") );    
       
   290       return;
       
   291     }
       
   292     
       
   293     
       
   294     if ( !( iController.UiConfigManagerPtr() && 
       
   295             iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() ) )
       
   296         {
       
   297         if ( !iController.IsTouchScreenSupported() )
       
   298             {
       
   299             if ( !appUi->ActivePalette() )
       
   300                 {
       
   301                 SetupActivePaletteL();
       
   302                 }
       
   303             else
       
   304                 {
       
   305                 appUi->APHandler()->UpdateActivePaletteL();
       
   306                 }
       
   307             }
       
   308         }
       
   309     UpdateCbaL();
       
   310     
       
   311     // restart idle timer in any case
       
   312      iController.StartIdleTimer();
       
   313                                  
       
   314     // If capture setup menu is active then ensure background is faded.
       
   315     if ( iCaptureSetupMenuContainer )
       
   316       {
       
   317       iCaptureSetupMenuContainer->FadeBehind( ETrue );
       
   318       }       
       
   319 
       
   320     // coming to the foreground from an eikon server window
       
   321     if ( iContinueInBackground )
       
   322       {
       
   323       iContinueInBackground = EFalse;
       
   324 
       
   325       if ( !iController.IsViewFinding()  && !iSceneSettingModeActive )
       
   326         {
       
   327       	iController.StartViewFinder();
       
   328         }
       
   329       else if( iLocationTrailConnecting )
       
   330           {
       
   331           iLocationTrailConnecting = EFalse;
       
   332           iController.StopViewFinder();
       
   333           iController.StartViewFinder();
       
   334           }
       
   335       CCamCaptureSetupViewBase::HandleForegroundEventL( aForeground );
       
   336 
       
   337       UpdateCbaL();
       
   338       if ( iController.CameraSwitchQueued() )
       
   339           {
       
   340           appUi->HandleCommandL( ECamCmdSwitchCamera );
       
   341           }
       
   342       PRINT( _L( "Camera <= CCamPreCaptureViewBase::HandleForegroundEventL - continuing in background" ) );            
       
   343       return;
       
   344       }
       
   345     
       
   346     // This only happens when the app is first launched        
       
   347     if ( !appUi->IsConstructionComplete() && 
       
   348          !iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported())    
       
   349       {
       
   350       iActivateToStandby = ETrue;
       
   351       if ( !iStandbyModeActive )
       
   352         {
       
   353         //iStandbyError = KErrNone;
       
   354         appUi->SetStandbyStatus( KErrNone );        
       
   355         PRINT( _L( "Camera <> CCamPreCaptureViewBase::HandleForegroundEventL: sending ECamCmdGoToStandby" ) );    
       
   356         HandleCommandL( ECamCmdGoToStandby );
       
   357         SetTitlePaneTextL();
       
   358         }            
       
   359       }
       
   360 
       
   361     // Register that we want to use the engine
       
   362     IncrementCameraUsers();
       
   363     
       
   364     if ( iController.UiConfigManagerPtr()->IsLensCoverSupported() )
       
   365         {
       
   366         if ( iController.CameraSwitchQueued() )
       
   367             {
       
   368             appUi->HandleCommandL( ECamCmdSwitchCamera );
       
   369             }
       
   370         else if ( appUi->TargetViewState() != ECamViewStatePostCapture )      
       
   371             {   
       
   372             TCamCameraMode mode = iController.CurrentMode(); 
       
   373             if ( mode == ECamControllerVideo )
       
   374                 {
       
   375                 iController.EnterViewfinderMode( ECamControllerVideo );
       
   376                 }       
       
   377             else if( mode == ECamControllerImage && !iSceneSettingModeActive )
       
   378                 {
       
   379                 iController.EnterViewfinderMode( ECamControllerImage );
       
   380                 }  
       
   381             }
       
   382         UpdateCbaL();
       
   383         }
       
   384       else
       
   385         {
       
   386         // Lens cover is not supported
       
   387         if ( iController.CameraSwitchQueued() )   
       
   388             {
       
   389             appUi->HandleCommandL( ECamCmdSwitchCamera );
       
   390             }
       
   391         }
       
   392 
       
   393 
       
   394       // Start the viewfinder unless the view is activating into standby mode
       
   395       // in other modes than scene setting mode (there is no VF and this causes problems with DSA VF)
       
   396       if ( ( !iStandbyModeActive || !iActivateToStandby )  && !iSceneSettingModeActive )
       
   397         {
       
   398         // If in embedded mode and image has been captured but view is not yet in
       
   399         // postcapture view VF should not be started.
       
   400         if( !iAssumePostCaptureView ) 
       
   401             {
       
   402             PRINT( _L("Camera <> CCamPreCaptureViewBase::HandleForegroundEventL start VF"))
       
   403             StartViewFinder();
       
   404             }
       
   405         }
       
   406     // Check if currently selected storagemedia has available memory for next capturing
       
   407     appUi->CheckMemoryAvailableForCapturing();                                   
       
   408     
       
   409     // <CAMERAAPP_CAPI_V2_MIGRATION/>
       
   410     // if ( iController.EngineState() == ECamEngineStillCapturePrepared ||
       
   411     //      iController.EngineState() == ECamEngineVideoCapturePrepared )
       
   412     // if ( ( ECamImageOn|ECamVideoOn )& ( iController.CameraState() ) )
       
   413     TCamCameraState state = iController.CameraState();
       
   414     if( ECamCameraPreparedImage == state ||
       
   415         ECamCameraPreparedVideo == state )     
       
   416       {
       
   417       // Now that the view is initialised, we may need to put up the
       
   418       // mmc removal note. Perform this is required.
       
   419       appUi->ShowMMCRemovalNoteIfRequiredL();                        
       
   420       
       
   421       if ( appUi && !iSceneSettingModeActive &&
       
   422            !( iController.UiConfigManagerPtr() && 
       
   423            iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() ) )
       
   424         {
       
   425         appUi->RaisePreCaptureCourtesyUI(ETrue);
       
   426         }
       
   427       }
       
   428     }
       
   429   // -----------------------------------------------------
       
   430   // Going to the background
       
   431   else 
       
   432       {
       
   433       PRINT( _L( "Camera <> CCamPreCaptureViewBase::HandleForegroundEventL: to background" ) );    
       
   434       // Not behind an eikon/avkon server window
       
   435 	  // or keylock on when camera needs to be released.
       
   436       TBool totalBackground = ETrue;
       
   437       if ( iController.IsAppUiAvailable() && !iController.IsKeyLockOn() )
       
   438           {
       
   439           totalBackground    = appUi->AppInBackground( EFalse );
       
   440           }
       
   441       // Either in foreground (moving to another view of our's)
       
   442       // or if in background, then not just behind a notifier dialog.
       
   443       if ( totalBackground )
       
   444           {
       
   445           ReleaseResources();
       
   446           // hide the AP to avoid blinking when coming back from bg
       
   447          if ( iController.UiConfigManagerPtr() && iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() )
       
   448             {
       
   449             appUi->SetActivePaletteVisibility( EFalse );	
       
   450             }      
       
   451           }
       
   452       // Behind a server window
       
   453       else 
       
   454           {
       
   455           iContinueInBackground = ETrue;            
       
   456           }
       
   457 
       
   458       // reset post capture assumption flag since post capture is not
       
   459       // used when video is stopped for usb 
       
   460       if ( iController.IsCaptureStoppedForUsb() )
       
   461           {
       
   462           iAssumePostCaptureView = EFalse;
       
   463           }
       
   464       }
       
   465   // -----------------------------------------------------
       
   466 
       
   467   if ( !iStandbyModeActive )
       
   468     {
       
   469     // Inform the container of foreground state change
       
   470     PRINT( _L( "Camera <> CCamPreCaptureViewBase::HandleForegroundEventL: inform container.." ) );        
       
   471     iContainer->HandleForegroundEventL( aForeground );
       
   472     }
       
   473   else
       
   474     {
       
   475     // if in videocall, don't exit standby	
       
   476     if ( iController.InVideocallOrRinging() )
       
   477         {
       
   478         iActivateToStandby = EFalse;
       
   479         }
       
   480     else    		
       
   481         {   	
       
   482         // If the view has been set to standby at activation then
       
   483         // the first foreground event should not be used to exit standby
       
   484         if ( !iActivateToStandby )
       
   485            {
       
   486            // inform standby container
       
   487            PRINT( _L( "Camera <> CCamPreCaptureViewBase::HandleForegroundEventL: inform standby container.." ) );        
       
   488            iStandbyContainer->HandleForegroundEventL( aForeground );
       
   489            }  
       
   490         else
       
   491            {
       
   492            iActivateToStandby = EFalse;
       
   493            }
       
   494         }
       
   495     }
       
   496          CCamCaptureSetupViewBase::HandleForegroundEventL( aForeground );
       
   497   PRINT( _L( "Camera <= CCamPreCaptureViewBase::HandleForegroundEventL" ) );        
       
   498   }
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // CCamPreCaptureViewBase::SetLocationTrailConnecting
       
   502 // Set iLocationTrailConnecting flag.
       
   503 // -----------------------------------------------------------------------------
       
   504 //
       
   505 void CCamPreCaptureViewBase::SetLocationTrailConnecting()
       
   506     {
       
   507     iLocationTrailConnecting = ETrue;
       
   508     }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // CCamPreCaptureViewBase::SetPostCaptureViewAsumption
       
   512 // Set iAssumePostCaptureView flag.
       
   513 // -----------------------------------------------------------------------------
       
   514 //
       
   515 void CCamPreCaptureViewBase::SetPostCaptureViewAsumption( TBool aAssumePostCaptureView )
       
   516     {
       
   517     iAssumePostCaptureView = aAssumePostCaptureView;
       
   518     }
       
   519 
       
   520 
       
   521 // -----------------------------------------------------------------------------
       
   522 // CCamPreCaptureViewBase::HandleControllerEventL
       
   523 // Handle controller events
       
   524 // -----------------------------------------------------------------------------
       
   525 //
       
   526 void CCamPreCaptureViewBase::HandleControllerEventL( TCamControllerEvent aEvent, 
       
   527                                                      TInt /*aError*/ )
       
   528   {
       
   529   PRINT( _L( "Camera => CCamPreCaptureViewBase::HandleControllerEventL" ) );        
       
   530   CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
   531 
       
   532   switch( aEvent )
       
   533     { 
       
   534     // ---------------------------------------------------
       
   535     case ECamEventEngineStateChanged:
       
   536       {
       
   537       // Do not do softkey update if we are already exiting
       
   538       // (AppUi is not available)
       
   539       if( iController.IsAppUiAvailable() )
       
   540       {          
       
   541       PRINT( _L( "Camera <> case ECamEventEngineStateChanged" ) );        
       
   542       if ( ECamCameraPreparedVideo == iController.CameraState() || 
       
   543            ECamCameraPreparedImage == iController.CameraState() )
       
   544         {
       
   545         // Now that the view is initialised, we may need to put up the
       
   546         // mmc removal note. Perform this is required.
       
   547         PRINT( _L( "Camera <> show mmc note if needed" ) );        
       
   548         appUi->ShowMMCRemovalNoteIfRequiredL();
       
   549 
       
   550         // Do not update (show) precapture view toolbar if capturing is almost
       
   551         // finished, otherwise there is flickering and finally inactive toolbar 
       
   552         // when returning to prepactureview after image deletion. 
       
   553         // This will happen only if camera is started directly to portrait 
       
   554         // secondary camera i.e. Lens cover feature is supported
       
   555         TBool noToolbar = ( ECamCompleting == iController.CurrentOperation() ) && appUi->IsSecondCameraEnabled();
       
   556 
       
   557         TBool showVideoModeToolbar = ( ECamCameraPreparedVideo == iController.CameraState() && 
       
   558                 ( iController.CurrentOperation() != ECamCapturing && iController.CurrentOperation() != ECamPaused ) );
       
   559 
       
   560         TBool precaptureToolbarState = !appUi->IsBurstEnabled()
       
   561                 && !iStandbyModeActive && !appUi->IsInPretendExit();
       
   562         
       
   563         if ( ( ECamCameraPreparedImage == iController.CameraState() || 
       
   564                 showVideoModeToolbar ) &&     
       
   565                !noToolbar && precaptureToolbarState )
       
   566             {
       
   567             // Also fixed toolbar might need to be enabled.
       
   568             appUi->SetToolbarVisibility();
       
   569             }
       
   570         }
       
   571       //Do not update CBA if we are capturing or paused to prevent blinking
       
   572 	  //during video capture saving and completing
       
   573       if ( iController.CurrentVideoOperation() != ECamCapturing
       
   574              && iController.CurrentVideoOperation() != ECamPaused )
       
   575           {
       
   576           PRINT( _L( "Camera <> Update CBA" ) );        
       
   577           UpdateCbaL();
       
   578           }
       
   579       }
       
   580       break;
       
   581       }
       
   582 
       
   583     case ECamEventSliderClosed:
       
   584       {
       
   585       // if embedded and the slider is closed, 
       
   586       // the menu items may change, close the menu   
       
   587       if( iEmbedded )
       
   588         {
       
   589         PRINT( _L("Camera <> CCamPreCaptureViewBase: calling StopDisplayingMenuBar") );
       
   590         StopDisplayingMenuBar();
       
   591         }
       
   592       break;
       
   593       }
       
   594     default:
       
   595       {
       
   596       // Other events => no action.
       
   597       break;
       
   598       }
       
   599     } // switch
       
   600   PRINT( _L( "Camera <= CCamPreCaptureViewBase::HandleControllerEventL" ) );        
       
   601   }
       
   602 
       
   603 // ---------------------------------------------------------------------------
       
   604 // CCamPreCaptureViewBase::DoActivateL
       
   605 // Activate this view
       
   606 // ---------------------------------------------------------------------------
       
   607 //
       
   608 void CCamPreCaptureViewBase::DoActivateL( const TVwsViewId& aPrevViewId, 
       
   609                                           TUid aCustomMessageId,
       
   610                                           const TDesC8& aCustomMessage )                                                                                    
       
   611     {
       
   612     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMPRECAPTUREVIEWBASE_DOACTIVATEL, "e_CCamPreCaptureViewBase_DoActivateL 1" );
       
   613     PRINT( _L( "Camera => CCamPreCaptureViewBase::DoActivateL" ) );
       
   614     iAssumePostCaptureView = EFalse;
       
   615     iLastMovement = 0;
       
   616 
       
   617     ShowToolbarOnViewActivation( EFalse );
       
   618     /*if ( iController.UiConfigManagerPtr() && 
       
   619          iController.UiConfigManagerPtr()->IsLocationSupported() )
       
   620         {
       
   621         if( ECamLocationOn == iController.IntegerSettingValue( ECamSettingItemRecLocation ) )
       
   622             {
       
   623             if( ECamActiveCameraPrimary == iController.ActiveCamera() && ECamStandby != iController.CurrentOperation() )
       
   624                 {
       
   625                 PRINT( _L("Camera: CCamPreCaptureViewBase::DoActivateL - primary camera, start location/gps") )
       
   626                 iController.StartLocationTrailL();
       
   627                 }
       
   628             else // Secondary camera 
       
   629                 {
       
   630                 PRINT( _L("Camera: CCamPreCaptureViewBase::DoActivateL - secondary camera, stop location trail") )
       
   631                 iController.StopLocationTrail();
       
   632                 }
       
   633             }
       
   634         }*/
       
   635  
       
   636     CCamAppUi* appUi =  static_cast<CCamAppUi*>( AppUi() );
       
   637 	__ASSERT_DEBUG(appUi, CamPanic(ECamPanicNullPointer));
       
   638     if(!appUi->DrawPreCaptureCourtesyUI() && !iController.IsTouchScreenSupported())
       
   639         {
       
   640         if ( !appUi->IsSecondCameraEnabled() )
       
   641             {	
       
   642             SetCourtesySoftKeysL();
       
   643             }
       
   644         appUi->SetActivePaletteVisibility( EFalse );
       
   645         }
       
   646     else if (appUi->DrawPreCaptureCourtesyUI())
       
   647         {
       
   648          Cba()->MakeVisible( ETrue );
       
   649         }
       
   650 
       
   651     if ( appUi->SettingsLaunchedFromCamera() )
       
   652     	{
       
   653     	if ( TUid::Uid( ECamCmdInternalExit ) == aCustomMessageId )
       
   654     	    {
       
   655             appUi->SettingsPluginExitedL( ECameraInternalExit );
       
   656     	    }
       
   657     	else if ( TUid::Uid ( EAknSoftkeyBack ) == aCustomMessageId )
       
   658     	    {
       
   659     	    appUi->SettingsPluginExitedL( ECameraPluginExit );
       
   660     	    }
       
   661     	else
       
   662     	    {
       
   663     	    // do nothing
       
   664     	    }
       
   665     	}
       
   666 
       
   667     CCamCaptureSetupViewBase::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );
       
   668 
       
   669     if ( appUi->IsSecondCameraEnabled() && !appUi->IsQwerty2ndCamera() )  
       
   670         {
       
   671         StatusPane()->MakeVisible( ETrue );
       
   672         }
       
   673     else
       
   674         {
       
   675         StatusPane()->MakeVisible( EFalse );
       
   676         }
       
   677     
       
   678     if ( iController.IsTouchScreenSupported() )
       
   679         {
       
   680         // Make sure that icons are upto date
       
   681         UpdateToolbarIconsL();
       
   682     
       
   683         CAknToolbar* fixedToolbar = Toolbar();
       
   684         if ( fixedToolbar )
       
   685             {
       
   686             // If video call is active, toolbar is set to dimmed, that user cannot use it
       
   687             TInt callType( EPSCTsyCallTypeUninitialized );
       
   688             RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType, callType );
       
   689             if ( callType == EPSCTsyCallTypeH324Multimedia)
       
   690                 {
       
   691                 fixedToolbar->SetDimmed( ETrue ); 
       
   692                 }
       
   693             else
       
   694                 {
       
   695                 fixedToolbar->SetDimmed( EFalse ); 
       
   696                 }
       
   697             fixedToolbar->SetToolbarObserver( this );
       
   698             // avoid toolbar flicker when returning from user scene setup 
       
   699             // after adjusting a setting
       
   700             if ( !iSceneSettingModeActive )
       
   701                 {
       
   702                 appUi->SetToolbarVisibility( );
       
   703                 }
       
   704    
       
   705             // Make sure toolbar extension button has no background
       
   706             CAknToolbarExtension* extension = fixedToolbar->ToolbarExtension();
       
   707             if ( extension )
       
   708                 {
       
   709                 extension->SetButtonFlags(
       
   710                     extension->ButtonFlags() | KAknButtonNoFrame );
       
   711                 extension->DrawDeferred();
       
   712                 }
       
   713             }
       
   714         }
       
   715 
       
   716     appUi->PushNaviPaneCounterL();
       
   717 
       
   718     // Pass on the ID of the previous view to the container    
       
   719     TCamAppViewIds viewId = static_cast<TCamAppViewIds>( aPrevViewId.iViewUid.iUid );
       
   720     iContainer->SetPreviousViewId( viewId );
       
   721 
       
   722     iController.AddControllerObserverL( this );    
       
   723 
       
   724     TBool transparentCba = EFalse;
       
   725 
       
   726     UpdateCbaL();
       
   727     
       
   728     switch( aCustomMessageId.iUid )
       
   729       {
       
   730       // -------------------------------
       
   731       // Standby with or without error
       
   732       case ECamViewMessageStandby:
       
   733         PRINT( _L( "Camera <> CCamPreCaptureViewBase::DoActivateL: custom message ECamViewMessageStandby" ) );
       
   734         //iStandbyError = KErrNone;
       
   735         //appUi->SetStandbyStatus( KErrNone );
       
   736         SetSceneSettingMode( EFalse );
       
   737         iActivateToStandby = ETrue;
       
   738         HandleCommandL( ECamCmdGoToStandby );
       
   739         return;
       
   740 //        break;
       
   741       // -------------------------------
       
   742       // Scene setting mode
       
   743       case ECamViewMessageSceneSettingList:
       
   744         PRINT( _L( "Camera <> CCamPreCaptureViewBase::DoActivateL: custom message ECamViewMessageSceneSettingList" ) );
       
   745         SwitchToSceneSettingModeL();
       
   746         break;
       
   747       // -------------------------------
       
   748       default:
       
   749         // Other precapture modes have transparent CBA buttons
       
   750         // except secondary camera
       
   751         if ( !appUi->IsSecondCameraEnabled() || appUi->IsQwerty2ndCamera() )  
       
   752             {
       
   753             transparentCba = ETrue;
       
   754             }
       
   755         // don't start VF if faster startup is used when cameraswitch is queued,
       
   756         // need to switch to maincamera first
       
   757         if ( !( iController.UiConfigManagerPtr() && 
       
   758                 iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() &&
       
   759                 iController.CameraSwitchQueued() ) )
       
   760             {
       
   761             StartViewFinder();
       
   762             }
       
   763         
       
   764         break;
       
   765       // -------------------------------
       
   766       }
       
   767     
       
   768     // Here we check if the previous view is ViaPlayer play mode
       
   769     if ( !iSceneSettingModeActive  && 
       
   770          ( aPrevViewId.iViewUid.iUid != ECamViewIdViaPlayerPlayBack ) && 
       
   771          !( iController.UiConfigManagerPtr() && 
       
   772          iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() ) )
       
   773         {
       
   774         appUi->RaisePreCaptureCourtesyUI(ETrue);
       
   775         }
       
   776     
       
   777     // Reset iContinueInBackground flag, which is set when app temporarily
       
   778     // goes behind a system window and there's no need to free resources.
       
   779     // Resetting this flag only in ReleaseResources causes problems (at least)
       
   780     // if power key is pressed during burst capture.
       
   781     iContinueInBackground = EFalse;
       
   782     
       
   783     // Reset iDeactivateToStandby flag, which is used when the PreCapture view
       
   784     // goes to the Standby mode, at which point the UI should not reactivate the
       
   785     // viewfinder.
       
   786     iDeactivateToStandby = EFalse;
       
   787 
       
   788 
       
   789     EikSoftkeyPostingTransparency::MakeTransparent(
       
   790         *Cba(), transparentCba );
       
   791     // Make sure appuis CBA is not visible
       
   792     CEikButtonGroupContainer* cba = AppUi()->Cba();
       
   793     if( cba )
       
   794         {
       
   795         cba->MakeVisible( EFalse );
       
   796         }
       
   797 
       
   798     PRINT( _L( "Camera <= CCamPreCaptureViewBase::DoActivateL" ) );
       
   799     OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMPRECAPTUREVIEWBASE_DOACTIVATEL, "e_CCamPreCaptureViewBase_DoActivateL 0" );
       
   800     }
       
   801 
       
   802 // ---------------------------------------------------------------------------
       
   803 // CCamPreCaptureViewBase::DoDeactivate
       
   804 // Deactivate this view
       
   805 // ---------------------------------------------------------------------------
       
   806 //
       
   807 void CCamPreCaptureViewBase::DoDeactivate()
       
   808     {                              
       
   809     PRINT( _L( "Camera => CCamPreCaptureViewBase::DoDeactivate" ) );
       
   810     
       
   811     delete iGestureFw;
       
   812     iGestureFw = NULL;
       
   813 
       
   814     CCamCaptureSetupViewBase::DoDeactivate();
       
   815                                
       
   816     iController.RemoveControllerObserver( this );
       
   817     
       
   818     if ( iController.IsTouchScreenSupported() )
       
   819         {
       
   820         CAknToolbar* fixedToolbar = Toolbar();
       
   821         if ( fixedToolbar )
       
   822             {
       
   823             CAknToolbarExtension* extension = fixedToolbar->ToolbarExtension();
       
   824             if ( extension )
       
   825                 {
       
   826                 // Reset toolbar extension button and view to closed state
       
   827                 extension->SetShown( EFalse );
       
   828                 extension->SetCurrentState( 0, EFalse );
       
   829                 }
       
   830             }
       
   831         }
       
   832     ReleaseResources();
       
   833 
       
   834     if ( iController.UiConfigManagerPtr()->IsLensCoverSupported() &&
       
   835          iController.ActiveCamera() == ECamActiveCameraSecondary ) 
       
   836         {
       
   837         if ( iController.CameraSwitchQueued() )
       
   838             {
       
   839             CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
   840             // If camera switch fails, main camera is used instead
       
   841             TRAP_IGNORE( appUi->HandleCommandL( ECamCmdSwitchCamera ) );
       
   842             }
       
   843         }
       
   844 
       
   845     PRINT( _L( "Camera <= CCamPreCaptureViewBase::DoDeactivate" ) );
       
   846     }
       
   847 
       
   848 // -----------------------------------------------------------------------------
       
   849 // CCamPreCaptureViewBase::HandleFocusLossL
       
   850 // Handle change of focus
       
   851 // -----------------------------------------------------------------------------
       
   852 //
       
   853 void CCamPreCaptureViewBase::HandleFocusLossL()
       
   854     {
       
   855     PRINT( _L( "Camera => CCamPreCaptureViewBase::HandleFocusLossL" ) );    
       
   856     // if the application was already in the background, but behind an
       
   857     // eikon server window, then handle backgrounding properly now.
       
   858     // Otherwise the backgrounding will be handled in the normal
       
   859     // HandleForeground() method.
       
   860     if ( iContinueInBackground )
       
   861         {
       
   862         ReleaseResources();
       
   863         // Inform the container of foreground state change
       
   864         iContainer->HandleForegroundEventL( EFalse );
       
   865         }
       
   866     CCamCaptureSetupViewBase::HandleFocusLossL();
       
   867 
       
   868     // dismiss menu bar if open
       
   869     StopDisplayingMenuBar();
       
   870     PRINT( _L( "Camera <= CCamPreCaptureViewBase::HandleFocusLossL" ) );
       
   871     }
       
   872                           
       
   873 // ---------------------------------------------------------------------------
       
   874 // CCamPreCaptureViewBase::SwitchToCaptureSetupModeL
       
   875 // Switches the current mode to capture setup and activates a 
       
   876 // specific control..
       
   877 // ---------------------------------------------------------------------------
       
   878 //
       
   879 void CCamPreCaptureViewBase::SwitchToCaptureSetupModeL( TInt aSetupCommand )
       
   880     {
       
   881     
       
   882     PRINT( _L("Camera => CCamPreCaptureViewBase::SwitchToCaptureSetupModeL") );
       
   883     
       
   884     // Remove the view's main container, and add the capture setup 
       
   885     // control associated with the input command to the container stack.
       
   886     CCamCaptureSetupViewBase::SwitchToCaptureSetupModeL( aSetupCommand );
       
   887 
       
   888     // only remove the capture setup menu container after 
       
   889     // the switch completes successfully
       
   890     RemoveCaptureSetupMenuContainers();
       
   891 
       
   892     SetCaptureSetupModeActive(ETrue);
       
   893     
       
   894     PRINT( _L("Camera <= CCamPreCaptureViewBase::SwitchToCaptureSetupModeL") );
       
   895     }
       
   896 
       
   897 // ---------------------------------------------------------------------------
       
   898 // CCamPreCaptureViewBase::SwitchToSceneSettingModeL
       
   899 // Switches the current mode to scene setting and activates a 
       
   900 // specific control.
       
   901 // ---------------------------------------------------------------------------
       
   902 //
       
   903 void CCamPreCaptureViewBase::SwitchToSceneSettingModeL()
       
   904     {
       
   905     // Remove the view's main container, and add the capture setup 
       
   906     // control associated with the input command to the container stack.
       
   907     CCamCaptureSetupViewBase::SwitchToSceneSettingModeL();
       
   908  
       
   909     // only remove the capture setup menu container after 
       
   910     // the switch completes successfully
       
   911     RemoveCaptureSetupMenuContainers();
       
   912     }
       
   913 
       
   914 // ---------------------------------------------------------------------------
       
   915 // CCamPreCaptureViewBase::ExitCaptureSetupModeL
       
   916 // Exits capture setup mode and activates the capture setup menu control.
       
   917 // ---------------------------------------------------------------------------
       
   918 //
       
   919 void CCamPreCaptureViewBase::ExitCaptureSetupModeL()
       
   920     {
       
   921     PRINT( _L("Camera => CCamPreCaptureViewBase::ExitCaptureSetupModeL") )
       
   922      
       
   923     CCamCaptureSetupViewBase::ExitCaptureSetupModeL();    
       
   924     iController.SetViewfinderWindowHandle( &iContainer->Window() );
       
   925 
       
   926     
       
   927     if( !iController.IsViewFinding() && !iController.InVideocallOrRinging() )
       
   928       {
       
   929       TCamCameraMode mode = iController.CurrentMode();    
       
   930 	  PRINT1( _L("Camera => CCamPreCaptureViewBase::ExitCaptureSetupModeL - CurrentMode %d"), mode );        
       
   931       if (mode == ECamControllerVideo )
       
   932     	{
       
   933    	    PRINT( _L("Camera => CCamPreCaptureViewBase::ExitCaptureSetupModeL - ECamControllerVideo") );        
       
   934     	iController.EnterViewfinderMode( ECamControllerVideo );
       
   935     	}    	
       
   936       else
       
   937     	{
       
   938    	    PRINT( _L("Camera => CCamPreCaptureViewBase::ExitCaptureSetupModeL - ECamControllerImage") );        
       
   939       iController.EnterViewfinderMode( ECamControllerImage );
       
   940     	}    	               
       
   941       }
       
   942     
       
   943     // make sure app is not left in an invalid state if a leave
       
   944     // occurs after exiting the capture setup
       
   945     iCaptureSetupMenuModeActive = EFalse;
       
   946     static_cast<CCamAppUiBase*>( AppUi() )->PushNaviPaneCounterL();
       
   947 	CCamAppUiBase* appUi =  static_cast<CCamAppUiBase*>( AppUi() );
       
   948 	if( appUi->ActiveCamera() == ECamActiveCameraSecondary )
       
   949 		{
       
   950 		PRINT( _L("Camera => CCamPreCaptureViewBase::ExitCaptureSetupModeL ###") )
       
   951     	SwitchToCaptureSetupMenuModeL();
       
   952 		}
       
   953 	
       
   954 	UpdateCbaL();
       
   955     PRINT( _L("Camera <= CCamPreCaptureViewBase::ExitCaptureSetupModeL") )
       
   956     }
       
   957 
       
   958 // ---------------------------------------------------------------------------
       
   959 // CCamPreCaptureViewBase::ExitSceneSettingModeL
       
   960 // Exits scene setting mode and activates the capture setup menu control.
       
   961 // ---------------------------------------------------------------------------
       
   962 //
       
   963 void CCamPreCaptureViewBase::ExitSceneSettingModeL()
       
   964     {
       
   965     CCamCaptureSetupViewBase::ExitSceneSettingModeL();
       
   966     // make sure app is not left in an invalid state if a leave
       
   967     // occurs after exiting the scene setting mode
       
   968     iCaptureSetupMenuModeActive = EFalse;
       
   969     static_cast<CCamAppUiBase*>( AppUi() )->PushNaviPaneCounterL();
       
   970 
       
   971 	CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( AppUi() );
       
   972     if ( appUi->ActiveCamera() == ECamActiveCameraPrimary )
       
   973         {
       
   974         if ( iDeactivateToStandby || iController.InVideocallOrRinging() )
       
   975             {
       
   976             // don't restart VF if we are going to standby mode
       
   977             }
       
   978         else
       
   979             {
       
   980             StartViewFinder();
       
   981             }
       
   982         }
       
   983     else
       
   984 		{
       
   985 		SwitchToCaptureSetupMenuModeL();
       
   986 		}
       
   987     }
       
   988 
       
   989 // ---------------------------------------------------------------------------
       
   990 // CCamPreCaptureViewBase::ExitInfoListBoxL
       
   991 // Exits InfoListBox
       
   992 // ---------------------------------------------------------------------------
       
   993 //
       
   994 void CCamPreCaptureViewBase::ExitInfoListBoxL()
       
   995     {
       
   996     CCamCaptureSetupViewBase::ExitInfoListBoxL();
       
   997     // make sure app is not left in an invalid state if a leave
       
   998     // occurs after exiting the scene setting mode
       
   999     iCaptureSetupMenuModeActive = EFalse;
       
  1000     static_cast<CCamAppUiBase*>( AppUi() )->PushNaviPaneCounterL();
       
  1001 
       
  1002 	CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( AppUi() );
       
  1003     if ( appUi->ActiveCamera() == ECamActiveCameraPrimary )
       
  1004         {
       
  1005         StartViewFinder();
       
  1006         }
       
  1007     else
       
  1008 		{
       
  1009 		SwitchToCaptureSetupMenuModeL();
       
  1010 		}
       
  1011     }
       
  1012 
       
  1013 
       
  1014 // -----------------------------------------------------------------------------
       
  1015 // CCamPreCaptureViewBase::ExitAllModesL
       
  1016 // Revert to normal mode
       
  1017 // -----------------------------------------------------------------------------
       
  1018 //
       
  1019 void 
       
  1020 CCamPreCaptureViewBase::ExitAllModesL()
       
  1021   {
       
  1022   PRINT( _L("Camera => CCamPreCaptureViewBase::ExitAllModesL" ) );
       
  1023   iController.DeepSleepTimerCancel();
       
  1024   TCamSettingMode currentMode = ActiveSettingMode();
       
  1025   
       
  1026   CCamAppUi* appUi =  static_cast<CCamAppUi*>( AppUi() );
       
  1027   
       
  1028   switch ( currentMode )
       
  1029     {
       
  1030     case ECamSettingModeCaptureMenu:
       
  1031       {
       
  1032       PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitAllModesL cap setup menu" ))
       
  1033       ExitCaptureSetupMenuModeL();
       
  1034       break;
       
  1035       }
       
  1036     case ECamSettingModeCapture:
       
  1037       {
       
  1038       PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitAllModesL capture" ))
       
  1039       
       
  1040       ExitCaptureSetupModeL();
       
  1041       if( appUi->ActiveCamera() == ECamActiveCameraSecondary  )
       
  1042         {
       
  1043         PRINT( _L("Camera <> CamPreCaptureViewBase::ExitAllModesL ##" )) 
       
  1044         ExitCaptureSetupMenuModeL();
       
  1045         }
       
  1046       break;
       
  1047       }
       
  1048     case ECamSettingModeScene:
       
  1049       {
       
  1050       PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitAllModesL scene" ))
       
  1051 	  ExitSceneSettingModeL();
       
  1052       if( appUi->ActiveCamera() == ECamActiveCameraSecondary  )
       
  1053         {
       
  1054         PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitAllModesL ##" )) 
       
  1055         ExitCaptureSetupMenuModeL();
       
  1056         }
       
  1057 	  if( Id() == TUid::Uid( ECamViewIdVideoPreCapture ) &&
       
  1058           iController.UiConfigManagerPtr() &&
       
  1059           iController.UiConfigManagerPtr()->IsXenonFlashSupported() )
       
  1060 		{
       
  1061 		iToolbarExtensionInvisible = ETrue;
       
  1062 		}
       
  1063       break;
       
  1064       }
       
  1065     case ECamSettingModeInfoListBox:
       
  1066       {
       
  1067       PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitAllModesL generic" ))
       
  1068       ExitInfoListBoxL();
       
  1069       if( appUi->ActiveCamera() == ECamActiveCameraSecondary  )
       
  1070         {
       
  1071         PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitAllModesL ##" )) 
       
  1072         ExitCaptureSetupMenuModeL();
       
  1073         }            
       
  1074       break;
       
  1075       }            
       
  1076     default:
       
  1077       {
       
  1078       iToolbarExtensionInvisible = ETrue;    	
       
  1079       }
       
  1080       break;
       
  1081     }
       
  1082 
       
  1083   if ( iController.InVideocallOrRinging() || !iController.IssueModeChangeSequenceSucceeded() )
       
  1084       {
       
  1085       return;
       
  1086       }	
       
  1087   
       
  1088   appUi->HandleCommandL(ECamCmdSwitchToPrecapture);
       
  1089   
       
  1090 
       
  1091   if ( !( iController.UiConfigManagerPtr() && 
       
  1092             iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() ) )
       
  1093     {
       
  1094     TCamOrientation orientation = appUi->CamOrientation();
       
  1095     if ( orientation == ECamOrientationCamcorder || orientation == ECamOrientationCamcorderLeft )
       
  1096       {
       
  1097       // force update of active palette
       
  1098       appUi->APHandler()->UpdateActivePaletteL();                    
       
  1099       }
       
  1100 
       
  1101     if ( appUi && !iSceneSettingModeActive )
       
  1102       {
       
  1103       appUi->RaisePreCaptureCourtesyUI(ETrue);
       
  1104       }
       
  1105     }
       
  1106     
       
  1107   if ( iController.IsTouchScreenSupported() )
       
  1108       {
       
  1109       CAknToolbar* fixedToolbar = Toolbar();
       
  1110       CAknToolbarExtension* extension = fixedToolbar->ToolbarExtension();
       
  1111       
       
  1112       // Only active view will set toolbar extension visibility.
       
  1113       if( this->IsForeground() )
       
  1114           {
       
  1115           if ( extension && iToolbarExtensionInvisible == EFalse )
       
  1116               {
       
  1117               extension->SetShown( ETrue );
       
  1118               }
       
  1119           else if( extension )
       
  1120               {
       
  1121               extension->SetShown( EFalse );
       
  1122               }
       
  1123           }
       
  1124 
       
  1125       iToolbarExtensionInvisible = EFalse;
       
  1126       }
       
  1127     
       
  1128   PRINT( _L("Camera <= CCamPreCaptureViewBase::ExitAllModesL" ) );
       
  1129   }
       
  1130 
       
  1131 
       
  1132 // ---------------------------------------------------------------------------
       
  1133 // CCamPreCaptureViewBase::ActiveSettingMode
       
  1134 // Returns the active setting mode
       
  1135 // ---------------------------------------------------------------------------
       
  1136 //
       
  1137 CCamPreCaptureViewBase::TCamSettingMode 
       
  1138 CCamPreCaptureViewBase::ActiveSettingMode()
       
  1139     {
       
  1140     if ( iCaptureSetupModeActive )
       
  1141         {
       
  1142         return ECamSettingModeCapture;
       
  1143         }
       
  1144     else if ( iSceneSettingModeActive )
       
  1145         {
       
  1146         return ECamSettingModeScene;
       
  1147         }
       
  1148     else if ( iCaptureSetupMenuModeActive )
       
  1149         {
       
  1150         return ECamSettingModeCaptureMenu;
       
  1151         }
       
  1152     else if ( iInfoListBoxActive )
       
  1153       {
       
  1154       return ECamSettingModeInfoListBox;
       
  1155         }
       
  1156     else
       
  1157         {
       
  1158         return ECamSettingModeNone;
       
  1159         }
       
  1160     }
       
  1161 
       
  1162 // ---------------------------------------------------------------------------
       
  1163 // CCamPreCaptureViewBase::CCamPreCaptureViewBase
       
  1164 // C++ constructor
       
  1165 // ---------------------------------------------------------------------------
       
  1166 //
       
  1167 CCamPreCaptureViewBase::CCamPreCaptureViewBase( CCamAppController& aController )
       
  1168     : CCamCaptureSetupViewBase( aController )   
       
  1169     {
       
  1170     iCaptureSetupMenuModeActive = EFalse;
       
  1171     iAssumePostCaptureView = EFalse;
       
  1172     }                          
       
  1173 
       
  1174 // ---------------------------------------------------------------------------
       
  1175 // CCamPreCaptureViewBase::ConstructL
       
  1176 // Symbian OS 2nd phase constructor
       
  1177 // ---------------------------------------------------------------------------
       
  1178 //
       
  1179 void CCamPreCaptureViewBase::ConstructL()
       
  1180     {
       
  1181     PRINT( _L("Camera => CCamPreCaptureViewBase::ConstructL") )    
       
  1182     /* Use AppUi to get this info.
       
  1183     // Get the id of Eikon Server window group
       
  1184     iEikonServerWindowGroupId =
       
  1185         iCoeEnv->WsSession().FindWindowGroupIdentifier( 0, KEikonServer );
       
  1186 
       
  1187     iBTServerWindowGroupId =  
       
  1188     		static_cast<CCamAppUi*>( iEikonEnv->AppUi() )->BTServerId();
       
  1189     */
       
  1190     UpdateToolbarIconsL();
       
  1191     PRINT( _L("Camera <= CCamPreCaptureViewBase::ConstructL") )    
       
  1192     }
       
  1193                           
       
  1194 // ---------------------------------------------------------------------------
       
  1195 // CCamPreCaptureViewBase::CleanupCaptureSetupMenu
       
  1196 // Cleanup the capture menu control if a leave occurs
       
  1197 // ---------------------------------------------------------------------------
       
  1198 //
       
  1199 void CCamPreCaptureViewBase::CleanupCaptureSetupMenu( TAny* aAny )
       
  1200     {
       
  1201     CCamPreCaptureViewBase* view = static_cast<CCamPreCaptureViewBase*>( aAny );
       
  1202     if ( view->iCaptureSetupMenuContainer )
       
  1203         {
       
  1204         view->AppUi()->RemoveFromStack( view->iCaptureSetupMenuContainer );
       
  1205         delete view->iCaptureSetupMenuContainer;
       
  1206         view->iCaptureSetupMenuContainer = NULL;
       
  1207         }
       
  1208     // reset the active mode
       
  1209     view->iCaptureSetupMenuModeActive = EFalse;
       
  1210     }
       
  1211 
       
  1212 // ---------------------------------------------------------------------------
       
  1213 // CCamPreCaptureViewBase::SwitchToCaptureSetupMenuModeL
       
  1214 // Switches the current mode to capture setup menu and activates 
       
  1215 // the capture setup menu control
       
  1216 // ---------------------------------------------------------------------------
       
  1217 //
       
  1218 void CCamPreCaptureViewBase::SwitchToCaptureSetupMenuModeL()
       
  1219     {
       
  1220     PRINT( _L("Camera => CCamPreCaptureViewBase::SwitchToCaptureSetupMenuModeL"))
       
  1221     __ASSERT_DEBUG( !iCaptureSetupMenuContainer, CamPanic( ECamPanicResourceLeak ) );
       
  1222 
       
  1223     // Create the relevant capture setup menu, e.g. video or photo...
       
  1224     CreateCaptureSetupMenuL();
       
  1225 
       
  1226     // Cleanup the view correctly if a leave occurs
       
  1227     CleanupStack::PushL( TCleanupItem( CleanupCaptureSetupMenu, this ) );
       
  1228     
       
  1229     PRINT( _L("Camera => CCamPreCaptureViewBase::SwitchToCaptureSetupMenuModeL start vf"))
       
  1230     StartViewFinder();
       
  1231     iCaptureSetupMenuContainer->SetMopParent( this );   
       
  1232     // Activate the menu control and mode.
       
  1233     AppUi()->AddToStackL( *this, iCaptureSetupMenuContainer );
       
  1234     iCaptureSetupMenuContainer->ActivateL();
       
  1235     // UpdateCbaL need this boolean to be set in
       
  1236     // order for the correct CBA to be returned
       
  1237     iCaptureSetupMenuModeActive = ETrue;
       
  1238     UpdateCbaL();
       
  1239     CleanupStack::Pop(); // CleanupCaptureSetupMenu
       
  1240 
       
  1241     // Fade the container that is behind.
       
  1242     iCaptureSetupMenuContainer->FadeBehind( ETrue );
       
  1243     }
       
  1244 
       
  1245 // ---------------------------------------------------------------------------
       
  1246 // CCamPreCaptureViewBase::ExitCaptureSetupMenuModeL
       
  1247 // Exits capture setup menu mode and activates the original precapture
       
  1248 // view container that was active before entering this mode.
       
  1249 // ---------------------------------------------------------------------------
       
  1250 //
       
  1251 void CCamPreCaptureViewBase::ExitCaptureSetupMenuModeL()
       
  1252     {
       
  1253     PRINT( _L("Camera => CCamPreCaptureViewBase::ExitCaptureSetupMenuModeL() ") );
       
  1254     
       
  1255     if ( !iCaptureSetupMenuModeActive )
       
  1256         {
       
  1257         return;
       
  1258         }
       
  1259     iCaptureSetupMenuModeActive = EFalse;
       
  1260     iContainer->MakeVisible( ETrue );  
       
  1261 
       
  1262     iCaptureSetupMenuContainer->FadeBehind( EFalse );
       
  1263     AppUi()->RemoveFromStack( iCaptureSetupMenuContainer );
       
  1264     delete iCaptureSetupMenuContainer;
       
  1265     iCaptureSetupMenuContainer = NULL;
       
  1266     UpdateCbaL();
       
  1267     SetTitlePaneTextL();
       
  1268     
       
  1269     PRINT( _L("Camera <= CCamPreCaptureViewBase::ExitCaptureSetupMenuModeL() ") );
       
  1270     }                         
       
  1271 
       
  1272 // ---------------------------------------------------------------------------
       
  1273 // CCamPreCaptureViewBase::SwitchToStandbyModeL
       
  1274 // Exits pre capture mode and activates the standby container
       
  1275 // ---------------------------------------------------------------------------
       
  1276 //
       
  1277 void CCamPreCaptureViewBase::SwitchToStandbyModeL( TCamAppViewIds aViewId, TInt aError )
       
  1278     {
       
  1279     iAssumePostCaptureView = EFalse;
       
  1280     iDeactivateToStandby = ETrue; // avoid viewfinder startup
       
  1281     iContinueInBackground = EFalse; 
       
  1282     
       
  1283     switch ( ActiveSettingMode() )
       
  1284         {
       
  1285         case ECamSettingModeCaptureMenu:   
       
  1286             {
       
  1287             ExitCaptureSetupMenuModeL();            
       
  1288             }
       
  1289             break;
       
  1290         case ECamSettingModeScene:
       
  1291             {
       
  1292             ExitSceneSettingModeL();
       
  1293             ExitCaptureSetupMenuModeL();
       
  1294             }
       
  1295             break;
       
  1296         case ECamSettingModeCapture:
       
  1297             {
       
  1298             ExitCaptureSetupModeL();
       
  1299             ExitCaptureSetupMenuModeL();
       
  1300             }
       
  1301             break;
       
  1302 			case ECamSettingModeInfoListBox:
       
  1303             {
       
  1304             ExitInfoListBoxL();
       
  1305             ExitCaptureSetupMenuModeL();
       
  1306             }				            
       
  1307             break;
       
  1308         default:  
       
  1309             break;
       
  1310         }    
       
  1311 
       
  1312 
       
  1313     // Hide the active palette
       
  1314     static_cast<CCamAppUi*>( iEikonEnv->AppUi() )
       
  1315         ->SetActivePaletteVisibility( EFalse );
       
  1316     
       
  1317     // Hide the toolbar in standby mode
       
  1318     if ( iController.IsTouchScreenSupported() )
       
  1319         {
       
  1320         CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
  1321         CAknToolbar* fixedToolbar = appUi->CurrentFixedToolbar();
       
  1322         if ( fixedToolbar )
       
  1323             {
       
  1324             fixedToolbar->SetToolbarVisibility( EFalse );
       
  1325             }
       
  1326         }
       
  1327 
       
  1328     // Hide the startup logo in standby mode. 
       
  1329     // Camera application will enter standby mode if it detect camera hardware is in use
       
  1330     // by another application (such as video call) when camera application is starting up. 
       
  1331     // If this, we need hiding startup logo in standby mode.
       
  1332     CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() ); 
       
  1333     if ( appUi->StartupLogoController() )
       
  1334       {
       
  1335       appUi->StartupLogoController()->HideLogo();
       
  1336       }
       
  1337       
       
  1338     // stop viewfinding
       
  1339     StopViewFinder();
       
  1340 
       
  1341     CCamViewBase::SwitchToStandbyModeL( aViewId, aError );
       
  1342     
       
  1343     iDeactivateToStandby = EFalse;
       
  1344     }
       
  1345 
       
  1346 // ---------------------------------------------------------------------------
       
  1347 // CCamPreCaptureViewBase::ExitStandbyModeL
       
  1348 // Exits standby mode and activates the previous pre-capture container
       
  1349 // ---------------------------------------------------------------------------
       
  1350 //
       
  1351 void CCamPreCaptureViewBase::ExitStandbyModeL()
       
  1352     {
       
  1353     PRINT( _L("Camera => CCamPreCaptureViewBase::ExitStandbyModeL" ) )
       
  1354     // start view finding
       
  1355     iAssumePostCaptureView = EFalse;
       
  1356     CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
  1357     if( appUi->AppInBackground(ETrue ))
       
  1358         {
       
  1359         PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitStandbyModeL: global note in foreground." ) )
       
  1360         return;
       
  1361         }
       
  1362     if( iController.UiConfigManagerPtr() && 
       
  1363         iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported() &&
       
  1364         iController.CurrentMode() != ECamControllerIdle )
       
  1365         {
       
  1366         PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitStandbyModeL: not in standby, returning without exit" ) )    
       
  1367         return;    
       
  1368         } 
       
  1369     
       
  1370     if( !appUi->DrawPreCaptureCourtesyUI() && 
       
  1371         !iController.IsTouchScreenSupported() &&
       
  1372         !appUi->IsSecondCameraEnabled() )
       
  1373         {
       
  1374         SetCourtesySoftKeysL();
       
  1375         }
       
  1376     
       
  1377     // In case coming back after dismissing videocall, need
       
  1378     // to register as using engine    
       
  1379     if( !appUi->IsInPretendExit() )
       
  1380         {
       
  1381         IncrementCameraUsers();
       
  1382         }
       
  1383         
       
  1384     PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitStandbyModeL: start vf" ) )
       
  1385     StartViewFinder();
       
  1386 
       
  1387     //static_cast<CCamAppUi*>( iEikonEnv->AppUi() )
       
  1388     //    ->APHandler()->UpdateActivePaletteL();
       
  1389     TBool uiOverride = iController.UiConfigManagerPtr() && iController.UiConfigManagerPtr()->IsUIOrientationOverrideSupported();
       
  1390     if ( !uiOverride )
       
  1391         {
       
  1392         SetupActivePaletteL();
       
  1393         }
       
  1394 
       
  1395     // Dimming is set if video call is active, remove dimming if video call is not active any more
       
  1396     TInt callType( EPSCTsyCallTypeUninitialized );
       
  1397     RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallType, callType );
       
  1398     if ( callType != EPSCTsyCallTypeH324Multimedia
       
  1399          && iController.IsTouchScreenSupported() )
       
  1400         {
       
  1401         CAknToolbar* toolbar = Toolbar();
       
  1402         if (toolbar)
       
  1403             {
       
  1404             toolbar->SetDimmed( EFalse );
       
  1405             }
       
  1406         }    
       
  1407     CCamViewBase::ExitStandbyModeL();
       
  1408     
       
  1409     // Need to update appui viewstate
       
  1410     PRINT( _L("Camera <> CCamPreCaptureViewBase::ExitStandbyModeL: emit ECamCmdSwitchToPrecapture" ) )
       
  1411     appUi->HandleCommandL( ECamCmdSwitchToPrecapture );
       
  1412     // Check if currently selected storagemedia has available memory for next capturing
       
  1413     appUi->CheckMemoryAvailableForCapturing();      
       
  1414         
       
  1415     if ( uiOverride )
       
  1416         {
       
  1417         appUi->SetActivePaletteVisibility( EFalse );    
       
  1418         }
       
  1419     else
       
  1420         {    
       
  1421         appUi->RaisePreCaptureCourtesyUI(ETrue);
       
  1422         }
       
  1423     PRINT( _L("Camera <= CCamPreCaptureViewBase::ExitStandbyModeL" ) )
       
  1424     }
       
  1425 
       
  1426 // ---------------------------------------------------------------------------
       
  1427 // CCamPreCaptureViewBase::IsOkOptionsMenuAllowed
       
  1428 // Checks whether or not the ok aoptions menu should be displayed
       
  1429 // ---------------------------------------------------------------------------
       
  1430 //
       
  1431 #if 0
       
  1432 TBool CCamPreCaptureViewBase::IsOkOptionsMenuAllowed()
       
  1433     {
       
  1434     CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( AppUi() );
       
  1435     // Check if we are in selftimer mode, scene setting mode,
       
  1436     // capture setup menu mode or if a capture mode preparation is
       
  1437     // taking place.  If so, do NOT show the menu
       
  1438     if ( ( appUi && !appUi->SelfTimerEnabled() ) &&
       
  1439         !iController.CaptureModeTransitionInProgress() &&
       
  1440             ActiveSettingMode() == ECamSettingModeNone && !appUi->IsEmbedded() )
       
  1441         {
       
  1442         return ETrue;
       
  1443         }
       
  1444     else
       
  1445         {
       
  1446         return EFalse;
       
  1447         }
       
  1448     }
       
  1449 #endif // 0
       
  1450 
       
  1451 // ---------------------------------------------------------------------------
       
  1452 // CCamPreCaptureViewBase::RemoveCaptureSetupMenuContainers
       
  1453 // Removes the capture setup menu and original container from
       
  1454 // the container stack
       
  1455 // ---------------------------------------------------------------------------
       
  1456 //
       
  1457 void CCamPreCaptureViewBase::RemoveCaptureSetupMenuContainers()
       
  1458     {
       
  1459     // Store the current item index value for the menu, so that it can
       
  1460     // be reused when the CSM container is reactivated from leaving
       
  1461     // a capture setup control.
       
  1462     if ( iCaptureSetupMenuContainer )
       
  1463         {
       
  1464         iCaptureSetupMenuLastItemIndex = 
       
  1465             iCaptureSetupMenuContainer->CurrentItemIndex();
       
  1466         iCaptureSetupMenuContainer->FadeBehind( EFalse );
       
  1467         
       
  1468         // Remove the Capture Setup Menu from the container stack.
       
  1469         AppUi()->RemoveFromStack( iCaptureSetupMenuContainer );
       
  1470         }
       
  1471     delete iCaptureSetupMenuContainer;
       
  1472     iCaptureSetupMenuContainer = NULL;
       
  1473     }
       
  1474 
       
  1475 // ---------------------------------------------------------------------------
       
  1476 // CCamPreCaptureViewBase::DynInitSwitchCameraMenuItemL
       
  1477 // Set up the text for switch camera in the options menu
       
  1478 // ---------------------------------------------------------------------------
       
  1479 //
       
  1480 void CCamPreCaptureViewBase::DynInitSwitchCameraMenuItemL( CEikMenuPane* aMenuPane )
       
  1481     {
       
  1482     CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
  1483     // Check if only 1 camera available
       
  1484     if ( !iController.UiConfigManagerPtr()->IsSecondaryCameraSupported() )
       
  1485         {
       
  1486         aMenuPane->SetItemDimmed( ECamCmdSwitchCamera, ETrue );
       
  1487         }
       
  1488     else 
       
  1489         {
       
  1490         // if secondary camera is enabled
       
  1491         if ( appUi->IsSecondCameraEnabled() )
       
  1492             {
       
  1493             if( iController.UiConfigManagerPtr()->IsLensCoverSupported() )
       
  1494                 {
       
  1495                 TInt slideState = iController.CameraSlideState();
       
  1496                 if ( slideState == CameraPlatPSKeys::EClosed )
       
  1497                     {
       
  1498                     aMenuPane->SetItemDimmed( ECamCmdSwitchCamera, ETrue );
       
  1499                     }
       
  1500                 else
       
  1501                     {                               
       
  1502                     aMenuPane->SetItemTextL( ECamCmdSwitchCamera, 
       
  1503                             R_CAM_PRE_CAPTURE_MENU_PRIMARY_CAMERA );
       
  1504                     }   
       
  1505                 }
       
  1506             else
       
  1507                 {
       
  1508                 aMenuPane->SetItemTextL( ECamCmdSwitchCamera, 
       
  1509                         R_CAM_PRE_CAPTURE_MENU_PRIMARY_CAMERA );
       
  1510                 }
       
  1511             }
       
  1512         }
       
  1513     }
       
  1514 
       
  1515 
       
  1516 // ---------------------------------------------------------------------------
       
  1517 // CCamPreCaptureViewBase::ReleaseResources
       
  1518 // Stop the viewfinder and inform the controller that this view has finished
       
  1519 // with the engine
       
  1520 // ---------------------------------------------------------------------------
       
  1521 //
       
  1522 void CCamPreCaptureViewBase::ReleaseResources()
       
  1523     {
       
  1524     PRINT( _L("Camera => CCamPreCaptureViewBase::ReleaseResources") );
       
  1525     CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
  1526     if( iStandbyModeActive && !appUi->IsRecoverableStatus() )
       
  1527         {
       
  1528         PRINT( _L("Camera <= CCamPreCaptureViewBase::ReleaseResources Standbymode") );
       
  1529         return;
       
  1530         }
       
  1531     iContinueInBackground = EFalse;
       
  1532     StopViewFinder();
       
  1533   
       
  1534     // Make sure that video recording is stopped (if ongoing).
       
  1535     iController.StopVideoRecording();
       
  1536     
       
  1537     // if the application is not closing then self-timer mode must be disabled.
       
  1538     // otherwise it will be deleted as part of the application shut down process
       
  1539     if ( !iController.IsInShutdownMode() )
       
  1540         {
       
  1541         // Do not do softkey update if we are already exiting
       
  1542         // (AppUi is not available)
       
  1543         if( iController.IsAppUiAvailable() )
       
  1544             {
       
  1545             // Ensure AppUi has had self-timer mode disabled
       
  1546             if ( appUi )
       
  1547                 {
       
  1548                 TRAP_IGNORE( appUi->SelfTimerEnableL( ECamSelfTimerDisabled ) );
       
  1549                 }
       
  1550             }
       
  1551         }
       
  1552     // Register that we no longer need the engine
       
  1553     // Checks if we incremented the count.
       
  1554     DecrementCameraUsers();
       
  1555     PRINT( _L("Camera <= CCamPreCaptureViewBase::ReleaseResources") );
       
  1556     }
       
  1557   
       
  1558 // ---------------------------------------------------------------------------
       
  1559 // CCamPreCaptureViewBase::IsPreCapture
       
  1560 // Returns whether the view is a precapture view
       
  1561 // ---------------------------------------------------------------------------
       
  1562 //
       
  1563 TBool CCamPreCaptureViewBase::IsPreCapture()
       
  1564     {
       
  1565     return ETrue;
       
  1566     }
       
  1567 
       
  1568 // ---------------------------------------------------------------------------
       
  1569 // CCamPreCaptureViewBase::OfferToolbarEventL
       
  1570 // Handle fixed toolbar and toolbar extension events
       
  1571 // ---------------------------------------------------------------------------
       
  1572 //
       
  1573 void CCamPreCaptureViewBase::OfferToolbarEventL( TInt aCommand )
       
  1574     {
       
  1575     iController.StartIdleTimer();
       
  1576     HandleCommandAoL( aCommand );
       
  1577     
       
  1578     if ( aCommand == ECamCmdSceneSettingList ||
       
  1579          aCommand == ECamCmdCaptureSetupFlashStill ||
       
  1580          aCommand == ECamCmdCaptureSetupSelfTimer ||
       
  1581          aCommand == ECamCmdCaptureSetupSceneStill ||
       
  1582          aCommand == ECamCmdCaptureSetupSceneVideo ||
       
  1583          aCommand == ECamCmdCaptureSetupColourFilterStill ||
       
  1584          aCommand == ECamCmdCaptureSetupColourFilterVideo ||
       
  1585          aCommand == ECamCmdCaptureSetupWhiteBalanceStill ||
       
  1586          aCommand == ECamCmdCaptureSetupWhiteBalanceVideo ||
       
  1587          aCommand == ECamCmdCaptureSetupExposureStill ||
       
  1588          aCommand == ECamCmdCaptureSetupLightSensitivityStill ||
       
  1589          aCommand == ECamCmdCaptureSetupContrastStill ||
       
  1590          aCommand == ECamCmdCaptureSetupImageSharpnessStill )
       
  1591         {
       
  1592         // These commands imply a container switch.
       
  1593         // iItemAccessedViaAP must be set so that softkeys work correctly.
       
  1594         CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( AppUi() );
       
  1595         appUi->APHandler()->iItemAccessedViaAP = ETrue;
       
  1596         iController.DeepSleepTimerStart();
       
  1597         }
       
  1598     }
       
  1599 
       
  1600 
       
  1601 // ---------------------------------------------------------------------------
       
  1602 // CCamPreCaptureViewBase::SetIconL
       
  1603 // ---------------------------------------------------------------------------
       
  1604 //
       
  1605 void CCamPreCaptureViewBase::SetIconL(
       
  1606         CAknButton* aButton,
       
  1607         const TDesC& aIconFilename,
       
  1608         TInt aIconId,
       
  1609         TInt aMaskId,
       
  1610         MAknsSkinInstance* aSkinInstance, 
       
  1611         const TAknsItemID& aSkinItemId )
       
  1612     {
       
  1613     CGulIcon* icon = AknsUtils::CreateGulIconL(
       
  1614         aSkinInstance,
       
  1615         aSkinItemId,
       
  1616         aIconFilename,
       
  1617         aIconId,
       
  1618         aMaskId );
       
  1619     icon->SetBitmapsOwnedExternally( EFalse ); // CGulIcon owns bitmaps
       
  1620     CAknButtonState* state = aButton->State( 0 );
       
  1621     if ( state )
       
  1622         {
       
  1623         state->SetIcon( icon );
       
  1624         icon = NULL;
       
  1625         }
       
  1626     else
       
  1627         {
       
  1628         delete icon;
       
  1629         icon = NULL;
       
  1630         }
       
  1631 	
       
  1632     }
       
  1633 
       
  1634 // ---------------------------------------------------------------------------
       
  1635 // CCamPreCaptureViewBase::HandleAppEvent <<virtual>>
       
  1636 //
       
  1637 // ---------------------------------------------------------------------------
       
  1638 //
       
  1639 void 
       
  1640 CCamPreCaptureViewBase::HandleAppEvent( const TCamAppEvent& aEvent )
       
  1641     {
       
  1642     PRINT1( _L("Camera => CCamPreCaptureViewBase::HandleAppEvent, event:%d"), aEvent );
       
  1643     // Reset last pinch movement direction
       
  1644     iLastMovement = 0;
       
  1645     CCamViewBase::HandleAppEvent( aEvent );
       
  1646 
       
  1647     if ( aEvent == ECamAppEventFocusGained && iController.InVideocallOrRinging() )
       
  1648         {
       
  1649         TRAP_IGNORE( BlankSoftkeysL() );
       
  1650         if ( iController.IsTouchScreenSupported() )
       
  1651             {
       
  1652             CAknToolbar* toolbar = Toolbar();
       
  1653             if ( toolbar )
       
  1654                 {
       
  1655                 toolbar->SetToolbarVisibility( EFalse );
       
  1656                 }
       
  1657             }
       
  1658         }
       
  1659     
       
  1660     if ( aEvent == ECamAppEventFocusGained )
       
  1661         {
       
  1662         if ( iController.UiConfigManagerPtr()->IsLensCoverSupported() && 
       
  1663              iController.CameraSwitchQueued() ) // fake exit done
       
  1664             {
       
  1665             iController.CheckSlideStatus(); // Do we still need to change cam?
       
  1666             CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
  1667             // How about portrait/landscape 2nd camera? 
       
  1668             if ( !iController.CameraSwitchQueued() && 
       
  1669                  appUi->IsSecondCameraEnabled() ) 
       
  1670                 {
       
  1671                 TBool landscape2ndCam = appUi->IsQwerty2ndCamera( ETrue );
       
  1672                 if( appUi->CamOrientation() != ECamOrientationPortrait )
       
  1673                     {
       
  1674                     if ( !landscape2ndCam )
       
  1675                         {
       
  1676                         PRINT( _L("Camera => CCamPreCaptureViewBase::HandleAppEvent, change to portrait 2nd cam."));
       
  1677                         iController.SetCameraSwitchRequired( 
       
  1678                                                  ESwitchSecondaryOrientation );  
       
  1679                         }
       
  1680                     }
       
  1681                 else
       
  1682                     {
       
  1683                     if ( landscape2ndCam )
       
  1684                         {
       
  1685                         PRINT( _L("Camera => CCamPreCaptureViewBase::HandleAppEvent, change to landscape 2nd cam."));
       
  1686                         iController.SetCameraSwitchRequired( 
       
  1687                                                  ESwitchSecondaryOrientation );
       
  1688                         }
       
  1689                     }
       
  1690                 }
       
  1691             }
       
  1692         if ( iController.UiConfigManagerPtr()->IsLensCoverSupported() && 
       
  1693              iController.ActiveCamera() == ECamActiveCameraPrimary )
       
  1694             {
       
  1695             if ( iController.CameraSwitchQueued() )
       
  1696                 {
       
  1697                 CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
  1698                 // If camera switch fails, main camera is used instead
       
  1699                 TRAP_IGNORE( appUi->HandleCommandL( ECamCmdSwitchCamera ) );
       
  1700                 }
       
  1701             }
       
  1702         }
       
  1703      
       
  1704     PRINT( _L("Camera <= CCamPreCaptureViewBase::HandleAppEvent") );
       
  1705     }
       
  1706 
       
  1707 // ---------------------------------------------------------------------------
       
  1708 // SetupActivePaletteL
       
  1709 // 
       
  1710 // Helper method to set up the Active Palette.
       
  1711 // If needed, a new instance of AP is created.
       
  1712 // Otherwise the existing AP items are cleared.
       
  1713 // New AP items are setup with resource from GetAPResourceId.
       
  1714 // ---------------------------------------------------------------------------
       
  1715 //
       
  1716 void CCamPreCaptureViewBase::SetupActivePaletteL()
       
  1717     {
       
  1718     if( iContainer && !iController.IsTouchScreenSupported() )
       
  1719         {
       
  1720         CCamAppUi* appUi = static_cast<CCamAppUi*>( AppUi() );
       
  1721         TCamOrientation orientation = appUi->CamOrientation();
       
  1722 
       
  1723         if( ECamOrientationCamcorder == orientation
       
  1724                 || ECamOrientationCamcorderLeft == orientation 
       
  1725                 || ECamOrientationPortrait == orientation )
       
  1726             {
       
  1727             // Creates Active Palette, sets items and sets view.
       
  1728             // Only AP2 supported.
       
  1729             static_cast<CCamPreCaptureContainerBase*>( iContainer )
       
  1730             ->SetupActivePaletteL( this );
       
  1731             }
       
  1732         else
       
  1733             {
       
  1734             // No AP  
       
  1735             }
       
  1736         }
       
  1737     }
       
  1738 
       
  1739 // ---------------------------------------------------------------------------
       
  1740 // CCamPreCaptureViewBase::ToolbarButtonById
       
  1741 //
       
  1742 // ---------------------------------------------------------------------------
       
  1743 //
       
  1744  CAknButton* CCamPreCaptureViewBase::ToolbarButtonById(const TCamCmd aCommandId) const
       
  1745      {
       
  1746      CAknButton* button = NULL;
       
  1747      if(iController.IsTouchScreenSupported())
       
  1748          {
       
  1749          CAknToolbar* toolbar = Toolbar();
       
  1750          if(toolbar)
       
  1751              {
       
  1752              button = static_cast<CAknButton*>
       
  1753                          (toolbar->ControlOrNull(aCommandId));
       
  1754 			 if(NULL == button)
       
  1755                  {
       
  1756                  CAknToolbarExtension* extension = toolbar->ToolbarExtension();
       
  1757                  if(extension)
       
  1758                      {
       
  1759                      button = static_cast<CAknButton*>
       
  1760                                  (extension->ControlOrNull(aCommandId));
       
  1761 					 }
       
  1762                  }
       
  1763              }
       
  1764          }
       
  1765      return button;
       
  1766      }
       
  1767      
       
  1768 // ---------------------------------------------------------------------------
       
  1769 // CCamPreCaptureViewBase::HideButton
       
  1770 //
       
  1771 // ---------------------------------------------------------------------------
       
  1772 //
       
  1773  void CCamPreCaptureViewBase::HideButton(const TCamCmd aCommandId)
       
  1774      {
       
  1775      if(iController.IsTouchScreenSupported())
       
  1776           {
       
  1777           CAknToolbar* toolbar = Toolbar();
       
  1778           if(toolbar)
       
  1779               {
       
  1780               if(toolbar->ControlOrNull(aCommandId))            
       
  1781                   {
       
  1782                   toolbar->HideItem(aCommandId,ETrue,ETrue);
       
  1783                   }
       
  1784               else if( toolbar->ToolbarExtension() && 
       
  1785 				toolbar->ToolbarExtension()->ControlOrNull(aCommandId))
       
  1786                   {
       
  1787                   TRAP_IGNORE(toolbar->ToolbarExtension()->HideItemL(aCommandId,ETrue));
       
  1788                   }
       
  1789 			  else
       
  1790 				 {
       
  1791 				 //Do Nothing
       
  1792 				 }
       
  1793               }
       
  1794           }
       
  1795      }
       
  1796 	 
       
  1797 // ---------------------------------------------------------------------------
       
  1798 // CCamPreCaptureViewBase::RedrawToolBar
       
  1799 //
       
  1800 // ---------------------------------------------------------------------------
       
  1801 //
       
  1802 void CCamPreCaptureViewBase::RedrawToolBar()
       
  1803 	{
       
  1804 	CEikonEnv::Static()->WsSession().ClearAllRedrawStores();
       
  1805 	}
       
  1806 
       
  1807 // ---------------------------------------------------------------------------
       
  1808 // CCamPreCaptureViewBase::CreateContainerL
       
  1809 //
       
  1810 // ---------------------------------------------------------------------------
       
  1811 //
       
  1812 void CCamPreCaptureViewBase::CreateContainerL()
       
  1813     {
       
  1814     PRINT( _L("Camera => CCamPreCaptureViewBase::CreateContainerL") );
       
  1815 
       
  1816     // Create gesture fw object, set observer and gesture interest
       
  1817     if ( iGestureFw ) 
       
  1818         {
       
  1819         delete iGestureFw;
       
  1820         iGestureFw = NULL;
       
  1821         }
       
  1822 
       
  1823     iGestureFw = CAknTouchGestureFw::NewL( *this, *iContainer );
       
  1824     iGestureFw->SetGestureInterestL( EAknTouchGestureFwGroupPinch | EAknTouchGestureFwGroupTap );
       
  1825 
       
  1826     PRINT( _L("Camera <= CCamPreCaptureViewBase::CreateContainerL") );            
       
  1827     }
       
  1828 
       
  1829 // ---------------------------------------------------------------------------
       
  1830 // CCamPreCaptureViewBase::HandleTouchGestureL
       
  1831 //
       
  1832 // ---------------------------------------------------------------------------
       
  1833 //
       
  1834 void CCamPreCaptureViewBase::HandleTouchGestureL( MAknTouchGestureFwEvent& aEvent )
       
  1835     {
       
  1836     PRINT( _L("Camera => CCamPreCaptureViewBase::HandleTouchGestureL") );
       
  1837     
       
  1838     // Skipped modes here
       
  1839     if ( iController.ActiveCamera() == ECamActiveCameraSecondary )
       
  1840         {
       
  1841         PRINT( _L("Camera <= CCamPreCaptureViewBase::HandleTouchGestureL - skipped") );
       
  1842         return;
       
  1843         }
       
  1844 
       
  1845     MAknTouchGestureFwPinchEvent *pinch = AknTouchGestureFwEventPinch( aEvent );
       
  1846     CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
  1847     if ( pinch && (ECamNoOperation == iController.CurrentOperation()) && appUi 
       
  1848                && !appUi->ZoomPane()->IsCurrentlyZooming() )
       
  1849         {
       
  1850         // Determine the direction of pinch: +ve -> pinch outward / zoom / widen VF
       
  1851         TInt currMove = pinch->Movement();
       
  1852         TBool wide = (currMove > 0) ? ETrue : EFalse;  
       
  1853         PRINT1( _L("Camera <> CCamPreCaptureViewBase::HandleTouchGestureL - pinch, movement:%d"), currMove );
       
  1854 
       
  1855         if ( ( iLastMovement >= 0 && currMove < 0 ) || 
       
  1856              ( iLastMovement <= 0 && currMove > 0 ) )
       
  1857             {
       
  1858             // Enable the blinking for resolution indicators and toggle image/video quality
       
  1859             // level between top widescreen and vga levels
       
  1860             CCamPreCaptureContainerBase* container = static_cast<CCamPreCaptureContainerBase*>( iContainer );
       
  1861             container->BlinkResolutionIndicatorOnChange( ETrue );
       
  1862 
       
  1863             // Hide the zoom pane in case of pinch
       
  1864            // CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
  1865            // appUi->ZoomPane()->MakeVisible( EFalse, ETrue );
       
  1866 
       
  1867             if ( iController.ToggleWideScreenQuality( wide ) )
       
  1868                 {
       
  1869                 iLastMovement = currMove;
       
  1870                 }
       
  1871             else
       
  1872                 {
       
  1873                 // if the quality level wasn't changed, then disable the blinking
       
  1874                 container->BlinkResolutionIndicatorOnChange( EFalse );
       
  1875                 }
       
  1876             }
       
  1877         }
       
  1878     else if ( EAknTouchGestureFwDoubleTap == aEvent.Type() 
       
  1879               && ( ECamNoOperation == iController.CurrentOperation() 
       
  1880                    || ( ( ECamCapturing   == iController.CurrentOperation() 
       
  1881                             || ECamPaused   == iController.CurrentOperation() )
       
  1882                         && iController.CurrentMode() == ECamControllerVideo ) ) )
       
  1883         {
       
  1884         PRINT( _L("Camera <> double tap event") );
       
  1885         CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() );
       
  1886         CCamZoomPane *zoomPane = appUi->ZoomPane();
       
  1887         
       
  1888         CCamPreCaptureContainerBase* container = static_cast<CCamPreCaptureContainerBase*>( iContainer );
       
  1889         if ( container && zoomPane )
       
  1890             {
       
  1891             container->ShowZoomPaneWithTimer();
       
  1892 
       
  1893             // Zoom to min (if not already at min) zoom level, otherwise zoom in to max level
       
  1894             if ( !zoomPane->IsZoomAtMinimum() )
       
  1895                 {
       
  1896                 PRINT( _L("Camera <> Zooming out to min level") );
       
  1897                 zoomPane->ZoomToMinimum();
       
  1898                 }
       
  1899             else
       
  1900                 {
       
  1901                 PRINT( _L("Camera <> Zooming to max level") );
       
  1902                 zoomPane->ZoomToMaximum();
       
  1903                 }
       
  1904             }
       
  1905         }
       
  1906     else
       
  1907         {
       
  1908         PRINT1( _L("Camera <> HandleTouchGestureL - gesture not used, type:%d"), aEvent.Type() );
       
  1909         }
       
  1910 
       
  1911     PRINT( _L("Camera <= CCamPreCaptureViewBase::HandleTouchGestureL") );
       
  1912     }
       
  1913 
       
  1914 // ---------------------------------------------------------------------------
       
  1915 // CCamPreCaptureViewBase::IsCaptureSetupMenuModeActive
       
  1916 //
       
  1917 // ---------------------------------------------------------------------------
       
  1918 //
       
  1919 TBool CCamPreCaptureViewBase::IsSetupModeActive()
       
  1920     {
       
  1921     TBool trueValue = ETrue;
       
  1922     TBool ret = ( iCaptureSetupModeActive == trueValue ||
       
  1923              iCaptureSetupMenuModeActive == trueValue || 
       
  1924              iSceneSettingModeActive == trueValue ||
       
  1925              iInfoListBoxActive == trueValue
       
  1926              );
       
  1927     PRINT1( _L("Camera <> CCamPreCaptureViewBase::IsSetupModeActive %d"), ret );
       
  1928     return ret;
       
  1929     }
       
  1930 //  End of File  
       
  1931